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.
 
 
 
 
 
 

207 lines
7.3 KiB

<?php
include_once("../header.php");
// require_once('./connT8.php');
require("../contract-repair/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";
$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)
{
$api_url = './api/get.php?contract_no=' . $contract_no;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($contract_no));
$response = curl_exec($ch);
echo $response;
if ($response === false) {
echo '123Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
if ($result['Status'] == 'Success')
return $result;
if ($result['Status'] == 'Error')
return $result;
}
curl_close($ch);
}
?>
<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 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>
<script defer src="../contract-repair/js/alpinejs/cdn.min.js"></script>
<div class="bonus_index" x-data="bonusIndex">
<div style="overflow-x:auto;margin-top:12px">
<a href="contract-newelevator-input.php?function_name=repair&<?php echo $token_link; ?>" 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>
</tr>
</thead>
<tbody>
<?php if (!empty($datas)) {
foreach ($datas as $key => $data) :
$isPay = isPay($data['contract_no']);
?>
<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><?= $data['receiver'] ?></td>
<td><?= $data['pay_day'] ?></td>
<td><?= ($data['status'] == 1) ? '未發放' : '已發放' ?></td>
<td>
<span x-text="data"></span>
</td>
<td>
<span></span>
<?php
// 判斷時間是否為一個月內
$payday = new DateTime($data['pay_day']);
if ($payday < $oneMonthAgo) {
?>
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtn">查看詳情</a>
<?php
} else {
echo '--';
}
?>
</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;
}
.applybtn {
color: #fff;
background-color: #1484c4;
display: block;
border-radius: 4px;
padding: 4px 2px;
font-size: 13px;
}
.applybtn:hover {
background-color: #1494f9;
color: #fff;
}
</style>
<script>
const datas = <?php echo json_encode($datas); ?>;
// $(function() {
// $('#table_index2').DataTable({
// "scrollX": true,
// "pageLength": 50
// });
// /*
// var api = $('#table_index').dataTable().api();
// //var order = api.order();
// //console.log(order);
// api
// .order([0, "desc"])
// .draw();
// */
// });
</script>