From 6a8ffe182eba41f25add7a130095cd57ae9c7fbc Mon Sep 17 00:00:00 2001 From: Cheng Date: Thu, 15 Feb 2024 17:56:34 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E7=8D=8E=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/api/postStatus.php | 60 ++++ wms/bonus/bonus.php | 477 +++++++++++++++----------- wms/bonus/bonus_detail.php | 21 +- wms/contract-repair/js/alpine.js | 47 ++- wms/contract-repair/styles/style.css | 423 +++++++++++++++-------- wms/contract-repair/styles/style.scss | 2 +- wms/contract/contract-new-apply.php | 10 +- 7 files changed, 679 insertions(+), 361 deletions(-) create mode 100644 wms/bonus/api/postStatus.php diff --git a/wms/bonus/api/postStatus.php b/wms/bonus/api/postStatus.php new file mode 100644 index 00000000..a7abb7b8 --- /dev/null +++ b/wms/bonus/api/postStatus.php @@ -0,0 +1,60 @@ +prepare($sql); + $stmt->execute(); + + echo 'Success'; +} +// 獎金確認發放,並更新獎金 OR 實際發放時間 +if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { + + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $review_at = date("Y-m-d"); + try { + $sql = "UPDATE bonus SET status = 2,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } catch (PDOException $e) { + header("HTTP/1.1 500 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} + +// 獎金暫不發放 +if (!empty($_POST['postType']) && $_POST['postType'] == 'c') { + // echo 'cccccc'; + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + try { + $sql = "UPDATE bonus SET status = 4,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } catch (PDOException $e) { + header("HTTP/1.1 500 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} + +if (!empty($_POST['postType']) && $_POST['postType'] == 'd') { + $id = empty($_POST['id']) ? '' : $_POST['id']; + print_r($id); + // echo 'ddddd'; +} diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index eb1959a2..4e5b3f8d 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -15,10 +15,22 @@ $bonus_type = [ '2' => '區經理獎金', '3' => '專任契約經理獎金' ]; + +$bonus_status = [ + '1' => '未確認', + '2' => '應發已確認', + '3' => '應發未確認', + '4' => '暫不發放', + '5' => '人事審核確認' +]; $clause = ''; +if ($user_id != 'M0225') { + $clause .= "AND receiver == '$user_id'"; +} if (!empty($_GET['check'])) { - if ($_GET['check'] == 1) { - $clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; + // 人事發放作業,應為一個月內 + if ($_GET['check'] == 4) { + $clause .= "AND pay_day_due > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; } else if ($_GET['check'] == 2) { $clause .= "AND status = 1"; } else if ($_GET['check'] == 3) { @@ -35,6 +47,14 @@ $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); $now = new DateTime(); $oneMonthAgo = $now->modify('+1 month'); +$id = []; +foreach ($datas as $data) { + $id[] = $data['id']; +} +$id_str = implode(',', $id); +echo "
";
+print_r($id_str);
+echo '
'; // 查看 T8 是否有收款明細 // require("./api/get.php"); function isPay($contract_no, $connT8) @@ -98,204 +118,257 @@ function isPay($contract_no, $connT8) -
- - -
- - - - btn-sm categoryBtn"> 所有獎金 - btn-sm categoryBtn"> 應發獎金 - btn-sm categoryBtn"> 未發獎金 - btn-sm categoryBtn"> 已發獎金 - - - - - - - - - - - - - - - - - - - - - - - $data) : - - $contract_no = $data['contract_no']; - $json = json_decode($data['bonus_json']); - - $total = empty($json->total) ? 0 : $json->total; - $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; - $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; - $isPay = isPay($data['contract_no'], $connT8); - - ?> - - - - - - - - - - - - - - - - - - - - -
項次合約類別合約號作番號獎金類別獎金版本作番總價牌價服務費應發人員預計發放時間獎金水庫狀態檢視/發放
- - - - - 發放獎金 - - 查看詳情 - -
+
+
+
+ + + + btn-sm categoryBtn"> 所有獎金 + + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $data) : + + $contract_no = $data['contract_no']; + $json = json_decode($data['bonus_json']); + + $total = empty($json->total) ? 0 : $json->total; + $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; + $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; + // $isPay = isPay($data['contract_no'], $connT8); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項次合約類別合約號作番號獎金類別獎金版本作番總價牌價服務費應發人員預計發放時間獎金水庫狀態實際發放時間發放 / 詳情
+ + + -- + + + + 查看詳情 + +
+
-
- - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/wms/bonus/bonus_detail.php b/wms/bonus/bonus_detail.php index 93762ac3..0ca70c7b 100644 --- a/wms/bonus/bonus_detail.php +++ b/wms/bonus/bonus_detail.php @@ -111,7 +111,7 @@ $maintain_type = [ 應發獎金 - + @@ -133,6 +133,17 @@ $maintain_type = [ + + 實發獎金 + + + + 實發時間 + + + 備註 + + @@ -145,6 +156,14 @@ $maintain_type = [
+ + 分期方式 + + +

未填寫

@@ -184,21 +196,13 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- 分期方式 + 附件 - -

未填寫

+ - + + + - - +
+ + + + + + + + + + + + + + + + + + + + + +
項次電梯人乘/
載重
停數速度(m/min)保養月數保養次數(月)保養方式公司發布價(月)數量公司發布價(總價)售價(月)售價(總價)
+
+ + + + + \ No newline at end of file From 8d4230eed8bd0767ba88715e6c5aa4f71cab6b04 Mon Sep 17 00:00:00 2001 From: Cheng Date: Thu, 15 Feb 2024 17:56:34 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E7=8D=8E=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/bonus/api/postStatus.php | 60 ++++ wms/bonus/bonus.php | 477 +++++++++++++++----------- wms/bonus/bonus_detail.php | 21 +- wms/contract-repair/js/alpine.js | 47 ++- wms/contract-repair/styles/style.css | 423 +++++++++++++++-------- wms/contract-repair/styles/style.scss | 2 +- wms/contract/contract-new-apply.php | 10 +- 7 files changed, 679 insertions(+), 361 deletions(-) create mode 100644 wms/bonus/api/postStatus.php diff --git a/wms/bonus/api/postStatus.php b/wms/bonus/api/postStatus.php new file mode 100644 index 00000000..a7abb7b8 --- /dev/null +++ b/wms/bonus/api/postStatus.php @@ -0,0 +1,60 @@ +prepare($sql); + $stmt->execute(); + + echo 'Success'; +} +// 獎金確認發放,並更新獎金 OR 實際發放時間 +if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { + + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $review_at = date("Y-m-d"); + try { + $sql = "UPDATE bonus SET status = 2,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } catch (PDOException $e) { + header("HTTP/1.1 500 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} + +// 獎金暫不發放 +if (!empty($_POST['postType']) && $_POST['postType'] == 'c') { + // echo 'cccccc'; + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + try { + $sql = "UPDATE bonus SET status = 4,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } catch (PDOException $e) { + header("HTTP/1.1 500 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} + +if (!empty($_POST['postType']) && $_POST['postType'] == 'd') { + $id = empty($_POST['id']) ? '' : $_POST['id']; + print_r($id); + // echo 'ddddd'; +} diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index eb1959a2..4e5b3f8d 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -15,10 +15,22 @@ $bonus_type = [ '2' => '區經理獎金', '3' => '專任契約經理獎金' ]; + +$bonus_status = [ + '1' => '未確認', + '2' => '應發已確認', + '3' => '應發未確認', + '4' => '暫不發放', + '5' => '人事審核確認' +]; $clause = ''; +if ($user_id != 'M0225') { + $clause .= "AND receiver == '$user_id'"; +} if (!empty($_GET['check'])) { - if ($_GET['check'] == 1) { - $clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; + // 人事發放作業,應為一個月內 + if ($_GET['check'] == 4) { + $clause .= "AND pay_day_due > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; } else if ($_GET['check'] == 2) { $clause .= "AND status = 1"; } else if ($_GET['check'] == 3) { @@ -35,6 +47,14 @@ $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); $now = new DateTime(); $oneMonthAgo = $now->modify('+1 month'); +$id = []; +foreach ($datas as $data) { + $id[] = $data['id']; +} +$id_str = implode(',', $id); +echo "
";
+print_r($id_str);
+echo '
'; // 查看 T8 是否有收款明細 // require("./api/get.php"); function isPay($contract_no, $connT8) @@ -98,204 +118,257 @@ function isPay($contract_no, $connT8) -
- - -
- - - - btn-sm categoryBtn"> 所有獎金 - btn-sm categoryBtn"> 應發獎金 - btn-sm categoryBtn"> 未發獎金 - btn-sm categoryBtn"> 已發獎金 - - - - - - - - - - - - - - - - - - - - - - - $data) : - - $contract_no = $data['contract_no']; - $json = json_decode($data['bonus_json']); - - $total = empty($json->total) ? 0 : $json->total; - $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; - $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; - $isPay = isPay($data['contract_no'], $connT8); - - ?> - - - - - - - - - - - - - - - - - - - - -
項次合約類別合約號作番號獎金類別獎金版本作番總價牌價服務費應發人員預計發放時間獎金水庫狀態檢視/發放
- - - - - 發放獎金 - - 查看詳情 - -
+
+
+
+ + + + btn-sm categoryBtn"> 所有獎金 + + btn-sm categoryBtn"> 未發獎金 + btn-sm categoryBtn"> 已發獎金 + btn-sm categoryBtn"> 人事發放作業 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $data) : + + $contract_no = $data['contract_no']; + $json = json_decode($data['bonus_json']); + + $total = empty($json->total) ? 0 : $json->total; + $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; + $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; + // $isPay = isPay($data['contract_no'], $connT8); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項次合約類別合約號作番號獎金類別獎金版本作番總價牌價服務費應發人員預計發放時間獎金水庫狀態實際發放時間發放 / 詳情
+ + + -- + + + + 查看詳情 + +
+
-
- - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/wms/bonus/bonus_detail.php b/wms/bonus/bonus_detail.php index 93762ac3..0ca70c7b 100644 --- a/wms/bonus/bonus_detail.php +++ b/wms/bonus/bonus_detail.php @@ -111,7 +111,7 @@ $maintain_type = [ 應發獎金 - + @@ -133,6 +133,17 @@ $maintain_type = [ + + 實發獎金 + + + + 實發時間 + + + 備註 + + @@ -145,6 +156,14 @@ $maintain_type = [
+ + 分期方式 + + +

未填寫

@@ -184,21 +196,13 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);

未填寫

- 分期方式 + 附件 - -

未填寫

+ - + + + - - +
+ + + + + + + + + + + + + + + + + + + + + +
項次電梯人乘/
載重
停數速度(m/min)保養月數保養次數(月)保養方式公司發布價(月)數量公司發布價(總價)售價(月)售價(總價)
+
+ + + + + \ No newline at end of file From 4bf5d6975d6e9f557f89be25016dc8cb3ae4c08d Mon Sep 17 00:00:00 2001 From: Ellin Date: Tue, 20 Feb 2024 17:38:19 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=87=89=E6=94=B6=E5=B8=B3=E6=AC=BE(?= =?UTF-8?q?=E6=96=B0=E6=A2=AF)=20v2=E4=BF=AE=E6=94=B9=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/account-receivable-new-index.php | 205 +++++++++++++++++---------- 1 file changed, 131 insertions(+), 74 deletions(-) diff --git a/wms/account-receivable-new-index.php b/wms/account-receivable-new-index.php index b5c07277..e4cd3eb7 100644 --- a/wms/account-receivable-new-index.php +++ b/wms/account-receivable-new-index.php @@ -60,39 +60,48 @@ function get_ratio($facilityno, $contractno, $arrayData) } // 查WMS 員工與對應主管 -$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A -LEFT JOIN account AS B ON A.manager = B.accountid "; -$managers = mysqli_query($link, $sql_manager); -// $find_manager['員工工號'] = array('員工姓名', '主管工號', '主管姓名'); -$find_manager = array(); -if (is_iterable($managers)) { - foreach ($managers as $manager) { - $find_manager[$manager['accountid']] = $manager; - } -} +// $sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A +// LEFT JOIN account AS B ON A.manager = B.accountid "; +// $managers = mysqli_query($link, $sql_manager); +// // $find_manager['員工工號'] = array('員工姓名', '主管工號', '主管姓名'); +// $find_manager = array(); +// if (is_iterable($managers)) { +// foreach ($managers as $manager) { +// $find_manager[$manager['accountid']] = $manager; +// } +// } $follower = find_follow($user_id); // T8所有合約號 -$sql_all_contract = "SELECT MainAll.* , -Person.PersonName, -Dept.DeptName FROM - (SELECT -Main.BillNo, -Main.BillDate, -Main.BizPartnerId, -Biz.ShortName, -Biz.BizPartnerName, -Biz.ContactAddress, -Main.OAmountWithTax, -Main.PersonId, -Main.DeptId, -Main.ModeId, -Main.CurrentState - FROM salSalesOrder AS Main - LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId) AS MainAll - LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId= Person.PersonId - LEFT JOIN comDepartment AS Dept ON MainAll.DeptId= Dept.DeptId - WHERE MainAll.ModeId = 'M' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) "; +$sql_all_contract = "SELECT +MainAll.*, +Person.PersonName, +Dept.DeptName, +Dept.LeaderId, +Leader.PersonName AS LeaderName +FROM +( + SELECT + Main.BillNo, + Main.BillDate, + Main.BizPartnerId, + Biz.ShortName, + Biz.BizPartnerName, + Biz.ContactAddress, + Main.OAmountWithTax, + Main.PersonId, + Main.DeptId, + Main.ModeId, + Main.CurrentState + FROM + salSalesOrder AS Main + LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId +) AS MainAll +LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId = Person.PersonId +LEFT JOIN comDepartment AS Dept ON MainAll.DeptId = Dept.DeptId +LEFT JOIN comGroupPerson AS Leader ON Dept.LeaderId = Leader.PersonId +WHERE +MainAll.ModeId = 'M' AND (MainAll.CurrentState = 2 OR MainAll.CurrentState = 4) "; if (!is_null($start_date)) { $start_date = (int)date('Ymd', strtotime($start_date)); $sql_all_contract .= " AND MainAll.BillDate >= $start_date "; @@ -130,8 +139,8 @@ if (is_iterable($query_all_contract)) { $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']]['ManagerId'] = isset($contract_numbers['LeaderId']) ? $contract_numbers['LeaderId'] : '--'; + $arrayData[$contract_numbers['BillNo']]['ManagerName'] = isset($contract_numbers['LeaderName']) ? $contract_numbers['LeaderName'] : '--'; $arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0; $arrayData[$contract_numbers['BillNo']]['received_budget'] = 0; $arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0; @@ -142,6 +151,7 @@ if (is_iterable($query_all_contract)) { $arrayData[$contract_numbers['BillNo']]['facility'] = array(); $arrayData[$contract_numbers['BillNo']]['total_budget'] = $contract_numbers['OAmountWithTax']; $sum_total_budget += $contract_numbers['OAmountWithTax']; + $sum_contract +=1; } } $str_numbers .= "('" . implode("','", $contractNumbers) . "')"; @@ -166,7 +176,18 @@ foreach ($query_contract_budget as $contract_budget) { $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['total_budget'] = $contract_budget['OAmountWithTax']; $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']][$contract_budget['MaterialId']] = $contract_budget['OAmountWithTax']; $arrayData[$contract_budget['BillNo']]['facility'][$contract_budget['CU_MaterialId']]['status'] = ""; + $sum_facility +=1; } + switch($contract_budget['CU_MaterialId']){ + case "A40001": + $sum_A40001 += $contract_budget['OAmountWithTax']; + break; + case "A40008": + $sum_A40008 += $contract_budget['OAmountWithTax']; + break; + + } + } } @@ -205,6 +226,7 @@ foreach ($query_PayStage as $PayStage) { } else { $PayStage_array[$PayStage['BillNo']] = $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage']; } + $arrayData[$PayStage['BillNo']]['facility'][$key]['PayStage'] = array(); } } } @@ -264,25 +286,25 @@ foreach ($query_wip as $wip) { if (isset($arrayData[$wip['contractno']]) && isset($arrayData[$wip['contractno']]['facility'][$wip['facilityno']])) { if ($wip['delivery_date'] != NULL && $wip['delivery_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['delivery_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['delivery_date'] . "已移交"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) ; "; } elseif ($wip['official_check_date'] != NULL && $wip['official_check_date'] != '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['official_check_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['official_check_date'] . "官檢完畢"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) ; "; } elseif ($wip['tryrun_end_date'] != NULL && $wip['tryrun_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['tryrun_end_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['tryrun_end_date'] . "試車完畢"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) ; "; } elseif ($wip['install_end_date'] != NULL && $wip['install_end_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['install_end_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['install_end_date'] . "安裝完畢"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) ; "; } elseif ($wip['real_arrival_date'] != NULL && $wip['real_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_arrival_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_arrival_date'] . "貨抵工地"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) ; "; } elseif ($wip['real_contract_arrival_date'] != NULL && $wip['real_contract_arrival_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['real_contract_arrival_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['real_contract_arrival_date'] . "預計出貨"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨) ; "; } elseif ($wip['estimated_shipping_date'] != NULL && $wip['estimated_shipping_date'] !== '1970-01-01' && $wip['delivery_date'] !== '1970-01-11' && !empty($wip['estimated_shipping_date'])) { $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['estimated_shipping_date'] . "預計出港"; - $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港) "; + $arrayData[$wip['contractno']]['facility_status'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港) ; "; } } } @@ -294,7 +316,6 @@ $sign0 = array('簽約', '簽訂', '合約簽訂', '訂金'); $arrival = array('貨抵工地', '貨底工地', '工地動工'); $final6 = array('核可函取得後6個月', '得合格函後6個月'); - foreach ($PayStage_array as $key => &$value) { foreach ($value as $paykey => &$payvalue) { if (isset($wip_array[$payvalue['facilityno']])) { @@ -375,7 +396,7 @@ foreach ($PayStage_array as $key => &$value) { $payvalue['PlanPayDate'] = NULL; } break; - case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)')): + case (stristr($payvalue['PayStage'], '出貨前30') || stristr($payvalue['PayStage'], '簽約(出貨前30天)') ||stristr($payvalue['PayStage'], '建照核發時')): $payvalue['stage'] = '二次款'; if ($wip_array[$payvalue['facilityno']]['real_arrival_date'] !== null && strtotime($wip_array[$payvalue['facilityno']]['real_arrival_date']) > 975686400 && !empty($wip_array[$payvalue['facilityno']]['real_arrival_date'])) { $estimate_time = strtotime($wip['real_arrival_date']); @@ -431,6 +452,12 @@ foreach ($PayStage_array as $key => &$value) { $payvalue['PlanPayDate'] = NULL; } break; + case "簽定30天內": + $payvalue['stage'] = '二次款'; + $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); + $signtime = $estimate_time + (30 * 86400); + $payvalue['PlanPayDate'] = date('Y-m-d', $signtime); + break; case (in_array($payvalue['PayStage'], $sign60)): $payvalue['stage'] = '二次款'; $estimate_time = strtotime($arrayData[$key]['PayStage'][1]['PlanPayDate']); @@ -513,6 +540,9 @@ foreach ($PayStage_array as $key => &$value) { if (strtotime($payvalue['PlanPayDate']) < 975686400) { $payvalue['PlanPayDate'] = NULL; } + } else { + $payvalue['PlanPayDate'] = NULL; + $payvalue['stage'] = "大日程無作番"; } } } @@ -560,8 +590,8 @@ CheckAll.FromSalSalesOrder AS BillNo $query_invoice = $conn->query($sql_invoice); //發票資訊回填到arrayData -foreach($query_invoice as $invoice) { - if(isset($arrayData[$invoice['BillNo']])) { +foreach ($query_invoice as $invoice) { + if (isset($arrayData[$invoice['BillNo']])) { $arrayData[$invoice['BillNo']]['invoice_budget'] += $invoice['LAmountWithTax']; } } @@ -590,8 +620,8 @@ WHERE CheckDetail.ModeId = 'M'"; $query_received = $conn->query($sql_received); // 核銷資訊回填到arrayData -foreach($query_received as $received) { - if(isset($arrayData[$received['OrderBillNo']])) { +foreach ($query_received as $received) { + if (isset($arrayData[$received['OrderBillNo']])) { $arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount']; } } @@ -601,64 +631,91 @@ $today = strtotime(date('Y-m-t')); foreach ($final_paystage as $key => &$value) { $tmpinvoice = $arrayData[$key]['invoice_budget']; $tmpreceived = $arrayData[$key]['received_budget']; - for($sequenceNumber = 1; $sequenceNumber <= count($value); $sequenceNumber++) { - if(isset($value[$sequenceNumber]['PlanPayDate'])) { + for ($sequenceNumber = 1; $sequenceNumber <= count($value); $sequenceNumber++) { + if (isset($value[$sequenceNumber]['PlanPayDate'])) { $collect_month = collect_month(strtotime($value[$sequenceNumber]['PlanPayDate'])); - if($today > strtotime($value[$sequenceNumber]['PlanPayDate'])){ + if ($today > strtotime($value[$sequenceNumber]['PlanPayDate'])) { $value[$sequenceNumber]['hadtopay'] = 'V'; - }else{ + $arrayData[$key]['receivable_budget'] += $value[$sequenceNumber]['PlanPayAmt']; + } else { $value[$sequenceNumber]['hadtopay'] = '--'; } - }else{ + } else { $collect_month = 0; $value[$sequenceNumber]['hadtopay'] = '--'; } - if($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']){ + if ($tmpinvoice >= $value[$sequenceNumber]['PlanPayAmt']) { $value[$sequenceNumber]['invoice_budget'] = $value[$sequenceNumber]['PlanPayAmt']; $tmpinvoice -= $value[$sequenceNumber]['invoice_budget']; - }else{ + } elseif ($tmpinvoice > 0) { $value[$sequenceNumber]['invoice_budget'] = $tmpinvoice; $tmpinvoice = 0; + } else { + $value[$sequenceNumber]['invoice_budget'] = 0; } - if($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']){ + if ($tmpreceived > $value[$sequenceNumber]['PlanPayAmt']) { $value[$sequenceNumber]['received_budget'] = $value[$sequenceNumber]['PlanPayAmt']; $tmpinvoice -= $value[$sequenceNumber]['received_budget']; - }else{ + } elseif ($tmpreceived > 0) { $value[$sequenceNumber]['received_budget'] = $tmpreceived; $tmpreceived = 0; + } else { + $value[$sequenceNumber]['received_budget'] = 0; } - if($collect_month >0 && $value[$sequenceNumber]['PlanPayAmt']> $value[$sequenceNumber]['received_budget']){ + if ($collect_month > 0 && $value[$sequenceNumber]['PlanPayAmt'] > $value[$sequenceNumber]['received_budget']) { $value[$sequenceNumber]['collect_month'] = $collect_month; - }else{ + } else { $value[$sequenceNumber]['collect_month'] = 0; } - } } -// foreach ($final_paystage as $key => $value) { -// echo $key." =>
"; + +// foreach($final_paystage as $key => $value) { +// echo $key."
"; +// echo "---------------------
"; // foreach($value as $key2 => $value2) { // echo $key2."
"; // print_r($value2); // echo "
"; // } -// echo "
-------------------------------
"; +// echo "
==================
"; // } // exit(); +foreach ($final_paystage as $key => $value) { + for ($sequence = 1; $sequence <= count($value); $sequence++) { + if (isset($arrayData[$key]) && isset($arrayData[$key]['facility']) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]) && isset($arrayData[$key]['facility'][$value[$sequence]['facilityno']]['PayStage'])) { + array_push($arrayData[$key]['facility'][$value[$sequence]['facilityno']]['PayStage'], $value[$sequence]); + foreach ($arrayData[$key]['PayStage'] as $arkey => &$arvalue) { + if ($arvalue['PayStage'] == $value[$sequence]['PayStage']) { + if (isset($arvalue['receivable_budget']) && isset($arvalue['received_budget']) && isset($arvalue['invoice_budget'])) { + $arvalue['receivable_budget'] += $value[$sequence]['PlanPayAmt']; + $arvalue['received_budget'] += $value[$sequence]['received_budget']; + $arvalue['invoice_budget'] += $value[$sequence]['invoice_budget']; + if ($arvalue['collect_month'] < $value[$sequence]['collect_month']) { + $arvalue['collect_month'] = $value[$sequence]['collect_month']; + } + } else { + $arvalue['stage'] = $value[$sequence]['stage']; + $arvalue['receivable_budget'] = $value[$sequence]['PlanPayAmt']; + $arvalue['received_budget'] = $value[$sequence]['received_budget']; + $arvalue['invoice_budget'] = $value[$sequence]['invoice_budget']; + $arvalue['collect_month'] = $value[$sequence]['collect_month']; + } + } + } + } + } +} // 存進excel_array -// $excel_array = array(); -// $today = strtotime(date('Ymt')); -foreach($arrayData as $key => $value) { - echo $key."
"; - foreach($value['facility'] as $key2 => $value2) { - echo $key2."
"; - foreach($value2 as $key3 => $value3){ - echo $key3."
"; - print_r($value3); - echo "
*********************
"; - } - echo "
==================
"; - } +$excel_array = array(); +foreach ($arrayData as $key => $value) { + echo $key . "
********************
"; + print_r($value); + // foreach($value['facility'] as $key2 => $value2) { + // echo $key2."
"; + // print_r($value2['PayStage']); + // echo "
"; + // } echo "
-------------------------------
"; -} \ No newline at end of file +} From 56768aa586115b01d6be496e98d4ec75e951bd78 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 20 Feb 2024 18:00:16 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E7=B0=BD=E5=9B=9E?= =?UTF-8?q?=E8=88=87=E7=8D=8E=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/T8_Authorization_from_bpm.php | 12 +- wms/bonus/api/postStatus.php | 117 +- wms/bonus/bonus.php | 70 +- wms/bonus/bonus_check.php | 199 +++ wms/bonus/bonus_detail.php | 13 +- .../other/maintenance_contract_bonus_v2_1.php | 14 +- wms/contract-repair/js/alpine.js | 12 +- wms/contract/api/T8salIncomeApply.php | 11 +- wms/contract/api/postContractData.php | 229 ++- wms/contract/api/testT8API.php | 45 +- wms/contract/contract-input.php | 2 +- wms/contract/js/alpine.js | 32 +- wms/mkt/assets/js/pricereviewAlpine.js | 1585 ++++++++--------- 13 files changed, 1355 insertions(+), 986 deletions(-) create mode 100644 wms/bonus/bonus_check.php diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index 7c206023..b862a81d 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -3,10 +3,7 @@ // $user_id = "M0000"; // $user_password = "M012290493119"; -$user_id = "M0117"; -$user_password = "90493119"; - -echo $validation = get_Auth($user_id, $user_password); +// echo $validation = get_Auth($user_id, $user_password); function get_Auth($user_id = "M0000", $user_password = "M012290493119") { @@ -16,8 +13,9 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") // $now = gmdate("YmdHis"); $now = gmdate("YmdHis", strtotime("-2 minutes")); $data = "$user_id." . $now; - $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); + $sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false); + // echo $sign; // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; @@ -30,7 +28,7 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") "Pwd: $user_password", "TimestampUTC: $now", "Sign: $sign", - "GroupId: TEST" + "GroupId:TEST" ]; $ch = curl_init(); @@ -53,4 +51,4 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119") curl_close($ch); } // $data = []; -get_Auth(); +// get_Auth(); diff --git a/wms/bonus/api/postStatus.php b/wms/bonus/api/postStatus.php index a7abb7b8..86f9f88d 100644 --- a/wms/bonus/api/postStatus.php +++ b/wms/bonus/api/postStatus.php @@ -2,32 +2,44 @@ require_once("../../contract/conn.php"); if (!empty($_POST['id']) && !empty($_POST['postType']) && $_POST['postType'] == 'a') { - $id = empty($_POST['id']) ? '' : $_POST['id']; - $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; - $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; - $review_at = date("Y-m-d"); - $sql = "UPDATE bonus SET status = 2 ,review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day' WHERE id = $id"; - $stmt = $conn->prepare($sql); - $stmt->execute(); - - echo 'Success'; -} -// 獎金確認發放,並更新獎金 OR 實際發放時間 -if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { - - $id = empty($_POST['id']) ? '' : $_POST['id']; - $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; - $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; - $note = empty($_POST['note']) ? '' : $_POST['note']; - $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; - $review_at = date("Y-m-d"); try { - $sql = "UPDATE bonus SET status = 2,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + $id = empty($_POST['id']) ? '' : $_POST['id']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $amount = empty($_POST['amount']) ? '' : $_POST['amount']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $review_at = date("Y-m-d H:i:s"); + $sql = "UPDATE bonus SET status = 2 ,bonus_actual='$amount',review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day',update_id='$user_id',update_at='$review_at' WHERE id = $id"; $stmt = $conn->prepare($sql); $stmt->execute(); + header("HTTP/1.1 200 success!"); + echo 'Success'; } catch (PDOException $e) { - header("HTTP/1.1 500 failed!"); + header("HTTP/1.1 404 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} +// 獎金確認發放,並更新獎金 OR 實際發放時間 +if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { + try { + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_actual']) ? '' : $_POST['bonus_actual']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $review_at = date("Y-m-d H:i:s"); + if ($pay_day != '' && $bonus_actual != '') { + $sql = "UPDATE bonus SET status = 2,review_hr='$user_id',review_at='$review_at',bonus_actual='$bonus_actual',pay_day='$pay_day',note='$note' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } else { + header("HTTP/1.1 400"); + echo '請填寫發放時間和實發獎金'; + } + } catch (PDOException $e) { + header("HTTP/1.1 404 failed!"); echo $e->getMessage(); die('Error!:' . $e->getMessage()); } @@ -36,25 +48,64 @@ if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { // 獎金暫不發放 if (!empty($_POST['postType']) && $_POST['postType'] == 'c') { // echo 'cccccc'; - $id = empty($_POST['id']) ? '' : $_POST['id']; - $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; - $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; - $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; - $note = empty($_POST['note']) ? '' : $_POST['note']; try { - $sql = "UPDATE bonus SET status = 4,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; - $stmt = $conn->prepare($sql); - $stmt->execute(); - header("HTTP/1.1 200 success!"); + $id = empty($_POST['id']) ? '' : $_POST['id']; + $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; + $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + $note = empty($_POST['note']) ? '' : $_POST['note']; + $review_at = date("Y-m-d H:i:s"); + + if ($note != '') { + $sql = "UPDATE bonus SET status = 4,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; + echo $sql; + $stmt = $conn->prepare($sql); + $stmt->execute(); + header("HTTP/1.1 200 success!"); + } else { + echo '請填寫備註!!'; + header("HTTP/1.1 400!"); + } } catch (PDOException $e) { - header("HTTP/1.1 500 failed!"); + header("HTTP/1.1 404 failed!"); echo $e->getMessage(); die('Error!:' . $e->getMessage()); } } if (!empty($_POST['postType']) && $_POST['postType'] == 'd') { - $id = empty($_POST['id']) ? '' : $_POST['id']; - print_r($id); + try { + $id = empty($_POST['id']) ? '' : $_POST['id']; + $review_at = date("Y-m-d H:i:s"); + $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; + + $sql = "SELECT * FROM bonus WHERE id IN ($id)"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $conn->beginTransaction(); + foreach ($results as $result) { + // echo '
';
+            // print_r($result);
+            // echo '
'; + // exit(); + $amount = $result['amount']; + $id = $result['id']; + $pay_day = $result['pay_day_due']; + + $sql = "UPDATE bonus SET status = 5 ,bonus_actual='$amount',review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day' WHERE id = $id"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + } + + $conn->commit(); + header("HTTP/1.1 200 success!"); + } catch (PDOException $e) { + $conn->rollBack(); + header("HTTP/1.1 404 failed!"); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } // echo 'ddddd'; } diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index 4e5b3f8d..f7462641 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -2,7 +2,7 @@ include_once("../header.php"); // require_once('./connT8.php'); require("../contract/conn.php"); - +$now = date("Y-m-d"); $contract_type = [ '1' => '新梯', @@ -30,15 +30,16 @@ if ($user_id != 'M0225') { if (!empty($_GET['check'])) { // 人事發放作業,應為一個月內 if ($_GET['check'] == 4) { - $clause .= "AND pay_day_due > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; + $oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); + $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo'"; } else if ($_GET['check'] == 2) { $clause .= "AND status = 1"; } else if ($_GET['check'] == 3) { - $clause .= "AND status = 2"; + $clause .= "AND status IN (2,5)"; } } -$sql = "SELECT * FROM bonus WHERE 1=1 $clause LIMIT 50"; +$sql = "SELECT * FROM bonus WHERE 1=1 $clause"; $stmt = $conn->prepare($sql); $stmt->execute(); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -47,14 +48,13 @@ $datas = $stmt->fetchAll(PDO::FETCH_ASSOC); $now = new DateTime(); $oneMonthAgo = $now->modify('+1 month'); + $id = []; foreach ($datas as $data) { $id[] = $data['id']; } $id_str = implode(',', $id); -echo "
";
-print_r($id_str);
-echo '
'; + // 查看 T8 是否有收款明細 // require("./api/get.php"); function isPay($contract_no, $connT8) @@ -121,9 +121,9 @@ function isPay($contract_no, $connT8)
- + btn-sm categoryBtn"> 所有獎金 btn-sm categoryBtn"> 未發獎金 @@ -132,8 +132,9 @@ function isPay($contract_no, $connT8) - - + + + @@ -142,12 +143,13 @@ function isPay($contract_no, $connT8) - + - + + 實際發放時間 - + + + @@ -164,7 +169,6 @@ function isPay($contract_no, $connT8) $contract_no = $data['contract_no']; $json = json_decode($data['bonus_json']); - $total = empty($json->total) ? 0 : $json->total; $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; @@ -178,12 +182,13 @@ function isPay($contract_no, $connT8) - + + - + - + + + const datas = ; - function issue(id, user_id, pay_day) { + function issue(id, user_id, pay_day, amount) { // console.log(id); const form = new FormData(); form.append('id', id) form.append('user_id', user_id); form.append('pay_day', pay_day) + form.append('amount', amount); + form.append('postType', 'a'); axios.post('./api/postStatus.php', form).then((res) => { if (res.data == 'Success') { alert('更新成功'); @@ -334,15 +341,20 @@ function isPay($contract_no, $connT8) function All(data) { let arr = data.split(","); - console.log(arr); const form = new FormData(); form.append('id', arr); + form.append('user_id', '') form.append('postType', 'd'); - axios.post('./api/postStatus.php', form).then((res) => { - console.log(res); - }).catch((err) => { - - }); + if (confirm('是否發放全部獎金')) { + axios.post('./api/postStatus.php', form).then((res) => { + if (res.status == 200) { + alert('更新成功'); + location.reload(); + } + }).catch((err) => { + + }); + } } // $(function() { // $("button[name=issuePay]").click(function() { diff --git a/wms/bonus/bonus_check.php b/wms/bonus/bonus_check.php new file mode 100644 index 00000000..82eb1ea9 --- /dev/null +++ b/wms/bonus/bonus_check.php @@ -0,0 +1,199 @@ +prepare($sql); +$stmt->bindParam(':id', $_GET['id']); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); +// echo '
';
+// 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' => '續簽約' +]; +?> + + + + + + + + + + +
+
+ +
+
項次作番號 獎金類別 獎金版本作番總價作番金額(月) 牌價 服務費 應發人員 預計發放時間獎金水庫應發獎金水庫實發金額 狀態 發放 / 詳情詳情
@@ -193,11 +198,9 @@ function isPay($contract_no, $connT8) -- - + 查看詳情查看詳情
+ + + + + + + +
+

獎金計算

+
+ + + +
+
+
+ + \ No newline at end of file diff --git a/wms/bonus/bonus_detail.php b/wms/bonus/bonus_detail.php index 0ca70c7b..93dafa31 100644 --- a/wms/bonus/bonus_detail.php +++ b/wms/bonus/bonus_detail.php @@ -48,17 +48,6 @@ $maintain_type = [ - - - - --> - - - 安裝 - 5、安裝完畢款 - - - - - - - - - - - - 6、驗收款 - - - - - - - - - - - - 7、其他 - - - - - - - - - - + + + + + + + 6、驗收款 + + + + + + + + + + + + 7、其他 + + + + + + + + + + - - 合計 - - - - - - - - - - - - + + 合計 + + + + + + + + + + + + - - + + - + - + - + + - \ No newline at end of file diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index f1c1a3fc..253e8d54 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -46,15 +46,52 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { try { $contractno = $_GET['contractno']; - $sql_str = "SELECT a.*,b.lm_tel,b.uscc,b.manager FROM pricereview_main AS a + $sql_str = "SELECT a.*,b.lm_tel,b.uscc,b.manager,b.linkman FROM pricereview_main AS a LEFT JOIN hope_elevator_customer AS b ON a.contractno = b.vol_no - WHERE a.contractno = :contractno AND a.status = 'YS' "; + WHERE a.contractno = :contractno AND a.status != 'YN' "; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':contractno', $contractno); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); - $contractResponse = json_encode($contract); + $salesman = $contract['person']; + $sql = "SELECT * FROM account WHERE accountid = :accountid "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':accountid', $salesman); + $stmt->execute(); + $account_detail = $stmt->fetch(PDO::FETCH_ASSOC); + $contract['manager'] = $account_detail['manager']; + $contract['salesman_departno'] = $account_detail['department_id']; + + + $mid = $contract['id']; + $sql = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A' "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators_detail_arr = []; + foreach ($results as $keys => $result) { + $note = explode(',', $result['note']); + $result['spec'] = $note[0]; //型號 + $result['person'] = $note[1]; // 人承 + $result['floor'] = $note[2]; // 樓層 + $result['speed'] = $note[3]; // 速度 + for ($i = 0; $i < $result['item_qty']; $i++) { + $result['item_no'] = $i + 1; + array_push($elevators_detail_arr, $result); + } + } + $count = COUNT($elevators_detail_arr); + + $contract['elevators'] = $results; + $contract['elevators_detail_arr'] = $elevators_detail_arr; + $contract['nums'] = $count; + // echo '
';
+        // print_r($contract);
+        // echo '
'; + // exit; + $contractResponse = json_encode($contract); // 設定回應標頭為 JSON header('Content-Type: application/json'); diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index 0ee6964e..08735fdc 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -24,6 +24,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $salesman = $_POST["salesman"]; $qc = $_POST["qc"]; $contracttype = $_POST["contracttype"]; + $elevators_nums = $_POST['nums']; + $elevators = json_decode($_POST['elevators'], true); + $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], true); + BounsCount($_POST, $conn); + // echo '
';
+    // print_r($elevators);
+    // echo '
'; + // exit; $files = !empty($_FILES['files']) ? $_FILES['files'] : null; $files_id = null; @@ -43,8 +51,27 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - - + //create facility table + $createFacilityNo = new CreateFacilityNo(); + $dailyNecessities = [ + 'MAE100' => 'X', + 'MAM200' => 'W', + 'MAH100' => 'H', + 'MAQ100' => 'Z', + 'MAF100' => 'F', + 'MAZ100' => 'B', + ]; + $arr = []; + // 建立作番號 + foreach ($elevators_detail_arr as $elevator) { + // $spec = explode('-', $elevator['item_spec']); + $arr[] = $dailyNecessities[$elevator['spec']]; + } + $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); + echo '
';
+    print_r($facilityno);
+    echo '
'; + exit(); $conn->beginTransaction(); $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; @@ -151,6 +178,7 @@ function T8Insert($data) $user_id = $data['user_id']; $salesman = $data['salesman']; $createAt = date("Y-m-dH-i-s"); + $elevators[] = $data['elevators']; $createTime = str_replace('-', '', $createAt); @@ -252,3 +280,45 @@ function T8Insert($data) $stmt->execute(); } } + + +function BounsCount($data, $conn) +{ + // echo '
';
+  // print_r($data);
+  // echo '
'; + // exit; + require_once("../../bonus/elevator_new/elevator_new_deal_bonus.php"); + $signing_date = $data['signing_date']; + $bonus_v1_0_date = '2024-01-02'; + $bonus_v2_0_date = '2024-01-03'; + $contractType = [ + '1' => 'strategy_customer', + '2' => 'general_customer' + ]; + $contract_type = $data['contract_type']; + + $type = $contractType[$contract_type]; //戰略客戶 or 一般客戶 + $elevator_knockdown_price = $data['price_total']; //受價總額 + + $salesman = $data['salesman']; + $manager = $data['manager']; + + $result_bonus = []; + if ($signing_date <= $bonus_v1_0_date) { + $ver = '1.0'; + $result_bonus = elevator_new_deal_bonus_v1_0($ver, $type, $elevator_knockdown_price, $salesman, $manager); + } else if ($signing_date >= $bonus_v2_0_date) { + $ver = '2.0'; + } + + echo '
';
+  print_r($result_bonus);
+  echo '
'; + exit(); + try { + } catch (PDOException $e) { + header("HTTP/1.1 500 Internal Server Error"); + die('Error!:' . $e->getMessage()); + } +} diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 41870a4c..9512cbc8 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,13 +1,36 @@ -$ADdate = implode('-', $click); -echo '
';
-print_r($date);
-echo '
'; + + 地址轉經緯度 + + -echo '
';
-print_r($ADdate);
-echo '
'; + +

輸入地址以獲取經緯度

+
+ + +
+
+ + + \ No newline at end of file diff --git a/wms/contract/contract-newelevator-input.php b/wms/contract/contract-newelevator-input.php index 219ced48..75992ffc 100644 --- a/wms/contract/contract-newelevator-input.php +++ b/wms/contract/contract-newelevator-input.php @@ -1,17 +1,17 @@ -prepare($sql_str); $stmt->bindParam(":accounttype", $accounttype); -$stmt -> execute(); +$stmt->execute(); $persons = $stmt->fetchAll(PDO::FETCH_ASSOC); -$persons = array_map(function($person){ +$persons = array_map(function ($person) { return [ - 'view'=>$person['accountid'] .'-'. $person['name'], - 'value'=>$person['accountid'], - 'name'=>$person['name'] + 'view' => $person['name'] . '-' . $person['accountid'], + 'value' => $person['accountid'], + 'name' => $person['name'] ]; }, $persons); ?> @@ -21,7 +21,7 @@ $persons = array_map(function($person){
-
+
@@ -31,106 +31,233 @@ $persons = array_map(function($person){

合約入力(新梯)

- + + + + +
- -