Browse Source

20231024(二)更新CODE

gary
IA2301\M0117 2 years ago
parent
commit
c157aacff5
  1. 960
      wms/createFacilityNo.php
  2. 468
      wms/wipwhole-index-table-html.php
  3. 479
      wms/wipwhole-renovate-index-table-html.php
  4. 978
      wms/wipwhole-renovate-index.php

960
wms/createFacilityNo.php

@ -1,481 +1,481 @@
<?php
ini_set('display_errors', 'on');
// 汰改 前三碼 流水號 + 後兩碼 號機
// 新梯 流水號
class CreateFacilityNo
{
/**
* 連接資料庫
*/
function connectionDB()
{
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=localhost;port=3306;dbname=appwms', 'masadaroot', 'x6h5E5p#u8y', $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 string $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
. 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
. 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
. 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 string $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
. 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
. 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
. 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("B");
return $new_facility_no_arr;
}
}
/**
* 檢查作番編列狀態 - 新梯
* @param array $faclikity_details
* @return string $status : 1:正確 else:error message
*/
function getMakeNewMFacilityNoStatus($faclikity_details)
{
$Y = substr(date("Y"), 3, 1);
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
$next_seq = $this->getNextFacilitySeq("mf_vol_no");
$new_facility_no = $Y . $sale_type . $make_type . str_pad($next_seq + 1, 5, "0", STR_PAD_LEFT);
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)
{
$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");
$new_facility_no = $Y . $sale_type . $make_type
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($num, 2, "0", STR_PAD_LEFT);
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 true;
return false;
}
/**
* 檢查 $sale_type 是否有存在規則之中
* @param string $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @return boolean $status : true:合法代碼 false:非法代碼
*/
function checkMakeTypeStatus($make_type)
{
if (in_array($make_type, ['X', 'W', 'H', 'Z', 'F', 'B', 'Q', 'T', 'N', 'W', 'J', 'Y']))
return true;
return false;
}
/**
* 檢查 取得下個作番的 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 string $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)
{
$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 string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param string $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)
{
$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 string $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)
{
$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", 5));
echo "<br/><br/>";
// 建立作番號 - 汰改
print_r($cfn->makeTFacilityNo( "M", "X", 1));
echo "<br/><br/>";
// 建立作番號 - 保養
print_r($cfn->makeBFacilityNo( "M", "X", 1));
<?php
ini_set('display_errors', 'on');
// 汰改 前三碼 流水號 + 後兩碼 號機
// 新梯 流水號
class CreateFacilityNo
{
/**
* 連接資料庫
*/
function connectionDB()
{
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=localhost;port=3306;dbname=appwms', 'masadaroot', 'x6h5E5p#u8y', $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 string $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
. 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
. 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
. 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 string $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
. 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
. 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
. 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("B");
return $new_facility_no_arr;
}
}
/**
* 檢查作番編列狀態 - 新梯
* @param array $faclikity_details
* @return string $status : 1:正確 else:error message
*/
function getMakeNewMFacilityNoStatus($faclikity_details)
{
$Y = substr(date("Y"), 3, 1);
$sale_type = $faclikity_details['sale_type'];
$make_type = $faclikity_details['make_type'];
$next_seq = $this->getNextFacilitySeq("mf_vol_no");
$new_facility_no = $Y . $sale_type . $make_type . str_pad($next_seq + 1, 5, "0", STR_PAD_LEFT);
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)
{
$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");
$new_facility_no = $Y . $sale_type . $make_type
. str_pad($next_seq + 1, 3, "0", STR_PAD_LEFT)
. str_pad($num, 2, "0", STR_PAD_LEFT);
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 true;
return false;
}
/**
* 檢查 $sale_type 是否有存在規則之中
* @param string $make_type : X:小機房 W:無機房 H:家用梯 Z:雜物梯 F:扶梯 B:部品 Q:品保對策 T:研究開發 N:設備 W:出貨現場要求購買 J:營業問題對策 Y:已出貨作番營業進行規格訂正
* @return boolean $status : true:合法代碼 false:非法代碼
*/
function checkMakeTypeStatus($make_type)
{
if (in_array($make_type, ['X', 'W', 'H', 'Z', 'F', 'B', 'Q', 'T', 'N', 'W', 'J', 'Y']))
return true;
return false;
}
/**
* 檢查 取得下個作番的 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 string $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)
{
$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 string $sale_type : M:内銷 E:外銷 T:他社维保 J:汰改 X:特殊部品
* @param string $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)
{
$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 string $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)
{
$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", 5));
echo "<br/><br/>";
// 建立作番號 - 汰改
print_r($cfn->makeTFacilityNo( "M", "X", 1));
echo "<br/><br/>";
// 建立作番號 - 保養
print_r($cfn->makeBFacilityNo( "M", "X", 1));
echo "<br/><br/>";

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

@ -1,224 +1,246 @@
<table id="table_index2" class="table table-striped table-bordered" style="width:98.5%">
<thead>
<tr>
<th style="vertical-align: middle;text-align:center;">合約號</th>
<th style="vertical-align: middle;text-align:center;">電梯編號</th>
<th style="vertical-align: middle;text-align:center;">客戶姓名</th>
<th style="vertical-align: middle;text-align:center;">地址</th>
<th style="vertical-align: middle;text-align:center;">工勘狀態</th>
<th style="vertical-align: middle;text-align:center;">下單日<br />(普來特富)</th>
<th style="vertical-align: middle;text-align:center;">預計到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">實際到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">預計出貨日<br />(到工地)</th>
<th style="vertical-align: middle;text-align:center;">營業/契約確認</th>
<th style="vertical-align: middle;text-align:center;">設計確認</th>
<th style="vertical-align: middle;text-align:center;">工務確認</th>
<th style="vertical-align: middle;text-align:center;">生管(業 務)確認</th>
</tr>
</thead>
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
//工務
$data['gongwuok'] = 0;
// 營業
$data['yingyeok'] = 0;
// 設計
$data['shejiok'] = 0;
// 生管
$data['shengguanok'] = 0;
// 財務
// $caiwuok = 0;
// 工務統計已確認
if ($data['building_heigh_verify'] == 0 || $data['building_heigh_verify'] == 2)
$data['gongwuok'] += 1;
if (!in_array($data['site_survey_contact_verify'], ['1', 'A']))
$data['gongwuok'] += 1;
// 營業統計已確認
if ($data['sales_spec_verify'] == 0 || $data['sales_spec_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_planning_verify'] == 0 || $data['customer_planning_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_color_verify'] == 0 || $data['customer_color_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_style_verify'] == 0 || $data['customer_style_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['site_survey_contact_form_verify'] == 0 || $data['site_survey_contact_form_verify'] == 2)
$data['yingyeok'] += 1;
// 設計統計已確認
if ($data['desin_spec_verify'] == 0 || $data['desin_spec_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_planning_verify'] == 0 || $data['desin_planning_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_color_verify'] == 0 || $data['desin_color_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_style_verify'] == 0 || $data['desin_style_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_leader_verify'] == 0 || $data['desin_leader_verify'] == 2)
$data['shejiok'] += 1;
// 生管統計已確認
if ($data['shengguanok_status'] == 0 || $data['shengguanok_status'] == 2)
$data['shengguanok'] += 1;
if ($data['prattford_order_date_verify'] == 0 || $data['prattford_order_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_date_verify'] == 0 || $data['estimated_shipping_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_schedule_date_verify'] == 0 || $data['estimated_shipping_schedule_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['goods_type'] == 'A' || $data['goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['taiwan_goods_type'] == 'A' || $data['taiwan_goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['arrival_date_verify'] == 'A')
$data['shengguanok'] += 1;
?>
<tr>
<td>
<?php
if (in_array($department_id, [311, 312, 313, 314, 315, 501, 511, 512, 513, 513, 220, 911])) {
$sql = "
SELECT
mid,
pr_item_id,
version
FROM specsurvey_main
WHERE contractno = '" . $data['contractno'] . "'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
if (empty($row['mid'])) {
echo $data['contractno'];
} else {
echo "<a target='_blank' href='/wms/mkt/specsurvey-view.php?pa=" . $row['mid'] . "," . $row['pr_item_id'] . "," . $row['version'] . "&$token_link'>" . $data['contractno'] . "</a>";
}
} else {
echo $data['contractno'];
}
?>
</td>
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $data['address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {
if (in_array($data['site_survey_contact_verify'], ['1', 'A'])) {
echo "<td style='color:#F00;'>$val</td>";
} else {
echo "<td>$val</td>";
}
}
}
?>
<td>
<?php
if (!empty($data['prattford_order_date']))
echo date("Y/m/d", strtotime($data['prattford_order_date']));
?>
</td>
<td>
<?php
if (!empty($data['estimated_shipping_schedule_date']))
echo date("Y/m/d", strtotime($data['estimated_shipping_schedule_date']));
?>
</td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<?php
if (!empty($data['real_contract_arrival_date'])) {
if ($futureDate >= date("Y/m/d", strtotime($data['real_contract_arrival_date']))) {
if ($data['yingyeok'] != '5' && $data['shejiok'] != '5' && $data['gongwuok'] != '2' && $data['shengguanok'] != '1') {
echo "<td style='color:#f00;'>" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td></td>";
}
?>
<td>
<?php
$str = $data['yingyeok'] . "/5";
if ($edit_flag & 1 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php echo accountidToName($data['salesid']); ?>
</a>
</p>
<?php
} else echo $str . " " . accountidToName($data['salesid']);
?>
</td>
<td>
<?php
$str = $data['shejiok'] . "/5";
if ($edit_flag & 2 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
郭承瑋
</a>
</p>
<?php
} else echo $str . " 郭承瑋";
?>
</td>
<td>
<?php
$str = $data['gongwuok'] . "/2";
if ($edit_flag & 4 && ($user_auth & 2)) {
?>
<p>
<?php
echo $str;
?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php
echo getGunwuName($data['address']);
?>
</a>
</p>
<?php
} else {
echo $str;
echo getGunwuName($data['address']);
}
?>
</td>
<td>
<?php
$str = $data['shengguanok'] . "/7";
if ($edit_flag & 8 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
<?php
} else echo $str . " ";
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php
$tableArr = array(
"All" => "table_index2",
"A" => "table_index3",
"B" => "table_index4",
"G" => "table_index5",
"CH" => "table_index6",
"Z" => "table_index7"
);
?>
<table id="<?php echo $tableArr[$key]; ?>" class="table table-striped table-bordered" style="width:98.5%">
<thead>
<tr>
<th style="vertical-align: middle;text-align:center;">合約號</th>
<th style="vertical-align: middle;text-align:center;">電梯編號</th>
<th style="vertical-align: middle;text-align:center;">客戶姓名</th>
<th style="vertical-align: middle;text-align:center;">規格</th>
<th style="vertical-align: middle;text-align:center;">地址</th>
<th style="vertical-align: middle;text-align:center;">工勘狀態</th>
<th style="vertical-align: middle;text-align:center;">下單日<br />(普來特富)</th>
<th style="vertical-align: middle;text-align:center;">預計到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">實際到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">預計出貨日<br />(到工地)</th>
<th style="vertical-align: middle;text-align:center;">營業/契約確認</th>
<th style="vertical-align: middle;text-align:center;">設計確認</th>
<th style="vertical-align: middle;text-align:center;">工務確認</th>
<th style="vertical-align: middle;text-align:center;">生管(業 務)確認</th>
</tr>
</thead>
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
//規格
$Specification = $data['facility_kind'];
$Specification .= !empty($data['numberofpassenger']) ? "-" . $data['numberofpassenger'] : "";
$Specification .= !empty($data['weight']) ? "-" . $data['weight'] : "";
$Specification .= !empty($data['numberofstop']) ? "-" . $data['numberofstop'] : "";
$Specification .= !empty($data['numberoffloor']) ? "/" . $data['numberoffloor'] : "";
$Specification .= !empty($data['opentype']) ? "-" . $data['opentype'] : "";
$Specification .= !empty($data['speed']) ? $data['speed'] : "";
//工務
$data['gongwuok'] = 0;
// 營業
$data['yingyeok'] = 0;
// 設計
$data['shejiok'] = 0;
// 生管
$data['shengguanok'] = 0;
// 財務
// $caiwuok = 0;
// 工務統計已確認
if ($data['building_heigh_verify'] == 0 || $data['building_heigh_verify'] == 2)
$data['gongwuok'] += 1;
if (!in_array($data['site_survey_contact_verify'], ['1', 'A']))
$data['gongwuok'] += 1;
// 營業統計已確認
if ($data['sales_spec_verify'] == 0 || $data['sales_spec_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_planning_verify'] == 0 || $data['customer_planning_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_color_verify'] == 0 || $data['customer_color_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_style_verify'] == 0 || $data['customer_style_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['site_survey_contact_form_verify'] == 0 || $data['site_survey_contact_form_verify'] == 2)
$data['yingyeok'] += 1;
// 設計統計已確認
if ($data['desin_spec_verify'] == 0 || $data['desin_spec_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_planning_verify'] == 0 || $data['desin_planning_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_color_verify'] == 0 || $data['desin_color_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_style_verify'] == 0 || $data['desin_style_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_leader_verify'] == 0 || $data['desin_leader_verify'] == 2)
$data['shejiok'] += 1;
// 生管統計已確認
if ($data['shengguanok_status'] == 0 || $data['shengguanok_status'] == 2)
$data['shengguanok'] += 1;
if ($data['prattford_order_date_verify'] == 0 || $data['prattford_order_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_date_verify'] == 0 || $data['estimated_shipping_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_schedule_date_verify'] == 0 || $data['estimated_shipping_schedule_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['goods_type'] == 'A' || $data['goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['taiwan_goods_type'] == 'A' || $data['taiwan_goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['arrival_date_verify'] == 'A')
$data['shengguanok'] += 1;
?>
<tr>
<td>
<?php
if (in_array($department_id, [311, 312, 313, 314, 315, 501, 511, 512, 513, 513, 220, 911])) {
$sql = "
SELECT
mid,
pr_item_id,
version
FROM specsurvey_main
WHERE contractno = '" . $data['contractno'] . "'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
if (empty($row['mid'])) {
echo $data['contractno'];
} else {
echo "<a target='_blank' href='/wms/mkt/specsurvey-view.php?pa=" . $row['mid'] . "," . $row['pr_item_id'] . "," . $row['version'] . "&$token_link'>" . $data['contractno'] . "</a>";
}
} else {
echo $data['contractno'];
}
?>
</td>
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $Specification; ?></td>
<td><?php echo $data['address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {
if (in_array($data['site_survey_contact_verify'], ['1', 'A'])) {
echo "<td style='color:#F00;'>$val</td>";
} else {
echo "<td>$val</td>";
}
}
}
?>
<td>
<?php
if (!empty($data['prattford_order_date']))
echo date("Y/m/d", strtotime($data['prattford_order_date']));
?>
</td>
<td>
<?php
if (!empty($data['estimated_shipping_schedule_date']))
echo date("Y/m/d", strtotime($data['estimated_shipping_schedule_date']));
?>
</td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<?php
if (!empty($data['real_contract_arrival_date'])) {
if ($futureDate >= date("Y/m/d", strtotime($data['real_contract_arrival_date']))) {
if ($data['yingyeok'] != '5' && $data['shejiok'] != '5' && $data['gongwuok'] != '2' && $data['shengguanok'] != '1') {
echo "<td style='color:#f00;'>" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td></td>";
}
?>
<td>
<?php
$str = $data['yingyeok'] . "/5";
if ($edit_flag & 1 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php echo accountidToName($data['salesid']); ?>
</a>
</p>
<?php
} else echo $str . " " . accountidToName($data['salesid']);
?>
</td>
<td>
<?php
$str = $data['shejiok'] . "/5";
if ($edit_flag & 2 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
郭承瑋
</a>
</p>
<?php
} else echo $str . " 郭承瑋";
?>
</td>
<td>
<?php
$str = $data['gongwuok'] . "/2";
if ($edit_flag & 4 && ($user_auth & 2)) {
?>
<p>
<?php
echo $str;
?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php
echo getGunwuName($data['address']);
?>
</a>
</p>
<?php
} else {
echo $str;
echo getGunwuName($data['address']);
}
?>
</td>
<td>
<?php
$str = $data['shengguanok'] . "/7";
if ($edit_flag & 8 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-rec-invoice-edit.php?function_name=wipwholestatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
<?php
} else echo $str . " ";
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

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

@ -1,229 +1,252 @@
<table id="table_index2" class="table table-striped table-bordered dt-responsive nowrap" style="width:98.5%">
<thead>
<tr>
<th style="vertical-align: middle;text-align:center;">合約號</th>
<th style="vertical-align: middle;text-align:center;">汰改種類</th>
<th style="vertical-align: middle;text-align:center;">電梯編號</th>
<th style="vertical-align: middle;text-align:center;">客戶姓名</th>
<th style="vertical-align: middle;text-align:center;">地址</th>
<th style="vertical-align: middle;text-align:center;">工勘狀態</th>
<th style="vertical-align: middle;text-align:center;">下單日<br />(普來特富)</th>
<th style="vertical-align: middle;text-align:center;">預計到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">實際到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">預計出貨日<br />(到工地)</th>
<th style="vertical-align: middle;text-align:center;">工務確認</th>
<th style="vertical-align: middle;text-align:center;">營業/契約確認</th>
<th style="vertical-align: middle;text-align:center;">設計確認</th>
<th style="vertical-align: middle;text-align:center;">生管(業務)<br />確認</th>
</tr>
</thead>
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
// 營業
$data['yingyeok'] = 0;
// 設計
$data['shejiok'] = 0;
// 工務
$data['gongwuok'] = 0;
// 生管
$data['shengguanok'] = 0;
// 財務
// $data['caiwuok'] = 0;
// 工務統計已確認
if ($data['building_heigh_verify'] == 0 || $data['building_heigh_verify'] == 2)
$data['gongwuok'] += 1;
if (!in_array($data['site_survey_contact_verify'], ['1', 'A']))
$data['gongwuok'] += 1;
if ($data['customer_planning_verify'] == 0 || $data['customer_planning_verify'] == 2)
$data['gongwuok'] += 1;
// 營業統計已確認
if ($data['sales_spec_verify'] == 0 || $data['sales_spec_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_color_verify'] == 0 || $data['customer_color_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_style_verify'] == 0 || $data['customer_style_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['site_survey_contact_form_verify'] == 0 || $data['site_survey_contact_form_verify'] == 2)
$data['yingyeok'] += 1;
// 設計統計已確認
if ($data['desin_spec_verify'] == 0 || $data['desin_spec_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_planning_verify'] == 0 || $data['desin_planning_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_color_verify'] == 0 || $data['desin_color_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_style_verify'] == 0 || $data['desin_style_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_leader_verify'] == 0 || $data['desin_leader_verify'] == 2)
$data['shejiok'] += 1;
// 生管統計已確認
if ($data['shengguanok_status'] == 0 || $data['shengguanok_status'] == 2)
$data['shengguanok'] += 1;
if ($data['prattford_order_date_verify'] == 0 || $data['prattford_order_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_date_verify'] == 0 || $data['estimated_shipping_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_schedule_date_verify'] == 0 || $data['estimated_shipping_schedule_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['goods_type'] == 'A' || $data['goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['taiwan_goods_type'] == 'A' || $data['taiwan_goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['arrival_date_verify'] == 'A')
$data['shengguanok'] += 1;
?>
<tr>
<td>
<?php
if (in_array($department_id, [311, 312, 313, 314,315, 501, 511, 512, 513, 514, 220, 911])) {
$sql = "
SELECT
mid,
pr_item_id,
version
FROM specsurvey_main
WHERE contractno = '" . $data['contractno'] . "'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
if (empty($row['mid'])) {
echo $data['contractno'];
} else {
echo "<a target='_blank' href='/wms/mkt/specsurvey_renovate-view.php?pa=" . $row['mid'] . "," . $row['pr_item_id'] . "," . $row['version'] . "&$token_link'>" . $data['contractno'] . "</a>";
}
} else {
echo $data['contractno'];
}
?>
</td>
<td>
<?php
// 汰改 json 轉字串組合 ex M1+M2
echo implode("+", json_decode($data['renovate_type']));
?>
</td>
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $data['address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {
if (in_array($data['site_survey_contact_verify'], ['1', 'A'])) {
echo "<td style='color:#F00;'>$val</td>";
} else {
echo "<td>$val</td>";
}
}
}
?>
<td>
<?php
if (!empty($data['prattford_order_date']))
echo date("Y/m/d", strtotime($data['prattford_order_date']));
?>
</td>
<td>
<?php
if (!empty($data['estimated_shipping_schedule_date']))
echo date("Y/m/d", strtotime($data['estimated_shipping_schedule_date']));
?>
</td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<?php
if (!empty($data['real_contract_arrival_date'])) {
if ($futureDate >= date("Y/m/d", strtotime($data['real_contract_arrival_date']))) {
if ($data['yingyeok'] != '4' && $data['shejiok'] != '5' && $data['gongwuok'] != '3' && $data['shengguanok'] != '1') {
echo "<td style='color:#f00;'>" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td></td>";
}
?>
<td>
<?php
$str = $data['gongwuok'] . "/3";
if ($edit_flag & 4 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php
echo getGunwuName($data['address']);
?>
</a>
</p>
<?php
} else {
echo $str;
echo getGunwuName($data['address']);
}
?>
</td>
<td>
<?php
$str = $data['yingyeok'] . "/4";
if ($edit_flag & 1 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<!-- <span class="glyphicon glyphicon-pencil"></span> -->
<?php echo accountidToName($data['salesid']); ?>
</a>
</p>
<?php
} else echo $str . " " . accountidToName($data['salesid']);
?>
</td>
<td>
<?php
$str = $data['shejiok'] . "/5";
if ($edit_flag & 2 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
林昭翰
</a>
</p>
<?php
} else echo $str . "林昭翰";
?>
</td>
<td>
<?php
$str = $data['shengguanok'] . "/7";
if ($edit_flag & 8 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
<?php
} else echo $str . " ";
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php
$tableArr = array(
"All" => "table_index2",
"A" => "table_index3",
"B" => "table_index4",
"C" => "table_index5",
"D" => "table_index6",
"Z" => "table_index7"
);
?>
<table id="<?php echo $tableArr[$key]; ?>" class="table table-striped table-bordered dt-responsive nowrap" style="width:98.5%">
<thead>
<tr>
<th style="vertical-align: middle;text-align:center;">合約號</th>
<th style="vertical-align: middle;text-align:center;">汰改種類</th>
<th style="vertical-align: middle;text-align:center;">電梯編號</th>
<th style="vertical-align: middle;text-align:center;">客戶姓名</th>
<th style="vertical-align: middle;text-align:center;">規格</th>
<th style="vertical-align: middle;text-align:center;">地址</th>
<th style="vertical-align: middle;text-align:center;">工勘狀態</th>
<th style="vertical-align: middle;text-align:center;">下單日<br />(普來特富)</th>
<th style="vertical-align: middle;text-align:center;">預計到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">實際到廠日<br />(觀音廠)</th>
<th style="vertical-align: middle;text-align:center;">預計出貨日<br />(到工地)</th>
<th style="vertical-align: middle;text-align:center;">工務確認</th>
<th style="vertical-align: middle;text-align:center;">營業/契約確認</th>
<th style="vertical-align: middle;text-align:center;">設計確認</th>
<th style="vertical-align: middle;text-align:center;">生管(業務)<br />確認</th>
</tr>
</thead>
<tbody>
<?php
foreach ($dataDetailsArr as $key => $data) :
//規格
$Specification = $data['facility_kind'];
$Specification .= !empty($data['numberofpassenger']) ? "-" . $data['numberofpassenger'] : "";
$Specification .= !empty($data['weight']) ? "-" . $data['weight'] : "";
$Specification .= !empty($data['numberofstop']) ? "-" . $data['numberofstop'] : "";
$Specification .= !empty($data['numberoffloor']) ? "/" . $data['numberoffloor'] : "";
$Specification .= !empty($data['opentype']) ? "-" . $data['opentype'] : "";
$Specification .= !empty($data['speed']) ? $data['speed'] : "";
// 營業
$data['yingyeok'] = 0;
// 設計
$data['shejiok'] = 0;
// 工務
$data['gongwuok'] = 0;
// 生管
$data['shengguanok'] = 0;
// 財務
// $data['caiwuok'] = 0;
// 工務統計已確認
if ($data['building_heigh_verify'] == 0 || $data['building_heigh_verify'] == 2)
$data['gongwuok'] += 1;
if (!in_array($data['site_survey_contact_verify'], ['1', 'A']))
$data['gongwuok'] += 1;
if ($data['customer_planning_verify'] == 0 || $data['customer_planning_verify'] == 2)
$data['gongwuok'] += 1;
// 營業統計已確認
if ($data['sales_spec_verify'] == 0 || $data['sales_spec_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_color_verify'] == 0 || $data['customer_color_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['customer_style_verify'] == 0 || $data['customer_style_verify'] == 2)
$data['yingyeok'] += 1;
if ($data['site_survey_contact_form_verify'] == 0 || $data['site_survey_contact_form_verify'] == 2)
$data['yingyeok'] += 1;
// 設計統計已確認
if ($data['desin_spec_verify'] == 0 || $data['desin_spec_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_planning_verify'] == 0 || $data['desin_planning_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_color_verify'] == 0 || $data['desin_color_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_style_verify'] == 0 || $data['desin_style_verify'] == 2)
$data['shejiok'] += 1;
if ($data['desin_leader_verify'] == 0 || $data['desin_leader_verify'] == 2)
$data['shejiok'] += 1;
// 生管統計已確認
if ($data['shengguanok_status'] == 0 || $data['shengguanok_status'] == 2)
$data['shengguanok'] += 1;
if ($data['prattford_order_date_verify'] == 0 || $data['prattford_order_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_date_verify'] == 0 || $data['estimated_shipping_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['estimated_shipping_schedule_date_verify'] == 0 || $data['estimated_shipping_schedule_date_verify'] == 2)
$data['shengguanok'] += 1;
if ($data['goods_type'] == 'A' || $data['goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['taiwan_goods_type'] == 'A' || $data['taiwan_goods_type'] == 'C')
$data['shengguanok'] += 1;
if ($data['arrival_date_verify'] == 'A')
$data['shengguanok'] += 1;
?>
<tr>
<td>
<?php
if (in_array($department_id, [311, 312, 313, 314, 315, 501, 511, 512, 513, 514, 220, 911])) {
$sql = "
SELECT
mid,
pr_item_id,
version
FROM specsurvey_main
WHERE contractno = '" . $data['contractno'] . "'
";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
if (empty($row['mid'])) {
echo $data['contractno'];
} else {
echo "<a target='_blank' href='/wms/mkt/specsurvey_renovate-view.php?pa=" . $row['mid'] . "," . $row['pr_item_id'] . "," . $row['version'] . "&$token_link'>" . $data['contractno'] . "</a>";
}
} else {
echo $data['contractno'];
}
?>
</td>
<td>
<?php
// 汰改 json 轉字串組合 ex M1+M2
echo implode("+", json_decode($data['renovate_type']));
?>
</td>
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['custom']; ?></td>
<td><?php echo $Specification; ?></td>
<td><?php echo $data['address']; ?></td>
<?php
foreach ($site_survey_status as $key => $val) {
if ((string)$data['site_survey_contact_verify'] == (string)$key) {
if (in_array($data['site_survey_contact_verify'], ['1', 'A'])) {
echo "<td style='color:#F00;'>$val</td>";
} else {
echo "<td>$val</td>";
}
}
}
?>
<td>
<?php
if (!empty($data['prattford_order_date']))
echo date("Y/m/d", strtotime($data['prattford_order_date']));
?>
</td>
<td>
<?php
if (!empty($data['estimated_shipping_schedule_date']))
echo date("Y/m/d", strtotime($data['estimated_shipping_schedule_date']));
?>
</td>
<td>
<?php
if (!empty($data['actual_tofactory_date']))
echo date("Y/m/d", strtotime($data['actual_tofactory_date']));
?>
</td>
<?php
if (!empty($data['real_contract_arrival_date'])) {
if ($futureDate >= date("Y/m/d", strtotime($data['real_contract_arrival_date']))) {
if ($data['yingyeok'] != '4' && $data['shejiok'] != '5' && $data['gongwuok'] != '3' && $data['shengguanok'] != '1') {
echo "<td style='color:#f00;'>" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td >" . date("Y/m/d", strtotime($data['real_contract_arrival_date'])) . "</td>";
}
} else {
echo "<td></td>";
}
?>
<td>
<?php
$str = $data['gongwuok'] . "/3";
if ($edit_flag & 4 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<?php
echo getGunwuName($data['address']);
?>
</a>
</p>
<?php
} else {
echo $str;
echo getGunwuName($data['address']);
}
?>
</td>
<td>
<?php
$str = $data['yingyeok'] . "/4";
if ($edit_flag & 1 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<!-- <span class="glyphicon glyphicon-pencil"></span> -->
<?php echo accountidToName($data['salesid']); ?>
</a>
</p>
<?php
} else echo $str . " " . accountidToName($data['salesid']);
?>
</td>
<td>
<?php
$str = $data['shejiok'] . "/5";
if ($edit_flag & 2 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
林昭翰
</a>
</p>
<?php
} else echo $str . "林昭翰";
?>
</td>
<td>
<?php
$str = $data['shengguanok'] . "/7";
if ($edit_flag & 8 && ($user_auth & 2)) {
?>
<p>
<?php echo $str; ?>
<a target='_blank' href="wipwhole-renovate-rec-invoice-edit.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>&id=<?php echo $data['id']; ?>" class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
<?php
} else echo $str . " ";
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

978
wms/wipwhole-renovate-index.php

@ -1,462 +1,518 @@
<?php
// ini_set('display_errors', 'on');
/**
* 權限規則:
* 1.營業經理查看全部 部門代碼:311 312 313 314 315
* 2.營業員瀏覽自己合約資料 部門代碼:511 512 513 514
* 3.設計部門代碼:911
* 4.工務:宜蘭=高培軒(M0087) 北=吳宗紘(M0040) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102)
* 5.生管:伃廷(M0024)
* 6.鍾哥 部門代碼:250 職位大小:1 4
* 7.許協理 部門代碼:320 職位大小:1
* 8.詹總 部門代碼:50 職位大小:1
* 9.許總 部門代碼:20 職位大小:1
*
* 新梯 543 筆 (已匯入)
* 舊改 141 筆 (已匯入)
* 已簽回 684 筆 (共計)
*/
include "header.php";
include "wipwhole-renovate-index-function.php";
include "css/view/wipwhole-renovate-index.php";
// 設定警告出貨到期的天數
$numberOfDaysToAdd = 45;
$futureDate = date("Y/m/d", strtotime(date("Y-m-d") . " +{$numberOfDaysToAdd} days"));
// 主資料陣列
$data = array();
// 取得當前使用者所屬部門
$department_id = getDepartmentId($link, $user_id);
// 取得當前使用者所屬職位
$role_id = getRoleId($link, $user_id);
// 下方編輯按鈕權限
// 1=營叢 2=設計 4=工務 8=生管 15=其他
$edit_flag = getEditFlag($department_id, $role_id, $user_id);
// 接受搜尋 post 後觸發
$contractno = empty($_REQUEST['contractno']) ? null : $_REQUEST['contractno'];
$facilityno = empty($_REQUEST['facilityno']) ? null : $_REQUEST['facilityno'];
$custom = empty($_REQUEST['custom']) ? null : $_REQUEST['custom'];
$site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ? '' : $_REQUEST['site_survey_contact_verify'];
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : $_REQUEST['real_contract_arrival_date_start'];
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : $_REQUEST['real_contract_arrival_date_end'];
$area_no = !isset($_REQUEST['area_no']) ? '' : $_REQUEST['area_no'];
// 取得資料 sql
$sql = getDataSql($department_id, $role_id, $user_id);
$data = mysqli_query($link, $sql);
// 取得資料(工勘部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "A");
$dataA = mysqli_query($link, $sql);
// 取得資料(營業部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "B");
$dataB = mysqli_query($link, $sql);
// 取得資料(設計部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "C");
$dataC = mysqli_query($link, $sql);
// 取得資料(生管階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "D");
$dataD = mysqli_query($link, $sql);
// 取得資料(結案階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "Z");
$dataZ = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
<form id='myForm' method='post' action='wipwhole-renovate-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 colspan="9">
<h3 style='text-align:center'>作番大日程(汰改)</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th>合約號</th>
<td><input type="text" class='form-control' id='contractno' name='contractno' value="<?php echo $contractno; ?>"></td>
<th>電梯編號</th>
<td><input type="text" class='form-control' id='facilityno' name='facilityno' value="<?php echo $facilityno; ?>"></td>
<th>客戶姓名</th>
<td><input type="text" class='form-control' id='custom' name='custom' value="<?php echo $custom; ?>"></td>
<th>預計出貨日</th>
<td colspan="2">
<input type="date" class='form-control' id='real_contract_arrival_date_start' name='real_contract_arrival_date_start' value="<?php echo $real_contract_arrival_date_start; ?>" style='width:40%;display:inline;'>
<input type="date" class='form-control' id='real_contract_arrival_date_end' name='real_contract_arrival_date_end' value="<?php echo $real_contract_arrival_date_end; ?>" style='width:40%;display:inline;'>
</td>
</tr>
<tr>
<th>
區域
</th>
<td>
<?php
$area_status = array(
"" => "全部",
"N" => "N:北區",
"Y" => "Y:宜蘭",
"T" => "T:桃區",
"C" => "C:中區",
"K" => "K:南區"
);
?>
<select name="area_no" id="area_no">
<?php
foreach ($area_status as $key => $val) {
if ((string)$area_no == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<th>
工勘狀態
</th>
<td>
<?php
$site_survey_status = array(
"0" => "已確認",
"1" => "未確認",
"2" => "無工勘需求",
"A" => "未動工",
"B" => "地下室施工",
"C" => "打樁",
"D" => "地基",
"E" => "挖土",
"G" => "機房",
"H" => "機械式淨高",
"M" => "樓中樓",
"OH" => "最高層(頂樓高度)",
"P" => "PIT(機坑深度)",
"R" => "R 樓",
"S" => "停工",
"T" => "TOP",
"TC" => "頂部間隙",
"TS" => "行程",
"TH" => "全高",
"Y" => "已搭、已出",
"YB" => "退購結案",
"YF" => "既有建物",
"YN" => "已搭、未出"
);
for ($i = 1; $i < 200; $i++) {
$site_survey_status[$i . "F"] = $i . "F";
}
?>
<select style="width:100%;" name="site_survey_contact_verify" id="site_survey_contact_verify">
<?php
echo "<option value=''>全部</option>";
foreach ($site_survey_status as $key => $val) {
if ((string)$site_survey_contact_verify == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<td colspan="5" style='text-align:left'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
<?php
if ($department_id == '321' || $department_id == '220') {
?>
<a href="wipwhole-renovate-rec-invoice.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">新增</a>
<?php
}
?>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_input()'><?php echo $numberOfDaysToAdd; ?>天內資料</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_all_input()'><?php echo $numberOfDaysToAdd; ?>天內資料(含今天以前)</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>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='estimatedShippingDateReportButton()'>出貨地區預定明細</button>
</td>
</tr>
</tfoot>
</table>
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showCTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showDTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
</nav>
<?php
$dataArr = array(
"All" => $data,
"A" => $dataA,
"B" => $dataB,
"C" => $dataC,
"D" => $dataD,
"Z" => $dataZ
);
foreach ($dataArr as $key => $val) {
if ($val) :
$dataDetailsArr = $val;
echo "<div id='data_" . $key . "_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
endif;
}
#結束連線
mysqli_close($link);
?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
var sheetNum = "<?php echo empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum']; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
$(".data_table_div").hide();
showTable(sheetNum);
})
const formData = new FormData();
formData.append("contractno", "<?php echo empty($_POST['contractno']) ? null : $_POST['contractno']; ?>");
formData.append("facilityno", "<?php echo empty($_POST['facilityno']) ? null : $_POST['facilityno']; ?>");
formData.append("custom", "<?php echo empty($_POST['custom']) ? null : $_POST['custom']; ?>");
formData.append("site_survey_contact_verify", "<?php echo empty($_POST['site_survey_contact_verify']) ? '' : $_POST['site_survey_contact_verify']; ?>");
formData.append("real_contract_arrival_date_start", "<?php echo empty($_POST['real_contract_arrival_date_start']) ? null : $_POST['real_contract_arrival_date_start']; ?>");
formData.append("real_contract_arrival_date_end", "<?php echo empty($_POST['real_contract_arrival_date_end']) ? null : $_POST['real_contract_arrival_date_end']; ?>");
formData.append("area_no", "<?php echo empty($_POST['area_no']) ? null : $_POST['area_no']; ?>");
// 使用 JavaScript 監聽按鈕點擊事件
function generateButton() {
// 使用 XMLHttpRequest 來呼叫 PHP 檔案,生成 Excel
var xhr = new XMLHttpRequest();
xhr.open('POST', window.location.origin + "/wms/wipwhole-renovate-index-export-excel.php?<?= $token_link ?>", true);
xhr.responseType = 'text';
xhr.onload = function() {
if (xhr.status === 200) {
// 取得 PHP 回傳的檔案路徑
var response = xhr.responseText;
console.log(xhr.responseText);
var file_path = xhr.responseText;
// 創建下載連結
var link = document.createElement('a');
link.setAttribute('href', window.location.origin + "/wms/excel/gary_test.xlsx");
// 設定下載的檔案名稱
link.setAttribute('download', '作番大日程報表(汰改).xlsx');
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};
xhr.send(formData);
}
function clean_all_input() {
document.getElementById("site_survey_contact_verify").value = "";
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "";
document.getElementById("myForm").submit();
}
function day_before_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "<?php echo date("Y-m-d"); ?>";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function day_before_all_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function estimatedShippingDateReportButton() {
window.location.href = '<?php echo "/wms/estimated_shipping_date_report.php?$token_link" ?>';
}
$('#table_index2,#table_index3,#table_index4,#table_index5,#table_index6,#table_index7').DataTable({
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示_MENU_ 筆",
"zeroRecords": "沒有符合的結果",
"info": "第 _START_ 至 _END_ 項,共 _TOTAL_ 項",
"infoEmpty": "第 0 至 0 項,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
}
}, {
"order": [
[4, "desc"],
[8, "asc"]
]
}
);
function showAllTable() {
sheetNum = "All";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showATable() {
sheetNum = "A";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showBTable() {
sheetNum = "B";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showCTable() {
sheetNum = "C";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showDTable() {
sheetNum = "D";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showZTable() {
sheetNum = "Z";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showTable(code) {
var tmp_arr = {
"All": "1",
"A": "2",
"B": "3",
"C": "4",
"D": "5",
"Z": "6",
}
$("body > nav.navbar.navbar-tabs > div > ul > li").attr("class", "");
$("body > nav.navbar.navbar-tabs > div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
$(".data_table_div").hide();
$("#data_" + code + "_table_div").show();
}
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index3_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index4_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index5_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index6_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index7_filter > label > input").placeholder = "快速搜尋";
// datatable 畫面重整後保留資料
var contractno = $("#contractno").val();
var facilityno = $("#facilityno").val();
var custom = $("#custom").val();
var site_survey_contact_verify = $("#site_survey_contact_verify").val();
var real_contract_arrival_date_start = $("#real_contract_arrival_date_start").val();
var real_contract_arrival_date_end = $("#real_contract_arrival_date_end").val();
var area_no = $("#area_no").val();
var showNum = <?php echo empty($_GET['showNum']) ? '10' : $_GET['showNum']; ?>;
var nowPage = <?php echo empty($_GET['nowPage']) ? '1' : $_GET['nowPage']; ?>;
var searchContent = "<?php echo empty($_GET['searchContent']) ? '' : $_GET['searchContent']; ?>";
var dataArr2 = {
"All": "table_index2",
"A": "table_index3",
"B": "table_index4",
"C": "table_index5",
"D": "table_index6",
"Z": "table_index7",
}
var table = $('#' + dataArr2[sheetNum]).DataTable();
table.search(searchContent).draw();
table.page.len(showNum).draw();
table.page((nowPage) - 1).draw('page');
// 監聽頁碼
table.on('page.dt', function() {
searchDatatable(table);
});
// 監聽資料筆數
table.on('length.dt', function(e, settings, len) {
searchDatatable(table);
});
// 監聽搜尋事件
$("#" + dataArr2[sheetNum] + "_filter > label > input").change(function() {
searchDatatable(table);
});
function searchDatatable(table) {
showNum = table.page.len();
nowPage = table.page.info().page + 1;
searchContent = table.search();
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" +
"&showNum=" + showNum + "&nowPage=" + nowPage + "&searchContent=" + searchContent + "&sheetNum=" + sheetNum +
"&contractno=" + contractno + "&facilityno=" + facilityno + "&custom=" + custom +
"&site_survey_contact_verify=" + site_survey_contact_verify + "&real_contract_arrival_date_start=" + real_contract_arrival_date_start +
"&real_contract_arrival_date_end=" + real_contract_arrival_date_end + "&area_no=" + area_no;
}
<?php
// ini_set('display_errors', 'on');
/**
* 權限規則:
* 1.營業經理查看全部 部門代碼:311 312 313 314 315
* 2.營業員瀏覽自己合約資料 部門代碼:511 512 513 514
* 3.設計部門代碼:911
* 4.工務:宜蘭=高培軒(M0087) 北=吳宗紘(M0040) 中=林瑋隆(M0113) 南=韋宗榮(M0039)改鄭存邑(M0102)
* 5.生管:伃廷(M0024)
* 6.鍾哥 部門代碼:250 職位大小:1 4
* 7.許協理 部門代碼:320 職位大小:1
* 8.詹總 部門代碼:50 職位大小:1
* 9.許總 部門代碼:20 職位大小:1
*
* 新梯 543 筆 (已匯入)
* 舊改 141 筆 (已匯入)
* 已簽回 684 筆 (共計)
*/
include "header.php";
include "wipwhole-renovate-index-function.php";
include "css/view/wipwhole-renovate-index.php";
// 設定警告出貨到期的天數
$numberOfDaysToAdd = 45;
$futureDate = date("Y/m/d", strtotime(date("Y-m-d") . " +{$numberOfDaysToAdd} days"));
// 主資料陣列
$data = array();
// 取得當前使用者所屬部門
$department_id = getDepartmentId($link, $user_id);
// 取得當前使用者所屬職位
$role_id = getRoleId($link, $user_id);
// 下方編輯按鈕權限
// 1=營叢 2=設計 4=工務 8=生管 15=其他
$edit_flag = getEditFlag($department_id, $role_id, $user_id);
// 接受搜尋 post 後觸發
$contractno = empty($_REQUEST['contractno']) ? null : $_REQUEST['contractno'];
$facilityno = empty($_REQUEST['facilityno']) ? null : $_REQUEST['facilityno'];
$custom = empty($_REQUEST['custom']) ? null : $_REQUEST['custom'];
$site_survey_contact_verify = !isset($_REQUEST['site_survey_contact_verify']) ? '' : $_REQUEST['site_survey_contact_verify'];
$real_contract_arrival_date_start = empty($_REQUEST['real_contract_arrival_date_start']) ? null : $_REQUEST['real_contract_arrival_date_start'];
$real_contract_arrival_date_end = empty($_REQUEST['real_contract_arrival_date_end']) ? null : $_REQUEST['real_contract_arrival_date_end'];
$area_no = !isset($_REQUEST['area_no']) ? '' : $_REQUEST['area_no'];
// 取得資料 sql
$sql = getDataSql($department_id, $role_id, $user_id);
$data = mysqli_query($link, $sql);
// 取得資料(工勘部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "A");
$dataA = mysqli_query($link, $sql);
// 取得資料(營業部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "B");
$dataB = mysqli_query($link, $sql);
// 取得資料(設計部門階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "C");
$dataC = mysqli_query($link, $sql);
// 取得資料(生管階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "D");
$dataD = mysqli_query($link, $sql);
// 取得資料(結案階段) sql
$sql = getDataSqlByflowCode($department_id, $role_id, $user_id, "Z");
$dataZ = mysqli_query($link, $sql);
?>
<div style="overflow-x:auto;">
<form id='myForm' method='post' action='wipwhole-renovate-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 colspan="9">
<h3 style='text-align:center'>作番大日程(汰改)</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th>合約號</th>
<td><input type="text" class='form-control' id='contractno' name='contractno' value="<?php echo $contractno; ?>"></td>
<th>電梯編號</th>
<td><input type="text" class='form-control' id='facilityno' name='facilityno' value="<?php echo $facilityno; ?>"></td>
<th>客戶姓名</th>
<td><input type="text" class='form-control' id='custom' name='custom' value="<?php echo $custom; ?>"></td>
<th>預計出貨日</th>
<td colspan="2">
<input type="date" class='form-control' id='real_contract_arrival_date_start' name='real_contract_arrival_date_start' value="<?php echo $real_contract_arrival_date_start; ?>" style='width:40%;display:inline;'>
<input type="date" class='form-control' id='real_contract_arrival_date_end' name='real_contract_arrival_date_end' value="<?php echo $real_contract_arrival_date_end; ?>" style='width:40%;display:inline;'>
</td>
</tr>
<tr>
<th>
區域
</th>
<td>
<?php
$area_status = array(
"" => "全部",
"N" => "N:北區",
"Y" => "Y:宜蘭",
"T" => "T:桃區",
"C" => "C:中區",
"K" => "K:南區"
);
?>
<select name="area_no" id="area_no">
<?php
foreach ($area_status as $key => $val) {
if ((string)$area_no == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<th>
工勘狀態
</th>
<td>
<?php
$site_survey_status = array(
"0" => "已確認",
"1" => "未確認",
"2" => "無工勘需求",
"A" => "未動工",
"B" => "地下室施工",
"C" => "打樁",
"D" => "地基",
"E" => "挖土",
"G" => "機房",
"H" => "機械式淨高",
"M" => "樓中樓",
"OH" => "最高層(頂樓高度)",
"P" => "PIT(機坑深度)",
"R" => "R 樓",
"S" => "停工",
"T" => "TOP",
"TC" => "頂部間隙",
"TS" => "行程",
"TH" => "全高",
"Y" => "已搭、已出",
"YB" => "退購結案",
"YF" => "既有建物",
"YN" => "已搭、未出"
);
for ($i = 1; $i < 200; $i++) {
$site_survey_status[$i . "F"] = $i . "F";
}
?>
<select style="width:100%;" name="site_survey_contact_verify" id="site_survey_contact_verify">
<?php
echo "<option value=''>全部</option>";
foreach ($site_survey_status as $key => $val) {
if ((string)$site_survey_contact_verify == (string)$key) {
echo "<option value='$key' selected>$val</option>";
} else {
echo "<option value='$key'>$val</option>";
}
}
?>
</select>
</td>
<td colspan="5" style='text-align:left'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button>
<?php
if ($department_id == '321' || $department_id == '220') {
?>
<a href="wipwhole-renovate-rec-invoice.php?function_name=wipwholerenstatus&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">新增</a>
<?php
}
?>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_input()'><?php echo $numberOfDaysToAdd; ?>天內資料</button>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='day_before_all_input()'><?php echo $numberOfDaysToAdd; ?>天內資料(含今天以前)</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>
<button type="button" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm" onclick='estimatedShippingDateReportButton()'>出貨地區預定明細</button>
</td>
</tr>
</tfoot>
</table>
</div>
<nav class="navbar navbar-tabs" style="margin:0;margin-top:5px;">
<div class="container-fluid">
<ul class="nav nav-pills">
<li class="active">
<a href="#" onclick="showAllTable()">全部資料</a>
</li>
<li>
<a href="#" onclick="showATable()">廠務確認中</a>
</li>
<li>
<a href="#" onclick="showBTable()">營業確認中</a>
</li>
<li>
<a href="#" onclick="showCTable()">設計確認中</a>
</li>
<li>
<a href="#" onclick="showDTable()">生管理確認中</a>
</li>
<li>
<a href="#" onclick="showZTable()">已結案</a>
</li>
</ul>
</div>
</nav>
<?php
$dataArr = array(
"All" => $data,
"A" => $dataA,
"B" => $dataB,
"C" => $dataC,
"D" => $dataD,
"Z" => $dataZ
);
foreach ($dataArr as $key => $val) {
if ($val) :
$dataDetailsArr = $val;
echo "<div id='data_" . $key . "_table_div' class='data_table_div' style='overflow-x:auto;'>";
include "wipwhole-renovate-index-table-html.php";
echo "</div>";
endif;
}
#結束連線
mysqli_close($link);
?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
var sheetNum = "<?php echo empty($_GET['sheetNum']) ? 'All' : $_GET['sheetNum']; ?>";
$(document).ready(function() {
$('#site_survey_contact_verify').select2();
});
$(function() {
$(".data_table_div").hide();
showTable(sheetNum);
})
const formData = new FormData();
formData.append("contractno", "<?php echo empty($_POST['contractno']) ? null : $_POST['contractno']; ?>");
formData.append("facilityno", "<?php echo empty($_POST['facilityno']) ? null : $_POST['facilityno']; ?>");
formData.append("custom", "<?php echo empty($_POST['custom']) ? null : $_POST['custom']; ?>");
formData.append("site_survey_contact_verify", "<?php echo empty($_POST['site_survey_contact_verify']) ? '' : $_POST['site_survey_contact_verify']; ?>");
formData.append("real_contract_arrival_date_start", "<?php echo empty($_POST['real_contract_arrival_date_start']) ? null : $_POST['real_contract_arrival_date_start']; ?>");
formData.append("real_contract_arrival_date_end", "<?php echo empty($_POST['real_contract_arrival_date_end']) ? null : $_POST['real_contract_arrival_date_end']; ?>");
formData.append("area_no", "<?php echo empty($_POST['area_no']) ? null : $_POST['area_no']; ?>");
// 使用 JavaScript 監聽按鈕點擊事件
function generateButton() {
// 使用 XMLHttpRequest 來呼叫 PHP 檔案,生成 Excel
var xhr = new XMLHttpRequest();
xhr.open('POST', window.location.origin + "/wms/wipwhole-renovate-index-export-excel.php?<?= $token_link ?>", true);
xhr.responseType = 'text';
xhr.onload = function() {
if (xhr.status === 200) {
// 取得 PHP 回傳的檔案路徑
var response = xhr.responseText;
console.log(xhr.responseText);
var file_path = xhr.responseText;
// 創建下載連結
var link = document.createElement('a');
link.setAttribute('href', window.location.origin + "/wms/excel/gary_test.xlsx");
// 設定下載的檔案名稱
link.setAttribute('download', '作番大日程報表(汰改).xlsx');
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
};
xhr.send(formData);
}
function clean_all_input() {
document.getElementById("site_survey_contact_verify").value = "";
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "";
document.getElementById("myForm").submit();
}
function day_before_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "<?php echo date("Y-m-d"); ?>";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function day_before_all_input() {
document.getElementById("contractno").value = "";
document.getElementById("facilityno").value = "";
document.getElementById("custom").value = "";
document.getElementById("real_contract_arrival_date_start").value = "";
document.getElementById("real_contract_arrival_date_end").value = "<?php echo date("Y-m-d", strtotime("+" . $numberOfDaysToAdd . " days")) ?>";
document.getElementById("myForm").submit();
}
function estimatedShippingDateReportButton() {
window.location.href = '<?php echo "/wms/estimated_shipping_date_report.php?$token_link" ?>';
}
$('#table_index2,#table_index3,#table_index4,#table_index5,#table_index6,#table_index7').DataTable({
// columnDefs: [{
// width: 100,
// targets: 0
// },{
// width: 100,
// targets: 1
// },{
// width: 100,
// targets: 2
// },{
// width: 200,
// targets: 3
// },{
// width: 230,
// targets: 4
// },{
// width: 250,
// targets: 5
// },{
// width: 100,
// targets: 6
// }
// ,{
// width: 100,
// targets: 7
// }
// ,{
// width: 100,
// targets: 8
// }
// ,{
// width: 100,
// targets: 9
// }
// ,{
// width: 100,
// targets: 10
// }
// ,{
// width: 100,
// targets: 11
// }
// ,{
// width: 100,
// targets: 12
// }
// ,{
// width: 100,
// targets: 13
// }
// ,{
// width: 100,
// targets: 14
// }],
// fixedColumns: true,
// paging: false,
// scrollCollapse: true,
// scrollX: true,
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示_MENU_ 筆",
"zeroRecords": "沒有符合的結果",
"info": "第 _START_ 至 _END_ 項,共 _TOTAL_ 項",
"infoEmpty": "第 0 至 0 項,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
}
}, {
"order": [
[4, "desc"],
[8, "asc"]
]
});
function showAllTable() {
sheetNum = "All";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showATable() {
sheetNum = "A";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showBTable() {
sheetNum = "B";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showCTable() {
sheetNum = "C";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showDTable() {
sheetNum = "D";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showZTable() {
sheetNum = "Z";
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" + "&sheetNum=" + sheetNum;
}
function showTable(code) {
var tmp_arr = {
"All": "1",
"A": "2",
"B": "3",
"C": "4",
"D": "5",
"Z": "6",
}
$("body > nav.navbar.navbar-tabs > div > ul > li").attr("class", "");
$("body > nav.navbar.navbar-tabs > div > ul > li:nth-child(" + tmp_arr[code] + ")").attr("class", "active");
$(".data_table_div").hide();
$("#data_" + code + "_table_div").show();
}
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index3_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index4_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index5_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index6_filter > label > input").placeholder = "快速搜尋";
document.querySelector("#table_index7_filter > label > input").placeholder = "快速搜尋";
// datatable 畫面重整後保留資料
var contractno = $("#contractno").val();
var facilityno = $("#facilityno").val();
var custom = $("#custom").val();
var site_survey_contact_verify = $("#site_survey_contact_verify").val();
var real_contract_arrival_date_start = $("#real_contract_arrival_date_start").val();
var real_contract_arrival_date_end = $("#real_contract_arrival_date_end").val();
var area_no = $("#area_no").val();
var showNum = <?php echo empty($_GET['showNum']) ? '10' : $_GET['showNum']; ?>;
var nowPage = <?php echo empty($_GET['nowPage']) ? '1' : $_GET['nowPage']; ?>;
var searchContent = "<?php echo empty($_GET['searchContent']) ? '' : $_GET['searchContent']; ?>";
var dataArr2 = {
"All": "table_index2",
"A": "table_index3",
"B": "table_index4",
"C": "table_index5",
"D": "table_index6",
"Z": "table_index7",
}
var table = $('#' + dataArr2[sheetNum]).DataTable();
table.search(searchContent).draw();
table.page.len(showNum).draw();
table.page((nowPage) - 1).draw('page');
// 監聽頁碼
table.on('page.dt', function() {
searchDatatable(table);
});
// 監聽資料筆數
table.on('length.dt', function(e, settings, len) {
searchDatatable(table);
});
// 監聽搜尋事件
$("#" + dataArr2[sheetNum] + "_filter > label > input").change(function() {
searchDatatable(table);
});
function searchDatatable(table) {
showNum = table.page.len();
nowPage = table.page.info().page + 1;
searchContent = table.search();
window.location.href = "<?php echo "wipwhole-renovate-index.php?function_name=wipinstall&$token_link"; ?>" +
"&showNum=" + showNum + "&nowPage=" + nowPage + "&searchContent=" + searchContent + "&sheetNum=" + sheetNum +
"&contractno=" + contractno + "&facilityno=" + facilityno + "&custom=" + custom +
"&site_survey_contact_verify=" + site_survey_contact_verify + "&real_contract_arrival_date_start=" + real_contract_arrival_date_start +
"&real_contract_arrival_date_end=" + real_contract_arrival_date_end + "&area_no=" + area_no;
}
</script>
Loading…
Cancel
Save