Browse Source

Merge branch 'main' into gary

gary
IA2301\IA_2301 1 year ago
parent
commit
26b3716994
  1. 14
      wms/T8_Authorization_from_bpm.php
  2. BIN
      wms/account-receivable-contract.xlsx
  3. 24
      wms/account-receivable-excel.php
  4. 17
      wms/account-receivable-maintainance-index.php
  5. 257
      wms/account-receivable-new-index.php
  6. 7
      wms/account-receivable-test.php
  7. 2
      wms/account-receivable.txt
  8. 126
      wms/bonus/bonus_person.php
  9. 236
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php
  10. 68
      wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php
  11. 166
      wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php
  12. 17
      wms/bonus/maintainance_bonus.php
  13. 748
      wms/bonus/maintance/maintaenance_contract_bonus.php
  14. 96
      wms/bonus/maintance/maintenance_contract_bonus_v2_0.php
  15. 167
      wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php
  16. 4
      wms/bonus/other/maintenance_contract_bonus_v2_1.php
  17. 17
      wms/class/Cmail.php
  18. 38
      wms/class/T8API.php
  19. 38
      wms/cont/api/getElevatorPrice.php
  20. 15
      wms/cont/api/getUsername.php
  21. 484
      wms/cont/api/postElevatorPricereview.php
  22. 58
      wms/cont/api/postFlow.php
  23. 20
      wms/cont/api/postSystemNotice.php
  24. 113
      wms/cont/js/pricereviewAlpine.js
  25. 153
      wms/cont/pricereviewCreate.php
  26. 2
      wms/cont/window-modal/modalElevaotr.php
  27. 4
      wms/cont/window-modal/otherOptionModal.php
  28. 10
      wms/contract/api/T8api.php
  29. 22
      wms/contract/api/getContractData.php
  30. 48
      wms/contract/api/getT8NewContractData.php
  31. 373
      wms/contract/api/postContractData.php
  32. 150
      wms/contract/api/test copy.json
  33. 258
      wms/contract/api/testT8API.php
  34. 10
      wms/contract/api/testocde.php
  35. 4
      wms/contract/conn.php
  36. 199
      wms/contract/contract-input.php
  37. 52
      wms/contract/js/alpine.js
  38. 21
      wms/mkt/assets/js/pricereviewAlpine0311.js
  39. 23
      wms/mkt/pricereviewCheck.php
  40. 2
      wms/mkt/pricereviewCreate.php
  41. 56
      wms/schedule-edit.php
  42. 30
      wms/schedule-index.php
  43. 66
      wms/schedule-setting-repaire-update.php
  44. 192
      wms/schedule-setting-repaire.php
  45. 4
      wms/sign/list.php

14
wms/T8_Authorization_from_bpm.php

@ -1,7 +1,6 @@
<?php
function get_Auth($user_id = "M0000", $user_password = "M012290493119")
// echo $validation = get_Auth($user_id, $user_password);
// function get_Auth($user_id = "ADMIN", $user_password = "chi")
function get_Auth($user_id = "M0000", $user_password = "M012290493119")
@ -12,15 +11,15 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
// $now = gmdate("YmdHis");
$now = gmdate("YmdHis", strtotime("-2 minutes"));
$data = "$user_id." . $now;
// $sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false);
$sign = hash_hmac('SHA256', $data, '91EB2CB12C3F8211', false);
$sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false); ///測試區
// $sign = hash_hmac('SHA256', $data, '91EB2CB12C3F8211', false);
// echo $sign;
$apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
// $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
$apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; /// 測試區
// $apiurl = 'http://101.132.66.206:880/twWebAPI/GetAuth';
// $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth';
// $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; /// 正式區
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
//GroupId : TEST測試區 ; MASADA正式區
@ -29,7 +28,8 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
"Pwd: $user_password",
"TimestampUTC: $now",
"Sign: $sign",
"GroupId:MASADA"
"GroupId:TEST"
// "GroupId:MASADA"
];
$ch = curl_init();

BIN
wms/account-receivable-contract.xlsx

Binary file not shown.

24
wms/account-receivable-excel.php

@ -5,6 +5,10 @@ require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\Font;
header('Content-Type: application/json');
$type = $_GET['type'];
@ -14,8 +18,16 @@ $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
if ($type == 'newContract') {
$sheet->mergeCells('A1:X1');
$sheet->setTitle('新梯催收統整');
$sheet->setCellValue('A1', '新梯催收統整');
$sheet->getStyle('A1')->getFont()->setBold(true);
$sheet->getStyle('A1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$sheet->getStyle('A1')->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
$sheet->getStyle('A1')->getFont()->setSize(14);
$sheet->getRowDimension('1')->setRowHeight(38);
$colomnHeader = [
'合約號', '客戶名稱', '營業員', '合約金額', '台數', '作番狀態', '催收金額', '催收次數', '訂金催收金額', '訂金催收次數', '二次款催收金額', '二次款催收次數',
'合約號', '客戶名稱','部門','營業員', '合約金額', '台數', '作番狀態', '催收金額', '訂金催收金額', '訂金催收次數', '二次款催收金額', '二次款催收次數',
'貨抵工地款催收金額', '貨抵工地款催收次數',
'安裝款催收金額', '安裝款催收次數',
'試車款催收金額', '試車款催收次數',
@ -25,8 +37,8 @@ if ($type == 'newContract') {
];
file_put_contents('account-receivable.txt', json_encode($Bill, JSON_UNESCAPED_UNICODE));
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
$sheet->fromArray($colomnHeader, NULL, 'A2');
$rowIndex = 3;
foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex);
@ -34,9 +46,9 @@ if ($type == 'newContract') {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'
];
foreach ($column as $col) {
if ($col == 'F') {
$sheet->getColumnDimension('F')->setWidth(35);
$sheet->getStyle('F')->getAlignment()->setWrapText(true);
if ($col == 'G') {
$sheet->getColumnDimension('G')->setWidth(35);
$sheet->getStyle('G')->getAlignment()->setWrapText(true);
} else {
// $sheet->getColumnDimension($col)->setAutoSize(true);
$sheet->getColumnDimension($col)->setWidth(10);

17
wms/account-receivable-maintainance-index.php

@ -136,7 +136,6 @@ for ($i = 0; $i < count($rows); $i++) {
$tmpname = $row['ProjectId'] . $row['RowCode'];
$data[$tmpname] = $row;
$data[$tmpname]['CU_EstPayDate'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
$receivable_date = $data[$tmpname]['CU_EstPayDate'];
$data[$tmpname]['havetopay'] = strtotime($row['CU_EstPayDate']) > $today ? '--' : 'V';
$datahavetopay = strtotime($row['CU_EstPayDate']) > $today ? 0 : 1;
$data[$tmpname]['collecttime'] = collect_month(strtotime($row['CU_EstPayDate']));
@ -152,19 +151,19 @@ for ($i = 0; $i < count($rows); $i++) {
$facility_no = $row['CU_MaterialId'];
$RowCode = $row['RowCode'];
$BillNo = $row['BillNo'];
$data[$tmpname]['receivable_date'] = date('Y-m-d', strtotime($row['CU_EstPayDate']));
$budget = $row['OAmountWithTax'];
$data[$tmpname]['receivable_date'] = (is_null($row['CU_EstPayDate'])) ? null : date('Y-m-d', strtotime($row['CU_EstPayDate']));
$receivable_date = (is_null($data[$tmpname]['receivable_date'])) ? null : $data[$tmpname]['receivable_date'];
$budget = (is_null($row['OAmountWithTax'])) ? 0 : $row['OAmountWithTax'];
$invoiceNo = $row['InvoiceNo'];
$tableinvoice_state = is_null($invoiceNo) ? 0 : 1;
$data[$tmpname]['invoice_budget'] = is_null($row['InvoiceOAmount']) ? 0 : $row['InvoiceOAmount'];
$invoice_budget = $data[$tmpname]['invoice_budget'];
$invoice_budget = (is_null($data[$tmpname]['invoice_budget'])) ? 0 : $data[$tmpname]['invoice_budget'];
$table_writeoff = ($data[$tmpname]['WriteOff'] =='V') ? 1 : 0;
$table1 = "INSERT INTO account_receivable_maintainance(
`contract_no`,
`facility_no`,
`RowCode`,
`BillNo`,
`receivable_date`,
`budget`,
`receivable`,
`invoice_state`,
@ -176,24 +175,26 @@ for ($i = 0; $i < count($rows); $i++) {
'$facility_no',
'$RowCode',
'$BillNo',
'$receivable_date',
$budget,
$datahavetopay,
$tableinvoice_state,
$invoice_budget,
$table_writeoff
";
$table1 .= is_null($receivable_date) ? "" : ",`receivable_date`";
$table2 .= is_null($receivable_date) ? "" : ",'$receivable_date'";
$table1 .= is_null($invoicedate) ? "" : ",`invoice_date`";
$table2 .= is_null($invoicedate) ? "" : ",'$invoicedate'";
$table1 .= is_null($invoiceNo) ? "" : ",`invoice_no`";
$table2 .= is_null($invoiceNo) ? "" : ",'$invoiceNo'";
$table .= $table1 . $table2 . "); \n";
}
// $file_path = 'account_receivable_maintainance_sql.sql';
// if (file_put_contents($file_path, $table) !== false) {
// echo "SQL文件已成功生成:{$file_path}";
// } else {
// echo "生成SQL文件时出现错误。";
// }else{
// "fail";
// }
// foreach ($data as $key => $row) {

257
wms/account-receivable-new-index.php

@ -338,6 +338,10 @@ $sign0 = array('簽約', '簽訂', '合約簽訂', '訂金');
$arrival = array('貨抵工地', '貨底工地', '工地動工');
$final6 = array('核可函取得後6個月', '得合格函後6個月');
foreach ($PayStage_array as $key => &$value) {
foreach ($value as $paykey => &$payvalue) {
if (isset($wip_array[$payvalue['facilityno']])) {
@ -860,7 +864,20 @@ $excel_contract_boga_array = array();
$excel_contract_noboga_array = array();
$excel_facility_array = array();
$total_collect_budget = 0;
$total_collect_facility = 0;
$boga_collect_budget = 0;
$boga_collect_facility = 0;
$noboga_collect_budget = 0;
$noboga_collect_facility = 0;
$total_sign_collect_budget = $boga_sign_collect_budget = $noboga_sign_collect_budget = 0;
$total_second_collect_budget = $boga_second_collect_budget = $noboga_second_collect_budget = 0;
$total_arrival_collect_budget = $boga_arrival_collect_budget = $noboga_arrival_collect_budget = 0;
$total_install_collect_budget = $boga_install_collect_budget = $noboga_install_collect_budget = 0;
$total_tryrun_collect_budget = $boga_tryrun_collect_budget = $noboga_tryrun_collect_budget = 0;
$total_check_collect_budget = $boga_check_collect_budget = $noboga_check_collect_budget = 0;
$total_delivery_collect_budget = $boga_delivery_collect_budget = $noboga_delivery_collect_budget = 0;
$total_final_collect_budget = $boga_final_collect_budget = $noboga_final_collect_budget = 0;
foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key] = array_fill(0, 76, '');
@ -875,30 +892,30 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][8] = (isset($value['PersonName']) && !is_null($value['PersonName'])) ? $value['PersonName'] : '';
$excel_contract_array[$key][9] = (isset($value['ManagerId']) && !is_null($value['ManagerId'])) ? $value['ManagerId'] : '';
$excel_contract_array[$key][10] = (isset($value['ManagerName']) && !is_null($value['ManagerName'])) ? $value['ManagerName'] : '';
$excel_contract_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? number_format(round($value['OAmountWithTax'])) : '0';
$excel_contract_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? number_format(round($value['A40001'])) : '0';
$excel_contract_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? number_format(round($value['A40008'])) : '0';
$excel_contract_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? $value['receivable_budget'] : 0;
$excel_contract_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? number_format(round($value['invoice_budget'])) : '0';
$excel_contract_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? $value['received_budget'] : 0;
$value['collect_budget'] = (($excel_contract_array[$key][14] - $excel_contract_array[$key][16]) > 0) ? $excel_contract_array[$key][14] - $excel_contract_array[$key][16] : 0;
$excel_contract_array[$key][17] = number_format(round($excel_contract_array[$key][14] - $excel_contract_array[$key][16]));
$excel_contract_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? number_format(round($value['collect_month'])) : '0';
$excel_contract_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? number_format(round($value['facility_num'])) : '0';
$excel_contract_array[$key][11] = (isset($value['OAmountWithTax']) && !is_null($value['OAmountWithTax'])) ? round($value['OAmountWithTax']) : 0;
$excel_contract_array[$key][12] = (isset($value['A40001']) && !is_null($value['A40001'])) ? round($value['A40001']) : 0;
$excel_contract_array[$key][13] = (isset($value['A40008']) && !is_null($value['A40008'])) ? round($value['A40008']) : 0;
$excel_contract_array[$key][14] = (isset($value['receivable_budget']) && !is_null($value['receivable_budget'])) ? round($value['receivable_budget']) : 0;
$excel_contract_array[$key][15] = (isset($value['invoice_budget']) && !is_null($value['invoice_budget'])) ? round($value['invoice_budget']) : 0;
$excel_contract_array[$key][16] = (isset($value['received_budget']) && !is_null($value['received_budget'])) ? round($value['received_budget']) : 0;
$value['collect_budget'] = (abs($excel_contract_array[$key][14] - $excel_contract_array[$key][16]) > 10) ? round($excel_contract_array[$key][14] - $excel_contract_array[$key][16]) : 0;
$excel_contract_array[$key][17] = $value['collect_budget'];
$excel_contract_array[$key][18] = (isset($value['collect_month']) && !is_null($value['collect_month'])) ? round($value['collect_month']) : 0;
$excel_contract_array[$key][19] = (isset($value['facility_num']) && !is_null($value['facility_num'])) ? round($value['facility_num']) : 0;
$excel_contract_array[$key][20] = (isset($value['facility_status']) && !is_null($value['facility_status'])) ? $value['facility_status'] : '--';
$excel_contract_array[$key][14] = number_format(round($excel_contract_array[$key][14]));
$excel_contract_array[$key][16] = number_format(round($excel_contract_array[$key][16]));
if (isset($value['PayStage']) && is_iterable($value['PayStage'])) {
if ($excel_contract_array[$key][18] !== '0') {
if ($excel_contract_array[$key][18] >0 && abs($value['collect_budget']) > 10) {
$excel_contract_all_array[$key] = array_fill(0, 24, 0);
$excel_contract_all_array[$key][0] = $excel_contract_array[$key][0];
$excel_contract_all_array[$key][1] = $excel_contract_array[$key][3];
$excel_contract_all_array[$key][2] = $excel_contract_array[$key][8];
$excel_contract_all_array[$key][3] = $excel_contract_array[$key][11];
$excel_contract_all_array[$key][4] = $excel_contract_array[$key][19];
$excel_contract_all_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_all_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_all_array[$key][7] = $excel_contract_array[$key][18];
$excel_contract_all_array[$key][2] = $excel_contract_array[$key][6];
$excel_contract_all_array[$key][3] = $excel_contract_array[$key][8];
$excel_contract_all_array[$key][4] = $excel_contract_array[$key][11];
$excel_contract_all_array[$key][5] = $excel_contract_array[$key][19];
$excel_contract_all_array[$key][6] = $excel_contract_array[$key][20];
$excel_contract_all_array[$key][7] = $excel_contract_array[$key][17];
$total_collect_budget += $excel_contract_all_array[$key][6];
$total_collect_facility += $excel_contract_all_array[$key][4];
$isBoga = 0;
if (stristr($value['PayStage'][1]['PayStage'], '寶佳')) {
$isBoga = 1;
@ -911,6 +928,8 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_boga_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_boga_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_boga_array[$key][7] = $excel_contract_array[$key][18];
$boga_collect_budget += $excel_contract_boga_array[$key][6];
$boga_collect_facility += $excel_contract_boga_array[$key][4];
} else {
$excel_contract_noboga_array[$key] = array_fill(0, 24, '');
$excel_contract_noboga_array[$key][0] = $excel_contract_array[$key][0];
@ -921,6 +940,8 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_noboga_array[$key][5] = $excel_contract_array[$key][20];
$excel_contract_noboga_array[$key][6] = $excel_contract_array[$key][17];
$excel_contract_noboga_array[$key][7] = $excel_contract_array[$key][18];
$noboga_collect_budget += $excel_contract_noboga_array[$key][6];
$noboga_collect_facility += $excel_contract_noboga_array[$key][4];
}
}
@ -928,175 +949,174 @@ foreach ($arrayData as $key => &$value) {
switch ($payvalue['stage']) {
case "訂金":
$excel_contract_array[$key][21] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][26] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25]));
$excel_contract_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][22] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][23] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][24] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][25] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][26] = (abs($excel_contract_array[$key][23] - $excel_contract_array[$key][25]) >10)?round($excel_contract_array[$key][23] - $excel_contract_array[$key][25]):0;
$excel_contract_array[$key][27] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][26]) > 10) ? round($payvalue['collect_month']) : 0;
$total_sign_collect_budget += $excel_contract_array[$key][26];
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][8] = number_format(round($excel_contract_array[$key][23] - $excel_contract_array[$key][25]));
$excel_contract_all_array[$key][9] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][8] = $excel_contract_array[$key][26];
$excel_contract_all_array[$key][9] = $excel_contract_array[$key][27];
$total_sign_collect_budget += $excel_contract_all_array[$key][8];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][8] = $excel_contract_all_array[$key][8];
$excel_contract_boga_array[$key][9] = $excel_contract_all_array[$key][9];
$boga_sign_collect_budget += $excel_contract_boga_array[$key][8];
} else {
$excel_contract_noboga_array[$key][8] = $excel_contract_all_array[$key][8];
$excel_contract_noboga_array[$key][9] = $excel_contract_all_array[$key][9];
$noboga_sign_collect_budget += $excel_contract_noboga_array[$key][8];
}
}
$excel_contract_array[$key][23] = number_format(round($excel_contract_array[$key][23]));
$excel_contract_array[$key][25] = number_format(round($excel_contract_array[$key][25]));
break;
case "二次款":
$excel_contract_array[$key][28] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][33] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32]));
$excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][29] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][30] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][31] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][32] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][33] = (abs($excel_contract_array[$key][30] - $excel_contract_array[$key][32]) >10)?round($excel_contract_array[$key][30] - $excel_contract_array[$key][32]):0;
$excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][33]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][10] = number_format(round($excel_contract_array[$key][30] - $excel_contract_array[$key][32]));
$excel_contract_all_array[$key][11] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][10] = $excel_contract_array[$key][33];
$excel_contract_all_array[$key][11] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_second_collect_budget += $excel_contract_all_array[$key][10];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][10] = $excel_contract_all_array[$key][10];
$excel_contract_boga_array[$key][11] = $excel_contract_all_array[$key][11];
$boga_second_collect_budget += $excel_contract_boga_array[$key][10];
} else {
$excel_contract_noboga_array[$key][10] = $excel_contract_all_array[$key][10];
$excel_contract_noboga_array[$key][11] = $excel_contract_all_array[$key][11];
$noboga_second_collect_budget += $excel_contract_noboga_array[$key][10];
}
}
$excel_contract_array[$key][30] = number_format(round($excel_contract_array[$key][30]));
$excel_contract_array[$key][32] = number_format(round($excel_contract_array[$key][32]));
break;
case "貨抵工地款":
$excel_contract_array[$key][35] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][40] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39]));
$excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][36] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][37] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][38] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][39] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][40] = (abs($excel_contract_array[$key][37] - $excel_contract_array[$key][39])>10)?round($excel_contract_array[$key][37] - $excel_contract_array[$key][39]):0;
$excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][40]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][12] = number_format(round($excel_contract_array[$key][37] - $excel_contract_array[$key][39]));
$excel_contract_all_array[$key][13] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][12] = $excel_contract_array[$key][40];
$excel_contract_all_array[$key][13] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_arrival_collect_budget += $excel_contract_all_array[$key][12];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][12] = $excel_contract_all_array[$key][12];
$excel_contract_boga_array[$key][13] = $excel_contract_all_array[$key][13];
$boga_arrival_collect_budget += $excel_contract_boga_array[$key][12];
} else {
$excel_contract_noboga_array[$key][12] = $excel_contract_all_array[$key][12];
$excel_contract_noboga_array[$key][13] = $excel_contract_all_array[$key][13];
$noboga_arrival_collect_budget += $excel_contract_noboga_array[$key][12];
}
}
$excel_contract_array[$key][37] = number_format(round($excel_contract_array[$key][37]));
$excel_contract_array[$key][39] = number_format(round($excel_contract_array[$key][39]));
break;
case "安裝款":
$excel_contract_array[$key][42] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][47] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46]));
$excel_contract_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][43] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][44] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][45] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][46] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][47] = (abs($excel_contract_array[$key][44] - $excel_contract_array[$key][46])>10)?round($excel_contract_array[$key][44] - $excel_contract_array[$key][46]):0;
$excel_contract_array[$key][48] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][47]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][14] = number_format(round($excel_contract_array[$key][44] - $excel_contract_array[$key][46]));
$excel_contract_all_array[$key][15] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][14] = $excel_contract_array[$key][47];
$excel_contract_all_array[$key][15] = $excel_contract_array[$key][48];
$excel_contract_noboga_array[$key][14] = $excel_contract_all_array[$key][14];
$excel_contract_noboga_array[$key][15] = $excel_contract_all_array[$key][15];
$total_install_collect_budget += $excel_contract_all_array[$key][14];
$noboga_install_collect_budget += $excel_contract_noboga_array[$key][14];
}
$excel_contract_array[$key][44] = number_format(round($excel_contract_array[$key][44]));
$excel_contract_array[$key][46] = number_format(round($excel_contract_array[$key][46]));
break;
case "試車款":
$excel_contract_array[$key][49] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][54] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53]));
$excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][50] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][51] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][52] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][53] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][54] = (abs($excel_contract_array[$key][51] - $excel_contract_array[$key][53])>10)?round($excel_contract_array[$key][51] - $excel_contract_array[$key][53]):0;
$excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][54]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][16] = number_format(round($excel_contract_array[$key][51] - $excel_contract_array[$key][53]));
$excel_contract_all_array[$key][17] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][16] = $excel_contract_array[$key][54];
$excel_contract_all_array[$key][17] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_tryrun_collect_budget += $excel_contract_all_array[$key][16];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][16] = $excel_contract_all_array[$key][16];
$excel_contract_boga_array[$key][17] = $excel_contract_all_array[$key][17];
$boga_tryrun_collect_budget += $excel_contract_boga_array[$key][16];
} else {
$excel_contract_noboga_array[$key][16] = $excel_contract_all_array[$key][16];
$excel_contract_noboga_array[$key][17] = $excel_contract_all_array[$key][17];
$noboga_tryrun_collect_budget += $excel_contract_noboga_array[$key][16];
}
}
$excel_contract_array[$key][51] = number_format(round($excel_contract_array[$key][51]));
$excel_contract_array[$key][53] = number_format(round($excel_contract_array[$key][53]));
break;
case "官檢驗收款":
$excel_contract_array[$key][56] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][61] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60]));
$excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][57] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][58] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][59] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][60] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][61] = (abs($excel_contract_array[$key][58] - $excel_contract_array[$key][60])>10)?round($excel_contract_array[$key][58] - $excel_contract_array[$key][60]):0;
$excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][61]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][18] = number_format(round($excel_contract_array[$key][58] - $excel_contract_array[$key][60]));
$excel_contract_all_array[$key][19] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][18] = $excel_contract_array[$key][61];
$excel_contract_all_array[$key][19] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_check_collect_budget += $excel_contract_all_array[$key][18];
$excel_contract_noboga_array[$key][18] = $excel_contract_all_array[$key][18];
$excel_contract_noboga_array[$key][19] = $excel_contract_all_array[$key][19];
$noboga_check_collect_budget += $excel_contract_noboga_array[$key][18];
}
$excel_contract_array[$key][58] = number_format(round($excel_contract_array[$key][58]));
$excel_contract_array[$key][60] = number_format(round($excel_contract_array[$key][60]));
break;
case "交車款":
$excel_contract_array[$key][63] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][68] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67]));
$excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][64] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][65] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][66] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][67] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][68] = (abs($excel_contract_array[$key][65] - $excel_contract_array[$key][67])>10)?round($excel_contract_array[$key][65] - $excel_contract_array[$key][67]):0;
$excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][68]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][20] = number_format(round($excel_contract_array[$key][65] - $excel_contract_array[$key][67]));
$excel_contract_all_array[$key][21] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][20] = $excel_contract_array[$key][68];
$excel_contract_all_array[$key][21] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_delivery_collect_budget += $excel_contract_all_array[$key][20];
$excel_contract_noboga_array[$key][20] = $excel_contract_all_array[$key][20];
$excel_contract_noboga_array[$key][21] = $excel_contract_all_array[$key][21];
$noboga_delivery_collect_budget += $excel_contract_noboga_array[$key][20];
}
$excel_contract_array[$key][65] = number_format(round($excel_contract_array[$key][65]));
$excel_contract_array[$key][67] = number_format(round($excel_contract_array[$key][67]));
break;
case "尾款":
$excel_contract_array[$key][70] = (isset($payvalue['PayStage']) && !is_null($payvalue['PayStage'])) ? $payvalue['PayStage'] : '--';
$excel_contract_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? number_format(round($payvalue['PlanPayAmt'])) : '0';
$excel_contract_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? $payvalue['receivable_budget'] : 0;
$excel_contract_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? number_format(round($payvalue['invoice_budget'])) : '0';
$excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? $payvalue['received_budget'] : 0;
$excel_contract_array[$key][75] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74]));
$excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_array[$key][71] = (isset($payvalue['PlanPayAmt']) && !is_null($payvalue['PlanPayAmt'])) ? round($payvalue['PlanPayAmt']) : 0;
$excel_contract_array[$key][72] = (isset($payvalue['receivable_budget']) && !is_null($payvalue['receivable_budget'])) ? round($payvalue['receivable_budget']) : 0;
$excel_contract_array[$key][73] = (isset($payvalue['invoice_budget']) && !is_null($payvalue['invoice_budget'])) ? round($payvalue['invoice_budget']) : 0;
$excel_contract_array[$key][74] = (isset($payvalue['received_budget']) && !is_null($payvalue['received_budget'])) ? round($payvalue['received_budget']) : 0;
$excel_contract_array[$key][75] = (abs($excel_contract_array[$key][72] - $excel_contract_array[$key][74])>10)?round($excel_contract_array[$key][72] - $excel_contract_array[$key][74]):0;
$excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][75]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][22] = number_format(round($excel_contract_array[$key][72] - $excel_contract_array[$key][74]));
$excel_contract_all_array[$key][23] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? number_format(round($payvalue['collect_month'])) : '0';
$excel_contract_all_array[$key][22] = $excel_contract_array[$key][75];
$excel_contract_all_array[$key][23] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$total_final_collect_budget += $excel_contract_all_array[$key][22];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][22] = $excel_contract_all_array[$key][22];
$excel_contract_boga_array[$key][23] = $excel_contract_all_array[$key][23];
$boga_final_collect_budget += $excel_contract_boga_array[$key][22];
} else {
$excel_contract_noboga_array[$key][22] = $excel_contract_all_array[$key][22];
$excel_contract_noboga_array[$key][23] = $excel_contract_all_array[$key][23];
$noboga_final_collect_budget += $excel_contract_noboga_array[$key][22];
}
}
$excel_contract_array[$key][72] = number_format(round($excel_contract_array[$key][72]));
$excel_contract_array[$key][74] = number_format(round($excel_contract_array[$key][74]));
break;
}
}
@ -1117,6 +1137,29 @@ foreach ($arrayData as $key => &$value) {
}
}
}
// $excel_contract_all_array['last']= $excel_contract_boga_array['last'] = $excel_contract_noboga_array['last'] = array_fill(0, 23, '');
$excel_contract_all_array['last']= ['合計', '', '', '', $total_collect_facility, '', $total_collect_budget, '', $total_sign_collect_budget, '', $total_second_collect_budget, '', $total_arrival_collect_budget, '', $total_install_collect_budget, '', $total_tryrun_collect_budget, '', $total_check_collect_budget, '', $total_delivery_collect_budget, '', $total_final_collect_budget, ''];
$excel_contract_boga_array['last']= ['合計', '', '', '', $boga_collect_facility, '', $boga_collect_budget, '', $boga_sign_collect_budget, '', $boga_second_collect_budget, '', $boga_arrival_collect_budget, '', $boga_install_collect_budget, '', $boga_tryrun_collect_budget, '', $boga_check_collect_budget, '', $boga_delivery_collect_budget, '', $boga_final_collect_budget, ''];
$excel_contract_noboga_array['last']= ['合計', '', '', '', $noboga_collect_facility, '', $noboga_collect_budget, '', $noboga_sign_collect_budget, '', $noboga_second_collect_budget, '', $noboga_arrival_collect_budget, '', $noboga_install_collect_budget, '', $noboga_tryrun_collect_budget, '', $noboga_check_collect_budget, '', $noboga_delivery_collect_budget, '', $noboga_final_collect_budget, ''];
// print_r($excel_contract_array['M230064']);
// echo "<br>---------------------------------------------------------<br>";
// foreach($arrayData['M230064'] as $key => $value){
// if($key == 'PayStage'){
// echo "是PayStage!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <br>";
// foreach($value as $k => $v){
// echo $k.' => ';
// print_r($v);
// echo '<br>';
// }
// echo "-----------------------<br>";
// }else{
// echo $key.' => ';
// print_r($value);
// echo '<br>';
// }
// }
// print_r($arrayData['M220003']);
// exit();
$total_data = json_encode($excel_contract_all_array);

7
wms/account-receivable-test.php

@ -441,7 +441,6 @@ $P_all = "
// echo $value['BillNo'] . ";" . $mode . ";" . $value['BizPartnerId'] .";".$value['BizPartnerName'].";".$value['ProjectId']. ";".$value['CU_MaterialId']. ";".$value['DispBillNo'].";" . $value['DispBillDate'] ."<br>";
// }
$TIME = strtotime('2000-12-02');
echo $TIME;
$sql = "SELECT salOrderStagePay.BillNo, salOrderStagePay.PayStage FROM salOrderStagePay LEFT JOIN salSalesOrder ON salSalesOrder.BillNo = salOrderStagePay.BillNo WHERE salSalesOrder.ModeId = 'M'
ORDER BY salOrderStagePay.BillNo, salOrderStagePay.PayStage";
$query = mysqli_query($link, $sql);

2
wms/account-receivable.txt

File diff suppressed because one or more lines are too long

126
wms/bonus/bonus_person.php

@ -6,34 +6,34 @@ $now = date("Y-m-d");
$oneMonthAgo = date("Y-m-d", strtotime("$now +1 months"));
$oneMonthAgo1 = date("m", strtotime($oneMonthAgo));
$clause = "";
if ($_GET['check'] == 'maintainance') {
if (!empty($_GET)) {
// if ($_GET['check'] == 'maintainance') {
if (!empty($_GET['months_select']) && !empty($_GET['years'])) {
$month = $_GET['months_select'];
$years = $_GET['years']; // 當前年份
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $years);
$select_date = date("$years-$month-01");
$select_date1 = date("$years-$month-$days_in_month");
echo $select_date1;
// echo $select_date1;
$clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' ";
} else {
} else {
$clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
}
}
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
$sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' ";
$sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a
LEFT JOIN account AS b ON a.receiver = b.accountid
WHERE 1=1 AND contract_type = 3 $clause ORDER BY a.receiver ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt = $conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$person_arr = [];
$bonus_arr = [];
$count = 0;
$person_arr = [];
$bonus_arr = [];
$count = 0;
$a = 0;
$j = 0;
}
$a = 0;
$j = 0;
// }
for ($i = 0; $i < COUNT($results); $i++) {
$a++;
@ -86,6 +86,7 @@ for ($i = 0; $i < COUNT($results); $i++) {
</thead>
</table>
<form method='get' action=''>
<table class='table table-striped table-bordered' style='width:70%;text-align:center;margin:0 auto'>
<tbody>
@ -117,6 +118,12 @@ for ($i = 0; $i < COUNT($results); $i++) {
<input type="hidden" name="function_name" value="schedule_index">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
<a href="/wms/bonus/maintainance_bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (empty($_GET)) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> -->
<a href="/wms/bonus/maintainance_bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/bonus_person.php?check=maintainance&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo ((isset($_GET['check']) && $_GET['check'] == 'maintainance') || !empty($_GET['months_select'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 獎金總計(人)</a>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
@ -144,3 +151,90 @@ for ($i = 0; $i < COUNT($results); $i++) {
</tbody>
</table>
</div>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
.width_st yle_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
table-layout: fixed;
width: 100%;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
.btn-secondary {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
color: #fff;
background-color: #5a6268;
border-color: #545b62;
}
.applybtn {
color: #fff;
background-color: #1484c4;
/* display: block; */
border-radius: 5px;
/* padding: 5px 2px; */
font-size: 13px;
line-height: 1;
display: grid;
place-items: center;
/* 水平和垂直居中 */
/* height: 2%vh; */
/* 100%视窗高度,可根据需要调整 */
}
.applybtncheck {
color: #fff;
background-color: #eea236;
/* display: block; */
border-radius: 4px;
padding: 4px 2px;
font-size: 13px;
line-height: 1;
display: grid;
place-items: center;
/* 水平和垂直居中 */
height: 2%vh;
/* 100%视窗高度,可根据需要调整 */
}
.applybtncheck:hover {
background-color: #f0ad4e;
color: #fff;
}
.applybtn:hover {
background-color: #1494f9;
color: #fff;
}
</style>

236
wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php

@ -0,0 +1,236 @@
<?php
/*
獎金辦法 1.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
1.0 作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0_1 作番賣價($elevator_knockdown_price) : 電梯合約價格收款階段比例金額
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
營業員獎金($sales_bonus)
區域經理獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、貨到工地款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
/* paykind_arr =[
[
pay_kind -- 1=訂金、2=二次款、3=貨到工地款、4=材料其他、5=安裝完畢、6=驗收款、7=其他安裝款
pay_scale -- 百分比
pay_amount -- 金額
],
[
]
]
*/
function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_pay_kind, $sales_id, $region_manger_id)
{
// echo "<pre>";
// print_r($elevator_pay_kind);
// echo "</pre>";
// exit;
$bonus_array = [];
if ($ver == "1.0") {
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
foreach ($elevator_pay_kind as $elevator_pay_kind) {
switch ($contract_type) {
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_pay_kind['pay_amount'] * 0.007;
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_pay_kind['pay_amount'] * 0.015;
#區域經理獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
};
$pay_scale = $elevator_pay_kind['pay_scale'];
// echo "<pre>";
// print_r($pay_scale);
// echo "</pre>";
switch ($elevator_pay_kind['pay_kind']) {
case '1':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "deposit", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
]);
break;
case '2':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-二次段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "twice", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '3':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "shipping", #訂金已收款20%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
"payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
]);
break;
case '4':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-材料其他段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "other", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '5':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-安裝完畢段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "installed", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '6':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "acceptance", #訂金已收款20%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
case '7':
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-安裝其他段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => $sales_bonus, #金額
"payment_schedul_due" => "installOther", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款$pay_scale%,發放總獎金$pay_scale%" #發放規定
]);
break;
}
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.2), #金額
// "payment_schedul_due" => "deposit", #訂金已收款20%
// "payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定
// ]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.5), #金額
// "payment_schedul_due" => "shipping", #訂金已收款20%
// "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定
// ]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
// array_push($bonus_array, [
// "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
// "bonus_receiver" => $sales_id, #發放人員
// "bonus_amount" => round($sales_bonus * 0.3), #金額
// "payment_schedul_due" => "acceptance", #訂金已收款20%
// "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定
// ]);
#區域經理獎金水庫-----訂金已收款100%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
// "bonus_receiver" => $region_manger_id, #發放人員
// "bonus_amount" => round($region_manager_bonus * 0.5), #金額
// "payment_schedul_due" => "deposit", #訂金已收款100%
// "payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
// ]);
// #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
// array_push($bonus_array, [
// "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
// "bonus_receiver" => $region_manger_id, #發放人員
// "bonus_amount" => round($region_manager_bonus * 0.5), #金額
// "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
// "payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
// ]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"payment_schedul_due" => "9999-1-1", #預計發放時間
"payment_schedul_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
};
return $result_array;
};

68
wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php

@ -1,9 +1,15 @@
<?php
/* 函數用法與參數
/*
獎金辦法 1.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):1.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0 作番賣價($elevator_knockdown_price):電梯的合約最後成交價
1.0_1 作番賣價($elevator_knockdown_price) : 電梯合約價格收款階段比例金額
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
@ -30,25 +36,59 @@ result_array[
*/
/* paykind_arr =[
[
pay_kind -- 1=訂金、2=二次款、3=貨到工地款、4=材料其他、5=安裝完畢、6=驗收款、7=其他安裝款
pay_scale -- 百分比
pay_amount -- 金額
],
[
]
]
*/
require_once("elevator_new_deal_bonus_v1_0.php");
require_once("elevator_new_deal_bonus_v1_0_1.php");
#$ver, $contract_type, $elevator_knockdown_price, $sales_id, $region_manger_id
#獎金測試
$pay_kind_arr = [
[
"pay_kind" => '1',
"pay_scale" => 20,
"pay_amount" => 318000
],
[
"pay_kind" => '3',
"pay_scale" => 50,
"pay_amount" => 795000
],
[
"pay_kind" => '5',
"pay_scale" => 20,
"pay_amount" => 318000
],
[
"pay_kind" => '6',
"pay_scale" => 10,
"pay_amount" => 159000
]
];
$examination_array = [
#錯誤版本
["2.0","strategy_customer",1000000,"M0001", "M0003"],
["1.0", "strategy_customer", ($pay_kind_arr), "M0001", "M0003"],
#戰略客戶(strategy_customer)
["1.0","strategy_customer",1000000,"M0001", "M0003"], #戰略客戶
// ["1.0", "strategy_customer", 1000000, "M0001", "M0003"], #戰略客戶
#一般客戶(general_customer)
["1.0","general_customer",1000000,"M0001", "M0003"] #一般客戶
// #一般客戶(general_customer)
["1.0", "general_customer", $pay_kind_arr, "M0001", "M0003"] #一般客戶
];
for($i = 0; $i<count($examination_array); $i++){
for ($i = 0; $i < count($examination_array); $i++) {
$result = elevator_new_deal_bonus_v1_0(
$examination_array[$i][0],
$examination_array[$i][1],
@ -56,17 +96,17 @@ for($i = 0; $i<count($examination_array); $i++){
$examination_array[$i][3],
$examination_array[$i][4]
);
// echo "<pre>";
// print_r($examination_array);
// echo "</pre>";
echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>";
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "<br>";
for ($j = 0; $j < count($result["bonus_array"]); $j++) {
echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " "
. $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " "
. $result["bonus_array"][$j]["payment_schedul_regulation"] . "<br>";
};
echo "-------------------------" . "<br>";
};
?>

166
wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php

@ -0,0 +1,166 @@
<?php
/*
獎金辦法 2.0_1 說明,需要查看合約收入的款項去發放該款項的獎金
函數用法與參數
【1.輸入參數:】
獎金版本($ver):2.0
合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
作番機種($elevator_type):客梯(passenger)、貨梯(cargo)、小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
作番表價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格
作番賣價($elevator_knockdown_price):電梯的合約最後成交價
營業員員工號($sales_id)
區域經理員工號($region_manger_id)
【2.函數中的變數說明】
// 銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price)
營業員獎金($sales_bonus)
區域經理提成獎金($region_manager_bonus)
獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款)
獎金預計發放規定($payment_schedule_regulation):訂金收齊、出貨款收齊、驗收款收齊
計算結果($result_status):success, error
獎金水庫(bonus_array)[
bonus_type:獎金名稱,
bonus_receiver:發放人員,
bonus_amount:金額,
payment_schedul_due:預計發放階段
payment_schedul_regulation, 發放規定
]
【3.輸出數據】
result_array[
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"$bonus_array"=>$bonus_array #所有獎金水庫
];
*/
function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $elevator_list_price, $elevator_knockdown_price, $sales_id, $region_manger_id)
{
$bonus_array = [];
if ($ver == "2.0") {
$elevator_knockdown_price = round($elevator_knockdown_price / 1.05); //不含稅
$discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。
#合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer)
switch ($contract_type) {
case "strategy_customer":
#契約員獎金($sales_bonus)
$sales_bonus = $elevator_knockdown_price * 0.007;
#地區經理提成獎金($region_manager_bonus)
$region_manager_bonus = 400;
break;
case "general_customer":
switch ($elevator_type) {
#客梯(passenger)、貨梯(cargo)
case ($elevator_type == "passenger" or $elevator_type == "cargo"):
switch ($discount) {
case ($discount >= 1.0):
$sales_bonus = $elevator_knockdown_price * 0.02;
break;
case ($discount >= 0.9 and $discount < 1.0):
$sales_bonus = $elevator_knockdown_price * 0.018;
break;
case ($discount >= 0.75 and $discount < 0.9):
$sales_bonus = $elevator_knockdown_price * 0.015;
break;
case ($discount < 0.75):
$sales_bonus = $elevator_knockdown_price * 0.008;
break;
};
break;
#小電梯(dumbwaiter)、平台梯(flatbase)、強驅(positive_drive)
case ($elevator_type == "dumbwaiter" or $elevator_type == "flatbase" or $elevator_type == "positive_drive"):
switch ($discount) {
case ($discount >= 1.0):
$sales_bonus = $elevator_knockdown_price * 0.02;
break;
case ($discount >= 0.9 and $discount < 1.0):
$sales_bonus = $elevator_knockdown_price * 0.018;
break;
case ($discount >= 0.72 and $discount < 0.9):
$sales_bonus = $elevator_knockdown_price * 0.015;
break;
case ($discount < 0.72):
$sales_bonus = $elevator_knockdown_price * 0.008;
break;
};
break;
};
#區域經理提成獎金($region_manager_bonus)
$region_manager_bonus = 600;
break;
};
#營銷人員銷售獎金水庫-----訂金已收款20%,發放總獎金20%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.2), #金額
"payment_schedul_due" => "deposit", #訂金已收款20%
"payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定
]);
#營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.5), #金額
"payment_schedul_due" => "shipping", #訂金已收款20%
"payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定
]);
#營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%
array_push($bonus_array, [
"bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus * 0.3), #金額
"payment_schedul_due" => "acceptance", #訂金已收款20%
"payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定
]);
#區域經理提成獎金水庫-----訂金已收款100%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deposit", #訂金已收款100%
"payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定
]);
#區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50%
array_push($bonus_array, [
"bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus * 0.5), #金額
"payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100%
"payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"payment_schedul_due" => "9999-1-1", #預計發放時間
"payment_schedul_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
};
return $result_array;
};

17
wms/bonus/maintainance_bonus.php

@ -23,9 +23,10 @@ $bonus_status = [
'4' => '暫不發放',
'5' => '人事審核確認'
];
// print_r($user_id);
$clause = '';
if ($user_id != 'M0225') {
$clause .= "AND receiver == '$user_id'";
if ($user_id != 'M0225' && $user_id != 'M0012' && $user_id != 'M0029') {
$clause .= "AND receiver = '$user_id'";
}
if (!empty($_GET['check'])) {
// 人事發放作業,應為一個月內
@ -43,7 +44,9 @@ if (!empty($_GET['check'])) {
$sql = "SELECT a.*,b.customer FROM bonus AS a
LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no
WHERE 1=1 $clause AND a.contract_type = 3";
// echo "<pre>";
// print_r($sql);
// echo "</pre>";
$stmt = $conn->prepare($sql);
$stmt->execute();
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -85,11 +88,11 @@ $id_str = implode(',', $id);
<!-- <a href="bonus_index1.php?function_name=bonus&token=<?php echo $token; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a> -->
<a href="/wms/bonus/bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> -->
<a href="/wms/bonus/bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/maintainance_bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
<a href="/wms/bonus/maintainance_bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a>
<a href="/wms/bonus/bonus_person.php?check=maintainance&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 5) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 獎金總計(人)</a>

748
wms/bonus/maintance/maintaenance_contract_bonus.php

@ -0,0 +1,748 @@
<?php
## 3/31 前套用 2.0 版本
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id = '')
{
$bonus_array = [];
if ($ver == "2.0") {
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.5;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.25;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
};
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount < 0.6):
$sales_bonus = $sales_bonus * 0.7;
break;
case ($discount >= 0.6 and $discount < 0.8):
$sales_bonus = $sales_bonus * 0.8;
break;
case ($discount >= 0.8):
$sales_bonus = $sales_bonus * 1.0;
break;
};
#簽約年數($contract_years):1年(1),超過1年(above)
switch ($contract_years) {
case $contract_years == "one":
#契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
case $contract_years == "above_two":
/*** 以下第1年獎金 ***/
#契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
/*** 以上第1年獎金 ***/
/*** 以下第2年獎金 ***/
#第2年契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
/*** 以上第2年獎金 ***/
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
}
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};
## 4/1 後套用 2.1 版本
function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '')
{
// $fee_per_st = round($fee_per_st);
$bonus_array = [];
if ($ver == "2.1") {
$discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
// $discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.48;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.64;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.72;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.42;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.49;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.63;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.45;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.25;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#地區處長獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放" #發放規定
]);
#專任契約經理獎金
if ($regular_contract_manger_id != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放" #發放規定
]);
}
#契約員獎金
switch ($payment_period) {
#年付
case "annually":
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
break;
#半年付
case "semiannually":
$payment_ratio_due_array = array(0.5, 0.5);
$payday_due_array = array(1, 7);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#季付
case "quarterly":
$payment_ratio_due_array = array(0.25, 0.25, 0.25, 0.25);
$payday_due_array = array(1, 4, 7, 10);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#2月1次
case "bimonthly":
$payment_ratio_due_array = array();
for ($i = 0; $i < 6; $i++) {
array_push($payment_ratio_due_array, 1 / 6);
}
$payday_due_array = array(1, 3, 5, 7, 9, 11);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#月付
case "monthly":
$payment_ratio_due_array = array();
// $payment_ratio_due_array = array();
for ($i = 0; $i < 12; $i++) {
array_push($payment_ratio_due_array, 1 / 12);
}
$payday_due_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};
## 五年以上長約
function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '')
{
$bonus_array = [];
if ($ver == "2.1") {
$discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge)
switch ($contract_type) {
case "longcontract_m1_free_charge":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3000 and $fee_per_st < 4000):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 1.0;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.42;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 4000):
$sales_bonus = ($fee_per_st) * 0.49;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.63;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 0.7;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3000 and $fee_per_st < 4000):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.45;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 0.5;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually)
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
#專任契約經理獎金
if ($regular_contract_manger_id != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
}
#地區處長獎金、專任契約經理、契約員獎金
switch ($payment_period) {
#簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金
#總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期,
#年繳
case 'annually':
$payment_ratio_due_array = array();
$a = $payment_period_amount / 12;
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, $i + 1);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定
]);
}
break;
#半年繳
case 'semiannually':
$payment_ratio_due_array = array();
$a = $payment_period_amount / 6;
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 6);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定
]);
}
break;
#季繳
case 'quarterly':
$a = $payment_period_amount / 3;
$payment_ratio_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 4);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#雙月繳
case 'bimonthly':
$a = $payment_period_amount / 2;
$payment_ratio_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 2);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
break;
#月繳
case 'monthly':
#產生契約員每個月的獎金應發比例
$payment_ratio_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payment_ratio_due_array, 1 / $payment_period_amount);
}
$payday_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payday_due_array, $i + 1);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};

96
wms/bonus/maintance/maintenance_contract_bonus_v2_0.php

@ -36,28 +36,29 @@ result_array[
*/
## 3/31 前套用 2.0 版本
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id){
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id)
{
$bonus_array = [];
if ($ver == "2.0"){
if ($ver == "2.0") {
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type){
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.6;
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7;
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.8;
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.9;
$sales_bonus = ($fee_per_st) * 0.9;
break;
};
#地區經理經理獎金($region_manager_bonus)
@ -69,16 +70,16 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3;
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35;
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4;
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.5;
$sales_bonus = ($fee_per_st) * 0.5;
break;
};
#地區經理經理獎金($region_manager_bonus)
@ -90,16 +91,16 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.25;
$sales_bonus = ($fee_per_st) * 0.25;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3;
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35;
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4;
$sales_bonus = ($fee_per_st) * 0.4;
break;
};
#地區經理經理獎金($region_manager_bonus)
@ -124,110 +125,110 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
#簽約年數($contract_years):1年(1),超過1年(above)
switch ($contract_years){
switch ($contract_years) {
case $contract_years == "one":
#契約員獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
case $contract_years == "above_two":
/*** 以下第1年獎金 ***/
#契約員獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
/*** 以上第1年獎金 ***/
/*** 以下第2年獎金 ***/
#第2年契約員獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年地區經理經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年專任契約經理獎金
array_push($bonus_array,[
array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
/*** 以上第2年獎金 ***/
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
}
}else{
array_push($bonus_array,[
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
@ -235,14 +236,11 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver"=>$ver, #獎金版本
"result_status"=>"error", #計算結果
"bonus_array"=>$bonus_array #獎金水庫
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};
?>

167
wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php

@ -44,89 +44,97 @@ require_once("maintenance_contract_bonus_v2_0.php");
#獎金測試
$examination_array = [
#錯誤版本
["1.0","new","one",0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"],
["1.0", "new", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"],
#新簽約
["2.0","new","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","new","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","new","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","new","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","new","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","new","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","new","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","new","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","new","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","new","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","new","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","new","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","new","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","new","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","new","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","new","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","new","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","new","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","new","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","new","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","new","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","new","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","new","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","new","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
["2.0", "new", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0", "new", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0", "new", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0", "new", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0", "new", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0", "new", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0", "new", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0", "new", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0", "new", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0", "new", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0", "new", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0", "new", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0", "new", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0", "new", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0", "new", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0", "new", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0", "new", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0", "new", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0", "new", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0", "new", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0", "new", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0", "new", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0", "new", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0", "new", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#免保轉有費(free_to_charge)
["2.0","free_to_charge","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","free_to_charge","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","free_to_charge","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","free_to_charge","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","free_to_charge","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","free_to_charge","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","free_to_charge","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","free_to_charge","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","free_to_charge","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","free_to_charge","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","free_to_charge","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","free_to_charge","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","free_to_charge","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","free_to_charge","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","free_to_charge","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","free_to_charge","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","free_to_charge","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","free_to_charge","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","free_to_charge","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","free_to_charge","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","free_to_charge","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","free_to_charge","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","free_to_charge","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","free_to_charge","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
["2.0", "free_to_charge", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0", "free_to_charge", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0", "free_to_charge", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0", "free_to_charge", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0", "free_to_charge", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0", "free_to_charge", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0", "free_to_charge", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0", "free_to_charge", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0", "free_to_charge", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0", "free_to_charge", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0", "free_to_charge", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0", "free_to_charge", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0", "free_to_charge", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0", "free_to_charge", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0", "free_to_charge", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0", "free_to_charge", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0", "free_to_charge", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0", "free_to_charge", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0", "free_to_charge", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0", "free_to_charge", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0", "free_to_charge", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0", "free_to_charge", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0", "free_to_charge", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0", "free_to_charge", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#續簽約(原價或僅契約金額異動)(renew_priceissue)
["2.0","renew_priceissue","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","renew_priceissue","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","renew_priceissue","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","renew_priceissue","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","renew_priceissue","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","renew_priceissue","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","renew_priceissue","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","renew_priceissue","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","renew_priceissue","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","renew_priceissue","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","renew_priceissue","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","renew_priceissue","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","renew_priceissue","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","renew_priceissue","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","renew_priceissue","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","renew_priceissue","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","renew_priceissue","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","renew_priceissue","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","renew_priceissue","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","renew_priceissue","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","renew_priceissue","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","renew_priceissue","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","renew_priceissue","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","renew_priceissue","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"] #新簽約、2年以上、折扣率0.6、4000元
["2.0", "renew_priceissue", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0", "renew_priceissue", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0", "renew_priceissue", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0", "renew_priceissue", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0", "renew_priceissue", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0", "renew_priceissue", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0", "renew_priceissue", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0", "renew_priceissue", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0", "renew_priceissue", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0", "renew_priceissue", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0", "renew_priceissue", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0", "renew_priceissue", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0", "renew_priceissue", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0", "renew_priceissue", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0", "renew_priceissue", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0", "renew_priceissue", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0", "renew_priceissue", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0", "renew_priceissue", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0", "renew_priceissue", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0", "renew_priceissue", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0", "renew_priceissue", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0", "renew_priceissue", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0", "renew_priceissue", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0", "renew_priceissue", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"] #新簽約、2年以上、折扣率0.6、4000元
];
$a = [
'new' => '新簽約',
'free_to_charge' => '免保轉有費',
'renew_priceissue' => '續約'
];
$b = [
'one' => '一年',
'above_two' => '一年以上'
];
for($i = 0; $i<count($examination_array); $i++){
for ($i = 0; $i < count($examination_array); $i++) {
$result = maintenance_contract_bonus_v2_0(
$examination_array[$i][0],
$examination_array[$i][1],
@ -141,16 +149,13 @@ for($i = 0; $i<count($examination_array); $i++){
);
echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>";
echo "輸入參數說明: " . $a[$examination_array[$i][1]] . "、" . $b[$examination_array[$i][2]] . "、折扣率:" . $examination_array[$i][3] . "、合約售價:" . $examination_array[$i][4] . "、服務費:" . $examination_array[$i][5] . "、第一筆保養款項應收回日:" . $examination_array[$i][6] . "、銷售人員:" . $examination_array[$i][7] . "、地區經理獎金:" . $examination_array[$i][8] . "、專任契約經理獎金:" . $examination_array[$i][9] . "<br>";
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " . $examination_array[$i][9] . "<br>";
for ($j = 0; $j < count($result["bonus_array"]); $j++) {
echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " "
. $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " "
. $result["bonus_array"][$j]["bonus_regulation"] . "<br>";
};
echo "-------------------------" . "<br>";
};
?>

4
wms/bonus/other/maintenance_contract_bonus_v2_1.php

@ -46,8 +46,8 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
// $fee_per_st = round($fee_per_st);
$bonus_array = [];
if ($ver == "2.1") {
// $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
$discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
$discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
// $discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {

17
wms/class/Cmail.php

@ -1,4 +1,5 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
@ -11,11 +12,11 @@ class Cmail
public $smtp_user = "";
public $smtp_pwd = "";
function __construct($charset='', $fromemail='')
function __construct($charset = '', $fromemail = '')
{
include dirname(__DIR__)."/PHPMailer/Exception.php";
include dirname(__DIR__)."/PHPMailer/PHPMailer.php";
include dirname(__DIR__)."/PHPMailer/SMTP.php";
include dirname(__DIR__) . "/PHPMailer/Exception.php";
include dirname(__DIR__) . "/PHPMailer/PHPMailer.php";
include dirname(__DIR__) . "/PHPMailer/SMTP.php";
$this->charset = "UTF-8";
$this->host = "mail.masada.com.tw";
@ -24,7 +25,7 @@ class Cmail
$this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼
}
function sendx($subject="", $em_body="", $sendlist=array(), $from="永佳捷科技", $bcc="", $files=array())
function sendx($subject = "", $em_body = "", $sendlist = array(), $from = "永佳捷科技", $bcc = "", $files = array())
{
if (!$sendlist) return;
$em_body = nl2br($em_body);
@ -53,10 +54,10 @@ class Cmail
//$mail->addBCC("personD@gmail.com", "person D");
//$mail->addAttachment("image1.jpg", "picture.jpg"); //設定附件, 對方會看到附件名稱為 picture.jpg
//print_r($mail);exit;
if (!$mail->Send()){
// echo "Mailer error: " . $mail->ErrorInfo;
if (!$mail->Send()) {
echo "Mailer error: " . $mail->ErrorInfo;
} else {
//echo "Email sent";
echo "Email sent";
}
}
}

38
wms/class/T8API.php

@ -0,0 +1,38 @@
<?php
require_once("../T8_Authorization_from_bpm.php");
function T8salIncomeApply($data, $api_url)
{
$validation = get_Auth();
$header = [
"CHI_Authorization :" . $validation,
"GroupId:TEST"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
return $result;
} else {
// print_r($result);
return $result;
}
return $result;
}
curl_close($ch);
}

38
wms/cont/api/getElevatorPrice.php

@ -2,29 +2,27 @@
require_once "../../mkt/conn.php";
$spec = $_GET['spec'];
$person = $_GET['person'];
$stop = $_GET['stop'];
$weight = $_GET['weight'];
$speed = $_GET['speed'];
$m1 = $_GET['m1'];
$method = $_GET['method'];
$cycle = $_GET['cycle'];
if($spec == "MAE100"){
$elevator_type = "A";
}elseif($spec == "MAF100"){
$elevator_type = "B";
}elseif($spec == "MAM200"){
$elevator_type = "D";
}elseif($spec == "MAH100"){
$elevator_type = "E";
}
$sql_str = "SELECT * FROM maintain_standard_option WHERE elevator_type=:elevator_type AND min_speed = :min_speed AND min_persons <= :person AND max_persons >= :person AND is_m1_bundle=:m1 ORDER bY id DESC";
$spec = $_GET['spec'] ?? '';
$person = $_GET['person'] ?? '';
$stop = $_GET['stop'] ?? '';
$weight = $_GET['weight'] ?? '';
$speed = $_GET['speed'] ?? '';
$m1 = $_GET['m1'] ?? '';
$method = $_GET['method'] ?? '';
$cycle = $_GET['cycle'] ?? '';
$elevator_type = match($spec){
"MAE100" => "A",
"MAF100" => "B",
"MAM200" => "D",
"MAH100" => "E",
};
$sql_str = "SELECT * FROM maintain_standard_option
WHERE elevator_type=:elevator_type AND min_speed<=:speed AND max_speed>=:speed AND min_persons <= :person AND max_persons >= :person AND is_m1_bundle=:m1
ORDER bY id DESC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type);
$stmt->bindParam(':min_speed', $speed);
$stmt->bindParam(':person', $person);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':m1', $m1);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);

15
wms/cont/api/getUsername.php

@ -0,0 +1,15 @@
<?php
require_once('../../mkt/conn.php');
$accountid = $_GET['user_id'];
if($accountid == "---"){
echo "---";
exit;
}
$sql_str = "SELECT name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $accountid);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
echo $user['name'];

484
wms/cont/api/postElevatorPricereview.php

@ -0,0 +1,484 @@
<?php
require_once "../../mkt/conn.php";
date_default_timezone_set('Asia/Taipei');
$vol_no = $_POST['vol_no'];
$apply_key = $_POST['apply_key'];
$customer = $_POST['customer'];
$address = $_POST['address'];
$case_name = $_POST['case_name'];
$brand = $_POST['brand'];
$num = $_POST['num'];
$salesman = $_POST['salesman'];
$contract_begin_date = $_POST['contract_begin_date'];
$contract_end_date = $_POST['contract_end_date'];
$contract_kind = $_POST['contract_kind'];
$progress_remark = $_POST['progress_status'];
$serviceFee = $_POST['serviceFee'];
$penalty = $_POST['penalty'];
$deposit_rate = $_POST['deposit_rate'];
$keep_rate = $_POST['keep_rate'];
$warranty_rate = $_POST['warranty_rate'];
$remark = $_POST['remark'];
$creater = $_POST['creater'];
$pay_method = $_POST['pay_method'];
$status = $_POST['status'];
$elevators = json_decode($_POST['elevators'], true);
$otherOptions = json_decode($_POST['otherOptions'], true);
$payment_kind = $_POST['pay_method'];
$current_date = date("Y-M-d H:i:s");
$total_price = $_POST['total_price'];
$total_sale_price = $_POST['total_sale_price'];
$sql_str = "SELECT status FROM con_maintance_examine_apply WHERE (vol_no, apply_key) = (:vol_no, :apply_key) ";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
$conn->beginTransaction();
try{
if(!$contract){
$sql_str = "INSERT INTO con_maintance_examine_apply (apply_key, vol_no, customer, address, case_name ,brand, num, salesman, maintain_kind, contract_begin_date, contract_end_date, contract_kind, payment_kind, progress_remark, service_fee, total_price, total_sale_price, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, creater, create_at)
VALUES (:apply_key, :vol_no, :customer, :address, :case_name ,:brand, :num, :salesman, :maintain_kind, :contract_begin_date, :contract_end_date, :contract_kind, :payment_kind, :progress_remark, :service_fee, :total_price, :total_sale_price, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->bindParam(':customer', $customer);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':brand', $brand);
$stmt->bindParam(':num', $num);
$stmt->bindParam(':salesman', $salesman);
$stmt->bindParam(':maintain_kind', $maintain_kind);
$stmt->bindParam(':contract_begin_date', $contract_begin_date);
$stmt->bindParam(':contract_end_date', $contract_end_date);
$stmt->bindParam(':contract_kind', $contract_kind);
$stmt->bindParam(':payment_kind', $payment_kind);
$stmt->bindParam(':progress_remark', $progress_remark);
$stmt->bindParam(':service_fee', $serviceFee);
$stmt->bindParam(':total_price', $total_price);
$stmt->bindParam(':total_sale_price', $total_sale_price);
$stmt->bindParam(':penalty', $penalty);
$stmt->bindParam(':deposit_rate', $deposit_rate);
$stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':memo', $remark);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $current_date);
$stmt->execute();
$sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, item_no, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain_months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at)
VALUES (:apply_key, :item_no, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain_months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) ";
foreach($elevators as $elevator){
if(empty($elevator['permitNumber'])) $register_code = "A";
if($elevator['spec'] == "MAE100") $elevator_kind = "A";
if($elevator['spec'] == "MAF100") $elevator_kind = "B";
if($elevator['spec'] == "MAM200") $elevator_kind = "D";
if($elevator['spec'] == "MAH100") $elevator_kind = "E";
$speed_governors_check_expense = null;
$maintain_times = 1;
$commission_expense = null;
$management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $elevator['id']);
$stmt->bindParam(':register_code', $register_code);
$stmt->bindParam(':elevator_brand', $elevator['brand']);
$stmt->bindParam(':elevator_kind', $elevator_kind);
$stmt->bindParam(':spec', $elevator['spec']);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':stop', $elevator['stop']);
$stmt->bindParam(':floors', $elevator['stop']);
$stmt->bindParam(':persons', $elevator['person']);
$stmt->bindParam(':elevator_num', $elevator['qty']);
$stmt->bindParam(':useful_years', $elevator['checkYear']);
$stmt->bindParam(':last_check_date', $elevator['lastDate']);
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']);
$stmt->bindParam(':sold_price', $elevator['sale_price']);
$stmt->bindParam(':commission_expense', $elevator['commission_expense']);
$stmt->bindParam(':management_expense', $elevator['management_expense']);
$stmt->bindParam(':annual_survey_expense', $elevator['yearCheckFee']);
$stmt->bindParam(':service_expense', $elevator['service_expense']);
$stmt->bindParam(':cmstatus', $cmstatus);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':created_at', $current_date);
$stmt->execute();
}
$sql_str = "INSERT INTO pricereview_maintain_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)";
foreach($otherOptions as $option){
$item_price_bp = $option['price']*$option['num'];
$option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$item_group = "E";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $option['price']);
$stmt->bindParam(':item_qty', $option['num']);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':memo', $option['memo']);
$stmt->execute();
}
}else{
$sql_str = "UPDATE con_maintance_examine_apply SET
case_name=:case_name,
num=:num,
maintain_kind=:maintain_kind,
contract_kind=:contract_kind,
payment_kind=:payment_kind,
contract_begin_date=:contract_begin_date,
contract_end_date=:contract_end_date,
service_fee=:service_fee,
total_price=:total_price,
total_sale_price=:total_sale_price,
penalty=:penalty,
deposit_rate=:deposit_rate,
keep_rate=:keep_rate,
warranty_rate=:warranty_rate,
memo=:memo,
brand=:brand,
status=:status,
updated_at=:updated_at,
progress_remark=:progress_remark
WHERE apply_key=:apply_key AND vol_no=:vol_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':num', $num);
$stmt->bindParam(':maintain_kind', $maintain_kind);
$stmt->bindParam(':contract_begin_date', $contract_begin_date);
$stmt->bindParam(':contract_end_date', $contract_end_date);
$stmt->bindParam(':contract_kind', $contract_kind);
$stmt->bindParam(':payment_kind', $payment_kind);
$stmt->bindParam(':progress_remark', $progress_remark);
$stmt->bindParam(':service_fee', $serviceFee);
$stmt->bindParam(':total_price', $total_price);
$stmt->bindParam(':total_sale_price', $total_sale_price);
$stmt->bindParam(':penalty', $penalty);
$stmt->bindParam(':deposit_rate', $deposit_rate);
$stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':memo', $remark);
$stmt->bindParam(':brand', $brand);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':updated_at', $current_date);
$stmt->execute();
//整機單價
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE (apply_key, cmstatus) = (:apply_key, 'Y')";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$oldElevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldItemsNo = (array)array_column($oldElevators, 'item_no');
$newItemsNo = (array)array_column($elevators, 'id');
$onlyInOldIds = array_values(array_diff($oldItemsNo, $newItemsNo)); // 只有舊的有,新傳入的沒有,所以刪除(delete)
$onlyInNewIds = array_values(array_diff($newItemsNo, $oldItemsNo)); //只有新傳入的有,舊的沒有,所以新增(insert)
$inBothIds = array_values(array_intersect($oldItemsNo, $newItemsNo)); //舊的跟新的都有,所以要更新(update)
foreach($onlyInOldIds as $oldIdx){
// $sql_str = "DELETE FROM con_maintance_examine_clear WHERE apply_key=:apply_key AND item_no=:item_no";
$sql_str = "UPDATE con_maintance_examine_clear SET cmstatus = 'D' WHERE apply_key=:apply_key AND item_no=:item_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $oldIdx);
$stmt->execute();
}
foreach($onlyInNewIds as $newidx){
$sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, item_no, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain_months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at)
VALUES (:apply_key, :item_no, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain_months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) ";
$elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $newidx))[0];
$register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber'];
if($elevator['spec'] == "MAE100") $elevator_kind = "A";
if($elevator['spec'] == "MAF100") $elevator_kind = "B";
if($elevator['spec'] == "MAM200") $elevator_kind = "D";
if($elevator['spec'] == "MAH100") $elevator_kind = "E";
$speed_governors_check_expense = null;
$maintain_times = 1;
$commission_expense = null;
$management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $elevator['id']);
$stmt->bindParam(':register_code', $register_code);
$stmt->bindParam(':elevator_brand', $elevator['brand']);
$stmt->bindParam(':elevator_kind', $elevator_kind);
$stmt->bindParam(':spec', $elevator['spec']);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':stop', $elevator['stop']);
$stmt->bindParam(':floors', $elevator['stop']);
$stmt->bindParam(':persons', $elevator['person']);
$stmt->bindParam(':elevator_num', $elevator['qty']);
$stmt->bindParam(':useful_years', $elevator['checkYear']);
$stmt->bindParam(':last_check_date', $elevator['lastDate']);
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']);
$stmt->bindParam(':sold_price', $elevator['sale_price']);
$stmt->bindParam(':commission_expense', $elevator['commission_expense']);
$stmt->bindParam(':management_expense', $elevator['management_expense']);
$stmt->bindParam(':annual_survey_expense', $elevator['yearCheckFee']);
$stmt->bindParam(':service_expense', $elevator['service_expense']);
$stmt->bindParam(':cmstatus', $cmstatus);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':created_at', $current_date);
$stmt->execute();
}
foreach($inBothIds as $bothidx){
$sql_str = "UPDATE con_maintance_examine_clear SET
register_code=:register_code,
elevator_brand=:elevator_brand,
elevator_kind=:elevator_kind,
spec=:spec,
weight=:weight,
speed=:speed,
stop=:stop,
floors=:floors,
persons=:persons,
elevator_num=:elevator_num,
useful_years=:useful_years,
last_check_date=:last_check_date,
speed_governors_check_expense=:speed_governors_check_expense,
maintain_times=:maintain_times,
is_m1_bundle=:is_m1_bundle,
maintain_months=:maintain_months,
maintain_period=:maintain_period,
maintain_method=:maintain_method,
stand_price=:stand_price,
contract_price=:contract_price,
sold_price=:sold_price,
commission_expense=:commission_expense,
management_expense=:management_expense,
annual_survey_expense=:annual_survey_expense,
service_expense=:service_expense,
cmstatus=:cmstatus,
updated_at=:updated_at
WHERE (apply_key, item_no) = (:apply_key, :item_no)";
$elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $bothidx))[0];
$register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber'];
if($elevator['spec'] == "MAE100") $elevator_kind = "A";
if($elevator['spec'] == "MAF100") $elevator_kind = "B";
if($elevator['spec'] == "MAM200") $elevator_kind = "D";
if($elevator['spec'] == "MAH100") $elevator_kind = "E";
$speed_governors_check_expense = null;
$maintain_times = 1;
$commission_expense = null;
$management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':register_code', $register_code);
$stmt->bindParam(':elevator_brand', $elevator['brand']);
$stmt->bindParam(':elevator_kind', $elevator_kind);
$stmt->bindParam(':spec', $elevator['spec']);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':stop', $elevator['stop']);
$stmt->bindParam(':floors', $elevator['stop']);
$stmt->bindParam(':persons', $elevator['person']);
$stmt->bindParam(':elevator_num', $elevator['qty']);
$stmt->bindParam(':useful_years', $elevator['checkYear']);
$stmt->bindParam(':last_check_date', $elevator['lastDate']);
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']);
$stmt->bindParam(':sold_price', $elevator['sale_price']);
$stmt->bindParam(':commission_expense', $elevator['commission_expense']);
$stmt->bindParam(':management_expense', $elevator['management_expense']);
$stmt->bindParam(':annual_survey_expense', $elevator['yearCheckFee']);
$stmt->bindParam(':service_expense', $elevator['service_expense']);
$stmt->bindParam(':cmstatus', $cmstatus);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':item_no', $bothidx);
$stmt->execute();
}
//除外項目
$sql_str = "SELECT * FROM pricereview_maintain_item WHERE (mid, item_group) = (:apply_key, 'E')";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$item_other_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldOtherOptionsNo = (array)array_column($item_other_options, 'item_no');
$newOtherOptioinNo = (array)array_column($otherOptions, 'id');
$onlyInOtherOptionOldIds = array_values(array_diff($oldOtherOptionsNo, $newOtherOptioinNo));
$onlyInOtherOptionNewIds = array_values(array_diff($newOtherOptioinNo, $oldOtherOptionsNo));
$inBothOtherOptionIds = array_values(array_intersect($oldOtherOptionsNo, $newOtherOptioinNo));
foreach($onlyInOtherOptionOldIds as $oldotheroptionidx){
$sql_str = "DELETE FROM pricereview_maintain_item WHERE (mid, item_no, item_group) = (:apply_key, :item_no, 'E')";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $oldotheroptionidx);
$stmt->execute();
}
foreach($onlyInOtherOptionNewIds as $newotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $newotheroptionidx))[0];
$sql_str = "INSERT INTO pricereview_maintain_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)";
$item_price_bp = $option['price']*$option['num'];
$option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$item_group = "E";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $option['price']);
$stmt->bindParam(':item_qty', $option['num']);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':memo', $option['memo']);
$stmt->execute();
}
foreach($inBothOtherOptionIds as $bothotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $bothotheroptionidx))[0];
$sql_str = "UPDATE pricereview_maintain_item SET item_spec=:item_spec, price_id=:price_id, option_relate_spec=:option_relate_spec, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, memo = :memo
WHERE (mid, item_no, item_group) = (:apply_key, :item_no, :item_group)";
$item_group = "E";
$item_price_bp = $option['price']*$option['num'];
$option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $option['price']);
$stmt->bindParam(':item_qty', $option['num']);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':memo', $option['memo']);
$stmt->execute();
}
}
if($status == "YS"){
$sql_str = "SELECT * FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $creater);
$stmt->execute();
$account = $stmt->fetch(PDO::FETCH_ASSOC);
$manager = $account['manager'];
$sign1 = $manager . ",,";
$sign2 = "M0012,,";
$sign3 = "M0008,,";
$sign_total = 3;
//服務費大於0 或是 價率低於0.8送至總經理(M0006)
if(false && ($serviceFee > 0 || ($total_sale_price / $total_price) < 0.8)){
$sign4 = "M0006,,";
$sign_total = 4;
}
$sql_str = "INSERT INTO pricereview_maintain_sign (mid, sign1, sign1_note, sign2, sign2_note, sign3, sign3_note, sign4, sign4_note, sign_total, created_at, created_by)
VALUES (:mid, :sign1, :sign1_note, :sign2, :sign2_note, :sign3, :sign3_note, :sign4, :sign4_note, :sign_total, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':sign1', $sign1);
$stmt->bindParam(':sign1_note', $sign1_note);
$stmt->bindParam(':sign2', $sign2);
$stmt->bindParam(':sign2_note', $sign2_note);
$stmt->bindParam(':sign3', $sign3);
$stmt->bindParam(':sign3_note', $sign3_note);
$stmt->bindParam(':sign4', $sign4);
$stmt->bindParam(':sign4_note', $sign4_note);
$stmt->bindParam(':sign_total', $sign_total);
$stmt->bindParam(':created_at', $current_date);
$stmt->bindParam(':created_by', $creater);
$stmt->execute();
include_once "./postFlow.php";
$form_key = null;
$createFlow = createFlow($apply_key, $manager, "A", "保養", $form_key);
include_once "./postSystemNotice.php";
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE apply_key = :apply_key ORDER BY create_at DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
$kind = 1;
$related_id = $apply_key;
$title = "保養價審待簽通知(".$vol_no."," .$customer. ")";
$content = "待簽核";
$content = "合約號:".$vol_no . "<br>";
$content .= "客戶名稱:" . $customer . "<br>";
$content .= "案件名稱:" . $case_name . "<br>";
$content .= "時間" . $current_date;
// $content .= "<a href='./mkt/pricreviewCheck.php?id=".$mid.">前往查看</a>";
$havaread = null;
$permissions = [$manager];
$creater = "system";
$create_at = $current_date;
$url = "cont/pricereviewCheck.php?id=" . $apply_key;
sendSystemNotice($kind, $related_id, $title, $content, $havaread, $permissions, $creater, $create_at, $url);
}
echo "success";
$conn->commit();
} catch (PDOException $e) {
$conn->rollBack();
echo $e->getMessage();
}

58
wms/cont/api/postFlow.php

@ -0,0 +1,58 @@
<?php
require_once("../../mkt/conn.php");
function createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key=null){
global $conn;
$form_id = $mid;
$seq = 0;
$system_id = "prm";
if($ekind == "新梯") $flow_id = "prm01";
if($ekind == "汰改") $flow_id = "prm02";
if($ekind == "保養") $flow_id = "prm03";
if($form_key == null){
$sql_str = "SELECT appwms.nextval('form_key') form_key";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$form_key = $result['form_key'];
$seq = 0;
$sql_str = "INSERT INTO flow (system_id, flow_id, form_id, form_key, flow_code)
VALUES (:system_id, :flow_id, :form_id, :form_key, :flow_code)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':system_id', $system_id);
$stmt->bindParam(':flow_id', $flow_id);
$stmt->bindParam(':form_id', $form_id);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':flow_code', $flow_code);
$stmt->execute();
}else{
$sql_str = "UPDATE flow SET flow_code = :flow_code WHERE form_key = :form_key";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':flow_code', $flow_code);
$stmt->execute();
$sql_str = "SELECT MAX(seq) AS max_seq FROM subflow WHERE form_key = :form_key";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$seq = $result['max_seq'];
$seq ++;
}
$created_at = date("Y-m-d H:i:s");
$sql_str = "INSERT INTO subflow (form_key, seq, current_assigner, update_date,create_date)
VALUES (:form_key, :seq, :current_assigner, :update_date,:create_date)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':seq', $seq);
$stmt->bindParam(':current_assigner', $current_assigner);
$stmt->bindParam(':update_date', $created_at);
$stmt->bindParam(':create_date', $created_at);
$stmt->execute();
return $form_key;
}

20
wms/cont/api/postSystemNotice.php

@ -0,0 +1,20 @@
<?php
require_once("../../mkt/conn.php");
function sendSystemNotice($kind, $related_id, $title, $content, $haveread, $permissions, $creater, $create_at, $url){
global $conn;
$sql_str = "INSERT INTO notice (kind, related_id, title, content, haveread, permission, url, creater, create_at)
VALUES (:kind, :related_id, :title, :content, :haveread, :permission, :url,:creater, :create_at)";
foreach($permissions as $permission){
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':kind', $kind);
$stmt->bindParam(':related_id', $related_id);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':content', $content);
$stmt->bindParam(':haveread', $haveread);
$stmt->bindParam(':permission', $permission);
$stmt->bindParam(':url', $url);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
}
}

113
wms/cont/js/pricereviewAlpine.js

@ -1,7 +1,6 @@
const pricereviewCreate = ()=>{
return {
init(){
console.log(123);
},
modalShow:{
elevator: false,
@ -17,13 +16,14 @@ const pricereviewCreate = ()=>{
pre_order_date:pre_order_date,
address:address,
progress_status:progress_status,
total_spec:0,
elevators:[],
case_name:'', //案件名稱
contract_status:'', // 契約性質
pay_method:'', // 付款方式
startDate:'', //合約開始日期
endDate:'', // 合約結束日期
total_spec:total_spec,
elevators: hope_elevators,
case_name:case_name, //案件名稱
contract_status:contract_kind, // 契約性質
pay_method:payment_kind, // 付款方式
startDate:contract_begin_date, //合約開始日期
endDate:contract_end_date, // 合約結束日期
brand:brand,
modalElevatorInfo:{
spec:'',
person:'',
@ -33,7 +33,7 @@ const pricereviewCreate = ()=>{
permitNumber:'', //許可證號碼
brand:'', //品牌
m1:'N', //贈送M1
months:'', // 保養月數
months:12, // 保養月數
cycle:'', // 保養週期
method:'', //保養方式
checkYear:'', //竣工檢查年度
@ -43,23 +43,24 @@ const pricereviewCreate = ()=>{
qty:1, //電梯數量
sale_price:'', //契約報價
},
otherOptions: [],
otherOptions: otherOptions,
modalOtherOptionInfo:{
pr_no:"",
name:"",
price: 0,
num:"",
memo:"",
},
otherOptionKey:0,
otherOptionKey: otherOptionKey,
currentOtherOptionKey:'',
toElevators:[],
toElevatorNo:'',
serviceFee:0,
remark:'',
penalty:'',
deposit_rate:'',
keep_rate:'',
warranty_rate:'',
serviceFee: service_fee,
remark:memo,
penalty: penalty,
deposit_rate: deposit_rate,
keep_rate: keep_rate,
warranty_rate: warranty_rate,
openCreateElevatorModal(){
this.modalShow.elevator = true;
body.style.overflow = 'hidden';
@ -76,7 +77,7 @@ const pricereviewCreate = ()=>{
permitNumber:'', //許可證號碼
brand:'', //品牌
m1:'N', //贈送M1
months:'', // 保養月數
months:12, // 保養月數
cycle:'', // 保養週期
method:'', //保養方式
checkYear:'', //竣工檢查年度
@ -140,7 +141,6 @@ const pricereviewCreate = ()=>{
const price = this.elevators[idx].price;
const qty = this.elevators[idx].qty;
const sale_price = this.elevators[idx].sale_price;
this.total_spec ++;
this.elevators.push({
id: this.total_spec,
@ -166,6 +166,15 @@ const pricereviewCreate = ()=>{
removeElevator(id){
if(!confirm('確定刪除該電梯?')) return;
this.elevators = this.elevators.filter(elevator=> elevator.id != id)
const issetElevators = [];
this.elevators.forEach(elevator=>{
issetElevators.push(elevator.id);
})
this.otherOptions.forEach(option=>{
option.toElevator = option.toElevator.filter(el=>{
return issetElevators.includes(el.id)
})
})
},
openCreateOtherOptionFn(){
this.modalShow.other = true
@ -179,6 +188,7 @@ const pricereviewCreate = ()=>{
name: this.modalOtherOptionInfo.name,
price: this.modalOtherOptionInfo.price,
num: this.modalOtherOptionInfo.num,
memo: this.modalOtherOptionInfo.memo,
toElevator:[],
})
this.modalOtherOptionInfo = {
@ -186,6 +196,7 @@ const pricereviewCreate = ()=>{
name: '',
price: 0,
num: '',
memo: '',
}
this.hideCreateOtherOptionModal();
},
@ -295,11 +306,29 @@ const pricereviewCreate = ()=>{
console.error("Error message:", error);
}
},
async getElevatorPrice(idx){
const spec = this.elevators[idx].spec
const person = this.elevators[idx].person
const stop = this.elevators[idx].stop
const weight = this.elevators[idx].weight
const speed = this.elevators[idx].speed
const m1 = this.elevators[idx].m1
const method = this.elevators[idx].method
const cycle = this.elevators[idx].cycle
try{
const res = await axios.get('./api/getElevatorPrice.php', {params: {spec: spec, person:person, weight: weight, stop: stop, speed: speed, m1: m1, method: method, cycle:cycle}})
this.elevators[idx].price = res.data;
console.log(res.data);
}catch (error) {
console.error("Error message:", error);
}
},
save(){
const form = new FormData();
form.append('vol_no', this.vol_no);
form.append('apply_key', this.apply_key);
form.append('customer', this.customer);
form.append('brand', this.brand);
form.append('address', this.address);
form.append('case_name', this.case_name);
form.append('brand', this.brand);
@ -315,10 +344,12 @@ const pricereviewCreate = ()=>{
form.append('keep_rate', this.keep_rate);
form.append('warranty_rate', this.warranty_rate);
form.append('remark', this.remark);
form.append('creater', this.user_id);
form.append('creater', user_id);
form.append('pay_method', this.pay_method);
form.append('status', 'Y1');
form.append('total_price', this.totalPrice);
form.append('total_sale_price', this.totalSalePrice);
form.append('elevators', JSON.stringify(this.elevators));
form.append('otherOptions', JSON.stringify(this.otherOptions));
@ -332,7 +363,49 @@ const pricereviewCreate = ()=>{
})
},
submit(){
const form = new FormData();
form.append('vol_no', this.vol_no);
form.append('apply_key', this.apply_key);
form.append('customer', this.customer);
form.append('brand', this.brand);
form.append('address', this.address);
form.append('case_name', this.case_name);
form.append('brand', this.brand);
form.append('num', this.totalElevatorsNum);
form.append('salesman', this.salesman);
form.append('contract_begin_date', this.startDate);
form.append('contract_end_date', this.endDate);
form.append('contract_kind', this.contract_status);
form.append('progress_status', this.progress_status);
form.append('serviceFee', this.serviceFee);
form.append('penalty', this.penalty);
form.append('deposit_rate', this.deposit_rate);
form.append('keep_rate', this.keep_rate);
form.append('warranty_rate', this.warranty_rate);
form.append('remark', this.remark);
form.append('creater', user_id);
form.append('pay_method', this.pay_method);
form.append('status', 'YS');
form.append('total_price', this.totalPrice);
form.append('total_sale_price', this.totalSalePrice);
form.append('elevators', JSON.stringify(this.elevators));
form.append('otherOptions', JSON.stringify(this.otherOptions));
axios.post('./api/postElevatorPricereview.php', form).then(res=>{
console.log(res.data);
if(res.data == 'success'){
alert("送審成功!");
// window.location.reload();
// window.location.href = './pricereview-index.php?' + token;
}
})
},
async getUsername(user_id){
if(user_id == '') return '---'
const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}})
return res.data ;
},
}
}

153
wms/cont/pricereviewCreate.php

@ -13,8 +13,90 @@ $stmt->bindParam(':vol_no', $vol_no);
$stmt->execute();
$hope_customer = $stmt->fetch(PDO::FETCH_ASSOC);
$apply_key = getApplyKey(date('ym'), 'cmea_apply_key');
echo $apply_key;
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute();
$apply = $stmt->fetch(PDO::FETCH_ASSOC);
if($apply['status'] == 'D'){
echo "<script>alert('非法訪問');window.history.go(-1);</script>";
}
if($apply['status'] == 'YS'){
echo "<script>alert('此單正在審核中!');window.history.go(-1);</script>";
}
if($apply['status'] == 'YY' || $apply['status'] == 'YN'){
echo "<script>alert('此單已申請過!');window.history.go(-1);</script>";
}
$apply_key = $apply ? $apply['apply_key'] : getApplyKey(date('ym'), 'cmea_apply_key');
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key ORDER BY created_at ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$hope_elevators = [];
$total_spec = 0;
foreach($elevators as $elevator){
if($elevator['item_no'] > $total_spec){
$total_spec = $elevator['item_no'];
}
if($elevator['cmstatus'] == 'D') continue;
$hope_elevators[] = [
'id'=> $elevator['item_no'],
'spec'=> $elevator['spec'],
'person'=> $elevator['persons'],
'weight'=> $elevator['weight'],
'stop'=> $elevator['stop'],
'speed'=> $elevator['speed'],
'permitNumber'=> $elevator['register_code'],
'brand'=> $elevator['elevator_brand'],
'm1'=> $elevator['is_m1_bundle'],
'months'=> $elevator['maintain_months'],
'cycle'=> $elevator['maintain_period'],
'method'=> $elevator['maintain_method'],
'checkYear'=> $elevator['useful_years'],
'lastDate'=> $elevator['last_check_date'],
'yearCheckFee'=> $elevator['annual_survey_expense'],
'price'=> $elevator['stand_price'],
'qty'=> $elevator['elevator_num'],
'sale_price'=> $elevator['contract_price'],
];
}
$sql_str = "SELECT * FROM pricereview_maintain_item WHERE (mid, item_group) = (:apply_key, 'E') ORDER BY id ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$otherOptions = [];
$otherOptionKey = 0;
foreach($items as $item){
if($item['item_no'] > $otherOptionKey){
$otherOptionKey = (int)$item['item_no'];
}
if($item['option_relate_spec']!= 0 ){
}
$toElevator = $item['option_relate_spec']==0 ? [] : [[
'id'=>$item['option_relate_spec'],
'model'=> array_values(array_filter($hope_elevators, fn($val)=> $val['id'] == $item['option_relate_spec']))[0]['spec'],
]];
$otherOptions[] = [
'id'=> $item['item_no'],
'pr_no'=> $item['price_id'],
'name'=> $item['item_spec'],
'price' => $item['item_unit_price'],
'num'=> $item['item_qty'],
'memo'=> $item['memo'],
'toElevator'=>$toElevator,
];
}
function getApplyKey($p_yyyymm, $seq_name){
if (empty($p_yyyymm) || empty($seq_name)) return null;
global $conn;
@ -78,11 +160,11 @@ function getApplyKey($p_yyyymm, $seq_name){
</tr>
<tr>
<th>電梯品牌</th>
<td><input class="form-control" type="text" disabled value="<?php echo $hope_customer['brand']; ?>" /></td>
<td><input class="form-control" type="text" disabled x-model="brand" /></td>
<th>電梯數量</th>
<td><input class="form-control" type="number" disabled value="<?php echo $hope_customer['num']; ?>" /></td>
<th>營業員</th>
<td><input class="form-control" type="text" disabled value="<?php echo $hope_customer['salesman_name']; ?>" /></td>
<td><input class="form-control" type="text" disabled :value="getUsername('<?php echo $hope_customer['salesman']; ?>')" /></td>
<th>當前契約期限結束</th>
<td><input class="form-control" type="date" disabled value="" /></td>
@ -106,6 +188,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<option value="2">免保轉有費</option>
<option value="3">續約</option>
</select>
<span class="errortext" x-cloak data-type="errortext" x-show="contract_status == ''">請選擇契約性質</span>
</td>
<th>付款方式</th>
<td>
@ -117,13 +200,23 @@ function getApplyKey($p_yyyymm, $seq_name){
<option value="A40005">半年繳</option>
<option value="A40006">年繳</option>
</select>
<span class="errortext" x-cloak data-type="errortext" x-show="pay_method == ''">請選擇付款方式</span>
</td>
<th>案件名稱</th>
<td><input class="form-control" type="text" x-model="case_name" /></td>
<td>
<input class="form-control" type="text" x-model="case_name" />
<span class="errortext" x-cloak data-type="errortext" x-show="!case_name">請填寫案件名稱</span>
</td>
<th>合約開始日期</th>
<td><input type="date" class="form-control" x-model="startDate" /></td>
<td>
<input type="date" class="form-control" x-model="startDate" />
<span class="errortext" x-cloak data-type="errortext" x-show="!startDate || startDate == '0000-00-00'">請填寫合約開始日期</span>
</td>
<th>合約結束日期</th>
<td><input type="date" class="form-control" x-model="endDate" /></td>
<td>
<input type="date" class="form-control" x-model="endDate" />
<span class="errortext" x-cloak data-type="errortext" x-show="!endDate || endDate == '0000-00-00'">請填寫合約結束日期</span>
</td>
</tr>
</tbody>
</table>
@ -136,7 +229,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<tbody>
<tr>
<td colspan=8>
<textarea class="form-control" name="progress" id="progress" cols="20" rows="5" disabled ><?php echo nl2br($hope_customer['progress_status']); ?></textarea>
<textarea class="form-control" name="progress" id="progress" cols="20" rows="5" disabled x-html="progress_status"></textarea>
</td>
</tr>
</tbody>
@ -179,28 +272,26 @@ function getApplyKey($p_yyyymm, $seq_name){
<tr>
<th >電梯</th>
<td>
<select class="form-control" x-model="elevator.spec">
<select class="form-control" x-model="elevator.spec" @change="getElevatorPrice(idx)">
<option value="">請選擇</option>
<option value="MAE100">MAE100有機房</option>
<option value="MAM200">MAM200無機房</option>
<option value="MAH100">MAH100小電梯</option>
<option value="MAF100">MAF100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option>
</select>
</td>
<th>載重(KG)</th>
<td>
<input type="number" class="form-control" x-model="elevator.weight" />
<input type="number" class="form-control" x-model="elevator.weight" @change="getElevatorPrice(idx)" @keyup="getElevatorPrice(idx)" />
</td>
<th>停數</th>
<td>
<input type="number" class="form-control" x-model="elevator.stop" />
<input type="number" class="form-control" x-model="elevator.stop" @keyup="getElevatorPrice(idx)" />
</td>
<th>速度(m/min)</th>
<td>
<select name="" id="" class="form-control" style="width:93px" x-model="elevator.speed" @change="getElevatorPrice()" >
<select name="" id="" class="form-control" style="width:93px" x-model="elevator.speed" @change="getElevatorPrice(idx)" >
<option value="">請選擇</option>
<option value="9">9</option>
<option value="24">24</option>
@ -215,7 +306,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td>
<th>人乘</th>
<td>
<select class="form-control" x-model="elevator.person">
<select class="form-control" x-model="elevator.person" @change="getElevatorPrice(idx)">
<option value="">請選擇</option>
<option value="6">6</option>
<option value="8">8</option>
@ -296,7 +387,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td>
<th>保養方式</th>
<td>
<select class="form-control" x-model="elevator.method">
<select class="form-control" x-model="elevator.method" @change="getElevatorPrice(idx)">
<option value="">請選擇</option>
<option value="A">全包</option>
<option value="B">半包</option>
@ -305,7 +396,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td>
<th>贈送M1</th>
<td>
<select class="form-control" x-model="elevator.m1">
<select class="form-control" x-model="elevator.m1" @change="getElevatorPrice(idx)">
<option value="N"></option>
<option value="Y"></option>
</select>
@ -315,6 +406,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<th>公司發布價(月)</th>
<td>
<input type="text" class="form-control" disabled x-model="elevator.price.toLocaleString()" />
<span class="errortext" x-show="elevator.price <= 0">公司無提供此規格牌價</span>
</td>
<th>保養月數</th>
<td>
@ -350,6 +442,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<td>單價</td>
<td>數量</td>
<td>複價</td>
<td>備註</td>
<td style="width:160px">所屬電梯</td>
<td style="width:220px">功能</td>
</tr>
@ -364,10 +457,11 @@ function getApplyKey($p_yyyymm, $seq_name){
</td>
<td><input type="text" class="form-control" x-model="option.price"></td>
<td>
<input type="number" class="form-control" x-model="option.num">
<input type="number" class="form-control" x-model="option.num" style="width:100px">
<span x-show="!option.num || option.num <= 0 || !Number.isInteger(Number(option.num))" class="errortext" x-cloak data-type="errortext">請輸入正整數</span>
</td>
<td><input type="text" class="form-control" x-model="(option.price * option.num).toLocaleString()" disabled></td>
<td><input type="text" class="form-control" x-model="option.memo" style="min-width:220px" /></td>
<td>
<template x-for="el in option.toElevator">
<p x-html="'<b>' + el.id + '</b>、' + el.model"></p>
@ -385,7 +479,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</template>
<tr x-show="otherOptions.length > 0">
<td colspan=3>小計</td>
<td colspan=1 ><input type="number" class="form-control" disabled :value="totalOtherOptionsNum.toLocaleString()" ></td>
<td colspan=1 ><input type="text" class="form-control" disabled :value="totalOtherOptionsNum.toLocaleString()" style="width:100px" /></td>
<td colspan=1 ><input type="text" class="form-control" disabled :value="totalOtherOptionsPrice.toLocaleString()" ></td>
<td colspan=3 ></td>
</tr>
@ -481,5 +575,26 @@ function getApplyKey($p_yyyymm, $seq_name){
const progress_status = '<?php echo $hope_customer['progress_status']; ?>';
const user_id = '<?php echo $user_id ?>';
const user_name = '<?php echo $user_name ?>';
const progress_remark = `<?php echo nl2br($hope_customer['progress_status']); ?>`;
const memo = `<?php echo nl2br($apply['memo']); ?>`;
const contract_kind = '<?php echo $apply ? $apply['contract_kind'] : '' ?>';
const payment_kind = '<?php echo $apply ? $apply['payment_kind'] : '' ?>';
const case_name = '<?php echo $apply ? $apply['case_name'] : '' ?>';
const contract_begin_date = '<?php echo $apply ? $apply['contract_begin_date'] : '' ?>';
const contract_end_date = '<?php echo $apply ? $apply['contract_end_date'] : '' ?>';
const total_spec = '<?php echo $total_spec; ?>';
const hope_elevators = [...<?php echo json_encode($hope_elevators); ?>];
const otherOptionKey = '<?php echo $otherOptionKey; ?>';
const otherOptions = [...<?php echo json_encode($otherOptions); ?>];
const token = '<?php echo $para = "function_name=pricereview&" . $token_link;; ?>';
const penalty = '<?php echo $apply['penalty']; ?>';
const deposit_rate = '<?php echo $apply['deposit_rate']; ?>';
const keep_rate = '<?php echo $apply['keep_rate']; ?>';
const warranty_rate = '<?php echo $apply['warranty_rate']; ?>';
const service_fee = '<?php echo $apply['service_fee']; ?>';
</script>

2
wms/cont/window-modal/modalElevaotr.php

@ -110,7 +110,7 @@
<th colspan=2>保養方式</th>
</tr>
<tr class="table-active">
<td colspan=2><input type="number" class="form-control" x-model="modalElevatorInfo.permitNumber" /></td>
<td colspan=2><input type="text" class="form-control" x-model="modalElevatorInfo.permitNumber" /></td>
<td colspan=2>
<select class="form-control" x-model="modalElevatorInfo.method" @change="getModalElevatorPrice()">
<option value="">請選擇</option>

4
wms/cont/window-modal/otherOptionModal.php

@ -13,13 +13,15 @@
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>備註</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="modalOtherOptionInfo.pr_no"></td>
<td><input type="text" class="form-control" x-model="modalOtherOptionInfo.name"></td>
<td><input type="number" class="form-control" x-model="modalOtherOptionInfo.price"></td>
<td><input type="number" class="form-control" x-model="modalOtherOptionInfo.num"></td>
<td><input type="number" style="width:80px;" class="form-control" x-model="modalOtherOptionInfo.num"></td>
<td><input type="text" disabled class="form-control" x-model="(modalOtherOptionInfo.price * modalOtherOptionInfo.num).toLocaleString()"></td>
<td><input type="text" class="form-control" x-model="modalOtherOptionInfo.memo"></td>
</tr>
</table>
</div>

10
wms/contract/api/T8api.php

@ -4,15 +4,11 @@ require_once("../../T8_Authorization_from_bpm.php");
function T8salIncomeApply($data, $api_url)
{
// $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth();
echo '<pre>';
print_r($validation);
echo '</pre>';
// exit;
$header = [
"CHI_Authorization :" . $validation,
"GroupId:MASADA"
"GroupId:TEST"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
@ -29,7 +25,7 @@ function T8salIncomeApply($data, $api_url)
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
// echo 'API傳入失敗,' . $result['ErrorMsg'];
return $result;
} else {
// print_r($result);

22
wms/contract/api/getContractData.php

@ -24,10 +24,9 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = COUNT($elevators);
// foreach ($elevators as $key => $elevator) {
// $elevator['discount'] = ($elevator['sold_price'] / $elevator['stand_price']) * 100;
// }
foreach ($elevators as $key => $elevator) {
$elevator['discount'] = round(($elevator['sold_price'] / $elevator['stand_price']), 2);
}
$contract['elevators'] = $elevators;
$contract['num'] = $count;
@ -150,28 +149,13 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont
foreach ($option_results as $key => $option) {
if ($option['item_qty'] == $result['item_qty']) {
$result['option_price'] += intval($option['item_unit_price']);
// echo '1..';
// echo "<pre>";
// print_r($option['item_unit_price']);
// echo "</pre>";
} else if ($option['item_qty'] / $result['item_qty'] != 1) {
$item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數
$result['option_price'] += intval($option['item_unit_price']) * $item_qty;
// echo '2..';
// echo "<pre>";
// print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
// echo "</pre>";
} else {
$result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']);
// echo '3..';
}
// echo '<pre>';
// print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
// echo '</pre>';
}
// print_r($result['option_price']);
// exit();
}
// 查詢保固延長
$sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='E' AND option_relate_spec = :item_no";

48
wms/contract/api/getT8NewContractData.php

@ -3,7 +3,8 @@ require_once('../conn.php');
$sql = "SELECT
BillNo, -- 合約號
OAmount -- 合約未稅金額
OAmount, -- 合約未稅金額
OAmountWithTax -- 含稅金額
FROM salSalesOrder WHERE 1=1";
$stmt = $connT8->prepare($sql);
$stmt->execute();
@ -19,12 +20,39 @@ foreach ($result as $key => $result) {
$no = $result['BillNo'];
$result_master['BillNo'] = $no;
$firstChar = substr($no, 0, 1);
if ($firstChar == 'M' && $key <= 100) {
if ($firstChar == 'M' && $key <= 50) {
// 查詢客戶名稱 是否為戰略客戶
$sql = "SELECT BizPartnerName FROM comBusinessPartner WHERE BizPartnerId = '$no' ";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$customer_name = $stmt->fetch(PDO::FETCH_ASSOC);
// $result_master[] = $result;
// 查詢作番號,與每台電梯在合約的價格、站比
$sql = "SELECT * FROM salSalesOrderDetail WHERE BillNo = '$no' AND ItemType = 0";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$elevator_facilityno = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($elevator_facilityno as $elevator) {
$facilityno = $elevator['MaterialId'];
$sql = "SELECT
BillNo,
MaterialId,
OAmountWithTax, -- 含稅金額
SPrice --未稅
FROM salSalesOrderDetail WHERE BillNo = '$no' AND CU_MaterialId = '$facilityno' AND ItemType = '1' ";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$elevator_amount = $stmt->fetchAll(PDO::FETCH_ASSOC);
// 單台電梯價格
$elevator_price = 0;
foreach ($elevator_amount as $amount) {
$elevator_price = $elevator_price + intval($amount['SPrice']);
}
//電梯在合約內所佔的比例
$elevator_prince_proportion = intval($result['OAmount']) / $elevator_price;
// exit;
$sql = "SELECT
BillNo, -- 合約號
PayStage, -- 收款階段
@ -36,10 +64,12 @@ foreach ($result as $key => $result) {
$Detail = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($Detail)) {
foreach ($Detail as $key => $detail) {
$elevator_inContract_payPrice = $elevator_prince_proportion * $detail['PlanPercentage'];
$Detail[$key]['facilityno'] = $facilityno;
$detail['PlanPercentage'] = (float)$detail['PlanPercentage'];
$Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位
$Detail[$key]['PlanPayAmt'] = intval($detail['PlanPayAmt']); // 比例金額轉整數
$Detail[$key]['contract_price_total'] = intval($detail['PlanPayAmt']); // 比例金額轉整數
$Detail[$key]['elevator_inContract_payPrice'] = round($elevator_inContract_payPrice * intval($detail['PlanPayAmt']), 2);
}
if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') {
@ -51,9 +81,15 @@ foreach ($result as $key => $result) {
}
$result_master['total_price'] = intval($result['OAmount']);
$result_master['detail'] = $Detail;
$result_master['elevotor_pay_detail'] = $Detail;
$result_arr[] = $result_master;
// echo "<pre>";
// print_r($result_arr);
// echo "</pre>";
}
}
// exit;
// $result_master[] = $result;
}
}

373
wms/contract/api/postContractData.php

@ -1,16 +1,17 @@
<meta charset="UTF-8">
<?php
header("Content-Type: text/html; charset=utf-8");
require_once("../conn.php");
// require_once("../connt8.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
include_once("./upload_chk.php");
include_once("../../class/Cmail.php");
ini_set('date.timezone', 'Asia/Taipei');
//保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
try {
$mail = new Cmail();
$created_at = date('Y-m-d H:i:s');
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
@ -19,7 +20,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : '';
// $mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
@ -38,7 +39,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
$contract_type = !empty($_POST['contract_type']) ? $_POST['contract_type'] : null;
$signing_date = !empty($_POST['signing_date']) ? $_POST['signing_date'] : null;
$token = !empty($_POST['token']) ? $_POST['token'] : '';
$maintance_manager = !empty($_POST['maintance_manager']) ? $_POST['maintance_manager'] : '';
$sql = "SELECT * FROM account WHERE accountid = '$salesman'";
$stmt = $conn->prepare($sql);
$stmt->execute();
@ -65,11 +68,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
// echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
echo json_encode($facilityno);
T8insert($_POST, $facilityno, $depId, $connT8);
// exit();
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
@ -77,32 +79,38 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// exit();
// }
$fail_arr = [];
if ($contractno === '') return $fail_arr[] = '合約號為必填';
// if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填';
if ($vat == '') $fail_arr[] = '統一編號為必填';
if ($mtype == '') $fail_arr[] = '維修型態為必填';
if ($phone == '') $fail_arr[] = '客戶電話為必填';
// if ($email == '') $fail_arr[] = 'Email為必填';
if ($mworker == '') $fail_arr[] = '保養員為必填';
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if ($salesman == '') $fail_arr[] = '營業員為必填';
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
if ($address == '') $fail_arr[] = '地址為必填';
if ($area == '') $fail_arr[] = '區域為必填';
if ($customer == '') $fail_arr[] = '客戶為必填';
if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填';
if ($payType == '') $fail_arr[] = '分期方式為必填';
if ($contract_type == '') $fail_arr[] = '合約類別為必填';
if ($maintance_manager == '') $fail_arr[] = '保養經理為必填';
//-------------------
// if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
// if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
// if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
// if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
// if ($vat == '') $fail_arr[] = '統一編號為必填';
// if ($mtype == '') $fail_arr[] = '維修型態為必填';
// if ($phone == '') $fail_arr[] = '客戶電話為必填';
// if ($email == '') $fail_arr[] = 'Email為必填';
// if ($mworker == '') $fail_arr[] = '保養員為必填';
// if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE);
exit();
}
exit();
T8insert($_POST, $facilityno, $depId, $connT8);
exit();
/// 獎金計算
$aaa = bonusCreate($_POST, $facilityno, $conn);
if (!empty($aaa) && $aaa['status'] == 2) {
@ -110,6 +118,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo $aaa['data'];
exit();
}
// exit();
//create account table
$accounttype = "A";
$accountid = $vat;
@ -120,6 +129,10 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
// exit();
$conn->beginTransaction();
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
@ -202,16 +215,17 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// // }
// echo json_encode($facilityno);
// echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid AND accounttype IN ('B','E','M','W')";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $mworker);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
$customerid = $vat;
$define = "B";
$repairtype = $mtype;
$repairerid = $mworker;
$repairername = $worker['name'];
$define = "B";
$repairername = !empty($worker) ? $worker['name'] : '';
foreach ($elevators as $idx => $elevator) {
// 民國年轉換西元年
$ROCuseful_date = $elevator['useful_date'];
@ -247,16 +261,23 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(':licensedate', $ADuseful_date);
$result = $stmt->execute();
}
$sql = "SELECT * FROM account WHERE accountid = '$user_id' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$user_detail = $stmt->fetch(PDO::FETCH_ASSOC);
//create schedule table
//create schedule table
// $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
// $comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($facilityno as $no) {
foreach ($facilityno as $key => $no) {
$comboNo = new CreateComboNo($maintain_times[$elevator['maintain_times']], $contract_begin_date, $contract_end_date);
$comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($comboArr as $combo) {
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
$sql_str = 'INSERT INTO schedule
(contractno, facilityno, combono, repairerid, repairername,customer_login_name, duedate, creater, create_at) VALUES
(:contractno, :facilityno, :combono, :repairerid, :repairername, :customer_login_name,:duedate, :creater, :create_at)';
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':facilityno', $no);
@ -264,10 +285,45 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':duedate', $combo[1]);
$stmt->bindParam(':customer_login_name', $customer);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$result = $stmt->execute();
}
// $regular_contract_manger_id = $elevators[$idx]['regular_contract_manger_id'];
// $sql = "SELECT * FROM account WHERE accountid = '' ";
$sql = "SELECT * FROM account WHERE accountid = '$maintance_manager' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$maintance_manager_detail = $stmt->fetch(PDO::FETCH_ASSOC);
// 寄郵件給 輸入合約助理,請他安排保養計畫
// 北北基 : M0090
// 保養組長 桃竹 : M0223
// 中部 : M0161
// 南部 : M0077
// 保養組長之後調整
$mail_title = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-請安排此作番的保養人員";
$mail_content = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-請安排此作番的保養人員 <a href='https://www.masada.com.tw/wms/schedule-index.php?contractno=$contractno&facilityno=$no&token=$token'>點我</a>";
// exit();
$mail->sendx(
$mail_title,
$mail_content,
[
// [$user_id, $user_detail['email']],
// [$maintance_manager, $maintance_manager_detail['email']],
// ['M0012', 'Yingying@masada.com.tw']
// [$regular_contract_manger_id, $regular_contract_manger_mail['mail']],
['M0225', 'lkmd555@masada.com.tw']
// ['M0012', 'Yingying@masada.com.tw']
],
"永佳捷科技"
);
// echo 'send';
// }
}
// create contract_b_signed_back table
$contract_type = $mtype;
@ -344,8 +400,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
} else {
$files = null;
}
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by,signing_date)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by,:signing_date)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type);
@ -372,15 +428,19 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id);
$stmt->bindParam(':payType', $payType);
$stmt->bindParam(':signing_date', $signing_date);
$stmt->execute();
// T8insert($_POST, $facilityno);
$conn->commit();
header('Content-Type: application/json');
$jsonData = json_encode($files);
$conn->commit();
// Cmail->sendx;
} catch (PDOException $e) {
$conn->rollback();
http_response_code(404);
@ -401,20 +461,22 @@ function T8insert($data, $facilityno, $depId, $connT8)
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱
$phone = !empty($data['phone']) ? $data['phone'] : null; //客戶電話
$vat = !empty($data['vat']) ? $data['vat'] : null; //統編
$email = !empty($data['email']) ? $data['email'] : null;
$salesman = !empty($data['salesman']) ? $data['salesman'] : null; // 銷售人員
$partyA = !empty($data['partyA']) ? $data['partyA'] : null; //客戶名稱 / 業務聯絡人
$partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址
$partyA = !empty($data['customer']) ? $data['customer'] : null; //客戶名稱 / 業務聯絡人
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : null;
$contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null;
$num = !empty($data['num']) ? $data['num'] : null; // 電梯數量
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
$area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$payType = !empty($data['payType']) ? $data['payType'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : '';
$invoice_address = !empty($_POST['invoice_address']) ? $_POST['invoice_address'] : '';
$total_price = !empty($_POST['total_price']) ? intval($_POST['total_price']) : 0;
// $email = !empty($data['email']) ? $data['email'] : null;
// $partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址
// $num = !empty($data['num']) ? $data['num'] : null; // 電梯數量
// $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$connT8->beginTransaction();
// $connT8->beginTransaction();
$sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
$stmt = $connT8->prepare($sql);
@ -436,19 +498,17 @@ function T8insert($data, $facilityno, $depId, $connT8)
// 若 客戶資料為空,新增一筆到 comCustomer
// 新增客戶資料
$sql = "INSERT INTO comBusinessPartner
(BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId)
VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')";
(BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId)
VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:CreatorId,:CreateTime,'10')";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->bindParam(':BizPartnerName', $partyA);
$stmt->bindParam(':WorkTelNo', $phone);
$stmt->bindParam(':TaxNo', $vat);
$stmt->bindParam(':EnterpriseName', $customer); //企業名稱
$stmt->bindParam(':ContactAddress', $partyAaddress);
$stmt->bindParam(':EMail', $email);
$stmt->bindParam(':EnterpriseName', $invoice); //企業名稱 //發票抬頭
$stmt->bindParam(':ContactAddress', $invoice_address);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comCustomer
@ -461,7 +521,6 @@ function T8insert($data, $facilityno, $depId, $connT8)
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':InvoiceAddress', $address);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
} else {
// // 若客戶資料不為空,更新該客戶資訊。
@ -487,7 +546,7 @@ function T8insert($data, $facilityno, $depId, $connT8)
TaxNo=:TaxNo,
EnterpriseName=:EnterpriseName,
ContactAddress=:ContactAddress,
EMail=:EMail,
-- EMail=:EMail,
LastOperatorId=:LastOperatorId,
LastOperateTime=:LastOperateTime
WHERE BizPartnerId = :BizPartnerId
@ -496,9 +555,9 @@ function T8insert($data, $facilityno, $depId, $connT8)
$stmt->bindParam(':BizPartnerName', $partyA);
$stmt->bindParam(':WorkTelNo', $phone);
$stmt->bindParam(':TaxNo', $vat);
$stmt->bindParam(':EnterpriseName', $customer);
$stmt->bindParam(':ContactAddress', $partyAaddress);
$stmt->bindParam(':EMail', $email);
$stmt->bindParam(':EnterpriseName', $invoice);
$stmt->bindParam(':ContactAddress', $invoice_address);
// $stmt->bindParam(':EMail', $email);
$stmt->bindParam(':LastOperatorId', $user_id);
$stmt->bindParam(':LastOperateTime', $createTime);
$stmt->bindParam(':BizPartnerId', $contractno);
@ -539,9 +598,7 @@ function T8insert($data, $facilityno, $depId, $connT8)
$row = 0;
// // 新增電梯數
foreach ($elevators as $index => $elevator) {
// echo '<pre>';
// print_r($elevator);
// echo '</pre>';
$facility_no = $facilityno[$index];
$sql = "INSERT INTO comMaterial
(FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
@ -581,10 +638,13 @@ function T8insert($data, $facilityno, $depId, $connT8)
];
// 幾年
// $SQuantityYear = $elevator['maintain_months'] / 12;
// 單台電梯契約報價
$price_of_month = intval($elevator['sold_price']);
print_r($price_of_month);
exit;
//分幾期 () => 總共保養月 / 分期月
$SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType];
$SQuantity = $IncomeId[$payType];
// $paymonth = $IncomeId[$payType] * $SQuantity;
$date_1 = getNext25thDate($contract_begin_date);
@ -602,7 +662,7 @@ function T8insert($data, $facilityno, $depId, $connT8)
"RowCode" => $row,
"RowNo" => $row,
"ItemType" => 1,
"SPrice" => intval($elevator['sold_price']),
"SPrice" => $price_of_month,
"SQuantity" => $SQuantity,
"ProjectId" => "$contractno",
"FromBillNo" => "$contractno",
@ -612,10 +672,18 @@ function T8insert($data, $facilityno, $depId, $connT8)
$salIncomeApplyDetail_rows[] = $rows_data;
}
}
$connT8->commit();
$count_rows_data = COUNT($salIncomeApplyDetail_rows);
$T8total = $price_of_month * $count_rows_data;
// echo "<pre>";
// print_r($salIncomeApplyDetail_rows);
// echo "</pre>";
if ($T8total != $total_price) {
$difference = $T8total - $total_price;
$salIncomeApplyDetail_rows[$count_rows_data - 1]['SPrice'] = $salIncomeApplyDetail_rows[$count_rows_data - 1]['SPrice'] - $difference;
}
// $connT8->commit();
// $insertime = settype($insertTime, 'integer');
$salIncomeApplyMaster_rows = [
"BillNo" => "$contractno",
@ -636,7 +704,9 @@ function T8insert($data, $facilityno, $depId, $connT8)
"CreatorId" => "$user_id",
"CreateTime" => intval($insertTime),
"DeptId" => "$depId",
"IsPriceWithTax" => 1
"IsPriceWithTax" => 1,
"CU_ContractStart" => intval($beginDate),
"CU_ContractEnd" => intval($endDate)
];
$salIncomeApplyMaster = [
@ -652,13 +722,17 @@ function T8insert($data, $facilityno, $depId, $connT8)
$API_body[] = $salIncomeApplyDetail;
// 呼叫 API
echo '<pre>';
print_r($API_body);
print_r(json_encode($API_body));
echo '</pre>';
$api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
// exit();
// $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; //正式區
$api_url = "http://60.244.87.101:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData"; //測試區
$result = T8salIncomeApply($API_body, $api_url);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// exit();
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') {
http_response_code(404);
die('Error!:' . $result['ErrorMsg']);
}
@ -668,8 +742,9 @@ function T8insert($data, $facilityno, $depId, $connT8)
function bonusCreate($data, $facilityno, $conn)
{
try {
require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php");
require_once("../../bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php");
require_once("../../bonus/maintance/maintaenance_contract_bonus.php");
// require_once("../../bonus/other/maintenance_longterm_contract_m1_free_charge_bonus_v2_1_1.php");
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : '';
@ -697,17 +772,17 @@ function bonusCreate($data, $facilityno, $conn)
$facility_no = $facilityno[$key];
$ver = $elevator['bonus_verson']; //獎金版本
$payment_period = $payment[$payType]; //付款方式
$elevator_list_price = !empty(intval($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價
$elevator_list_price = !empty(($elevator['stand_price'])) ? intval($elevator['stand_price']) : ''; //牌價
$fee_per_st = !empty($elevator['sold_price']) ? intval(round($elevator['sold_price'] / 1.05, 2)) : ''; //作翻契約金額 (不含稅)
$commission_fee = !empty($elevator['service_expense']) ? $elevator['service_expense'] : ''; //服務費(月/台)
$receivable_date_due = $payDay; //第一筆保養款項收回日
$sales_id = $salesman; //營業人員
$discount = $elevator['discount'];
$discount = $elevator['discount'] / 100;
$region_director_id = $elevator['manager'];
$regular_contract_manger_id = !empty($elevator['regular_contract_manger_id']) ? $elevator['regular_contract_manger_id'] : '';
$maintain_months = intval($elevator['maintain_months']);
$years = $maintain_months / 12;
echo $years;
// echo $years;
if ($maintain_months == '') $fail_arr[] = "保養月費為必填";
if ($fee_per_st == '') $fail_arr[] = "契約金額為必填";
if ($elevator_list_price == '') $fail_arr[] = "牌價為必填";
@ -720,87 +795,111 @@ function bonusCreate($data, $facilityno, $conn)
}
$renew_priceissue_bonus = [];
// $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : '';
// 如果保養合約 大於一年
if (!empty($maintain_months)) {
if ($maintain_months > 12 && $contract_type == 'new') {
// 第一年為 "新簽約"
$results = maintenance_contract_bonus_v2_1(
$ver,
$contract_type,
$payment_period,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due,
$sales_id,
$region_director_id,
$regular_contract_manger_id
);
for ($i = 1; $i <= $years - 1; $i++) {
$contract_type = 'renew_priceissue';
$receivable_date_due_renew = date("Y-m-d", strtotime("$receivable_date_due + $i year"));
// 第二年以上改 "續約"
$renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1(
$ver,
$contract_type,
$payment_period,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due_renew,
$sales_id,
$region_director_id,
$regular_contract_manger_id
);
}
} else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') {
// 超過一年的 "續約"
for ($i = 0; $i < $years; $i++) {
$contract_type = 'renew_priceissue';
$renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1(
$ver,
$contract_type,
$payment_period,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due,
$sales_id,
$region_director_id,
$regular_contract_manger_id
);
}
} else if ($maintain_months >= 60 && $contract_type = 'longcontract_m1_free_charge') {
// 五年以上長約
$results = maintenance_longterm_contract_m1_free_charge_bonus_v2_1(
$ver,
$contract_type,
$payment_period,
$maintain_months,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due,
$sales_id,
$region_director_id,
$regular_contract_manger_id
);
} else {
$results = maintenance_contract_bonus_v2_1(
/////////////////////////////////
// 如果保養合約 大於一年 2.0版本
// if (!empty($maintain_months)) {
// if ($ver == '2.1') {
// if ($maintain_months > 12 && $contract_type == 'new') {
// // 第一年為 "新簽約"
// $results = maintenance_contract_bonus_v2_1(
// $ver,
// $contract_type,
// $payment_period,
// $elevator_list_price,
// $fee_per_st,
// $commission_fee,
// $receivable_date_due,
// $sales_id,
// $region_director_id,
// $regular_contract_manger_id
// );
// for ($i = 1; $i <= $years - 1; $i++) {
// $contract_type = 'renew_priceissue';
// $receivable_date_due_renew = date("Y-m-d", strtotime("$receivable_date_due + $i year"));
// // 第二年以上改 "續約"
// $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1(
// $ver,
// $contract_type,
// $payment_period,
// $elevator_list_price,
// $fee_per_st,
// $commission_fee,
// $receivable_date_due_renew,
// $sales_id,
// $region_director_id,
// $regular_contract_manger_id
// );
// }
// } else if ($maintain_months > 12 && $contract_type == 'renew_priceissue') {
// // 超過一年的 "續約"
// for ($i = 0; $i < $years; $i++) {
// $contract_type = 'renew_priceissue';
// $renew_priceissue_bonus[] = maintenance_contract_bonus_v2_1(
// $ver,
// $contract_type,
// $payment_period,
// $elevator_list_price,
// $fee_per_st,
// $commission_fee,
// $receivable_date_due,
// $sales_id,
// $region_director_id,
// $regular_contract_manger_id
// );
// }
// } else if ($maintain_months >= 60 && $contract_type = 'longcontract_m1_free_charge') {
// // 五年以上長約
// $results = maintenance_longterm_contract_m1_free_charge_bonus_v2_1(
// $ver,
// $contract_type,
// $payment_period,
// $maintain_months,
// $elevator_list_price,
// $fee_per_st,
// $commission_fee,
// $receivable_date_due,
// $sales_id,
// $region_director_id,
// $regular_contract_manger_id
// );
// } else {
// $results = maintenance_contract_bonus_v2_1(
// $ver,
// $contract_type,
// $payment_period,
// $elevator_list_price,
// $fee_per_st,
// $commission_fee,
// $receivable_date_due,
// $sales_id,
// $region_director_id,
// $regular_contract_manger_id
// );
// }
// } else
if ($ver == '2.0') {
$contract_years = $years > 2 ? 'above_two' : 'one';
// echo $contract_years;
$discount = round($elevator['discount'] / 100, 1);
$results = maintenance_contract_bonus_v2_0(
$ver,
$contract_type,
$payment_period,
$elevator_list_price,
$fee_per_st,
$commission_fee,
$receivable_date_due,
$contract_years,
$discount, // 折扣率
$fee_per_st, //售價
$receivable_date_due, // 第一筆金額繳款時間
$sales_id,
$region_director_id,
$regular_contract_manger_id
);
}
}
// }
/////////////////////////////////
// echo "<pre>";
// print_r($results);
// echo "</pre>";
/////////////////////////////////
$bonus_json = [
'contract_type' => $contract_type,
'total' => $elevator_list_price,

150
wms/contract/api/test copy.json

@ -1,115 +1,43 @@
[
{
"name": "MainSalesOrder",
"rows": [
{
"BillNo": "M24020076",
"BillDate": 20240320,
"TypeId": "SO",
"FOrgId": "1000",
"OrgId": "1000",
"ModeId": "M",
"BizPartnerId": "M24020076",
"CurrId": "TWD",
"CurrOAmount": 1,
"CurrLAmount": 1,
"PersonId": "M0073",
"DueToId": "M24020076",
"TradeConditionId": "",
"TaxId": "ST005",
"CreditorCompId": "1001",
"CreditorOrgId": "1000",
"CreatorId": "M0225"
}
]
},
{
"name": "SubOrder",
"rows": [
{
"TaxId": "ST005",
"RequirementDate": 20240320,
"ConsignmentDate": 20240320,
"BillNo": "M24020076",
"RowCode": 1,
"ItemType": 1,
"MaterialId": "A40001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 910000,
"CU_MaterialId": "4MW00001"
},
{
"TaxId": "ST005",
"RequirementDate": 20240320,
"ConsignmentDate": 20240320,
"BillNo": "M24020076",
"RowCode": 2,
"ItemType": 1,
"MaterialId": "A40008",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 390000,
"CU_MaterialId": "4MW00001"
},
{
"TaxId": "ST005",
"RequirementDate": 20240320,
"ConsignmentDate": 20240320,
"BillNo": "M24020076",
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MW00001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MW00001"
}
]
},
{
"name": "salOrderStagePay",
"rows": [
{
"PayStage": "簽約",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20240420,
"BillNo": "M24020076",
"RowCode": 1,
"RowNo": 1,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "貨抵工地",
"PlanPercentage": 0.5,
"PlanPayAmt": 650000,
"PlanPayDate": 20241220,
"BillNo": "M24020076",
"RowCode": 2,
"RowNo": 2,
"UnWriteOffOAmount": 650000
},
{
"PayStage": "試車完工",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20250120,
"BillNo": "M24020076",
"RowCode": 3,
"RowNo": 3,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "交車",
"PlanPercentage": 0.1,
"PlanPayAmt": 130000,
"PlanPayDate": 20250220,
"BillNo": "M24020076",
"RowCode": 4,
"RowNo": 4,
"UnWriteOffOAmount": 130000
}
]
"apply_key": "11111111",
"register_code": "B32510261185",
"elevator_brand": "1",
"elevator_kind": "E",
"spec": "MAH100",
"weight": "450",
"speed": "45.00",
"stop": "3",
"floors": "3",
"persons": "6",
"elevator_num": "0",
"useful_years": "106",
"last_check_date": "1",
"speed_governors_check_expense": "0",
"maintain_times": "1",
"is_m1_bundle": "N",
"maintainance": "B",
"maintain_months": "12",
"maintain_period": "1",
"stand_price": "1250.00",
"contract_price": "1250.00",
"sold_price": 1250,
"commission_expense": null,
"management_expense": null,
"annual_survey_expense": "0.00",
"service_expense": 0,
"cmstatus": "Y",
"updated_at": null,
"creater": null,
"created_at": "2024-02-26 15:24:23",
"discount": 100,
"latitude": "112",
"longitude": "11",
"takecertificatedate": "112",
"opendoor": "2PCO",
"useful_date": "113-01-01",
"bonus_verson": "2.0",
"manager": "M0029",
"regular_contract_manger_id": "M0054"
}
]

258
wms/contract/api/testT8API.php

@ -1,258 +0,0 @@
<?php
// {
// "BillNo": "Z001", //合約單號
// "BillDate": 20210420, //簽約日期
// "TypeId": "SO", //
// "FOrgId": "1000",
// "OrgId": "1000",
// "ModeId": "T", // T汰改 M新梯
// "BizPartnerId": "M0225", //創建人ID
// "CurrId": "TWD",
// "CurrOAmount": 1,
// "CurrLAmount": 1,
// "PersonId": "M0225", //業務人員
// "DueToId": "512", //業務部門
// "TradeConditionId": "",
// "TaxId": "ST005",
// "CreditorCompId": "1000",
// "CreditorOrgId": "1000",
// "CreditorCurrOAmount": 1,
// "CreditorCurrLAmount": 1,
// "CompId": "1000"
// }
// ]
// },
// {
// //salSalesOrderDetail
// "name": "SubOrder",
// "rows": [
// {
// "SupplyCompId": "1001",
// "SupplyOrgId": "1000",
// "TaxId": "ST005",
// "RequirementDate": 20210420, //出貨日期
// "ConsignmentDate": 20210420, //發貨日期
// "DispatchCompId": "1001",
// "DispatchOrgId": "1000",
// "BillNo": "Z001", //合約號
// "RowCode": 1, //全部筆數排列
// "ItemType": 0,
// "MaterialId": "Z001", //作番號
// "SUnitId": "SET",
// "SQuantity": 1, //交易數量
// "SPrice": 1 //交易價格
// }
// ]
// },
// {
// "name": "salOrderStagePay",
// "rows": [
// {
// "BillNo": "",
// "RowCode": "",
// "RowNo": "",
// "PayStage": "ST003", //收款階段
// "PlanPercentage": "Z001", //計劃收款比例(%)
// "PlanPayAmt": 1, //計劃收款金額
// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日
// "UnWriteOffOAmount": 1 //未核銷金額
// }
// ]
// }
// ]
require_once("../../T8_Authorization_from_bpm.php");
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData";
$validation = get_Auth();
$header = [
"CHI_Authorization :" . $validation,
"GroupId:MASADA"
];
$url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=1000,M24020076";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
print_r($result);
} else {
// print_r($result);
print_r($result);
}
print_r($result);
}
curl_close($ch);
exit();
$contract_no = "M24020003";
// $contract_no = "M24010109";
$MainSalesOrder_row = [
"BillNo" => "$contract_no", //合約單號
"BillDate" => 20210420, //簽約日期
"TypeId" => "SO", //
"FOrgId" => "1000",
"OrgId" => "1000",
"ModeId" => "M", // T汰改 M新梯
"BizPartnerId" => "$contract_no", //客戶代碼
"CurrId" => "TWD",
"CurrOAmount" => 1,
"CurrLAmount" => 1,
"PersonId" => "M0177", //業務人員
"DueToId" => "$contract_no", //債務方
"TradeConditionId" => "",
"TaxId" => "ST005",
"CreditorCompId" => "1001",
"CreditorOrgId" => "1000",
"CreatorId" => "M0225"
];
// //salSalesOrderDetail
// $SubOrder_row = [];
for ($i = 0; $i < 3; $i++) {
if ($i == 0) {
$row = [
// "SupplyCompId" => "1001",
// "SupplyOrgId" => "1000",
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 100000 //交易價格
];
}
if ($i == 1) {
$row = [
// "SupplyCompId" => "1001",
// "SupplyOrgId" => "1000",
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
// "DispatchCompId" => "1001",
// "DispatchOrgId" => "1000",
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 1,
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 650000 //交易價格
];
}
if ($i == 2) {
$row = [
"TaxId" => "ST005",
"RequirementDate" => 20210420, //出貨日期
"ConsignmentDate" => 20210420, //發貨日期
"BillNo" => "$contract_no", //合約號
"RowCode" => $i, //全部筆數排列
"ItemType" => 0,
"MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番)
"SUnitId" => "SET",
"SQuantity" => 1, //交易數量
"SPrice" => 0 //交易價格
];
}
$SubOrder_row[] = $row;
}
$salOrderStagePay_row = [];
$roww = [
"PayStage" => "簽約", //收款階段
"PlanPercentage" => 0.5, //計劃收款比例(%)
"PlanPayAmt" => 375000, //計劃收款金額
"PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日
"BillNo" => "$contract_no",
"RowCode" => 1,
"RowNo" => 1,
"UnWriteOffOAmount" => 375000 //未核銷金額
];
$roww2 = [
"PayStage" => "貨抵工地",
"PlanPercentage" => 0.5,
"PlanPayAmt" => 375000,
"PlanPayDate" => 20240101,
"BillNo" => "$contract_no",
"RowCode" => 2,
"RowNo" => 2,
"UnWriteOffOAmount" => 375000
];
$salOrderStagePay_row[] = $roww;
$salOrderStagePay_row[] = $roww2;
$MainSalesOrder = [
"name" => "MainSalesOrder",
'rows' => [$MainSalesOrder_row]
];
$SubOrder = [
"name" => "SubOrder",
"rows" => $SubOrder_row
];
$salOrderStagePay = [
"name" => "salOrderStagePay",
"rows" => $salOrderStagePay_row
];
$APIbody = [];
$APIbody[] = $MainSalesOrder;
$APIbody[] = $SubOrder;
$APIbody[] = $salOrderStagePay;
// $data = file_get_contents('test copy.json');
// $arr = json_decode($data, true);
// echo "<pre>";
// print_r($data);
// echo "</pre>";
echo "<pre>";
print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
echo "</pre>";
// exit();
$header = [
"CHI_Authorization :" . $validation,
"GroupId:TEST"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($APIbody, JSON_UNESCAPED_UNICODE));
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
// 若 API 傳入失敗。
if ($result['Status'] == 'Erroe') {
echo 'API傳入失敗,' . $result['ErrorMsg'];
print_r($result);
} else {
// print_r($result);
print_r($result);
}
print_r($result);
}
curl_close($ch);

10
wms/contract/api/testocde.php

@ -0,0 +1,10 @@
<?php
include_once("../conn.php");
$sql = "SELECT * FROM pricereview_pay WHERE mid = '441'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$pay_kind = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($pay_kind);
echo "</pre>";

4
wms/contract/conn.php

@ -34,9 +34,9 @@ try {
//設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E=");
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E=");
// $connT8 = new PDO("sqlsrv:Server=10.10.145.2;Database=T8MASADA", "masada", "@m222222");
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222");
// $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222");
if ($connT8) {

199
wms/contract/contract-input.php

@ -64,7 +64,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td>
</tr>
<tr>
<td style="vertical-align: middle">立約人</td>
<td style="vertical-align: middle">客戶名稱</td>
<td>
<input type="text" x-model="data.customer" />
<p class="alerttext" x-show="data.customer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -74,12 +74,12 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<select class="ui fluid search dropdown" name="promiser" x-model="data.salesman">
<option value="">選擇營業員</option>
<?php foreach ($contractpersons as $person) { ?>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['name'] ?></option>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['accountid'] . '--' . $person['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約開始時間</td>
<!-- <td style="vertical-align: middle">合約開始時間</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date">
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -88,29 +88,52 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date">
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
</td> -->
<td style="vertical-align: middle">電梯台數</td>
<td>
<input class="form-control disabled_select" type="number" x-model="data.num" :disabled="data.disabled">
<p class="alerttext" x-show="data.num==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.num==0 && data.num!=''"><i class="fa-solid fa-circle-xmark"></i>電梯數量需大於0</p>
</td>
<td style="vertical-align: middle">統一編號/身分證</td>
<td style="vertical-align: middle">分期方式</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat">
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<select class="ui search dropdown" x-model="data.payType">
<option value="">選擇付款方式</option>
<option value="A40006">年繳</option>
<option value="A40007">季繳</option>
<option value="A40003">月繳</option>
<option value="A40004">雙月繳</option>
<option value="A40005">半年繳</option>
</select>
<p class="alerttext" x-show="data.payType==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">維修型態</td>
<!-- <td style="vertical-align: middle">維修型態</td>
<td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.mtype">
<select class="ui search dropdown" name="" x-model="data.mtype" disabled>
<option value="">選擇維修型態</option>
<option value="A">定期保養</option>
</select>
<p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> -->
</tr>
<tr>
<td style="vertical-align: middle">簽約日</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.signing_date">
<p class="alerttext" x-show="data.signing_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約開始時間</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date">
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約終止時間</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date">
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">契約成交價</td>
<td>
<input class="form-control disabled_select" type="number" name="tel" x-model="data.total_price" :disabled="data.disabled">
@ -118,26 +141,33 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td>
</tr>
<tr>
<td style="vertical-align: middle">發票抬頭</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.invoice">
<!-- <p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">統一編號/身分證</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat">
<!-- <p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">客戶電話</td>
<td>
<input class="form-control disabled_select" type="text" name="tel" x-model="data.phone">
<p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">Email</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="email" name="email" x-model="data.email">
<p class="alerttext" x-show="data.email==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<!-- <p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">保養員</td>
<td style="vertical-align: middle">區域</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mworker">
<option value="">選擇保養員</option>
<?php foreach ($workers as $worker) { ?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?>
<select class="ui search dropdown" x-model="data.area">
<option value="">選擇區域</option>
<template x-for="city in cities" :key="city.code">
<option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
</template>
</select>
<p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<!-- <td style="vertical-align: middle">保養頻率</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mcycle">
@ -147,21 +177,10 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</select>
<p class="alerttext" x-show="data.mcycle==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> -->
<td style="vertical-align: middle">分期方式</td>
<td>
<select class="ui search dropdown" x-model="data.payType">
<option value="">選擇付款方式</option>
<option value="A40006">年繳</option>
<option value="A40007">季繳</option>
<option value="A40003">月繳</option>
<option value="A40004">雙月繳</option>
<option value="A40005">半年繳</option>
</select>
<p class="alerttext" x-show="data.payType==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">業務聯繫人</td>
<!-- <tr>
<td style="vertical-align: middle">合約聯繫人</td>
<td>
<input type="text" x-model="data.partyA" name="partyA" />
<p class="alerttext" x-show="data.partyA==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -181,27 +200,41 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<input class="form-control disabled_select" type="email" name="contracttel" x-model="data.partyAemail">
<p class="alerttext" x-show="data.partyAemail==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
</tr> -->
<tr>
<td style="vertical-align: middle">區域</td>
<td>
<select class="ui search dropdown" x-model="data.area">
<option value="">選擇區域</option>
<template x-for="city in cities" :key="city.code">
<option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
</template>
</select>
<p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">詳細地址</td>
<td style="vertical-align: middle">發票地址</td>
<td colspan="2">
<input type="text" x-model="data.invoice_address" />
<!-- <p class="alerttext" x-show="data.invoice_address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">現場地址</td>
<td colspan="2">
<input type="text" x-model="data.address" />
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">附件</td>
<td colspan="2">
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
<td style="vertical-align: middle">保養經理</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.maintance_manager">
<option value="">選擇保養經理</option>
<option value="M0090">M0090--顏慶豪(北北基)</option>
<option value="M0223">M0223--鄭登元(桃竹)</option>
<option value="M0161">M0161--鄭永典(中區)</option>
<option value="M0077">M0077--鍾玉龍(南區)</option>
<!-- <?php foreach ($workers as $worker) {
// 北北基 : M0090
// 保養組長 桃竹 : M0223
// 中部 : M0161
// 南部 : M0077
?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?> -->
</select>
<!-- <p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
</tr>
<tr>
<td style="vertical-align:middle">合約類別</td>
@ -211,9 +244,22 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<option value="new">新簽約</option>
<option value="free_to_charge">免保轉有費</option>
<option value="renew_priceissue">續簽約</option>
<option value="longcontract_m1_free_charge">長約</option>
<option value="longcontract_m1_free_charge">長約(保養+免費M1電控)</option>
</select>
<p class="alerttext" x-show="data.contract_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td></td>
<td></td>
<td></td>
<td style="vertical-align: middle">合約附件</td>
<td colspan="2">
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
</td>
</tr>
<tr>
</tr>
<!-- <tr>
<td></td>
@ -241,11 +287,11 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td>
<select class="ui search dropdown" name="spec" x-model="data.elevators[idx].spec">
<option value="">選擇規格</option>
<option value="MAE100">MAE100</option>
<option value="MAM200">MAM200</option>
<option value="MAH100">MAH100</option>
<option value="MAQ100">MAQ100</option>
<option value="MAF100">MAF100</option>
<option value="MAE100">MAE100(有機房)</option>
<option value="MAM200">MAM200(無機房)</option>
<option value="MAH100">MAH100(家庭梯)</option>
<option value="MAQ100">MAQ100(強驅梯)</option>
<option value="MAF100">MAF100(貨梯) </option>
<option value="MAZ100">MAZ100</option>
</select>
<p class="alerttext" x-show="!(data.elevators[idx].spec=='MAE100' || data.elevators[idx].spec=='MAM200' || data.elevators[idx].spec=='MAH100' || data.elevators[idx].spec=='MAQ100' || data.elevators[idx].spec=='MAF100' || data.elevators[idx].spec=='MAZ100')"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -327,7 +373,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td style="vertical-align: middle">竣檢日(民國年分)</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.elevators[idx].takecertificatedate">
<p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<!-- <p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
</tr>
<tr>
@ -335,14 +381,16 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td style="vertical-align: middle">許可證有效日期<br>(民國年-月-日。Ex.113-01-01)</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.elevators[idx].useful_date">
<p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<!-- <p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">保養頻率</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.elevators[idx].maintain_times">
<option value="">選擇保養頻率</option>
<option value="2">雙週保</option>
<option value="1">月保</option>
<option value="2">月保兩次</option>
<option value="3">雙月保(2月一次)</option>
<option value="4">季保</option>
</select>
<p class="alerttext" x-show="data.maintain_times==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
@ -372,7 +420,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<tr>
<td style="vertical-align:middle">契約人員</td>
<td><input type="text" x-model="data.salesman"></td>
<td style="vertical-align:middle">保養月份</td>
<td style="vertical-align:middle">合約總計保養月份</td>
<td>
<input type="text" x-model="elevator.maintain_months">
</td>
@ -387,25 +435,27 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td> -->
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="elevator.bonus_verson">
<input type="text" x-model="elevator.bonus_verson" disabled>
</td>
<td style="vertical-align:middle">作番契約金額(月)</td>
<td><input type="text" x-model="elevator.sold_price"></td>
</tr>
<tr>
<td style="vertical-align:middle">服務費</td>
<td>
<input type="text" x-model="elevator.service_expense">
</td>
<td style="vertical-align:middle">牌價(標準價)</td>
<td style="vertical-align:middle">折扣率<br>(取小數點第一位)</td>
<td><input type="text" x-model="elevator.discount"></td>
<td style="vertical-align:middle">地區處長員工號</td>
<td>
<input type="text" x-model="elevator.stand_price">
<p>標準價+Option價格+與其他電梯共同分擔的費用貨價格</p>
<select class="ui search dropdown" name="manage" id="manage" x-model="elevator.regular_contract_manger_id">
<option value="">請選擇</option>
<option value="M0137">劉永德</option>
<option value="M0054">陳志文</option>
<option value="M0033">吳育宗</option>
<option value="M0086">李烘銘</option>
</select>
</td>
<td style="vertical-align:middle">地區處長員工號</td>
<td><input type="text" x-model="elevator.manager"></td>
<td style="vertical-align:middle">專任契約經理員工號</td>
<td><input type="text" x-model="elevator.regular_contract_manger_id"></td>
<td><input type="text" x-model="elevator.manager"></td>
<!-- <td style="vertical-align:middle">折扣率(%)</td>
<td colspan="2">
<input type="text" x-model='elevator.discount'>
@ -458,5 +508,6 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<script>
const user_id = '<?php echo $user_id; ?>'
const user_name = '<?php echo $user_name; ?>'
const token = '<?php echo $token ?>';
// console.log(123);
</script>

52
wms/contract/js/alpine.js

@ -246,7 +246,7 @@ const contractDownload = () => {
{
editshow: false,
origin: true,
text: '交貨期限及甲方配合事項:<br>乙方應於接獲甲方圖色確認第180日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材 運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。',
text: '交貨期限及甲方配合事項:<br>乙方應於接獲甲方圖色確認第180日(應於合約簽訂日起兩年內),將本工程所需之全部設備、器材運抵工地,甲方應提供適當的場所供乙方貯放設備、器材。於指定出貨日期,且乙方備妥材料後,如甲方向後延展出貨日期,如延展日期逾三個月,乙方得酌收額外增生之倉儲保管費用。',
type: 'title',
deleted: false,
id: 5,
@ -830,6 +830,7 @@ const contractNewInput = () => {
area_no: 'T',
contract_arrival_date: ''
},
fail_arr: [],
step: 1,
isLoading: false,
customize: false,
@ -840,6 +841,7 @@ const contractNewInput = () => {
this.getContractDate();
} else if (this.step == 2) {
if (this.data.nums <= 0) return alert('請填寫電梯數量!')
checkInput();
this.getElevatorsData();
} else if (this.step == 3) {
this.getElevatorsData();
@ -909,11 +911,23 @@ const contractNewInput = () => {
}
this.step = 2
this.isLoading = false
}).catch(err => {
console.error(err)
this.isLoading = false
})
},
checkInput() {
// if (this.data.customer == '') this.fail_arr.push('客戶名稱為必填')
// console.log(123);
// let msg = '';
// if (this.fail_arr.length > 0) {
// for (let i = 0; i < this.fail_arr.length; i++) {
// msg += this.fail_arr[i] + "、";
// }
// }
// alert(msg)
},
save() {
this.isLoading = true
const form = new FormData();
@ -976,7 +990,7 @@ const contractNewInput = () => {
},
errorFn() {
let msg = ''
for (let i = 0; i < this.fail_arr.length; i++) {
for (let i = 0; i < JSON.parse(this.fail_arr).length; i++) {
msg += this.fail_arr[i] + '、'
}
alert(msg)
@ -998,7 +1012,7 @@ const contractInput = () => {
},
cities: [],
data: {
contractno: 'B24010030',
contractno: '',
total_price: '', //合約總價
vat: '', //統一編號
mtype: 'A', //維修型態
@ -1022,7 +1036,10 @@ const contractInput = () => {
disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '', //付款方式
contract_type: 'new'
contract_type: 'new',
signing_date: '',
token: token,
maintance_manager: ''
// bonus_verson: 2.1,
// manager: '',
// regular_contract_manger_id: '',
@ -1050,14 +1067,18 @@ const contractInput = () => {
}
},
getBonusVerson(data) {
getBonusVerson(data, signing_date) {
// 目前獎金版本為 2.1,若之後要依辦法建立時間來判斷在這邊修改
data.bonus_verson = 2.1;
if (new Date(signing_date) >= new Date("2024-04-01")) {
data.bonus_verson = "2.1";
} else {
data.bonus_verson = "2.0";
}
},
getManager() {
for (let i = 0; i < this.data.elevators.length; i++) {
this.getBonusVerson(this.data.elevators[i]);
this.getBonusVerson(this.data.elevators[i], this.data.signing_date);
console.log(this.data.elevators[i].bonus_version);
axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => {
this.data.elevators[i].manager = res.data.manager;
console.log(this.data.elevators[i]);
@ -1100,7 +1121,9 @@ const contractInput = () => {
manager: '',
regular_contract_manger_id: '',
bonus_verson: '',
sold_price: ''
sold_price: '',
invoice: '', //發票抬頭
invoice_address: "" //發票地址
})
}
}
@ -1112,19 +1135,21 @@ const contractInput = () => {
this.isLoading = false
return
}
console.log(res.data.service_expense);
// console.log(res.data.service_expense);
if (!this.customize) {
this.data.elevators = res.data.elevators;
for (let i = 0; i < res.data.elevators.length; i++) {
// 合約總價格。
// 合約總價格 (月)
this.data.total_price = Math.round(Number(res.data.elevators[i].sold_price) + Number(this.data.total_price));
// 服務費 (以單筆合約記,但計算獎金須傳入單月服務費)
this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / res.data.elevators[i].maintain_months);
// 折扣率
this.data.elevators[i].discount = ((res.data.elevators[i].sold_price - this.data.elevators[i].service_expense) / res.data.elevators[i].stand_price);
this.data.elevators[i].discount = (((res.data.elevators[i].sold_price - this.data.elevators[i].service_expense) / res.data.elevators[i].stand_price).toFixed(2)) * 100;
this.data.elevators[i].sold_price = Math.round(res.data.elevators[i].sold_price);
}
console.log(this.data.elevators);
// 合約總價
this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
this.data.salesman = res.data.salesman
this.data.contract_begin_date = res.data.contract_begin_date
@ -1218,8 +1243,11 @@ const contractInput = () => {
form.append('num', this.data.num);
form.append('elevators', JSON.stringify(this.data.elevators));
form.append('contracttype', 'b');
form.append('token', this.data.token);
form.append('payType', this.data.payType);
form.append('contract_type', this.data.contract_type);
form.append('signing_date', this.data.signing_date);
form.append('maintance_manager', this.data.maintance_manager);
// 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) {

21
wms/mkt/assets/js/pricereviewAlpine.js → wms/mkt/assets/js/pricereviewAlpine0311.js

@ -988,8 +988,6 @@ const pricereviewCheck = ()=>{
this.demolishOptions = items.filter(item=> item.item_group =='C');
this.maintainOptions = items.filter(item=> item.item_group =='D');
this.otherOptions = items.filter(item=> item.item_group =='E');
console.log("optionnnn=>", this.options);
console.log(this.elevators);
this.elevators.forEach((elevator, idx)=>{
this.options.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){
@ -1071,10 +1069,7 @@ const pricereviewCheck = ()=>{
}
}
}
this.getElevatorMi(idx, spec, person, stop, open, speed, elevator.item_weight)
});
this.sign1 = this.getUsername(sign1)
this.sign2 = this.getUsername(sign2)
@ -1170,38 +1165,38 @@ const pricereviewCheck = ()=>{
mid: mid,
user_id: user_id,
reviewcomment:'',
optionsTotalPrice(){
get optionsTotalPrice(){
return this.options.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
otherOptionsTotalPrice(){
get otherOptionsTotalPrice(){
return this.otherOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
maintainOptionsTotalPrice(){
get maintainOptionsTotalPrice(){
return this.maintainOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
demolishOptionsTotalPrice(){
get demolishOptionsTotalPrice(){
return this.demolishOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
totalScale(){
get totalScale(){
return this.pays.reduce((total, option) => {
return total + Number(option.pay_scale );
}, 0);
},
totalElevatorsPrice(){
get totalElevatorsPrice(){
return this.elevators.reduce((total, elevator) => {
return total + (elevator.item_qty * elevator.price);
}, 0);
},
totalStandardPrice(){
return this.totalElevatorsPrice() + this.otherOptionsTotalPrice() + this.optionsTotalPrice() + this.maintainOptionsTotalPrice() + this.demolishOptionsTotalPrice();
get totalStandardPrice(){
return this.totalElevatorsPrice + this.otherOptionsTotalPrice + this.optionsTotalPrice + this.maintainOptionsTotalPrice + this.demolishOptionsTotalPrice;
},
check(sign, status, user_id = this.user_id ){
console.log(sign);

23
wms/mkt/pricereviewCheck.php

@ -264,7 +264,7 @@ function getSignerName($signer){
<link rel="stylesheet" href="./css/pricereview.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script defer src="./assets/js/alpinejs/cdn.min.js"></script>
<script src="./assets/js/pricereviewAlpine.js"></script>
<script src="./assets/js/pricereviewAlpine0311.js"></script>
<div id="pricereviewCheck" x-data=pricereviewCheck()>
<?php include_once('./window-modal/historySignModal.php'); ?>
@ -409,7 +409,7 @@ function getSignerName($signer){
<tr>
<td colspan=5>小計</td>
<td >
<input type="text" x-model="optionsTotalPrice().toLocaleString()" disabled class="form-control">
<input type="text" x-model="optionsTotalPrice.toLocaleString()" disabled class="form-control">
</td>
<td colspan=3></td>
</tr>
@ -449,7 +449,7 @@ function getSignerName($signer){
<tr>
<td colspan=5>小計</td>
<td >
<input type="text" x-model="otherOptionsTotalPrice().toLocaleString()" disabled class="form-control">
<input type="text" x-model="otherOptionsTotalPrice.toLocaleString()" disabled class="form-control">
</td>
<td colspan=3></td>
</tr>
@ -457,7 +457,7 @@ function getSignerName($signer){
</tbody>
</table>
<table class="table mi-table" border=1>
<table class="table mi-table" border=1 x-show="false">
<thead>
<tr>
<th colspan=8>保固延長</th>
@ -489,7 +489,7 @@ function getSignerName($signer){
<tr>
<td colspan=4>小計</td>
<td >
<input type="text" x-model="maintainOptionsTotalPrice().toLocaleString()" disabled class="form-control">
<input type="text" x-model="maintainOptionsTotalPrice.toLocaleString()" disabled class="form-control">
</td>
<td colspan=2></td>
</tr>
@ -497,7 +497,7 @@ function getSignerName($signer){
</tbody>
</table>
<table class="table mi-table" border=1>
<table class="table mi-table" border=1 x-show="is_renovate == '汰改'">
<thead>
<tr>
<th colspan=8>拆梯價格</th>
@ -529,7 +529,7 @@ function getSignerName($signer){
<tr>
<td colspan=4>小計</td>
<td >
<input type="text" x-model="demolishOptionsTotalPrice().toLocaleString()" disabled class="form-control">
<input type="text" x-model="demolishOptionsTotalPrice.toLocaleString()" disabled class="form-control">
</td>
<td colspan=2></td>
</tr>
@ -671,7 +671,7 @@ function getSignerName($signer){
</tr>
<tr>
<td colspan="2">合計</td>
<td><input type="text" class="form-control" x-model="totalScale()" disabled /></td>
<td><input type="text" class="form-control" x-model="totalScale" disabled /></td>
<td><input type="text" class="form-control" :value="Number(price_total).toLocaleString()" disabled /></td>
<td></td>
</tr>
@ -707,12 +707,12 @@ function getSignerName($signer){
<th>價率%(B/A)</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="Number(totalStandardPrice()).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(totalStandardPrice).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="(price_total - price_lowest).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="qty" disabled /></td>
<td><input type="text" class="form-control" x-model="special_fee.toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Math.round(price_total/totalStandardPrice() * 1000)/10" disabled /></td>
<td><input type="text" class="form-control" x-model="Math.round(price_total/totalStandardPrice * 1000)/10" disabled /></td>
</tr>
<tr>
<th>預定成交日</th>
@ -935,6 +935,7 @@ function getSignerName($signer){
const is_renovate = '<?php echo $contract['ekind']; ?>';
const user_id = '<?php echo $user_id; ?>';
const sign1 = '<?php echo ($sign) ? explode(',', $sign['sign1'])[0] : "---" ?>';
@ -946,4 +947,6 @@ function getSignerName($signer){
const currentSignId = '<?php echo $currentSignId; ?>';
const token = '<?php echo $para = "function_name=pricereview&" . $token_link;; ?>';
const form_key = '<?php echo $form_key; ?>';
console.log(is_renovate);
</script>

2
wms/mkt/pricereviewCreate.php

@ -376,7 +376,7 @@ function convertDateTimeFormat($dateTimeStr) {
<link rel="stylesheet" href="./css/pricereview.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script defer src="./assets/js/alpinejs/cdn.min.js"></script>
<script src="./assets/js/pricereviewAlpine.js"></script>
<script src="./assets/js/pricereviewAlpine0311.js"></script>
<div id="pricereviewCreate" x-data=pricereviewCreate()>
<?php

56
wms/schedule-edit.php

@ -1,15 +1,24 @@
<?php
include "header.php";
include "header.php";
include_once "./contract/conn.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM schedule WHERE id=$id";
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM schedule WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $db_query);
$sql = "SELECT * FROM account WHERE accounttype = 'B' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$repaire = $stmt->fetchAll(PDO::FETCH_ASSOC);
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
@ -24,10 +33,10 @@
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
foreach ($data as $data) :
?>
<div class="container">
<div class="container">
<form class="form-inline" method="post" action="schedule-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
@ -48,7 +57,16 @@
<div>
<label for="repairerid">保養人員工號</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
<select name="repaire" id="repaire">
<option value=""></option>
<?php
foreach ($repaire as $repaire) {
?>
<option value="<?= $repaire['accountid'] ?>"><?php echo $repaire['accountid'] . '---' . $repaire['name'] ?></option>
<?php
}
?>
</select>
</div>
<div>
@ -81,7 +99,7 @@
<input type="text" name="result" id="result" value="<?php echo $data['result']; ?>">
</div>
<!--
<!--
<div>
<label for="evidences">上傳照片</label>
<input type="text" name="evidences" id="evidences" >
@ -116,7 +134,7 @@
<label for="details">內容</label>
<input type="text" name="details" id="details" value="<?php echo $data['details']; ?>">
</div>
<!--
<!--
<div>
<label for="customer_signature">簽名檔</label>
<input type="text" name="customer_signature" id="customer_signature" value="<?php echo $data['customer_signature']; ?>">
@ -131,15 +149,21 @@
<div>
<br>
<button type="submit" name="update">確認</button>
<!-- <button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>)" style="text-align: right;">更新此作番保養人員</button> -->
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
</div>
<?php
endforeach;
include "footer.php";
endforeach;
include "footer.php";
// include_once "./bonus/api/postSchedule.php"
?>
<script src="../contract-repair/js/axios/axios.min.js"></script>
<script>
</script>

30
wms/schedule-index.php

@ -4,7 +4,7 @@ include "header.php";
$tourl = $_SERVER["SCRIPT_NAME"] . "?function_name=schedule&token=" . $token;
// 工務總處可瀏覽全部資料
$sql = "select department_id, role_id from account where accountid = '$user_id'";
$sql = "select department_id, role_id from account where accountid = '$user_id' AND accounttype IN ('B','E','M','W') ";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
@ -36,12 +36,16 @@ if (!empty($sql_cmd2)) {
else $sql_cmd .= $sql_cmd2;
$page_close = 1; // 不分頁
}
$clause = "WHERE id IN (
SELECT MIN(id)
FROM schedule
GROUP BY contractno
)";
//$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
$sql = "SELECT DISTINCT contractno, schedule.* FROM schedule $sql_cmd ORDER BY CASE WHEN repairerid IS NULL THEN 0 ELSE 1 END, id";
// $sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
if (!$page_close) $sql .= " limit $page_from, $page_each";
//echo $sql;
// echo $sql;
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $sql);
@ -192,7 +196,8 @@ if ($data) :
<th>建檔時間</th>
<?php if ($user_auth & 2) { ?>
<th>修改</th>
<th>刪除</th>
<!-- <th>刪除</th> -->
<th>安排保養計畫人員</th>
<?php } ?>
</tr>
</thead>
@ -211,7 +216,8 @@ if ($data) :
<!-- <td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item_detail']; ?></td> -->
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;">
<?php //echo $data['result']; ?>
<?php //echo $data['result'];
?>
<a href="/app/app-maintenance-uploadsuccess-survey.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>">查看明細</a>
</td>
<td>
@ -219,7 +225,8 @@ if ($data) :
<?php if ($data['evidences']) {
// echo "<a href=\"/app/" . $data['evidences'] . "\">瀏覽</a>";
} ?></td>
} ?>
</td>
<td><?php echo $data['descriptons']; ?></td>
<!-- <td><?php echo $data['customer_login_id']; ?></td> -->
<td><?php echo $data['customer_login_name']; ?></td>
@ -248,11 +255,16 @@ if ($data) :
</p>
</td>
<td>
<p>
<!-- <p>
<a href="schedule-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p> -->
<?php if (empty($data['repairerid'])) { ?>
<p>
<a href="schedule-setting-repaire.php?id=<?= $data['id'] ?>&<?php echo $token_link; ?>"" class=" btn btn-info btn-sm">安排</a>
</p>
<?php } ?>
</td>
<?php } ?>
</tr>

66
wms/schedule-setting-repaire-update.php

@ -0,0 +1,66 @@
<?php
include "header.php";
include_once "./contract/conn.php";
if (isset($_POST['update'])) {
function user_input($data)
{
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$sql = "SELECT * FROM schedule WHERE id = '$id'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$checkRepaireIsit = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($checkRepaireIsit)) {
echo "<script type ='text/JavaScript'>";
echo "alert('此單號已經有保養人員');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
}
$contractno = user_input($_POST["contractno"]);
$facilityno = user_input($_POST["facilityno"]);
$repairerid = user_input($_POST["repairerid"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$sql = "SELECT name FROM account WHERE accountid = '$repairerid'";
$stmt = $conn->prepare($sql);
$stmt->execute();
$account = $stmt->fetch(PDO::FETCH_ASSOC);
$repairername = $account['name'];
$db_query = "UPDATE schedule set
repairerid = '$repairerid',
repairername = '$repairername',
updater = '$creater',
update_at = '$create_at' WHERE contractno='$contractno' AND facilityno='$facilityno'";
$stmt = $conn->prepare($db_query);
$stmt->execute();
$affected = $stmt->rowCount();
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='schedule-index.php?function_name=schedule&" . $token_link . "';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: ";
}
}

192
wms/schedule-setting-repaire.php

@ -0,0 +1,192 @@
<?php
include "header.php";
include_once "./contract/conn.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM schedule WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $db_query);
$sql = "SELECT * FROM account WHERE accounttype = 'B' ";
$stmt = $conn->prepare($sql);
$stmt->execute();
$repaire = $stmt->fetchAll(PDO::FETCH_ASSOC);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach ($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="schedule-setting-repaire-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>" disabled>
</div>
<div>
<label for="facilityno">作番號</label>
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data['facilityno']; ?>" disabled>
</div>
<!--
<div>
<label for="combono">保養套餐編號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div> -->
<div>
<label for="repairerid">保養人員工號</label>
<select name="repairerid" id="repairerid">
<option value=""></option>
<?php
foreach ($repaire as $repaire) {
?>
<option value="<?= $repaire['accountid'] ?>"><?php echo $repaire['accountid'] . '---' . $repaire['name'] ?></option>
<?php
}
?>
</select>
</div>
<!--
<div>
<label for="repairername">保養人員姓名</label>
<input type="text" name="repairername" id="repairername" value="<?php echo $data['repairername']; ?>">
</div> -->
<!--
<div>
<label for="duedate">應保養日期</label>
<input type="text" name="duedate" id="duedate" value="<?php echo $data['duedate']; ?>">
</div>
<div>
<label for="actualdate">實際保養日期</label>
<input type="text" name="actualdate" id="actualdate" data-date-format="yyyy-mm-dd" value="<?php echo $data['actualdate']; ?>">
</div>
<div>
<label for="item">保養項目編號</label>
<input type="text" name="item" id="item" value="<?php echo $data['item']; ?>">
</div>
<div>
<label for="item_detail">保養項目內容</label>
<input type="text" name="item_detail" id="item_detail" value="<?php echo $data['item_detail']; ?>">
</div> -->
<!-- <div>
<label for="result">保養結果</label>
<input type="text" name="result" id="result" value="<?php echo $data['result']; ?>">
</div> -->
<!--
<div>
<label for="evidences">上傳照片</label>
<input type="text" name="evidences" id="evidences" >
</div>
-->
<!-- <div>
<label for="descriptons">說明</label>
<input type="text" name="descriptons" id="descriptons" value="<?php echo $data['descriptons']; ?>">
</div>
<div>
<label for="customer_login_id">客戶評價登入帳號</label>
<input type="text" name="customer_login_id" id="customer_login_id" value="<?php echo $data['customer_login_id']; ?>">
</div>
<div>
<label for="customer_login_name">客戶姓名</label>
<input type="text" name="customer_login_name" id="customer_login_name" value="<?php echo $data['customer_login_name']; ?>">
</div>
<div>
<label for="stars">保養品質/評價等級(1-5星)</label>
<input type="text" name="stars" id="stars" onkeyup="if(value<0)value=0;if(value>5)value=5;value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" value="<?php echo $data['stars_c1']; ?>">
</div>
<div>
<label for="stars2">服務態度/評價等級(1-5星)</label>
<input type="text" name="stars2" id="stars2" onkeyup="if(value<0)value=0;if(value>5)value=5;value=value.replace(/^\D*(\d*(?:\.\d)?).*$/g, '$1')" value="<?php echo $data['stars_c2']; ?>">
</div>
<div>
<label for="details">內容</label>
<input type="text" name="details" id="details" value="<?php echo $data['details']; ?>">
</div> -->
<!--
<div>
<label for="customer_signature">簽名檔</label>
<input type="text" name="customer_signature" id="customer_signature" value="<?php echo $data['customer_signature']; ?>">
</div>
-->
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確認</button>
<!-- <button onclick="updateRepaire(<?= $data['contractno'] ?>,<?= $data['facilityno'] ?>,<?= $user_id ?>)" style="text-align: right;">更新此作番保養人員</button> -->
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="hidden" name="reqaire" id="reqaire" value="">
</form>
</div>
<?php
endforeach;
include "footer.php";
// include_once "./bonus/api/postSchedule.php"
?>
<script src="./contract-repair/js/axios/axios.min.js"></script>
<script>
document.getElementById('repairerid').onchange = function() {
var repaireridValue = this.value;
// 根據選擇的值做相應的處理
document.getElementById('reqaire').value = repaireridValue;
console.log(repaireridValue);
};
// function updateRepaire(contractno, facilityno, user_id) {
// const form = new FormData();
// form.append("contractno", contractno);
// form.append("facilityno", facilityno);
// form.append("user_id", user_id)
// axios.post('./bonus/api/postSchedule.php', form).then((res) => {
// if (res.data == 'Success') {
// alert('更新成功');
// location.reload();
// }
// }).catch((err) => {
// })
// }
</script>

4
wms/sign/list.php

@ -113,7 +113,9 @@ JOIN
FROM
subflow
GROUP BY
form_key) AS sf ON d.form_key = sf.form_key
form_key
ORDER BY update_date DESC) AS sf ON d.form_key = sf.form_key
JOIN
subflow c ON c.form_key = sf.form_key AND c.seq = sf.max_seq
WHERE

Loading…
Cancel
Save