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.
557 lines
24 KiB
557 lines
24 KiB
<?php
|
|
|
|
include "header.php";
|
|
|
|
|
|
$sum_total_budget = 0;
|
|
$start_date = empty($_POST['date_start']) ? null : $_POST['date_start'];
|
|
$end_date = empty($_POST['date_end']) ? null : $_POST['date_end'];
|
|
|
|
|
|
/* 比較應收日期
|
|
@param $a array
|
|
@param $b array
|
|
return int */
|
|
function comparePlanPayDate($a, $b)
|
|
{
|
|
return strtotime($a['PlanPayDate']) - strtotime($b['PlanPayDate']);
|
|
}
|
|
|
|
// 查WMS 契約員主管
|
|
$sql_manager = "SELECT A.accountid, A.name, A.manager, B.name AS manager_name FROM account AS A
|
|
LEFT JOIN account AS B ON A.manager = B.accountid ";
|
|
$managers = mysqli_query($link, $sql_manager);
|
|
|
|
$find_manager = array();
|
|
if (is_iterable($managers)) {
|
|
foreach ($managers as $manager) {
|
|
$find_manager[$manager['accountid']] = $manager;
|
|
}
|
|
}
|
|
$follower = find_follow($user_id);
|
|
$arrayData = array();
|
|
$receivable_array = [];
|
|
// T8所有合約號
|
|
$sql_contractNumber = "SELECT MainAll.* ,
|
|
Person.PersonName,
|
|
Dept.DeptName FROM
|
|
(SELECT
|
|
Main.BillNo,
|
|
Main.BillDate,
|
|
Main.BizPartnerId,
|
|
Biz.ShortName,
|
|
Biz.BizPartnerName,
|
|
Biz.ContactAddress,
|
|
Main.OAmountWithTax,
|
|
Main.PersonId,
|
|
Main.DeptId,
|
|
Main.TypeId,
|
|
Main.CurrentState
|
|
FROM salSalesOrder AS Main
|
|
LEFT JOIN comBusinessPartner AS Biz ON Biz.BizPartnerId = Main.BizPartnerId) AS MainAll
|
|
LEFT JOIN comGroupPerson AS Person ON MainAll.PersonId= Person.PersonId
|
|
LEFT JOIN comDepartment AS Dept ON MainAll.DeptId= Dept.DeptId
|
|
WHERE MainAll.TypeId = 'SP' AND (MainAll.CurrentState=2 OR MainAll.CurrentState=4) ";
|
|
if (!is_null($start_date)) {
|
|
$start_date = (int)date('Ymd', strtotime($start_date));
|
|
$sql_contractNumber .= " AND MainAll.BillDate >= $start_date ";
|
|
}
|
|
if (!is_null($end_date)) {
|
|
$end_date = (int)date('Ymd', strtotime($end_date));
|
|
$sql_contractNumber .= " AND MainAll.BillDate <= $end_date ";
|
|
}
|
|
if ((in_array($user_id, array('M0008', 'M0012'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '501')))) {
|
|
} else {
|
|
$sql_contractNumber .= " AND (MainAll.PersonId = '$user_id'";
|
|
if (count($follower) > 0) {
|
|
$column_str = "('$user_id'" . ",'";
|
|
$column_str .= implode("','", $follower);
|
|
$column_str .= "')";
|
|
$sql_contractNumber .= " OR MainAll.PersonId IN $column_str)";
|
|
} else {
|
|
$sql_contractNumber .= ")";
|
|
};
|
|
}
|
|
|
|
$contractNumbers = array();
|
|
$query_contract_number = $conn->query($sql_contractNumber);
|
|
if (is_iterable($query_contract_number)) {
|
|
foreach ($query_contract_number as $contract_numbers) {
|
|
array_push($contractNumbers, $contract_numbers['BillNo']);
|
|
$arrayData[$contract_numbers['BillNo']]['BillNo'] = isset($contract_numbers['BillNo']) ? $contract_numbers['BillNo'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['BillDate'] = isset($contract_numbers['BillDate']) ? $contract_numbers['BillDate'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['CustomerId'] = isset($contract_numbers['BizPartnerId']) ? $contract_numbers['BizPartnerId'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['CustomerName'] = isset($contract_numbers['BizPartnerName']) ? $contract_numbers['BizPartnerName'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['CustomerAddress'] = isset($contract_numbers['ContactAddress']) ? $contract_numbers['ContactAddress'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['OAmountWithTax'] = isset($contract_numbers['OAmountWithTax']) ? $contract_numbers['OAmountWithTax'] : 0;
|
|
$arrayData[$contract_numbers['BillNo']]['PersonId'] = isset($contract_numbers['PersonId']) ? $contract_numbers['PersonId'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['DeptId'] = isset($contract_numbers['DeptId']) ? $contract_numbers['DeptId'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['PersonName'] = isset($contract_numbers['PersonName']) ? $contract_numbers['PersonName'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['DeptName'] = isset($contract_numbers['DeptName']) ? $contract_numbers['DeptName'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['ShortName'] = isset($contract_numbers['ShortName']) ? $contract_numbers['ShortName'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerId'] = !empty($find_manager[$contract_numbers['PersonId']]['manager']) ? $find_manager[$contract_numbers['PersonId']]['manager'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['ManagerName'] = !empty($find_manager[$contract_numbers['PersonId']]['manager_name']) ? $find_manager[$contract_numbers['PersonId']]['manager_name'] : '--';
|
|
$arrayData[$contract_numbers['BillNo']]['invoice_budget'] = 0;
|
|
$arrayData[$contract_numbers['BillNo']]['received_budget'] = 0;
|
|
$arrayData[$contract_numbers['BillNo']]['receivable_budget'] = 0;
|
|
$arrayData[$contract_numbers['BillNo']]['detail'] = "";
|
|
$sum_total_budget += $contract_numbers['OAmountWithTax'];
|
|
}
|
|
$str_numbers = "('" . implode("','", $contractNumbers) . "')";
|
|
}
|
|
|
|
// T8發票
|
|
$sql_invoice = "SELECT
|
|
Detail.BillNo AS InvoiceBillNo,
|
|
Detail.MaterialId,
|
|
Detail.LAmountWithTax,
|
|
Main.InvoiceNo,
|
|
CheckAll.FromSalSalesOrder AS BillNo
|
|
FROM arSellInvoiceMaterial AS Detail
|
|
LEFT JOIN arSellInvoice AS Main ON Detail.BillNo=Main.BillNo
|
|
LEFT JOIN (
|
|
SELECT CheckDetail.BillNo, CheckDetail.FromSalSalesOrder, CheckDetail.RowNo
|
|
FROM arCheckBillDetail AS CheckDetail )
|
|
AS CheckAll ON CheckAll.BillNo= Detail.FromBillNo AND Detail.FromRowCode = CheckAll.RowNo
|
|
WHERE Detail.ItemType=0 AND Main.InvoiceState!=2";
|
|
|
|
// T8核銷
|
|
$sql_received = "SELECT
|
|
CheckDetail.OrderBillNo,
|
|
arWriteOffBillDetail.FromBillNo AS CheckBillNo,
|
|
arWriteOffBillDetail.FromRowCode AS CheckRowCode,
|
|
arWriteOffBillDetail.CurrStandOffOAmount
|
|
FROM arWriteOffBillDetail
|
|
LEFT JOIN
|
|
(SELECT
|
|
arCheckBillDetail.BillNo,
|
|
arCheckBillDetail.RowCode,
|
|
arCheckBillDetail.FromSalSalesOrder AS OrderBillNo,
|
|
salSalesOrder.TypeId
|
|
FROM arCheckBillDetail
|
|
LEFT JOIN salSalesOrder
|
|
ON salSalesOrder.BillNo =arCheckBillDetail.FromSalSalesOrder )
|
|
AS CheckDetail
|
|
ON CheckDetail.BillNo=arWriteOffBillDetail.FromBillNo AND arWriteOffBillDetail.FromRowCode = CheckDetail.RowCode
|
|
WHERE CheckDetail.TypeId = 'SP'";
|
|
|
|
|
|
//T8 銷售訂單 階段收款計畫
|
|
$sql_paystage = "SELECT * from salOrderStagePay";
|
|
if (isset($str_numbers)) {
|
|
$sql_paystage .= " WHERE BillNo IN $str_numbers ";
|
|
$sql_invoice .= " AND CheckAll.FromSalSalesOrder IN $str_numbers ";
|
|
}
|
|
|
|
// T8 銷售訂單 表身
|
|
$sql_detail ="SELECT
|
|
A.BillNo,
|
|
A.MaterialId,
|
|
salSalesOrder.TypeId,
|
|
CASE
|
|
WHEN A.ItemType = 0 THEN B.MaterialName
|
|
WHEN A.ItemType = 1 THEN C.FeeTypeName
|
|
ELSE 'Unknown'
|
|
END AS ItemName,
|
|
E.ProjectId,
|
|
E.ProjectName,
|
|
D.MaterialId AS CU_MaterialId,
|
|
D.MaterialName AS CU_MaterialName
|
|
FROM
|
|
salSalesOrderDetail A
|
|
LEFT JOIN
|
|
comMaterialGroup B ON A.MaterialId = B.MaterialId AND A.ItemType = 0
|
|
LEFT JOIN
|
|
comFeeType C ON A.MaterialId = C.FeeTypeId AND A.ItemType = 1
|
|
LEFT JOIN
|
|
comProject E ON A.ProjectId = E.ProjectId
|
|
LEFT JOIN
|
|
comMaterialGroup D ON A.CU_MaterialId = D.MaterialId
|
|
LEFT JOIN
|
|
salSalesOrder ON A.BillNo = salSalesOrder.BillNo
|
|
WHERE salSalesOrder.TypeId = 'SP'";
|
|
|
|
|
|
$PayStage = $conn->query($sql_paystage);
|
|
$received_array = $conn->query($sql_received);
|
|
$invoice_data = $conn->query($sql_invoice);
|
|
$detail_data = $conn->query($sql_detail);
|
|
|
|
// 將合約表身明細填入arrayData
|
|
foreach ($detail_data as $detail) {
|
|
if(isset($arrayData[$detail['BillNo']])) {
|
|
$memo = $detail['MaterialId'].' '.$detail['ItemName'].' 【'.$detail['ProjectId'].$detail['ProjectName'].'】'.'['.$detail['CU_MaterialId'].' '.$detail['CU_MaterialName'].'] ; <br>';
|
|
$arrayData[$detail['BillNo']]['detail'] .= $memo;
|
|
}
|
|
}
|
|
|
|
|
|
$allPayStages = array();
|
|
foreach ($PayStage as $stage) {
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayAmt'] = $stage['PlanPayAmt'];
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['PlanPayDate'] = $stage['PlanPayDate'];
|
|
$month = collect_month(strtotime($stage['PlanPayDate']));
|
|
if (strtotime($stage['PlanPayDate']) > strtotime(date('Y-m-t', strtotime('now')))) {
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = '--';
|
|
} else {
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['receivable_ornot'] = 'Y';
|
|
}
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['month'] = $month;
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['received'] = 0;
|
|
$allPayStages[$stage['BillNo']][$stage['PayStage']]['invoice'] = 0;
|
|
}
|
|
foreach ($allPayStages as $paykey => $pay) {
|
|
uasort($allPayStages[$paykey], 'comparePlanPayDate');
|
|
}
|
|
|
|
foreach ($allPayStages as &$payStage) {
|
|
$sequenceNumber = 1;
|
|
foreach ($payStage as $tk => &$pstage) {
|
|
$pstage['sequenceNumber'] = $sequenceNumber;
|
|
$sequenceNumber += 1;
|
|
}
|
|
}
|
|
// 整理好的收款階段
|
|
$final_paystage = array();
|
|
foreach ($allPayStages as $key => &$payStage) {
|
|
if (is_iterable($payStage)) {
|
|
foreach ($payStage as $key2 => $pstage) {
|
|
if (isset($arrayData[$key])) {
|
|
$arrayData[$key]['PayStage'][$pstage['sequenceNumber']] = $pstage;
|
|
if (isset($pstage['receivable_ornot']) && $pstage['receivable_ornot'] == 'Y') {
|
|
$arrayData[$key]['receivable_budget'] += $pstage['PlanPayAmt'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($invoice_data as $inv) {
|
|
if (isset($arrayData[$inv['BillNo']])) {
|
|
|
|
$arrayData[$inv['BillNo']]['invoice_budget'] += $inv['LAmountWithTax'];
|
|
|
|
if (isset($arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']])) {
|
|
$arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] += $inv['LAmountWithTax'];
|
|
} else {
|
|
$arrayData[$inv['BillNo']]['invoice'][$inv['InvoiceNo']] = $inv['LAmountWithTax'];
|
|
}
|
|
}
|
|
}
|
|
foreach ($received_array as $received) {
|
|
if (isset($arrayData[$received['OrderBillNo']]) && isset($received['CurrStandOffOAmount']) && $received['CurrStandOffOAmount'] > 0) {
|
|
$arrayData[$received['OrderBillNo']]['received_budget'] += $received['CurrStandOffOAmount'];
|
|
}
|
|
}
|
|
//未在T8的收款資料
|
|
$sql_wms = "SELECT * FROM account_received WHERE type='Z' ";
|
|
$query_wms = mysqli_query($link, $sql_wms);
|
|
foreach ($query_wms as $wms) {
|
|
if (isset($arrayData[$wms['BillNo']]) && isset($wms['invoice_budget']) && isset($wms['invoice_no']) && isset($arrayData[$wms['BillNo']]['invoice_budget'])) {
|
|
$arrayData[$wms['BillNo']]['invoice_budget'] += $wms['invoice_budget'];
|
|
if (isset($arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']])) {
|
|
$arrayData[$wms['BillNo']]['invoice'][$wms['invoice_no']] += $wms['invoice_budget'];
|
|
}
|
|
}
|
|
if (isset($arrayData[$wms['BillNo']]) && isset($wms['received_budget']) && isset($arrayData[$wms['BillNo']]['received_budget'])) {
|
|
$arrayData[$wms['BillNo']]['received_budget'] += $wms['received_budget'];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
foreach ($arrayData as $key => &$value) {
|
|
if (!isset($value['PayStage'])) {
|
|
$value['receivable_budget'] = $value['OAmountWithTax'];
|
|
} else {
|
|
$tmpReceived = $value['received_budget'];
|
|
$tmpInvoice = $value['invoice_budget'];
|
|
if (is_iterable($value['PayStage'])) {
|
|
for ($sequence = 1; $sequence <= count($value['PayStage']); $sequence++) {
|
|
if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpInvoice) {
|
|
$value['PayStage'][$sequence]['invoice'] = $tmpInvoice;
|
|
$tmpInvoice = 0;
|
|
} else {
|
|
$value['PayStage'][$sequence]['invoice'] = $value['PayStage'][$sequence]['PlanPayAmt'];
|
|
$tmpInvoice -= $value['PayStage'][$sequence]['PlanPayAmt'];
|
|
}
|
|
if ($value['PayStage'][$sequence]['PlanPayAmt'] > $tmpReceived) {
|
|
$value['PayStage'][$sequence]['received'] = $tmpReceived;
|
|
$tmpReceived = 0;
|
|
} else {
|
|
$value['PayStage'][$sequence]['received'] = $value['PayStage'][$sequence]['PlanPayAmt'];
|
|
$tmpReceived -= $value['PayStage'][$sequence]['PlanPayAmt'];
|
|
}
|
|
}
|
|
}
|
|
$value['received_budget'] = $tmpReceived;
|
|
}
|
|
if ($value['receivable_budget'] > 0 && $value['received_budget'] < $value['receivable_budget']) {
|
|
$value['month'] = collect_month(strtotime($value['BillDate']));
|
|
} else {
|
|
$value['month'] = 0;
|
|
}
|
|
}
|
|
|
|
$excel_aray = array();
|
|
$print_array = array();
|
|
|
|
foreach ($arrayData as $key => $value) {
|
|
$uninvoice_budget = $value['OAmountWithTax'] - $value['invoice_budget'];
|
|
$unreceive_budget = $value['receivable_budget'] - $value['received_budget'];
|
|
$collect_month = $value['month']==0? '0':$value['month'];
|
|
|
|
$excel_aray[$key] = [
|
|
$value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'],
|
|
$value['DeptName'], $value['PersonId'], $value['PersonName'],
|
|
$value['ManagerId'], $value['ManagerName'],
|
|
number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])),
|
|
number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)),
|
|
number_format(round($value['received_budget'])), $unreceive_budget, $collect_month, $value['detail']
|
|
];
|
|
|
|
if ($excel_aray[$key][14] > 1) {
|
|
$print_array[$key] = [
|
|
$value['BillNo'], date('Y-m-d', strtotime($value['BillDate'])), $value['CustomerId'], $value['CustomerName'],
|
|
$value['DeptName'], $value['PersonId'], $value['PersonName'],
|
|
$value['ManagerId'], $value['ManagerName'],
|
|
number_format(round($value['OAmountWithTax'])), number_format(round($value['receivable_budget'])),
|
|
number_format(round($value['invoice_budget'])), number_format(round($uninvoice_budget)),
|
|
number_format(round($value['received_budget'])), $unreceive_budget, $collect_month, $value['detail']
|
|
];
|
|
}
|
|
}
|
|
|
|
$total_data = json_encode($print_array);
|
|
|
|
?>
|
|
<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>
|
|
<form class="form-horizontal" id='myForm' method='post' action='account-receivable-repair-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_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="2">
|
|
<input type="text" class="form-control" id="sum_total_budget" name="sum_total_budget" value="<?= number_format($sum_total_budget) ?> 元" disabled>
|
|
</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="請輸入合約號" oninput="searchFront('contract')">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="search_customerid">查詢客戶編號</label>
|
|
<input type="text" id="search_customerid" name="search_customerid" class="form-control" placeholder="請輸入客戶編號" oninput="searchFront('customerid')">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="search_customername">查詢客戶名稱</label>
|
|
<input type="text" id="search_customername" name="search_customername" class="form-control" placeholder="請輸入客戶名稱" oninput="searchFront('customername')">
|
|
</div>
|
|
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-md-4">
|
|
<label for="search_department">查詢部門</label>
|
|
<input type="text" id="search_department" name="search_department" class="form-control" placeholder="請輸入部門" oninput="searchFront('department')">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="search_personId">查詢契約員</label>
|
|
<input type="text" id="search_personId" name="search_personId" class="form-control" placeholder="請輸入契約員工號/姓名" oninput="searchFront('personId')">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label for="search_manager">查詢主管</label>
|
|
<input type="text" id="search_manager" name="search_manager" class="form-control" placeholder="請輸入主管工號/姓名" oninput="searchFront('manager')">
|
|
</div>
|
|
</div>
|
|
<!-- <div class="form-group">
|
|
<div class="col-md-2">
|
|
<input type="text" id="search_manager" name="search_manager" class="form-control" placeholder="請輸入主管工號/姓名" oninput="searchFront('manager')">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<input class="form-control" value="催收次數" disabled>
|
|
</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:140px'>合約號</th>
|
|
<th style='text-align:center;vertical-align: middle;width:100px'>合約日期</th>
|
|
<th style='text-align:center;vertical-align: middle;width:100px'>部門</th>
|
|
<th style='text-align:center;vertical-align: middle;width:100px'>主管</th>
|
|
<th style='text-align:center;vertical-align: middle;width:100px'>保養員</th>
|
|
<th style='text-align:center;vertical-align: middle;width:140px'>客戶</th>
|
|
<!-- <th style='text-align:center;vertical-align: middle;width:140px'>客戶名稱</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: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:center;vertical-align: middle;'>催收次數</th>
|
|
<th style='text-align:center;vertical-align: middle;width:350px'>內容 <br> 產品 【專案】[作番號]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($excel_aray as $key => $row) { ?>
|
|
|
|
<tr class="data-row" style="display: '';" id="<?= $key; ?>">
|
|
<td style='text-align:center;vertical-align: middle;' class="contract"><?= $row[0]; ?></td>
|
|
<td style='text-align:center;vertical-align: middle;' class="contractdate"><?= $row[1]; ?></td>
|
|
<td style='text-align:center;vertical-align: middle;' class="department"><?= $row[4] ?></td>
|
|
<td style='text-align:center;vertical-align: middle;' class="manager"><?= $row[7] . "<br>" . $row[8]; ?></td>
|
|
<td style='text-align:center;vertical-align: middle;' class="personId"><?= $row[5] . "<br>" . $row[6]; ?></td>
|
|
<td style='text-align:center;vertical-align: middle;' class="customerid"><?= $row[2] . "<br>".$row[3] ?></td>
|
|
<!-- <td style='text-align:center;vertical-align: middle;' class="customername"><?= $row[3] ?></td> -->
|
|
|
|
<td style='text-align:end;vertical-align: middle;' class="total_budget"><?= $row[9]; ?></td>
|
|
<td style='text-align:end;vertical-align: middle;' class="receivable_budget"><?= $row[10]; ?></td>
|
|
<!-- <td style='text-align:end;vertical-align: middle;' class="invoice_budget"><?= $row[11]; ?></td>
|
|
<td style='text-align:end;vertical-align: middle;' class="un_invoice_budget"><?= $row[12]; ?></td> -->
|
|
<td style='text-align:end;vertical-align: middle;' class="received_budget"><?= $row[13]; ?></td>
|
|
<td style='text-align:end;vertical-align: middle;' class="un_received_budget"><?= $row[14]; ?></td>
|
|
<td style='text-align:end;vertical-align: middle;' class="collect_month"><?= $row[15]; ?></td>
|
|
<td style='text-align:end;vertical-align: middle;' class="collect_content"><?= $row[16]; ?></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();
|
|
if (rowText.includes(searchTerm)) {
|
|
console.log(rowText);
|
|
rows[i].style.display = '';
|
|
} else {
|
|
rows[i].style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
|
|
function searchFront(area) {
|
|
var term = 'search_' + area;
|
|
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 downloadData() {
|
|
var xhr = new XMLHttpRequest();
|
|
var url = window.location.origin + "/wms/account-receivable-renovate-excel.php?type=repair&<?= $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-repair.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 check(searchname) {
|
|
console.log(searchname);
|
|
|
|
}
|
|
</script>
|