Browse Source

Merge branch 'main' into gary

gary
gary_chen\gary_chen 1 year ago
parent
commit
adc75b7f46
  1. 48
      .vscode/launch.json
  2. 251
      wms/account-receivable-check.php
  3. 250
      wms/account-receivable-index.php
  4. 124
      wms/account-receivable-received-create.php
  5. 142
      wms/account-receivable-received-edit.php
  6. 96
      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"
}
}
]
}

251
wms/account-receivable-check.php

@ -0,0 +1,251 @@
<?php
include "./header.php";
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$pay_received = mysqli_query($link, $sql_received);
$had_received_amount = intval(0);
$had_invoice_amount=intval(0);
$status_summary = intval(0);
if (mysqli_num_rows($pay_received) > 0) {
foreach ($pay_received as $received) {
$had_received_amount += intval($received['received_amount']);
$had_invoice_amount += intval($received['invoice_amount']);
if(in_array(intval($received['status']),array(0,4,5,99))){
$tem_status = intval(0);
}else{
$tem_status = intval($received['status']);
}
if($status_summary < $tem_status){
$status_summary = $tem_status;
}
}
}
$unreceived_amount = intval($Bill[12]) - intval($had_received_amount);
$uninvoice_amount = intval($Bill[12]) - intval($had_invoice_amount);
$Bill[19] =$had_invoice_amount;
$Bill[20] =$had_received_amount;
$Bill[21] =$uninvoice_amount;
$Bill[22] =$unreceived_amount;
$Bill[23] =$status_summary;
$data = json_encode($Bill);
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
</style>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span>
</a>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong><?= $Bill[4] ?></strong></h3>
</div>
<form class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="Manager">經理</label>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[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="<?= $Bill[14] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled>
</div>
</div>
<div>
<label for="detail">狀態</label>
<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;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>簽約款</th>
<th>二次款</th>
<th>貨抵工地款</th>
<th>安裝款</th>
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[5])) ?></td>
<td><?= number_format(round($Bill[6])) ?></td>
<td><?= number_format(round($Bill[7])) ?></td>
<td><?= number_format(round($Bill[8])) ?></td>
<td><?= number_format(round($Bill[9])) ?></td>
<td><?= number_format(round($Bill[10])) ?></td>
<td><?= number_format(round($Bill[11])) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
include "./footer.php";
?>
<?php
if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) {
?>
<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
}
?>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>發票日期</th>
<th>發票金額</th>
<th>發票號碼</th>
<th>收款日期</th>
<th>收款金額</th>
<th>備註</th>
<th>狀態</th>
<?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
<th style="width: 10%;">功能</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php if ($pay_received) {
foreach ($pay_received as $received) { ?>
<tr>
<td><?= $received['invoice_date'] ?></td>
<td><?= number_format($received['invoice_amount']) ?></td>
<td><?= $received['invoice_no'] ?></td>
<td><?= $received['received_date'] ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<td><?= $received['remark'] ?></td>
<td style="text-align: center;">
<?php
switch ($received['status']) {
case 0:
echo "<span style='color:blue;'>進行中</span>";
break;
case 1:
echo "<span style='color:brown;'>催收</span>";
break;
case 2:
echo "<span style='color:red;'>法務件 (發函)</span>";
break;
case 3:
echo "<span style='color:red;'>法務件 (訴訟)</span>";
break;
case 4:
echo "折讓";
break;
case 5:
echo "壞帳";
break;
case 99:
echo "完成";
break;
}
?></td>
<?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
<td>
<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> -->
</td>
<?php } ?>
</tr>
<?php }
} ?>
</tbody>
</table>
</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>

250
wms/account-receivable-index.php

@ -7,24 +7,58 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls;
//use PhpOffice\PhpSpreadsheet\Reader\Xls; //use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$follower = find_follow($user_id);
$arrayData = []; $arrayData = [];
$receivable_array = []; $receivable_array = [];
$received_array = [];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 //4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 //arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>"; $sql_received = "SELECT * from account_received";
// $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC); $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
// $sql_depid = "SELECT department_id, name from department";
// $dept_query = mysqli_query($link, $sql_depid);
// $deptype = mysqli_fetch_all($dept_query, MYSQLI_ASSOC);
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId 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); $contract = $conn->query($sql_contract);
// 取收款資料 account_received
$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'];
$received['status'] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
if ($received_array[$BillNo][2] < intval($received['status'])) {
$received_array[$BillNo][2] = intval($received['status']);
}
} else {
$received_array[$BillNo][0] = $received['invoice_amount'];
$received_array[$BillNo][1] = $received['received_amount'];
$received_array[$BillNo][2] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
}
}
foreach ($contract as $cont) { foreach ($contract as $cont) {
// print_r($cont); // print_r($cont);
// echo "<br>"; // echo "<br>";
@ -38,6 +72,9 @@ foreach ($contract as $cont) {
$PayStage = $cont['PayStage']; $PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt']; $PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName']; $partnerName = $cont['BizPartnerName'];
$EnterpriseName = $cont['EnterpriseName'];
$TaxNo = $cont['TaxNo'];
$ContactAddress = $cont['ContactAddress'];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 //4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
if (isset($arrayData[$BillNo])) { if (isset($arrayData[$BillNo])) {
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
@ -60,6 +97,9 @@ foreach ($contract as $cont) {
} else { } else {
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; $arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$arrayData[$BillNo][3] = $partnerName; $arrayData[$BillNo][3] = $partnerName;
$arrayData[$BillNo][13] = $EnterpriseName;
$arrayData[$BillNo][14] = $TaxNo;
$arrayData[$BillNo][15] = $ContactAddress;
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) { if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
$arrayData[$BillNo][5] = $PayAmount; $arrayData[$BillNo][5] = $PayAmount;
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) { } elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) {
@ -124,79 +164,153 @@ ON d.department_id = tmp2.department_id";
$official_num = 0; $official_num = 0;
$wipwhole_array = mysqli_query($link, $sql); $wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) { foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name']; $value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name']; $value[1] = $wip['manager_name'];
$value[2] = $wip['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) { if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$total_facility_num += 1; $total_facility_num += 1;
$arrive_num += 1; $arrive_num += 1;
$tryrun_num += 1; $tryrun_num += 1;
$official_num += 1; $official_num += 1;
$delivery_num += 1; $delivery_num += 1;
} elseif ($wip['official_check_date'] != NULL) { } elseif ($wip['official_check_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$total_facility_num += 1; $total_facility_num += 1;
$arrive_num += 1; $arrive_num += 1;
$tryrun_num += 1; $tryrun_num += 1;
$official_num += 1; $official_num += 1;
} elseif ($wip['tryrun_end_date'] != NULL) { } elseif ($wip['tryrun_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$total_facility_num += 1; $total_facility_num += 1;
$arrive_num += 1; $arrive_num += 1;
$tryrun_num += 1; $tryrun_num += 1;
} elseif ($wip['install_end_date'] != NULL) { } elseif ($wip['install_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$total_facility_num += 1; $total_facility_num += 1;
$arrive_num += 1; $arrive_num += 1;
} elseif ($wip['real_arrival_date'] != NULL) { } elseif ($wip['real_arrival_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$total_facility_num += 1; $total_facility_num += 1;
$arrive_num += 1; $arrive_num += 1;
} elseif ($wip['actual_tofactory_date'] != NULL) { } elseif ($wip['actual_tofactory_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) <br>";
$total_facility_num += 1; $total_facility_num += 1;
} elseif ($wip['estimated_shipping_date'] != NULL) { } elseif ($wip['estimated_shipping_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) , \n"; $facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>";
$total_facility_num += 1; $total_facility_num += 1;
} else { } else {
$facitities .= $wip['facilityno'] . " (預計到港日待確認) , \n"; $facitities .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$total_facility_num += 1; $total_facility_num += 1;
} }
} }
$receivable_budget = 0;
//這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車 //這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交 //這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
if ($total_facility_num > 0) { if ($total_facility_num > 0) {
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) + $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[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num)
+ ($value[10]) * ($delivery_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($received_array[$key][2])) {
$status = $received_array[$key][2];
} else {
$status = 0;
}
}
if (isset($key)) {
$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, $status
];
} }
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]);
// 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>";
} }
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>"; $data = json_encode($receivable_array);
//0 合約號; 1 部門; 2 經理; 3 營業員; 4 客戶名稱; 5 簽約款; 6 二次款; 7 貨底工地款; 8 安裝款; 9 式車款; 10 官檢款;
//11 交車款; 12 目前應收; 13 作番狀態; 14 抬頭; 15 統一編號; 16 聯絡地址; 17 部門id; 18 營業員id; 19 已開發票金額; 20 已收金額;
//21 未開發票金額; 22 未收金額; 23 狀態
?> ?>
<div id="account-receivable" style="overflow-x:auto;"> <style>
<table id="table_index" class="table table-striped table-bordered" style="width:100%;table-layout:fixed"> 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;
}
</style>
<div style="width:98%;margin:1%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead> <thead>
<tr> <tr>
<th style="width: 100px;">合約號</th> <th style="width: 120px;">合約號</th>
<th style="width: 150px;">部門</th> <th style="width: 120px;">部門</th>
<th style="width: 100px;">經理</th> <th style="width: 80px;">經理</th>
<th>營業員</th> <th style="width: 80px;">營業員</th>
<th>客戶名稱</th> <th>客戶名稱</th>
<th>簽約款</th> <!-- <th style="width: 100px;">簽約款</th>
<th>二次款</th> <th style="width: 100px;">二次款</th>
<th>貨抵工地款</th> <th style="width: 100px;">貨抵工地款</th>
<th>安裝款</th> <th style="width: 100px;">安裝款</th>
<th>試車款</th> <th style="width: 100px;">試車款</th>
<th>官檢款</th> <th style="width: 100px;">官檢款</th>
<th>交車款</th> <th style="width: 100px;">交車款</th> -->
<th>目前應收</th> <th style="width: 100px;">目前應收</th>
<th>狀態</th> <th style="width: 150px;">未開發票金額</th>
<th style="width: 100px;">未收金額</th>
<th>作番狀態</th>
<th style="width: 100px;">收款狀態</th>
<th style="width: 100px;">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -209,15 +323,28 @@ ON d.department_id = tmp2.department_id";
<td><?= $contract[2] ?></td> <td><?= $contract[2] ?></td>
<td><?= $contract[3] ?></td> <td><?= $contract[3] ?></td>
<td><?= $contract[4] ?></td> <td><?= $contract[4] ?></td>
<td><?= $contract[5] ?></td> <!-- <td><?= round($contract[5]) ?></td>
<td><?= $contract[6] ?></td> <td><?= round($contract[6]) ?></td>
<td><?= $contract[7] ?></td> <td><?= round($contract[7]) ?></td>
<td><?= $contract[8] ?></td> <td><?= round($contract[8]) ?></td>
<td><?= $contract[9] ?></td> <td><?= round($contract[9]) ?></td>
<td><?= $contract[10] ?></td> <td><?= round($contract[10]) ?></td>
<td><?= $contract[11] ?></td> <td><?= round($contract[11]) ?></td> -->
<td><?= $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 style="text-align: start;"><?= $contract[13] ?></td>
<td style="text-align: start;"><?php
if (in_array($contract[23], array(0, 4, 5))) {
echo "正常";
} elseif ($contract[23] == 1) {
echo "<span style='color:blue'>催收</span>";
} else {
echo "<span style='color:red'>法務件</span>";
}
?></td>
<td><button type="button" onclick="sendData('<?= $contract[0] ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
</td>
</tr> </tr>
<?php <?php
} }
@ -225,18 +352,21 @@ ON d.department_id = tmp2.department_id";
</tbody> </tbody>
</table> </table>
</div> </div>
<script>
function sendData(BillNo) {
console.log(BillNo);
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];
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();
<style> }
th{ </script>
word-wrap: break-word;
text-align: center;
}
td {
word-wrap: break-word;
text-align: center;
}
img {
width: 125px;
}
</style>

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

@ -0,0 +1,124 @@
<?php
include "./header.php";
$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] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</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);
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

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

@ -0,0 +1,142 @@
<?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>
<div class="form-group">
<div class="col-md-3">
<label for="status" style="color: red;">狀態</label>
<select id="status" name="status">
<option value=0 <?php if($pay['status'] == 0) echo "selected" ?>>進行中</option>
<option value=1 <?php if($pay['status'] == 1) echo "selected" ?>>催收</option>
<option value=2 <?php if($pay['status'] == 2) echo "selected" ?>>法務件 (發函)</option>
<option value=3 <?php if($pay['status'] == 3) echo "selected" ?>>法務件 (訴訟)</option>
<option value=4 <?php if($pay['status'] == 4) echo "selected" ?>>折讓</option>
<option value=5 <?php if($pay['status'] == 5) echo "selected" ?>>壞帳</option>
<option value=99 <?php if($pay['status'] == 99) echo "selected" ?>>完成</option>
</select>
</div>
</div>
<input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</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();
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

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

@ -0,0 +1,96 @@
<?php
include "./header.php";
$type = $_GET['type'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? '' : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = isset($_POST['InvoiceDate']) ? $_POST['InvoiceDate'] : '';
$Bill = $_POST['Bill'];
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
$received_date = isset($_POST['ReceivedDate']) ? $_POST['ReceivedDate'] : '';
$remark = isset($_POST['remark']) ? $_POST['remark'] : '';
if ($type == 'edit') {
$pay_id = $_POST['pay_id'];
$status = $_POST['status'];
$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',";
}
if ($status != $pay['status']) {
$sql1 .= "status = $status,";
}
// $sql1 = substr($sql1, 0, -1);
$sql = $sql1 . "LastOperatorId = '$user_id' WHERE pay_id = $pay_id";
} 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 (isset($InvoiceNo)) {
$sql1 .= ",invoice_no";
$sql2 .= ",'$InvoiceNo'";
}
if ((!empty($InvoiceDate))) {
$sql1 .= ",invoice_date";
$sql2 .= ",'$InvoiceDate'";
}
if (isset($invoice_amount)) {
$sql1 .= ",invoice_amount";
$sql2 .= ",$invoice_amount";
}
if (isset($received_amount)) {
$sql1 .= ",received_amount";
$sql2 .= ",$received_amount";
}
if (!(empty($received_date))) {
$sql1 .= ",received_date";
$sql2 .= ",'$received_date'";
}
if (!(empty($remark))) {
$sql1 .= ",remark";
$sql2 .= ",'$remark'";
}
$sql = $sql1 . $sql2 . ",'$user_id')";
}
mysqli_query($link, $sql);
?>
<script>
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();
</script>

2
wms/rib01-check.php

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

Loading…
Cancel
Save