14 changed files with 1321 additions and 436 deletions
@ -0,0 +1,31 @@ |
|||||
|
<?php |
||||
|
require_once dirname(__FILE__) . "/../mkt/database.php"; |
||||
|
include "fun_global.php"; |
||||
|
|
||||
|
// AJAX 顯示合約明細 |
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
if ($_POST['form_name'] == 'showDetail') { |
||||
|
$billno = $_POST['billno']; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
siad.IncomeId, |
||||
|
cft.FeeTypeName, |
||||
|
FLOOR(siad.SQuantity) AS SQuantity, |
||||
|
FLOOR(siad.SPrice) AS SPrice, |
||||
|
FLOOR(siad.OAmount) AS OAmount, |
||||
|
FLOOR(siad.OTax) AS OTax, |
||||
|
FLOOR(siad.OAmountWithTax) AS OAmountWithTax, |
||||
|
siad.ProjectId, |
||||
|
siad.CU_MaterialId, |
||||
|
siad.CU_EstPayDate |
||||
|
FROM salIncomeApplyDetail AS siad |
||||
|
LEFT JOIN comFeeType AS cft |
||||
|
ON siad.IncomeId = cft.FeeTypeId |
||||
|
WHERE BillNo = '$billno' |
||||
|
ORDER BY siad.CU_EstPayDate ASC |
||||
|
"; |
||||
|
$result = $conn->query($sql); |
||||
|
$data = $result->fetchAll(PDO::FETCH_ASSOC); |
||||
|
echo json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
||||
|
} |
@ -0,0 +1,291 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
include "header.php"; |
||||
|
include "css/view/wipwhole-index.php"; |
||||
|
|
||||
|
// 設置一個空陣列來放資料 |
||||
|
$data = array(); |
||||
|
$contractno = empty($_POST['contractno']) ? null : $_POST['contractno']; |
||||
|
$department_id = accountidToDepartId($user_id); |
||||
|
|
||||
|
if (in_array(accountidToDepartId($user_id), ['220'])) { |
||||
|
$sql_cmd = " WHERE 1=1 "; |
||||
|
} else { |
||||
|
$sql_cmd = sql_myself($user_id, "cgp.PersonId"); |
||||
|
} |
||||
|
|
||||
|
// 合約主檔 |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
siam.BillNo, -- 單據號 |
||||
|
siad_tmp.ProjectId,-- 合約號 |
||||
|
siam.BillDate, -- 合約日期 |
||||
|
BizPartnerName, -- 客戶名稱 |
||||
|
cp.PersonId, -- 業務人員 |
||||
|
cgp.PersonName, -- 業務人員名稱 |
||||
|
cd.DeptName, -- 業務人員部門 |
||||
|
siam.UnTransAmount -- 合約金額 |
||||
|
-- siad_tmp2.Max_CU_EstPayDate -- 最後收款日期 |
||||
|
FROM salIncomeApplyMaster AS siam |
||||
|
LEFT JOIN ( |
||||
|
SELECT |
||||
|
cc.BizPartnerId, |
||||
|
cbp.BizPartnerName |
||||
|
FROM comCustomer AS cc |
||||
|
LEFT JOIN comBusinessPartner AS cbp |
||||
|
ON cc.BizPartnerId = cbp.BizPartnerId |
||||
|
)cb_tmp |
||||
|
ON cb_tmp.BizPartnerId = siam.BizPartnerId |
||||
|
LEFT JOIN comPerson AS cp -- 員工主檔 |
||||
|
ON siam.PersonId = cp.PersonId |
||||
|
LEFT JOIN comGroupPerson AS cgp -- 員工明細檔 |
||||
|
ON cp.PersonId = cgp.PersonId |
||||
|
LEFT JOIN comDepartment AS cd -- 部門主檔 |
||||
|
ON cp.DeptId = cd.DeptId |
||||
|
LEFT JOIN |
||||
|
( |
||||
|
SELECT DISTINCT |
||||
|
siad.BillNo, |
||||
|
siad.ProjectId |
||||
|
FROM salIncomeApplyDetail AS siad |
||||
|
WHERE siad.ProjectId != '' |
||||
|
AND siad.ProjectId IS NOT NULL |
||||
|
)AS siad_tmp -- 合約明細 |
||||
|
ON siam.BillNo = siad_tmp.BillNo |
||||
|
LEFT JOIN |
||||
|
( |
||||
|
SELECT |
||||
|
siad.BillNo, |
||||
|
MAX(siad.CU_EstPayDate) as Max_CU_EstPayDate |
||||
|
FROM salIncomeApplyDetail AS siad |
||||
|
GROUP BY siad.BillNo |
||||
|
)AS siad_tmp2 -- 合約明細2 |
||||
|
ON siam.BillNo = siad_tmp.BillNo |
||||
|
$sql_cmd |
||||
|
AND siam.CurrentState = '2' |
||||
|
"; |
||||
|
if (!empty($contractno)) { |
||||
|
$sql .= " AND siad_tmp.ProjectId = '$contractno' "; |
||||
|
} |
||||
|
// echo "<pre>"; |
||||
|
// echo $sql; |
||||
|
// echo "</pre>"; |
||||
|
// exit; |
||||
|
|
||||
|
$data = $conn->query($sql); |
||||
|
if ($data) : |
||||
|
?> |
||||
|
|
||||
|
<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 id="myModal" class="modal"> |
||||
|
<div class="back"></div> |
||||
|
<div class="modal-content"> |
||||
|
<button type="button" class="close" id="myCloseBtn">X</button> |
||||
|
<div class='col-12' style='text-align:center'> |
||||
|
<div class='row'> |
||||
|
<div class='col-12'> |
||||
|
<table id="table_detail" class="table table-bordered" style="width:100%; margin:0 auto;"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>收入代碼</th> |
||||
|
<th>收入名稱</th> |
||||
|
<th>數量</th> |
||||
|
<th>單價</th> |
||||
|
<th>金額(未稅)</th> |
||||
|
<th>稅金</th> |
||||
|
<th>含稅金額</th> |
||||
|
<th>專案代碼</th> |
||||
|
<th>作番號</th> |
||||
|
<th>預計請款日</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
|
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div style="overflow-x:auto;"> |
||||
|
<form id='myForm' method='post' action='contract_b-index.php?<?= $token_link ?>'> |
||||
|
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<td colspan="5"> |
||||
|
<h3 style='text-align:center'>保養合約管理</h3> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<th style='text-align:center;vertical-align: middle;'>合約號</th> |
||||
|
<td style='text-align:center;vertical-align: middle;'> |
||||
|
<input type="text" class='form-control' id='contractno' name='contractno' value=""> |
||||
|
</td> |
||||
|
<td style='text-align:left;vertical-align: middle;'> |
||||
|
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</form> |
||||
|
</div> |
||||
|
|
||||
|
<div style="overflow-x:auto;"> |
||||
|
<a href="contract/contract-input.php?function_name=contract-input&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
||||
|
<span class="glyphicon glyphicon-plus"></span> |
||||
|
</a> |
||||
|
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>營業人員/契約人員</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>部門</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>合約號</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>單據號</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>客戶名稱</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:80px;'>單據日期</th> |
||||
|
<!-- <th style='text-align:center;vertical-align: middle;width:80px;'>最後收款日</th> --> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>金額</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:60px;'>明細</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php foreach ($data as $row) { ?> |
||||
|
<tr> |
||||
|
<td> |
||||
|
<?php |
||||
|
echo $row['PersonId']; |
||||
|
echo "<br/>"; |
||||
|
echo $row['PersonName']; |
||||
|
?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['DeptName']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['ProjectId']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['BillNo']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['BizPartnerName']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo date('Y/m/d', strtotime($row['BillDate'])); ?> |
||||
|
</td> |
||||
|
<!-- <td> |
||||
|
<?php echo date('Y/m/d', strtotime($row['Max_CU_EstPayDate'])); ?> |
||||
|
</td> --> |
||||
|
<td> |
||||
|
<?php echo number_format(intval($row['UnTransAmount']), 0, '', ','); ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<button class="btn btn-primary myBtn" type="button" onclick="showDetail('<?php echo $row['BillNo']; ?>')">明細</button> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<?php } ?> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<script> |
||||
|
var modal = document.getElementById("myModal"); |
||||
|
$(".myBtn").click(function() { |
||||
|
$("#myModal").show(); |
||||
|
}); |
||||
|
$("#myCloseBtn").click(function(e) { |
||||
|
$("#myModal").hide(); |
||||
|
}); |
||||
|
$(".back").click(function(e) { |
||||
|
$("#myModal").hide(); |
||||
|
}); |
||||
|
|
||||
|
function showDetail(billno) { |
||||
|
$.ajax({ |
||||
|
type: "POST", |
||||
|
dataType: "json", |
||||
|
url: "contract_b-index-model.php", |
||||
|
data: { |
||||
|
form_name: 'showDetail', |
||||
|
billno: billno |
||||
|
}, |
||||
|
complete: function(data) { |
||||
|
var data = data.responseJSON |
||||
|
var str = ""; |
||||
|
for (var i = 0; i < data.length; i++) { |
||||
|
str += "<tr>"; |
||||
|
str += "<td>" + data[i]['IncomeId'] + "</td>"; |
||||
|
str += "<td>" + data[i]['FeeTypeName'] + "</td>"; |
||||
|
str += "<td>" + data[i]['SQuantity'] + "</td>"; |
||||
|
str += "<td>" + data[i]['SPrice'] + "</td>"; |
||||
|
str += "<td>" + data[i]['OAmount'] + "</td>"; |
||||
|
str += "<td>" + data[i]['OTax'] + "</td>"; |
||||
|
str += "<td>" + data[i]['OAmountWithTax'] + "</td>"; |
||||
|
str += "<td>" + data[i]['ProjectId'] + "</td>"; |
||||
|
str += "<td>" + data[i]['CU_MaterialId'] + "</td>"; |
||||
|
str += "<td>" + data[i]['CU_EstPayDate'] + "</td>"; |
||||
|
str += "</tr>"; |
||||
|
} |
||||
|
if ($('#table_detail').hasClass('dataTable')) { |
||||
|
dttable = $('#table_detail').dataTable(); |
||||
|
dttable.fnClearTable(); |
||||
|
dttable.fnDestroy(); |
||||
|
} |
||||
|
$("#table_detail").find("tbody").html(str); |
||||
|
$('#table_detail').dataTable(); |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
</script> |
||||
|
<?php |
||||
|
|
||||
|
else : |
||||
|
echo "<h2>There is no record!</h2>"; |
||||
|
endif; |
||||
|
|
||||
|
#代表結束連線 |
||||
|
mysqli_close($link); |
||||
|
|
||||
|
include "footer.php"; |
||||
|
?> |
@ -0,0 +1,311 @@ |
|||||
|
<?php |
||||
|
include "header.php"; |
||||
|
include "css/view/wipwhole-index.php"; |
||||
|
|
||||
|
// 設置一個空陣列來放資料 |
||||
|
$data = array(); |
||||
|
$contractno = empty($_POST['contractno']) ? null : $_POST['contractno']; |
||||
|
$department_id = accountidToDepartId($user_id); |
||||
|
// $contractno = getContractnoDetails($link, $user_id, $department_id, $contractno); |
||||
|
|
||||
|
|
||||
|
$sql = " |
||||
|
SELECT TOP 1000 |
||||
|
sso_tmp.BillNo, |
||||
|
sso_tmp.BillDate, |
||||
|
sso_tmp.PersonId, --負責業務人 |
||||
|
sso_tmp.SumOAmountWithTax, |
||||
|
cgp.PersonName, |
||||
|
cd.DeptName, |
||||
|
sso_tmp.BizPartnerId, |
||||
|
sso_tmp.fsso_status, -- 發票狀態 |
||||
|
CASE |
||||
|
WHEN awob_tmp.status IS NOT NULL THEN 'true' |
||||
|
ELSE 'false' |
||||
|
END AS awob_status, -- 收款狀態 |
||||
|
sso_tmp.BizPartnerName |
||||
|
FROM ( |
||||
|
SELECT |
||||
|
sso.BillNo, |
||||
|
sso.BillDate, |
||||
|
sso.PersonId, --負責業務人 |
||||
|
ssod.SumOAmountWithTax, |
||||
|
sso.BizPartnerId, |
||||
|
'true' AS fsso_status, |
||||
|
cbp.BizPartnerName |
||||
|
FROM salSalesOrder AS sso |
||||
|
LEFT JOIN ( |
||||
|
SELECT |
||||
|
BillNo, |
||||
|
SUM(OAmountWithTax) SumOAmountWithTax |
||||
|
FROM salSalesOrderDetail |
||||
|
GROUP BY BillNo |
||||
|
)AS ssod ON sso.BillNo = ssod.BillNo |
||||
|
LEFT JOIN comBusinessPartner AS cbp |
||||
|
ON sso.BizPartnerId = cbp.BizPartnerId |
||||
|
WHERE sso.BillNo IN |
||||
|
( |
||||
|
SELECT FromSalSalesOrder |
||||
|
FROM arCheckBillDetail |
||||
|
) |
||||
|
AND sso.TypeId = 'SP' |
||||
|
|
||||
|
UNION |
||||
|
|
||||
|
SELECT |
||||
|
sso.BillNo, |
||||
|
sso.BillDate, |
||||
|
sso.PersonId, --負責業務人, |
||||
|
ssod.SumOAmountWithTax, |
||||
|
sso.BizPartnerId, |
||||
|
'false' AS fsso_status, |
||||
|
cbp.BizPartnerName |
||||
|
FROM salSalesOrder AS sso |
||||
|
LEFT JOIN ( |
||||
|
SELECT |
||||
|
BillNo, |
||||
|
SUM(OAmountWithTax) SumOAmountWithTax |
||||
|
FROM salSalesOrderDetail |
||||
|
GROUP BY BillNo |
||||
|
)AS ssod ON sso.BillNo = ssod.BillNo |
||||
|
LEFT JOIN comBusinessPartner AS cbp |
||||
|
ON sso.BizPartnerId = cbp.BizPartnerId |
||||
|
WHERE sso.BillNo NOT IN |
||||
|
( |
||||
|
SELECT FromSalSalesOrder |
||||
|
FROM arCheckBillDetail |
||||
|
) |
||||
|
AND sso.TypeId = 'SP' |
||||
|
)AS sso_tmp |
||||
|
LEFT JOIN ( |
||||
|
SELECT DISTINCT |
||||
|
c.OrderBillNo, |
||||
|
'1' AS status |
||||
|
FROM arWriteOffBill AS a |
||||
|
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo |
||||
|
LEFT JOIN |
||||
|
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail |
||||
|
LEFT JOIN |
||||
|
(SELECT |
||||
|
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo |
||||
|
FROM arCheckBill |
||||
|
LEFT JOIN arCheckBillInvInfo |
||||
|
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1 |
||||
|
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c |
||||
|
ON a.BillNo=c.BillNo |
||||
|
WHERE DATALENGTH(c.OrderBillNo) >0 |
||||
|
)AS awob_tmp |
||||
|
ON sso_tmp.BillNo = awob_tmp.OrderBillNo |
||||
|
LEFT JOIN comPerson AS cp -- 員工主檔 |
||||
|
ON sso_tmp.PersonId = cp.PersonId |
||||
|
LEFT JOIN comGroupPerson AS cgp |
||||
|
ON cp. PersonId = cgp.PersonId |
||||
|
LEFT JOIN comDepartment AS cd -- 部門主檔 |
||||
|
ON cp.DeptId = cd.DeptId |
||||
|
WHERE 1=1 |
||||
|
"; |
||||
|
$sql .= !empty($contractno) ? " AND sso_tmp.BillNo = '$contractno' " : ""; |
||||
|
|
||||
|
// echo "<pre>"; |
||||
|
// echo $sql; |
||||
|
// echo "</pre>"; |
||||
|
// exit; |
||||
|
|
||||
|
// $sql .= !empty($contractno) ? " AND sso_tmp.BillNo IN ($contractno)" : ""; |
||||
|
$data = $conn->query($sql); |
||||
|
|
||||
|
function checkCollectMonth($row) |
||||
|
{ |
||||
|
$BillDate = $row['BillDate']; |
||||
|
if (collect_month(strtotime($BillDate)) >= 3) { |
||||
|
return "<span class='text-danger'>" . collect_month(strtotime($BillDate)) . "</span>"; |
||||
|
} else { |
||||
|
return "<span class=''>" . collect_month(strtotime($BillDate)) . "</span>"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function getFixDetails($conn, $row) |
||||
|
{ |
||||
|
$BillNo = $row['BillNo']; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
ssod.MaterialId, |
||||
|
cmg.MaterialName, |
||||
|
ssod.OAmountWithTax |
||||
|
FROM salSalesOrder AS sso |
||||
|
LEFT JOIN salSalesOrderDetail AS ssod |
||||
|
ON sso.BillNo = ssod.BillNo |
||||
|
LEFT JOIN comMaterialGroup AS cmg |
||||
|
ON ssod.MaterialId = cmg.MaterialId |
||||
|
WHERE sso.BillNo = '$BillNo' |
||||
|
"; |
||||
|
$data = $conn->query($sql); |
||||
|
$str = ""; |
||||
|
foreach ($data as $row) { |
||||
|
$str .= $row['MaterialId'] . "_"; |
||||
|
$str .= $row['MaterialName'] . ":"; |
||||
|
$str .= number_format(intval($row['OAmountWithTax'])) . "<br/>"; |
||||
|
} |
||||
|
return $str; |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
|
||||
|
|
||||
|
<?php if ($user_auth & 2) { ?> |
||||
|
<!-- <p> |
||||
|
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
||||
|
<span class="glyphicon glyphicon-plus"></span> |
||||
|
</a> |
||||
|
</p> --> |
||||
|
<?php |
||||
|
} |
||||
|
if ($data) : |
||||
|
?> |
||||
|
|
||||
|
<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="overflow-x:auto;"> |
||||
|
<form id='myForm' method='post' action='fix_contract_payment_status.php?<?= $token_link ?>'> |
||||
|
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<td colspan="5"> |
||||
|
<h3 style='text-align:center'>新梯合約管理</h3> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<th style='text-align:center;vertical-align: middle;'>合約號</th> |
||||
|
<td style='text-align:center;vertical-align: middle;'> |
||||
|
<input type="text" class='form-control' id='contractno' name='contractno' value=""> |
||||
|
</td> |
||||
|
<td style='text-align:left;vertical-align: middle;'> |
||||
|
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</form> |
||||
|
</div> |
||||
|
|
||||
|
<div style="overflow-x:auto;"> |
||||
|
<a href="contract-repair/contract-repair-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
||||
|
<span class="glyphicon glyphicon-plus"></span> |
||||
|
</a> |
||||
|
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>營業人員/契約人員</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>部門</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>單據號</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>客戶名稱</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:80px;'>單據日期</th> |
||||
|
<!-- <th style='text-align:center;vertical-align: middle;width:50px;'>催收次數</th> --> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>金額</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>發票狀態</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:120px;'>收款狀態</th> |
||||
|
<th style='text-align:center;vertical-align: middle;width:250px;'>修理明細</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php foreach ($data as $row) { ?> |
||||
|
<tr> |
||||
|
<td> |
||||
|
<?php |
||||
|
echo $row['PersonId']; |
||||
|
echo "<br/>"; |
||||
|
echo $row['PersonName']; |
||||
|
?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['DeptName']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['BillNo']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['BizPartnerName']; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo date('Y/m/d', strtotime($row['BillDate'])); ?> |
||||
|
</td> |
||||
|
<!-- <td> |
||||
|
<?php echo $row['awob_status'] == 'true' ? '0' : checkCollectMonth($row); ?> |
||||
|
</td> --> |
||||
|
<td> |
||||
|
<?php echo number_format(intval($row['SumOAmountWithTax']), 0, '', ','); ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['fsso_status'] == 'true' |
||||
|
? '<span class="text-primary">已開發票</span>' |
||||
|
: '<span class="text-danger">未開發票</span>'; ?> |
||||
|
</td> |
||||
|
<td> |
||||
|
<?php echo $row['awob_status'] == 'true' |
||||
|
? '<span class="text-primary">已收款</span>' |
||||
|
: '<span class="text-danger">未收款</span>'; ?> |
||||
|
</td> |
||||
|
<td style='text-align:left;'> |
||||
|
<?php |
||||
|
echo getFixDetails($conn, $row); |
||||
|
?> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<?php } ?> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<script> |
||||
|
$(function() { |
||||
|
document.getElementById('loadingOverlay').classList.add('hidden'); |
||||
|
}) |
||||
|
</script> |
||||
|
<?php |
||||
|
|
||||
|
else : |
||||
|
echo "<h2>There is no record!</h2>"; |
||||
|
endif; |
||||
|
|
||||
|
#代表結束連線 |
||||
|
mysqli_close($link); |
||||
|
|
||||
|
include "footer.php"; |
||||
|
?> |
@ -0,0 +1,157 @@ |
|||||
|
<?php |
||||
|
require_once dirname(__FILE__) . "/../mkt/database.php"; |
||||
|
include "fun_global.php"; |
||||
|
|
||||
|
// AJAX 顯示合約明細 |
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
$form_name = $_POST['form_name']; |
||||
|
$type = $_POST['type']; |
||||
|
$mtype = $_POST['mtype']; |
||||
|
$year = $_POST['year']; |
||||
|
$month = $_POST['month']; |
||||
|
if ($form_name == 'getShipping') { |
||||
|
echo getShipping($type, $mtype, $year, $month); |
||||
|
} |
||||
|
if ($form_name == 'getInstalling') { |
||||
|
echo getInstalling($type, $mtype, $year, $month); |
||||
|
} |
||||
|
if ($form_name == 'getInstalling2') { |
||||
|
echo getInstalling2($type, $mtype, $year, $month); |
||||
|
} |
||||
|
if ($form_name == 'getQCing') { |
||||
|
echo getQCing($type, $mtype, $year, $month); |
||||
|
} |
||||
|
if ($form_name == 'getDeliverying') { |
||||
|
echo getDeliverying($type, $mtype, $year, $month); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 出貨台數 |
||||
|
function getShipping($type, $mtype, $year, $month) |
||||
|
{ |
||||
|
global $link; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM wipwholestatus |
||||
|
WHERE status = '1' |
||||
|
AND ( |
||||
|
real_arrival_date IS NOT NULL |
||||
|
AND real_arrival_date != '' |
||||
|
) |
||||
|
"; |
||||
|
if(!empty($month)){ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
||||
|
}else{ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; |
||||
|
} |
||||
|
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
||||
|
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); |
||||
|
return json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
||||
|
|
||||
|
// 在裝台數 |
||||
|
function getInstalling($type, $mtype, $year, $month) |
||||
|
{ |
||||
|
global $link; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM wipwholestatus |
||||
|
WHERE status = '1' |
||||
|
AND ( |
||||
|
install_start_date IS NOT NULL |
||||
|
OR install_start_date != '' |
||||
|
) |
||||
|
AND ( |
||||
|
install_end_date IS NULL |
||||
|
OR install_end_date = '' |
||||
|
) |
||||
|
"; |
||||
|
if(!empty($month)){ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
||||
|
}else{ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; |
||||
|
} |
||||
|
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
||||
|
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); |
||||
|
return json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
||||
|
|
||||
|
// 完工台數 |
||||
|
function getInstalling2($type, $mtype, $year, $month) |
||||
|
{ |
||||
|
global $link; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM wipwholestatus |
||||
|
WHERE status = '1' |
||||
|
AND install_start_date IS NOT NULL |
||||
|
AND install_start_date != '' |
||||
|
AND install_end_date IS NOT NULL |
||||
|
AND install_end_date != '' |
||||
|
"; |
||||
|
if(!empty($month)){ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
||||
|
}else{ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; |
||||
|
} |
||||
|
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
||||
|
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); |
||||
|
return json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
||||
|
|
||||
|
// QC台數 |
||||
|
function getQCing($type, $mtype, $year, $month) |
||||
|
{ |
||||
|
global $link; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM wipwholestatus |
||||
|
WHERE status = '1' |
||||
|
AND end_qc_date IS NOT NULL |
||||
|
AND end_qc_date != '' |
||||
|
"; |
||||
|
if(!empty($month)){ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
||||
|
}else{ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; |
||||
|
} |
||||
|
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
||||
|
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); |
||||
|
return json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
||||
|
|
||||
|
// 移交台數 |
||||
|
function getDeliverying($type, $mtype, $year, $month) |
||||
|
{ |
||||
|
global $link; |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM wipwholestatus |
||||
|
WHERE status = '1' |
||||
|
AND delivery_date IS NOT NULL |
||||
|
AND delivery_date != '' |
||||
|
"; |
||||
|
if(!empty($month)){ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
||||
|
}else{ |
||||
|
$sql .= " AND real_arrival_date BETWEEN '$year-01-01' AND '$year-12-31'"; |
||||
|
} |
||||
|
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
||||
|
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result, MYSQLI_ASSOC); |
||||
|
return json_encode($data, JSON_UNESCAPED_UNICODE); |
||||
|
} |
Loading…
Reference in new issue