Browse Source

1.選單新增部門可以批次可讀可寫

2.修正大日程倉管的edit標籤
3.系統改為網址有帶入 token 即可自動登入系統
4.新增在裝中統計表
gary
gary_chen\gary_chen 1 year ago
parent
commit
54c4ce2cd9
  1. 7
      wms/fun_global.php
  2. 22
      wms/header.php
  3. 353
      wms/menu-edit.php
  4. 140
      wms/menu-record-update.php
  5. 30
      wms/wipwhole-change-contractdate.php
  6. 31
      wms/wipwhole-change-planning-customer-name.php
  7. 2
      wms/wipwhole-index-function.php
  8. 2
      wms/wipwhole-renovate-index-function.php
  9. 673
      wms/wipwhole-wipinstallstatus-index.php

7
wms/fun_global.php

@ -563,3 +563,10 @@ function sign_status($arr) {
} }
return $ret; return $ret;
} }
function getAccounttype($link,$user_id){
$sql = "SELECT * FROM account where accountid = '$user_id'";
$data = mysqli_query($link, $sql);
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
return $row['accounttype'];
}

22
wms/header.php

@ -23,7 +23,7 @@ if (isset($_REQUEST["function_name"])) {
try { try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "@m222222"); $conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "@m222222");
if ($conn) { if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} }
} catch (PDOException $e) { } catch (PDOException $e) {
//echo "fail"; //echo "fail";
@ -46,6 +46,24 @@ $token_link = "token=" . $_REQUEST["token"];
list($user_id, $enc_user_name, $login_dt) = explode(".", $token); list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$user_name = urldecode(base64_decode($enc_user_name)); $user_name = urldecode(base64_decode($enc_user_name));
$user_id = !empty($_GET["employee_no"]) ? $_GET["employee_no"] : $user_id;
$login_dt = !empty($_GET["timestamp"]) ? $_GET["timestamp"] : $login_dt;
include 'IncludeCommon.php';
$includecommon = new IncludeCommon();
$accounttype = getAccounttype($link, $user_id);
$login_json = null;
if (strlen($accounttype) != 0) {
$jsonres['menu'] = $includecommon->menu_v3($user_id, $accounttype);
$login_json = json_encode($jsonres, JSON_UNESCAPED_UNICODE);
}
?>
<script>
res = eval("(" + JSON.stringify(<?php echo $login_json; ?>) + ")");
window.localStorage.setItem("menu_<?php echo $user_id; ?>", res.menu);
</script>
<?php
// uesr可操作權限 // uesr可操作權限
$user_auth = check_user_permission($user_id, $token); $user_auth = check_user_permission($user_id, $token);
@ -145,7 +163,7 @@ $user_auth = check_user_permission($user_id, $token);
@media screen and (max-width: 992px) { @media screen and (max-width: 992px) {
#member_content_phone { #member_content_phone {
display:inline-grid !important; display: inline-grid !important;
} }
} }
</style> </style>

353
wms/menu-edit.php

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

140
wms/menu-record-update.php

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

30
wms/wipwhole-change-contractdate.php

@ -1,36 +1,6 @@
<?php <?php
// ini_set('display_errors', 'on'); // ini_set('display_errors', 'on');
function getAccounttype($link,$user_id){
$sql = "SELECT * FROM account where accountid = '$user_id'";
$data = mysqli_query($link, $sql);
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
return $row['accounttype'];
}
include 'IncludeCommon.php';
require_once "database.php";
$includecommon = new IncludeCommon();
$token = empty($token) ? $_REQUEST["token"] : $token;
$token_link = "token=" . $token;
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$user_name = urldecode(base64_decode($enc_user_name));
$accounttype = getAccounttype($link,$user_id);
$data = array();
$login_json = null;
if (strlen($accounttype) != 0) {
$jsonres['menu']=$includecommon->menu_v3($user_id, $accounttype);
$login_json = json_encode($jsonres, JSON_UNESCAPED_UNICODE);
}
?>
<script>
res=eval("("+JSON.stringify(<?php echo $login_json; ?>)+")");
window.localStorage.setItem("menu_<?php echo $user_id; ?>",res.menu);
</script>
<?php
/* /*
1. 有 cid 是已申請過的單 1. 有 cid 是已申請過的單
2. 沒有 cid 是新申請單 2. 沒有 cid 是新申請單

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

@ -1,37 +1,6 @@
<?php <?php
// ini_set('display_errors', 'on'); // ini_set('display_errors', 'on');
function getAccounttype($link, $user_id)
{
$sql = "SELECT * FROM account where accountid = '$user_id'";
$data = mysqli_query($link, $sql);
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
return $row['accounttype'];
}
include 'IncludeCommon.php';
require_once "database.php";
$includecommon = new IncludeCommon();
$token = empty($token) ? $_REQUEST["token"] : $token;
$token_link = "token=" . $token;
list($user_id, $enc_user_name, $login_dt) = explode(".", $token);
$user_name = urldecode(base64_decode($enc_user_name));
$accounttype = getAccounttype($link, $user_id);
$data = array();
$login_json = null;
if (strlen($accounttype) != 0) {
$jsonres['menu'] = $includecommon->menu_v3($user_id, $accounttype);
$login_json = json_encode($jsonres, JSON_UNESCAPED_UNICODE);
}
?>
<script>
res = eval("(" + JSON.stringify(<?php echo $login_json; ?>) + ")");
window.localStorage.setItem("menu_<?php echo $user_id; ?>", res.menu);
</script>
<?php
/* /*
1. 有 cid 是已申請過的單 1. 有 cid 是已申請過的單
2. 沒有 cid 是新申請單 2. 沒有 cid 是新申請單

2
wms/wipwhole-index-function.php

@ -76,7 +76,7 @@ function getEditFlag($department_id, $role_id, $user_id)
if ($department_id == "321") if ($department_id == "321")
return 8; return 8;
// 鍾哥(生管) 部門代碼:250 職位大小:1 4 // 鍾哥(生管) 部門代碼:250 職位大小:1 4
if ($department_id == "250" && in_array($role_id, ["1", "4"])) if ($department_id == "250")
return 8; return 8;
// 許協理 部門代碼:320 職位大小:1 // 許協理 部門代碼:320 職位大小:1
if ($department_id == "320" && $role_id == "1") if ($department_id == "320" && $role_id == "1")

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

@ -334,7 +334,7 @@ function getEditFlag($department_id, $role_id, $user_id)
if ($department_id == "321") if ($department_id == "321")
return 8; return 8;
if ($department_id == "250" && in_array($role_id, ["1", "4"])) if ($department_id == "250")
return 8; return 8;
if ($department_id == "320" && $role_id == "1") if ($department_id == "320" && $role_id == "1")
return 8; return 8;

673
wms/wipwhole-wipinstallstatus-index.php

@ -0,0 +1,673 @@
<?php
// ini_set('display_errors', 'on');
// 新梯
// $Adata
// 出貨台數 = 有實際出貨日期
// $Adata2
// 在裝台數 = 已出貨且官檢日跟移交日都沒填日期
// $Adata3
// 工收台數 = 已出貨且官檢日或移交日其中一個有日期
// 合計
// $data
// 出貨台數 = 有實際出貨日期
// $data2
// 在裝台數 = 已出貨且官檢日跟移交日都沒填日期
// $data3
// 工收台數 = 已出貨且官檢日或移交日其中一個有日期
$real_arrival_date_start = empty($_REQUEST['real_arrival_date_start']) ? date("Y") . '-01' : $_REQUEST['real_arrival_date_start'];
$real_arrival_date_end = empty($_REQUEST['real_arrival_date_end']) ? date("Y-m") : $_REQUEST['real_arrival_date_end'];
$radsY = SUBSTR($real_arrival_date_start, 0, 4);
$radsM = SUBSTR($real_arrival_date_start, 5, 2);
$radeY = SUBSTR($real_arrival_date_end, 0, 4);
$radeM = SUBSTR($real_arrival_date_end, 5, 2);
include "header.php";
// 新梯-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata = $result->fetch_all(MYSQLI_ASSOC);
// 新梯-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata2 = $result->fetch_all(MYSQLI_ASSOC);
// 新梯-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'A'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Adata3 = $result->fetch_all(MYSQLI_ASSOC);
// M1-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data = $result->fetch_all(MYSQLI_ASSOC);
// M1-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data2 = $result->fetch_all(MYSQLI_ASSOC);
// M1-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%M1%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$M1data3 = $result->fetch_all(MYSQLI_ASSOC);
// MA-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata = $result->fetch_all(MYSQLI_ASSOC);
// MA-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata2 = $result->fetch_all(MYSQLI_ASSOC);
// MA-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND contract_type = 'B'
AND renovate_type like '%MA%'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$Madata3 = $result->fetch_all(MYSQLI_ASSOC);
// 合計-出貨台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data = $result->fetch_all(MYSQLI_ASSOC);
// 合計-在裝台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND (
delivery_date IS NULL
OR delivery_date = ''
)AND (
official_check_date IS NULL
OR official_check_date = ''
)
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data2 = $result->fetch_all(MYSQLI_ASSOC);
// 合計-工收台數
$sql = "
SELECT
SUBSTR(real_arrival_date,1,4) AS year,
SUBSTR(real_arrival_date,6,2) AS month,
COUNT(real_arrival_date) AS all_count
FROM wipwholestatus
WHERE status = '1'
AND (
real_arrival_date IS NOT NULL
AND real_arrival_date != ''
)AND ((
delivery_date IS NOT NULL
AND delivery_date != ''
)OR (
official_check_date IS NOT NULL
AND official_check_date != ''
))
GROUP BY year, month
";
$result = mysqli_query($link, $sql);
$data_count = $result->num_rows;
$data3 = $result->fetch_all(MYSQLI_ASSOC);
?>
<form id='myForm' method='post' action='wipwhole-wipinstallstatus-index.php?<?= $token_link ?>'>
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td>
<h3 style='text-align:center'>在裝中統計表</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style='text-align:center'>
<?php
if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
echo "<span class='text-danger'>結束時間不可小於開始時間</span>";
}
?>
</td>
</tr>
<tr>
<td style='text-align:center'>
<input type="month" class='form-control' id='real_contract_arrival_date_start' name='real_arrival_date_start' value="<?php echo $real_arrival_date_start; ?>" style='width:20%;display:inline;'>
<input type="month" class='form-control' id='real_arrival_date_end' name='real_arrival_date_end' value="<?php echo $real_arrival_date_end; ?>" style='width:20%;display:inline;'>
</td>
</tr>
<tr>
<td style='text-align:center'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='clean_all_input()'>清除</button>
<!-- <button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='generateButton()'>匯出excel</button> -->
</td>
</tr>
</tfoot>
</table>
</form>
<?php
if ((int)$radsY . $radsM > (int)$radeY . $radeM) {
exit;
}
?>
<table class="table table-striped table-bordered" style="width:98.5%;overflow-x:auto">
<thead>
<tr>
<th style="width:150px;" rowspan="2">出貨年月</th>
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
?>
<th style='text-align:center;' colspan="<?php echo $end_month * 3 ?>"><?php echo $radsYi . '年'; ?></th>
<?php
}
?>
<th style='width:200px' colspan="3" rowspan="2">總計(全部)</th>
</tr>
<tr>
<!-- <th style="width:150px;"></th> -->
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
?>
<th style='width:200px' colspan="3"><?php echo (int)$start_month . '月'; ?></th>
<?php
}
?>
<?php
}
?>
<!-- <th style='width:200px' colspan="3" rowspan="2"></th> -->
</tr>
<tr>
<th>種類</th>
<?php
$start_y = $radsY;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
?>
<th style="background-color:#CECECE;">出貨</th>
<th style="background-color:#DEDEDE;">工收</th>
<th>在裝</th>
<?php
}
?>
<?php
}
?>
<th style="background-color:#FF8040;">出貨</th>
<th style="background-color:#FFAF60;">工收</th>
<th style="background-color:#9D9D9D;">在裝</th>
</tr>
</thead>
<tbody>
<tr>
<td>新梯</td>
<?php
$a_count = 0;
$b_count = 0;
$c_count = 0;
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
$all_count = 0;
foreach ($Adata as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
echo "<td style='background-color:#CECECE;'>$all_count</td>";
$all_count = 0;
foreach ($Adata3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
$all_count = 0;
foreach ($Adata2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
<td>M1</td>
<?php
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
$all_count = 0;
foreach ($M1data as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
echo "<td style='background-color:#CECECE;'>$all_count</td>";
$all_count = 0;
foreach ($M1data3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
$all_count = 0;
foreach ($M1data2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
<td>MA</td>
<?php
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
$all_count = 0;
foreach ($Madata as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
echo "<td style='background-color:#CECECE;'>$all_count</td>";
$all_count = 0;
foreach ($Madata3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
$all_count = 0;
foreach ($Madata2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
<tr>
<td>合計</td>
<?php
for ($radsYi = $radsY; $radsYi <= $radeY; $radsYi++) {
$start_month = 1;
$end_month = 12;
// 迴圈第一年
if ($start_y == $radsYi) {
$start_month = $radsM;
} else {
$start_month = 1;
}
// 迴圈最後一年
if ($radsYi == $radeY) {
$end_month = $radeM;
}
for ($start_month; $start_month <= $end_month; $start_month++) {
$all_count = 0;
foreach ($data as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$a_count += $all_count;
break;
}
}
echo "<td style='background-color:#CECECE;'>$all_count</td>";
$all_count = 0;
foreach ($data3 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$b_count += $all_count;
break;
}
}
echo "<td style='background-color:#DEDEDE;'>$all_count</td>";
$all_count = 0;
foreach ($data2 as $row) {
if ($radsYi == $row['year'] && $start_month == $row['month']) {
$all_count = $row['all_count'];
$c_count += $all_count;
break;
}
}
echo "<td>$all_count</td>";
}
?>
<?php
}
echo "<td style='background-color:#FF8040;'>$a_count</td>";
echo "<td style='background-color:#FFAF60;'>$b_count</td>";
echo "<td style='background-color:#9D9D9D;'>$c_count</td>";
?>
</tr>
</tbody>
</table>
<script>
</script>
Loading…
Cancel
Save