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.
 
 
 
 
 
 

518 lines
22 KiB

<?php
// ini_set('display_errors', 'on');
/**
* 權限規則:
* 1.營業經理查看全部 部門代碼:311 312 313 314 315
* 2.營業員瀏覽自己合約資料 部門代碼:511 512 513 514
* 3.設計部門代碼:911
* 4.工務:宜蘭=高培軒(M0087) 北=吳宗紘(M0040) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102)
* 5.生管:伃廷(M0024)
* 6.鍾哥 部門代碼:250 職位大小:1 4
* 7.許協理 部門代碼:320 職位大小:1
* 8.詹總 部門代碼:50 職位大小:1
* 9.許總 部門代碼:20 職位大小:1
*
* 新梯 543 筆 (已匯入)
* 舊改 141 筆 (已匯入)
* 已簽回 684 筆 (共計)
*/
include "header.php";
include "wipwhole-renovate-index-function.php";
include "css/view/wipwhole-renovate-index.php";
// 設定警告出貨到期的天數
$numberOfDaysToAdd = 45;
$futureDate = date("Y/m/d", strtotime(date("Y-m-d") . " +{$numberOfDaysToAdd} days"));
// 主資料陣列
$data = array();
// 取得當前使用者所屬部門
$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'];
// 取得資料 sql
$sql = getDataSql($department_id, $role_id, $user_id);
$data = mysqli_query($link, $sql);
// 取得資料(工勘部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "A");
$dataA = mysqli_query($link, $sql);
// 取得資料(營業部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "B");
$dataB = mysqli_query($link, $sql);
// 取得資料(設計部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "C");
$dataC = mysqli_query($link, $sql);
// 取得資料(生管階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "D");
$dataD = mysqli_query($link, $sql);
// 取得資料(結案階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "Z");
$dataZ = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
<form id='myForm' method='post' action='wipwhole-renovate-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-renovate-rec-invoice.php?function_name=wipwholerenstatus&<?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>
</tfoot>
</table>
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<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="showCTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showDTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
</nav>
<?php
$dataArr = array(
"All" => $data,
"A" => $dataA,
"B" => $dataB,
"C" => $dataC,
"D" => $dataD,
"Z" => $dataZ
);
foreach ($dataArr as $key => $val) {
if ($val) :
$dataDetailsArr = $val;
echo "<div id='data_" . $key . "_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
endif;
}
#結束連線
mysqli_close($link);
?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
var sheetNum = "<?php echo empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum']; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
$(".data_table_div").hide();
showTable(sheetNum);
})
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-renovate-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 estimatedShippingDateReportButton() {
window.location.href = '<?php echo "/wms/estimated_shipping_date_report.php?$token_link" ?>';
}
$('#table_index2,#table_index3,#table_index4,#table_index5,#table_index6,#table_index7').DataTable({
// columnDefs: [{
// width: 100,
// targets: 0
// },{
// width: 100,
// targets: 1
// },{
// width: 100,
// targets: 2
// },{
// width: 200,
// targets: 3
// },{
// width: 230,
// targets: 4
// },{
// width: 250,
// targets: 5
// },{
// width: 100,
// targets: 6
// }
// ,{
// width: 100,
// targets: 7
// }
// ,{
// width: 100,
// targets: 8
// }
// ,{
// width: 100,
// targets: 9
// }
// ,{
// width: 100,
// targets: 10
// }
// ,{
// width: 100,
// targets: 11
// }
// ,{
// width: 100,
// targets: 12
// }
// ,{
// width: 100,
// targets: 13
// }
// ,{
// width: 100,
// targets: 14
// }],
// fixedColumns: true,
// paging: false,
// scrollCollapse: true,
// scrollX: true,
"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"]
]
});
function showAllTable() {
sheetNum = "All";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showATable() {
sheetNum = "A";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showBTable() {
sheetNum = "B";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showCTable() {
sheetNum = "C";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showDTable() {
sheetNum = "D";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showZTable() {
sheetNum = "Z";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showTable(code) {
var tmp_arr = {
"All": "1",
"A": "2",
"B": "3",
"C": "4",
"D": "5",
"Z": "6",
}
$("body > nav.navbar.navbar-tabs > div > ul > li").attr("class", "");
$("body > nav.navbar.navbar-tabs > div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
$(".data_table_div").hide();
$("#data_" + code + "_table_div").show();
}
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index3_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index4_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index5_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index6_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index7_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 dataArr2 = {
"All": "table_index2",
"A": "table_index3",
"B": "table_index4",
"C": "table_index5",
"D": "table_index6",
"Z": "table_index7",
}
var table = $('#' + dataArr2[sheetNum]).DataTable();
table.search(searchContent).draw();
table.page.len(showNum).draw();
table.page((nowPage) - 1).draw('page');
// 監聽頁碼
table.on('page.dt', function() {
searchDatatable(table);
});
// 監聽資料筆數
table.on('length.dt', function(e, settings, len) {
searchDatatable(table);
});
// 監聽搜尋事件
$("#" + dataArr2[sheetNum] + "_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-renovate-index.php?function_name=wipinstall&$token_link"; ?>" +
"&showNum=" + showNum + "&nowPage=" + nowPage + "&searchContent=" + searchContent + "&sheetNum=" + sheetNum +
"&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;
}
</script>