Browse Source

header

main
Cheng 2 years ago
parent
commit
75a7bf5a5d
  1. 200
      wms/IncludeCommon.php
  2. 99
      wms/T8_APItest_from_bpm.php
  3. 43
      wms/T8_Authorization_from_bpm.php
  4. 239
      wms/account-index.php
  5. 136
      wms/account-receivable-check.php
  6. 51
      wms/account-receivable-excel.php
  7. 410
      wms/account-receivable-index.php
  8. 5
      wms/account-receivable-received-create.php
  9. 21
      wms/account-receivable-received-edit.php
  10. 74
      wms/account-receivable-received-submit.php
  11. BIN
      wms/account-receivable.xlsx
  12. 1
      wms/account_auth-index.php
  13. 91
      wms/board-create.php
  14. 239
      wms/board-index.php
  15. 3
      wms/board-record-submit.php
  16. 91
      wms/fun_global.php
  17. 170
      wms/gary.php
  18. 556
      wms/header.php
  19. 2
      wms/loginapi.php
  20. 353
      wms/menu-edit.php
  21. 155
      wms/menu-record-update.php
  22. 20
      wms/rib01-create.php
  23. 22
      wms/wipwhole-change-contractdate-function.php
  24. 35
      wms/wipwhole-change-contractdate.php
  25. 22
      wms/wipwhole-change-planning-customer-name.php
  26. 60
      wms/wipwhole-index-function.php
  27. 15
      wms/wipwhole-index-table-html.php
  28. 230
      wms/wipwhole-index.php
  29. 2
      wms/wipwhole-rec-invoice-edit-fileupload.php
  30. 365
      wms/wipwhole-rec-invoice-edit-submit.php
  31. 326
      wms/wipwhole-rec-invoice-edit.php
  32. 1
      wms/wipwhole-rec-invoice.php
  33. 49
      wms/wipwhole-renovate-index-function.php
  34. 15
      wms/wipwhole-renovate-index-table-html.php
  35. 220
      wms/wipwhole-renovate-index.php
  36. 1
      wms/wipwhole-renovate-rec-invoice.php
  37. 32
      wms/wipwholeinstall-index-table-html.php
  38. 17
      wms/wipwholeinstall-renovate-index-table-html.php

200
wms/IncludeCommon.php

@ -1,67 +1,65 @@
<?php
class IncludeCommon
{
function CheckToken($token)
{
date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s");
if (!isset($token) || empty($token)) {
$data['code'] = '400';
$data['message'] = '非法请求';
return $data;
}
//对比token
$explode = explode('.', $token); //以.分割token为数组
if (!empty($explode[0]) && !empty($explode[1]) && !empty($explode[2]) && !empty($explode[3]) && !empty($explode[4])) {
$info = $explode[0] . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; //信息部分
$true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名
if ($time > $explode[3]) {
$data['user_id'] = '';
$data['code'] = '401';
$data['message'] = 'Token已过期,请重新登录';
return $data;
}
if (($true_signature == $explode[4])) {
$data['user_id'] = $explode[0];
$data['code'] = '200';
$data['message'] = 'Token合法';
return $data;
} else {
$data['user_id'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
} else {
$data['user_id'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
}
//生成登录记录
function save_log_response($account, $response_result, $source_flag = 'web')
{
# 储存纪录并输出
#echo date("Y-m-d");
$file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini";
$data = serialize($response_result) . date("H:i:s") . "\n";
$fp = fopen($file_path, "a"); # 如果档案不存在择尝试建立再写入
fwrite($fp, $data);
fclose($fp);
if ($source_flag == "web") {
// header("Location: custom-create.php?function_list=" . serialize($response_result) .
// "&token=" . $response_result["token"]); #请输入使用者名称密码
// exit();
return true;
} else {
// echo json_encode($response_result, JSON_UNESCAPED_UNICODE);
return false;
}
function CheckToken($token) {
date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s");
if (!isset($token) || empty($token)) {
$data['code'] = '400';
$data['message'] = '非法请求';
return $data;
}
//对比token
$explode = explode('.', $token); //以.分割token为数组
if (!empty($explode[0]) && !empty($explode[1]) && !empty($explode[2]) && !empty($explode[3]) && !empty($explode[4])) {
$info = $explode[0] . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; //信息部分
$true_signature = hash_hmac('md5', $info, $encryption_code); //正确的签名
if ($time > $explode[3]) {
$data['user_id'] = '';
$data['code'] = '401';
$data['message'] = 'Token已过期,请重新登录';
return $data;
}
if (($true_signature == $explode[4])) {
$data['user_id'] = $explode[0];
$data['code'] = '200';
$data['message'] = 'Token合法';
return $data;
} else {
$data['user_id'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
} else {
$data['user_id'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
}
//生成登录记录
function save_log_response($source_flag='web', $account, $response_result){
# 储存纪录并输出
#echo date("Y-m-d");
$file_path = "account_log/" . $account . "-" . date("Y-m-d") . ".ini";
$data = serialize($response_result). date("H:i:s") . "\n";
$fp = fopen($file_path,"a"); # 如果档案不存在择尝试建立再写入
fwrite($fp, $data);
fclose($fp);
if ($source_flag == "web"){
// header("Location: custom-create.php?function_list=" . serialize($response_result) .
// "&token=" . $response_result["token"]); #请输入使用者名称密码
// exit();
return true;
}else{
// echo json_encode($response_result, JSON_UNESCAPED_UNICODE);
return false;
}
/*
/*
if ($source_flag == "app"){
echo json_encode($response_result, JSON_UNESCAPED_UNICODE);
}elseif ($source_flag == "web"){
@ -70,28 +68,26 @@ class IncludeCommon
exit();
}
*/
}
//生成token
function CreateToken($user_id, $user_name)
{
date_default_timezone_set("Asia/Taipei");
$start_time = date("Y-m-d H:i:s");
$end_time = date('Y-m-d H:i:s', strtotime('+24 hour')); #设定24小时
$info = $user_id . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
}
//生成菜单
}
//生成token
function CreateToken($user_id, $user_name) {
date_default_timezone_set("Asia/Taipei");
$start_time = date("Y-m-d H:i:s");
$end_time = date('Y-m-d H:i:s',strtotime('+24 hour')); #设定24小时
$info = $user_id . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
}
//生成菜单
/**
* 將模擬帳號寫入token
*/
function FakeToken($fake_user_id, $token)
{
function FakeToken($fake_user_id, $token) {
date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s");
@ -101,32 +97,31 @@ class IncludeCommon
return $token = $info . '.' . $signature;
}
function menu($type, $from = 'tw')
{
$function_type = array(
"tw" => array(
# F角色菜单
"F" => array(
"language" => "tw",
"type" => "manage",
"list" => array(
array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"),
),
"note" => "none",
"token" => ""
),
)
);
return $function_type[$from][$type];
}
function menu ($from='tw',$type){
$function_type = array(
"tw" => array(
# F角色菜单
"F" => array(
"language" => "tw",
"type" => "manage",
"list" => array(
array("name" => "批量导入", "path" => "http://192.168.0.12/wms/excel-upload"),
),
"note" => "none",
"token" => ""
),
)
);
return $function_type[$from][$type];
}
/**
* 依帳號類別檢視功能目錄
*/
function menu_v2($atype = "")
{
function menu_v2($atype="") {
global $link;
if (!$atype) return;
@ -145,8 +140,7 @@ class IncludeCommon
* 管理者可看到全部選單
* 其餘人員依account_auth決定可檢視的選單
*/
function menu_v3($accounttype, $aid = "")
{
function menu_v3($aid="", $accounttype) {
global $link;
if (!$aid) return;
@ -167,7 +161,7 @@ class IncludeCommon
$sql = "select permission from account_auth where accountid = '$aid'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$permission = empty($row) ? json_encode([]) : $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30
$permission = empty($row)? json_encode([]): $row[0]; // $permission = $row[0]; //P0044 修改于2023/6/13 16:30
$permission_arr = json_decode($permission, true);
foreach ($menu_arr as $key => $val) {

99
wms/T8_APItest_from_bpm.php

@ -0,0 +1,99 @@
<?php
ini_set('display_errors', 'on');
date_default_timezone_set('Asia/Taipei');
$referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : "";
$hashReferer = "https://bpm.masada.com.twMasada@2023";
if ($hashReferer == $referrer) {
include "T8_Authorization_from_bpm.php";
$user_id = "M0000";
$user_password = "M012290493119";
$validation = get_Auth("M0000", "M012290493119");
send_data_to_API($validation);
} else {
echo "非法訪問!";
exit;
}
function send_data_to_API($validation)
{
// $apiurl = 'http://60.244.87.101:880//twWebAPI/V1/STKASSY/PostERPData';
$apiurl = 'http://10.10.145.2:880//twWebAPI/V1/STKASSY/PostERPData';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
$headerParam = [
'CHI_Authorization: ' . $validation,
'Content-Type: application/json'
];
$body = [
[
"name" => "stkAssyMast",
"rows" => [
[
"BillNo" => "TEST06",
"OrgId" => "1000",
"TypeId" => "CA",
"MaterialId" => "3MH00302",
"PersonId" => "M0122",
"CompId" => "1001",
"DeptId" => "220",
"SQuantity" => 1,
"SUnitId" => "SET",
"CurrentState" => 2,
"CreatorId" => "M0122"
]
]
],
[
"name" => "stkAssySubMatInfo",
"rows" => [
[
"BillNo" => "TEST06",
"MaterialId" => "3MH00302P",
"ComponentBaseQty" => 1,
"UnitQty" => 1,
"SUnitId" => "SET",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
],
[
"BillNo" => "TEST06",
"MaterialId" => "MX00000001",
"ComponentBaseQty" => 1,
"UnitQty" => 3,
"SUnitId" => "PCS",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
]
]
]
];
$json = json_encode($body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
echo $result['Status'] . "\n";
echo $result['ErrorMsg'] . "\n";
print_r($result['Data']);
}
curl_close($ch);
}

43
wms/T8_Authorization_from_bpm.php

@ -0,0 +1,43 @@
<?php
$user_id = "M0000";
$user_password = "M012290493119";
function get_Auth($user_id = "M0000", $user_password = "M012290493119")
{
$now = gmdate("YmdHis");
$data = "$user_id." . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
// $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
$apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
$headerParam = [
"UserId: $user_id",
"Pwd: $user_password",
"TimestampUTC: $now",
"Sign: $sign"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
// print_r($response);
// exit;
$result = json_decode($response, true);
$validation = $result['Data']['CHI_Authorization'];
return $validation;
}
curl_close($ch);
}

239
wms/account-index.php

@ -17,23 +17,23 @@ $sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM account $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
$data = mysqli_query($link, $sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php if ($user_auth & 2) { ?>
<p>
<a href="account-create.php?function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
if ($data) :
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) {
echo "<p class='error'>Please fill up the required field!</p>";
} else {
header("Location:account-index.php");
@ -42,126 +42,151 @@ if($data):
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
td {
word-wrap: break-word;
}
img {
width:125px;
}
img {
width: 125px;
}
.width_style_1 {
width:125px;
}
.width_style_1 {
width: 125px;
}
table{
width:100%;
}
#table_index_filter{
float:right;
}
#table_index_paginate{
float:right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
table {
width: 100%;
}
}
#table_index_filter {
float: right;
}
</style>
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>帳號類型</th>
<th>帳號</th>
<!--<th>密碼</th>-->
<th>姓名</th>
<th>電話</th>
<th>地址</th>
<th>電子郵件</th>
<th>Line ID</th>
<th>微信id</th>
<th>遠端協助</th>
<th>維修ID</th>
<th>直屬主管</th>
<th>建檔人</th>
<th>建檔時間</th>
<?php if ($user_auth&2) { ?>
<th>修改</th>
<!--<th>刪除</th>-->
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<thead>
<tr>
<td><?php echo $data['id']; ?></td>
<td data-toggle="tooltip" data-placement="right" title="
<th>項次</th>
<th>帳號類型</th>
<th>帳號</th>
<!--<th>密碼</th>-->
<th>姓名</th>
<th>電話</th>
<th>地址</th>
<th>電子郵件</th>
<th>Line ID</th>
<th>微信id</th>
<th>遠端協助</th>
<th>維修ID</th>
<th>直屬主管</th>
<th>建檔人</th>
<th>建檔時間</th>
<?php if ($user_auth & 2) { ?>
<th>修改</th>
<th>新人資料</th>
<!--<th>刪除</th>-->
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach ($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td data-toggle="tooltip" data-placement="right" title="
<?php
if (isset($accounttype_arr[$data['accounttype']])){
echo $accounttype_arr[$data['accounttype']];
}else{
echo $data['accounttype'];
}
?>
if (isset($accounttype_arr[$data['accounttype']])) {
echo $accounttype_arr[$data['accounttype']];
} else {
echo $data['accounttype'];
}
?>
">
<?php
if (isset($accounttype_arr[$data['accounttype']])){
echo $accounttype_arr[$data['accounttype']];
}else{
echo $data['accounttype'];
}
?></td>
<td><?php echo $data['accountid']; ?></td>
<!--<td><?php echo $data['pwd']; ?></td>-->
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['tel']; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['email']; ?></td>
<td><?php echo $data['lineid']; ?></td>
<td><?php echo $data['wechatid']; ?></td>
<td><a href="<?php echo $data['remote_help']; ?>">連結<a/></td>
<td><?php echo $data['repairerid']; ?></td>
<td><?php echo $data['manager']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<!--<td>
<?php
if (isset($accounttype_arr[$data['accounttype']])) {
echo $accounttype_arr[$data['accounttype']];
} else {
echo $data['accounttype'];
}
?></td>
<td><?php echo $data['accountid']; ?></td>
<!--<td><?php echo $data['pwd']; ?></td>-->
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['tel']; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['email']; ?></td>
<td><?php echo $data['lineid']; ?></td>
<td><?php echo $data['wechatid']; ?></td>
<td><a href="<?php echo $data['remote_help']; ?>">連結<a /></td>
<td><?php echo $data['repairerid']; ?></td>
<td><?php echo $data['manager']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth & 2) { ?>
<td>
<p>
<a href="account-edit.php?id=<?php echo $data['id']; ?>&function_name=account&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<!--<td>
<p>
<a href="account-delete.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td>-->
<?php } ?>
</tr>
<?php endforeach; ?>
</tbody>
<?php } ?>
<td>
<button type="button" class="btn" onclick="sendJuniorStaffDoc(<?php echo $data['id']; ?>)">寄送</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script>
function sendJuniorStaffDoc(id) {
$.ajax({
url: window.location.origin + '/wms/account-index-submit.php',
type: 'POST',
data: {
'method': 'sendJuniorStaffDoc',
'id': id
},
dataType: 'json',
success: function(response) {
alert("寄送成功!");
},
error: function(xhr, status, error) {
alert("寄送失敗!");
}
});
}
</script>
<?php
else:
else :
echo "<h2>There is no record!</h2>";
endif;

136
wms/account-receivable-check.php

@ -1,17 +1,36 @@
<?php
include "./header.php";
//企業名稱 統一編號 聯絡地址
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
$pay_received = mysqli_query($link, $sql_received);
$had_received = 0;
if (mysqli_num_rows($pay_received) == 0) {
foreach ($pay_received as $received) {
$had_received += $received['received_amount'];
}
}
$unreceived = $Bill[12] - $had_received;
print_r($Bill);
// $sql_received = "SELECT * from account_received where BillNo = '$Bill[0]' ORDER BY `pay_id` ASC";
// $pay_received = mysqli_query($link, $sql_received);
// $had_received_amount = intval(0);
// $had_invoice_amount=intval(0);
// $status_summary = intval(0);
// if (mysqli_num_rows($pay_received) > 0) {
// foreach ($pay_received as $received) {
// $had_received_amount += intval($received['received_amount']);
// $had_invoice_amount += intval($received['invoice_amount']);
// if(in_array(intval($received['status']),array(0,4,5,99))){
// $tem_status = intval(0);
// }else{
// $tem_status = intval($received['status']);
// }
// if($status_summary < $tem_status){
// $status_summary = $tem_status;
// }
// }
// }
// $unreceived_amount = intval($Bill[12]) - intval($had_received_amount);
// $uninvoice_amount = intval($Bill[12]) - intval($had_invoice_amount);
// $Bill[19] =$had_invoice_amount;
// $Bill[20] =$had_received_amount;
// $Bill[21] =$uninvoice_amount;
// $Bill[22] =$unreceived_amount;
// $Bill[23] =$status_summary;
$data = json_encode($Bill);
?>
<style>
@ -40,7 +59,7 @@ $data = json_encode($Bill);
<div class="form-group">
<div class="col-md-3">
<label for="BillNo">合約號</label>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[0] ?>" disabled>
<input type="text" class="form-control" id="BillNo" name="BillNo" value="<?= $Bill[10] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
@ -52,27 +71,27 @@ $data = json_encode($Bill);
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" disabled>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[4] ?>" disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="EnterpriseName">抬頭</label>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[14] ?>" disabled>
<input type="text" class="form-control" id="EnterpriseName" name="EnterpriseName" value="<?= $Bill[6] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" disabled>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[7] ?>" disabled>
</div>
<div class="col-md-6">
<label for="ContactAddress">聯絡地址</label>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[16] ?>" disabled>
<input type="text" class="form-control" id="ContactAddress" name="ContactAddress" value="<?= $Bill[8] ?>" disabled>
</div>
</div>
<div>
<label for="detail">狀態</label>
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill[13]) ?></textarea>
<textarea class="form-control" style="height: 150px; width: 50%;" name="detail" id="detail" disabled><?= str_replace("<br>", "\n", $Bill['facilities']) ?></textarea>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
@ -80,20 +99,20 @@ $data = json_encode($Bill);
<thead>
<tr>
<th>目前應收</th>
<th>已開發票金額</th>
<!-- <th>已開發票金額</th>
<th>未開發票金額</th>
<th>已收金額</th>
<th>未收金額</th>
<th>未收金額</th> -->
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[12])) ?></td>
<td><?= number_format(round($Bill[19])) ?></td>
<td><?= number_format(round($Bill['receivable_budget'])) ?></td>
<!-- <td><?= number_format(round($Bill[19])) ?></td>
<td><?= number_format(round($Bill[21])) ?></td>
<td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td> -->
</tr>
</tbody>
@ -112,18 +131,20 @@ $data = json_encode($Bill);
<th>試車款</th>
<th>官檢款</th>
<th>交車款</th>
<th>尾款</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill[5])) ?></td>
<td><?= number_format(round($Bill[6])) ?></td>
<td><?= number_format(round($Bill[7])) ?></td>
<td><?= number_format(round($Bill[8])) ?></td>
<td><?= number_format(round($Bill[9])) ?></td>
<td><?= number_format(round($Bill[10])) ?></td>
<td><?= number_format(round($Bill[11])) ?></td>
<td><?= number_format(round($Bill['sign'][1])) ?></td>
<td><?= number_format(round($Bill['second'][1])) ?></td>
<td><?= number_format(round($Bill['arrive'][1])) ?></td>
<td><?= number_format(round($Bill['install'][1])) ?></td>
<td><?= number_format(round($Bill['tryrun'][1])) ?></td>
<td><?= number_format(round($Bill['check'][1])) ?></td>
<td><?= number_format(round($Bill['delivery'][1])) ?></td>
<td><?= number_format(round($Bill['final'][1])) ?></td>
</tr>
</tbody>
@ -135,7 +156,7 @@ include "./footer.php";
?>
<?php
if ($user_id == "M0122") {
if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) {
?>
<button type="button" onclick="create('create',0)" class="btn btn-primary btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
新增收款紀錄<span class=" glyphicon glyphicon-plus"></span></button>
@ -148,10 +169,15 @@ if ($user_id == "M0122") {
<tr>
<th>發票日期</th>
<th>發票金額</th>
<th>發票號碼</th>
<th>收款日期</th>
<th>收款金額</th>
<th>說明</th>
<th style="width: 10%;">功能</th>
<th>備註</th>
<th>狀態</th>
<?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
<th style="width: 10%;">功能</th>
<?php } ?>
</tr>
</thead>
<tbody>
@ -160,17 +186,47 @@ if ($user_id == "M0122") {
<tr>
<td><?= $received['invoice_date'] ?></td>
<td><?= number_format($received['invoice_amount']) ?></td>
<td><?= $received['invoice_no'] ?></td>
<td><?= $received['received_date'] ?></td>
<td><?= number_format($received['received_amount']) ?></td>
<td><?= $received['remark'] ?></td>
<td><?php if (in_array(accountidToDepartId($user_id), array('220', '210'))) { ?>
<td style="text-align: center;">
<?php
switch ($received['status']) {
case 0:
echo "<span style='color:blue;'>進行中</span>";
break;
case 1:
echo "<span style='color:brown;'>催收</span>";
break;
case 2:
echo "<span style='color:red;'>法務件 (發函)</span>";
break;
case 3:
echo "<span style='color:red;'>法務件 (訴訟)</span>";
break;
case 4:
echo "折讓";
break;
case 5:
echo "壞帳";
break;
case 99:
echo "完成";
break;
}
?></td>
<?php if ((accountidToDepartId($user_id) == '220') || ($user_id == "M0209")) { ?>
<td>
<button type="button" onclick="create('edit',<?= $received['pay_id'] ?>)" class="btn btn-warning btn-sm pull-right" style="margin-right: 10%;margin-bottom: 10px;">
<span class="glyphicon glyphicon-pencil"></span></button>
<a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<!-- <a href="account-receivable-received-delete.php?id=<?php echo $received['pay_id'] ?>&<?= $token_link ?>" class="btn btn-danger btn-sm">
<span class=" glyphicon glyphicon-trash"></span>
</a>
<?php } ?>
</td>
</a> -->
</td>
<?php } ?>
</tr>
<?php }
} ?>
@ -178,14 +234,14 @@ if ($user_id == "M0122") {
</table>
</div>
<script>
function create(type,pay_id) {
function create(type, pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
if(type === 'create'){
if (type === 'create') {
form.action = "account-receivable-received-create.php?<?= $token_link ?>";
}else{
form.action = "account-receivable-received-edit.php?pay_id="+pay_id+"&<?= $token_link ?>";
} else {
form.action = "account-receivable-received-edit.php?pay_id=" + pay_id + "&<?= $token_link ?>";
}
var input = document.createElement("input");

51
wms/account-receivable-excel.php

@ -0,0 +1,51 @@
<?php
include "./header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$Bill = $_POST['Bill'];
$array_data = array();
$Bill = json_decode($Bill, true);
foreach($Bill as $key=>$value){
// for ($i = 0; $i < 17; $i++) {
// $value[$i] = (isset($value[$i])) ? $value[$i] : 0;
// }
$array_data[$key][0] = $key;
$array_data[$key][1] = $value[1];
$array_data[$key][2] = $value[2];
$array_data[$key][3] = $value[4];
$array_data[$key][4] = $value[5];
$array_data[$key][5] = $value[7];
$array_data[$key][6] = $value[8];
$array_data[$key][7] = $value[6];
$array_data[$key][8] = $value['sign'][1];
$array_data[$key][9] = $value['second'][1];
$array_data[$key][10] = $value['arrive'][1];
$array_data[$key][11] = $value['install'][1];
$array_data[$key][12] = $value['tryrun'][1];
$array_data[$key][13] = $value['check'][1];
$array_data[$key][14] = $value['delivery'][1];
$array_data[$key][15] = $value['final'][1];
$array_data[$key][16] = $value['receivable_budget'];
$array_data[$key][17] = str_replace('<br>','; ',$value['facilities']);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colomnHeader = ['合約號','部門','經理','營業員','客戶名稱','統一編號','聯絡地址','抬頭','簽約款',
'二次款','貨抵工地款','安裝款','試車款','官檢款','交車款','尾款','目前應收','作番狀態'];
$sheet->fromArray($colomnHeader,NULL,'A1');
$rowIndex = 2;
foreach($array_data as $key => $value){
$sheet->fromArray([$value], NULL, 'A' . $rowIndex);
$sheet->getStyle('R' . $rowIndex)->getAlignment()->setWrapText(true);
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable.xlsx';
$writer->save($excelFileName);
?>
<script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script>

410
wms/account-receivable-index.php

@ -1,60 +1,62 @@
<?php
include "header.php";
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls;
//use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$follower = find_follow($user_id);
$arrayData = [];
$receivable_array = [];
$received_array = [];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
$sql_received = "SELECT * from account_received";
$sql_received = "SELECT * FROM arWriteOffBillDetail WHERE (DATALENGTH(OrderBillNo) >0)";
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName, s.PersonId,
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt, a.PlanPayDate,s.BizPartnerId,c.BizPartnerName, s.PersonId,
c.EnterpriseName, c.TaxNo, c.ContactAddress FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_contract .= "AND (s.PersonId = '$user_id'";
$sql_received .= " WHERE person_id = '$user_id'";
$sql_received .= " AND (PersonId = '$user_id'";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$sql_contract .= " OR s.PersonId IN $column_str)";
$sql_received .= " OR person_id IN $column_str)";
$sql_received .= " OR PersonId IN $column_str)";
} else {
$sql_contract .= ")";
$sql_received .= ")";
};
}
$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天');
$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天');
$sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天');
$contract = $conn->query($sql_contract);
$received_data = mysqli_query($link, $sql_received);
foreach ($received_data as $received) {
if ($received['BillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
} elseif ($received['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
} else {
$BillNo = $received['BillNo'];
};
if (isset($received_array[$BillNo])) {
$received_array[$BillNo][0] += $received['invoice_amount'];
$received_array[$BillNo][1] += $received['received_amount'];
} else {
$received_array[$BillNo][0] = $received['invoice_amount'];
$received_array[$BillNo][1] = $received['received_amount'];
}
}
$received_array = $conn->query($sql_received);
// 取收款資料 account_received
// $received_data = mysqli_query($link, $sql_received);
// foreach ($received_data as $received) {
// if ($received['BillNo'] == 'SO20230801001') {
// $BillNo = 'M230947';
// } elseif ($received['BillNo'] == 'SO20230801002') {
// $BillNo = 'M231067';
// } else {
// $BillNo = $received['BillNo'];
// };
// if (isset($received_array[$BillNo])) {
// $received_array[$BillNo][0] += $received['invoice_amount'];
// $received_array[$BillNo][1] += $received['received_amount'];
// $received['status'] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
// if ($received_array[$BillNo][2] < intval($received['status'])) {
// $received_array[$BillNo][2] = intval($received['status']);
// }
// } else {
// $received_array[$BillNo][0] = $received['invoice_amount'];
// $received_array[$BillNo][1] = $received['received_amount'];
// $received_array[$BillNo][2] = (intval($received['status']) < 4) ? intval($received['status']) : 0;
// }
// }
// 將T8合約收款階段資料依據款別分類放進arraData裡
foreach ($contract as $cont) {
// print_r($cont);
// echo "<br>";
if ($cont['BillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
} elseif ($cont['BillNo'] == 'SO20230801002') {
@ -63,58 +65,84 @@ foreach ($contract as $cont) {
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage'];
$PlanPayDate = $cont['PlanPayDate'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
$EnterpriseName = $cont['EnterpriseName'];
$TaxNo = $cont['TaxNo'];
$ContactAddress = $cont['ContactAddress'];
//4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
if (isset($arrayData[$BillNo])) {
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
$arrayData[$BillNo][5] = $PayAmount;
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) {
$arrayData[$BillNo][4] = $PayAmount;
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) {
$arrayData[$BillNo][6] = $PayAmount;
} elseif (stristr($PayStage, '試車') || stristr($PayStage, '驗收完成')) {
$arrayData[$BillNo][8] = $PayAmount;
} elseif (stristr($PayStage, '安裝')) {
$arrayData[$BillNo][7] = $PayAmount;
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) {
$arrayData[$BillNo][10] = $PayAmount;
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) {
$arrayData[$BillNo][9] = $PayAmount;
} else {
$arrayData[$BillNo][12] = $PayAmount;
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期
//['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期
if (!(isset($arrayData[$BillNo]))) {
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
$arrayData[$BillNo][5] = $partnerName;
$arrayData[$BillNo][6] = $EnterpriseName;
$arrayData[$BillNo][7] = $TaxNo;
$arrayData[$BillNo][8] = $ContactAddress;
$arrayData[$BillNo]['received']= array();
$arrayData[$BillNo]['sign'][1] = $arrayData[$BillNo]['second'][1] = $arrayData[$BillNo]['arrive'][1] = $arrayData[$BillNo]['install'][1] = $arrayData[$BillNo]['tryrun'][1] = $arrayData[$BillNo]['check'][1] = $arrayData[$BillNo]['delivery'][1] = $arrayData[$BillNo]['final'][1] = 0;
$arrayData[$BillNo]['facilities'] = "";
$arrayData[$BillNo]['total_facility_num'] = $arrayData[$BillNo]['delivery_num'] = $arrayData[$BillNo]['check_num'] = $arrayData[$BillNo]['tryrun_num'] = $arrayData[$BillNo]['install_num'] = $arrayData[$BillNo]['arrive_num'] = $arrayData[$BillNo]['second_num'] = $arrayData[$BillNo]['receivable_budget'] = 0;
}
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
$arrayData[$BillNo]['second'][0] = $PayStage;
$arrayData[$BillNo]['second'][1] = $PayAmount;
$arrayData[$BillNo]['second'][2] = $PlanPayDate;
if (isset($arrayData[$BillNo]['sign'][2]) && !is_null($arrayData[$BillNo]['sign'][2])) {
$signtime = strtotime(strval($arrayData[$BillNo]['sign'][2]));
if (in_array($PayStage, $sign60)) {
$secondtime = $signtime + (60 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif (in_array($PayStage, $sign90)) {
$secondtime = $signtime + (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif (in_array($PayStage, $sign120)) {
$secondtime = $signtime + (120 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
} elseif (stristr($PayStage, '簽訂後30天')) {
$secondtime = $signtime + (30 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$BillNo]['second'][2] = intval($secondtime);
}
}
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金') || stristr($PayStage, '工地動工')) {
$arrayData[$BillNo]['sign'][0] = $PayStage;
$arrayData[$BillNo]['sign'][1] = $PayAmount;
$arrayData[$BillNo]['sign'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '試車')) {
$arrayData[$BillNo]['tryrun'][0] = $PayStage;
$arrayData[$BillNo]['tryrun'][1] = $PayAmount;
$arrayData[$BillNo]['tryrun'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '安裝') || stristr($PayStage, '貨抵工地且完工')) {
$arrayData[$BillNo]['install'][0] = $PayStage;
$arrayData[$BillNo]['install'][1] = $PayAmount;
$arrayData[$BillNo]['install'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) {
$arrayData[$BillNo]['arrive'][0] = $PayStage;
$arrayData[$BillNo]['arrive'][1] = $PayAmount;
$arrayData[$BillNo]['arrive'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) {
$arrayData[$BillNo]['delivery'][0] = $PayStage;
$arrayData[$BillNo]['delivery'][1] = $PayAmount;
$arrayData[$BillNo]['delivery'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) {
$arrayData[$BillNo]['check'][0] = $PayStage;
$arrayData[$BillNo]['check'][1] = $PayAmount;
$arrayData[$BillNo]['check'][2] = $PlanPayDate;
} elseif (stristr($PayStage, '驗收完成')) {
$arrayData[$BillNo]['final'][0] = $PayStage;
$arrayData[$BillNo]['final'][1] = $PayAmount;
$arrayData[$BillNo]['final'][2] = $PlanPayDate;
} else {
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$arrayData[$BillNo][3] = $partnerName;
$arrayData[$BillNo][13] = $EnterpriseName;
$arrayData[$BillNo][14] = $TaxNo;
$arrayData[$BillNo][15] = $ContactAddress;
if (stristr($PayStage, '二次款') || stristr($PayStage, '出貨前') || stristr($PayStage, '簽約後') || stristr($PayStage, '簽訂後') || stristr($PayStage, '建照核發時') || stristr($PayStage, '簽約60')) {
$arrayData[$BillNo][5] = $PayAmount;
} elseif ($PayStage == '簽約' || stristr($PayStage, '簽定') || stristr($PayStage, '簽訂') || stristr($PayStage, '訂金')) {
$arrayData[$BillNo][4] = $PayAmount;
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) {
$arrayData[$BillNo][6] = $PayAmount;
} elseif (stristr($PayStage, '試車') || stristr($PayStage, '驗收完成')) {
$arrayData[$BillNo][8] = $PayAmount;
} elseif (stristr($PayStage, '安裝')) {
$arrayData[$BillNo][7] = $PayAmount;
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) {
$arrayData[$BillNo][10] = $PayAmount;
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) {
$arrayData[$BillNo][9] = $PayAmount;
} else {
$arrayData[$BillNo][12] = $PayAmount;
}
$arrayData[$BillNo]['other'][1] = $PayAmount;
$arrayData[$BillNo]['other'][2] = $PlanPayDate;
}
}
foreach ($arrayData as $key => $value) {
$sql = "SELECT
$sql = "SELECT
tmp2.*,
d.name AS depart_name
FROM(
@ -138,8 +166,7 @@ left join account AS a
ON w.salesid = a.accountid
left join account AS a2
ON a2.accountid = a.manager
where w.status = '1' AND w.contractno='" . $key . "'" . "
where w.status = '1' AND w.contract_type='A'
)AS tmp2
left join (
SELECT DISTINCT
@ -149,89 +176,106 @@ FROM department
) AS d
ON d.department_id = tmp2.department_id";
$facitities = "";
$total_facility_num = 0;
$arrive_num = 0;
$tryrun_num = 0;
$delivery_num = 0;
$official_num = 0;
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name'];
$value[2] = $wip['name'];
$value[16] = isset($wip['department_id']) ? $wip['department_id'] : '';
$value[17] = isset($wip['salesid']) ? $wip['salesid'] : '';
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
if (isset($arrayData[$wip['contractno']])) {
$arrayData[$wip['contractno']][0] = $wip['department_id'];;
$arrayData[$wip['contractno']][1] = $wip['depart_name'];
$arrayData[$wip['contractno']][2] = $wip['manager_name'];
$arrayData[$wip['contractno']][3] = $wip['salesid'];
$arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno'];
if (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前30天')) {
$estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$secondtime = $estimate_delivery_time - (30 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前90天')) {
$estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$secondtime = $estimate_delivery_time - (90 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = intval($secondtime);
}
if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$total_facility_num += 1;
$arrive_num += 1;
$tryrun_num += 1;
$official_num += 1;
$delivery_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif ($wip['official_check_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$total_facility_num += 1;
$arrive_num += 1;
$tryrun_num += 1;
$official_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif ($wip['tryrun_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$total_facility_num += 1;
$arrive_num += 1;
$tryrun_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif ($wip['install_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$total_facility_num += 1;
$arrive_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif ($wip['real_arrival_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$total_facility_num += 1;
$arrive_num += 1;
} elseif ($wip['actual_tofactory_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) <br>";
$total_facility_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
if ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出貨日) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} elseif ($wip['actual_tofactory_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['actual_tofactory_date'] . "實際到觀音日) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
} else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
}
} elseif ($wip['estimated_shipping_date'] != NULL) {
$facitities .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>";
$total_facility_num += 1;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計到港) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
} else {
$facitities .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$total_facility_num += 1;
}
}
$receivable_budget = 0;
//這是錢 4 簽約 5 二次款 6 貨抵工地 7 安裝 8 試車 9官檢 10 交車
//這是數量 arrive_num 貨抵工地 tryrun_num 試車安裝完畢 official_num 官檢完畢 delivery_num 移交
if ($total_facility_num > 0) {
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) +
($value[7] + $value[8]) * ($tryrun_num / $total_facility_num) + ($value[9]) * ($official_num / $total_facility_num)
+ ($value[10]) * ($delivery_num / $total_facility_num);
$uninvoice_budget = $receivable_budget;
$unreceived_budget = $receivable_budget;
$received_invoice = 0;
$received_budget = 0;
if (isset($received_array[$key][0])) {
$uninvoice_budget = $receivable_budget - $received_array[$key][0];
$received_invoice = $received_array[$key][0];
}else{
$uninvoice_budget = $receivable_budget;
}
if (isset($received_array[$key][1])) {
$unreceived_budget = $receivable_budget - $received_array[$key][1];
$received_budget = $received_array[$key][1];
}else{
$unreceived_budget = $receivable_budget;
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計到港日待確認) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
}
}
if (isset($value[0]) && ($value[0] != 0)) {
$receivable_array[$key] = [$key, $value[0], $value[1], $value[2], $value[3], $value[4], $value[5], $value[6], $value[7], $value[8], $value[9],
$value[10], $receivable_budget, $facitities, $value[13], $value[14], $value[15], $value[16], $value[17], $received_invoice, $received_budget,
$uninvoice_budget, $unreceived_budget];
}
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
$value['receivable_budget'] = $value['sign'][1] + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
($value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num'])) + ($value['install'][1] * ($value['install_num'] / $value['total_facility_num'])) +
($value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num'])) + ($value['check'][1] * ($value['check_num'] / $value['total_facility_num'])) +
(($value['delivery'][1] + $value['final'][1]) * ($value['delivery_num'] / $value['total_facility_num']));
}
}
$data = json_encode($receivable_array);
// array_push($arrayData[$wip['contractno']]['received'], ['assaaa',123124,'sdrfrqa']);
foreach($received_array as $received){
if(isset($arrayData[$received['OrderBillNo']])){
array_push($arrayData[$received['OrderBillNo']]['received'], [$received['BillNo'],$received['WriteOffBizPartnerId'],$received['OrderBillNo'],]);
}
}
$data = json_encode($arrayData);
// echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;官檢款;交車款;目前應收;總作番數;貨抵;安裝試車;官檢;移交數;狀態</br>";
?>
<style>
table {
@ -270,6 +314,8 @@ $data = json_encode($receivable_array);
}
</style>
<button type="button" onclick="downloadData()" class="btn btn-warning btn-lg pull-right"><span class="glyphicon glyphicon-download-alt"></span></button>
<div style="width:98%;margin:1%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
@ -285,36 +331,38 @@ $data = json_encode($receivable_array);
<th style="width: 100px;">安裝款</th>
<th style="width: 100px;">試車款</th>
<th style="width: 100px;">官檢款</th>
<th style="width: 100px;">交車款</th> -->
<th style="width: 100px;">交車款</th>
<th style="width: 100px;">尾款</th> -->
<th style="width: 100px;">目前應收</th>
<th style="width: 150px;">未開發票金額</th>
<th style="width: 100px;">未收金額</th>
<th>狀態</th>
<!-- <th style="width: 150px;">未開發票金額</th>
<th style="width: 100px;">未收金額</th> -->
<th>作番狀態</th>
<!-- <th style="width: 100px;">收款狀態</th> -->
<th style="width: 100px;">操作</th>
</tr>
</thead>
<tbody>
<?php
foreach ($receivable_array as $contract) {
foreach ($arrayData as $key =>$value) {
?>
<tr>
<th><?= $contract[0] ?></th>
<td><?= $contract[1] ?></td>
<td><?= $contract[2] ?></td>
<td><?= $contract[3] ?></td>
<td><?= $contract[4] ?></td>
<!-- <td><?= round($contract[5]) ?></td>
<td><?= round($contract[6]) ?></td>
<td><?= round($contract[7]) ?></td>
<td><?= round($contract[8]) ?></td>
<td><?= round($contract[9]) ?></td>
<td><?= round($contract[10]) ?></td>
<td><?= round($contract[11]) ?></td> -->
<td style="text-align: end;"><?= number_format(round($contract[12])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[21])) ?></td>
<td style="text-align: end;"><?= number_format(round($contract[22])) ?></td>
<td style="text-align: start;"><?= $contract[13] ?></td>
<td><button type="button" onclick="sendData('<?= $contract[0] ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
<th><?= $key ?></th>
<td><?= $value[1] ?></td>
<td><?= $value[2] ?></td>
<td><?= $value[4] ?></td>
<td><?= $value[5] ?></td>
<!-- <td style="text-align: end;"><?= number_format(round($value['sign'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['second'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['arrive'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['install'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['tryrun'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['check'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['delivery'][1])) ?></td>
<td style="text-align: end;"><?= number_format(round($value['final'][1])) ?></td> -->
<td style="text-align: end;"><?= number_format(round($value['receivable_budget'])) ?></td>
<!-- <td style="text-align: end;"><?= number_format(round($value['total_facility_num'])) ?></td> -->
<td style="text-align: start;"><?= $value['facilities'] ?></td>
<td><button type="button" onclick="sendData('<?= $key ?>')" class="btn btn-primary btn-sm"><span class=" glyphicon glyphicon-search"></span></button>
</td>
</tr>
<?php
@ -324,12 +372,23 @@ $data = json_encode($receivable_array);
</table>
</div>
<script>
function downloadData() {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-excel.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(BillData);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function sendData(BillNo) {
console.log(BillNo);
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];
console.log(Bill);
console.log(typeof(Bill));
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
@ -340,6 +399,5 @@ $data = json_encode($receivable_array);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
</script>

5
wms/account-receivable-received-create.php

@ -81,6 +81,7 @@ $BillData = json_decode($Bill, true);
<input type="hidden" name="DeptId" value="<?= $BillData[17] ?>">
<input type="hidden" name="PersonId" value="<?= $BillData[18] ?>">
<input type="hidden" name="CustName" value="<?= $BillData[4] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</div>
<div class="form-group">
<div class="col-md-3">
@ -115,7 +116,9 @@ $BillData = json_decode($Bill, true);
$("#DeptName").prop("disabled", false);
$("#ManagerName").prop("disabled", false);
$("#PersonName").prop("disabled", false);
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

21
wms/account-receivable-received-edit.php

@ -16,6 +16,8 @@ $pay = mysqli_fetch_assoc($pay);
<button type="button" onclick="backToIndex()" class="btn btn-outline-primary btn-lg"><span class="glyphicon glyphicon-menu-left"></span></button>
</div>
</div>
<div class="container">
<div class="text-center">
<h3><strong><?= $BillData[4] ?></strong></h3>
@ -83,9 +85,24 @@ $pay = mysqli_fetch_assoc($pay);
<input type="text" class="form-control" id="remark" name="remark" value="<?= $pay['remark'] ?>">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="status" style="color: red;">狀態</label>
<select id="status" name="status">
<option value=0 <?php if($pay['status'] == 0) echo "selected" ?>>進行中</option>
<option value=1 <?php if($pay['status'] == 1) echo "selected" ?>>催收</option>
<option value=2 <?php if($pay['status'] == 2) echo "selected" ?>>法務件 (發函)</option>
<option value=3 <?php if($pay['status'] == 3) echo "selected" ?>>法務件 (訴訟)</option>
<option value=4 <?php if($pay['status'] == 4) echo "selected" ?>>折讓</option>
<option value=5 <?php if($pay['status'] == 5) echo "selected" ?>>壞帳</option>
<option value=99 <?php if($pay['status'] == 99) echo "selected" ?>>完成</option>
</select>
</div>
</div>
<input type="hidden" name="pay_id" value="<?= $pay['pay_id'] ?>">
<input type="hidden" name="Bill" id="Bill" value="">
</div>
<div class="form-group">
<div class="col-md-3">
@ -99,6 +116,7 @@ $pay = mysqli_fetch_assoc($pay);
<script>
function backToIndex() {
var Bill = <?= $Bill ?>;
@ -116,6 +134,9 @@ $pay = mysqli_fetch_assoc($pay);
function send() {
event.preventDefault();
var Bill = <?= $Bill ?>;
Bill = JSON.stringify(Bill);
$("#Bill").val(Bill);
$("#pay_received").submit();
}
</script>

74
wms/account-receivable-received-submit.php

@ -1,43 +1,47 @@
<?php
include "./header.php";
$type = $_GET['type'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? NULL : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = empty($_POST['InvoiceDate']) ? NULL: $_POST['InvoiceDate'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? '' : str_replace('-', '', trim($_POST['InvoiceNo']));
$InvoiceDate = isset($_POST['InvoiceDate']) ? $_POST['InvoiceDate'] : '';
$Bill = $_POST['Bill'];
$invoice_amount = empty($_POST['InvoiceAmount']) ? 0 : $_POST['InvoiceAmount'];
$received_amount = empty($_POST['ReceivedAmount']) ? 0 : $_POST['ReceivedAmount'];
$received_date = empty($_POST['ReceivedDate']) ? NULL : $_POST['ReceivedDate'];
$remark = empty($_POST['remark']) ? '' : $_POST['remark'];
$received_date = isset($_POST['ReceivedDate']) ? $_POST['ReceivedDate'] : '';
$remark = isset($_POST['remark']) ? $_POST['remark'] : '';
if ($type == 'edit') {
$pay_id = $_POST['pay_id'];
$status = $_POST['status'];
$sql_query_pay = "SELECT * from account_received where pay_id = $pay_id";
$pay = mysqli_query($link, $sql_query_pay);
$pay = mysqli_fetch_assoc($pay);
$sql1 = "UPDATE account_received SET ";
if ($InvoiceNo !== $pay['invoice_no']) {
$sql1.="invoice_no = '$InvoiceNo',";
$sql1 .= "invoice_no = '$InvoiceNo',";
}
if($InvoiceDate !== $pay['invoice_date']){
$sql1.="invoice_date = '$InvoiceDate',";
if ($InvoiceDate != $pay['invoice_date']) {
$sql1 .= "invoice_date = '$InvoiceDate',";
}
if ($invoice_amount != $pay['invoice_amount']) {
$sql1 .= "invoice_amount = $invoice_amount,";
}
if($invoice_amount != $pay['invoice_amount']){
$sql1.="invoice_amount = $invoice_amount,";
if ($received_amount != $pay['received_amount']) {
$sql1 .= "received_amount = $received_amount,";
}
if($received_amount != $pay['received_amount']){
$sql1.="received_amount = $received_amount,";
if ($received_date != $pay['received_date']) {
$sql1 .= "received_date = '$received_date',";
}
if($received_date !== $pay['received_date']){
$sql1.="received_date = '$received_date',";
if ($remark != $pay['remark']) {
$sql1 .= "remark = '$remark',";
}
if($remark !== $pay['remark']){
$sql1.="remark = '$remark',";
if ($status != $pay['status']) {
$sql1 .= "status = $status,";
}
$sql1=substr($sql1,0,-1);
$sql = $sql1 . " WHERE pay_id = $pay_id";
echo $sql;
exit();
// $sql1 = substr($sql1, 0, -1);
$sql = $sql1 . "LastOperatorId = '$user_id' WHERE pay_id = $pay_id";
} else {
$BillNo = $_POST['BillNo'];
$dept_id = $_POST['DeptId'];
@ -49,36 +53,44 @@ if ($type == 'edit') {
$sql1 = "INSERT INTO account_received (
BillNo,dept_id,dept_name,manager_name,person_id,person_name,cust_name";
$sql2 = ",CreatorId) VALUES ('$BillNo','$dept_id','$dept_name','$manager_name','$person_id','$person_name','$cust_name'";
if (!empty($InvoiceNo)) {
if (isset($InvoiceNo)) {
$sql1 .= ",invoice_no";
$sql2 .= ",'$InvoiceNo'";
}
if (isset($InvoiceDate)) {
if ((!empty($InvoiceDate))) {
$sql1 .= ",invoice_date";
$sql2 .= ",'$InvoiceDate'";
}
if (!empty($invoice_amount)) {
if (isset($invoice_amount)) {
$sql1 .= ",invoice_amount";
$sql2 .= ",$invoice_amount";
}
if (!empty($received_amount)) {
if (isset($received_amount)) {
$sql1 .= ",received_amount";
$sql2 .= ",$received_amount";
}
if (isset($received_date)) {
if (!(empty($received_date))) {
$sql1 .= ",received_date";
$sql2 .= ",'$received_date'";
}
if (!empty($remark)) {
if (!(empty($remark))) {
$sql1 .= ",remark";
$sql2 .= ",'$remark'";
}
$sql = $sql1 . $sql2 . ",'$user_id')";
}
mysqli_query($link, $sql);
if (mysqli_affected_rows($link)) {
echo '<script>alert("新增/更新 成功")</script>';
echo $sql;
} else {
echo '<script>alert("新增/更新 失敗")</script>';
}
?>
<script>
var Bill = <?= $Bill ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-check.php?<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
input.value = JSON.stringify(Bill);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
</script>

BIN
wms/account-receivable.xlsx

Binary file not shown.

1
wms/account_auth-index.php

@ -20,7 +20,6 @@ $data = mysqli_query($link,$sql);
-->
<?php
if($data):
?>
<style>
table {

91
wms/board-create.php

@ -2,13 +2,12 @@
include "header.php";
?>
<script>
$(function(){
});
$(function() {});
</script>
<div class="container">
<?php
include "board-record-submit.php";
/*
<?php
include "board-record-submit.php";
/*
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>";
@ -17,35 +16,65 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
}
}
*/
?>
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="title">主旨</label>
<input type="text" name="title" id="title" size="30" maxlength="25" required>
</div>
<!--<div>
<label for="pin">置頂</label>
<select name="pin" id="pin">
<option value="Y"></option>
<option value="N" selected></option>
</select>
</div>-->
<div>
<label for="attatch1">附件上傳</label>
<div>
<input type="file" name="attatch1" id="attatch1">
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
<div class='container'>
<div class='row'>
<div class='col-md-6 col-12'>
<label for="title">主旨</label>
<input type="text" name="title" id="title" size="30" maxlength="25" required>
</div>
<div class='col-md-6 col-12'>
<label for="attatch1">附件上傳</label>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
</div>
<div class='row'>
<div class='col-md-3 col-3'>
<label>連結名稱</label>
<input type="text" id="linkName">
</div>
<div class='col-md-9 col-6'>
<label>連結網址</label>
<input type="text" id="linkURL">
</div>
<div class='col-md-2 col-2'>
<button type='button' onclick="insertLink()">插入超連結</button>
</div>
</div>
<div class='row'>
<div class='col-md-12 col-12'>
<label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required></textarea>
</div>
</div>
<br />
<div class='row'>
<div class='col-md-12 col-12'>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<button type="submit" name="submit" id="submit">確定</button>
</div>
</div>
</div>
<div>
<label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required></textarea>
</div>
<div>
<button type="submit" name="submit" id="submit">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<script>
function insertLink() {
var linkName = document.getElementById('linkName').value;
var linkURL = document.getElementById('linkURL').value;
if (linkName !== '' && linkURL !== '') {
var textarea = document.getElementById('content');
var link = '<a style="color:blue" href="' + linkURL + '">' + linkName + '</a>';
// 插入超連結到 textarea 中
textarea.value += link;
} else {
alert('請輸入連結名稱和 URL');
}
}
</script>
<?php include "footer.php"; ?>

239
wms/board-index.php

@ -8,96 +8,189 @@ $data = array();
$sql = "select * from board where status = 'Y' order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
$data = mysqli_query($link, $sql);
$data2 = $data;
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php if ($user_auth & 2) { ?>
<p>
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
if ($data) :
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
td {
word-wrap: break-word;
}
img {
width:125px;
}
img {
width: 125px;
}
.width_style_1 {
width:125px;
}
.width_style_1 {
width: 125px;
}
table{
width:100%;
}
#table_index_filter{
float:right;
}
#table_index_paginate{
float:right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
table {
width: 100%;
}
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>主旨</th>
<th>附件</th>
<!--<th>是否置頂</th>-->
<th>建檔人</th>
<th>建檔時間</th>
<th>關閉公告</th>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['title']; ?></td>
<td><a href="/wms/board-file.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" target="_blank"><?php echo str_replace("board-attach/","",$data['attach']); ?></a></td>
<!--<td><?php if ($data['pin'] > 1) echo "是"; else echo "否"; ?></td>-->
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<?php if (($data['creater'] == $user_id) && ($data['status']=="Y")) { ?>
<a href="board-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('確認關閉公告嗎?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
<?php } else echo "-"; ?>
</p>
</td>
</tr>
/* The Modal (background) */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
}
.modal .back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.modal-content {
z-index: 9;
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>主旨</th>
<th>附件</th>
<!--<th>是否置頂</th>-->
<th>建檔人</th>
<th>建檔時間</th>
<th>關閉公告</th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<!-- <td><?php echo $data['title']; ?></td> -->
<td><a onclick="openModal('<?php echo $data['id']; ?>')" href="#"><?php echo $data['title']; ?></button></a>
<td><a href="/wms/board-file.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" target="_blank"><?php echo str_replace("board-attach/", "", $data['attach']); ?></a></td>
<!--<td><?php if ($data['pin'] > 1) echo "是";
else echo "否"; ?></td>-->
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<?php if (($data['creater'] == $user_id) && ($data['status'] == "Y")) { ?>
<a href="board-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('確認關閉公告嗎?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
<?php } else echo "-"; ?>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
foreach ($data2 as $data2) :
?>
<div id="myModal<?php echo $data2['id']; ?>" class="modal">
<div class="back"></div>
<div class="modal-content">
<button type="button" class="close myCloseBtn" id="">X</button>
<div class='col-12' style='text-align:center'>
<h3><?php echo $data2['title']; ?></h3>
<br/>
<?php echo nl2br($data2['content']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script>
var modal = document.getElementById("myModal");
function openModal(id) {
$("#myModal" + id).show();
}
$(".myCloseBtn").click(function(e) {
$(".modal").hide();
});
$(".back").click(function(e) {
$(".modal").hide();
});
</script>
<?php
else:
else :
echo "<h2>There is no record!</h2>";
endif;

3
wms/board-record-submit.php

@ -3,7 +3,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST);
//print_r($_FILES);exit;
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
// $$k = htmlspecialchars(stripslashes(trim($v)));
$$k = trim($v);
}
function get_basename($filename) {

91
wms/fun_global.php

@ -1,4 +1,5 @@
<?php
/**
* 組sql語法:限制可查詢範圍
* 系統管理員、總經理權限全開
@ -8,7 +9,8 @@
*
* @return string
*/
function sql_myself($user_id, $column="creater") {
function sql_myself($user_id, $column = "creater")
{
global $link;
$follower_arr = []; // 下屬列表
@ -36,7 +38,8 @@ function sql_myself($user_id, $column="creater") {
* @param array $ret:下屬ID
* @return array
*/
function find_follow($user_id, &$ret=[]) {
function find_follow($user_id, &$ret = [])
{
global $link;
$sql = "select accountid from account where manager = '$user_id'";
@ -56,7 +59,8 @@ function find_follow($user_id, &$ret=[]) {
* @param array $ret:上級主管ID
* @return array
*/
function manage_class($user_id, &$ret=[]) {
function manage_class($user_id, &$ret = [])
{
global $link;
$sql = "select manager from account where accountid = '$user_id'";
@ -79,7 +83,8 @@ function manage_class($user_id, &$ret=[]) {
* @return array
*
*/
function pricereview_class($rate, $user_id, &$ret=[]) {
function pricereview_class($rate, $user_id, &$ret = [])
{
global $link;
$sql = "select manager from account where accountid = '$user_id'";
@ -87,7 +92,7 @@ function pricereview_class($rate, $user_id, &$ret=[]) {
while ($row = mysqli_fetch_assoc($res)) {
if ($row["manager"] == "M0001") return; // 董事長略過
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
$ret[1] = $row["manager"].",,";
$ret[1] = $row["manager"] . ",,";
pricereview_class($rate, $row["manager"], $ret);
} else {
$ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人)
@ -108,7 +113,8 @@ function pricereview_class($rate, $user_id, &$ret=[]) {
* @return array
*
*/
function pricereview_renovate_class($rate, $user_id, $renovate_flag) {
function pricereview_renovate_class($rate, $user_id, $renovate_flag)
{
global $link;
$sql = "select manager from account where accountid = '$user_id'";
@ -142,11 +148,20 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag) {
* @param string $token
* @return string
*/
function check_user_permission($user_id, $token) {
function check_user_permission($user_id, $token)
{
global $link;
// 不檢查清單
$ignore_url_arr = ['/wms/index.php', '/wms/notice-index.php', '/wms/notice-edit.php', '/wms/change-password.php', '/wms/wipwhole-change-contractdate.php', '/wms/wipwhole-change-planning-customer-name.php','/wms/test.php', '/wms/mkt/pricereview_mi-api.php'];
$ignore_url_arr = [
'/wms/index.php',
'/wms/notice-index.php',
'/wms/notice-edit.php',
'/wms/change-password.php',
'/wms/wipwhole-change-contractdate.php',
'/wms/wipwhole-change-planning-customer-name.php',
'/wms/test.php',
];
if (in_array($_SERVER["SCRIPT_NAME"], $ignore_url_arr)) return;
$do = "";
@ -169,9 +184,12 @@ function check_user_permission($user_id, $token) {
mysqli_free_result($res);
if (!$do) {
echo "無權限操作,請洽管理員。";
exit;
echo "<script>alert('無權限操作,請洽管理員。');if (history.length==1) location.href='/wms/index.php?token=".$token."'; else history.go(-1);</script>";
// 判斷是否從藍凌過來
if (!empty($_GET['employee_no'])) {
echo "無權限操作,請洽管理員。";
exit;
}
echo "<script>alert('無權限操作,請洽管理員。');if (history.length==1) location.href='/wms/index.php?token=" . $token . "'; else history.go(-1);</script>";
} else return $do;
}
@ -179,7 +197,8 @@ function check_user_permission($user_id, $token) {
* 員工編號對應姓名表
* @return array
*/
function accountid2name() {
function accountid2name()
{
global $link;
$arr = [];
@ -198,7 +217,8 @@ function accountid2name() {
* @param array $uid 員工編號
* @return array
*/
function accountid2email($uid) {
function accountid2email($uid)
{
global $link;
if (is_array($uid)) $accountid = implode("','", $uid);
@ -224,7 +244,8 @@ function accountid2email($uid) {
* @param string|array $user_id:下位簽核者
* @param string $seq:順序
*/
function do_assign($flow_id, $id, $content, $user_id, $seq=0) {
function do_assign($flow_id, $id, $content, $user_id, $seq = 0)
{
global $link;
$tds = date("Y-m-d H:i:s");
@ -279,7 +300,8 @@ function do_assign($flow_id, $id, $content, $user_id, $seq=0) {
* @param string $id:價審單序號
* @param string $content:卷號
*/
function end_flow($system_id, $flow_id, $id, $content) {
function end_flow($system_id, $flow_id, $id, $content)
{
global $link;
$tds = date("Y-m-d H:i:s");
@ -297,7 +319,7 @@ function end_flow($system_id, $flow_id, $id, $content) {
$sql = "select ekind, person from pricereview_main where id = '$id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
$content = $row[0]."價格審查結案通知 > ".$content;
$content = $row[0] . "價格審查結案通知 > " . $content;
$kind = ($row[0] == "新梯") ? 3 : 4;
$sql2 = "insert into notice (kind, related_id, title, permission, creater, create_at) values (";
$sql2 .= "'$kind', '$id', '$content', '$row[1]', 'system', '$tds')";
@ -493,47 +515,50 @@ function accountidToRoleName($accountid)
* @param array $arr:[電梯種類,人乘/載重,停數,開門方式,速度]
* @return string 規格名,載重
*/
function facility_spec($arr) {
function facility_spec($arr)
{
if (empty($arr)) return;
list($kind, $seat, $stop, $op, $speed) = $arr;
if (strlen($speed) == 1) $speed = str_pad($speed, 2, "0", STR_PAD_LEFT);
$seat2weight_arr = ["A3" => 320, "A8" => 320, "G10" => 320, "G20" => 320, "G5" => 320, "G6" => 320,
"280-1-A" => 280, "280-1-L" => 280, "280-2-A" => 280, "280-2-L" => 280,
"320-1-A" => 320, "320-1-L" => 320, "320-2-A" => 320, "320-2-L" => 320,
"6" => 450, "8" => 550, "9" => 600, "10" => 700, "11" => 750, "12" => 800,
"13" => 900, "15" => 1000, "17" => 1150, "20" => 1350, "24" => 1600];
$seat2weight_arr = [
"A3" => 320, "A8" => 320, "G10" => 320, "G20" => 320, "G5" => 320, "G6" => 320,
"280-1-A" => 280, "280-1-L" => 280, "280-2-A" => 280, "280-2-L" => 280,
"320-1-A" => 320, "320-1-L" => 320, "320-2-A" => 320, "320-2-L" => 320,
"6" => 450, "8" => 550, "9" => 600, "10" => 700, "11" => 750, "12" => 800,
"13" => 900, "15" => 1000, "17" => 1150, "20" => 1350, "24" => 1600
];
switch ($kind) {
case "MAQ100":
$weight = $seat2weight_arr[$seat];
$ret = $kind."-".$weight."-".$stop."-".$op.$speed;
$ret = $kind . "-" . $weight . "-" . $stop . "-" . $op . $speed;
break;
case "MAP100":
$weight = $seat2weight_arr[$seat];
$ret = $kind."-".$weight."*".$stop."-".$op.$speed;
$ret = $kind . "-" . $weight . "*" . $stop . "-" . $op . $speed;
break;
case "MAM200":
case "MAH100":
$weight = $seat2weight_arr[$seat];
$ret = $kind."-".$seat."*".$stop."-".$op.$speed;
$ret = $kind . "-" . $seat . "*" . $stop . "-" . $op . $speed;
break;
case "MAF100":
$weight = $seat;
$ret = $kind."-".$seat."*".$stop."-".$op.$speed;
$ret = $kind . "-" . $seat . "*" . $stop . "-" . $op . $speed;
break;
case "MAE100":
$weight = $seat2weight_arr[$seat];
$ret = $kind."-".$seat."*".$stop."-".$op.$speed;
$ret = $kind . "-" . $seat . "*" . $stop . "-" . $op . $speed;
break;
case "M1+M4(2:1)":
case "M1+M4(1:1)":
case "M1":
$weight = $seat2weight_arr[$seat];
$ret = "P".$seat."-".$seat2weight_arr[$seat]."-".$op."-".$speed."-".$stop;
$ret = "P" . $seat . "-" . $seat2weight_arr[$seat] . "-" . $op . "-" . $speed . "-" . $stop;
break;
default:
$weight = $ret = "";
}
return $ret.",".$weight;
return $ret . "," . $weight;
}
/**
@ -541,7 +566,8 @@ function facility_spec($arr) {
* @param array $arr:[簽核人1,簽核人2,簽核人3,簽核人4]
* @return array 進度,下位審批人
*/
function sign_status($arr) {
function sign_status($arr)
{
$ret = [];
foreach ($arr as $k => $sign) {
$sign_nos = 0;
@ -554,7 +580,7 @@ function sign_status($arr) {
}
}
if (count($sign_arr) == $sign_nos) {
$ret["sign_st"] = $k+1;
$ret["sign_st"] = $k + 1;
$ret["sign_nt"] = $sign_nt_arr;
return $ret;
}
@ -566,7 +592,8 @@ function sign_status($arr) {
return $ret;
}
function getAccounttype($link,$user_id){
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);

170
wms/gary.php

@ -1,61 +1,123 @@
<?php
// 接收 referer 參數
if (isset($_GET['referer'])) {
$referer = urldecode($_GET['referer']);
echo "HTTP_REFERER 是: $referer";
echo "<br/>";
date_default_timezone_set('Asia/Taipei');
$currentTimestamp = time();
$hashReferer = "";
for ($i = -3; $i <= 3; $i++) {
$modifiedTimestamp = strtotime("$i seconds", $currentTimestamp);
$formattedTime = date("Y-m-d H:i:s", $modifiedTimestamp);
$hashReferer .= md5("https://bpm.masada.com.twMasada@2023".$formattedTime);
}
echo $hashReferer;
if (strpos($hashReferer, $referer)) {
echo "login";
}
} else {
echo "沒有 HTTP_REFERER 資訊可用";
}
echo "<br/>";
if(isset($_SERVER['HTTP_REFERER'])) {
$referrer = $_SERVER['HTTP_REFERER'];
echo "來自於: $referrer";
} else {
echo "沒有 referrer 資訊可用";
}
echo "<br/>";
if (isset($_SERVER['REMOTE_ADDR'])) {
$visitor_ip = $_SERVER['REMOTE_ADDR'];
echo "訪問者的 IP 地址是: $visitor_ip";
} else {
echo "REMOTE_ADDR : 無法獲取訪問者的 IP 地址";
}
echo "<br/>";
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$visitor_ip = $_SERVER['HTTP_CLIENT_IP'];
echo "訪問者的 IP 地址是: $visitor_ip";
} else {
echo "HTTP_CLIENT_IP : 無法獲取訪問者的 IP 地址";
}
echo "<br/>";
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$visitor_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
echo "訪問者的 IP 地址是: $visitor_ip";
} else {
echo "HTTP_X_FORWARDED_FOR : 法獲取訪問者的 IP 地址";
}
echo "<br/>";
?>
<script>
var referrer = document.referrer;
console.log("前一個網頁是:" + referrer);
</script>
<?php
exit;
ini_set('display_errors', 'on');
echo $referrer = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "抓不到";
exit;
include "fun_global.php";
include "database.php";
print_r(manage_class("M0117"));
echo manage_class("M0117")[0];
// account table
$accounttype = "A";
$accountid = "";
$pwd = "123";
$name = "";
$creater = "";
$create_at = date("Y-m-d H:i:s");
// 檢查 accountid 是否未重複並寫入 account 資料表
$sql = "
SELECT DISTINCT
a.accountid,
w.contractno,
w.custom
FROM wipwholestatus AS w
LEFT JOIN (
SELECT
accountid
FROM account
) AS a
ON a.accountid = w.contractno
WHERE a.accountid IS NULL
";
$data = mysqli_query($link, $sql);
$J = 0;
foreach ($data as $key => $row) :
echo $row['accountid']."<br>";
echo $J++;
if (empty($row['accountid'])) {
$accountid = $row['contractno'];
$name = $row['custom'];
echo $sql2 = "
INSERT INTO account (
accounttype,
accountid,
pwd,
name,
creater,
create_at
) VALUES (
'$accounttype',
'$accountid',
'$pwd',
'$name',
'$creater',
'$create_at'
)
";
echo "<br/>";
mysqli_query($link, $sql2);
}
endforeach;
// // account table
// $accounttype = "A";
// $accountid = "";
// $pwd = "123";
// $name = "";
// $creater = "";
// $create_at = date("Y-m-d H:i:s");
// // 檢查 accountid 是否未重複並寫入 account 資料表
// $sql = "
// SELECT DISTINCT
// a.accountid,
// w.contractno,
// w.custom
// FROM wipwholestatus AS w
// LEFT JOIN (
// SELECT
// accountid
// FROM account
// ) AS a
// ON a.accountid = w.contractno
// WHERE a.accountid IS NULL
// ";
// $data = mysqli_query($link, $sql);
// $J = 0;
// foreach ($data as $key => $row) :
// echo $row['accountid']."<br>";
// echo $J++;
// if (empty($row['accountid'])) {
// $accountid = $row['contractno'];
// $name = $row['custom'];
// echo $sql2 = "
// INSERT INTO account (
// accounttype,
// accountid,
// pwd,
// name,
// creater,
// create_at
// ) VALUES (
// '$accounttype',
// '$accountid',
// '$pwd',
// '$name',
// '$creater',
// '$create_at'
// )
// ";
// echo "<br/>";
// mysqli_query($link, $sql2);
// }
// endforeach;

556
wms/header.php

@ -9,38 +9,38 @@ ini_set('display_errors', 'off');
function CreateToken($user_id, $user_name)
{
date_default_timezone_set("Asia/Taipei");
$start_time = date("Y-m-d H:i:s");
$end_time = date('Y-m-d H:i:s', strtotime('+24 hour')); #设定24小时
$info = $user_id . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
date_default_timezone_set("Asia/Taipei");
$start_time = date("Y-m-d H:i:s");
$end_time = date('Y-m-d H:i:s', strtotime('+24 hour')); #设定24小时
$info = $user_id . '.' . base64_encode(urlencode($user_name)) . '.' . $start_time . '.' . $end_time; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
}
require_once dirname(__FILE__) . "/../mkt/database.php";
include "fun_global.php";
if (isset($_REQUEST["function_name"])) {
$function_name = $_REQUEST["function_name"];
$function_flag = True;
$function_name = $_REQUEST["function_name"];
$function_flag = True;
} else {
$function_name = "";
$function_flag = False;
$function_name = "";
$function_flag = False;
}
/**
* 連線T8 MSSQL
*/
try {
$conn = new PDO("sqlsrv:Server=erp.masada.com.tw;Database=T8MASADA", "masada", "ztPmPP!HRoV6SL3E");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
$conn = new PDO("sqlsrv:Server=erp.masada.com.tw;Database=T8MASADA", "masada", "ztPmPP!HRoV6SL3E");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
} catch (PDOException $e) {
//echo "fail";
//echo $e->getMessage();
//echo "fail";
//echo $e->getMessage();
}
@ -57,32 +57,32 @@ try {
$token = isset($_REQUEST["token"]) ? $_REQUEST["token"] : "";
if (count(explode(".", $token)) > 1) {
$token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$user_name = urldecode(base64_decode($enc_user_name));
$token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$user_name = urldecode(base64_decode($enc_user_name));
} else {
$referrer = isset($_GET['referer']) ? $_GET['referer'] : "";
date_default_timezone_set('Asia/Taipei');
$currentTimestamp = time();
$hashReferer = "";
for ($i = -3; $i <= 3; $i++) {
$modifiedTimestamp = strtotime("$i seconds", $currentTimestamp);
$formattedTime = date("Y-m-d H:i:s", $modifiedTimestamp);
$hashReferer .= md5("https://bpm.masada.com.twMasada@2023" . $formattedTime);
}
if (strpos($hashReferer, $referrer)) {
$user_id = !empty($_GET["employee_no"]) ? $_GET["employee_no"] : $user_id;
$login_dt = !empty($_GET["timestamp"]) ? substr($_GET["timestamp"], 0, 10) : $login_dt;
$login_dt = date('Y-m-d H:i:s', $login_dt);
// 藍凌超連結過來 token 設置永久
$login_dt = (date("Y") + 100) . "-12-31 23:59:59";
$user_name = accountid2name()[$user_id];
$token = CreateToken($user_id, $user_name);
$token_link = "token=" . $token;
} else {
echo "非法訪問!";
echo "<script>location.href='/wms/login.php'</script>";
}
$referrer = isset($_GET['referer']) ? $_GET['referer'] : "";
date_default_timezone_set('Asia/Taipei');
$currentTimestamp = time();
$hashReferer = "";
for ($i = -3; $i <= 3; $i++) {
$modifiedTimestamp = strtotime("$i seconds", $currentTimestamp);
$formattedTime = date("Y-m-d H:i:s", $modifiedTimestamp);
$hashReferer .= md5("https://bpm.masada.com.twMasada@2023" . $formattedTime);
}
if (strpos($hashReferer, $referrer)) {
$user_id = !empty($_GET["employee_no"]) ? $_GET["employee_no"] : $user_id;
$login_dt = !empty($_GET["timestamp"]) ? substr($_GET["timestamp"], 0, 10) : $login_dt;
$login_dt = date('Y-m-d H:i:s', $login_dt);
// 藍凌超連結過來 token 設置永久
$login_dt = (date("Y") + 100) . "-12-31 23:59:59";
$user_name = accountid2name()[$user_id];
$token = CreateToken($user_id, $user_name);
$token_link = "token=" . $token;
} else {
echo "非法訪問!";
echo "<script>location.href='/wms/login.php'</script>";
}
}
include 'IncludeCommon.php';
@ -90,13 +90,13 @@ $includecommon = new IncludeCommon();
$accounttype = getAccounttype($link, $user_id);
$login_json = null;
if (strlen($accounttype) != 0) {
$jsonres['menu'] = $includecommon->menu_v3($user_id, $accounttype);
$login_json = json_encode($jsonres, JSON_UNESCAPED_UNICODE);
$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);
res = eval("(" + JSON.stringify(<?php echo $login_json; ?>) + ")");
window.localStorage.setItem("menu_<?php echo $user_id; ?>", res.menu);
</script>
<?php
@ -110,196 +110,196 @@ $user_auth = check_user_permission($user_id, $token);
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Masada後臺系統</title>
<link rel="stylesheet" href="<?php dirname(__DIR__); ?>/wms/css/styles.css" />
<link rel="stylesheet" href="<?php dirname(__DIR__); ?>/wms/css/bootstrap.min.css">
<style>
a svg {
display: inline-block;
vertical-align: text-top;
}
.nav .icon {
display: none;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Masada後臺系統</title>
<link rel="stylesheet" href="<?php dirname(__DIR__); ?>/wms/css/styles.css" />
<link rel="stylesheet" href="<?php dirname(__DIR__); ?>/wms/css/bootstrap.min.css">
<style>
a svg {
display: inline-block;
vertical-align: text-top;
}
input:read-only {
background-color: #eee5e5;
}
.nav .icon {
display: none;
}
@media screen and (max-width: 992px) {
.header-right {
float: left !important;
margin-top: -40px;
margin-left: -15px;
}
/*.nav.navbar-nav a:not(:last-child), .dropdown {*/
.nav.navbar-nav a,
.dropdown {
display: none;
}
.nav.navbar-nav .icon {
color: #fff;
display: block;
position: fixed;
right: 0;
top: 0;
}
}
input:read-only {
background-color: #eee5e5;
}
@media screen and (max-width: 992px) {
.nav.navbar-nav.responsive {
position: relative;
}
.nav.navbar-nav.responsive a.icon {
position: fixed;
right: 0;
top: 0;
}
.nav.navbar-nav.responsive li {
float: none;
display: block;
text-align: left;
}
.nav.navbar-nav.responsive .dropdown {
float: none;
}
.nav.navbar-nav.responsive .dropdown li {
position: relative;
}
.nav.navbar-nav.responsive .dropdown a {
display: block;
width: 100%;
text-align: left;
top: -10px;
line-height: 10px;
}
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #000;
}
.nav.navbar-nav.responsive .dropdown ul {
width: 200px;
background-color: #fff;
}
.navbar-nav .open .dropdown-menu {
position: absolute;
}
}
@media screen and (max-width: 992px) {
.header-right {
float: left !important;
margin-top: -40px;
margin-left: -15px;
}
/*.nav.navbar-nav a:not(:last-child), .dropdown {*/
.nav.navbar-nav a,
.dropdown {
display: none;
}
.nav.navbar-nav .icon {
color: #fff;
display: block;
position: fixed;
right: 0;
top: 0;
}
}
@media screen and (max-width: 992px) {
#member_content_phone {
display: inline-grid !important;
}
}
</style>
<script src="<?php dirname(__DIR__); ?>/wms/css/jquery.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/bootstrap.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/jquery.dataTables.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/dataTables.bootstrap4.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/function.js"></script>
<script>
$(document).ready(function() {
if ($('#table_index').length !== 0) $('#table_index').DataTable();
if (window.localStorage) {
//var tokendata=window.localStorage.getItem("token");
//var namedata=window.localStorage.getItem("name");
//var logindata=window.localStorage.getItem("login");
var menudata = window.localStorage.getItem("menu_<?php echo $user_id; ?>");
//if(tokendata==null || namedata==null || menudata==null){
if (menudata == null) {
window.location.href = "<?php dirname(__DIR__); ?>/wms/login.php";
@media screen and (max-width: 992px) {
.nav.navbar-nav.responsive {
position: relative;
}
.nav.navbar-nav.responsive a.icon {
position: fixed;
right: 0;
top: 0;
}
.nav.navbar-nav.responsive li {
float: none;
display: block;
text-align: left;
}
.nav.navbar-nav.responsive .dropdown {
float: none;
}
.nav.navbar-nav.responsive .dropdown li {
position: relative;
}
.nav.navbar-nav.responsive .dropdown a {
display: block;
width: 100%;
text-align: left;
top: -10px;
line-height: 10px;
}
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #000;
}
.nav.navbar-nav.responsive .dropdown ul {
width: 200px;
background-color: #fff;
}
.navbar-nav .open .dropdown-menu {
position: absolute;
}
}
} else {
// var tokendata=$.cookie("token");
}
var url = "<?php dirname(__DIR__); ?>/wms/headerapi.php";
$.ajax({
method: 'post',
url: url,
data: {
token: '<?php echo $token; ?>'
},
success: function(data) {
var res = eval('(' + data + ')');
//console.log(res);
if (res.code != '200') {
window.location.href = '<?php dirname(__DIR__); ?>/wms/login.php?errno=3';
}
@media screen and (max-width: 992px) {
#member_content_phone {
display: inline-grid !important;
}
}
});
var mdata = JSON.parse(menudata);
var menuStr = '';
var checkAuth = 0;
var m = 1;
for (var i in mdata) {
menuStr += '<li class="dropdown">';
menuStr += '<a class="dropdown-toggle" data-toggle="dropdown" href="#">' + i;
menuStr += '<span class="caret"></span></a>';
menuStr += '<ul class="dropdown-menu">';
for (var j in mdata[i]) {
for (var k in mdata[i][j]) {
menuStr += '<li';
if (k == '<?php echo $function_name; ?>') menuStr += " class='active'";
menuStr += '><a href="<?php dirname(__DIR__); ?>/wms/' + mdata[i][j][k] + '?function_name=' + k + '&<?php echo $token_link; ?>"';
if (k.indexOf('open-') !== -1) menuStr += ' target="_blank"';
menuStr += '>' + j + '</a></li>';
if (mdata[i][j][k] == window.location.pathname) checkAuth = 1;
m++;
}
</style>
<script src="<?php dirname(__DIR__); ?>/wms/css/jquery.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/bootstrap.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/jquery.dataTables.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/dataTables.bootstrap4.min.js"></script>
<script src="<?php dirname(__DIR__); ?>/wms/css/function.js"></script>
<script>
$(document).ready(function() {
if ($('#table_index').length !== 0) $('#table_index').DataTable();
if (window.localStorage) {
//var tokendata=window.localStorage.getItem("token");
//var namedata=window.localStorage.getItem("name");
//var logindata=window.localStorage.getItem("login");
var menudata = window.localStorage.getItem("menu_<?php echo $user_id; ?>");
//if(tokendata==null || namedata==null || menudata==null){
if (menudata == null) {
window.location.href = "<?php dirname(__DIR__); ?>/wms/login.php";
}
} else {
// var tokendata=$.cookie("token");
}
var url = "<?php dirname(__DIR__); ?>/wms/headerapi.php";
$.ajax({
method: 'post',
url: url,
data: {
token: '<?php echo $token; ?>'
},
success: function(data) {
var res = eval('(' + data + ')');
//console.log(res);
if (res.code != '200') {
window.location.href = '<?php dirname(__DIR__); ?>/wms/login.php?errno=3';
}
}
});
var mdata = JSON.parse(menudata);
var menuStr = '';
var checkAuth = 0;
var m = 1;
for (var i in mdata) {
menuStr += '<li class="dropdown">';
menuStr += '<a class="dropdown-toggle" data-toggle="dropdown" href="#">' + i;
menuStr += '<span class="caret"></span></a>';
menuStr += '<ul class="dropdown-menu">';
for (var j in mdata[i]) {
for (var k in mdata[i][j]) {
menuStr += '<li';
if (k == '<?php echo $function_name; ?>') menuStr += " class='active'";
menuStr += '><a href="<?php dirname(__DIR__); ?>/wms/' + mdata[i][j][k] + '?function_name=' + k + '&<?php echo $token_link; ?>"';
if (k.indexOf('open-') !== -1) menuStr += ' target="_blank"';
menuStr += '>' + j + '</a></li>';
if (mdata[i][j][k] == window.location.pathname) checkAuth = 1;
m++;
}
}
menuStr += '</ul>';
menuStr += '</li>';
}
menuStr += '<li><a href="javascript:void(0);" class="icon" onclick="myFunction()"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-grid-3x3-gap-fill" viewBox="0 0 16 16"><path d="M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V2zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V7zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-2z"/></svg></a></li>';
/*
if (checkAuth == 0 && ('/wms/custom-create.php' != window.location.pathname)) {
window.location.href='login.php?errno=4';
}
*/
$('#menu_content').html(menuStr);
$('.dropdown a').on('click', function() {
$('.dropdown').removeClass('open');
});
});
function myFunction() {
var x = document.getElementById("menu_content");
if (x.className === "nav navbar-nav") {
x.className += " responsive";
} else {
x.className = "nav navbar-nav";
}
}
menuStr += '</ul>';
menuStr += '</li>';
}
menuStr += '<li><a href="javascript:void(0);" class="icon" onclick="myFunction()"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-grid-3x3-gap-fill" viewBox="0 0 16 16"><path d="M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V2zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V7zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1v-2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-2zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-2z"/></svg></a></li>';
/*
if (checkAuth == 0 && ('/wms/custom-create.php' != window.location.pathname)) {
window.location.href='login.php?errno=4';
}
*/
$('#menu_content').html(menuStr);
$('.dropdown a').on('click', function() {
$('.dropdown').removeClass('open');
});
});
function myFunction() {
var x = document.getElementById("menu_content");
if (x.className === "nav navbar-nav") {
x.className += " responsive";
} else {
x.className = "nav navbar-nav";
}
}
</script>
</script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="<?php dirname(__DIR__); ?>/wms/index.php?<?php echo $token_link; ?>">Masada</a>
</div>
<ul class="nav navbar-nav" id="menu_content">
</ul>
<!--
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="<?php dirname(__DIR__); ?>/wms/index.php?<?php echo $token_link; ?>">Masada</a>
</div>
<ul class="nav navbar-nav" id="menu_content">
</ul>
<!--
<div class="topnav" id="myTopnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
@ -319,53 +319,53 @@ $user_auth = check_user_permission($user_id, $token);
</div>
-->
<div class="header-right">
<ul class="nav navbar-nav" id="member_content">
<li class="dropdown d-lg-none">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style='padding:0px;padding-top:5px;'>
<?php echo $user_name . "(" . $user_id . ")" . "<br/>" . $login_dt; ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a style="color:#000;" href="<?php dirname(__DIR__); ?>/wms/change-password.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<rect width="24" height="24" fill="white"></rect>
<path d="M2.5 12C2.5 12.2761 2.72386 12.5 3 12.5C3.27614 12.5 3.5 12.2761 3.5 12H2.5ZM3.5 12C3.5 7.30558 7.30558 3.5 12 3.5V2.5C6.75329 2.5 2.5 6.75329 2.5 12H3.5ZM12 3.5C15.3367 3.5 18.2252 5.4225 19.6167 8.22252L20.5122 7.77748C18.9583 4.65062 15.7308 2.5 12 2.5V3.5Z" fill="#000000"></path>
<path d="M20.4716 2.42157V8.07843H14.8147" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M21.5 12C21.5 11.7239 21.2761 11.5 21 11.5C20.7239 11.5 20.5 11.7239 20.5 12L21.5 12ZM20.5 12C20.5 16.6944 16.6944 20.5 12 20.5L12 21.5C17.2467 21.5 21.5 17.2467 21.5 12L20.5 12ZM12 20.5C8.66333 20.5 5.77477 18.5775 4.38328 15.7775L3.48776 16.2225C5.04168 19.3494 8.26923 21.5 12 21.5L12 20.5Z" fill="#000000"></path>
<path d="M3.52844 21.5784L3.52844 15.9216L9.18529 15.9216" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
</g>
</svg>
更改密碼
</a>
</li>
<li>
<a style="color:#000;" href="<?php dirname(__DIR__); ?>/wms/logout.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg>
登出
</a>
</li>
</ul>
</li>
</ul>
<div id="member_content_phone" style="display:none">
<span class="navbar-brand">
<h5><?php echo $user_name . "(" . $user_id . ")" . $login_dt; ?></h5>
</span>
<a href="<?php dirname(__DIR__); ?>/wms/change-password.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
更改密碼</a>
<a href="<?php dirname(__DIR__); ?>/wms/logout.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg>
登出</a>
</div>
</div>
</nav>
<div class="header-right">
<ul class="nav navbar-nav" id="member_content">
<li class="dropdown d-lg-none">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" style='padding:0px;padding-top:5px;'>
<?php echo $user_name . "(" . $user_id . ")" . "<br/>" . $login_dt; ?>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a style="color:#000;" href="<?php dirname(__DIR__); ?>/wms/change-password.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<rect width="24" height="24" fill="white"></rect>
<path d="M2.5 12C2.5 12.2761 2.72386 12.5 3 12.5C3.27614 12.5 3.5 12.2761 3.5 12H2.5ZM3.5 12C3.5 7.30558 7.30558 3.5 12 3.5V2.5C6.75329 2.5 2.5 6.75329 2.5 12H3.5ZM12 3.5C15.3367 3.5 18.2252 5.4225 19.6167 8.22252L20.5122 7.77748C18.9583 4.65062 15.7308 2.5 12 2.5V3.5Z" fill="#000000"></path>
<path d="M20.4716 2.42157V8.07843H14.8147" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M21.5 12C21.5 11.7239 21.2761 11.5 21 11.5C20.7239 11.5 20.5 11.7239 20.5 12L21.5 12ZM20.5 12C20.5 16.6944 16.6944 20.5 12 20.5L12 21.5C17.2467 21.5 21.5 17.2467 21.5 12L20.5 12ZM12 20.5C8.66333 20.5 5.77477 18.5775 4.38328 15.7775L3.48776 16.2225C5.04168 19.3494 8.26923 21.5 12 21.5L12 20.5Z" fill="#000000"></path>
<path d="M3.52844 21.5784L3.52844 15.9216L9.18529 15.9216" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
</g>
</svg>
更改密碼
</a>
</li>
<li>
<a style="color:#000;" href="<?php dirname(__DIR__); ?>/wms/logout.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg>
登出
</a>
</li>
</ul>
</li>
</ul>
<div id="member_content_phone" style="display:none">
<span class="navbar-brand">
<h5><?php echo $user_name . "(" . $user_id . ")" . $login_dt; ?></h5>
</span>
<a href="<?php dirname(__DIR__); ?>/wms/change-password.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;">
更改密碼</a>
<a href="<?php dirname(__DIR__); ?>/wms/logout.php?<?php echo $token_link; ?>" class="navbar-brand" style="font-size:14px;line-height:34px;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z" />
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z" />
</svg>
登出</a>
</div>
</div>
</nav>

2
wms/loginapi.php

@ -18,7 +18,7 @@ if(!empty($_REQUEST["account"])&& !empty($_REQUEST["password"])) {
$accounttype = $row['accounttype'];
$user_name = $row['name'];
// 修正小寫登入 token 會帶入小寫的bug //M0117修改于 2023/07/31 13:45
$accountid = $row['accountid'];
$accountid = strtoupper($row['accountid']);
if (strlen($accounttype) != 0) {
// B=保養員 M=永佳捷員工 E=管理員
if ($accounttype == "B" || $accounttype == "M" || $accounttype == "E" || $accounttype == "W"){

353
wms/menu-edit.php

@ -1,95 +1,302 @@
<style>
input,
select {
margin: 0 0 !important;
vertical-align: middle !important;
}
.mybutton {
padding: 3px !important;
}
</style>
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql语法存在变数中
$db_query = "SELECT * FROM menu WHERE id = $id";
// 用mysqli_query方法执行(sql语法)将结果存在变数中
$data = mysqli_query($link, $db_query);
// sql语法存在变数中
$db_query = "SELECT * FROM menu WHERE id = $id";
// 用mysqli_query方法执行(sql语法)将结果存在变数中
$result = mysqli_query($link, $db_query);
$data = mysqli_fetch_assoc($result);
mysqli_free_result($result);
foreach($data as $data) :
//$link_content = str_replace(',', PHP_EOL, $data['link_content']);
?>
<script>
$(function () {
$db_query = "
SELECT * FROM department
ORDER BY department_id ASC
";
$result = mysqli_query($link, $db_query);
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
});
</script>
//$link_content = str_replace(',', PHP_EOL, $data['link_content']);
?>
<div class="container">
<form class="form-inline" method="post" action="menu-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="main_menu">主功能名稱</label>
<input type="text" name="main_menu" id="main_menu" value="<?php echo $data['main_menu']; ?>" required>
</div>
<div>
<label for="main_menu_seq">主功能排序</label>
<select name="main_menu_seq" id="main_menu_seq">
<?php
for ($i=1;$i<21;$i++) {
echo '<option value="'.$i.'"';
if ($i == $data["main_menu_seq"]) echo " selected";
echo '>'.$i.'</option>';
}
?>
</select>
</div>
<div>
<label for="sub_menu">子功能名稱</label>
<input type="text" name="sub_menu" id="sub_menu" value="<?php echo $data['sub_menu']; ?>" required>
</div>
<div>
<label for="sub_menu_seq">子功能排序</label>
<select name="sub_menu_seq" id="sub_menu_seq">
<?php
for ($i=1;$i<21;$i++) {
echo '<option value="'.$i.'"';
if ($i == $data["sub_menu_seq"]) echo " selected";
echo '>'.$i.'</option>';
}
?>
</select>
</div>
<div>
<label for="sub_menu_eng">子功能英文名</label>
<input type="text" name="sub_menu_eng" id="sub_menu_eng" value="<?php echo $data['sub_menu_eng']; ?>" required>
</div>
<div>
<label for="mlink">主網址</label>
<input type="text" name="mlink" id="mlink" size="30" value="<?php echo $data['mlink']; ?>" required>
</div>
<div>
<label for="link_content">程式列表</label>
<textarea name="link_content" id="link_content" rows="10" cols="60" class="form-control" required><?php echo $data['link_content']; ?></textarea>
<div class="row col-md-12 col-sm-12">
<div class="col-md-2 col-sm-12">
<label for="main_menu">主功能名稱</label>
<input type="text" name="main_menu" id="main_menu" value="<?php echo $data['main_menu']; ?>" required>
</div>
<div class="col-md-2 col-sm-12">
<label for="main_menu_seq">主功能排序</label>
<select name="main_menu_seq" id="main_menu_seq">
<?php
for ($i = 1; $i < 21; $i++) {
echo '<option value="' . $i . '"';
if ($i == $data["main_menu_seq"]) echo " selected";
echo '>' . $i . '</option>';
}
?>
</select>
</div>
<div class="col-md-2 col-sm-12">
<label for="sub_menu">子功能名稱</label>
<input type="text" name="sub_menu" id="sub_menu" value="<?php echo $data['sub_menu']; ?>" required>
</div>
<div class="col-md-2 col-sm-12">
<label for="sub_menu_seq">子功能排序</label>
<select name="sub_menu_seq" id="sub_menu_seq">
<?php
for ($i = 1; $i < 21; $i++) {
echo '<option value="' . $i . '"';
if ($i == $data["sub_menu_seq"]) echo " selected";
echo '>' . $i . '</option>';
}
?>
</select>
</div>
<div class="col-md-2 col-sm-12">
<label for="sub_menu_eng">子功能英文名</label>
<input type="text" name="sub_menu_eng" id="sub_menu_eng" value="<?php echo $data['sub_menu_eng']; ?>" required>
</div>
<div class="col-md-2 col-sm-12">
<label for="mlink">主網址</label>
<input type="text" name="mlink" id="mlink" size="30" value="<?php echo $data['mlink']; ?>" required>
</div>
<div class="col-md-4 col-sm-12">
<label for="status">狀態</label>
<select name="status" id="status">
<option value="N" <?php if ($data["status"] == "N") echo " selected"; ?>>隱藏</option>
<!--<option value="T"<?php if ($data["status"] == "T") echo " selected"; ?>>測試</option>-->
<option value="Y" <?php if ($data["status"] == "Y") echo " selected"; ?>>正常</option>
</select>
</div>
<div class="col-md-4 col-sm-12">
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div class="col-md-12 col-sm-12" style="margin-top:15px;">
<label class='col-md-12' for="link_content">程式列表</label>
<textarea name="link_content" id="link_content" rows="10" cols="60" class="form-control" required><?php echo $data['link_content']; ?></textarea>
</div>
</div>
<div>
<label for="status">狀態</label>
<select name="status" id="status">
<option value="N"<?php if ($data["status"]=="N") echo " selected"; ?>>隱藏</option>
<!--<option value="T"<?php if ($data["status"]=="T") echo " selected"; ?>>測試</option>-->
<option value="Y"<?php if ($data["status"]=="Y") echo " selected"; ?>>正常</option>
</select>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
<div class="row col-md-12 col-sm-12" style="margin-top:15px;">
<div class="col-md-4 col-sm-12">
<label class='col-md-12' for="selectL1">可讀權限</label>
<select multiple="multiple" id="selectL1" style="width:100%;height:300px; border:4px #A0A0A4 outset; padding:4px; ">
<?php
foreach ($data2 as $row) {
$menu_permission = json_decode($row['permission']);
$status = false;
foreach ($menu_permission as $key => $value) {
if ($key == $data['mlink'] && in_array($value, ['1'])) {
$status = true;
break;
}
}
if (!$status)
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>";
}
?>
</select>
</div>
<div class="col-md-1 col-sm-12">
<label class='col-md-12' for="add"> </label>
<button id="add1" type="button" class="btn mybutton">添加</button>
<button id="remove1" type="button" class="btn mybutton">移除</button>
<button id="add_all1" type="button" class="btn mybutton">全部添加</button>
<button id="remove_all1" type="button" class="btn mybutton">全部移除</button>
</div>
<div class="col-md-4 col-sm-12">
<label class='col-md-12' for="selectR1"> </label>
<select multiple="multiple" id="selectR1" name="can_read[]" style="width:100%;height:300px;;border:4px #A0A0A4 outset; padding:4px;">
<?php
foreach ($data2 as $row) {
$menu_permission = json_decode($row['permission']);
foreach ($menu_permission as $key => $value) {
if ($key == $data['mlink'] && in_array($value, ['1'])) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>";
}
}
}
?>
</select>
</div>
</div>
<div class="row col-md-12 col-sm-12" style="margin-top:15px;">
<div class="col-md-4 col-sm-12">
<label class='col-md-12' for="selectL2">可寫權限</label>
<select multiple="multiple" id="selectL2" style="width:100%;height:300px; border:4px #A0A0A4 outset; padding:4px; ">
<?php
foreach ($data2 as $row) {
$menu_permission = json_decode($row['permission']);
$status = false;
foreach ($menu_permission as $key => $value) {
if ($key == $data['mlink'] && in_array($value, ['2', '3'])) {
$status = true;
break;
}
}
if (!$status)
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>";
}
?>
</select>
</div>
<div class="col-md-1 col-sm-12">
<label class='col-md-12' for="add"> </label>
<button id="add2" type="button" class="btn mybutton">添加</button>
<button id="remove2" type="button" class="btn mybutton">移除</button>
<button id="add_all2" type="button" class="btn mybutton">全部添加</button>
<button id="remove_all2" type="button" class="btn mybutton">全部移除</button>
</div>
<div class="col-md-4 col-sm-12">
<label class='col-md-12' for="selectR2"> </label>
<select multiple="multiple" id="selectR2" name="can_write[]" style="width:100%;height:300px;;border:4px #A0A0A4 outset; padding:4px;">
<?php
foreach ($data2 as $row) {
$menu_permission = json_decode($row['permission']);
foreach ($menu_permission as $key => $value) {
if ($key == $data['mlink'] && in_array($value, ['2', '3'])) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "_" . $row['role'] . "</option>";
}
}
}
?>
</select>
</div>
</div>
<div>
<br>
<button type="submit" name="update">確定</button>
<div class="row col-md-12 col-sm-12">
<div class="col-md-12 col-sm-12">
<button class="pull-right" type="submit" name="update" id="update_btn" disabled>請先鎖定再提交</button>
<button class="pull-right" type="button" onclick="lockAuthSelect()">鎖定權限</button>
</div>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
</form>
</div>
<script>
$(function() {
lrSelectChange('selectL', 'selectR', '1');
lrSelectChange('selectL', 'selectR', '2');
});
function lockAuthSelect() {
$("#selectR1 option").prop("selected", true);
$("#selectR2 option").prop("selected", true);
$("#update_btn").text("提交").removeAttr("disabled");
}
function lrSelectChange(lSelect, rSelect, id) {
lSelect = lSelect + id;
rSelect = rSelect + id;
//移到右边
$('#add' + id).click(function() {
//获取选中的选项,删除并追加给对方
for (var i = 0; i < $('#' + lSelect + ' option:selected').length; i++) {
$('#' + lSelect + ' option:selected')[i].text = $('#' + lSelect + ' option:selected')[i].text
$('#' + lSelect + ' option:selected')[i].value = $('#' + lSelect + ' option:selected')[i].value
}
$('#' + lSelect + ' option:selected').appendTo('#' + rSelect);
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
//移到左边
$('#remove' + id).click(function() {
for (var i = 0; i < $('#' + rSelect + ' option:selected').length; i++) {
$('#' + rSelect + ' option:selected')[i].text = $('#' + rSelect + ' option:selected')[i].text
$('#' + rSelect + ' option:selected')[i].value = $('#' + rSelect + ' option:selected')[i].value
}
$('#' + rSelect + ' option:selected').appendTo('#' + lSelect + '');
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
//全部移到右边
$('#add_all' + id).click(function() {
for (var i = 0; i < $('#' + lSelect + ' option').length; i++) {
$('#' + lSelect + ' option')[i].text = $('#' + lSelect + ' option')[i].text
$('#' + lSelect + ' option')[i].value = $('#' + lSelect + ' option')[i].value
}
//获取全部的选项,删除并追加给对方
$('#' + lSelect + ' option').appendTo('#' + rSelect + '');
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
//全部移到左边
$('#remove_all' + id).click(function() {
for (var i = 0; i < $('#' + rSelect + ' option').length; i++) {
$('#' + rSelect + ' option')[i].text = $('#' + rSelect + ' option')[i].text
$('#' + rSelect + ' option')[i].value = $('#' + rSelect + ' option')[i].value
}
$('#' + rSelect + ' option').appendTo('#' + lSelect + '');
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
//双击选项,左边到右边
$('#' + lSelect + '').dblclick(function() { //绑定双击事件
for (var i = 0; i < $('#' + lSelect + ' option:selected').length; i++) {
$('#' + lSelect + ' option:selected')[i].text = $('#' + lSelect + ' option:selected')[i].text
$('#' + lSelect + ' option:selected')[i].value = $('#' + lSelect + ' option:selected')[i].value
}
$('#' + lSelect + ' option:selected').appendTo('#' + rSelect + '');
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
//双击选项,右边到左边
$('#' + rSelect + '').dblclick(function() {
for (var i = 0; i < $('#selectR1 option:selected').length; i++) {
$('#' + rSelect + ' option:selected')[i].text = $('#' + rSelect + ' option:selected')[i].text
$('#' + rSelect + ' option:selected')[i].value = $('#' + rSelect + ' option:selected')[i].value
}
$('#' + rSelect + ' option:selected').appendTo('#' + lSelect + '');
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
});
$('#' + rSelect + '').click(function() {
$("#update_btn").text("請先鎖定再提交").attr("disabled", "disabled");
if ($('#' + rSelect + ' option:selected').length > 1) { //右侧选中多个时,只允许点击一个使其变序
return;
}
if (($("option:selected", this).text().substring($("option:selected", this).text().length - 4, $("option:selected", this).text().length)) == '(升序)') {
var a = $("option:selected", this).text();
$("option:selected", this).prop('text', a)
var b = $("option:selected", this).val();
b = b.replace("$asc", "$desc")
$("option:selected", this).prop('value', b)
return
}
if (($("option:selected", this).text().substring($("option:selected", this).text().length - 4, $("option:selected", this).text().length)) == '(降序)') {
var a = $("option:selected", this).text();
$("option:selected", this).prop('text', a)
var b = $("option:selected", this).val();
b = b.replace("$desc", "$asc")
$("option:selected", this).prop('value', b)
return
}
});
}
$(function() {
});
</script>
<?php
endforeach;
include "footer.php";
include "footer.php";
?>

155
wms/menu-record-update.php

@ -1,29 +1,172 @@
<?php
ini_set('display_errors', 'on');
include "header.php";
if(isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
$auth_change_status = false;
if (isset($_POST['update'])) {
// foreach ($_POST as $k => $v) {
// $$k = htmlspecialchars(stripslashes(trim($v)));
// }
if (!empty($_POST['can_read'])) {
$auth_change_status = true;
$link_content = explode("\r\n", $_POST['link_content']);
foreach ($_POST['can_read'] as $id) {
// 更新部門可寫權限 json
$permission = [];
$department_id = 0;
$role_id = 0;
$sql = "
SELECT
department_id,
role_id,
permission
FROM department
WHERE 1=1
AND id = '$id'
";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_assoc($result);
$department_id = $data['department_id'];
$role_id = $data['role_id'];
mysqli_free_result($result);
$permission = json_decode($data['permission'], true);
foreach ($link_content as $row) {
$permission[$row] = '1';
}
$new_permiccion = json_encode($permission);
// 更改此職位權限
$sql = "
UPDATE department
SET permission = '$new_permiccion'
WHERE 1=1
AND id = '$id'
";
mysqli_query($link, $sql);
// 更改此職位底下所有員工的權限
$sql = "
SELECT accountid
FROM account
WHERE 1=1
AND department_id = '$department_id'
AND role_id = '$role_id'
";
$result = mysqli_query($link, $sql);
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
foreach ($data2 as $row) {
$sql = "
UPDATE account_auth
SET permission = '$new_permiccion'
WHERE 1=1
AND accountid = '" . $row['accountid'] . "'
";
mysqli_query($link, $sql);
}
}
}
if (!empty($_POST['can_write'])) {
$auth_change_status = true;
$link_content = explode("\r\n", $_POST['link_content']);
foreach ($_POST['can_write'] as $id) {
// 更新部門可寫權限 json
$permission = [];
$department_id = 0;
$role_id = 0;
$sql = "
SELECT
department_id,
role_id,
permission
FROM department
WHERE 1=1
AND id = '$id'
";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_assoc($result);
$department_id = $data['department_id'];
$role_id = $data['role_id'];
mysqli_free_result($result);
$permission = json_decode($data['permission'], true);
foreach ($link_content as $row) {
$permission[$row] = '3';
}
$new_permiccion = json_encode($permission);
// 更改此職位權限
$sql = "
UPDATE department
SET permission = '$new_permiccion'
WHERE 1=1
AND id = '$id'
";
mysqli_query($link, $sql);
// 更改此職位底下所有員工的權限
$sql = "
SELECT accountid
FROM account
WHERE 1=1
AND department_id = '$department_id'
AND role_id = '$role_id'
";
$result = mysqli_query($link, $sql);
$data2 = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_free_result($result);
foreach ($data2 as $row) {
$sql = "
UPDATE account_auth
SET permission = '$new_permiccion'
WHERE 1=1
AND accountid = '" . $row['accountid'] . "'
";
mysqli_query($link, $sql);
}
}
}
$main_menu_seq = empty($_POST['main_menu_seq']) ? '' : $_POST['main_menu_seq'];
$main_menu = empty($_POST['main_menu']) ? '' : $_POST['main_menu'];
$sub_menu_seq = empty($_POST['sub_menu_seq']) ? '' : $_POST['sub_menu_seq'];
$sub_menu = empty($_POST['sub_menu']) ? '' : $_POST['sub_menu'];
$sub_menu_eng = empty($_POST['sub_menu_eng']) ? '' : $_POST['sub_menu_eng'];
$mlink = empty($_POST['mlink']) ? '' : $_POST['mlink'];
$link_content = empty($_POST['link_content']) ? '' : $_POST['link_content'];
$status = empty($_POST['status']) ? '' : $_POST['status'];
$id = empty($_POST['id']) ? '' : $_POST['id'];
$create_at = date('Y-m-d H:i:s');
//$link_content = str_replace(PHP_EOL, ',', $link_content);
$db_query = "UPDATE menu set main_menu_seq = '$main_menu_seq', main_menu = '$main_menu', sub_menu_seq = '$sub_menu_seq', sub_menu = '$sub_menu', ";
$db_query .= "sub_menu_eng = '$sub_menu_eng', mlink = '$mlink', link_content = '$link_content', status = '$status', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='menu-index.php?function_name=menu&".$token_link."';";
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';";
echo "</script>";
} elseif ($auth_change_status == true) {
echo "<script type ='text/JavaScript'>";
echo "alert('權限調整成功');";
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='menu-index.php?function_name=menu&".$token_link."';";
echo "location.href='menu-index.php?function_name=menu&" . $token_link . "';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

20
wms/rib01-create.php

@ -33,7 +33,6 @@ foreach ($deptmem as $mem) {
$username = $mem['Username'];
$member["$userid"] = [$username];
};
// print_r($member);
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE (DeptId!='0001')";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
@ -124,6 +123,9 @@ if ($MaxBillNo < 10) {
<option value="" style="display:flex" id="WriteOffoption">請選擇報銷人</option>
<?php
foreach ($member as $key => $value) { ?>
<!-- <option value="<?php echo $value['UserId']; ?>" style="display:none" id="<?= 'WriteOff' . $value['UserId'] . $key ?>" <?php if ($value['UserId'] == $user_id) {
echo "selected";
} ?>> <?php echo $value['Username']; ?> </option> -->
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . "-" . $value[0] ?>" <?php if ($key == $user_id) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
@ -140,18 +142,15 @@ if ($MaxBillNo < 10) {
</div>
<div class="col-md-3">
<label for="GatheringPersonId" style="color: red;">收款人</label>
<select name="GatheringPersonId" id="GatheringPersonId" class="form-control">
<select name="GatheringPersonId" id="GatheringPersonId" >
<option value="" style="display:flex" id="GatheringOption">請選擇收款人</option>
<?php
// foreach ($deptmem as $key => $value) {
foreach ($member as $key => $value) {
?>
<!-- <option value="<?php echo $value['accountid']; ?>" id="<?= 'Gathering' . $value['department_id'] ?>" <?php if ($value['accountid'] == $user_id) {
echo "selected";
} ?>> <?php echo $value['name']; ?> </option> -->
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . "-" . $value[0] ?>" <?php if ($key == $user_id) {
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . "-" . $value[0] ?>" style="display:flex" <?php if ($key == $user_id) {
echo "selected";
} ?>> <?php echo $value[0]; ?> </option>
} ?>> <?php echo $key.$value[0]; ?> </option>
<?php }; ?>
</select>
</div>
@ -178,7 +177,12 @@ if ($MaxBillNo < 10) {
</div>
</form>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css" integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js" integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$(document).ready(function() {
$('#GatheringPersonId').selectize();
})
$(function() {
$("#DeptId").change(function() {
changeWriteOffId($('#DeptId').val());

22
wms/wipwhole-change-contractdate-function.php

@ -436,6 +436,7 @@ function getShengguanokOptions($link)
FROM `account`
WHERE `department_id` IN ('250')
AND `role_id` IN ('1','4')
ORDER BY accountid DESC
";
return mysqli_query($link, $sql);
}
@ -598,16 +599,17 @@ function getAssignStatusSelect($link, $user_id, $nowFormStatus)
} else {
$options_str .= "<option value='B'>提出申請</option>";
}
}
if (in_array(checkNowFormStatus($link), ['A', 'D'])) {
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"]))
$options_str .= "<option value='Z'>通過</option>";
$options_str .= "<option value='C'>取消</option>";
}
if (checkNowFormStatus($link) == 'B') {
if (in_array(getDepartmentId($link, $user_id), ['521', '531', '541', '542', '543', '544', '545']))
$options_str .= "<option value='D'>通過</option>";
$options_str .= "<option value='C'>取消</option>";
}else{
if (in_array(checkNowFormStatus($link), ['A', 'D'])) {
if (accountidToDepartId($user_id) == "250" && in_array(accountidToRoleId($user_id), ["1", "4"]))
$options_str .= "<option value='Z'>通過</option>";
$options_str .= "<option value='C'>取消</option>";
}
if (checkNowFormStatus($link) == 'B') {
if (in_array(getDepartmentId($link, $user_id), ['521', '531', '541', '542', '543', '544', '545']))
$options_str .= "<option value='D'>通過</option>";
$options_str .= "<option value='C'>取消</option>";
}
}
$options_str .= "</select>";
return $options_str;

35
wms/wipwhole-change-contractdate.php

@ -1,36 +1,6 @@
<?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();
$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 是新申請單
@ -41,6 +11,9 @@ if (strlen($accounttype) != 0) {
// ini_set('display_errors', 'on');
// include 'IncludeCommon.php';
require_once "database.php";
// $includecommon = new IncludeCommon();
include "header.php";
include "css/view/wipwhole-change-contractdate.php";
include "wipwhole-change-contractdate-function.php";
@ -367,7 +340,7 @@ if (!empty(checkNowFormStatus($link)))
</select>
";
} else if (checkNowFormStatus($link) == 'B') {
if (getDepartmentId($link, $user_id) == '521' || getDepartmentId($link, $user_id) == '531') {
if (in_array(getDepartmentId($link, $user_id), ['521', '531', '541', '542', '543', '544', '545'])){
echo "<select name='next_users' id='next_users'>";
foreach ($shengguanok_options as $shengguanok_option) :
echo "

22
wms/wipwhole-change-planning-customer-name.php

@ -1,18 +1,18 @@
<?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'];
}
// 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';
// include 'IncludeCommon.php';
require_once "database.php";
$includecommon = new IncludeCommon();
// $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);
@ -40,7 +40,7 @@ if (strlen($accounttype) != 0) {
5. 大日程的 id 新申請過的直接取得
*/
include "header.php";
include "css/view/wipwhole-change-contractdate.php";
include "wipwhole-change-planning-customer-name-function.php";

60
wms/wipwhole-index-function.php

@ -1,5 +1,22 @@
<?php
/**
* 取得生管主管 options
* @param object $link:資料庫連線
* @param string $id:作番大日程唯一值
* @return object 回傳 mysqli_query
*/
function getWipwholestatusDetail($link, $id)
{
$db_query = "
SELECT * FROM
wipwholestatus WHERE id = '$id'
AND status = '1'
";
$receivabledata = mysqli_query($link, $db_query);
return mysqli_fetch_array($receivabledata, MYSQLI_ASSOC);
}
function getWipwholestatusData($link, $id)
{
$db_query = "
@ -76,7 +93,7 @@ function getEditFlag($department_id, $role_id, $user_id)
if ($department_id == "321")
return 8;
// 鍾哥(生管) 部門代碼:250 職位大小:1 4
if ($department_id == "250" && in_array($role_id, ["1", "4"]))
if ($department_id == "250")
return 8;
// 許協理 部門代碼:320 職位大小:1
if ($department_id == "320" && $role_id == "1")
@ -130,6 +147,10 @@ function getDataSql($department_id, $role_id, $user_id)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
$sql_cmd = sql_myself($user_id, "salesid");
$sql = "
@ -180,7 +201,7 @@ function getDataSql($department_id, $role_id, $user_id)
";
return $sql;
}
if ($department_id == '314' && (in_array($role_id, ['2']))) {
if ($department_id == '314' && (in_array($role_id, ['1', '2']))) {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
@ -298,7 +319,10 @@ function getDataSqlByFlowCode($department_id, $role_id, $user_id, $flow_code)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
$flow_code_tmp = explode(',', $flow_code);
$flow_code = implode("','", $flow_code_tmp);
@ -549,7 +573,7 @@ function getYDForm_key($link, $form_id)
ON f.form_key = s.form_key
WHERE 1=1
AND f.form_id = '$form_id'
AND f.flow_code IN ('A','B','C','D')
AND f.flow_code IN ('A','B','C','D','I')
AND f.system_id = 'wws'
AND f.flow_id = 'wws01'
";
@ -748,11 +772,12 @@ function getGongWuokNo($link)
// 取得生管部主管編號
function getShengGuanokLeaderNo($link)
{
return "M0079";
$sql = "
SELECT accountid
FROM `account`
WHERE `department_id` = '321'
AND `role_id` = '1';
WHERE `department_id` = '250'
AND `role_id` = '4';
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
@ -770,7 +795,7 @@ function checkNowFormYDStatus($link)
flow_code
FROM flow
WHERE form_id = '$id'
AND flow_code IN ('A','B','C','D')
AND flow_code IN ('A','B','C','D','I')
AND system_id = 'wws'
AND flow_id = 'wws01'
";
@ -820,7 +845,8 @@ 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])) {
if(getSaveEstimateInstallData($user_department_id, $role_id)){
if ($status == 1) {
return checkNowFormGStatus($link) == 'G' ? "" : "disabled";
} else {
@ -884,7 +910,7 @@ function getForm_key($link, $form_id)
ON f.form_key = s.form_key
WHERE 1=1
AND f.form_id = '$form_id'
AND f.flow_code IN ('A','B','C','D','E')
AND f.flow_code IN ('A','B','C','D','E','I')
AND f.system_id = 'wws'
AND f.flow_id = 'wws01'
";
@ -944,11 +970,11 @@ function getTabNo($user_department_id)
if ($user_department_id == 220)
return 0;
if ($user_department_id == 311 || $user_department_id == 312 || $user_department_id == 313 || $user_department_id == 314 || $user_department_id == 315)
return 0;
if ($user_department_id == 911)
return 1;
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545]))
if ($user_department_id == 911)
return 2;
if (in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545]))
return 0;
if ($user_department_id == 321 || $user_department_id == 250)
return 3;
if ($user_department_id == 912)
@ -1124,7 +1150,7 @@ function getSaveEstimateInstallData($user_department_id, $role_id)
return true;
if ($user_department_id == '521' && in_array($role_id, ['11', '9', '12']))
return true;
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6']))
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6', '8']))
return true;
if ($user_department_id == '544' && in_array($role_id, ['3', '6']))
return true;
@ -1141,11 +1167,11 @@ function saveInstallData($user_department_id, $role_id)
return true;
if ($user_department_id == '521' && $role_id == '9')
return true;
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6']))
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6', '8']))
return true;
if ($user_department_id == '543' && $role_id == '2')
return true;
if ($user_department_id == '544' && in_array($role_id, ['3', '6']))
if ($user_department_id == '544' && in_array($role_id, ['3', '4', '6']))
return true;
if ($user_department_id == '545' && in_array($role_id, ['3', '6']))
return true;
@ -1176,9 +1202,9 @@ function getAllCustomerPlanningVerify($link, $id)
{
$sql = "
SELECT
custom AS custom_name,
real_custom_name AS custom_name,
customer_planning_verify_file,
create_at
date_format(customer_planning_verify_at, '%Y-%m-%d %H:%i:%s') AS create_at
FROM wipwholestatus
WHERE id = $id
AND customer_planning_verify_file != ''

15
wms/wipwhole-index-table-html.php

@ -1,13 +1,4 @@
<?php
$tableArr = array(
"All" => "table_index2",
"A" => "table_index3",
"B" => "table_index4",
"G" => "table_index5",
"CH" => "table_index6",
"Z" => "table_index7"
);
// 暫時可編輯及刪除權限
$update_delete_status = false;
if (in_array($user_id, ['M0175', 'M0079'])) {
@ -15,7 +6,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
}
?>
<table id="<?php echo $tableArr[$key]; ?>" class="table table-striped table-bordered " style="width:100%;table-layout:fixed;">
<table id="table_index2" class="table table-striped table-bordered " style="width:100%;table-layout:fixed;">
<thead>
<tr>
<?php
@ -42,7 +33,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
foreach ($data as $key => $data) :
//規格
$Specification = $data['facility_kind'];
@ -139,7 +130,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $Specification; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo empty($data['real_address']) ? $data['address'] : $data['real_address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {

230
wms/wipwhole-index.php

@ -1,3 +1,9 @@
<div id="loadingOverlay" class="hidden">
<div class="loading-icon"></div>
</div>
<script>
document.getElementById('loadingOverlay').classList.remove('hidden');
</script>
<?php
// ini_set('display_errors', 'on');
/**
@ -26,16 +32,14 @@ include "wipwhole-index-function.php";
include "css/view/wipwhole-index.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'del_form') {
$del_seq = $_POST['del_seq'];
$form_name = empty($_REQUEST['form_name']) ? null : $_REQUEST['form_name'];
$del_seq = empty($_REQUEST['del_seq']) ? null : $_REQUEST['del_seq'];
if ($form_name == 'del_form') {
$sql = "UPDATE wipwholestatus SET status = '0' WHERE id = '$del_seq' ";
mysqli_query($link, $sql);
}
}
// 宣告主資料空陣列
$data = array();
// 取得當前使用者所屬部門
$department_id = getDepartmentId($link, $user_id);
// 取得當前使用者所屬職位
@ -55,30 +59,27 @@ $site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ?
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : $_REQUEST['real_contract_arrival_date_start'];
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : $_REQUEST['real_contract_arrival_date_end'];
$area_no = !isset($_REQUEST['area_no']) ? '' : $_REQUEST['area_no'];
$sheetNum = empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum'];
$tableArr = array(
"All" => "",
"A" => "A",
"B" => "B",
"G" => "G",
"CH" => "C,H",
"Z" => "Z"
);
if (empty($sheetNum) || $sheetNum == "All") {
$sql = getDataSql($department_id, $role_id, $user_id);
} else {
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, $tableArr[$sheetNum]);
}
// 取得資料 sql
$sql = getDataSql($department_id, $role_id, $user_id);
$data = mysqli_query($link, $sql);
// 取得資料(營業部門階段) sql
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, "A");
$dataA = mysqli_query($link, $sql);
// 取得資料(設計部門階段) sql
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, "B");
$dataB = mysqli_query($link, $sql);
// 取得資料(工勘部門階段) sql
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, "G");
$dataG = mysqli_query($link, $sql);
// 取得資料(生管階段) sql
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, "C,H");
$dataCH = mysqli_query($link, $sql);
// 取得資料(結案階段) sql
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, "Z");
$dataZ = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
@ -202,45 +203,110 @@ $dataZ = mysqli_query($link, $sql);
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showGTable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showCHTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
<div class="row">
<div class="col-md-9 col-12">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showGTable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showCHTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
<div class="col-md-3 col-12 text-right" id="myBtn">
<button class="btn btn-primary " type="button">欄位維護權限</button>
</div>
</div>
</div>
</nav>
<div id="myModal" class="modal">
<div class="back"></div>
<div class="modal-content">
<button type="button" class="close" id="myCloseBtn">X</button>
<div class='col-12' style='text-align:center'>
<h3>欄位維護權限</h3>
<hr>
<div class='row'>
<div class='col-12'>
<table class="table table-bordered" style="width:50%; margin:0 auto;">
<tr>
<th style="text-align:right;">欄位</th>
<th style="text-align:left;">維護單位</th>
</tr>
<tr>
<td style="text-align:right;">合約號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">電梯編號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">客戶姓名</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">規格</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">地址</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">工勘狀態</td>
<td style="text-align:left;">工勘人員</td>
</tr>
<tr>
<td style="text-align:right;">合約交期(到工地)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">下單日(普來特富)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">預計到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">實際到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">預計出貨日(到工地)</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">實際出貨日(到工地)</td>
<td style="text-align:left;">生管部門</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
$dataArr = array(
"All" => $data,
"A" => $dataA,
"B" => $dataB,
"G" => $dataG,
"CH" => $dataCH,
"Z" => $dataZ
);
foreach ($dataArr as $key => $val) {
if ($val) :
$dataDetailsArr = $val;
echo "<div id='data_" . $key . "_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-index-table-html.php";
echo "</div>";
endif;
}
echo "<div id='data_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-index-table-html.php";
echo "</div>";
// 結束連線
@ -263,15 +329,15 @@ mysqli_close($link);
}
</style>
<script>
var sheetNum = "<?php echo empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum']; ?>";
var sheetNum = "<?php echo $sheetNum; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
$(".data_table_div").hide();
showTable(sheetNum);
document.getElementById('loadingOverlay').classList.add('hidden');
})
const formData = new FormData();
@ -376,17 +442,15 @@ mysqli_close($link);
"CH": "5",
"Z": "6",
}
$("body > nav.navbar.navbar-tabs > div > ul > li").attr("class", "");
$("body > nav.navbar.navbar-tabs > div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
$(".data_table_div").hide();
$("#data_" + code + "_table_div").show();
$("nav.navbar.navbar-tabs div > ul > li").attr("class", "");
$("nav.navbar.navbar-tabs div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
}
function estimatedShippingDateReportButton() {
window.location.href = '<?php echo "/wms/estimated_shipping_date_report.php?$token_link" ?>';
}
$('#table_index2,#table_index3,#table_index4,#table_index5,#table_index6,#table_index7').DataTable({
$('#table_index2').DataTable({
scrollX: true,
fixedHeader: true,
scrollY: 500,
@ -421,11 +485,6 @@ mysqli_close($link);
);
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index3_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index4_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index5_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index6_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index7_filter > label > input").placeholder = "快速搜尋";
// datatable 畫面重整後保留資料
@ -443,16 +502,7 @@ mysqli_close($link);
var orderColumn = "<?php echo empty($_GET['orderColumn']) ? '' : $_GET['orderColumn']; ?>";
var orderDirection = "<?php echo empty($_GET['orderDirection']) ? '' : $_GET['orderDirection']; ?>";
var dataArr2 = {
"All": "table_index2",
"A": "table_index3",
"B": "table_index4",
"G": "table_index5",
"CH": "table_index6",
"Z": "table_index7",
}
var table = $('#' + dataArr2[sheetNum]).DataTable();
var table = $('#table_index2').DataTable();
// 设置排序信息
if (orderColumn !== '' && orderDirection !== '') {
@ -481,7 +531,7 @@ mysqli_close($link);
});
// 監聽搜尋事件
$("#" + dataArr2[sheetNum] + "_filter > label > input").change(function() {
$("#table_index2_filter > label > input").change(function() {
searchDatatable(table);
});
@ -503,6 +553,22 @@ mysqli_close($link);
$("#del_form").submit();
}
</script>
<script>
var modal = document.getElementById("myModal");
$("#myBtn").click(function() {
$("#myModal").show();
});
$("#myCloseBtn").click(function(e) {
console.log(e.target);
$("#myModal").hide();
// modal.style.display = "none"
});
$(".back").click(function(e) {
$("#myModal").hide();
// modal.style.display = "none"
});
</script>
<form id='del_form' method='post'>
<input type='hidden' id='del_seq' name='del_seq' value='' />
<input type='hidden' id='form_name' name='form_name' value='del_form' />

2
wms/wipwhole-rec-invoice-edit-fileupload.php

@ -67,3 +67,5 @@ $completion_acceptance_file = fileIUpload("completion_acceptance_file");
$shengguanok_status_file = fileIUpload("shengguanok_status_file");
// 工務助理
$outsourcer_contract_file = fileIUploads("outsourcer_contract_file");
// 品證
$official_check_file = fileIUpload("official_check_file");

365
wms/wipwhole-rec-invoice-edit-submit.php

@ -1,5 +1,5 @@
<?php
// ini_set('display_errors', 'on');
ini_set('display_errors', 'on');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'main_form') {
@ -52,6 +52,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$sales_spec_verify_at = $_POST['sales_spec_verify_at'] ?: $row['sales_spec_verify_at'];
$sales_spec_verify_owner = $_POST['sales_spec_verify_owner'] ?: $row['sales_spec_verify_owner'];
//客户计划图确认
$real_custom_name = $_POST['real_custom_name'] ?: $row['real_custom_name'];
$customer_planning_verify = $_POST['customer_planning_verify'];
$customer_planning_verify_at = $_POST['customer_planning_verify_at'] ?: $row['customer_planning_verify_at'];
$customer_planning_verify_owner = $_POST['customer_planning_verify_owner'] ?: $row['customer_planning_verify_owner'];
@ -152,6 +153,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$official_check_date_owner = $_POST['official_check_date_owner'] ?: $row['official_check_date_owner'];
$delivery_date = $_POST['delivery_date'] ?: $row['delivery_date'];
$delivery_date_owner = $_POST['delivery_date_owner'] ?: $row['delivery_date_owner'];
$qc_official_type = $_POST['qc_official_type'] ?: $row['qc_official_type'];
// 工務助理
$outsourcer_type = $_POST['outsourcer_type'];
@ -174,53 +176,54 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$warehouse_assistant_remark = $_POST['warehouse_assistant_remark'];
$creater = $_POST['creater'];
$create_at = $_POST['create_at'];
$create_at = date("Y-m-fd H:i:s");
// 上傳附件
include "wipwhole-rec-invoice-edit-fileupload.php";
// 工勘變更通知繪圖人員
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";
if (!empty($official_check_date)) {
if ($official_check_date !== $old_official_check_date) {
$sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'$title',
'$content',
null,
'$permission',
'$creater',
'" . date("Y-m-d H:i:s") . "'
);
";
mysqli_query($link, $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";
$sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'$title',
'$content',
null,
'$permission',
'$creater',
'" . date("Y-m-d H:i:s") . "'
);
";
mysqli_query($link, $sql);
}
}
}
// 工勘變更通知繪圖人員
if ($site_survey_contact_verify !== $old_site_survey_contact_verify) {
$site_survey_status = array(
@ -287,6 +290,30 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
}
if (!empty($desin_documents_verify_file)) {
echo $sql = "
INSERT INTO notice(
kind,
related_id,
title,
content,
haveread,
permission,
creater,
create_at
)VALUES(
'1',
'$id',
'合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件',
'合約號:$contract_no 作番號:$facilityno 設計上傳追加技術文件',
null,
'M0168',
'$creater',
'$create_at'
);
";
mysqli_query($link, $sql);
}
$updatesql = "
UPDATE wipwholestatus
@ -333,6 +360,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
delivery_date = '$delivery_date',
delivery_date_owner = '$delivery_date_owner',
marketing_remark = '',
real_custom_name = '$real_custom_name',
";
if (!empty(trim($marketing_remark))) {
$updatesql .= "
@ -475,6 +503,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
} else if ($user_department_id == 912) {
// 品證部
$updatesql .= "
qc_official_type = '$qc_official_type',
qc_date = '$qc_date',
qc_date_owner = '$qc_date_owner',
end_qc_date = '$end_qc_date',
@ -510,8 +539,54 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
// 工務助理
if (in_array($user_id, ['M0164', 'M0165', 'M0127', 'M0193', 'M0170', 'M0188','M0117'])) {
if (
in_array($user_id, ['M0164', 'M0165', 'M0127', 'M0193', 'M0170', 'M0188', 'M0117'])
|| in_array($user_department_id, [521, 531, 541, 542, 543, 544, 545])
|| $user_id == 'M0054'
) {
$qc_official_type = $_POST['qc_official_type2'] ?: $row['qc_official_type'];
$outsourcer_type = $_POST['outsourcer_type'];
$qc_date = $_POST['qc_date2'] ?: $row['qc_date'];
$qc_date_owner = $_POST['qc_date2_owner'] ?: $row['qc_date_owner'];
$end_qc_date = $_POST['end_qc_date2'] ?: $row['end_qc_date'];
$end_qc_date_owner = $_POST['end_qc_date2_owner'] ?: $row['end_qc_date_owner'];
$official_check_date = $_POST['official_check_date2'] ?: $row['official_check_date'];
$old_official_check_date = $_POST['old_official_check_date2'] ?: $row['old_official_check_date'];
$official_check_date_owner = $_POST['official_check_date2_owner'] ?: $row['official_check_date_owner'];
$delivery_date = $_POST['delivery_date2'] ?: $row['delivery_date'];
$delivery_date_owner = $_POST['delivery_date2_owner'] ?: $row['delivery_date_owner'];
$install_start_date = $_POST['install_start_date2'] ?: $row['install_start_date'];
$install_start_date_owner = $_POST['install_start_date2_owner'] ?: $row['install_start_date_owner'];
$install_end_date = $_POST['install_end_date2'] ?: $row['install_end_date'];
$install_end_date_owner = $_POST['install_end_date2_owner'] ?: $row['install_end_date_owner'];
$tryrun_start_date = $_POST['tryrun_start_date2'] ?: $row['tryrun_start_date'];
$tryrun_start_date_owner = $_POST['tryrun_start_date2_owner'] ?: $row['tryrun_start_date_owner'];
$tryrun_end_date = $_POST['tryrun_end_date2'] ?: $row['tryrun_end_date'];
$tryrun_end_date_owner = $_POST['tryrun_end_date2_owner'] ?: $row['tryrun_end_date_owner'];
$updatesql .= "
qc_official_type = '$qc_official_type',
install_start_date = '$install_start_date',
install_start_date_owner = '$install_start_date_owner',
install_end_date = '$install_end_date',
install_end_date_owner = '$install_end_date_owner',
tryrun_start_date = '$tryrun_start_date',
tryrun_start_date_owner = '$tryrun_start_date_owner',
tryrun_end_date = '$tryrun_end_date',
tryrun_end_date_owner = '$tryrun_end_date_owner',
delivery_date = '$delivery_date',
delivery_date_owner = '$delivery_date_owner',
qc_date = '$qc_date',
qc_date_owner = '$qc_date_owner',
end_qc_date = '$end_qc_date',
end_qc_date_owner = '$end_qc_date_owner',
official_check_date = '$official_check_date',
official_check_date_owner = '$official_check_date_owner',
outsourcer_type = '$outsourcer_type',
install_outsourcer = '$install_outsourcer',
install_outsourcer_owner = '$install_outsourcer_owner',
@ -605,8 +680,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
// 檢查簽核狀態
if (checkWwsAssianStatus($link, $user_id)) {
$id = empty($_POST['id']) ? null : $_POST['id'];
// // 檢查簽核狀態
if (checkWwsAssianStatus($link, $user_id, $id)) {
echo "<script type ='text/JavaScript'>";
echo "alert('此表單已進入下個階段');";
echo "location.href='wipwhole-rec-invoice-edit.php?function_name=pricereview&id=$id&" . $token_link . "';";
@ -919,8 +995,43 @@ function write_note($link, $id, $user_id, $content)
mysqli_query($link, $updatesql);
}
// function getWipwholestatusDetail($link, $id)
// {
// $sql = "
// SELECT *
// FROM wipwholestatus
// WHERE 1=1
// AND id = '$id'
// AND status = '1'
// ";
// $result = mysqli_query($link, $sql);
// $row = mysqli_fetch_assoc($result);
// return $row;
// }
// 各區營銷(契約)經理判斷程式
function checkUseridIsManager($user_id)
{
// 北區 劉永德
if (in_array($user_id, ['M0137']))
return true;
// 中區 李烘銘
if (in_array($user_id, ['M0086']))
return true;
// 桃竹 張莉凱
if (in_array($user_id, ['M0026']))
return true;
// 宜花東 陳志文
if (in_array($user_id, ['M0054']))
return true;
// 南區 吳育宗
if (in_array($user_id, ['M0033']))
return true;
return false;
}
// 表單簽核狀態檢查主程式
function checkWwsAssianStatus($link, $user_id)
function checkWwsAssianStatus($link, $user_id, $id = null)
{
if (isset($_GET['id']) || isset($_GET['form_key'])) {
@ -929,33 +1040,144 @@ function checkWwsAssianStatus($link, $user_id)
$form_G_key = isset($_GET['form_key']) ? $_GET['form_key'] : getGForm_key($link, $id);
}
// 確認營業階段 進入設計人員(新梯:郭承瑋 M0023)階段
include "./class/Cmail.php";
$cmail = new Cmail();
$data = getWipwholestatusDetail($link, $id);
$data['salesname'] = accountid2name($data['salesid'])[$data['salesid']];
$data['salesmail'] = accountid2email([$data['salesid']])[$data['salesid']];
$data['salesmanagername'] = accountid2name(manage_class($data['salesid'])[0])[manage_class($data['salesid'])[0]];
$data['salesmanagermail'] = accountid2email([manage_class($data['salesid'])[0]])[manage_class($data['salesid'])[0]];
$data['designname'] = accountid2name("M0023")["M0023"];
$data['designmail'] = accountid2email(["M0023"])["M0023"];
$data['designleadername'] = accountid2name(getSheJiokLeaderNo($link))[getSheJiokLeaderNo($link)];
$data['designleadermail'] = accountid2email([getSheJiokLeaderNo($link)])[getSheJiokLeaderNo($link)];
$data['gongwokname'] = accountid2name(getGongWuokNo($link))[getGongWuokNo($link)];
$data['gongwokmail'] = accountid2email([getGongWuokNo($link)])[getGongWuokNo($link)];
$data['shengguanname'] = accountid2name(getShengGuanokLeaderNo($link))[getShengGuanokLeaderNo($link)];
$data['shengguanmail'] = accountid2email([getShengGuanokLeaderNo($link)])[getShengGuanokLeaderNo($link)];
// 確認營業階段
// 非主管進入主管階段
// 主管進入設計人員(新梯:郭承瑋 M0023)階段
if (checkNowFormYDStatus($link) == 'A' && checkYingYeok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>營業提交至設計階段</em>");
do_wws_next_assign("M0023", $form_YD_key, 'B');
return true;
if (checkUseridIsManager($user_id)) {
write_note($link, $id, $user_id, "<em>營業經理提交至設計階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['designname'], $data['designmail']]
],
"永佳捷科技"
);
do_wws_next_assign("M0023", $form_YD_key, 'B');
return true;
} else {
write_note($link, $id, $user_id, "<em>營業提交至營業經理階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至營業經理階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業提交至營業經理階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['salesmanagername'], $data['salesmanagermail']]
],
"永佳捷科技"
);
do_wws_next_assign(manage_class($data['salesid'])[0], $form_YD_key, 'I');
return true;
}
}
// 確認營業主管階段 進入設計人員(新梯:郭承瑋 M0023)階段
if (checkNowFormYDStatus($link) == 'I' && checkYingYeok($link, $id) == '0') {
if (checkUseridIsManager($user_id)) {
write_note($link, $id, $user_id, "<em>營業經理提交至設計階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-營業經理提交至設計階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
[$data['designname'], $data['designmail']]
],
"永佳捷科技"
);
do_wws_next_assign("M0023", $form_YD_key, 'B');
return true;
}
}
// 確認設計人員(新梯:郭承瑋 M0023)階段 進入設計主管階段
if (checkNowFormYDStatus($link) == 'B' && checkSheJiok($link, $id) == '0') {
if (in_array(checkNowFormYDStatus($link), ['B', 'I']) && checkSheJiok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>設計提交至設計主管階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-設計提交至設計主管階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-設計提交至設計主管階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['designleadername'], $data['designleadermail']],
[$data['designname'], $data['designmail']]
],
"永佳捷科技"
);
do_wws_next_assign(getSheJiokLeaderNo($link), $form_YD_key, 'C');
return true;
}
// 確認設計主管階段 進入生管階段
if (checkNowFormYDStatus($link) == 'C' && checkSheJiokLeader($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>設計主管提交至生管階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-設計主管提交至生管階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-設計主管提交至生管階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['designleadername'], $data['designleadermail']],
[$data['shengguanname'], $data['shengguanmail']]
],
"永佳捷科技"
);
do_wws_next_assign(getShengGuanokLeaderNo($link), $form_YD_key, 'D');
return true;
}
// 確認工務階段 進入生管階段
if (checkNowFormGStatus($link) == 'G' && checkGongWuok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>工務提交至生管階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-工務提交至生管階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-工務提交至生管階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['gongwuname'], $data['gongwumail']],
[$data['shengguanname'], $data['shengguanmail']]
],
"永佳捷科技"
);
do_wws_next_assign(getShengGuanokLeaderNo($link), $form_G_key, 'H');
return true;
}
// 確認生管階段(營業部及設計部) 結束簽核流程
if (checkNowFormYDStatus($link) == 'D' && checkNowFormGStatus($link) == 'H' && checkShengGuanok($link, $id) == '0') {
write_note($link, $id, $user_id, "<em>進入結案階段</em>");
write_note($link, $id, $user_id, "<em>進入生產結案階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-進入生產結案階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-進入生產結案階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['shengguanname'], $data['shengguanmail']]
],
"永佳捷科技"
);
do_wws_next_assign('00000', $form_YD_key, 'Z');
do_wws_next_assign('00000', $form_G_key, 'Z');
return true;
@ -970,7 +1192,22 @@ function backMarketingSssign($link, $salesid, $user_id)
if (isset($_GET['id']) || isset($_GET['form_key'])) {
$id = isset($_GET['id']) ? $_GET['id'] : getId($link, $_GET['form_key']);
$form_YD_key = isset($_GET['form_key']) ? $_GET['form_key'] : getYDForm_key($link, $id);
include "./class/Cmail.php";
$cmail = new Cmail();
$data = getWipwholestatusDetail($link, $id);
$data['salesname'] = accountid2name($data['salesid'])[$data['salesid']];
$data['salesmail'] = accountid2email([$data['salesid']])[$data['salesid']];
write_note($link, $id, $user_id, "<em>退回營業階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回營業階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回營業階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['salesname'], $data['salesmail']],
],
"永佳捷科技"
);
do_wws_next_assign($salesid, $form_YD_key, 'A');
}
}
@ -981,7 +1218,22 @@ function backDesignssign($link, $user_id)
$id = isset($_GET['id']) ? $_GET['id'] : getId($link, $_GET['form_key']);
$form_YD_key = isset($_GET['form_key']) ? $_GET['form_key'] : getYDForm_key($link, $id);
}
include "./class/Cmail.php";
$cmail = new Cmail();
$data = getWipwholestatusDetail($link, $id);
$data['designname'] = accountid2name("M0023")["M0023"];
$data['designmail'] = accountid2email(["M0023"])["M0023"];
write_note($link, $id, $user_id, "<em>退回設計階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回設計階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回設計階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['designname'], $data['designmail']],
],
"永佳捷科技"
);
do_wws_next_assign("M0023", $form_YD_key, 'B');
}
// 退回至工務階段
@ -991,6 +1243,21 @@ function backWarehouse($link, $user_id)
$id = isset($_GET['id']) ? $_GET['id'] : getId($link, $_GET['form_key']);
$form_YD_key = isset($_GET['form_key']) ? $_GET['form_key'] : getYDForm_key($link, $id);
}
include "./class/Cmail.php";
$cmail = new Cmail();
$data = getWipwholestatusDetail($link, $id);
$data['gongwokname'] = accountid2name(getGongWuokNo($link))[getGongWuokNo($link)];
$data['gongwokmail'] = accountid2email([getGongWuokNo($link)])[getGongWuokNo($link)];
write_note($link, $id, $user_id, "<em>退回工務階段</em>");
$mail_title = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回至工務階段";
$mail_content = "作番大日程(新梯)合約號:" . $data['contractno'] . "作番號:" . $data['facilityno'] . "-退回至工務階段";
$cmail->sendx(
$mail_title,
$mail_content,
[
[$data['gongwokname'], $data['gongwokmail']],
],
"永佳捷科技"
);
do_wws_next_assign(getGongWuokNo($link), $form_YD_key, 'G');
}

326
wms/wipwhole-rec-invoice-edit.php

@ -2,7 +2,8 @@
// ini_set('display_errors', 'on');
/**
* (新梯)流程規則:
* 1. A:營業員確認中 生管建立大日程 (或是系統洗入)
* 1. A:營業員確認中 業務建立大日程 (或是系統洗入)
* 6. I:營業主管確認中
* 2. B:設計部門確認中 (郭承瑋)
* 3. C:設計部門主管確認中 (N0019江京鴻)
* 4. D:生管確認中 (M0024伃廷)
@ -50,6 +51,7 @@ $shengguan2 = getShengguanStatus($link, $user_department_id, $role_id, 2);
$pinzheng = getPinzhengStatus($link, $user_department_id, $role_id);
// 取得分頁頁碼
$user_department_id;
$tab = getTabNo($user_department_id);
// 工務助理
@ -239,6 +241,7 @@ include "wipwhole-rec-invoice-edit-submit.php";
<?php
$assign_status_YD = array(
'A' => '營業員確認中',
'I' => '營業部門已確認<br/>營業部門主管確認中',
'B' => '營業部門已確認<br/>設計部門確認中',
'C' => '營業部門已確認<br/>設計部門主管確認中',
'D' => '營業部門已確認<br/>設計部門主管已確認',
@ -283,9 +286,9 @@ include "wipwhole-rec-invoice-edit-submit.php";
<div id="tabs">
<input class="form-control " type="hidden" name="tab" id='tab' value="<?= $tab; ?>">
<ul>
<li><a href="#tabs-3">工務確認項</a></li>
<li><a href="#tabs-1">營業確認項</a></li>
<li><a href="#tabs-2">設計確認項</a></li>
<li><a href="#tabs-3">工務確認項</a></li>
<li><a href="#tabs-4">生管確認項</a></li>
<li><a href="#tabs-5">品證確認項</a></li>
<li><a href="#tabs-6">工務助理確認項</a></li>
@ -293,6 +296,9 @@ include "wipwhole-rec-invoice-edit-submit.php";
<div id="tabs-1">
<table class="table table-bordered" style="width:100%">
<tbody style="font-weight: bolder;margin-bottom: 20px">
<tr>
<td>營業人員確認項</td>
</tr>
<tr>
<td style="vertical-align: middle;width:auto;">營業/契約確認規格</td>
<td style="width:150px;">
@ -328,31 +334,31 @@ include "wipwhole-rec-invoice-edit-submit.php";
<br />
(意匠圖)
<?php
$result2 = getWipwholeChangePlanningCustomerDetailsStatus($link, $id);
$row2 = mysqli_fetch_assoc($result2);
if (empty($row2['change_status'])) {
$show_tmp_arr = [
'311', '312', '313', '314', '315',
'501', '511', '512', '513', '514',
'220', '320'
];
if (in_array($user_department_id, $show_tmp_arr))
echo "<br/>";
echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>申請上傳</a>";
} else {
if (in_array($row2['change_status'], ['A', 'B', 'D'])) {
echo "<br/>";
echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:審核中</a>";
}
if ($row2['change_status'] == 'C') {
echo "<br/>";
echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:已取消</a>";
}
if ($row2['change_status'] == 'Z') {
echo "<br/>";
echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:審核通過</a>";
}
}
// $result2 = getWipwholeChangePlanningCustomerDetailsStatus($link, $id);
// $row2 = mysqli_fetch_assoc($result2);
// if (empty($row2['change_status'])) {
// $show_tmp_arr = [
// '311', '312', '313', '314', '315',
// '501', '511', '512', '513', '514',
// '220', '320'
// ];
// if (in_array($user_department_id, $show_tmp_arr))
// echo "<br/>";
// echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>申請上傳</a>";
// } else {
// if (in_array($row2['change_status'], ['A', 'B', 'D'])) {
// echo "<br/>";
// echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:審核中</a>";
// }
// if ($row2['change_status'] == 'C') {
// echo "<br/>";
// echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:已取消</a>";
// }
// if ($row2['change_status'] == 'Z') {
// echo "<br/>";
// echo "<a target='_blank' style='color:#00F;' href='wipwhole-change-planning-customer-name.php?function_name=wipwholerenstatus&$token_link&id=$id'>客戶姓名:" . $row2['custom_name'] . "<br/>狀態:審核通過</a>";
// }
// }
?>
</td>
<td>
@ -365,13 +371,9 @@ include "wipwhole-rec-invoice-edit-submit.php";
</td>
<td style="vertical-align: middle;">附件</td>
<td style="vertical-align: middle;">
<input style="width:70%;display:inline;" type="file" id="customer_planning_verify_file" name="customer_planning_verify_file" <?php
if (isset($row2['change_status'])) {
echo $row2['change_status'] === 'Z' ? "" : "disabled";
} else {
echo "disabled";
}
?>>
客戶姓名:<input type="text" name="real_custom_name" id="real_custom_name" style="width:70%;display:inline;" value="<?= $row["real_custom_name"]; ?>" <?= $marketing; ?> placeholder="輸入後即可上傳附件" />
<br />
<input style="width:70%;display:inline;" type="file" id="customer_planning_verify_file" name="customer_planning_verify_file" disabled>
<?php
// echo !empty($row['customer_planning_verify_file']) ? "<a id='customer_planning_verify_file_a' style='color:#00F;' href='" . $row['customer_planning_verify_file'] . "' target='_blank'>下載附件</a>" : "";
?>
@ -505,13 +507,25 @@ include "wipwhole-rec-invoice-edit-submit.php";
<input class="form-control " type="hidden" name="creater" value="<?= $user_id; ?>">
<input class="form-control " type="hidden" name="create_at" value="<?= $row["create_at"]; ?>">
<?php
if (checkNowFormYDStatus($link) == 'A' && ($user_department_id == 220 || $user_department_id == 311 || $user_department_id == 312 || $user_department_id == 313 || $user_department_id == 314 || $user_department_id == 315)) {
if (checkNowFormYDStatus($link) == 'A' && in_array($user_department_id, [220, 311, 312, 313, 314, 315])) {
?>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">提交至設計部門</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至<?php echo checkUseridIsManager($user_id) ? "設計部門" : "營業主管"; ?>
</button>
<?php
} else if (checkNowFormYDStatus($link) == 'I' && checkUseridIsManager($user_id)) {
?>
<button onclick="doBackMarketingAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">
退回營業
</button>
<button onclick="doMarketingAssign()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">
提交至設計部門
</button>
<?php
}
?>
<button onclick="savedata()" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;" <?= $marketing2; ?>>存檔</button>
<span class="text-danger pull-right">若無工勘資料請勿移交至設計階段!</span>
</td>
</tr>
</tbody>
@ -1144,15 +1158,18 @@ include "wipwhole-rec-invoice-edit-submit.php";
if (checkNowFormGStatus($link) == 'Z' && checkNowFormYDStatus($link) == 'Z' && ($user_department_id == 220 || $user_department_id == 321)) {
?>
<button class="btn btn-primary btn-lg pull-right" type="button" style="margin-left:3px;" disabled>日程已結案</button>
<?php
<?php
} else {
// 生管 小雯 預計到貨日(到觀音廠日)權限
if ($user_id == 'M0168') {
?>
<button onclick="savedata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">存檔</button>
// if ($user_id == 'M0168') {
?>
<!-- <button onclick="savedata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">存檔</button> -->
<?php
}
if (($user_department_id == 220 || ($user_department_id == 321 && $role_id !== '5') || $user_id == 'M0060')) {
// }
if (($user_department_id == 220 || ($user_department_id == 321 && $role_id !== '5') || $user_id == 'M0060' || $user_id == 'M0168')) {
?>
<button onclick="savedata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-left:3px;">存檔</button>
<?php
@ -1163,12 +1180,12 @@ include "wipwhole-rec-invoice-edit-submit.php";
}
}
}
if (checkNowFormGStatus($link) == 'H' && ($user_department_id == 220 || ($user_department_id == 321 && $role_id !== '5'))) {
if (checkNowFormGStatus($link) == 'H' && ($user_department_id == 220 || ($user_department_id == 321 && $role_id !== '5') || $user_id == 'M0168')) {
?>
<button onclick="doBackWarhouseAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">退回工務部門</button>
<?php
}
if (checkNowFormYDStatus($link) == 'D' && ($user_department_id == 220 || ($user_department_id == 321 && $ro !== '5'))) {
if (checkNowFormYDStatus($link) == 'D' && ($user_department_id == 220 || ($user_department_id == 321 && $role_id !== '5') || $user_id == 'M0168')) {
?>
<button onclick="doBackMarketingAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">退回營業</button>
<button onclick="doBackDesignAssign()" type="button" class="btn btn-danger btn-lg pull-right" style="margin-left:3px;">退回設計部門</button>
@ -1255,12 +1272,12 @@ include "wipwhole-rec-invoice-edit-submit.php";
<tr>
<td style="vertical-align: middle">QC及官檢類型</td>
<td>
<input type='radio' disabled <?php echo $row['qc_official_type'] == 'Q' ? "checked" : ""; ?> />
<label for='outsourcer_type_I'>只需QC</label>
<input type='radio' disabled <?php echo $row['qc_official_type'] == 'O' ? "checked" : ""; ?> />
<label for='outsourcer_type_T'>只需官檢</label>
<input type='radio' disabled <?php echo $row['qc_official_type'] == 'QO' ? "checked" : ""; ?> />
<label for='outsourcer_type_IT'>QC+官檢</label>
<input type='radio' id="qc_official_type_Q" name='qc_official_type' value='Q' <?= $pinzheng; ?> <?php echo $row['qc_official_type'] == 'Q' ? "checked" : ""; ?> />
<label for='qc_official_type_Q'>只需QC</label>
<input type='radio' id="qc_official_type_O" name='qc_official_type' value='O' <?= $pinzheng; ?> <?php echo $row['qc_official_type'] == 'O' ? "checked" : ""; ?> />
<label for='qc_official_type_O'>只需官檢</label>
<input type='radio' id="qc_official_type_QO" name='qc_official_type' value='QO' <?= $pinzheng; ?> <?php echo $row['qc_official_type'] == 'QO' ? "checked" : ""; ?> />
<label for='qc_official_type_QO'>QC+官檢</label>
</td>
</tr>
<tr>
@ -1349,6 +1366,96 @@ include "wipwhole-rec-invoice-edit-submit.php";
(工務助理項目)
</td>
</tr>
<?php
if ($user_id == 'M0193') {
?>
<tr>
<td style="vertical-align: middle">QC及官檢類型</td>
<td>
<input type='radio' id="qc_official_type_Q2" name='qc_official_type2' value='Q' <?= $warehouse2; ?> <?php echo $row['qc_official_type'] == 'Q' ? "checked" : ""; ?> />
<label for='qc_official_type_Q2'>只需QC</label>
<input type='radio' id="qc_official_type_O2" name='qc_official_type2' value='O' <?= $warehouse2; ?> <?php echo $row['qc_official_type'] == 'O' ? "checked" : ""; ?> />
<label for='qc_official_type_O2'>只需官檢</label>
<input type='radio' id="qc_official_type_QO2" name='qc_official_type2' value='QO' <?= $warehouse2; ?> <?php echo $row['qc_official_type'] == 'QO' ? "checked" : ""; ?> />
<label for='qc_official_type_QO2'>QC+官檢</label>
</td>
</tr>
<tr>
<td style="vertical-align: middle">內部QC日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" id="qc_date2" name="qc_date2" value="<?= $row['qc_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#qc_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" id="qc_date2_owner" name="qc_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['qc_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">QC合格日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" id="end_qc_date2" name="end_qc_date2" value="<?= $row['end_qc_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#end_qc_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" id="end_qc_date2_owner" name="end_qc_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['end_qc_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">官檢日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" id="official_check_date2" name="official_check_date2" value="<?= $row['official_check_date']; ?>" <?= $warehouse2; ?>>
<input type="hidden" id="old_official_check_date2" name="old_official_check_date2" value="<?= $row['official_check_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#official_check_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" id="official_check_date2_owner" name="official_check_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['official_check_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">移交日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control disabled_select" type="date" id="delivery_date2" name="delivery_date2" value="<?= $row['delivery_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#delivery_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" id="delivery_date2_owner" name="delivery_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['delivery_date_owner']); ?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td style="vertical-align: middle">發包類型</td>
<td>
@ -1522,6 +1629,84 @@ include "wipwhole-rec-invoice-edit-submit.php";
</select>
</td>
</tr>
<?php
if ($user_id == 'M0193') {
?>
<tr>
<td style="vertical-align: middle">實際安裝開工日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" name="install_start_date2" id="install_start_date2" value="<?= $row['install_start_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#install_start_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" name="install_start_date2_owner" id="install_start_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['install_start_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">實際安裝完工日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" name="install_end_date2" id="install_end_date2" value="<?= $row['install_end_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#install_end_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" name="install_end_date2_owner" id="install_end_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['install_end_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">實際試車開工日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" name="tryrun_start_date2" id="tryrun_start_date2" value="<?= $row['tryrun_start_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#tryrun_start_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" name="tryrun_start_date2_owner" id="tryrun_start_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['tryrun_start_date_owner']); ?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle">實際試車完工日</td>
<td style="vertical-align: middle">
<div class="input-group">
<input class="form-control" type="date" name="tryrun_end_date2" id="tryrun_end_date2" value="<?= $row['tryrun_end_date']; ?>" <?= $warehouse2; ?>>
<span class="input-group-btn">
<button class="btn btn-default" type='button' onclick='$("#tryrun_end_date2").val("");' <?= $warehouse2; ?>>清除</button>
</span>
</div>
</td>
<td style="vertical-align: middle">確認人</td>
<td>
<select class="disabled_select" name="tryrun_end_date2_owner" id="tryrun_end_date2_owner" disabled>
<option value="">請選擇</option>
<?php echo getSelectOptionHtml($all_users_options, $row['tryrun_end_date_owner']); ?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td>備註</td>
<td colspan="3">
@ -1560,16 +1745,20 @@ include "wipwhole-rec-invoice-edit-submit.php";
</form>
<form method="post" id="assign_form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="assign_form" />
<input type="hidden" name='id' value="<?php echo $id; ?>" />
</form>
<form method="post" id="back_marketing_assign_form" enctype="multipart/form-data">
<input type="hidden" name='salesid' value="<?php echo $row['salesid']; ?>" />
<input type="hidden" name='form_name' value="back_marketing_assign_form" />
<input type="hidden" name='id' value="<?php echo $id; ?>" />
</form>
<form method="post" id="back_design_assign_form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="back_design_assign_form" />
<input type="hidden" name='id' value="<?php echo $id; ?>" />
</form>
<form method="post" id="warehouse_assign_form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="warehouse_assign_form" />
<input type="hidden" name='id' value="<?php echo $id; ?>" />
</form>
<form method="post" id="update_contract_date_form" enctype="multipart/form-data">
<input type="hidden" name="contract_type" value="<?= $row["contract_type"]; ?>">
@ -1628,7 +1817,34 @@ include "wipwhole-rec-invoice-edit-submit.php";
var taiwan_item_id = <?php echo empty($taiwan_item_id) ? 0 : $taiwan_item_id; ?>;
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
checkCustomerPlanningVerifyFileKeyinStatus();
checkDeliveryDateKeyinStatus();
});
function checkCustomerPlanningVerifyFileKeyinStatus() {
checkCustomerPlanningVerifyFileDisabled();
$("#real_custom_name").keyup(function() {
checkCustomerPlanningVerifyFileDisabled();
});
}
function checkCustomerPlanningVerifyFileDisabled() {
if ($("#real_custom_name").val() !== "") {
$("#customer_planning_verify_file").prop("disabled", false);
} else {
$("#customer_planning_verify_file").prop("disabled", true);
}
}
function checkDeliveryDateKeyinStatus() {
$("#delivery_date").prop("disabled", true);
if ($("#end_qc_date").val() !== "") {
$("#delivery_date").prop("disabled", false);
}
if ($("#official_check_date").val() !== "") {
$("#delivery_date").prop("disabled", false);
}
}
$(function() {
$("title").text("合約號:<?php echo $row["contractno"]; ?>作番號:<?php echo $row["facilityno"]; ?>");
var tab = $('#tab').val();
@ -1653,7 +1869,15 @@ include "wipwhole-rec-invoice-edit-submit.php";
'qc_date',
'end_qc_date',
'official_check_date',
'delivery_date'
'qc_date2',
'end_qc_date2',
'official_check_date2',
'delivery_date',
'delivery_date2',
'install_start_date2',
'install_end_date2',
'tryrun_start_date2',
'tryrun_end_date2',
]
for (var i = 0; i < catchTime_input_arr.length; i++) {
inputChangeCatchTime(catchTime_input_arr[i]);

1
wms/wipwhole-rec-invoice.php

@ -39,6 +39,7 @@ if ($department_id == "321" || $department_id == "220") {
COUNT(*)
FROM wipwholestatus
WHERE facilityno = '$facilityno'
AND status = '1'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);

49
wms/wipwhole-renovate-index-function.php

@ -1,5 +1,21 @@
<?php
/**
* 取得生管主管 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);
}
// 取得本次簽核的表單id值
function getId($link, $form_key)
{
@ -26,7 +42,7 @@ function getForm_key($link, $form_id)
ON f.form_key = s.form_key
WHERE 1=1
AND f.form_id = '$form_id'
AND f.flow_code IN ('A','B','C','D','E')
AND f.flow_code IN ('A','B','C','D','E','F')
AND f.system_id = 'wws'
AND f.flow_id = 'wws02'
";
@ -228,11 +244,12 @@ function getGongWuokNo($link)
// 取得生管部主管編號
function getShengGuanokLeaderNo($link)
{
return "M0079";
$sql = "
SELECT accountid
FROM `account`
WHERE `department_id` = '321'
AND `role_id` = '1';
WHERE `department_id` = '250'
AND `role_id` = '4';
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
@ -334,7 +351,7 @@ function getEditFlag($department_id, $role_id, $user_id)
if ($department_id == "321")
return 8;
if ($department_id == "250" && in_array($role_id, ["1", "4"]))
if ($department_id == "250")
return 8;
if ($department_id == "320" && $role_id == "1")
return 8;
@ -370,6 +387,10 @@ function getDataSql($department_id, $role_id, $user_id)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
$contract_type = 'B';
// 營業員主管或營業員
@ -427,7 +448,7 @@ function getDataSql($department_id, $role_id, $user_id)
";
return $sql;
}
if ($department_id == '314' && (in_array($role_id, ['2']))) {
if ($department_id == '314' && (in_array($role_id, ['1', '2']))) {
$sql = "
SELECT * FROM wipwholestatus
WHERE 1=1
@ -545,6 +566,10 @@ function getDataSqlByflowCode($department_id, $role_id, $user_id, $flow_code)
if (in_array($user_id, ['M0166', 'M0091'])) {
$user_id = 'M0086';
}
// 補丁 孫仲凱 = 林瑋隆
if (in_array($user_id, ['M0159'])) {
$user_id = 'M0113';
}
$contract_type = 'B';
// 營業員主管或營業員
@ -809,7 +834,8 @@ function getWarehouseStatus($link, $user_department_id, $role_id, $status)
{
if ($user_department_id == 220)
return "";
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])) {
if(getSaveEstimateInstallData($user_department_id, $role_id)){
if ($status == 1) {
return checkNowFormStatus($link) == 'A' ? "" : "disabled";
} else {
@ -818,6 +844,7 @@ function getWarehouseStatus($link, $user_department_id, $role_id, $status)
}
return "disabled";
}
function getMarketingStatus($link, $user_department_id, $role_id, $status)
{
if ($user_department_id == 220)
@ -1055,7 +1082,7 @@ function getSaveEstimateInstallData($user_department_id, $role_id)
return true;
if ($user_department_id == '521' && in_array($role_id, ['11', '9', '12']))
return true;
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6']))
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6', '8']))
return true;
if ($user_department_id == '544' && in_array($role_id, ['3', '6']))
return true;
@ -1072,11 +1099,11 @@ function getSaveInstallDataButtonStatus($user_department_id, $role_id)
return true;
if ($user_department_id == '521' && $role_id == '9')
return true;
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6']))
if ($user_department_id == '542' && in_array($role_id, ['1', '5', '6', '8']))
return true;
if ($user_department_id == '543' && $role_id == '2')
return true;
if ($user_department_id == '544' && in_array($role_id, ['3', '6']))
if ($user_department_id == '544' && in_array($role_id, ['3', '4', '6']))
return true;
if ($user_department_id == '545' && in_array($role_id, ['3', '6']))
return true;
@ -1105,9 +1132,9 @@ function getAllCustomerPlanningVerify($link, $id)
{
$sql = "
SELECT
custom AS custom_name,
real_custom_name AS custom_name,
customer_planning_verify_file,
create_at
date_format(customer_planning_verify_at, '%Y-%m-%d %H:%i:%s') AS create_at
FROM wipwholestatus
WHERE id = $id
AND customer_planning_verify_file != ''

15
wms/wipwhole-renovate-index-table-html.php

@ -1,13 +1,4 @@
<?php
$tableArr = array(
"All" => "table_index2",
"A" => "table_index3",
"B" => "table_index4",
"C" => "table_index5",
"D" => "table_index6",
"Z" => "table_index7"
);
// 暫時可編輯及刪除權限
$update_delete_status = false;
if (in_array($user_id, ['M0175', 'M0079'])) {
@ -15,7 +6,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
}
?>
<table id="<?php echo $tableArr[$key]; ?>" class="table table-striped table-bordered dt-responsive nowrap" style="width:98.5%">
<table id="table_index2" class="table table-striped table-bordered dt-responsive nowrap" style="width:98.5%">
<thead>
<tr>
<?php
@ -42,7 +33,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
</thead>
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
foreach ($data as $key => $data) :
//規格
$Specification = $data['facility_kind'];
@ -146,7 +137,7 @@ if (in_array($user_id, ['M0175', 'M0079'])) {
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $Specification; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo empty($data['real_address']) ? $data['address'] : $data['real_address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {

220
wms/wipwhole-renovate-index.php

@ -1,3 +1,9 @@
<div id="loadingOverlay" class="hidden">
<div class="loading-icon"></div>
</div>
<script>
document.getElementById('loadingOverlay').classList.remove('hidden');
</script>
<?php
// ini_set('display_errors', 'on');
/**
@ -22,8 +28,9 @@ include "wipwhole-renovate-index-function.php";
include "css/view/wipwhole-renovate-index.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['form_name'] == 'del_form') {
$del_seq = $_POST['del_seq'];
$form_name = empty($_REQUEST['form_name']) ? null : $_REQUEST['form_name'];
$del_seq = empty($_REQUEST['del_seq']) ? null : $_REQUEST['del_seq'];
if ($form_name == 'del_form') {
$sql = "UPDATE wipwholestatus SET status = '0' WHERE id = '$del_seq' ";
mysqli_query($link, $sql);
}
@ -33,9 +40,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$numberOfDaysToAdd = 45;
$futureDate = date("Y/m/d", strtotime(date("Y-m-d") . " +{$numberOfDaysToAdd} days"));
// 主資料陣列
$data = array();
// 取得當前使用者所屬部門
$department_id = getDepartmentId($link, $user_id);
// 取得當前使用者所屬職位
@ -53,31 +57,25 @@ $site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ?
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : $_REQUEST['real_contract_arrival_date_start'];
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : $_REQUEST['real_contract_arrival_date_end'];
$area_no = !isset($_REQUEST['area_no']) ? '' : $_REQUEST['area_no'];
$sheetNum = empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum'];
$tableArr = array(
"All" => "",
"A" => "A",
"B" => "B",
"C" => "C",
"D" => "D",
"Z" => "Z"
);
if (empty($sheetNum) || $sheetNum == "All") {
$sql = getDataSql($department_id, $role_id, $user_id);
} else {
$sql = getDataSqlByFlowCode($department_id, $role_id, $user_id, $tableArr[$sheetNum]);
}
// 取得資料 sql
$sql = getDataSql($department_id, $role_id, $user_id);
$data = mysqli_query($link, $sql);
// 取得資料(工勘部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "A");
$dataA = mysqli_query($link, $sql);
// 取得資料(營業部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "B");
$dataB = mysqli_query($link, $sql);
// 取得資料(設計部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "C");
$dataC = mysqli_query($link, $sql);
// 取得資料(生管階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "D");
$dataD = mysqli_query($link, $sql);
// 取得資料(結案階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "Z");
$dataZ = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
@ -201,45 +199,107 @@ $dataZ = mysqli_query($link, $sql);
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showCTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showDTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
<div class="col-md-9 col-12">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showCTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showDTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
<div class="col-md-3 col-12 text-right" id="myBtn">
<button class="btn btn-primary " type="button">欄位維護權限</button>
</div>
</div>
</nav>
<div id="myModal" class="modal">
<div class="back"></div>
<div class="modal-content">
<button type="button" class="close" id="myCloseBtn">X</button>
<div class='col-12' style='text-align:center'>
<h3>欄位維護權限</h3>
<hr>
<div class='row'>
<div class='col-12'>
<table class="table table-bordered" style="width:50%; margin:0 auto;">
<tr>
<th style="text-align:right;">欄位</th>
<th style="text-align:left;">維護單位</th>
</tr>
<tr>
<td style="text-align:right;">合約號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">電梯編號</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">客戶姓名</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">規格</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">地址</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">工勘狀態</td>
<td style="text-align:left;">工勘人員</td>
</tr>
<tr>
<td style="text-align:right;">合約交期(到工地)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">下單日(普來特富)</td>
<td style="text-align:left;">業務部</td>
</tr>
<tr>
<td style="text-align:right;">預計到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">實際到廠日(觀音廠)</td>
<td style="text-align:left;">生管部門</td>
</tr>
<tr>
<td style="text-align:right;">預計出貨日(到工地)</td>
<td style="text-align:left;">業務部(營業人員 or 工勘人員透過申請單)</td>
</tr>
<tr>
<td style="text-align:right;">實際出貨日(到工地)</td>
<td style="text-align:left;">生管部門</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
$dataArr = array(
"All" => $data,
"A" => $dataA,
"B" => $dataB,
"C" => $dataC,
"D" => $dataD,
"Z" => $dataZ
);
foreach ($dataArr as $key => $val) {
if ($val) :
$dataDetailsArr = $val;
echo "<div id='data_" . $key . "_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
endif;
}
echo "<div id='data_detail_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
#結束連線
mysqli_close($link);
@ -261,14 +321,14 @@ mysqli_close($link);
}
</style>
<script>
var sheetNum = "<?php echo empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum']; ?>";
var sheetNum = "<?php echo $sheetNum; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
$(".data_table_div").hide();
showTable(sheetNum);
document.getElementById('loadingOverlay').classList.add('hidden');
})
const formData = new FormData();
@ -413,18 +473,11 @@ mysqli_close($link);
"D": "5",
"Z": "6",
}
$("body > nav.navbar.navbar-tabs > div > ul > li").attr("class", "");
$("body > nav.navbar.navbar-tabs > div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
$(".data_table_div").hide();
$("#data_" + code + "_table_div").show();
$("nav.navbar.navbar-tabs div > ul > li").attr("class", "");
$("nav.navbar.navbar-tabs div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
}
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index3_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index4_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index5_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index6_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index7_filter > label > input").placeholder = "快速搜尋";
// datatable 畫面重整後保留資料
@ -444,7 +497,7 @@ mysqli_close($link);
var orderDirection = "<?php echo empty($_GET['orderDirection']) ? '' : $_GET['orderDirection']; ?>";
var dataArr2 = {
"All": "table_index2",
"All": "",
"A": "table_index3",
"B": "table_index4",
"C": "table_index5",
@ -453,7 +506,7 @@ mysqli_close($link);
}
var table = $('#' + dataArr2[sheetNum]).DataTable();
var table = $('#table_index2').DataTable();
// 设置排序信息
if (orderColumn !== '' && orderDirection !== '') {
@ -482,7 +535,7 @@ mysqli_close($link);
});
// 監聽搜尋事件
$("#" + dataArr2[sheetNum] + "_filter > label > input").change(function() {
$("#table_index2_filter > label > input").change(function() {
searchDatatable(table);
});
@ -504,6 +557,21 @@ mysqli_close($link);
$("#del_form").submit();
}
</script>
<script>
var modal = document.getElementById("myModal");
$("#myBtn").click(function() {
$("#myModal").show();
});
$("#myCloseBtn").click(function(e) {
console.log(e.target);
$("#myModal").hide();
// modal.style.display = "none"
});
$(".back").click(function(e) {
$("#myModal").hide();
// modal.style.display = "none"
});
</script>
<form id='del_form' method='post'>
<input type='hidden' id='del_seq' name='del_seq' value='' />
<input type='hidden' id='form_name' name='form_name' value='del_form' />

1
wms/wipwhole-renovate-rec-invoice.php

@ -41,6 +41,7 @@ if ($department_id == "321" || $department_id == "220") {
COUNT(*)
FROM wipwholestatus
WHERE facilityno = '$facilityno'
AND status = '1'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);

32
wms/wipwholeinstall-index-table-html.php

@ -6,7 +6,8 @@
<th style="vertical-align: middle;text-align:center;width:250px;">合約地址</th>
<th style="vertical-align: middle;text-align:center;width:250px;">地工地址</th>
<th style="vertical-align: middle;text-align:center;width:140px;">警示</th>
<th style="vertical-align: middle;text-align:center;width:140px;">預計出貨日</th>
<th style="text-align:center;width:100px;">實際到廠日(觀音廠)</th>
<th style="text-align:center;width:100px;">預計出貨日(到工地)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">發包廠商(工勘)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">發包日期(工勘)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">預計開工日(工勘)</th>
@ -56,7 +57,18 @@
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['real_address']; ?></td>
<td style="text-align:left;"><span class="text-danger"><?php echo warningMessage($data); ?></span></td>
<td><?php echo substr($data['real_contract_arrival_date'], 0, 10); ?></td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<td>
<?php
if (!empty($data['real_contract_arrival_date']))
echo date("Y/m/d", strtotime(substr($data['real_contract_arrival_date'], 0, 10)));
?>
</td>
<?php
// foreach ($site_survey_status as $key => $val) {
// if ((string)$data['site_survey_contact_verify'] == (string)$key) {
@ -88,9 +100,9 @@
echo "<br/>" . date("Y/m/d", strtotime($data['tryrun_outsourcer_date']));
} else {
if (!empty($data['install_outsourcer_date']))
echo date("Y/m/d", strtotime($data['install_outsourcer_date'])). "<br/> ";
echo date("Y/m/d", strtotime($data['install_outsourcer_date'])) . "<br/> ";
if (!empty($data['tryrun_outsourcer_date']))
echo " <br/>" .date("Y/m/d", strtotime($data['tryrun_outsourcer_date']));
echo " <br/>" . date("Y/m/d", strtotime($data['tryrun_outsourcer_date']));
}
?>
</td>
@ -114,9 +126,9 @@
echo "<br/>" . date("Y/m/d", strtotime($data['tryrun_start_date']));
} else {
if (!empty($data['install_start_date']))
echo date("Y/m/d", strtotime($data['install_start_date'])). "<br/> ";
echo date("Y/m/d", strtotime($data['install_start_date'])) . "<br/> ";
if (!empty($data['tryrun_start_date']))
echo " <br/>" .date("Y/m/d", strtotime($data['tryrun_start_date']));
echo " <br/>" . date("Y/m/d", strtotime($data['tryrun_start_date']));
}
?>
</td>
@ -127,9 +139,9 @@
echo "<br/>" . date("Y/m/d", strtotime($data['estimate_tryrun_end_date']));
} else {
if (!empty($data['estimate_install_end_date']))
echo date("Y/m/d", strtotime($data['estimate_install_end_date'])). "<br/> ";
echo date("Y/m/d", strtotime($data['estimate_install_end_date'])) . "<br/> ";
if (!empty($data['estimate_tryrun_end_date']))
echo " <br/>" .date("Y/m/d", strtotime($data['estimate_tryrun_end_date']));
echo " <br/>" . date("Y/m/d", strtotime($data['estimate_tryrun_end_date']));
}
?>
</td>
@ -140,9 +152,9 @@
echo "<br/>" . date("Y/m/d", strtotime($data['tryrun_end_date']));
} else {
if (!empty($data['install_end_date']))
echo date("Y/m/d", strtotime($data['install_end_date'])). "<br/> ";
echo date("Y/m/d", strtotime($data['install_end_date'])) . "<br/> ";
if (!empty($data['tryrun_end_date']))
echo " <br/>" .date("Y/m/d", strtotime($data['tryrun_end_date']));
echo " <br/>" . date("Y/m/d", strtotime($data['tryrun_end_date']));
}
?>
</td>

17
wms/wipwholeinstall-renovate-index-table-html.php

@ -7,7 +7,8 @@
<th style="vertical-align: middle;text-align:center;width:250px;">合約地址</th>
<th style="vertical-align: middle;text-align:center;width:250px;">地工地址</th>
<th style="vertical-align: middle;text-align:center;width:250px;">警示</th>
<th style="vertical-align: middle;text-align:center;width:140px;">預計出貨日</th>
<th style="text-align:center;width:100px;">實際到廠日(觀音廠)</th>
<th style="text-align:center;width:100px;">預計出貨日(到工地)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">發包廠商(工勘)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">發包日期(工勘)</th>
<th style="vertical-align: middle;text-align:center;width:140px;">預計開工日(工勘)</th>
@ -39,7 +40,18 @@
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['real_address']; ?></td>
<td style="text-align:left;"><span class="text-danger"><?php echo warningMessage($data); ?></span></td>
<td><?php echo substr($data['real_contract_arrival_date'], 0, 10); ?></td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<td>
<?php
if (!empty($data['real_contract_arrival_date']))
echo date("Y/m/d", strtotime(substr($data['real_contract_arrival_date'], 0, 10)));
?>
</td>
<?php
// foreach ($site_survey_status as $key => $val) {
// if ((string)$data['site_survey_contact_verify'] == (string)$key) {
@ -181,7 +193,6 @@
</tbody>
</table>
<script>
const subContentDiv = document.createElement("div");
subContentDiv.style.position = "relative";
subContentDiv.style.top = 0;

Loading…
Cancel
Save