Browse Source

保養簽回與獎金

gary
Cheng 1 year ago
parent
commit
56768aa586
  1. 12
      wms/T8_Authorization_from_bpm.php
  2. 117
      wms/bonus/api/postStatus.php
  3. 70
      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. 229
      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. 1585
      wms/mkt/assets/js/pricereviewAlpine.js

12
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();

117
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 '<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';
}

70
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 "<pre>";
print_r($id_str);
echo '</pre>';
// 查看 T8 是否有收款明細
// require("./api/get.php");
function isPay($contract_no, $connT8)
@ -121,9 +121,9 @@ function isPay($contract_no, $connT8)
<div class="bonus_index" x-data="bonusIndexTest">
<div class="form" method="post" id="form" enctype="multipart/form-data">
<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>
</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?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>
@ -132,8 +132,9 @@ function isPay($contract_no, $connT8)
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<button class="btn btn-primary float-end" style="float: right;" onclick="All('<?= $id_str ?>')">確認並發放</button>
<?php if (!empty($_GET['check']) && $_GET['check'] == '4') { ?>
<button class="btn btn-primary float-end" style="float: right;" onclick="All('<?= $id_str ?>')">確認並發放</button>
<?php } ?>
<thead>
<tr>
<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>
<?php
if (!empty($_GET['check']) && $_GET['check'] == '4') {
@ -155,7 +157,10 @@ function isPay($contract_no, $connT8)
<th>實際發放時間</th>
<th>發放 / 詳情</th>
<?php } ?>
<?php } else { ?>
<th>詳情</th>
<?php
} ?>
</tr>
</thead>
<tbody>
@ -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)
<td><?= $data['facility_no'] ?></td>
<td><?= $bonus_type[$data['bonus_type']] ?></td>
<td><?= $data['bonus_verson'] ?></td>
<td><?= $total ?></td>
<td><?= $fee_per_st ?></td>
<td><?= $total ?></td>
<td><?= $commission_fee ?></td>
<td><?= $data['receiver'] ?></td>
<td><?= $data['pay_day_due'] ?></td>
<td><?= $data['amount'] ?></td>
<td><?= $data['bonus_actual'] ?></td>
<td>
<?= $bonus_status[$data['status']] ?>
<!-- <span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span> -->
@ -193,11 +198,9 @@ function isPay($contract_no, $connT8)
<td> -- </td>
<td>
<?php
// 判斷時間是否為一個月內
$payday = new DateTime($data['pay_day']);
// 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
// } else if ($payday < $oneMonthAgo) {
@ -211,11 +214,13 @@ function isPay($contract_no, $connT8)
<?php } else { ?>
<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>
<?php
endforeach;
@ -316,12 +321,14 @@ function isPay($contract_no, $connT8)
<script>
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);
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', '<?= $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() {

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>
</tr>
</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">
<tbody style="font-weight: bolder;margin-bottom:20px">
@ -195,7 +184,7 @@ $maintain_type = [
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->maintain_type] ?>';
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 ?>';

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, [
"bonus_type" => "地區處長獎金", #獎金名稱
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"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 != '') {
array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"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":
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"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])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"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])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"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])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"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])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"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,
bonus_actual: '',
note: '',
id: id
id: id,
bonus_actual: bonus_actual,
payDay: payDay,
note: note
},
step: 1,
@ -984,8 +987,8 @@ const bonunsIndex = () => {
window.history.go(-1);
}).catch((err) => {
alert('更新失敗');
console.log(err);
// alert('更新失敗');
alert('更新失敗' + err.response.data);
})
}
},
@ -998,10 +1001,11 @@ const bonunsIndex = () => {
form.append('note', this.data.note);
form.append('postType', 'c');
axios.post('./api/postStatus.php', form).then((res) => {
console.log(res);
alert('更新成功');
window.history.go(-1);
}).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)
{
// echo '<pre>';
// print_r(json_encode($data));
// echo '</pre>';
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
$validation = get_Auth();
echo '<pre>';
print_r(json_encode($data));
echo '</pre>';
$header = [
"CHI_Authorization :" . $validation
"CHI_Authorization :" . $validation,
"GroupId:TEST"
];
$ch = curl_init();
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_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
@ -32,6 +34,7 @@ function T8API($data)
// print_r($result);
return $result;
}
return $result;
}
curl_close($ch);

229
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) : [];
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
// 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 = [];
if ($contractno === '') return $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);
exit();
}
T8insert($_POST, $facilityno);
bonusCreate($_POST, $facilityno, $conn);
//create account table
$accounttype = "A";
$accountid = $vat;
@ -78,6 +105,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$create_at = date('Y-m-d H:i:s');
$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)";
$stmt = $conn->prepare($sql_str);
@ -130,35 +159,35 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->execute();
//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();
// $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($facilityno);
echo '-------';
// 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 '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$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);
// $comboArr = json_decode($comboNo->getComboNo(), true);
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);
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)';
@ -328,7 +357,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
// T8insert($_POST, $facilityno);
header('Content-Type: application/json');
$jsonData = json_encode($files);
@ -362,7 +390,6 @@ function T8insert($data, $facilityno)
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
$area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$payType = !empty($data['payType']) ? $data['payType'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
@ -373,8 +400,8 @@ function T8insert($data, $facilityno)
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i');
$date_1 = date('Y-m-s');
$date = date('Y-m-dH-s-i');
$date_1 = date('Y-m-d');
$createTime = str_replace("-", '', $date);
$insertTime = str_replace('-', '', $date_1);
$beginDate = str_replace("-", '', $contract_begin_date);
@ -493,12 +520,12 @@ function T8insert($data, $facilityno)
// echo '<pre>';
// print_r($elevator);
// echo '</pre>';
$facility_no = $facilityno[$index];
$sql = "INSERT INTO comMaterial
(FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
@ -507,7 +534,7 @@ function T8insert($data, $facilityno)
(MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':MaterialName', $customer);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
@ -517,7 +544,7 @@ function T8insert($data, $facilityno)
(Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':MaterialId', $facility_no);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
@ -533,6 +560,9 @@ function T8insert($data, $facilityno)
//分幾期 => 總共保養月 / 分期月
$SQuantity = $elevator['maintain_months'] / $IncomeId[$payType];
$date_1 = getNext25thDate($contract_begin_date);
// 依每台電梯去加入各個的付款項
for ($i = 0; $i < $IncomeId[$payType]; $i++) {
$row++;
@ -547,14 +577,16 @@ function T8insert($data, $facilityno)
"RowCode" => $row,
"RowNo" => $row,
"ItemType" => 1,
"SPrice" => $elevator['sold_price'],
"SPrice" => intval($elevator['sold_price']),
"SQuantity" => $SQuantity,
"ProjectId" => "$contractno",
"FromSourceTag" => 0,
"CU_MaterialId" => "$facilityno[$index]",
"CU_EstPayDate" => "$payDay"
"CU_MaterialId" => "$facility_no",
"CU_EstPayDate" => intval($payDay)
];
$salIncomeApplyDetail_rows[] = $rows_data;
// echo '<pre>';
// print_r($salIncomeApplyDetail_rows);
// echo '</pre>';
}
}
@ -564,7 +596,7 @@ function T8insert($data, $facilityno)
// $insertime = settype($insertTime, 'integer');
$salIncomeApplyMaster_rows = [
"BillNo" => "$contractno",
"BillDate" => $insertTime,
"BillDate" => intval($insertTime),
"OrgId" => "1000",
"FOrgId" => "1000",
"TypeId" => "RAS",
@ -578,7 +610,8 @@ function T8insert($data, $facilityno)
"DueToId" => "$contractno",
"TaxId" => "ST005",
"CompId" => "1001",
"CreatorId" => "$user_id"
"CreatorId" => "$user_id",
"CreateTime" => intval($insertTime)
];
$salIncomeApplyMaster = [
@ -593,6 +626,9 @@ function T8insert($data, $facilityno)
$API_body[] = $salIncomeApplyMaster;
$API_body[] = $salIncomeApplyDetail;
// 呼叫 API
// echo '<pre>';
// print_r($API_body);
// echo '</pre>';
$result = T8API($API_body);
if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') {
@ -603,15 +639,100 @@ function T8insert($data, $facilityno)
}
function bonusCreate($elevators)
function bonusCreate($data, $facilityno, $conn)
{
require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php");
$elevators = !empty($elevators) ? $elevators : '';
try {
require_once("../../bonus/other/maintenance_contract_bonus_v2_1.php");
$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) {
echo '<pre>';
print_r($elevator);
echo '</pre>';
exit;
$payDay = getNext25thDate($contract_begin_date);
foreach ($elevators as $key => $elevator) {
// print_r($payDay);
// echo '<pre>';
// 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
$date = Date('Y-m-d');
$date1 = Date('Y-m-d', strtotime("$date +1 months"));
// $paymonth = $i * $SQuantity;
// $countDay = date('Y-m-d', strtotime("$date + $paymonth months"));
// $payDay = str_replace('-', '', $countDay);
// $countDay = date('Ymd', strtotime("$date1 + 1 months"));
// echo '<pre>';
// print_r($countDay);
// echo '</pre>';
// exit();
$SQuantity = 2;
// $b = 24 / $a;
for ($i = 0; $i < 12; $i++) {
$paymonth = $i * $SQuantity;
$countDay = date('Y-m-d', strtotime("$date + $paymonth months"));
$payDay = str_replace('-', '', $countDay);
echo '<pre>';
print_r($payDay);
echo '</pre>';
function getNext25thDate($dateString)
{
// 將傳入的日期字串轉換成 Unix 時間戳記
$timestamp = strtotime($dateString);
// 取得該日期所在月份的天數
$daysInMonth = date('t', $timestamp);
// 取得該日期的日期
$day = date('d', $timestamp);
// 如果日期大於 25,則回傳下個月的 25 號日期
if ($day > 25) {
// 增加一個月
$timestamp = strtotime('+1 month', $timestamp);
}
// 設定日期為 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 style="vertical-align:middle">獎金適用版本</td>
<td>
<input type="text" x-model="data.bonus_verson" disabled="disabled">
<input type="text" x-model="elevator.bonus_verson" disabled="disabled">
</td>
</tr>
<tr>

32
wms/contract/js/alpine.js

@ -972,15 +972,13 @@ const contractInput = () => {
disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '', //付款方式
bonus_verson: 2.1,
// bonus_verson: 2.1,
// manager: '',
// regular_contract_manger_id: '',
// bonus: [],
},
customize: false,
step: 1,
isLoading: false,
fail_arr: [],
nextStepFn() {
@ -997,27 +995,20 @@ const contractInput = () => {
} else if (this.step == 3) {
this.getManager();
this.step = 4;
console.log(this.step);
// console.log(this.step);
}
},
createBonus() {
for (let i = 0; i < elevators.length; i++) {
this.data.bonus.push({
salesman: this.data.salesman,
contract_type: 'new',
bonus_verson: 2.1,
manager: this.data.manager,
discount: this.elevators[i].discount,
regular_contract_manger_id: ''
})
}
getBonusVerson(data) {
// 目前獎金版本為 2.1,若之後要依辦法建立時間來判斷在這邊修改
data.bonus_verson = 2.1;
},
getManager() {
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 => {
this.data.elevators[i].manager = res.data.manager;
console.log(res.data.manager);
console.log(this.data.elevators[i]);
}).catch(err => {
})
@ -1054,7 +1045,8 @@ const contractInput = () => {
discount: '', //折價率
contract_type: '',
manager: '',
regular_contract_manger_id: ''
regular_contract_manger_id: '',
bonus_verson: ''
})
}
},
@ -1068,10 +1060,12 @@ const contractInput = () => {
if (!this.customize) {
this.data.elevators = res.data.elevators;
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.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.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
@ -1137,6 +1131,8 @@ const contractInput = () => {
}
} else if (this.step == 3) {
this.step = 2
} else if (this.step == 4) {
this.step = 3
}
},
save() {

1585
wms/mkt/assets/js/pricereviewAlpine.js

File diff suppressed because it is too large
Loading…
Cancel
Save