9 changed files with 1657 additions and 23 deletions
@ -0,0 +1,682 @@ |
|||||
|
<?php |
||||
|
|
||||
|
function isLeader($link, $user_id) |
||||
|
{ |
||||
|
if (getDepartmentId($link, $user_id) == '314' && getRoleId($link, $user_id) == '1') |
||||
|
return true; |
||||
|
if (getDepartmentId($link, $user_id) == '313' && getRoleId($link, $user_id) == '1') |
||||
|
return true; |
||||
|
if (getDepartmentId($link, $user_id) == '312' && getRoleId($link, $user_id) == '2') |
||||
|
return true; |
||||
|
if (getDepartmentId($link, $user_id) == '311' && getRoleId($link, $user_id) == '3') |
||||
|
return true; |
||||
|
if (getDepartmentId($link, $user_id) == '315' && getRoleId($link, $user_id) == '1') |
||||
|
return true; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 檢查是否為非相關人員進入當前頁面 |
||||
|
* @param string $user_id:使用者代碼(員工編號) |
||||
|
* @return bollean true:合法 false:非法 |
||||
|
*/ |
||||
|
function checkPageUserStatus($user_id) |
||||
|
{ |
||||
|
$user_department_id = accountidToDepartId($user_id); |
||||
|
$allow_arr = [ |
||||
|
'311', '312', '313', '314', '315', |
||||
|
'501', '511', '512', '513', '514', |
||||
|
'541', '542', '543', '544', '545', |
||||
|
'521', '531', |
||||
|
'250', |
||||
|
'220' |
||||
|
]; |
||||
|
if ($user_id == 'M0060') |
||||
|
return true; |
||||
|
if (in_array($user_department_id, $allow_arr)) |
||||
|
return true; |
||||
|
return false; |
||||
|
} |
||||
|
/** |
||||
|
* 寫入 `wipwhole_change_planning_customer_details` |
||||
|
* - $data: |
||||
|
* - 'id' => 作番大日程 id |
||||
|
* - 'all_contractno_change' => 是否更改全部合約號 |
||||
|
* - 'real_contract_arrival_date' => 原日期 |
||||
|
* - 'contract_arrival_date' => 新日期 |
||||
|
* - 'real_address' => 原工地地址 |
||||
|
* - 'old_real_address' => 新工地地址 |
||||
|
* - 'contractno' => 合約號 |
||||
|
* - 'tds' => 資料時間戳記 |
||||
|
* - 'form_key' => 本表單 form_key |
||||
|
* - 'user_id' => 申請者 id (員工編號) |
||||
|
* - 'change_status' => 寫入簽核狀態代碼 |
||||
|
* |
||||
|
* @param object $link: 資料庫連線 |
||||
|
* @param string $data: 新增資料 |
||||
|
*/ |
||||
|
function addWipwholeChangeContractdateDetails($link, $data) |
||||
|
{ |
||||
|
$user_id = $data['user_id']; |
||||
|
$tds = $data['tds']; |
||||
|
$id = $data['id']; |
||||
|
$custom_name = $data['custom_name']; |
||||
|
$change_status = $data['change_status']; |
||||
|
$sql2 = " |
||||
|
INSERT INTO `wipwhole_change_planning_customer_details` ( |
||||
|
`creater`, |
||||
|
`create_at`, |
||||
|
`wipwholestatus_id`, |
||||
|
`custom_name`, |
||||
|
`change_status` |
||||
|
) VALUES ( |
||||
|
'$user_id', |
||||
|
'$tds', |
||||
|
'$id', |
||||
|
'$custom_name', |
||||
|
'$change_status' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql2); |
||||
|
} |
||||
|
|
||||
|
function addFlow($link, $data) |
||||
|
{ |
||||
|
$last_id = $data['last_id']; |
||||
|
$form_key = $data['form_key']; |
||||
|
$flow_code = $data['change_status']; |
||||
|
$sql2 = " |
||||
|
INSERT into flow ( |
||||
|
system_id, |
||||
|
flow_id, |
||||
|
form_id, |
||||
|
form_key, |
||||
|
flow_code |
||||
|
) VALUES ( |
||||
|
'wws', |
||||
|
'wws04', |
||||
|
'$last_id', |
||||
|
'$form_key', |
||||
|
'$flow_code' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql2); |
||||
|
} |
||||
|
|
||||
|
function addSubflow($link, $data) |
||||
|
{ |
||||
|
$form_key = $data['form_key']; |
||||
|
$current_assigner = $data['current_assigner']; |
||||
|
$tds = $data['tds']; |
||||
|
$seq = $data['seq']; |
||||
|
$sql2 = " |
||||
|
INSERT INTO subflow ( |
||||
|
form_key, |
||||
|
seq, |
||||
|
current_assigner, |
||||
|
create_date |
||||
|
) values ( |
||||
|
'$form_key', |
||||
|
'$seq', |
||||
|
'$current_assigner', |
||||
|
'$tds' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql2); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 用大日程的合約號取得大日程表單唯一值 (id) |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @param string $contractno:合約編號 |
||||
|
* @return object 回傳 mysqli_fetch_all |
||||
|
*/ |
||||
|
function getWipwholestatusIdByConstractNo($link, $contractno) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
id |
||||
|
FROM wipwholestatus |
||||
|
WHERE contractno = '$contractno' |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$data = mysqli_fetch_all($result); |
||||
|
mysqli_free_result($result); |
||||
|
return $data; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得新申請簽核的 formk_key 用於新增 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @return string $formk_key |
||||
|
*/ |
||||
|
function getFomkeySeq($link) |
||||
|
{ |
||||
|
$sql = "SELECT appwms.nextval('form_key') form_key"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
if ($row = mysqli_fetch_row($res)) |
||||
|
return $row[0]; |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增通知 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param array $data kind:通知類型 related_id:關聯序號 title:通知標題 content:通知內容 permission:觀看者 creater:建立者 create_at:建立時間 |
||||
|
* @return string 簽核單 cid |
||||
|
*/ |
||||
|
function addNotice($link, $data) |
||||
|
{ |
||||
|
$kind = empty($data['kind']) ? "1" : $data['kind']; |
||||
|
$related_id = empty($data['related_id']) ? "" : $data['related_id']; |
||||
|
$title = empty($data['title']) ? "" : $data['title']; |
||||
|
$content = empty($data['content']) ? "" : $data['content']; |
||||
|
$permission = empty($data['permission']) ? "" : $data['permission']; |
||||
|
$creater = empty($data['creater']) ? "system" : $data['creater']; |
||||
|
$create_at = empty($data['create_at']) ? date("Y-m-d H:i:s") : $data['create_at']; |
||||
|
|
||||
|
$sql = " |
||||
|
INSERT INTO notice ( |
||||
|
kind, |
||||
|
related_id, |
||||
|
title, |
||||
|
content, |
||||
|
permission, |
||||
|
creater, |
||||
|
create_at |
||||
|
) VALUES( |
||||
|
'$kind', |
||||
|
'$related_id', |
||||
|
'$title', |
||||
|
'$content', |
||||
|
'$permission', |
||||
|
'$creater', |
||||
|
'$create_at' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得本次簽核的表單 cid 值 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $form_key 簽核單唯一值 |
||||
|
* @return string 簽核單 cid |
||||
|
*/ |
||||
|
function getCid($link, $form_key) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT form_id AS id FROM flow |
||||
|
WHERE form_key = '$form_key' |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($result); |
||||
|
return $row['id']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得此單據的大日程id值 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $cid 簽核單 cid |
||||
|
* @return string 簽核單 form_key |
||||
|
*/ |
||||
|
function getId($link, $cid) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT wipwholestatus_id AS id |
||||
|
FROM wipwhole_change_planning_customer_details |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($result); |
||||
|
return $row['id']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得本次簽核的表單form_key值 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $form_id 簽核單 cid |
||||
|
* @return string 簽核單 form_key |
||||
|
*/ |
||||
|
function getForm_key($link, $form_id) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
f.form_key |
||||
|
FROM flow AS f |
||||
|
LEFT JOIN subflow AS s |
||||
|
ON f.form_key = s.form_key |
||||
|
WHERE 1=1 |
||||
|
AND f.system_id = 'wws' |
||||
|
AND f.flow_id = 'wws04' |
||||
|
AND f.form_id = '$form_id' |
||||
|
AND f.flow_code IN ('A','B','D','C','Z') |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($result); |
||||
|
return empty($row['form_key']) ? null : $row['form_key']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 確認目前簽核狀態 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @return string 工務部主管accountid |
||||
|
*/ |
||||
|
function checkNowFormStatus($link) |
||||
|
{ |
||||
|
if (isset($_GET['cid']) || isset($_GET['form_key'])) { |
||||
|
$cid = isset($_GET['cid']) ? $_GET['cid'] : getCid($link, $_GET['form_key']); |
||||
|
$form_key = getForm_key($link, $cid); |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
flow_code |
||||
|
FROM flow |
||||
|
WHERE 1=1 |
||||
|
AND form_id = '$cid' |
||||
|
AND form_key = '$form_key' |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($result); |
||||
|
return empty($row['0']) ? null : $row['0']; |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得工務部主管編號 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $contract_type A:新梯 B:汰改 |
||||
|
* @return string 工務部主管accountid |
||||
|
*/ |
||||
|
function getGongWuokNo($link, $contract_type) |
||||
|
{ |
||||
|
if (isset($_GET['id']) || isset($_GET['form_key'])) |
||||
|
$id = isset($_GET['id']) ? $_GET['id'] : getId($link, getCid($link, $_GET['form_key'])); |
||||
|
$sql = " |
||||
|
SELECT DISTINCT |
||||
|
SUBSTR(address,1,2) |
||||
|
FROM `wipwholestatus` |
||||
|
WHERE id = '$id' |
||||
|
"; |
||||
|
$result = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($result); |
||||
|
// 新梯 |
||||
|
// 宜蘭=高培軒(M0087) 北=張潘榮(M0041) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102) |
||||
|
// 汰改 |
||||
|
// 宜蘭=高培軒(M0087) 北=吳宗紘(M0040) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102) |
||||
|
$arr = array( |
||||
|
"宜蘭" => "M0087", |
||||
|
"北" => "M0041", |
||||
|
"台北" => "M0041", |
||||
|
"基隆" => "M0041", |
||||
|
"新北" => "M0041", |
||||
|
"新竹" => "M0041", |
||||
|
"桃園" => "M0041", |
||||
|
"苗栗" => "M0113", |
||||
|
"中" => "M0113", |
||||
|
"南投" => "M0113", |
||||
|
"台中" => "M0113", |
||||
|
"彰化" => "M0113", |
||||
|
"雲林" => "M0113", |
||||
|
"南" => "M0102", |
||||
|
"台南" => "M0102", |
||||
|
"嘉義" => "M0102", |
||||
|
"屏東" => "M0102", |
||||
|
"高雄" => "M0102" |
||||
|
); |
||||
|
$arr2 = array( |
||||
|
"宜蘭" => "M0087", |
||||
|
"北" => "M0040", |
||||
|
"台北" => "M0040", |
||||
|
"基隆" => "M0040", |
||||
|
"新北" => "M0040", |
||||
|
"新竹" => "M0040", |
||||
|
"桃園" => "M0040", |
||||
|
"苗栗" => "M0113", |
||||
|
"中" => "M0113", |
||||
|
"南投" => "M0113", |
||||
|
"台中" => "M0113", |
||||
|
"彰化" => "M0113", |
||||
|
"雲林" => "M0113", |
||||
|
"南" => "M0102", |
||||
|
"台南" => "M0102", |
||||
|
"嘉義" => "M0102", |
||||
|
"屏東" => "M0102", |
||||
|
"高雄" => "M0102" |
||||
|
); |
||||
|
if ($contract_type == 'A') { |
||||
|
return empty($arr[$row[0]]) ? "" : $arr[$row[0]]; |
||||
|
} else { |
||||
|
return empty($arr2[$row[0]]) ? "" : $arr2[$row[0]]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得簽核者 user_id |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $form_key 本簽核單唯一值 |
||||
|
* @param string $seq 簽核者順序 |
||||
|
* @return string 簽核者accountid |
||||
|
*/ |
||||
|
function getCurrentAssigner($link, $form_key, $seq) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM subflow |
||||
|
WHERE form_key = '$form_key' |
||||
|
AND seq = '$seq' |
||||
|
"; |
||||
|
$subflow_data = mysqli_query($link, $sql); |
||||
|
$subflow = mysqli_fetch_array($subflow_data, MYSQLI_ASSOC); |
||||
|
return empty($subflow['current_assigner']) ? null : $subflow['current_assigner']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得本表單狀態代碼 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $cid 本簽核單 id |
||||
|
* @return string 表單狀態代碼 |
||||
|
*/ |
||||
|
function getChangeStatus($link, $cid) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
change_status |
||||
|
FROM wipwhole_change_planning_customer_details |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
$subflow_data = mysqli_query($link, $sql); |
||||
|
$subflow = mysqli_fetch_array($subflow_data, MYSQLI_ASSOC); |
||||
|
return empty($subflow['change_status']) ? null : $subflow['change_status']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得本表單狀態名稱 |
||||
|
* @param object $link 資料庫連線 |
||||
|
* @param string $cid 本簽核單 id |
||||
|
* @return string 本單據狀態名稱 |
||||
|
*/ |
||||
|
function getChangeStatusName($link, $cid) |
||||
|
{ |
||||
|
$dataArr = array( |
||||
|
'A' => '申請中', |
||||
|
'B' => '申請中', |
||||
|
'C' => '已取消', |
||||
|
'D' => '工務已通過', |
||||
|
'Z' => '已通過', |
||||
|
); |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
change_status |
||||
|
FROM wipwhole_change_planning_customer_details |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
$subflow_data = mysqli_query($link, $sql); |
||||
|
$subflow = mysqli_fetch_array($subflow_data, MYSQLI_ASSOC); |
||||
|
return empty($subflow['change_status']) ? "" : $dataArr[$subflow['change_status']]; |
||||
|
} |
||||
|
|
||||
|
function getNowFormStatus($link, $cid) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
change_status |
||||
|
FROM wipwhole_change_planning_customer_details |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
$subflow_data = mysqli_query($link, $sql); |
||||
|
$subflow = mysqli_fetch_array($subflow_data, MYSQLI_ASSOC); |
||||
|
return empty($subflow['change_status']) ? "" : $subflow['change_status']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得許MAX options |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @return object 回傳 mysqli_query |
||||
|
*/ |
||||
|
function getShengguanokOptions($link) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
accountid AS val , |
||||
|
name AS label |
||||
|
FROM `account` |
||||
|
WHERE `department_id` IN ('320') |
||||
|
AND `role_id` IN ('1') |
||||
|
"; |
||||
|
return mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得工務部門所有員工 options |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @return object 回傳 mysqli_query |
||||
|
*/ |
||||
|
function getGongwuokOptions($link, $user_id) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
a1.manager AS val , |
||||
|
a2.name AS label |
||||
|
FROM account AS a1 |
||||
|
LEFT JOIN account AS a2 |
||||
|
ON a1.manager = a2.accountid |
||||
|
WHERE a1.accountid = '$user_id' |
||||
|
"; |
||||
|
return mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 用 user_id(員工編號) 取得部門代碼 id |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @param string $user_id:使用者 id (員工編號) |
||||
|
* @return string 回傳 $department_id:部門代碼 |
||||
|
*/ |
||||
|
function getDepartmentId($link, $user_id) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
department_id |
||||
|
FROM account |
||||
|
WHERE accountid = '$user_id' |
||||
|
"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
mysqli_free_result($res); |
||||
|
return $row[0]; |
||||
|
} |
||||
|
function getRoleId($link, $user_id) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
role_id |
||||
|
FROM account |
||||
|
WHERE accountid = '$user_id' |
||||
|
"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
mysqli_free_result($res); |
||||
|
return $row[0]; |
||||
|
} |
||||
|
/** |
||||
|
* 取得生管主管 options |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @param string $id:作番大日程唯一值 |
||||
|
* @return object 回傳 mysqli_query |
||||
|
*/ |
||||
|
function getWipwholestatusDetail($link, $id) |
||||
|
{ |
||||
|
$db_query = " |
||||
|
SELECT * FROM |
||||
|
wipwholestatus WHERE id = '$id' |
||||
|
"; |
||||
|
$receivabledata = mysqli_query($link, $db_query); |
||||
|
return mysqli_fetch_array($receivabledata, MYSQLI_ASSOC); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得 wipwhole_change_planning_customer_details 所有資料並放入陣列 |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @param string $cid:表單唯一值 |
||||
|
* @return object 回傳 mysqli_fetch_array |
||||
|
*/ |
||||
|
function getWipwholeChangeContractdateDetails($link, $cid) |
||||
|
{ |
||||
|
$db_query = " |
||||
|
SELECT * FROM wipwhole_change_planning_customer_details |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
$receivabledata = mysqli_query($link, $db_query); |
||||
|
return mysqli_fetch_array($receivabledata, MYSQLI_ASSOC); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得生管主管 options |
||||
|
* @param object $link:資料庫連線 |
||||
|
* @param string $user_id:使用者 id (員工編號) |
||||
|
* @param string $id:大日程唯一值 |
||||
|
* @return object 回傳 mysqli_query |
||||
|
*/ |
||||
|
function getDateOptions($link, $user_id, $id) |
||||
|
{ |
||||
|
if ($user_id == 'M0060') { |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM `wipwhole_change_planning_customer_details` |
||||
|
WHERE 1=1 |
||||
|
AND wipwholestatus_id = '$id' |
||||
|
AND change_status in ('A','C','D','Z') |
||||
|
"; |
||||
|
} else if (isLeader($link, $user_id)) { |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM `wipwhole_change_planning_customer_details` |
||||
|
WHERE 1=1 |
||||
|
AND wipwholestatus_id = '$id' |
||||
|
"; |
||||
|
} else { |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
* |
||||
|
FROM `wipwhole_change_planning_customer_details` |
||||
|
WHERE 1=1 |
||||
|
AND creater = '$user_id' |
||||
|
AND wipwholestatus_id = '$id' |
||||
|
"; |
||||
|
} |
||||
|
return mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得提交表單後的回傳訊息 |
||||
|
* @param string $assign_status:簽核狀態代碼 |
||||
|
* @return string 回傳訊息 |
||||
|
*/ |
||||
|
function getAssignStatusMessage($data, $checkStatus) |
||||
|
{ |
||||
|
|
||||
|
if ($data['assign_status'] == 'A' || $data['assign_status'] == 'B') |
||||
|
if (empty($_POST['custom_name'])) |
||||
|
return "<p class='text-danger'>請填寫 客戶姓名 !</p>"; |
||||
|
if ($data['assign_status'] == 'C') |
||||
|
return "<p class='text-danger'>申請已取消</p>"; |
||||
|
if ($data['assign_status'] == 'Z') |
||||
|
return "<p class='text-danger'>申請已通過</p>"; |
||||
|
if (!$checkStatus) |
||||
|
return "<p class='text-danger'>請勿重複申請!</p>"; |
||||
|
return "<p class='text-danger'>已提交申請!</p>"; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 依照此表單狀態給予 select 選項 |
||||
|
* @param object $link:資料庫連線檔 |
||||
|
* @param string $user_id:使用者id (員工編號) |
||||
|
* @param string $nowFormStatus:此表單目前狀態代碼 |
||||
|
* @return string 回傳select字串 |
||||
|
*/ |
||||
|
function getAssignStatusSelect($link, $user_id, $nowFormStatus) |
||||
|
{ |
||||
|
$options_str = "<select name='assign_status' id='assign_status'>"; |
||||
|
if (empty($nowFormStatus)) { |
||||
|
if (isLeader($link, $user_id)) { |
||||
|
$options_str .= "<option value='A'>提出申請</option>"; |
||||
|
} else { |
||||
|
$options_str .= "<option value='B'>提出申請</option>"; |
||||
|
} |
||||
|
} |
||||
|
if (in_array(checkNowFormStatus($link), ['A', 'D'])) { |
||||
|
if ($user_id == 'M0060') |
||||
|
$options_str .= "<option value='Z'>通過</option>"; |
||||
|
$options_str .= "<option value='C'>取消</option>"; |
||||
|
} |
||||
|
if (checkNowFormStatus($link) == 'B') { |
||||
|
if (isLeader($link, $user_id)) |
||||
|
$options_str .= "<option value='D'>通過</option>"; |
||||
|
$options_str .= "<option value='C'>取消</option>"; |
||||
|
} |
||||
|
$options_str .= "</select>"; |
||||
|
return $options_str; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得此簽核單所有人簽核狀況 |
||||
|
* @param object $link:資料庫連線檔 |
||||
|
* @param string $form_key:此簽核單唯一值 |
||||
|
* @return object 回傳 mysqli_query |
||||
|
*/ |
||||
|
function getCurrentAssigners($link, $form_key) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
nowData.*, |
||||
|
nextData.next_current_assigner |
||||
|
FROM( |
||||
|
SELECT |
||||
|
f.flow_code, |
||||
|
s.seq, |
||||
|
(s.seq + 1) AS next_seq , |
||||
|
s.current_assigner, |
||||
|
wccd.change_status |
||||
|
FROM |
||||
|
flow AS f |
||||
|
LEFT JOIN subflow AS s ON f.form_key = s.form_key |
||||
|
LEFT JOIN wipwhole_change_planning_customer_details AS wccd ON wccd.id = f.form_id |
||||
|
WHERE |
||||
|
f.form_key = '$form_key' |
||||
|
AND f.system_id = 'wws' |
||||
|
AND f.flow_id = 'wws04' |
||||
|
) AS nowData |
||||
|
LEFT JOIN( |
||||
|
SELECT |
||||
|
s.seq, |
||||
|
s.current_assigner AS next_current_assigner |
||||
|
FROM |
||||
|
flow AS f |
||||
|
LEFT JOIN subflow AS s ON f.form_key = s.form_key |
||||
|
LEFT JOIN wipwhole_change_planning_customer_details AS wccd ON wccd.id = f.form_id |
||||
|
WHERE |
||||
|
f.form_key = '$form_key' |
||||
|
AND f.system_id = 'wws' |
||||
|
AND f.flow_id = 'wws04' |
||||
|
) AS nextData |
||||
|
ON nowData.next_seq = nextData.seq |
||||
|
"; |
||||
|
return mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
function checkStatus($link, $cid, $user_id) |
||||
|
{ |
||||
|
$sql = " |
||||
|
SELECT |
||||
|
change_status |
||||
|
FROM wipwhole_change_planning_customer_details |
||||
|
WHERE creater = '$user_id' |
||||
|
AND wipwholestatus_id = '$cid' |
||||
|
AND change_status NOT IN ('C','Z') |
||||
|
"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
return $res->num_rows > 0 ? false : true; |
||||
|
} |
@ -0,0 +1,273 @@ |
|||||
|
<?php |
||||
|
// echo $_POST['assign_status'];exit; |
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
$checkStatus = checkStatus($link, $id, $user_id); |
||||
|
if (!empty($_POST['custom_name'])) { |
||||
|
if ($checkStatus) { |
||||
|
|
||||
|
$all_contractno_change = empty($_POST['all_contractno_change']) ? null : $_POST['all_contractno_change']; |
||||
|
$custom_name = $_POST['custom_name']; |
||||
|
$contractno = $_POST['contractno']; |
||||
|
$next_users = $_POST['next_users']; |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
|
||||
|
// 單次申請 |
||||
|
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && empty($all_contractno_change)) { |
||||
|
$data_arr = array( |
||||
|
'id' => $id, |
||||
|
'all_contractno_change' => $all_contractno_change, |
||||
|
'custom_name' => $custom_name, |
||||
|
'contractno' => $contractno, |
||||
|
'tds' => $tds, |
||||
|
'form_key' => getFomkeySeq($link), |
||||
|
'user_id' => $user_id, |
||||
|
'change_status' => $_POST['assign_status'] |
||||
|
); |
||||
|
// 寫入表單主檔 |
||||
|
addWipwholeChangeContractdateDetails($link, $data_arr); |
||||
|
// 取得寫入後表單seq |
||||
|
$data_arr['last_id'] = $link->insert_id; |
||||
|
// 寫入待簽 |
||||
|
addFlow($link, $data_arr); |
||||
|
$data_arr['seq'] = '0'; |
||||
|
$data_arr['current_assigner'] = $user_id; |
||||
|
addSubflow($link, $data_arr); |
||||
|
$data_arr['seq'] = '1'; |
||||
|
$data_arr['current_assigner'] = $next_users; |
||||
|
addSubflow($link, $data_arr); |
||||
|
} |
||||
|
|
||||
|
// 批次申請 |
||||
|
if (($_POST['assign_status'] == 'A' || $_POST['assign_status'] == 'B') && !empty($all_contractno_change)) { |
||||
|
$wipwholestatus_id_arr = getWipwholestatusIdByConstractNo($link, $contractno); |
||||
|
foreach ($wipwholestatus_id_arr as $wipwholestatus_id) { |
||||
|
$data_arr = array( |
||||
|
'id' => $wipwholestatus_id[0], |
||||
|
'all_contractno_change' => $all_contractno_change, |
||||
|
'custom_name' => $custom_name, |
||||
|
'contractno' => $contractno, |
||||
|
'tds' => $tds, |
||||
|
'form_key' => getFomkeySeq($link), |
||||
|
'user_id' => $user_id |
||||
|
); |
||||
|
// 寫入表單主檔 |
||||
|
addWipwholeChangeContractdateDetails($link, $data_arr); |
||||
|
// 取得寫入後表單seq |
||||
|
$data_arr['last_id'] = $link->insert_id; |
||||
|
// 寫入待簽 |
||||
|
addFlow($link, $data_arr); |
||||
|
$data_arr['seq'] = '0'; |
||||
|
$data_arr['current_assigner'] = $user_id; |
||||
|
addSubflow($link, $data_arr); |
||||
|
$data_arr['seq'] = '1'; |
||||
|
$data_arr['current_assigner'] = $next_users; |
||||
|
addSubflow($link, $data_arr); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 單次申請 營業 |
||||
|
if ($_POST['assign_status'] == 'D') { |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
$next_users = $_POST['next_users']; |
||||
|
$seq = $_POST['seq']; |
||||
|
$sql = " |
||||
|
UPDATE wipwhole_change_planning_customer_details |
||||
|
SET change_status = 'D' |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = " |
||||
|
UPDATE flow |
||||
|
SET flow_code = 'D' |
||||
|
WHERE form_key = '$form_key' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = " |
||||
|
INSERT into subflow ( |
||||
|
form_key, |
||||
|
seq, |
||||
|
current_assigner, |
||||
|
create_date |
||||
|
) VALUES ( |
||||
|
'$form_key', |
||||
|
'2', |
||||
|
'$next_users', |
||||
|
'$tds' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
// 取消 |
||||
|
if ($_POST['assign_status'] == 'C') { |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
$next_users = "00000"; |
||||
|
if ($user_id == 'M0060') { |
||||
|
if (getChangeStatus($link, $cid) == 'D' || getChangeStatus($link, $cid) == 'A') { |
||||
|
$seq = $_POST['seq']; |
||||
|
} |
||||
|
$sql = " |
||||
|
INSERT into subflow ( |
||||
|
form_key, |
||||
|
seq, |
||||
|
current_assigner, |
||||
|
create_date |
||||
|
) VALUES ( |
||||
|
'$form_key', |
||||
|
'$seq', |
||||
|
'$next_users', |
||||
|
'$tds' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} else if (isLeader($link, $user_id)) { |
||||
|
if (getChangeStatus($link, $cid) == 'D') { |
||||
|
$sql = " |
||||
|
UPDATE subflow |
||||
|
SET current_assigner = '$next_users', |
||||
|
create_date = '$tds' |
||||
|
WHERE form_key = '$form_key' |
||||
|
AND seq = '$seq' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} else if (getChangeStatus($link, $cid) == 'A') { |
||||
|
$seq = $_POST['seq']; |
||||
|
$sql = " |
||||
|
UPDATE subflow |
||||
|
SET current_assigner = '$next_users', |
||||
|
create_date = '$tds' |
||||
|
WHERE form_key = '$form_key' |
||||
|
AND seq = '$seq' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} else { |
||||
|
$seq = $_POST['seq']; |
||||
|
$sql = " |
||||
|
INSERT into subflow ( |
||||
|
form_key, |
||||
|
seq, |
||||
|
current_assigner, |
||||
|
create_date |
||||
|
) VALUES ( |
||||
|
'$form_key', |
||||
|
'$seq', |
||||
|
'$next_users', |
||||
|
'$tds' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
} else { |
||||
|
$seq = $_POST['seq']; |
||||
|
$sql = " |
||||
|
UPDATE subflow |
||||
|
SET current_assigner = '$next_users', |
||||
|
create_date = '$tds' |
||||
|
WHERE form_key = '$form_key' |
||||
|
AND seq = '$seq' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
$sql = " |
||||
|
UPDATE wipwhole_change_planning_customer_details |
||||
|
SET change_status = 'C' |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = " |
||||
|
UPDATE flow |
||||
|
SET flow_code = 'Z' |
||||
|
WHERE form_key = '$form_key' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
// 通過 |
||||
|
if ($_POST['assign_status'] == 'Z') { |
||||
|
if ($user_id == 'M0060') { |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
$next_users = $_POST['next_users']; |
||||
|
$seq = $_POST['seq'] + 1; |
||||
|
$sql = " |
||||
|
UPDATE wipwhole_change_planning_customer_details |
||||
|
SET change_status = 'Z' |
||||
|
WHERE id = '$cid' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = " |
||||
|
UPDATE flow |
||||
|
SET flow_code = 'Z' |
||||
|
WHERE form_key = '$form_key' |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = " |
||||
|
INSERT into subflow ( |
||||
|
form_key, |
||||
|
seq, |
||||
|
current_assigner, |
||||
|
create_date |
||||
|
) VALUES ( |
||||
|
'$form_key', |
||||
|
'$seq', |
||||
|
'$next_users', |
||||
|
'$tds' |
||||
|
) |
||||
|
"; |
||||
|
mysqli_query($link, $sql); |
||||
|
|
||||
|
// // 發送系統通知 |
||||
|
// $contractno = $_POST['contractno']; |
||||
|
// $facilityno = $_POST['facilityno']; |
||||
|
// $real_contract_arrival_date = $_POST['real_contract_arrival_date']; |
||||
|
// $salesid = $_POST['salesid']; |
||||
|
// $gongWuokid = $_POST['gongWuokid']; |
||||
|
// $old_real_address = $_POST['old_real_address']; |
||||
|
// $real_address = $_POST['real_address']; |
||||
|
// $content = "合約號 : $contractno |
||||
|
// 作番號 : $facilityno |
||||
|
// 出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . " |
||||
|
// 工地地址微調: " . $old_real_address . " => " . $real_address_tmp; |
||||
|
|
||||
|
// // 大日程出貨日調整 通知營業人員 |
||||
|
// $noticeData = array( |
||||
|
// 'related_id' => $cid, |
||||
|
// 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, |
||||
|
// 'content' => $content, |
||||
|
// 'permission' => $salesid, |
||||
|
// ); |
||||
|
// addNotice($link, $noticeData); |
||||
|
// // 大日程出貨日調整 通知工務人員 |
||||
|
// $noticeData = array( |
||||
|
// 'related_id' => $cid, |
||||
|
// 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, |
||||
|
// 'content' => $content, |
||||
|
// 'permission' => $gongWuokid, |
||||
|
// ); |
||||
|
// addNotice($link, $noticeData); |
||||
|
|
||||
|
// $shengguano_arr = getShengguanokOptions($link); |
||||
|
// foreach ($shengguano_arr as $row) : |
||||
|
// $contractno = $_POST['contractno']; |
||||
|
// $facilityno = $_POST['facilityno']; |
||||
|
// $real_contract_arrival_date = $_POST['real_contract_arrival_date']; |
||||
|
// $gongWuokid = $_POST['gongWuokid']; |
||||
|
// $old_real_address = $_POST['old_real_address']; |
||||
|
// $real_address = $_POST['real_address']; |
||||
|
// $content = "合約號 : $contractno |
||||
|
// 作番號 : $facilityno |
||||
|
// 出貨日期微調: " . substr($real_contract_arrival_date, 0, 10) . " => " . substr($contract_arrival_date_tmp, 0, 10) . " |
||||
|
// 工地地址微調: " . $old_real_address . " => " . $real_address_tmp; |
||||
|
|
||||
|
// // 大日程出貨日調整 通知營業人員 |
||||
|
// $noticeData = array( |
||||
|
// 'related_id' => $cid, |
||||
|
// 'title' => '作番大日程(新梯)出貨日調整通知 > ' . $facilityno, |
||||
|
// 'content' => $content, |
||||
|
// 'permission' => $row['val'], |
||||
|
// ); |
||||
|
// addNotice($link, $noticeData); |
||||
|
// endforeach; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,528 @@ |
|||||
|
<?php |
||||
|
// ini_set('display_errors', 'on'); |
||||
|
|
||||
|
$token = empty($token) ? $_REQUEST["token"] : $token; |
||||
|
$token_link = "token=" . $_REQUEST["token"]; |
||||
|
list($user_id, $enc_user_name, $login_dt) = explode(".", $token); |
||||
|
$user_name = urldecode(base64_decode($enc_user_name)); |
||||
|
|
||||
|
|
||||
|
include 'IncludeCommon.php'; |
||||
|
include "header.php"; |
||||
|
require_once "database.php"; |
||||
|
|
||||
|
$includecommon = new IncludeCommon(); |
||||
|
$data = array(); |
||||
|
$sql = "SELECT * FROM account where accountid = '$user_id'"; |
||||
|
$data = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_array($data, MYSQLI_ASSOC); |
||||
|
$accounttype = $row['accounttype']; |
||||
|
|
||||
|
$login_json = null; |
||||
|
|
||||
|
if (strlen($accounttype) != 0) { |
||||
|
if ($accounttype == "B" || $accounttype == "M" || $accounttype == "E" || $accounttype == "W"){ |
||||
|
$response_result =['list'=>''] ; |
||||
|
$response_menu = $includecommon->menu_v3($user_id, $accounttype); |
||||
|
if (is_array($response_result["list"])) { |
||||
|
for ($i = 0; $i < count($response_result["list"]); $i++) { |
||||
|
$response_result["list"][$i]["path"] = $response_result["list"][$i]["path"] . "?token=" . $token; |
||||
|
} |
||||
|
} |
||||
|
$response_result["note"] = "success"; |
||||
|
$response_result["token"] = $token; |
||||
|
$farr = []; |
||||
|
$jsonres['menu']=$response_menu; |
||||
|
$login_json = json_encode($jsonres); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
<script> |
||||
|
// window.localStorage.setItem("menu_<?php echo $user_id; ?>", "123"); |
||||
|
|
||||
|
res=eval("("+<?php echo $login_json; ?>+")"); |
||||
|
if(res.code=='200'){ |
||||
|
var token=res.token; |
||||
|
var name=res.name; |
||||
|
var login=res.login; |
||||
|
var menu=res.menu; |
||||
|
window.localStorage.setItem("menu_"+res.uid,menu); |
||||
|
window.location.href='index.php?token='+token; |
||||
|
}else{ |
||||
|
window.location.href='login.php?errno=1'; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
</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"> |
||||
|
<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 colspan="2"> |
||||
|
<?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> |
||||
|
</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)) { |
||||
|
echoMaxSelect($max_options); |
||||
|
} 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) == 'A' || checkNowFormStatus($link) == 'D') { |
||||
|
echo " |
||||
|
<select name='next_users' id='next_users'> |
||||
|
<option value='00000'>00000</option> |
||||
|
</select> |
||||
|
"; |
||||
|
} else if (checkNowFormStatus($link) == 'B') { |
||||
|
if (isLeader($link, $user_id)) { |
||||
|
echoMaxSelect($max_options); |
||||
|
} 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 ($user_id == 'M0060') { |
||||
|
echo "<input type='hidden' name='seq' value = '2' />"; |
||||
|
} else 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>"; |
||||
|
} else if (checkNowFormStatus($link) == 'B') { |
||||
|
if (isLeader($link, $user_id)) { |
||||
|
echo "<input type='hidden' name='seq' value = '1' />"; |
||||
|
} else if ($user_id == 'M0060') { |
||||
|
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 (isLeader($link, $user_id)) { |
||||
|
echo "<input type='hidden' name='seq' value = '1' />"; |
||||
|
} else if ($user_id == 'M0060') { |
||||
|
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-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> |
Loading…
Reference in new issue