You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

245 lines
9.0 KiB

<?php
include "header.php";
$BillNo = $_GET['BillNo'];
if ($cont['BillNo'] == 'M231067') {
$BillNo = 'SO20230801002';
}
// 合約收款款別名稱
$arrayData = [];
// echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>";
$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 comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.BillNo = '$BillNo'";
// T8發票
//M220478
$sql_invoice = "SELECT DISTINCT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState,
b.ProjectId
FROM arSellInvoice as a
LEFT JOIN arSellInvoiceMaterial as b
ON a.BillNo=b.BillNo
WHERE b.ProjectId='$BillNo'";
$contract = $conn->query($sql_contract);
$invoices = $conn->query($sql_invoice);
// foreach($contract as $con){
// print_r($con);
// echo "<br>";
// }
// foreach ($contract as $cont) {
// if ($cont['BillNo'] == 'SO20230801002') {
// $BillNo = 'M231067';
// }else{
// $BillNo = $cont['BillNo'];
// };
// $PayStage = $cont['PayStage'];
// $PayAmount = $cont['PlanPayAmt'];
// $partnerName = $cont['BizPartnerName'];
// if(isset($arrayData[$BillNo])){
// array_push($arrayData[$BillNo], $PayStage);
// array_push($arrayData[$BillNo], $PayAmount);
// }else{
// $arrayData[$BillNo][0] = $BillNo;
// $arrayData[$BillNo][1] = $partnerName;
// array_push($arrayData[$BillNo], $PayStage);
// array_push($arrayData[$BillNo], $PayAmount);
// }
// };
// foreach($arrayData as $data){
// foreach($data as $value){
// echo $value.";";
// }
// echo "</br>";
// }
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
</style>
<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 ($user_id == "M0122") {
?>
<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 style="width: 10%;">功能</th>
</tr>
</thead>
<tbody>
<?php if (!empty($invoices)) {
foreach ($invoices as $invoice) { ?>
<tr>
<td><?= $invoice['InvoiceNo'] ?></td>
<td><?= date('Y-m-d', strtotime(strval($invoice['InvoiceTime']))) ?></td>
<td><?= number_format($invoice['OAmountWithTax']) ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<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>
<?php } ?>
</td>
</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>