26 changed files with 3664 additions and 791 deletions
@ -0,0 +1,523 @@ |
|||
<?php |
|||
include "header.php"; |
|||
include "css/view/wipwhole-index.php"; |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
$start_date = empty($_POST['date_start']) ? null : $_POST['date_start']; |
|||
$end_date = empty($_POST['date_end']) ? null : $_POST['date_end']; |
|||
$start_SignDate = empty($_POST['date_Signstart']) ? null : $_POST['date_Signstart']; |
|||
$end_SignDate = empty($_POST['date_Signend']) ? null : $_POST['date_Signend']; |
|||
|
|||
$sql = " |
|||
SELECT |
|||
siam.PersonId, |
|||
cp.PersonName, |
|||
cd.DeptId, |
|||
cd.DeptName, |
|||
cd.LeaderId, |
|||
lcp.PersonName AS LeaderName, |
|||
siam.BizPartnerId, |
|||
cbp.BizPartnerName, |
|||
siamd.RowCode, |
|||
siam.BillNo, |
|||
siamd.ProjectId, |
|||
siamd.CU_EstPayDate, |
|||
siamd.UnTransCheckBLAmtWTax , |
|||
siamd.HadTransCheckBLAmtWTax, |
|||
siamd.OAmountWithTax, |
|||
siamd.CU_MaterialId, |
|||
acb_tmp.BillNo2, |
|||
acb_tmp.RowCode2, |
|||
acb_tmp.checkOAmount, |
|||
asim.BillNo AS BillNo3, |
|||
asim.InvoiceName, |
|||
asim.OAmountWithTax AS InvoiceOAmount, |
|||
asi.InvoiceNo, |
|||
asi.InvoiceTime, |
|||
writeoff.BillDate AS WriteOffDate, |
|||
SUM(arwobd.CurrStandOffOAmount) AS TotalCurrStandOffOAmount |
|||
FROM salIncomeApplyMaster AS siam -- 收入申請單 |
|||
LEFT JOIN salIncomeApplyDetail AS siamd -- 收入申請單明細 |
|||
ON siam.BillNo = siamd.BillNo |
|||
LEFT JOIN comGroupPerson AS cp -- 員工主檔 |
|||
ON siam.PersonId = cp.PersonId |
|||
LEFT JOIN comDepartment AS cd -- 部門主檔 |
|||
ON siam.DeptId = cd.DeptId |
|||
LEFT JOIN comGroupPerson AS lcp |
|||
ON lcp.PersonId= cd.LeaderId |
|||
LEFT JOIN ( |
|||
SELECT |
|||
acbd.FromRowCode, |
|||
acb.FromBillNo, |
|||
acbd.BillNo AS BillNo2, |
|||
acbd.RowCode AS RowCode2, |
|||
acbd.LAmountWithTax AS checkOAmount |
|||
FROM arCheckBill AS acb -- 應收確認單 |
|||
LEFT JOIN arCheckBillDetail AS acbd -- 應收確認單明細 |
|||
ON acb.BillNo = acbd.BillNo |
|||
WHERE 1 = 1 |
|||
AND acb.TypeId = 'RVS') AS acb_tmp |
|||
ON siamd.RowCode = acb_tmp.FromRowCode |
|||
AND siamd.BillNo = acb_tmp.FromBillNo |
|||
LEFT JOIN arSellInvoiceMaterial AS asim -- 買賣發票明細 |
|||
ON asim.FromBillNo = acb_tmp.BillNo2 |
|||
AND asim.RowCode = acb_tmp.RowCode2 |
|||
LEFT JOIN arSellInvoice AS asi |
|||
ON asim.BillNo = asi.BillNo |
|||
LEFT JOIN comBusinessPartner AS cbp |
|||
ON siam.BizPartnerId = cbp.BizPartnerId |
|||
LEFT JOIN |
|||
arWriteOffBillDetail AS arwobd |
|||
ON acb_tmp.BillNo2 = arwobd.FromBillNo |
|||
LEFT JOIN |
|||
arWriteOffBill AS writeoff ON arwobd.BillNo = writeoff.BillNo |
|||
WHERE 1 = 1 |
|||
"; |
|||
$follower = find_follow($user_id); |
|||
if ((in_array($user_id, array('M0008', 'M0012'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '501')))) { |
|||
} else { |
|||
$sql .= " AND (siam.PersonId = '$user_id'"; |
|||
if (count($follower) > 0) { |
|||
$column_str = "('$user_id'" . ",'"; |
|||
$column_str .= implode("','", $follower); |
|||
$column_str .= "')"; |
|||
$sql .= " OR siam.PersonId IN $column_str OR cd.LeaderId = '$user_id')"; |
|||
} else { |
|||
$sql .= " OR cd.LeaderId = '$user_id')"; |
|||
}; |
|||
} |
|||
if (!is_null($start_date)) { |
|||
$start_date = (int)date('Ymd', strtotime($start_date)); |
|||
$sql .= " AND siam.CU_ContractStart >= $start_date "; |
|||
} |
|||
if (!is_null($end_date)) { |
|||
$end_date = (int)date('Ymd', strtotime($end_date)); |
|||
$sql .= " AND siam.CU_ContractStart <= $end_date "; |
|||
} |
|||
if (!is_null($start_SignDate)) { |
|||
$start_SignDate = (int)date('Ymd', strtotime($start_SignDate)); |
|||
$sql .= " AND siam.BillDate >= $start_SignDate "; |
|||
} |
|||
if (!is_null($end_SignDate)) { |
|||
$end_SignDate = (int)date('Ymd', strtotime($end_SignDate)); |
|||
$sql .= " AND siam.BillDate <= $end_SignDate "; |
|||
} |
|||
$sql .= " GROUP BY |
|||
siam.PersonId, |
|||
cp.PersonName, |
|||
cd.DeptId, |
|||
cd.DeptName, |
|||
cd.LeaderId, |
|||
lcp.PersonName, |
|||
siam.BizPartnerId, |
|||
cbp.BizPartnerName, |
|||
siamd.RowCode, |
|||
siam.BillNo, |
|||
siamd.ProjectId, |
|||
siamd.CU_EstPayDate, |
|||
siamd.UnTransCheckBLAmtWTax, |
|||
siamd.HadTransCheckBLAmtWTax, |
|||
siamd.OAmountWithTax, |
|||
siamd.CU_MaterialId, |
|||
acb_tmp.BillNo2, |
|||
acb_tmp.RowCode2, |
|||
acb_tmp.checkOAmount, |
|||
asim.BillNo, |
|||
asim.InvoiceName, |
|||
asim.OAmountWithTax, |
|||
asi.InvoiceNo, |
|||
asi.InvoiceTime, |
|||
writeoff.BillDate |
|||
ORDER BY |
|||
siam.PersonId ASC, |
|||
siam.BillNo ASC, |
|||
siamd.RowCode ASC"; |
|||
|
|||
$query_T8 = $conn->query($sql); |
|||
$rows = $query_T8->fetchAll(PDO::FETCH_ASSOC); |
|||
$today = strtotime(date('Ymt')); |
|||
$table = ""; |
|||
for ($i = 0; $i < count($rows); $i++) { |
|||
$row = $rows[$i]; |
|||
$tmpname = $row['ProjectId'] . $row['RowCode']; |
|||
$data[$tmpname] = $row; |
|||
$data[$tmpname]['CU_EstPayDate'] = date('Y-m-d', strtotime($row['CU_EstPayDate'])); |
|||
$data[$tmpname]['havetopay'] = strtotime($row['CU_EstPayDate']) > $today ? '--' : 'V'; |
|||
$datahavetopay = $row['CU_EstPayDate'] > $today ? 0 : 1; |
|||
$data[$tmpname]['collecttime'] = collect_month(strtotime($row['CU_EstPayDate'])); |
|||
$invoicedate = is_null($row['InvoiceTime']) ? null : date('Y-m-d', strtotime($row['InvoiceTime'])); |
|||
$tableinvoice_state = is_null($invoicedate) ? 0 : 1; |
|||
$contract_no = $row['ProjectId']; |
|||
$facility_no = $row['CU_MaterialId']; |
|||
$RowCode = $row['RowCode']; |
|||
$BillNo = $row['BillNo']; |
|||
$receivable_date = date('Y-m-d', strtotime($row['CU_EstPayDate'])); |
|||
$budget = $row['OAmountWithTax']; |
|||
$invoiceNo = $row['InvoiceNo']; |
|||
$invoice_budget = is_null($row['InvoiceOAmount']) ? 0 : $row['InvoiceOAmount']; |
|||
$table_writeoff_date = is_null($row['WriteOffDate']) ? null : date('Y-m-d', strtotime($row['WriteOffDate'])); |
|||
$table_writeoff_amount = is_null($row['TotalCurrStandOffOAmount']) ? 0 : $row['TotalCurrStandOffOAmount']; |
|||
$table1 = "INSERT INTO account_receivable_maintainance( |
|||
`contract_no`, |
|||
`facility_no`, |
|||
`RowCode`, |
|||
`BillNo`, |
|||
`receivable_date`, |
|||
`budget`, |
|||
`receivable`, |
|||
`invoice_state`, |
|||
`invoice_budget`, |
|||
`received_budget` |
|||
"; |
|||
$table2 = ") VALUES( |
|||
'$contract_no', |
|||
'$facility_no', |
|||
'$RowCode', |
|||
'$BillNo', |
|||
'$receivable_date', |
|||
$budget, |
|||
$datahavetopay, |
|||
$tableinvoice_state, |
|||
$invoice_budget, |
|||
$table_writeoff_amount |
|||
"; |
|||
$table1 .= is_null($invoicedate) ? "" : ",`invoice_date`"; |
|||
$table2 .= is_null($invoicedate) ? "" : ",'$invoicedate'"; |
|||
$table1 .= is_null($table_writeoff_date) ? "" : ",`received_date`"; |
|||
$table2 .= is_null($table_writeoff_date) ? "" : ",'$table_writeoff_date'"; |
|||
$table1 .= is_null($invoiceNo) ? "" : ",`invoice_no`"; |
|||
$table2 .= is_null($invoiceNo) ? "" : ",'$invoiceNo'"; |
|||
$table .= $table1 . $table2 . "); \n"; |
|||
} |
|||
// $file_path = 'account_receivable_maintainance_sql.sql'; |
|||
// if (file_put_contents($file_path, $table) !== false) { |
|||
// echo "SQL文件已成功生成:{$file_path}"; |
|||
// } else { |
|||
// echo "生成SQL文件时出现错误。"; |
|||
// } |
|||
|
|||
// foreach ($data as $key => $row) { |
|||
// echo $key . "<br>"; |
|||
// print_r($row); |
|||
// echo "<br>------------<br>"; |
|||
// } |
|||
// exit(); |
|||
?> |
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 100%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
table { |
|||
width: 100%; |
|||
} |
|||
|
|||
#table_index_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
|
|||
.hiddenTable { |
|||
display: none; |
|||
} |
|||
|
|||
.hidden { |
|||
display: none; |
|||
} |
|||
</style> |
|||
|
|||
<div style="width: 98%;margin: 1%;"> |
|||
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;"> |
|||
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">下載 <span class="glyphicon glyphicon-download-alt"></span></button> |
|||
</div> |
|||
</div> |
|||
<div class="container"> |
|||
<div class="text-center" style="margin-bottom: 20px;"> |
|||
<h3><strong>應收帳款(保養)</strong></h3> |
|||
</div> |
|||
<hr> |
|||
<form class="form-horizontal" id='myForm' method='post' action='account-receivable-new-index.php?<?= $token_link ?>'> |
|||
<table class="table table-striped table-bordered" style='width:98%;text-align:center;margin:0 auto'> |
|||
<tbody> |
|||
<tr> |
|||
<th class="text-center" style="vertical-align: middle;">簽約日期</th> |
|||
<td colspan="2"> |
|||
<input type="date" class='form-control' id='date_Signstart' name='date_Signstart' style='width:40%;display:inline;'> |
|||
~ |
|||
<input type="date" class='form-control' id='date_Signend' name='date_Signend' style='width:40%;display:inline;'> |
|||
|
|||
</td> |
|||
<td rowspan="2"> |
|||
<button type="submit" class="btn btn-primary btn-sm">搜尋</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th class="text-center" style="vertical-align: middle;">合約日期</th> |
|||
<td colspan="2"> |
|||
<input type="date" class='form-control' id='date_start' name='date_start' style='width:40%;display:inline;'> |
|||
~ |
|||
<input type="date" class='form-control' id='date_end' name='date_end' style='width:40%;display:inline;'> |
|||
<!-- <button type="submit" class="btn btn-primary btn-sm">搜尋</button> --> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th class="text-center" style="vertical-align: middle;">催收次數</th> |
|||
<td colspan="3"> |
|||
<input type="text" class='form-control' id='search_collectstart' name='collect_time_start' style='width:30%;display:inline;' oninput="searchFront('collectstart')"> |
|||
≤ 催收次數 ≤ |
|||
<input type="text" class='form-control' id='search_collectend' name='collect_time_end' style='width:30%;display:inline;' oninput="searchFront('collectend')"> |
|||
<!-- <button type="submit" class="btn btn-primary btn-sm">搜尋</button> --> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<th class="text-center" style="vertical-align: middle;">催收金額</th> |
|||
<td colspan="3"> |
|||
<input type="text" class='form-control' id='search_CBudgetstart' name='collect_budget_start' style='width:30%;display:inline;' onblur="searchFront('CBudgetstart')"> |
|||
≤ 催收金額 ≤ |
|||
<input type="text" class='form-control' id='search_CBudgetend' name='collect_budget_end' style='width:30%;display:inline;' onblur="searchFront('CBudgetend')"> |
|||
<!-- <button type="submit" class="btn btn-primary btn-sm">搜尋</button> --> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</form> |
|||
<hr> |
|||
<div class="form-group"> |
|||
<div class="col-md-4"> |
|||
<label for="search_contract">查詢合約號</label> |
|||
<input type="text" id="search_contract" name="search_contract" class="form-control" placeholder="請輸入合約號" onblur="searchFront('contract')"> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<label for="search_dept">查詢部門</label> |
|||
<input type="text" id="search_dept" name="search_dept" class="form-control" placeholder="請輸入部門" onblur="searchFront('dept')"> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<label for="search_manager">查詢主管</label> |
|||
<input type="text" id="search_manager" name="search_manager" class="form-control" placeholder="請輸入主管工號/姓名" onblur="searchFront('manager')"> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="form-group"> |
|||
|
|||
<div class="col-md-4"> |
|||
<label for="search_personId">查詢契約員</label> |
|||
<input type="text" id="search_personId" name="search_personId" class="form-control" placeholder="請輸入契約員工號/姓名" onblur="searchFront('personId')"> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<label for="search_customerid">查詢客戶名稱</label> |
|||
<input type="text" id="search_customerid" name="search_customerid" class="form-control" placeholder="請輸入客戶名稱" onblur="searchFront('customerid')"> |
|||
</div> |
|||
<div class="col-md-4"> |
|||
<label for="search_facility">查詢作番號</label> |
|||
<input type="text" id="search_facility" name="search_facility" class="form-control" placeholder="請輸入作番號" onblur="searchFront('facility')"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<?php |
|||
include "./footer.php"; |
|||
?> |
|||
<div style="width: 20%;float:right;margin-right:5%; "> |
|||
<label>查詢條件</label> |
|||
<input type="text" id="search" name="search" class="form-control" placeholder="請輸入合約號/作番號/客戶名稱" oninput="searchData()"> |
|||
</div> |
|||
<div style="width: 98%; margin:1%;" style="overflow-x:auto;"> |
|||
<table class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align: middle;width:100px'>合約號</th> |
|||
<th style='text-align:center;vertical-align: middle;'>序號</th> |
|||
<th style='text-align:center;vertical-align: middle;width:100px'>作番號</th> |
|||
<th style='text-align:center;vertical-align: middle;width:110px'>部門</th> |
|||
<th style='text-align:center;vertical-align: middle;'>主管</th> |
|||
<th style='text-align:center;vertical-align: middle;'>契約員</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px'>客戶名稱</th> |
|||
|
|||
<th style='text-align:center;vertical-align: middle;'>應收日期</th> |
|||
<th style='text-align:center;vertical-align: middle;'>是否應收</th> |
|||
<th style='text-align:center;vertical-align: middle;'>應收金額</th> |
|||
<!-- |
|||
<th style='text-align:end;vertical-align: middle;'>已開金額</th> |
|||
<th style='text-align:end;vertical-align: middle;'>未開金額</th> --> |
|||
<th style='text-align:center;vertical-align: middle;'>已收金額</th> |
|||
<th style='text-align:center;vertical-align: middle;'>催收金額</th> |
|||
<th style='text-align:center;vertical-align: middle;'>催收次數</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $key => $row) { ?> |
|||
<tr class="data-row" style="display: '';" id="<?= $key; ?>"> |
|||
<td class="contract"><?= $row['ProjectId']; ?></td> |
|||
<td><?= $row['RowCode']; ?></td> |
|||
<td class="facility"><?= $row['CU_MaterialId']; ?></td> |
|||
<td class="dept"><?= $row['DeptId'] . "<br>" . $row['DeptName']; ?></td> |
|||
<td class="manager"><?= $row['LeaderId'] . "<br>" . $row['LeaderName']; ?></td> |
|||
<td class="personId"><?= $row['PersonId'] . "<br>" . $row['PersonName']; ?></td> |
|||
<td class="customerid"><?= $row['BizPartnerId'] . "<br>" . $row['BizPartnerName']; ?></td> |
|||
|
|||
<td><?= $row['CU_EstPayDate']; ?></td> |
|||
<td><?= $row['havetopay']; ?></td> |
|||
<td><?= number_format(round($row['OAmountWithTax'])); ?></td> |
|||
|
|||
<td><?= is_null($row['TotalCurrStandOffOAmount']) ? 0 : number_format(round($row['TotalCurrStandOffOAmount'])); ?></td> |
|||
<td class="CBudget"><?= ($row['havetopay'] == "V")? (number_format(round($row['OAmountWithTax'] - $row['TotalCurrStandOffOAmount']))) :0; ?></td> |
|||
<td class="collect"><?= (($row['havetopay'] == "V") && ($row['OAmountWithTax'] - $row['TotalCurrStandOffOAmount'] >1))? $row['collecttime']:0; ?></td> |
|||
</tr> |
|||
<?php } ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<script> |
|||
function searchData() { |
|||
var searchTerm = document.getElementById('search').value.toLowerCase(); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = rows[i].textContent.toLowerCase(); |
|||
// var rowText = rows[i].id.toLowerCase(); |
|||
if (rowText.includes(searchTerm)) { |
|||
console.log(rowText); |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} |
|||
|
|||
function downloadData() { |
|||
var xhr = new XMLHttpRequest(); |
|||
var url = window.location.origin + "/wms/account-receivable-renovate-excel.php?type=all&<?= $token_link ?>"; |
|||
xhr.open('POST', url, true); |
|||
xhr.setRequestHeader('Content-Type', 'application/json'); |
|||
xhr.onreadystatechange = function() { |
|||
if (xhr.readyState === 4 && xhr.status === 200) { |
|||
var file_path = xhr.responseText; |
|||
var link = document.createElement('a'); |
|||
var name = "汰改應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx"; |
|||
link.setAttribute('href', window.location.origin + "/wms/account-receivable-renovate.xlsx"); |
|||
link.setAttribute('download', name); |
|||
link.style.display = 'none'; |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
} |
|||
} |
|||
xhr.send(JSON.stringify({ |
|||
Bill: <?= $total_data ?> |
|||
})); |
|||
|
|||
} |
|||
|
|||
function searchFront(area) { |
|||
var term = 'search_' + area; |
|||
|
|||
if (area == 'collectstart') { |
|||
var searchTerm = parseInt(document.getElementById(term).value); |
|||
var searchArea = document.getElementsByClassName('collect'); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
var criterion = parseInt(document.getElementById('search_collectend').value); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = parseInt(searchArea[i].textContent); |
|||
if (rowText >= searchTerm) { |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
if (criterion !== '' && rowText > criterion) { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} else if (area == 'collectend') { |
|||
var searchTerm = parseInt(document.getElementById(term).value); |
|||
var searchArea = document.getElementsByClassName('collect'); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
var criterion = parseInt(document.getElementById('search_collectstart').value); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = parseInt(searchArea[i].textContent); |
|||
if (rowText <= searchTerm) { |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
if (criterion !== '' && rowText < criterion) { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} else if (area == 'CBudgetstart') { |
|||
var searchTerm = parseInt(document.getElementById(term).value); |
|||
var searchArea = document.getElementsByClassName('CBudget'); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
var criterion = parseInt(document.getElementById('search_CBudgetend').value); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = parseInt(searchArea[i].textContent.replace(/,/g, '')); |
|||
if (isNaN(searchTerm) || searchTerm == 0) { |
|||
rows[i].style.display = ''; |
|||
} else if (rowText >= searchTerm) { |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
if (criterion !== '' && rowText > criterion) { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} else if (area == 'CBudgetend') { |
|||
var searchTerm = parseInt(document.getElementById(term).value); |
|||
var searchArea = document.getElementsByClassName('CBudget'); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
var criterion = parseInt(document.getElementById('search_CBudgetstart').value); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = parseInt(searchArea[i].textContent.replace(/,/g, '')); |
|||
if (isNaN(searchTerm) || searchTerm == 0) { |
|||
rows[i].style.display = ''; |
|||
} else if (rowText <= searchTerm) { |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
if (!isNaN(criterion) && rowText < criterion) { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} else { |
|||
var searchTerm = document.getElementById(term).value.toLowerCase(); |
|||
var searchArea = document.getElementsByClassName(area); |
|||
var rows = document.getElementsByClassName('data-row'); |
|||
for (var i = 0; i < rows.length; i++) { |
|||
var rowText = searchArea[i].textContent.toLowerCase(); |
|||
if (rowText.includes(searchTerm)) { |
|||
rows[i].style.display = ''; |
|||
} else { |
|||
rows[i].style.display = 'none'; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
function check(searchname) { |
|||
console.log(searchname); |
|||
|
|||
} |
|||
</script> |
@ -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,400 @@ |
|||
<?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 = 1 ORDER BY a.id DESC"; |
|||
$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"); |
|||
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" 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/new_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/new_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/new_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/new_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=new&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%"> |
|||
<?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> |
|||
<?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) : |
|||
$bonus_json = json_decode($data['bonus_json']); |
|||
$bonus_kind = !empty($bonus_json->bonus_kind) ? $bonus_json->bonus_kind : ''; |
|||
$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><?php echo $bonus_type[$data['bonus_type']] . '-' . $bonus_kind ?></td> |
|||
<td><?= $data['bonus_verson'] ?></td> |
|||
<td><?= $fee_per_st ?></td> |
|||
<td><?= $total ?></td> |
|||
<td><?= $commission_fee ?></td> |
|||
<td><?= $data['receiver'] ?></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) { |
|||
// console.log(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', 'new'); |
|||
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() { |
|||
// $("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> |
@ -0,0 +1,311 @@ |
|||
<?php |
|||
/* 函數用法與參數 |
|||
【1.輸入參數:】 |
|||
獎金版本($ver):2.1 |
|||
契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) |
|||
作番契約金額($fee_per_st):3000元/月以下、3001-3499元/月、3500-3999元/月、4000元/月以上 |
|||
牌價($elevator_list_price):該電梯的合約發佈(標準)價+Option價格+與其他電梯共同分擔的費用貨價格 |
|||
該作番所佔的服務費金額($commission_fee) |
|||
合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) ; 契約折扣率=(簽約價格-服務費)/牌價 |
|||
總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, |
|||
付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) |
|||
第一筆保養款項應收回日($receivable_date_due, array) |
|||
契約員員工號($sales_id) |
|||
地區處長員工號($region_director_id) |
|||
專任契約經理員工號($regular_contract_manger_id) |
|||
|
|||
【2.函數中的變數說明】 |
|||
契約員獎金($sales_bonus) |
|||
地區處長獎金($region_director_bonus) |
|||
專任契約經理獎金($regular_contract_manger_bonus) |
|||
獎金預計發放比例($payment_ratio_due_array) |
|||
當次應發獎金($current_bonus) |
|||
獎金預計發放日($payday_due_array) |
|||
獎金預計發放規定($payday_due_regulation):合約簽回及保養款項收回的次月一次性發 |
|||
計算結果($result_status):success, error |
|||
獎金水庫(bonus_array)[ |
|||
bonus_type:獎金名稱, |
|||
bonus_receiver:發放人員, |
|||
bonus_amount:金額, |
|||
pay_day_due:預計發放時間 |
|||
bonus_regulation, 發放規定 |
|||
] |
|||
|
|||
【3.輸出數據】 |
|||
result_array[ |
|||
"ver"=>$ver, #獎金版本 |
|||
"result_status"=>"success", #計算結果 |
|||
"$bonus_array"=>$bonus_array #所有獎金水庫 |
|||
]; |
|||
|
|||
*/ |
|||
|
|||
|
|||
|
|||
function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '') |
|||
{ |
|||
$bonus_array = []; |
|||
if ($ver == "2.1") { |
|||
$discount = ($fee_per_st - $commission_fee) / $elevator_list_price; |
|||
#契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge) |
|||
switch ($contract_type) { |
|||
case "longcontract_m1_free_charge": |
|||
#契約員獎金($sales_bonus) |
|||
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59) |
|||
switch ($discount) { |
|||
case ($discount >= 0.8): |
|||
switch ($fee_per_st) { |
|||
case ($fee_per_st < 3000): |
|||
$sales_bonus = ($fee_per_st) * 0.6; |
|||
break; |
|||
case ($fee_per_st >= 3000 and $fee_per_st < 4000): |
|||
$sales_bonus = ($fee_per_st) * 0.7; |
|||
break; |
|||
case ($fee_per_st >= 4000 and $fee_per_st < 5000): |
|||
$sales_bonus = ($fee_per_st) * 0.8; |
|||
break; |
|||
case ($fee_per_st >= 5000 and $fee_per_st < 6000): |
|||
$sales_bonus = ($fee_per_st) * 0.9; |
|||
break; |
|||
case ($fee_per_st >= 6000): |
|||
$sales_bonus = ($fee_per_st) * 1.0; |
|||
break; |
|||
}; |
|||
break; |
|||
case ($discount >= 0.6 and $discount < 0.8): |
|||
switch ($fee_per_st) { |
|||
case ($fee_per_st < 3000): |
|||
$sales_bonus = ($fee_per_st) * 0.42; |
|||
break; |
|||
case ($fee_per_st >= 3000 and $fee_per_st <= 4000): |
|||
$sales_bonus = ($fee_per_st) * 0.49; |
|||
break; |
|||
case ($fee_per_st >= 4000 and $fee_per_st < 5000): |
|||
$sales_bonus = ($fee_per_st) * 0.56; |
|||
break; |
|||
case ($fee_per_st >= 5000 and $fee_per_st < 6000): |
|||
$sales_bonus = ($fee_per_st) * 0.63; |
|||
break; |
|||
case ($fee_per_st >= 6000): |
|||
$sales_bonus = ($fee_per_st) * 0.7; |
|||
break; |
|||
}; |
|||
break; |
|||
case ($discount < 0.6): |
|||
switch ($fee_per_st) { |
|||
case ($fee_per_st < 3000): |
|||
$sales_bonus = ($fee_per_st) * 0.3; |
|||
break; |
|||
case ($fee_per_st >= 3000 and $fee_per_st < 4000): |
|||
$sales_bonus = ($fee_per_st) * 0.35; |
|||
break; |
|||
case ($fee_per_st >= 4000 and $fee_per_st < 5000): |
|||
$sales_bonus = ($fee_per_st) * 0.4; |
|||
break; |
|||
case ($fee_per_st >= 5000 and $fee_per_st < 6000): |
|||
$sales_bonus = ($fee_per_st) * 0.45; |
|||
break; |
|||
case ($fee_per_st >= 6000): |
|||
$sales_bonus = ($fee_per_st) * 0.5; |
|||
break; |
|||
}; |
|||
break; |
|||
}; |
|||
|
|||
#地區處長獎金($region_director_bonus) |
|||
$region_director_bonus = 170; |
|||
#專任契約經理獎金($regular_contract_manger_bonus) |
|||
$regular_contract_manger_bonus = 300; |
|||
break; |
|||
}; |
|||
#付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually) |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "2", #獎金名稱 |
|||
"bonus_receiver" => $region_director_id, #發放人員 |
|||
"bonus_amount" => round($region_director_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 |
|||
"bonus_regulation" => "訂金收回後次月發放" #發放規定 |
|||
]); |
|||
|
|||
#專任契約經理獎金 |
|||
if ($regular_contract_manger_id != '') { |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "3", #獎金名稱 |
|||
"bonus_receiver" => $regular_contract_manger_id, #發放人員 |
|||
"bonus_amount" => round($regular_contract_manger_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間 |
|||
"bonus_regulation" => "訂金收回後次月發放" #發放規定 |
|||
]); |
|||
} |
|||
|
|||
#地區處長獎金、專任契約經理、契約員獎金 |
|||
switch ($payment_period) { |
|||
#簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金 |
|||
#總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期, |
|||
#年繳 |
|||
case 'annually': |
|||
$payment_ratio_due_array = array(); |
|||
$a = $payment_period_amount / 12; |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payment_ratio_due_array, 1 / $a); |
|||
} |
|||
|
|||
$payday_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payday_due_array, $i + 1); |
|||
} |
|||
|
|||
for ($i = 0; $i < count($payment_ratio_due_array); $i++) { |
|||
if ($i < count($payment_ratio_due_array) - 1) { |
|||
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 |
|||
} else { |
|||
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 |
|||
}; |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "1", #獎金名稱 |
|||
"bonus_receiver" => $sales_id, #發放人員 |
|||
"bonus_amount" => round($current_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間 |
|||
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定 |
|||
]); |
|||
} |
|||
|
|||
break; |
|||
#半年繳 |
|||
case 'semiannually': |
|||
$payment_ratio_due_array = array(); |
|||
$a = $payment_period_amount / 6; |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payment_ratio_due_array, 1 / $a); |
|||
} |
|||
|
|||
$payday_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payday_due_array, ($i + 1) * 6); |
|||
} |
|||
|
|||
for ($i = 0; $i < count($payment_ratio_due_array); $i++) { |
|||
if ($i < count($payment_ratio_due_array) - 1) { |
|||
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 |
|||
} else { |
|||
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 |
|||
}; |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "1", #獎金名稱 |
|||
"bonus_receiver" => $sales_id, #發放人員 |
|||
"bonus_amount" => round($current_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 |
|||
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定 |
|||
]); |
|||
} |
|||
break; |
|||
#季繳 |
|||
case 'quarterly': |
|||
$a = $payment_period_amount / 3; |
|||
$payment_ratio_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payment_ratio_due_array, 1 / $a); |
|||
} |
|||
|
|||
$payday_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payday_due_array, ($i + 1) * 4); |
|||
} |
|||
|
|||
for ($i = 0; $i < count($payment_ratio_due_array); $i++) { |
|||
if ($i < count($payment_ratio_due_array) - 1) { |
|||
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 |
|||
} else { |
|||
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 |
|||
}; |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "1", #獎金名稱 |
|||
"bonus_receiver" => $sales_id, #發放人員 |
|||
"bonus_amount" => round($current_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 |
|||
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 |
|||
]); |
|||
} |
|||
break; |
|||
#雙月繳 |
|||
case 'bimonthly': |
|||
$a = $payment_period_amount / 2; |
|||
$payment_ratio_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payment_ratio_due_array, 1 / $a); |
|||
} |
|||
|
|||
$payday_due_array = array(); |
|||
for ($i = 0; $i < $a; $i++) { |
|||
array_push($payday_due_array, ($i + 1) * 2); |
|||
} |
|||
|
|||
for ($i = 0; $i < count($payment_ratio_due_array); $i++) { |
|||
if ($i < count($payment_ratio_due_array) - 1) { |
|||
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 |
|||
} else { |
|||
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 |
|||
}; |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "1", #獎金名稱 |
|||
"bonus_receiver" => $sales_id, #發放人員 |
|||
"bonus_amount" => round($current_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 |
|||
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 |
|||
]); |
|||
} |
|||
break; |
|||
break; |
|||
#月繳 |
|||
case 'monthly': |
|||
|
|||
#產生契約員每個月的獎金應發比例 |
|||
$payment_ratio_due_array = array(); |
|||
for ($i = 0; $i < $payment_period_amount; $i++) { |
|||
array_push($payment_ratio_due_array, 1 / $payment_period_amount); |
|||
} |
|||
|
|||
$payday_due_array = array(); |
|||
for ($i = 0; $i < $payment_period_amount; $i++) { |
|||
array_push($payday_due_array, $i + 1); |
|||
} |
|||
|
|||
for ($i = 0; $i < count($payment_ratio_due_array); $i++) { |
|||
if ($i < count($payment_ratio_due_array) - 1) { |
|||
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額 |
|||
} else { |
|||
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額 |
|||
}; |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "1", #獎金名稱 |
|||
"bonus_receiver" => $sales_id, #發放人員 |
|||
"bonus_amount" => round($current_bonus), #金額 |
|||
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間 |
|||
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定 |
|||
]); |
|||
} |
|||
break; |
|||
} |
|||
|
|||
$result_array = [ |
|||
"ver" => $ver, #獎金版本 |
|||
"result_status" => "success", #計算結果 |
|||
"bonus_array" => $bonus_array #獎金水庫 |
|||
]; |
|||
} else { |
|||
array_push($bonus_array, [ |
|||
"bonus_type" => "error", #獎金名稱 |
|||
"bonus_receiver" => "error", #發放人員 |
|||
"bonus_amount" => 0, #金額 |
|||
"pay_day_due" => "9999-1-1", #預計發放時間 |
|||
"bonus_regulation" => "error" #發放規定 |
|||
]); |
|||
$result_array = [ |
|||
"ver" => $ver, #獎金版本 |
|||
"result_status" => "error", #計算結果 |
|||
"bonus_array" => $bonus_array #獎金水庫 |
|||
]; |
|||
} |
|||
|
|||
return $result_array; |
|||
}; |
@ -0,0 +1,398 @@ |
|||
[ |
|||
{ |
|||
"name": "MainSalesOrder", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "M23110121", |
|||
"BillDate": 20240313, |
|||
"TypeId": "SO", |
|||
"FOrgId": "1000", |
|||
"OrgId": "1000", |
|||
"ModeId": "M", |
|||
"BizPartnerId": "M23110121", |
|||
"CurrId": "TWD", |
|||
"CurrOAmount": 1, |
|||
"CurrLAmount": 1, |
|||
"PersonId": "M0042", |
|||
"DueToId": "M23110121", |
|||
"TradeConditionId": "", |
|||
"TaxId": "ST005", |
|||
"CreditorCompId": "1001", |
|||
"CreditorOrgId": "1000", |
|||
"CreatorId": "M0225" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name": "SubOrder", |
|||
"rows": [ |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00836" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00836" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00836", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00836" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00837" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00837" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00837", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00837" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00838" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00838" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00838", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00838" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00839" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00839" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00839", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00839" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00840" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00840" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00840", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00840" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00841" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00841" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00841", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00841" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00842" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00842" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00842", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00842" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40001", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 3904000, |
|||
"CU_MaterialId": "4MH00843" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"ItemType": 1, |
|||
"MaterialId": "A40008", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 976000, |
|||
"CU_MaterialId": "4MH00843" |
|||
}, |
|||
{ |
|||
"TaxId": "ST005", |
|||
"RequirementDate": 20240313, |
|||
"ConsignmentDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"ItemType": 0, |
|||
"MaterialId": "4MH00843", |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, |
|||
"SPrice": 0, |
|||
"CU_MaterialId": "4MH00843" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name": "salOrderStagePay", |
|||
"rows": [ |
|||
{ |
|||
"PayStage": "簽約", |
|||
"PlanPercentage": 0.2, |
|||
"PlanPayAmt": 976000, |
|||
"PlanPayDate": 20240413, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"UnWriteOffOAmount": 976000 |
|||
}, |
|||
{ |
|||
"PayStage": "二次款", |
|||
"PlanPercentage": 0.4, |
|||
"PlanPayAmt": 1952000, |
|||
"PlanPayDate": 20240313, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"UnWriteOffOAmount": 1952000 |
|||
}, |
|||
{ |
|||
"PayStage": "貨抵工地", |
|||
"PlanPercentage": 0.2, |
|||
"PlanPayAmt": 976000, |
|||
"PlanPayDate": 20241104, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 3, |
|||
"RowNo": 3, |
|||
"UnWriteOffOAmount": 976000 |
|||
}, |
|||
{ |
|||
"PayStage": "試車完工", |
|||
"PlanPercentage": 0.1, |
|||
"PlanPayAmt": 488000, |
|||
"PlanPayDate": 20241204, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 4, |
|||
"RowNo": 4, |
|||
"UnWriteOffOAmount": 488000 |
|||
}, |
|||
{ |
|||
"PayStage": "交車", |
|||
"PlanPercentage": 0.1, |
|||
"PlanPayAmt": 488000, |
|||
"PlanPayDate": 20250104, |
|||
"BillNo": "M23110121", |
|||
"RowCode": 5, |
|||
"RowNo": 5, |
|||
"UnWriteOffOAmount": 488000 |
|||
} |
|||
] |
|||
} |
|||
] |
@ -1,185 +1,66 @@ |
|||
[ |
|||
{ |
|||
"name": "salIncomeApplyMaster", |
|||
//salSalesOrder |
|||
"name": "MainSalesOrder", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"BillDate": "20240122", |
|||
"OrgId": "1000", |
|||
"BillNo": "Z001", //合約單號 |
|||
"BillDate": 20210420, //簽約日期 |
|||
"TypeId": "SO", // |
|||
"FOrgId": "1000", |
|||
"TypeId": "RAS", |
|||
"BpOrgId": "1000", |
|||
"BizPartnerId": "B23100060", |
|||
"OrgId": "1000", |
|||
"ModeId": "T", // T汰改 M新梯 |
|||
"BizPartnerId": "M0225", //創建人ID |
|||
"CurrId": "TWD", |
|||
"CurrOAmount": 1, |
|||
"CurrLAmount": 1, |
|||
"PersonId": "M0065", |
|||
"DtOrgId": "1000", |
|||
"DueToId": "B23100060", |
|||
"PersonId": "M0225", //業務人員 |
|||
"DueToId": "512", //業務部門 |
|||
"TradeConditionId": "", |
|||
"TaxId": "ST005", |
|||
"CompId": "1001", |
|||
"CreatorId": "M0225" |
|||
"CreditorCompId": "1000", |
|||
"CreditorOrgId": "1000", |
|||
"CreditorCurrOAmount": 1, |
|||
"CreditorCurrLAmount": 1, |
|||
"CompId": "1000" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name": "salIncomeApplyDetail", |
|||
// salSalesOrderDetail |
|||
"name": "SubOrder", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 3, |
|||
"RowNo": 3, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 4, |
|||
"RowNo": 4, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 5, |
|||
"RowNo": 5, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 6, |
|||
"RowNo": 6, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"SupplyCompId": "1001", |
|||
"SupplyOrgId": "1000", |
|||
"TaxId": "ST005", |
|||
"RowCode": 7, |
|||
"RowNo": 7, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 8, |
|||
"RowNo": 8, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 9, |
|||
"RowNo": 9, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 10, |
|||
"RowNo": 10, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 11, |
|||
"RowNo": 11, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
}, |
|||
"RequirementDate": 20210420, //出貨日期 |
|||
"ConsignmentDate": 20210420, //發貨日期 |
|||
"DispatchCompId": "1001", |
|||
"DispatchOrgId": "1000", |
|||
"BillNo": "Z001", //合約號 |
|||
"RowCode": 1, //全部筆數排列 |
|||
"ItemType": 0, |
|||
"MaterialId": "Z001", //作番號 |
|||
"SUnitId": "SET", |
|||
"SQuantity": 1, //交易數量 |
|||
"SPrice": 1 //交易價格 |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
//salOrderStagePay |
|||
"name": "salOrderStagePay", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"IncomeId": "A40003", |
|||
"TaxId": "ST005", |
|||
"RowCode": 12, |
|||
"RowNo": 12, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 1, |
|||
"ProjectId": "B23100060", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": "4TH53801" |
|||
"BillNo": "", |
|||
"RowCode": "", |
|||
"RowNo": "", |
|||
"PayStage": "ST003", //收款階段 |
|||
"PlanPercentage": "Z001", //計劃收款比例(%) |
|||
"PlanPayAmt": 1, //計劃收款金額 |
|||
"PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 |
|||
"UnWriteOffOAmount": 1 //未核銷金額 |
|||
} |
|||
] |
|||
} |
|||
|
@ -1,36 +1,257 @@ |
|||
<?php |
|||
?> |
|||
|
|||
<head> |
|||
<title>地址轉經緯度</title> |
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> |
|||
</head> |
|||
|
|||
<body> |
|||
<h1>輸入地址以獲取經緯度</h1> |
|||
<form id="addressForm" method="post"> |
|||
<input type="text" id="addressInput" name="address" placeholder="輸入地址"> |
|||
<button type="submit">查詢</button> |
|||
</form> |
|||
<div id="map"></div> |
|||
|
|||
<script> |
|||
// 使用AJAX提交表單 |
|||
$(document).ready(function() { |
|||
$("#addressForm").submit(function(event) { |
|||
event.preventDefault(); |
|||
var address = $("#addressInput").val(); |
|||
$.ajax({ |
|||
url: "get_lat_lng.php", |
|||
type: "POST", |
|||
data: { |
|||
address: address |
|||
}, |
|||
success: function(data) { |
|||
$("#map").html(data); |
|||
} |
|||
}); |
|||
}); |
|||
}); |
|||
</script> |
|||
</body> |
|||
|
|||
// { |
|||
// "BillNo": "Z001", //合約單號 |
|||
// "BillDate": 20210420, //簽約日期 |
|||
// "TypeId": "SO", // |
|||
// "FOrgId": "1000", |
|||
// "OrgId": "1000", |
|||
// "ModeId": "T", // T汰改 M新梯 |
|||
// "BizPartnerId": "M0225", //創建人ID |
|||
// "CurrId": "TWD", |
|||
// "CurrOAmount": 1, |
|||
// "CurrLAmount": 1, |
|||
// "PersonId": "M0225", //業務人員 |
|||
// "DueToId": "512", //業務部門 |
|||
// "TradeConditionId": "", |
|||
// "TaxId": "ST005", |
|||
// "CreditorCompId": "1000", |
|||
// "CreditorOrgId": "1000", |
|||
// "CreditorCurrOAmount": 1, |
|||
// "CreditorCurrLAmount": 1, |
|||
// "CompId": "1000" |
|||
// } |
|||
// ] |
|||
// }, |
|||
// { |
|||
// //salSalesOrderDetail |
|||
// "name": "SubOrder", |
|||
// "rows": [ |
|||
// { |
|||
// "SupplyCompId": "1001", |
|||
// "SupplyOrgId": "1000", |
|||
// "TaxId": "ST005", |
|||
// "RequirementDate": 20210420, //出貨日期 |
|||
// "ConsignmentDate": 20210420, //發貨日期 |
|||
// "DispatchCompId": "1001", |
|||
// "DispatchOrgId": "1000", |
|||
// "BillNo": "Z001", //合約號 |
|||
// "RowCode": 1, //全部筆數排列 |
|||
// "ItemType": 0, |
|||
// "MaterialId": "Z001", //作番號 |
|||
// "SUnitId": "SET", |
|||
// "SQuantity": 1, //交易數量 |
|||
// "SPrice": 1 //交易價格 |
|||
// } |
|||
// ] |
|||
// }, |
|||
// { |
|||
// "name": "salOrderStagePay", |
|||
// "rows": [ |
|||
// { |
|||
// "BillNo": "", |
|||
// "RowCode": "", |
|||
// "RowNo": "", |
|||
// "PayStage": "ST003", //收款階段 |
|||
// "PlanPercentage": "Z001", //計劃收款比例(%) |
|||
// "PlanPayAmt": 1, //計劃收款金額 |
|||
// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 |
|||
// "UnWriteOffOAmount": 1 //未核銷金額 |
|||
// } |
|||
// ] |
|||
// } |
|||
// ] |
|||
require_once("../../T8_Authorization_from_bpm.php"); |
|||
|
|||
$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; |
|||
|
|||
$validation = get_Auth(); |
|||
// $header = [ |
|||
// "CHI_Authorization :" . $validation, |
|||
// "GroupId:TEST" |
|||
// ]; |
|||
// $url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=M24020032"; |
|||
|
|||
// $ch = curl_init(); |
|||
// curl_setopt($ch, CURLOPT_URL, $url); |
|||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|||
// curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|||
// $response = curl_exec($ch); |
|||
// if ($response === false) { |
|||
// echo 'Curl error: ' . curl_error($ch); |
|||
// } else { |
|||
// $result = json_decode($response, true); |
|||
// // 若 API 傳入失敗。 |
|||
// if ($result['Status'] == 'Erroe') { |
|||
// echo 'API傳入失敗,' . $result['ErrorMsg']; |
|||
// print_r($result); |
|||
// } else { |
|||
// // print_r($result); |
|||
// print_r($result); |
|||
// } |
|||
// print_r($result); |
|||
// } |
|||
|
|||
// curl_close($ch); |
|||
// exit(); |
|||
$contract_no = "M24020003"; |
|||
// $contract_no = "M24010109"; |
|||
$MainSalesOrder_row = [ |
|||
"BillNo" => "$contract_no", //合約單號 |
|||
"BillDate" => 20210420, //簽約日期 |
|||
"TypeId" => "SO", // |
|||
"FOrgId" => "1000", |
|||
"OrgId" => "1000", |
|||
"ModeId" => "M", // T汰改 M新梯 |
|||
"BizPartnerId" => "$contract_no", //客戶代碼 |
|||
"CurrId" => "TWD", |
|||
"CurrOAmount" => 1, |
|||
"CurrLAmount" => 1, |
|||
"PersonId" => "M0177", //業務人員 |
|||
"DueToId" => "$contract_no", //債務方 |
|||
"TradeConditionId" => "", |
|||
"TaxId" => "ST005", |
|||
"CreditorCompId" => "1001", |
|||
"CreditorOrgId" => "1000", |
|||
"CreatorId" => "M0225" |
|||
|
|||
]; |
|||
// //salSalesOrderDetail |
|||
// $SubOrder_row = []; |
|||
for ($i = 0; $i < 3; $i++) { |
|||
if ($i == 0) { |
|||
$row = [ |
|||
// "SupplyCompId" => "1001", |
|||
// "SupplyOrgId" => "1000", |
|||
"TaxId" => "ST005", |
|||
"RequirementDate" => 20210420, //出貨日期 |
|||
"ConsignmentDate" => 20210420, //發貨日期 |
|||
// "DispatchCompId" => "1001", |
|||
// "DispatchOrgId" => "1000", |
|||
"BillNo" => "$contract_no", //合約號 |
|||
"RowCode" => $i, //全部筆數排列 |
|||
"ItemType" => 1, |
|||
"MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) |
|||
"SUnitId" => "SET", |
|||
"SQuantity" => 1, //交易數量 |
|||
"SPrice" => 100000 //交易價格 |
|||
]; |
|||
} |
|||
if ($i == 1) { |
|||
$row = [ |
|||
// "SupplyCompId" => "1001", |
|||
// "SupplyOrgId" => "1000", |
|||
"TaxId" => "ST005", |
|||
"RequirementDate" => 20210420, //出貨日期 |
|||
"ConsignmentDate" => 20210420, //發貨日期 |
|||
// "DispatchCompId" => "1001", |
|||
// "DispatchOrgId" => "1000", |
|||
"BillNo" => "$contract_no", //合約號 |
|||
"RowCode" => $i, //全部筆數排列 |
|||
"ItemType" => 1, |
|||
"MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) |
|||
"SUnitId" => "SET", |
|||
"SQuantity" => 1, //交易數量 |
|||
"SPrice" => 650000 //交易價格 |
|||
]; |
|||
} |
|||
if ($i == 2) { |
|||
$row = [ |
|||
"TaxId" => "ST005", |
|||
"RequirementDate" => 20210420, //出貨日期 |
|||
"ConsignmentDate" => 20210420, //發貨日期 |
|||
"BillNo" => "$contract_no", //合約號 |
|||
"RowCode" => $i, //全部筆數排列 |
|||
"ItemType" => 0, |
|||
"MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) |
|||
"SUnitId" => "SET", |
|||
"SQuantity" => 1, //交易數量 |
|||
"SPrice" => 0 //交易價格 |
|||
]; |
|||
} |
|||
$SubOrder_row[] = $row; |
|||
} |
|||
|
|||
|
|||
$salOrderStagePay_row = []; |
|||
$roww = [ |
|||
"PayStage" => "簽約", //收款階段 |
|||
"PlanPercentage" => 0.5, //計劃收款比例(%) |
|||
"PlanPayAmt" => 375000, //計劃收款金額 |
|||
"PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 |
|||
"BillNo" => "$contract_no", |
|||
"RowCode" => 1, |
|||
"RowNo" => 1, |
|||
"UnWriteOffOAmount" => 375000 //未核銷金額 |
|||
]; |
|||
$roww2 = [ |
|||
"PayStage" => "貨抵工地", |
|||
"PlanPercentage" => 0.5, |
|||
"PlanPayAmt" => 375000, |
|||
"PlanPayDate" => 20240101, |
|||
"BillNo" => "$contract_no", |
|||
"RowCode" => 2, |
|||
"RowNo" => 2, |
|||
"UnWriteOffOAmount" => 375000 |
|||
]; |
|||
$salOrderStagePay_row[] = $roww; |
|||
$salOrderStagePay_row[] = $roww2; |
|||
|
|||
|
|||
$MainSalesOrder = [ |
|||
"name" => "MainSalesOrder", |
|||
'rows' => [$MainSalesOrder_row] |
|||
]; |
|||
$SubOrder = [ |
|||
"name" => "SubOrder", |
|||
"rows" => $SubOrder_row |
|||
]; |
|||
$salOrderStagePay = [ |
|||
"name" => "salOrderStagePay", |
|||
"rows" => $salOrderStagePay_row |
|||
]; |
|||
|
|||
$APIbody = []; |
|||
$APIbody[] = $MainSalesOrder; |
|||
$APIbody[] = $SubOrder; |
|||
$APIbody[] = $salOrderStagePay; |
|||
// $data = file_get_contents('test copy.json'); |
|||
// $arr = json_decode($data, true); |
|||
// echo "<pre>"; |
|||
// print_r($data); |
|||
// echo "</pre>"; |
|||
|
|||
echo "<pre>"; |
|||
print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE)); |
|||
echo "</pre>"; |
|||
// exit(); |
|||
|
|||
$header = [ |
|||
"CHI_Authorization :" . $validation, |
|||
"GroupId:TEST" |
|||
]; |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|||
curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($APIbody, JSON_UNESCAPED_UNICODE)); |
|||
$response = curl_exec($ch); |
|||
|
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
$result = json_decode($response, true); |
|||
// 若 API 傳入失敗。 |
|||
if ($result['Status'] == 'Erroe') { |
|||
echo 'API傳入失敗,' . $result['ErrorMsg']; |
|||
print_r($result); |
|||
} else { |
|||
// print_r($result); |
|||
print_r($result); |
|||
} |
|||
print_r($result); |
|||
} |
|||
|
|||
curl_close($ch); |
|||
|
Loading…
Reference in new issue