From 56768aa586115b01d6be496e98d4ec75e951bd78 Mon Sep 17 00:00:00 2001 From: Cheng Date: Tue, 20 Feb 2024 18:00:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E9=A4=8A=E7=B0=BD=E5=9B=9E=E8=88=87?= =?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/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 = [ -