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.
486 lines
24 KiB
486 lines
24 KiB
<?php
|
|
// ini_set('display_errors', 'on');
|
|
|
|
// function getAccounttype($link, $user_id)
|
|
// {
|
|
// $sql = "SELECT * FROM account where accountid = '$user_id'";
|
|
// $data = mysqli_query($link, $sql);
|
|
// $row = mysqli_fetch_array($data, MYSQLI_ASSOC);
|
|
// return $row['accounttype'];
|
|
// }
|
|
|
|
// include 'IncludeCommon.php';
|
|
require_once "database.php";
|
|
// $includecommon = new IncludeCommon();
|
|
include "header.php";
|
|
$token = empty($token) ? $_REQUEST["token"] : $token;
|
|
$token_link = "token=" . $token;
|
|
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
|
|
$user_name = urldecode(base64_decode($enc_user_name));
|
|
$accounttype = getAccounttype($link, $user_id);
|
|
|
|
$data = array();
|
|
$login_json = null;
|
|
if (strlen($accounttype) != 0) {
|
|
$jsonres['menu'] = $includecommon->menu_v3($user_id, $accounttype);
|
|
$login_json = json_encode($jsonres, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
?>
|
|
<script>
|
|
res = eval("(" + JSON.stringify(<?php echo $login_json; ?>) + ")");
|
|
window.localStorage.setItem("menu_<?php echo $user_id; ?>", res.menu);
|
|
</script>
|
|
<?php
|
|
/*
|
|
1. 有 cid 是已申請過的單
|
|
2. 沒有 cid 是新申請單
|
|
3. 若是從待簽過來 cid 從 form_key 取得
|
|
4. 大日程的 id 已申請過的從 cid 取得
|
|
5. 大日程的 id 新申請過的直接取得
|
|
*/
|
|
|
|
|
|
include "css/view/wipwhole-change-contractdate.php";
|
|
include "wipwhole-change-planning-customer-name-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-planning-customer-name-submit.php";
|
|
|
|
// select => options
|
|
$max_options = getShengguanokOptions($link);
|
|
$self_leader_options = getGongwuokOptions($link, $user_id);
|
|
|
|
// 帶入大日程資料
|
|
$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" enctype="multipart/form-data">
|
|
<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></th>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>地址</th>
|
|
<td>
|
|
<?php echo $row["address"]; ?>
|
|
</td>
|
|
<th>填寫客戶姓名</th>
|
|
<td>
|
|
<?php
|
|
if (empty(checkNowFormStatus($link))) {
|
|
echo "<input type='text' name='custom_name' />";
|
|
} else {
|
|
echo $row2["custom_name"];
|
|
echo "<input type='hidden' name='custom_name' value='" . $row2["custom_name"] . "' />";
|
|
}
|
|
?>
|
|
</td>
|
|
<th>上傳計劃圖</th>
|
|
<td colspan="3">
|
|
<input type='file' name='customer_planning_verify_file' id='customer_planning_verify_file' style='width:190px;' />
|
|
<?php
|
|
echo !empty($row2['customer_planning_verify_file']) ? "<a id='customer_planning_verify_file_a' style='color:#00F;' href='" . $row2['customer_planning_verify_file'] . "' target='_blank'>下載附件</a>" : "";
|
|
?>
|
|
</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
|
|
|
|
function echoMaxSelect($max_options)
|
|
{
|
|
echo "<select name='next_users' id='next_users'>";
|
|
foreach ($max_options as $max_option) :
|
|
echo "
|
|
<option value='" . $max_option['val'] . "'>" . $max_option['val'] . $max_option['label'] . "</option>
|
|
";
|
|
endforeach;
|
|
echo "</select>";
|
|
}
|
|
|
|
if (empty(checkNowFormStatus($link))) {
|
|
if (isLeader($link, $user_id)) {
|
|
echo "
|
|
<select name='next_users' id='next_users'>
|
|
<option value='00000'>00000</option>
|
|
</select>
|
|
";
|
|
} else if (in_array(getDepartmentId($link, $user_id), [
|
|
'311', '312', '313', '314', '315',
|
|
'501', '511', '512', '513', '514',
|
|
'220'
|
|
])) {
|
|
echo "<select name='next_users' id='next_users'>";
|
|
foreach ($self_leader_options as $option) :
|
|
echo "
|
|
<option value='" . $option['val'] . "'>" . $option['val'] . $option['label'] . "</option>
|
|
";
|
|
endforeach;
|
|
echo "</select>";
|
|
}
|
|
} else if (checkNowFormStatus($link) == 'B') {
|
|
if (isLeader($link, $user_id)) {
|
|
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) == 'B') {
|
|
if (isLeader($link, $user_id)) {
|
|
echo "<input type='hidden' name='seq' value = '1' />";
|
|
} 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-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id"; ?>";
|
|
} else {
|
|
window.location.href = "<?php echo "wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id&cid="; ?>" + $("#date_select").val();
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|