22 changed files with 885 additions and 544 deletions
@ -1,8 +1,48 @@ |
|||||
<html> |
<html> |
||||
<head> |
|
||||
<meta http-equiv="refresh" content="0;url= https://masada-tw.com/ "> |
|
||||
</head> |
|
||||
<body> |
|
||||
|
|
||||
</body> |
<head> |
||||
</html> |
<!-- <meta http-equiv="refresh" content="0;url= https://masada-tw.com/ "> --> |
||||
|
<meta charset="utf-8"> |
||||
|
<script src="https://cdn.tailwindcss.com"></script> |
||||
|
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script> |
||||
|
<script> |
||||
|
tailwind.config = { |
||||
|
theme: { |
||||
|
extend: { |
||||
|
colors: { |
||||
|
clifford: '#da373d', |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
<style type="text/tailwindcss"> |
||||
|
@layer utilities { |
||||
|
.content-auto { |
||||
|
content-visibility: auto; |
||||
|
} |
||||
|
} |
||||
|
</style> |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div class="flex justify-center items-center h-screen bg-blue-500"> |
||||
|
<div class="bg-white p-8 rounded-lg"> |
||||
|
<img src="/wms/assets/img/logo.png" alt="LOGO" class="mb-4 mx-auto w-[350]"> |
||||
|
<h1 class="text-2xl font-bold mb-4 text-center">開發連結</h1> |
||||
|
<ul> |
||||
|
<li class="p-3 text-cyan-700"> |
||||
|
<a href="/wms">wms</a> |
||||
|
</li> |
||||
|
<li class="p-3 text-cyan-700"> |
||||
|
<a href="/app">app</a> |
||||
|
</li> |
||||
|
<li class="p-3 text-cyan-700"> |
||||
|
<a href="http://10.10.1.3/phpmyadmin" target="_blank">開發用資料庫</a> |
||||
|
</li> |
||||
|
</ul> |
||||
|
</div> |
||||
|
</div> |
||||
|
</body> |
||||
|
|
||||
|
</html> |
@ -1,75 +1,153 @@ |
|||||
<?php |
<?php |
||||
$id= ""; |
$id = ""; |
||||
$accounttype= ""; |
$accounttype = ""; |
||||
$accountid= ""; |
$accountid = ""; |
||||
$pwd= ""; |
$pwd = ""; |
||||
$name= ""; |
$name = ""; |
||||
$tel= ""; |
$tel = ""; |
||||
$address= ""; |
$address = ""; |
||||
$email= ""; |
$email = ""; |
||||
$lineid= ""; |
$lineid = ""; |
||||
$wechatid= ""; |
$wechatid = ""; |
||||
$phone_call_help= ""; |
$phone_call_help = ""; |
||||
$chat_for_help= ""; |
$chat_for_help = ""; |
||||
$remote_help= ""; |
$remote_help = ""; |
||||
$repairerid= ""; |
$repairerid = ""; |
||||
$manager= ""; |
$manager = ""; |
||||
$creater= ""; |
$creater = ""; |
||||
$create_at= ""; |
$create_at = ""; |
||||
|
|
||||
|
|
||||
|
|
||||
$id_error = ""; |
$id_error = ""; |
||||
$accounttype_error= ""; |
$accounttype_error = ""; |
||||
$accountid_error= ""; |
$accountid_error = ""; |
||||
$pwd_error= ""; |
$pwd_error = ""; |
||||
$name_error= ""; |
$name_error = ""; |
||||
$tel_error= ""; |
$tel_error = ""; |
||||
$address_error= ""; |
$address_error = ""; |
||||
$email_error= ""; |
$email_error = ""; |
||||
$lineid_error= ""; |
$lineid_error = ""; |
||||
$wechatid_error= ""; |
$wechatid_error = ""; |
||||
$phone_call_help_error= ""; |
$phone_call_help_error = ""; |
||||
$chat_for_help_error= ""; |
$chat_for_help_error = ""; |
||||
$remote_help_error= ""; |
$remote_help_error = ""; |
||||
$repairerid_error= ""; |
$repairerid_error = ""; |
||||
$manager_error= ""; |
$manager_error = ""; |
||||
$creater_error= ""; |
$creater_error = ""; |
||||
$create_at_error= ""; |
$create_at_error = ""; |
||||
|
$department_id_error = ""; |
||||
|
$role_id_error = ""; |
||||
|
|
||||
|
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
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 "; |
include "account-user-input.php"; |
||||
$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"|| $accounttype == "W") && $department_id && $role_id) { |
if ($link->connect_errno) { |
||||
$db_query = "insert into account_auth (accountid, permission) "; |
echo "連接 MySQL 失敗:" . $link->connect_error; |
||||
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'"; |
exit(); |
||||
$res = mysqli_query($link, $db_query); |
|
||||
} |
} |
||||
|
|
||||
// mysqli_insert_id可以抓到第一筆的id |
// 開始事務 |
||||
//$new_id= mysqli_insert_id ($link); |
$link->begin_transaction(); |
||||
#echo "新增後的id為 {$id} "; |
try { |
||||
$affected = mysqli_affected_rows($link); |
|
||||
mysqli_close($link); |
if (in_array($accounttype, ["B", "E", "M", "W"])) { |
||||
if ($affected > 0) { |
if (empty($department_id)) { |
||||
// 如果有一筆以上代表有更新 |
$department_id_error = "部門未填寫"; |
||||
echo "<script>"; |
throw new Exception('部門未填寫'); |
||||
echo "alert('新增成功');"; |
} |
||||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
if (empty($role_id)) { |
||||
echo "</script>"; |
$role_id_error = "職別未填寫"; |
||||
} elseif ($affected == 0) { |
throw new Exception('職別未填寫'); |
||||
echo "<script>"; |
} |
||||
echo "alert('無新增資料');"; |
} |
||||
echo "location.href='account-index.php?function_name=account&".$token_link."';"; |
|
||||
echo "</script>"; |
|
||||
} else { |
// 新增帳號 table account |
||||
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); |
$sql = "INSERT INTO account ( |
||||
|
accounttype, accountid, pwd, name, tel, |
||||
|
address, email, lineid, wechatid, phone_call_help, |
||||
|
chat_for_help, remote_help, repairerid, manager, department_id, |
||||
|
role_id, creater, create_at |
||||
|
)VALUES( |
||||
|
?,?,?,?,?,?,?,?,?,?, |
||||
|
?,?,?,?,?,?,?,? |
||||
|
) |
||||
|
"; |
||||
|
$stmt = $link->prepare($sql); |
||||
|
$stmt->bind_param( |
||||
|
'ssssssssssssssssss', |
||||
|
$i_data['accounttype'], |
||||
|
$i_data['accountid'], |
||||
|
$i_data['pwd'], |
||||
|
$i_data['name'], |
||||
|
$i_data['tel'], |
||||
|
$i_data['address'], |
||||
|
$i_data['email'], |
||||
|
$i_data['lineid'], |
||||
|
$i_data['wechatid'], |
||||
|
$i_data['phone_call_help'], |
||||
|
$i_data['chat_for_help'], |
||||
|
$i_data['remote_help'], |
||||
|
$i_data['repairerid'], |
||||
|
$i_data['manager'], |
||||
|
$i_data['department_id'], |
||||
|
$i_data['role_id'], |
||||
|
$i_data['creater'], |
||||
|
$i_data['create_at'] |
||||
|
); |
||||
|
$stmt->execute(); |
||||
|
|
||||
|
// 新增權限 table account_auth |
||||
|
if (in_array($accounttype, ["B", "E", "M", "W"])) { |
||||
|
$sql = "INSERT INTO account_auth (accountid, permission) |
||||
|
SELECT '$accountid', permission FROM department WHERE department_id = ? AND role_id = ? |
||||
|
"; |
||||
|
$stmt2 = $link->prepare($sql); |
||||
|
$stmt2->bind_param('ss', $department_id, $role_id); |
||||
|
$stmt2->execute(); |
||||
|
} |
||||
|
|
||||
|
// 新增帳號 table employee |
||||
|
$sql = " |
||||
|
INSERT INTO employee ( |
||||
|
employee_no, |
||||
|
depart_no, |
||||
|
name, |
||||
|
mail |
||||
|
)VALUES( |
||||
|
?, |
||||
|
?, |
||||
|
?, |
||||
|
? |
||||
|
); |
||||
|
"; |
||||
|
$stmt3 = $link->prepare($sql); |
||||
|
$stmt3->bind_param('ssss', $i_data['accountid'], $i_data['department_id'], $i_data['name'], $i_data['email']); |
||||
|
$stmt3->execute(); |
||||
|
|
||||
|
$link->commit(); |
||||
|
|
||||
|
$url = "location.href='account-index.php?function_name=account&" . $token_link . "';"; |
||||
|
redircetTo($url); |
||||
|
} catch (Exception $e) { |
||||
|
// 如果發生任何錯誤,回滾事務 |
||||
|
$link->rollback(); |
||||
|
// echo "rollback:" . $e->getMessage(); |
||||
} |
} |
||||
|
|
||||
|
// 關閉連接 |
||||
|
$link->close(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function redircetTo($url) |
||||
|
{ |
||||
|
echo "<script type='text/JavaScript'>"; |
||||
|
echo "alert('新增失敗');"; |
||||
|
echo "location.href='" . $url . "';"; |
||||
|
echo "</script>"; |
||||
} |
} |
||||
?> |
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue