Browse Source

應收帳款(新梯)系統index跟check

gary
Ellin 1 year ago
parent
commit
e7c1311974
  1. 159
      wms/account-receivable-check.php
  2. 145
      wms/account-receivable-index.php
  3. 4
      wms/account-receivable-received-create.php

159
wms/account-receivable-check.php

@ -0,0 +1,159 @@
<?php
include "./header.php";
//企業名稱 統一編號 聯絡地址
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]'";
$pay_received = mysqli_query($link, $sql_received);
$had_received = 0;
if (mysqli_num_rows($pay_received) == 0) {
foreach ($pay_received as $received) {
$had_received += $received['received_amount'];
}
}
// echo $Bill[2];
?>
<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>
<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>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($had_received)) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
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>
<?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 style="width: 10%;">功能</th>
</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['receive_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>
<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>
<?php } ?>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>

145
wms/account-receivable-index.php

@ -20,7 +20,8 @@ $receivable_array = [];
// $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
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName,
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) ";
@ -38,6 +39,9 @@ foreach ($contract as $cont) {
$PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
$EnterpriseName = $cont['EnterpriseName'];
$TaxNo = $cont['TaxNo'];
$ContactAddress = $cont['ContactAddress'];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
if (isset($arrayData[$BillNo])) {
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
@ -60,6 +64,9 @@ foreach ($contract as $cont) {
} else {
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$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')) {
$arrayData[$BillNo][5] = $PayAmount;
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) {
@ -130,42 +137,43 @@ ON d.department_id = tmp2.department_id";
$value[1] = $wip['manager_name'];
$value[2] = $wip['name'];
if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) , \n";
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$total_facility_num += 1;
$arrive_num += 1;
$tryrun_num += 1;
$official_num += 1;
$delivery_num += 1;
} 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;
$arrive_num += 1;
$tryrun_num += 1;
$official_num += 1;
} 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;
$arrive_num += 1;
$tryrun_num += 1;
} 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;
$arrive_num += 1;
} 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;
$arrive_num += 1;
} 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;
} 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;
} else {
$facitities .= $wip['facilityno'] . " (預計到港日待確認) , \n";
$facitities .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$total_facility_num += 1;
}
}
$receivable_budget=0;
//這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
if ($total_facility_num > 0) {
@ -173,30 +181,70 @@ ON d.department_id = tmp2.department_id";
($value[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num)
+ ($value[10]) * ($delivery_num / $total_facility_num);
}
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]);
// 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);
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>";
?>
<div id="account-receivable" style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;table-layout:fixed">
<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;
}
</style>
<div style="width:98%;margin:1%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th style="width: 100px;">合約號</th>
<th style="width: 150px;">部門</th>
<th style="width: 100px;">經理</th>
<th>營業員</th>
<th style="width: 120px;">合約號</th>
<th style="width: 120px;">部門</th>
<th style="width: 80px;">經理</th>
<th style="width: 80px;">營業員</th>
<th>客戶名稱</th>
<th>簽約款</th>
<th>二次款</th>
<th>貨抵工地款</th>
<th>安裝款</th>
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
<th>目前應收</th>
<!-- <th style="width: 100px;">簽約款</th>
<th style="width: 100px;">二次款</th>
<th style="width: 100px;">貨抵工地款</th>
<th style="width: 100px;">安裝款</th>
<th style="width: 100px;">試車款</th>
<th style="width: 100px;">官檢款</th>
<th style="width: 100px;">交車款</th> -->
<th style="width: 150px;">目前應收</th>
<th>狀態</th>
<th style="width: 100px;">操作</th>
</tr>
</thead>
<tbody>
@ -209,15 +257,17 @@ ON d.department_id = tmp2.department_id";
<td><?= $contract[2] ?></td>
<td><?= $contract[3] ?></td>
<td><?= $contract[4] ?></td>
<td><?= $contract[5] ?></td>
<td><?= $contract[6] ?></td>
<td><?= $contract[7] ?></td>
<td><?= $contract[8] ?></td>
<td><?= $contract[9] ?></td>
<td><?= $contract[10] ?></td>
<td><?= $contract[11] ?></td>
<td><?= $contract[12] ?></td>
<!-- <td><?= round($contract[5]) ?></td>
<td><?= round($contract[6]) ?></td>
<td><?= round($contract[7]) ?></td>
<td><?= round($contract[8]) ?></td>
<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: 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>
</tr>
<?php
}
@ -225,18 +275,23 @@ ON d.department_id = tmp2.department_id";
</tbody>
</table>
</div>
<script>
function sendData(BillNo) {
console.log(BillNo);
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];
console.log(Bill);
console.log(typeof(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();
<style>
th{
word-wrap: break-word;
text-align: center;
}
td {
word-wrap: break-word;
text-align: center;
}
img {
width: 125px;
}
</style>
</script>

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

@ -0,0 +1,4 @@
<?php
include "./header.php";
$BillNo = $_GET['BillNo'];
echo $BillNo;
Loading…
Cancel
Save