51 changed files with 5464 additions and 1496 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,62 @@ |
|||
<?php |
|||
use PHPMailer\PHPMailer\PHPMailer; |
|||
use PHPMailer\PHPMailer\SMTP; |
|||
use PHPMailer\PHPMailer\Exception; |
|||
|
|||
class Cmail |
|||
{ |
|||
public $charset = ""; |
|||
public $host = ""; |
|||
public $port = ""; |
|||
public $smtp_user = ""; |
|||
public $smtp_pwd = ""; |
|||
|
|||
function __construct($charset='', $fromemail='') |
|||
{ |
|||
include dirname(__DIR__)."/PHPMailer/Exception.php"; |
|||
include dirname(__DIR__)."/PHPMailer/PHPMailer.php"; |
|||
include dirname(__DIR__)."/PHPMailer/SMTP.php"; |
|||
|
|||
$this->charset = "UTF-8"; |
|||
$this->host = "mail.masada.com.tw"; |
|||
$this->port = 25; |
|||
$this->smtp_user = "notice"; // 這裡填寫SMTP登入帳號, 例如 your.gmail.name@gmail.com 則填寫your.gmail.name |
|||
$this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼 |
|||
} |
|||
|
|||
function sendx($subject="", $em_body="", $sendlist=array(), $from="永佳捷科技", $bcc="", $files=array()) |
|||
{ |
|||
if (!$sendlist) return; |
|||
$em_body = nl2br($em_body); |
|||
$em_body .= "<p>※此信件為系統發出信件,請勿直接回覆。</p>"; |
|||
|
|||
$mail = new PHPMailer(true); |
|||
$mail->IsHTML(true); //設定是否使用HTML格式 |
|||
$mail->CharSet = $this->charset; |
|||
$mail->isSMTP(); |
|||
$mail->SMTPAuth = true; |
|||
$mail->Host = $this->host; |
|||
$mail->Port = $this->port; |
|||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //使用SSL, 如果是TLS 請改為 PHPMailer::ENCRYPTION_STARTTLS |
|||
$mail->Username = $this->smtp_user; |
|||
$mail->Password = $this->smtp_pwd; |
|||
$mail->SMTPSecure = ""; |
|||
$mail->From = "notice@masada.com.tw"; |
|||
$mail->FromName = $from; |
|||
$mail->Subject = $subject; |
|||
$mail->Body = $em_body; |
|||
foreach ($sendlist as $v) { // $sendlist[0]=['M0044', 'jrbin@masada.com.tw'] |
|||
list($name, $email) = $v; |
|||
if ($email) $mail->addAddress($email, $name); |
|||
} |
|||
//$mail->addCC("personC@gmail.com", "person C"); |
|||
//$mail->addBCC("personD@gmail.com", "person D"); |
|||
//$mail->addAttachment("image1.jpg", "picture.jpg"); //設定附件, 對方會看到附件名稱為 picture.jpg |
|||
//print_r($mail);exit; |
|||
if (!$mail->Send()){ |
|||
// echo "Mailer error: " . $mail->ErrorInfo; |
|||
} else { |
|||
//echo "Email sent"; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,109 @@ |
|||
<?php |
|||
//ini_set('display_errors', 'on'); |
|||
|
|||
class Cnotice |
|||
{ |
|||
|
|||
function __construct() |
|||
{ |
|||
} |
|||
|
|||
function connectionDB() |
|||
{ |
|||
$envFile = __DIR__ . '/../../.env'; |
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$host = getenv('DB_HOST'); |
|||
$dbport = getenv('DB_PORT'); |
|||
$dbuser = getenv('DB_USERNAME'); |
|||
$dbpassword = getenv('DB_PASSWORD'); |
|||
$dbname = getenv('DB_DATABASE'); |
|||
|
|||
try { |
|||
$options = [ |
|||
PDO::ATTR_PERSISTENT => false, |
|||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
|||
PDO::ATTR_EMULATE_PREPARES => false, |
|||
PDO::ATTR_STRINGIFY_FETCHES => false, |
|||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', |
|||
]; |
|||
$pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
return $pdo; |
|||
} catch (PDOException $e) { |
|||
die("Something wrong: {$e->getMessage()}"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 結束資料庫連線 |
|||
*/ |
|||
function endConnectionDB($pdo) |
|||
{ |
|||
unset($pdo); |
|||
} |
|||
|
|||
/** |
|||
* 提交消息 notice |
|||
* @param string $kind : 類別 1=系統 2=會議 |
|||
* @param int $related_id : 關聯序號 |
|||
* @param string $title : 標題 |
|||
* @param string $title : 內容 |
|||
* @param string $permission : 瀏覽權限 員編/ALL=全體 |
|||
* @param string $creater : 建立者 |
|||
* @param string $create_at : 建立時間 |
|||
*/ |
|||
function sendx($data) |
|||
{ |
|||
|
|||
$kind = $data['kind']; |
|||
$related_id = $data['related_id']; |
|||
$title = $data['title']; |
|||
$content = $data['content']; |
|||
$permission = $data['permission']; |
|||
$creater = $data['creater']; |
|||
$create_at = $data['create_at']; |
|||
|
|||
$pdo = $this->connectionDB(); |
|||
$pdo->exec('SET CHARACTER SET utf8mb4'); |
|||
$str = " |
|||
INSERT INTO `notice` (`kind`, `related_id`, `title`, `content`, `permission`, `creater`, `create_at`) |
|||
VALUES (?,?,?,?,?,?,?) |
|||
"; |
|||
|
|||
$sth = $pdo->prepare($str); |
|||
$sth->bindValue(1, $kind); |
|||
$sth->bindValue(2, $related_id); |
|||
$sth->bindValue(3, $title); |
|||
$sth->bindValue(4, $content); |
|||
$sth->bindValue(5, $permission); |
|||
$sth->bindValue(6, $creater); |
|||
$sth->bindValue(7, $create_at); |
|||
|
|||
$sth->execute(); |
|||
|
|||
$this->endConnectionDB($pdo); |
|||
} |
|||
} |
|||
|
|||
// $cn = new Cnotice(); |
|||
// $data = array( |
|||
// 'kind' => 1, |
|||
// 'related_id' => 1, |
|||
// 'title' => "標題", |
|||
// 'content' => "內容", |
|||
// 'permission' => "M0117", |
|||
// 'creater' => "M0117", |
|||
// 'create_at' => date("Y-m-d H:i:s") |
|||
// ); |
|||
// $cn->sendx($data); |
@ -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); |
|||
} |
|||
} |
@ -1,309 +1,310 @@ |
|||
<?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_tmp2.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: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 empty($row['Max_CU_EstPayDate']) ? '' : date('Y/m/d', strtotime($row['Max_CU_EstPayDate'])); ?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
|
|||
$date1 = new DateTime(date('Y-m-d', strtotime($row['Max_CU_EstPayDate']))); |
|||
$date2 = new DateTime(date('Y-m-d')); |
|||
$interval = $date1->diff($date2); |
|||
$months = $interval->m; |
|||
$months += $interval->y * 12; |
|||
if ($date1 <= $date2) { |
|||
echo "<span class=''>合約已過期</span>"; |
|||
} else if ($months <= 2) { |
|||
echo "<span class='text-danger'>合約快到期</span>"; |
|||
} else { |
|||
echo "<span class='text-success'>合約未到期</span>"; |
|||
} |
|||
?> |
|||
</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"; |
|||
<?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_tmp2.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: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 empty($row['Max_CU_EstPayDate']) ? '' : date('Y/m/d', strtotime($row['Max_CU_EstPayDate'])); ?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
|
|||
$date1 = new DateTime(date('Y-m-d', strtotime($row['Max_CU_EstPayDate']))); |
|||
$date2 = new DateTime(date('Y-m-d')); |
|||
$interval = $date1->diff($date2); |
|||
$months = $interval->m; |
|||
$months += $interval->y * 12; |
|||
if ($date1 <= $date2) { |
|||
echo "<span class=''>合約已過期</span>"; |
|||
} else if ($months <= 2) { |
|||
echo "<span class='text-danger'>合約快到期</span>"; |
|||
} else { |
|||
echo "<span class='text-success'>合約未到期</span>"; |
|||
} |
|||
?> |
|||
</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,269 @@ |
|||
<?php |
|||
// ini_set('display_errors', 'on'); |
|||
include "header.php"; |
|||
|
|||
// 出貨台數 |
|||
function getShipping($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND ( |
|||
real_arrival_date IS NOT NULL |
|||
AND real_arrival_date != '' |
|||
) |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 在裝台數 |
|||
function getInstalling($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND ( |
|||
install_end_date IS NULL |
|||
OR install_end_date = '' |
|||
) |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 完工台數 |
|||
function getInstalling2($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND install_end_date IS NOT NULL |
|||
AND install_end_date != '' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// QC台數 |
|||
function getQCing($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND end_qc_date IS NOT NULL |
|||
AND end_qc_date != '' |
|||
|
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 移交台數 |
|||
function getDeliverying($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND delivery_date IS NOT NULL |
|||
AND delivery_date != '' |
|||
|
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
$contract_type = [ |
|||
'' => '新梯 + 汰改', |
|||
'A' => '新梯', |
|||
'B' => '汰改' |
|||
]; |
|||
foreach ($contract_type as $c_val => $c_key) { |
|||
|
|||
?> |
|||
|
|||
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='15'> |
|||
<h4>出貨完工推移表(<?php echo $c_key; ?>)</h4> |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>階段台數</th> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>年度</th> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='12'>月份</th> |
|||
<th style='text-align:center;vertical-align:middle;' rowspan='2'>合計</th> |
|||
</tr> |
|||
<tr> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td style='text-align:center;'>" . $i . "月</td>"; |
|||
} |
|||
?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
$type_arr = [ |
|||
'A' => '出貨台數', |
|||
'B' => '在裝台數', |
|||
'C' => '完工台數', |
|||
'D' => 'QC台數', |
|||
'E' => '移交台數' |
|||
]; |
|||
foreach ($type_arr as $val => $key) { |
|||
?> |
|||
<tr> |
|||
<td style='text-align:center;vertical-align:middle;' rowspan='2'> |
|||
<?php |
|||
echo $key; |
|||
echo "<br/>"; |
|||
if ($val == 'A') |
|||
echo "<span style='font-size:12px;'>有出貨日</span>"; |
|||
if ($val == 'B') |
|||
echo "<span style='font-size:12px;'>有安裝開工日,沒安裝完工日</span> "; |
|||
if ($val == 'C') |
|||
echo "<span style='font-size:12px;'>有安裝完工日</span> "; |
|||
if ($val == 'D') |
|||
echo "<span style='font-size:12px;'>有QC完工日</span> "; |
|||
if ($val == 'E') |
|||
echo "<span style='font-size:12px;'>移交日</span> "; |
|||
?> |
|||
|
|||
</td> |
|||
<td>前一年度(<?php echo (date("Y") - 1); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
echo '<td style="text-align:center;">' . $a . '</td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
echo '<td style="text-align:center;">' . $b . '</td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
echo '<td style="text-align:center;">' . $c . '</td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
echo '<td style="text-align:center;">' . $d . '</td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
echo '<td style="text-align:center;">' . $e . '</td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') |
|||
echo '<td style="text-align:center;">' . $a_count . '</td>'; |
|||
if ($val == 'B') |
|||
echo '<td style="text-align:center;">' . $b_count . '</td>'; |
|||
if ($val == 'C') |
|||
echo '<td style="text-align:center;">' . $c_count . '</td>'; |
|||
if ($val == 'D') |
|||
echo '<td style="text-align:center;">' . $d_count . '</td>'; |
|||
if ($val == 'E') |
|||
echo '<td style="text-align:center;">' . $e_count . '</td>'; |
|||
?> |
|||
</tr> |
|||
<tr> |
|||
<td>本年度(<?php echo date("Y"); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
echo '<td style="text-align:center;">' . $a . '</td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
echo '<td style="text-align:center;">' . $b . '</td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
echo '<td style="text-align:center;">' . $c . '</td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
echo '<td style="text-align:center;">' . $d . '</td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
echo '<td style="text-align:center;">' . $e . '</td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') |
|||
echo '<td style="text-align:center;">' . $a_count . '</td>'; |
|||
if ($val == 'B') |
|||
echo '<td style="text-align:center;">' . $b_count . '</td>'; |
|||
if ($val == 'C') |
|||
echo '<td style="text-align:center;">' . $c_count . '</td>'; |
|||
if ($val == 'D') |
|||
echo '<td style="text-align:center;">' . $d_count . '</td>'; |
|||
if ($val == 'E') |
|||
echo '<td style="text-align:center;">' . $e_count . '</td>'; |
|||
?> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
<?php |
|||
} |
|||
?> |
@ -0,0 +1,585 @@ |
|||
<?php |
|||
include("header.php"); |
|||
|
|||
$this_year = 2024; |
|||
|
|||
$expected_a['2024'] = [ |
|||
1 => 10, |
|||
2 => 20, |
|||
3 => 10, |
|||
4 => 26, |
|||
5 => 13, |
|||
6 => 26, |
|||
7 => 13, |
|||
8 => 26, |
|||
9 => 13, |
|||
10 => 26, |
|||
11 => 13, |
|||
12 => 14 |
|||
]; |
|||
$real_a['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
$expected_b['2024'] = [ |
|||
1 => 15, |
|||
2 => 30, |
|||
3 => 15, |
|||
4 => 40, |
|||
5 => 20, |
|||
6 => 40, |
|||
7 => 20, |
|||
8 => 40, |
|||
9 => 20, |
|||
10 => 40, |
|||
11 => 20, |
|||
12 => 30 |
|||
]; |
|||
$real_b['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
$expected_c['2024'] = [ |
|||
1 => 18, |
|||
2 => 18, |
|||
3 => 19, |
|||
4 => 20, |
|||
5 => 20, |
|||
6 => 20, |
|||
7 => 20, |
|||
8 => 20, |
|||
9 => 20, |
|||
10 => 20, |
|||
11 => 20, |
|||
12 => 20 |
|||
]; |
|||
$real_c['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
$expected_d['2024'] = [ |
|||
1 => 12650, |
|||
2 => 12650, |
|||
3 => 12650, |
|||
4 => 18150, |
|||
5 => 18150, |
|||
6 => 19800, |
|||
7 => 23650, |
|||
8 => 23650, |
|||
9 => 23650, |
|||
10 => 26400, |
|||
11 => 26400, |
|||
12 => 26400 |
|||
]; |
|||
$real_d['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
$expected_e['2024'] = [ |
|||
1 => 192, |
|||
2 => 192, |
|||
3 => 192, |
|||
4 => 272, |
|||
5 => 272, |
|||
6 => 272, |
|||
7 => 272, |
|||
8 => 272, |
|||
9 => 272, |
|||
10 => 272, |
|||
11 => 272, |
|||
12 => 272 |
|||
]; |
|||
$real_e['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
$expected_f['2024'] = [ |
|||
1 => 822, |
|||
2 => 957, |
|||
3 => 1092, |
|||
4 => 1227, |
|||
5 => 1362, |
|||
6 => 1497, |
|||
7 => 2162, |
|||
8 => 2297, |
|||
9 => 2432, |
|||
10 => 2567, |
|||
11 => 2702, |
|||
12 => 2838, |
|||
]; |
|||
$real_f['2024'] = [ |
|||
1 => 0, |
|||
2 => 0, |
|||
3 => 0, |
|||
4 => 0, |
|||
5 => 0, |
|||
6 => 0, |
|||
7 => 0, |
|||
8 => 0, |
|||
9 => 0, |
|||
10 => 0, |
|||
11 => 0, |
|||
12 => 0 |
|||
]; |
|||
|
|||
function getMAdetails($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
-- 全機汰改 |
|||
SELECT |
|||
count(*) |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
WHERE ssod.MaterialId = 'A40010' |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
"; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
|
|||
function getM1details($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
-- M1汰改 |
|||
SELECT |
|||
count(*) |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
where ssod.MaterialId = 'A40002' |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
"; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
|
|||
function getM1Freedetails($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
-- M1汰改送免費一年保養 |
|||
SELECT |
|||
count(*) |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
where ssod.PresentSQty >0 |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
"; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
|
|||
function getMContractAllAmount($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
SELECT |
|||
SUM(T.OAmountWithTax) AS OAmountWithTax |
|||
FROM( |
|||
-- 全機汰改 |
|||
SELECT |
|||
SUM(ssod.OAmountWithTax) AS OAmountWithTax |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
WHERE ssod.MaterialId = 'A40010' |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
UNION ALL |
|||
-- M1汰改 |
|||
SELECT |
|||
SUM(ssod.OAmountWithTax) AS OAmountWithTax |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
where ssod.MaterialId = 'A40002' |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
UNION ALL |
|||
-- M1汰改送免費一年保養 |
|||
SELECT |
|||
SUM(ssod.OAmountWithTax) AS OAmountWithTax |
|||
FROM salSalesOrder AS sso |
|||
LEFT JOIN salSalesOrderDetail AS ssod |
|||
ON ssod.BillNo = sso.BillNo |
|||
where ssod.PresentSQty >0 |
|||
AND SUBSTRING(CONVERT(VARCHAR, sso.BillDate, 112), 1, 6) = '$date' |
|||
-- AND SUBSTR(sso.CustomerOrderDate, 1, 6) = '$date', |
|||
) AS T |
|||
"; |
|||
// echo "<pre>$sql</pre>"; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
|
|||
function getMataincedetails($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
-- 保養合約 |
|||
SELECT |
|||
COUNT(sia_tmp.CU_MaterialId) |
|||
FROM( |
|||
SELECT |
|||
MIN(siam.BillDate) AS BillDate, |
|||
siad.CU_MaterialId |
|||
FROM salIncomeApplyMaster AS siam |
|||
LEFT JOIN salIncomeApplyDetail AS siad |
|||
ON siam.BillNo = siad.BillNo |
|||
GROUP BY siad.CU_MaterialId |
|||
)AS sia_tmp |
|||
WHERE 1=1 |
|||
AND SUBSTRING(CONVERT(VARCHAR, sia_tmp.BillDate, 112), 1, 6) = '$date' |
|||
"; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
|
|||
function getFixdetails($conn, $this_year, $i) |
|||
{ |
|||
$date = $this_year . str_pad($i, 2, '0', STR_PAD_LEFT); |
|||
$sql = " |
|||
SELECT |
|||
SUM(sia_tmp.OAmountWithTax) AS OAmountWithTax |
|||
FROM( |
|||
SELECT |
|||
sdlm.BillDate AS BillDate, |
|||
sdld.OAmountWithTax |
|||
FROM salDispatchListMaster AS sdlm |
|||
LEFT JOIN salDispatchListDetail AS sdld |
|||
ON sdlm.BillNo = sdld.BillNo |
|||
)AS sia_tmp |
|||
WHERE 1=1 |
|||
AND SUBSTRING(CONVERT(VARCHAR, sia_tmp.BillDate, 112), 1, 6) = '$date' |
|||
"; |
|||
// echo $sql; |
|||
$result = $conn->query($sql); |
|||
foreach ($result as $row) { |
|||
return $row[0]; |
|||
} |
|||
} |
|||
?> |
|||
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='17'> |
|||
<h4><?php echo date("Y"); ?>年指標與實績</h4> |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' colspan='2'>項目</th> |
|||
<th style='text-align:center;width:100px;vertical-align:middle;'><?php echo (date("Y") - 1); ?>年</th> |
|||
<th style='text-align:center;vertical-align:middle;'>月份</th> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td style='text-align:center;'>" . $i . "月</td>"; |
|||
} |
|||
?> |
|||
<th style='text-align:center;vertical-align:middle;' rowspan='2'>累計</th> |
|||
</tr> |
|||
<tr> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td rowspan="3">1</td> |
|||
<td rowspan="3">舊梯全汰改(合約台數)</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_a_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_a_count += $expected_a[$this_year][$i]; |
|||
echo "<td>" . $expected_a[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_a_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_a_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_a[$this_year][$i] = getMAdetails($conn, $this_year, $i); |
|||
$real_a_count += $real_a[$this_year][$i]; |
|||
echo "<td>" . $real_a[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_a_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_a[$this_year][$i] / $expected_a[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_a_count / $expected_a_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
|
|||
|
|||
|
|||
<tr> |
|||
<td rowspan="6">2</td> |
|||
<td rowspan="3">舊梯M1改(合約台數)</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_b_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_b_count += $expected_b[$this_year][$i]; |
|||
echo "<td>" . $expected_b[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_b_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_b_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_b[$this_year][$i] = getM1details($conn, $this_year, $i); |
|||
$real_b_count += $real_b[$this_year][$i]; |
|||
echo "<td>" . $real_b[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_b_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_b[$this_year][$i] / $expected_b[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_b_count / $expected_b_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
|
|||
<tr> |
|||
<td rowspan="3">保養簽長約,免費M1(合約台數)</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_c_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_c_count += $expected_c[$this_year][$i]; |
|||
echo "<td>" . $expected_c[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_c_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_c_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_c[$this_year][$i] = getM1Freedetails($conn, $this_year, $i); |
|||
$real_c_count += $real_c[$this_year][$i]; |
|||
echo "<td>" . $real_c[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_c_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_c[$this_year][$i] / $expected_c[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_c_count / $expected_c_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
|
|||
|
|||
<tr> |
|||
<td rowspan="3">3</td> |
|||
<td rowspan="3">汰改合計金額(千元)</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_d_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_d_count += $expected_d[$this_year][$i]; |
|||
echo "<td>" . $expected_d[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_d_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_d_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_d[$this_year][$i] = round(getMContractAllAmount($conn, $this_year, $i) / 1000, 0); |
|||
$real_d_count += $real_d[$this_year][$i]; |
|||
echo "<td>" . $real_d[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_d_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_d[$this_year][$i] / $expected_d[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_d_count / $expected_d_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td rowspan="3">4</td> |
|||
<td rowspan="3">保養契約台數(合約台數)</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_e_count += $expected_e[$this_year][$i]; |
|||
echo "<td>" . $expected_e[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_e_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_e[$this_year][$i] = getMataincedetails($conn, $this_year, $i, $real_e[$this_year]); |
|||
$real_e_count += $real_e[$this_year][$i]; |
|||
echo "<td>" . $real_e[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_e_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_e[$this_year][$i] / $expected_e[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_e_count / $expected_e_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td rowspan="3">5</td> |
|||
<td rowspan="3">修理金額(千元)/台.年</td> |
|||
<td rowspan="3"> |
|||
X |
|||
</td> |
|||
<td>預定</td> |
|||
<?php |
|||
$expected_f_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$expected_f_count += $expected_f[$this_year][$i]; |
|||
echo "<td>" . $expected_f[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $expected_f_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>實際</td> |
|||
<?php |
|||
$real_f_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
$real_f[$this_year][$i] = round(getFixdetails($conn, $this_year, $i) / 1000, 0); |
|||
$real_f_count += $real_f[$this_year][$i]; |
|||
echo "<td>" . $real_f[$this_year][$i] . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo $real_f_count; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>達成率</td> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td>" . round(($real_f[$this_year][$i] / $expected_f[$this_year][$i]) * 100, 2) . "%" . "</td>"; |
|||
} |
|||
?> |
|||
<td><?php echo round(($real_f_count / $expected_f_count) * 100, 2) . "%"; ?></td> |
|||
</tr> |
|||
|
|||
|
|||
</tbody> |
|||
</table> |
|||
|
|||
<?php |
|||
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"; |
|||
?> |
After Width: | Height: | Size: 276 KiB |
@ -0,0 +1,181 @@ |
|||
<?php |
|||
include "header.php"; |
|||
include "css/view/wipwhole-index.php"; |
|||
?> |
|||
<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='maintainance_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="button" id='serch_btn' onclick='drawDatatable()' 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;"> |
|||
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<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:50px;'>標示號</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:50px;'>催收次數</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:50px;'>發票單標示號</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:80px;'>發票金額</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>發票號碼</th> |
|||
<th style='text-align:center;vertical-align: middle;'>核銷</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
include "footer.php"; |
|||
?> |
|||
|
|||
<script> |
|||
function drawDatatable() { |
|||
$('#table_index2').DataTable().destroy(); |
|||
$('#table_index2').DataTable({ |
|||
"serverSide": true, |
|||
"ajax": { |
|||
"url": "maintainance_contract_payment_status_modal.php", |
|||
"type": "POST", |
|||
"dataType": "json", |
|||
"data": { |
|||
"user_id": "<?php echo $user_id; ?>", |
|||
"contractno": $("#contractno").val(), |
|||
}, |
|||
}, |
|||
"columns": [{ |
|||
"data": "PersonId" |
|||
}, |
|||
{ |
|||
"data": "DeptName" |
|||
}, |
|||
{ |
|||
"data": "BillNo" |
|||
}, |
|||
{ |
|||
"data": "RowNo" |
|||
}, |
|||
{ |
|||
"data": "CU_MaterialId" |
|||
}, |
|||
{ |
|||
"data": "BizPartnerName" |
|||
}, |
|||
{ |
|||
"data": "CU_EstPayDate" |
|||
}, |
|||
{ |
|||
"data": "checkCollectMonth" |
|||
}, |
|||
{ |
|||
"data": "checkArCheckBillStatus" |
|||
}, |
|||
{ |
|||
"data": "UnTransCheckBLAmtWTax" |
|||
}, |
|||
{ |
|||
"data": "HadTransCheckBLAmtWTax" |
|||
}, |
|||
{ |
|||
"data": "BillNo2" |
|||
}, |
|||
{ |
|||
"data": "arSellInvoiceMaterial" |
|||
}, |
|||
{ |
|||
"data": "RowCode2" |
|||
}, |
|||
{ |
|||
"data": "BillNo3" |
|||
}, |
|||
{ |
|||
"data": "InvoiceName" |
|||
}, |
|||
{ |
|||
"data": "OAmountWithTax" |
|||
}, |
|||
{ |
|||
"data": "InvoiceNo" |
|||
}, |
|||
{ |
|||
"data": "checkArWriteOffBill" |
|||
} |
|||
] |
|||
}); |
|||
} |
|||
|
|||
$(document).ready(function() { |
|||
drawDatatable(); |
|||
}); |
|||
</script> |
@ -0,0 +1,325 @@ |
|||
<?php |
|||
include "database.php"; |
|||
include "fun_global.php"; |
|||
|
|||
function getContractnoDetails($link, $user_id, $department_id, $contractno = null) |
|||
{ |
|||
$sql = " |
|||
SELECT |
|||
c.contractno |
|||
FROM contract AS c |
|||
LEFT JOIN con_maintance_examine_apply AS cmea |
|||
ON c.contractno = cmea.vol_no |
|||
WHERE 1 = 1 |
|||
"; |
|||
|
|||
if (!in_array($department_id, ['210', '220', '240'])) { |
|||
$sql .= " AND cmea.salesman IN (" . getAccountids($link, $user_id) . ")"; |
|||
} |
|||
|
|||
if (!empty($contractno)) { |
|||
$sql .= " |
|||
AND c.contractno = '$contractno' |
|||
"; |
|||
} |
|||
$result = mysqli_query($link, $sql); |
|||
$data = []; |
|||
foreach ($result as $row) { |
|||
array_push($data, $row['contractno']); |
|||
} |
|||
return "'" . implode("','", $data) . "'"; |
|||
} |
|||
|
|||
function getSalesmanNo($link, $contractno) |
|||
{ |
|||
$sql = " |
|||
SELECT |
|||
cmea.salesman |
|||
FROM contract AS c |
|||
LEFT JOIN con_maintance_examine_apply AS cmea |
|||
ON c.contractno = cmea.vol_no |
|||
WHERE 1 = 1 |
|||
AND c.contractno IN ('$contractno') |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = []; |
|||
foreach ($result as $row) |
|||
return $row['salesman']; |
|||
return ""; |
|||
} |
|||
function getSalesmanName($link, $contractno) |
|||
{ |
|||
$sql = " |
|||
SELECT |
|||
a.name |
|||
FROM contract AS c |
|||
LEFT JOIN con_maintance_examine_apply AS cmea |
|||
ON c.contractno = cmea.vol_no |
|||
LEFT JOIN account AS a |
|||
ON cmea.salesman = a.accountid |
|||
WHERE 1 = 1 |
|||
AND c.contractno IN ('$contractno') |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = []; |
|||
foreach ($result as $row) |
|||
return $row['name']; |
|||
return ""; |
|||
} |
|||
|
|||
function getAccountids($link, $user_id) |
|||
{ |
|||
$sql = " |
|||
SELECT |
|||
accountid |
|||
FROM account |
|||
WHERE 1 = 1 |
|||
AND (accountid = '$user_id' |
|||
OR accountid IN ( |
|||
SELECT |
|||
accountid |
|||
FROM account |
|||
WHERE 1 = 1 |
|||
AND manager = '$user_id' |
|||
AND accounttype IN ('B','E','M','W') |
|||
) |
|||
) |
|||
"; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = []; |
|||
foreach ($result as $row) { |
|||
array_push($data, $row['accountid']); |
|||
} |
|||
return "'" . implode("','", $data) . "'"; |
|||
} |
|||
|
|||
function checkArCheckBillStatus($row) |
|||
{ |
|||
$CU_EstPayDate = $row['CU_EstPayDate']; |
|||
$BillNo2 = $row['BillNo2']; |
|||
if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) { |
|||
if (empty($BillNo2)) { |
|||
return "<span class='text-danger'>未轉應收確認單</span>"; |
|||
} else { |
|||
return "<span class='text-primary'>已轉應收確認單</span>"; |
|||
} |
|||
} else { |
|||
return "時間未到"; |
|||
} |
|||
} |
|||
|
|||
function arSellInvoiceMaterial($row) |
|||
{ |
|||
|
|||
$CU_EstPayDate = $row['CU_EstPayDate']; |
|||
$InvoiceName = $row['InvoiceName']; |
|||
|
|||
if (substr($CU_EstPayDate, 0, 6) <= date("Ym")) { |
|||
if (empty($InvoiceName)) { |
|||
return "<span class='text-danger'>未開發票</span>"; |
|||
} else { |
|||
return "<span class='text-primary'>已開發票</span>"; |
|||
} |
|||
} else { |
|||
return "時間未到"; |
|||
} |
|||
} |
|||
|
|||
function checkCollectMonth($row) |
|||
{ |
|||
$CU_EstPayDate = $row['CU_EstPayDate']; |
|||
if (collect_month(strtotime($CU_EstPayDate)) >= 3) { |
|||
return "<span class='text-danger'>" . collect_month(strtotime($CU_EstPayDate)) . "</span>"; |
|||
} else { |
|||
return "<span class=''>" . collect_month(strtotime($CU_EstPayDate)) . "</span>"; |
|||
} |
|||
} |
|||
|
|||
function checkArWriteOffBill($conn, $row) |
|||
{ |
|||
$BillNo = $row['BillNo2']; |
|||
|
|||
$sql = " |
|||
SELECT |
|||
* |
|||
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 c.checkBillNo = '$BillNo' |
|||
"; |
|||
|
|||
$del = $conn->query($sql); |
|||
$i = 0; |
|||
foreach ($del as $row) |
|||
$i++; |
|||
if (empty($i)) { |
|||
return "<span class='text-danger'>未收款</span>"; |
|||
} else { |
|||
return "<span class='text-primary'>已收款</span>"; |
|||
} |
|||
} |
|||
|
|||
function getAllCount($conn, $sql) |
|||
{ |
|||
$result = $conn->query($sql); |
|||
$count = 0; |
|||
foreach ($result as $row) { |
|||
$count++; |
|||
} |
|||
return $count; |
|||
} |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
$columns = array( |
|||
'PersonId', |
|||
'DeptName', |
|||
'BillNo', |
|||
'RowNo', |
|||
'CU_MaterialId', |
|||
'BizPartnerName', |
|||
'CU_EstPayDate', |
|||
// 'checkCollectMonth', |
|||
// 'checkArCheckBillStatus', |
|||
'UnTransCheckBLAmtWTax', |
|||
'HadTransCheckBLAmtWTax', |
|||
'BillNo2', |
|||
'arSellInvoiceMaterial', |
|||
'RowCode2', |
|||
'BillNo3', |
|||
'InvoiceName', |
|||
'OAmountWithTax', |
|||
'InvoiceNo', |
|||
'checkArWriteOffBill' |
|||
); |
|||
|
|||
$user_id = empty($_POST['user_id']) ? null : $_POST['user_id']; |
|||
$department_id = accountidToDepartId($user_id); |
|||
$contractno = empty($_POST['contractno']) ? '' : getContractnoDetails($link, $user_id, $department_id, $_POST['contractno']); |
|||
$draw = $_POST['draw']; |
|||
$start = $_POST['start']; |
|||
$length = $_POST['length']; |
|||
$order_column = $_POST['order'][0]['column']; |
|||
$order_dir = $_POST['order'][0]['dir']; |
|||
|
|||
$sql = " |
|||
SELECT |
|||
siam.PersonId, |
|||
cd.DeptName, |
|||
cbp.BizPartnerName, |
|||
siamd.RowNo, |
|||
siamd.RowCode, |
|||
siam.BillNo, |
|||
siamd.CU_EstPayDate, |
|||
siamd.UnTransCheckBLAmtWTax , |
|||
siamd.HadTransCheckBLAmtWTax, |
|||
siamd.CU_MaterialId, |
|||
acb_tmp.BillNo2, |
|||
acb_tmp.RowCode2, |
|||
asim.BillNo AS BillNo3, |
|||
asim.InvoiceName, |
|||
asim.OAmountWithTax, |
|||
asi.InvoiceNo |
|||
FROM salIncomeApplyMaster AS siam -- 收入申請單 |
|||
LEFT JOIN salIncomeApplyDetail AS siamd -- 收入申請單明細 |
|||
ON siam.BillNo = siamd.BillNo |
|||
LEFT JOIN comPerson AS cp -- 員工主檔 |
|||
ON siam.PersonId = cp.PersonId |
|||
LEFT JOIN comDepartment AS cd -- 部門主檔 |
|||
ON cp.DeptId = cd.DeptId |
|||
LEFT JOIN ( |
|||
SELECT |
|||
acbd.FromRowCode, |
|||
acb.FromBillNo, |
|||
acbd.BillNo AS BillNo2, |
|||
acbd.RowCode AS RowCode2 |
|||
FROM arCheckBill AS acb -- 應收確認單 |
|||
LEFT JOIN arCheckBillDetail AS acbd -- 應收確認單明細 |
|||
ON acb.BillNo = acbd.BillNo |
|||
WHERE 1 = 1 |
|||
AND acb.TypeId = 'RVS' |
|||
"; |
|||
$sql .= !empty($contractno) ? " AND acb.FromBillNo IN ($contractno) " : ""; |
|||
$sql .= " |
|||
) AS acb_tmp |
|||
ON siamd.RowNo = acb_tmp.FromRowCode |
|||
AND siamd.BillNo = acb_tmp.FromBillNo |
|||
LEFT JOIN arSellInvoiceMaterial AS asim -- 買賣發票明細 |
|||
ON asim.FromBillNo = acb_tmp.BillNo2 |
|||
AND asim.RowCode = acb_tmp.RowCode2 |
|||
LEFT JOIN arSellInvoice AS asi |
|||
ON asim.BillNo = asi.BillNo |
|||
LEFT JOIN comBusinessPartner AS cbp |
|||
ON siam.BizPartnerId = cbp.BizPartnerId |
|||
WHERE 1 = 1 |
|||
"; |
|||
$sql .= !empty($contractno) ? " AND siam.BillNo IN ($contractno)" : ""; |
|||
if (!empty($_POST['search']['value'])) { |
|||
|
|||
$sql .= " |
|||
AND ( |
|||
siam.PersonId LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR cd.DeptName LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR cbp.BizPartnerName LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siam.BillNo LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.CU_MaterialId LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR asi.InvoiceNo LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR asim.InvoiceName LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.CU_EstPayDate LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.UnTransCheckBLAmtWTax LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.HadTransCheckBLAmtWTax LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR acb_tmp.BillNo2 LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR asim.OAmountWithTax LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.RowNo LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR siamd.RowCode LIKE '%" . $_POST['search']['value'] . "%' |
|||
OR acb_tmp.RowCode2 LIKE '%" . $_POST['search']['value'] . "%' |
|||
) |
|||
"; |
|||
} |
|||
$count = getAllCount($conn, $sql); |
|||
$sql .= " ORDER BY " . $columns[$order_column] . " " . $order_dir; |
|||
$sql .= " OFFSET $start ROWS FETCH NEXT $length ROWS ONLY "; |
|||
|
|||
$result = $conn->query($sql); |
|||
$data = []; |
|||
|
|||
foreach ($result as $row) { |
|||
$tmp = []; |
|||
$tmp['PersonId'] = $row['PersonId'] . "<br/>" . accountidToName($row['PersonId']); |
|||
$tmp['DeptName'] = $row['DeptName']; |
|||
$tmp['BillNo'] = $row['BillNo']; |
|||
$tmp['RowNo'] = $row['RowNo']; |
|||
$tmp['CU_MaterialId'] = $row['CU_MaterialId']; |
|||
$tmp['BizPartnerName'] = $row['BizPartnerName']; |
|||
$tmp['CU_EstPayDate'] = date('Y/m/d', strtotime($row['CU_EstPayDate'])); |
|||
$tmp['checkCollectMonth'] = checkCollectMonth($row); |
|||
$tmp['checkArCheckBillStatus'] = checkArCheckBillStatus($row); |
|||
$tmp['UnTransCheckBLAmtWTax'] = number_format(intval($row['UnTransCheckBLAmtWTax']), 0, '', ','); |
|||
$tmp['HadTransCheckBLAmtWTax'] = number_format(intval($row['HadTransCheckBLAmtWTax']), 0, '', ','); |
|||
$tmp['BillNo2'] = $row['BillNo2']; |
|||
$tmp['arSellInvoiceMaterial'] = arSellInvoiceMaterial($row); |
|||
$tmp['RowCode2'] = $row['RowCode2']; |
|||
$tmp['BillNo3'] = $row['BillNo3']; |
|||
$tmp['InvoiceName'] = $row['InvoiceName']; |
|||
$tmp['OAmountWithTax'] = number_format(intval($row['OAmountWithTax']), 0, '', ','); |
|||
$tmp['InvoiceNo'] = $row['InvoiceNo']; |
|||
$tmp['checkArWriteOffBill'] = checkArWriteOffBill($conn, $row); |
|||
array_push($data, $tmp); |
|||
} |
|||
|
|||
echo json_encode(array( |
|||
"draw" => intval($draw), |
|||
"recordsTotal" => $count, |
|||
"recordsFiltered" => $count, |
|||
"data" => $data |
|||
), JSON_UNESCAPED_UNICODE); |
@ -0,0 +1,357 @@ |
|||
<?php |
|||
require_once dirname(__FILE__) . "/../mkt/database.php"; |
|||
include "fun_global.php"; |
|||
require dirname(__DIR__) . '/common/composer/vendor/autoload.php'; |
|||
|
|||
use PhpOffice\PhpSpreadsheet\Spreadsheet; |
|||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
|||
use PhpOffice\PhpSpreadsheet\Style\Fill; |
|||
|
|||
// AJAX 顯示合約明細 |
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
|
|||
$form_name = $_POST['form_name']; |
|||
$type = $_POST['type']; |
|||
$mtype = $_POST['mtype']; |
|||
$year = $_POST['year']; |
|||
$month = $_POST['month']; |
|||
|
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
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); |
|||
if ($form_name == 'getShipping_makeExcel') { |
|||
$data = getShipping_makeExcel($type, $mtype, $year, $month); |
|||
downloadExcel($data); |
|||
} |
|||
if ($form_name == 'getInstalling_makeExcel') { |
|||
$data = getInstalling_makeExcel($type, $mtype, $year, $month); |
|||
downloadExcel($data); |
|||
} |
|||
if ($form_name == 'getInstalling2_makeExcel') { |
|||
$data = getInstalling2_makeExcel($type, $mtype, $year, $month); |
|||
downloadExcel($data); |
|||
} |
|||
if ($form_name == 'getQCing_makeExcel') { |
|||
$data = getQCing_makeExcel($type, $mtype, $year, $month); |
|||
downloadExcel($data); |
|||
} |
|||
if ($form_name == 'getDeliverying_makeExcel') { |
|||
$data = getDeliverying_makeExcel($type, $mtype, $year, $month); |
|||
downloadExcel($data); |
|||
} |
|||
} |
|||
|
|||
|
|||
function fixDataNull($data) |
|||
{ |
|||
foreach ($data as $key => $row) { |
|||
foreach ($row as $field => $value) { |
|||
if ($value === null) { |
|||
$data[$key][$field] = ''; |
|||
} |
|||
} |
|||
} |
|||
return $data; |
|||
} |
|||
|
|||
// 出貨台數 |
|||
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(fixDataNull($data), JSON_UNESCAPED_UNICODE); |
|||
} |
|||
|
|||
// 在裝台數 |
|||
function getInstalling($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND ( |
|||
tryrun_end_date = '' |
|||
OR tryrun_end_date IS NULL |
|||
) |
|||
"; |
|||
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(fixDataNull($data), JSON_UNESCAPED_UNICODE); |
|||
} |
|||
|
|||
// 完工台數 |
|||
function getInstalling2($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND tryrun_end_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND tryrun_end_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(fixDataNull($data), JSON_UNESCAPED_UNICODE); |
|||
} |
|||
|
|||
// QC台數 |
|||
function getQCing($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND end_qc_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND end_qc_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(fixDataNull($data), JSON_UNESCAPED_UNICODE); |
|||
} |
|||
|
|||
// 移交台數 |
|||
function getDeliverying($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND delivery_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND delivery_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(fixDataNull($data), JSON_UNESCAPED_UNICODE); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// 出貨台數 產生excel |
|||
function getShipping_makeExcel($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); |
|||
return mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
} |
|||
|
|||
// 在裝台數 產生excel |
|||
function getInstalling_makeExcel($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND ( |
|||
tryrun_end_date = '' |
|||
OR tryrun_end_date IS NULL |
|||
) |
|||
"; |
|||
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); |
|||
return mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
} |
|||
|
|||
// 完工台數 產生excel |
|||
function getInstalling2_makeExcel($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND tryrun_end_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND tryrun_end_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); |
|||
return mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
} |
|||
|
|||
// QC台數 產生excel |
|||
function getQCing_makeExcel($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND end_qc_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND end_qc_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); |
|||
return mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
} |
|||
|
|||
// 移交台數 產生excel |
|||
function getDeliverying_makeExcel($type, $mtype, $year, $month) |
|||
{ |
|||
|
|||
global $link; |
|||
// 建立一個新的 Spreadsheet 物件 |
|||
$sql = " |
|||
SELECT |
|||
* |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
"; |
|||
if (!empty($month)) { |
|||
$sql .= " AND delivery_date BETWEEN '$year-$month-01' AND '$year-$month-31'"; |
|||
} else { |
|||
$sql .= " AND delivery_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); |
|||
return mysqli_fetch_all($result, MYSQLI_ASSOC); |
|||
} |
|||
|
|||
|
|||
function downloadExcel($data) |
|||
{ |
|||
|
|||
$spreadsheet = new Spreadsheet(); |
|||
$sheet = $spreadsheet->getActiveSheet(); |
|||
$colArr = [ |
|||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', |
|||
]; |
|||
$colTitleArr = [ |
|||
'合約號', |
|||
'作番號', |
|||
'客戶名稱', |
|||
'預計出貨日', |
|||
'試車完工日', |
|||
'QC合格日', |
|||
'官檢日', |
|||
'移交日', |
|||
]; |
|||
$sheet->setTitle('出貨完工推移表'); |
|||
for ($i = 0; $i < count($colArr); $i++) |
|||
$sheet->setCellValue($colArr[$i] . '1', $colTitleArr[$i]); |
|||
|
|||
$i = 2; |
|||
foreach ($data as $row) { |
|||
$colContentArr = [ |
|||
$row['contractno'], |
|||
$row['facilityno'], |
|||
$row['custom'], |
|||
$row['real_arrival_date'], |
|||
$row['tryrun_end_date'], |
|||
$row['end_qc_date'], |
|||
$row['official_check_date'], |
|||
$row['delivery_date'] |
|||
]; |
|||
for ($j = 0; $j < count($colContentArr); $j++) |
|||
$sheet->setCellValue($colArr[$j] . $i, $colContentArr[$j]); |
|||
$i++; |
|||
} |
|||
|
|||
// 調整欄位大小 |
|||
foreach ($sheet->getColumnIterator() as $column) { |
|||
$sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); |
|||
} |
|||
|
|||
$writer = new Xlsx($spreadsheet); |
|||
$file_path = dirname(__DIR__) . '/wms/excel/' . 'gary_test.xlsx'; |
|||
try { |
|||
$writer->save($file_path); |
|||
// 回傳檔案路徑給 JavaScript |
|||
echo $file_path; |
|||
} catch (Exception $e) { |
|||
echo 'Error: ' . $e->getMessage(); |
|||
} |
|||
exit(); |
|||
} |
@ -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); |
|||
} |
@ -0,0 +1,435 @@ |
|||
<?php |
|||
// ini_set('display_errors', 'on'); |
|||
include "header.php"; |
|||
include "css/view/wipwhole-index.php"; |
|||
|
|||
|
|||
// 出貨台數 |
|||
function getShipping($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND ( |
|||
real_arrival_date IS NOT NULL |
|||
AND real_arrival_date != '' |
|||
) |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 在裝台數 |
|||
function getInstalling($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND ( |
|||
tryrun_end_date = '' |
|||
OR tryrun_end_date IS NULL |
|||
) |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 完工台數 |
|||
function getInstalling2($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND tryrun_end_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// QC台數 |
|||
function getQCing($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND end_qc_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 移交台數 |
|||
function getDeliverying($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
if (in_array($type, ['M1', 'MA'])) |
|||
$type = null; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND delivery_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
$contract_type = [ |
|||
'' => '新梯+汰改', |
|||
'A' => '新梯', |
|||
'B' => '汰改 M1+MA', |
|||
'M1' => '汰改 M1', |
|||
'MA' => '汰改 MA' |
|||
]; |
|||
foreach ($contract_type as $c_val => $c_key) { |
|||
$mtype = null; |
|||
if ($c_val == "M1") |
|||
$mtype = "M1"; |
|||
if ($c_val == "MA") |
|||
$mtype = "MA"; |
|||
?> |
|||
|
|||
<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' style="text-align:left !important;"> |
|||
<button type="button" class="btn btn-primary" id="btn_download">下載excel</button> |
|||
</div> |
|||
</div> |
|||
<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>QC合格日</th> |
|||
<th>官檢日</th> |
|||
<th>移交日</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='15'> |
|||
<h4>出貨完工推移表(<?php echo $c_key; ?>)</h4> |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>階段台數</th> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>年度</th> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='12'>月份</th> |
|||
<th style='text-align:center;vertical-align:middle;' rowspan='2'>合計</th> |
|||
</tr> |
|||
<tr> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td style='text-align:center;'>" . $i . "月</td>"; |
|||
} |
|||
?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
$type_arr = [ |
|||
'A' => '出貨台數', |
|||
'B' => '在裝台數', |
|||
'C' => '完工台數', |
|||
'D' => 'QC台數', |
|||
'E' => '移交台數' |
|||
]; |
|||
foreach ($type_arr as $val => $key) { |
|||
?> |
|||
<tr> |
|||
<td style='text-align:center;vertical-align:middle;' rowspan='2'> |
|||
<?php |
|||
echo $key; |
|||
echo "<br/>"; |
|||
if ($val == 'A') |
|||
echo "<span style='font-size:12px;'>有出貨日</span>"; |
|||
if ($val == 'B') |
|||
echo "<span style='font-size:12px;'>沒有實際試車完工日</span> "; |
|||
if ($val == 'C') |
|||
echo "<span style='font-size:12px;'>有實際試車完工日</span> "; |
|||
if ($val == 'D') |
|||
echo "<span style='font-size:12px;'>有QC合格日</span> "; |
|||
if ($val == 'E') |
|||
echo "<span style='font-size:12px;'>移交日</span> "; |
|||
?> |
|||
|
|||
</td> |
|||
<td>前一年度(<?php echo (date("Y") - 1); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, $mtype, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
$onclick = "showDetail('getShipping', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, $mtype, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
$onclick = "showDetail('getInstalling', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, $mtype, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, $mtype, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
$onclick = "showDetail('getQCing', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, $mtype, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e . '</a></td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') { |
|||
$onclick = "showDetail('getShipping', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a_count . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$onclick = "showDetail('getInstalling', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b_count . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c_count . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$onclick = "showDetail('getQCing', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d_count . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '$mtype', '" . (date("Y") - 1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e_count . '</a></td>'; |
|||
} |
|||
?> |
|||
</tr> |
|||
<tr> |
|||
<td>本年度(<?php echo date("Y"); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, $mtype, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
$onclick = "showDetail('getShipping', '$c_val', '$mtype', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, $mtype, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
$onclick = "showDetail('getInstalling', '$c_val', '$mtype', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, $mtype, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '$mtype', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, $mtype, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
$onclick = "showDetail('getQCing', '$c_val', '$mtype', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, $mtype, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '$mtype', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e . '</a></td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') { |
|||
$onclick = "showDetail('getShipping', '$c_val', '$mtype', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $a_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$onclick = "showDetail('getInstalling', '$c_val', '$mtype', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $b_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '$mtype', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $c_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$onclick = "showDetail('getQCing', '$c_val', '$mtype', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $d_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '$mtype', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $e_count . ' </a></td>'; |
|||
} |
|||
?> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<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(form_name, type, mtype, year, month) { |
|||
$("#btn_download").attr("onclick", "generateButton('" + form_name + "', '" + type + "', '" + mtype + "', '" + year + "', '" + month + "')"); |
|||
$.ajax({ |
|||
type: "POST", |
|||
dataType: "json", |
|||
url: "ship_run_chart-model.php", |
|||
data: { |
|||
form_name: form_name, |
|||
type: type, |
|||
mtype: mtype, |
|||
year: year, |
|||
month: month |
|||
}, |
|||
complete: function(data) { |
|||
var data = data.responseJSON |
|||
var str = ""; |
|||
for (var i = 0; i < data.length; i++) { |
|||
str += "<tr>"; |
|||
str += "<td>" + data[i]['contractno'] + "</td>"; |
|||
str += "<td>" + data[i]['facilityno'] + "</td>"; |
|||
str += "<td>" + data[i]['custom'] + "</td>"; |
|||
str += "<td>" + data[i]['real_arrival_date'] + "</td>"; |
|||
str += "<td>" + data[i]['tryrun_end_date'] + "</td>"; |
|||
str += "<td>" + data[i]['end_qc_date'] + "</td>"; |
|||
str += "<td>" + data[i]['official_check_date'] + "</td>"; |
|||
str += "<td>" + data[i]['delivery_date'] + "</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({ |
|||
displayLength: 100, |
|||
}); |
|||
} |
|||
}) |
|||
} |
|||
|
|||
// 使用 JavaScript 監聽按鈕點擊事件 |
|||
function generateButton(form_name, type, mtype, year, month) { |
|||
|
|||
const formData = new FormData(); |
|||
formData.append("form_name", form_name + "_makeExcel"); |
|||
formData.append("type", type); |
|||
formData.append("mtype", mtype); |
|||
formData.append("year", year); |
|||
formData.append("month", month); |
|||
|
|||
// 使用 XMLHttpRequest 來呼叫 PHP 檔案,生成 Excel |
|||
var xhr = new XMLHttpRequest(); |
|||
xhr.open('POST', window.location.origin + "/wms/ship_run_chart-model.php", true); |
|||
xhr.responseType = 'text'; |
|||
xhr.onload = function() { |
|||
if (xhr.status === 200) { |
|||
// 取得 PHP 回傳的檔案路徑 |
|||
var response = xhr.responseText; |
|||
console.log(xhr.responseText); |
|||
var file_path = xhr.responseText; |
|||
// 創建下載連結 |
|||
var link = document.createElement('a'); |
|||
link.setAttribute('href', window.location.origin + "/wms/excel/gary_test.xlsx"); |
|||
// 設定下載的檔案名稱 |
|||
link.setAttribute('download', '出貨完工推移表.xlsx'); |
|||
link.style.display = 'none'; |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
} |
|||
}; |
|||
xhr.send(formData); |
|||
} |
|||
</script> |
|||
<?php |
|||
} |
|||
|
|||
include("footer.php"); |
|||
?> |
@ -0,0 +1,391 @@ |
|||
<?php |
|||
// ini_set('display_errors', 'on'); |
|||
include "header.php"; |
|||
include "css/view/wipwhole-index.php"; |
|||
|
|||
|
|||
// 出貨台數 |
|||
function getShipping($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND ( |
|||
real_arrival_date IS NOT NULL |
|||
AND real_arrival_date != '' |
|||
) |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 在裝台數 |
|||
function getInstalling($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND ( |
|||
install_start_date IS NOT NULL |
|||
OR install_start_date != '' |
|||
) |
|||
AND ( |
|||
install_end_date IS NULL |
|||
OR install_end_date = '' |
|||
) |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 完工台數 |
|||
function getInstalling2($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND install_start_date IS NOT NULL |
|||
AND install_start_date != '' |
|||
AND install_end_date IS NOT NULL |
|||
AND install_end_date != '' |
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// QC台數 |
|||
function getQCing($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND end_qc_date IS NOT NULL |
|||
AND end_qc_date != '' |
|||
|
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
|
|||
// 移交台數 |
|||
function getDeliverying($type, $mtype, $year, $month) |
|||
{ |
|||
global $link; |
|||
$sql = " |
|||
SELECT |
|||
count(*) AS all_count |
|||
FROM wipwholestatus |
|||
WHERE status = '1' |
|||
AND real_arrival_date BETWEEN '$year-$month-01' AND '$year-$month-31' |
|||
AND delivery_date IS NOT NULL |
|||
AND delivery_date != '' |
|||
|
|||
"; |
|||
$sql .= !empty($type) ? " AND contract_type = '$type'" : ""; |
|||
$sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; |
|||
$result = mysqli_query($link, $sql); |
|||
$data = mysqli_fetch_array($result, MYSQLI_ASSOC); |
|||
return $data['all_count']; |
|||
} |
|||
$contract_type = [ |
|||
'' => '新梯+汰改', |
|||
'A' => '新梯', |
|||
'B' => '汰改' |
|||
]; |
|||
foreach ($contract_type as $c_val => $c_key) { |
|||
|
|||
?> |
|||
|
|||
<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>QC合格日</th> |
|||
<th>官檢日</th> |
|||
<th>移交日</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='15'> |
|||
<h4>出貨完工推移表(<?php echo $c_key; ?>)</h4> |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>階段台數</th> |
|||
<th style='text-align:center;width:150px;vertical-align:middle;' rowspan='2'>年度</th> |
|||
<th style='text-align:center;vertical-align:middle;' colspan='12'>月份</th> |
|||
<th style='text-align:center;vertical-align:middle;' rowspan='2'>合計</th> |
|||
</tr> |
|||
<tr> |
|||
<?php |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
echo "<td style='text-align:center;'>" . $i . "月</td>"; |
|||
} |
|||
?> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
$type_arr = [ |
|||
'A' => '出貨台數', |
|||
'B' => '在裝台數', |
|||
'C' => '完工台數', |
|||
'D' => 'QC台數', |
|||
'E' => '移交台數' |
|||
]; |
|||
foreach ($type_arr as $val => $key) { |
|||
?> |
|||
<tr> |
|||
<td style='text-align:center;vertical-align:middle;' rowspan='2'> |
|||
<?php |
|||
echo $key; |
|||
echo "<br/>"; |
|||
if ($val == 'A') |
|||
echo "<span style='font-size:12px;'>有出貨日</span>"; |
|||
if ($val == 'B') |
|||
echo "<span style='font-size:12px;'>有安裝開工日,沒安裝完工日</span> "; |
|||
if ($val == 'C') |
|||
echo "<span style='font-size:12px;'>有安裝完工日</span> "; |
|||
if ($val == 'D') |
|||
echo "<span style='font-size:12px;'>有QC完工日</span> "; |
|||
if ($val == 'E') |
|||
echo "<span style='font-size:12px;'>移交日</span> "; |
|||
?> |
|||
|
|||
</td> |
|||
<td>前一年度(<?php echo (date("Y") - 1); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
$onclick = "showDetail('getShipping', '$c_val', '', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
$onclick = "showDetail('getInstalling', '$c_val', '', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
$onclick = "showDetail('getQCing', '$c_val', '', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, null, (date("Y") - 1), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '', '" . (date("Y") - 1) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e . '</a></td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') { |
|||
$onclick = "showDetail('getShipping', '$c_val', '', '" . (date("Y")-1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a_count . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$onclick = "showDetail('getInstalling', '$c_val', '', '" . (date("Y")-1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b_count . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '', '" . (date("Y")-1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c_count . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$onclick = "showDetail('getQCing', '$c_val', '', '" . (date("Y")-1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d_count . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '', '" . (date("Y")-1) . "', '')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e_count . '</a></td>'; |
|||
} |
|||
?> |
|||
</tr> |
|||
<tr> |
|||
<td>本年度(<?php echo date("Y"); ?>)</td> |
|||
<?php |
|||
$a_count = 0; |
|||
$b_count = 0; |
|||
$c_count = 0; |
|||
$d_count = 0; |
|||
$e_count = 0; |
|||
for ($i = 1; $i <= 12; $i++) { |
|||
if ($val == 'A') { |
|||
$a = getShipping($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$a_count += $a; |
|||
$onclick = "showDetail('getShipping', '$c_val', '', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $a . '</a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$b = getInstalling($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$b_count += $b; |
|||
$onclick = "showDetail('getInstalling', '$c_val', '', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $b . '</a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$c = getInstalling2($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$c_count += $c; |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $c . '</a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$d = getQCing($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$d_count += $d; |
|||
$onclick = "showDetail('getQCing', '$c_val', '', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $d . '</a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$e = getDeliverying($c_val, null, (date("Y")), str_pad($i, 2, '0', STR_PAD_LEFT)); |
|||
$e_count += $e; |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '', '" . (date("Y")) . "', '" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; |
|||
echo '<td style="text-align:center;"><a class="myBtn" href="#" onclick="' . $onclick . '">' . $e . '</a></td>'; |
|||
} |
|||
} |
|||
if ($val == 'A') { |
|||
$onclick = "showDetail('getShipping', '$c_val', '', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $a_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'B') { |
|||
$onclick = "showDetail('getInstalling', '$c_val', '', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $b_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'C') { |
|||
$onclick = "showDetail('getInstalling2', '$c_val', '', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $c_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'D') { |
|||
$onclick = "showDetail('getQCing', '$c_val', '', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $d_count . ' </a></td>'; |
|||
} |
|||
if ($val == 'E') { |
|||
$onclick = "showDetail('getDeliverying', '$c_val', '', '" . (date("Y")) . "', '')"; |
|||
echo '<td style="text-align:center;"> <a class="myBtn" href="#" onclick="' . $onclick . '">' . $e_count . ' </a></td>'; |
|||
} |
|||
?> |
|||
</tr> |
|||
<?php |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
|
|||
<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(form_name, type, mtype, year, month) { |
|||
$.ajax({ |
|||
type: "POST", |
|||
dataType: "json", |
|||
url: "ship_run_chart-model.php", |
|||
data: { |
|||
form_name: form_name, |
|||
type: type, |
|||
mtype: mtype, |
|||
year: year, |
|||
month: month |
|||
}, |
|||
complete: function(data) { |
|||
console.log(data); |
|||
var data = data.responseJSON |
|||
var str = ""; |
|||
for (var i = 0; i < data.length; i++) { |
|||
str += "<tr>"; |
|||
str += "<td>" + data[i]['contractno'] + "</td>"; |
|||
str += "<td>" + data[i]['facilityno'] + "</td>"; |
|||
str += "<td>" + data[i]['custom'] + "</td>"; |
|||
str += "<td>" + data[i]['real_arrival_date'] + "</td>"; |
|||
str += "<td>" + data[i]['tryrun_end_date'] + "</td>"; |
|||
str += "<td>" + data[i]['end_qc_date'] + "</td>"; |
|||
str += "<td>" + data[i]['official_check_date'] + "</td>"; |
|||
str += "<td>" + data[i]['delivery_date'] + "</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 |
|||
} |
|||
|
|||
include("footer.php"); |
|||
?> |
Loading…
Reference in new issue