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.
146 lines
6.0 KiB
146 lines
6.0 KiB
<?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>
|