Browse Source

保養簽回與獎金

gary
Cheng 1 year ago
parent
commit
56768aa586
  1. 10
      wms/T8_Authorization_from_bpm.php
  2. 73
      wms/bonus/api/postStatus.php
  3. 58
      wms/bonus/bonus.php
  4. 199
      wms/bonus/bonus_check.php
  5. 13
      wms/bonus/bonus_detail.php
  6. 14
      wms/bonus/other/maintenance_contract_bonus_v2_1.php
  7. 12
      wms/contract-repair/js/alpine.js
  8. 11
      wms/contract/api/T8salIncomeApply.php
  9. 227
      wms/contract/api/postContractData.php
  10. 45
      wms/contract/api/testT8API.php
  11. 2
      wms/contract/contract-input.php
  12. 32
      wms/contract/js/alpine.js
  13. 11
      wms/mkt/assets/js/pricereviewAlpine.js

10
wms/T8_Authorization_from_bpm.php

@ -3,10 +3,7 @@
// $user_id = "M0000"; // $user_id = "M0000";
// $user_password = "M012290493119"; // $user_password = "M012290493119";
$user_id = "M0117"; // echo $validation = get_Auth($user_id, $user_password);
$user_password = "90493119";
echo $validation = get_Auth($user_id, $user_password);
function get_Auth($user_id = "M0000", $user_password = "M012290493119") 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");
$now = gmdate("YmdHis", strtotime("-2 minutes")); $now = gmdate("YmdHis", strtotime("-2 minutes"));
$data = "$user_id." . $now; $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 = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
$apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
@ -53,4 +51,4 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
curl_close($ch); curl_close($ch);
} }
// $data = []; // $data = [];
get_Auth(); // get_Auth();

73
wms/bonus/api/postStatus.php

@ -2,32 +2,44 @@
require_once("../../contract/conn.php"); require_once("../../contract/conn.php");
if (!empty($_POST['id']) && !empty($_POST['postType']) && $_POST['postType'] == 'a') { if (!empty($_POST['id']) && !empty($_POST['postType']) && $_POST['postType'] == 'a') {
try {
$id = empty($_POST['id']) ? '' : $_POST['id']; $id = empty($_POST['id']) ? '' : $_POST['id'];
$user_id = empty($_POST['user_id']) ? '' : $_POST['user_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']; $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day'];
$review_at = date("Y-m-d"); $review_at = date("Y-m-d H:i:s");
$sql = "UPDATE bonus SET status = 2 ,review_hr = '$user_id' ,review_at = '$review_at',pay_day ='$pay_day' WHERE id = $id"; $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 = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
header("HTTP/1.1 200 success!");
echo 'Success'; echo 'Success';
} catch (PDOException $e) {
header("HTTP/1.1 404 failed!");
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
} }
// 獎金確認發放,並更新獎金 OR 實際發放時間 // 獎金確認發放,並更新獎金 OR 實際發放時間
if (!empty($_POST['postType']) && $_POST['postType'] == 'b') { if (!empty($_POST['postType']) && $_POST['postType'] == 'b') {
try {
$id = empty($_POST['id']) ? '' : $_POST['id']; $id = empty($_POST['id']) ? '' : $_POST['id'];
$pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day'];
$bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; $bonus_actual = empty($_POST['bonus_actual']) ? '' : $_POST['bonus_actual'];
$note = empty($_POST['note']) ? '' : $_POST['note']; $note = empty($_POST['note']) ? '' : $_POST['note'];
$user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id'];
$review_at = date("Y-m-d"); $review_at = date("Y-m-d H:i:s");
try { if ($pay_day != '' && $bonus_actual != '') {
$sql = "UPDATE bonus SET status = 2,review_hr='$user_id',review_at='$review_at',pay_day='$pay_day',note='$note' WHERE id = $id"; $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 = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
header("HTTP/1.1 200 success!"); header("HTTP/1.1 200 success!");
} else {
header("HTTP/1.1 400");
echo '請填寫發放時間和實發獎金';
}
} catch (PDOException $e) { } catch (PDOException $e) {
header("HTTP/1.1 500 failed!"); header("HTTP/1.1 404 failed!");
echo $e->getMessage(); echo $e->getMessage();
die('Error!:' . $e->getMessage()); die('Error!:' . $e->getMessage());
} }
@ -36,25 +48,64 @@ if (!empty($_POST['postType']) && $_POST['postType'] == 'b') {
// 獎金暫不發放 // 獎金暫不發放
if (!empty($_POST['postType']) && $_POST['postType'] == 'c') { if (!empty($_POST['postType']) && $_POST['postType'] == 'c') {
// echo 'cccccc'; // echo 'cccccc';
try {
$id = empty($_POST['id']) ? '' : $_POST['id']; $id = empty($_POST['id']) ? '' : $_POST['id'];
$pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day']; $pay_day = empty($_POST['pay_day']) ? '' : $_POST['pay_day'];
$bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue']; $bonus_actual = empty($_POST['bonus_issue']) ? '' : $_POST['bonus_issue'];
$user_id = empty($_POST['user_id']) ? '' : $_POST['user_id']; $user_id = empty($_POST['user_id']) ? '' : $_POST['user_id'];
$note = empty($_POST['note']) ? '' : $_POST['note']; $note = empty($_POST['note']) ? '' : $_POST['note'];
try { $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"; $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 = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
header("HTTP/1.1 200 success!"); header("HTTP/1.1 200 success!");
} else {
echo '請填寫備註!!';
header("HTTP/1.1 400!");
}
} catch (PDOException $e) { } catch (PDOException $e) {
header("HTTP/1.1 500 failed!"); header("HTTP/1.1 404 failed!");
echo $e->getMessage(); echo $e->getMessage();
die('Error!:' . $e->getMessage()); die('Error!:' . $e->getMessage());
} }
} }
if (!empty($_POST['postType']) && $_POST['postType'] == 'd') { if (!empty($_POST['postType']) && $_POST['postType'] == 'd') {
try {
$id = empty($_POST['id']) ? '' : $_POST['id']; $id = empty($_POST['id']) ? '' : $_POST['id'];
print_r($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 '<pre>';
// print_r($result);
// echo '</pre>';
// 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'; // echo 'ddddd';
} }

58
wms/bonus/bonus.php

@ -2,7 +2,7 @@
include_once("../header.php"); include_once("../header.php");
// require_once('./connT8.php'); // require_once('./connT8.php');
require("../contract/conn.php"); require("../contract/conn.php");
$now = date("Y-m-d");
$contract_type = [ $contract_type = [
'1' => '新梯', '1' => '新梯',
@ -30,15 +30,16 @@ if ($user_id != 'M0225') {
if (!empty($_GET['check'])) { if (!empty($_GET['check'])) {
// 人事發放作業,應為一個月內 // 人事發放作業,應為一個月內
if ($_GET['check'] == 4) { 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) { } else if ($_GET['check'] == 2) {
$clause .= "AND status = 1"; $clause .= "AND status = 1";
} else if ($_GET['check'] == 3) { } 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 = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC); $datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
@ -47,14 +48,13 @@ $datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
$now = new DateTime(); $now = new DateTime();
$oneMonthAgo = $now->modify('+1 month'); $oneMonthAgo = $now->modify('+1 month');
$id = []; $id = [];
foreach ($datas as $data) { foreach ($datas as $data) {
$id[] = $data['id']; $id[] = $data['id'];
} }
$id_str = implode(',', $id); $id_str = implode(',', $id);
echo "<pre>";
print_r($id_str);
echo '</pre>';
// 查看 T8 是否有收款明細 // 查看 T8 是否有收款明細
// require("./api/get.php"); // require("./api/get.php");
function isPay($contract_no, $connT8) function isPay($contract_no, $connT8)
@ -121,9 +121,9 @@ function isPay($contract_no, $connT8)
<div class="bonus_index" x-data="bonusIndexTest"> <div class="bonus_index" x-data="bonusIndexTest">
<div class="form" method="post" id="form" enctype="multipart/form-data"> <div class="form" method="post" id="form" enctype="multipart/form-data">
<div style="overflow-x:auto;margin-top:12px"> <div style="overflow-x:auto;margin-top:12px">
<a href="bonus_index1.php?function_name=bonus&token=<?php echo $token; ?>" class="btn btn-info btn-sm"> <!-- <a href="bonus_index1.php?function_name=bonus&token=<?php echo $token; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</a> </a> -->
<a href="/wms/bonus/bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a> <a href="/wms/bonus/bonus.php?function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有獎金</a>
<!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> --> <!-- <a href="/wms/bonus/bonus.php?check=1&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 應發獎金</a> -->
<a href="/wms/bonus/bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a> <a href="/wms/bonus/bonus.php?check=2&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 未發獎金</a>
@ -132,8 +132,9 @@ function isPay($contract_no, $connT8)
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<?php if (!empty($_GET['check']) && $_GET['check'] == '4') { ?>
<button class="btn btn-primary float-end" style="float: right;" onclick="All('<?= $id_str ?>')">確認並發放</button> <button class="btn btn-primary float-end" style="float: right;" onclick="All('<?= $id_str ?>')">確認並發放</button>
<?php } ?>
<thead> <thead>
<tr> <tr>
<th>項次</th> <th>項次</th>
@ -142,12 +143,13 @@ function isPay($contract_no, $connT8)
<th>作番號</th> <th>作番號</th>
<th>獎金類別</th> <th>獎金類別</th>
<th>獎金版本</th> <th>獎金版本</th>
<th>作番總價</th> <th>作番金額(月)</th>
<th>牌價</th> <th>牌價</th>
<th>服務費</th> <th>服務費</th>
<th>應發人員</th> <th>應發人員</th>
<th>預計發放時間</th> <th>預計發放時間</th>
<th>獎金水庫</th> <th>應發獎金水庫</th>
<th>實發金額</th>
<th>狀態</th> <th>狀態</th>
<?php <?php
if (!empty($_GET['check']) && $_GET['check'] == '4') { if (!empty($_GET['check']) && $_GET['check'] == '4') {
@ -155,7 +157,10 @@ function isPay($contract_no, $connT8)
<th>實際發放時間</th> <th>實際發放時間</th>
<th>發放 / 詳情</th> <th>發放 / 詳情</th>
<?php } ?> <?php } else { ?>
<th>詳情</th>
<?php
} ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -164,7 +169,6 @@ function isPay($contract_no, $connT8)
$contract_no = $data['contract_no']; $contract_no = $data['contract_no'];
$json = json_decode($data['bonus_json']); $json = json_decode($data['bonus_json']);
$total = empty($json->total) ? 0 : $json->total; $total = empty($json->total) ? 0 : $json->total;
$fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st; $fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st;
$commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee; $commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee;
@ -178,12 +182,13 @@ function isPay($contract_no, $connT8)
<td><?= $data['facility_no'] ?></td> <td><?= $data['facility_no'] ?></td>
<td><?= $bonus_type[$data['bonus_type']] ?></td> <td><?= $bonus_type[$data['bonus_type']] ?></td>
<td><?= $data['bonus_verson'] ?></td> <td><?= $data['bonus_verson'] ?></td>
<td><?= $total ?></td>
<td><?= $fee_per_st ?></td> <td><?= $fee_per_st ?></td>
<td><?= $total ?></td>
<td><?= $commission_fee ?></td> <td><?= $commission_fee ?></td>
<td><?= $data['receiver'] ?></td> <td><?= $data['receiver'] ?></td>
<td><?= $data['pay_day_due'] ?></td> <td><?= $data['pay_day_due'] ?></td>
<td><?= $data['amount'] ?></td> <td><?= $data['amount'] ?></td>
<td><?= $data['bonus_actual'] ?></td>
<td> <td>
<?= $bonus_status[$data['status']] ?> <?= $bonus_status[$data['status']] ?>
<!-- <span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span> --> <!-- <span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span> -->
@ -193,11 +198,9 @@ function isPay($contract_no, $connT8)
<td> -- </td> <td> -- </td>
<td> <td>
<?php <?php
// 判斷時間是否為一個月內
$payday = new DateTime($data['pay_day']);
// if ($isPay == 1) { // if ($isPay == 1) {
?> ?>
<button onclick="issue(<?= $data['id'] ?>,'<?= $user_id ?>','<?= $data['pay_day_due'] ?>')" type="button" class="btn applybtn" name='issuePay'>發放獎金</button> <button onclick="issue(<?= $data['id'] ?>,'<?= $user_id ?>','<?= $data['pay_day_due'] ?>','<?= $data['amount'] ?>')" type="button" class="btn applybtn" name='issuePay'>發放獎金</button>
<?php <?php
// } else if ($payday < $oneMonthAgo) { // } else if ($payday < $oneMonthAgo) {
@ -211,11 +214,13 @@ function isPay($contract_no, $connT8)
<?php } else { ?> <?php } else { ?>
<td><?= $data['pay_day'] ?></td> <td><?= $data['pay_day'] ?></td>
<td></td> <td><a href="bonus_check.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a></td>
<?php } <?php }
} ?> } else { ?>
<td><a href="bonus_check.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a></td>
<?php } ?>
</tr> </tr>
<?php <?php
endforeach; endforeach;
@ -316,12 +321,14 @@ function isPay($contract_no, $connT8)
<script> <script>
const datas = <?php echo json_encode($datas); ?>; const datas = <?php echo json_encode($datas); ?>;
function issue(id, user_id, pay_day) { function issue(id, user_id, pay_day, amount) {
// console.log(id); // console.log(id);
const form = new FormData(); const form = new FormData();
form.append('id', id) form.append('id', id)
form.append('user_id', user_id); form.append('user_id', user_id);
form.append('pay_day', pay_day) form.append('pay_day', pay_day)
form.append('amount', amount);
form.append('postType', 'a');
axios.post('./api/postStatus.php', form).then((res) => { axios.post('./api/postStatus.php', form).then((res) => {
if (res.data == 'Success') { if (res.data == 'Success') {
alert('更新成功'); alert('更新成功');
@ -334,16 +341,21 @@ function isPay($contract_no, $connT8)
function All(data) { function All(data) {
let arr = data.split(","); let arr = data.split(",");
console.log(arr);
const form = new FormData(); const form = new FormData();
form.append('id', arr); form.append('id', arr);
form.append('user_id', '<?= $user_id ?>')
form.append('postType', 'd'); form.append('postType', 'd');
if (confirm('是否發放全部獎金')) {
axios.post('./api/postStatus.php', form).then((res) => { axios.post('./api/postStatus.php', form).then((res) => {
console.log(res); if (res.status == 200) {
alert('更新成功');
location.reload();
}
}).catch((err) => { }).catch((err) => {
}); });
} }
}
// $(function() { // $(function() {
// $("button[name=issuePay]").click(function() { // $("button[name=issuePay]").click(function() {
// console.log(123); // console.log(123);

199
wms/bonus/bonus_check.php

@ -0,0 +1,199 @@
<?php
include('../header.php');
require_once('../contract-repair/conn.php');
$sql = "SELECT * FROM bonus WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':id', $_GET['id']);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
// echo '<pre>';
// print_r($result['bonus_json']);
// echo '</pre>';
$bonus_json = json_decode($result['bonus_json']);
$paykind = [
'monthly' => '月繳',
'bimonthly' => '雙月繳',
'quarterly' => '季繳',
'semiannually' => '半年繳',
'annually' => '年繳'
];
$maintain_type = [
'new' => '新簽約',
'free_to_charge' => '免保轉有費',
'renew_priceissue' => '續簽約'
];
?>
<link rel="stylesheet" href="../contract-repair/styles/style.css">
<link rel="stylesheet" href="../contract-repair/semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="../contract-repair/js/alpine.js"></script>
<script defer src="../contract-repair/js/alpinejs/cdn.min.js"></script>
<script src="../contract-repair/js/axios/axios.min.js"></script>
<script src="../contract-repair/js/jquery/jquery-3.1.1.min.js"></script>
<script src="../contract-repair/semantic/dist/semantic.min.js"></script>
<div class="bonuns_index" x-data="bonunsIndex">
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name="form_name" value="main_form">
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>獎金計算</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom:20px">
<tr>
<td colspan="7" style="vertical-align:middle;border-right:0px">
<h4>獎金確認項</h4>
</td>
<td class="text-right" style="border: left 0px;">
<button type="button" id="btn_back" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close()">關閉</button>
</td>
</tr>
<tr>
<td style="vertical-align:middle">合約號</td>
<td>
<input type="text" x-model="data.contract_no" disabled="disabled">
</td>
<td style="vertical-align:middle">合約類別</td>
<td>
<select id="contract_type" x-model="data.contract_type" disabled="disabled">
<option value="">--請選擇--</option>
<option value="1">新梯</option>
<option value="2">汰改</option>
<option value="3">保養</option>
</select>
<p class="alerttext" x-show="data.contract_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align:middle">作番號</td>
<td>
<input type="text" x-model="data.facility_no" disabled="disabled">
</td>
<td style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="data.bonus_verson" disabled="disabled">
</td>
</tr>
<tr>
<td style="vertical-align:middle">保養類別</td>
<td>
<input type="text" x-model="data.maintain_type" disabled>
</td>
<td style="vertical-align:middle">付款方式</td>
<td>
<input type="text" x-model="data.pay_kind" disabled>
</td>
<td style="vertical-align:middle">合約付款日</td>
<td>
<input type="text" x-model="data.receivable_date_due" disabled>
</td>
<td style="vertical-align:middle">應發獎金</td>
<td>
<input type="text" x-model="data.maintain_price_total">
</td>
</tr>
<tr>
<td style="vertical-align:middle">作番總價</td>
<td>
<input type="text" x-model="data.total" disabled>
</td>
<td style="vertical-align:middle">牌價</td>
<td>
<input type="text" x-model="data.fee_per_st" disabled>
</td>
<td style="vertical-align:middle">服務費</td>
<td>
<input type="text" x-model="data.commission_fee" disabled>
</td>
<td style="vertical-align:middle">價率</td>
<td>
<input type="text" x-model="data.discount" disabled>
</td>
</tr>
<tr>
<td style="vertical-align:middle">實發獎金</td>
<td>
<input type="text" x-model="data.bonus_actual" disabled>
</td>
<td style="vertical-align:middle">實發時間</td>
<td> <input class="form-control disabled_select" type="date" x-model="data.payDay" disabled>
</td>
<td style="vertical-align:middle">備註</td>
<td><input type="text" x-model='data.note' disabled></td>
<td></td>
<td></td>
</tr>
</tbody>
</template>
</table>
<!-- <button x-show=" step==1" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>確認</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show=" step==1" @click="stop()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>暫不發放</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button> -->
<!-- <button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button> -->
</div>
</div>
</div>
<script>
const user_id = '<?= $user_id ?>';
const id = '<?= $_GET['id'] ?>';
const contract_no = '<?= $result['contract_no'] ?>';
const facility_no = '<?= $result['facility_no'] ?>';
const bonus_verson = '<?= $result['bonus_verson'] ?>';
const receiver = '<?= $result['receiver'] ?>';
const payDaydue = '<?= $result['pay_day'] ?>';
const maintain_price_total = '<?= $result['amount'] ?>';
const contract_type = '<?= $result['contract_type'] ?>';
// const bonus_verson = '<?= $result['bonus_verson'] ?>';
const maintain_type = '<?= $maintain_type[$bonus_json->contract_type] ?>';
const pay_kind = '<?= $paykind[$bonus_json->paykind] ?>';
const receivable_date_due = '<?= $bonus_json->receivable_date_due ?>';
const total = '<?= $bonus_json->total ?>';
const fee_per_st = '<?= $bonus_json->fee_per_st ?>';
const commission_fee = '<?= $bonus_json->commission_fee ?>';
const discount = '<?= $bonus_json->discount ?>'
const bonus_actual = '<?= $result['bonus_actual'] ?>';
const payDay = '<?= $result['pay_day'] ?>';
const note = '<?= $result['note'] ?>'
</script>

13
wms/bonus/bonus_detail.php

@ -48,17 +48,6 @@ $maintain_type = [
</td> </td>
</tr> </tr>
</thead> </thead>
<!-- <template x-if="step==1">
<tbody style="font-weight: bolder;margin: botton 20px;">
<tr>
<td style="vertical-align: middle;">合約號</td>
<td colspan="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contract_no" x-model="data.contract_no">
</td>
<td colspan="2" style="vertical-align:middle"></td>
</tr>
</tbody>
</template> -->
<template x-if="step==1"> <template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom:20px"> <tbody style="font-weight: bolder;margin-bottom:20px">
@ -195,7 +184,7 @@ $maintain_type = [
const maintain_price_total = '<?= $result['amount'] ?>'; const maintain_price_total = '<?= $result['amount'] ?>';
const contract_type = '<?= $result['contract_type'] ?>'; const contract_type = '<?= $result['contract_type'] ?>';
// const bonus_verson = '<?= $result['bonus_verson'] ?>'; // const bonus_verson = '<?= $result['bonus_verson'] ?>';
const maintain_type = '<?= $maintain_type[$bonus_json->maintain_type] ?>'; const maintain_type = '<?= $maintain_type[$bonus_json->contract_type] ?>';
const pay_kind = '<?= $paykind[$bonus_json->paykind] ?>'; const pay_kind = '<?= $paykind[$bonus_json->paykind] ?>';
const receivable_date_due = '<?= $bonus_json->receivable_date_due ?>'; const receivable_date_due = '<?= $bonus_json->receivable_date_due ?>';
const total = '<?= $bonus_json->total ?>'; const total = '<?= $bonus_json->total ?>';

14
wms/bonus/other/maintenance_contract_bonus_v2_1.php

@ -153,7 +153,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
#地區處長獎金 #地區處長獎金
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "地區處長獎金", #獎金名稱 "bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員 "bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額 "bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
@ -163,7 +163,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
#專任契約經理獎金 #專任契約經理獎金
if ($regular_contract_manger_id != '') { if ($regular_contract_manger_id != '') {
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額 "bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
@ -176,7 +176,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
#年付 #年付
case "annually": case "annually":
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額 "bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
@ -195,7 +195,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
}; };
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額 "bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
@ -215,7 +215,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
}; };
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額 "bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
@ -235,7 +235,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
}; };
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額 "bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
@ -255,7 +255,7 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 $current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
}; };
array_push($bonus_array, [ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額 "bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間

12
wms/contract-repair/js/alpine.js

@ -903,7 +903,10 @@ const bonunsIndex = () => {
discount: discount, discount: discount,
bonus_actual: '', bonus_actual: '',
note: '', note: '',
id: id id: id,
bonus_actual: bonus_actual,
payDay: payDay,
note: note
}, },
step: 1, step: 1,
@ -984,8 +987,8 @@ const bonunsIndex = () => {
window.history.go(-1); window.history.go(-1);
}).catch((err) => { }).catch((err) => {
alert('更新失敗'); // alert('更新失敗');
console.log(err); alert('更新失敗' + err.response.data);
}) })
} }
}, },
@ -998,10 +1001,11 @@ const bonunsIndex = () => {
form.append('note', this.data.note); form.append('note', this.data.note);
form.append('postType', 'c'); form.append('postType', 'c');
axios.post('./api/postStatus.php', form).then((res) => { axios.post('./api/postStatus.php', form).then((res) => {
console.log(res);
alert('更新成功'); alert('更新成功');
window.history.go(-1); window.history.go(-1);
}).catch((err) => { }).catch((err) => {
alert('更新失敗'); alert(err.response.data);
}) })
} }
}, },

11
wms/contract/api/T8salIncomeApply.php

@ -3,14 +3,15 @@ require_once("../../T8_Authorization_from_bpm.php");
function T8API($data) function T8API($data)
{ {
// echo '<pre>';
// print_r(json_encode($data));
// echo '</pre>';
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth(); $validation = get_Auth();
echo '<pre>';
print_r(json_encode($data));
echo '</pre>';
$header = [ $header = [
"CHI_Authorization :" . $validation "CHI_Authorization :" . $validation,
"GroupId:TEST"
]; ];
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL
@ -20,6 +21,7 @@ function T8API($data)
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response === false) { if ($response === false) {
echo 'Curl error: ' . curl_error($ch); echo 'Curl error: ' . curl_error($ch);
} else { } else {
@ -32,6 +34,7 @@ function T8API($data)
// print_r($result); // print_r($result);
return $result; return $result;
} }
return $result;
} }
curl_close($ch); curl_close($ch);

227
wms/contract/api/postContractData.php

@ -36,10 +36,36 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null; $payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
// validate // validate
//create facility table
$createFacilityNo = new CreateFacilityNo();
$dailyNecessities = [
'MAE100' => 'X',
'MAM200' => 'W',
'MAH100' => 'H',
'MAQ100' => 'Z',
'MAF100' => 'F',
'MAZ100' => 'B',
];
$maintain_times = [
'1' => 'em', //月保
'2' => 'bw' // 雙周保
];
$facility_arr = [];
foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
echo json_encode($facilityno);
/// 獎金計算 /// 獎金計算
bonusCreate($elevators);
$fail_arr = []; $fail_arr = [];
if ($contractno === '') return $fail_arr[] = '合約號為必填'; if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填'; if ($total_price == '') $fail_arr[] = '合約總價為必填';
@ -66,7 +92,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo json_encode($fail_arr); echo json_encode($fail_arr);
exit(); exit();
} }
T8insert($_POST, $facilityno);
bonusCreate($_POST, $facilityno, $conn);
//create account table //create account table
$accounttype = "A"; $accounttype = "A";
$accountid = $vat; $accountid = $vat;
@ -78,6 +105,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$create_at = date('Y-m-d H:i:s'); $create_at = date('Y-m-d H:i:s');
$conn->beginTransaction(); $conn->beginTransaction();
// bonusCreate($_POST, $facilityno, $conn);
// exit();
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
@ -130,35 +159,35 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->execute(); $stmt->execute();
//create facility table //create facility table
$createFacilityNo = new CreateFacilityNo(); // $createFacilityNo = new CreateFacilityNo();
$dailyNecessities = [ // $dailyNecessities = [
'MAE100' => 'X', // 'MAE100' => 'X',
'MAM200' => 'W', // 'MAM200' => 'W',
'MAH100' => 'H', // 'MAH100' => 'H',
'MAQ100' => 'Z', // 'MAQ100' => 'Z',
'MAF100' => 'F', // 'MAF100' => 'F',
'MAZ100' => 'B', // 'MAZ100' => 'B',
]; // ];
$maintain_times = [ // $maintain_times = [
'1' => 'em', //月保 // '1' => 'em', //月保
'2' => 'bw' // 雙周保 // '2' => 'bw' // 雙周保
]; // ];
$facility_arr = []; // $facility_arr = [];
foreach ($elevators as $elevator) { // foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']]; // $facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// } // }
echo json_encode($facilityno); // echo json_encode($facility_arr);
echo '-------'; // // 電梯做番號
// $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// // if ($user_id == 'M0225') {
// // echo '<pre>';
// // print_r($facilityno);
// // echo '</pre>';
// // exit();
// // }
// 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";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $mworker); $stmt->bindParam(':accountid', $mworker);
@ -204,7 +233,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); // $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
// $comboArr = json_decode($comboNo->getComboNo(), true); // $comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($facilityno as $no) { foreach ($facilityno as $no) {
// $comboNo = new CreateComboNo($maintain_times[$elevator['maintain_times']], $contract_begin_date, $contract_end_date); $comboNo = new CreateComboNo($maintain_times[$elevator['maintain_times']], $contract_begin_date, $contract_end_date);
$comboArr = json_decode($comboNo->getComboNo(), true); $comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($comboArr as $combo) { 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, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
@ -328,7 +357,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// T8insert($_POST, $facilityno); // T8insert($_POST, $facilityno);
header('Content-Type: application/json'); header('Content-Type: application/json');
$jsonData = json_encode($files); $jsonData = json_encode($files);
@ -362,7 +390,6 @@ function T8insert($data, $facilityno)
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯 $elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
$area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。 $area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$payType = !empty($data['payType']) ? $data['payType'] : null; $payType = !empty($data['payType']) ? $data['payType'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
@ -373,8 +400,8 @@ function T8insert($data, $facilityno)
$stmt->bindParam(':BizPartnerId', $contractno); $stmt->bindParam(':BizPartnerId', $contractno);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC); $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i'); $date = date('Y-m-dH-s-i');
$date_1 = date('Y-m-s'); $date_1 = date('Y-m-d');
$createTime = str_replace("-", '', $date); $createTime = str_replace("-", '', $date);
$insertTime = str_replace('-', '', $date_1); $insertTime = str_replace('-', '', $date_1);
$beginDate = str_replace("-", '', $contract_begin_date); $beginDate = str_replace("-", '', $contract_begin_date);
@ -493,12 +520,12 @@ function T8insert($data, $facilityno)
// echo '<pre>'; // echo '<pre>';
// print_r($elevator); // print_r($elevator);
// echo '</pre>'; // echo '</pre>';
$facility_no = $facilityno[$index];
$sql = "INSERT INTO comMaterial $sql = "INSERT INTO comMaterial
(FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime) (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)"; VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
$stmt->execute(); $stmt->execute();
@ -507,7 +534,7 @@ function T8insert($data, $facilityno)
(MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime) (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)"; VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':MaterialName', $customer); $stmt->bindParam(':MaterialName', $customer);
$stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
@ -517,7 +544,7 @@ function T8insert($data, $facilityno)
(Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime) (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)"; VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]); $stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id); $stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime); $stmt->bindParam(':CreateTime', $createTime);
$stmt->execute(); $stmt->execute();
@ -533,6 +560,9 @@ function T8insert($data, $facilityno)
//分幾期 => 總共保養月 / 分期月 //分幾期 => 總共保養月 / 分期月
$SQuantity = $elevator['maintain_months'] / $IncomeId[$payType]; $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType];
$date_1 = getNext25thDate($contract_begin_date);
// 依每台電梯去加入各個的付款項 // 依每台電梯去加入各個的付款項
for ($i = 0; $i < $IncomeId[$payType]; $i++) { for ($i = 0; $i < $IncomeId[$payType]; $i++) {
$row++; $row++;
@ -547,14 +577,16 @@ function T8insert($data, $facilityno)
"RowCode" => $row, "RowCode" => $row,
"RowNo" => $row, "RowNo" => $row,
"ItemType" => 1, "ItemType" => 1,
"SPrice" => $elevator['sold_price'], "SPrice" => intval($elevator['sold_price']),
"SQuantity" => $SQuantity, "SQuantity" => $SQuantity,
"ProjectId" => "$contractno", "ProjectId" => "$contractno",
"FromSourceTag" => 0, "CU_MaterialId" => "$facility_no",
"CU_MaterialId" => "$facilityno[$index]", "CU_EstPayDate" => intval($payDay)
"CU_EstPayDate" => "$payDay"
]; ];
$salIncomeApplyDetail_rows[] = $rows_data; $salIncomeApplyDetail_rows[] = $rows_data;
// echo '<pre>';
// print_r($salIncomeApplyDetail_rows);
// echo '</pre>';
} }
} }
@ -564,7 +596,7 @@ function T8insert($data, $facilityno)
// $insertime = settype($insertTime, 'integer'); // $insertime = settype($insertTime, 'integer');
$salIncomeApplyMaster_rows = [ $salIncomeApplyMaster_rows = [
"BillNo" => "$contractno", "BillNo" => "$contractno",
"BillDate" => $insertTime, "BillDate" => intval($insertTime),
"OrgId" => "1000", "OrgId" => "1000",
"FOrgId" => "1000", "FOrgId" => "1000",
"TypeId" => "RAS", "TypeId" => "RAS",
@ -578,7 +610,8 @@ function T8insert($data, $facilityno)
"DueToId" => "$contractno", "DueToId" => "$contractno",
"TaxId" => "ST005", "TaxId" => "ST005",
"CompId" => "1001", "CompId" => "1001",
"CreatorId" => "$user_id" "CreatorId" => "$user_id",
"CreateTime" => intval($insertTime)
]; ];
$salIncomeApplyMaster = [ $salIncomeApplyMaster = [
@ -593,6 +626,9 @@ function T8insert($data, $facilityno)
$API_body[] = $salIncomeApplyMaster; $API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail; $API_body[] = $salIncomeApplyDetail;
// 呼叫 API // 呼叫 API
// echo '<pre>';
// print_r($API_body);
// echo '</pre>';
$result = T8API($API_body); $result = T8API($API_body);
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') {
@ -603,15 +639,100 @@ function T8insert($data, $facilityno)
} }
function bonusCreate($elevators) function bonusCreate($data, $facilityno, $conn)
{ {
try {
require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php"); require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php");
$elevators = !empty($elevators) ? $elevators : ''; $elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : '';
$salesman = !empty($data['salesman']) ? $data['salesman'] : '';
$payType = !empty($data['payType']) ? $data['payType'] : '';
$status = 1;
$bonus_json = [];
$create_id = $data['user_id'];
$create_at = date('Y-m-d');
$contract_no = !empty($data['contractno']) ? $data['contractno'] : '';
$contract_kind = 3;
$payment = [
'A40006' => 'annually', //年繳
'A40007' => 'quarterly', //季繳
'A40004' => 'bimonthly', // 雙月繳
'A40005' => 'semiannually', // 半年繳
'A40003' => 'monthly' //月繳
];
foreach ($elevators as $elevator) { $payDay = getNext25thDate($contract_begin_date);
echo '<pre>'; foreach ($elevators as $key => $elevator) {
print_r($elevator); // print_r($payDay);
echo '</pre>'; // echo '<pre>';
exit; // print_r($elevator);
// echo '</pre>';
// exit;
$facility_no = $facilityno[$key];
$ver = $elevator['bonus_verson']; //獎金版本
$contract_type = $elevator['contract_type']; //合約類別
$payment_period = $payment[$payType]; //付款方式
$elevator_list_price = $elevator['stand_price']; //牌價
$fee_per_st = $elevator['contract_price']; //作翻契約金額
$commission_fee = $elevator['service_expense']; //服務費(月)
$receivable_date_due = $payDay; //第一筆保養款項收回日
$sales_id = $salesman; //營業人員
$discount = $elevator['discount'];
$region_director_id = $elevator['manager'];
$regular_contract_manger_id = !empty($elevator['regular_contract_manger_id']) ? $elevator['regular_contract_manger_id'] : '';
$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);
$bonus_json = [
'contract_type' => $contract_type,
'total' => $elevator_list_price,
'fee_per_st' => $fee_per_st,
'commission_fee' => $commission_fee,
'paykind' => $payment_period,
'receivable_date_due' => $receivable_date_due,
'discount' => $discount
];
if ($results['result_status'] != 'error') {
foreach ($results['bonus_array'] as $i => $result) {
$bonus_type = $result['bonus_type'];
$pay_day = $result['pay_day_due'];
$amount = $result['bonus_amount'];
$receiver = $result['bonus_receiver'];
$a = json_encode($bonus_json);
$sql = "INSERT INTO bonus
(bonus_type,bonus_verson,contract_no,contract_type,facility_no,amount,receiver,pay_day_due,status,bonus_json,create_id,create_at) VALUES
($bonus_type,'$ver','$contract_no',$contract_kind,'$facility_no',$amount,'$receiver','$pay_day',$status,'$a','$create_id','$create_at')";
$stmt = $conn->prepare($sql);
$stmt->execute();
}
}
} }
// exit();
} catch (PDOException $e) {
http_response_code(404);
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
}
// 計算保養開始日期的當月25號
function getNext25thDate($dateString)
{
// 將傳入的日期字串轉換成 Unix 時間戳記
$timestamp = strtotime($dateString);
// 取得該日期的日期
$day = date('d', $timestamp);
// 如果日期大於 25,則回傳下個月的 25 號日期
if ($day > 25) {
// 增加一個月
$timestamp = strtotime('+1 month', $timestamp);
}
// 設定日期為 25 號
$targetDate = date('Y-m-25', $timestamp);
return $targetDate;
} }

45
wms/contract/api/testT8API.php

@ -1,21 +1,28 @@
<?php <?php
$date = Date('Y-m-d'); function getNext25thDate($dateString)
$date1 = Date('Y-m-d', strtotime("$date +1 months")); {
// $paymonth = $i * $SQuantity; // 將傳入的日期字串轉換成 Unix 時間戳記
// $countDay = date('Y-m-d', strtotime("$date + $paymonth months")); $timestamp = strtotime($dateString);
// $payDay = str_replace('-', '', $countDay);
// $countDay = date('Ymd', strtotime("$date1 + 1 months")); // 取得該日期所在月份的天數
// echo '<pre>'; $daysInMonth = date('t', $timestamp);
// print_r($countDay);
// echo '</pre>'; // 取得該日期的日期
// exit(); $day = date('d', $timestamp);
$SQuantity = 2;
// $b = 24 / $a; // 如果日期大於 25,則回傳下個月的 25 號日期
for ($i = 0; $i < 12; $i++) { if ($day > 25) {
$paymonth = $i * $SQuantity; // 增加一個月
$countDay = date('Y-m-d', strtotime("$date + $paymonth months")); $timestamp = strtotime('+1 month', $timestamp);
$payDay = str_replace('-', '', $countDay);
echo '<pre>';
print_r($payDay);
echo '</pre>';
} }
// 設定日期為 25 號
$targetDate = date('Y-m-25', $timestamp);
return $targetDate;
}
// 測試函數
$dateString = '2024-05-1';
$next25thDate = getNext25thDate($dateString);
echo "傳入日期的下個 25 號日期是:$next25thDate";

2
wms/contract/contract-input.php

@ -374,7 +374,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td> </td>
<td style="vertical-align:middle">獎金適用版本</td> <td style="vertical-align:middle">獎金適用版本</td>
<td> <td>
<input type="text" x-model="data.bonus_verson" disabled="disabled"> <input type="text" x-model="elevator.bonus_verson" disabled="disabled">
</td> </td>
</tr> </tr>
<tr> <tr>

32
wms/contract/js/alpine.js

@ -972,15 +972,13 @@ const contractInput = () => {
disabled: false, //資料庫是否有電梯數量資料 disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '', //付款方式 payType: '', //付款方式
bonus_verson: 2.1, // bonus_verson: 2.1,
// manager: '', // manager: '',
// regular_contract_manger_id: '', // regular_contract_manger_id: '',
// bonus: [], // bonus: [],
}, },
customize: false, customize: false,
step: 1, step: 1,
isLoading: false, isLoading: false,
fail_arr: [], fail_arr: [],
nextStepFn() { nextStepFn() {
@ -997,27 +995,20 @@ const contractInput = () => {
} else if (this.step == 3) { } else if (this.step == 3) {
this.getManager(); this.getManager();
this.step = 4; this.step = 4;
console.log(this.step); // console.log(this.step);
} }
}, },
createBonus() { getBonusVerson(data) {
for (let i = 0; i < elevators.length; i++) { // 目前獎金版本為 2.1,若之後要依辦法建立時間來判斷在這邊修改
this.data.bonus.push({ data.bonus_verson = 2.1;
salesman: this.data.salesman,
contract_type: 'new',
bonus_verson: 2.1,
manager: this.data.manager,
discount: this.elevators[i].discount,
regular_contract_manger_id: ''
})
}
}, },
getManager() { getManager() {
for (let i = 0; i < this.data.elevators.length; i++) { for (let i = 0; i < this.data.elevators.length; i++) {
this.getBonusVerson(this.data.elevators[i]);
axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => { axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => {
this.data.elevators[i].manager = res.data.manager; this.data.elevators[i].manager = res.data.manager;
console.log(res.data.manager); console.log(this.data.elevators[i]);
}).catch(err => { }).catch(err => {
}) })
@ -1054,7 +1045,8 @@ const contractInput = () => {
discount: '', //折價率 discount: '', //折價率
contract_type: '', contract_type: '',
manager: '', manager: '',
regular_contract_manger_id: '' regular_contract_manger_id: '',
bonus_verson: ''
}) })
} }
}, },
@ -1068,10 +1060,12 @@ const contractInput = () => {
if (!this.customize) { if (!this.customize) {
this.data.elevators = res.data.elevators; this.data.elevators = res.data.elevators;
for (let i = 0; i < res.data.elevators.length; i++) { for (let i = 0; i < res.data.elevators.length; i++) {
// 合約總價格。
this.data.total_price = Number(res.data.elevators[i].sold_price) + Number(this.data.total_price); this.data.total_price = Number(res.data.elevators[i].sold_price) + Number(this.data.total_price);
// 折扣率 // 服務費 (以單筆合約記,但計算獎金須傳入單月服務費)
this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / 12); this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / 12);
// 折扣率
this.data.elevators[i].discount = Math.round(((res.data.elevators[i].sold_price / res.data.elevators[i].stand_price) + this.data.elevators[i].service_expense) * 100); this.data.elevators[i].discount = Math.round(((res.data.elevators[i].sold_price / res.data.elevators[i].stand_price) + this.data.elevators[i].service_expense) * 100);
} }
this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price; this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
@ -1137,6 +1131,8 @@ const contractInput = () => {
} }
} else if (this.step == 3) { } else if (this.step == 3) {
this.step = 2 this.step = 2
} else if (this.step == 4) {
this.step = 3
} }
}, },
save() { save() {

11
wms/mkt/assets/js/pricereviewAlpine.js

@ -1,20 +1,11 @@
const pricereviewCreate = () => {
const pricereviewCreate = () => { const pricereviewCreate = () => {
return { return {
init() {
init() { init() {
this.elevators = elevators; this.elevators = elevators;
console.log(this.elevators); console.log(this.elevators);
console.log(this.total_spec); console.log(this.total_spec);
}, },
openFn: {
4: '2U',
5: "4PCO",
7: "6PCO",
8: "2S",
9: "CO"
openFn: { openFn: {
4: '2U', 4: '2U',
5: "4PCO", 5: "4PCO",
@ -613,8 +604,6 @@ const pricereviewCreate = () => {
} }
} }
const pricereviewCheck = () => { const pricereviewCheck = () => {
return { return {
init() { init() {

Loading…
Cancel
Save