From 758600ebcc4f93cebc77c170c9f52447258ec884 Mon Sep 17 00:00:00 2001 From: Cheng Date: Thu, 7 Mar 2024 21:19:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=91=E7=B4=84=E5=83=B9=E5=AF=A9=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/api/postSchedule.php | 4 + wms/bonus/bonus_person.php | 142 ++++++-- .../elevator_new_deal_bonus_v1_0_1.php | 128 +++++++ .../elevator_new_deal_bonus_v2_0_1.php | 166 +++++++++ wms/bonus/maintainance_bonus.php | 17 +- wms/class/Cmail.php | 21 +- wms/contract/api/postContractData.php | 327 ++++++++++-------- wms/contract/api/test copy.json | 112 +++--- wms/contract/api/testT8API.php | 261 +------------- wms/contract/contract-input.php | 36 +- wms/contract/js/alpine.js | 22 +- wms/schedule-edit.php | 258 ++++++++------ wms/schedule-index.php | 14 +- 13 files changed, 876 insertions(+), 632 deletions(-) create mode 100644 wms/bonus/api/postSchedule.php create mode 100644 wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php create mode 100644 wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0_1.php diff --git a/wms/bonus/api/postSchedule.php b/wms/bonus/api/postSchedule.php new file mode 100644 index 00000000..7147ac5f --- /dev/null +++ b/wms/bonus/api/postSchedule.php @@ -0,0 +1,4 @@ +='$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..e75f6302 --- /dev/null +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v1_0_1.php @@ -0,0 +1,128 @@ +$ver, #獎金版本 + "result_status"=>"success", #計算結果 + "$bonus_array"=>$bonus_array #所有獎金水庫 + ]; + +*/ + + + +function elevator_new_deal_bonus_v1_0($ver, $contract_type, $elevator_knockdown_price, $elevator_pay_kind, $sales_id, $region_manger_id) +{ + $bonus_array = []; + if ($ver == "1.0") { + + #合約總類($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": + #契約員獎金($sales_bonus) + $sales_bonus = $elevator_knockdown_price * 0.015; + #區域經理獎金($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/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 d5fca570..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' || $user_id != 'M0012' || $user_id != 'M0029') { - $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/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/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 0a80ae1b..f1aad841 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,16 +1,18 @@ - prepare($sql); @@ -66,11 +69,9 @@ 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 '
';
@@ -79,7 +80,7 @@ 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 ($salesman == '')  $fail_arr[] = '營業員為必填';
     if ($contract_begin_date == '')  $fail_arr[] = '合約開始時間為必填';
@@ -104,9 +105,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
     // 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();
     }
+    // T8insert($_POST, $facilityno, $depId, $connT8);
+
     /// 獎金計算
     $aaa = bonusCreate($_POST, $facilityno, $conn);
     if (!empty($aaa) && $aaa['status'] == 2) {
@@ -143,7 +146,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
     $stmt->bindParam(':repairerid', $repairerid);
     $stmt->bindParam(':creater', $creater);
     $stmt->bindParam(':create_at', $create_at);
-    // $stmt->execute();
+    $stmt->execute();
 
     //create contract table
 
@@ -179,7 +182,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
     $stmt->bindParam(':end_date', $end_date);
     $stmt->bindParam(':creater', $creater);
     $stmt->bindParam(':create_at', $create_at);
-    // $stmt->execute();
+    $stmt->execute();
 
     //create facility table
     // $createFacilityNo = new CreateFacilityNo();
@@ -211,16 +214,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'];
@@ -254,18 +258,25 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
         $stmt->bindParam(':area', $area);
         $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
         $stmt->bindParam(':licensedate', $ADuseful_date);
-        // $result = $stmt->execute();
+        $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);
@@ -273,10 +284,38 @@ 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();
+            $result = $stmt->execute();
         }
+
+
+        // $regular_contract_manger_id = $elevators[$idx]['regular_contract_manger_id'];
+        // $sql = "SELECT * FROM account WHERE accountid = '' ";
+        $regular_contract_manger_id = !empty($elevators[$key]['regular_contract_manger_id']) ? $elevators[$key]['regular_contract_manger_id'] : '';
+        // if ($regular_contract_manger_id != '') {
+        $sql = "SELECT * FROM account WHERE accountid = '$regular_contract_manger_id' ";
+        $stmt = $conn->prepare($sql);
+        $stmt->execute();
+        $regular_contract_manger_mail = $stmt->fetch(PDO::FETCH_ASSOC);
+
+
+        $mail_title = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-營業經理提交至設計階段";
+        $mail_content = "保養計畫 : 合約號:" . $contractno . "作番號:" . $no . "-營業經理提交至設計階段  點我";
+        // exit();
+        $mail->sendx(
+            $mail_title,
+            $mail_content,
+            [
+                // [$user_id, $user_detail['email']],
+                // [$regular_contract_manger_id, $regular_contract_manger_mail['mail']],
+                ['M0225', 'lkmd555@masada.com.tw']
+            ],
+            "永佳捷科技"
+        );
+        // echo 'send';
+        // }
     }
     // create contract_b_signed_back table
     $contract_type = $mtype;
@@ -383,14 +422,17 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
     $stmt->bindParam(':payType', $payType);
     $stmt->bindParam(':signing_date', $signing_date);
 
-    // $stmt->execute();
+    $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);
@@ -411,19 +453,20 @@ 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['customer']) ? $data['customer'] : null;  //客戶名稱 / 業務聯絡人
-    // $partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : 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();
 
@@ -456,7 +499,6 @@ function T8insert($data, $facilityno, $depId, $connT8)
         $stmt->bindParam(':TaxNo', $vat);
         $stmt->bindParam(':EnterpriseName', $invoice);  //企業名稱 //發票抬頭
         $stmt->bindParam(':ContactAddress', $invoice_address);
-        // $stmt->bindParam(':EMail', $email);
         $stmt->bindParam(':CreatorId', $user_id);
         $stmt->bindParam(':CreateTime', $createTime);
         $stmt->execute();
@@ -588,10 +630,10 @@ function T8insert($data, $facilityno, $depId, $connT8)
         ];
         // 幾年
         // $SQuantityYear = $elevator['maintain_months'] / 12;
+        $price_of_month = intval($elevator['sold_price']);
         //分幾期 () => 總共保養月 / 分期月
         $SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType];
         $SQuantity = $IncomeId[$payType];
-        // $paymonth = $IncomeId[$payType] * $SQuantity;
 
         $date_1 = getNext25thDate($contract_begin_date);
 
@@ -609,7 +651,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",
@@ -619,10 +661,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", @@ -643,7 +693,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 = [ @@ -658,15 +710,15 @@ function T8insert($data, $facilityno, $depId, $connT8) $API_body[] = $salIncomeApplyMaster; $API_body[] = $salIncomeApplyDetail; // 呼叫 API - echo '
';
-    print_r(json_encode($API_body));
-    echo '
'; - // $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; - $api_url = "http://60.244.87.101:880/twWebAPI/V1/SALINCOMEAPPLY/PostERPData"; + // echo '
';
+    // print_r(json_encode($API_body));
+    // echo '
'; + // $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); - if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { + if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { http_response_code(404); die('Error!:' . $result['ErrorMsg']); } @@ -706,7 +758,7 @@ 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; //第一筆保養款項收回日 @@ -729,108 +781,111 @@ function bonusCreate($data, $facilityno, $conn) } $renew_priceissue_bonus = []; // $years = ($maintain_months % 12) == 0 ? $maintain_months / 12 : ''; - - // 如果保養合約 大於一年 - 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'], 2); - $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 - ); - } + ///////////////////////////////// + // 如果保養合約 大於一年 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 "
"; + // } + ///////////////////////////////// + // 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 d6490c33..d7250a17 100644 --- a/wms/contract/api/test copy.json +++ b/wms/contract/api/test copy.json @@ -1,72 +1,40 @@ -[ - { - "apply_key": "MB24010007", - "register_code": "036B017432", - "elevator_brand": "1", - "elevator_kind": "A", - "spec": "MAE100", - "weight": 550, - "speed": 60, - "stop": 12, - "floors": 12, - "persons": 8, - "elevator_num": 0, - "useful_years": 83, - "last_check_date": 1121109, - "speed_governors_check_expense": 0, - "maintain_times": 1, - "is_m1_bundle": "N", - "maintainance": "A", - "maintain_months": "12", - "maintain_period": 1, - "stand_price": 3140, - "contract_price": 1666.67, - "sold_price": 1667, - "commission_expense": null, - "management_expense": null, - "annual_survey_expense": 0, - "service_expense": 2, - "cmstatus": "Y", - "updated_at": null, - "creater": null, - "created_at": "2024-01-10 11:16:26", - "discount": 0.5301496815286625, - "bonus_verson": "2.0", - "manager": "M0137" - }, - { - "apply_key": "MB24010007", - "register_code": "036B032903", - "elevator_brand": "1", - "elevator_kind": "A", - "spec": "MAE100", - "weight": 450, - "speed": 60, - "stop": 7, - "floors": 7, - "persons": 6, - "elevator_num": 0, - "useful_years": 83, - "last_check_date": 1121109, - "speed_governors_check_expense": 0, - "maintain_times": 1, - "is_m1_bundle": "N", - "maintainance": "A", - "maintain_months": "12", - "maintain_period": 1, - "stand_price": 2540, - "contract_price": 1666.67, - "sold_price": 1667, - "commission_expense": null, - "management_expense": null, - "annual_survey_expense": 0, - "service_expense": 2, - "cmstatus": "Y", - "updated_at": null, - "creater": null, - "created_at": "2024-01-10 11:16:26", - "discount": 0.6553818897637795, - "bonus_verson": "2.0", - "manager": "M0137" - } -] \ No newline at end of file +{ + "apply_key": "MB24010007", + "register_code": "036B017432", + "elevator_brand": "1", + "elevator_kind": "A", + "spec": "MAE100", + "weight": 550, + "speed": 60, + "stop": 12, + "floors": 12, + "persons": 8, + "elevator_num": 0, + "useful_years": 83, + "last_check_date": 1121109, + "speed_governors_check_expense": 0, + "maintain_times": 1, + "is_m1_bundle": "N", + "maintainance": "A", + "maintain_months": 12, + "maintain_period": 1, + "stand_price": 3140, + "contract_price": 1666.67, + "sold_price": 1667, + "commission_expense": null, + "management_expense": null, + "annual_survey_expense": 0, + "service_expense": 8, + "cmstatus": "Y", + "updated_at": null, + "creater": null, + "created_at": "2024-01-10 11:16:26", + "discount": 53, + "opendoor": "2S", + "latitude": "112", + "longitude": "11", + "takecertificatedate": "112", + "useful_date": "113-01-01", + "bonus_verson": "2.0", + "manager": "M0137" +} \ No newline at end of file diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index a77acf8b..40b60024 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,258 +1,17 @@ prepare($sql); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); -// { -// "BillNo": "Z001", //合約單號 -// "BillDate": 20210420, //簽約日期 -// "TypeId": "SO", // -// "FOrgId": "1000", -// "OrgId": "1000", -// "ModeId": "T", // T汰改 M新梯 -// "BizPartnerId": "M0225", //創建人ID -// "CurrId": "TWD", -// "CurrOAmount": 1, -// "CurrLAmount": 1, -// "PersonId": "M0225", //業務人員 -// "DueToId": "512", //業務部門 -// "TradeConditionId": "", -// "TaxId": "ST005", -// "CreditorCompId": "1000", -// "CreditorOrgId": "1000", -// "CreditorCurrOAmount": 1, -// "CreditorCurrLAmount": 1, -// "CompId": "1000" -// } -// ] -// }, -// { -// //salSalesOrderDetail -// "name": "SubOrder", -// "rows": [ -// { -// "SupplyCompId": "1001", -// "SupplyOrgId": "1000", -// "TaxId": "ST005", -// "RequirementDate": 20210420, //出貨日期 -// "ConsignmentDate": 20210420, //發貨日期 -// "DispatchCompId": "1001", -// "DispatchOrgId": "1000", -// "BillNo": "Z001", //合約號 -// "RowCode": 1, //全部筆數排列 -// "ItemType": 0, -// "MaterialId": "Z001", //作番號 -// "SUnitId": "SET", -// "SQuantity": 1, //交易數量 -// "SPrice": 1 //交易價格 -// } -// ] -// }, -// { -// "name": "salOrderStagePay", -// "rows": [ -// { -// "BillNo": "", -// "RowCode": "", -// "RowNo": "", -// "PayStage": "ST003", //收款階段 -// "PlanPercentage": "Z001", //計劃收款比例(%) -// "PlanPayAmt": 1, //計劃收款金額 -// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 -// "UnWriteOffOAmount": 1 //未核銷金額 -// } -// ] -// } -// ] -require_once("../../T8_Authorization_from_bpm.php"); -$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; +$aaa = intval($result['OAmountWithTax']) - 24; +$sql = "UPDATE salIncomeApplyDetail SET OAmountWithTax = $aaa WHERE BillNo = 'B24010032' AND RowCode = '1'"; +$stmt = $connT8->prepare($sql); +$stmt->execute(); -$validation = get_Auth(); -$header = [ - "CHI_Authorization :" . $validation, - "GroupId:MASADA" -]; -$url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=1000,M24020076"; - -$ch = curl_init(); -curl_setopt($ch, CURLOPT_URL, $url); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_HTTPHEADER, $header); - -$response = curl_exec($ch); -if ($response === false) { - echo 'Curl error: ' . curl_error($ch); -} else { - $result = json_decode($response, true); - // 若 API 傳入失敗。 - if ($result['Status'] == 'Erroe') { - echo 'API傳入失敗,' . $result['ErrorMsg']; - print_r($result); - } else { - // print_r($result); - print_r($result); - } - print_r($result); -} - -curl_close($ch); -exit(); -$contract_no = "M24020003"; -// $contract_no = "M24010109"; -$MainSalesOrder_row = [ - "BillNo" => "$contract_no", //合約單號 - "BillDate" => 20210420, //簽約日期 - "TypeId" => "SO", // - "FOrgId" => "1000", - "OrgId" => "1000", - "ModeId" => "M", // T汰改 M新梯 - "BizPartnerId" => "$contract_no", //客戶代碼 - "CurrId" => "TWD", - "CurrOAmount" => 1, - "CurrLAmount" => 1, - "PersonId" => "M0177", //業務人員 - "DueToId" => "$contract_no", //債務方 - "TradeConditionId" => "", - "TaxId" => "ST005", - "CreditorCompId" => "1001", - "CreditorOrgId" => "1000", - "CreatorId" => "M0225" - -]; -// //salSalesOrderDetail -// $SubOrder_row = []; -for ($i = 0; $i < 3; $i++) { - if ($i == 0) { - $row = [ - // "SupplyCompId" => "1001", - // "SupplyOrgId" => "1000", - "TaxId" => "ST005", - "RequirementDate" => 20210420, //出貨日期 - "ConsignmentDate" => 20210420, //發貨日期 - // "DispatchCompId" => "1001", - // "DispatchOrgId" => "1000", - "BillNo" => "$contract_no", //合約號 - "RowCode" => $i, //全部筆數排列 - "ItemType" => 1, - "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => 100000 //交易價格 - ]; - } - if ($i == 1) { - $row = [ - // "SupplyCompId" => "1001", - // "SupplyOrgId" => "1000", - "TaxId" => "ST005", - "RequirementDate" => 20210420, //出貨日期 - "ConsignmentDate" => 20210420, //發貨日期 - // "DispatchCompId" => "1001", - // "DispatchOrgId" => "1000", - "BillNo" => "$contract_no", //合約號 - "RowCode" => $i, //全部筆數排列 - "ItemType" => 1, - "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => 650000 //交易價格 - ]; - } - if ($i == 2) { - $row = [ - "TaxId" => "ST005", - "RequirementDate" => 20210420, //出貨日期 - "ConsignmentDate" => 20210420, //發貨日期 - "BillNo" => "$contract_no", //合約號 - "RowCode" => $i, //全部筆數排列 - "ItemType" => 0, - "MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) - "SUnitId" => "SET", - "SQuantity" => 1, //交易數量 - "SPrice" => 0 //交易價格 - ]; - } - $SubOrder_row[] = $row; -} - - -$salOrderStagePay_row = []; -$roww = [ - "PayStage" => "簽約", //收款階段 - "PlanPercentage" => 0.5, //計劃收款比例(%) - "PlanPayAmt" => 375000, //計劃收款金額 - "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 - "BillNo" => "$contract_no", - "RowCode" => 1, - "RowNo" => 1, - "UnWriteOffOAmount" => 375000 //未核銷金額 -]; -$roww2 = [ - "PayStage" => "貨抵工地", - "PlanPercentage" => 0.5, - "PlanPayAmt" => 375000, - "PlanPayDate" => 20240101, - "BillNo" => "$contract_no", - "RowCode" => 2, - "RowNo" => 2, - "UnWriteOffOAmount" => 375000 -]; -$salOrderStagePay_row[] = $roww; -$salOrderStagePay_row[] = $roww2; - - -$MainSalesOrder = [ - "name" => "MainSalesOrder", - 'rows' => [$MainSalesOrder_row] -]; -$SubOrder = [ - "name" => "SubOrder", - "rows" => $SubOrder_row -]; -$salOrderStagePay = [ - "name" => "salOrderStagePay", - "rows" => $salOrderStagePay_row -]; - -$APIbody = []; -$APIbody[] = $MainSalesOrder; -$APIbody[] = $SubOrder; -$APIbody[] = $salOrderStagePay; -// $data = file_get_contents('test copy.json'); -// $arr = json_decode($data, true); -// echo "
";
-// print_r($data);
-// echo "
"; echo "
";
-print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE));
+print_r($result['OAmountWithTax']);
 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/contract-input.php b/wms/contract/contract-input.php index cab62f7e..dcba75cd 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -74,7 +74,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

@@ -236,6 +236,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); +

未填寫

@@ -276,11 +277,11 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

@@ -362,7 +363,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 竣檢日(民國年分) -

未填寫

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

未填寫

+ 保養頻率

未填寫

@@ -422,7 +425,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); --> 獎金適用版本 - + 作番契約金額(月) @@ -432,9 +435,17 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); 地區處長員工號 - + + + 專任契約經理員工號 - + - -
- - -
- -
- - -
- -
- - -
- -
- - -
-
- - -
+--> -
- - -
- -
- - -
- - -
-
- -
- - - +
+ + +
+ + +
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/wms/schedule-index.php b/wms/schedule-index.php index 0aec06c1..d0f5c57f 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]; @@ -41,7 +41,7 @@ if (!empty($sql_cmd2)) { $sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc"; $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); @@ -211,15 +211,17 @@ if ($data) : - + 查看明細 - 瀏覽 + 瀏覽 瀏覽"; - } ?> + } ?> +