Files
old-wiaas-legacy/api-wiaas/server/components/v1/financing/FinancingController.php
2018-06-11 11:09:35 +02:00

77 lines
2.0 KiB
PHP

<?php
class FinancingController{
private $model;
function __construct(){
$this->model = new FinancingModel();
}
/**
* get interest rate
* @return json value for intereset rate
*/
public function getInterestRate(){
echo json_encode($this->model->getInterestRate(), JSON_NUMERIC_CHECK);
}
/**
* get interest rate for customers
* @return json values for interest rate for each customer
*/
public function getInterestRateForCustomers(){
echo json_encode($this->model->getInterestRateForCustomers(), JSON_NUMERIC_CHECK);
}
/**
* save interest rate
* @return json update message
*/
public function saveInterestRate(){
$interestRate = isset($_REQUEST['interestRate']) ? $_REQUEST['interestRate'] : 0;
echo json_encode($this->model->saveInterestRate($interestRate));
}
/**
* get customers and their discount
* @return json values for customers and dicounts
*/
public function getCustomersAndDiscount(){
echo json_encode($this->model->getCustomersAndDiscount());
}
/**
* save customers discount
* @return json update message
*/
public function saveCustomersDiscount() {
$discounts = isset($_REQUEST['discounts']) ? $_REQUEST['discounts'] : [];
echo json_encode($this->model->saveCustomersDiscount($discounts));
}
/**
* include financing template
*/
public function financingTemplate() {
require_once('templates/FinancingTempalte.php');
}
/**
* include set interest rate template
*/
public function setInterestRateTemplate() {
require_once('templates/SetInterestRateTemplate.php');
}
public function setCustomersDiscountTemplate() {
require_once('templates/SetCustomersDiscountTemplate.php');
}
/**
* open financing page
*/
public function showPage(){
require_once('FinancingPage.php');
}
}