Browse Source

Merge branch 'main' into cheng

main
Cheng 1 year ago
parent
commit
4011e624a8
  1. 48
      .vscode/launch.json
  2. 70
      wms/account-receivable-check.php
  3. 86
      wms/account-receivable-index.php
  4. 121
      wms/account-receivable-received-create.php
  5. 121
      wms/account-receivable-received-edit.php
  6. 84
      wms/account-receivable-received-submit.php
  7. 2
      wms/rib01-check.php

48
.vscode/launch.json

@ -0,0 +1,48 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}

70
wms/account-receivable-check.php

@ -3,7 +3,7 @@ include "./header.php";
//企業名稱 統一編號 聯絡地址
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]'";
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$pay_received = mysqli_query($link, $sql_received);
$had_received = 0;
if (mysqli_num_rows($pay_received) == 0) {
@ -11,8 +11,8 @@ if (mysqli_num_rows($pay_received) == 0) {
$had_received += $received['received_amount'];
}
}
// echo $Bill[2];
$unreceived = $Bill[12] - $had_received;
$data = json_encode($Bill);
?>
<style>
th {
@ -75,6 +75,30 @@ if (mysqli_num_rows($pay_received) == 0) {
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>目前應收</th>
<th>已開發票金額</th>
<th>未開發票金額</th>
<th>已收金額</th>
<th>未收金額</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($Bill[19])) ?></td>
<td><?= number_format(round($Bill[21])) ?></td>
<td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td>
</tr>
</tbody>
</table>
</div>
<div style="width: auto; margin-top: 30px;">
@ -88,8 +112,6 @@ if (mysqli_num_rows($pay_received) == 0) {
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
<th>目前應收</th>
<th>已收金額</th>
</tr>
</thead>
@ -102,8 +124,6 @@ if (mysqli_num_rows($pay_received) == 0) {
<td><?= number_format(round($Bill[9])) ?></td>
<td><?= number_format(round($Bill[10])) ?></td>
<td><?= number_format(round($Bill[11])) ?></td>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($had_received)) ?></td>
</tr>
</tbody>
@ -117,9 +137,8 @@ include "./footer.php";
<?php
if ($user_id == "M0122") {
?>
<a href="account-receivable-received-create.php?BillNo=<?= $Bill[0] ?>&<?= $token_link ?>" class="btn btn-info btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span>
</a>
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button>
<?php
}
?>
@ -141,11 +160,12 @@ if ($user_id == "M0122") {
<tr>
<td><?= $received['invoice_date'] ?></td>
<td><?= number_format($received['invoice_amount']) ?></td>
<td><?= $received['receive_date'] ?></td>
<td><?= $received['received_date'] ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<td><?php if ($user_id == "M0122") { ?><a href="account-receivable-received-edit.php.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-warning btn-sm">
<span class=" glyphicon glyphicon-pencil"></span>
</a>
<td><?= $received['remark'] ?></td>
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
<span class="glyphicon glyphicon-pencil"></span></button>
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
@ -156,4 +176,24 @@ if ($user_id == "M0122") {
} ?>
</tbody>
</table>
</div>
</div>
<script>
function create(type,pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
if(type === 'create'){
form.action = "account-receivable-received-create.php?<?= $token_link ?>";
}else{
form.action = "account-receivable-received-edit.php?pay_id="+pay_id+"&<?= $token_link ?>";
}
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(BillData);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
</script>

86
wms/account-receivable-index.php

@ -7,25 +7,51 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls;
//use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$follower = find_follow($user_id);
$arrayData = [];
$receivable_array = [];
$received_array = [];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>";
// $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC);
// $sql_depid = "SELECT department_id, name from department";
// $dept_query = mysqli_query($link, $sql_depid);
// $deptype = mysqli_fetch_all($dept_query, MYSQLI_ASSOC);
$sql_received = "SELECT * from account_received";
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName,
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName, s.PersonId,
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_contract .= "AND (s.PersonId = '$user_id'";
$sql_received .= " WHERE person_id = '$user_id'";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$sql_contract .= " OR s.PersonId IN $column_str)";
$sql_received .= " OR person_id IN $column_str)";
} else {
$sql_contract .= ")";
};
}
$contract = $conn->query($sql_contract);
$received_data = mysqli_query($link, $sql_received);
foreach ($received_data as $received) {
if ($received['BillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
} elseif ($received['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
} else {
$BillNo = $received['BillNo'];
};
if (isset($received_array[$BillNo])) {
$received_array[$BillNo][0] += $received['invoice_amount'];
$received_array[$BillNo][1] += $received['received_amount'];
} else {
$received_array[$BillNo][0] = $received['invoice_amount'];
$received_array[$BillNo][1] = $received['received_amount'];
}
}
foreach ($contract as $cont) {
// print_r($cont);
// echo "<br>";
@ -131,11 +157,11 @@ ON d.department_id = tmp2.department_id";
$official_num = 0;
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name'];
$value[2] = $wip['name'];
$value[16] = isset($wip['department_id']) ? $wip['department_id'] : '';
$value[17] = isset($wip['salesid']) ? $wip['salesid'] : '';
if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$total_facility_num += 1;
@ -173,17 +199,35 @@ ON d.department_id = tmp2.department_id";
$total_facility_num += 1;
}
}
$receivable_budget=0;
$receivable_budget = 0;
//這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
if ($total_facility_num > 0) {
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) +
($value[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num)
+ ($value[10]) * ($delivery_num / $total_facility_num);
$uninvoice_budget = $receivable_budget;
$unreceived_budget = $receivable_budget;
$received_invoice = 0;
$received_budget = 0;
if (isset($received_array[$key][0])) {
$uninvoice_budget = $receivable_budget - $received_array[$key][0];
$received_invoice = $received_array[$key][0];
}else{
$uninvoice_budget = $receivable_budget;
}
if (isset($received_array[$key][1])) {
$unreceived_budget = $receivable_budget - $received_array[$key][1];
$received_budget = $received_array[$key][1];
}else{
$unreceived_budget = $receivable_budget;
}
}
if (isset($value[0]) && ($value[0] != 0)) {
$receivable_array[$key] = [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9],
$value[10], $receivable_budget, $facitities, $value[13], $value[14], $value[15], $value[16], $value[17], $received_invoice, $received_budget,
$uninvoice_budget, $unreceived_budget];
}
// array_push($receivable_array, [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9], $value[10], $receivable_budget, $facitities]);
$receivable_array[$key] = [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9], $value[10], $receivable_budget, $facitities, $value[13],$value[14],$value[15]];
// echo $key . ";" . $value[0] . ";" . $value[1] . ";" . $value[2] . ";" . $value[3] . ";" . $value[4] . ";" . $value[5] . ";" . $value[6] . ";" . $value[7] . ";" . $value[8] . ";" . $value[9].";" . $value[10] . ";" . $receivable_budget . ";" . $total_facility_num . ";" . $arrive_num . ";". $tryrun_num . ";" .$official_num.";". $delivery_num . ";" . $facitities . "<br>";
}
$data = json_encode($receivable_array);
@ -242,7 +286,9 @@ $data = json_encode($receivable_array);
<th style="width: 100px;">試車款</th>
<th style="width: 100px;">官檢款</th>
<th style="width: 100px;">交車款</th> -->
<th style="width: 150px;">目前應收</th>
<th style="width: 100px;">目前應收</th>
<th style="width: 150px;">未開發票金額</th>
<th style="width: 100px;">未收金額</th>
<th>狀態</th>
<th style="width: 100px;">操作</th>
</tr>
@ -264,7 +310,9 @@ $data = json_encode($receivable_array);
<td><?= round($contract[9]) ?></td>
<td><?= round($contract[10]) ?></td>
<td><?= round($contract[11]) ?></td> -->
<td><?= number_format(round($contract[12])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[12])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[21])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[22])) ?></td>
<td style="text-align: start;"><?= $contract[13] ?></td>
<td><button type="button" onclick="sendData('<?= $contract[0] ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
</td>
@ -292,6 +340,6 @@ $data = json_encode($receivable_array);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
</script>

121
wms/account-receivable-received-create.php

@ -1,4 +1,121 @@
<?php
include "./header.php";
$BillNo = $_GET['BillNo'];
echo $BillNo;
$Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true);
?>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div>
</div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3>
<h4>新增收款資訊</h4>
</div>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=create&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptName">部門</label>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="ManagerName">經理</label>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" >
</div>
<div class="col-md-3">
<label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" >
</div>
<div class="col-md-3">
<label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" >
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" >
</div>
<div class="col-md-3">
<label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" >
</div>
<div class="col-md-3">
<label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark" >
</div>
</div>
<input type="hidden" name="DeptId" value="<?= $BillData[17] ?>">
<input type="hidden" name="PersonId" value="<?= $BillData[18] ?>">
<input type="hidden" name="CustName" value="<?= $BillData[4] ?>">
</div>
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
</div>
</div>
</form>
</div>
<script>
function backToIndex() {
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function send() {
event.preventDefault();
$("#BillNo").prop("disabled", false);
$("#DeptName").prop("disabled", false);
$("#ManagerName").prop("disabled", false);
$("#PersonName").prop("disabled", false);
$("#pay_received").submit();
}
</script>

121
wms/account-receivable-received-edit.php

@ -0,0 +1,121 @@
<?php
include "./header.php";
$Bill = $_POST['Bill'];
$BillData = json_decode($Bill, true);
$pay_id = $_GET['pay_id'];
// echo $pay_id."<br>";
// print_r($BillData);
$sql_pay = "SELECT * from account_received where pay_id = '$pay_id'";
$pay = mysqli_query($link, $sql_pay);
$pay = mysqli_fetch_assoc($pay);
?>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div>
</div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3>
<h4>編輯收款資訊</h4>
</div>
<form class="form-horizontal" id="pay_received" method="POST" action="account-receivable-received-submit.php?type=edit&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group" style="margin-left: 1%;margin-right: 1%;">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $BillData[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptName">部門</label>
<input type="text" class="form-control" id="DeptName" name="DeptName" value="<?= $BillData[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="ManagerName">經理</label>
<input type="text" class="form-control" id="ManagerName" name="ManagerName" value="<?= $BillData[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $BillData[3] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $BillData[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $BillData[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $BillData[16] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" value="<?= $pay['invoice_date'] ?>">
</div>
<div class="col-md-3">
<label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" value="<?= $pay['invoice_amount'] ?>">
</div>
<div class="col-md-3">
<label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" value="<?= $pay['invoice_no'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" value="<?= $pay['received_date'] ?>">
</div>
<div class="col-md-3">
<label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" value="<?= $pay['received_amount'] ?>">
</div>
<div class="col-md-3">
<label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark" value="<?= $pay['remark'] ?>">
</div>
</div>
<input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>">
</div>
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
<button type="button" onclick="send()" class="btn btn-primary btn-lg pull-right">送出</button>
</div>
</div>
</form>
</div>
<script>
function backToIndex() {
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function send() {
event.preventDefault();
$("#pay_received").submit();
}
</script>

84
wms/account-receivable-received-submit.php

@ -0,0 +1,84 @@
<?php
include "./header.php";
$type = $_GET['type'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? NULL : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = empty($_POST['InvoiceDate']) ? NULL: $_POST['InvoiceDate'];
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
$received_date = empty($_POST['ReceivedDate']) ? NULL : $_POST['ReceivedDate'];
$remark = empty($_POST['remark']) ? '' : $_POST['remark'];
if ($type == 'edit') {
$pay_id = $_POST['pay_id'];
$sql_query_pay = "SELECT * from account_received where pay_id = $pay_id";
$pay = mysqli_query($link, $sql_query_pay);
$pay = mysqli_fetch_assoc($pay);
$sql1 = "UPDATE account_received SET ";
if ($InvoiceNo !== $pay['invoice_no']) {
$sql1.="invoice_no = '$InvoiceNo',";
}
if($InvoiceDate !== $pay['invoice_date']){
$sql1.="invoice_date = '$InvoiceDate',";
}
if($invoice_amount != $pay['invoice_amount']){
$sql1.="invoice_amount = $invoice_amount,";
}
if($received_amount != $pay['received_amount']){
$sql1.="received_amount = $received_amount,";
}
if($received_date !== $pay['received_date']){
$sql1.="received_date = '$received_date',";
}
if($remark !== $pay['remark']){
$sql1.="remark = '$remark',";
}
$sql1=substr($sql1,0,-1);
$sql = $sql1 . " WHERE pay_id = $pay_id";
echo $sql;
exit();
} else {
$BillNo = $_POST['BillNo'];
$dept_id = $_POST['DeptId'];
$dept_name = $_POST['DeptName'];
$manager_name = $_POST['ManagerName'];
$person_id = $_POST['PersonId'];
$person_name = $_POST['PersonName'];
$cust_name = $_POST['CustName'];
$sql1 = "INSERT INTO account_received (
BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name";
$sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'";
if (!empty($InvoiceNo)) {
$sql1 .= ",invoice_no";
$sql2 .= ",'$InvoiceNo'";
}
if (isset($InvoiceDate)) {
$sql1 .= ",invoice_date";
$sql2 .= ",'$InvoiceDate'";
}
if (!empty($invoice_amount)) {
$sql1 .= ",invoice_amount";
$sql2 .= ",$invoice_amount";
}
if (!empty($received_amount)) {
$sql1 .= ",received_amount";
$sql2 .= ",$received_amount";
}
if (isset($received_date)) {
$sql1 .= ",received_date";
$sql2 .= ",'$received_date'";
}
if (!empty($remark)) {
$sql1 .= ",remark";
$sql2 .= ",'$remark'";
}
$sql = $sql1 . $sql2 . ",'$user_id')";
}
mysqli_query($link, $sql);
if (mysqli_affected_rows($link)) {
echo '<script>alert("新增/更新 成功")</script>';
echo $sql;
} else {
echo '<script>alert("新增/更新 失敗")</script>';
}

2
wms/rib01-check.php

@ -107,7 +107,7 @@ elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) :
</p>
</div>
<?php
elseif ($state == 1 && ($user_id == "M0056" || $user_id == "M0209")) :
elseif ($state == 1) :
?>
<div style="padding-left: 2rem;">

Loading…
Cancel
Save