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.
528 lines
28 KiB
528 lines
28 KiB
<?php
|
|
// ini_set('display_errors', 'on');
|
|
|
|
/*
|
|
1. 有 cid 是已申請過的單
|
|
2. 沒有 cid 是新申請單
|
|
3. 若是從待簽過來 cid 從 form_key 取得
|
|
4. 大日程的 id 已申請過的從 cid 取得
|
|
5. 大日程的 id 新申請過的直接取得
|
|
*/
|
|
|
|
// ini_set('display_errors', 'on');
|
|
|
|
// include 'IncludeCommon.php';
|
|
require_once "database.php";
|
|
// $includecommon = new IncludeCommon();
|
|
include "header.php";
|
|
include "css/view/wipwhole-change-contractdate.php";
|
|
include "wipwhole-change-contractdate-function.php";
|
|
|
|
if (!checkPageUserStatus($user_id)) {
|
|
echo "此帳號無權限使用任何相關功能";
|
|
exit;
|
|
}
|
|
|
|
// 查詢數據
|
|
if (!empty($_GET['form_key'])) {
|
|
$cid = isset($_GET['cid']) ? $_GET['cid'] : getCid($link, $_GET['form_key']);
|
|
} else {
|
|
$cid = isset($_GET['cid']) ? $_GET['cid'] : null;
|
|
}
|
|
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : getForm_key($link, $cid);
|
|
$id = isset($_GET['id']) ? $_GET['id'] : getId($link, $cid);
|
|
|
|
include "wipwhole-change-contractdate-submit.php";
|
|
|
|
// select => options
|
|
$shengguanok_options = getShengguanokOptions($link);
|
|
$gongwuok_options = getGongwuokOptions($link);
|
|
|
|
// 帶入大日程資料
|
|
$row = getWipwholestatusDetail($link, $id);
|
|
// 帶入所有人歷史單據
|
|
$date_options = getDateOptions($link, $user_id, $id);
|
|
// 檢查此單據狀態非新申請則帶入申請資料
|
|
if (!empty(checkNowFormStatus($link)))
|
|
$row2 = getWipwholeChangeContractdateDetails($link, $cid);
|
|
|
|
?>
|
|
|
|
<div style="overflow-x:auto;">
|
|
<form method="post">
|
|
<div class="tab-pane active" class="assign_content" role="mainpanel" id="tabassign">
|
|
<!-- hidden域 -->
|
|
<input type="hidden" name="form_key" value='' />
|
|
<input type="hidden" value="" name="sheet_no" />
|
|
<table id='basic_info' class="form-content-table">
|
|
<thead>
|
|
<tr>
|
|
<td colspan="8" style="text-align:right;">
|
|
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
|
|
</td>
|
|
</tr>
|
|
<tr class="no-border">
|
|
<th colspan="8">
|
|
<h4>預計出貨日(到工地)調整申請表</h4>
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
</tr>
|
|
<tr class="no-border">
|
|
<th colspan="8">
|
|
<?php
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
// 檢查日期是否正確
|
|
echo getAssignStatusMessage($_POST, $checkStatus);
|
|
}
|
|
?>
|
|
</th>
|
|
</tr>
|
|
<tr class="no-border">
|
|
<th style="text-align:left;">
|
|
<b> 申請紀錄:</b>
|
|
</th>
|
|
<th colspan="3" style="text-align:left;">
|
|
<select class="select2" id="date_select" onchange="dateSelect()">
|
|
<option value="new">填寫新申請</option>
|
|
<?php
|
|
$change_status_name = array(
|
|
"A" => "新申請",
|
|
"B" => "新申請",
|
|
"D" => "新申請",
|
|
"Z" => "通過",
|
|
"C" => "取消",
|
|
);
|
|
while ($date_option = mysqli_fetch_assoc($date_options)) {
|
|
if ($cid == $date_option['id']) {
|
|
echo "<option selected value='" . $date_option['id'] . "'>" . $change_status_name[$date_option['change_status']] . "_" . $date_option['create_at'] . "</option>";
|
|
} else {
|
|
echo "<option value='" . $date_option['id'] . "'>" . $change_status_name[$date_option['change_status']] . "_" . $date_option['create_at'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</th>
|
|
<th colspan="4">
|
|
<span style="float: right;text-align:right;">
|
|
<b>申請日期:
|
|
<?php
|
|
echo empty(checkNowFormStatus($link)) ? date("Y-m-d") : $row2['create_at'];
|
|
?>
|
|
</b>
|
|
</span>
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td style="background-color:#ffffff;"> </td>
|
|
</tr>
|
|
<tr>
|
|
<th colspan="8">基本信息</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<th>申請人員編</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link))
|
|
? $user_id : $row2['creater'];
|
|
?>
|
|
</td>
|
|
<th>申請人</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link))
|
|
? accountidToName($user_id)
|
|
: accountidToName($row2['creater']);
|
|
?>
|
|
</td>
|
|
<th>申請人部門</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link))
|
|
? departIdToDepartName(accountidToDepartId($user_id))
|
|
: departIdToDepartName(accountidToDepartId($row2['creater']));
|
|
?>
|
|
</td>
|
|
<th>申請人職稱</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link))
|
|
? accountidToRoleName($user_id)
|
|
: accountidToRoleName($row2['creater']);
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>合約號</th>
|
|
<td>
|
|
<?php
|
|
echo $row["contractno"];
|
|
echo "<input type='hidden' name='contractno' value='" . $row["contractno"] . "' />";
|
|
?>
|
|
<br />
|
|
<?php
|
|
if (accountidToDepartId($user_id) !== '250')
|
|
if (empty(checkNowFormStatus($link)))
|
|
echo "
|
|
<input type='checkbox' name='all_contractno_change' value='1' />
|
|
變更此合約所有作番
|
|
";
|
|
?>
|
|
</td>
|
|
<th>作番號</th>
|
|
<td>
|
|
<?php
|
|
echo $row["facilityno"];
|
|
echo "<input type='hidden' name='facilityno' value='" . $row["facilityno"] . "' />";
|
|
?>
|
|
</td>
|
|
<th>客戶名稱</th>
|
|
<td>
|
|
<?php
|
|
echo $row["custom"];
|
|
echo "<input type='hidden' name='custom' value='" . $row["custom"] . "' />";
|
|
?>
|
|
</td>
|
|
<th>作番大日程</th>
|
|
<td>
|
|
<?php
|
|
$wipwhole_url = "wipwhole-rec-invoice-edit.php?function_name=wipwholerenstatus&$token_link&id=$id";
|
|
if ($row["contract_type"] === 'B')
|
|
$wipwhole_url = "wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&$token_link&id=$id";
|
|
?>
|
|
<a target='_blank' href="<?php echo $wipwhole_url; ?>" class="btn btn-info btn-sm">
|
|
開啟
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>營業/契約<br />人員員編</th>
|
|
<td>
|
|
<?php echo $row['salesid']; ?>
|
|
<?php echo "<input type='hidden' name='salesid' value='" . $row["salesid"] . "' />"; ?>
|
|
</td>
|
|
<th>營業/契約<br />人員</th>
|
|
<td>
|
|
<?php echo accountidToName($row['salesid']); ?>
|
|
</td>
|
|
<th>工務人員員編</th>
|
|
<td>
|
|
<?php echo getGongWuokNo($link, $row['contract_type']); ?>
|
|
<?php echo "<input type='hidden' name='gongWuokid' value='" . getGongWuokNo($link, $row['contract_type']) . "' />"; ?>
|
|
</td>
|
|
<th>工務人員</th>
|
|
<td>
|
|
<?php echo accountidToName(getGongWuokNo($link, $row['contract_type'])); ?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>下單日<br />(下單普來特富)</th>
|
|
<td>
|
|
<?php echo substr($row["prattford_order_date"], 0, 10); ?>
|
|
</td>
|
|
<th>預計發貨日<br />(出港日)</th>
|
|
<td>
|
|
<?php echo substr($row["estimated_shipping_date"], 0, 10); ?>
|
|
</td>
|
|
<th>預計到貨日<br />(到觀音廠日)</th>
|
|
<td>
|
|
<?php echo substr($row["estimated_shipping_schedule_date"], 0, 10); ?>
|
|
<input type='hidden' name='estimated_shipping_schedule_date' value='<?php echo $row['estimated_shipping_schedule_date']; ?>' />
|
|
</td>
|
|
<th>實際到貨日<br />(到觀音廠日)</th>
|
|
<td>
|
|
<?php echo substr($row["actual_tofactory_date"], 0, 10); ?>
|
|
<input type='hidden' name='actual_tofactory_date' value='<?php echo $row['estimated_shipping_schedule_date']; ?>' />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>合約交期</th>
|
|
<td>
|
|
<?php echo substr($row["contract_arrival_date"], 0, 10); ?>
|
|
</td>
|
|
<th>原出貨日</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link))
|
|
? substr($row['real_contract_arrival_date'], 0, 10)
|
|
: substr($row2["old_change_date"], 0, 10);
|
|
echo "<input type='hidden' name='real_contract_arrival_date' value='" . $row['real_contract_arrival_date'] . "' />";
|
|
?>
|
|
</td>
|
|
<th>調整出貨日</th>
|
|
<td colspan="3">
|
|
<?php
|
|
if (empty(checkNowFormStatus($link))) {
|
|
?>
|
|
<input type="date" name="contract_arrival_date" />
|
|
<?php
|
|
} else {
|
|
echo substr($row2["change_date"], 0, 10);
|
|
echo "<input type='hidden' name='contract_arrival_date' value='" . $row2["change_date"] . "' />";
|
|
}
|
|
?>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>地址</th>
|
|
<td>
|
|
<?php echo $row["address"]; ?>
|
|
</td>
|
|
<th>原工地地址</th>
|
|
<td>
|
|
<?php
|
|
echo empty(checkNowFormStatus($link)) ? $row['real_address'] : $row2["old_real_address"];
|
|
echo "<input type='hidden' name='old_real_address' value='" . $row['real_address'] . "' />";
|
|
?>
|
|
</td>
|
|
<th>調整工地地址</th>
|
|
<td colspan="3">
|
|
<?php
|
|
if (empty(checkNowFormStatus($link))) {
|
|
echo "<select id='city' name='city' required>";
|
|
$citys = getCity($link);
|
|
echo "<option value=''>請選擇</option>";
|
|
foreach ($citys as $city)
|
|
echo "<option value='" . $city['content'] . "'>" . $city['content'] . "</option>";
|
|
echo "</select>";
|
|
echo "<input type='text' id='real_address' name='real_address' />";
|
|
} else {
|
|
echo $row2["real_address"];
|
|
echo "<input type='hidden' name='real_address' value='" . $row2["real_address"] . "' />";
|
|
}
|
|
?>
|
|
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<table id="assign_area" class="form-content-table ">
|
|
<thead>
|
|
<tr>
|
|
<th colspan="8"><b>簽核操作 </b></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<th> 簽核狀態</th>
|
|
<td colspan="2">
|
|
<?php
|
|
if (checkNowFormStatus($link) == 'Z') {
|
|
echo getChangeStatusName($link, $cid);
|
|
} else {
|
|
$nowFormStatus = getNowFormStatus($link, $cid);
|
|
echo getAssignStatusSelect($link, $user_id, $nowFormStatus);
|
|
}
|
|
?>
|
|
</td>
|
|
<th class="td_title"> 下位簽核者</th>
|
|
<td colspan="2">
|
|
<?php
|
|
if (empty(checkNowFormStatus($link))) {
|
|
if (in_array(getDepartmentId($link, $user_id), ['250'])) {
|
|
echo "<input type='hidden' name='shengguanok_insert_status' value='1' />";
|
|
}
|
|
}
|
|
if (empty(checkNowFormStatus($link))) {
|
|
if (in_array(getDepartmentId($link, $user_id), ['521', '531', '541', '542', '543', '544', '545'])) {
|
|
echo "<select name='next_users' id='next_users'>";
|
|
foreach ($shengguanok_options as $shengguanok_option) :
|
|
echo "
|
|
<option value='" . $shengguanok_option['val'] . "'>" . $shengguanok_option['val'] . $shengguanok_option['label'] . "</option>
|
|
";
|
|
endforeach;
|
|
echo "</select>";
|
|
} else if (in_array(getDepartmentId($link, $user_id), ['250'])) {
|
|
echo "<select name='next_users' id='next_users'>";
|
|
foreach ($shengguanok_options as $shengguanok_option) :
|
|
echo "
|
|
<option value='" . $shengguanok_option['val'] . "'>" . $shengguanok_option['val'] . $shengguanok_option['label'] . "</option>
|
|
";
|
|
endforeach;
|
|
echo "</select>";
|
|
} else {
|
|
echo "
|
|
<select name='next_users' id='next_users'>
|
|
<option value='" . getGongWuokNo($link, $row['contract_type']) . "'>" . accountidToName(getGongWuokNo($link, $row['contract_type'])) . getGongWuokNo($link, $row['contract_type']) . "</option>
|
|
</select>
|
|
";
|
|
}
|
|
} else if (checkNowFormStatus($link) == 'A' || checkNowFormStatus($link) == 'D') {
|
|
echo "
|
|
<select name='next_users' id='next_users'>
|
|
<option value='00000'>00000</option>
|
|
</select>
|
|
";
|
|
} else if (checkNowFormStatus($link) == 'B') {
|
|
if (in_array(getDepartmentId($link, $user_id), ['521', '531', '541', '542', '543', '544', '545'])) {
|
|
echo "<select name='next_users' id='next_users'>";
|
|
foreach ($shengguanok_options as $shengguanok_option) :
|
|
echo "
|
|
<option value='" . $shengguanok_option['val'] . "'>" . $shengguanok_option['val'] . $shengguanok_option['label'] . "</option>
|
|
";
|
|
endforeach;
|
|
echo "</select>";
|
|
} else {
|
|
echo "
|
|
<select name='next_users' id='next_users'>
|
|
<option value='00000'>00000</option>
|
|
</select>
|
|
";
|
|
}
|
|
}
|
|
?>
|
|
</td>
|
|
<td colspan="2">
|
|
<?php
|
|
// 誰通過或取消簽核位子
|
|
if (empty(checkNowFormStatus($link))) {
|
|
echo "<input type='hidden' name='seq' value = '0' />";
|
|
echo "<button class='btn btn-primary'>提交</button>";
|
|
} else if (checkNowFormStatus($link) == 'A') {
|
|
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
|
|
echo "<input type='hidden' name='seq' value = '2' />";
|
|
} else if (in_array(accountidToDepartId($user_id), ["521", "531"])) {
|
|
echo "<input type='hidden' name='seq' value = '1' />";
|
|
} else {
|
|
echo "<input type='hidden' name='seq' value = '0' />";
|
|
}
|
|
echo "<button class='btn btn-primary'>提交</button>";
|
|
} else if (checkNowFormStatus($link) == 'B') {
|
|
if (in_array(accountidToDepartId($user_id), ["521", "531"])) {
|
|
echo "<input type='hidden' name='seq' value = '1' />";
|
|
} else if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
|
|
echo "<input type='hidden' name='seq' value = '2' />";
|
|
} else {
|
|
echo "<input type='hidden' name='seq' value = '0' />";
|
|
}
|
|
echo "<button class='btn btn-primary'>提交</button>";
|
|
} else if (checkNowFormStatus($link) == 'D') {
|
|
if (in_array(accountidToDepartId($user_id), ["521", "531"])) {
|
|
echo "<input type='hidden' name='seq' value = '1' />";
|
|
} else if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"])) {
|
|
echo "<input type='hidden' name='seq' value = '2' />";
|
|
} else {
|
|
echo "<input type='hidden' name='seq' value = '0' />";
|
|
}
|
|
echo "<button class='btn btn-primary'>提交</button>";
|
|
}
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
if (!empty(checkNowFormStatus($link))) {
|
|
$current_assigners = getCurrentAssigners($link, $form_key);
|
|
foreach ($current_assigners as $current_assigner) :
|
|
if ($current_assigner['current_assigner'] != '00000') {
|
|
?>
|
|
<tr>
|
|
<td colspan="1">
|
|
<?php
|
|
if ($current_assigner['seq'] == '0') {
|
|
echo "申請者";
|
|
} else {
|
|
echo departIdToDepartName(accountidToDepartId($current_assigner['current_assigner']));
|
|
}
|
|
?>
|
|
</td>
|
|
<td colspan="1">
|
|
<?php
|
|
if ($current_assigner['current_assigner'] !== '00000')
|
|
echo $current_assigner['current_assigner'] . "_" . accountidToName($current_assigner['current_assigner']);
|
|
?>
|
|
</td>
|
|
<td colspan="1">
|
|
<?php
|
|
if ($current_assigner['seq'] == '0') {
|
|
if ($current_assigner['next_current_assigner'] == '00000') {
|
|
if ($current_assigner['change_status'] == 'C') {
|
|
echo "已取消";
|
|
} else {
|
|
echo "已申請";
|
|
}
|
|
} else {
|
|
echo "已申請";
|
|
}
|
|
}
|
|
if ($current_assigner['seq'] == '1') {
|
|
if (isset($current_assigner['next_current_assigner'])) {
|
|
if ($current_assigner['next_current_assigner'] !== '00000') {
|
|
echo "已通過";
|
|
} else {
|
|
if ($current_assigner['change_status'] == 'C')
|
|
echo "已取消";
|
|
if ($current_assigner['change_status'] == 'Z')
|
|
echo "已通過";
|
|
}
|
|
} else {
|
|
if (!isset($current_assigner['next_current_assigner'])) {
|
|
if ($current_assigner['change_status'] == 'C') {
|
|
echo "已取消";
|
|
} else if ($current_assigner['change_status'] == 'Z') {
|
|
echo "已通過";
|
|
} else {
|
|
echo "審核中";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($current_assigner['seq'] == '2') {
|
|
if (isset($current_assigner['next_current_assigner'])) {
|
|
if ($current_assigner['next_current_assigner'] !== '00000') {
|
|
echo "已通過";
|
|
} else {
|
|
if ($current_assigner['change_status'] == 'C')
|
|
echo "已取消";
|
|
if ($current_assigner['change_status'] == 'Z')
|
|
echo "已通過";
|
|
}
|
|
} else {
|
|
if (!isset($current_assigner['next_current_assigner'])) {
|
|
if ($current_assigner['change_status'] == 'C') {
|
|
echo "已取消";
|
|
} else if ($current_assigner['change_status'] == 'Z') {
|
|
echo "已通過";
|
|
} else {
|
|
echo "審核中";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
endforeach;
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</form>
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div style="overflow-x:auto;">
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
$("title").text("<?php echo $row["contractno"]; ?>預計出貨日(到工地)調整申請表");
|
|
})
|
|
|
|
function dateSelect() {
|
|
if ($("#date_select").val() == 'new') {
|
|
window.location.href = "<?php echo "wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id"; ?>";
|
|
} else {
|
|
window.location.href = "<?php echo "wipwhole-change-contractdate.php?function_name=wipwholerenstatus&$token_link&id=$id&cid="; ?>" + $("#date_select").val();
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|