10994015 1 year ago
parent
commit
2a1d009390
  1. 225
      mkt/IncludeCommon.php
  2. 4
      mkt/database.php
  3. 422
      wms/IncludeCommon.php
  4. 180
      wms/T8_APItest.php
  5. 72
      wms/T8_Authorization.php
  6. 140
      wms/T8_assemble_apply.php
  7. 46
      wms/T8_purBillOrder_search.php
  8. 88
      wms/T8_purRequestOrder_create.php
  9. 360
      wms/account-create.php
  10. 36
      wms/account-delete.php
  11. 346
      wms/account-edit.php
  12. 170
      wms/account-index-submit.php
  13. 394
      wms/account-index.php
  14. 442
      wms/account-receivable-check.php
  15. 76
      wms/account-receivable-contract.php
  16. 53
      wms/account-receivable-excel.php
  17. 343
      wms/account-receivable-index.php
  18. 12
      wms/account-receivable-received-create.php
  19. 14
      wms/account-receivable-received-edit.php
  20. BIN
      wms/account-receivable.xlsx
  21. 148
      wms/account-record-submit.php
  22. 130
      wms/account-record-update.php
  23. 130
      wms/account-user-input.php
  24. 354
      wms/account_auth-create.php
  25. 364
      wms/account_auth-edit.php
  26. 208
      wms/account_auth-index.php
  27. 128
      wms/account_auth-record-update.php
  28. BIN
      wms/assets/img/icon/(Ñ╝¿╧Ñ╬)icon-star-active.png
  29. BIN
      wms/assets/img/icon/(Ñ╝¿╧Ñ╬)icon-star-default.png
  30. 624
      wms/bargain-create.php
  31. 56
      wms/bargain-delete.php
  32. 748
      wms/bargain-edit.php
  33. 286
      wms/bargain-index.php
  34. 296
      wms/bargain-record-submit.php
  35. 286
      wms/bargain-record-update.php
  36. 44
      wms/board-delete.php
  37. 118
      wms/board-edit.php
  38. 36
      wms/board-file.php
  39. 400
      wms/board-index.php
  40. 16
      wms/board-record-submit.php
  41. 102
      wms/board-record-update.php
  42. 94
      wms/change-password-update.php
  43. 152
      wms/change-password.php
  44. 21
      wms/class/Cmail.php
  45. 172
      wms/combo-create.php
  46. 22
      wms/combo-delete.php
  47. 186
      wms/combo-edit.php
  48. 278
      wms/combo-index.php
  49. 84
      wms/combo-record-submit.php
  50. 80
      wms/combo-record-update.php
  51. 108
      wms/combo-user-input.php
  52. 1612
      wms/cont/apply_form.php
  53. 912
      wms/cont/apply_form1.php
  54. 1151
      wms/cont/sign_form.php
  55. 36
      wms/cont/sign_list.php
  56. 157
      wms/cont/submit.php
  57. 252
      wms/contract-create.php
  58. 22
      wms/contract-delete.php
  59. 284
      wms/contract-edit.php
  60. 324
      wms/contract-index.php
  61. 122
      wms/contract-record-submit.php
  62. 98
      wms/contract-record-update.php
  63. 34
      wms/contract-repair/api/deleteNewContractData.php
  64. 59
      wms/contract-repair/api/getComboNo.php
  65. 122
      wms/contract-repair/api/getContractData.php
  66. 518
      wms/contract-repair/api/getFacilityNo.php
  67. 16
      wms/contract-repair/api/getPriceview.php
  68. 423
      wms/contract-repair/api/postContractData.php
  69. 68
      wms/contract-repair/api/postContractNewApplyData.php
  70. 139
      wms/contract-repair/api/postNewContractData.php
  71. 190
      wms/contract-repair/api/putContractData.php
  72. 0
      wms/contract-repair/api/store_contract.php
  73. 61
      wms/contract-repair/api/upload_chk.php
  74. 43
      wms/contract-repair/conn.php
  75. 214
      wms/contract-repair/contract-repair-edit.php
  76. 185
      wms/contract-repair/contract-repair-input.php
  77. 131
      wms/contract-repair/contract-repair-management.php
  78. 1507
      wms/contract-repair/js/alpine.js
  79. 5
      wms/contract-repair/js/alpinejs/cdn.min.js
  80. 25
      wms/contract-repair/js/axios.js
  81. 2
      wms/contract-repair/js/axios/axios.min.js
  82. 48
      wms/contract-repair/js/el.js
  83. 4
      wms/contract-repair/js/jquery/jquery-3.1.1.min.js
  84. 5
      wms/contract-repair/semantic/.browserlistrc
  85. 322
      wms/contract-repair/semantic/.csscomb.json
  86. 18
      wms/contract-repair/semantic/.csslintrc
  87. 24
      wms/contract-repair/semantic/.github/ISSUE_TEMPLATE.md
  88. 28
      wms/contract-repair/semantic/.github/PULL_REQUEST_TEMPLATE.md
  89. 33
      wms/contract-repair/semantic/.github/stale.yml
  90. 38
      wms/contract-repair/semantic/.gitignore
  91. 38
      wms/contract-repair/semantic/.jshintrc
  92. 58
      wms/contract-repair/semantic/CONTRIBUTING.md
  93. 7
      wms/contract-repair/semantic/LICENSE.md
  94. 112
      wms/contract-repair/semantic/README.md
  95. 2959
      wms/contract-repair/semantic/RELEASE-NOTES.md
  96. 5
      wms/contract-repair/semantic/Semantic-UI-master/.browserlistrc
  97. 322
      wms/contract-repair/semantic/Semantic-UI-master/.csscomb.json
  98. 18
      wms/contract-repair/semantic/Semantic-UI-master/.csslintrc
  99. 24
      wms/contract-repair/semantic/Semantic-UI-master/.github/ISSUE_TEMPLATE.md
  100. 28
      wms/contract-repair/semantic/Semantic-UI-master/.github/PULL_REQUEST_TEMPLATE.md

225
mkt/IncludeCommon.php

@ -1,110 +1,115 @@
<?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[2]) {
$data['user_id'] = '';
$data['user_name'] = '';
$data['code'] = '401';
$data['message'] = 'Token已过期,请重新登录';
return $data;
}
if ($true_signature == $explode[4]) {
$data['user_id'] = $explode[0];
$data['user_name'] = $explode[3];
$data['code'] = '200';
$data['message'] = 'Token合法';
return $data;
} else {
$data['user_id'] = '';
$data['user_name'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
} else {
$data['user_id'] = '';
$data['user_name'] = '';
$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"){
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) .
"&token=" . $response_result["token"]); #请输入使用者名称密码
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 . '.' . $start_time . '.' . $end_time . '.' . $user_name; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
}
//生成菜单
function menu ($from='tw',$type){
$function_type = array(
"tw" => array(
# F角色菜单
"H" => 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];
}
}
<?php
// phpinfo();
// exit;
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[2]) {
$data['user_id'] = '';
$data['user_name'] = '';
$data['code'] = '401';
$data['message'] = 'Token已過期,請重新登入';
return $data;
}
if ($true_signature == $explode[4]) {
$data['user_id'] = $explode[0];
$data['user_name'] = $explode[3];
$data['code'] = '200';
$data['message'] = 'Token合法';
return $data;
} else {
$data['user_id'] = '';
$data['user_name'] = '';
$data['code'] = '400';
$data['message'] = 'Token不合法';
return $data;
}
} else {
$data['user_id'] = '';
$data['user_name'] = '';
$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"){
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) .
"&token=" . $response_result["token"]); #请输入使用者名称密码
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 . '.' . $start_time . '.' . $end_time . '.' . $user_name; //设置token过期时间为一天
$encryption_code = "MASADA!^***";
//根据以上信息信息生成签名(密钥为 SIGNATURE 自定义全局常量)
$signature = hash_hmac('md5', $info, $encryption_code);
//最后将这两部分拼接起来,得到最终的Token字符串
return $token = $info . '.' . $signature;
}
//生成菜单
function menu($from = 'tw', $type)
{
$function_type = array(
"tw" => array(
# F角色菜单
"H" => 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];
}
}

4
mkt/database.php

@ -31,8 +31,8 @@ try {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
// echo "fail";
// echo $e->getMessage();
}
//print_r($link);exit;
if($link){

422
wms/IncludeCommon.php

@ -1,212 +1,212 @@
<?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($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"){
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) .
"&token=" . $response_result["token"]); #请输入使用者名称密码
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 FakeToken($fake_user_id, $token) {
date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s");
$explode = explode('.', $token);
$info = $fake_user_id . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; // 欲模擬帳號.本人帳號.有效開始時間.失效時間
$signature = hash_hmac('md5', $info, $encryption_code);
return $token = $info . '.' . $signature;
}
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="") {
global $link;
if (!$atype) return;
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu where accounttype = '$atype' and status = 'Y' order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$arr[$row["main_menu"]][$row["sub_menu"]][$row["sub_menu_eng"]] = $row["mlink"];
}
mysqli_free_result($res);
$str = json_encode($arr, JSON_UNESCAPED_UNICODE);
return $str;
}
/**
* 依帳號檢視功能目錄
* 管理者可看到全部選單
* 其餘人員依account_auth決定可檢視的選單
*/
function menu_v3($aid="", $accounttype) {
global $link;
if (!$aid) return;
$str = "";
$arr = $menu_arr = [];
$sql_cmd = ($accounttype == "E") ? "" : "where status = 'Y'";
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu $sql_cmd order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"];
$menu_arr[$row["mlink"]]["sub_menu"] = $row["sub_menu"];
$menu_arr[$row["mlink"]]["sub_menu_eng"] = $row["sub_menu_eng"];
}
mysqli_free_result($res);
$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_arr = json_decode($permission, true);
foreach ($menu_arr as $key => $val) {
if (($accounttype == "E") || !empty($permission_arr[$key])) {
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key;
}
}
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE);
/*
if ($permission_arr) {
foreach ($menu_arr as $key => $val) {
if ($permission_arr[$key]) {
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key;
}
}
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE);
}
*/
mysqli_free_result($res);
return $str;
/*
$str = "";
$sql = "select a.id, a.accountid, m.auth_content from account a, menu_auth m where a.accountid = '$aid' and a.accountid = m.accountid and m.status = 'Y'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
list($id, $accountid, $auth_content) = $row;
$auth_arr = json_decode($auth_content, true);
$menuid_arr = array_keys($auth_arr);
if ($menuid_arr) {
$arr = [];
$menuid_str = implode(",", $menuid_arr);
$sql2 = "select id, main_menu, sub_menu, sub_menu_eng, link from menu_tree where id in ($menuid_str) and status = 'Y' order by main_menu_seq, sub_menu_seq";
$res2 = mysqli_query($link, $sql2);
while ($row2 = mysqli_fetch_assoc($res2)) {
$arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = $row2["link"]; // R+W
if ($auth_arr[$row2["id"]] == "N") $arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = "";//"/wms/forbidden.php"; // R
}
mysqli_free_result($res2);
$str = json_encode($arr, JSON_UNESCAPED_UNICODE);
}
}
mysqli_free_result($res);
return $str;
*/
}
<?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($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"){
header("Location: api-account-reply-functions.php?function_list=" . serialize($response_result) .
"&token=" . $response_result["token"]); #请输入使用者名称密码
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 FakeToken($fake_user_id, $token) {
date_default_timezone_set("Asia/Taipei");
$encryption_code = "MASADA!^***";
$time = date("Y-m-d H:i:s");
$explode = explode('.', $token);
$info = $fake_user_id . '.' . $explode[1] . '.' . $explode[2] . '.' . $explode[3]; // 欲模擬帳號.本人帳號.有效開始時間.失效時間
$signature = hash_hmac('md5', $info, $encryption_code);
return $token = $info . '.' . $signature;
}
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="") {
global $link;
if (!$atype) return;
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu where accounttype = '$atype' and status = 'Y' order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$arr[$row["main_menu"]][$row["sub_menu"]][$row["sub_menu_eng"]] = $row["mlink"];
}
mysqli_free_result($res);
$str = json_encode($arr, JSON_UNESCAPED_UNICODE);
return $str;
}
/**
* 依帳號檢視功能目錄
* 管理者可看到全部選單
* 其餘人員依account_auth決定可檢視的選單
*/
function menu_v3($aid="", $accounttype) {
global $link;
if (!$aid) return;
$str = "";
$arr = $menu_arr = [];
$sql_cmd = ($accounttype == "E") ? "" : "where status = 'Y'";
$sql = "select main_menu, sub_menu, sub_menu_eng, mlink from menu $sql_cmd order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$menu_arr[$row["mlink"]]["main_menu"] = $row["main_menu"];
$menu_arr[$row["mlink"]]["sub_menu"] = $row["sub_menu"];
$menu_arr[$row["mlink"]]["sub_menu_eng"] = $row["sub_menu_eng"];
}
mysqli_free_result($res);
$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_arr = json_decode($permission, true);
foreach ($menu_arr as $key => $val) {
if (($accounttype == "E") || !empty($permission_arr[$key])) {
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key;
}
}
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE);
/*
if ($permission_arr) {
foreach ($menu_arr as $key => $val) {
if ($permission_arr[$key]) {
$arr[$val["main_menu"]][$val["sub_menu"]][$val["sub_menu_eng"]] = $key;
}
}
if (!empty($arr)) $str = json_encode($arr, JSON_UNESCAPED_UNICODE);
}
*/
mysqli_free_result($res);
return $str;
/*
$str = "";
$sql = "select a.id, a.accountid, m.auth_content from account a, menu_auth m where a.accountid = '$aid' and a.accountid = m.accountid and m.status = 'Y'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
list($id, $accountid, $auth_content) = $row;
$auth_arr = json_decode($auth_content, true);
$menuid_arr = array_keys($auth_arr);
if ($menuid_arr) {
$arr = [];
$menuid_str = implode(",", $menuid_arr);
$sql2 = "select id, main_menu, sub_menu, sub_menu_eng, link from menu_tree where id in ($menuid_str) and status = 'Y' order by main_menu_seq, sub_menu_seq";
$res2 = mysqli_query($link, $sql2);
while ($row2 = mysqli_fetch_assoc($res2)) {
$arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = $row2["link"]; // R+W
if ($auth_arr[$row2["id"]] == "N") $arr[$row2["main_menu"]][$row2["sub_menu"]][$row2["sub_menu_eng"]] = "";//"/wms/forbidden.php"; // R
}
mysqli_free_result($res2);
$str = json_encode($arr, JSON_UNESCAPED_UNICODE);
}
}
mysqli_free_result($res);
return $str;
*/
}
}

180
wms/T8_APItest.php

@ -1,91 +1,91 @@
<?php
include "T8_Authorization.php";
echo "ii";
?>
<script>
get_Auth();
window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
// if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) {
var validation = event.data;
console.log("event");
console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001';
headerParam = {
CHI_Authorization: `${validation}`,
};
var body = [{
"name": "MasterTable",
"rows": [{
"BillNo": "Z001",
"BillDate": 20230930,
"OrgId": "1000",
"TypeId": "OPV",
"BizPartnerId": "03051501",
"CurrId": "RMB",
"CurrLAmount":5,
"TaxId": "ST005",
"PersonId": "M0012",
"DeptId": "220",
"CompId": "1001",
"CreditAgeDate": 20230930,
"RecBizPartnerId": "03051501",
}]
},
{
"name": "DetailTable",
"rows": [{
"BillNo": "Z001",
"RowCode": 1,
"RowNo": 1,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 10,
"SPrice": 141.18,
"OAmount": 1344.57,
"OTax": 67.23,
"OAmountWithTax": 1411.8,
"TaxId": "ST005"
},
{
"BillNo": "Z001",
"RowCode": 2,
"RowNo": 2,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 15,
"SPrice": 141.18,
"OAmount": 2016.86,
"OTax": 100.84,
"OAmountWithTax": 2117.7,
"TaxId": "ST005"
}
]
}
];
var json = JSON.stringify(body);
obj = {
type: 'GET',
// url: `${corsurl}${apiurl}`,
url: `${apiurl}`,
// dataType: 'json',
headers: headerParam,
// data: json,
// dataType: "json",
success: function(res) {
console.log(res.Status);
console.log(res.ErrorMsg);
console.log(res.Data);
}
};
jQuery.ajax(obj);
}
})
<?php
include "T8_Authorization.php";
echo "ii";
?>
<script>
get_Auth();
window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
// if (event.origin === "https://masada.com.tw" && (typeof event.data === "string")) {
var validation = event.data;
console.log("event");
console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001';
headerParam = {
CHI_Authorization: `${validation}`,
};
var body = [{
"name": "MasterTable",
"rows": [{
"BillNo": "Z001",
"BillDate": 20230930,
"OrgId": "1000",
"TypeId": "OPV",
"BizPartnerId": "03051501",
"CurrId": "RMB",
"CurrLAmount":5,
"TaxId": "ST005",
"PersonId": "M0012",
"DeptId": "220",
"CompId": "1001",
"CreditAgeDate": 20230930,
"RecBizPartnerId": "03051501",
}]
},
{
"name": "DetailTable",
"rows": [{
"BillNo": "Z001",
"RowCode": 1,
"RowNo": 1,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 10,
"SPrice": 141.18,
"OAmount": 1344.57,
"OTax": 67.23,
"OAmountWithTax": 1411.8,
"TaxId": "ST005"
},
{
"BillNo": "Z001",
"RowCode": 2,
"RowNo": 2,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 15,
"SPrice": 141.18,
"OAmount": 2016.86,
"OTax": 100.84,
"OAmountWithTax": 2117.7,
"TaxId": "ST005"
}
]
}
];
var json = JSON.stringify(body);
obj = {
type: 'GET',
// url: `${corsurl}${apiurl}`,
url: `${apiurl}`,
// dataType: 'json',
headers: headerParam,
// data: json,
// dataType: "json",
success: function(res) {
console.log(res.Status);
console.log(res.ErrorMsg);
console.log(res.Data);
}
};
jQuery.ajax(obj);
}
})
</script>

72
wms/T8_Authorization.php

@ -1,37 +1,37 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<?php
$now = gmdate("YmdHis");
$data = 'M0000.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
?>
<script>
function get_Auth() {
var api_key = 'B2D6395D2883E26C';
var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
headerParam = {
UserId: 'M0000',
Pwd: 'M012290493119',
TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>'
};
obj = {
type: 'get',
// url: `${corsurl}${apiurl}`,
url: `${apiurl}`,
dataType: 'json',
headers: headerParam,
success: function(res) {
validation = res.Data['CHI_Authorization'];
console.log("validation:",validation);
window.parent.postMessage(validation,'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw');
}
};
jQuery.ajax(obj);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<?php
$now = gmdate("YmdHis");
$data = 'M0000.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
?>
<script>
function get_Auth() {
var api_key = 'B2D6395D2883E26C';
var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
headerParam = {
UserId: 'M0000',
Pwd: 'M012290493119',
TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>'
};
obj = {
type: 'get',
// url: `${corsurl}${apiurl}`,
url: `${apiurl}`,
dataType: 'json',
headers: headerParam,
success: function(res) {
validation = res.Data['CHI_Authorization'];
console.log("validation:",validation);
window.parent.postMessage(validation,'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw');
}
};
jQuery.ajax(obj);
}
</script>

140
wms/T8_assemble_apply.php

@ -1,71 +1,71 @@
<?php
//外購組裝單 (組裝申請單)
include "T8_Authorization.php";
?>
<script>
get_Auth();
window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
var validation = event.data;
console.log(validation);
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
headerParam = {
CHI_Authorization: `${validation}`,
};
var body = [{
"name":"stkAssyMast",
"rows":[
{
"BillNo":"TEST02",
"OrgId":"1000",
"TypeId":"CA",
"MaterialId":"3MH00302",
"PersonId":"M0122",
"CompId":"1001",
"DeptId":"220",
"SQuantity":1,
"SUnitId":"SET",
"CurrentState":2,
"CreatorId":"M0122"
}
]
},{
"name":"stkAssySubMatInfo",
"rows":[
{
"BillNo":"TEST02",
"MaterialId":"3MH00302P",
"ComponentBaseQty":1,
"UnitQty":1,
"SUnitId":"SET",
"MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302"
},{
"BillNo":"TEST02",
"MaterialId":"MX00000001",
"ComponentBaseQty":1,
"UnitQty":3,
"SUnitId":"PCS",
"MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302"
}
]
}];
var json = JSON.stringify(body);
obj = {
type:'POST',
url:`${apiurl}`,
headers:headerParam,
data: json,
dataType:"json",
success: function(res){
console.log(res.Status);
console.log(res.ErrorMsg);
console.log(res.Data);
}
};
jQuery.ajax(obj);
}
})
<?php
//外購組裝單 (組裝申請單)
include "T8_Authorization.php";
?>
<script>
get_Auth();
window.addEventListener('message', function(event) {
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) {
var validation = event.data;
console.log(validation);
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
headerParam = {
CHI_Authorization: `${validation}`,
};
var body = [{
"name":"stkAssyMast",
"rows":[
{
"BillNo":"TEST02",
"OrgId":"1000",
"TypeId":"CA",
"MaterialId":"3MH00302",
"PersonId":"M0122",
"CompId":"1001",
"DeptId":"220",
"SQuantity":1,
"SUnitId":"SET",
"CurrentState":2,
"CreatorId":"M0122"
}
]
},{
"name":"stkAssySubMatInfo",
"rows":[
{
"BillNo":"TEST02",
"MaterialId":"3MH00302P",
"ComponentBaseQty":1,
"UnitQty":1,
"SUnitId":"SET",
"MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302"
},{
"BillNo":"TEST02",
"MaterialId":"MX00000001",
"ComponentBaseQty":1,
"UnitQty":3,
"SUnitId":"PCS",
"MarkerNo":"3MH00302",
"CU_MaterialId":"3MH00302"
}
]
}];
var json = JSON.stringify(body);
obj = {
type:'POST',
url:`${apiurl}`,
headers:headerParam,
data: json,
dataType:"json",
success: function(res){
console.log(res.Status);
console.log(res.ErrorMsg);
console.log(res.Data);
}
};
jQuery.ajax(obj);
}
})
</script>

46
wms/T8_purBillOrder_search.php

@ -1,23 +1,23 @@
<?php
include "./header.php";
//假設供應商代碼為P
$BizPartnerId = "P";
$sql_purBillOrder = "
SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2";
$purMaster = $conn->query($sql_purBillOrder);
//每筆採購單資料
foreach($purMaster as $master){
//print_r($master);
$BillNo = $master['BillNo'];
//每筆採購單明細資料
$sql_purDetail = "
SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'";
$purDetail = $conn->query($sql_purDetail);
foreach($purDetail as $detail){
print_r($detail);
}
echo "<br>----------------------<br>";
}
<?php
include "./header.php";
//假設供應商代碼為P
$BizPartnerId = "P";
$sql_purBillOrder = "
SELECT * FROM purBillOrderMaster WHERE BizPartnerId = '$BizPartnerId' AND CurrentState = 2";
$purMaster = $conn->query($sql_purBillOrder);
//每筆採購單資料
foreach($purMaster as $master){
//print_r($master);
$BillNo = $master['BillNo'];
//每筆採購單明細資料
$sql_purDetail = "
SELECT * FROM purBillOrderDetail WHERE BillNo = '$BillNo'";
$purDetail = $conn->query($sql_purDetail);
foreach($purDetail as $detail){
print_r($detail);
}
echo "<br>----------------------<br>";
}

88
wms/T8_purRequestOrder_create.php

@ -1,45 +1,45 @@
<?php
include "./header.php";
date_default_timezone_set('Asia/Taipei');
//表頭
$BillNo ="TEST01";
$BillDate = 20231204;
$PersonId = "M0122";
$DeptId = "220";
// $ProjectId = "3MH00545";
$CreateTime = Date("YmdHis");
$CurrentState = 2;
//表身
$ItemType = 0;
$MaterialId = "MX00011078";
$SUnitId = "PCS";
$DemandSQty = 5; //核准數量
$RequestSQty = 5; //請購數量
$RequireDate=20231205;
$CurrId="TWD";
$UnTransQty = 5; //未轉採購基本數量
$TransQty = 0; //已轉採購基本數量
$SupplyQty = 5; //供給數量
$ProjectId="3MH00545"; //合約號
$SupplyId= "P"; //供應商
$UnTransOtherSQty = 5;
$AllowTransOtherSQty = 5;
$CU_MaterialId="3MH00352"; //作番號 、預留標示號
$sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState,
TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState,
'PR','1000','1000','$user_id','1001')";
$sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId,
DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId,
PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId,
UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo
) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId',
$DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId',
'1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000',
$UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')";
$conn ->query($sql);
<?php
include "./header.php";
date_default_timezone_set('Asia/Taipei');
//表頭
$BillNo ="TEST01";
$BillDate = 20231204;
$PersonId = "M0122";
$DeptId = "220";
// $ProjectId = "3MH00545";
$CreateTime = Date("YmdHis");
$CurrentState = 2;
//表身
$ItemType = 0;
$MaterialId = "MX00011078";
$SUnitId = "PCS";
$DemandSQty = 5; //核准數量
$RequestSQty = 5; //請購數量
$RequireDate=20231205;
$CurrId="TWD";
$UnTransQty = 5; //未轉採購基本數量
$TransQty = 0; //已轉採購基本數量
$SupplyQty = 5; //供給數量
$ProjectId="3MH00545"; //合約號
$SupplyId= "P"; //供應商
$UnTransOtherSQty = 5;
$AllowTransOtherSQty = 5;
$CU_MaterialId="3MH00352"; //作番號 、預留標示號
$sql = "INSERT INTO purRequestOrder(BillNo, BillDate, PersonId, DeptId, CreateTime, CurrentState,
TypeId, DemandOrgId, FOrgId,CreatorId, CompId) VALUES ('$BillNo',$BillDate,'$PersonId','$DeptId',$CreateTime,$CurrentState,
'PR','1000','1000','$user_id','1001')";
$sql_sub = "INSERT INTO purApplyOrderDetail(BillNo,RowCode, RowNo, ItemType, MaterialId, SUnitId,
DemandSQty, DemandQty, RequestSQty,RequestQty, RequireDate, IsPriceWithTax, CurrId,
PurOrgId, BpOrgId, SupplyId, UnTransQty, TransQty, SupplyQty, ProjectId, PlanRangeId,
UnTransOtherSQty, AllowTransOtherSQty,P_A_DemandOrgId, PurCompId, CU_MaterialId, MarkerNo
) VALUES ('$BillNo',1,1,$ItemType,'$MaterialId','$SUnitId',
$DemandSQty, $DemandSQty, $RequestSQty, $RequestSQty, $RequireDate, 1, '$CurrId',
'1000', '1000', '$SupplyId', $UnTransQty, $TransQty, $SupplyQty, '$ProjectId', '1000',
$UnTransOtherSQty, $AllowTransOtherSQty,'1000','1001','$CU_MaterialId','$CU_MaterialId')";
$conn ->query($sql);
$conn ->query($sql_sub);

360
wms/account-create.php

@ -1,180 +1,180 @@
<?php
include "header.php";
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
?>
<script>
$(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
});
</script>
<div class="container">
<?php
include "account-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div>
<label for="accounttype">帳號類別(必選)</label>
<select name="accounttype" id="accounttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<option value="A">客戶(A)</option>
<option value="B">保養人員(B)</option>
<!--
<option value="C">檢查人員</option>
<option value="D">契約人員</option>
-->
<option value="E">管理人員(E)</option>
<option value="M">永佳捷員工(M)</option>
<option value="X">未分類(X)</option>
</select>
<!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> -->
</div>
<div>
<label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label>
<input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required>
</div>
<div>
<label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" required>
</div>
<div>
<label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" required>
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" maxlength="16">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address">
</div>
<div>
<label for="email">電子郵箱</label>
<input type="text" name="email" id="email">
</div>
<div>
<label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid">
</div>
<div>
<label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid">
</div>
<div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" maxlength="16">
</div>
<div>
<label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help">
</div>
<div>
<label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help">
</div>
<div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" maxlength="10">
</div>
<div>
<label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" maxlength="10">
</div>
<div>
<label for="department_id">部門(員工必填)</label>
<select name="department_id">
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別(員工必填)</label>
<select name="role_id">
<option value="">請選擇</option>
</select>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<?php if ($user_auth&2) { ?>
<div>
<button type="submit" name="submit">確定</button>
</div>
<?php } ?>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>
<?php
include "header.php";
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
?>
<script>
$(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
});
</script>
<div class="container">
<?php
include "account-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div>
<label for="accounttype">帳號類別(必選)</label>
<select name="accounttype" id="accounttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<option value="A">客戶(A)</option>
<option value="B">保養人員(B)</option>
<!--
<option value="C">檢查人員</option>
<option value="D">契約人員</option>
-->
<option value="E">管理人員(E)</option>
<option value="M">永佳捷員工(M)</option>
<option value="X">未分類(X)</option>
</select>
<!-- <input type="text" name="accounttype" id="accounttype" placeholder="帳號類別..." required> -->
</div>
<div>
<label for="accountid">請輸入員工、個人客戶ID或公司客戶統編(必填)</label>
<input type="text" name="accountid" id="accountid" placeholder="請輸入員工、個人客戶ID或公司客戶統編...(必填)" maxlength="10" required>
</div>
<div>
<label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" required>
</div>
<div>
<label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" required>
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" maxlength="16">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address">
</div>
<div>
<label for="email">電子郵箱</label>
<input type="text" name="email" id="email">
</div>
<div>
<label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid">
</div>
<div>
<label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid">
</div>
<div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" maxlength="16">
</div>
<div>
<label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help">
</div>
<div>
<label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help">
</div>
<div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" maxlength="10">
</div>
<div>
<label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" maxlength="10">
</div>
<div>
<label for="department_id">部門(員工必填)</label>
<select name="department_id">
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別(員工必填)</label>
<select name="role_id">
<option value="">請選擇</option>
</select>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<?php if ($user_auth&2) { ?>
<div>
<button type="submit" name="submit">確定</button>
</div>
<?php } ?>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>

36
wms/account-delete.php

@ -1,19 +1,19 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$sql = "select accountid from account where id = '$id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) {
$db_query = "delete from account where id = '$id'";
mysqli_query($link, $db_query);
$db_query = "delete from account_auth where accountid = '".$row["accountid"]."'";
mysqli_query($link, $db_query);
}
mysqli_free_result($res);
header("Refresh:0; url=account-index.php?function_name=account&".$token_link);
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$sql = "select accountid from account where id = '$id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) {
$db_query = "delete from account where id = '$id'";
mysqli_query($link, $db_query);
$db_query = "delete from account_auth where accountid = '".$row["accountid"]."'";
mysqli_query($link, $db_query);
}
mysqli_free_result($res);
header("Refresh:0; url=account-index.php?function_name=account&".$token_link);
ob_end_flush();
?>

346
wms/account-edit.php

@ -1,173 +1,173 @@
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM account WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<script>
$(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
});
</script>
<div class="container">
<form class="form-inline" method="post" action="account-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="accounttype">帳號類別</label>
<input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly>
</div>
<div>
<label for="accountid">帳號</label>
<input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly>
</div>
<div>
<label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>">
</div>
<div>
<label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>">
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div>
<div>
<label for="email">電子郵箱</label>
<input type="text" name="email" id="email" value="<?php echo $data['email']; ?>">
</div>
<div>
<label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>">
</div>
<div>
<label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>">
</div>
<div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>">
</div>
<div>
<label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>">
</div>
<div>
<label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>">
</div>
<div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
</div>
<div>
<label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>">
</div>
<div>
<label for="department_id">部門(員工必填)</label>
<select name="department_id">
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["department_id"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別(員工必填)</label>
<select name="role_id">
<?php
foreach ($role_arr[$data["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["role_id"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM account WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<script>
$(function(){
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
});
</script>
<div class="container">
<form class="form-inline" method="post" action="account-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="accounttype">帳號類別</label>
<input type="text" name="accounttype" id="accounttype" value="<?php echo $data['accounttype']; ?>" readonly>
</div>
<div>
<label for="accountid">帳號</label>
<input type="text" name="accountid" id="accountid" value="<?php echo $data['accountid']; ?>" readonly>
</div>
<div>
<label for="pwd">密碼(必填)</label>
<input type="text" name="pwd" id="pwd" value="<?php echo $data['pwd']; ?>">
</div>
<div>
<label for="name">姓名(必填)</label>
<input type="text" name="name" id="name" value="<?php echo $data['name']; ?>">
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div>
<div>
<label for="email">電子郵箱</label>
<input type="text" name="email" id="email" value="<?php echo $data['email']; ?>">
</div>
<div>
<label for="lineid">Line ID</label>
<input type="text" name="lineid" id="lineid" value="<?php echo $data['lineid']; ?>">
</div>
<div>
<label for="wechatid">微信ID</label>
<input type="text" name="wechatid" id="wechatid" value="<?php echo $data['wechatid']; ?>">
</div>
<div>
<label for="phone_call_help">保養員聯絡手機號(客戶必填)</label>
<input type="text" name="phone_call_help" id="phone_call_help" value="<?php echo $data['phone_call_help']; ?>">
</div>
<div>
<label for="chat_for_help">線上文字客服</label>
<input type="text" name="chat_for_help" id="chat_for_help" value="<?php echo $data['chat_for_help']; ?>">
</div>
<div>
<label for="remote_help">遠端視頻帳號</label>
<input type="text" name="remote_help" id="remote_help" value="<?php echo $data['remote_help']; ?>">
</div>
<div>
<label for="repairerid">服務與支持人員工號(客戶必填)</label>
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data['repairerid']; ?>">
</div>
<div>
<label for="manager">直屬主管工號(員工必填)</label>
<input type="text" name="manager" id="manager" value="<?php echo $data['manager']; ?>">
</div>
<div>
<label for="department_id">部門(員工必填)</label>
<select name="department_id">
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["department_id"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別(員工必填)</label>
<select name="role_id">
<?php
foreach ($role_arr[$data["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["role_id"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>

170
wms/account-index-submit.php

@ -1,85 +1,85 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "database.php";
include 'class/Cmail.php';
header('Content-Type: application/json');
$method = $_POST['method'];
$id = empty($_POST['id']) ? '' : $_POST['id'];
$sql = "
SELECT * FROM account WHERE id = '$id'
";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_assoc($result);
$cmail = new Cmail();
$subject = "永佳捷新人文件";
$em_body = "";
$file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf");
$file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"];
$sendlist[0] = [$data['name'], $data['email']];
// 保養人員
if (in_array($data['accounttype'], ['B'])) {
$em_body = "
您好,我是桃園資訊處的子苹,
以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . "
公司手機門號:請和資訊人員聯絡
你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . "
登入後密碼可再自行更改
除了這個web方式收信,你也可以點擊手機裡的gmail收發信
桌面有安裝「維保APP系統」
登入帳號 " . $data['accountid'] . "
密碼 " . explode('@', $data['email'])[0] . "
GPS定位APP的登入帳密跟上面的一樣
http://oa.masada.com.tw
這是公司內部系統
登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/
這是公司雲端系統
預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝!
";
}
// 員工
if (in_array($data['accounttype'], ['M', 'E'])) {
$em_body = "
您好,
以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . "
你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . "
登入後密碼可再自行更改
除了這個web方式收信,你也可以用電腦裡的outlook收發信
http://oa.masada.com.tw
這是公司內部系統
登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/
這是公司雲端系統
預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝!
";
}
$cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file);
echo json_encode([1, "信件發送成功"]);
}
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "database.php";
include 'class/Cmail.php';
header('Content-Type: application/json');
$method = $_POST['method'];
$id = empty($_POST['id']) ? '' : $_POST['id'];
$sql = "
SELECT * FROM account WHERE id = '$id'
";
$result = mysqli_query($link, $sql);
$data = mysqli_fetch_assoc($result);
$cmail = new Cmail();
$subject = "永佳捷新人文件";
$em_body = "";
$file_name = str_replace('/', '\\', __DIR__ . "/public/file/永佳捷雲端空間使用設定方式.pdf");
$file[0] = [$file_name, "永佳捷雲端空間使用設定方式.pdf"];
$sendlist[0] = [$data['name'], $data['email']];
// 保養人員
if (in_array($data['accounttype'], ['B'])) {
$em_body = "
您好,我是桃園資訊處的子苹,
以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . "
公司手機門號:請和資訊人員聯絡
你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . "
登入後密碼可再自行更改
除了這個web方式收信,你也可以點擊手機裡的gmail收發信
桌面有安裝「維保APP系統」
登入帳號 " . $data['accountid'] . "
密碼 " . explode('@', $data['email'])[0] . "
GPS定位APP的登入帳密跟上面的一樣
http://oa.masada.com.tw
這是公司內部系統
登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/
這是公司雲端系統
預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝!
";
}
// 員工
if (in_array($data['accounttype'], ['M', 'E'])) {
$em_body = "
您好,
以下是給新報到同仁的基本資訊,您再參考:
員編:" . $data['accountid'] . "
你的email:" . $data['email'] . "
web收信:http://webmail.masada.com.tw:8081
帳號:" . explode('@', $data['email'])[0] . "
密碼:" . $data['accountid'] . "
登入後密碼可再自行更改
除了這個web方式收信,你也可以用電腦裡的outlook收發信
http://oa.masada.com.tw
這是公司內部系統
登入帳號:" . $data['accountid'] . "
登入密碼:" . explode('@', $data['email'])[0] . "
https://cloud.masada.com.tw:1846/
這是公司雲端系統
預設帳密在信箱 請記得去更改密碼
以上,有問題請隨時與資訊聯繫,謝謝!
";
}
$cmail->sendx($subject, $em_body, $sendlist, "永佳捷科技", "", $file);
echo json_encode([1, "信件發送成功"]);
}

394
wms/account-index.php

@ -1,198 +1,198 @@
<?php
include "header.php";
$accounttype_arr = ["A" => "客戶", "B" => "保養人員", "C" => "檢查人員", "D" => "契約人員", "M" => "員工", "E" => "管理員(IT)", "X" => "未分類"]; #A=客戶 B=保養人員 C=檢查人員 D=契約人員 E=管理人員 M=永佳捷員工 X=未分類
// 工務總處、王凱欣可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$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);
?>
<!-- <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 ($data) :
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");
}
}
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
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;
}
</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>
<!--<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'];
}
?>
">
<?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 } ?>
<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 :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
<?php
include "header.php";
$accounttype_arr = ["A" => "客戶", "B" => "保養人員", "C" => "檢查人員", "D" => "契約人員", "M" => "員工", "E" => "管理員(IT)", "X" => "未分類"]; #A=客戶 B=保養人員 C=檢查人員 D=契約人員 E=管理人員 M=永佳捷員工 X=未分類
// 工務總處、王凱欣可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$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);
?>
<!-- <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 ($data) :
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");
}
}
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
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;
}
</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>
<!--<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'];
}
?>
">
<?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 } ?>
<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 :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

442
wms/account-receivable-check.php

@ -1,245 +1,199 @@
<?php
include "./header.php";
$Bill = $_POST['Bill'];
$Bill = json_decode($Bill, true);
$data = json_encode($Bill);
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
</style>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span>
</a>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong><?= $Bill[5] ?></strong></h3>
</div>
<form class="form-horizontal">
<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[10] ?>" disabled>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="Manager">經理</label>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<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[6] ?>" disabled>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<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[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['facilities']) ?></textarea>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
<table 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>尾款</th>
</tr>
</thead>
<tbody>
<tr>
<td>合約金額</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>
<tr>
<td>目前應收</td>
<td><?= number_format(round($Bill['sign'][3])) ?></td>
<td><?= number_format(round($Bill['second'][3])) ?></td>
<td><?= number_format(round($Bill['arrive'][3])) ?></td>
<td><?= number_format(round($Bill['install'][3])) ?></td>
<td><?= number_format(round($Bill['tryrun'][3])) ?></td>
<td><?= number_format(round($Bill['check'][3])) ?></td>
<td><?= number_format(round($Bill['delivery'][3])) ?></td>
<td><?= number_format(round($Bill['final'][3])) ?></td>
</tr>
</tbody>
</table>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>目前應收</th>
<th>已開發票金額</th>
<th>未開發票金額</th>
<th>已收金額</th>
<th>未收金額</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= number_format(round($Bill['receivable_budget'])) ?></td>
<td><?= number_format(round($Bill['invoice_budget'])) ?></td>
<td><?= number_format(round($Bill['receivable_budget'] - $Bill['invoice_budget'])) ?></td>
<td><?= number_format(round($Bill['received_budget'])) ?></td>
<td><?= number_format(round($Bill['invoice_budget'] - $Bill['received_budget'])) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<?php
include "./footer.php";
?>
<?php
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> -->
<?php
}
?>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<table 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>狀態</th> -->
</tr>
</thead>
<tbody>
<?php if ($Bill['invoice'] != Null) {
foreach ($Bill['invoice'] as $key => $invoice) { ?>
<tr>
<td><?= $key ?></td>
<td><?= $invoice[0] ?></td>
<td><?php switch ($invoice[2]) {
case 0:
echo "藍字";
break;
case 1:
echo "紅字";
break;
case 2:
echo "作廢";
break;
} ?></td>
<td><?= isset($invoice[1])? number_format($invoice[1]):0 ?></td>
<td><?= isset($invoice[3])? $invoice[3]:' ' ?></td>
<td><?= isset($invoice[4])? number_format($invoice[4]):0 ?></td>
<td><?= isset($invoice[5])? number_format($invoice[5]):0 ?></td>
<!-- <td><?= $received['remark'] ?></td>
<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> -->
</tr>
<?php }
}
?>
</tbody>
</table>
</div>
<script>
function create(type, pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
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 ?>";
}
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();
}
<?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;
$data = json_encode($Bill);
?>
<style>
th {
text-align: center;
}
td {
text-align: right;
}
</style>
<div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="account-receivable-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span>
</a>
</div>
</div>
<div class="container">
<div class="text-center" style="margin-bottom: 20px;">
<h3><strong><?= $Bill[4] ?></strong></h3>
</div>
<form class="form-horizontal">
<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>
</div>
<div class="col-md-3">
<label for="DeptId">部門</label>
<input type="text" class="form-control" id="DeptId" name="DeptId" value="<?= $Bill[1] ?>" disabled>
</div>
<div class="col-md-3">
<label for="Manager">經理</label>
<input type="text" class="form-control" id="Manager" name="Manager" value="<?= $Bill[2] ?>" disabled>
</div>
<div class="col-md-3">
<label for="PersonName">營業員</label>
<input type="text" class="form-control" id="PersonName" name="PersonName" value="<?= $Bill[3] ?>" 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>
</div>
<div class="col-md-3">
<label for="TaxNo">統一編號</label>
<input type="text" class="form-control" id="TaxNo" name="TaxNo" value="<?= $Bill[15] ?>" 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>
</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>
</div>
</form>
<div style="width: auto; margin-top: 30px;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<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[21])) ?></td>
<td><?= number_format(round($Bill[20])) ?></td>
<td><?= number_format(round($Bill[22])) ?></td>
</tr>
</tbody>
</table>
</div>
<div style="width: auto; margin-top: 30px;">
<table 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>
<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>
</tr>
</tbody>
</table>
</div>
</div>
<?php
include "./footer.php";
?>
<?php
if ($user_id == "M0122") {
?>
<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>
<?php
}
?>
<div style="margin-right: 10%;margin-left: 10%; justify-content: center;">
<table class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th>發票日期</th>
<th>發票金額</th>
<th>收款日期</th>
<th>收款金額</th>
<th>說明</th>
<th style="width: 10%;">功能</th>
</tr>
</thead>
<tbody>
<?php if ($pay_received) {
foreach ($pay_received as $received) { ?>
<tr>
<td><?= $received['invoice_date'] ?></td>
<td><?= number_format($received['invoice_amount']) ?></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'))) { ?>
<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">
<span class=" glyphicon glyphicon-trash"></span>
</a>
<?php } ?>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<script>
function create(type, pay_id) {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
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 ?>";
}
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();
}
</script>

76
wms/account-receivable-contract.php

@ -1,39 +1,39 @@
<?php
include "header.php";
// 合約收款款別名稱
$arrayData = [];
echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>";
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName
FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)";
$contract = $conn->query($sql_contract);
foreach ($contract as $cont) {
if ($cont['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
}else{
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
if(isset($arrayData[$BillNo])){
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
}else{
$arrayData[$BillNo][0] = $BillNo;
$arrayData[$BillNo][1] = $partnerName;
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
}
};
foreach($arrayData as $data){
foreach($data as $value){
echo $value.";";
}
echo "</br>";
<?php
include "header.php";
// 合約收款款別名稱
$arrayData = [];
echo "合約號;客戶名稱;1款;金額;2款;金額;3款;金額;4款;金額;5款;金額;6款;金額;7款;金額;8款;金額;9款;金額;10款;金額;11款;金額;12款</br>";
$sql_contract = "SELECT a.BillNo, a.PayStage, a.PlanPayAmt,s.BizPartnerId,c.BizPartnerName
FROM salOrderStagePay AS a
LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner as c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4)";
$contract = $conn->query($sql_contract);
foreach ($contract as $cont) {
if ($cont['BillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
}else{
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName'];
if(isset($arrayData[$BillNo])){
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
}else{
$arrayData[$BillNo][0] = $BillNo;
$arrayData[$BillNo][1] = $partnerName;
array_push($arrayData[$BillNo], $PayStage);
array_push($arrayData[$BillNo], $PayAmount);
}
};
foreach($arrayData as $data){
foreach($data as $value){
echo $value.";";
}
echo "</br>";
}

53
wms/account-receivable-excel.php

@ -13,46 +13,43 @@ foreach ($Bill as $key => $value) {
// for ($i = 0; $i < 17; $i++) {
// $value[$i] = (isset($value[$i])) ? $value[$i] : 0;
// }
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
$value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
$value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0;
$value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0;
$value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0;
$value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0;
$value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
$array_data[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['second'][1], $value['arrive'][1], $value['install'][1], $value['tryrun'][1], $value['check'][1], $value['delivery'][1], $value['final'][1],
$value['sign'][3], $value['second'][3], $value['arrive'][3], $value['install'][3], $value['tryrun'][3], $value['check'][3], $value['delivery'][3], $value['final'][3],
$value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
];
$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('AB' . $rowIndex)->getAlignment()->setWrapText(true);
$column = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA'];
foreach($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
$sheet->getStyle('R' . $rowIndex)->getAlignment()->setWrapText(true);
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-test.xlsx';
$excelFileName = 'account-receivable.xlsx';
$writer->save($excelFileName);
echo $excelFileName;
?>
<!-- <script>
<script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script> -->
</script>

343
wms/account-receivable-index.php

@ -4,73 +4,56 @@ include "header.php";
$follower = find_follow($user_id);
$arrayData = [];
$receivable_array = [];
// T8發票 (有專案的發票)
$sql_invoice = "SELECT DISTINCT
a.InvoiceNo, a.InvoiceTime,a.OAmountWithTax,a.InvoiceState,
b.ProjectId
FROM arSellInvoice as a
LEFT JOIN arSellInvoiceMaterial as b
ON a.BillNo=b.BillNo
WHERE DATALENGTH(b.ProjectId)>0";
// T8核銷
$sql_received = "SELECT
a.BillNo, a.WriteOffBizPartnerId,a.PayWriteOffOAmount,
b.FromBillDate AS ReceivedDate,b.CurrWOFeeOAmt AS Fee,
c.OrderBillNo, c.checkBillNo, c.InvoiceNo, c.BillDate AS CheckBillDate
FROM arWriteOffBill AS a
LEFT JOIN arWriteOffBillRec AS b ON a.BillNo=b.BillNo
LEFT JOIN
(SELECT temp1.*,arWriteOffBillDetail.* FROM arWriteOffBillDetail
LEFT JOIN
(SELECT
arCheckBill.BillNo AS checkBillNo, arCheckBill.BillDate,arCheckBillInvInfo.InvoiceNo
FROM arCheckBill
LEFT JOIN arCheckBillInvInfo
ON arCheckBill.InvoiceBillNo=arCheckBillInvInfo.InvoiceBillNo) AS temp1
ON temp1.checkBillNo = arWriteOffBillDetail.FromBillNo) AS c
ON a.BillNo=c.BillNo
WHERE DATALENGTH(c.OrderBillNo) >0";
$sql_received = "SELECT * FROM arWriteOffBillDetail WHERE (DATALENGTH(OrderBillNo) >0)";
$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
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_contract .= "AND (s.PersonId = '$user_id'";
$sql_received .= " AND (PersonId = '$user_id'";
$sql_opening .= " OR person_id = '$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 PersonId IN $column_str)";
$sql_opening .= " OR person_id IN $column_str)";
} else {
$sql_contract .= ")";
$sql_received .= ")";
$sql_opening .= ")";
};
}
$contract = $conn->query($sql_contract);
$received_array = $conn->query($sql_received);
$opening_data = mysqli_query($link, $sql_opening);
$invoice_data = $conn->query($sql_invoice);
// 合約收款階段內容分類
$sign60 = array('簽訂後60天', '簽約60日', '簽約後60天', '簽訂後60日內', '訂金支付後60天');
$sign90 = array('簽約後90天', '簽約後90日', '簽訂後90天');
$sign120 = array('簽約後120天', '簽約後120日', '簽訂後120天');
$contract = $conn->query($sql_contract);
$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) {
@ -88,7 +71,7 @@ foreach ($contract as $cont) {
$EnterpriseName = $cont['EnterpriseName'];
$TaxNo = $cont['TaxNo'];
$ContactAddress = $cont['ContactAddress'];
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期
//['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 通訊地址
@ -97,13 +80,8 @@ foreach ($contract as $cont) {
$arrayData[$BillNo][6] = $EnterpriseName;
$arrayData[$BillNo][7] = $TaxNo;
$arrayData[$BillNo][8] = $ContactAddress;
$arrayData[$BillNo]['total_budget'] = 0;
$arrayData[$BillNo]['invoice'] = array();
$arrayData[$BillNo]['received_budget'] = 0;
$arrayData[$BillNo]['invoice_budget'] = 0;
$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]['sign']['min'] = $arrayData[$BillNo]['second']['min'] = $arrayData[$BillNo]['arrive']['min'] = $arrayData[$BillNo]['install']['min'] = $arrayData[$BillNo]['tryrun']['min'] = $arrayData[$BillNo]['check']['min'] = $arrayData[$BillNo]['delivery']['min'] = $arrayData[$BillNo]['final']['min'] = array();
$arrayData[$BillNo]['sign']['max'] = $arrayData[$BillNo]['second']['max'] = $arrayData[$BillNo]['arrive']['max'] = $arrayData[$BillNo]['install']['max'] = $arrayData[$BillNo]['tryrun']['max'] = $arrayData[$BillNo]['check']['max'] = $arrayData[$BillNo]['delivery']['max'] = $arrayData[$BillNo]['final']['max'] = array();
$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;
}
@ -111,7 +89,6 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['second'][0] = $PayStage;
$arrayData[$BillNo]['second'][1] = $PayAmount;
$arrayData[$BillNo]['second'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
if (isset($arrayData[$BillNo]['sign'][2]) && !is_null($arrayData[$BillNo]['sign'][2])) {
$signtime = strtotime(strval($arrayData[$BillNo]['sign'][2]));
if (in_array($PayStage, $sign60)) {
@ -136,43 +113,33 @@ foreach ($contract as $cont) {
$arrayData[$BillNo]['sign'][0] = $PayStage;
$arrayData[$BillNo]['sign'][1] = $PayAmount;
$arrayData[$BillNo]['sign'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
array_push($arrayData[$BillNo]['sign']['min'], intval(substr($PlanPayDate, 4, 2)));
array_push($arrayData[$BillNo]['sign']['max'], intval(substr($PlanPayDate, 4, 2)));
} elseif (stristr($PayStage, '試車')) {
$arrayData[$BillNo]['tryrun'][0] = $PayStage;
$arrayData[$BillNo]['tryrun'][1] = $PayAmount;
$arrayData[$BillNo]['tryrun'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} elseif (stristr($PayStage, '安裝') || stristr($PayStage, '貨抵工地且完工')) {
$arrayData[$BillNo]['install'][0] = $PayStage;
$arrayData[$BillNo]['install'][1] = $PayAmount;
$arrayData[$BillNo]['install'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} elseif (stristr($PayStage, '貨抵工地') || stristr($PayStage, '貨底工地')) {
$arrayData[$BillNo]['arrive'][0] = $PayStage;
$arrayData[$BillNo]['arrive'][1] = $PayAmount;
$arrayData[$BillNo]['arrive'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} elseif (stristr($PayStage, '得合格函後6個月') || stristr($PayStage, '核可函取得後6個月') || stristr($PayStage, '交車')) {
$arrayData[$BillNo]['delivery'][0] = $PayStage;
$arrayData[$BillNo]['delivery'][1] = $PayAmount;
$arrayData[$BillNo]['delivery'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} elseif (stristr($PayStage, '合格') || stristr($PayStage, '驗收') || stristr($PayStage, '許可') || stristr($PayStage, '核可')) {
$arrayData[$BillNo]['check'][0] = $PayStage;
$arrayData[$BillNo]['check'][1] = $PayAmount;
$arrayData[$BillNo]['check'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} elseif (stristr($PayStage, '驗收完成')) {
$arrayData[$BillNo]['final'][0] = $PayStage;
$arrayData[$BillNo]['final'][1] = $PayAmount;
$arrayData[$BillNo]['final'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
} else {
$arrayData[$BillNo]['other'][1] = $PayAmount;
$arrayData[$BillNo]['other'][2] = $PlanPayDate;
$arrayData[$BillNo]['total_budget'] += $PayAmount;
}
}
$sql = "SELECT
@ -222,24 +189,12 @@ foreach ($wipwhole_array as $wip) {
$estimate_delivery_time = strtotime($wip['estimated_shipping_date']);
$secondtime = $estimate_delivery_time - (30 * 86400);
$secondtime = date('Ymd', $secondtime);
if (empty($wip['estimated_shipping_date'])) {
$arrayData[$wip['contractno']]['second']['min'] = 0;
} else {
array_push($arrayData[$wip['contractno']]['second']['max'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['second']['min'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
}
$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 (empty($wip['estimated_shipping_date'])) {
$arrayData[$wip['contractno']]['second']['min'] = 0;
} else {
array_push($arrayData[$wip['contractno']]['second']['max'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['second']['min'], intval(substr($wip['estimated_shipping_date'], 5, 2)));
}
}
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
@ -250,24 +205,6 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['delivery']['min'], intval(substr($wip['delivery_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], intval(substr($wip['delivery_date'], 5, 2)));
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], intval(substr($wip['official_check_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['check']['max'], intval(substr($wip['official_check_date'], 5, 2)));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
@ -276,20 +213,6 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
array_push($arrayData[$wip['contractno']]['check']['min'], intval(substr($wip['official_check_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['check']['max'], intval(substr($wip['official_check_date'], 5, 2)));
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
@ -297,41 +220,17 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], intval(substr($wip['tryrun_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], intval(substr($wip['tryrun_end_date'], 5, 2)));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['install_end_date'] != NULL) {
$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;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], intval(substr($wip['install_end_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['install']['max'], intval(substr($wip['install_end_date'], 5, 2)));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} elseif ($wip['real_arrival_date'] != NULL) {
$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;
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['arrive']['min'], intval(substr($wip['real_arrival_date'], 5, 2)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], intval(substr($wip['real_arrival_date'], 5, 2)));
}
} 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>";
@ -359,59 +258,18 @@ foreach ($wipwhole_array as $wip) {
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
$month = 11;
$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']));
$value['sign'][3] = $value['sign'][1];
$value['second'][3] = $value['second'][1] * ($value['second_num'] / $value['total_facility_num']);
$value['arrive'][3] = $value['arrive'][1] * ($value['arrive_num'] / $value['total_facility_num']);
$value['install'][3] = $value['install'][1] * ($value['install_num'] / $value['total_facility_num']);
$value['tryrun'][3] = $value['tryrun'][1] * ($value['tryrun_num'] / $value['total_facility_num']);
$value['check'][3] = $value['check'][1] * ($value['check_num'] / $value['total_facility_num']);
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']);
$value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']);
}
$value['sign']['max'] = empty($value['sign']['max']) ? 0 : (($month - max($value['sign']['max'])) < 0 ? 0 : ($month - max($value['sign']['max'])));
$value['sign']['min'] = empty($value['sign']['min']) ? 0 : (($month - min($value['sign']['min'])) < 0 ? 0 : ($month - min($value['sign']['min'])));
$value['second']['max'] = empty($value['second']['max']) ? 0 : (($month - max($value['second']['max'])) < 0 ? 0 : ($month - max($value['second']['max'])));
$value['second']['min'] = empty($value['second']['min']) ? 0 : (($month - min($value['second']['min'])) < 0 ? 0 : ($month - min($value['second']['min'])));
$value['arrive']['max'] = empty($value['arrive']['max']) ? 0 : (($month - max($value['arrive']['max'])) < 0 ? 0 : ($month - max($value['arrive']['max'])));
$value['arrive']['min'] = empty($value['arrive']['min']) ? 0 : (($month - min($value['arrive']['min'])) < 0 ? 0 : ($month - min($value['arrive']['min'])));
$value['install']['max'] = empty($value['install']['max']) ? 0 : (($month - max($value['install']['max'])) < 0 ? 0 : ($month - max($value['install']['max'])));
$value['install']['min'] = empty($value['install']['min']) ? 0 : (($month - min($value['install']['min'])) < 0 ? 0 : ($month - min($value['install']['min'])));
$value['tryrun']['max'] = empty($value['tryrun']['max']) ? 0 : (($month - max($value['tryrun']['max'])) < 0 ? 0 : ($month - max($value['tryrun']['max'])));
$value['tryrun']['min'] = empty($value['tryrun']['min']) ? 0 : (($month - min($value['tryrun']['min'])) < 0 ? 0 : ($month - min($value['tryrun']['min'])));
$value['check']['max'] = empty($value['check']['max']) ? 0 : (($month - max($value['check']['max'])) < 0 ? 0 : ($month - max($value['check']['max'])));
$value['check']['min'] = empty($value['check']['min']) ? 0 : (($month - min($value['check']['min'])) < 0 ? 0 : ($month - min($value['check']['min'])));
$value['delivery']['max'] = empty($value['delivery']['max']) ? 0 : (($month - max($value['delivery']['max'])) < 0 ? 0 : ($month - max($value['delivery']['max'])));
$value['delivery']['min'] = empty($value['delivery']['min']) ? 0 : (($month - min($value['delivery']['min'])) < 0 ? 0 : ($month - min($value['delivery']['min'])));
$value['final']['max'] = empty($value['final']['max']) ? 0 : (($month - max($value['final']['max'])) < 0 ? 0 : ($month - max($value['final']['max'])));
$value['final']['min'] = empty($value['final']['min']) ? 0 : (($month - min($value['final']['min'])) < 0 ? 0 : ($month - min($value['final']['min'])));
}
// [invoice][發票號碼][0 發票日期, 1 發票金額, 2 發票狀態, 3 收款日期, 4 收款金額, 5 手續費, 6 核銷單號]
foreach ($invoice_data as $invoice) {
if (isset($arrayData[$invoice['ProjectId']])) {
$arrayData[$invoice['ProjectId']]['invoice_budget'] += intval($invoice['OAmountWithTax']);
$arrayData[$invoice['ProjectId']]['invoice'][$invoice['InvoiceNo']] = [date("Ymd", strtotime($invoice['InvoiceTime'])), $invoice['OAmountWithTax'], $invoice['InvoiceState']];
}
}
// array_push($arrayData[$wip['contractno']]['received'], ['assaaa',123124,'sdrfrqa']);
// 把核銷單的內容補到發票資料中
foreach ($received_array as $received) {
if ($received['OrderBillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
} elseif ($received['OrderBillNo'] == 'SO20230801002') {
$BillNo = 'M231067';
} else {
$BillNo = $received['OrderBillNo'];
};
if (isset($arrayData[$BillNo])) {
if (isset($arrayData[$BillNo]['invoice'][$received['InvoiceNo']])) {
$arrayData[$BillNo]['received_budget'] += $received['PayWriteOffOAmount'];
array_push($arrayData[$BillNo]['invoice'][$received['InvoiceNo']], date($received['ReceivedDate']), $received['PayWriteOffOAmount'], $received['Fee'], $received['BillNo']);
}
if (isset($arrayData[$received['OrderBillNo']])) {
array_push($arrayData[$received['OrderBillNo']]['received'], [$received['BillNo'], $received['WriteOffBizPartnerId'], $received['OrderBillNo'],]);
}
}
@ -456,54 +314,30 @@ $data = json_encode($arrayData);
}
</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% ;overflow-x: auto;">
<div style="width:98%;margin:1%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
<tr>
<th style="width: 120px;">合約號</th>
<th style="width: 120px;">部門</th>
<th style="width: 120px;">經理</th>
<th style="width: 120px;">營業員</th>
<th style="width: 120px;">客戶名稱</th>
<th style="width: 120px;">簽約款</th>
<th style="width: 120px;">應收簽約金額</th>
<th style="width: 120px;">簽約最大催收次數</th>
<th style="width: 120px;">簽約最小催收次數</th>
<th style="width: 120px;">二次款</th>
<th style="width: 120px;">應收二次金額</th>
<th style="width: 120px;">二次最大催收次數</th>
<th style="width: 120px;">二次最小催收次數</th>
<th style="width: 120px;">貨抵工地款</th>
<th style="width: 120px;">應收貨抵工地金額</th>
<th style="width: 120px;">貨抵工地最大催收次數</th>
<th style="width: 120px;">貨抵工地最小催收次數</th>
<th style="width: 120px;">安裝款</th>
<th style="width: 120px;">應收安裝金額</th>
<th style="width: 120px;">安裝最大催收次數</th>
<th style="width: 120px;">安裝最小催收次數</th>
<th style="width: 120px;">試車款</th>
<th style="width: 120px;">應收試車金額</th>
<th style="width: 120px;">試車最大催收次數</th>
<th style="width: 120px;">試車最小催收次數</th>
<th style="width: 120px;">官檢款</th>
<th style="width: 120px;">應收官檢金額</th>
<th style="width: 120px;">官檢最大催收次數</th>
<th style="width: 120px;">官檢最小催收次數</th>
<th style="width: 120px;">移交款</th>
<th style="width: 120px;">應收移交金額</th>
<th style="width: 120px;">移交最大催收次數</th>
<th style="width: 120px;">移交最小催收次數</th>
<th style="width: 120px;">尾款</th>
<th style="width: 120px;">應收尾款金額</th>
<th style="width: 120px;">尾款最大催收次數</th>
<th style="width: 120px;">尾款最小催收次數</th>
<th style="width: 120px;">合約總金額</th>
<th style="width: 120px;" style="width: 120px;">目前應收</th>
<th style="width: 120px;" style="width: 120px;">已開發票金額</th>
<th style="width: 120px;">已收金額</th>
<!-- <th>作番狀態</th> -->
<th style="width: 80px;">經理</th>
<th style="width: 80px;">營業員</th>
<th>客戶名稱</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: 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: 100px;">收款狀態</th> -->
<th style="width: 100px;">操作</th>
</tr>
</thead>
<tbody>
@ -516,45 +350,19 @@ $data = json_encode($arrayData);
<td><?= $value[2] ?></td>
<td><?= $value[4] ?></td>
<td><?= $value[5] ?></td>
<td><?= number_format(round($value['sign'][1])) ?></td>
<td style="text-align: end;"><?= isset($value['sign'][3]) ? number_format(round($value['sign'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['sign']['min']) ? $value['sign']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['sign']['max']) ? $value['sign']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['second'][1]) ? number_format(round($value['second'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['second'][3]) ? number_format(round($value['second'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['second']['min']) ? $value['second']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['second']['max']) ? $value['second']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['arrive'][1]) ? number_format(round($value['arrive'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['arrive'][3]) ? number_format(round($value['arrive'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['arrive']['min']) ? $value['arrive']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['arrive']['max']) ? $value['arrive']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['install'][1]) ? number_format(round($value['install'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['install'][3]) ? number_format(round($value['install'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['install']['min']) ? $value['install']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['install']['max']) ? $value['install']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['tryrun'][1]) ? number_format(round($value['tryrun'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['tryrun'][3]) ? number_format(round($value['tryrun'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['tryrun']['min']) ? $value['tryrun']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['tryrun']['max']) ? $value['tryrun']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['check'][1]) ? number_format(round($value['check'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['check'][3]) ? number_format(round($value['check'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['check']['min']) ? $value['check']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['check']['max']) ? $value['check']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['delivery'][1]) ? number_format(round($value['delivery'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['delivery'][3]) ? number_format(round($value['delivery'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['delivery']['min']) ? $value['delivery']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['delivery']['max']) ? $value['delivery']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['final'][1]) ? number_format(round($value['final'][1])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['final'][3]) ? number_format(round($value['final'][3])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['final']['min']) ? $value['final']['min'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['final']['max']) ? $value['final']['max'] : '--' ?></td>
<td style="text-align: end;"><?= isset($value['total_budget']) ? number_format(round($value['total_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['receivable_budget']) ? number_format(round($value['receivable_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['invoice_budget']) ? number_format(round($value['invoice_budget'])) : '--' ?></td>
<td style="text-align: end;"><?= isset($value['received_budget']) ? number_format(round($value['received_budget'])) : '--' ?></td>
<!-- <td style="text-align: start;"><?= $value['facilities'] ?></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> -->
</td>
</tr>
<?php
}
@ -563,7 +371,7 @@ $data = json_encode($arrayData);
</table>
</div>
<script>
function test() {
function downloadData() {
var BillData = <?= $data ?>;
var form = document.createElement("form");
form.method = 'POST';
@ -578,29 +386,6 @@ $data = json_encode($arrayData);
}
function downloadData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $data ?>
}));
}
function sendData(BillNo) {
var BillData = <?= $data ?>;
var Bill = BillData[BillNo];

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

@ -51,29 +51,29 @@ $BillData = json_decode($Bill, true);
<div class="form-group">
<div class="col-md-3">
<label for="InvoiceDate">發票開立日期</label>
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate" >
<input type="date" class="form-control" id="InvoiceDate" name="InvoiceDate">
</div>
<div class="col-md-3">
<label for="InvoiceAmount">發票金額</label>
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount" >
<input type="number" class="form-control" id="InvoiceAmount" name="InvoiceAmount">
</div>
<div class="col-md-3">
<label for="InvoiceNo">發票號碼</label>
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo" >
<input type="text" class="form-control" id="InvoiceNo" name="InvoiceNo">
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="ReceivedDate">收款日期</label>
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate" >
<input type="date" class="form-control" id="ReceivedDate" name="ReceivedDate">
</div>
<div class="col-md-3">
<label for="ReceivedAmount">收款金額</label>
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount" >
<input type="number" class="form-control" id="ReceivedAmount" name="ReceivedAmount">
</div>
<div class="col-md-3">
<label for="remark">備註</label>
<input type="text" class="form-control" id="remark" name="remark" >
<input type="text" class="form-control" id="remark" name="remark">
</div>
</div>

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

@ -89,13 +89,13 @@ $pay = mysqli_fetch_assoc($pay);
<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>
<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>

BIN
wms/account-receivable.xlsx

Binary file not shown.

148
wms/account-record-submit.php

@ -1,75 +1,75 @@
<?php
$id= "";
$accounttype= "";
$accountid= "";
$pwd= "";
$name= "";
$tel= "";
$address= "";
$email= "";
$lineid= "";
$wechatid= "";
$phone_call_help= "";
$chat_for_help= "";
$remote_help= "";
$repairerid= "";
$manager= "";
$creater= "";
$create_at= "";
$id_error = "";
$accounttype_error= "";
$accountid_error= "";
$pwd_error= "";
$name_error= "";
$tel_error= "";
$address_error= "";
$email_error= "";
$lineid_error= "";
$wechatid_error= "";
$phone_call_help_error= "";
$chat_for_help_error= "";
$remote_help_error= "";
$repairerid_error= "";
$manager_error= "";
$creater_error= "";
$create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "account-user-input.php";
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES ";
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
// 新增權限
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
$db_query = "insert into account_auth (accountid, permission) ";
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $db_query);
}
// mysqli_insert_id可以抓到第一筆的id
//$new_id= mysqli_insert_id ($link);
#echo "新增後的id為 {$id} ";
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
// 如果有一筆以上代表有更新
echo "<script>";
echo "alert('新增成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script>";
echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
$id= "";
$accounttype= "";
$accountid= "";
$pwd= "";
$name= "";
$tel= "";
$address= "";
$email= "";
$lineid= "";
$wechatid= "";
$phone_call_help= "";
$chat_for_help= "";
$remote_help= "";
$repairerid= "";
$manager= "";
$creater= "";
$create_at= "";
$id_error = "";
$accounttype_error= "";
$accountid_error= "";
$pwd_error= "";
$name_error= "";
$tel_error= "";
$address_error= "";
$email_error= "";
$lineid_error= "";
$wechatid_error= "";
$phone_call_help_error= "";
$chat_for_help_error= "";
$remote_help_error= "";
$repairerid_error= "";
$manager_error= "";
$creater_error= "";
$create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include "account-user-input.php";
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES ";
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
// 新增權限
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
$db_query = "insert into account_auth (accountid, permission) ";
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $db_query);
}
// mysqli_insert_id可以抓到第一筆的id
//$new_id= mysqli_insert_id ($link);
#echo "新增後的id為 {$id} ";
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
// 如果有一筆以上代表有更新
echo "<script>";
echo "alert('新增成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script>";
echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

130
wms/account-record-update.php

@ -1,66 +1,66 @@
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]);
$pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]);
$email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', ";
$db_query .= "email = '$email', lineid = '$lineid', wechatid = '$wechatid', phone_call_help = '$phone_call_help', chat_for_help = '$chat_for_help', ";
$db_query .= "remote_help = '$remote_help', repairerid = '$repairerid', manager = '$manager', ";
$db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
$sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
$db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'";
mysqli_query($link, $db_query);
}
mysqli_free_result($res);
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]);
$pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]);
$email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE account set pwd = '$pwd', name = '$name', tel = '$tel', address = '$address', ";
$db_query .= "email = '$email', lineid = '$lineid', wechatid = '$wechatid', phone_call_help = '$phone_call_help', chat_for_help = '$chat_for_help', ";
$db_query .= "remote_help = '$remote_help', repairerid = '$repairerid', manager = '$manager', ";
$db_query .= "department_id = '$department_id', role_id = '$role_id', create_at = '$create_at' WHERE id='$id'";
mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
$sql = "select permission from department where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
$db_query = "update account_auth set permission = '$row[0]' where accountid = '$accountid'";
mysqli_query($link, $db_query);
}
mysqli_free_result($res);
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='account-index.php?function_name=account&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

130
wms/account-user-input.php

@ -1,65 +1,65 @@
<?php
//Function to filter the form input
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]);
#$accountid = $accounttype . $accountid;
$pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]);
$email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
/*
if(empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed";
}
}
/*
if(empty($_POST["website"])) {
$website_error = "Website address is required";
} else {
$website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL";
}
}
if(empty($_POST["comment"])) {
$comment = "";
} else {
$comment = user_input($_POST["comment"]);
}
*/
?>
<?php
//Function to filter the form input
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$accounttype = user_input($_POST["accounttype"]);
$accountid = user_input($_POST["accountid"]);
#$accountid = $accounttype . $accountid;
$pwd = user_input($_POST["pwd"]);
$name = user_input($_POST["name"]);
$tel = user_input($_POST["tel"]);
$address = user_input($_POST["address"]);
$email = user_input($_POST["email"]);
$lineid = user_input($_POST["lineid"]);
$wechatid = user_input($_POST["wechatid"]);
$phone_call_help = user_input($_POST["phone_call_help"]);
$chat_for_help = user_input($_POST["chat_for_help"]);
$remote_help = user_input($_POST["remote_help"]);
$repairerid = user_input($_POST["repairerid"]);
$manager = user_input($_POST["manager"]);
$department_id = user_input($_POST["department_id"]);
$role_id = user_input($_POST["role_id"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
/*
if(empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed";
}
}
/*
if(empty($_POST["website"])) {
$website_error = "Website address is required";
} else {
$website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL";
}
}
if(empty($_POST["comment"])) {
$comment = "";
} else {
$comment = user_input($_POST["comment"]);
}
*/
?>

354
wms/account_auth-create.php

@ -1,177 +1,177 @@
<?php
include "header.php";
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
// 選單結構
$data = array();
$db_query = "select * from menu order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$data[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"];
}
mysqli_free_result($res);
//print_r($data);exit;
?>
<style>
table {
margin-top:10px;
}
.table-off, .table-off > td, .table-off > th {
background-color: #d6d8db;
}
.label-checkbox { cursor: pointer; }
</style>
<script>
$(function () {
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
$('#submit').click(function(){
var optRStr = "";
var optRArr = [];
$("input[name=opt_r]").each(function(){
optRStr = "";
optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";X";
optRArr.push(optRStr);
})
$('#opt_r_all').val(optRArr);
var optWStr = "";
var optWArr = [];
$("input[name=opt_w]").each(function(){
optWStr = "";
optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";X";
optWArr.push(optWStr);
})
$('#opt_w_all').val(optWArr);
});
});
</script>
<div class="container">
<?php
include "account_auth-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div>
<label for="department_id">部門</label>
<select name="department_id" required>
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別</label>
<select name="role_id" required>
<?php
foreach ($role_arr[$data2["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th>
<th scope="col">控管</th>
</tr>
</thead>
<tbody>
<?php
foreach($data as $key => $val) {
foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
?>
<tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?>
<td><?php echo $v2["sub_menu"]; ?></td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>">
可讀</label>
<label class="label-checkbox">
<input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>">
可寫</label>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" id="submit" name="submit">確定</button>
</div>
<input type="hidden" name="opt_r_all" id="opt_r_all">
<input type="hidden" name="opt_w_all" id="opt_w_all">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
include "footer.php";
?>
<?php
include "header.php";
// 部門職別
$db_query = "select department_id, name, role_id, role from department order by department_id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$depart_arr[$row["department_id"]] = $row["name"];
$role_arr[$row["department_id"]][$row["role_id"]] = $row["role"];
}
mysqli_free_result($res);
// 選單結構
$data = array();
$db_query = "select * from menu order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$data[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"];
$data[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"];
}
mysqli_free_result($res);
//print_r($data);exit;
?>
<style>
table {
margin-top:10px;
}
.table-off, .table-off > td, .table-off > th {
background-color: #d6d8db;
}
.label-checkbox { cursor: pointer; }
</style>
<script>
$(function () {
var jroleStr = '<?php echo json_encode($role_arr); ?>';
var jroleArr = JSON.parse(jroleStr);
var optStr = "";
$("select[name=department_id]").change(function(){
if ($(this).val() != "") {
optStr = "";
for (var i in jroleArr[$(this).val()]) {
if ('undefined' !== jroleArr[$(this).val()][i]) {
optStr += '<option value="'+i+'">'+jroleArr[$(this).val()][i]+'</option>';
}
}
$("select[name=role_id]").html(optStr);
} else $("select[name=role_id]").html('<option value="">請選擇</option>');
})
$('#submit').click(function(){
var optRStr = "";
var optRArr = [];
$("input[name=opt_r]").each(function(){
optRStr = "";
optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";X";
optRArr.push(optRStr);
})
$('#opt_r_all').val(optRArr);
var optWStr = "";
var optWArr = [];
$("input[name=opt_w]").each(function(){
optWStr = "";
optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";X";
optWArr.push(optWStr);
})
$('#opt_w_all').val(optWArr);
});
});
</script>
<div class="container">
<?php
include "account_auth-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div>
<label for="department_id">部門</label>
<select name="department_id" required>
<option value="">請選擇</option>
<?php
foreach ($depart_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="role_id">職別</label>
<select name="role_id" required>
<?php
foreach ($role_arr[$data2["department_id"]] as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th>
<th scope="col">控管</th>
</tr>
</thead>
<tbody>
<?php
foreach($data as $key => $val) {
foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
?>
<tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?>
<td><?php echo $v2["sub_menu"]; ?></td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_r" value="R" data-auth="<?php echo $key.";".$k2; ?>">
可讀</label>
<label class="label-checkbox">
<input type="checkbox" name="opt_w" value="W" data-auth="<?php echo $key.";".$k2; ?>">
可寫</label>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" id="submit" name="submit">確定</button>
</div>
<input type="hidden" name="opt_r_all" id="opt_r_all">
<input type="hidden" name="opt_w_all" id="opt_w_all">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
include "footer.php";
?>

364
wms/account_auth-edit.php

@ -1,182 +1,182 @@
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// 選單結構
$menu = array();
$db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$menu[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["mlink"] = $row["mlink"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"];
}
mysqli_free_result($res);
$data = array();
// sql语法存在变数中
$db_query = "select * from department where id = '$id'";
// 用mysqli_query方法执行(sql语法)将结果存在变数中
$data = mysqli_query($link,$db_query);
foreach($data as $data) :
$permission_arr = json_decode(urldecode($data["permission"]), true);
$person = "";
$sql = "select accountid, name from account where department_id = '".$data["department_id"]."' and role_id = '".$data["role_id"]."' and accounttype <> 'X'";
$result = mysqli_query($link, $sql);
while ($row_a = mysqli_fetch_row($result)) {
$person .= $row_a[1]."(".$row_a[0].")、";
}
mysqli_free_result($result);
?>
<style>
table {
margin-top:10px;
}
.table-off, .table-off > td, .table-off > th {
background-color: #d6d8db;
}
.label-checkbox {
cursor: pointer;
}
body > div > form > table > thead > tr > th:nth-child(3) > label > span {
font-size:14px;
}
.nextline {
width: 100%;
height: 0;
}
</style>
<script>
$(function () {
$("input[name=rall]").click(function(){
$("input[name=opt_r]").not(this).prop('checked', this.checked);
});
$("input[name=wall]").click(function(){
$("input[name=opt_w]").not(this).prop('checked', this.checked);
});
$('#update').click(function(){
var optRStr = "";
var optRArr = [];
$("input[name=opt_r]").each(function(){
optRStr = "";
optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";0";
optRArr.push(optRStr);
})
$('#opt_r_all').val(optRArr);
var optWStr = "";
var optWArr = [];
$("input[name=opt_w]").each(function(){
optWStr = "";
optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";0";
optWArr.push(optWStr);
})
$('#opt_w_all').val(optWArr);
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="account_auth-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="department_name">部門</label>
<input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly>
</div>
<div>
<label for="role_name">職別</label>
<input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th>
<th scope="col">
<label class="label-checkbox"><input type="checkbox" name="rall">
全選</label>
</th>
<th scope="col">
<label class="label-checkbox"><input type="checkbox" name="wall">
全選</label>
</th>
</tr>
</thead>
<tbody>
<?php
foreach($menu as $key => $val) {
foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
$chk_r = $chk_w = "";
if (!empty($permission_arr[$v2["mlink"]])) {
if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked";
if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked";
}
?>
<tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?>
<td>
<?php echo $v2["sub_menu"]; ?>
</td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>>
可讀</label>
</td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>>
可寫</label>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div>
<label>所屬人員</label>
<textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea>
</div>
<div class="nextline"></div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="opt_r_all" id="opt_r_all">
<input type="hidden" name="opt_w_all" id="opt_w_all">
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data["department_id"]; ?>">
<input type="hidden" name="role_id" id="role_id" value="<?php echo $data["role_id"]; ?>">
<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>
<?php
endforeach;
include "footer.php";
?>
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// 選單結構
$menu = array();
$db_query = "select * from menu where status = 'Y' order by main_menu_seq, sub_menu_seq";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res)) {
$menu[$row["main_menu_seq"]]["main_menu"] = $row["main_menu"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["sub_menu"] = $row["sub_menu"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["mlink"] = $row["mlink"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["link_content"] = $row["link_content"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["status"] = $row["status"];
$menu[$row["main_menu_seq"]][$row["sub_menu_seq"]]["id"] = $row["id"];
}
mysqli_free_result($res);
$data = array();
// sql语法存在变数中
$db_query = "select * from department where id = '$id'";
// 用mysqli_query方法执行(sql语法)将结果存在变数中
$data = mysqli_query($link,$db_query);
foreach($data as $data) :
$permission_arr = json_decode(urldecode($data["permission"]), true);
$person = "";
$sql = "select accountid, name from account where department_id = '".$data["department_id"]."' and role_id = '".$data["role_id"]."' and accounttype <> 'X'";
$result = mysqli_query($link, $sql);
while ($row_a = mysqli_fetch_row($result)) {
$person .= $row_a[1]."(".$row_a[0].")、";
}
mysqli_free_result($result);
?>
<style>
table {
margin-top:10px;
}
.table-off, .table-off > td, .table-off > th {
background-color: #d6d8db;
}
.label-checkbox {
cursor: pointer;
}
body > div > form > table > thead > tr > th:nth-child(3) > label > span {
font-size:14px;
}
.nextline {
width: 100%;
height: 0;
}
</style>
<script>
$(function () {
$("input[name=rall]").click(function(){
$("input[name=opt_r]").not(this).prop('checked', this.checked);
});
$("input[name=wall]").click(function(){
$("input[name=opt_w]").not(this).prop('checked', this.checked);
});
$('#update').click(function(){
var optRStr = "";
var optRArr = [];
$("input[name=opt_r]").each(function(){
optRStr = "";
optRStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optRStr += ";"+$(this).val();
else optRStr += ";0";
optRArr.push(optRStr);
})
$('#opt_r_all').val(optRArr);
var optWStr = "";
var optWArr = [];
$("input[name=opt_w]").each(function(){
optWStr = "";
optWStr += $(this).attr('data-auth');
if ($(this).prop('checked')) optWStr += ";"+$(this).val();
else optWStr += ";0";
optWArr.push(optWStr);
})
$('#opt_w_all').val(optWArr);
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="account_auth-record-update.php">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="department_name">部門</label>
<input type="text" name="department_name" id="department_name" value="<?php echo $data['name']; ?>" readonly>
</div>
<div>
<label for="role_name">職別</label>
<input type="text" name="role_name" id="role_name" value="<?php echo $data['role']; ?>" readonly>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">主功能名稱</th>
<th scope="col">子功能名稱</th>
<th scope="col">
<label class="label-checkbox"><input type="checkbox" name="rall">
全選</label>
</th>
<th scope="col">
<label class="label-checkbox"><input type="checkbox" name="wall">
全選</label>
</th>
</tr>
</thead>
<tbody>
<?php
foreach($menu as $key => $val) {
foreach($val as $k2 => $v2) {
if ($k2 == "main_menu") continue;
$td_str = ($k2 == 1) ? '<td rowspan="'.(count($val)-1).'">'.$val["main_menu"].'</td>' : '';
$sta_str = ($v2["status"] == "Y") ? '' : ' class="table-off"';
$chk_r = $chk_w = "";
if (!empty($permission_arr[$v2["mlink"]])) {
if ($permission_arr[$v2["mlink"]]&1) $chk_r = " checked";
if ($permission_arr[$v2["mlink"]]&2) $chk_w = " checked";
}
?>
<tr<?php echo $sta_str; ?>>
<?php echo $td_str; ?>
<td>
<?php echo $v2["sub_menu"]; ?>
</td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_r" value="1" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_r; ?>>
可讀</label>
</td>
<td>
<label class="label-checkbox">
<input type="checkbox" name="opt_w" value="2" data-auth="<?php echo $v2["id"]; ?>"<?php echo $chk_w; ?>>
可寫</label>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<div>
<label>所屬人員</label>
<textarea name="person-info" rows="6" cols="70" class="form-control" readonly><?php echo rtrim($person, "、"); ?></textarea>
</div>
<div class="nextline"></div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="opt_r_all" id="opt_r_all">
<input type="hidden" name="opt_w_all" id="opt_w_all">
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data["department_id"]; ?>">
<input type="hidden" name="role_id" id="role_id" value="<?php echo $data["role_id"]; ?>">
<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>
<?php
endforeach;
include "footer.php";
?>

208
wms/account_auth-index.php

@ -1,105 +1,105 @@
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql = "select * from department order by department_id, role_id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<!--
<p>
<a href="account_auth-create.php?function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
-->
<?php
if($data):
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['department_id']; ?></td>
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['role_id']; ?></td>
<td><?php echo $data['role']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<a href="account_auth-edit.php?id=<?php echo $data['id']; ?>&function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql = "select * from department order by department_id, role_id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<!--
<p>
<a href="account_auth-create.php?function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
-->
<?php
if($data):
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['department_id']; ?></td>
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['role_id']; ?></td>
<td><?php echo $data['role']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<a href="account_auth-edit.php?id=<?php echo $data['id']; ?>&function_name=account_auth&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

128
wms/account_auth-record-update.php

@ -1,65 +1,65 @@
<?php
include "header.php";
if(isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);exit;
// 選單各功能的權限
$prog_arr = [];
$opt_r_arr = explode(",", $opt_r_all);
$opt_w_arr = explode(",", $opt_w_all);
foreach ($opt_r_arr as $key => $val) {
list($menu_id, $auth_r) = explode(";", $val);
list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]);
// 找出相關程式
$sql = "select link_content from menu where id = '$menu_id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) {
if ($row["link_content"]) {
$tmp_arr = explode("\r\n", $row["link_content"]);
foreach ($tmp_arr as $v) {
$prog_arr[$v] = $auth_r|$auth_w;
}
}
}
mysqli_free_result($res);
if (($key%10)==0) usleep(200000);
}
// 開始更新權限
$permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES);
$sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'";
mysqli_query($link, $sql);
$affected = mysqli_affected_rows($link);
// 更新user權限
$sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') ";
$db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'";
$res_u = mysqli_query($link, $db_query);
}
mysqli_free_result($res);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
include "header.php";
if(isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);exit;
// 選單各功能的權限
$prog_arr = [];
$opt_r_arr = explode(",", $opt_r_all);
$opt_w_arr = explode(",", $opt_w_all);
foreach ($opt_r_arr as $key => $val) {
list($menu_id, $auth_r) = explode(";", $val);
list($menu_id, $auth_w) = explode(";", $opt_w_arr[$key]);
// 找出相關程式
$sql = "select link_content from menu where id = '$menu_id'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_assoc($res)) {
if ($row["link_content"]) {
$tmp_arr = explode("\r\n", $row["link_content"]);
foreach ($tmp_arr as $v) {
$prog_arr[$v] = $auth_r|$auth_w;
}
}
}
mysqli_free_result($res);
if (($key%10)==0) usleep(200000);
}
// 開始更新權限
$permission = json_encode($prog_arr, JSON_UNESCAPED_SLASHES);
$sql = "update department set permission = '$permission', create_at = '$create_at' where id = '$id'";
mysqli_query($link, $sql);
$affected = mysqli_affected_rows($link);
// 更新user權限
$sql = "select accountid from account where department_id = '$department_id' and role_id = '$role_id'";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$db_query = "insert into account_auth (accountid, permission) values ('$row[0]', '$permission') ";
$db_query .= "ON DUPLICATE KEY UPDATE accountid = '$row[0]', permission = '$permission'";
$res_u = mysqli_query($link, $db_query);
}
mysqli_free_result($res);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='account_auth-index.php?function_name=account_auth&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

BIN
wms/assets/img/icon/(Ñ╝¿╧Ñ╬)icon-star-active.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
wms/assets/img/icon/(Ñ╝¿╧Ñ╬)icon-star-default.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

624
wms/bargain-create.php

@ -1,313 +1,313 @@
<?php
include "header.php";
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$bargainno = $row[0] ? $row[0]+1 : date("Ym")."001";
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($department_id) = $row;
mysqli_free_result($res);
$department_arr = [];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
?>
<style>
</style>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
$(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$('#btnadd').click(function(){
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end());
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='supplier_templ']").length);
});
$('#submit').click(function(){
var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr);
var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr);
var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr);
var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr);
//console.log(itemNameArr);
//return false;
});
});
</script>
<div class="container">
<?php
include "bargain-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly>
</div>
<div>
<label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$department_id]; ?>" readonly>
<input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?>">
</div>
<div>
<label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly>
</div>
<div>
<label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required>
<option value="">請選擇</option>
<?php
foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" required>
</div>
<div>
<label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" required>
</div>
<div>
<label for="annual">年度議價件</label>
<select name="annual" id="annual">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="urgent">緊急件</label>
<select name="urgent" id="urgent">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="vendor">指定廠商</label>
<select name="vendor" id="vendor">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="category">類別</label>
<select name="category" id="category" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required>
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50">
</div>
<div>
<label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25">
</div>
<div>
<label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25">
</div>
<div>
<label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" required>
</div>
<div>
<label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25">
</div>
<div>
<label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time">
</div>
<div>
<label for="margin">質保金</label>
<select name="margin" id="margin">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" required>
</div>
<div>
<label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50">
</div>
<div>
<label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="attatch1">附件1</label>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="attatch2">附件2</label>
<div>
<input type="file" name="attatch2" id="attatch2">
</div>
</div>
<div>
<label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120">
</div>
<div>
<label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20">
</div>
<div>
<label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea>
</div>
<div>
<label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" readonly>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr>
<tr>
<th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th>
</tr>
<tr>
<th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th>
<th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th>
<th nowrap>備註</th>
</tr>
</thead>
<tbody>
<tr name="supplier_templ">
<td>1</td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_be[]" multiple></td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_ar[]" multiple></td>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr>
</tbody>
</table>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit" id="submit">確定</button>
</div>
<input type="hidden" name="sup_id_all" id="sup_id_all">
<input type="hidden" name="supplier_all" id="supplier_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_be_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_ar_all">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
include "header.php";
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$bargainno = $row[0] ? $row[0]+1 : date("Ym")."001";
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($department_id) = $row;
mysqli_free_result($res);
$department_arr = [];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
?>
<style>
</style>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
$(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$('#btnadd').click(function(){
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end());
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='supplier_templ']").length);
});
$('#submit').click(function(){
var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr);
var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr);
var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr);
var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr);
//console.log(itemNameArr);
//return false;
});
});
</script>
<div class="container">
<?php
include "bargain-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $bargainno; ?>" readonly>
</div>
<div>
<label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$department_id]; ?>" readonly>
<input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?>">
</div>
<div>
<label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $user_name; ?>" readonly>
</div>
<div>
<label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required>
<option value="">請選擇</option>
<?php
foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" required>
</div>
<div>
<label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" required>
</div>
<div>
<label for="annual">年度議價件</label>
<select name="annual" id="annual">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="urgent">緊急件</label>
<select name="urgent" id="urgent">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="vendor">指定廠商</label>
<select name="vendor" id="vendor">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="category">類別</label>
<select name="category" id="category" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required>
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50">
</div>
<div>
<label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25">
</div>
<div>
<label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25">
</div>
<div>
<label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" required>
</div>
<div>
<label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25">
</div>
<div>
<label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time">
</div>
<div>
<label for="margin">質保金</label>
<select name="margin" id="margin">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" required>
</div>
<div>
<label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50">
</div>
<div>
<label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history">
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
<div>
<label for="attatch1">附件1</label>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="attatch2">附件2</label>
<div>
<input type="file" name="attatch2" id="attatch2">
</div>
</div>
<div>
<label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120">
</div>
<div>
<label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20">
</div>
<div>
<label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"></textarea>
</div>
<div>
<label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" readonly>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr>
<tr>
<th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th>
</tr>
<tr>
<th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th>
<th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th>
<th nowrap>備註</th>
</tr>
</thead>
<tbody>
<tr name="supplier_templ">
<td>1</td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_be[]" multiple></td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_ar[]" multiple></td>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr>
</tbody>
</table>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit" id="submit">確定</button>
</div>
<input type="hidden" name="sup_id_all" id="sup_id_all">
<input type="hidden" name="supplier_all" id="supplier_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_be_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_ar_all">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>

56
wms/bargain-delete.php

@ -1,29 +1,29 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
/* 已進入簽核流程
$db_query = "select checker_1_result from bargin where id = '$id'";
$res = mysqli_query($link, $db_query);
$row = mysqli_fetch_array($res, MYSQLI_ASSOC);
if (!$row || $row["checker_1_result"]) {
mysqli_free_result($res);
mysqli_close($link);
echo "<script>";
//echo "alert('審核中,已無法刪除');";
echo "alert('資料無法刪除');";
echo "location.href='pricereview-index.php'";
echo "</script>";
exit;
}
*/
$db_query = "delete from bargain_supplier where bid = '$id'";
if ($rs = mysqli_query($link, $db_query)) {
$db_query = "delete from bargain where id = '$id'";
mysqli_query($link, $db_query);
}
header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link);
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
/* 已進入簽核流程
$db_query = "select checker_1_result from bargin where id = '$id'";
$res = mysqli_query($link, $db_query);
$row = mysqli_fetch_array($res, MYSQLI_ASSOC);
if (!$row || $row["checker_1_result"]) {
mysqli_free_result($res);
mysqli_close($link);
echo "<script>";
//echo "alert('審核中,已無法刪除');";
echo "alert('資料無法刪除');";
echo "location.href='pricereview-index.php'";
echo "</script>";
exit;
}
*/
$db_query = "delete from bargain_supplier where bid = '$id'";
if ($rs = mysqli_query($link, $db_query)) {
$db_query = "delete from bargain where id = '$id'";
mysqli_query($link, $db_query);
}
header("Refresh:0; url=bargain-index.php?function_name=bargain&".$token_link);
ob_end_flush();
?>

748
wms/bargain-edit.php

@ -1,375 +1,375 @@
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$db_query = "select * from bargain where id = '$id'";
$data = mysqli_query($link, $db_query);
$department_arr = [];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
foreach($data as $data) :
$sql = "select name from account where accountid = '".$data['creater']."'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($creater_name) = $row;
mysqli_free_result($res);
$item_arr = [];
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$item_arr[$row['supplier_id']]['id'] = $row['id'];
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier'];
$item_arr[$row['supplier_id']]['supplier_attatch_be'] = $row['supplier_attatch_be'];
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_be'];
$item_arr[$row['supplier_id']]['note_be'] = $row['note_be'];
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar'];
$item_arr[$row['supplier_id']]['quote_amt_ar'] = $row['quote_amt_ar'];
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar'];
}
mysqli_free_result($res);
?>
<style>
</style>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
$(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$('#btnadd').click(function(){
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show();
else {
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end());
//$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length);
}
});
$('#update').click(function(){
var bsidArr = [];
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); })
$('#bsid_all').val(bsidArr);
var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr);
var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr);
var supplierAttatchBeAllArr = [];
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); })
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr);
var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr);
var supplierAttatchArArr = [];
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); })
$('#supplier_attatch_ar_all').val(supplierAttatchArArr);
var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr);
//console.log(noteArArr);
//return false;
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data">
<div>
<label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly>
</div>
<div>
<label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled>
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>">
</div>
<div>
<label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled>
</div>
<div>
<label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required>
<option value="">請選擇</option>
<?php
foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["receiver"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required>
</div>
<div>
<label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required>
</div>
<div>
<label for="annual">年度議價件</label>
<select name="annual" id="annual">
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="urgent">緊急件</label>
<select name="urgent" id="urgent">
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="vendor">指定廠商</label>
<select name="vendor" id="vendor">
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting">
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="category">類別</label>
<select name="category" id="category" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required>
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>">
</div>
<div>
<label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>">
</div>
<div>
<label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>">
</div>
<div>
<label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required>
</div>
<div>
<label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>">
</div>
<div>
<label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>">
</div>
<div>
<label for="margin">質保金</label>
<select name="margin" id="margin">
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required>
</div>
<div>
<label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>">
</div>
<div>
<label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history">
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="attatch1">附件1</label>
<?php
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="attatch2">附件2</label>
<?php
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch2" id="attatch2">
</div>
</div>
<div>
<label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>">
</div>
<div>
<label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>">
</div>
<div>
<label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category_repair"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea>
</div>
<div>
<label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr>
<tr>
<th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th>
</tr>
<tr>
<th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th>
<th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th>
<th nowrap>備註</th>
</tr>
</thead>
<tbody>
<?php
foreach ($item_arr as $supplier_id => $val) {
?>
<tr>
<td><?php echo $supplier_id; ?><input type="hidden" name="sup_id" value="<?php echo $supplier_id; ?>"><input type="hidden" name="bsid" value="<?php echo $val['id']; ?>"></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_be']) echo "<a href=\"".$val['supplier_attatch_be']."\" target=\"_blank\">".substr($val['supplier_attatch_be'], strrpos($val['supplier_attatch_be'],"/")+1)."</a>";
else echo "--";
?>
</td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_be']); ?>"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_ar']) echo "<a href=\"".$val['supplier_attatch_ar']."\" target=\"_blank\">".substr($val['supplier_attatch_ar'], strrpos($val['supplier_attatch_ar'],"/")+1)."</a>";
else echo "--";
?>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_ar']); ?>"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td>
</tr>
<?php
}
?>
<tr name="supplier_templ" style="display:none;">
<td></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_be[]" multiple></td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_ar[]" multiple></td>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr>
</tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr>
</tbody>
</table>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="bsid_all" id="bsid_all">
<input type="hidden" name="sup_id_all" id="sup_id_all">
<input type="hidden" name="supplier_all" id="supplier_all">
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_be_all">
<input type="hidden" name="supplier_attatch_ar_all" id="supplier_attatch_ar_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_ar_all">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$db_query = "select * from bargain where id = '$id'";
$data = mysqli_query($link, $db_query);
$department_arr = [];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
foreach($data as $data) :
$sql = "select name from account where accountid = '".$data['creater']."'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($creater_name) = $row;
mysqli_free_result($res);
$item_arr = [];
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$item_arr[$row['supplier_id']]['id'] = $row['id'];
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier'];
$item_arr[$row['supplier_id']]['supplier_attatch_be'] = $row['supplier_attatch_be'];
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_be'];
$item_arr[$row['supplier_id']]['note_be'] = $row['note_be'];
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar'];
$item_arr[$row['supplier_id']]['quote_amt_ar'] = $row['quote_amt_ar'];
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar'];
}
mysqli_free_result($res);
?>
<style>
</style>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
$(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$('#btnadd').click(function(){
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show();
else {
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end());
//$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length);
}
});
$('#update').click(function(){
var bsidArr = [];
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); })
$('#bsid_all').val(bsidArr);
var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr);
var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr);
var supplierAttatchBeAllArr = [];
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); })
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr);
var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr);
var supplierAttatchArArr = [];
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); })
$('#supplier_attatch_ar_all').val(supplierAttatchArArr);
var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr);
//console.log(noteArArr);
//return false;
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data">
<div>
<label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly>
</div>
<div>
<label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled>
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>">
</div>
<div>
<label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled>
</div>
<div>
<label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required>
<option value="">請選擇</option>
<?php
foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["receiver"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required>
</div>
<div>
<label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required>
</div>
<div>
<label for="annual">年度議價件</label>
<select name="annual" id="annual">
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="urgent">緊急件</label>
<select name="urgent" id="urgent">
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="vendor">指定廠商</label>
<select name="vendor" id="vendor">
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting">
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="category">類別</label>
<select name="category" id="category" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required>
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>">
</div>
<div>
<label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>">
</div>
<div>
<label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>">
</div>
<div>
<label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required>
</div>
<div>
<label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>">
</div>
<div>
<label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>">
</div>
<div>
<label for="margin">質保金</label>
<select name="margin" id="margin">
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required>
</div>
<div>
<label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>">
</div>
<div>
<label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history">
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>></option>
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="attatch1">附件1</label>
<?php
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="attatch2">附件2</label>
<?php
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch2" id="attatch2">
</div>
</div>
<div>
<label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>">
</div>
<div>
<label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>">
</div>
<div>
<label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category_repair"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea>
</div>
<div>
<label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr>
<tr>
<th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th>
</tr>
<tr>
<th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th>
<th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th>
<th nowrap>備註</th>
</tr>
</thead>
<tbody>
<?php
foreach ($item_arr as $supplier_id => $val) {
?>
<tr>
<td><?php echo $supplier_id; ?><input type="hidden" name="sup_id" value="<?php echo $supplier_id; ?>"><input type="hidden" name="bsid" value="<?php echo $val['id']; ?>"></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_be']) echo "<a href=\"".$val['supplier_attatch_be']."\" target=\"_blank\">".substr($val['supplier_attatch_be'], strrpos($val['supplier_attatch_be'],"/")+1)."</a>";
else echo "--";
?>
</td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_be']); ?>"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_ar']) echo "<a href=\"".$val['supplier_attatch_ar']."\" target=\"_blank\">".substr($val['supplier_attatch_ar'], strrpos($val['supplier_attatch_ar'],"/")+1)."</a>";
else echo "--";
?>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_ar']); ?>"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td>
</tr>
<?php
}
?>
<tr name="supplier_templ" style="display:none;">
<td></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_be[]" multiple></td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_ar[]" multiple></td>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr>
</tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr>
</tbody>
</table>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="bsid_all" id="bsid_all">
<input type="hidden" name="sup_id_all" id="sup_id_all">
<input type="hidden" name="supplier_all" id="supplier_all">
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_be_all">
<input type="hidden" name="supplier_attatch_ar_all" id="supplier_attatch_ar_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_ar_all">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>

286
wms/bargain-index.php

@ -1,144 +1,144 @@
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
// sql語法存在變數中
$sql = "select * from bargain order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<p>
<a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
if($data):
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:bargain-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>品牌</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['bargainno']; ?></td>
<td><?php echo $department_arr[$data['department_id']]; ?></td>
<td><?php echo $data['proposer']; ?></td>
<td><?php echo $department_arr[$data['receiver']]; ?></td>
<td><?php echo $data['response_dt']; ?></td>
<td><?php echo $data['item']; ?></td>
<td><?php echo $category_arr[$data['category']]; ?></td>
<td><?php echo $data['brand']; ?></td>
<td><?php echo $data['model']; ?></td>
<td><?php echo number_format($data['quantity']); ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<a href="bargain-edit.php?id=<?php echo $data['id']; ?>&function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="bargain-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" 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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
// sql語法存在變數中
$sql = "select * from bargain order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<p>
<a href="bargain-create.php?function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
if($data):
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:bargain-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>品牌</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['bargainno']; ?></td>
<td><?php echo $department_arr[$data['department_id']]; ?></td>
<td><?php echo $data['proposer']; ?></td>
<td><?php echo $department_arr[$data['receiver']]; ?></td>
<td><?php echo $data['response_dt']; ?></td>
<td><?php echo $data['item']; ?></td>
<td><?php echo $category_arr[$data['category']]; ?></td>
<td><?php echo $data['brand']; ?></td>
<td><?php echo $data['model']; ?></td>
<td><?php echo number_format($data['quantity']); ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<a href="bargain-edit.php?id=<?php echo $data['id']; ?>&function_name=bargain&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="bargain-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" 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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

296
wms/bargain-record-submit.php

@ -1,149 +1,149 @@
<?php
$accountid= "";
$facilityno= "";
$issue_time= "";
$process= "";
$memo= "";
$creater= "";
$create_at= "";
$accountid_error= "";
$facilityno_error= "";
$issue_time_error= "";
$process_error= "";
$memo_error= "";
$creater_error= "";
$create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST);
//print_r($_FILES);exit;
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
$sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001";
if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check;
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
} else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
} else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "insert into bargain (bargainno, department_id, proposer, receiver, response_dt, item, annual, urgent, vendor, prospecting, category, ";
$db_query .= "dealer, reason, brand, model, quantity, brandkeep, lead_time, margin, margin_day, acceptance, purchase_history, ";
$db_query .= "attatch1, attatch2, item_description, repairno, category_repair, content, quotation, creater, create_at) values (";
$db_query .= "'$bargainno', '$department_id', '$proposer', '$receiver', '$response_dt', '$item', '$annual', '$urgent', '$vendor', '$prospecting', '$category', ";
$db_query .= "'$dealer', '$reason', '$brand', '$model', '$quantity', '$brandkeep', '$lead_time', '$margin', '$margin_day', '$acceptance', '$purchase_history', ";
$db_query .= "'$target_file1', '$target_file2', '$item_description', '$repairno', '$category_repair', '$content', '$quotation', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") {
$bid = mysqli_insert_id($link);
$sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", $supplier_all);
$quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all);
$item_no = 1;
for ($i=0; $i<count($supplier_arr); $i++) {
if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0;
if (!$supplier_arr[$i]) continue;
if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_be"]["size"][$i];
$target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
} else $target_file_be = "";
if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$i];
$target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
} else $target_file_ar = "";
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
$sql = "delete from bargain where id = '$bid'";
mysqli_query($link, $sql);
$sql = "delete from bargain_supplier where bid = '$bid'";
mysqli_query($link, $sql);
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]);
$quote_amt_ar_all[$i] = str_replace(",", "", $quote_amt_ar_all[$i]);
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, ";
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values (";
$db_query .= "'$bid', '$item_no', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', ";
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$item_no++;
}
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功(申請單號:".$bargainno.")');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
$accountid= "";
$facilityno= "";
$issue_time= "";
$process= "";
$memo= "";
$creater= "";
$create_at= "";
$accountid_error= "";
$facilityno_error= "";
$issue_time_error= "";
$process_error= "";
$memo_error= "";
$creater_error= "";
$create_at_error= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST);
//print_r($_FILES);exit;
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
$sql = "select max(bargainno) as maxno from bargain";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$bargainno_check = $row[0] ? $row[0]+1 : date("Ym")."001";
if ($bargainno_check <> $bargainno) $bargainno = $bargainno_check;
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
} else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
} else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "insert into bargain (bargainno, department_id, proposer, receiver, response_dt, item, annual, urgent, vendor, prospecting, category, ";
$db_query .= "dealer, reason, brand, model, quantity, brandkeep, lead_time, margin, margin_day, acceptance, purchase_history, ";
$db_query .= "attatch1, attatch2, item_description, repairno, category_repair, content, quotation, creater, create_at) values (";
$db_query .= "'$bargainno', '$department_id', '$proposer', '$receiver', '$response_dt', '$item', '$annual', '$urgent', '$vendor', '$prospecting', '$category', ";
$db_query .= "'$dealer', '$reason', '$brand', '$model', '$quantity', '$brandkeep', '$lead_time', '$margin', '$margin_day', '$acceptance', '$purchase_history', ";
$db_query .= "'$target_file1', '$target_file2', '$item_description', '$repairno', '$category_repair', '$content', '$quotation', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") {
$bid = mysqli_insert_id($link);
$sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", $supplier_all);
$quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all);
$item_no = 1;
for ($i=0; $i<count($supplier_arr); $i++) {
if (!$sup_id_arr[$i]) $sup_id_arr[$i] = 0;
if (!$supplier_arr[$i]) continue;
if ($_FILES["supplier_attatch_be"]["name"][$i] && ($_FILES["supplier_attatch_be"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_be"]["size"][$i];
$target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
} else $target_file_be = "";
if ($_FILES["supplier_attatch_ar"]["name"][$i] && ($_FILES["supplier_attatch_ar"]["error"][$i] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$i];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$i];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$i];
$target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$item_no."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
} else $target_file_ar = "";
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
$sql = "delete from bargain where id = '$bid'";
mysqli_query($link, $sql);
$sql = "delete from bargain_supplier where bid = '$bid'";
mysqli_query($link, $sql);
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$quote_amt_be_arr[$i] = str_replace(",", "", $quote_amt_be_arr[$i]);
$quote_amt_ar_all[$i] = str_replace(",", "", $quote_amt_ar_all[$i]);
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, ";
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values (";
$db_query .= "'$bid', '$item_no', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', ";
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$item_no++;
}
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功(申請單號:".$bargainno.")');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

286
wms/bargain-record-update.php

@ -1,144 +1,144 @@
<?php
include "header.php";
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);
//print_r($_FILES);exit;
$sql_atta = "";
$quantity = str_replace(",", "", $quantity);
$lead_time = str_replace(",", "", $lead_time);
$margin_day = str_replace(",", "", $margin_day);
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "attatch1 = '$target_file1', ";
} else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
$sql_atta .= "attatch2 = '$target_file2', ";
} else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "update bargain set receiver = '$receiver', response_dt = '$response_dt', item = '$item', annual = '$annual', urgent = '$urgent', ";
$db_query .= "vendor = '$vendor', prospecting = '$prospecting', category = '$category', dealer = '$dealer', reason = '$reason', brand = '$brand', ";
$db_query .= "model = '$model', quantity = '$quantity', brandkeep = '$brandkeep', lead_time = '$lead_time', margin = '$margin', margin_day = '$margin_day', ";
$db_query .= "acceptance = '$acceptance', purchase_history = '$purchase_history', item_description = '$item_description', repairno = '$repairno', ";
$db_query .= $sql_atta;
$db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' ";
$db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") {
$bsid_arr = explode(",", $bsid_all);
$sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", rtrim($supplier_all, ","));
$quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all);
$item_no = 1;
// 有新增的供應商
$new_sup_cnt = count($supplier_arr) - count($bsid_arr);
if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1;
$idx = 0;
for ($i=0; $i<count($supplier_arr); $i++) {
if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增
$target_file_be = $target_file_ar = "";
if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_be"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
}
}
if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
}
}
if ($upload_res_be || $upload_res_ar) $idx++;
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, ";
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values (";
$db_query .= "'$id', '$next_sup_id', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', ";
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$next_sup_id++;
} else { // 修改(不支援重傳檔案)
$db_query = "update bargain_supplier set supplier = '$supplier_arr[$i]', quote_amt_be = '$quote_amt_be_arr[$i]', ";
$db_query .= "note_be = '$note_be_arr[$i]', quote_amt_ar = '$quote_amt_ar_arr[$i]', ";
$db_query .= "note_ar = '$note_ar_arr[$i]', create_at = '$create_at' ";
$db_query .= "where id = '$bsid_arr[$i]'";
$result = mysqli_query($link, $db_query);
}
}
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
include "header.php";
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);
//print_r($_FILES);exit;
$sql_atta = "";
$quantity = str_replace(",", "", $quantity);
$lead_time = str_replace(",", "", $lead_time);
$margin_day = str_replace(",", "", $margin_day);
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "bargain-uploads/";
$target_file1 = strtolower($target_dir.$bargainno."-1-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file1)) unlink($target_file1);
foreach (glob($target_dir.$bargainno."-1-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "attatch1 = '$target_file1', ";
} else $target_file1 = "";
if ($_FILES["attatch2"]["error"] == 0) {
$file_name = $_FILES["attatch2"]["name"];
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$target_dir = "bargain-uploads/";
$target_file2 = strtolower($target_dir.$bargainno."-2-".basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
//if (file_exists($target_file2)) unlink($target_file2);
foreach (glob($target_dir.$bargainno."-2-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
$sql_atta .= "attatch2 = '$target_file2', ";
} else $target_file2 = "";
if (($target_file1 && !$upload_res_1) || ($target_file2 && !$upload_res_2)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "update bargain set receiver = '$receiver', response_dt = '$response_dt', item = '$item', annual = '$annual', urgent = '$urgent', ";
$db_query .= "vendor = '$vendor', prospecting = '$prospecting', category = '$category', dealer = '$dealer', reason = '$reason', brand = '$brand', ";
$db_query .= "model = '$model', quantity = '$quantity', brandkeep = '$brandkeep', lead_time = '$lead_time', margin = '$margin', margin_day = '$margin_day', ";
$db_query .= "acceptance = '$acceptance', purchase_history = '$purchase_history', item_description = '$item_description', repairno = '$repairno', ";
$db_query .= $sql_atta;
$db_query .= "category_repair = '$category_repair', content = '$content', quotation = '$quotation', create_dt = '$create_at' ";
$db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
if ($result && $sup_id_all != "") {
$bsid_arr = explode(",", $bsid_all);
$sup_id_arr = explode(",", $sup_id_all);
$supplier_arr = explode(",", rtrim($supplier_all, ","));
$quote_amt_be_arr = explode(",", $quote_amt_be_all);
$note_be_arr = explode(",", $note_be_all);
$quote_amt_ar_arr = explode(",", $quote_amt_ar_all);
$note_ar_arr = explode(",", $note_ar_all);
$item_no = 1;
// 有新增的供應商
$new_sup_cnt = count($supplier_arr) - count($bsid_arr);
if ($new_sup_cnt > 0) $next_sup_id = max($sup_id_arr)+1;
$idx = 0;
for ($i=0; $i<count($supplier_arr); $i++) {
if ($new_sup_cnt > 0 && $bsid_arr[$i] == "") { // 新增
$target_file_be = $target_file_ar = "";
if ($_FILES["supplier_attatch_be"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_be"]["name"][$idx] && ($_FILES["supplier_attatch_be"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_be"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_be"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_be"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/";
$target_file_be = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_be, PATHINFO_EXTENSION);
$upload_res_be = move_uploaded_file($temp_file_name, $target_file_be);
}
}
if ($_FILES["supplier_attatch_ar"]["name"]) { // 有上傳檔案
if ($_FILES["supplier_attatch_ar"]["name"][$idx] && ($_FILES["supplier_attatch_ar"]["error"][$idx] == 0)) {
$file_name = $_FILES["supplier_attatch_ar"]["name"][$idx];
$temp_file_name = $_FILES["supplier_attatch_ar"]["tmp_name"][$idx];
$file_size = $_FILES["supplier_attatch_ar"]["size"][$idx];
$target_dir = "bargain-uploads/supplier/";
$target_file_ar = strtolower($target_dir.$bargainno."-".$next_sup_id."-".basename($file_name));
$upload_ok = 1;
$img_file_type = pathinfo($target_file_ar, PATHINFO_EXTENSION);
$upload_res_ar = move_uploaded_file($temp_file_name, $target_file_ar);
}
}
if ($upload_res_be || $upload_res_ar) $idx++;
if (($target_file_be && !$upload_res_be) || ($target_file_ar && !$upload_res_ar)) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作!".$sql."');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
}
$db_query = "insert into bargain_supplier (bid, supplier_id, supplier, supplier_attatch_be, quote_amt_be, note_be, ";
$db_query .= "supplier_attatch_ar, quote_amt_ar, note_ar, creater, create_at) values (";
$db_query .= "'$id', '$next_sup_id', '$supplier_arr[$i]', '$target_file_be', '$quote_amt_be_arr[$i]', '$note_be_arr[$i]', ";
$db_query .= "'$target_file_ar', '$quote_amt_ar_arr[$i]', '$note_ar_arr[$i]', '$user_id', '$create_at')";
$result = mysqli_query($link, $db_query);
$next_sup_id++;
} else { // 修改(不支援重傳檔案)
$db_query = "update bargain_supplier set supplier = '$supplier_arr[$i]', quote_amt_be = '$quote_amt_be_arr[$i]', ";
$db_query .= "note_be = '$note_be_arr[$i]', quote_amt_ar = '$quote_amt_ar_arr[$i]', ";
$db_query .= "note_ar = '$note_ar_arr[$i]', create_at = '$create_at' ";
$db_query .= "where id = '$bsid_arr[$i]'";
$result = mysqli_query($link, $db_query);
}
}
}
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='bargain-index.php?function_name=bargain&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

44
wms/board-delete.php

@ -1,23 +1,23 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "update board set status = 'N', create_at = NOW() where id = '$id' and creater = '$user_id'";
$res = mysqli_query($link, $db_query);
/*
$db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query);
$row = mysqli_fetch_row($res);
$target_file = $row[0];
mysqli_free_result($res);
$db_query = "delete from board where id = '$id'";
mysqli_query($link, $db_query);
unlink($target_file);
*/
//header("Location:board-index.php");
header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "update board set status = 'N', create_at = NOW() where id = '$id' and creater = '$user_id'";
$res = mysqli_query($link, $db_query);
/*
$db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query);
$row = mysqli_fetch_row($res);
$target_file = $row[0];
mysqli_free_result($res);
$db_query = "delete from board where id = '$id'";
mysqli_query($link, $db_query);
unlink($target_file);
*/
//header("Location:board-index.php");
header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
ob_end_flush();
?>

118
wms/board-edit.php

@ -1,60 +1,60 @@
<?php
exit;
require_once "database.php";
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select * from board where id = '$id'";
$data = mysqli_query($link, $db_query);
foreach($data as $data) :
?>
<script>
$(function(){
});
</script>
<div class="container">
<form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data">
<div>
<label for="title">主旨</label>
<input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required>
</div>
<!--<div>
<label for="sdate">開始日期</label><br>
<input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required>
</div>
<div>
<label for="edate">結束日期</label><br>
<input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required>
</div>-->
<div>
<label for="pin">置頂</label>
<select name="pin" id="pin">
<option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>></option>
<option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="attatch1">附件上傳</label>
<a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
<?php
exit;
require_once "database.php";
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select * from board where id = '$id'";
$data = mysqli_query($link, $db_query);
foreach($data as $data) :
?>
<script>
$(function(){
});
</script>
<div class="container">
<form class="form-inline" method="post" action="board-record-update.php" enctype="multipart/form-data">
<div>
<label for="title">主旨</label>
<input type="text" name="title" id="title" size="30" maxlength="25" value="<?php echo $data['title']; ?>" required>
</div>
<!--<div>
<label for="sdate">開始日期</label><br>
<input type="date" name="sdate" id="sdate" value="<?php echo $data['sdate']; ?>" required>
</div>
<div>
<label for="edate">結束日期</label><br>
<input type="date" name="edate" id="edate" value="<?php echo $data['edate']; ?>" required>
</div>-->
<div>
<label for="pin">置頂</label>
<select name="pin" id="pin">
<option value="Y"<?php if ($data["pin"]>1) echo " selected"; ?>></option>
<option value="N"<?php if ($data["pin"]==1) echo " selected"; ?>></option>
</select>
</div>
<div>
<label for="attatch1">附件上傳</label>
<a href="<?php echo $data['attach']; ?>" target="_blank"><?php echo str_replace("/wms/board-attach/","",$data['attach']); ?></a>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="content">公告內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="8" cols="100" required><?php echo $data['content']; ?></textarea>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>

36
wms/board-file.php

@ -1,19 +1,19 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
header("Location: /wms/".$row[0]);
exit;
} else {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案下載失敗!');";
echo "</script>";
header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
}
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "select attach from board where id = '$id'";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
header("Location: /wms/".$row[0]);
exit;
} else {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案下載失敗!');";
echo "</script>";
header("Refresh:0; url=board-index.php?function_name=board&".$token_link);
}
ob_end_flush();
?>

400
wms/board-index.php

@ -1,201 +1,201 @@
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql = "select * from board where status = 'Y' order by id";
// 用mysqli_query方法執行(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 ($data) :
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
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;
}
/* 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; ?>
<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 :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql = "select * from board where status = 'Y' order by id";
// 用mysqli_query方法執行(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 ($data) :
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
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;
}
/* 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; ?>
<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 :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

16
wms/board-record-submit.php

@ -7,7 +7,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$$k = trim($v);
}
function get_basename($filename) {
function get_basename($filename)
{
return preg_replace('/^.+[\\\\\\/]/', '', $filename);
}
@ -16,7 +17,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "board-attach/";
$target_file1 = strtolower($target_dir.get_basename($file_name));
$target_file1 = strtolower($target_dir . get_basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
if (file_exists($target_file1)) unlink($target_file1);
@ -27,22 +28,22 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,資料請重建。');";
echo "location.href='board-index.php?function_name=board&token=".$token."';";
echo "location.href='board-index.php?function_name=board&token=" . $token . "';";
echo "</script>";
}
$db_query = "insert into board (title, content, attach, pin, creater, create_at) values (";
$db_query .= "'$title', '$content', '$target_file1', '1', '".$user_id."', NOW())";
$db_query .= "'$title', '$content', '$target_file1', '1', '" . $user_id . "', NOW())";
$result = mysqli_query($link, $db_query);
if (mysqli_affected_rows($link) > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');";
echo "location.href='board-index.php?function_name=board&token=".$token."';";
echo "location.href='board-index.php?function_name=board&token=" . $token . "';";
echo "</script>";
} elseif (mysqli_affected_rows($link)==0) {
} elseif (mysqli_affected_rows($link) == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='board-index.php?function_name=board&token=".$token."';";
echo "location.href='board-index.php?function_name=board&token=" . $token . "';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
@ -50,4 +51,3 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
mysqli_close($link);
}
?>

102
wms/board-record-update.php

@ -1,52 +1,52 @@
<?php
exit;
require_once "database.php";
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);
//print_r($_FILES);exit;
function get_basename($filename) {
return preg_replace('/^.+[\\\\\\/]/', '', $filename);
}
$pin = ($pin == "Y") ? "99" : "1";
$sql_atta = "";
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "board-attach/";
$target_file1 = strtolower($target_dir.get_basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
if (file_exists($target_file1)) unlink($target_file1);
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "path = '$target_file1', ";
} else $target_file1 = "";
if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='board-index.php';";
echo "</script>";
}
$db_query = "update board set title = '$title', pin = '$pin', ";
$db_query .= $sql_atta;
$db_query .= "content = '$content'";
$db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query);
mysqli_close($link);
echo "<script type ='text/JavaScript'>";
echo "alert('修改成功');";
echo "location.href='board-index.php';";
echo "</script>";
}
<?php
exit;
require_once "database.php";
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
//print_r($_POST);
//print_r($_FILES);exit;
function get_basename($filename) {
return preg_replace('/^.+[\\\\\\/]/', '', $filename);
}
$pin = ($pin == "Y") ? "99" : "1";
$sql_atta = "";
if ($_FILES["attatch1"]["error"] == 0) {
$file_name = $_FILES["attatch1"]["name"];
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$target_dir = "board-attach/";
$target_file1 = strtolower($target_dir.get_basename($file_name));
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$upload_ok = 1;
if (file_exists($target_file1)) unlink($target_file1);
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
$sql_atta .= "path = '$target_file1', ";
} else $target_file1 = "";
if ($target_file1 && !$upload_res_1) {
echo "<script type ='text/JavaScript'>";
echo "alert('檔案上傳失敗,請重新操作。');";
echo "location.href='board-index.php';";
echo "</script>";
}
$db_query = "update board set title = '$title', pin = '$pin', ";
$db_query .= $sql_atta;
$db_query .= "content = '$content'";
$db_query .= "where id = '$id'";
$result = mysqli_query($link, $db_query);
mysqli_close($link);
echo "<script type ='text/JavaScript'>";
echo "alert('修改成功');";
echo "location.href='board-index.php';";
echo "</script>";
}
?>

94
wms/change-password-update.php

@ -1,48 +1,48 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once "database.php";
$token = $_REQUEST["token"];
$token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$old_pwd = $_REQUEST['old_pwd'];
$new_pwd = $_REQUEST['new_pwd'];
$data = array(); # 設置一個空陣列來放資料
$real_user_id = "";
$real_pwd = "";
$sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) {
$real_user_id = $data['accountid'];
$real_pwd = $data['pwd'];
}
#如果帳號密碼都正確才可update
if (strlen($real_user_id) > 0) {
$sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))";
mysqli_query($link, $sql_query);
$result_message = "
<script>
alert('修改成功!');
location.href='change-password.php?" . $token_link . "';
</script>
";
} else {
$result_message = "
<script>
alert('帳號密碼錯誤!');
location.href='change-password.php?" . $token_link . "';
</script>
";
}
echo $result_message;
}
mysqli_close($link);
?>
<script>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once "database.php";
$token = $_REQUEST["token"];
$token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$old_pwd = $_REQUEST['old_pwd'];
$new_pwd = $_REQUEST['new_pwd'];
$data = array(); # 設置一個空陣列來放資料
$real_user_id = "";
$real_pwd = "";
$sql = "SELECT * FROM account where ((accountid = '$user_id') and (pwd = '$old_pwd'))"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) {
$real_user_id = $data['accountid'];
$real_pwd = $data['pwd'];
}
#如果帳號密碼都正確才可update
if (strlen($real_user_id) > 0) {
$sql_query = "UPDATE account set pwd = '$new_pwd' where ((accountid = '$user_id') and (pwd = '$old_pwd'))";
mysqli_query($link, $sql_query);
$result_message = "
<script>
alert('修改成功!');
location.href='change-password.php?" . $token_link . "';
</script>
";
} else {
$result_message = "
<script>
alert('帳號密碼錯誤!');
location.href='change-password.php?" . $token_link . "';
</script>
";
}
echo $result_message;
}
mysqli_close($link);
?>
<script>
</script>

152
wms/change-password.php

@ -1,77 +1,77 @@
<?php
if ($_REQUEST["token"]) {
$item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], "."));
if ($item) {
require_once "header.php";
}
}
?>
<!-- 主頁header -->
<?php
require_once "header.php";
require_once "database.php"; # 載入db.php來連結資料庫
$data = array(); # 設置一個空陣列來放資料
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) {
$phone_call_help = $data['phone_call_help'];
}
?>
<div>
<div id="loader">
<div class="spinner-border text-primary" role="status"></div>
</div>
<div class="appHeader bg-primary text-light">
<div class="left">
<a href="javascript:;" class="headerButton goBack">
<ion-icon name="chevron-back-outline"></ion-icon>
</a>
</div>
<div class="pageTitle">變更密碼</div>
</div>
<div id="appCapsule">
<div class="section full mt-2">
<div class="section-title">請輸入變更前後密碼!</div>
<div class="wide-block pt-2 pb-2">
<form action="change-password-update.php?token=<?php echo $_REQUEST["token"];?>" method="post" enctype="multipart/form-data">
<!-- 以下是要傳遞的資料 -->
<input type="hidden" name="token" value="<?php echo $token; ?>" />
<!-- 以上是要傳遞的資料 -->
<div class="form-group boxed">
<div class="input-wrapper">
<input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼">
<i class="clear-input">
<ion-icon name="close-circle"></ion-icon>
</i>
</div>
</div>
<div class="form-group boxed">
<div class="input-wrapper">
<input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼">
<i class="clear-input">
<ion-icon name="close-circle"></ion-icon>
</i>
</div>
</div>
<div class="mt-1">
<button type="submit" class="btn btn-primary btn-lg btn-block">
確定
</button>
</div>
</form>
</div>
</div>
</div>
<!-- * App Capsule -->
</div>
<?php
mysqli_close($link);
<?php
if ($_REQUEST["token"]) {
$item = substr($_REQUEST["token"], 0, strpos($_REQUEST["token"], "."));
if ($item) {
require_once "header.php";
}
}
?>
<!-- 主頁header -->
<?php
require_once "header.php";
require_once "database.php"; # 載入db.php來連結資料庫
$data = array(); # 設置一個空陣列來放資料
$sql = "SELECT * FROM account where (accountid = '$user_id')"; # sql語法存在變數中
$data = mysqli_query($link, $sql); # 用mysqli_query方法執行(sql語法)將結果存在變數中
foreach ($data as $data) {
$phone_call_help = $data['phone_call_help'];
}
?>
<div>
<div id="loader">
<div class="spinner-border text-primary" role="status"></div>
</div>
<div class="appHeader bg-primary text-light">
<div class="left">
<a href="javascript:;" class="headerButton goBack">
<ion-icon name="chevron-back-outline"></ion-icon>
</a>
</div>
<div class="pageTitle">變更密碼</div>
</div>
<div id="appCapsule">
<div class="section full mt-2">
<div class="section-title">請輸入變更前後密碼!</div>
<div class="wide-block pt-2 pb-2">
<form action="change-password-update.php?token=<?php echo $_REQUEST["token"];?>" method="post" enctype="multipart/form-data">
<!-- 以下是要傳遞的資料 -->
<input type="hidden" name="token" value="<?php echo $token; ?>" />
<!-- 以上是要傳遞的資料 -->
<div class="form-group boxed">
<div class="input-wrapper">
<input type="text" class="form-control" name="old_pwd" placeholder="變更前密碼">
<i class="clear-input">
<ion-icon name="close-circle"></ion-icon>
</i>
</div>
</div>
<div class="form-group boxed">
<div class="input-wrapper">
<input type="text" class="form-control" name="new_pwd" placeholder="變更後密碼">
<i class="clear-input">
<ion-icon name="close-circle"></ion-icon>
</i>
</div>
</div>
<div class="mt-1">
<button type="submit" class="btn btn-primary btn-lg btn-block">
確定
</button>
</div>
</form>
</div>
</div>
</div>
<!-- * App Capsule -->
</div>
<?php
mysqli_close($link);
?>

21
wms/class/Cmail.php

@ -1,5 +1,4 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
@ -12,11 +11,11 @@ class Cmail
public $smtp_user = "";
public $smtp_pwd = "";
function __construct($charset = '', $fromemail = '')
function __construct($charset='', $fromemail='')
{
include dirname(__DIR__) . "/PHPMailer/Exception.php";
include dirname(__DIR__) . "/PHPMailer/PHPMailer.php";
include dirname(__DIR__) . "/PHPMailer/SMTP.php";
include dirname(__DIR__)."/PHPMailer/Exception.php";
include dirname(__DIR__)."/PHPMailer/PHPMailer.php";
include dirname(__DIR__)."/PHPMailer/SMTP.php";
$this->charset = "UTF-8";
$this->host = "mail.masada.com.tw";
@ -24,8 +23,8 @@ class Cmail
$this->smtp_user = "notice"; // 這裡填寫SMTP登入帳號, 例如 your.gmail.name@gmail.com 則填寫your.gmail.name
$this->smtp_pwd = "90493119"; // 這裡填寫SMTP登入密碼
}
function sendx($subject = "", $em_body = "", $sendlist = array(), $from = "永佳捷科技", $bcc = "", $files = array())
function sendx($subject="", $em_body="", $sendlist=array(), $from="永佳捷科技", $bcc="", $files=array())
{
if (!$sendlist) return;
$em_body = nl2br($em_body);
@ -53,15 +52,11 @@ class Cmail
//$mail->addCC("personC@gmail.com", "person C");
//$mail->addBCC("personD@gmail.com", "person D");
//$mail->addAttachment("image1.jpg", "picture.jpg"); //設定附件, 對方會看到附件名稱為 picture.jpg
foreach ($files as $v) {
list($file, $file_name) = $v;
$mail->addAttachment($file, $file_name);
}
//print_r($mail);exit;
if (!$mail->Send()) {
if (!$mail->Send()){
// echo "Mailer error: " . $mail->ErrorInfo;
} else {
//echo "Email sent";
}
}
}
}

172
wms/combo-create.php

@ -1,86 +1,86 @@
<?php
include "header.php";
?>
<div class="container">
<?php
include "combo-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono">
</div>
<div>
<label for="part">部位</label>
<input type="text" name="part" id="part">
</div>
<div>
<label for="partid">部位類別</label>
<input type="text" name="partid" id="partid">
</div>
<div>
<label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="1">
</div>
<div>
<label for="detail">保養內容</label>
<input type="text" name="detail" id="detail">
</div>
<div>
<label for="enable">是否啟用</label>
<Select name="enable" id="enable" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="1">啟用</Option>
<Option Value="0">停用</Option>
</Select>
<!-- <input type="text" name="enable" id="enable" value="1"> -->
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div class="bottom-margin">
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>
<?php
include "header.php";
?>
<div class="container">
<?php
include "combo-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono">
</div>
<div>
<label for="part">部位</label>
<input type="text" name="part" id="part">
</div>
<div>
<label for="partid">部位類別</label>
<input type="text" name="partid" id="partid">
</div>
<div>
<label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="1">
</div>
<div>
<label for="detail">保養內容</label>
<input type="text" name="detail" id="detail">
</div>
<div>
<label for="enable">是否啟用</label>
<Select name="enable" id="enable" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="1">啟用</Option>
<Option Value="0">停用</Option>
</Select>
<!-- <input type="text" name="enable" id="enable" value="1"> -->
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div class="bottom-margin">
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>

22
wms/combo-delete.php

@ -1,12 +1,12 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM combo WHERE id='$id'";
mysqli_query($link, $db_query);
header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link);
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM combo WHERE id='$id'";
mysqli_query($link, $db_query);
header("Refresh:0; url=combo-index.php?function_name=combo&".$token_link);
ob_end_flush();
?>

186
wms/combo-edit.php

@ -1,93 +1,93 @@
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM combo WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div>
<div>
<label for="part">部位</label>
<input type="text" name="part" id="part" value="<?php echo $data['part']; ?>">
</div>
<div>
<label for="partid">部位類別</label>
<input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>">
</div>
<div>
<label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>">
</div>
<div>
<label for="detail">保養內容</label>
<input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>">
</div>
<div>
<label for="enable">是否啟用</label>
<Select name="enable" id="enable" required>
<?php
if($data["enable"] == 1){
echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>";
}else{
echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>";
}
?>
</Select>
<!-- <input type="text" name="enable" id="enable" value=""> -->
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM combo WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="combo-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="combono">保養套餐號</label>
<input type="text" name="combono" id="combono" value="<?php echo $data['combono']; ?>">
</div>
<div>
<label for="part">部位</label>
<input type="text" name="part" id="part" value="<?php echo $data['part']; ?>">
</div>
<div>
<label for="partid">部位類別</label>
<input type="text" name="partid" id="partid" value="<?php echo $data['partid']; ?>">
</div>
<div>
<label for="comboitem">部位類別序號</label>
<input type="text" name="comboitem" id="comboitem" value="<?php echo $data['comboitem']; ?>">
</div>
<div>
<label for="detail">保養內容</label>
<input type="text" name="detail" id="detail" value="<?php echo $data['detail']; ?>">
</div>
<div>
<label for="enable">是否啟用</label>
<Select name="enable" id="enable" required>
<?php
if($data["enable"] == 1){
echo "<Option Value='1' selected='selected'>啟用</Option> <Option Value='0'>停用</Option>";
}else{
echo "<Option Value='0' selected='selected'>停用</Option> <Option Value='1'>啟用</Option>";
}
?>
</Select>
<!-- <input type="text" name="enable" id="enable" value=""> -->
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>

278
wms/combo-index.php

@ -1,140 +1,140 @@
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM combo $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="combo-create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
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:combo-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>建檔時間</th>
<?php if ($user_auth&2) { ?>
<th>修改</th>
<th>刪除</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['combono']; ?></td>
<td><?php echo $data['part']; ?></td>
<td><?php echo $data['partid']; ?></td>
<td><?php echo $data['comboitem']; ?></td>
<td><?php echo $data['detail']; ?></td>
<td><?php echo $data['enable']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="combo-edit.php?id=<?php echo $data['id']; ?>&function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="combo-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" 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>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql_cmd = sql_myself($user_id);
$sql = "SELECT * FROM combo $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="combo-create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="combo-create.php?function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
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:combo-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>建檔時間</th>
<?php if ($user_auth&2) { ?>
<th>修改</th>
<th>刪除</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['combono']; ?></td>
<td><?php echo $data['part']; ?></td>
<td><?php echo $data['partid']; ?></td>
<td><?php echo $data['comboitem']; ?></td>
<td><?php echo $data['detail']; ?></td>
<td><?php echo $data['enable']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="combo-edit.php?id=<?php echo $data['id']; ?>&function_name=combo&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="combo-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" 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>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

84
wms/combo-record-submit.php

@ -1,42 +1,42 @@
<?php
$combono= "";
$part= "";
$partid= "";
$comboitem= "";
$detail= "";
$enable= "";
$creater= "";
$create_at= "";
$combono_error= "";
$part_error= "";
$partid_error= "";
$comboitem_error= "";
$detail_error= "";
$enable_error= "";
$creater_error = "";
$create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include "combo-user-input.php";
$db_query = "INSERT INTO combo(combono, part, partid, comboitem,detail, enable,creater, create_at) VALUES ('$combono', '$part', '$partid', '$comboitem','$detail', '$enable','$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>
<?php
$combono= "";
$part= "";
$partid= "";
$comboitem= "";
$detail= "";
$enable= "";
$creater= "";
$create_at= "";
$combono_error= "";
$part_error= "";
$partid_error= "";
$comboitem_error= "";
$detail_error= "";
$enable_error= "";
$creater_error = "";
$create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include "combo-user-input.php";
$db_query = "INSERT INTO combo(combono, part, partid, comboitem,detail, enable,creater, create_at) VALUES ('$combono', '$part', '$partid', '$comboitem','$detail', '$enable','$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

80
wms/combo-record-update.php

@ -1,41 +1,41 @@
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE combo set combono = '$combono', part = '$part', partid = '$partid', comboitem = '$comboitem', detail = '$detail', enable = '$enable',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='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE combo set combono = '$combono', part = '$part', partid = '$partid', comboitem = '$comboitem', detail = '$detail', enable = '$enable',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='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='combo-index.php?function_name=combo&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

108
wms/combo-user-input.php

@ -1,54 +1,54 @@
<?php
//Function to filter the form input
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
/*
if(empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed";
}
}
/*
if(empty($_POST["website"])) {
$website_error = "Website address is required";
} else {
$website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL";
}
}
if(empty($_POST["comment"])) {
$comment = "";
} else {
$comment = user_input($_POST["comment"]);
}
*/
?>
<?php
//Function to filter the form input
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$combono = user_input($_POST["combono"]);
$part = user_input($_POST["part"]);
$partid = user_input($_POST["partid"]);
$comboitem = user_input($_POST["comboitem"]);
$detail = user_input($_POST["detail"]);
$enable = user_input($_POST["enable"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
/*
if(empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = user_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z ]*$/", $name)) {
$name_error = "Only letter and white space are allowed";
}
}
/*
if(empty($_POST["website"])) {
$website_error = "Website address is required";
} else {
$website = user_input($_POST["website"]);
if(!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $website)) {
$website_error = "Invalid website URL";
}
}
if(empty($_POST["comment"])) {
$comment = "";
} else {
$comment = user_input($_POST["comment"]);
}
*/
?>

1612
wms/cont/apply_form.php

File diff suppressed because it is too large

912
wms/cont/apply_form1.php

@ -0,0 +1,912 @@
<?php
require_once '../header_nomenu.php';
require_once './FormHelper.php';
require_once './wf_common.php';
$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no'];
/***
* 检查是否重复生成价审单
* con_maintance_examine_apply
*/
/*
list($cnt)=DB::fields("select count(*) cnt from con_maintance_examine_apply where vol_no='$vol_no'");
if($cnt>0) {
echo"<script>alert('卷號".$vol_no."已生成價審單,請勿重複生成!');history.go(-1);</script>";
exit;
}
*/
#係統ID
$system_id = 'con';
#流程ID
$flow_id = 'con01';
#表單號 $form_id;
$form_id = "";
#價審單狀態
$apply_st = "";
list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1");
// echo '<pre>';
// print_r($apply_key);
// echo '</pre>';
// exit;
// if ($salesman != $user_id) {
// echo '<script>alert("您並不是該單營業員,無法訪問。");history.go(-1);</script>';
// exit;
// }
if (empty($apply_key)) $apply_st = 1; // 準備新增
else {
//list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'");
list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1");
if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交
else $apply_st = 9; // 已到下一關,無法䖺改
}
// if ($apply_st > 2) {
// echo "<script>alert('卷號" . $vol_no . "已生成價審單,請勿重複生成!');history.go(-1);</script>";
// exit;
// }
if ($apply_st == 1) {
$wf = new WorkFlow($system_id, $flow_id, $form_id);
$wf->initWorkFlow($user_id);
$form_key = $wf->flowContext->getFormKey();
} else {
$wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key);
}
#獲取簽核意見
$assign_opinions = Assign::get_records($form_key);
#會簽部門意見
$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key);
//預設冇有摺扣
$wf->setFormData(['discount' => 100]);
$flowName = $wf->getFlowName();
$assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner);
$if_show_assign = true;
//加載流程圖
//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID());
//$path = $fc[0]->wf_file;
//echo dirname(__DIR__)."/../"."$path";
//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path);
#是否可會簽
$isSplitable = $wf->isSplitable();
//表單數據
#客戶表
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc ";
$elevator_brand_opt = DB::result($sql);
#2.保養方式
$sql = "select code_name value ,content label from code where field_name='maintain_kind'";
$maintain_kind_opt = DB::result($sql);
#3.電梯類型
$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.付款方式
$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc";
$payment_kind_opt = DB::result($sql);
#5.契約性質
$sql = "select code_name value ,content label from code where field_name='contract_kind'";
$contract_kind_opt = DB::result($sql);
#6.是否贈送M1
$is_m1_bundle_opt = [
['label' => '是', 'value' => 'Y'],
['label' => '否', 'value' => 'N']
];
#7.機種
$sql = "select code_name value ,content label from code where field_name='fp_kind'";
$fp_kind_opt = DB::result($sql);
#抓取有望客戶資料
$vol_no = $_GET['vol_no'];
$where = " and vol_no='$vol_no'";
$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no";
$hope_contract = DB::result($sql);
$hope_contract = empty($hope_contract) ? [] : $hope_contract[0];
#寫入 con_maintance_examine_apply
if ($apply_st == 1) {
#獲取評審單號
$apply_key = get_sequnece_no('cmea_apply_key', date('ym'));
//var_dump($hope_contract);
$insert_data = [
'apply_key' => $apply_key,
'vol_no' => $vol_no,
'form_key' => $form_key,
'address' => $hope_contract['address'],
'case_name' => $hope_contract['customer'],
'num' => $hope_contract['num'],
'brand' => '',
'customer' => $hope_contract['customer'],
'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'],
'progress_remark' => $hope_contract['progress_status']
//'platform_company'=>'',
// 'platforom_company_tel'=> ''
];
//var_dump($insert_data);
DB::insert_table('con_maintance_examine_apply', $insert_data);
}
#抓使用者主管
$sql = "SELECT * FROM account WHERE accountid = '$user_id' ";
list($result) = DB::result($sql);
if ($result['department_id'] == '511') {
$managerid = 'M0137';
$managername = '劉永德';
} else if ($result['department_id'] == '512') {
$managerid = 'M0137';
$managername = '劉永德';
} else if ($result['department_id'] == '513') {
$managerid = 'M0086';
$managername = '李烘銘';
} else if ($result['department_id'] == '514') {
$managerid = 'M0033';
$managername = '吳育宗';
}
if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') {
$managerid = 'M0008';
$managername = '詹益彰';
}
if ($result['department_id'] == 'M0008') {
$managerid = 'M0008';
$managername = '詹益彰';
}
$table = 'con_maintance_examine_apply';
#可編輯的列
$editableColumn = [
'apply_key' => [
'label' => "評審單號", "value" => "$apply_key", "tag" => 'text',
'attr' => [
'readonly=true ',
'class' => 'form-control form-control-sm'
]
],
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']],
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt],
'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']],
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt],
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt],
'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt],
];
$where = " and apply_key='$apply_key'";
$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no";
$data = [];
$data = DB::result($sql);
#電梯詳細資料
$con_maintance_examine_clear_columm = [
'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']],
'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt],
'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt],
'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt],
'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']],
'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']],
'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']],
'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']],
'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']],
'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt],
'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']],
'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']],
'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']],
'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']],
'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt],
'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']],
'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']],
'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']],
];
$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) .
" FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' ");
$j = 0;
$col_count = 12;
$cmecRow = " <tr>";
foreach ($con_maintance_examine_clear_columm as $key => $val) {
$fieldVal = "";
$_input = $val['tag'] == 'select' ?
FormHelper::select('', $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
// : "<input type='" . $val['tag'] . "' class=' form-control form-control-sm' " . $val['attr'] . " value='" . $fieldVal . "' name='${key}[]' id='$key' placeholder='請輸入'>";
$cmecRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>";
if ((++$j % $col_count) == 0) {
if ($j == $col_count) $cmecRow .= "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
$cmecRow .= "</tr><tr>";
}
}
$cmecRow .= "</tr>";
function base_url($url)
{
return "https://www.masada.com.tw/static/" . $url;
}
function get_sequnece_no($seq_name = '', $p_yyyymm = '')
{
if (empty($p_yyyymm) || empty($seq_name)) return null;
#當前年月
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' ");
if ($p_yyyymm != $yyyymm) {
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' ");
}
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no ";
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no ");
return $seq_no;
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" />
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>">
</script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100); ?>" />
<script type="text/javascript">
window.param = {
elevator_type: '',
floors: 1,
speed: 1,
persons: 6,
weight: 1000,
maintain_times: 1, //病床梯一月2次保養
maintain_months: 12,
maintain_kind: 2,
maintain_period: 1, //預設為1月1次, 2是為2月一次
is_m1_bundle: 'N',
};
let regDelStr = "";
$(document).ready(function() {
var tag_data;
$.ajax({
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner',
//url: 'http://localhost/fds/index.php/DesignFlow/get_assigner',
type: 'post',
dataType: 'json',
success: function(data) {
window.tag_data = data;
$('#selectPage').selectPage({
showField: 'show_name',
keyField: 'val',
data: data,
multiple: true,
multipleControlbar: true,
pagination: false,
focusDropList: false
});
}
});
$.validator.addMethod('gt', function(value, element, param) {
return value > param;
}, $.validator.format("輸入值必須大於0"));
var assigner = eval('<?= json_encode($assigner) ?>');
//console.log(assigner);
var cmecRow = "<?= str_replace('"', '\'', $cmecRow) ?>";
// $('#cmecTbody').append(cmecRow);
$('.sp_element_box').attr("disabled", true);
$("#assign_opinion").cleditor({
height: 100, // height not including margins, borders or padding
controls: // controls to add to the toolbar
"bold italic underline strikethrough subscript superscript | font size " +
"style | color highlight removeformat | bullets numbering | outdent " +
"indent | alignleft center alignright justify | undo redo | "
});
$('#contract_begin_date').on('input propertychange', function(e) {
var date = new Date(e.target.value);
var yyyy = date.getFullYear() + 1;
var mm = date.getMonth() + 1;
var dd = date.getDate();
var time = yyyy + `-` + (mm < 10 ? '0' + mm : mm) + '-' + (dd < 10 ? '0' + dd : dd);
$('#contract_end_date').val(time);
});
$('#brand').change(function() {
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
if (_selected_status == 'Z') {
$('#brandModal').modal('show')
}
});
$('#assign_status').change(function() {
$("#next_users").empty();
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
var _option_tmp = ""; //獲取下拉列表
// for (a in assigner) { //遍曆assigner
// if (assigner[a][0] == _selected_status) {
// _tmp = assigner[a][1].split(',');
// for (var b in _tmp) {
// if (_tmp[b] == '') {
// continue;
// }
// _uname = _tmp[b].split('-')[1];
// _uid = _tmp[b].split('-')[0];
// /* console.log(_tmp[b]);*/
// _option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>';
// }
// }
// }
_option_tmp += '<option value=' + '<?php echo $managerid ?>' + '>' + '<?php echo $managername ?>' + '</option>';
console.log(_option_tmp);
$("#next_users").append(_option_tmp);
});
$('#maintain_kind').change(function() {
if ($('#cmecTbody tr').length > 0) {
alert("保養方式已更動,請開始輸入電梯資料!");
$('#cmecTbody').find(':input').val('');
return false;
}
});
$("#form").validate();
$("form").submit(function(e) {
$('#reg_del').val(regDelStr);
});
});
addRow = function() {
if ($('#maintain_kind').val() == "") {
alert("請選擇保養方式!");
$('#maintain_kind').eq(0).focus();
return false;
}
const cmecRow = $('#elevator_list').html();
console.log(cmecRow);
$('#elevator_list').append(cmecRow);
$("select[name^='elevator_kind'],select[name^='is_m1_bundle']").on('change', function(obj) {
//console.log('#'+$(this).attr('name')+'#');
var elen = 1;
if ('elevator_kind[]' == $(this).attr('name')) {
var children = $(this).parent().parent().parent();
var elementObj = $(children).next('tr').find("input[name^='stand_price']");
//var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option:selected").val();
} else if ('is_m1_bundle[]' == $(this).attr('name')) {
var children = $(this).parent().parent().parent().prev('tr');
var elementObj = $(this).parent().parent().parent().find("input[name^='stand_price']");
//var is_m1_bundle = $(this).val();
}
var element = elementObj;
if ('elevator_kind[]' == $(this).attr('name')) {
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option: selected").val("");
} else if ('is_m1_bundle[]' == $(this).attr('name')) {
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle']").val();
}
var floors = $(children).find("input[name^='floors']").val();
var speed = $(children).find("input[name^='speed']").val();
var weight = $(children).find("input[name^='weight']").val();
var persons = $(children).find("input[name^='persons']").val();
var maintain_times = $(children).find("input[name^='maintain_times']").val();
var maintain_months = $(children).find("input[name^='maintain_months']").val();
var maintain_period = $(children).find("input[name^='maintain_period']").val();
var maintain_kind = $('#maintain_kind').val();
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val();
var param1 = {
...param,
persons,
floors,
speed,
weight,
maintain_times,
maintain_months,
maintain_period,
maintain_kind,
elevator_type,
is_m1_bundle
}
setStandPrice(param1, element);
//console.info(param1);
});
$("input[name^='floors']" +
",input[name^='speed']" +
",input[name^='persons']" +
",input[name^='weight']" +
",input[name^='maintain_times']" +
",input[name^='maintain_months']" +
",input[name^='maintain_period']"
).on('input propertychange', function(obj) {
// $(obj).parent().parent().parent().remove();
var children = $(this).parent().parent().parent().children();
var floors = $(children).find("input[name^='floors']").val();
var speed = $(children).find("input[name^='speed']").val();
var weight = $(children).find("input[name^='weight']").val();
var persons = $(children).find("input[name^='persons']").val();
var maintain_times = $(children).find("input[name^='maintain_times']").val();
var maintain_months = $(children).find("input[name^='maintain_months']").val();
var maintain_period = $(children).find("input[name^='maintain_period']").val();
var maintain_kind = $('#maintain_kind').val();
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val();
var is_m1_bundle = $(this).parent().parent().parent().next('tr').find("select[name^='is_m1_bundle'] option:selected").val();
var param1 = {
...param,
persons,
floors,
speed,
weight,
maintain_times,
maintain_months,
maintain_period,
maintain_kind,
elevator_type,
is_m1_bundle
}
var element = $(this).parent().parent().parent().next().children().find("input[name^='stand_price']");
setStandPrice(param1, element);
});
}
delRow = function(btn) {
if ($(btn).attr('name') == 'btn1') {
// console.log($(btn).parent().parent().prev('tr').find('input[id=register_code]').val());
regDelStr += $(btn).parent().parent().parent().find('input[id=register_code]').val() + ",";
$(btn).parent().parent().next('tr').remove();
console.log(regDelStr)
} else {
// console.log($(btn).parent().parent().find('input[id=register_code]').val());
$(btn).parent().parent().next('tr').remove();
$(btn).parent().parent().remove();
}
$(btn).parent().parent().parent().parent().remove();
}
setStandPrice = function(p, obj) {
$.ajax({
url: '../cont/t.php',
data: p,
type: 'get',
dataType: 'json',
//success: function(data) {},
success: function(data) {
console.info(data);
if (data.status == 'ok') {
$(obj).val(data.price);
} else {
$(obj).val(data.message);
}
}
});
}
addNewBrand = function() {
var new_brand = $("#new_brand").val();
if (new_brand != '') {
p = {
new_brand: new_brand,
method: 'add_brand'
}
$.ajax({
url: 'async_req.php',
data: p,
type: 'post',
dataType: 'json',
success: function(data) {
console.info(data);
$("#brand").append("<option value='" + data.seq + "'>" + new_brand + "</option>");
},
error: function(data) {
console.info(data);
}
});
}
}
</script>
<body>
<div id="toolbarmenu">
<!--<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>-->
<!-- 導航欄 -->
<ul class="nav nav-tabs" role="tablist" id="tablist">
<li class=" nav-item ">
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">簽核表單</a>
</li>
</ul>
</div>
<!-- 導航欄 END-->
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="submit.php" id='form' method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' />
<input type="hidden" name="token" value='<?= $_GET['token'] ?>' />
<input type="hidden" name="reg_del" id="reg_del">
<input type="hidden" name="form_src" id="form_src" value="apply_form">
<!--表單start-->
<div class=" form container-fluid pt-5">
<div class="row form_head ">
<div class=" col-12 form_head_title ">
<h4> 保養契約價格審核單</h4>
</div>
</div>
<div class="row " style='padding-top:30px;'>
<div class=" col-lg-12 form_row_header ">
<b>契約信息</b>
</div>
</div>
<?php
//一行顯示三列
$i = 0;
echo " <div class='row '>";
foreach ($editableColumn as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($data) ? "" : $data[0][$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "'
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>";
if ($i != 1 && $j == 0) {
echo "
</div>
<div class='row'>
";
}
echo " <div class='col-1 form_field_title'>
" . $val['label'] . "
</div>
<div class=' col-2 form_field_content ' >
$_input
</div>
";
}
echo "</div>";
?>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>洽商進度</b>
</div>
<div class="col-12 " style="padding:0">
<textarea class='form-control textarea' id="progress_remark" name="progress_remark" value='12' rows='6'><?= $hope_contract['progress_status'] ?></textarea>
</div>
</div>
<div id="elevator_list_area " class="row ">
<div class="col-12 form_row_header ">
<b>電梯詳細資料</b>
</div>
<table style='margin-top:0px;text-align:center' class=' table-condensed' id='elevator_list1'>
<thead>
<tr>
<td colspan='18' style='text-align:left;font-size:13px'>
<b>註意事項:</b>
<p>1.速度單位是 米/分.</p>
<p>2.選擇贈送M1,保養月數需填寫60.</p>
<p>3.標準價格未帶出,請聯係業務部建立該規格報價.</p>
<p>4.無機房速度20~60米 以60米為標準.</p>
</td>
</tr>
<tr>
<td colspan='18' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td>
</tr>
</thead>
</table>
<table class=' table-condensed' id='elevator_list'>
<thead>
<tr style=' margin-top:0px;text-align:center'>
<th colspan="2">電梯許可代碼</th>
<th colspan="2">品牌</th>
<th colspan="2">電梯類型</th>
<th colspan="2">規格型號</th>
<th>載重(KG)</th>
<th colspan="2">速度(m/min)</th>
<th>停數</th>
<th>層數</th>
<th>人乘</th>
<th colspan="2">保養次數</th>
<th>保養月數</th>
<th>保養周期</th>
<th>贈送M1</th>
</tr>
</thead>
<tbody id='cmecTbody'>
<tr>
<td colspan="2">
<div class=' col-12'><input id="register_code" name="register_code[]" type="text" value placeholder="無證號請輸入A、B..." repuired class="form-control form=control-sm"></div>
</td>
<td colspan="2">
<div class=' col-12'>
<select name="elevator_brand[]" id="" class="form-control form-control-sm">
<option value=""></option>
<?php foreach ($elevator_brand_opt as $data) : ?>
<option value="<?php echo $data['value']; ?>"><?php echo $data['label'] ?></option>
<?php endforeach ?>
</select>
</div>
</td>
<td colspan="2">
<div class=' col-12'>
<select name="elevator_kind[]" id="" class="form-control form-control-sm">
<option value=""></option>
<?php foreach ($elevator_kind_opt as $data) : ?>
<option value="<?php echo $data['value'] ?>"><?php echo $data['label'] ?></option>
<?php endforeach ?>
</select>
</div>
</td>
<td colspan="2">
<div class=' col-12'>
<select name="spec[]" id="" class="form-control form-control-sm">
<option value=""></option>
<?php foreach ($fp_kind_opt as $data) : ?>
<option value="<?php echo $data['value'] ?>"><?php echo $data['label'] ?></option>
<?php endforeach ?>
</select>
</div>
</td>
<!-- <td><section name='spec'></section></td> -->
<td>
<div class=' col-12'><input type="digits" id="weight" name="weight[]" value gt="0" min="0" required class="form-control form-control-sm"></div>
</td>
<td colspan="2">
<div class=' col-12'><input type="number" id="speed" name="speed[]" valaue gt="0" min="0" require class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><input type="number" id="stop" name="stop[]" class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><input type="digits" id="floors" name="floors[]" value min="1" required class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><input type="digits" id="persons" name="persons[]" value min='1' required class="form-control form-contorl-sm"></div>
</td>
<td colspan="2">
<div class=' col-12'><input type="digits" id="maintain_times" name="maintain_times[]" value='1' min='1' required class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><input type="digits" id="maintain_months" name="maintain_months[]" value="12" min='12' required class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><input type="digits" id="maintain_period" name="maintain_period[]" value="1" min='1' require class="form-control form-control-sm"></div>
</td>
<td>
<div class='col-12'>
<select name="is_m1_bundle[]" id required class="form-control form-control-sm" id="">
<option value=""></option>
<?php foreach ($is_m1_bundle_opt as $data) : ?>
<option value="<?php $data['value'] ?>"><?php echo $data['label'] ?></option>
<?php endforeach ?>
</select>
</div>
</td>
</tr>
</tbody>
<thead>
<tr style='margin-top:0px;text-align:center'>
<th colspan="2">竣工檢查年度</th>
<th colspan="2">上次年檢日期</th>
<th colspan="2">年檢費用(元)</th>
<th colspan="2">標準價格(元/月)</th>
<th colspan="2">契約報價(元/月)</th>
<th colspan="2">契約成交價(元/月)</th>
<th>刪除</th>
<th colspan="6"></th>
</tr>
</thead>
<tbody id='cmecTbody2'>
<tr>
<td colspan="2">
<div class="col-12"><input type="text" id="useful_years" name="useful_years[]" type="digits" value colspan='2' required gt='0' min='0' class="form-control form-control-sm"></div>
</td>
<td colspan="2">
<div class="col-12"><input type="number" id="last_check_date" name="last_check_date[]" value required colspan="2" class="form-control form-control-sn"></div>
</td>
<td colspan="2">
<div class="col-12"><input type="text" id="annual_survey_expense" name="annual_survey_exoense[]" type="number" value required colspan='2' class="form-control form-control-sm"></div>
</td>
<td colspan="2">
<div class="col-12"><input type="text" id='stand_price' name="stand_price[]" value required readonly colspan='2' class="form-control form-control-sm"></div>
</td>
<td colspan="2">
<div class="col-12"><input type="number" id="contract_price" name="contract_price[]" required colsapn="2" class="form-control form-control-sm"></div>
</td>
<td colspan="2">
<div class="col-12"><input type="number" id="sold_price" name="sold_price[]" colspan='2' class="form-control form-control-sm"></div>
</td>
<td>
<div class=' col-12'><button onclick="delRow(this)" name='btn1' type="button" class="btn btn-link btn md">刪除</button></div>
</td>
<td colspan="6"></td>
</tr>
</tbody>
</table>
</div>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>簽核操作</b>
</div>
<div class="col-12 col-3 form_field_content " style="padding:0">
<textarea id="assign_opinion" name="assign_opinion" required></textarea>
</div>
</div>
<div class="row">
<div class=" col-3 form_field_title">
<b style='float:right'>簽核狀態</b>
</div>
<div class=" col-2 form_field_content ">
<select name="assign_status" id="assign_status" required class='form-control form-control form-control-sm '>
<?php echo $assign_status; ?>
</select>
</div>
<div class=" col-2 form_field_title">
<b>下位簽核者</b>
</div>
<div class="col-2 form_field_content">
<select lect name="next_users" id="next_users" class='form-control form-control-sm '></select>
</div>
<div class="col-3 form_field_title ">
<button type="submit" name="btn_save" class="btn btn-warning btn-sm" value="save" style='float:left;margin-right:4px;'>保存</button>&nbsp;
<button type="submit" name="btn_save" class="btn btn-primary btn-sm" value="tosign" style='float:left'>提交</button>
</div>
</div>
<div id="opinion_area " class="row form_comment ">
<div class='col-12 '>
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'>
<li class="active nav-item ">
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a>
</li>
</ul>
</div>
<div class="tab-content col-12">
<div role="tabpanel" class="tab-pane active" id="main_flow_assign">
<div class="comment_items ">
<?php $cnt = 1;
$tmp_code = "0";
foreach ($assign_opinions as $as) { ?>
<div class="comment-item">
<!-- <div class="comment-title">
<b></b>
</div>-->
<?php
if (($as['flow_code']) != $tmp_code)
echo ' <div class="comment-title">
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b>
</div>';
$tmp_code = $as['flow_code'];
?>
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>">
<div class="comment-content-header">
<span>
<strong>
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?>
&nbsp;
<?php if ($as['lead_code'] < 90) echo
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?>
</strong>
</span>
<span>
<strong>
&nbsp;
<?php if ($as['assign_status'] == 'S') echo
" <label class='comment-content-tag'>申請人 </label>"; ?>
<?php if (substr($as['assign_status'], 0, 1) == 'B')
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?>
<?php if (substr($as['assign_status'], 0, 2) == 'X3')
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?>
</strong>
</span>
<span class="comment-content-header-time">
簽核於:<?= $as['assign_date'] ?>
</span>
<!-- <ul class="comment-content-tags">
<li class="">不同意</li>
<li class="comment-content-tag-alert">退回</li>
</ul>-->
</div>
<div class="comment-content-body">
<?= $as['assign_opinion'] ?>
</div>
<!-- <div class="comment-content-footer">
<span>已上載附件:&nbsp;</span><a href="#">附件1</a>
</div>-->
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</form>
<!-- 模態框(Modal) -->
<div class="modal fade" id="brandModal" tabindex="-1" role="dialog" aria-labelledby="brandModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
新增廠牌
</div>
<div class="modal-body">
<input type="text" class='form-control form-control form-control-sm ' id='new_brand'>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onClick="addNewBrand()" data-dismiss="modal">保存</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</div>
</div>
</body>

1151
wms/cont/sign_form.php

File diff suppressed because it is too large

36
wms/cont/sign_list.php

@ -70,8 +70,11 @@ form_key,
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table
where 1=1 $where ORDER BY vol_no";
// echo $sql;
$data = mysqli_query($link, $sql);
// echo '<pre>';
// print_r($data);
// echo '</pre>';
?>
<?php
@ -91,8 +94,7 @@ if ($data) :
<div style="overflow-x:auto;">
<form method='get' action='#'>
<table class='table query-table table-striped table-bordered display compact'
style='width:98%;text-align:center;margin:0 auto'>
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td colspan="8">
@ -101,17 +103,17 @@ if ($data) :
</tr>
</thead>
</table>
<table id="table_index" class="table table-striped table-bordered" style="width:98%" >
<table id="table_index" class="table table-striped table-bordered" style="width:98%">
<thead>
<?php
echo "<tr>";
foreach ($editableColumn as $key => $val) {
echo "<th>".$val['label']."</th>";
echo "<th>" . $val['label'] . "</th>";
}
echo "<th>是否結案</th>";
echo "<th>是否結案</th>";
// echo "<th>刪除</th>";
echo "</tr>";
?>
@ -121,22 +123,22 @@ if ($data) :
<tr>
<?php
foreach ($editableColumn as $key => $val) {
if ( $key =='apply_key') {
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=".$_GET['token']."'>" . $row[$key] . "</td>";
if ($key == 'apply_key') {
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=" . $_GET['token'] . "'>" . $row[$key] . "</td>";
} elseif ($key == 'brand') {
echo "<td>" . (!empty($row[$key])?$elevator_brand_arr[$row[$key]]:"") . "</td>";
echo "<td>" . (!empty($row[$key]) ? $elevator_brand_arr[$row[$key]] : "") . "</td>";
} else {
echo "<td>" . $row[$key] . "</td>";
}
}
//list($signer)=DB::fields(");
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ."
list($signer)=mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='". $row['form_key'] ."'" ));
//list($signer)=DB::fields(");
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ."
list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'"));
echo "<td>" . (empty($signer) ? "結案" : "N") . "</td>";
echo "<td>" .(empty($signer)?"結案":"N") . "</td>";
?>
</tr>
<?php endforeach; ?>
</tbody>

157
wms/cont/submit.php

@ -1,78 +1,79 @@
<?php
//require_once "../database.php";
require_once './wf_common.php';
require_once './model/ConMaintanceExamineApplyModel.php';
require_once './model/ConMaintanceExamineClearModel.php';
//print_r($_POST);exit;
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) {
echo "<script type = 'text/JavaScript'>";
echo "alert('請確認電梯資料或未選擇下位簽核者!');";
echo "history.go(-1);";
echo "</script>";
exit;
}
//更新表单ConMaintanceExamineApplyModel
$cmea = new ConMaintanceExamineApplyModel();
$apply_key=$request['apply_key'];
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => '']));
//更新电梯列表
if (!empty($request["reg_del"])) {
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ","));
foreach ($register_code_del_arr as $val) {
$sql = "update con_maintance_examine_clear set cmstatus = 'D' where apply_key = '$apply_key' and register_code = '$val' and cmstatus <> 'D'";
DB::query($sql);
}
}
if (!empty($request['register_code']) && count($request['register_code']) > 0) {
$cmec = new ConMaintanceExamineClearModel();
for ($i = 0; $i < count($request['register_code']); $i++) {
$data = [
'apply_key' => $request['apply_key']
];
$cols = array_diff($cmec->fillable, ['apply_key']);
foreach ($cols as $col) {
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i];
if ($col=="annual_survey_expense") $data[$col] = '0.00';
}
$cmec->create($data);
}
}
//var_dump($_POST);
//var_dump($_GET);
if ($tosign) {
#流程开始,var_dump($request);
$flow = new Flow($request['form_key']);
// 当前节点签核开始
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']);
$wf->setFormData($request);
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']);
//当前节点签核结束
$responses['flowName'] = $wf->getFlowName();
$responses['form_key'] = $request['form_key'];
//var_dump($request);
#結案發通知給營業員
if ($request['assign_status'] == 'F4') {
list($salesman, $case_name ) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key. "' ");
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`)
VALUES ( '1', '契約價審單結案通知(" .$case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')";
DB::query($ins_notice_sql);
// echo $ins_notice_sql;
}
}
echo "<script type = 'text/JavaScript'>";
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>";
if ($tosign) {
echo "alert('成功提交');";
echo "location.href='../cont/sign_list.php?function_name=sign_list&token=".$request['token']."';";
} else {
echo "alert('資料已保存');";
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=".$request['token']."';";
}
echo "</script>";
<?php
//require_once "../database.php";
require_once './wf_common.php';
require_once './model/ConMaintanceExamineApplyModel.php';
require_once './model/ConMaintanceExamineClearModel.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
// print_r($request);
// exit;
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交
if ($request["form_src"] == "apply_form" && $tosign && (!isset($request["register_code"]) || empty($request["register_code"][0]) || !isset($request["next_users"]) || empty($request["next_users"]))) {
echo "<script type = 'text/JavaScript'>";
echo "alert('請確認電梯資料或未選擇下位簽核者!');";
echo "history.go(-1);";
echo "</script>";
exit;
}
//更新表单ConMaintanceExamineApplyModel
$cmea = new ConMaintanceExamineApplyModel();
$apply_key = $request['apply_key'];
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => '']));
//更新电梯列表
if (!empty($request["reg_del"])) {
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ","));
foreach ($register_code_del_arr as $val) {
$sql = "UPDATE con_maintance_examine_clear SET cmstatus = 'D' WHERE apply_key = '$apply_key' AND register_code = '$val' AND cmstatus <> 'D'";
DB::query($sql);
}
}
if (!empty($request['register_code']) && count($request['register_code']) > 0) {
$cmec = new ConMaintanceExamineClearModel();
for ($i = 0; $i < count($request['register_code']); $i++) {
$data = [
'apply_key' => $request['apply_key']
];
$cols = array_diff($cmec->fillable, ['apply_key']);
foreach ($cols as $col) {
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i];
if ($col == "annual_survey_expense") $data[$col] = '0.00';
}
$cmec->create($data);
}
}
//var_dump($_POST);
//var_dump($_GET);
if ($tosign) {
#流程开始,var_dump($request);
$flow = new Flow($request['form_key']);
// 当前节点签核开始
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']);
$wf->setFormData($request);
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']);
//当前节点签核结束
$responses['flowName'] = $wf->getFlowName();
$responses['form_key'] = $request['form_key'];
//var_dump($request);
#結案發通知給營業員
if ($request['assign_status'] == 'F4') {
list($salesman, $case_name) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key . "' ");
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`)
VALUES ( '1', '契約價審單結案通知(" . $case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')";
DB::query($ins_notice_sql);
// echo $ins_notice_sql;
}
}
echo "<script type = 'text/JavaScript'>";
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>";
if ($tosign) {
echo "alert('成功提交');";
echo "location.href='../wms/index.php.php?function_name=sign_list&token=" . $request['token'] . "';";
} else {
echo "alert('資料已保存');";
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=" . $request['token'] . "';";
}
echo "</script>";

252
wms/contract-create.php

@ -1,126 +1,126 @@
<?php
include "header.php";
?>
<div class="container">
<?php
include "contract-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="contracttype">合約類型(必填)</label>
<Select name="contracttype" id="contracttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option>
</Select>
</div>
<div>
<label for="contractno">合約號(必填)</label>
<input type="text" name="contractno" id="contractno" required>
</div>
<div>
<label for="company">公司名稱</label>
<input type="text" name="company" id="company" >
</div>
<div>
<label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" >
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" >
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" >
</div>
<div>
<label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser">
</div>
<div>
<label for="customerid">客戶維護帳號(必填)</label>
<input type="text" name="customerid" id="customerid" required>
</div>
<div>
<label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" >
</div>
<div>
<label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" >
</div>
<div>
<label for="contracttel">業務聯繫人電話(必填)</label>
<input type="text" name="contracttel" id="contracttel" required>
</div>
<div>
<label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" >
</div>
<div>
<label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" >
</div>
<div>
<label for="start_date">合約起始年月日(必填)</label><br>
<input type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required>
</div>
<div>
<label for="end_date">合約終止年月日(必填)</label><br>
<input type="text" data-date-format="yyyy-mm-dd" name="end_date" id="end_date" value="<?php echo date('Y-m-d',strtotime('+364 day')); ?>" required>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>
<?php
include "header.php";
?>
<div class="container">
<?php
include "contract-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>";
} else {
echo "<p class='success'>Record has added successfully</p>";
}
}
*/
?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<div>
<label for="contracttype">合約類型(必填)</label>
<Select name="contracttype" id="contracttype" required>
<option selected="selected" disabled="disabled" style="display: none" value=""></option>
<Option Value="A">定期保養</Option>
<Option Value="B">單次保養</Option>
<Option Value="C">單次維修</Option>
</Select>
</div>
<div>
<label for="contractno">合約號(必填)</label>
<input type="text" name="contractno" id="contractno" required>
</div>
<div>
<label for="company">公司名稱</label>
<input type="text" name="company" id="company" >
</div>
<div>
<label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" >
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" >
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" >
</div>
<div>
<label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser">
</div>
<div>
<label for="customerid">客戶維護帳號(必填)</label>
<input type="text" name="customerid" id="customerid" required>
</div>
<div>
<label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" >
</div>
<div>
<label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" >
</div>
<div>
<label for="contracttel">業務聯繫人電話(必填)</label>
<input type="text" name="contracttel" id="contracttel" required>
</div>
<div>
<label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" >
</div>
<div>
<label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" >
</div>
<div>
<label for="start_date">合約起始年月日(必填)</label><br>
<input type="text" data-date-format="yyyy-mm-dd" name="start_date" id="start_date" value="<?php echo date('Y-m-d'); ?>" required>
</div>
<div>
<label for="end_date">合約終止年月日(必填)</label><br>
<input type="text" data-date-format="yyyy-mm-dd" name="end_date" id="end_date" value="<?php echo date('Y-m-d',strtotime('+364 day')); ?>" required>
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $user_id; ?>" readonly>
<p class="error"><?php echo $creater_error; ?></p>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php date('Y/m/d H:i:s'); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="submit">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php include "footer.php"; ?>

22
wms/contract-delete.php

@ -1,12 +1,12 @@
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM contract WHERE id='$id'";
mysqli_query($link, $db_query);
header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link);
ob_end_flush();
<?php
ob_start();
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$db_query = "DELETE FROM contract WHERE id='$id'";
mysqli_query($link, $db_query);
header("Refresh:0; url=contract-index.php?function_name=contract&".$token_link);
ob_end_flush();
?>

284
wms/contract-edit.php

@ -1,142 +1,142 @@
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM contract WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="contracttype">合約類型</label>
<Select name="contracttype" id="contracttype" required>
<?php
switch ($data['contracttype']) {
case "A":
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break;
case "B":
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break;
case "C":
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>";
break;
}
?>
</Select>
</div>
<div>
<label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>">
</div>
<div>
<label for="company">公司名稱</label>
<input type="text" name="company" id="company" value="<?php echo $data['company']; ?>">
</div>
<div>
<label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div>
<div>
<label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>">
</div>
<div>
<label for="customerid">客戶維護帳號</label>
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>">
</div>
<div>
<label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>">
</div>
<div>
<label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>">
</div>
<div>
<label for="contracttel">業務聯繫人電話</label>
<input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>">
</div>
<div>
<label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>">
</div>
<div>
<label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>">
</div>
<div>
<label for="start_date">合約起始年月日</label>
<input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>">
</div>
<div>
<label for="end_date">合約終止年月日</label>
<input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>">
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>
<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM contract WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
/*
include "inc/record_update.php";
try {
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$db_query = "SELECT * FROM expert WHERE id=$id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$db_query);
}catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
*/
foreach($data as $data) :
?>
<div class="container">
<form class="form-inline" method="post" action="contract-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div>
<label for="contracttype">合約類型</label>
<Select name="contracttype" id="contracttype" required>
<?php
switch ($data['contracttype']) {
case "A":
echo "<Option Value='A' selected='selected'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break;
case "B":
echo "<Option Value='A'>定期保養</Option> <Option Value='B' selected='selected'>單次保養</Option> <Option Value='C'>單次維修</Option>";
break;
case "C":
echo "<Option Value='A'>定期保養</Option> <Option Value='B'>單次保養</Option> <Option Value='C' selected='selected'>單次維修</Option>";
break;
}
?>
</Select>
</div>
<div>
<label for="contractno">合約號</label>
<input type="text" name="contractno" id="contractno" value="<?php echo $data['contractno']; ?>">
</div>
<div>
<label for="company">公司名稱</label>
<input type="text" name="company" id="company" value="<?php echo $data['company']; ?>">
</div>
<div>
<label for="taxid">統一編號</label>
<input type="text" name="taxid" id="taxid" value="<?php echo $data['taxid']; ?>">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" value="<?php echo $data['address']; ?>">
</div>
<div>
<label for="tel">電話</label>
<input type="text" name="tel" id="tel" value="<?php echo $data['tel']; ?>">
</div>
<div>
<label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser" value="<?php echo $data['promiser']; ?>">
</div>
<div>
<label for="customerid">客戶維護帳號</label>
<input type="text" name="customerid" id="customerid" value="<?php echo $data['customerid']; ?>">
</div>
<div>
<label for="contractperson">業務聯繫人</label>
<input type="text" name="contractperson" id="contractperson" value="<?php echo $data['contractperson']; ?>">
</div>
<div>
<label for="contractaddress">業務聯繫人地址</label>
<input type="text" name="contractaddress" id="contractaddress" value="<?php echo $data['contractaddress']; ?>">
</div>
<div>
<label for="contracttel">業務聯繫人電話</label>
<input type="text" name="contracttel" id="contracttel" value="<?php echo $data['contracttel']; ?>">
</div>
<div>
<label for="contractemail">業務聯繫人郵件地址</label>
<input type="text" name="contractemail" id="contractemail" value="<?php echo $data['contractemail']; ?>">
</div>
<div>
<label for="contract_employee">契約人員工號</label>
<input type="text" name="contract_employee" id="contract_employee" value="<?php echo $data['contract_employee']; ?>">
</div>
<div>
<label for="start_date">合約起始年月日</label>
<input type="text" name="start_date" id="start_date" value="<?php echo $data['start_date']; ?>">
</div>
<div>
<label for="end_date">合約終止年月日</label>
<input type="text" name="end_date" id="end_date" value="<?php echo $data['end_date']; ?>">
</div>
<div>
<label for="creater">建檔人</label>
<input type="text" name="creater" id="creater" value="<?php echo $data['creater']; ?>" readonly>
</div>
<div>
<br>
<button type="submit" name="update">確定</button>
</div>
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>

324
wms/contract-index.php

@ -1,162 +1,162 @@
<?php
include "header.php";
// 工務總處可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM contract $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
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:contract-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>客戶維護帳號</th>
<th>業務聯繫人</th>
<th>業務聯繫人地址</th>
<th>業務聯繫人電話</th>
<th>業務聯繫人郵件地址</th>
<th>契約人員工號</th>
<th>合約起始日</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) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['contracttype']; ?></td>
<td><?php echo $data['contractno']; ?></td>
<td><?php echo $data['company']; ?></td>
<td><?php echo $data['taxid']; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['tel']; ?></td>
<td><?php echo $data['promiser']; ?></td>
<td><?php echo $data['customerid']; ?></td>
<td><?php echo $data['contractperson']; ?></td>
<td><?php echo $data['contractaddress']; ?></td>
<td><?php echo $data['contracttel']; ?></td>
<td><?php echo $data['contractemail']; ?></td>
<td><?php echo $data['contract_employee']; ?></td>
<td><?php echo $data['start_date']; ?></td>
<td><?php echo $data['end_date']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="contract-edit.php?id=<?php echo $data['id']; ?>&function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<!--<td>
<p>
<a href="contract-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>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>
<?php
include "header.php";
// 工務總處可瀏覽全部資料
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql_cmd = sql_myself($user_id);
if ($user_department_id == "501" || $user_id == "M0105") $sql_cmd = "";
$sql = "SELECT * FROM contract $sql_cmd ORDER BY id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link,$sql);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth&2) { ?>
<p>
<a href="contract-create.php?function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if($data):
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:contract-index.php");
}
}
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
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;
}
</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>客戶維護帳號</th>
<th>業務聯繫人</th>
<th>業務聯繫人地址</th>
<th>業務聯繫人電話</th>
<th>業務聯繫人郵件地址</th>
<th>契約人員工號</th>
<th>合約起始日</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) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['contracttype']; ?></td>
<td><?php echo $data['contractno']; ?></td>
<td><?php echo $data['company']; ?></td>
<td><?php echo $data['taxid']; ?></td>
<td><?php echo $data['address']; ?></td>
<td><?php echo $data['tel']; ?></td>
<td><?php echo $data['promiser']; ?></td>
<td><?php echo $data['customerid']; ?></td>
<td><?php echo $data['contractperson']; ?></td>
<td><?php echo $data['contractaddress']; ?></td>
<td><?php echo $data['contracttel']; ?></td>
<td><?php echo $data['contractemail']; ?></td>
<td><?php echo $data['contract_employee']; ?></td>
<td><?php echo $data['start_date']; ?></td>
<td><?php echo $data['end_date']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="contract-edit.php?id=<?php echo $data['id']; ?>&function_name=contract&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<!--<td>
<p>
<a href="contract-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>
</table>
</div>
<?php
else:
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>

122
wms/contract-record-submit.php

@ -1,61 +1,61 @@
<?php
$contracttype= "";
$contractno= "";
$company= "";
$taxid= "";
$address= "";
$tel= "";
$promiser= "";
$customerid= "";
$contractperson= "";
$contractaddress= "";
$contracttel= "";
$contractemail= "";
$contract_employee= "";
$start_date= "";
$end_date= "";
$creater= "";
$create_at= "";
$contracttype_error= "";
$contractno_error= "";
$company_error= "";
$taxid_error= "";
$address_error= "";
$tel_error= "";
$promiser_error= "";
$customerid_error= "";
$contractperson_error= "";
$contractaddress_error= "";
$contracttel_error= "";
$contractemail_error= "";
$contract_employee_error= "";
$start_date_error= "";
$end_date_error= "";
$creater_error = "";
$create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include "contract-user-input.php";
$db_query = "INSERT INTO contract(contracttype, contractno, company, taxid, address, tel, promiser, customerid, contractperson, contractaddress, contracttel, contractemail,contract_employee,start_date,end_date, creater, create_at) VALUES ('$contracttype', '$contractno', '$company', '$taxid', '$address', '$tel', '$promiser', '$customerid', '$contractperson', '$contractaddress', '$contracttel', '$contractemail','$contract_employee','$start_date','$end_date', '$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>
<?php
$contracttype= "";
$contractno= "";
$company= "";
$taxid= "";
$address= "";
$tel= "";
$promiser= "";
$customerid= "";
$contractperson= "";
$contractaddress= "";
$contracttel= "";
$contractemail= "";
$contract_employee= "";
$start_date= "";
$end_date= "";
$creater= "";
$create_at= "";
$contracttype_error= "";
$contractno_error= "";
$company_error= "";
$taxid_error= "";
$address_error= "";
$tel_error= "";
$promiser_error= "";
$customerid_error= "";
$contractperson_error= "";
$contractaddress_error= "";
$contracttel_error= "";
$contractemail_error= "";
$contract_employee_error= "";
$start_date_error= "";
$end_date_error= "";
$creater_error = "";
$create_at_error = "";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include "contract-user-input.php";
$db_query = "INSERT INTO contract(contracttype, contractno, company, taxid, address, tel, promiser, customerid, contractperson, contractaddress, contracttel, contractemail,contract_employee,start_date,end_date, creater, create_at) VALUES ('$contracttype', '$contractno', '$company', '$taxid', '$address', '$tel', '$promiser', '$customerid', '$contractperson', '$contractaddress', '$contracttel', '$contractemail','$contract_employee','$start_date','$end_date', '$creater', '$create_at')";
$result = mysqli_query($link,$db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
if ($affected > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

98
wms/contract-record-update.php

@ -1,50 +1,50 @@
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$contracttype = user_input($_POST["contracttype"]);
$contractno = user_input($_POST["contractno"]);
$company = user_input($_POST["company"]);
$taxid = user_input($_POST["taxid"]);
$address = user_input($_POST["address"]);
$tel = user_input($_POST["tel"]);
$promiser = user_input($_POST["promiser"]);
$customerid = user_input($_POST["customerid"]);
$contractperson = user_input($_POST["contractperson"]);
$contractaddress = user_input($_POST["contractaddress"]);
$contracttel = user_input($_POST["contracttel"]);
$contractemail = user_input($_POST["contractemail"]);
$contract_employee = user_input($_POST["contract_employee"]);
$start_date = user_input($_POST["start_date"]);
$end_date = user_input($_POST["end_date"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE contract set contracttype = '$contracttype', contractno = '$contractno', company = '$company', taxid = '$taxid', address = '$address', tel = '$tel', promiser = '$promiser', customerid = '$customerid', contractperson = '$contractperson', contractaddress = '$contractaddress', contracttel = '$contracttel', contractemail = '$contractemail', contract_employee = '$contract_employee',start_date = '$start_date',end_date = '$end_date',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='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
<?php
include "header.php";
if(isset($_POST['update'])) {
function user_input( $data ) {
$data1 = trim($data);
$data2 = stripslashes($data1);
$data3 = htmlspecialchars($data2);
return $data3;
}
$id = $_POST['id'];
$contracttype = user_input($_POST["contracttype"]);
$contractno = user_input($_POST["contractno"]);
$company = user_input($_POST["company"]);
$taxid = user_input($_POST["taxid"]);
$address = user_input($_POST["address"]);
$tel = user_input($_POST["tel"]);
$promiser = user_input($_POST["promiser"]);
$customerid = user_input($_POST["customerid"]);
$contractperson = user_input($_POST["contractperson"]);
$contractaddress = user_input($_POST["contractaddress"]);
$contracttel = user_input($_POST["contracttel"]);
$contractemail = user_input($_POST["contractemail"]);
$contract_employee = user_input($_POST["contract_employee"]);
$start_date = user_input($_POST["start_date"]);
$end_date = user_input($_POST["end_date"]);
$creater = user_input($_POST["creater"]);
$create_at = date('Y/m/d H:i:s');
$db_query = "UPDATE contract set contracttype = '$contracttype', contractno = '$contractno', company = '$company', taxid = '$taxid', address = '$address', tel = '$tel', promiser = '$promiser', customerid = '$customerid', contractperson = '$contractperson', contractaddress = '$contractaddress', contracttel = '$contracttel', contractemail = '$contractemail', contract_employee = '$contract_employee',start_date = '$start_date',end_date = '$end_date',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='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='contract-index.php?function_name=contract&".$token_link."';";
echo "</script>";
} else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
}
?>

34
wms/contract-repair/api/deleteNewContractData.php

@ -0,0 +1,34 @@
<?php
require_once("../conn.php");
ini_set('date.timezone', 'Asia/Taipei');
if (isset($_GET['contractid']) && $_GET['contractid'] != "" && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') {
try {
$id = $_GET['contractid'];
$user_id = $_GET['user_id'];
$date = date('Y-m-d H:i:s');
$del = '2';
$sql = "UPDATE contract_r_signed_back SET delete_status = :del,delete_userid= :user_id, delete_date = :date WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(":id", $id);
$stmt->bindParam(":del", $del);
$stmt->bindParam(":user_id", $user_id);
$stmt->bindParam(":date", $date);
$stmt->execute();
header("HTTP/1.1 204 NO Content");
} catch (PDOException $e) {
die("ERROR!!!" . $e->getMessage());
}
}
if (isset($_GET['contractid']) && $_GET['contractid'] != "") {
try {
$id = $_GET["contractid"];
$sql_str = "DELETE FROM contract_m_signed_back WHERE id = :contractid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contractid", $id);
$stmt->execute();
header("HTTP/1.1 204 No Content");
} catch (PDOException $e) {
die("ERROR!!!: " . $e->getMessage());
}
}

59
wms/contract-repair/api/getComboNo.php

@ -0,0 +1,59 @@
<?php
class CreateComboNo{
private $comboarr = [
'week'=>'BW002',
'month'=>'EM002',
'quarter'=>'EQ002',
'half'=>'HY002',
'year'=>'EY002'
];
private $bwarr = [
'week','month','week','month','week','quarter',
'week','month','week','month','week','half',
'week','month','week','month','week','quarter',
'week','month','week','month','week','year'
];
private $emarr = [
'month','month','quarter','month','month','half',
'month','month','quarter','month','month','year'
];
private $combo;
private $startdate;
private $enddate;
public function __construct($combo, $startdate, $enddate){
$this->combo = $combo;
$this->startdate = $startdate;
$this->enddate = $enddate;
}
public function getComboNo(){
$comboarr = (array) $this->combo === 'bw' ? $this->bwarr : $this->emarr;
$startdate = new DateTime($this->startdate);
$enddate = new DateTime($this->enddate);
$interval = date_diff($startdate, $enddate);
$months = $interval->y * 12 + $interval->m;
$months = $this->combo === 'bw' ? $months*2 : $months;
$newarr = [];
$idx = 0;
$ori_first_month = date('m', strtotime($this->startdate));
$first_day = date('Y-m-d', strtotime($this->startdate. ' + 3 days'));
$new_first_month = date('m', strtotime($first_day));
if($ori_first_month != $new_first_month){
$first_day = date('Y-m-t', strtotime($this->startdate));
}
$scheduleDate = new DateTime($first_day);
for ($i = 0; $i < $months; $i++){
$newarr[] = [$this->comboarr[$comboarr[$idx]], $scheduleDate->format("Y-m-d")];
$idx ++;
$scheduleDate = $startdate->modify("+1 month");
if($idx >= count($comboarr)){
$idx = 0;
}
}
return json_encode($newarr);
}
}

122
wms/contract-repair/api/getContractData.php

@ -0,0 +1,122 @@
<?php
require_once('../conn.php');
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'b') {
try {
$contractno = $_GET['contractno'];
$sql_str = "SELECT con_maintance_examine_apply.*, con_maintance_examine_clear.* FROM con_maintance_examine_apply
JOIN con_maintance_examine_clear on con_maintance_examine_apply.apply_key=con_maintance_examine_clear.apply_key
WHERE con_maintance_examine_apply.vol_no = :vol_no ;";
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC;";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $contractno);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
if (empty($contract)) {
echo false;
exit;
}
$apply_key = $contract['apply_key'];
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = COUNT($elevators);
$contract['elevators'] = $elevators;
$contract['num'] = $count;
$contractResponse = json_encode($contract);
// 設定回應標頭為 JSON
header('Content-Type: application/json');
// 將 JSON 回應返回給客戶端
echo $contractResponse;
// echo json_encode($contractResponse);
} catch (PDOException $e) {
die("ERROR!!!: " . $e->getMessage());
}
}
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') {
try {
$contractno = $_GET['contractno'];
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $contractno);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
$contractResponse = json_encode($contract);
// 設定回應標頭為 JSON
header('Content-Type: application/json');
// 將 JSON 回應返回給客戶端
echo $contractResponse;
} catch (PDOException $e) {
die("ERROR!!!: " . $e->getMessage());
}
}
//////////////////////////////
//// 合約簽回(修理)
////
//// 製作人:梓誠
/// 時間 :
//////////////////////////////
if (isset($_GET['repair_no']) && $_GET['repair_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') {
try {
$repair_no = $_GET['repair_no'];
$fail_arr = [];
$d_status = '1';
// 判斷單號是否在合約簽核已建立
$sql = "SELECT COUNT(*) AS num FROM contract_r_signed_back WHERE repair_no = :repair_no AND delete_status = :d_status ";
$stmt = $conn->prepare($sql);
$stmt->bindParam(":repair_no", $repair_no);
$stmt->bindParam(":d_status", $d_status);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$count = $result['num'];
if ($count >= 1) {
$fail_arr[] = '合約單號重複,請至契約管理(修理)查看。';
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
// 判斷單號是否在價格審查中以建立。
$sql = "SELECT COUNT(*) AS num FROM pricereview_repair_main WHERE repair_no = :repair_no";
$stmt = $conn->prepare($sql);
$stmt->bindParam(":repair_no", $repair_no);
$stmt->execute();
$result2 = $stmt->fetch(PDO::FETCH_ASSOC);
$count2 = $result2['num'];
if ($count2 == 0) {
$fail_arr[] = '找不到單號,請再確認。';
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
// $contractno = $_GET['contractno'];
$sql = "SELECT a.*,b.name,b.accountid
FROM pricereview_repair_main AS a
LEFT JOIN account AS b
ON a.repairerid = b.accountid
WHERE a.repair_no = :repair_no ";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':repair_no', $repair_no);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
$contractResponse = json_encode($contract);
// 設定回應標頭為 JSON
header('Content-Type : appliction/json');
// 將 JSON 回應給客戶端
echo $contractResponse;
} catch (PDOException $e) {
die("ERROR!!:" . $e->getMessage());
}
}

518
wms/contract-repair/api/getFacilityNo.php

@ -0,0 +1,518 @@
<?php
//ini_set('display_errors', 'on');
// 汰改 前三碼 流水號 + 後兩碼 號機
// 新梯 流水號
// 新增 seq 的初始值
// INSERT INTO `sequence` (`seq_name`, `current_val`, `increment_val`, `remark`, `yyyymm`, `prefix`, `creator`, `create_at`) VALUES ('bf_vol_no', '0', '1', '保養-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11'), ('mf_vol_no', '0', '1', '新梯-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11'), ('tf_vol_no', '0', '1', '汰改-作番編號', '202310', '', 'M0117', '2023-10-26 11:28:11')
class CreateFacilityNo
{
/**
* 連接資料庫
*/
function connectionDB()
{
$envFile = __DIR__ . '/../../../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
putenv("$key=$value");
}
}
}
date_default_timezone_set("Asia/Taipei");
$host = getenv('DB_HOST');
$dbport = getenv('DB_PORT');
$dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE');
try {
$options = [
PDO::ATTR_PERSISTENT => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
];
$pdo = new PDO('mysql:host=' . $host . ';port=' . $dbport . ';dbname=' . $dbname . '', $dbuser, $dbpassword, $options);
$pdo->exec('SET CHARACTER SET utf8mb4');
return $pdo;
} catch (PDOException $e) {
die("Something wrong: {$e->getMessage()}");
}
}
/**
* 結束資料庫連線
*/
function endConnectionDB($pdo)
{
unset($pdo);
}
/**
* 取得下一個新的作番
* @param string $facility_type : M:新梯 T:汰改 B:保養
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @param int $num : 號機
* @return array $new_facility_arr
*/
function getNextFacilityNo($facility_type, $sale_type, $make_type, $num = 1)
{
$this->checkYearAndResetAllSeq();
$Y = substr(date("Y"), 3, 1);
switch ($facility_type) {
case "M":
$next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1;
$new_facility_arr = [];
for ($start_num = 1; $start_num <= $num; $start_num++) {
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1]
. str_pad($next_seq, 5, "0", STR_PAD_LEFT);
array_push($new_facility_arr, $facility_no_tmp);
$next_seq++;
}
return $new_facility_arr;
case "T":
$next_seq = $this->getNextFacilitySeq("tf_vol_no");
$new_facility_arr = [];
for ($start_num = 1; $start_num <= $num; $start_num++) {
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1]
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($start_num, 2, "0", STR_PAD_LEFT);
array_push($new_facility_arr, $facility_no_tmp);
}
return $new_facility_arr;
case "B":
$next_seq = $this->getNextFacilitySeq("bf_vol_no");
$new_facility_arr = [];
for ($start_num = 1; $start_num <= $num; $start_num++) {
$facility_no_tmp = $Y . $sale_type . $make_type[$start_num - 1]
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($start_num, 2, "0", STR_PAD_LEFT);
array_push($new_facility_arr, $facility_no_tmp);
}
return $new_facility_arr;
default:
return "不存在的作番類型";
}
}
/**
* 建立新的作番
* @param string $facility_type : M:新梯 T:汰改 B:保養
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @param string $num : 號機 (非必填)
* @return string $new_facility_no
*/
function makeFacilityNo($facility_type, $sale_type, $make_type, $num = null)
{
$this->checkYearAndResetAllSeq();
$faclikity_details = array(
'facility_type' => $facility_type,
'sale_type' => $sale_type,
'make_type' => $make_type,
'num' => $num
);
switch ($facility_type) {
case "M":
return $this->makeNewMFacilityNo($faclikity_details);
break;
case "T":
return $this->makeNewTFacilityNo($faclikity_details);
break;
case "B":
return $this->makeNewBFacilityNo($faclikity_details);
break;
default:
return "不存在的作番類型";
}
}
/**
* 建立作番 -- 新梯
*/
function makeNewMFacilityNo($faclikity_details)
{
$Y = substr(date("Y"), 3, 1);
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
$num = $faclikity_details['num'];
$next_seq = $this->getNextFacilitySeq("mf_vol_no") + 1;
$new_facility_no_arr = [];
for ($i = 1; $i <= $num; $i++) {
$new_facility_no = $Y . $sale_type . $make_type[$i - 1]
. str_pad($next_seq, 5, "0", STR_PAD_LEFT);
array_push($new_facility_no_arr, $new_facility_no);
$next_seq++;
}
foreach ($new_facility_no_arr as $new_facility_no) {
if ($this->getMakeNewMFacilityNoStatus($faclikity_details) !== "1") {
return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details);
}
// seq +1
$this->facilitySeqAddOne("M");
}
return $new_facility_no_arr;
}
/**
* 建立作番 -- 汰改
*/
function makeNewTFacilityNo($faclikity_details)
{
$Y = substr(date("Y"), 3, 1);
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
$num = $faclikity_details['num'];
$next_seq = $this->getNextFacilitySeq("tf_vol_no");
$new_facility_no_arr = [];
for ($i = 1; $i <= $num; $i++) {
$new_facility_no = $Y . $sale_type . $make_type[$i - 1]
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($i, 2, "0", STR_PAD_LEFT);
array_push($new_facility_no_arr, $new_facility_no);
}
foreach ($new_facility_no_arr as $new_facility_no) {
if ($this->getMakeNewTFacilityNoStatus($faclikity_details) !== "1") {
return $new_facility_no . ":" . $this->getMakeNewTFacilityNoStatus($faclikity_details);
}
// seq +1
$this->facilitySeqAddOne("T");
return $new_facility_no_arr;
}
}
/**
* 建立作番 -- 保養
*/
function makeNewBFacilityNo($faclikity_details)
{
$Y = substr(date("Y"), 3, 1);
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
$num = $faclikity_details['num'];
$next_seq = $this->getNextFacilitySeq("bf_vol_no");
$new_facility_no_arr = [];
for ($i = 1; $i <= $num; $i++) {
$new_facility_no = $Y . $sale_type . $make_type[$i - 1]
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($i, 2, "0", STR_PAD_LEFT);
array_push($new_facility_no_arr, $new_facility_no);
}
foreach ($new_facility_no_arr as $new_facility_no) {
if ($this->getMakeNewBFacilityNoStatus($faclikity_details) !== "1") {
return $new_facility_no . ":" . $this->getMakeNewBFacilityNoStatus($faclikity_details);
}
// seq +1
$this->facilitySeqAddOne("B");
return $new_facility_no_arr;
}
}
/**
* 檢查作番編列狀態 - 新梯
* @param array $faclikity_details
* @return string $status : 1:正確 else:error message
*/
function getMakeNewMFacilityNoStatus($faclikity_details)
{
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
if ($this->checkSaleTypeStatus($sale_type) == false)
return "銷售代號錯誤";
if ($this->checkMakeTypeStatus($make_type) == false)
return "製造編號類型錯誤";
return "1";
}
/**
* 檢查作番編列狀態 - 汰改
* @param array $faclikity_details
* @return string $status : 1:正確 else:error message
*/
function getMakeNewTFacilityNoStatus($faclikity_details)
{
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
if ($this->checkSaleTypeStatus($sale_type) == false)
return "銷售代號錯誤";
if ($this->checkMakeTypeStatus($make_type) == false)
return "製造編號類型錯誤";
return "1";
}
/**
* 檢查作番編列狀態 - 保養
* @param array $faclikity_details
* @return string $status : 1:正確 else:error message
*/
function getMakeNewBFacilityNoStatus($faclikity_details)
{
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
if ($this->checkSaleTypeStatus($sale_type) == false)
return "銷售代號錯誤";
if ($this->checkMakeTypeStatus($make_type) == false)
return "製造編號類型錯誤";
return "1";
}
/**
* seq 取號
* @param string $type M:新梯 T:汰改 B:保養
*/
function facilitySeqAddOne($type)
{
$type_arr = array(
"M" => "mf_vol_no",
"T" => "tf_vol_no",
"B" => "bf_vol_no",
);
if (!empty($type_arr[$type])) {
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sth = $pdo->prepare('UPDATE sequence SET current_val = current_val + 1 WHERE `seq_name` = ?');
$sth->bindValue(1, $type_arr[$type]);
$sth->execute();
}
}
/**
* 修正 seq 取號
* @param string $type M:新梯 T:汰改 B:保養
*/
function facilityFixSeq($type)
{
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$type_arr = array(
"M" => "mf_vol_no",
"T" => "tf_vol_no",
"B" => "bf_vol_no",
);
$after_fix_seq = $this->getMaxSeq($type);
$sql = "
UPDATE sequence
SET current_val = ?
WHERE seq_name = ?
";
$sth = $pdo->prepare($sql);
$sth->bindValue(1, $after_fix_seq);
$sth->bindValue(2, $type_arr[$type]);
$sth->execute();
}
function getMaxSeq($type)
{
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$Y = substr(date("Y"), 3, 1);
$seq_num = $type == 'M' ? 5 : 3;
$sql = "
SELECT MAX(SUBSTR(f.facilityno,4,?))+1 AS seq
FROM facility AS f
WHERE 1=1
AND SUBSTR(f.facilityno,1,1) = ?
AND f.define = ?
ORDER BY SUBSTR(f.facilityno,4,3) ASC
";
$sth = $pdo->prepare($sql);
$sth->bindValue(1, $seq_num);
$sth->bindValue(2, $Y);
$sth->bindValue(3, $type);
$sth->execute();
$result = $sth->fetch();
return $result['seq'];
}
/**
* 檢查年月後 新梯及汰改seq歸零
*/
function checkYearAndResetAllSeq()
{
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?');
$sth->bindValue(1, 'mf_vol_no');
$sth->execute();
$result = $sth->fetch();
$yyyymm = $result['yyyymm'];
$dataY = substr($yyyymm, 0, 4);
$today_Y = date("Y");
$today_Ym = date("Ym");
if ($dataY != $today_Y) {
$sth = $pdo->prepare('UPDATE `sequence` SET `current_val` = ? , `yyyymm` = ? WHERE `seq_name` = ?');
$sth->bindValue(1, '0');
$sth->bindValue(2, $today_Ym);
$sth->bindValue(3, 'mf_vol_no');
$sth->execute();
}
}
/**
* 檢查作番在 facility table 中是否重複
* @param string|array $facility_no
* @return boolean $status : true:沒重複 false:重複
*/
function checkFacilityRepeatStatus($facility_no)
{
if (gettype($facility_no) == "string") {
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?');
$sth->bindValue(1, $facility_no);
$sth->execute();
if ($sth->rowCount() == 0)
return true;
return false;
}
if (gettype($facility_no) == "array") {
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$status = true;
foreach ($facility_no as $row) {
$sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?');
$sth->bindValue(1, $row);
$sth->execute();
if ($sth->rowCount() !== 0)
$status = false;
}
return $status;
}
}
/**
* 檢查 $sale_type 是否有存在規則之中
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @return boolean $status : true:合法代碼 false:非法代碼
*/
function checkSaleTypeStatus($sale_type)
{
if (!in_array($sale_type, ['M', 'E', 'T', 'J', 'X']))
return false;
return true;
}
/**
* 檢查 $sale_type 是否有存在規則之中
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @return boolean $status : true:合法代碼 false:非法代碼
*/
function checkMakeTypeStatus($make_type)
{
foreach ($make_type as $row)
if (!in_array($row, ['X', 'W', 'H', 'Z', 'F', 'B', 'Q', 'T', 'N', 'W', 'J', 'Y']))
return false;
return true;
}
/**
* 檢查 取得下個作番的 seq
* @param string $seq_name : 新梯:mf_vol_no 汰改:tf_vol_no 保養:bf_vol_no
* @return int $seq : 作番流水號
*/
function getNextFacilitySeq($seq_name)
{
$pdo = $this->connectionDB();
$pdo->exec('SET CHARACTER SET utf8mb4');
$sth = $pdo->prepare('SELECT * FROM `sequence` WHERE `seq_name` = ?');
$sth->bindValue(1, $seq_name);
$sth->execute();
$result = $sth->fetch();
return $result['current_val'];
}
/**
* 建立新的新梯作番
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @param int $seq_name : 幾個案場 0-99
* @return array $new_facilityno : 作番號
*/
function makeMFacilityNo($sale_type, $make_type, $num)
{
if (count($make_type) !== $num)
return "陣列數量不一致!";
$new_facility_no = $this->getNextFacilityNo("M", $sale_type, $make_type, $num);
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) {
// 如果作番號重複 使用此函數修正
$this->facilityFixSeq("M");
}
return $this->makeFacilityNo("M", $sale_type, $make_type, $num);
}
/**
* 建立新的汰改作番
* @param array $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @param int $seq_name : 幾個案場 0-99
* @return array $new_facilityno : 作番號
*/
function makeTFacilityNo($sale_type, $make_type, $num)
{
if (count($make_type) !== $num)
return "陣列數量不一致!";
$new_facility_no = $this->getNextFacilityNo("T", $sale_type, $make_type, $num);
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) {
// 如果作番號重複 使用此函數修正
$this->facilityFixSeq("T");
}
return $this->makeFacilityNo("T", $sale_type, $make_type, $num);
}
/**
* 建立新的保養作番
* @param string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param array $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @param int $seq_name : 幾個案場 0-99
* @return array $new_facilityno : 作番號
*/
function makeBFacilityNo($sale_type, $make_type, $num = 1)
{
if (count($make_type) !== $num)
return "陣列數量不一致!";
$new_facility_no = $this->getNextFacilityNo("B", $sale_type, $make_type, $num);
if ($this->checkFacilityRepeatStatus($new_facility_no) == false) {
// 如果作番號重複 使用此函數修正
$this->facilityFixSeq("B");
}
return $this->makeFacilityNo("B", $sale_type, $make_type, $num);
}
}
// $cfn = new CreateFacilityNo;
// // 建立作番號 - 新梯
// print_r($cfn->makeMFacilityNo("M", ["X", "W"], 2));
// echo "<br/><br/>";
// // 建立作番號 - 汰改
// print_r($cfn->makeTFacilityNo("M", ["X", "W"], 2));
// echo "<br/><br/>";
// // 建立作番號 - 保養
// print_r($cfn->makeBFacilityNo("M", ["X", "W"], 2));
// echo "<br/><br/>";

16
wms/contract-repair/api/getPriceview.php

@ -0,0 +1,16 @@
<?php
require_once('../conn.php');
try{
$id = $_GET['id'];
$sql_str = "SELECT * FROM pricereview_main WHERE id = :id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id',$id);
$stmt->execute();
$prices = $stmt->fetch(PDO::FETCH_ASSOC);
header("Content-Type: application/json");
echo json_encode(['prices'=> $prices]);
}catch (PDOException $e ){
die("ERROR!!!: ". $e->getMessage());
}

423
wms/contract-repair/api/postContractData.php

@ -0,0 +1,423 @@
<?php
require_once("../conn.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei');
//保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
try {
$created_at = date('Y-m-d H:i:s');
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null;
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null;
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null;
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null;
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null;
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null;
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null;
$area = !empty($_POST['area']) ? $_POST['area'] : null;
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null;
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null;
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null;
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null;
$num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
// validate
$fail_arr = [];
if ($contractno === '') return $fail_arr[] = '合約號為必填';
if ($total_price == '') $fail_arr[] = '合約總價為必填';
if ($vat == '') $fail_arr[] = '統一編號為必填';
if ($mtype == '') $fail_arr[] = '維修型態為必填';
if ($phone == '') $fail_arr[] = '客戶電話為必填';
if ($email == '') $fail_arr[] = 'Email為必填';
if ($mworker == '') $fail_arr[] = '保養員為必填';
if ($mcycle == '') $fail_arr[] = '保養頻率為必填';
if ($salesman == '') $fail_arr[] = '營業員為必填';
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填';
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填';
if ($address == '') $fail_arr[] = '地址為必填';
if ($area == '') $fail_arr[] = '區域為必填';
if ($customer == '') $fail_arr[] = '客戶為必填';
if ($partyA == '') $fail_arr[] = '業務聯繫人為必填';
if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填';
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
//create account table
$accounttype = "A";
$accountid = $vat;
$pwd = "123";
$name = $partyA;
$tel = $phone ?? '';
$repairerid = $mworker;
$creater = $user_id;
$create_at = date('Y-m-d H:i:s');
$conn->beginTransaction();
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->bindParam(':accountid', $accountid);
$stmt->bindParam(':pwd', $pwd);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
//create contract table
$contracttype = $mtype;
$company = $partyA;
$taxid = $vat;
$tel = $phone;
$promiser = $partyA;
$contractperson = $partyA;
$contractaddress = $address;
$contracttel = $phone;
$contractemail = $email;
$contract_employee = $salesman;
$start_date = $contract_begin_date;
$end_date = $contract_end_date;
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contracttype', $contracttype);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':taxid', $taxid);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':tel', $tel);
$stmt->bindParam(':promiser', $promiser);
$stmt->bindParam(':contractperson', $contractperson);
$stmt->bindParam(':contractaddress', $contractaddress);
$stmt->bindParam(':contracttel', $contracttel);
$stmt->bindParam(':contractemail', $contractemail);
$stmt->bindParam(':contract_employee', $contract_employee);
$stmt->bindParam(':start_date', $start_date);
$stmt->bindParam(':end_date', $end_date);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
//create facility table
$createFacilityNo = new CreateFacilityNo();
$dailyNecessities = [
'MAE100' => 'X',
'MAM200' => 'W',
'MAH100' => 'H',
'MAQ100' => 'Z',
'MAF100' => 'F',
'MAZ100' => 'B',
];
$facility_arr = [];
foreach ($elevators as $elevator) {
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
echo json_encode($facilityno);
echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $mworker);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
$customerid = $vat;
$define = "B";
$repairtype = $mtype;
$repairerid = $mworker;
$repairername = $worker['name'];
foreach ($elevators as $idx => $elevator) {
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate)
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':define', $define);
$stmt->bindParam(':facilityno', $facilityno[$idx]);
$stmt->bindParam(':latitude', $elevator['latitude']);
$stmt->bindParam(':longitude', $elevator['longitude']);
$stmt->bindParam(':customerid', $customerid);
$stmt->bindParam(':weight', $elevator['weight']);
$stmt->bindParam(':numberofpassenger', $elevator['persons']);
$stmt->bindParam(':numberofstop', $elevator['stop']);
$stmt->bindParam(':numberoffloor', $elevator['floors']);
$stmt->bindParam(':opentype', $elevator['opendoor']);
$stmt->bindParam(':speed', $elevator['speed']);
$stmt->bindParam(':repairtype', $repairtype);
$stmt->bindParam(':maintainance', $elevator['maintainance']);
$stmt->bindParam(':facility_kind', $elevator['spec']);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->bindParam(':area', $area);
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']);
$stmt->bindParam(':licensedate', $elevator['useful_date']);
$result = $stmt->execute();
}
//create schedule table
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date);
$comboArr = json_decode($comboNo->getComboNo(), true);
foreach ($facilityno as $no) {
foreach ($comboArr as $combo) {
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)';
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':facilityno', $no);
$stmt->bindParam(':combono', $combo[0]);
$stmt->bindParam(':repairerid', $repairerid);
$stmt->bindParam(':repairername', $repairername);
$stmt->bindParam(':duedate', $combo[1]);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$result = $stmt->execute();
}
}
// create contract_b_signed_back table
$contract_type = $mtype;
$company = $customer;
$customer_no = $vat;
$salesperson = $salesman;
$customer_phone = $phone;
$customer_email = $email;
$repairman = $mworker;
$cycle = $mcycle;
$contact_person = $partyA;
$contact_address = $partyAaddress;
$contact_phone = $partyAphone;
$contract_email = $partyAemail;
$elevators_number = $num;
$bonus = 1000;
$max_bonus = 2000;
if (!empty($files)) {
$englisharr = range('a', 'z');
$file = $_FILES['files'];
$file_name = $file['name'];
$file_type = $file['type'];
$tmp_name = $file['tmp_name'];
$file_size = $file['size'];
$error = $file['error'];
$newfiles = [];
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach ($file as $key => $val) {
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
}
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
$path = '../images/contracts/';
if (!file_exists($path)) {
mkdir($path);
}
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$datetime = (string)date('YmdHis');
$files_id = 'b' . $datetime; // 保養=>b + 日期時間
foreach ($newfiles as $key => $file) {
$randNum = rand(1000, 9999);
$randEnglish = $englisharr[rand(0, 25)];
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
if ($msg == 1) {
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':files_id', $files_id);
$stmt->bindParam(':file_name', $file_name);
$stmt->bindParam(':file_mime', $file['type']);
$stmt->bindParam(':file_size', $file['size']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $user_id);
$stmt->execute();
}
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path . $file['name'];
if (file_exists($src_name)) {
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.' . $extname);
}
}
} else {
$files = null;
}
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type);
$stmt->bindParam(":company", $company);
$stmt->bindParam(":customer_no", $customer_no);
$stmt->bindParam(":salesperson", $salesperson);
$stmt->bindParam(":contract_start_date", $contract_begin_date);
$stmt->bindParam(":contract_end_date", $contract_end_date);
$stmt->bindParam(":total_price", $total_price);
$stmt->bindParam(":customer_phone", $customer_phone);
$stmt->bindParam(":customer_email", $customer_email);
$stmt->bindParam(":repairman", $repairman);
$stmt->bindParam(":cycle", $cycle);
$stmt->bindParam(":contact_person", $contact_person);
$stmt->bindParam(":contact_address", $contact_address);
$stmt->bindParam(":contact_phone", $contact_phone);
$stmt->bindParam(":contact_email", $contact_email);
$stmt->bindParam(":elevators_number", $elevators_number);
$stmt->bindParam(":area", $area);
$stmt->bindParam(":address", $address);
$stmt->bindParam(":files_id", $files_id);
$stmt->bindParam(":bonus", $bonus);
$stmt->bindParam(":max_bonus", $max_bonus);
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id);
$stmt->execute();
header('Content-Type: application/json');
// $jsonData = json_encode($files);
$conn->commit();
} catch (PDOException $e) {
$conn->rollback();
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
}
//////////////////////////////
//// 合約簽回(修理)
////
//// 製作人:梓誠
/// 時間 :
//////////////////////////////
if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'r') {
// echo $_POST;
// exit;
try {
$created_at = date('Y-m-d H:i:s');
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$company = !empty($_POST['company']) ? $_POST['company'] : null;
$repairid = !empty($_POST['repairid']) ? $_POST['repairid'] : null;
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null;
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null;
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null;
$repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null;
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$type = !empty($_POST['type']) ? $_POST['type'] : null;
$sign_date = !empty($_POST['sign_date']) ? $_POST['sign_date'] : null;
$contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : 1;
$fail_arr = [];
if (empty($contractno)) $fail_arr[] = '合約號為必填';
if (empty($repair_no)) $fail_arr[] = '報價單編號為必填';
if (empty($company)) $fail_arr[] = '客戶名稱為必填';
if (empty($repairid)) $fail_arr[] = '為保人員為必填';
// iempty(f($taxid === '') return $fail_arr[] = '統一編號為必填';
if (empty($facilityno)) $fail_arr[] = '電梯編號為必填';
if (empty($address)) $fail_arr[] = '工程地址為必填';
if (empty($type)) $fail_arr[] = '工程類別為必填';
if (empty($invoice)) $fail_arr[] = '發票抬頭為必填';
if (empty($taxid)) $fail_arr[] = '統一編號為必填';
// echo json_encode($fail_arr);
// exit;
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
// exit();
//create contrac_r_signed_back table
$conn->beginTransaction();
$sql = "INSERT INTO contract_r_signed_back(
repair_no,
contractno,
company,
taxid,
facilityno,
address,
type,
invoice,
repaireid,
total_price,
sign_date,
contract_status,
create_user,
create_date) VALUES(
:repair_no,
:contractno,
:company,
:taxid,
:facilityno,
:address,
:type,
:invoice,
:repaireid,
:total_price,
:sign_date,
:contract_status,
:create_userid,
:create_date
)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(":repair_no", $repair_no);
$stmt->bindParam(":contractno", $contractno);
$stmt->bindParam(":company", $company);
$stmt->bindParam(":taxid", $taxid);
$stmt->bindParam(":facilityno", $facilityno);
$stmt->bindParam(":address", $address);
$stmt->bindParam(":type", $type);
$stmt->bindParam(":invoice", $invoice);
$stmt->bindParam(":repaireid", $repairid);
$stmt->bindParam(":total_price", $total_price);
$stmt->bindParam(":sign_date", $sign_date);
$stmt->bindParam(":contract_status", $contract_status);
$stmt->bindParam(":create_userid", $user_id);
$stmt->bindParam("create_date", $created_at);
$stmt->execute();
header('Content-Type: application/json');
// $jsonData = json_encode($files);
$conn->commit();
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 422 Unprocessable Entity");
echo $e->getMessage();
die('Error!' . $e->getMessage());
}
}

68
wms/contract-repair/api/postContractNewApplyData.php

@ -0,0 +1,68 @@
<?php
require_once("../conn.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
if(isset($_POST['vol_no']) && !empty($_POST['vol_no'])){
$mid = $_POST['mid'];
$vol_no = $_POST['vol_no'];
$salesman = $_POST['salesman'];
$apply_date = $_POST['apply_date'];
$apply_type = $_POST['apply_type'];
$case_name = $_POST['case_name'];
$customer = $_POST['company'];
$manager = $_POST['manager'];
$vat = $_POST['vat'];
$total_price = $_POST['total_price'];
$buy_fee = $_POST['price_a'];
$install_fee = $_POST['price_b'];
$contact_address = $_POST['address'];
$workdeadline_a = $_POST['workdeadline_a'];
$workdeadline_b = $_POST['workdeadline_b'];
$test_time = $_POST['regulations'];
$freedeadline = $_POST['freedeadline'];
$trade_address = $_POST['tradeaddress'];
$tradedeadline = $_POST['tradedeadline'];
$progress = 0;
$status = 0;
$created_at = date('Y-m-d H:i:s');
$created_by = $_POST['user_id'];
$isFirst = $_POST['isFirst'];
$conn->beginTransaction();
try{
if($isFirst == 1){
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, progress, status, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :progress, :status, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':contractno', $vol_no);
$stmt ->bindParam(':sales_man', $salesman);
$stmt ->bindParam(':apply_date', $apply_date);
$stmt ->bindParam(':apply_type', $apply_type);
$stmt ->bindParam(':case_name', $case_name);
$stmt ->bindParam(':customer', $customer);
$stmt ->bindParam(':manager', $manager);
$stmt ->bindParam(':vat', $vat);
$stmt ->bindParam(':total_price', $total_price);
$stmt ->bindParam(':buy_fee', $buy_fee);
$stmt ->bindParam(':install_fee', $install_fee);
$stmt ->bindParam(':contact_address', $contact_address);
$stmt ->bindParam(':workdeadline_a', $workdeadline_a);
$stmt ->bindParam(':workdeadline_b', $workdeadline_b);
$stmt ->bindParam(':test_time', $test_time);
$stmt ->bindParam(':freedeadline', $freedeadline);
$stmt ->bindParam(':trade_address', $trade_address);
$stmt ->bindParam(':tradedeadline', $tradedeadline);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':created_at', $created_at);
$stmt ->bindParam(':created_by', $created_by);
$stmt ->execute();
header("HTTP/1.1 201 success!");
$conn->commit();
}
}catch(PDOException $e){
$conn->rollback();
echo $e->getMessage();
die('Error!:'.$e->getMessage());
}
}

139
wms/contract-repair/api/postNewContractData.php

@ -0,0 +1,139 @@
<?php
require_once("../conn.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
include_once("./upload_chk.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
if($_SERVER['REQUEST_METHOD'] != 'POST'){
exit();
}
//新梯簽回
if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') {
try{
$created_at = date('Y-m-d H:i:s');
$created_by = $_POST["user_id"];
$contractno = $_POST["contractno"];
$customer = $_POST["customer"];
$manager = $_POST["manager"];
$vat = $_POST["vat"];
$case_name = $_POST["case_name"];
$linkman = $_POST["linkman"];
$lm_tel = $_POST["lm_tel"];
$address = $_POST["address"];
$salesman = $_POST["salesman"];
$qc = $_POST["qc"];
$contracttype = $_POST["contracttype"];
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$files_id = null;
$fail_arr = [];
if(empty($contractno)) $fail_arr[] = '合約號為必填';
if(empty($customer)) $fail_arr[] = '客戶名稱為必填';
if(empty($manager)) $fail_arr[] = '負責人為必填';
if(empty($vat)) $fail_arr[] = '統編/身分證為必填';
if(empty($case_name)) $fail_arr[] = '案名為必填';
if(empty($linkman)) $fail_arr[] = '聯絡人為必填';
if(empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填';
if(empty($address)) $fail_arr[] = '地址為必填';
if(empty($salesman)) $fail_arr[] = '營業員為必填';
if(empty($qc)) $fail_arr[] = '請選擇QC或官檢';
if(count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
$conn->beginTransaction();
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC";
$stmt = $conn -> prepare($sql_str);
$stmt -> bindParam(":accountid",$salesman);
$stmt -> execute();
$saleman = $stmt->fetch(PDO::FETCH_ASSOC);
$salesman_name = $saleman['name'];
if(!empty($files)){
$englisharr = range('a', 'z');
$files = $_FILES['files'];
$newfiles = [];
foreach( $files as $file ){
$i = 0; //新陣列的索引編號
foreach( $file as $key => $val ){
$newfiles[$i]['name'] = $files['name'][$key];
$newfiles[$i]['type'] = $files['type'][$key];
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
$newfiles[$i]['error'] = $files['error'][$key];
$newfiles[$i]['size'] = $files['size'][$key];
$i++;
} //foreach 第2層 end
}
$max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型
$path = '../images/contracts/';
if (!file_exists($path)) { mkdir($path); }
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
$datetime = (string)date('YmdHis');
$files_id = 'm' . $datetime; // 保養=>b + 日期時間
foreach( $newfiles as $key => $file ){
$randNum = rand(1000,9999);
$randEnglish = $englisharr[rand(0,25)];
$file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name'];
$msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name );
if($msg==1){
$msg = '檔案傳送成功!';
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt -> bindParam(':files_id' ,$files_id);
$stmt -> bindParam(':file_name' ,$file_name);
$stmt -> bindParam(':file_mime' ,$file['type']);
$stmt -> bindParam(':file_size' ,$file['size']);
$stmt -> bindParam(':created_at' ,$created_at);
$stmt -> bindParam(':created_by' ,$created_by);
$stmt ->execute();
}else{
throw new PDOException('檔案上傳失敗:' . $msg);
}
$msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path.$file['name'];
if( file_exists($src_name) ){
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.'.$extname);
}
}
}else{
$files = null;
}
$sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)";
$stmt = $conn -> prepare($sql_str);
$stmt -> bindParam(":contract_no",$contractno);
$stmt -> bindParam(":customer",$customer);
$stmt -> bindParam(":manager",$manager);
$stmt -> bindParam(":vat",$vat);
$stmt -> bindParam(":case_name",$case_name);
$stmt -> bindParam(":linkman",$linkman);
$stmt -> bindParam(":lm_tel",$lm_tel);
$stmt -> bindParam(":address",$address);
$stmt -> bindParam(":salesman",$salesman);
$stmt -> bindParam(":salesman_name",$salesman_name);
$stmt -> bindParam(":files_id",$files_id);
$stmt -> bindParam(":created_at",$created_at);
$stmt -> bindParam(":created_by",$created_by);
$stmt -> bindParam(":qc",$qc);
$stmt -> execute();
$result = $conn->commit();
if($result){
header("HTTP/1.1 201 Created");
}
}catch(PDOException $e){
$conn->rollback();
header("HTTP/1.1 500 Internal Server Error");
die('Error!:'.$e->getMessage());
}
}

190
wms/contract-repair/api/putContractData.php

@ -0,0 +1,190 @@
<?php
require_once("../conn.php");
include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei');
// echo json_encode(explode(',', $_POST['deletefiles']));
if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id'] != "") {
try {
$create_date = date('Y-m-d H:i:s');
$repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null;
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$company = !empty($_POST['company']) ? $_POST['company'] : null;
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null;
$facilityno = !empty($_POST['facilityno']) ? $_POST['facilityno'] : null;
$address = !empty($_POST['address']) ? $_POST['address'] : null;
$type = !empty($_POST['type']) ? $_POST['type'] : null;
$invoice = !empty($_POST['invoice']) ? $_POST['invoice'] : null;
$repaireid = !empty($_POST['repaireid']) ? $_POST['repaireid'] : null;
$contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : null;
// $total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null;
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$fail_arr = [];
// if (empty($repair_no)) $fail_arr[] = '號為必填';
if (empty($contractno)) $fail_arr[] = '合約號為必填';
if (empty($company)) $fail_arr[] = '客戶名稱為必填';
if (empty($taxid)) $fail_arr[] = '統一編號為必填';
if (empty($facilityno)) $fail_arr[] = '電梯號為必填';
if (empty($address)) $fail_arr[] = '工程地址為必填';
if (empty($type)) $fail_arr[] = '工程類行為必填';
if (empty($invoice)) $fail_arr[] = '發票抬頭為必填';
if (empty($repaireid)) $fail_arr[] = '維修人員為必填';
if (empty($contract_status)) $fail_arr[] = '工程類別為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 442 Unprocessable Entity");
echo json_encode($fail_arr);
exit();
}
// $conn->beginTransaction();
$sql = "UPDATE contract_r_signed_back SET
repaireid = :repaireid,facilityno= :facilityno, invoice=:invoice, taxid=:taxid, address=:address,type=:type,contract_status=:contract_status,update_user=:update_user,update_date=:update_date
WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':repaireid', $repaireid);
$stmt->bindParam(':facilityno', $facilityno);
$stmt->bindParam(':invoice', $invoice);
$stmt->bindParam(':taxid', $taxid);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':type', $type);
$stmt->bindParam(':contract_status', $contract_status);
$stmt->bindParam(':update_user', $user_id);
$stmt->bindParam(':update_date', $create_date);
$stmt->bindParam(':id', $_POST['id']);
// echo json_encode($sql);
// exit;
$stmt->execute();
// header("HTTP/1.1 204 NO Content");
// $conn->commit();
} catch (PDOException $e) {
// $conn->rollback();
header("HTTPP/1.1 500 Internal Server Error");
die('Error!:' . $e->getMessage());
}
}
// if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST["id"]) && $_POST['id'] != "") {
// try {
// $created_at = date('Y-m-d H:i:s');
// $created_by = $_POST['user_id'];
// $id = $_POST["id"];
// $contract_no = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
// $customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
// $manager = !empty($_POST['manager']) ? $_POST['manager'] : null;
// $vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
// $case_name = !empty($_POST['case_name']) ? $_POST['case_name'] : null;
// $linkman = !empty($_POST['linkman']) ? $_POST['linkman'] : null;
// $lm_tel = !empty($_POST['lm_tel']) ? $_POST['lm_tel'] : null;
// $address = !empty($_POST['address']) ? $_POST['address'] : null;
// $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
// $qc = !empty($_POST['qc']) ? $_POST['qc'] : null;
// $deletefiles = !empty($_POST['deletefiles']) ? $_POST['deletefiles'] : null;
// $files_id = !empty($_POST['files_id']) ? $_POST['files_id'] : null;
// $files = !empty($_FILES['files']) ? $_FILES['files'] : null;
// $deletefilesArr = explode(',', $_POST['deletefiles']);
// $fail_arr = [];
// if (empty($contract_no)) $fail_arr[] = '合約號為必填';
// if (empty($customer)) $fail_arr[] = '客戶名稱為必填';
// if (empty($manager)) $fail_arr[] = '負責人為必填';
// if (empty($vat)) $fail_arr[] = '統編/身分證為必填';
// if (empty($case_name)) $fail_arr[] = '案名為必填';
// if (empty($linkman)) $fail_arr[] = '聯絡人為必填';
// if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填';
// if (empty($address)) $fail_arr[] = '地址為必填';
// if (empty($salesman)) $fail_arr[] = '營業員為必填';
// if (empty($qc)) $fail_arr[] = '請選擇QC或管檢';
// if (count($fail_arr) > 0) {
// header("HTTP/1.1 422 Unprocessable Entity");
// echo json_encode($fail_arr);
// exit();
// }
// $conn->beginTransaction();
// $sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':contract_no', $contract_no);
// $stmt->bindParam(':customer', $customer);
// $stmt->bindParam(':manager', $manager);
// $stmt->bindParam(':vat', $vat);
// $stmt->bindParam(':case_name', $case_name);
// $stmt->bindParam(':linkman', $linkman);
// $stmt->bindParam(':lm_tel', $lm_tel);
// $stmt->bindParam(':address', $address);
// $stmt->bindParam(':salesman', $salesman);
// $stmt->bindParam(':qc', $qc);
// $stmt->bindParam(':id', $id);
// $stmt->execute();
// if (!empty($deletefiles)) {
// $sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)";
// $stmt = $conn->prepare($sql_str);
// $stmt->execute();
// }
// if (!empty($files)) {
// $englisharr = range('a', 'z');
// $files = $_FILES['files'];
// $newfiles = [];
// foreach ($files as $file) {
// $i = 0; //新陣列的索引編號
// foreach ($file as $key => $val) {
// $newfiles[$i]['name'] = $files['name'][$key];
// $newfiles[$i]['type'] = $files['type'][$key];
// $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key];
// $newfiles[$i]['error'] = $files['error'][$key];
// $newfiles[$i]['size'] = $files['size'][$key];
// $i++;
// } //foreach 第2層 end
// }
// $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
// $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型
// $path = '../images/contracts/';
// if (!file_exists($path)) {
// mkdir($path);
// }
// $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息
// $datetime = (string)date('YmdHis');
// $files_id = ($files_id !== null) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間
// foreach ($newfiles as $key => $file) {
// $randNum = rand(1000, 9999);
// $randEnglish = $englisharr[rand(0, 25)];
// $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name'];
// $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name);
// if ($msg == 1) {
// $msg = '檔案傳送成功!';
// $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':files_id', $files_id);
// $stmt->bindParam(':file_name', $file_name);
// $stmt->bindParam(':file_mime', $file['type']);
// $stmt->bindParam(':file_size', $file['size']);
// $stmt->bindParam(':created_at', $created_at);
// $stmt->bindParam(':created_by', $created_by);
// $stmt->execute();
// } else {
// throw new PDOException('檔案上傳失敗:' . $msg);
// }
// $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
// $src_name = $path . $file['name'];
// if (file_exists($src_name)) {
// //副檔名
// $extname = pathinfo($src_name, PATHINFO_EXTENSION);
// //主檔名
// $basename = basename($src_name, '.' . $extname);
// }
// }
// } else {
// $files = null;
// }
// $conn->commit();
// } catch (PDOException $e) {
// $conn->rollback();
// header("HTTP/1.1 500 Internal Server Error");
// die('Error!:' . $e->getMessage());
// }
// }

0
wms/contract-repair/api/store_contract.php

61
wms/contract-repair/api/upload_chk.php

@ -0,0 +1,61 @@
<?php
function upload_chk( $file, $path, $max_size, $allow_ext, $file_name ){
$source_file_name = $file['name']; //上傳檔案的原來檔案名稱
$file_type = $file['type']; //上傳檔案的類型(副檔名)
$tmp_name = $file['tmp_name']; //上傳到暫存空間的路徑/檔名
$file_size = $file['size']; //上傳檔案的檔案大小(容量)
$error = $file['error']; //上傳工作傳回的錯誤訊息編號
$msg = ''; //負責記錄回傳的訊息
//1.判斷錯誤編號只有為0時表示沒有錯誤發生,才表示上傳成功 =================
if( $error == 0 ){
//取得檔案延伸的副檔名, 以下函數可以取得檔案延伸的副檔名
//pathinfo(上傳檔案的原來檔案名稱, PATHINFO_EXTENSION)
$ext = pathinfo($source_file_name, PATHINFO_EXTENSION);
$ext = strtolower($ext); //將延伸的副檔名轉小寫
//2.判斷上傳檔案的大小 ====================================
if( $file_size > $max_size ){
//當目前檔案容量超過容量限制時, 以下準備顯示的資訊
if( $max_size >= 4096*4096 ){
$max_size /= (4096*4096);
$max_size .= 'M';
}elseif( $max_size >= 4096 ){
$max_size /= 4096;
$max_size .= 'K';
}
$msg ='上傳檔案過大,請選擇容量小於 '.$max_size.' 的檔案';
//3.判斷檔案類型 ===========================================
//in_array($ext, $allow_ext) 判斷 $ext變數的值 是否在 $allow_ext 這個陣列變數中
}elseif( !in_array( $ext, $allow_ext ) ){
$allow_str = ''; //準備將允許檔案類型的陣列內容, 組合成字串
foreach( $allow_ext as $key=>$value ){
//if的縮寫語法:條件?成立執行的工作:不成立執行的工作;
$key==0? $allow_str.= $value : $allow_str.=', '.$value;
}
$msg = '檔案類型不符合,請選擇 '.$allow_str.' 檔案';
//4.以上條件都沒問題的話, 則進行最後else中的工作===============
}else{
//搬移檔案 move_uploaded_file(要搬移的檔案, 目的地位置及目的檔案名稱), 成功傳回true(1)
$msg = @move_uploaded_file($tmp_name, $path.$file_name);
}
}else{
//這裡表示上傳有錯誤, 匹配錯誤編號顯示對應的訊息 ======================================
switch ($error) {
case 1: $msg = '上傳檔案超過 upload_max_filesize 容量最大值'; break;
case 2: $msg = '上傳檔案超過 post_max_size 總容量最大值'; break;
case 3: $msg = '檔案只有部份被上傳'; break;
case 4: $msg = '沒有檔案被上傳'; break;
case 6: $msg = '找不到主機端暫存檔案的目錄位置'; break;
case 7: $msg = '檔案寫入失敗'; break;
case 8: $msg = '上傳檔案被PHP程式中斷,表示主機端系統錯誤'; break;
}
} //if( $error == 0 ){ ..... end
return $msg; //回傳$msg的結果
}

43
wms/contract-repair/conn.php

@ -0,0 +1,43 @@
<?php
$envFile = __DIR__ . '/.env'; // .env 文件的路径
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
// 设置环境变量
putenv("$key=$value");
}
}
}
$db_hostname = getenv('DB_HOST'); //資料庫主機名稱
$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號
$db_password = getenv('DB_PASSWORD'); //登入密碼
$db_name = getenv('DB_DATABASE'); //使用的資料庫
$db_charset = 'utf8'; //設定字元編碼
//建立PDO的指定工作
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset";
try{
//使用PDO連接到MySQL資料庫,建立PDO物件
$conn = new PDO($dsn, $db_username, $db_password);
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException)
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。
//設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
//如果連接錯誤,將抛出一個PDOException異常對象
}
catch ( PDOException $e ){
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作
die("ERROR!!!: ". $e->getMessage());
}
//$conn = null; //關閉資料庫的連線

214
wms/contract-repair/contract-repair-edit.php

@ -0,0 +1,214 @@
<?php
include("../header.php");
require_once("./conn.php");
$id = $_GET['contractid'];
$sql_str = "SELECT a.*,b.name FROM contract_r_signed_back AS a LEFT JOIN account AS b ON a.repaireid = b.accountid
WHERE a.id = :id ORDER BY id DESC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
// echo '<pre>';
// print_r($contract['contract_status'] + 1);
// echo '</pre>';
// $files_id = $contract['files_id'];
// $sql_str = "SELECT * FROM contract_back_files WHERE files_id = :files_id ";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':files_id', $files_id);
// $stmt->execute();
// $files= $stmt->fetchAll(PDO::FETCH_ASSOC);
// $files = json_encode($files);
$accounttype = "M";
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":accounttype", $accounttype);
$stmt->execute();
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC);
$persons = array_map(function ($person) {
return [
'view' => $person['accountid'] . '-' . $person['name'],
'value' => $person['accountid'],
'name' => $person['name']
];
}, $persons);
$contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"];
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<!-- <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css" />
<div class="contract-management" x-data='contract_edit'>
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="main_form" />
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>合約管理(修理)</h3>
</td>
</tr>
</thead>
<tbody style="font-weight: bolder;margin-bottom: 20px">
<tr>
<td colspan="7" style='vertical-align: middle;border-right:0px;'>
<h4>檢視合約</h4>
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
</td>
</tr>
<tr>
<td style="vertical-align: middle">立約人</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.company">
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">維保人員</td>
<td style="vertical-align: middle">
<select class="repaireid" id="repaireid" x-model="data.repaireid">
<option value="<?php echo $contract['repaireid'] ?>"><?php echo $contract['repaireid'] . '-' . $contract['name'] ?></option>
<?php foreach ($persons as $person) : ?>
<option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option>
<?php endforeach ?>
</select>
<p class="alerttext" x-show="data.repaireid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">電梯編號</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.facilityno">
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">報價單編號</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.repair_no">
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">工程類別</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.type">
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">簽訂時間</td>
<td>
<input class="form-control disabled_select" type="text" name="sign_date" x-model="data.sign_date">
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">發票抬頭</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.invoice">
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">統一編號</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.taxid">
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">工程地址</td>
<td colspan=3>
<input class="form-control disabled_select" type="text" x-model="data.address">
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<!-- <td style="vertical-align: middle">附件上傳</td>
<td colspan=3>
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
<p class="alerttext" x-show="data.lm_tel==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> -->
<td style="vertical-align: middle">工程進度</td>
<td style="vertical-align: middle">
<select class="contract_status" id="contract_status" x-model="data.contract_status">
<?php foreach ($contract_stauts as $key => $status) : ?>
<option value="<?php echo $key + 1 ?>"><?php echo $status; ?></option>
<?php endforeach ?>
</select>
<p class="alerttext" x-show="data.contract_status==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td></td>
<td></td>
</tr>
<!-- <tr>
<td style="vertical-align: middle">附件</td>
<td colspan=7>
<div class="images">
<template x-for="file in data.files" :key="file.id">
<div class="image">
<a :href="'./images/contracts/' + file.file_name" data-fancybox="gallery" :data-src="'./images/contracts/' + file.file_name" data-caption="">
<img :src="'./images/contracts/' + file.file_name" />
</a>
<i class="fas fa-times" @click="deleteFileFn(file.id)"></i>
</div>
</template>
</div>
</td>
</tr> -->
</tbody>
</table>
<button @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>更新</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button type="button" class="btn btn-primary btn-lg pull-right savebtn" @click="window.location.href='./contract-repair-management.php?<?php echo $token_link; ?>'">回列表</button>
</div>
</div>
</div>
<script src="./js/jquery/jquery-3.1.1.min.js"></script>
<script src="semantic/dist/semantic.min.js"></script>
<script src="./js/alpine.js"></script>
<script>
const user_id = '<?php echo $user_id; ?>';
const user_name = '<?php echo $user_name; ?>';
const id = <?php echo $contract['id'] ?>;
const repair_no = '<?php echo $contract['repair_no']; ?>';
const contractno = '<?php echo $contract['contractno']; ?>';
const company = '<?php echo $contract['company']; ?>';
const taxid = '<?php echo $contract['taxid']; ?>';
const facilityno = '<?php echo $contract['facilityno']; ?>';
const address = '<?php echo $contract['address']; ?>';
const type = '<?php echo $contract['type']; ?>';
const repaireid = '<?php echo $contract['repaireid']; ?>';
const total_price = '<?php echo $contract['total_price']; ?>';
const sign_date = '<?php echo $contract['sign_date']; ?>';
const invoice = '<?php echo $contract['invoice']; ?>'
const contract_status = '<?php echo $contract['contract_status']; ?>'
// $('#table_index').DataTable(
// {
// "order": [
// [0, "desc"],
// ]
// }
// );
// Fancybox.bind('[data-fancybox="gallery"]', {
// });
</script>

185
wms/contract-repair/contract-repair-input.php

@ -0,0 +1,185 @@
<?php
include("../header.php");
require_once("./conn.php");
include_once("./api/getFacilityNo.php");
$accounttype = "B";
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->execute();
$workers = $stmt->fetchAll(PDO::FETCH_ASSOC);
$accounttype = "M";
$sql_str = "SELECT id,accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->execute();
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
$persons = array_map(function ($person) {
return [
'view' => $person['accountid'] . '-' . $person['name'],
'value' => $person['accountid'],
'name' => $person['name']
];
}, $contractpersons);
$contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"];
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<div class="contract-input-component" x-data="contractRepair">
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="main_form" />
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>合約入力(修理)</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1">
<tr>
<td style="vertical-align: middle">報價單編號</td>
<td colspan="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="repair_no" x-model="data.repair_no">
</td>
<td colspan="2" style="vertical-align: middle">
<label for="customize">
<input type="checkbox" x-model="customize" id="customize" />自定義欄位
</label>
</td>
</tr>
</tbody>
</template>
<template x-if="step==2">
<!-- <template x-if="step==1"> -->
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==2">
<!-- <tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> -->
<tr>
<td colspan="7" style='vertical-align: middle;border-right:0px;'>
<h4>業務確認項</h4>
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
</td>
</tr>
<tr>
<td style="vertical-align: middle">立約人</td>
<td>
<input type="text" x-model="data.company" />
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">維保人員</td>
<td style="vertical-align: middle">
<select class="repaireid" id="repaireid" x-model="data.repairerid">
<option value="<?php echo $contract['repaireid'] ?>"><?php echo $contract['repairerid'] . '-' . $contract['name'] ?></option>
<?php foreach ($persons as $person) : ?>
<option value="<?php echo $person['value']; ?>"><?php echo $person['view']; ?></option>
<?php endforeach ?>
</select>
<p class="alerttext" x-show="data.repaireid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">電梯編號</td>
<td>
<input class="form-control disabled_select" type="text" name="facilityno" x-model="data.facilityno">
<p class="alerttext" x-show="data.facilityno==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">報價單編號</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="text" name="repair_no" x-model="data.repair_no" disabled="disabled">
<p class="alerttext" x-show="data.repair_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">工程進度</td>
<td>
<input class="form-control disabled_select" type="text" name="type" x-model="data.type">
<p class="alerttext" x-show="data.type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">簽訂時間</td>
<td>
<input class="form-control disabled_select" type="date" name="sign_date" x-model="data.sign_date">
<p class="alerttext" x-show="data.sign_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">發票抬頭</td>
<td>
<input class="form-control disabled_select" type="text" name="invoice" x-model="data.invoice">
<p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">統一編號</td>
<td>
<input class="form-control disabled_select" type="text" name="taxid" x-model="data.taxid">
<p class="alerttext" x-show="data.taxid==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">工程地址</td>
<td colspan=3>
<input class="form-control disabled_select" type="text" x-model="data.address">
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">工程確認</td>
<td style="vertical-align: middle">
<select class="contract_status" id="contract_status" x-model="data.contract_status">
<option value="">選擇工程類別</option>
<?php foreach ($contract_stauts as $key => $status) : ?>
<option value="<?php echo $key + 1; ?>"><?php echo $status; ?></option>
<?php endforeach ?>
</select>
<p class="alerttext" x-show="data.contract_status==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td></td>
<td></td>
</tr>
</tbody>
</template>
</table>
<button x-show="step==2" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>存檔</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step<=1" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
</div>
</div>
</div>
<script src="./js/jquery/jquery-3.1.1.min.js"></script>
<script src="semantic/dist/semantic.min.js"></script>
<script src="./js/alpine.js"></script>
<script>
const user_id = '<?php echo $user_id; ?>'
const user_name = '<?php echo $user_name; ?>'
</script>

131
wms/contract-repair/contract-repair-management.php

@ -0,0 +1,131 @@
<?php
include("../header.php");
require_once("./conn.php");
$sql_str = "SELECT * FROM contract_r_signed_back WHERE 1=1 AND delete_status = 1 ORDER BY id DESC";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<div class="contract-management" x-data="{
deleteFn(id,user){
if(confirm('確定要刪除嗎?')){
axios.get('./api/deleteNewContractData.php?contracttype=r&contractid='+id+'&user_id='+user).then(res=> {
console.log(res);
if(res.status === 204){
alert('刪除成功!')
location.reload();
}
})
}
}
}">
<div style="overflow-x:auto;margin-top:12px">
<a href="contract-repair-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
<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>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($contracts as $key => $contract) : ?>
<tr>
<td><?php echo $contract['id']; ?></td>
<td><?php echo $contract['contractno'] ?></td>
<td><?php echo $contract['company'] ?></td>
<td><?php echo $contract['taxid'] ?></td>
<td><?php echo $contract['total_price'] ?></td>
<th><?php if ($contract['contract_status'] == 1) {
echo '合約簽回';
} else if ($contract['contract_status'] == 2) {
echo '採購';
} else if ($contract['contract_status'] == 3) {
echo '工程發包';
} else if ($contract['contract_status'] == 4) {
echo '工程中';
} else if ($contract['contract_status'] == 5) {
echo '修理完成';
}
?></th>
<td><?php echo $contract['create_user'] ?></td>
<td><?php echo $contract['create_date'] ?></td>
<td style="width:30px">
<p>
<a href="contract-repair-edit.php?&contractid=<?php echo $contract['id']; ?>&function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a href="javascript:;" class="btn btn-info btn-sm" style="margin-left:10px;" @click="deleteFn(<?php echo $contract['id']; ?>,'<?php echo $user_id; ?>')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
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;
}
</style>
<script src="semantic/dist/semantic.min.js"></script>
<script>
$('#table_index').DataTable({
"order": [
[0, "desc"],
]
});
</script>

1507
wms/contract-repair/js/alpine.js

File diff suppressed because it is too large

5
wms/contract-repair/js/alpinejs/cdn.min.js

File diff suppressed because one or more lines are too long

25
wms/contract-repair/js/axios.js

@ -0,0 +1,25 @@
const axiosClient = axios.create({
baseURL : `${import.meta.env.VITE_API_BASE_URL}/api`,
});
axiosClient.interceptors.request.use( (config)=> {
config.headers.Authorization = `Bearer ${store.state.user.token}`
return config;
}, (error)=> {
return Promise.reject(error);
});
axiosClient.interceptors.response.use( (response)=> {
return response;
}, (error)=>{
if(error.response.status === 401){
store.commit('setToken', null)
sessionStorage.removeItem('TOKEN')
router.push({name:'login'})
}
throw error;
});
export default axiosClient;

2
wms/contract-repair/js/axios/axios.min.js

File diff suppressed because one or more lines are too long

48
wms/contract-repair/js/el.js

@ -0,0 +1,48 @@
export default {
data() {
return {
options: [],
value: [],
list: [],
loading: false,
states: ["Alabama", "Alaska", "Arizona",
"Arkansas", "California", "Colorado",
"Connecticut", "Delaware", "Florida",
"Georgia", "Hawaii", "Idaho", "Illinois",
"Indiana", "Iowa", "Kansas", "Kentucky",
"Louisiana", "Maine", "Maryland",
"Massachusetts", "Michigan", "Minnesota",
"Mississippi", "Missouri", "Montana",
"Nebraska", "Nevada", "New Hampshire",
"New Jersey", "New Mexico", "New York",
"North Carolina", "North Dakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania",
"Rhode Island", "South Carolina",
"South Dakota", "Tennessee", "Texas",
"Utah", "Vermont", "Virginia",
"Washington", "West Virginia", "Wisconsin",
"Wyoming"]
}
},
mounted() {
this.list = this.states.map(item => {
return { value: `value:${item}`, label: `label:${item}` };
});
},
methods: {
remoteMethod(query) {
if (query !== '') {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.options = this.list.filter(item => {
return item.label.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
}, 200);
} else {
this.options = [];
}
}
}
}

4
wms/contract-repair/js/jquery/jquery-3.1.1.min.js

File diff suppressed because one or more lines are too long

5
wms/contract-repair/semantic/.browserlistrc

@ -0,0 +1,5 @@
last 2 versions
> 1%
opera 12.1
bb 10
android 4

322
wms/contract-repair/semantic/.csscomb.json

@ -0,0 +1,322 @@
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "upper",
"block-indent": " ",
"color-shorthand": false,
"element-case": "lower",
"leading-zero": true,
"space-after-colon": " ",
"space-before-combinator": " ",
"space-after-combinator": " ",
"space-between-declarations": "\n",
"space-before-opening-brace": " ",
"space-after-opening-brace": "\n",
"space-after-selector-delimiter": "\n",
"space-before-selector-delimiter": "",
"space-before-closing-brace": "\n",
"strip-spaces": true,
"tab-size": true,
"vendor-prefix-align": true,
"sort-order": [
[
"display",
"visibility",
"float",
"clear",
"overflow",
"overflow-x",
"overflow-y",
"-webkit-box-sizing",
"-moz-box-sizing",
"box-sizing",
"-ms-overflow-x",
"-ms-overflow-y",
"clip",
"zoom",
"flex-direction",
"flex-order",
"flex-pack",
"flex-align"
],
[
"position",
"z-index",
"top",
"right",
"bottom",
"left"
],
[
"font",
"font-family",
"font-size",
"font-weight",
"font-style",
"font-variant",
"font-size-adjust",
"font-stretch",
"font-effect",
"font-emphasize",
"font-emphasize-position",
"font-emphasize-style",
"font-smooth",
"line-height"
],
[
"width",
"min-width",
"max-width",
"height",
"min-height",
"max-height",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left"
],
[
"table-layout",
"empty-cells",
"caption-side",
"border-spacing",
"border-collapse",
"list-style",
"list-style-position",
"list-style-type",
"list-style-image"
],
[
"opacity",
"filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
"-ms-filter:\\'progid:DXImageTransform.Microsoft.Alpha",
"-ms-interpolation-mode",
"color",
"border",
"border-width",
"border-style",
"border-color",
"border-top",
"border-top-width",
"border-top-style",
"border-top-color",
"border-right",
"border-right-width",
"border-right-style",
"border-right-color",
"border-bottom",
"border-bottom-width",
"border-bottom-style",
"border-bottom-color",
"border-left",
"border-left-width",
"border-left-style",
"border-left-color",
"-webkit-border-radius",
"-moz-border-radius",
"border-radius",
"-webkit-border-top-left-radius",
"-moz-border-radius-topleft",
"border-top-left-radius",
"-webkit-border-top-right-radius",
"-moz-border-radius-topright",
"border-top-right-radius",
"-webkit-border-bottom-right-radius",
"-moz-border-radius-bottomright",
"border-bottom-right-radius",
"-webkit-border-bottom-left-radius",
"-moz-border-radius-bottomleft",
"border-bottom-left-radius",
"-webkit-border-image",
"-moz-border-image",
"-o-border-image",
"border-image",
"-webkit-border-image-source",
"-moz-border-image-source",
"-o-border-image-source",
"border-image-source",
"-webkit-border-image-slice",
"-moz-border-image-slice",
"-o-border-image-slice",
"border-image-slice",
"-webkit-border-image-width",
"-moz-border-image-width",
"-o-border-image-width",
"border-image-width",
"-webkit-border-image-outset",
"-moz-border-image-outset",
"-o-border-image-outset",
"border-image-outset",
"-webkit-border-image-repeat",
"-moz-border-image-repeat",
"-o-border-image-repeat",
"border-image-repeat",
"outline",
"outline-width",
"outline-style",
"outline-color",
"outline-offset",
"background",
"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
"background-color",
"background-image",
"background-repeat",
"background-attachment",
"background-position",
"background-position-x",
"-ms-background-position-x",
"background-position-y",
"-ms-background-position-y",
"-webkit-background-clip",
"-moz-background-clip",
"background-clip",
"background-origin",
"-webkit-background-size",
"-moz-background-size",
"-o-background-size",
"background-size",
"box-decoration-break",
"-webkit-box-shadow",
"-moz-box-shadow",
"box-shadow",
"filter:progid:DXImageTransform.Microsoft.gradient",
"-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient",
"text-shadow"
],
[
"content",
"quotes",
"counter-reset",
"counter-increment",
"resize",
"cursor",
"-webkit-user-select",
"-moz-user-select",
"-ms-user-select",
"user-select",
"nav-index",
"nav-up",
"nav-right",
"nav-down",
"nav-left",
"-webkit-transition",
"-moz-transition",
"-ms-transition",
"-o-transition",
"transition",
"-webkit-transition-delay",
"-moz-transition-delay",
"-ms-transition-delay",
"-o-transition-delay",
"transition-delay",
"-webkit-transition-timing-function",
"-moz-transition-timing-function",
"-ms-transition-timing-function",
"-o-transition-timing-function",
"transition-timing-function",
"-webkit-transition-duration",
"-moz-transition-duration",
"-ms-transition-duration",
"-o-transition-duration",
"transition-duration",
"-webkit-transition-property",
"-moz-transition-property",
"-ms-transition-property",
"-o-transition-property",
"transition-property",
"-webkit-transform",
"-moz-transform",
"-ms-transform",
"-o-transform",
"transform",
"-webkit-transform-origin",
"-moz-transform-origin",
"-ms-transform-origin",
"-o-transform-origin",
"transform-origin",
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-name",
"-moz-animation-name",
"-ms-animation-name",
"-o-animation-name",
"animation-name",
"-webkit-animation-duration",
"-moz-animation-duration",
"-ms-animation-duration",
"-o-animation-duration",
"animation-duration",
"-webkit-animation-play-state",
"-moz-animation-play-state",
"-ms-animation-play-state",
"-o-animation-play-state",
"animation-play-state",
"-webkit-animation-timing-function",
"-moz-animation-timing-function",
"-ms-animation-timing-function",
"-o-animation-timing-function",
"animation-timing-function",
"-webkit-animation-delay",
"-moz-animation-delay",
"-ms-animation-delay",
"-o-animation-delay",
"animation-delay",
"-webkit-animation-iteration-count",
"-moz-animation-iteration-count",
"-ms-animation-iteration-count",
"-o-animation-iteration-count",
"animation-iteration-count",
"-webkit-animation-direction",
"-moz-animation-direction",
"-ms-animation-direction",
"-o-animation-direction",
"animation-direction",
"text-align",
"-webkit-text-align-last",
"-moz-text-align-last",
"-ms-text-align-last",
"text-align-last",
"vertical-align",
"white-space",
"text-decoration",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-style",
"text-emphasis-position",
"text-indent",
"-ms-text-justify",
"text-justify",
"letter-spacing",
"word-spacing",
"-ms-writing-mode",
"text-outline",
"text-transform",
"text-wrap",
"text-overflow",
"-ms-text-overflow",
"text-overflow-ellipsis",
"text-overflow-mode",
"-ms-word-wrap",
"word-wrap",
"word-break",
"-ms-word-break",
"-moz-tab-size",
"-o-tab-size",
"tab-size",
"-webkit-hyphens",
"-moz-hyphens",
"hyphens",
"pointer-events"
]
]
}

18
wms/contract-repair/semantic/.csslintrc

@ -0,0 +1,18 @@
{
"vendor-prefix" : true,
"duplicate-properties" : true,
"display-property-grouping" : true,
"empty-rules" : true,
"adjoining-classes" : false,
"box-model" : false,
"compatible-vendor-prefixes" : false,
"box-sizing" : false,
"duplicate-background-images" : false,
"floats" : false,
"important" : false,
"overqualified-elements" : false,
"rules-count" : false,
"shorthand" : false,
"zero-units" : false
}

24
wms/contract-repair/semantic/.github/ISSUE_TEMPLATE.md

@ -0,0 +1,24 @@
✖ USAGE QUESTIONS → Use these dedicated resources:
Docs - http://www.semantic-ui.com
Chat - https://gitter.im/Semantic-Org/Semantic-UI
SO - https://stackoverflow.com/questions/tagged/semantic-ui?sort=votes
✔ Enhancements → Be specific. Assume backwards compatibility is a necessity. Suggest implementation when possible.
✔ BUGS → ❤❤❤. Keep in mind some bugs may not be immediately fixable due to backwards compatibility or CSS limitations.
### Title (Put in field above)
Use the format: [Component] Component Should Do X
i.e. [Checkbox] onChange Should Fire When Update Triggered via DOM
### Steps
### Expected Result
### Actual Result
### Version
x.y.z
### Testcase
[Fork, update, and replace to show the bug]:
https://jsfiddle.net/ca0rovs3/

28
wms/contract-repair/semantic/.github/PULL_REQUEST_TEMPLATE.md

@ -0,0 +1,28 @@
✖ Multiple features in one PR
✖ New Components Unless Previously Discussed with Maintainers (Consider creating separate repo, I'll link out to you)
✔ Add comments to complex/confusing code in "code" view of PR
✔ BUGS → This form is required:
✔ Enhancements → Only specific enhancements with detailed descriptions.
### Issue Titles
Use the format: [Component] Adds Support for Thing
For example: [Build Tools] Adds Source Map Support
Or: [Button] Fixes Inheritance for Red Basic Active State
### Closed Issues
#222 #333 #444
### Description
### Testcase
[Show before with this fiddle]
https://jsfiddle.net/ca0rovs3/
[Consider showing "fixed" case with your fiddle]()
You can link to your JS using https://rawgit.com/

33
wms/contract-repair/semantic/.github/stale.yml

@ -0,0 +1,33 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 90
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
There has been no activity in this thread for 90 days. While we care about
every issue and we’d love to see this fixed, the core team’s time is
limited so we have to focus our attention on the issues that are most
pressing. Therefore, we will likely not be able to get to this one.
However, PRs for this issue will of course be accepted and welcome!
If there is no more activity in the next 90 days, this issue will be closed
automatically for housekeeping. To prevent this, simply leave a reply here.
Thanks!
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue will be closed due to lack of activity for 6 months. If you’d
like this to be reopened, just leave a comment; we do monitor them!

38
wms/contract-repair/semantic/.gitignore

@ -0,0 +1,38 @@
node_modules/
test/coverage/
coverage/
src/**/site/
theme.config
semantic.json
tasks/**/oauth.js
package-lock.json
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~
*.sass-cache
*.ruby-version
# OS or Editor folders
.DS_Store
._*
Thumbs.db
.cache
.project
.settings
.tmproj
.docpad.db
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
.build*
.idea

38
wms/contract-repair/semantic/.jshintrc

@ -0,0 +1,38 @@
{
"globals": {
"$" : true,
"afterEach" : true,
"AnimatedPNG" : true,
"beforeEach" : true,
"console" : true,
"describe" : true,
"expect" : true,
"it" : true,
"jQuery" : true,
"loadFixtures" : true,
"module" : true,
"requestAnimationFrame" : true,
"require" : true,
"semantic" : true
},
"debug" : false,
"devel" : true,
"browser" : true,
"curly" : true,
"immed" : true,
"latedef" : true,
"loopfunc" : true,
"noarg" : true,
"undef" : true,
"sub" : true,
"loopfunc" : true,
"laxbreak" : true,
"evil" : true,
"indent" : false,
"trailing" : false
}

58
wms/contract-repair/semantic/CONTRIBUTING.md

@ -0,0 +1,58 @@
# Contributing to Semantic UI
### Usage Questions
Questions about usage should be asked in our [Gitter chatroom](https://gitter.im/Semantic-Org/Semantic-UI), on [Semantic UI forums](http://forums.semantic-ui.com) or [StackOverflow](http://stackoverflow.com/questions/tagged/semantic-ui).
Examples of usage questions
* *Why isn't my code working?*
* *Can Semantic UI do this?*
Once you receive feedback through community channels you may find your question is actually a bug. At this point it's a good idea to submit it as a bug report. Just keep in mind the following suggestions.
### Creating Bug Reports
[Github Issues Tracker](https://github.com/Semantic-Org/Semantic-UI/issues) is used to track all upcoming milestones and changes to the project.
**Please create a fork of this [JSFiddle](https://jsfiddle.net/ca0rovs3/) to demonstrate bugs.**
When submiting a bug report, include a set of steps to reproduce the issue and any related information, browser, OS etc. If we can't reproduce the issue then it will make solving things much more difficult.
If your bug uses a third party framework like Ember, Meteor, or Angular. Be sure to submit the issue to their respective issues boards. If you are confident the bug is part of the 'vanilla' SUI release, keep in mind not all maintainers are familiar with all framework and a simple test case is greatly appreciated.
If your bug is reproduced by a maintainer it will be assigned the [`confirmed bug`](https://github.com/Semantic-Org/Semantic-UI/issues?q=is%3Aopen+is%3Aissue+label%3A%22Confirmed+Bug%22) tag. Browsing this tag is a good way to keep track of known issues with SUI.
#### Naming Issues
Semantic UI boards use a special naming convention to help tag issue titles by the component the issue is related to.
##### Bugs
Please tag titles in the format "[Component] *Sub-type* should do *correct behavior*". Please use standard [title case](http://www.titlecase.com) for titles, including the bracketed tag.
For example
* [Dropdown] Multiple Selection Should Preserve "Set Selected" Order
* [Validation] - E-mail Validation Should Handle Cyrillic
* [Button] - Grouped Buttons Should Display Correctly on Mobile
##### Enhancements
For new feature requests, you can use the format "[Component] Add *new feature*"
For example
* [Dropdown] Add "Clearable" Setting
* [Validation] Add Rules for Zipcode Validation
* [API] Add "onProgress" callback setting
### Tracking Issue Progress
As bugs and features are triaged they will be assigned to milestones. The best indication of when a change will land is to check the date on the [upcoming milestones](https://github.com/Semantic-Org/Semantic-UI/milestones) page.
### Creating Pull Requests
**All pull requests should be merged into the `next` branch.**
Anyone can jump on the issues board and grab off bugs to fix. This is probably the best way to become a contributor to Semantic. Be sure to adhere to the style guides when submitting code.
* [Create a Pull Request](https://github.com/Semantic-Org/Semantic-UI/compare)
* [View Open Issues](https://github.com/Semantic-Org/Semantic-UI/issues)

7
wms/contract-repair/semantic/LICENSE.md

@ -0,0 +1,7 @@
# The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

112
wms/contract-repair/semantic/README.md

@ -0,0 +1,112 @@
![Semantic](http://semantic-ui.com/images/logo.png)
# Semantic UI
[![Join the chat at https://gitter.im/Semantic-Org/Semantic-UI](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Semantic-Org/Semantic-UI?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![CDNJS](https://img.shields.io/cdnjs/v/semantic-ui.svg)](https://cdnjs.com/libraries/semantic-ui/)
[Semantic](http://www.semantic-ui.com) is a UI framework designed for theming.
Key Features
* 50+ UI elements
* 3000 + CSS variables
* 3 Levels of variable inheritance (similar to SublimeText)
* Built with EM values for responsive design
* Flexbox friendly
Semantic allows developers to build beautiful websites fast, with **concise HTML**, **intuitive javascript**, and **simplified debugging**, helping make front-end development a delightful experience. Semantic is responsively designed allowing your website to scale on multiple devices. Semantic is production ready and partnered with frameworks such as **React**, **Angular**, **Meteor**, and **Ember**, which means you can integrate it with any of these frameworks to organize your UI layer alongside your application logic.
## 2.5.0 Release (Oct 6, 2022)
Semantic UI is now compatible with Node 18 and Gulp 4.
## User Support
Please help us keep the issue tracker organized. For technical questions that do not include a specific [JSFiddle test case](https://jsfiddle.net/ca0rovs3/) (bug reports), or feature request please use [StackOverflow](http://stackoverflow.com/questions/tagged/semantic-ui) to find a solution.
Visit our [contributing guide](https://github.com/Semantic-Org/Semantic-UI/blob/master/CONTRIBUTING.md) for more on what should be posted to GitHub Issues.
## Install
#### Recommended Install
```bash
npm install semantic-ui # Use themes, import build/watch tasks into your own gulpfile.
```
Semantic UI includes an interactive installer to help setup your project.
* For more details on setup visit our [getting started guide](http://semantic-ui.com/introduction/getting-started.html).
* To learn more about theming please read our [theming guide](http://www.semantic-ui.com/usage/theming.html)
#### Additional Versions
Environment | Install Script | Repo
--- | --- | --- |
CSS Only | `npm install semantic-ui-css` | [CSS Repo](https://github.com/Semantic-Org/Semantic-UI-CSS)
[LESS](https://github.com/less/less.js/) Only | `npm install semantic-ui-less` | [LESS Repo](https://github.com/Semantic-Org/Semantic-UI-LESS)
[LESS](https://github.com/less/less.js/) plugin | `npm install less-plugin-semantic-ui` | [LESS Plugin Repo](https://github.com/bassjobsen/less-plugin-semantic-ui/)
[EmberJS](http://emberjs.com/) | `ember install:addon semantic-ui-ember` | [Ember Repo](https://github.com/Semantic-Org/Semantic-UI-Ember)
|[Meteor](https://www.meteor.com/) - [LESS](https://github.com/less/less.js/) | `meteor add semantic:ui` | [Meteor Repo](https://github.com/Semantic-Org/Semantic-UI-Meteor) |
|[Meteor](https://www.meteor.com/) - CSS | `meteor add semantic:ui-css` | [CSS Repo](https://github.com/Semantic-Org/Semantic-UI-CSS) |
[Bower](http://bower.io/) | `bower install semantic-ui` |
Check out our [integration wiki](https://github.com/Semantic-Org/Semantic-UI/wiki/Integration) for more options.
#### Browser Support
* Last 2 Versions FF, Chrome, Safari Mac
* IE 11+
* Android 4.4+, Chrome for Android 44+
* iOS Safari 7+
* Microsoft Edge 12+
Although some components will work in IE9, [grids](http://semantic-ui.com/collections/grid.html) and other [flexbox](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes) components are not supported by IE9 and may not appear correctly.
## Community
#### Getting Help
Please **do not post** usage questions to GitHub Issues. For these types of questions use our [Gitter chatroom][Gitter.im Room] or [StackOverflow](http://stackoverflow.com/questions/tagged/semantic-ui).
#### Submitting Bugs and Enhancements
[GitHub Issues](https://github.com/Semantic-Org/Semantic-UI/issues) is for suggesting enhancements and reporting bugs. Before submiting a bug make sure you do the following:
* Check out our [contributing guide](https://github.com/Semantic-Org/Semantic-UI/blob/master/CONTRIBUTING.md) for info on our release cycle.
* [Fork this boilerplate JSFiddle](https://jsfiddle.net/ca0rovs3/) to create a test case for your bug. If a bug is apparent in the docs, that's ok as a test case, just make it clear exactly how to reproduce the issue. Only bugs that include a test case can be triaged.
#### Pull Requests
When adding pull requests, be sure to merge into the [next](https://github.com/Semantic-Org/Semantic-UI/tree/next) branch. If you need to demonstrate a fix in ``next`` release, you can use [this JSFiddle](https://jsfiddle.net/ca0rovs3/)
#### International
* **Chinese** A Chinese mirror site is available at [http://www.semantic-ui.cn](http://www.semantic-ui.cn).
* **Right-to-Left (RTL)** An RTL version can be created using our build tools by selecting `rtl` from the install script.
* **Translation** To help translate see the [Wiki Guide](https://github.com/Semantic-Org/Semantic-UI/wiki/Translating-Semantic-UI-Docs) for translations.
#### Resources
Resource | Description
--- | --- |
Bugs & Feature Requests | All bug submission **require** a link to a test case, and a set of steps to reproduce the issue. You can make a test case by forking this [JSFiddle](https://jsfiddle.net/ca0rovs3/), then submit your [bug report on GitHub Issues](https://github.com/Semantic-Org/Semantic-UI/issues)
Live Chat | Join our [Gitter.im Room][Gitter.im Room]
Newsletter Updates | Sign up for updates at [semantic-ui.com](http://www.semantic-ui.com)
Additional Resources | Submit a question on [StackOverflow](http://stackoverflow.com/questions/tagged/semantic-ui) or ask our [Google Group](https://groups.google.com/forum/#!forum/semantic-ui)
#### Places to Help
Project | How To Help | Next Step
--- | --- | --- |
Localization | Help us translate Semantic UI into your language | [Join our Translation Community](https://github.com/Semantic-Org/Semantic-UI/wiki/Translating-Semantic-UI-Docs)
[SCSS](http://sass-lang.com/) | SASS needs PR to support variables inside `@import` | [Add Pull Request](https://github.com/sass/sass/pulls) for [#739](https://github.com/sass/sass/issues/739#issuecomment-73984809)
[Angular](https://angularjs.org/) | Help develop angular bindings | Reach Out on [GitHub Issues](https://github.com/Semantic-Org/Semantic-UI-Angular/issues/8)
Guides & Tutorials | Help write guides and tutorials | [Join the discussion](https://github.com/Semantic-Org/Semantic-UI/issues/1571)
#### Reaching Out
If you'd like to start a conversation about Semantic feel free to e-mail me at [jack@semantic-ui.com](mailto:jack@semantic-ui.com)
<a href="http://packagequality.com/#?package=semantic-ui"><img src="http://npm.packagequality.com/badge/semantic-ui.png"/></a>
[Gitter.im Room]: https://gitter.im/Semantic-Org/Semantic-UI

2959
wms/contract-repair/semantic/RELEASE-NOTES.md

File diff suppressed because it is too large

5
wms/contract-repair/semantic/Semantic-UI-master/.browserlistrc

@ -0,0 +1,5 @@
last 2 versions
> 1%
opera 12.1
bb 10
android 4

322
wms/contract-repair/semantic/Semantic-UI-master/.csscomb.json

@ -0,0 +1,322 @@
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "upper",
"block-indent": " ",
"color-shorthand": false,
"element-case": "lower",
"leading-zero": true,
"space-after-colon": " ",
"space-before-combinator": " ",
"space-after-combinator": " ",
"space-between-declarations": "\n",
"space-before-opening-brace": " ",
"space-after-opening-brace": "\n",
"space-after-selector-delimiter": "\n",
"space-before-selector-delimiter": "",
"space-before-closing-brace": "\n",
"strip-spaces": true,
"tab-size": true,
"vendor-prefix-align": true,
"sort-order": [
[
"display",
"visibility",
"float",
"clear",
"overflow",
"overflow-x",
"overflow-y",
"-webkit-box-sizing",
"-moz-box-sizing",
"box-sizing",
"-ms-overflow-x",
"-ms-overflow-y",
"clip",
"zoom",
"flex-direction",
"flex-order",
"flex-pack",
"flex-align"
],
[
"position",
"z-index",
"top",
"right",
"bottom",
"left"
],
[
"font",
"font-family",
"font-size",
"font-weight",
"font-style",
"font-variant",
"font-size-adjust",
"font-stretch",
"font-effect",
"font-emphasize",
"font-emphasize-position",
"font-emphasize-style",
"font-smooth",
"line-height"
],
[
"width",
"min-width",
"max-width",
"height",
"min-height",
"max-height",
"margin",
"margin-top",
"margin-right",
"margin-bottom",
"margin-left",
"padding",
"padding-top",
"padding-right",
"padding-bottom",
"padding-left"
],
[
"table-layout",
"empty-cells",
"caption-side",
"border-spacing",
"border-collapse",
"list-style",
"list-style-position",
"list-style-type",
"list-style-image"
],
[
"opacity",
"filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
"-ms-filter:\\'progid:DXImageTransform.Microsoft.Alpha",
"-ms-interpolation-mode",
"color",
"border",
"border-width",
"border-style",
"border-color",
"border-top",
"border-top-width",
"border-top-style",
"border-top-color",
"border-right",
"border-right-width",
"border-right-style",
"border-right-color",
"border-bottom",
"border-bottom-width",
"border-bottom-style",
"border-bottom-color",
"border-left",
"border-left-width",
"border-left-style",
"border-left-color",
"-webkit-border-radius",
"-moz-border-radius",
"border-radius",
"-webkit-border-top-left-radius",
"-moz-border-radius-topleft",
"border-top-left-radius",
"-webkit-border-top-right-radius",
"-moz-border-radius-topright",
"border-top-right-radius",
"-webkit-border-bottom-right-radius",
"-moz-border-radius-bottomright",
"border-bottom-right-radius",
"-webkit-border-bottom-left-radius",
"-moz-border-radius-bottomleft",
"border-bottom-left-radius",
"-webkit-border-image",
"-moz-border-image",
"-o-border-image",
"border-image",
"-webkit-border-image-source",
"-moz-border-image-source",
"-o-border-image-source",
"border-image-source",
"-webkit-border-image-slice",
"-moz-border-image-slice",
"-o-border-image-slice",
"border-image-slice",
"-webkit-border-image-width",
"-moz-border-image-width",
"-o-border-image-width",
"border-image-width",
"-webkit-border-image-outset",
"-moz-border-image-outset",
"-o-border-image-outset",
"border-image-outset",
"-webkit-border-image-repeat",
"-moz-border-image-repeat",
"-o-border-image-repeat",
"border-image-repeat",
"outline",
"outline-width",
"outline-style",
"outline-color",
"outline-offset",
"background",
"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
"background-color",
"background-image",
"background-repeat",
"background-attachment",
"background-position",
"background-position-x",
"-ms-background-position-x",
"background-position-y",
"-ms-background-position-y",
"-webkit-background-clip",
"-moz-background-clip",
"background-clip",
"background-origin",
"-webkit-background-size",
"-moz-background-size",
"-o-background-size",
"background-size",
"box-decoration-break",
"-webkit-box-shadow",
"-moz-box-shadow",
"box-shadow",
"filter:progid:DXImageTransform.Microsoft.gradient",
"-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient",
"text-shadow"
],
[
"content",
"quotes",
"counter-reset",
"counter-increment",
"resize",
"cursor",
"-webkit-user-select",
"-moz-user-select",
"-ms-user-select",
"user-select",
"nav-index",
"nav-up",
"nav-right",
"nav-down",
"nav-left",
"-webkit-transition",
"-moz-transition",
"-ms-transition",
"-o-transition",
"transition",
"-webkit-transition-delay",
"-moz-transition-delay",
"-ms-transition-delay",
"-o-transition-delay",
"transition-delay",
"-webkit-transition-timing-function",
"-moz-transition-timing-function",
"-ms-transition-timing-function",
"-o-transition-timing-function",
"transition-timing-function",
"-webkit-transition-duration",
"-moz-transition-duration",
"-ms-transition-duration",
"-o-transition-duration",
"transition-duration",
"-webkit-transition-property",
"-moz-transition-property",
"-ms-transition-property",
"-o-transition-property",
"transition-property",
"-webkit-transform",
"-moz-transform",
"-ms-transform",
"-o-transform",
"transform",
"-webkit-transform-origin",
"-moz-transform-origin",
"-ms-transform-origin",
"-o-transform-origin",
"transform-origin",
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-name",
"-moz-animation-name",
"-ms-animation-name",
"-o-animation-name",
"animation-name",
"-webkit-animation-duration",
"-moz-animation-duration",
"-ms-animation-duration",
"-o-animation-duration",
"animation-duration",
"-webkit-animation-play-state",
"-moz-animation-play-state",
"-ms-animation-play-state",
"-o-animation-play-state",
"animation-play-state",
"-webkit-animation-timing-function",
"-moz-animation-timing-function",
"-ms-animation-timing-function",
"-o-animation-timing-function",
"animation-timing-function",
"-webkit-animation-delay",
"-moz-animation-delay",
"-ms-animation-delay",
"-o-animation-delay",
"animation-delay",
"-webkit-animation-iteration-count",
"-moz-animation-iteration-count",
"-ms-animation-iteration-count",
"-o-animation-iteration-count",
"animation-iteration-count",
"-webkit-animation-direction",
"-moz-animation-direction",
"-ms-animation-direction",
"-o-animation-direction",
"animation-direction",
"text-align",
"-webkit-text-align-last",
"-moz-text-align-last",
"-ms-text-align-last",
"text-align-last",
"vertical-align",
"white-space",
"text-decoration",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-style",
"text-emphasis-position",
"text-indent",
"-ms-text-justify",
"text-justify",
"letter-spacing",
"word-spacing",
"-ms-writing-mode",
"text-outline",
"text-transform",
"text-wrap",
"text-overflow",
"-ms-text-overflow",
"text-overflow-ellipsis",
"text-overflow-mode",
"-ms-word-wrap",
"word-wrap",
"word-break",
"-ms-word-break",
"-moz-tab-size",
"-o-tab-size",
"tab-size",
"-webkit-hyphens",
"-moz-hyphens",
"hyphens",
"pointer-events"
]
]
}

18
wms/contract-repair/semantic/Semantic-UI-master/.csslintrc

@ -0,0 +1,18 @@
{
"vendor-prefix" : true,
"duplicate-properties" : true,
"display-property-grouping" : true,
"empty-rules" : true,
"adjoining-classes" : false,
"box-model" : false,
"compatible-vendor-prefixes" : false,
"box-sizing" : false,
"duplicate-background-images" : false,
"floats" : false,
"important" : false,
"overqualified-elements" : false,
"rules-count" : false,
"shorthand" : false,
"zero-units" : false
}

24
wms/contract-repair/semantic/Semantic-UI-master/.github/ISSUE_TEMPLATE.md

@ -0,0 +1,24 @@
✖ USAGE QUESTIONS → Use these dedicated resources:
Docs - http://www.semantic-ui.com
Chat - https://gitter.im/Semantic-Org/Semantic-UI
SO - https://stackoverflow.com/questions/tagged/semantic-ui?sort=votes
✔ Enhancements → Be specific. Assume backwards compatibility is a necessity. Suggest implementation when possible.
✔ BUGS → ❤❤❤. Keep in mind some bugs may not be immediately fixable due to backwards compatibility or CSS limitations.
### Title (Put in field above)
Use the format: [Component] Component Should Do X
i.e. [Checkbox] onChange Should Fire When Update Triggered via DOM
### Steps
### Expected Result
### Actual Result
### Version
x.y.z
### Testcase
[Fork, update, and replace to show the bug]:
https://jsfiddle.net/ca0rovs3/

28
wms/contract-repair/semantic/Semantic-UI-master/.github/PULL_REQUEST_TEMPLATE.md

@ -0,0 +1,28 @@
✖ Multiple features in one PR
✖ New Components Unless Previously Discussed with Maintainers (Consider creating separate repo, I'll link out to you)
✔ Add comments to complex/confusing code in "code" view of PR
✔ BUGS → This form is required:
✔ Enhancements → Only specific enhancements with detailed descriptions.
### Issue Titles
Use the format: [Component] Adds Support for Thing
For example: [Build Tools] Adds Source Map Support
Or: [Button] Fixes Inheritance for Red Basic Active State
### Closed Issues
#222 #333 #444
### Description
### Testcase
[Show before with this fiddle]
https://jsfiddle.net/ca0rovs3/
[Consider showing "fixed" case with your fiddle]()
You can link to your JS using https://rawgit.com/

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save