diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index c3592c3d..e67c83d5 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -1,7 +1,6 @@ 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); diff --git a/wms/account-receivable-maintainance-index.php b/wms/account-receivable-maintainance-index.php index aad21f66..e1c0d427 100644 --- a/wms/account-receivable-maintainance-index.php +++ b/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) { diff --git a/wms/account-receivable-new-index.php b/wms/account-receivable-new-index.php index e2ac10a8..712c8647 100644 --- a/wms/account-receivable-new-index.php +++ b/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 "
---------------------------------------------------------
"; +// foreach($arrayData['M230064'] as $key => $value){ +// if($key == 'PayStage'){ +// echo "是PayStage!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"; +// foreach($value as $k => $v){ + +// echo $k.' => '; +// print_r($v); +// echo '
'; +// } +// echo "-----------------------
"; +// }else{ +// echo $key.' => '; +// print_r($value); +// echo '
'; +// } +// } // print_r($arrayData['M220003']); // exit(); $total_data = json_encode($excel_contract_all_array); diff --git a/wms/account-receivable-test.php b/wms/account-receivable-test.php index 2c28e510..d9e447c7 100644 --- a/wms/account-receivable-test.php +++ b/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'] ."
"; // } - -$TIME = strtotime('2000-12-02'); - -echo $TIME; \ No newline at end of file +$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); diff --git a/wms/account-receivable.txt b/wms/account-receivable.txt index 8e19026c..d5ddbaf2 100644 --- a/wms/account-receivable.txt +++ b/wms/account-receivable.txt @@ -1 +1 @@ -{"Bill":{"M220366":["M220366","欣佳德營造工程有限公司","陳敦德","750,000","1","2MW00038 (2024-07-01預計出貨) ; ","450,000","14","150,000","14","300,000","11","0","0",0,0,"0","0",0,0,"0","0",0,0],"M220473":["M220473","國合營造-新北市雙溪案","陳敦德","3,822,000","3","3MW00050 (2024-02-23預計出貨) ; 3MW00051 (2024-02-23預計出貨) ; 3MW00052 (2024-02-16預計出貨) ; ","1,974,000","10","658,000","10","1,316,000","8","0","0",0,0,"0","0",0,0,"0","0",0,0],"M230022":["M230022","旺旺工程行-鄭秋月","陳敦德","600,000","1","3MH00076 (2024-06-01預計出貨) ; ","360,000","11","120,000","11","240,000","8","0","0",0,0,"0","0",0,0,"0","0",0,0],"M230166":["M230166","富德開發有限公司-東海段98-54地號","陳敦德","650,000","1","3MH00294 (2024-01-04安裝完畢) ; ","520,000","8","130,000","8","260,000","6","130,000","2",0,0,"0","0",0,0,"0","0",0,0],"M230563":["M230563","葉建中-大里新建住宅","陳敦德","820,000","1","3MX00295 (2024-05-15預計出貨) ; ","492,000","8","164,000","8","328,000","5","0","0",0,0,"0","0",0,0,"0","0",0,0],"M230579":["M230579","洪輝龍-A2","李烘銘","520,000","1","3MH00245 (2024-06-28預計出貨) ; ","156,000","9","156,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230580":["M230580","翔富裕股份有限公司(林紡鍥-A8)","李烘銘","520,000","1","3MH00246 (2024-06-28預計出貨) ; ","156,000","9","156,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230438":["M230438","佳意工程有限公司","李烘銘","600,000","1","3MH00196 (2023-09-28試車完畢) ; ","420,000","10","180,000","10",0,0,"180,000","6",0,0,"60,000","5",0,0,"0","0",0,0],"M230483":["M230483","蔡育薰-博思特幼兒學校","李烘銘","550,000","1","3MH00450 (2024-01-02官檢完畢) ; ","495,000","7","165,000","7",0,0,"165,000","3",0,0,"165,000","2",0,0,"0","0",0,0],"M230484":["M230484","協順營造有限公司","李烘銘","630,000","1","3MH00360 (2024-01-16官檢完畢) ; ","567,000","8","189,000","8",0,0,"189,000","3",0,0,"189,000","2",0,0,"0","0",0,0],"M230485":["M230485","順宇土地建築(大雅秀山段)","李烘銘","2,100,000","4","3MH00356 (2023-12-22貨抵工地) ; 3MH00357 (2023-12-22貨抵工地) ; 3MH00358 (2023-12-29貨抵工地) ; 3MH00359 (2023-12-29貨抵工地) ; ","1,260,000","9","630,000","9",0,0,"630,000","2",0,0,"0","0",0,0,"0","0",0,0],"M230512":["M230512","陳宜羣","李烘銘","550,000","1","3MH00197 (2024-07-10預計出貨) ; ","165,000","10","165,000","10",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230620":["M230620","洪輝龍-A1","李烘銘","520,000","1","3MH00247 (2024-06-28預計出貨) ; ","156,000","9","156,000","9",0,0,"0","0","0","0",0,0,0,0,"0","0",0,0],"M230621":["M230621","金寶城糖業-虎尾科虎路","李烘銘","550,000","1","3MH00266 (2023-12-21貨抵工地) ; ","330,000","9","165,000","9",0,0,"165,000","2",0,0,"0","0",0,0,"0","0",0,0],"M230631":["M230631","劉建利","李烘銘","740,000","1","3MW00248 (2023-10-05試車完畢) ; ","385,560","6","0","0",0,0,"163,560","6",0,0,"222,000","4",0,0,"0","0",0,0],"M230635":["M230635","村玉建設-長春路案(A棟)","李烘銘","850,000","1","3MW00267 (2024-04-16預計出貨) ; ","255,000","5","255,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230636":["M230636","村玉建設-科邨一路案","李烘銘","5,940,000","6","3MW00279 (2024-06-25預計出貨) ; 3MW00278 (2024-06-25預計出貨) ; 3MW00277 (2024-06-25預計出貨) ; 3MW00276 (2024-06-25預計出貨) ; 3MW00275 (2024-06-25預計出貨) ; 3MW00274 (2024-06-25預計出貨) ; ","1,782,000","9","1,782,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230637":["M230637","村玉建設-高南","李烘銘","1,320,000","2","3MH00281 (2024-05-10預計出貨) ; 3MH00280 (2024-05-10預計出貨) ; ","396,000","9","396,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M220471":["M220471","東禹營造-台中果菜市場","李烘銘","3,280,000","2","3MW00118 (2023-09-12官檢完畢) ; 3MW00119 (2023-09-12官檢完畢) ; ","2,987,280","12","538,912","12",0,0,0,0,"1,886,192","6","292,720","5","269,456","5","0","0",0,0],"M230238":["M230238","王色鳳","李烘銘","630,000","1","3MH00130 (2023-11-08已移交) ; ","189,000","5","0","0",0,0,"0","0",0,0,"126,000","5",0,0,"63,000","3",0,0],"M230239":["M230239","弘宬營造股份有限公司","李烘銘","600,000","1","3MH00173 (2024-05-15預計出貨) ; ","180,000","10","180,000","10",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230240":["M230240","弘宬營造股份有限公司","李烘銘","1,260,000","2","3MH00174 (2024-03-12預計出貨) ; 3MH00175 (2024-03-12預計出貨) ; ","378,000","10","378,000","10",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230284":["M230284","劉玉閔-施洽成撚線厰","李烘銘","600,000","1","3MH00195 (2024-04-03預計出貨) ; ","180,000","10","180,000","10",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230391":["M230391","台翰營造","李烘銘","740,000","1","3MW00209 (2024-01-31官檢完畢) ; ","666,000","9","222,000","9",0,0,"222,000","5",0,0,"222,000","2",0,0,"0","0",0,0],"M230412":["M230412","勝德營造(順宇)","李烘銘","1,050,000","2","3MH00312 (2024-01-03貨抵工地) ; 3MH00313 (2024-01-03貨抵工地) ; ","630,000","9","315,000","9",0,0,"315,000","1",0,0,"0","0",0,0,"0","0",0,0],"M230662":["M230662","劉建忠","李烘銘","740,000","1","3MW00249 (2023-10-02試車完畢) ; ","388,320","6","0","0",0,0,"166,320","6",0,0,"222,000","5",0,0,"0","0",0,0],"M230679":["M230679","劉繕綸","李烘銘","810,000","1","3MW00311 (2024-02-22預計出貨) ; ","225,000","9","225,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230687":["M230687","永豪營造有限公司","李烘銘","525,000","1","3MH00355 (2023-12-08試車完畢) ; ","472,500","8","157,500","8",0,0,"157,500","4",0,0,"157,500","2",0,0,"0","0",0,0],"M230734":["M230734","盛立交通-貨運集貨站新建工程","李烘銘","750,000","1","3MW00509 (2024-02-21預計出貨) ; ","225,000","6","225,000","6",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230737":["M230737","萬大建設有限公司-台中沙鹿區","李烘銘","540,000","1","3MH00297 (2023-09-08試車完畢) ; ","162,000","5","0","0",0,0,"0","0",0,0,"162,000","5",0,0,"0","0",0,0],"M230738":["M230738","江春池","李烘銘","560,000","1","3MH00298 (2023-11-02試車完畢) ; ","168,000","4","0","0",0,0,"0","0",0,0,"168,000","4",0,0,"0","0",0,0],"M230759":["M230759","通權建設-王江海","李烘銘","520,000","1","3MH00496 (2024-10-15預計出貨) ; ","156,000","7","156,000","7",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230760":["M230760","通權建設-南投市","李烘銘","680,000","1","3MH00497 (2024-10-15預計出貨) ; ","204,000","7","204,000","7",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230545":["M230545","耀鼎建設-北屯","李烘銘","1,100,000","2","3MH00207 (2024-08-01預計出貨) ; 3MH00208 (2024-08-01預計出貨) ; ","330,000","7","330,000","7",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230548":["M230548","益豪建築-竹山大同街","李烘銘","1,500,000","2","3MW00260 (2024-01-16貨抵工地) ; 3MW00261 (2024-01-31安裝完畢) ; ","900,000","9","450,000","9",0,0,"450,000","1",0,0,"0","0",0,0,"0","0",0,0],"M230549":["M230549","益豪建造-竹山大明路","李烘銘","2,400,000","4","3MH00262 (2024-04-19預計出貨) ; 3MH00263 (2024-04-19預計出貨) ; 3MH00264 (2024-04-19預計出貨) ; 3MH00265 (2024-04-19預計出貨) ; ","720,000","9","720,000","9",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230838":["M230838","福興建設有限公司","李烘銘","5,615,000","10","3MH00582 (2024-02-16預計出貨) ; 3MH00583 (2024-02-16預計出貨) ; 3MH00584 (2024-03-06預計出貨) ; 3MH00585 (2024-03-06預計出貨) ; 3MH00586 (2024-03-06預計出貨) ; 3MH00587 (2024-03-06預計出貨) ; 3MH00588 (2024-03-18預計出貨) ; 3MH00589 (2024-03-18預計出貨) ; 3MH00590 (2024-03-18預計出貨) ; 3MH00591 (2024-01-08貨抵工地) ; ","212,000","1","0","0",0,0,"212,000","1",0,0,"0","0",0,0,"0","0",0,0],"M230839":["M230839","全鴻建設開發有限公司(觀音安和街)","李烘銘","530,000","1","3MH00592 (2024-02-03已移交) ; ","424,000","1","0","0",0,0,"212,000","1",0,0,"159,000","0",0,0,"53,000","0",0,0],"M23090095":["M23090095","格誠建設有限公司","李烘銘","1,100,000","1","3MW00845 (2024-05-15預計出貨) ; ","220,000","4","220,000","4",0,0,"0","0",0,0,"0","0","0","0","0","0",0,0],"M23090096":["M23090096","格睿建設有限公司","李烘銘","2,430,000","2","3MW00846 (2024-05-15預計出貨) ; 3MW00847 (2024-05-15預計出貨) ; ","486,000","4","486,000","4",0,0,"0","0",0,0,"0","0","0","0","0","0",0,0],"M23090097":["M23090097","格睿建設有限公司","李烘銘","830,000","1","3MH00848 (2024-05-15預計出貨) ; ","166,000","4","166,000","4",0,0,"0","0",0,0,"0","0","0","0","0","0",0,0],"M23090132":["M23090132","上群地產開發股份有限公司","李烘銘","2,300,000","2","3MX00859 (2024-06-14預計出貨) ; 3MX00860 (2024-06-14預計出貨) ; ","230,000","4","230,000","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23090140":["M23090140","廣瓏建設有限公司","李烘銘","4,000,000","4","3MW00855 (2024-06-14預計出貨) ; 3MW00856 (2024-06-14預計出貨) ; 3MW00857 (2024-06-14預計出貨) ; 3MW00858 (2024-06-14預計出貨) ; ","400,000","4","400,000","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230994":["M230994","村玉建設-長春路案(B棟)","李烘銘","3,300,000","6","3MH00273 (2024-05-10預計出貨) ; 3MH00272 (2024-05-10預計出貨) ; 3MH00271 (2024-05-10預計出貨) ; 3MH00270 (2024-05-10預計出貨) ; 3MH00268 (2024-05-10預計出貨) ; 3MH00269 (2024-05-10預計出貨) ; ","990,000","5","990,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230881":["M230881","胡方翔(溫玉嬌)","李烘銘","910,000","1","3MW00415 (2024-03-19預計出貨) ; ","258,000","8","258,000","8",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100138":["M23100138","王凱莉","李烘銘","670,000","1","3MH01034 (2024-05-21預計出貨) ; ","201,000","2","201,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100140":["M23100140","薆綉室內裝修工程有限公司","李烘銘","520,000","1","3MH01048 (2024-03-11預計出貨) ; ","159,000","2","159,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231045":["M231045","寶祥營造廠有限公司(林梅清)","李烘銘","560,000","1","3MH00503 (2023-12-22安裝完畢) ; ","168,000","3","0","0",0,0,"168,000","3",0,0,"0","0",0,0,"0","0",0,0],"M23110060":["M23110060","張弘起","李烘銘","535,000","1","3MH01054 (2024-04-10預計出貨) ; ","160,500","2","160,500","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110069":["M23110069","弘泰-彰化和美鎮","李烘銘","2,120,000","4","3MH01071 (2024-05-15預計出貨) ; 3MH01072 (2024-05-15預計出貨) ; 3MH01073 (2024-05-15預計出貨) ; 3MH01074 (2024-05-15預計出貨) ; ","636,000","2","636,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231126":["M231126","薆綉室內裝修工程有限公司-南投草屯鎮","李烘銘","540,000","1","3MH00535 (2024-01-12貨抵工地) ; ","324,000","7","162,000","7",0,0,"162,000","1",0,0,"0","0",0,0,"0","0",0,0],"M231133":["M231133","弘宬營造股份有限公司(西屯區)","李烘銘","700,000","1","3MH00646 (2024-11-29預計出貨) ; ","210,000","6","210,000","6",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231134":["M231134","弘宬營造股份有限公司(北區)","李烘銘","1,170,000","2","3MH00644 (2024-06-05預計出貨) ; 3MH00645 (2024-06-05預計出貨) ; ","3,000","6","3,000","6",0,0,"0","0","0","0",0,0,0,0,"0","0",0,0],"M23100133":["M23100133","總富建設-彰化溪州鄉","李烘銘","610,000","1","3MH00962 (2024-02-27預計出貨) ; ","183,000","3","183,000","3",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110123":["M23110123","瑋瓏營造有限公司","李烘銘","1,080,000","2","3MH01051 (2024-05-10預計出貨) ; 3MH01052 (2024-04-23預計出貨) ; ","324,000","2","324,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110129":["M23110129","蕭崇家-彰化縣員林市","李烘銘","1,300,000","2","4MH00159 (2024-12-26預計出貨) ; 4MH00160 (2024-12-16預計出貨) ; ","390,000","1","390,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231153":["M231153","馨盛-明德北路","李烘銘","510,000","1","3MH00779 (2024-05-14預計出貨) ; ","153,000","5","153,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231154":["M231154","上互營造股份有限公司","李烘銘","1,020,000","2","3MH00777 (2024-08-10預計出貨) ; 3MH00778 (2024-08-10預計出貨) ; ","255,000","5","255,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231169":["M231169","鄭茂昌","李烘銘","2,080,000","2","3MH00596 (2024-03-15預計出貨) ; ","210,000","6","210,000","6",0,0,0,0,0,0,0,0,0,0,0,0,0,0],"M231172":["M231172","乾唐建設有限公司","李烘銘","820,000","1","3MX00619 (2024-01-08安裝完畢) ; ","246,000","2","0","0",0,0,"246,000","2",0,0,"0","0",0,0,"0","0",0,0],"M231173":["M231173","厚德建設有限公司","葉博澄","1,670,000","3","3MH00641 (2024-01-19安裝完畢) ; 3MH00642 (2024-01-20安裝完畢) ; 3MH00643 (2023-12-27貨抵工地) ; ","501,000","2","0","0",0,0,"501,000","2",0,0,"0","0",0,0,"0","0",0,0],"M231207":["M231207","三冠企業社","葉博澄","840,000","1","3MW01082 (2024-09-02預計出貨) ; ","252,000","2","252,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231184":["M231184","裕民工務企業有限公司","葉博澄","530,000","1","3MH00640 (2024-01-24已移交) ; ","371,000","3","0","0",0,0,"159,000","3",0,0,"159,000","2",0,0,"53,000","1",0,0],"M23120001":["M23120001","東松建設-台中西屯區廣昌段","葉博澄","15,080,000","29","4MH00188 (2024-05-06預計出貨) ; 4MH00189 (2024-05-06預計出貨) ; 4MH00190 (2024-05-06預計出貨) ; 4MH00191 (2024-05-06預計出貨) ; 4MH00192 (2024-05-06預計出貨) ; 4MH00193 (2024-05-06預計出貨) ; 4MH00194 (2024-05-06預計出貨) ; 4MH00195 (2024-05-06預計出貨) ; 4MH00196 (2024-05-06預計出貨) ; 4MH00197 (2024-05-06預計出貨) ; 4MH00198 (2024-05-06預計出貨) ; 4MH00199 (2024-05-06預計出貨) ; 4MH00200 (2024-05-06預計出貨) ; 4MH00201 (2024-05-06預計出貨) ; 4MH00202 (2024-05-06預計出貨) ; 4MH00203 (2024-05-06預計出貨) ; 4MH00204 (2024-05-06預計出貨) ; 4MH00205 (2024-05-06預計出貨) ; 4MH00206 (2024-05-06預計出貨) ; 4MH00207 (2024-05-06預計出貨) ; 4MH00208 (2024-05-06預計出貨) ; 4MH00209 (2024-05-06預計出貨) ; 4MH00210 (2024-05-06預計出貨) ; 4MH00211 (2024-05-06預計出貨) ; 4MH00212 (2024-05-06預計出貨) ; 4MH00213 (2024-05-06預計出貨) ; 4MH00214 (2024-05-06預計出貨) ; 4MH00215 (2024-05-06預計出貨) ; 4MH00216 (2024-05-06預計出貨) ; ","4,524,000","1","4,524,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23120100":["M23120100","林佳民-台中豐原區","葉博澄","650,000","1","4MH00089 (2024-04-22預計出貨) ; ","195,000","1","195,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231168":["M231168","山本耀(鄭榆錚)","葉博澄","800,000","1","3MH00950 (2024-03-11預計出貨) ; ","240,000","3","240,000","3",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231118":["M231118","立傑營造-台中太平","葉博澄","2,000,000","2","3MW00613 (2024-03-07預計出貨) ; 3MW00612 (2023-12-08貨抵工地) ; ","285,000","2","0","0",0,0,"285,000","2",0,0,"0","0",0,0,"0","0",0,0],"M23100134":["M23100134","興安-北屯區陳平段","葉博澄","5,120,000","5","4MW00132 (2024-05-20預計出貨) ; 4MW00133 (2024-05-20預計出貨) ; 4MW00134 (2024-05-20預計出貨) ; 4MW00135 (2024-05-20預計出貨) ; 4MW00136 (2024-05-20預計出貨) ; ","1,536,000","1","1,536,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100136":["M23100136","興安-美和綠洲","葉博澄","3,780,000","4","4MW00122 (2024-04-08預計出貨) ; 4MW00123 (2024-04-08預計出貨) ; 4MW00124 (2024-04-08預計出貨) ; 4MW00125 (2024-04-08預計出貨) ; ","1,134,000","1","1,134,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231141":["M231141","太禾發建設開發企業有限公司","葉博澄","565,000","1","3MH00885 (2024-03-01預計出貨) ; ","169,500","4","169,500","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231151":["M231151","太裕營造股份有限公司","葉博澄","1,300,000","1","3MW00788 (2024-03-01預計出貨) ; ","390,000","5","390,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110080":["M23110080","金進億","葉博澄","650,000","1","3MH01050 (2024-03-04預計出貨) ; ","195,000","2","195,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110103":["M23110103","亘玉露生技","葉博澄","930,000","1","4MW00066 (2024-04-01預計出貨) ; ","279,000","1","279,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110005":["M23110005","興安-南投司馬按段","葉博澄","3,300,000","6","4MH00126 (2024-04-08預計出貨) ; 4MH00127 (2024-04-08預計出貨) ; 4MH00128 (2024-04-08預計出貨) ; 4MH00129 (2024-04-08預計出貨) ; 4MH00130 (2024-04-08預計出貨) ; 4MH00131 (2024-04-08預計出貨) ; ","990,000","1","990,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110007":["M23110007","經緯營造","葉博澄","820,000","1","4MW00065 (2024-04-15預計出貨) ; ","246,000","1","246,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23110011":["M23110011","孫室空間","葉博澄","700,000","1","3MP01032 (2024-02-29預計出貨) ; ","210,000","2","210,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231026":["M231026","伍灃營造開發有限公司","葉博澄","520,000","1","3MH00881 (2024-05-03預計出貨) ; ","156,000","5","156,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M231030":["M231030","陳慶宏","葉博澄","530,000","1","3MH00796 (2023-12-29安裝完畢) ; ","159,000","2","0","0",0,0,"159,000","2",0,0,"0","0",0,0,"0","0",0,0],"M231039":["M231039","玉明玻璃股份有限公司(劉澄藝)","葉博澄","530,000","1","3MH00534 (2023-12-16安裝完畢) ; ","318,000","7","159,000","7",0,0,"159,000","3",0,0,"0","0",0,0,"0","0",0,0],"M231043":["M231043","磐檍建設(邑鼎)-北屯段","葉博澄","570,000","1","4MH00158 (2024-05-30預計出貨) ; ","171,000","1","171,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100074":["M23100074","政馭實業","葉博澄","620,000","1","4MH00062 (2024-04-15預計出貨) ; ","186,000","2","186,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100082":["M23100082","靖捷企業社","葉博澄","580,000","1","3MH00978 (2024-03-25預計出貨) ; ","174,000","3","174,000","3",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100129":["M23100129","金順億大坑巷二期","葉博澄","650,000","1","3MH00957 (2024-02-22預計出貨) ; ","195,000","3","195,000","3",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100045":["M23100045","深坑區土庫段廠房-永陞建設","葉博澄","10,300,000","4","4MW00181 (2024-11-01預計出貨) ; 4MW00182 (2024-11-01預計出貨) ; 4MX00183 (2024-11-01預計出貨) ; 4MX00184 (2024-11-01預計出貨) ; ","1,854,000","2","1,854,000","2",0,0,"0","0",0,0,"0","0","0","0",0,0,0,0],"M23100051":["M23100051","山王營造有限公司","葉博澄","530,000","1","3MH00926 (2024-02-19預計出貨) ; ","159,000","4","159,000","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100057":["M23100057","吉成食品","葉博澄","910,000","1","3MW01083 (2024-05-02預計出貨) ; ","273,000","2","273,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100058":["M23100058","岩城營造(億豪建設)-新營區周武段","葉博澄","990,000","1","4MW00217 (2024-04-15預計出貨) ; ","297,000","1","297,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230896":["M230896","勝邦開發建設股份有限公司","葉博澄","1,620,000","3","3MH00352 (2023-10-27試車完畢) ; 3MH00353 (2023-11-01試車完畢) ; 3MH00354 (2023-11-29試車完畢) ; ","1,458,000","8","486,000","8",0,0,"486,000","6",0,0,"486,000","4",0,0,"0","0",0,0],"M23100002":["M23100002","悅綠樹-彰化田中","葉博澄","1,740,000","2","4MW00090 (2024-05-15預計出貨) ; 4MW00091 (2024-05-15預計出貨) ; ","522,000","1","522,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100003":["M23100003","悅綠樹-彰化員林","葉博澄","1,330,000","2","4MW00092 (2024-05-15預計出貨) ; 4MH00093 (2024-05-15預計出貨) ; ","399,000","1","399,000","1",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23090101":["M23090101","佑翔營造工程有限公司","葉博澄","1,160,000","2","3MH00883 (2024-02-27預計出貨) ; 3MH00884 (2024-02-27預計出貨) ; ","348,000","4","348,000","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230848":["M230848","山王營造","葉博澄","530,000","1","3MH00351 (2023-10-27試車完畢) ; ","477,000","8","212,000","8",0,0,"106,000","6",0,0,"159,000","4",0,0,"0","0",0,0],"M230790":["M230790","班米羅幼兒園","葉博澄","750,000","1","3MW00410 (2024-03-05預計出貨) ; ","225,000","8","225,000","8",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230791":["M230791","吳明鴻","葉博澄","960,000","1","3MW00350 (2023-11-10試車完畢) ; ","864,000","8","288,000","8",0,0,"288,000","5",0,0,"288,000","3",0,0,"0","0",0,0],"M23080163":["M23080163","吉旺營造股份有限公司","葉博澄","653,000","1","3MH00879 (2024-03-20預計出貨) ; ","192,000","4","192,000","4",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230743":["M230743","拾益營造-清水幼兒園","葉博澄","790,000","1","3MH00296 (2024-01-31官檢完畢) ; ","711,000","9","316,000","9",0,0,"158,000","5",0,0,"237,000","3",0,0,"0","0",0,0],"M230745":["M230745","陳加樺","葉博澄","550,000","1","3MH00508 (2023-12-19貨抵工地) ; ","330,000","7","165,000","7",0,0,"165,000","2",0,0,"0","0",0,0,"0","0",0,0],"M230415":["M230415","岩城營造(名富建設)","葉博澄","1,800,000","3","3MH00156 (2024-01-08試車完畢) ; 3MH00157 (2024-03-22預計出貨) ; 3MH00158 (2024-01-08試車完畢) ; ","1,260,000","10","540,000","10",0,0,"360,000","4",0,0,"360,000","1",0,0,"0","0",0,0],"M230416":["M230416","雲啟建設(周素鳳)","葉博澄","2,550,000","5","3MH00491 (2024-03-15預計出貨) ; 3MH00492 (2024-03-15預計出貨) ; 3MH00493 (2024-03-15預計出貨) ; 3MH00494 (2024-03-15預計出貨) ; 3MH00495 (2024-03-15預計出貨) ; ","765,000","7","765,000","7",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230432":["M230432","彰員營造股份有限公司","葉博澄","11,860,000","13","3MW00171 (2023-10-20試車完畢) ; 3MW00160 (2024-06-01預計出貨) ; 3MW00161 (2024-06-01預計出貨) ; 3MW00162 (2024-06-01預計出貨) ; 3MW00163 (2024-06-01預計出貨) ; 3MW00164 (2024-06-01預計出貨) ; 3MW00165 (2024-06-01預計出貨) ; 3MW00166 (2024-06-01預計出貨) ; 3MW00167 (2024-06-01預計出貨) ; 3MW00168 (2024-06-01預計出貨) ; 3MW00169 (2024-06-01預計出貨) ; 3MW00170 (2024-06-01預計出貨) ; 3MW00159 (2024-06-01預計出貨) ; ","3,978,000","10","3,558,000","10",0,0,"210,000","6",0,0,"210,000","4",0,0,"0","0",0,0],"M230205":["M230205","金順億建設有限公司","葉博澄","2,520,000","4","3MH00121 (2023-08-18官檢完畢) ; 3MH00122 (2023-08-18官檢完畢) ; 3MH00123 (2023-08-18官檢完畢) ; 3MH00124 (2023-08-18官檢完畢) ; ","2,268,000","10","756,000","10",0,0,"756,000","9",0,0,"756,000","7",0,0,"0","0",0,0],"M230639":["M230639","洪婉楹(林俊輝)","葉博澄","620,000","1","3MH00411 (2024-04-01預計出貨) ; ","186,000","8","186,000","8",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230641":["M230641","秉禾營造(詹朝揚)","葉博澄","640,000","1","3MH00244 (2024-01-16官檢完畢) ; ","576,000","9","256,000","9",0,0,"128,000","4",0,0,"192,000","2",0,0,"0","0",0,0],"M230646":["M230646","立傑營造","葉博澄","1,140,000","1","3MW00243 (2023-10-25試車完畢) ; ","1,026,000","9","342,000","9",0,0,"342,000","6",0,0,"342,000","4",0,0,"0","0",0,0],"M230530":["M230530","保成營造","葉博澄","700,000","1","3MW00210 (2023-11-30官檢完畢) ; ","630,000","10","210,000","10",0,0,"210,000","6",0,0,"210,000","3",0,0,"0","0",0,0],"M230531":["M230531","保成營造","葉博澄","680,000","1","3MW00211 (2024-02-05官檢完畢) ; ","612,000","10","204,000","10",0,0,"204,000","5",0,0,"204,000","2",0,0,"0","0",0,0],"M230593":["M230593","耐福營造股份有限公司","葉博澄","5,160,000","8","3MH00573 (2023-11-17貨抵工地) ; 3MH00574 (2023-11-17貨抵工地) ; 3MH00575 (2024-03-06預計出貨) ; 3MH00576 (2024-01-03貨抵工地) ; 3MH00577 (2024-03-06預計出貨) ; 3MH00578 (2024-01-03貨抵工地) ; 3MW00579 (2024-03-06預計出貨) ; 3MW00580 (2024-03-06預計出貨) ; ","666,000","3","0","0",0,0,"666,000","3",0,0,"0","0",0,0,"0","0",0,0],"M230600":["M230600","玄盟營造","葉博澄","3,600,000","6","3MH00835 (2024-03-19預計出貨) ; 3MH00836 (2024-03-19預計出貨) ; 3MH00837 (2024-03-19預計出貨) ; 3MH00838 (2024-03-20預計出貨) ; 3MH00839 (2024-03-20預計出貨) ; 3MH00840 (2024-03-20預計出貨) ; ","1,080,000","5","1,080,000","5",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M230607":["M230607","豐田流通供應鏈物流有限公司","葉博澄","580,000","1","3MH00259 (2023-10-18試車完畢) ; ","522,000","9","174,000","9",0,0,"174,000","6",0,0,"174,000","4",0,0,"0","0",0,0],"M220316":["M220316","白鴿建設-自由路都更案","黃孟澤","700,000","1","3MH00814 (2024-02-20預計出貨) ; ","280,000","1","0","0","280,000","1","0","0",0,0,"0","0",0,0,"0","0",0,0],"M220381":["M220381","睿邑生物科技廠房","黃孟澤","2,200,000","2","3MW00128 (2023-12-22試車完畢) ; 3MW00129 (2024-01-11安裝完畢) ; ","1,061,650","10","336,800","10",0,0,"673,600","5",0,0,"51,250","2","0","0","0","0",0,0],"M23100027":["M23100027","總財建設實業股份有限公司","黃孟澤","1,456,000","2","3MX00968 (2024-08-15預計出貨) ; 3MX00969 (2024-08-15預計出貨) ; ","436,800","3","436,800","3",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0],"M23100029":["M23100029","高臺營造","黃孟澤","10,080,000","16","3MH01055 (2024-10-15預計出貨) ; 3MH01056 (2024-10-15預計出貨) ; 3MH01057 (2024-10-15預計出貨) ; 3MH01058 (2024-10-15預計出貨) ; 3MH01059 (2024-10-15預計出貨) ; 3MH01060 (2024-10-15預計出貨) ; 3MH01061 (2024-10-15預計出貨) ; 3MH01062 (2024-10-15預計出貨) ; 3MH01063 (2024-10-15預計出貨) ; 3MH01064 (2024-10-15預計出貨) ; 3MH01065 (2024-10-15預計出貨) ; 3MH01066 (2024-10-15預計出貨) ; 3MH01067 (2024-10-15預計出貨) ; 3MH01068 (2024-10-15預計出貨) ; 3MH01069 (2024-10-15預計出貨) ; 3MH01070 (2024-10-15預計出貨) ; ","3,024,000","2","3,024,000","2",0,0,"0","0",0,0,"0","0",0,0,"0","0",0,0]}} \ No newline at end of file +{"Bill":{"M220005":["M220005","【和峻】新長壽段C區","何政揚",3603162,4,"3MX00011 (2023-11-29貨抵工地) ; 3MX00012 (2024-01-29安裝完畢) ; 3MX00013 (2023-11-29貨抵工地) ; 3MX00014 (2024-01-29安裝完畢) ; ",1387217,4,0,4,0,2,1387217,0,"","",0,0,"","","","",0,0],"M220011":["M220011","【和境】善捷段","何政揚",5964849,6,"2MX00016 (2023-12-07貨抵工地) ; 2MX00017 (2024-01-05貨抵工地) ; 2MX00018 (2023-12-07貨抵工地) ; 2MX00019 (2024-01-05貨抵工地) ; 2MX00020 (2024-01-05貨抵工地) ; 2MX00021 (2023-12-07貨抵工地) ; ",1129768,3,0,3,569,2,1129199,0,"","",0,0,"","","","",0,0],"M220012":["M220012","【鴻廣】樂捷段","何政揚",7807005,7,"2MX00006 (2024-02-05已移交) ; 2MX00007 (2023-10-27貨抵工地) ; 2MX00008 (2023-12-12已移交) ; 2MX00009 (2024-01-19已移交) ; 2MX00010 (2023-10-27貨抵工地) ; 2MX00011 (2023-10-27貨抵工地) ; 2MX00012 (2023-12-19已移交) ; ",3708328,6,1,6,0,5,3005697,2,"","",702630,0,"","","","",0,0],"M220013":["M220013","【鴻承 】豐田段一期","何政揚",6786188,4,"3MX00015 (2024-03-20預計出貨) ; 3MX00016 (2024-02-29預計出貨) ; 3MX00017 (2024-03-20預計出貨) ; 3MX00018 (2024-02-29預計出貨) ; ",712550,1,712550,1,0,0,0,0,"","",0,0,"","","","",0,0],"M220114":["M220114","【鴻豐】大金山下段","何政揚",4136280,4,"3MX00019 (2023-09-28貨抵工地) ; 3MX00020 (2023-12-25已移交) ; 3MX00021 (2023-12-25已移交) ; 3MX00022 (2023-09-28貨抵工地) ; ",2026778,7,0,7,0,4,1592468,4,"","",434310,0,"","","","",0,0],"M220115":["M220115","【鴻築】青山段","何政揚",4073580,4,"2MX00022 (2023-12-29貨抵工地) ; 2MX00023 (2023-11-30貨抵工地) ; 2MX00024 (2024-02-06安裝完畢) ; 2MX00025 (2023-12-29貨抵工地) ; ",1359143,3,0,3,0,2,1568328,0,"","",-209185,0,"","","","",0,0],"M220179":["M220179","【鴻築】大湖段A區","何政揚",3056365,3,"2MX00013 (2023-12-25已移交) ; 2MX00014 (2023-12-25已移交) ; 2MX00015 (2023-12-25已移交) ; ",641836,5,-1,0,0,5,0,3,"","",641837,1,"","","","",0,0],"D23090047":["D23090047","【秉和】榮華段","何政揚",10821075,10,"3MX00740 (2024-01-31安裝完畢) ; 3MX00741 (2024-01-15貨抵工地) ; 3MX00742 (2024-02-01已移交) ; 3MX00743 (2024-01-15貨抵工地) ; 3MX00744 (2023-12-15貨抵工地) ; 3MX00745 (2024-01-15貨抵工地) ; 3MX00746 (2023-12-15貨抵工地) ; 3MX00747 (2024-01-15貨抵工地) ; 3MX00748 (2024-01-15貨抵工地) ; 3MX00749 (2023-12-15貨抵工地) ; ",2083058,3,1,3,1,2,2083056,0,"","",0,0,"","","","",0,0],"M220245":["M220245","【勝麗】興隆B3-2區(協侑)","何政揚",463200,1,"3MH00482 (2024-01-18貨抵工地) ; ",145908,2,48636,2,97272,1,0,0,"","",0,0,"","","","",0,0],"M230780":["M230780","【勝麗】興隆B3-4區","何政揚",2609862,3,"3MX00628 (2023-12-01貨抵工地) ; 3MX00629 (2024-02-02試車完畢) ; 3MX00630 (2023-12-01貨抵工地) ; ",1552869,3,2,3,548071,2,1004796,0,"","",0,0,"","","","",0,0],"M23080111":["M23080111","【協勝】育賢段","何政揚",4452002,4,"3MX00729 (2023-12-20貨抵工地) ; 3MX00730 (2023-12-20貨抵工地) ; 3MX00731 (2023-12-20貨抵工地) ; 3MX00732 (2023-12-20貨抵工地) ; ",1714022,3,0,3,0,2,1714022,0,"","",0,0,"","","","",0,0],"M230878":["M230878","【協和】市鎮北段二期","何政揚",9205241,8,"3MX00631 (2023-12-08貨抵工地) ; 3MX00632 (2023-12-12貨抵工地) ; 3MX00633 (2023-12-08貨抵工地) ; 3MX00634 (2023-12-12貨抵工地) ; 3MX00635 (2023-12-12貨抵工地) ; 3MX00636 (2023-12-08貨抵工地) ; 3MX00637 (2023-12-08貨抵工地) ; 3MX00638 (2023-12-12貨抵工地) ; ",3544013,2,-2,0,-2,2,3544017,0,"","",0,0,"","","","",0,0],"M23090105":["M23090105","【益翔】市鎮南段二期","何政揚",4214001,4,"3MX00809 (2024-01-09貨抵工地) ; 3MX00810 (2024-01-09貨抵工地) ; 3MX00811 (2024-01-09貨抵工地) ; 3MX00812 (2024-01-09貨抵工地) ; ",884941,2,110618,2,774323,1,0,0,"","",0,0,"","","","",0,0],"M231009":["M231009","【泓瑞】育賢段","何政揚",9997399,8,"3MX00672 (2023-12-07貨抵工地) ; 3MX00673 (2023-12-07貨抵工地) ; 3MX00674 (2023-12-07貨抵工地) ; 3MX00675 (2023-12-26貨抵工地) ; 3MX00676 (2023-12-26貨抵工地) ; 3MX00677 (2023-12-07貨抵工地) ; 3MX00678 (2023-12-26貨抵工地) ; 3MX00679 (2023-12-07貨抵工地) ; ",5948451,2,-1,0,2099454,2,3848998,0,"","",0,0,"","","","",0,0],"M231011":["M231011","【佳友】北城段","何政揚",1975764,2,"3MX00614 (2024-01-24貨抵工地) ; 3MX00615 (2024-01-24貨抵工地) ; ",622365,2,207455,2,414910,0,0,0,"","",0,0,"","","","",0,0],"M220001":["M220001","【恆鵬】善新段","謝文憲",2911500,3,"3MX00191 (2024-02-20預計出貨) ; 3MX00192 (2024-02-20預計出貨) ; 3MX00193 (2024-02-20預計出貨) ; ",305708,1,305708,1,0,0,0,0,"","",0,0,"","","","",0,0],"last":["合計","","","",75,"",27766955,"",1384967,"",3934598,"",20877798,"",0,"",1569592,"",0,"",0,"",0,""]}} \ No newline at end of file diff --git a/wms/bonus/bonus_person.php b/wms/bonus/bonus_person.php index 1b01b289..501c5b21 100644 --- a/wms/bonus/bonus_person.php +++ b/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)) { - $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; - $clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' "; - } else { - $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' "; - } +// 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; + $clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' "; +} 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++) { +
@@ -117,6 +118,12 @@ for ($i = 0; $i < COUNT($results); $i++) { + btn-sm categoryBtn"> 所有獎金 + + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 獎金總計(人)
@@ -143,4 +150,91 @@ for ($i = 0; $i < COUNT($results); $i++) { } ?>
- \ No newline at end of file + + + \ No newline at end of file diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php new file mode 100644 index 00000000..c639fe48 --- /dev/null +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php @@ -0,0 +1,236 @@ +$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 "
";
+	// print_r($elevator_pay_kind);
+	// echo "
"; + // 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 "
";
+			// print_r($pay_scale);
+			// echo "
"; + 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; +}; diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php index 97c47660..17a5899a 100644 --- a/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_examination.php @@ -1,9 +1,15 @@ '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"; + // print_r($examination_array); + // echo ""; + echo "獎金版本:" . $result["ver"] . "
"; echo "計算結果:" . $result["result_status"] . "
"; - echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . "
"; - for($j = 0; $j"; + 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"] . "
"; + . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["payment_schedul_due"] . " " + . $result["bonus_array"][$j]["payment_schedul_regulation"] . "
"; }; echo "-------------------------" . "
"; - }; - - -?> diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php new file mode 100644 index 00000000..a63b72a8 --- /dev/null +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php @@ -0,0 +1,166 @@ +$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; +}; diff --git a/wms/bonus/maintainance_bonus.php b/wms/bonus/maintainance_bonus.php index ee2ab36b..5734d57c 100644 --- a/wms/bonus/maintainance_bonus.php +++ b/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 "
";
+// print_r($sql);
+// echo "
"; $stmt = $conn->prepare($sql); $stmt->execute(); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -85,11 +88,11 @@ $id_str = implode(',', $id); - btn-sm categoryBtn"> 所有獎金 + btn-sm categoryBtn"> 所有獎金 - btn-sm categoryBtn"> 未發獎金 - btn-sm categoryBtn"> 已發獎金 - btn-sm categoryBtn"> 人事發放作業 + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 btn-sm categoryBtn"> 獎金總計(人) diff --git a/wms/bonus/maintance/maintaenance_contract_bonus.php b/wms/bonus/maintance/maintaenance_contract_bonus.php new file mode 100644 index 00000000..b267eef9 --- /dev/null +++ b/wms/bonus/maintance/maintaenance_contract_bonus.php @@ -0,0 +1,748 @@ += 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; +}; diff --git a/wms/bonus/maintance/maintenance_contract_bonus_v2_0.php b/wms/bonus/maintance/maintenance_contract_bonus_v2_0.php index c2cadb3e..c665f1bd 100644 --- a/wms/bonus/maintance/maintenance_contract_bonus_v2_0.php +++ b/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; - break; + $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; - break; + $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; - break; + $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) @@ -86,29 +87,29 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, #專任契約經理獎金($regular_contract_manger_bonus) $regular_contract_manger_bonus = 100; break; - + 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) $region_manager_bonus = 100; #專任契約經理獎金($regular_contract_manger_bonus) $regular_contract_manger_bonus = 100; break; }; - + #合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) switch ($discount) { case ($discount < 0.6): @@ -121,128 +122,125 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $sales_bonus = $sales_bonus * 1.0; break; }; - + #簽約年數($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年獎金 ***/ + ]); + /*** 以上第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年獎金 ***/ - + ]); + /*** 以上第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, #金額 "pay_day_due" => "9999-1-1", #預計發放時間 "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; }; - - -?> diff --git a/wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php b/wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php index de316b53..3fe834f6 100644 --- a/wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php +++ b/wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php @@ -44,113 +44,118 @@ 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"; echo "計算結果:" . $result["result_status"] . "
"; + 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] . "
"; 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] . "
"; - for($j = 0; $j"; + 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"] . "
"; + . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " + . $result["bonus_array"][$j]["bonus_regulation"] . "
"; }; echo "-------------------------" . "
"; - }; - - -?> diff --git a/wms/bonus/other/maintenance_contract_bonus_v2_1.php b/wms/bonus/other/maintenance_contract_bonus_v2_1.php index 9015a83c..0f6d3227 100644 --- a/wms/bonus/other/maintenance_contract_bonus_v2_1.php +++ b/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) { diff --git a/wms/class/Cmail.php b/wms/class/Cmail.php index 51ed924b..eadc2a0d 100644 --- a/wms/class/Cmail.php +++ b/wms/class/Cmail.php @@ -1,4 +1,5 @@ charset = "UTF-8"; $this->host = "mail.masada.com.tw"; @@ -23,8 +24,8 @@ class Cmail $this->smtp_user = "notice"; // 這裡填寫SMTP登入帳號, 例如 your.gmail.name@gmail.com 則填寫your.gmail.name $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"; } } -} \ No newline at end of file +} diff --git a/wms/class/T8API.php b/wms/class/T8API.php new file mode 100644 index 00000000..e4a60d8e --- /dev/null +++ b/wms/class/T8API.php @@ -0,0 +1,38 @@ += :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); diff --git a/wms/cont/api/getUsername.php b/wms/cont/api/getUsername.php new file mode 100644 index 00000000..396682d1 --- /dev/null +++ b/wms/cont/api/getUsername.php @@ -0,0 +1,15 @@ +prepare($sql_str); +$stmt->bindParam(':accountid', $accountid); +$stmt->execute(); +$user = $stmt->fetch(PDO::FETCH_ASSOC); +echo $user['name']; \ No newline at end of file diff --git a/wms/cont/api/postElevatorPricereview.php b/wms/cont/api/postElevatorPricereview.php index e69de29b..03356932 100644 --- a/wms/cont/api/postElevatorPricereview.php +++ b/wms/cont/api/postElevatorPricereview.php @@ -0,0 +1,484 @@ +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 . "
"; + $content .= "客戶名稱:" . $customer . "
"; + $content .= "案件名稱:" . $case_name . "
"; + $content .= "時間" . $current_date; + // $content .= "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; +} \ No newline at end of file diff --git a/wms/cont/api/postSystemNotice.php b/wms/cont/api/postSystemNotice.php new file mode 100644 index 00000000..acfc49e1 --- /dev/null +++ b/wms/cont/api/postSystemNotice.php @@ -0,0 +1,20 @@ +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(); + } +} \ No newline at end of file diff --git a/wms/cont/js/pricereviewAlpine.js b/wms/cont/js/pricereviewAlpine.js index 1fabad15..03423d76 100644 --- a/wms/cont/js/pricereviewAlpine.js +++ b/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 ; }, } } \ No newline at end of file diff --git a/wms/cont/pricereviewCreate.php b/wms/cont/pricereviewCreate.php index 27174458..e8eaf216 100644 --- a/wms/cont/pricereviewCreate.php +++ b/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 ""; +} +if($apply['status'] == 'YS'){ + echo ""; +} +if($apply['status'] == 'YY' || $apply['status'] == 'YN'){ + echo ""; +} + +$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){ 電梯品牌 - + 電梯數量 營業員 - + 當前契約期限結束 @@ -106,6 +188,7 @@ function getApplyKey($p_yyyymm, $seq_name){ + 請選擇契約性質 付款方式 @@ -117,13 +200,23 @@ function getApplyKey($p_yyyymm, $seq_name){ + 請選擇付款方式 案件名稱 - + + + 請填寫案件名稱 + 合約開始日期 - + + + 請填寫合約開始日期 + 合約結束日期 - + + + 請填寫合約結束日期 + @@ -136,7 +229,7 @@ function getApplyKey($p_yyyymm, $seq_name){ - + @@ -179,28 +272,26 @@ function getApplyKey($p_yyyymm, $seq_name){ 電梯 - - - 載重(KG) - + 停數 - + 速度(m/min) - @@ -215,7 +306,7 @@ function getApplyKey($p_yyyymm, $seq_name){ 人乘 - @@ -296,7 +387,7 @@ function getApplyKey($p_yyyymm, $seq_name){ 保養方式 - @@ -305,7 +396,7 @@ function getApplyKey($p_yyyymm, $seq_name){ 贈送M1 - @@ -315,6 +406,7 @@ function getApplyKey($p_yyyymm, $seq_name){ 公司發布價(月) + 公司無提供此規格牌價 保養月數 @@ -350,6 +442,7 @@ function getApplyKey($p_yyyymm, $seq_name){ 單價 數量 複價 + 備註 所屬電梯 功能 @@ -364,10 +457,11 @@ function getApplyKey($p_yyyymm, $seq_name){ - + 請輸入正整數 + 小計 - + @@ -481,5 +575,26 @@ function getApplyKey($p_yyyymm, $seq_name){ const progress_status = ''; const user_id = ''; const user_name = ''; + const progress_remark = ``; + + const memo = ``; + + const contract_kind = ''; + const payment_kind = ''; + const case_name = ''; + const contract_begin_date = ''; + const contract_end_date = ''; + + const total_spec = ''; + const hope_elevators = [...]; + const otherOptionKey = ''; + const otherOptions = [...]; + const token = ''; + + const penalty = ''; + const deposit_rate = ''; + const keep_rate = ''; + const warranty_rate = ''; + const service_fee = ''; \ No newline at end of file diff --git a/wms/cont/window-modal/modalElevaotr.php b/wms/cont/window-modal/modalElevaotr.php index 045362b7..602e7c86 100644 --- a/wms/cont/window-modal/modalElevaotr.php +++ b/wms/cont/window-modal/modalElevaotr.php @@ -110,7 +110,7 @@ 保養方式 - + - + + diff --git a/wms/contract/api/T8api.php b/wms/contract/api/T8api.php index 88d8dffa..842b62fc 100644 --- a/wms/contract/api/T8api.php +++ b/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 '
';
-    print_r($validation);
-    echo '
'; - // 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); diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index e2aedd43..60519045 100644 --- a/wms/contract/api/getContractData.php +++ b/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 "
";
-                        // print_r($option['item_unit_price']);
-                        // echo "
"; } 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 "
";
-                        // print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
-                        // echo "
"; } else { $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); - // echo '3..'; } - // echo '
';
-                    // print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
-                    // echo '
'; } - - // print_r($result['option_price']); - // exit(); } // 查詢保固延長 $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='E' AND option_relate_spec = :item_no"; diff --git a/wms/contract/api/getT8NewContractData.php b/wms/contract/api/getT8NewContractData.php index 2d348558..4b5d0513 100644 --- a/wms/contract/api/getT8NewContractData.php +++ b/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,41 +20,76 @@ 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 + + // 查詢作番號,與每台電梯在合約的價格、站比 + $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, -- 收款階段 PlanPercentage, -- 收款比例 PlanPayAmt -- 收款金額 FROM salOrderStagePay WHERE BillNo = '$no'"; - $stmt = $connT8->prepare($sql); - $stmt->execute(); - $Detail = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (!empty($Detail)) { - foreach ($Detail as $key => $detail) { - $detail['PlanPercentage'] = (float)$detail['PlanPercentage']; - $Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位 - $Detail[$key]['PlanPayAmt'] = intval($detail['PlanPayAmt']); // 比例金額轉整數 + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $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]['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) == '寶佳') { + $result_master['customer_status'] = 'strategy_customer'; + } else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') { + $result_master['customer_status'] = 'strategy_customer'; + } else { + $result_master['customer_status'] = 'general_customer'; + } - if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') { - $result_master['customer_status'] = 'strategy_customer'; - } else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') { - $result_master['customer_status'] = 'strategy_customer'; - } else { - $result_master['customer_status'] = 'general_customer'; + $result_master['total_price'] = intval($result['OAmount']); + $result_master['elevotor_pay_detail'] = $Detail; + $result_arr[] = $result_master; + // echo "
";
+                // print_r($result_arr);
+                // echo "
"; } - - $result_master['total_price'] = intval($result['OAmount']); - $result_master['detail'] = $Detail; - $result_arr[] = $result_master; } + // exit; + // $result_master[] = $result; } } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 9522defe..296d7144 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,16 +1,17 @@ - - 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 '
';
         //     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 . "-請安排此作番的保養人員  點我";
+            // 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 '
';
-        // print_r($elevator);
-        // echo '
'; + $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 "
";
+    // print_r($salIncomeApplyDetail_rows);
+    // echo "
"; + 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 '
';
-    print_r($API_body);
+    print_r(json_encode($API_body));
     echo '
'; - $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 '
';
+    // print_r($result);
+    // echo '
'; + // 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( - $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 - ); - } + ///////////////////////////////// + // 如果保養合約 大於一年 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, + $contract_years, + $discount, // 折扣率 + $fee_per_st, //售價 + $receivable_date_due, // 第一筆金額繳款時間 + $sales_id, + $region_director_id, + $regular_contract_manger_id + ); } - + // } + ///////////////////////////////// + // echo "
";
+            // print_r($results);
+            // echo "
"; + ///////////////////////////////// $bonus_json = [ 'contract_type' => $contract_type, 'total' => $elevator_list_price, diff --git a/wms/contract/api/test copy.json b/wms/contract/api/test copy.json index cb1ba7c7..7ef01c22 100644 --- a/wms/contract/api/test copy.json +++ b/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" } ] \ No newline at end of file diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php deleted file mode 100644 index a77acf8b..00000000 --- a/wms/contract/api/testT8API.php +++ /dev/null @@ -1,258 +0,0 @@ - "$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 "
";
-// print_r($data);
-// echo "
"; - -echo "
";
-print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
-echo "
"; -// 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); diff --git a/wms/contract/api/testocde.php b/wms/contract/api/testocde.php new file mode 100644 index 00000000..b6bb6c8d --- /dev/null +++ b/wms/contract/api/testocde.php @@ -0,0 +1,10 @@ +prepare($sql); +$stmt->execute(); +$pay_kind = $stmt->fetchAll(PDO::FETCH_ASSOC); + +echo "
";
+print_r($pay_kind);
+echo "
"; diff --git a/wms/contract/conn.php b/wms/contract/conn.php index bbfd1c50..5ac49515 100644 --- a/wms/contract/conn.php +++ b/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) { diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 92aaf7d0..48d61379 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -64,7 +64,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - 立約人 + 客戶名稱

未填寫

@@ -74,12 +74,12 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- 合約開始時間 + 電梯台數

未填寫

電梯數量需大於0

- - 統一編號/身分證 + 分期方式 - -

未填寫

+ +

未填寫

- 維修型態 + + + + 簽約日 + + +

未填寫

+ + 合約開始時間 + + +

未填寫

+ + 合約終止時間 + + +

未填寫

+ + 契約成交價 @@ -118,26 +141,33 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); + 發票抬頭 + + + + + 統一編號/身分證 + + + + 客戶電話 -

未填寫

- - Email - - -

未填寫

+ - 保養員 + 區域 - + + -

未填寫

+

未填寫

+ + - 分期方式 - - -

未填寫

- + - - 業務聯繫人 + + - 區域 - - -

未填寫

- 詳細地址 + 發票地址 + + + + + 現場地址

未填寫

- 附件 - - + + 保養經理 + + + + 合約類別 @@ -211,9 +244,22 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - + +

未填寫

+ + + + + 合約附件 + + + + + + + @@ -335,14 +381,16 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 許可證有效日期
(民國年-月-日。Ex.113-01-01) -

未填寫

+ 保養頻率

未填寫

@@ -372,7 +420,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 契約人員 - 保養月份 + 合約總計保養月份 @@ -387,25 +435,27 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); --> 獎金適用版本 - + 作番契約金額(月) - 服務費 - - - - 牌價(標準價) + 折扣率
(取小數點第一位) + + + 地區處長員工號 - -

標準價+Option價格+與其他電梯共同分擔的費用貨價格

+ - 地區處長員工號 - 專任契約經理員工號 - + - -
- - -
- -
- - -
- -
- - -
- -
- - -
-
- - -
+--> -
- - -
- -
- - -
- - -
-
- -
- - - +
+ + +
+ + +
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/wms/schedule-index.php b/wms/schedule-index.php index 0aec06c1..bf13ef45 100644 --- a/wms/schedule-index.php +++ b/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) : 建檔時間 修改 - 刪除 + + 安排保養計畫人員 @@ -211,15 +216,17 @@ if ($data) : - + 查看明細 - 瀏覽 + 瀏覽 瀏覽"; - } ?> + } ?> + @@ -248,11 +255,16 @@ if ($data) :

-

+ + +

+ 安排 +

+ diff --git a/wms/schedule-setting-repaire-update.php b/wms/schedule-setting-repaire-update.php new file mode 100644 index 00000000..7f586808 --- /dev/null +++ b/wms/schedule-setting-repaire-update.php @@ -0,0 +1,66 @@ +prepare($sql); + $stmt->execute(); + $checkRepaireIsit = $stmt->fetch(PDO::FETCH_ASSOC); + if (!empty($checkRepaireIsit)) { + echo ""; + } + + + $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 ""; + } elseif ($affected == 0) { + echo ""; + } else { + echo "{$db_query} 語法執行失敗,錯誤訊息SSS: "; + } +} diff --git a/wms/schedule-setting-repaire.php b/wms/schedule-setting-repaire.php new file mode 100644 index 00000000..bf2468d3 --- /dev/null +++ b/wms/schedule-setting-repaire.php @@ -0,0 +1,192 @@ +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) : +?> + +
+
+ + +
+ + +
+ +
+ + +
+ + +
+ + +
+ + + + + + + + + +
+ + +
+ + +
+
+ + +
+ + + +
+
+ + + + + \ No newline at end of file diff --git a/wms/sign/list.php b/wms/sign/list.php index f2d65bf5..bde03b37 100644 --- a/wms/sign/list.php +++ b/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