diff --git a/wms/account-receivable-renovate-excel.php b/wms/account-receivable-renovate-excel.php index 77341d5a..36463a97 100644 --- a/wms/account-receivable-renovate-excel.php +++ b/wms/account-receivable-renovate-excel.php @@ -13,30 +13,51 @@ $Bill = json_decode(file_get_contents("php://input"), true); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // file_put_contents('account-receivable.txt', json_encode($Bill)); +if ($type == 'repair') { + $colomnHeader = [ + '合約號', '合約日期', '客戶編號', '客戶名稱', + '部門', '契約人員工號', '契約人員名稱', + '主管工號', '主管名稱', + '合約總金額', '應收金額', + '已開金額', '未開金額', + '已收金額', '催收金額', '催收次數' + ]; + $sheet->fromArray($colomnHeader, NULL, 'A1'); + $rowIndex = 2; + foreach ($Bill as $key => $value) { -$colomnHeader = [ - '合約號', '作番號', '部門編號', '部門名稱', '主管工號','主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址', - '收款階段名稱', '應收日期','是否應收', '應收金額', '已開金額','未開金額', '已收金額','催收金額', '催收次數' -]; -$sheet->fromArray($colomnHeader, NULL, 'A1'); -$rowIndex = 2; -foreach ($Bill as $key => $value) { - - $sheet->fromArray($value, NULL, 'A' . $rowIndex); - $column = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R','S','T' + $sheet->fromArray($value, NULL, 'A' . $rowIndex); + $column = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q' + ]; + foreach ($column as $col) { + $sheet->getColumnDimension($col)->setAutoSize(true); + } + $rowIndex++; + } + $writer = new Xlsx($spreadsheet); + $excelFileName = 'account-receivable-repair.xlsx'; +} else { + $colomnHeader = [ + '合約號', '作番號', '部門編號', '部門名稱', '主管工號', '主管名稱', '營業員工號', '營業員名稱', '客戶名稱', '抬頭', '統編', '通訊地址', + '收款階段名稱', '應收日期', '是否應收', '應收金額', '已開金額', '未開金額', '已收金額', '催收金額', '催收次數' ]; - foreach ($column as $col) { - $sheet->getColumnDimension($col)->setAutoSize(true); + $sheet->fromArray($colomnHeader, NULL, 'A1'); + $rowIndex = 2; + foreach ($Bill as $key => $value) { + + $sheet->fromArray($value, NULL, 'A' . $rowIndex); + $column = [ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T' + ]; + foreach ($column as $col) { + $sheet->getColumnDimension($col)->setAutoSize(true); + } + $rowIndex++; } - $rowIndex++; + $writer = new Xlsx($spreadsheet); + $excelFileName = 'account-receivable-renovate.xlsx'; } -$writer = new Xlsx($spreadsheet); -$excelFileName = 'account-receivable-renovate.xlsx'; $writer->save($excelFileName); echo $excelFileName; -?> - \ No newline at end of file diff --git a/wms/account-receivable-renovate.xlsx b/wms/account-receivable-renovate.xlsx index 3c8c5dcf..0228fc23 100644 Binary files a/wms/account-receivable-renovate.xlsx and b/wms/account-receivable-renovate.xlsx differ diff --git a/wms/account-receivable-repair-index.php b/wms/account-receivable-repair-index.php new file mode 100644 index 00000000..bd1d7acc --- /dev/null +++ b/wms/account-receivable-repair-index.php @@ -0,0 +1,483 @@ += $start_date "; +} +if (!is_null($end_date)) { + $end_date = (int)date('Ymd', strtotime($end_date)); + $sql_contractNumber .= " AND MainAll.BillDate <= $end_date "; +} +if ((in_array($user_id, array('M0008', 'M0012'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '501')))) { +} else { + $sql_contractNumber .= " AND (MainAll.PersonId = '$user_id'"; + if (count($follower) > 0) { + $column_str = "('$user_id'" . ",'"; + $column_str .= implode("','", $follower); + $column_str .= "')"; + $sql_contractNumber .= " OR MainAll.PersonId IN $column_str)"; + } else { + $sql_contractNumber .= ")"; + }; +} + +$contractNumbers = array(); +$query_contract_number = $conn->query($sql_contractNumber); +if (is_iterable($query_contract_number)) { + foreach ($query_contract_number as $contract_numbers) { + array_push($contractNumbers, $contract_numbers['BillNo']); + $arrayData[$contract_numbers['BillNo']]['BillNo'] = isset($contract_numbers['BillNo']) ? $contract_numbers['BillNo'] : '--'; + $arrayData[$contract_numbers['BillNo']]['BillDate'] = isset($contract_numbers['BillDate']) ? $contract_numbers['BillDate'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerId'] = isset($contract_numbers['BizPartnerId']) ? $contract_numbers['BizPartnerId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerName'] = isset($contract_numbers['BizPartnerName']) ? $contract_numbers['BizPartnerName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['CustomerAddress'] = isset($contract_numbers['ContactAddress']) ? $contract_numbers['ContactAddress'] : '--'; + $arrayData[$contract_numbers['BillNo']]['OAmountWithTax'] = isset($contract_numbers['OAmountWithTax']) ? $contract_numbers['OAmountWithTax'] : 0; + $arrayData[$contract_numbers['BillNo']]['PersonId'] = isset($contract_numbers['PersonId']) ? $contract_numbers['PersonId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['DeptId'] = isset($contract_numbers['DeptId']) ? $contract_numbers['DeptId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['PersonName'] = isset($contract_numbers['PersonName']) ? $contract_numbers['PersonName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['DeptName'] = isset($contract_numbers['DeptName']) ? $contract_numbers['DeptName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ManagerId'] = !empty($find_manager[$contract_numbers['PersonId']]['manager']) ? $find_manager[$contract_numbers['PersonId']]['manager'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ManagerName'] = !empty($find_manager[$contract_numbers['PersonId']]['manager_name']) ? $find_manager[$contract_numbers['PersonId']]['manager_name'] : '--'; + $arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['received_budget'] = 0; + $arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0; + $sum_total_budget += $contract_numbers['OAmountWithTax']; + } + $str_numbers = "('" . implode("','", $contractNumbers) . "')"; +} + +// T8發票 +$sql_invoice = "SELECT +Detail.BillNo AS InvoiceBillNo, +Detail.MaterialId, +Detail.LAmountWithTax, +Main.InvoiceNo, +CheckAll.FromSalSalesOrder AS BillNo + FROM arSellInvoiceMaterial AS Detail + LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo + LEFT JOIN ( + SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo + FROM arCheckBillDetail AS CheckDetail ) + AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo + WHERE Detail.ItemType=0 AND Main.InvoiceState!=2"; + +// T8核銷 +$sql_received = "SELECT +CheckDetail.OrderBillNo, +arWriteOffBillDetail.FromBillNo AS CheckBillNo, +arWriteOffBillDetail.FromRowCode AS CheckRowCode, +arWriteOffBillDetail.CurrStandOffOAmount +FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBillDetail.BillNo, + arCheckBillDetail.RowCode, + arCheckBillDetail.FromSalSalesOrder AS OrderBillNo, + salSalesOrder.TypeId + FROM arCheckBillDetail + LEFT JOIN salSalesOrder + ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder ) + AS CheckDetail + ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode +WHERE CheckDetail.TypeId = 'SP'"; + + +//T8 銷售訂單 階段收款計畫 +$sql_paystage = "SELECT * from salOrderStagePay"; +if (isset($str_numbers)) { + $sql_paystage .= " WHERE BillNo IN $str_numbers "; + $sql_invoice .= " AND CheckAll.FromSalSalesOrder IN $str_numbers "; +} + +$PayStage = $conn->query($sql_paystage); +$received_array = $conn->query($sql_received); +$invoice_data = $conn->query($sql_invoice); + +$allPayStages = array(); +foreach ($PayStage as $stage) { + $allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayAmt'] = $stage['PlanPayAmt']; + $allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayDate'] = $stage['PlanPayDate']; + $month = collect_month(strtotime($stage['PlanPayDate'])); + if (strtotime($stage['PlanPayDate']) > strtotime(date('Y-m-t', strtotime('now')))) { + $allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = '--'; + } else { + $allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = 'Y'; + } + $allPayStages[$stage['BillNo']][$stage['PayStage']]['month'] = $month; + $allPayStages[$stage['BillNo']][$stage['PayStage']]['received'] = 0; + $allPayStages[$stage['BillNo']][$stage['PayStage']]['invoice'] = 0; +} +foreach ($allPayStages as $paykey => $pay) { + uasort($allPayStages[$paykey], 'comparePlanPayDate'); +} + +foreach ($allPayStages as &$payStage) { + $sequenceNumber = 1; + foreach ($payStage as $tk => &$pstage) { + $pstage['sequenceNumber'] = $sequenceNumber; + $sequenceNumber += 1; + } +} +// 整理好的收款階段 +$final_paystage = array(); +foreach ($allPayStages as $key => &$payStage) { + if (is_iterable($payStage)) { + foreach ($payStage as $key2 => $pstage) { + if (isset($arrayData[$key])) { + $arrayData[$key]['PayStage'][$pstage['sequenceNumber']] = $pstage; + if (isset($pstage['receivable_ornot']) && $pstage['receivable_ornot'] == 'Y') { + $arrayData[$key]['receivable_budget'] += $pstage['PlanPayAmt']; + } + } + } + } +} + +foreach ($invoice_data as $inv) { + if (isset($arrayData[$inv['BillNo']])) { + + $arrayData[$inv['BillNo']]['invoice_budget'] += $inv['LAmountWithTax']; + + if (isset($arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']])) { + $arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] += $inv['LAmountWithTax']; + } else { + $arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] = $inv['LAmountWithTax']; + } + } +} +foreach ($received_array as $received) { + if (isset($arrayData[$received['OrderBillNo']]) && isset($received['CurrStandOffOAmount']) && $received['CurrStandOffOAmount'] > 0) { + $arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount']; + } +} + + +foreach ($arrayData as $key => &$value) { + if (!isset($value['PayStage'])) { + $value['receivable_budget'] = $value['OAmountWithTax']; + } else { + $tmpReceived = $value['received_budget']; + $tmpInvoice = $value['invoice_budget']; + if (is_iterable($value['PayStage'])) { + for ($sequence = 1; $sequence <= count($value['PayStage']); $sequence++) { + if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpInvoice) { + $value['PayStage'][$sequence]['invoice'] = $tmpInvoice; + $tmpInvoice = 0; + } else { + $value['PayStage'][$sequence]['invoice'] = $value['PayStage'][$sequence]['PlanPayAmt']; + $tmpInvoice -= $value['PayStage'][$sequence]['PlanPayAmt']; + } + if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpReceived) { + $value['PayStage'][$sequence]['received'] = $tmpReceived; + $tmpReceived = 0; + } else { + $value['PayStage'][$sequence]['received'] = $value['PayStage'][$sequence]['PlanPayAmt']; + $tmpReceived -= $value['PayStage'][$sequence]['PlanPayAmt']; + } + } + } + $value['received_budget'] = $tmpReceived; + } + if ($value['receivable_budget'] > 0 && $value['received_budget'] < $value['receivable_budget']) { + $value['month'] = collect_month(strtotime($value['BillDate'])); + } else { + $value['month'] = 0; + } +} + +$excel_aray = array(); + +foreach ($arrayData as $key => $value) { + $uninvoice_budget = $value['OAmountWithTax'] - $value['invoice_budget']; + $unreceive_budget = $value['receivable_budget'] - $value['received_budget']; + + $excel_aray[$key] = [ + $value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'], + $value['DeptName'], $value['PersonId'], $value['PersonName'], + $value['ManagerId'], $value['ManagerName'], + number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])), + number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)), + number_format(round($value['received_budget'])), $unreceive_budget, $value['month'] + ]; +} + +$total_data = json_encode($excel_aray); + +?> + + +
合約號 | +合約日期 | +客戶編號 | +客戶名稱 | +部門 | +主管 | +契約員 | +合約總金額 | +應收金額 | +已開金額 | +未開金額 | +已收金額 | +催收金額 | +催收次數 | +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= $row[0]; ?> | += $row[1]; ?> | += $row[2] ?> | += $row[3] ?> | += $row[4] ?> | += $row[7] . " " . $row[8]; ?> |
+ = $row[5] . " " . $row[6]; ?> |
+ = $row[9]; ?> | += $row[10]; ?> | += $row[11]; ?> | += $row[12]; ?> | += $row[13]; ?> | += $row[14]; ?> | += $row[15]; ?> | +
營業人員/契約人員 | -合約號 | -標示號 | -電梯編號 | -預計請款日 | -催收次數 | -應收申請單狀態 | -請款金額(未轉應收) | -請款金額(已轉應收) | -應收申請單號 | -發票狀態 | -發票單標示號 | -發票單號 | -發票明細 | -發票金額 | -發票號碼 | -核銷 | - -
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- "; - echo getSalesmanName($link, $row['BillNo']); - ?> - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -- - | -
'; + // print_r($result); + // echo ''; + $bonus_type = $result['bonus_type']; + $pay_day = $result['pay_day_due']; + $amount = $result['bonus_amount']; + $receiver = $result['bonus_receiver']; + $discount = $result['discount']; + foreach ($bonus_json as $json) { + $json['discount'] = "$discount"; + $a = json_encode($json); + } + echo '
'; + print_r($a); + echo ''; + // exit(); + // $sql = "INSERT INTO bonus + // (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES + // ($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; + // $stmt = $conn->prepare($sql); + // $stmt->execute(); + // $count++; + // echo '
'; + // print_r($count . '-- > Success'); + // echo ''; + + // exit; + } + } else { + header('Content-Type: application/json'); + echo json_encode($results); + } + } +} diff --git a/wms/bonus/api/updateBonus.php b/wms/bonus/api/updateBonus.php new file mode 100644 index 00000000..2748a91d --- /dev/null +++ b/wms/bonus/api/updateBonus.php @@ -0,0 +1,27 @@ +;prepare($sql); + $stmt->bindParam(':bonus_type', $bonus_type); + $stmt->bindParam(':bonus_verson', $bonus_verson); + $stmt->bindParam('conreact_no', $contract_no); + $stmt->bindParam(':contract_type', $contract_type); + } + } diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php new file mode 100644 index 00000000..eb1959a2 --- /dev/null +++ b/wms/bonus/bonus.php @@ -0,0 +1,301 @@ + '新梯', + '2' => '汰改', + '3' => '保養' +]; + +$bonus_type = [ + '1' => '契約人獎金', + '2' => '區經理獎金', + '3' => '專任契約經理獎金' +]; +$clause = ''; +if (!empty($_GET['check'])) { + if ($_GET['check'] == 1) { + $clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; + } else if ($_GET['check'] == 2) { + $clause .= "AND status = 1"; + } else if ($_GET['check'] == 3) { + $clause .= "AND status = 2"; + } +} + +$sql = "SELECT * FROM bonus WHERE 1=1 $clause LIMIT 50"; +$stmt = $conn->prepare($sql); +$stmt->execute(); +$datas = $stmt->fetchAll(PDO::FETCH_ASSOC); + + +$now = new DateTime(); +$oneMonthAgo = $now->modify('+1 month'); + +// 查看 T8 是否有收款明細 +// require("./api/get.php"); +function isPay($contract_no, $connT8) +{ + // echo $contract_no; + $sql = "SELECT + a.BillNo, + b.OTaxAmt as amount, + a.CU_EstPayDate as createDate, + b.PersonId as personId, + c.BillNo as CBno, + c.CU_MaterialId as facility + FROM salIncomeApplyDetail as a + LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo + LEFT JOIN ( + SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster + LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo + WHERE aMaster.BizPartnerId = '$contract_no' AND aMaster.TypeId = 'RVS' + ) AS c ON a.BillNo = c.BizPartnerId + WHERE a.BillNo = '$contract_no' + AND a.RowNo = '1' + "; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $data = $stmt->fetch(PDO::FETCH_ASSOC); + // $data['amount'] = intval($data['amount']); + if (!empty($data['CBno']) && $data['CBno'] != '') { + $checkBillNo = $data['CBno']; + + $sql = "SELECT + c.BillDate AS CheckBillDate + FROM arWriteOffBill AS a + LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo + LEFT JOIN + (SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail + LEFT JOIN + (SELECT + arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo + FROM arCheckBill + LEFT JOIN arCheckBillInvInfo + ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 + ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c + ON a.BillNo=c.BillNo + WHERE c.checkBillNo = '$checkBillNo' + "; + + $stmt = $connT8->prepare($sql); + $stmt->execute(); + + return '1'; + } else { + return '2'; + } +} +?> + + + + + + + + +
項次 | +合約類別 | +合約號 | +作番號 | +獎金類別 | +獎金版本 | +作番總價 | +牌價 | +服務費 | +應發人員 | +預計發放時間 | +獎金水庫 | + +狀態 | +檢視/發放 | +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= $data['id'] ?> | += $contract_type[$data['contract_type']] ?> | += $data['contract_no'] ?> | += $data['facility_no'] ?> | += $bonus_type[$data['bonus_type']] ?> | += $data['bonus_verson'] ?> | += $total ?> | += $fee_per_st ?> | += $commission_fee ?> | += $data['receiver'] ?> | += $data['pay_day'] ?> | += $data['amount'] ?> | + ++ + = ($isPay == 1) ? '已收款' : '未收款' ?> + | ++ + 發放獎金 + + 查看詳情 + + | + +
'; +// print_r($result['bonus_json']); +// echo ''; +$bonus_json = json_decode($result['bonus_json']); + +$paykind = [ + 'monthly' => '月繳', + 'bimonthly' => '雙月繳', + 'quarterly' => '季繳', + 'semiannually' => '半年繳', + 'annually' => '年繳' +]; + +$maintain_type = [ + 'new' => '新簽約', + 'free_to_charge' => '免保轉有費', + 'renew_priceissue' => '續簽約' +]; ?> @@ -12,7 +36,7 @@ require_once('../contract-repair/conn.php'); -
+ 獎金計算+ |
+ |||||||
獎金類型 | +
+
+
+
+ + + + + + |
+
+ ||||||
+ 獎金確認項(新梯V1)+ |
+
+ |
+ ||||||
合約類別 | +
+ 未填寫 + |
+
+
+ 獎金適用版本 | ++ + | +契約人員 | ++ + | +付款方式(月/次) | +
+ |
+
保養月份 | ++ + | +應收款日期(月/次) | +
+
+ (Ex:20240101) + |
+ 地區經理經理員 | ++ + | +專任契約經理員 | ++ + | +
保養金額(月) | ++ + | +牌價 | +
+
+ 標準價+Option價格+與其他電梯共同分擔的費用貨價格 + |
+ 服務費 | ++ + | + + +||
+ 獎金確認項(新梯V2)+ |
+
+ |
+ ||||||
合約類別 | +
+ 未填寫 + |
+
+
+ 獎金適用版本 | ++ + | +契約人員 | ++ + | +付款方式(月/次) | +
+ |
+
保養月份 | ++ + | +應收款日期(月/次) | +
+
+ (Ex:20240101) + |
+ 地區經理經理員 | ++ + | +專任契約經理員 | ++ + | +
保養金額(月) | ++ + | +牌價 | +
+
+ 標準價+Option價格+與其他電梯共同分擔的費用貨價格 + |
+ 服務費 | ++ + | + + +||
+ 獎金確認項(保養)+ |
+
+ |
+ ||||||
合約類別 | +
+ 未填寫 + |
+
+
+ 獎金適用版本 | ++ + | +契約人員 | ++ + | +付款方式(月/次) | +
+ |
+
保養月份 | ++ + | +應收款日期(月/次) | +
+
+ (Ex:20240101) + |
+ 地區經理經理員 | ++ + | +專任契約經理員 | ++ + | +
保養金額(月) | ++ + | +牌價 | +
+
+ 標準價+Option價格+與其他電梯共同分擔的費用貨價格 + |
+ 服務費 | ++ + | + + +||
獎金類型 | ++ + | +發放人員 | ++ + | +發放金額 | ++ + | +預計發放時間 | ++ + | +
發放規定 | ++ + | +||||||
+ | + | + | + | + | + | + | + |
'; + // print_r($result); + // echo ''; + $bonus_type = $result['bonus_type']; + $pay_day = $result['pay_day_due']; + $amount = $result['bonus_amount']; + $receiver = $result['bonus_receiver']; + $discount = $result['discount']; + foreach ($bonus_json as $json) { + $json['discount'] = "$discount"; + $a = json_encode($json); + } + // echo '
'; + // print_r($a); + // echo ''; + // exit(); + $sql = "INSERT INTO bonus + (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES + ($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $count++; + echo '
'; + print_r($count . '-- > Success'); + echo ''; + + // exit; + } + } + + + + // $sql = "INSERT INTO bonus + // (bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day,status,bonus_json,create_id,create_at) VALUES + // ($bonus_type,'$bonus_verson','$contract_no',$contract_type,'$facility_no',$amount,'$receiver','$pay_day',$status,'$bonus_json','$create_id','$create_at')"; + // echo '
'; + // print_r($sql); + // echo ''; + // if ($key == 2) { + // exit; + // } +} diff --git a/wms/bons/maintance/maintenance_contract_bonus_v2_0.php b/wms/bonus/maintance/maintenance_contract_bonus_v2_0.php similarity index 100% rename from wms/bons/maintance/maintenance_contract_bonus_v2_0.php rename to wms/bonus/maintance/maintenance_contract_bonus_v2_0.php diff --git a/wms/bons/maintance/maintenance_contract_bonus_v2_0_examination.php b/wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php similarity index 100% rename from wms/bons/maintance/maintenance_contract_bonus_v2_0_examination.php rename to wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php diff --git a/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1.php b/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1.php new file mode 100644 index 00000000..f44ae1a6 --- /dev/null +++ b/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1.php @@ -0,0 +1,159 @@ +$ver, #獎金版本 + "result_status"=>"success", #計算結果 + "$bonus_array"=>$bonus_array #所有獎金水庫 + ]; + +*/ + + + +function elevator_renew_noninstallment_bonus_v2_1($ver, $contract_type, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $sales_id, $region_manger_id){ + $bonus_array = []; + if ($ver == "2.1"){ + $discount = round(($elevator_knockdown_price - $commission_fee) / $elevator_list_price, 2); #銷售點數,取到小數點第2位。 + + #折扣率 + switch ($discount) { + case ($discount >= 0.8): + #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) + switch ($contract_type){ + case "strategy_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 400; + break; + case "general_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.018; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 600; + break; + } + break; + case ($discount >= 0.60 and $discount < 0.8): + #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) + switch ($contract_type){ + case "strategy_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 400; + break; + case "general_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.0144; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 300; + break; + } + break; + case ($discount < 0.60): + #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) + switch ($contract_type){ + case "strategy_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 400; + break; + case "general_customer": + #契約員獎金($sales_bonus) + $sales_bonus = ($elevator_knockdown_price - $commission_fee) * 0.01; + #地區經理提成獎金($region_manager_bonus) + $region_manager_bonus = 200; + break; + } + break; + }; + + #營銷人員銷售獎金水庫-----訂金已收款100%,發放總獎金30% + array_push($bonus_array,[ + "bonus_type" => "營銷人員銷售獎金-訂金段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.3), #金額 + "payment_schedul_due" => "deposit", #訂金已收款100% + "payment_schedul_regulation" => "訂金已收款100%,發放總獎金30%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款100%,發放總獎金50% + array_push($bonus_array,[ + "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus * 0.5), #金額 + "payment_schedul_due" => "shipping", #出貨前期所有款項已收齊,且出貨款已收款100% + "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款100%,發放總獎金50%" #發放規定 + ]); + + #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款100%,發放總獎金30% + array_push($bonus_array,[ + "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 + "bonus_receiver" => $sales_id, #發放人員 + "bonus_amount" => round($sales_bonus) - round($sales_bonus * 0.3) - round($sales_bonus * 0.5), #金額 + "payment_schedul_due" => "acceptance", #驗收前期所有款項已收齊,且驗收款已收款100% + "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款100%,發放總獎金20%" #發放規定 + ]); + + #區域經理提成獎金水庫-----訂金已收款100%,發放總獎金100% + array_push($bonus_array,[ + "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 + "bonus_receiver" => $region_manger_id, #發放人員 + "bonus_amount" => $region_manager_bonus, #金額 + "payment_schedul_due" => "deposit", #訂金已收款100% + "payment_schedul_regulation" => "訂金已收款100%,次月發放" #發放規定 + ]); + + $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; +}; + +?> \ No newline at end of file diff --git a/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1_examination.php b/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1_examination.php new file mode 100644 index 00000000..c7ddd5ad --- /dev/null +++ b/wms/bonus/other/elevator_renew_noninstallment_bonus_v2_1_examination.php @@ -0,0 +1,83 @@ +$ver, #獎金版本 + "result_status"=>"success", #計算結果 + "$bonus_array"=>$bonus_array #所有獎金水庫 + ]; + +*/ + + +require_once("elevator_renew_noninstallment_bonus_v2_1.php"); + +#$ver, $contract_type, $elevator_list_price, $elevator_knockdown_price, $commission_fee, $sales_id, $region_manger_id + +#獎金測試 +$examination_array = [ + #錯誤版本 + ["1.0","strategy_customer",1000000,1000000,100000,"M0001", "M0003"], + #戰略客戶(strategy_customer) + ["2.1","strategy_customer",1000000,900000,100000,"M0001", "M0003"], #戰略客戶、折扣率80% + ["2.1","strategy_customer",1000000,700000,100000,"M0001", "M0003"], #戰略客戶、折扣率60% + ["2.1","strategy_customer",1000000,690000,100000,"M0001", "M0003"], #戰略客戶、折扣率59% + + #一般客戶(general_customer) + ["2.1","general_customer",1000000,900000,100000,"M0001", "M0003"], #一般客戶、折扣率80% + ["2.1","general_customer",1000000,700000,100000,"M0001", "M0003"], #一般客戶、折扣率60% + ["2.1","general_customer",1000000,690000,100000,"M0001", "M0003"] #一般客戶、折扣率59% +]; + + + +for($i = 0; $i
※此信件為系統發出信件,請勿直接回覆。
"; - - $mail = new PHPMailer(true); - $mail->IsHTML(true); //設定是否使用HTML格式 - $mail->CharSet = $this->charset; - $mail->isSMTP(); - $mail->SMTPAuth = true; - $mail->Host = $this->host; - $mail->Port = $this->port; - $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //使用SSL, 如果是TLS 請改為 PHPMailer::ENCRYPTION_STARTTLS - $mail->Username = $this->smtp_user; - $mail->Password = $this->smtp_pwd; - $mail->SMTPSecure = ""; - $mail->From = "notice@masada.com.tw"; - $mail->FromName = $from; - $mail->Subject = $subject; - $mail->Body = $em_body; - foreach ($sendlist as $v) { // $sendlist[0]=['M0044', 'jrbin@masada.com.tw'] - list($name, $email) = $v; - if ($email) $mail->addAddress($email, $name); - } - //$mail->addCC("personC@gmail.com", "person C"); - //$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; - } else { - //echo "Email sent"; - } - } -} \ No newline at end of file diff --git a/wms/class/Cnotice.php b/wms/class/Cnotice.php deleted file mode 100644 index 970bf81c..00000000 --- a/wms/class/Cnotice.php +++ /dev/null @@ -1,109 +0,0 @@ - false, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_EMULATE_PREPARES => false, - PDO::ATTR_STRINGIFY_FETCHES => false, - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - ]; - $pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options); - $pdo->exec('SET CHARACTER SET utf8mb4'); - return $pdo; - } catch (PDOException $e) { - die("Something wrong: {$e->getMessage()}"); - } - } - - /** - * 結束資料庫連線 - */ - function endConnectionDB($pdo) - { - unset($pdo); - } - - /** - * 提交消息 notice - * @param string $kind : 類別 1=系統 2=會議 - * @param int $related_id : 關聯序號 - * @param string $title : 標題 - * @param string $title : 內容 - * @param string $permission : 瀏覽權限 員編/ALL=全體 - * @param string $creater : 建立者 - * @param string $create_at : 建立時間 - */ - function sendx($data) - { - - $kind = $data['kind']; - $related_id = $data['related_id']; - $title = $data['title']; - $content = $data['content']; - $permission = $data['permission']; - $creater = $data['creater']; - $create_at = $data['create_at']; - - $pdo = $this->connectionDB(); - $pdo->exec('SET CHARACTER SET utf8mb4'); - $str = " - INSERT INTO `notice` (`kind`, `related_id`, `title`, `content`, `permission`, `creater`, `create_at`) - VALUES (?,?,?,?,?,?,?) - "; - - $sth = $pdo->prepare($str); - $sth->bindValue(1, $kind); - $sth->bindValue(2, $related_id); - $sth->bindValue(3, $title); - $sth->bindValue(4, $content); - $sth->bindValue(5, $permission); - $sth->bindValue(6, $creater); - $sth->bindValue(7, $create_at); - - $sth->execute(); - - $this->endConnectionDB($pdo); - } -} - -// $cn = new Cnotice(); -// $data = array( -// 'kind' => 1, -// 'related_id' => 1, -// 'title' => "標題", -// 'content' => "內容", -// 'permission' => "M0117", -// 'creater' => "M0117", -// 'create_at' => date("Y-m-d H:i:s") -// ); -// $cn->sendx($data); diff --git a/wms/cont/FormHelper.php b/wms/cont/FormHelper.php deleted file mode 100644 index 8025239a..00000000 --- a/wms/cont/FormHelper.php +++ /dev/null @@ -1,509 +0,0 @@ - 'post', 'accept-charset' => 'utf-8'), $attributes); - - return "'; - } - - /** - * Creates a label for an input - * - * @param string $text The label text - * @param string $fieldName Name of the input element - * @param array $attributes HTML attributes - * @return string - */ - public static function label($text, $fieldName = null, array $attributes = array()) - { - if (!isset($attributes['for']) && $fieldName !== null) { - $attributes['for'] = static::autoId($fieldName); - } - if (!isset($attributes['id']) && isset($attributes['for'])) { - $attributes['id'] = $attributes['for'] . '-label'; - } - - return self::tag('label', $attributes, $text); - } - - /** - * Creates a text field - * - * @param string $name - * @param string $value - * @param array $attributes HTML attributes - * @return string - */ - public static function text($name, $value = null, array $attributes = array(),$type='text') - { - $attributes = array_merge(array( - 'id' => static::autoId($name), - 'name' => $name, - 'type' => $type, - 'value' => $value, - ), $attributes); - - return self::tag('input', $attributes); - } - - /** - * Creates a password input field - * - * @static - * @param string $name - * @param string $value - * @param array $attributes HTML attributes - * @return string - */ - public static function password($name, $value = null, array $attributes = array()) - { - $attributes = array_merge(array( - 'id' => static::autoId($name), - 'name' => $name, - 'type' => 'password', - 'value' => $value, - ), $attributes); - - return self::tag('input', $attributes); - } - - /** - * Creates a hidden input field - * - * @static - * @param string $name - * @param string $value - * @param array $attributes - * @return string - */ - public static function hidden($name, $value, array $attributes = array()) - { - $attributes = array_merge(array( - 'id' => static::autoId($name), - 'name' => $name, - 'type' => 'hidden', - 'value' => $value, - ), $attributes); - - return self::tag('input', $attributes); - } - - /** - * Creates a textarea - * - * @param string $name - * @param string $text - * @param array $attributes HTML attributes - * @return string - */ - public static function textArea($name, $text = null, array $attributes = array()) - { - $attributes = array_merge(array( - 'id' => static::autoId($name), - 'name' => $name, - ), $attributes); - - return self::tag('textarea', $attributes, (string)$text); - } - - /** - * Creates a check box. - * By default creates a hidden field with the value of 0, so that the field is present in $_POST even when not checked - * - * @param string $name - * @param bool $checked - * @param mixed $value Checked value - * @param array $attributes HTML attributes - * @param bool|string $withHiddenField Pass false to omit the hidden field or "array" to return both parts as an array - * @return string - */ - public static function checkBox( - $name, - $checked = false, - $value = 1, - array $attributes = array(), - $withHiddenField = true - ) { - $auto_id = static::autoId($name); - - $checkboxAttributes = array_merge(array( - 'name' => $name, - 'type' => 'checkbox', - 'value' => $value, - 'id' => $auto_id, - 'checked' => (bool)$checked, - ), $attributes); - $checkbox = self::tag('input', $checkboxAttributes); - - if ($withHiddenField === false) { - return $checkbox; - } - - $hiddenAttributes = array( - 'name' => $name, - 'type' => 'hidden', - 'value' => 0, - 'id' => $auto_id . '-hidden', - ); - $hidden = self::tag('input', $hiddenAttributes); - - return $withHiddenField === 'array' - ? array($hidden, $checkbox) - : $hidden . $checkbox; - } - - /** - * Creates multiple checkboxes for a has-many association. - * - * @param string $name - * @param array $collection - * @param array|\Traversable $checked Collection of checked values - * @param array $labelAttributes - * @param bool $returnAsArray - * @throws \InvalidArgumentException - * @return string - */ - public static function collectionCheckBoxes($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false) - { - // TODO: Does this check cover all options? - if (!(is_array($checked) || $checked instanceof \Traversable)) { - throw new \InvalidArgumentException("$name must be an array or Traversable!"); - } - - $checkBoxes = array(); - foreach ($collection as $value => $label) { - $checkBoxes[] = self::tag( - 'label', - $labelAttributes, - FormHelper::checkBox("{$name}[]", in_array($value, $checked, true), $value, array(), false) . self::escape($label), - false - ); - } - - return $returnAsArray ? $checkBoxes : implode('', $checkBoxes); - } - - /** - * Creates a radio button - * - * @static - * @param string $name - * @param string $value - * @param bool $checked - * @param array $attributes - * @return string - */ - public static function radio($name, $value, $checked = false, array $attributes = array()) - { - $attributes = array_merge(array( - 'type' => 'radio', - 'name' => $name, - 'value' => $value, - 'checked' => (bool)$checked, - ), $attributes); - - return self::tag('input', $attributes); - } - - /** - * Creates multiple radio buttons with labels - * - * @static - * @param string $name - * @param array $collection - * @param mixed $checked Checked value - * @param array $labelAttributes - * @param bool $returnAsArray - * @return array|string - */ - public static function collectionRadios($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false) - { - $radioButtons = array(); - foreach ($collection as $value => $label) { - $radioButtons[] = self::tag( - 'label', - $labelAttributes, - FormHelper::radio($name, $value, $value === $checked) . self::escape($label), - false - ); - } - - return $returnAsArray ? $radioButtons : implode('', $radioButtons); - } - - /** - * Creates a select tag - *
- * // Simple select
- * select('coffee_id', array('b' => 'black', 'w' => 'white'));
- *
- * With option groups
- * select('beverage', array(
- * 'Coffee' => array('bc' => 'black', 'wc' => 'white'),
- * 'Tea' => array('gt' => 'Green', 'bt' => 'Black'),
- * ));
- *
- *
- * @param string $name Name of the attribute
- * @param array $collection An associative array used for the option values
- * @param mixed $selected Selected option Can be array or scalar
- * @param array $attributes HTML attributes
- * @return string
- */
- public static function select($name, array $collection, $selected = null, array $attributes = array())
- {
- $attributes = array_merge(array(
- 'name' => $name,
- 'id' => static::autoId($name),
- 'multiple' => false,
- ), $attributes);
-
- if (is_string($selected) || is_numeric($selected)) {
- $selected = array($selected => 1);
- } else if (is_array($selected)) {
- $selected = array_flip($selected);
- } else {
- $selected = array();
- }
-
- $content = self::option('', '', $selected);
- foreach ($collection as $value => $element) {
- // Element is an optgroup
- $content .= self::option($element['value'], $element['label'], $selected);
- }
-
- return self::tag('select', $attributes, $content, false);
- }
-
- /**
- * Creates an option tag
- *
- * @param string $value
- * @param string $label
- * @param array $selected
- * @return string
- */
- private static function option($value, $label, $selected)
- {
- // Special handling of option tag contents to enable indentation with
- //$label = str_replace(' ', ' ', self::escape($label));
-
- return self::tag(
- 'option',
- array(
- 'value' => $value,
- 'selected' => isset($selected[$value]),
- ),
- $label,
- false
- );
- }
-
- /**
- * Creates a file input field
- *
- * @static
- * @param string $name
- * @param array $attributes HTML attributes
- * @return string
- */
- public static function file($name, array $attributes = array())
- {
- $attributes = array_merge(array(
- 'type' => 'file',
- 'name' => $name,
- 'id' => static::autoId($name),
- ), $attributes);
-
- return self::tag('input', $attributes);
- }
-
- public static function button($name, $text, array $attributes = array())
- {
- $attributes = array_merge(array(
- 'id' => static::autoId($name),
- 'name' => $name,
- ), $attributes);
-
- return self::tag('button', $attributes, $text);
- }
-
-
- /**
- * Generate an ID given the name of an input
- *
- * @static
- * @param string $name
- * @return string|null
- */
- public static function autoId($name)
- {
- // Don't set an id on collection inputs
- if (strpos($name, '[]') !== false) {
- return null;
- }
-
- // Hyphenate array keys, for example model[field][other_field] => model-field-other_field
- $name = preg_replace('/\[([^]]+)\]/u', '-\\1', $name);
-
- return $name;
- }
-
- /**
- * Generates an HTML tag
- *
- * @param string $tagName Name of the tag
- * @param array $attributes HTML attributes
- * @param string $content Content of the tag. Omit to create a self-closing tag
- * @param bool $escape_content
- *
- * @see attributes()
- *
- * @return string
- */
- public static function tag($tagName, array $attributes = array(), $content = null, $escape_content = true)
- {
- $result = '<' . $tagName . static::attributes($attributes) . '>';
-
- if ($content !== null) {
- $result .= ($escape_content ? static::escape($content) : $content) . '' . $tagName . '>';
- }
-
- return $result;
- }
-
- /**
- * Converts an array of HTML attributes to a string
- *
- * If an attribute is false or null, it will not be set.
- *
- * If an attribute is true or is passed without a key, it will
- * be set without an explicit value (useful for checked, disabled, ..)
- *
- * If an array is passed as a value, it will be joined using spaces
- *
- * Note: Starts with a space
- *
- * Html::attributes(array('id' => 'some-id', 'selected' => false, 'disabled' => true, 'class' => array('a', 'b')));
- * //=> ' id="some-id" disabled class="a b"'
- *
- *
- * @param array $attributes Associative array of attributes
- *
- * @return string
- */
- public static function attributes(array $attributes)
- {
- $result = '';
-
- foreach ($attributes as $attribute => $value) {
- if ($value === false || $value === null) continue;
- if ($value === true) {
- $result .= ' ' . $attribute;
- } else if (is_numeric($attribute)) {
- $result .= ' ' . $value;
- } else {
- if (is_array($value)) { // support cases like 'class' => array('one', 'two')
- $value = implode(' ', $value);
- }
- $result .= ' ' . $attribute . '=\'' . static::escape($value) . '\'';
- }
- }
-
- return $result;
- }
-
- /**
- * Escapes a string for output in HTML
- *
- * @static
- * @param string $string
- * @return string
- */
- public static function escape($string)
- {
- return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
- }
- /**
- * 输出表单标题
- *
- * @param string $title
- * @return void
- */
- public static function formTitle(string $title)
- {
- return '' . $fieldName . '
-'; -// print_r($apply_key); -// echo ''; -// exit; -// if ($salesman != $user_id) { -// echo ''; -// exit; -// } -if (empty($apply_key)) $apply_st = 1; // 準備新增 -else { - //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); - list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); - if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 - else $apply_st = 9; // 已到下一關,無法䖺改 -} - -// if ($apply_st > 2) { -// echo ""; -// exit; -// } - -if ($apply_st == 1) { - $wf = new WorkFlow($system_id, $flow_id, $form_id); - $wf->initWorkFlow($user_id); - $form_key = $wf->flowContext->getFormKey(); -} else { - $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); -} - -#獲取簽核意見 -$assign_opinions = Assign::get_records($form_key); - -#會簽部門意見 -$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); - -//預設冇有摺扣 -$wf->setFormData(['discount' => 100]); -$flowName = $wf->getFlowName(); -$assigner = $wf->getAssignerList(); -$assign_status = $wf->getAssignStatus($assigner); - -$if_show_assign = true; -//加載流程圖 -//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); -//$path = $fc[0]->wf_file; -//echo dirname(__DIR__)."/../"."$path"; - -//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); -#是否可會簽 -$isSplitable = $wf->isSplitable(); - -//表單數據 -#客戶表 -#1.電梯品牌選項 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='elevator_brand' order by code_name asc "; -$elevator_brand_opt = DB::result($sql); -#2.保養方式 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='maintain_kind'"; -$maintain_kind_opt = DB::result($sql); -#3.電梯類型 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='maintain_elevator_kind'"; -$elevator_kind_opt = DB::result($sql); -#4.付款方式 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='payment_kind' order by code_name+ 0 asc"; -$payment_kind_opt = DB::result($sql); -#5.契約性質 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='contract_kind'"; -$contract_kind_opt = DB::result($sql); -#6.是否贈送M1 -$is_m1_bundle_opt = [ - ['label' => '是', 'value' => 'Y'], - ['label' => '否', 'value' => 'N'] - -]; -#7.機種 -$sql = "SELECT code_name value ,content label FROM code WHERE field_name='fp_kind'"; -$fp_kind_opt = DB::result($sql); -#抓取有望客戶資料 - - -$vol_no = $_GET['vol_no']; -$where = " and vol_no='$vol_no'"; -$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; -// print_r($sql); -$hope_contract = DB::result($sql); -$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; -#寫入 con_maintance_examine_apply -if ($apply_st == 1) { - #獲取評審單號 - $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); - //var_dump($hope_contract); - $insert_data = [ - 'apply_key' => $apply_key, - 'vol_no' => $vol_no, - 'form_key' => $form_key, - 'address' => $hope_contract['address'], - 'case_name' => $hope_contract['customer'], - 'num' => $hope_contract['num'], - 'brand' => '', - 'customer' => $hope_contract['customer'], - 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], - 'progress_remark' => $hope_contract['progress_status'] - //'platform_company'=>'', - // 'platforom_company_tel'=> '' - - ]; - //var_dump($insert_data); - DB::insert_table('con_maintance_examine_apply', $insert_data); -} - -$table = 'con_maintance_examine_apply'; -#可編輯的列 -$editableColumn = [ - 'apply_key' => [ - 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', - 'attr' => [ - 'readonly=true ', - 'class' => 'form-control form-control-sm' - ] - ], - 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], - 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], - 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], - 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], - 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - - 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], - -]; -$where = " and apply_key='$apply_key'"; - -$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; -$data = []; -$data = DB::result($sql); - -#電梯詳細資料 -$con_maintance_examine_clear_columm = [ - 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], - 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], - 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], - 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], - 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], - 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], - - 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], - 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], - 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], - - 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], - - 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], - 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], - 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], - 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'placeholder' => '契約成交價', 'class' => 'form-control form-control-sm']], - -]; -$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . - " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); - -$j = 0; -$col_count = 12; -$cmecRow = "
'; -// print_r($salesman); -// echo ''; -// exit; -if ($salesman != $user_id) { - echo ''; - exit; -} -if (empty($apply_key)) $apply_st = 1; // 準備新增 -else { - //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); - list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); - if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 - else $apply_st = 9; // 已到下一關,無法䖺改 -} - -// if ($apply_st > 2) { -// echo ""; -// exit; -// } - -if ($apply_st == 1) { - $wf = new WorkFlow($system_id, $flow_id, $form_id); - $wf->initWorkFlow($user_id); - $form_key = $wf->flowContext->getFormKey(); -} else { - $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); -} - -#獲取簽核意見 -$assign_opinions = Assign::get_records($form_key); - -#會簽部門意見 -$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); - -//預設冇有摺扣 -$wf->setFormData(['discount' => 100]); -$flowName = $wf->getFlowName(); -$assigner = $wf->getAssignerList(); -$assign_status = $wf->getAssignStatus($assigner); -$if_show_assign = true; -//加載流程圖 -//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); -//$path = $fc[0]->wf_file; -//echo dirname(__DIR__)."/../"."$path"; - -//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); -#是否可會簽 -$isSplitable = $wf->isSplitable(); - -//表單數據 -#客戶表 -#1.電梯品牌選項 -$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; -$elevator_brand_opt = DB::result($sql); -#2.保養方式 -$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; -$maintain_kind_opt = DB::result($sql); -#3.電梯類型 -$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; -$elevator_kind_opt = DB::result($sql); -#4.付款方式 -$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; -$payment_kind_opt = DB::result($sql); -#5.契約性質 -$sql = "select code_name value ,content label from code where field_name='contract_kind'"; -$contract_kind_opt = DB::result($sql); -#6.是否贈送M1 -$is_m1_bundle_opt = [ - ['label' => '是', 'value' => 'Y'], - ['label' => '否', 'value' => 'N'] - -]; -#7.機種 -$sql = "select code_name value ,content label from code where field_name='fp_kind'"; -$fp_kind_opt = DB::result($sql); -#抓取有望客戶資料 - -$vol_no = $_GET['vol_no']; -$where = " and vol_no='$vol_no'"; -$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; -$hope_contract = DB::result($sql); -$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; -#寫入 con_maintance_examine_apply -if ($apply_st == 1) { - #獲取評審單號 - $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); - //var_dump($hope_contract); - $insert_data = [ - 'apply_key' => $apply_key, - 'vol_no' => $vol_no, - 'form_key' => $form_key, - 'address' => $hope_contract['address'], - 'case_name' => $hope_contract['customer'], - 'num' => $hope_contract['num'], - 'brand' => '', - 'customer' => $hope_contract['customer'], - 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], - 'progress_remark' => $hope_contract['progress_status'] - //'platform_company'=>'', - // 'platforom_company_tel'=> '' - - ]; - //var_dump($insert_data); - DB::insert_table('con_maintance_examine_apply', $insert_data); -} -#抓使用者主管 -$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; -list($result) = DB::result($sql); -if ($result['department_id'] == '511') { - $managerid = 'M0137'; - $managername = '劉永德'; -} else if ($result['department_id'] == '512') { - $managerid = 'M0137'; - $managername = '劉永德'; -} else if ($result['department_id'] == '513') { - $managerid = 'M0086'; - $managername = '李烘銘'; -} else if ($result['department_id'] == '514') { - $managerid = 'M0033'; - $managername = '吳育宗'; -} - -if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { - $managerid = 'M0008'; - $managername = '詹益彰'; -} - -if ($result['department_id'] == 'M0008') { - $managerid = 'M0008'; - $managername = '詹益彰'; -} -$table = 'con_maintance_examine_apply'; -#可編輯的列 -$editableColumn = [ - 'apply_key' => [ - 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', - 'attr' => [ - 'readonly=true ', - 'class' => 'form-control form-control-sm' - ] - ], - 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], - 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], - 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], - 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], - 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - - 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], - -]; -$where = " and apply_key='$apply_key'"; - -$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; -$data = []; -$data = DB::result($sql); - -#電梯詳細資料 -$con_maintance_examine_clear_columm = [ - 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], - 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], - 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], - 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], - 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], - 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], - - 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], - 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], - 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], - - 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], - - 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], - 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], - 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], - 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], - -]; -$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . - " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); -$j = 0; -$col_count = 12; -$cmecRow = "
'; - // print_r($result); - // echo ''; - $id[] = $test; - } - } - $inClause = implode(',', $id); -} - - -#可編輯的列 -$editableColumn = [ - 'apply_key' => [ - 'label' => "評審單號", "value" => "", "tag" => 'text', - 'attr' => [ - 'readonly=true ', - 'class' => 'form-control form-control-sm' - ] - ], - 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], - 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], - 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], - 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - //'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], - -]; -// 設置一個空陣列來放資料 -$data = array(); - -$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; -//$where = " and salesman like '%'"; -$where = " and salesman = '$salesman'"; - -// 可瀏覽全部資料的部門 -$depart_arr = ["220"]; -$sql = "select department_id from account where accountid = '$user_id'"; -$res = mysqli_query($link, $sql); -$row = mysqli_fetch_row($res); -$user_department_id = $row[0]; -mysqli_free_result($res); -if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $where = ""; - -// 電梯廠牌 -$elevator_brand_arr = []; -$sql = "select code_name ,content from code where field_name='elevator_brand'"; -$res = mysqli_query($link, $sql); -while ($row = mysqli_fetch_row($res)) { - $elevator_brand_arr[$row[0]] = $row[1]; -} -mysqli_free_result($res); -if (!empty($res_get)) { - $sql = "SELECT - apply_key, - vol_no, - address, - case_name, - brand , - num , - f_return_name(salesman) salesman, - f_return_content('maintain_kind',maintain_kind ) maintain_kind, - date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, - date_format(contract_end_date,'%Y/%m/%d') contract_end_date , - f_return_content('contract_kind',contract_kind ) contract_kind, - platform_company, - platforom_company_tel, - form_key, - - f_return_content('payment_kind',payment_kind ) payment_kind FROM $table WHERE form_key IN ($inClause) "; -} else { - $sql = "SELECT - apply_key, - vol_no, - address, - case_name, - brand , - num , - f_return_name(salesman) salesman, - f_return_content('maintain_kind',maintain_kind ) maintain_kind, - date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, - date_format(contract_end_date,'%Y/%m/%d') contract_end_date , - f_return_content('contract_kind',contract_kind ) contract_kind, - platform_company, - platforom_company_tel, - form_key, - - f_return_content('payment_kind',payment_kind ) payment_kind FROM $table - where 1=1 $where ORDER BY vol_no"; -} -// echo $sql; -$data = mysqli_query($link, $sql); -// echo '
'; -// print_r($data); -// echo ''; -?> - -Please fill up the required field!"; - } else { - header("Location:repair-index.php"); - } - } - -?> - - -
"; - var_dump($region_data); -} diff --git a/wms/cont/wf_common.php b/wms/cont/wf_common.php deleted file mode 100644 index 519d341f..00000000 --- a/wms/cont/wf_common.php +++ /dev/null @@ -1,20 +0,0 @@ -getMessage()); } } + +if (isset($_GET['contract_no']) && $_GET['contract_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 't') { + $contract_no = $_GET['contract_no']; + try { + $sql = "SELECT * FROM pricereview_main AS a + LEFT JOIN pricereview_pay as b ON a.id = b.mid + WHERE a.kind='汰改' AND a.contract_no = :contract_no AND a.status='YY' + "; + header('Content-Type: application/json'); + } catch (PDOException $e) { + die("ERROR!!!: " . $e->getMessage()); + } +} diff --git a/wms/contract-repair/api/postContractData.php b/wms/contract-repair/api/postContractData.php index b4815669..ae043761 100644 --- a/wms/contract-repair/api/postContractData.php +++ b/wms/contract-repair/api/postContractData.php @@ -377,7 +377,9 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c sign_date, contract_status, create_user, - create_date) VALUES( + create_date, + delete_status) + VALUES( :repair_no, :contractno, :company, @@ -391,7 +393,8 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c :sign_date, :contract_status, :create_userid, - :create_date + :create_date, + 1 )"; $stmt = $conn->prepare($sql); $stmt->bindParam(":repair_no", $repair_no); diff --git a/wms/contract-repair/contract-renovate-input.php b/wms/contract-repair/contract-renovate-input.php new file mode 100644 index 00000000..deaeb0cb --- /dev/null +++ b/wms/contract-repair/contract-renovate-input.php @@ -0,0 +1,263 @@ +prepare($sql); +// $stmt->bindParam(':depart_no', $depart_no); +$stmt->execute(); +$contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC); +// echo ''; +// print_r($contractSalesman); +// echo ''; +?> + + + + + + + + + + ++\ No newline at end of file diff --git a/wms/contract-repair/contract-repair-input.php b/wms/contract-repair/contract-repair-input.php index d85fa1bd..939edeea 100644 --- a/wms/contract-repair/contract-repair-input.php +++ b/wms/contract-repair/contract-repair-input.php @@ -14,6 +14,7 @@ $stmt = $conn->prepare($sql_str); $stmt->bindParam(':accounttype', $accounttype); $stmt->execute(); $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); + $persons = array_map(function ($person) { return [ 'view' => $person['accountid'] . '-' . $person['name'], @@ -21,6 +22,9 @@ $persons = array_map(function ($person) { 'name' => $person['name'] ]; }, $contractpersons); +// echo '+ +++++ +
+ ++ + + + ++ +汰改合約入力
++ + + + + +合約號 ++ + ++ + ++ +業務確認項
++ +返回 +關閉 ++ + +立約人 ++ + +營業員 ++ + ++ + + + + +地址 ++ + ++ ++ + + ++ + + +款別分期 ++ + + +付款辦法 +款別 +比例% +金額 +繳款方式(月) ++ +材料 +1、訂金 ++ + ++ + ++ ++ + + + + ++ +2、二次款 ++ + ++ + ++ ++ + + + + ++ + + + + + + --> + +3、貨到工地款 ++ + ++ + ++ ++ + + + + ++ +安裝 +5、安裝完畢款 ++ + ++ + ++ ++ + + + + ++ +6、驗收款 ++ + ++ + ++ ++ + + + + ++ + +7、其他 ++ + ++ + ++ ++ + + + + ++ +合計 ++ + ++ + ++ + ++ + 存檔 + + + + + + ++ + 下一步 + + + + + + ++ + 上一步 + + + + + +'; +// print_r($persons); +// echo ''; $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"]; ?> @@ -81,7 +85,7 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修維保人員 - + diff --git a/wms/contract-repair/contract-repair-management.php b/wms/contract-repair/contract-repair-management.php index 92283545..8aed456e 100644 --- a/wms/contract-repair/contract-repair-management.php +++ b/wms/contract-repair/contract-repair-management.php @@ -64,7 +64,7 @@ $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); echo '修理完成'; } ?> - + diff --git a/wms/contract-repair/js/alpine.js b/wms/contract-repair/js/alpine.js index 326d6908..43991cca 100644 --- a/wms/contract-repair/js/alpine.js +++ b/wms/contract-repair/js/alpine.js @@ -320,7 +320,7 @@ const contractRepair = () => { repair_no: '', total_price: '', sign_date: '', - contract_status: '' + contract_status: '', }, step: 1, isLoading: false, @@ -874,16 +874,34 @@ const contract_edit = () => { } -const bonsIndex = () => { +const bonunsIndex = () => { return { data: { - contract_no: 'Q23080067', - client_type: '', - facility_no: '', - bons_verson: '', - receiver: '', + contract_no: contract_no, + facility_no: facility_no, + bonus_verson: bonus_verson, + receiver: receiver, maintain_month: '', - maintain_price_toal: '' + maintain_price_total: maintain_price_total, + payDaydue: payDaydue, + bonusArr: [], + contract_type: contract_type, + manager: '', + bonus_type: '', + bouns_receiver: '', + bouns_amount: '', + payDay: '', + bouns_regulation: '', + contract_manger: 'M0001', + user_id: user_id, + maintain_type: maintain_type, + pay_kind: pay_kind, + receivable_date_due: receivable_date_due, + total: total, + fee_per_st: fee_per_st, + commission_fee: commission_fee, + discount: discount + }, step: 1, isLoading: false, @@ -921,29 +939,203 @@ const bonsIndex = () => { if (!this.customize) { this.data.contract_no = res.data.BillNo; this.data.facility_no = res.data.facility; - this.data.bons_verson = res.data.bons_verson; + this.data.bonus_verson = res.data.bonuns_verson; this.data.receiver = res.data.personId; - this.data.maintain_price_toal = res.data.amount; - this.data.bons_verson = 2; + this.data.maintain_price_total = res.data.amount; + // this.data.bonuns_verson = 2; this.data.maintain_month = res.data.maintain_month; - } + this.data.payDay = res.data.payDay; + axios.get('./api/getAccount.php?accountid=' + res.data.personId).then(res => { + this.data.manager = res.data.manager; + }).catch(err => { + console.log(err); + }) + }; this.step = 2; this.isLoading = false; }).catch(err => { - + errorFn(); }) + // axios.get('./api/getAccount.php?accountid=' + this.data.receiver).then(res => { + // console.log(res); + // this.data.manager = res.result.manager; + // }).catch(err => { + // console.log(err); + // }) + }, + save() { + if (this.step == 1) { + window.history.back(); + } + }, + calBons() { + console.log(this.step); + const form = new FormData(); + form.append('cotract_no', this.data.contract_no); + form.append('bonuns_verson', this.data.bonus_verson); + form.append('contract_type', this.data.contract_type); + form.append('maintain_month', this.data.maintain_month); + form.append('maintain_price_total', this.data.maintain_price_total); + form.append('payDay', this.data.payDay); + form.append('receiver', this.data.receiver); + form.append('manager', this.data.manager); + axios.post('./api/postCalBouns.php', form).then(res => { + // console.log(res); + this.data.bonusArr = res.data.bonus_array; + console.log(this.data.bonusArr); + this.step = 3; + this.isLoading = false; + }).catch(err => { + console.log(err.response.data); + alert(err.response.data); + this.step = 2; + }) + }, + errorFn() { + let msg = ''; + for (let i = 0; i < this.fail_arr.length; i++) { + msg += this.fail_arr[i] + '、'; + } + alert(msg); }, - preStepFn() { - this.step = 1 - if (this.step == 2) { + } +} +const bonunsIndexTest = () => { + return { + data: { + bonus_verson: '2.1', + receiver: 'M0225', + maintain_month: '12', + client_type: '', + maintain_price_month: '3000', + maintain_price_total: '3000', + commission_fee: '0', + bonusArr: [], + manager: 'M0008', + bonus_type: '', + bouns_receiver: '', + bouns_amount: '', + payDay: '20240101', + bouns_regulation: '', + contract_manger: 'M0001', + paykindArr: ['請選擇月份', 1, 2, 3, 6, 12], + paykind: '', + checkbox: '', + + }, + checkbox: 0, + step: 1, + isLoading: false, + fail_arr: [], + test() { + console.log(this.data.paykind); + }, + nextStepFn() { + if (this.step == 1) { + this.checkbox = Number(this.data.checkbox); + this.step = 2; + } else if (this.step == 2) { + this.isLoading = true; + this.calBons(); } + // this.step = 3; + console.log(this.step); + console.log(this.checkbox); + + }, + nextStepKeyupFn(e) { + if (e.keyCode !== 13) return; + if (this.step == 1) { + this.step = 2; + } else if (this.step == 2) { + this.step = 3; + } + }, + getContractData() { + axios.get('./api/get.php?contract_no=' + this.data.contract_no).then(res => { + if (!res.data) { + this.step = 2; + this.isLoading = false; + return; + } + if (!this.customize) { + this.data.contract_no = res.data.BillNo; + this.data.facility_no = res.data.facility; + this.data.bonus_verson = res.data.bonuns_verson; + this.data.receiver = res.data.personId; + this.data.maintain_price_total = res.data.amount; + // this.data.bonuns_verson = 2; + this.data.maintain_month = res.data.maintain_month; + this.data.payDay = res.data.payDay; + axios.get('./api/getAccount.php?accountid=' + res.data.personId).then(res => { + this.data.manager = res.data.manager; + }).catch(err => { + console.log(err); + }) + }; + this.step = 2; + this.isLoading = false; + }).catch(err => { + errorFn(); + }) + // axios.get('./api/getAccount.php?accountid=' + this.data.receiver).then(res => { + // console.log(res); + // this.data.manager = res.result.manager; + // }).catch(err => { + // console.log(err); + // }) }, save() { - + if (this.step == 3) { + const form = new FormData(); + form.append('status', 'save'); + form.append('checkbox', this.data.checkbox); + form.append('bonuns_verson', this.data.bonus_verson); + form.append('contract_type', this.data.contract_type); + form.append('maintain_month', this.data.maintain_month); + form.append('maintain_price_total', this.data.maintain_price_total); + form.append('payDay', this.data.payDay); + form.append('receiver', this.data.receiver); + form.append('manager', this.data.manager); + form.append('paykind', this.data.paykind); + form.append('contract_manger', this.data.contract_manger); + form.append('maintain_price_month', this.data.maintain_price_month); + form.append('commission_fee', this.data.commission_fee); + form.append('client_type', this.data.client_type); + axios.post('./api/postCalBouns.php', form).then(res => { + console.log(res.data); + }).catch(err => { + console.log(err.response.data); + }) + } }, calBons() { - console.log('123'); + const form = new FormData(); + form.append('checkbox', this.data.checkbox); + form.append('bonuns_verson', this.data.bonus_verson); + form.append('contract_type', this.data.contract_type); + form.append('maintain_month', this.data.maintain_month); + form.append('maintain_price_total', this.data.maintain_price_total); + form.append('payDay', this.data.payDay); + form.append('receiver', this.data.receiver); + form.append('manager', this.data.manager); + form.append('paykind', this.data.paykind); + form.append('contract_manger', this.data.contract_manger); + form.append('maintain_price_month', this.data.maintain_price_month); + form.append('commission_fee', this.data.commission_fee); + form.append('client_type', this.data.client_type); + axios.post('./api/postCalBouns.php', form).then(res => { + // console.log(res); + this.data.bonusArr = res.data.bonus_array; + console.log(this.data.bonusArr); + this.step = 3; + this.isLoading = false; + }).catch(err => { + console.log(err.response.data); + alert(err.response.data); + this.step = 1; + }) }, errorFn() { let msg = ''; @@ -953,5 +1145,66 @@ const bonsIndex = () => { alert(msg); }, + } +} + +const renovateInput = () => { + return { + data: { + contract_no: '', + customer: '', + salesman: '', + address: '', + paykind: [0, 0, 0, 0, 0, 0, 0], + payarr: ['', 1, 2, 6, 12], + total: '', + // paykindTotal: this.total(), + }, + step: 1, + isLoading: false, + nextStepFn() { + if (this.step == 1) { + if (this.data.contract_no == '') return alert('請輸入合約號'); + this.isLoading = true; + this.getContractData(); + } else if (this.step == 2) { + console.log('1111'); + } + // this.step = 3; + }, + // 計算總共分期月數 + totalFn() { + let total = 0 + for (let i = 0; i < this.data.paykind.length; i++) { + if (this.data.paykind[i] != '0') { + total += Number(this.data.paykind[i]); + + } + } + // console.log(123); + this.data.total = total; + }, + nextStepKeyupFn() { + + }, + preStepFn() { + this.step -= 1; + console.log(this.step); + }, + getContractData() { + axios.get('../api/getContractData.php?contracttype=t&contract_no=' + this.data.contract_no, (res) => { + + }) + }, + save() { + + }, + getContractData() { + this.step = 2; + this.isLoading = false; + console.log(this.step); + + } + } } \ No newline at end of file diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index e7a85071..59730e98 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,19 +1,21 @@ '; // print_r($countDay); // echo ''; // exit(); -$a = 0; +$SQuantity = 2; // $b = 24 / $a; -for ($i = 0; $i < 2; $i++) { - for ($j = 0; $j < 12; $j++) { - $a++; - echo '
'; - print_r($a); - echo ''; - } +for ($i = 0; $i < 12; $i++) { + $paymonth = $i * $SQuantity; + $countDay = date('Y-m-d', strtotime("$date + $paymonth months")); + $payDay = str_replace('-', '', $countDay); + echo ''; + print_r($payDay); + echo ''; } diff --git a/wms/contract/conn.php b/wms/contract/conn.php index 78007657..a795b27c 100644 --- a/wms/contract/conn.php +++ b/wms/contract/conn.php @@ -33,6 +33,11 @@ try { //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 //設定主動以警告的形式報錯 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E="); + if ($connT8) { + $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } //如果連接錯誤,將抛出一個PDOException異常對象 } catch (PDOException $e) { //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 diff --git a/wms/contract/connt8.php b/wms/contract/connt8.php index 2a40e459..a13f85d2 100644 --- a/wms/contract/connt8.php +++ b/wms/contract/connt8.php @@ -4,7 +4,7 @@ include "/Users/LO_2342/Desktop/httpdocs/wms/fun_global.php"; // phpinfo(); // exit(); try { - $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E="); + $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8test", "M0225", "IFFBU1E="); if ($connT8) { $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } diff --git a/wms/contract/contract-new-apply.php b/wms/contract/contract-new-apply.php index c6e8ee2c..2ac75ae2 100644 --- a/wms/contract/contract-new-apply.php +++ b/wms/contract/contract-new-apply.php @@ -708,9 +708,9 @@ $para = "function_name=pricereview&" . $token_link; "; -header("Location:" . "https://www.masada.com.tw/wms/crm/crmm02-index.php?token=" . $request['token']); +header("Location:" . "localhost/wms/crm/crmm02-index.php?token=" . $request['token']); diff --git a/wms/excel/import.php b/wms/excel/import.php index 75602fc1..34841720 100644 --- a/wms/excel/import.php +++ b/wms/excel/import.php @@ -1,5 +1,6 @@ Reader\Xlsx::class, self::READER_XLS => Reader\Xls::class, @@ -54,6 +55,7 @@ abstract class IOFactory return new $className(); } +} $object = new IOFactory(); $spreadsheet = $object::createReader('Xlsx')->load('1.xlsx'); -echo "success"; \ No newline at end of file +echo "success"; diff --git a/wms/frame/api_getdata.php b/wms/frame/api_getdata.php index cfcee966..d306794d 100644 --- a/wms/frame/api_getdata.php +++ b/wms/frame/api_getdata.php @@ -22,7 +22,6 @@ */ $json = array("st" => "ok", "err" => "", "errCode" => ""); -echo '123'; /** * 表單列表 */ diff --git a/wms/fun_global.php b/wms/fun_global.php index d9f9e98d..627fd90b 100644 --- a/wms/fun_global.php +++ b/wms/fun_global.php @@ -99,36 +99,37 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0) return $ret; exit; } else { - // 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。 - if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) { - $ret[1] = $user_id . ",,"; - // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) - $ret[3] = "M0060,,"; // 業務協理 - if ($rate < 80 || $special_fee > 0) { - $ret[4] = "M0006,,"; // 總經理 - } - return $ret; - exit; - } - if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") { - // 新梯的部分 桃竹本該給陳家文,改為劉永德 - if ($row["manager"] == 'M0029') { - $ret[1] = "M0137,,"; - $i++; - pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); - } else { - $ret[1] = $row["manager"] . ",,"; - $i++; - pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); - } - } else { - - // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) - $ret[3] = "M0060,,"; // 業務協理 - if ($rate < 80 || $special_fee > 0) { - $ret[4] = "M0006,,"; // 總經理 - } + // // 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。 + // if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) { + // $ret[1] = $user_id . ",,"; + // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) + // $ret[3] = "M0060,,"; // 業務協理 + // if ($rate < 80 || $special_fee > 0) { + // $ret[4] = "M0006,,"; // 總經理 + // } + // return $ret; + // exit; + // } + // if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") { + // // 新梯的部分 桃竹本該給陳家文,改為劉永德 + // if ($row["manager"] == 'M0029') { + // $ret[1] = "M0137,,"; + // $i++; + // pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); + // } else { + // $ret[1] = $row["manager"] . ",,"; + // $i++; + // pricereview_class($rate, $row["manager"], $ret, $special_fee, $i); + // } + // } else { + // $ret[1] = ''; + // $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) + // $ret[2] = ''; + $ret[3] = "M0060,,"; // 業務協理 + if ($rate < 80 || $special_fee > 0) { + $ret[4] = "M0006,,"; // 總經理 } + // } return $ret; } diff --git a/wms/mkt/pricereview-check.php b/wms/mkt/pricereview-check.php index 0757599c..6795979a 100644 --- a/wms/mkt/pricereview-check.php +++ b/wms/mkt/pricereview-check.php @@ -205,6 +205,7 @@ foreach ($res as $data) { } mysqli_free_result($res_spec); } elseif ($row['item_group'] == "B") { + $option_arr[$row['item_no']]['price_id'] = $row['price_id']; $option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; $option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; @@ -321,14 +322,14 @@ foreach ($res as $data) { function getMI(id) { var formdata = new FormData(); formdata.append('pa', id); - // formdata.append('user_id', = $user_id ?>); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { + console.log(this.responseText); if (this.readyState == 4 && this.status == 200) { data = JSON.parse(this.responseText); console.log(data); - if(data.err == "notfoundmi"){ - for(let i=0;i', k); - console.log(data.content); + // console.log('k=>', k); + // console.log(data.content); //console.log(data.content[k][0]); // 有值表示先前已寫入MI if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") { @@ -362,7 +363,7 @@ foreach ($res as $data) { mihtml += " 一年免保:" + commafy(data.content[k][6]) + " "; mihtml += "起吊+木箱+耗材:" + commafy(data.content[k][7]) + " "; //mihtml += "加價:"+commafy(data.content[k][9])+" "; - mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台" ; + mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台"; mihtml += "
"; mihtml += "OPTION
"; total_mi = total_mi + data.content[k][12]; @@ -386,14 +387,14 @@ foreach ($res as $data) { total_mi += data.content[k][13]; - if(total_mi == ""){ + if (total_mi == "") { console.log("undefided!!!"); } $("#tb1").find("tr[name=facil_templ2]").eq(k).find('td').eq(1).html(mihtml); //$("#tb1").find("input[name=mi_fix]").eq(k).closest('td').append(mihtml); console.log(document.getElementsByClassName('total_mi_fix')[k]); document.getElementsByClassName('total_mi_fix')[k].value = commafy(total_mi) - + // document.getElementsByClassName('item_price_ct')[k].value =commafy(total_mi) document.getElementsByClassName('gross_profit')[k].value = commafy(Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) - total_mi) document.getElementsByClassName('gross_profit_rate')[k].value = Math.round((Number(document.getElementsByClassName('gross_profit')[k].value.replace(/[,]+/g, "")) / Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) * 100) * 10) / 10 @@ -641,6 +642,7 @@ foreach ($res as $data) {