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

689 lines
26 KiB

<?php
// ini_set('display_errors', 'on');
$real_arrival_date_start = empty($_REQUEST['real_arrival_date_start']) ? date("Y") . '-01' : $_REQUEST['real_arrival_date_start'];
$real_arrival_date_end = empty($_REQUEST['real_arrival_date_end']) ? date("Y-m") : $_REQUEST['real_arrival_date_end'];
$radsY = SUBSTR($real_arrival_date_start, 0, 4);
$radsM = SUBSTR($real_arrival_date_start, 5, 2);
$radeY = SUBSTR($real_arrival_date_end, 0, 4);
$radeM = SUBSTR($real_arrival_date_end, 5, 2);
include "header.php";
// 出貨台數
function getShipping($type, $mtype, $radsY, $radsM, $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 '$radsY-$radsM-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, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(*) AS all_count
-- real_arrival_date,
-- tryrun_end_date
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND tryrun_end_date <= '$year-$month-31'
AND tryrun_end_date != ''
AND tryrun_end_date IS NOT 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 getEnding($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(
*
) AS all_count
-- real_arrival_date,
-- delivery_date,
-- official_check_date
FROM wipwholestatus
WHERE status = '1'
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND (delivery_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
OR
official_check_date BETWEEN '$radsY-$radsM-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 getInstalling2($type, $mtype, $radsY, $radsM, $year, $month)
{
global $link;
$sql = "
SELECT
count(*) AS all_count
-- delivery_date,
-- official_check_date
FROM wipwholestatus
WHERE status = '1'
AND real_arrival_date BETWEEN '$radsY-$radsM-01' AND '$year-$month-31'
AND (
delivery_date IS NULL
OR delivery_date = ''
OR delivery_date >= '$year-$month-31'
)
AND(
official_check_date IS NULL
OR official_check_date = ''
OR official_check_date >= '$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'];
}
?>
<form id='myForm' method='post' action='wipwhole-wipinstallstatus-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>
<h3 style='text-align:center'>在裝中統計表</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style='text-align:center'>
<?php
if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
echo "<span class='text-danger'>結束時間不可小於開始時間</span>";
}
?>
</td>
</tr>
<tr>
<td style='text-align:center'>
<input type="month" class='form-control' id='real_contract_arrival_date_start' name='real_arrival_date_start' value="<?php echo $real_arrival_date_start; ?>" style='width:20%;display:inline;'>
<input type="month" class='form-control' id='real_arrival_date_end' name='real_arrival_date_end' value="<?php echo $real_arrival_date_end; ?>" style='width:20%;display:inline;'>
</td>
</tr>
<tr>
<td style='text-align:center'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='clean_all_input()'>清除</button>
</td>
</tr>
</tfoot>
</table>
</form>
<?php
if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
exit;
}
?>
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto">
<thead>
<tr>
<th style="width:150px;" rowspan="2">出貨年月</th>
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
?>
<th style='text-align:center;' colspan="<?php echo $end_month * 4 ?>"><?php echo $radsYi . '年'; ?></th>
<?php
}
?>
</tr>
<tr>
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
?>
<th style='width:200px;text-align:center;' colspan="4"><?php echo (int)$start_month . '月'; ?></th>
<?php
}
?>
<?php
}
?>
</tr>
<tr>
<th>種類</th>
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
?>
<th style="background-color:#CECECE;">出貨</th>
<th style="background-color:#DEDEDE;">工收</th>
<th style="background-color:#EEEEEE;">試車完</th>
<th style="background-color:#FFFFFF;">在裝中</th>
<?php
}
?>
<?php
}
?>
</tr>
</thead>
<tbody>
<tr>
<td>新梯</td>
<?php
$a_count = 0;
$b_count = 0;
$c_count = 0;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// 新梯出貨
$all_count = 0;
$all_count = getShipping("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#CECECE;'>
<a href='#' onclick='showDetails("getShippingDetails","A","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 新梯工收
$all_count = 0;
$all_count = getEnding("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#DEDEDE;'>
<a href='#' onclick='showDetails("getEndingDetails","A","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 新梯試車完
$all_count = 0;
$all_count = getInstalling("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#EEEEEE;'>
<a href='#' onclick='showDetails("getInstallingDetails","A","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 新梯在裝中
$all_count = 0;
$all_count = getInstalling2("A", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#FFFFFF;'>
<a href='#' onclick='showDetails("getInstalling2Details","A","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
}
?>
<?php
}
?>
</tr>
<tr>
<td>M1</td>
<?php
$a_count = 0;
$b_count = 0;
$c_count = 0;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// M1出貨
$all_count = 0;
$all_count = getShipping("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#CECECE;'>
<a href='#' onclick='showDetails("getShippingDetails","B","M1","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// M1工收
$all_count = 0;
$all_count = getEnding("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#DEDEDE;'>
<a href='#' onclick='showDetails("getEndingDetails","B","M1","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// M1試車完
$all_count = 0;
$all_count = getInstalling("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#EEEEEE;'>
<a href='#' onclick='showDetails("getInstallingDetails","B","M1","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// M1在裝中
$all_count = 0;
$all_count = getInstalling2("B", "M1", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#FFFFFF;'>
<a href='#' onclick='showDetails("getInstalling2Details","B","M1","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
}
?>
<?php
}
?>
</tr>
<tr>
<td>MA</td>
<?php
$a_count = 0;
$b_count = 0;
$c_count = 0;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// MA出貨
$all_count = 0;
$all_count = getShipping("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#CECECE;'>
<a href='#' onclick='showDetails("getShippingDetails","B","MA","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// MA工收
$all_count = 0;
$all_count = getEnding("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#DEDEDE;'>
<a href='#' onclick='showDetails("getEndingDetails","B","MA","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// MA試車完
$all_count = 0;
$all_count = getInstalling("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#EEEEEE;'>
<a href='#' onclick='showDetails("getInstallingDetails","B","MA","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// MA在裝中
$all_count = 0;
$all_count = getInstalling2("B", "MA", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#FFFFFF;'>
<a href='#' onclick='showDetails("getInstalling2Details","B","MA","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
}
?>
<?php
}
?>
</tr>
<tr>
<td>合計</td>
<?php
$a_count = 0;
$b_count = 0;
$c_count = 0;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
// 出貨
$all_count = 0;
$all_count = getShipping("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#CECECE;'>
<a href='#' onclick='showDetails("getShippingDetails","","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 工收
$all_count = 0;
$all_count = getEnding("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#DEDEDE;'>
<a href='#' onclick='showDetails("getEndingDetails","","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 試車完
$all_count = 0;
$all_count = getInstalling("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#EEEEEE;'>
<a href='#' onclick='showDetails("getInstallingDetails","","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
// 在裝中
$all_count = 0;
$all_count = getInstalling2("", "", $radsY, $radsM, $radsYi, str_pad($start_month, 2, "0", STR_PAD_LEFT));
?>
<td style='background-color:#FFFFFF;'>
<a href='#' onclick='showDetails("getInstalling2Details","","","<?php echo $radsY ?>","<?php echo $radsM ?>","<?php echo $radsYi ?>","<?php echo $start_month ?>")'>
<?php echo $all_count ?>
</a>
</td>
<?php
}
?>
<?php
}
?>
</tr>
</tbody>
</table>
<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="myTable" class="table table-bordered" style="width:50%; margin:0 auto;">
<thead>
<tr>
<td>序列</td>
<td>合約號</td>
<td>作番號</td>
<td>出貨日</td>
<td>試車完工日</td>
<td>官檢日</td>
<td>移交日</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<style>
/* The Modal (background) */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
}
.modal .back {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.modal-content {
z-index: 9;
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
<script>
var modal = document.getElementById("myModal");
function showDetails(method, contract_type, renovate_type, radsY, radsM, radsYi, start_month) {
$("#myModal").show();
$.ajax({
type: "POST",
dataType: "html",
url: "wipwhole-wipinstallstatus-index-modal.php",
data: {
method: method+'Sql',
contract_type: contract_type,
renovate_type: renovate_type,
radsY: radsY,
radsM: radsM,
radsYi: radsYi,
start_month: start_month
},
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(data);
}
})
$.ajax({
type: "POST",
dataType: "json",
url: "wipwhole-wipinstallstatus-index-modal.php",
data: {
method: method,
contract_type: contract_type,
renovate_type: renovate_type,
radsY: radsY,
radsM: radsM,
radsYi: radsYi,
start_month: start_month
},
success: function(data) {
var str = "";
for (var i = 0; i < data.length; i++) {
var contractno = data[i].contractno;
var facilityno = data[i].facilityno
var real_arrival_date = data[i].real_arrival_date == null ? "" : data[i].real_arrival_date
var tryrun_end_date = data[i].tryrun_end_date == null ? "" : data[i].tryrun_end_date
var official_check_date = data[i].official_check_date == null ? "" : data[i].official_check_date
var delivery_date = data[i].delivery_date == null ? "" : data[i].delivery_date
str += "<tr>";
str += "<td>" + (i + 1) + "</td>";
str += "<td>" + contractno + "</td>";
str += "<td>" + facilityno + "</td>";
str += "<td>" + real_arrival_date + "</td>";
str += "<td>" + tryrun_end_date + "</td>";
str += "<td>" + official_check_date + "</td>";
str += "<td>" + delivery_date + "</td>";
str += "</tr>";
}
$("#myTable tbody").html(str);
},
error: function(data) {
console.log(data);
}
})
}
$("#myCloseBtn").click(function(e) {
$("#myModal").hide();
});
$(".back").click(function(e) {
$("#myModal").hide();
});
</script>