You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
301 lines
11 KiB
301 lines
11 KiB
<?php
|
|
include_once("../header.php");
|
|
// require_once('./connT8.php');
|
|
require("../contract/conn.php");
|
|
|
|
|
|
$contract_type = [
|
|
'1' => '新梯',
|
|
'2' => '汰改',
|
|
'3' => '保養'
|
|
];
|
|
|
|
$bonus_type = [
|
|
'1' => '契約人獎金',
|
|
'2' => '區經理獎金',
|
|
'3' => '專任契約經理獎金'
|
|
];
|
|
$clause = '';
|
|
if (!empty($_GET['check'])) {
|
|
if ($_GET['check'] == 1) {
|
|
$clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)";
|
|
} else if ($_GET['check'] == 2) {
|
|
$clause .= "AND status = 1";
|
|
} else if ($_GET['check'] == 3) {
|
|
$clause .= "AND status = 2";
|
|
}
|
|
}
|
|
|
|
$sql = "SELECT * FROM bonus WHERE 1=1 $clause LIMIT 50";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
$now = new DateTime();
|
|
$oneMonthAgo = $now->modify('+1 month');
|
|
|
|
// 查看 T8 是否有收款明細
|
|
// require("./api/get.php");
|
|
function isPay($contract_no, $connT8)
|
|
{
|
|
// echo $contract_no;
|
|
$sql = "SELECT
|
|
a.BillNo,
|
|
b.OTaxAmt as amount,
|
|
a.CU_EstPayDate as createDate,
|
|
b.PersonId as personId,
|
|
c.BillNo as CBno,
|
|
c.CU_MaterialId as facility
|
|
FROM salIncomeApplyDetail as a
|
|
LEFT JOIN salIncomeApplyMaster as b ON a.BillNo = b.BillNo
|
|
LEFT JOIN (
|
|
SELECT aMaster.BillNo,aMaster.BizPartnerId,aDetail.CU_MaterialId FROM arCheckBill as aMaster
|
|
LEFT JOIN arCheckBillDetail as aDetail ON aMaster.BizPartnerId = aDetail.FromBillNo
|
|
WHERE aMaster.BizPartnerId = '$contract_no' AND aMaster.TypeId = 'RVS'
|
|
) AS c ON a.BillNo = c.BizPartnerId
|
|
WHERE a.BillNo = '$contract_no'
|
|
AND a.RowNo = '1'
|
|
";
|
|
$stmt = $connT8->prepare($sql);
|
|
$stmt->execute();
|
|
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
// $data['amount'] = intval($data['amount']);
|
|
if (!empty($data['CBno']) && $data['CBno'] != '') {
|
|
$checkBillNo = $data['CBno'];
|
|
|
|
$sql = "SELECT
|
|
c.BillDate AS CheckBillDate
|
|
FROM arWriteOffBill AS a
|
|
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
|
|
LEFT JOIN
|
|
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
|
|
LEFT JOIN
|
|
(SELECT
|
|
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
|
|
FROM arCheckBill
|
|
LEFT JOIN arCheckBillInvInfo
|
|
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
|
|
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
|
|
ON a.BillNo=c.BillNo
|
|
WHERE c.checkBillNo = '$checkBillNo'
|
|
";
|
|
|
|
$stmt = $connT8->prepare($sql);
|
|
$stmt->execute();
|
|
|
|
return '1';
|
|
} else {
|
|
return '2';
|
|
}
|
|
}
|
|
?>
|
|
<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 defer src="../contract-repair/js/alpinejs/cdn.min.js"></script>
|
|
<script src="../contract-repair/js/alpine.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="bonus_index">
|
|
<!-- <input type="button" hidden x-ref="initbtn" @click="isPay()" /> -->
|
|
|
|
<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">
|
|
<span class="glyphicon glyphicon-plus"></span>
|
|
</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>
|
|
<a href="/wms/bonus/bonus.php?check=3&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 已發獎金</a>
|
|
|
|
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
|
|
<thead>
|
|
<tr>
|
|
<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>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (!empty($datas)) {
|
|
foreach ($datas as $key => $data) :
|
|
|
|
$contract_no = $data['contract_no'];
|
|
$json = json_decode($data['bonus_json']);
|
|
|
|
$total = empty($json->total) ? 0 : $json->total;
|
|
$fee_per_st = empty($json->fee_per_st) ? 0 : $json->fee_per_st;
|
|
$commission_fee = empty($json->commission_fee) ? 0 : $json->commission_fee;
|
|
$isPay = isPay($data['contract_no'], $connT8);
|
|
|
|
?>
|
|
<tr>
|
|
<td><?= $data['id'] ?></td>
|
|
<td><?= $contract_type[$data['contract_type']] ?></td>
|
|
<td><?= $data['contract_no'] ?></td>
|
|
<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><?= $commission_fee ?></td>
|
|
<td><?= $data['receiver'] ?></td>
|
|
<td><?= $data['pay_day'] ?></td>
|
|
<td><?= $data['amount'] ?></td>
|
|
<!-- <td><?= ($data['status'] == 1) ? '未發放' : '已發放' ?></td> -->
|
|
<td>
|
|
<!-- <input type="text" x-model="isPays[<?php echo $key; ?>]" /> -->
|
|
<span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span>
|
|
</td>
|
|
<td>
|
|
<?php
|
|
// 判斷時間是否為一個月內
|
|
$payday = new DateTime($data['pay_day']);
|
|
if ($isPay == 1) {
|
|
?>
|
|
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtn" style="">發放獎金</a>
|
|
<?php
|
|
} else if ($payday < $oneMonthAgo) {
|
|
?>
|
|
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a>
|
|
<?php
|
|
}
|
|
?>
|
|
</td>
|
|
|
|
</tr>
|
|
<?php
|
|
endforeach;
|
|
} ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
table {
|
|
table-layout: fixed;
|
|
width: 100%;
|
|
}
|
|
|
|
td {
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
.width_style_1 {
|
|
width: 125px;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
}
|
|
|
|
#table_index_filter {
|
|
float: right;
|
|
}
|
|
|
|
#table_index_paginate {
|
|
table-layout: fixed;
|
|
width: 100%;
|
|
}
|
|
|
|
label {
|
|
display: inline-flex;
|
|
margin-bottom: .5rem;
|
|
margin-top: .5rem;
|
|
|
|
}
|
|
|
|
.btn-secondary {
|
|
color: #fff;
|
|
background-color: #6c757d;
|
|
border-color: #6c757d;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
color: #fff;
|
|
background-color: #5a6268;
|
|
border-color: #545b62;
|
|
}
|
|
|
|
.applybtn {
|
|
color: #fff;
|
|
background-color: #1484c4;
|
|
/* display: block; */
|
|
border-radius: 5px;
|
|
padding: 5px 2px;
|
|
font-size: 13px;
|
|
line-height: 1;
|
|
display: grid;
|
|
place-items: center;
|
|
/* 水平和垂直居中 */
|
|
height: 2%vh;
|
|
/* 100%视窗高度,可根据需要调整 */
|
|
}
|
|
|
|
.applybtncheck {
|
|
color: #fff;
|
|
background-color: #eea236;
|
|
/* display: block; */
|
|
border-radius: 4px;
|
|
padding: 4px 2px;
|
|
font-size: 13px;
|
|
line-height: 1;
|
|
display: grid;
|
|
place-items: center;
|
|
/* 水平和垂直居中 */
|
|
height: 2%vh;
|
|
/* 100%视窗高度,可根据需要调整 */
|
|
}
|
|
|
|
.applybtncheck:hover {
|
|
background-color: #f0ad4e;
|
|
color: #fff;
|
|
}
|
|
|
|
.applybtn:hover {
|
|
background-color: #1494f9;
|
|
color: #fff;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
const datas = <?php echo json_encode($datas); ?>;
|
|
|
|
// function init() {
|
|
// this.isPay();
|
|
|
|
// }
|
|
// const bonusIndex = () => {
|
|
// return {
|
|
// async isPay() {
|
|
// // console.log(123)
|
|
// for (let i = 0; i < datas.length; i++) {
|
|
// await axios.get('./api/get.php?contract_no=' + datas[i].contract_no).then(res => {
|
|
// let isPay = res.data;
|
|
// // this.data.isPay.push(isPay); // 更新 x-data 中的数据
|
|
// this.isPays.push(isPay);
|
|
// }).catch(err => {
|
|
|
|
// })
|
|
// }
|
|
|
|
// console.log(this.isPays);
|
|
// }
|
|
// }
|
|
// }
|
|
</script>
|