diff --git a/index.html b/index.html index eeb09682..26669857 100644 --- a/index.html +++ b/index.html @@ -1,8 +1,48 @@ - - - - - - + + + + + + + + + + +
+
+ LOGO +

開發連結

+ +
+
+ + + \ No newline at end of file diff --git a/wms/account-create.php b/wms/account-create.php index cd9e78e6..8497840f 100644 --- a/wms/account-create.php +++ b/wms/account-create.php @@ -31,17 +31,7 @@ $(function(){
Please fill up the required field!

"; - } else { - echo "

Record has added successfully

"; - } - } - */ ?> @@ -151,12 +141,14 @@ $(function(){ } ?> +
+
diff --git a/wms/account-record-submit.php b/wms/account-record-submit.php index 8ecd02b7..8b24d0ff 100644 --- a/wms/account-record-submit.php +++ b/wms/account-record-submit.php @@ -1,75 +1,153 @@ connect_errno) { + echo "連接 MySQL 失敗:" . $link->connect_error; + exit(); } - - // mysqli_insert_id可以抓到第一筆的id - //$new_id= mysqli_insert_id ($link); - #echo "新增後的id為 {$id} "; - $affected = mysqli_affected_rows($link); - mysqli_close($link); - if ($affected > 0) { - // 如果有一筆以上代表有更新 - echo ""; - } elseif ($affected == 0) { - echo ""; - } else { - echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); + + // 開始事務 + $link->begin_transaction(); + try { + + if (in_array($accounttype, ["B", "E", "M", "W"])) { + if (empty($department_id)) { + $department_id_error = "部門未填寫"; + throw new Exception('部門未填寫'); + } + if (empty($role_id)) { + $role_id_error = "職別未填寫"; + throw new Exception('職別未填寫'); + } + } + + + // 新增帳號 table account + $sql = "INSERT INTO account ( + accounttype, accountid, pwd, name, tel, + address, email, lineid, wechatid, phone_call_help, + chat_for_help, remote_help, repairerid, manager, department_id, + role_id, creater, create_at + )VALUES( + ?,?,?,?,?,?,?,?,?,?, + ?,?,?,?,?,?,?,? + ) + "; + $stmt = $link->prepare($sql); + $stmt->bind_param( + 'ssssssssssssssssss', + $i_data['accounttype'], + $i_data['accountid'], + $i_data['pwd'], + $i_data['name'], + $i_data['tel'], + $i_data['address'], + $i_data['email'], + $i_data['lineid'], + $i_data['wechatid'], + $i_data['phone_call_help'], + $i_data['chat_for_help'], + $i_data['remote_help'], + $i_data['repairerid'], + $i_data['manager'], + $i_data['department_id'], + $i_data['role_id'], + $i_data['creater'], + $i_data['create_at'] + ); + $stmt->execute(); + + // 新增權限 table account_auth + if (in_array($accounttype, ["B", "E", "M", "W"])) { + $sql = "INSERT INTO account_auth (accountid, permission) + SELECT '$accountid', permission FROM department WHERE department_id = ? AND role_id = ? + "; + $stmt2 = $link->prepare($sql); + $stmt2->bind_param('ss', $department_id, $role_id); + $stmt2->execute(); + } + + // 新增帳號 table employee + $sql = " + INSERT INTO employee ( + employee_no, + depart_no, + name, + mail + )VALUES( + ?, + ?, + ?, + ? + ); + "; + $stmt3 = $link->prepare($sql); + $stmt3->bind_param('ssss', $i_data['accountid'], $i_data['department_id'], $i_data['name'], $i_data['email']); + $stmt3->execute(); + + $link->commit(); + + $url = "location.href='account-index.php?function_name=account&" . $token_link . "';"; + redircetTo($url); + } catch (Exception $e) { + // 如果發生任何錯誤,回滾事務 + $link->rollback(); + // echo "rollback:" . $e->getMessage(); } + + // 關閉連接 + $link->close(); +} + + +function redircetTo($url) +{ + echo ""; } -?> \ No newline at end of file diff --git a/wms/account-record-update.php b/wms/account-record-update.php index a5a9171c..2cf3ee4e 100644 --- a/wms/account-record-update.php +++ b/wms/account-record-update.php @@ -4,63 +4,123 @@ include "header.php"; if (isset($_POST['update'])) { function user_input($data) { - $data1 = trim($data); - $data2 = stripslashes($data1); - $data3 = htmlspecialchars($data2); - return $data3; + return htmlspecialchars(stripslashes(trim($data))); } - $id = $_POST['id']; - $accounttype = user_input($_POST["accounttype"]); - $accountid = user_input($_POST["accountid"]); - $pwd = user_input($_POST["pwd"]); - $name = user_input($_POST["name"]); - $tel = user_input($_POST["tel"]); - $address = user_input($_POST["address"]); - $email = user_input($_POST["email"]); - $lineid = user_input($_POST["lineid"]); - $wechatid = user_input($_POST["wechatid"]); - $phone_call_help = user_input($_POST["phone_call_help"]); - $chat_for_help = user_input($_POST["chat_for_help"]); - $remote_help = user_input($_POST["remote_help"]); - $repairerid = user_input($_POST["repairerid"]); - $manager = user_input($_POST["manager"]); - $department_id = user_input($_POST["department_id"]); - $role_id = user_input($_POST["role_id"]); - $creater = user_input($_POST["creater"]); - $create_at = date('Y/m/d H:i:s'); + $id = $_POST['id']; + $accounttype = user_input($_POST["accounttype"]); + $accountid = user_input($_POST["accountid"]); + $pwd = user_input($_POST["pwd"]); + $name = user_input($_POST["name"]); + $tel = user_input($_POST["tel"]); + $address = user_input($_POST["address"]); + $email = user_input($_POST["email"]); + $lineid = user_input($_POST["lineid"]); + $wechatid = user_input($_POST["wechatid"]); + $phone_call_help = user_input($_POST["phone_call_help"]); + $chat_for_help = user_input($_POST["chat_for_help"]); + $remote_help = user_input($_POST["remote_help"]); + $repairerid = user_input($_POST["repairerid"]); + $manager = user_input($_POST["manager"]); + $department_id = user_input($_POST["department_id"]); + $role_id = user_input($_POST["role_id"]); + $creater = user_input($_POST["creater"]); + $create_at = date('Y-m-d H:i:s'); + // 檢查連接是否成功 + if ($link->connect_errno) { + echo "連接 MySQL 失敗:" . $link->connect_error; + exit(); + } + + // 開始事務 + $link->begin_transaction(); + + try { + if (in_array($accounttype, ["B", "E", "M", "W"])) { + if (empty($department_id)) { + $department_id_error = "部門未填寫"; + throw new Exception('部門未填寫'); + } + if (empty($role_id)) { + $role_id_error = "職別未填寫"; + throw new Exception('職別未填寫'); + } + } + + $sql = "UPDATE account + SET + pwd = ?, name = ?, tel = ?, address = ?, email = ?, + lineid = ?, wechatid = ?,phone_call_help = ?, chat_for_help = ?,remote_help = ?, + repairerid = ?, manager = ?, accounttype = ?, department_id = ?, role_id = ?, + creater = ?, create_at = ? + WHERE id = ? + "; + $stmt = $link->prepare($sql); + $stmt->bind_param( + 'ssssssssssssssssss', + $pwd, + $name, + $tel, + $address, + $email, + $lineid, + $wechatid, + $phone_call_help, + $chat_for_help, + $remote_help, + $repairerid, + $manager, + $accounttype, + $department_id, + $role_id, + $creater, + $create_at, + $id + ); + $stmt->execute(); - $db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', "; - $db_query .= "email = '$email', lineid = '$lineid', wechatid = '$wechatid', phone_call_help = '$phone_call_help', chat_for_help = '$chat_for_help', "; - $db_query .= "remote_help = '$remote_help', repairerid = '$repairerid', manager = '$manager', "; - $db_query .= "accounttype = '$accounttype', "; - $db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'"; - mysqli_query($link, $db_query); - $affected = mysqli_affected_rows($link); - if ((in_array($accounttype, ["B", "E", "M", "W"])) && $department_id && $role_id) { - $sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'"; - $res = mysqli_query($link, $sql); - if ($row = mysqli_fetch_row($res)) { - $db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'"; - mysqli_query($link, $db_query); + if (in_array($accounttype, ["B", "E", "M", "W"])) { + $sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'"; + $result = $link->query($sql); + if ($result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $permission = $row['permission']; + $sql = "UPDATE account_auth SET permission = '$permission' WHERE accountid = ?"; + $stmt2 = $link->prepare($sql); + $stmt2->bind_param('s', $accountid); + $stmt2->execute(); + } + } } - mysqli_free_result($res); + + $sql = "UPDATE employee + SET + depart_no = ? , + name = ? , + mail = ? + WHERE employee_no = ? + "; + $stmt3 = $link->prepare($sql); + $stmt3->bind_param('ssss', $department_id, $name, $email, $accountid); + $stmt3->execute(); + + $link->commit(); + + $url = "account-edit.php?function_name=account&id=$id&$token_link"; + redircetTo($url); + } catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; } mysqli_close($link); - if ($affected > 0) { - echo ""; - } elseif ($affected == 0) { - echo ""; - } else { - echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); - } +} + +function redircetTo($url) +{ + echo ""; } diff --git a/wms/account-user-input.php b/wms/account-user-input.php index 2af17727..b97ea5d2 100644 --- a/wms/account-user-input.php +++ b/wms/account-user-input.php @@ -29,7 +29,26 @@ $role_id = user_input($_POST["role_id"]); $creater = user_input($_POST["creater"]); $create_at = date('Y/m/d H:i:s'); - +$i_data = array( + "accounttype" => $accounttype, + "accountid" => $accountid, + "pwd" => $pwd, + "name" => $name, + "tel" => $tel, + "address" => $address, + "email" => $email, + "lineid" => $lineid, + "wechatid" => $wechatid, + "phone_call_help" => $phone_call_help, + "chat_for_help" => $chat_for_help, + "remote_help" => $remote_help, + "repairerid" => $repairerid, + "manager" => $manager, + "department_id" => $department_id, + "role_id" => $role_id, + "creater" => $creater, + "create_at" => $create_at +) /* diff --git a/wms/class/Ctranslate.php b/wms/class/Ctranslate.php index dbbbaa0e..14a67a4a 100644 --- a/wms/class/Ctranslate.php +++ b/wms/class/Ctranslate.php @@ -3,23 +3,35 @@ require_once __DIR__ . '/vendor/autoload.php'; use sqhlib\Hanzi\HanziConvert; -class Ctranslate extends HanziConvert{ - function simpleToTrad($str){ - return $this->convert($str,true); - } +class Ctranslate extends HanziConvert +{ - function tradToSimple($str){ - return $this->convert($str,false); + function fix($str){ + $arr = array( + '槼' => '規', + '讅' => '審', + ); + foreach($arr as $k => $v){ + $str = str_replace($k, $v, $str); + } + return $str; } -} -// $str = '平時已秉班揚筆,暇處不妨甘石經。吾里忻傳日邊信,君言頻中斗杓星。會稽夫子餘詩禮,巴蜀君平舊典型。歷歷周天三百度,更參璿玉到虞廷。'; -// echo HanziConvert::convert($str);//默认是繁体转简体 -// echo HanziConvert::convert($str,true);//第二个参数传入布尔真则是简体转繁体 + function simpleToTrad($str) + { + $str = $this->convert($str, true); + $str = $this->fix($str); + return $str; + } -//简体转繁体 -echo $str = '平时已秉班扬笔,暇处不妨甘石经。吾里忻传日边信,君言频中斗杓星。会稽夫子余诗礼,巴蜀君平旧典型。歷歷周天三百度,更参璇玉到虞廷。'; -echo "
"; + function tradToSimple($str) + { + return $this->convert($str, false); + } +} -$ct = new Ctranslate(); -echo $ct->simpleToTrad($str); \ No newline at end of file +// 简体转繁体 +// echo $str = '价格审查'; +// echo "
"; +// $ct = new Ctranslate(); +// echo $ct->simpleToTrad($str); diff --git a/wms/excel/sanlien.xlsx b/wms/excel/sanlien.xlsx index a36a6f3e..4dea8642 100644 Binary files a/wms/excel/sanlien.xlsx and b/wms/excel/sanlien.xlsx differ diff --git a/wms/excel/signed_overdue_date.xlsx b/wms/excel/signed_overdue_date.xlsx new file mode 100644 index 00000000..a16b51ab Binary files /dev/null and b/wms/excel/signed_overdue_date.xlsx differ diff --git a/wms/fun_global.php b/wms/fun_global.php index cb2462ec..653eeadf 100644 --- a/wms/fun_global.php +++ b/wms/fun_global.php @@ -202,7 +202,9 @@ function check_user_permission($user_id, $token) '/wms/delivery_kpi.php', '/wms/contract_m-index.php', '/wms/contract_b-index.php', - '/wms/report_system/signed_overdue_date.php' + '/wms/report_system/signed_overdue_date.php', + '/wms/basedata_system/departs_config.php', + '/wms/basedata_system/posts_config.php' ]; if (in_array($_SERVER["SCRIPT_NAME"], $ignore_url_arr)) return; diff --git a/wms/report_system/api/downloadExcel.php b/wms/report_system/api/downloadExcel.php index eb912df1..d33814f7 100644 --- a/wms/report_system/api/downloadExcel.php +++ b/wms/report_system/api/downloadExcel.php @@ -26,26 +26,78 @@ function alpha2num($a) } try { - $create_at_start = isset($_REQUEST['create_at_start']) ? $_REQUEST['create_at_start'] : ''; - $create_at_end = isset($_REQUEST['create_at_end']) ? $_REQUEST['create_at_end'] : ''; - if (!empty($create_at_start) && !empty($create_at_end)) { - $sql_str = "SELECT * - FROM sanlien_log - WHERE SUBSTR(create_at, 1, 10) - BETWEEN :create_at_start AND :create_at_end - "; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':create_at_start', $create_at_start); - $stmt->bindParam(':create_at_end', $create_at_end); - } else { - $sql_str = "SELECT * FROM sanlien_log "; - $stmt = $conn->prepare($sql_str); + $department_id = isset($_REQUEST['department_id']) ? $_REQUEST['department_id'] : ''; + $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : ''; + $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; + + $sql_str = " + SELECT + sm.system_name AS '序號', + fm.flow_name AS '系統名稱', + f.form_key AS '流程名稱', + sf.current_assigner AS '當前簽核者', + a.name AS '姓名', + d.depart_name AS '所屬部門', + sf.update_date AS '接收日期' + FROM flow AS f + LEFT JOIN system_main as sm + ON f.system_id = sm.system_id + LEFT JOIN flow_main as fm + ON f.flow_id = fm.flow_id + LEFT JOIN ( + SELECT + form_key, + current_assigner, + IF(update_date IS NULL,create_date,update_date) AS update_date, + MAX(seq) AS seq + FROM subflow + WHERE 1 = 1 + GROUP BY form_key, current_assigner, update_date + ) AS sf + ON f.form_key = sf.form_key + LEFT JOIN account AS a + ON sf.current_assigner = a.accountid + LEFT JOIN ( + SELECT DISTINCT + department_id, + name AS depart_name + FROM department + ) AS d + ON a.department_id = d.department_id + WHERE 1 =1 + AND f.flow_code != 'Z' + AND sf.form_key != '' + AND sf.form_key IS NOT NULL + AND sf.current_assigner != '' + AND sf.current_assigner IS NOT NULL + "; + $sql_str .= !empty($department_id) ? " AND a.department_id = :department_id " : ""; + $sql_str .= !empty($user_id) ? " AND sf.current_assigner = :user_id " : ""; + if (!empty($search)) { + $sql_str .= " AND ( + sm.system_name LIKE :search + OR fm.flow_name LIKE :search + OR f.form_key LIKE :search + OR sf.current_assigner LIKE :search + OR a.name LIKE :search + OR d.department_id LIKE :search + OR d.depart_name LIKE :search + OR sf.update_date LIKE :search + ) "; } + $stmt = $conn->prepare($sql_str); + + !empty($department_id) ? $stmt->bindParam(':department_id', $department_id) : ''; + !empty($user_id) ? $stmt->bindParam(':user_id', $user_id) : ''; + !empty($search) ? $stmt->bindValue(':search', '%' . $search . '%') : ''; + $stmt->execute(); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt->execute(); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); - $sheet->setTitle('三連地震數據'); + $sheet->setTitle('部門逾期待簽'); // 設定標題 $colTitleArr = []; @@ -69,7 +121,7 @@ try { $writer = new Xlsx($spreadsheet); - $file_path = dirname(dirname(dirname(__DIR__))) . '/wms/excel/' . 'sanlien.xlsx'; + $file_path = dirname(dirname(dirname(__DIR__))) . '/wms/excel/' . 'signed_overdue_date.xlsx'; $writer->save($file_path); try { diff --git a/wms/report_system/api/getSingedDetails.php b/wms/report_system/api/getSingedDetails.php index a9fd5dbf..99dafdee 100644 --- a/wms/report_system/api/getSingedDetails.php +++ b/wms/report_system/api/getSingedDetails.php @@ -2,85 +2,197 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { require_once('../conn.php'); - header("Content-Type: application/json; charset=UTF-8"); + $signDetails = new signDetails(); - echo $signDetails->getSingDetails(); + $method = !empty($_POST['method']) ? $_POST['method'] : ''; + + if ($method == 'getSingDetails') { + header("Content-Type: application/json; charset=UTF-8"); + echo $signDetails->getSingDetails(); + } + + if ($method == 'getSingDetailsAllCount') { + header("Content-Type: application/html; charset=UTF-8"); + echo $signDetails->getSingDetailsAllCount(); + } } class signDetails { - - public function getSingDetails() + public $count = 0; + public $now_page = 1; + public $end_page = 1; + public $per = 10; + public $system_name = ''; + public $department_id = ''; + public $user_id = ''; + public $search = ''; + + public function __construct() { - global $conn; + $this->now_page = !empty($_POST['now_page']) ? $_POST['now_page'] : 1; + $this->per = !empty($_POST['per']) ? $_POST['per'] : 10; + $this->system_name = !empty($_POST['system_name']) ? $_POST['system_name'] : ''; + $this->department_id = !empty($_POST['department_id']) ? $_POST['department_id'] : ''; + $this->user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : ''; + $this->search = !empty($_POST['search']) ? $_POST['search'] : ''; + } - $system_name = !empty($_POST['system_name']) ? $_POST['system_name'] : ''; - $department_id = !empty($_POST['department_id']) ? $_POST['department_id'] : ''; - $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : ''; + public function getSingDetailsAllCount() + { + global $conn; + global $connEkp; + $system_name = $this->system_name; + $department_id = $this->department_id; + $user_id = $this->user_id; + $search = $this->search; + $all_count = 0; + $wms_count = 0; + $bpm_count = 0; $sql_str = " - SELECT - sm.system_name, - fm.flow_name, - f.form_key, - sf.current_assigner, - a.name AS user_name, - d.department_id, - d.depart_name AS depart_name, - sf.update_date - FROM flow AS f - LEFT JOIN system_main as sm - ON f.system_id = sm.system_id - LEFT JOIN flow_main as fm - ON f.flow_id = fm.flow_id - LEFT JOIN ( - SELECT - form_key, - current_assigner, - IF(update_date IS NULL,create_date,update_date) AS update_date, - MAX(seq) AS seq - FROM subflow - WHERE 1 = 1 - GROUP BY form_key, current_assigner, update_date - ) AS sf - ON f.form_key = sf.form_key - LEFT JOIN account AS a - ON sf.current_assigner = a.accountid - LEFT JOIN ( - SELECT DISTINCT - department_id, - name AS depart_name - FROM department - ) AS d - ON a.department_id = d.department_id - WHERE 1 =1 - AND f.flow_code != 'Z' - AND sf.form_key != '' - AND sf.form_key IS NOT NULL - AND sf.current_assigner != '' - AND sf.current_assigner IS NOT NULL - "; - if(!empty($department_id)){ - $sql_str .= " AND d.department_id = :department_id "; - } - if(!empty($user_id)){ - $sql_str .= " AND sf.current_assigner = :user_id "; + SELECT + sm.system_name, + fm.flow_name, + f.form_key, + sf.current_assigner, + a.name AS user_name, + d.department_id, + d.depart_name AS depart_name, + sf.update_date + FROM flow AS f + LEFT JOIN system_main as sm + ON f.system_id = sm.system_id + LEFT JOIN flow_main as fm + ON f.flow_id = fm.flow_id + LEFT JOIN ( + SELECT + form_key, + current_assigner, + IF(update_date IS NULL,create_date,update_date) AS update_date, + MAX(seq) AS seq + FROM subflow + WHERE 1 = 1 + GROUP BY form_key, current_assigner, update_date + ) AS sf + ON f.form_key = sf.form_key + LEFT JOIN account AS a + ON sf.current_assigner = a.accountid + LEFT JOIN ( + SELECT DISTINCT + department_id, + name AS depart_name + FROM department + ) AS d + ON a.department_id = d.department_id + WHERE 1 =1 + AND f.flow_code != 'Z' + AND sf.form_key != '' + AND sf.form_key IS NOT NULL + AND sf.current_assigner != '' + AND sf.current_assigner IS NOT NULL + "; + $sql_str .= !empty($department_id) ? " AND a.department_id = :department_id " : ""; + $sql_str .= !empty($user_id) ? " AND sf.current_assigner = :user_id " : ""; + if (!empty($search)) { + $sql_str .= " AND ( + sm.system_name LIKE :search + OR fm.flow_name LIKE :search + OR f.form_key LIKE :search + OR sf.current_assigner LIKE :search + OR a.name LIKE :search + OR d.department_id LIKE :search + OR d.depart_name LIKE :search + OR sf.update_date LIKE :search + ) "; } $stmt = $conn->prepare($sql_str); - if(!empty($department_id)){ - $stmt->bindParam(':department_id', $department_id); - } - if(!empty($user_id)){ - $stmt->bindParam(':user_id', $user_id); + !empty($department_id) ? $stmt->bindParam(':department_id', $department_id) : ''; + !empty($user_id) ? $stmt->bindParam(':user_id', $user_id) : ''; + !empty($search) ? $stmt->bindValue(':search', '%' . $search . '%') : ''; + $stmt->execute(); + $wms_count = $stmt->rowCount(); + + $sql_str = " + SELECT + '藍凌BPM' AS system_name, + krt.fd_name AS flow_name, -- 流程名稱 + lp.fd_id AS form_key, + soe.fd_no AS current_assigner, -- 預計處理人員工編號 + soe.fd_name AS user_name, -- 預計處理人名稱 + '' AS department_id, + soe2.fd_name AS depart_name, -- 部門 + lp.fd_create_time AS update_date -- 創建時間 + FROM lbpm_process AS lp + LEFT JOIN km_review_template AS krt + ON lp.fd_template_model_id = krt.fd_id + LEFT JOIN lbpm_workitem AS lw + ON lp.fd_id = lw.fd_process_id + LEFT JOIN sys_org_element AS soe + ON lw.fd_expected_id = soe.fd_id + LEFT JOIN sys_org_element AS soe2 + ON soe2.fd_id = soe.fd_parentid + LEFT JOIN lbpm_history_workitem AS lhw + ON lp.fd_id = lhw.fd_process_id + WHERE 1=1 + -- AND lw.fd_status = '20' + AND lhw.fd_activity_type = 'reviewWorkitem' + AND krt.fd_name != '' + AND soe.fd_no != '' + "; + $sql_str .= !empty($department_id) ? " AND a.department_id = :department_id " : ""; + $sql_str .= !empty($user_id) ? " AND sf.current_assigner = :user_id " : ""; + if (!empty($search)) { + $sql_str .= " AND ( + krt.fd_name LIKE :search + OR lp.fd_id LIKE :search + OR soe.fd_no LIKE :search + OR soe.fd_name LIKE :search + OR soe2.fd_name LIKE :search + OR lp.fd_create_time LIKE :search + ) "; } + $stmt = $connEkp->prepare($sql_str); + !empty($department_id) ? $stmt->bindParam(':department_id', $department_id) : ''; + !empty($user_id) ? $stmt->bindParam(':user_id', $user_id) : ''; + !empty($search) ? $stmt->bindValue(':search', '%' . $search . '%') : ''; $stmt->execute(); - $data = $stmt->fetchAll(PDO::FETCH_ASSOC); - return json_encode($data, JSON_UNESCAPED_UNICODE); + $bpm_count = $stmt->rowCount(); + + $all_count = $wms_count + $bpm_count; + if ($system_name == 'wms') + return $wms_count; + if ($system_name == 'bpm') + return $bpm_count; + return $all_count; } - public function getSingDetailsAllCount() + public function getNowPage() + { + return $this->now_page = !empty($_POST['now_page']) ? $_POST['now_page'] : 1; + } + + public function getEndPage() + { + $count = $this->getSingDetailsAllCount(); + return $this->end_page = ceil($count / $this->per); + } + + public function getSingDetails() { global $conn; + global $connEkp; + $system_name = $this->system_name; + $department_id = $this->department_id; + $user_id = $this->user_id; + $search = $this->search; + $per = $this->per; + $now_page = $this->now_page; + $limit_start = ($now_page - 1) * $per; + $data = []; + $wms_data = []; + $bpm_data = []; + $sql_str = " SELECT sm.system_name, @@ -90,8 +202,8 @@ class signDetails a.name AS user_name, d.department_id, d.depart_name AS depart_name, - -- d.name AS depart_name, - sf.update_date + sf.update_date, + DATEDIFF(NOW(),sf.update_date) AS diff_days FROM flow AS f LEFT JOIN system_main as sm ON f.system_id = sm.system_id @@ -124,8 +236,85 @@ class signDetails AND sf.current_assigner != '' AND sf.current_assigner IS NOT NULL "; + $sql_str .= !empty($department_id) ? " AND a.department_id = :department_id " : ""; + $sql_str .= !empty($user_id) ? " AND sf.current_assigner = :user_id " : ""; + if (!empty($search)) { + $sql_str .= " AND ( + sm.system_name LIKE :search + OR fm.flow_name LIKE :search + OR f.form_key LIKE :search + OR sf.current_assigner LIKE :search + OR a.name LIKE :search + OR d.department_id LIKE :search + OR d.depart_name LIKE :search + OR sf.update_date LIKE :search + ) "; + } + $sql_str .= " LIMIT :per OFFSET :limit_start"; $stmt = $conn->prepare($sql_str); + !empty($department_id) ? $stmt->bindParam(':department_id', $department_id) : ''; + !empty($user_id) ? $stmt->bindParam(':user_id', $user_id) : ''; + $stmt->bindParam(':limit_start', $limit_start, PDO::PARAM_INT); + $stmt->bindParam(':per', $per, PDO::PARAM_INT); + !empty($search) ? $stmt->bindValue(':search', '%' . $search . '%') : ''; $stmt->execute(); - return $stmt->rowCount(); + $wms_data = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $sql_str = " + SELECT + '藍凌BPM' AS system_name, + krt.fd_name AS flow_name, -- 流程名稱 + lp.fd_id AS form_key, + soe.fd_no AS current_assigner, -- 預計處理人員工編號 + soe.fd_name AS user_name, -- 預計處理人名稱 + '' AS department_id, + soe2.fd_name AS depart_name, -- 部門 + SUBSTR(lp.fd_create_time,1,19) AS update_date, -- 創建時間 + DATEDIFF(NOW(),lp.fd_create_time) AS diff_days + FROM lbpm_process AS lp + LEFT JOIN km_review_template AS krt + ON lp.fd_template_model_id = krt.fd_id + LEFT JOIN lbpm_workitem AS lw + ON lp.fd_id = lw.fd_process_id + LEFT JOIN sys_org_element AS soe + ON lw.fd_expected_id = soe.fd_id + LEFT JOIN sys_org_element AS soe2 + ON soe2.fd_id = soe.fd_parentid + LEFT JOIN lbpm_history_workitem AS lhw + ON lp.fd_id = lhw.fd_process_id + WHERE 1=1 + -- AND lw.fd_status = '20' + AND lhw.fd_activity_type = 'reviewWorkitem' + AND krt.fd_name != '' + AND soe.fd_no != '' + "; + $sql_str .= !empty($department_id) ? " AND a.department_id = :department_id " : ""; + $sql_str .= !empty($user_id) ? " AND sf.current_assigner = :user_id " : ""; + if (!empty($search)) { + $sql_str .= " AND ( + krt.fd_name LIKE :search + OR lp.fd_id LIKE :search + OR soe.fd_no LIKE :search + OR soe.fd_name LIKE :search + OR soe2.fd_name LIKE :search + OR lp.fd_create_time LIKE :search + ) "; + } + $sql_str .= " LIMIT :per OFFSET :limit_start"; + $stmt = $connEkp->prepare($sql_str); + !empty($department_id) ? $stmt->bindParam(':department_id', $department_id) : ''; + !empty($user_id) ? $stmt->bindParam(':user_id', $user_id) : ''; + $stmt->bindParam(':limit_start', $limit_start, PDO::PARAM_INT); + $stmt->bindParam(':per', $per, PDO::PARAM_INT); + !empty($search) ? $stmt->bindValue(':search', '%' . $search . '%') : ''; + $stmt->execute(); + $bpm_data = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $data = array_merge($wms_data, $bpm_data); + if ($system_name == 'wms') + return json_encode($wms_data, JSON_UNESCAPED_UNICODE); + if ($system_name == 'bpm') + return json_encode($bpm_data, JSON_UNESCAPED_UNICODE); + return json_encode($data, JSON_UNESCAPED_UNICODE); } -} \ No newline at end of file +} diff --git a/wms/report_system/conn.php b/wms/report_system/conn.php index 7c57c0e0..66e4e76e 100644 --- a/wms/report_system/conn.php +++ b/wms/report_system/conn.php @@ -13,35 +13,39 @@ if (file_exists($envFile)) { } } } -$db_hostname = getenv('DB_HOST'); //資料庫主機名稱 -$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號 -$db_password = getenv('DB_PASSWORD'); //登入密碼 -$db_name = getenv('DB_DATABASE'); //使用的資料庫 -$db_charset = 'utf8'; //設定字元編碼 -//建立PDO的指定工作 -$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; +// wms +$db_hostname = getenv('DB_HOST'); +$db_username = getenv('DB_USERNAME'); +$db_password = getenv('DB_PASSWORD'); +$db_name = getenv('DB_DATABASE'); +$db_charset = 'utf8'; + +// ekp bpm +$db_ekp_hostname = getenv('DB_BPM_HOST'); +$db_ekp_username = getenv('DB_BPM_USERNAME'); +$db_ekp_password = getenv('DB_BPM_PASSWORD'); +$db_ekp_name = getenv('DB_BPM_DATABASE'); +$db_ekp_charset = 'utf8'; + try { - //使用PDO連接到MySQL資料庫,建立PDO物件 - $conn = new PDO($dsn, $db_username, $db_password); - //當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) - //PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 - //PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 - //PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 - //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 - //設定主動以警告的形式報錯 + $dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; + $conn = new PDO($dsn, $db_username, $db_password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $dsn_ekp = "mysql:host=$db_ekp_hostname;dbname=$db_ekp_name;charset=$db_ekp_charset"; + $connEkp = new PDO($dsn_ekp, $db_ekp_username, $db_ekp_password); + $connEkp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0117", "IFFCUFM="); // if ($connT8) { // $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // } - //如果連接錯誤,將抛出一個PDOException異常對象 + } catch (PDOException $e) { - //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 die("ERROR!!!: " . $e->getMessage()); } -//$conn = null; //關閉資料庫的連線 diff --git a/wms/report_system/js/alpine.js b/wms/report_system/js/alpine.js index de95c8e9..2a947f7a 100644 --- a/wms/report_system/js/alpine.js +++ b/wms/report_system/js/alpine.js @@ -4,6 +4,12 @@ const signed_overdue_date_data = () => { this.$watch('data.department_id', () => { this.changeDepartment() }) + this.$watch('data.per', () => { + this.changeDetailsTable() + }) + this.$watch('data.now_page', () => { + this.changeDetailsTable() + }) }, data: { system_name_options: [{ text: '全部', @@ -21,6 +27,11 @@ const signed_overdue_date_data = () => { system_name: '', department_id: '', user_id: '', + now_page: now_page, + end_page: end_page, + per: 10, + search: search, + all_count: all_count, }, table_details: [], searchLoading: false, @@ -31,6 +42,17 @@ const signed_overdue_date_data = () => { form.append('system_name', this.data.system_name); form.append('department_id', this.data.department_id); form.append('user_id', this.data.user_id); + form.append('search', this.data.search); + form.append('method', 'getSingDetailsAllCount'); + axios.post('./api/getSingedDetails.php', form).then(res => { + this.data.all_count = res.data; + this.data.end_page = Math.ceil(this.data.all_count / this.data.per); + }).catch(error => { + console.log(error.response.data) + this.searchLoading = false + }) + + form.append('method', 'getSingDetails'); axios.post('./api/getSingedDetails.php', form).then(res => { this.data.signDetails = res.data; this.searchLoading = false; @@ -43,20 +65,61 @@ const signed_overdue_date_data = () => { this.data.deparetment_options = res.data }).catch(error => { console.log(error.response.data) - this.downloadLoading = false }) }, getUser() { axios.post('./api/getUser.php').then(res => { this.data.user_options = res.data }).catch(error => { console.log(error.response.data) - this.downloadLoading = false }) }, changeDepartment() { const form = new FormData(); form.append('department_id', this.data.department_id); axios.post('./api/getUser.php', form).then(res => { this.data.user_options = res.data + }).catch(error => { + console.log(error.response.data) + }) + }, changeDetailsTable() { + const form = new FormData(); + this.data.end_page = Math.ceil(this.data.all_count / this.data.per); + form.append('system_name', this.data.system_name); + form.append('department_id', this.data.department_id); + form.append('user_id', this.data.user_id); + form.append('now_page', this.data.now_page); + form.append('per', this.data.per); + form.append('search', this.data.search); + form.append('method', 'getSingDetails'); + axios.post('./api/getSingedDetails.php', form).then(res => { + this.data.signDetails = res.data; + }).catch(error => { + console.log(error.response.data) + }) + }, goEndPage() { + this.data.now_page = this.data.end_page + }, goFirstPage() { + this.data.now_page = 1 + }, goLastPage() { + if (this.data.now_page > 1) + this.data.now_page-- + }, goNextPage() { + this.data.now_page++ + }, download() { + this.downloadLoading = true + const form = new FormData(); + form.append('system_name', this.data.system_name); + form.append('department_id', this.data.department_id); + form.append('user_id', this.data.user_id); + form.append('search', this.data.search); + axios.post('./api/downloadExcel.php', form).then(res => { + var link = document.createElement('a'); + link.setAttribute('href', window.location.origin + "/wms/excel/signed_overdue_date.xlsx"); + link.setAttribute('download', '部門逾期待簽.xlsx'); + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + this.downloadLoading = false }).catch(error => { console.log(error.response.data) this.downloadLoading = false diff --git a/wms/report_system/signed_overdue_date.php b/wms/report_system/signed_overdue_date.php index 527f274a..760f6984 100644 --- a/wms/report_system/signed_overdue_date.php +++ b/wms/report_system/signed_overdue_date.php @@ -6,19 +6,25 @@ include("./api/getSingedDetails.php"); include("./api/getDepartment.php"); include("./api/getUser.php"); + + $sd = new signDetails(); $d = new Department(); $u = new User(); -$details_all_count = $sd->getSingDetailsAllCount(); $signDetails = $sd->getSingDetails(); $deparetment_options = $d->getDepartment(); $user_options = $u->getUser(null); +$now_page = $sd->getNowPage(); +$end_page = $sd->getEndPage(); +$all_count = $sd->getSingDetailsAllCount(); + + ?> "> - + @@ -83,26 +89,76 @@ $user_options = $u->getUser(null); - + + - + + + +
序號表單序號 系統名稱 流程名稱接受日期接收日期 當前簽核者 姓名 所屬部門 逾期天數
@@ -123,4 +179,8 @@ $user_options = $u->getUser(null); const signDetails = [...]; const deparetment_options = [...]; const user_options = [...]; - \ No newline at end of file + const now_page = ; + const end_page = ; + const all_count = ; + const search = ""; + \ No newline at end of file diff --git a/wms/sanlien/conn.php b/wms/sanlien/conn.php index 7c57c0e0..66e4e76e 100644 --- a/wms/sanlien/conn.php +++ b/wms/sanlien/conn.php @@ -13,35 +13,39 @@ if (file_exists($envFile)) { } } } -$db_hostname = getenv('DB_HOST'); //資料庫主機名稱 -$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號 -$db_password = getenv('DB_PASSWORD'); //登入密碼 -$db_name = getenv('DB_DATABASE'); //使用的資料庫 -$db_charset = 'utf8'; //設定字元編碼 -//建立PDO的指定工作 -$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; +// wms +$db_hostname = getenv('DB_HOST'); +$db_username = getenv('DB_USERNAME'); +$db_password = getenv('DB_PASSWORD'); +$db_name = getenv('DB_DATABASE'); +$db_charset = 'utf8'; + +// ekp bpm +$db_ekp_hostname = getenv('DB_BPM_HOST'); +$db_ekp_username = getenv('DB_BPM_USERNAME'); +$db_ekp_password = getenv('DB_BPM_PASSWORD'); +$db_ekp_name = getenv('DB_BPM_DATABASE'); +$db_ekp_charset = 'utf8'; + try { - //使用PDO連接到MySQL資料庫,建立PDO物件 - $conn = new PDO($dsn, $db_username, $db_password); - //當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) - //PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 - //PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 - //PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 - //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 - //設定主動以警告的形式報錯 + $dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; + $conn = new PDO($dsn, $db_username, $db_password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $dsn_ekp = "mysql:host=$db_ekp_hostname;dbname=$db_ekp_name;charset=$db_ekp_charset"; + $connEkp = new PDO($dsn_ekp, $db_ekp_username, $db_ekp_password); + $connEkp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0117", "IFFCUFM="); // if ($connT8) { // $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // } - //如果連接錯誤,將抛出一個PDOException異常對象 + } catch (PDOException $e) { - //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 die("ERROR!!!: " . $e->getMessage()); } -//$conn = null; //關閉資料庫的連線 diff --git a/wms/wipwhole-index-function.php b/wms/wipwhole-index-function.php index f628d232..ff5afc12 100644 --- a/wms/wipwhole-index-function.php +++ b/wms/wipwhole-index-function.php @@ -180,6 +180,19 @@ function getDataSql($department_id, $role_id, $user_id) return $sql; } + // 補丁 蘇孝倫 權限全開 + if (in_array($user_id, ['M0176'])) { + $sql = " + SELECT * FROM wipwholestatus + WHERE 1=1 + AND status = '1' + AND contract_type = '$contract_type' + " . getWipwholeSearchSql() . " + ORDER BY real_contract_arrival_date ASC + "; + return $sql; + } + $sql_cmd = sql_myself($user_id, "salesid"); $sql = " SELECT * FROM wipwholestatus $sql_cmd @@ -969,7 +982,7 @@ function getYewuStatus($link, $user_department_id, $role_id) // 取得工務的欄位權限 function getWarehouseStatus($link, $user_department_id, $role_id, $status) { - if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 50, 501, 311, 313, 314, 521, 315, 912])) { + if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545, 50, 501, 311, 313, 314, 521, 315, 912,220])) { // if (getSaveEstimateInstallData($user_department_id, $role_id)) { if ($status == 1) { return checkNowFormGStatus($link) == 'G' ? "" : "disabled"; diff --git a/wms/wipwhole-renovate-index-function.php b/wms/wipwhole-renovate-index-function.php index fd7706f7..e7849513 100644 --- a/wms/wipwhole-renovate-index-function.php +++ b/wms/wipwhole-renovate-index-function.php @@ -438,6 +438,20 @@ function getDataSql($department_id, $role_id, $user_id) return $sql; } + // 補丁 蘇孝倫 權限全開 + if (in_array($user_id, ['M0176'])) { + $sql = " + SELECT * FROM wipwholestatus + WHERE 1=1 + AND status = '1' + AND contract_type = '$contract_type' + " . getWipwholeSearchSql() . " + ORDER BY real_contract_arrival_date ASC + "; + return $sql; + } + + if (in_array($department_id, $department_arr)) { // 北區營銷部 營銷專案經理 311 1 // 新梯營銷經理 311 3 diff --git a/wms/wipwhole-renovate-rec-invoice-edit-submit.php b/wms/wipwhole-renovate-rec-invoice-edit-submit.php index 939c203a..db317b85 100644 --- a/wms/wipwhole-renovate-rec-invoice-edit-submit.php +++ b/wms/wipwhole-renovate-rec-invoice-edit-submit.php @@ -204,267 +204,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // 系統通知信及系統通知 include "wipwhole-renovate-rec-invoice-edit-notice-mail.php"; - // 指派工勘人員 - if ($warehouseid !== $old_warehouseid) { - if (checkNowFormStatus($link) == 'A') { - $sql = "SELECT form_key FROM flow - WHERE form_id = '$id' - AND flow_id = 'wws02' - AND flow_code = 'A' - "; - $result = mysqli_query($link, $sql); - $form_key = $result->fetch_row()[0]; - if (!empty($form_key)) { - $sql = "UPDATE wipwholestatus - SET warehouseid = '$warehouseid' - WHERE id = '$id'; - "; - mysqli_query($link, $sql); - $sql = "UPDATE subflow - SET current_assigner = '$warehouseid' - WHERE 1 = 1 - AND seq = '1' - AND form_key = '$form_key'; - "; - mysqli_query($link, $sql); - } - } - } - - if (!empty($official_check_date)) { - if ($official_check_date !== $old_official_check_date) { - $sql = " - SELECT accountid - FROM account - WHERE department_id = '250' - AND role_id IN ('1','2','3','4'); - "; - $result = mysqli_query($link, $sql); - foreach ($result as $row) { - $permission = $row["accountid"]; - $title = "客戶:$custom 作番:$facilityno 官檢日變更"; - $content = "客戶:$custom - 作番:$facilityno - 官檢日 $old_official_check_date => $official_check_date"; - $data = array( - 'kind' => 1, - 'related_id' => $id, - 'title' => $title, - 'content' => $content, - 'permission' => $permission, - 'creater' => $creater, - 'create_at' => date("Y-m-d H:i:s") - ); - $cn->sendx($data); - } - } - } - - // 工勘變更通知繪圖人員 - if ($site_survey_contact_verify !== $old_site_survey_contact_verify) { - $site_survey_status = array( - "1" => "請選擇", - "0" => "已確認", - "2" => "無工勘需求", - "A" => "未動工", - "B" => "地下室施工", - "C" => "打樁", - "D" => "地基", - "E" => "挖土", - "G" => "機房", - "H" => "機械式淨高", - "M" => "樓中樓", - "OH" => "最高層(頂樓高度)", - "P" => "PIT(機坑深度)", - "R" => "R 樓", - "S" => "停工", - "T" => "TOP", - "TC" => "頂部間隙", - "TS" => "行程", - "TH" => "全高", - "Y" => "已搭、已出", - "YB" => "退購結案", - "YF" => "既有建物", - "YN" => "已搭、未出" - ); - $sql = " - SELECT accountid - FROM account - WHERE department_id = '321' - AND role_id IN ('2','3','5'); - "; - $result = mysqli_query($link, $sql); - foreach ($result as $row) { - $permission = $row["accountid"]; - $title = "客戶:$custom 作番:$facilityno 工勘狀態更改"; - $content = "客戶:$custom -作番:$facilityno -工勘狀態 $site_survey_status[$old_site_survey_contact_verify] => $site_survey_status[$site_survey_contact_verify]"; - - $data = array( - 'kind' => 1, - 'related_id' => $id, - 'title' => $title, - 'content' => $content, - 'permission' => $permission, - 'creater' => $creater, - 'create_at' => date("Y-m-d H:i:s") - ); - $cn->sendx($data); - } - } - - if (!empty($desin_documents_verify_file)) { - $title = "合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件"; - $content = "合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件 - 前往下載 -"; - $data = array( - 'kind' => 1, - 'related_id' => $id, - 'title' => $title, - 'content' => $content, - 'permission' => "M0168", - 'creater' => $creater, - 'create_at' => date("Y-m-d H:i:s") - ); - $cn->sendx($data); - } - - - // 官檢日及移交日通知生管人員 - if (!empty($official_check_date)) { - if ($official_check_date !== $old_official_check_date) { - $permission = "M0168"; - $title = "官檢日變更 客戶:$custom 作番:$facilityno"; - $content = "客戶:$custom - 作番:$facilityno - 官檢日 $old_official_check_date => $official_check_date"; - $data = array( - 'kind' => 1, - 'related_id' => $id, - 'title' => $title, - 'content' => $content, - 'permission' => $permission, - 'creater' => $creater, - 'create_at' => date("Y-m-d H:i:s") - ); - $cn->sendx($data); - } - } - - if (!empty($delivery_date)) { - if ($delivery_date !== $old_delivery_date) { - $permission_arr = ['M0168', 'M0012']; - foreach ($permission_arr as $permission) { - // $permission = "M0168"; - $title = "移交日變更 客戶:$custom 作番:$facilityno"; - $content = "客戶:$custom - 作番:$facilityno - 移交日 $old_delivery_date => $delivery_date"; - $data = array( - 'kind' => 1, - 'related_id' => $id, - 'title' => $title, - 'content' => $content, - 'permission' => $permission, - 'creater' => $creater, - 'create_at' => date("Y-m-d H:i:s") - ); - $cn->sendx($data); - } - } - } - - if (!empty($delivery_date)) { - if ($old_delivery_date !== $delivery_date) { - - if (empty($change_all_contractno)) { - $mail_title = "作番大日程(汰改)合約號:" . $contractno . "-移交日變更通知"; - $mail_content = "作番大日程(汰改) - 合約號:" . $contractno - . " - 移交日:" . $old_delivery_date . " => " . $delivery_date; - } else { - $mail_title = "作番大日程(汰改)合約號:" . $contractno . "作番號:" . $facilityno . "-移交日變更通知"; - $mail_content = "作番大日程(汰改) - 合約號:" . $contractno - . " - 作番號:" . $facilityno - . " - 移交日:" . $old_delivery_date . " => " . $delivery_date; - } - - $cmail->sendx( - $mail_title, - $mail_content, - [ - [$salesname, $salesmail], - // ['gary', 'gary_chen@masada.com.tw'] - ], - "永佳捷科技" - ); - } - } - - // 當試車完工日更改時 發出通知 - if (!empty($tryrun_end_date) ) { - if ($tryrun_end_date !== $old_tryrun_end_date) { - $mail_title = "作番大日程(汰改)合約號:" . $contractno . "作番號:" . $facilityno . "客戶名稱:" . $custom . "-試車已完成通知"; - $mail_content = "作番大日程(汰改) - 合約號:" . $contractno . " - 作番號:" . $facilityno . " - 客戶名稱:" . $custom . " - 已完成試車, 請注意後續交車時間, 如需要官檢, 請提供如下資料 - -"; - - $cmail->sendx( - $mail_title, - $mail_content, - [ - [$salesname, $salesmail], - [ - accountid2name(manage_class_gary_ver($salesid))[manage_class_gary_ver($salesid)], - accountid2email(manage_class_gary_ver($salesid))[manage_class_gary_ver($salesid)] - ], - ['張崇傑', 'jaychang@masada.com.tw'], - ['賴定國', 'guo@masada.com.tw'] - // ['gary', 'gary_chen@masada.com.tw'] - ], - "永佳捷科技" - ); - } - } - - // 當移交日附件更改時 發出通知 - if (!empty($delivery_date_file) || !empty($delivery_date_file2)) { - if ($delivery_date_file !== $old_delivery_date_file || $delivery_date_file2 !== $old_delivery_date_file) { - $delivery_date_file_tmp = $delivery_date_file !== $old_delivery_date_file ? $delivery_date_file : $delivery_date_file2; - $mail_title = "作番大日程(汰改)合約號:" . $contractno . "-交車完成通知"; - $mail_content = "作番大日程(汰改) - 合約號:" . $contractno . " - 作番號:" . $facilityno . " - 客戶名稱:" . $custom . " - 已完成交車並已上傳交車單或竣工單, 請至OA系統中填寫移交日, 並準備後續請款事宜! -"; - $cmail->sendx( - $mail_title, - $mail_content, - [ - [$salesname, $salesmail], - [ - accountid2name(manage_class_gary_ver($salesid))[manage_class_gary_ver($salesid)], - accountid2email(manage_class_gary_ver($salesid))[manage_class_gary_ver($salesid)] - ], - ['葉俊麟', 'darren@masada.com.tw'], - ['蘇淑娥 ', 'supe1218@masada.com.tw'] - // ['gary', 'gary_chen@masada.com.tw'] - ], - "永佳捷科技" - ); - } - } echo "