13 changed files with 922 additions and 137 deletions
@ -0,0 +1,146 @@ |
|||
<?php |
|||
include_once("../header.php"); |
|||
// require_once('./connT8.php'); |
|||
require("../contract/conn.php"); |
|||
$now = date("Y-m-d"); |
|||
$oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); |
|||
$oneMonthAgo1 = date("m", strtotime($oneMonthAgo)); |
|||
$clause = ""; |
|||
if ($_GET['check'] == 'maintainance') { |
|||
if (!empty($_GET)) { |
|||
$month = $_GET['months_select']; |
|||
$years = $_GET['years']; // 當前年份 |
|||
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $years); |
|||
$select_date = date("$years-$month-01"); |
|||
$select_date1 = date("$years-$month-$days_in_month"); |
|||
echo $select_date1; |
|||
$clause .= "AND pay_day_due >='$select_date' AND pay_day_due <= '$select_date1' "; |
|||
} else { |
|||
$clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' "; |
|||
} |
|||
|
|||
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' "; |
|||
$sql = "SELECT a.receiver,a.amount,b.name FROM bonus AS a |
|||
LEFT JOIN account AS b ON a.receiver = b.accountid |
|||
WHERE 1=1 AND contract_type = 3 $clause ORDER BY a.receiver ASC"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->execute(); |
|||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
|
|||
$person_arr = []; |
|||
$bonus_arr = []; |
|||
$count = 0; |
|||
|
|||
$a = 0; |
|||
$j = 0; |
|||
} |
|||
|
|||
for ($i = 0; $i < COUNT($results); $i++) { |
|||
$a++; |
|||
if ($i + 1 < COUNT($results)) { |
|||
if ($results[$i]['receiver'] != $results[$i + 1]['receiver']) { |
|||
$amount = 0; |
|||
if ($i != $j) { |
|||
for ($j; $j <= $i; $j++) { |
|||
$amount += $results[$j]['amount']; |
|||
} |
|||
$person_arr['person_id'] = $results[$i]['receiver']; |
|||
$person_arr['person'] = $results[$i]['name']; |
|||
$person_arr['bonus'] = $amount; |
|||
array_push($bonus_arr, $person_arr); |
|||
} else { |
|||
$amount += $results[$j]['amount']; |
|||
$person_arr['person_id'] = $results[$i]['receiver']; |
|||
$person_arr['person'] = $results[$i]['name']; |
|||
$person_arr['bonus'] = $amount; |
|||
array_push($bonus_arr, $person_arr); |
|||
} |
|||
|
|||
$j = $i + 1; |
|||
} |
|||
} else { |
|||
$amount = 0; |
|||
for ($j; $j <= $i; $j++) { |
|||
$amount += $results[$j]['amount']; |
|||
} |
|||
$amount += $results[$i]['amount']; |
|||
$person_arr['person_id'] = $results[$i]['receiver']; |
|||
$person_arr['bonus'] = $amount; |
|||
$person_arr['person'] = $results[$i]['name']; |
|||
array_push($bonus_arr, $person_arr); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<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> --> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'><?= !empty($years) ? $years : date('Y') ?>年<?= !empty($month) ? $month : $oneMonthAgo1 ?>月份、個人獎金計算</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
</table> |
|||
<form method='get' action=''> |
|||
<table class='table table-striped table-bordered' style='width:70%;text-align:center;margin:0 auto'> |
|||
<tbody> |
|||
<tr> |
|||
<th style="text-align:center;vertical-align:middle;">年份</th> |
|||
<td> |
|||
<select name="years" id=""> |
|||
<?php for ($i = 2020; $i <= 2030; $i++) { ?> |
|||
<option value="<?= $i ?>" <?php echo isset($_GET["years"]) && $_GET["years"] == $i ? 'selected' : ''; ?>> |
|||
<?= $i ?> |
|||
</option> <?php } ?> |
|||
</select> |
|||
</td> |
|||
<th style="text-align:center;vertical-align:middle;">月份</th> |
|||
<td> |
|||
<select name="months_select" id=""> |
|||
<?php for ($i = 1; $i <= 12; $i++) { ?> |
|||
<option value="<?= $i ?>" <?php echo isset($_GET["months_select"]) && $_GET["months_select"] == $i ? 'selected' : ''; ?>> |
|||
<?= $i ?> |
|||
</option> <?php } ?> |
|||
</select> |
|||
</td> |
|||
<!-- <td><input type="text" class="form-control" name="months_select" value="<?php if (isset($_GET["facilityno"])) echo $_GET["facilityno"]; ?>"></td> --> |
|||
<!--<th>保養員姓名</th> --> |
|||
<td style="text-align:center;vertical-align:middle;width:80px"><button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<input type="hidden" name="function_name" value="schedule_index"> |
|||
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
|||
</form> |
|||
|
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<!-- <th>項次</th> --> |
|||
<th>工號</th> |
|||
<th>姓名</th> |
|||
<th>總獎金水庫(實發總價)</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
<?php |
|||
if (!empty($bonus_arr)) { |
|||
foreach ($bonus_arr as $key => $bonus) { |
|||
?> |
|||
<tr> |
|||
<!-- <td><?php echo $key ?></td> --> |
|||
<td><?php echo $bonus['person_id'] ?></td> |
|||
<td><?php echo $bonus['person'] ?></td> |
|||
<td><?php echo $bonus['bonus'] ?></td> |
|||
</tr> |
|||
<?php } |
|||
} ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
@ -0,0 +1,366 @@ |
|||
<?php |
|||
include_once("../header.php"); |
|||
// require_once('./connT8.php'); |
|||
require("../contract/conn.php"); |
|||
$now = date("Y-m-d"); |
|||
|
|||
$contract_type = [ |
|||
'1' => '新梯', |
|||
'2' => '汰改', |
|||
'3' => '保養' |
|||
]; |
|||
|
|||
$bonus_type = [ |
|||
'1' => '契約人獎金', |
|||
'2' => '區經理獎金', |
|||
'3' => '專任契約經理獎金' |
|||
]; |
|||
|
|||
$bonus_status = [ |
|||
'1' => '未確認', |
|||
'2' => '應發已確認', |
|||
'3' => '應發未確認', |
|||
'4' => '暫不發放', |
|||
'5' => '人事審核確認' |
|||
]; |
|||
$clause = ''; |
|||
if ($user_id != 'M0225') { |
|||
$clause .= "AND receiver == '$user_id'"; |
|||
} |
|||
if (!empty($_GET['check'])) { |
|||
// 人事發放作業,應為一個月內 |
|||
if ($_GET['check'] == 4) { |
|||
$oneMonthAgo = date("Y-m-d", strtotime("$now +1 months")); |
|||
// $clause .= "AND pay_day_due >= '$now' AND pay_day_due <= '$oneMonthAgo' AND status IN (1,2,5)"; |
|||
$clause .= "AND a.status IN (1,2,5)"; |
|||
} else if ($_GET['check'] == 2) { |
|||
$clause .= "AND a.status = 1"; |
|||
} else if ($_GET['check'] == 3) { |
|||
$clause .= "AND a.status IN (2,5)"; |
|||
} |
|||
} |
|||
|
|||
$sql = "SELECT a.*,b.customer FROM bonus AS a |
|||
LEFT JOIN con_maintance_examine_apply AS b ON a.contract_no = b.vol_no |
|||
WHERE 1=1 $clause AND a.contract_type = 3"; |
|||
|
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->execute(); |
|||
$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); |
|||
|
|||
// 查看 T8 是否有收款明細 |
|||
// require("./api/get.php"); |
|||
?> |
|||
<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" x-data="bonusIndexTest"> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<div style="overflow-x:auto;margin-top:12px"> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>(契約)獎金計算</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
</table> |
|||
<!-- <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> |
|||
<a href="/wms/bonus/bonus.php?check=4&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 4) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 人事發放作業</a> |
|||
<a href="/wms/bonus/bonus_person.php?check=maintainance&function_name=bonus&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 5) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 獎金總計(人)</a> |
|||
|
|||
|
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
|||
<button class="btn btn-primary float-end" style="float: right;" onclick="isPay()">查看是否收款</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> |
|||
<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') { |
|||
?> |
|||
<th>實際發放時間</th> |
|||
<th>發放 / 詳情</th> |
|||
|
|||
<?php } else { ?> |
|||
<th>詳情</th> |
|||
<?php |
|||
} ?> |
|||
</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><?= $data['contract_no'] ?></td> |
|||
<td><?= $data['customer'] ?></td> |
|||
<td><?= $data['facility_no'] ?></td> |
|||
<td><?= $bonus_type[$data['bonus_type']] ?></td> |
|||
<td><?= $data['bonus_verson'] ?></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> --> |
|||
</td> |
|||
<?php if (!empty($_GET['check']) && $_GET['check'] == '4') { |
|||
if ($data['status'] == '3' || $data['status'] == '1') { ?> |
|||
<td> -- </td> |
|||
<td> |
|||
<?php |
|||
// if ($isPay == 1) { |
|||
?> |
|||
<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) { |
|||
?> |
|||
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a> |
|||
<?php |
|||
// } |
|||
?> |
|||
</td> |
|||
<!-- <td><input type="date" value="<?= $data['pay_day'] ?>"></td> --> |
|||
|
|||
<?php } else { ?> |
|||
<td><?= $data['pay_day'] ?></td> |
|||
<td><a href="bonus_check.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a></td> |
|||
|
|||
<?php } |
|||
} else { ?> |
|||
<td><a href="bonus_check.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtncheck">查看詳情</a></td> |
|||
|
|||
<?php } ?> |
|||
</tr> |
|||
<?php |
|||
endforeach; |
|||
} ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<!-- </div> --> |
|||
|
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 100%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
.width_st yle_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 issue(id, user_id, pay_day, amount) { |
|||
// consolelog(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'); |
|||
form.append('contract_type', 'maintainance'); |
|||
axios.post('./api/postStatus.php', form).then((res) => { |
|||
if (res.data == 'Success') { |
|||
alert('更新成功'); |
|||
location.reload(); |
|||
} |
|||
}).catch((err) => { |
|||
|
|||
}) |
|||
} |
|||
|
|||
function All(data) { |
|||
let arr = data.split(","); |
|||
const form = new FormData(); |
|||
form.append('id', arr); |
|||
form.append('user_id', '<?= $user_id ?>') |
|||
form.append('postType', 'd'); |
|||
if (confirm('是否發放全部獎金')) { |
|||
axios.post('./api/postStatus.php', form).then((res) => { |
|||
if (res.status == 200) { |
|||
alert('更新成功'); |
|||
location.reload(); |
|||
} |
|||
}).catch((err) => { |
|||
|
|||
}); |
|||
} |
|||
} |
|||
|
|||
function isPay() { |
|||
const form = new FormData(); |
|||
form.append('user_id', '<?= $user_id ?>'); |
|||
form.append('postType', 'e'); |
|||
// 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() { |
|||
// console.log(123); |
|||
// }) |
|||
// }) |
|||
// 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> |
Loading…
Reference in new issue