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.
 
 
 
 
 
 

575 lines
25 KiB

<div id="loadingOverlay" class="hidden">
<div class="loading-icon"></div>
</div>
<script>
document.getElementById('loadingOverlay').classList.remove('hidden');
</script>
<?php
// ini_set('display_errors', 'on');
/**
* 權限規則:
* 1.營業經理查看全部 部門代碼:311 312 313 314 315
* 2.營業員瀏覽自己合約資料 部門代碼:311 312 313 314 315
* 3.設計部門代碼:911
* 4.工務:宜蘭=高培軒(M0087) 北=張潘榮(M0041) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102)
* 5.生管:伃廷(M0024)
* 6.鍾哥(生管) 部門代碼:250 職位大小:1 4
* 7.許協理 部門代碼:320 職位大小:1
* 8.詹總 部門代碼:50 職位大小:1
* 9.許總 部門代碼:20 職位大小:1
*
* 新梯 543 筆 (已匯入)
* 舊改 141 筆 (已匯入)
* 已簽回 684 筆 (共計)
*/
include "header.php";
// 設定警告出貨到期的天數
$numberOfDaysToAdd = 45;
$futureDate = date("Y/m/d", strtotime(date("Y-m-d") . " +{$numberOfDaysToAdd} days"));
include "wipwhole-index-function.php";
include "css/view/wipwhole-index.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$form_name = empty($_REQUEST['form_name']) ? null : $_REQUEST['form_name'];
$del_seq = empty($_REQUEST['del_seq']) ? null : $_REQUEST['del_seq'];
if ($form_name == 'del_form') {
$sql = "UPDATE wipwholestatus SET status = '0' WHERE id = '$del_seq' ";
mysqli_query($link, $sql);
}
}
// 取得當前使用者所屬部門
$department_id = getDepartmentId($link, $user_id);
// 取得當前使用者所屬職位
$role_id = getRoleId($link, $user_id);
// 下方編輯按鈕權限
// 1=營叢 2=設計 4=工務 8=生管 15=其他
$edit_flag = getEditFlag($department_id, $role_id, $user_id);
// 接受搜尋 post 後觸發
$contractno = empty($_REQUEST['contractno']) ? null : $_REQUEST['contractno'];
$facilityno = empty($_REQUEST['facilityno']) ? null : $_REQUEST['facilityno'];
$custom = empty($_REQUEST['custom']) ? null : $_REQUEST['custom'];
$site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ? '' : $_REQUEST['site_survey_contact_verify'];
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : $_REQUEST['real_contract_arrival_date_start'];
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : $_REQUEST['real_contract_arrival_date_end'];
$area_no = !isset($_REQUEST['area_no']) ? '' : $_REQUEST['area_no'];
$sheetNum = empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum'];
$tableArr = array(
"All" => "",
"A" => "A",
"B" => "B",
"G" => "G",
"CH" => "C,H",
"Z" => "Z"
);
if (empty($sheetNum) || $sheetNum == "All") {
$sql = getDataSql($department_id, $role_id, $user_id);
} else {
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, $tableArr[$sheetNum]);
}
// 取得資料 sql
$data = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
<form id='myForm' method='post' action='wipwhole-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="9">
<h3 style='text-align:center'>作番大日程(新梯)</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th>合約號</th>
<td><input type="text" class='form-control' id='contractno' name='contractno' value="<?php echo $contractno; ?>"></td>
<th>電梯編號</th>
<td><input type="text" class='form-control' id='facilityno' name='facilityno' value="<?php echo $facilityno; ?>"></td>
<th>客戶姓名</th>
<td><input type="text" class='form-control' id='custom' name='custom' value="<?php echo $custom; ?>"></td>
<th>預計出貨日</th>
<td colspan="2">
<input type="date" class='form-control' id='real_contract_arrival_date_start' name='real_contract_arrival_date_start' value="<?php echo $real_contract_arrival_date_start; ?>" style='width:40%;display:inline;'>
<input type="date" class='form-control' id='real_contract_arrival_date_end' name='real_contract_arrival_date_end' value="<?php echo $real_contract_arrival_date_end; ?>" style='width:40%;display:inline;'>
</td>
</tr>
<tr>
<th>
區域
</th>
<td>
<?php
$area_status = array(
"" => "全部",
"N" => "N:北區",
"Y" => "Y:宜蘭",
"T" => "T:桃區",
"C" => "C:中區",
"K" => "K:南區"
);
?>
<select name="area_no" id="area_no">
<?php
foreach ($area_status as $key => $val) {
if ((string)$area_no == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<th>
工勘狀態
</th>
<td>
<?php
$site_survey_status = array(
"0" => "已確認",
"1" => "未確認",
"2" => "無工勘需求",
"A" => "未動工",
"B" => "地下室施工",
"C" => "打樁",
"D" => "地基",
"E" => "挖土",
"G" => "機房",
"H" => "機械式淨高",
"M" => "樓中樓",
"OH" => "最高層(頂樓高度)",
"P" => "PIT(機坑深度)",
"R" => "R 樓",
"S" => "停工",
"T" => "TOP",
"TC" => "頂部間隙",
"TS" => "行程",
"TH" => "全高",
"Y" => "已搭、已出",
"YB" => "退購結案",
"YF" => "既有建物",
"YN" => "已搭、未出"
);
for ($i = 1; $i < 200; $i++) {
$site_survey_status[$i . "F"] = $i . "F";
}
?>
<select style="width:100%;" name="site_survey_contact_verify" id="site_survey_contact_verify">
<?php
echo "<option value=''>全部</option>";
foreach ($site_survey_status as $key => $val) {
if ((string)$site_survey_contact_verify == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<td colspan="5" style='text-align:left'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
<?php
if ($department_id == '321' || $department_id == '220') {
?>
<a href="wipwhole-rec-invoice.php?function_name=wipwholestatus&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">新增</a>
<?php
}
?>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_input()'><?php echo $numberOfDaysToAdd; ?>天內資料</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_all_input()'><?php echo $numberOfDaysToAdd; ?>天內資料(含今天以前)</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='clean_all_input()'>清除</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='generateButton()'>匯出excel</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='estimatedShippingDateReportButton()'>出貨地區預定明細</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<div class="row">
<div class="col-md-9 col-12">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showGTable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showCHTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
<div class="col-md-3 col-12 text-right" id="myBtn">
<button class="btn btn-primary " type="button">欄位維護權限</button>
</div>
</div>
</div>
</nav>
<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'>
<h3>欄位維護權限</h3>
<hr>
<div class='row'>
<div class='col-12'>
<table class="table table-bordered" style="width:50%; margin:0 auto;">
<tr>
<th style="text-align:right;">欄位</th>
<th style="text-align:left;">維護單位</th>
</tr>
<tr>
<td style="text-align:right;">合約號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">電梯編號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">客戶姓名</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">規格</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">地址</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">工勘狀態</td>
<td style="text-align:left;">工勘人員</td>
</tr>
<tr>
<td style="text-align:right;">合約交期(到工地)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">下單日(普來特富)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">預計到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">實際到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">預計出貨日(到工地)</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">實際出貨日(到工地)</td>
<td style="text-align:left;">生管部門</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
echo "<div id='data_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-index-table-html.php";
echo "</div>";
// 結束連線
mysqli_close($link);
?>
<link href="/wms/css/select2.min.css" rel="stylesheet" />
<script src="/wms/css/select2.min.js"></script>
<script src="/wms/css/dataTables.fixedColumns.min.js"></script>
<style>
.dataTables_scrollHead .dataTable {
margin-bottom: -2px;
}
.dataTables_scrollBody .dataTable {
margin-bottom: 0;
}
table {
margin-left: 0px;
}
</style>
<script>
var sheetNum = "<?php echo $sheetNum; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
showTable(sheetNum);
document.getElementById('loadingOverlay').classList.add('hidden');
})
const formData = new FormData();
formData.append("contractno", "<?php echo empty($_POST['contractno']) ? null : $_POST['contractno']; ?>");
formData.append("facilityno", "<?php echo empty($_POST['facilityno']) ? null : $_POST['facilityno']; ?>");
formData.append("custom", "<?php echo empty($_POST['custom']) ? null : $_POST['custom']; ?>");
formData.append("site_survey_contact_verify", "<?php echo empty($_POST['site_survey_contact_verify']) ? '' : $_POST['site_survey_contact_verify']; ?>");
formData.append("real_contract_arrival_date_start", "<?php echo empty($_POST['real_contract_arrival_date_start']) ? null : $_POST['real_contract_arrival_date_start']; ?>");
formData.append("real_contract_arrival_date_end", "<?php echo empty($_POST['real_contract_arrival_date_end']) ? null : $_POST['real_contract_arrival_date_end']; ?>");
formData.append("area_no", "<?php echo empty($_POST['area_no']) ? null : $_POST['area_no']; ?>");
// 使用 JavaScript 監聽按鈕點擊事件
function generateButton() {
// 使用 XMLHttpRequest 來呼叫 PHP 檔案,生成 Excel
var xhr = new XMLHttpRequest();
xhr.open('POST', window.location.origin + "/wms/wipwhole-index-export-excel.php?<?= $token_link ?>", 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);
}
function clean_all_input() {
document.getElementById("site_survey_contact_verify").value = "";
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "";
document.getElementById("myForm").submit();
}
function day_before_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "<?php echo date("Y-m-d"); ?>";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function day_before_all_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function showAllTable() {
sheetNum = "All";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showATable() {
sheetNum = "A";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showBTable() {
sheetNum = "B";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showGTable() {
sheetNum = "G";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showCHTable() {
sheetNum = "CH";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showZTable() {
sheetNum = "Z";
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showTable(code) {
var tmp_arr = {
"All": "1",
"A": "2",
"B": "3",
"G": "4",
"CH": "5",
"Z": "6",
}
$("nav.navbar.navbar-tabs div > ul > li").attr("class", "");
$("nav.navbar.navbar-tabs div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
}
function estimatedShippingDateReportButton() {
window.location.href = '<?php echo "/wms/estimated_shipping_date_report.php?$token_link" ?>';
}
$('#table_index2').DataTable({
scrollX: true,
fixedHeader: true,
scrollY: 500,
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示_MENU_ 筆",
"zeroRecords": "沒有符合的結果",
"info": "第 _START_ 至 _END_ 項,共 _TOTAL_ 項",
"infoEmpty": "第 0 至 0 項,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
}
}, {
"order": [
[4, "desc"],
[8, "asc"]
]
}
);
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
// datatable 畫面重整後保留資料
var contractno = $("#contractno").val();
var facilityno = $("#facilityno").val();
var custom = $("#custom").val();
var site_survey_contact_verify = $("#site_survey_contact_verify").val();
var real_contract_arrival_date_start = $("#real_contract_arrival_date_start").val();
var real_contract_arrival_date_end = $("#real_contract_arrival_date_end").val();
var area_no = $("#area_no").val();
var showNum = <?php echo empty($_GET['showNum']) ? '10' : $_GET['showNum']; ?>;
var nowPage = <?php echo empty($_GET['nowPage']) ? '1' : $_GET['nowPage']; ?>;
var searchContent = "<?php echo empty($_GET['searchContent']) ? '' : $_GET['searchContent']; ?>";
var orderColumn = "<?php echo empty($_GET['orderColumn']) ? '' : $_GET['orderColumn']; ?>";
var orderDirection = "<?php echo empty($_GET['orderDirection']) ? '' : $_GET['orderDirection']; ?>";
var table = $('#table_index2').DataTable();
// 设置排序信息
if (orderColumn !== '' && orderDirection !== '') {
table.order([orderColumn, orderDirection]).draw();
}
table.search(searchContent).draw();
table.page.len(showNum).draw();
table.page((nowPage) - 1).draw('page');
// 監聽排序
table.on('order.dt', function() {
var order = table.order();
orderColumn = order[0][0];
orderDirection = order[0][1];
});
// 監聽頁碼
table.on('page.dt', function() {
searchDatatable(table);
});
// 監聽資料筆數
table.on('length.dt', function(e, settings, len) {
searchDatatable(table);
});
// 監聽搜尋事件
$("#table_index2_filter > label > input").change(function() {
searchDatatable(table);
});
function searchDatatable(table) {
showNum = table.page.len();
nowPage = table.page.info().page + 1;
searchContent = table.search();
window.location.href = "<?php echo "wipwhole-index.php?function_name=wipinstall&$token_link"; ?>" +
"&showNum=" + showNum + "&nowPage=" + nowPage + "&searchContent=" + searchContent + "&sheetNum=" + sheetNum +
"&orderColumn=" + orderColumn + "&orderDirection=" + orderDirection +
"&contractno=" + contractno + "&facilityno=" + facilityno + "&custom=" + custom +
"&site_survey_contact_verify=" + site_survey_contact_verify + "&real_contract_arrival_date_start=" + real_contract_arrival_date_start +
"&real_contract_arrival_date_end=" + real_contract_arrival_date_end + "&area_no=" + area_no;
}
function delete_wipwholestatus(id) {
$("#del_seq").val(id);
alert(id)
$("#del_form").submit();
}
</script>
<script>
var modal = document.getElementById("myModal");
$("#myBtn").click(function() {
$("#myModal").show();
});
$("#myCloseBtn").click(function(e) {
console.log(e.target);
$("#myModal").hide();
// modal.style.display = "none"
});
$(".back").click(function(e) {
$("#myModal").hide();
// modal.style.display = "none"
});
</script>
<form id='del_form' method='post'>
<input type='hidden' id='del_seq' name='del_seq' value='' />
<input type='hidden' id='form_name' name='form_name' value='del_form' />
</form>