You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
<?php
|
|
require_once("../../contract/conn.php");
|
|
require_once("../maintance/maintenance_contract_bonus_v2_0.php");
|
|
if (!empty($_POST)) {
|
|
$contract_no = empty($_POST['contract_no']) ? '' : $_POST['contract_no'];
|
|
$bonuns_verson = empty($_POST['bonuns_verson']) ? '' : $_POST['bonuns_verson'];
|
|
$client_type = empty($_POST['client_type']) ? '' : $_POST['client_type'];
|
|
$maintain_month = empty($_POST['maintain_month']) ? '' : $_POST['maintain_month'];
|
|
$maintain_price_total = empty($_POST['maintain_price_total']) ? '' : $_POST['maintain_price_total'];
|
|
$payDay = empty($_POST['payDay']) ? '' : $_POST['payDay'];
|
|
$receiver = empty($_POST['receiver']) ? '' : $_POST['receiver'];
|
|
$manager = empty($_POST['manager']) ? '' : $_POST['manager'];
|
|
$a = "M001";
|
|
|
|
$fail_arr = [];
|
|
if ($client_type == '') $fail_arr[] = '合約類行為必填';
|
|
if (count($fail_arr) > 0) {
|
|
header("HTTP/1.1 422 Unprocessable Entity");
|
|
echo json_encode($fail_arr);
|
|
exit();
|
|
}
|
|
|
|
|
|
|
|
// 合約類型
|
|
$clientType = [
|
|
'1' => 'new',
|
|
'2' => 'free_to_charge',
|
|
'3' => 'renew_priceissue'
|
|
];
|
|
|
|
// 應付日期
|
|
$day = DateTime::createFromFormat('Ymd', $payDay);
|
|
$pay_day = $day->format('Y-m-d');
|
|
|
|
$years = $maintain_month / 12;
|
|
$contract_years = ($years >= 2) ? 'above_two' : 'one';
|
|
|
|
$result = maintenance_contract_bonus_v2_0(
|
|
$bonuns_verson,
|
|
$clientType[$client_type],
|
|
$contract_years,
|
|
0.8,
|
|
$maintain_price_total,
|
|
0,
|
|
$payDay,
|
|
$receiver,
|
|
$manager,
|
|
$a
|
|
);
|
|
header('Content-Type: application/json');
|
|
echo json_encode($result);
|
|
}
|
|
|