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.
311 lines
12 KiB
311 lines
12 KiB
<?php
|
|
|
|
function getDataSql($department_id, $role_id, $user_id)
|
|
{
|
|
// 工務
|
|
if (in_array($department_id, [220, 521, 542, 543, 544, 545])) {
|
|
$sql = "
|
|
SELECT * FROM wipwholestatus
|
|
WHERE 1=1
|
|
" . getWipwholeSearchSql() . "
|
|
ORDER BY real_contract_arrival_date DESC
|
|
";
|
|
return $sql;
|
|
}
|
|
}
|
|
|
|
function getWipwholeSearchSql()
|
|
{
|
|
|
|
$area = [
|
|
'Y' => " '宜蘭','花蓮','台東' ",
|
|
'N' => " '臺北', '台北', '基隆', '新北' ",
|
|
'T' => " '桃園', '新竹' ",
|
|
'C' => " '南投', '臺中', '台中', '彰化', '雲林', '苗栗' ",
|
|
'K' => " '台南', '臺南', '嘉義', '屏東', '高雄' "
|
|
];
|
|
|
|
$contract_type = empty($_REQUEST['contract_type']) ? 'A' : trim($_REQUEST['contract_type']);
|
|
$contractno = empty($_REQUEST['contractno']) ? null : trim($_REQUEST['contractno']);
|
|
$facilityno = empty($_REQUEST['facilityno']) ? null : trim($_REQUEST['facilityno']);
|
|
$custom = empty($_REQUEST['custom']) ? null : trim($_REQUEST['custom']);
|
|
$site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ? null : trim($_REQUEST['site_survey_contact_verify']);
|
|
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : trim($_REQUEST['real_contract_arrival_date_start']);
|
|
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : trim($_REQUEST['real_contract_arrival_date_end']);
|
|
$area_no = empty($_REQUEST['area_no']) ? null : trim($_REQUEST['area_no']);
|
|
|
|
$sql = "";
|
|
|
|
$sql .= empty($contract_type) ? "" : " AND contract_type = '$contract_type' ";
|
|
$sql .= empty($area_no) ? "" : " AND SUBSTR(address,1,2) IN (" . $area[$area_no] . ") ";
|
|
$sql .= empty($contractno) ? "" : " AND contractno LIKE '%$contractno%' ";
|
|
$sql .= empty($facilityno) ? "" : " AND facilityno LIKE '%$facilityno%' ";
|
|
$sql .= empty($custom) ? "" : " AND custom LIKE '%$custom%' ";
|
|
$sql .= empty($real_contract_arrival_date_start) ? "" : " AND DATE_FORMAT(real_contract_arrival_date, '%Y-%m-%d') >= '$real_contract_arrival_date_start' ";
|
|
$sql .= empty($real_contract_arrival_date_end) ? "" : " AND DATE_FORMAT(real_contract_arrival_date, '%Y-%m-%d') <= '$real_contract_arrival_date_end' ";
|
|
if (isset($site_survey_contact_verify))
|
|
if ($site_survey_contact_verify != "")
|
|
$sql .= " AND site_survey_contact_verify = '" . $site_survey_contact_verify . "' ";
|
|
|
|
return $sql;
|
|
}
|
|
|
|
function getUserDepartId($user_id)
|
|
{
|
|
global $link;
|
|
$name = "";
|
|
$sql = "
|
|
select
|
|
d.department_id
|
|
from account AS a
|
|
LEFT JOIN department AS d
|
|
ON a.department_id = d.department_id
|
|
AND a.role_id = d.role_id
|
|
where a.accountid = '$user_id'
|
|
";
|
|
$res = mysqli_query($link, $sql);
|
|
while ($row = mysqli_fetch_row($res)) {
|
|
$name = $row[0];
|
|
}
|
|
mysqli_free_result($res);
|
|
return $name;
|
|
}
|
|
|
|
function getUserRoleId($user_id)
|
|
{
|
|
global $link;
|
|
$name = "";
|
|
$sql = "
|
|
select
|
|
d.role_id
|
|
from account AS a
|
|
LEFT JOIN department AS d
|
|
ON a.department_id = d.department_id
|
|
AND a.role_id = d.role_id
|
|
where a.accountid = '$user_id'
|
|
";
|
|
$res = mysqli_query($link, $sql);
|
|
while ($row = mysqli_fetch_row($res)) {
|
|
$name = $row[0];
|
|
}
|
|
mysqli_free_result($res);
|
|
return $name;
|
|
}
|
|
|
|
$contract_type = empty($_REQUEST['contract_type']) ? 'A' : trim($_REQUEST['contract_type']);
|
|
$contractno = empty($_REQUEST['contractno']) ? null : trim($_REQUEST['contractno']);
|
|
$facilityno = empty($_REQUEST['facilityno']) ? null : trim($_REQUEST['facilityno']);
|
|
$custom = empty($_REQUEST['custom']) ? null : trim($_REQUEST['custom']);
|
|
$site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ? null : trim($_REQUEST['site_survey_contact_verify']);
|
|
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : trim($_REQUEST['real_contract_arrival_date_start']);
|
|
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : trim($_REQUEST['real_contract_arrival_date_end']);
|
|
$area_no = empty($_REQUEST['area_no']) ? null : trim($_REQUEST['area_no']);
|
|
|
|
$area_status = array(
|
|
"" => "全部",
|
|
"N" => "N:北區",
|
|
"Y" => "Y:宜蘭",
|
|
"T" => "T:桃區",
|
|
"C" => "C:中區",
|
|
"K" => "K:南區"
|
|
);
|
|
|
|
$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";
|
|
}
|
|
|
|
?>
|
|
|
|
<!doctype html>
|
|
<html lang="en">
|
|
|
|
|
|
<?php
|
|
|
|
include "include-session-security.php";
|
|
|
|
require_once "db/database.php";
|
|
// $data = array();
|
|
// ec ho "<br/><br/><br/><br/>";
|
|
$sql = getDataSql(getUserDepartId($user_id), getUserRoleId($user_id), $user_id);
|
|
$data = mysqli_query($link, $sql);
|
|
|
|
include "include-header.php";
|
|
?>
|
|
|
|
|
|
<body>
|
|
|
|
<div id="loader">
|
|
<div class="spinner-border text-primary" role="status"></div>
|
|
</div>
|
|
|
|
<div class="appHeader bg-primary text-light">
|
|
<div class="left">
|
|
<a href="javascript:;" class="headerButton goBack">
|
|
<ion-icon name="chevron-back-outline"></ion-icon>
|
|
</a>
|
|
</div>
|
|
<div class="pageTitle">工勘回報</div>
|
|
</div>
|
|
|
|
|
|
<div id="appCapsule">
|
|
|
|
<div class="section full mt-2">
|
|
<p id="msg"></p>
|
|
<div class="wide-block pt-2 pb-2">
|
|
<form id="app-investigation" action="app-investigation.php" method="post" enctype="multipart/form-data">
|
|
<input type="hidden" value="<?php echo $token; ?>" name="token" />
|
|
<div class="section-title">合約號</div>
|
|
<div class="form-group boxed">
|
|
<div class="input-wrapper">
|
|
<input type="text" class="form-control" name="contractno" id="contractno" value="<?php echo !empty($contractno) ? $contractno : ""; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="section-title">電梯號</div>
|
|
<div class="form-group boxed">
|
|
<div class="input-wrapper">
|
|
<input type="text" class="form-control" name="facilityno" id="facilityno" value="<?php echo !empty($facilityno) ? $facilityno : ""; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="section-title">客戶姓名</div>
|
|
<div class="form-group boxed">
|
|
<div class="input-wrapper">
|
|
<input type="text" class="form-control" name="custom" id="custom" value="<?php echo !empty($custom) ? $custom : ""; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="section-title">區域</div>
|
|
<div class="form-group boxed">
|
|
<div class="input-wrapper">
|
|
<select class="form-control" 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>
|
|
</div>
|
|
</div>
|
|
<div class="section-title">工勘狀態</div>
|
|
<div class="form-group boxed">
|
|
<div class="input-wrapper">
|
|
<select class="form-control" 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>
|
|
</div>
|
|
</div>
|
|
<div class="section-title">類型</div>
|
|
<div class="custom-control custom-radio custom-control-inline">
|
|
<input type="radio" id="contract_type" name="contract_type" class="custom-control-input" value="A" <?php echo $contract_type == 'A' ? "checked" : ""; ?>>
|
|
<label class="custom-control-label" for="contract_type">新梯</label>
|
|
</div>
|
|
<div class="custom-control custom-radio custom-control-inline">
|
|
<input type="radio" id="contract_type2" name="contract_type" class="custom-control-input" value="B" <?php echo $contract_type == 'B' ? "checked" : ""; ?>>
|
|
<label class="custom-control-label" for="contract_type2">汰改</label>
|
|
</div>
|
|
<div class="mt-1 row">
|
|
<button type="submit" class="btn btn-primary btn-lg col-4 mx-1">
|
|
搜尋
|
|
</button>
|
|
<button type="button" onclick="resetAndSendform()" class="btn btn-secondary btn-lg col-4 mx-1">
|
|
清除
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="section mt-2">
|
|
<?php foreach ($data as $data) { ?>
|
|
<div class="card cart-item mb-2">
|
|
<div class="card-body">
|
|
<div class="in">
|
|
<div class="text">
|
|
<h3 class="title price">
|
|
<a href="app-investigation-update.php?token=<?php echo $token; ?>&id=<?php echo $data['id']; ?>">
|
|
<?php echo $data['custom']; ?>
|
|
<br />
|
|
合約號:<?php echo $data['contractno']; ?>
|
|
<br />
|
|
作番號:<?php echo $data['facilityno']; ?>
|
|
<br />
|
|
號機:<?php echo $data['facility_temp_no']; ?>
|
|
</a>
|
|
</h3>
|
|
<p class="detail">工勘狀態:<?php echo $site_survey_status[$data['site_survey_contact_verify']]; ?></p>
|
|
<p class="detail">地址:<?php echo $data['address']; ?></p>
|
|
<p class="detail">工地地址:<?php echo $data['real_address']; ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
include "include-footer.php";
|
|
mysqli_close($link);
|
|
include "include-jsfiles.php";
|
|
?>
|
|
<script>
|
|
function resetAndSendform() {
|
|
$("#contractno").val("");
|
|
$("#facilityno").val("");
|
|
$("#custom").val("");
|
|
$("#area_no").val("");
|
|
$("#site_survey_contact_verify").val("");
|
|
$("#contractno").val("");
|
|
$("#contract_type").prop("checked", true);
|
|
$("#app-investigation").submit();
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|