Browse Source

獎金頁面

gary
Cheng 1 year ago
parent
commit
38836b65e1
  1. 10
      wms/bonus/api/get.php
  2. 0
      wms/bonus/api/updateBonus.php
  3. 171
      wms/bonus/bonus.php
  4. 20
      wms/bonus/bonus_detail.php
  5. 65
      wms/contract-repair/js/alpine.js
  6. 16
      wms/contract/api/testT8API.php
  7. 5
      wms/contract/conn.php

10
wms/bonus/api/get.php

@ -62,12 +62,18 @@ if (!empty($_GET['contract_no'])) {
// $result = $stmt->fetchAll(PDO::FETCH_ASSOC); // $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
// $count = COUNT($result); // $count = COUNT($result);
// $data['maintain_month'] = intval($count * $result[0]['SQuantity']); // $data['maintain_month'] = intval($count * $result[0]['SQuantity']);
$reult = true;
echo '1'; echo '1';
// return true;
} else { } else {
$result = false;
echo '2'; echo '2';
// return false;
} }
} catch (PDOException $e) { } catch (PDOException $e) {
echo '123'; echo '111';
return false;
// exit;
} }
// if (($check['CheckBillDate']) !== '') { // if (($check['CheckBillDate']) !== '') {
// header('Content-Type: application/json'); // header('Content-Type: application/json');
@ -76,4 +82,6 @@ if (!empty($_GET['contract_no'])) {
// echo false; // echo false;
// exit; // exit;
// } // }
} else {
exit();
} }

0
wms/bonus/api/insertBonus.php → wms/bonus/api/updateBonus.php

171
wms/bonus/bonus.php

@ -1,7 +1,7 @@
<?php <?php
include_once("../header.php"); include_once("../header.php");
// require_once('./connT8.php'); // require_once('./connT8.php');
require("../contract-repair/conn.php"); require("../contract/conn.php");
$contract_type = [ $contract_type = [
@ -37,39 +37,70 @@ $oneMonthAgo = $now->modify('+1 month');
// 查看 T8 是否有收款明細 // 查看 T8 是否有收款明細
// require("./api/get.php"); // require("./api/get.php");
function isPay($contract_no) function isPay($contract_no, $connT8)
{ {
$api_url = './api/get.php?contract_no=' . $contract_no; // echo $contract_no;
$ch = curl_init(); $sql = "SELECT
curl_setopt($ch, CURLOPT_URL, $api_url); a.BillNo,
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); b.OTaxAmt as amount,
curl_setopt($ch, CURLOPT_HTTPHEADER, array($contract_no)); a.CU_EstPayDate as createDate,
b.PersonId as personId,
$response = curl_exec($ch); c.BillNo as CBno,
echo $response; c.CU_MaterialId as facility
if ($response === false) { FROM salIncomeApplyDetail as a
echo '123Curl error: ' . curl_error($ch); 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 = 'Q23080067' 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 { } else {
$result = json_decode($response, true); return '2';
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/styles/style.css">
<link rel="stylesheet" href="../contract-repair/semantic/dist/semantic.min.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" /> <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/alpine.js"></script>
<script src="../contract-repair/js/axios/axios.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/js/jquery/jquery-3.1.1.min.js"></script> -->
<script src="../contract-repair/semantic/dist/semantic.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 class="bonus_index" x-data="bonusIndex">
<!-- <input type="button" hidden x-ref="initbtn" @click="isPay()" /> -->
<div style="overflow-x:auto;margin-top:12px"> <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"> <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> <span class="glyphicon glyphicon-plus"></span>
@ -98,9 +129,14 @@ function isPay($contract_no)
<tbody> <tbody>
<?php if (!empty($datas)) { <?php if (!empty($datas)) {
foreach ($datas as $key => $data) : foreach ($datas as $key => $data) :
$isPay = isPay($data['contract_no']);
$contract_no = $data['contract_no'];
$isPay = isPay($contract_no, $connT8);
// echo '<pre>';
// print($isPay);
// echo '</pre>';
?> ?>
<tr> <tr x-data="{isPays: []}" x-init="init">
<td><?= $data['id'] ?></td> <td><?= $data['id'] ?></td>
<td><?= $contract_type[$data['contract_type']] ?></td> <td><?= $contract_type[$data['contract_type']] ?></td>
<td><?= $data['contract_no'] ?></td> <td><?= $data['contract_no'] ?></td>
@ -111,19 +147,21 @@ function isPay($contract_no)
<td><?= $data['pay_day'] ?></td> <td><?= $data['pay_day'] ?></td>
<td><?= ($data['status'] == 1) ? '未發放' : '已發放' ?></td> <td><?= ($data['status'] == 1) ? '未發放' : '已發放' ?></td>
<td> <td>
<span x-text="data"></span> <!-- <input type="text" x-model="isPays[<?php echo $key; ?>]" /> -->
<span><?= ($isPay == 1) ? '已收款' : '未收款' ?></span>
</td> </td>
<td> <td>
<span></span>
<?php <?php
// 判斷時間是否為一個月內 // 判斷時間是否為一個月內
$payday = new DateTime($data['pay_day']); $payday = new DateTime($data['pay_day']);
if ($payday < $oneMonthAgo) { if ($isPay == 1) {
?> ?>
<a href="bonus_detail.php?id=<?= $data['id'] ?>&token=<?php echo $token; ?>" class="applybtn">查看詳情</a> <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 <?php
} else {
echo '--';
} }
?> ?>
</td> </td>
@ -171,14 +209,51 @@ function isPay($contract_no)
} }
.btn-secondary {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
color: #fff;
background-color: #5a6268;
border-color: #545b62;
}
.applybtn { .applybtn {
color: #fff; color: #fff;
background-color: #1484c4; background-color: #1484c4;
display: block; /* 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; border-radius: 4px;
padding: 4px 2px; padding: 4px 2px;
font-size: 13px; font-size: 13px;
line-height: 1;
display: grid;
place-items: center;
/* 水平和垂直居中 */
height: 2%vh;
/* 100%视窗高度,可根据需要调整 */
}
.applybtncheck:hover {
background-color: #f0ad4e;
color: #fff;
} }
.applybtn:hover { .applybtn:hover {
@ -190,18 +265,26 @@ function isPay($contract_no)
<script> <script>
const datas = <?php echo json_encode($datas); ?>; const datas = <?php echo json_encode($datas); ?>;
// $(function() { function init() {
// $('#table_index2').DataTable({ this.isPay();
// "scrollX": true,
// "pageLength": 50 }
// }); const bonusIndex = () => {
// /* return {
// var api = $('#table_index').dataTable().api(); async isPay() {
// //var order = api.order(); // console.log(123)
// //console.log(order); for (let i = 0; i < datas.length; i++) {
// api await axios.get('./api/get.php?contract_no=' + datas[i].contract_no).then(res => {
// .order([0, "desc"]) let isPay = res.data;
// .draw(); // this.data.isPay.push(isPay); // 更新 x-data 中的数据
// */ this.isPays.push(isPay);
// }); }).catch(err => {
})
}
console.log(this.isPays);
}
}
}
</script> </script>

20
wms/bonus/bonus_detail.php

@ -7,9 +7,9 @@ $stmt = $conn->prepare($sql);
$stmt->bindParam(':id', $_GET['id']); $stmt->bindParam(':id', $_GET['id']);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC); $result = $stmt->fetch(PDO::FETCH_ASSOC);
echo '<pre>'; // echo '<pre>';
print_r($result); // print_r($result);
echo '</pre>'; // echo '</pre>';
?> ?>
<link rel="stylesheet" href="../contract-repair/styles/style.css"> <link rel="stylesheet" href="../contract-repair/styles/style.css">
@ -86,16 +86,20 @@ echo '</pre>';
<td> <td>
<input type="text" x-model="data.receiver" disabled="disabled"> <input type="text" x-model="data.receiver" disabled="disabled">
</td> </td>
<td style="vertical-align:middle">發放日期</td> <td style="vertical-align: middle">發放日期</td>
<td> <td>
<input type="text" x-model="data.payDay" disabled="disabled"> <input class="form-control disabled_select" type="date" name="start_date" x-model="data.payDaydue" disabled>
<p class="alerttext" x-show="data.payDaydue==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">應發日期</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.payDay">
<p class="alerttext" x-show="data.payDay==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align:middle">發放金額</td> <td style="vertical-align:middle">發放金額</td>
<td> <td>
<input type="text" x-model="data.maintain_price_total" disabled="disabled"> <input type="text" x-model="data.maintain_price_total" disabled="disabled">
</td> </td>
<td></td>
<td></td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align:middle">地區經理經理員</td> <td style="vertical-align:middle">地區經理經理員</td>
@ -191,7 +195,7 @@ echo '</pre>';
const facility_no = '<?= $result['facility_no'] ?>'; const facility_no = '<?= $result['facility_no'] ?>';
const bonus_verson = '<?= $result['bonus_verson'] ?>'; const bonus_verson = '<?= $result['bonus_verson'] ?>';
const receiver = '<?= $result['receiver'] ?>'; const receiver = '<?= $result['receiver'] ?>';
const payDay = '<?= $result['pay_day'] ?>'; const payDaydue = '<?= $result['pay_day_due'] ?>';
const maintain_price_total = '<?= $result['amount'] ?>'; const maintain_price_total = '<?= $result['amount'] ?>';
const contract_type = '<?= $result['contract_type'] ?>'; const contract_type = '<?= $result['contract_type'] ?>';
// const bonus_verson = '<?= $result['bonus_verson'] ?>'; // const bonus_verson = '<?= $result['bonus_verson'] ?>';

65
wms/contract-repair/js/alpine.js

@ -883,14 +883,14 @@ const bonunsIndexTest = () => {
receiver: receiver, receiver: receiver,
maintain_month: '', maintain_month: '',
maintain_price_total: maintain_price_total, maintain_price_total: maintain_price_total,
payDay: payDay, payDaydue: payDaydue,
bonusArr: [], bonusArr: [],
contract_type: contract_type, contract_type: contract_type,
manager: '', manager: '',
bonus_type: '', bonus_type: '',
bouns_receiver: '', bouns_receiver: '',
bouns_amount: '', bouns_amount: '',
dayDus: '', payDay: '',
bouns_regulation: '', bouns_regulation: '',
contract_manger: 'M0001', contract_manger: 'M0001',
user_id: user_id user_id: user_id
@ -956,14 +956,11 @@ const bonunsIndexTest = () => {
// }) // })
}, },
save() { save() {
if (this.step == 3) { if (this.step == 1) {
const form = new FormData(); const form = new FormData();
form.append('contract_no', this.data.contract_no); form.append('contract_no', this.data.contract_no);
form.append('facility_no', this.data.facility_no); form.append('payDay', this.data.payDay);
form.append('bonuns_verson', this.data.bonus_verson); axios.post('./api/updateBonus.php', form).then(res => {
form.append('user_id', this.data.user_id);
form.append('bonusArr', JSON.stringify(this.data.bonusArr));
axios.post('./api/insertBonus.php', form).then(res => {
console.log(res.data); console.log(res.data);
}).catch(err => { }).catch(err => {
@ -975,7 +972,7 @@ const bonunsIndexTest = () => {
const form = new FormData(); const form = new FormData();
form.append('cotract_no', this.data.contract_no); form.append('cotract_no', this.data.contract_no);
form.append('bonuns_verson', this.data.bonus_verson); form.append('bonuns_verson', this.data.bonus_verson);
form.append('c[ontract_type', this.data.contract_type); form.append('contract_type', this.data.contract_type);
form.append('maintain_month', this.data.maintain_month); form.append('maintain_month', this.data.maintain_month);
form.append('maintain_price_total', this.data.maintain_price_total); form.append('maintain_price_total', this.data.maintain_price_total);
form.append('payDay', this.data.payDay); form.append('payDay', this.data.payDay);
@ -1004,26 +1001,32 @@ const bonunsIndexTest = () => {
} }
} }
{/* <span x-bind='data[<?= $index ?>].contract_no'><?= $data['contract_no'] ?></span> */ } {/* <span x-bind='data[<?= $index ?>].contract_no'><?= $data['contract_no'] ?></span> */ }
const bonusIndex = () => { // const bonusIndex = () => {
return { // return {
init() { // init() {
// console.log(datas) // window.onload = () => {
// console.log(Array(datas)); // this.isPay();
for (let i = 0; i < datas.length; i++) { // }
this.data[i] = this.isPay(datas[i].contract_no); // },
} // initbtn: null,
console.log(this.data); // data: {
}, // isPay: []
data: [], // },
step: 1, // isPays: [],
isPay(data) { // step: 1,
axios.get('./api/get.php?contract_no=' + data.contract_no).then(res => { // async isPay() {
console.log(res.data); // // console.log(this.data)
let isPay = res.data; // for (let i = 0; i < datas.length; i++) {
return isPay; // await axios.get('./api/get.php?contract_no=' + datas[i].contract_no).then(res => {
}).catch(err => { // let isPay = res.data;
// this.isPays.push(isPay);
// }).catch(err => {
}) // })
} // }
}
} // console.log(this.isPays);
// }
// }
// }

16
wms/contract/api/testT8API.php

@ -1,19 +1,21 @@
<?php <?php
$date = Date('Y-m-d'); $date = Date('Y-m-d');
$date1 = Date('Y-m-d', strtotime("$date +1 months")); $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")); // $countDay = date('Ymd', strtotime("$date1 + 1 months"));
// echo '<pre>'; // echo '<pre>';
// print_r($countDay); // print_r($countDay);
// echo '</pre>'; // echo '</pre>';
// exit(); // exit();
$a = 0; $SQuantity = 2;
// $b = 24 / $a; // $b = 24 / $a;
for ($i = 0; $i < 2; $i++) { for ($i = 0; $i < 12; $i++) {
for ($j = 0; $j < 12; $j++) { $paymonth = $i * $SQuantity;
$a++; $countDay = date('Y-m-d', strtotime("$date + $paymonth months"));
$payDay = str_replace('-', '', $countDay);
echo '<pre>'; echo '<pre>';
print_r($a); print_r($payDay);
echo '</pre>'; echo '</pre>';
}
} }

5
wms/contract/conn.php

@ -33,6 +33,11 @@ try {
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。
//設定主動以警告的形式報錯 //設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8masada", "M0225", "IFFBU1E=");
if ($connT8) {
$connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
//如果連接錯誤,將抛出一個PDOException異常對象 //如果連接錯誤,將抛出一個PDOException異常對象
} catch (PDOException $e) { } catch (PDOException $e) {
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作

Loading…
Cancel
Save