Browse Source

Merge branch 'main' into gary

gary
gary_chen\gary_chen 1 year ago
parent
commit
97c9be8dd0
  1. 5
      wms/T8_APItest.php
  2. BIN
      wms/WriteOff.xlsx
  3. 30
      wms/database.php
  4. 90
      wms/rib-test.php
  5. 35
      wms/rib-test02.php
  6. 101
      wms/rib01-business-check.php
  7. 65
      wms/rib01-business-create.php
  8. 86
      wms/rib01-business-index.php
  9. 59
      wms/rib01-check.php
  10. 78
      wms/rib01-create.php
  11. 74
      wms/rib01-edit.php
  12. 27
      wms/rib01-submit.php
  13. 753
      wms/rib02-business-create.php
  14. 26
      wms/rib02-check.php
  15. 96
      wms/rib02-create.php
  16. 85
      wms/rib02-edit.php
  17. 22
      wms/rib02-submit.php
  18. 23
      wms/rib03-download.php
  19. 364
      wms/rib03-submit.php

5
wms/T8_APItest.php

@ -26,11 +26,12 @@ echo "ii";
"CurrId": "RMB", "CurrId": "RMB",
"CurrLAmount":5, "CurrLAmount":5,
"TaxId": "ST005", "TaxId": "ST005",
"PersonId": "M0006", "PersonId": "M0012",
"DeptId": "220", "DeptId": "220",
"CompId": "1001", "CompId": "1001",
"CreditAgeDate": 20230930, "CreditAgeDate": 20230930,
"RecBizPartnerId": "03051501" "RecBizPartnerId": "03051501",
}] }]
}, },
{ {

BIN
wms/WriteOff.xlsx

Binary file not shown.

30
wms/database.php

@ -1,30 +0,0 @@
<?php
$envFile = __DIR__ . '/../.env'; // .env 文件的路徑
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines !== false) {
foreach ($lines as $line) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
// 设置环境变量
putenv("$key=$value");
}
}
}
date_default_timezone_set("Asia/Taipei");
$host = getenv('DB_HOST');
$dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE');
$link = mysqli_connect($host,$dbuser,$dbpassword,$dbname);
if($link){
mysqli_query($link,'SET NAMES utf8');
// echo "正確連接資料庫";
}
else {
echo "不正確連接資料庫</br>" . mysqli_connect_error();
}
?>

90
wms/rib-test.php

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

35
wms/rib-test02.php

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

101
wms/rib01-business-check.php

@ -9,44 +9,37 @@ foreach ($query_rib as $q) {
$rib = $q; $rib = $q;
} }
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
}
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
//取得供應商 $member = array();
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'"; //取得人員名單與使用者的部門
$BizPartner = $conn->query($sql_Biz); $sql_mydept = "SELECT UserId, Username FROM capMembership";
$conn = null; $deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
} }
} catch (PDOException $e) { $personid = $man['PersonId'];
echo "fail"; $depart = $man['DeptId'];
echo $e->getMessage(); if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
//取得供應商
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'";
$BizPartner = $conn->query($sql_Biz);
$conn = null;
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">
@ -192,24 +185,24 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
</a> </a>
<table class="table table-striped table-bordered" style="width:100%"> <table class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>
<th>發票日期</th> <th>發票日期</th>
<th>數量</th> <th>數量</th>
<th>單價</th> <th>單價</th>
<th>費用項目</th> <th>費用項目</th>
<th>原幣報銷金額</th> <th>原幣報銷金額</th>
<th>說明</th> <th>說明</th>
<th>發票號碼</th> <th>發票號碼</th>
<th style="width: 10%;">功能</th> <th style="width: 10%;">功能</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
if (isset($pay_data)) : if (isset($pay_data)) :
?> ?>
<?php foreach ($pay_data as $pay) : ?> <?php foreach ($pay_data as $pay) : ?>
<tr> <tr>
<td><?= $pay['FeeDate'] ?></td> <td><?= $pay['FeeDate'] ?></td>
@ -246,11 +239,11 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
} ?> } ?>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<?php <?php
endif; endif;
?> ?>
</div> </div>

65
wms/rib01-business-create.php

@ -17,44 +17,37 @@ foreach ($myNo as $thisMyNo) {
} }
$BillNo = $sqlname; $BillNo = $sqlname;
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
}
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
//取得供應商 $member = array();
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'"; //取得人員名單與使用者的部門
$BizPartner = $conn->query($sql_Biz); $sql_mydept = "SELECT UserId, Username FROM capMembership";
$conn = null; $deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
} }
} catch (PDOException $e) { $personid = $man['PersonId'];
echo "fail"; $depart = $man['DeptId'];
echo $e->getMessage(); if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
//取得供應商
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'";
$BizPartner = $conn->query($sql_Biz);
$conn = null;
$MaxBillNo += 1; $MaxBillNo += 1;
if ($MaxBillNo < 10) { if ($MaxBillNo < 10) {
$BillNo .= "0" . strval($MaxBillNo); $BillNo .= "0" . strval($MaxBillNo);
@ -189,7 +182,7 @@ if ($MaxBillNo < 10) {
}; };
function send() { function send() {
if($("#comSupplierId").val()===""){ if ($("#comSupplierId").val() === "") {
alert("請選擇供應商"); alert("請選擇供應商");
return; return;
} }

86
wms/rib01-business-index.php

@ -30,54 +30,46 @@ if ($user_id == 'M0056') {
} }
$DeptName = array(); $DeptName = array();
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
}
//取得部門代碼 $member = array();
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; //取得人員名單與使用者的部門
$deptype = $conn->query($sql_department); $sql_mydept = "SELECT UserId, Username FROM capMembership";
foreach ($deptype as $dept) { $deptmem = $conn->query($sql_mydept);
$deptid = $dept['DeptId']; foreach ($deptmem as $mem) {
$deptname = $dept['DeptName']; $userid = $mem['UserId'];
$DeptName[$deptid] = $deptname; $username = $mem['Username'];
} $member["$userid"] = [$username];
//取得供應商 };
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'"; $sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$BizPartner = $conn->query($sql_Biz); $allpeople = $conn->query($sql_dept);
foreach($BizPartner as $partner){ foreach ($allpeople as $man) {
$partnerid = $partner['BizPartnerId']; if ($man['PersonId'] == $user_id) {
$partnername = $partner['BizPartnerName']; $mydepart = $man['DeptId'];
$Supplier[$partnerid]= $partnername;
}
$conn = null;
} }
} catch (PDOException $e) { $personid = $man['PersonId'];
echo "fail"; $depart = $man['DeptId'];
echo $e->getMessage(); if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
foreach ($deptype as $dept) {
$deptid = $dept['DeptId'];
$deptname = $dept['DeptName'];
$DeptName[$deptid] = $deptname;
}
//取得供應商
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'";
$BizPartner = $conn->query($sql_Biz);
foreach ($BizPartner as $partner) {
$partnerid = $partner['BizPartnerId'];
$partnername = $partner['BizPartnerName'];
$Supplier[$partnerid] = $partnername;
}
?> ?>
<!-- <!--
新增單據 --> 新增單據 -->
@ -149,8 +141,8 @@ if ($data) :
<tr> <tr>
<td><?php echo $data['BillNo']; ?></td> <td><?php echo $data['BillNo']; ?></td>
<td><?php echo substr($data['BillDate'], 0, 10); ?></td> <td><?php echo substr($data['BillDate'], 0, 10); ?></td>
<td><?php $supp= $data['BizPartnerId']; <td><?php $supp = $data['BizPartnerId'];
echo $Supplier[$supp]; ?></td> echo $Supplier[$supp]; ?></td>
<td><?php echo accountidToName($data['PersonId']); ?></td> <td><?php echo accountidToName($data['PersonId']); ?></td>
<td><?php $depid = $data['DeptId']; <td><?php $depid = $data['DeptId'];
echo $DeptName[$depid] ?></td> echo $DeptName[$depid] ?></td>

59
wms/rib01-check.php

@ -28,42 +28,35 @@ if ($pay_data) {
} }
} }
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $member = array();
if ($conn) { //取得人員名單與使用者的部門
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array(); $sql_mydept = "SELECT UserId, Username FROM capMembership";
//取得人員名單與使用者的部門 $deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$sql_mydept = "SELECT UserId, Username FROM capMembership"; $userid = $mem['UserId'];
$deptmem = $conn->query($sql_mydept); $username = $mem['Username'];
foreach ($deptmem as $mem) { $member["$userid"] = [$username];
$userid = $mem['UserId']; };
$username = $mem['Username']; $sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$member["$userid"] = [$username]; $allpeople = $conn->query($sql_dept);
}; foreach ($allpeople as $man) {
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'"; if ($man['PersonId'] == $user_id) {
$allpeople = $conn->query($sql_dept); $mydepart = $man['DeptId'];
foreach ($allpeople as $man) { }
if ($man['PersonId'] == $user_id) { $personid = $man['PersonId'];
$mydepart = $man['DeptId']; $depart = $man['DeptId'];
} if (isset($member["$personid"])) {
$personid = $man['PersonId']; array_push($member["$personid"], "$depart");
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
}
}
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">

78
wms/rib01-create.php

@ -7,7 +7,7 @@ include "./header.php";
$MaxBillNo = 0; $MaxBillNo = 0;
$curreny_date = date('ym'); $curreny_date = date('ym');
$query_rib = array(); $query_rib = array();
$sqlname = "C".$user_id; $sqlname = "C" . $user_id;
$sqlname .= $curreny_date; $sqlname .= $curreny_date;
$date_sql = "SELECT BillNo from rib WHERE (BillNo LIKE '$sqlname%')"; $date_sql = "SELECT BillNo from rib WHERE (BillNo LIKE '$sqlname%')";
$query_rib = mysqli_query($link, $date_sql); $query_rib = mysqli_query($link, $date_sql);
@ -22,41 +22,34 @@ $BillNo = $sqlname;
$today = (int)date('Ymd'); $today = (int)date('Ymd');
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership WHERE ValidityToDate >$today";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE (DeptId!='0001')";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if(isset($member["$personid"])){
array_push($member["$personid"], "$depart");
};
}
//取得部門代碼 $member = array();
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; //取得人員名單與使用者的部門
$deptype = $conn->query($sql_department);
$sql_mydept = "SELECT UserId, Username FROM capMembership WHERE ValidityToDate >$today";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE (DeptId!='0001')";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
} }
} catch (PDOException $e) { $personid = $man['PersonId'];
echo "fail"; $depart = $man['DeptId'];
echo $e->getMessage(); if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
};
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
$MaxBillNo += 1; $MaxBillNo += 1;
if ($MaxBillNo < 10) { if ($MaxBillNo < 10) {
$BillNo .= "0" . strval($MaxBillNo); $BillNo .= "0" . strval($MaxBillNo);
@ -145,9 +138,9 @@ if ($MaxBillNo < 10) {
<!-- <option value="<?php echo $value['UserId']; ?>" style="display:none" id="<?= 'WriteOff' . $value['UserId'] . $key ?>" <?php if ($value['UserId'] == $user_id) { <!-- <option value="<?php echo $value['UserId']; ?>" style="display:none" id="<?= 'WriteOff' . $value['UserId'] . $key ?>" <?php if ($value['UserId'] == $user_id) {
echo "selected"; echo "selected";
} ?>> <?php echo $value['Username']; ?> </option> --> } ?>> <?php echo $value['Username']; ?> </option> -->
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] ."-". $value[0] ?>" <?php if ($key == $user_id) { <option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . "-" . $value[0] ?>" <?php if ($key == $user_id) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php } <?php }
?> ?>
</select> </select>
@ -170,9 +163,9 @@ if ($MaxBillNo < 10) {
<!-- <option value="<?php echo $value['accountid']; ?>" id="<?= 'Gathering' . $value['department_id'] ?>" <?php if ($value['accountid'] == $user_id) { <!-- <option value="<?php echo $value['accountid']; ?>" id="<?= 'Gathering' . $value['department_id'] ?>" <?php if ($value['accountid'] == $user_id) {
echo "selected"; echo "selected";
} ?>> <?php echo $value['name']; ?> </option> --> } ?>> <?php echo $value['name']; ?> </option> -->
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1]."-".$value[0] ?>" <?php if ($key== $user_id) { <option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . "-" . $value[0] ?>" <?php if ($key == $user_id) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php }; ?> <?php }; ?>
</select> </select>
</div> </div>
@ -207,8 +200,8 @@ if ($MaxBillNo < 10) {
}) })
function changeWriteOffId(SelectedDept) { function changeWriteOffId(SelectedDept) {
var GatheringSelectDeptId = 'Gathering' + SelectedDept+"-"; var GatheringSelectDeptId = 'Gathering' + SelectedDept + "-";
var SelectDeptId = 'WriteOff' + SelectedDept+"-"; var SelectDeptId = 'WriteOff' + SelectedDept + "-";
for (var i = 0; i < WriteOffId.options.length; i++) { for (var i = 0; i < WriteOffId.options.length; i++) {
WriteOffId.options[i].selected = false; WriteOffId.options[i].selected = false;
let thisid = WriteOffId.options[i].id let thisid = WriteOffId.options[i].id
@ -229,7 +222,8 @@ if ($MaxBillNo < 10) {
}; };
} }
}; };
function send(){
function send() {
$("#BillNo").prop("disabled", false); $("#BillNo").prop("disabled", false);
$('#ribadd').submit(); $('#ribadd').submit();
} }

74
wms/rib01-edit.php

@ -10,41 +10,35 @@ $res = mysqli_query($link, $db_query);
//取得人員名單 //取得人員名單
// 連線T8MASADA // 連線T8MASADA
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if(isset($member["$personid"])){
array_push($member["$personid"], "$depart");}
}
//取得部門代碼 $member = array();
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department); //取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
//取得 rib_sub的資料 //取得 rib_sub的資料
$pay_data = array(); $pay_data = array();
$pay_sql = "select * from rib_sub where rib_id = $rib_id"; $pay_sql = "select * from rib_sub where rib_id = $rib_id";
@ -115,7 +109,7 @@ if ($pay_data) {
<select name="TransactId" id="TransactId" class="form-control" <?php if ($state == 1) { <select name="TransactId" id="TransactId" class="form-control" <?php if ($state == 1) {
echo "disabled"; echo "disabled";
} ?>> } ?>>
<option value="<?php echo $user_id; ?>"> <?php echo $user_name; ?> </option> <option value="<?php echo $user_id; ?>"> <?php echo $user_name; ?> </option>
</select> </select>
@ -151,9 +145,9 @@ if ($pay_data) {
<?php <?php
foreach ($deptype as $dept) { ?> foreach ($deptype as $dept) { ?>
<option value="<?php echo $dept['DeptId']; ?>" <?php <option value="<?php echo $dept['DeptId']; ?>" <?php
if ($dept['DeptId'] == $data['DeptId']) { if ($dept['DeptId'] == $data['DeptId']) {
echo "selected"; echo "selected";
} ?>><?php echo $dept['DeptName']; ?></option> } ?>><?php echo $dept['DeptName']; ?></option>
<?php }; <?php };
?> ?>
</select> </select>
@ -167,8 +161,8 @@ if ($pay_data) {
<?php <?php
foreach ($member as $key => $value) { ?> foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) { <option value="<?php echo $key; ?>" id="<?= 'WriteOff' . $value[1] . $value[0] ?>" <?php if ($key == $data['WriteOffId']) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php } <?php }
?> ?>
</select> </select>
@ -195,9 +189,9 @@ if ($pay_data) {
<?php <?php
foreach ($member as $key => $value) { foreach ($member as $key => $value) {
?> ?>
<option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1].$value[0] ?>" <?php if ($key == $data['GatheringPersonId']) { <option value="<?php echo $key; ?>" id="<?= 'Gathering' . $value[1] . $value[0] ?>" <?php if ($key == $data['GatheringPersonId']) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php }; ?> <?php }; ?>
</select> </select>
</div> </div>

27
wms/rib01-submit.php

@ -19,24 +19,17 @@ $GatheringPersonId = empty($_POST["GatheringPersonId"]) ? NULL : $_POST["Gatheri
$OAmountWithTax = empty($_POST["OAmountWithTax"]) ? NULL : $_POST["OAmountWithTax"]; $OAmountWithTax = empty($_POST["OAmountWithTax"]) ? NULL : $_POST["OAmountWithTax"];
$CostCenterId = empty($_POST["CostCenterId"]) ? NULL : $_POST["CostCenterId"]; $CostCenterId = empty($_POST["CostCenterId"]) ? NULL : $_POST["CostCenterId"];
//連線T8MASADA 取得收款人銀行帳戶資料 //連線T8MASADA 取得收款人銀行帳戶資料
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $sql = "SELECT * FROM comCompanyPersonAccountSetting WHERE PersonId='$GatheringPersonId'";
if ($conn) { $bank = $conn->query($sql);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn = null;
$sql = "SELECT * FROM comCompanyPersonAccountSetting WHERE PersonId='$GatheringPersonId'"; while ($bankInfo = $bank->fetch(PDO::FETCH_ASSOC)) {
$bank = $conn->query($sql); $BankId = $bankInfo['BankId'];
$conn = null; $BankName = $bankInfo['BankName'];
while ($bankInfo = $bank->fetch(PDO::FETCH_ASSOC)) { $BankAccount = $bankInfo['BankAccount'];
$BankId = $bankInfo['BankId']; $BankAccountName = $bankInfo['AccountName'];
$BankName = $bankInfo['BankName'];
$BankAccount = $bankInfo['BankAccount'];
$BankAccountName = $bankInfo['AccountName'];
}
}
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
$SQL1 = ""; $SQL1 = "";
if ($submit == "edit") { if ($submit == "edit") {

753
wms/rib02-business-create.php

@ -1,463 +1,446 @@
<?php <?php
include "./header.php"; include "./header.php";
$BillNo = $_GET['BillNo'] ; $BillNo = $_GET['BillNo'];
$RowCode= $_GET['RowCode']; $RowCode = $_GET['RowCode'];
//取得計量單位 //取得計量單位
$sql_unit = "SELECT * FROM unit"; $sql_unit = "SELECT * FROM unit";
$unit_query = mysqli_query($link, $sql_unit); $unit_query = mysqli_query($link, $sql_unit);
$unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC); $unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC);
$sql_rib_biz = "SELECT * FROM rib_business WHERE BillNo = '$BillNo'"; $sql_rib_biz = "SELECT * FROM rib_business WHERE BillNo = '$BillNo'";
$rib = mysqli_query($link,$sql_rib_biz); $rib = mysqli_query($link, $sql_rib_biz);
foreach($rib as $rib){ foreach ($rib as $rib) {
$TaxId = $rib['TaxId']; $TaxId = $rib['TaxId'];
$CurrId = $rib['CurrId']; $CurrId = $rib['CurrId'];
} }
// 連線T8MASADA 取得供應商、合約跟作番號 // 連線T8MASADA 取得供應商、合約跟作番號
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql_Biz = "SELECT * FROM comBusinessPartner";
$BizPartner = $conn->query($sql_Biz);
$sql_Project = "SELECT * FROM comProject";
$projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup";
$materials = $conn->query($sql_Material);
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if(isset($member["$personid"])){
array_push($member["$personid"], "$depart");}
}
//取得部門代碼 $sql_Biz = "SELECT * FROM comBusinessPartner";
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; $BizPartner = $conn->query($sql_Biz);
$deptype = $conn->query($sql_department); $sql_Project = "SELECT * FROM comProject";
$conn= null; $projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup";
$materials = $conn->query($sql_Material);
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
$conn = null;
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">
<div style="padding-left: 2rem; padding-bottom: 1rem;"> <div style="padding-left: 2rem; padding-bottom: 1rem;">
<a href="rib-business-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg"> <a href="rib-business-index.php?<?php echo $token_link; ?>" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-home"></span> <span class="glyphicon glyphicon-home"></span>
</a> </a>
</div> </div>
</div> </div>
<div class="container" id="ribsubadd"> <div class="container" id="ribsubadd">
<div class="text-center"> <div class="text-center">
<h3>新增費用單據 (廠商)</h3> <h3>新增費用單據 (廠商)</h3>
</div> </div>
<form class="form-horizontal" name="ribsubform" id="ribsubform" method="POST" action="rib02-business-submit.php?rib_id=<?= $rib_id ?>&submit=add&<?= $token_link ?>" enctype="multipart/form-data"> <form class="form-horizontal" name="ribsubform" id="ribsubform" method="POST" action="rib02-business-submit.php?rib_id=<?= $rib_id ?>&submit=add&<?= $token_link ?>" enctype="multipart/form-data">
<div class="form-group"> <div class="form-group">
<div class="col-md-3" style="display: none;"> <div class="col-md-3" style="display: none;">
<label for="RowCode" style="color: red;">序號</label> <label for="RowCode" style="color: red;">序號</label>
<input class="form-control" type="int" name="RowCode" id="RowCode" value="<?= $RowCode ?>" disabled> <input class="form-control" type="int" name="RowCode" id="RowCode" value="<?= $RowCode ?>" disabled>
</div>
<?php if ($user_id == "M0056") { ?>
<div class="col-md-3">
<label for="FeeTypeId" style="color: red;">費用項目代碼</label>
<select name="FeeTypeId" class="form-control" required>
<?php
foreach ($feetype as $key => $value) { ?>
<option value="<?php echo $value['FeeTypeId']; ?>"><?php echo $value['FeeTypeName']; ?></option>
<?php };
?>
</select>
</div>
<?php } else { ?>
<div class="col-md-3">
<label for="FeeTypeGen" style="color: red;">費用類別</label>
<select name="FeeTypeGen" id="FeeTypeGen" class="form-control" required>
<option value="">請選擇費用類別</option>
<option value=1>交通費</option>
<option value=2>出差旅費</option>
<option value=3>交際餐飲禮品</option>
<option value=4>文具用品</option>
<option value=5>郵資、電話/網路費、匯費</option>
<option value=6>水費</option>
<option value=7>電費</option>
<option value=8>瓦斯費</option>
<option value=9>運費/快遞</option>
<option value=10>堆高機費用</option>
<option value=11>五金材料工具</option>
<option value=12>汽車維修</option>
<option value=13>研發測試打樣</option>
<option value=14>繳稅</option>
<option value=15>其他費用</option>
</select>
</div>
<div class="col-md-3">
<label for="FeeTypeId" style="color: red;">費用項目代碼</label>
<select name="FeeTypeId" id="FeeTypeId" class="form-control" required>
</select>
</div>
<?php } ?>
</div> </div>
<div class="form-group">
<?php if ($user_id == "M0056") { ?>
<div class="col-md-3"> <div class="col-md-3">
<label for="FeeTypeId" style="color: red;">費用項目代碼</label> <label for="FeeNoteShow" style="color: red;">費用說明</label>
<select name="FeeTypeId" class="form-control" required> <input class="form-control" type="text" name="FeeNoteShow" id="FeeNoteShow">
</div>
<div class="col-md-3">
<label for="ProjectId">合約號</label>
<select name="ProjectId" id="ProjectId">
<option value=""></option>
<?php <?php
foreach ($feetype as $key => $value) { ?> foreach ($projects as $Project) {
<option value="<?php echo $value['FeeTypeId']; ?>"><?php echo $value['FeeTypeName']; ?></option> ?>
<?php }; <option value="<?= $Project['ProjectId'] ?>"><?= $Project['ProjectId'] . $Project['ProjectName'] ?></option>
<?php
}
?> ?>
</select> </select>
</div> </div>
<?php } else { ?>
<div class="col-md-3"> <div class="col-md-3">
<label for="FeeTypeGen" style="color: red;">費用類別</label> <label for="CU_MaterialId">作番號</label>
<select name="FeeTypeGen" id="FeeTypeGen" class="form-control" required> <select name="CU_MaterialId" id="CU_MaterialId">
<option value="">請選擇費用類別</option> <option value=""></option>
<option value=1>交通費</option> <?php
<option value=2>出差旅費</option> foreach ($materials as $material) {
<option value=3>交際餐飲禮品</option> ?>
<option value=4>文具用品</option> <option value="<?= $material['MaterialId'] ?>"><?= $material['MaterialId'] . $material['MaterialName'] ?></option>
<option value=5>郵資、電話/網路費、匯費</option> <?php
<option value=6>水費</option> }
<option value=7>電費</option> ?>
<option value=8>瓦斯費</option>
<option value=9>運費/快遞</option>
<option value=10>堆高機費用</option>
<option value=11>五金材料工具</option>
<option value=12>汽車維修</option>
<option value=13>研發測試打樣</option>
<option value=14>繳稅</option>
<option value=15>其他費用</option>
</select> </select>
</div> </div>
<div class="col-md-3">
<label for="FeeTypeId" style="color: red;">費用項目代碼</label>
<select name="FeeTypeId" id="FeeTypeId" class="form-control" required>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="UnitId" style="color: red;">計量單位</label>
<select name="UnitId" class="form-control" required>
<?php
foreach ($unit as $key => $value) { ?>
<option value="<?php echo $value['UnitId']; ?>"><?php echo $value['UnitName']; ?></option>
<?php };
?>
</select> </select>
</div> </div>
<div class="col-md-3">
<label for="Price" style="color: red;">單價 (原幣值含稅)</label>
<?php } ?> <input class="form-control" type="number" step="any" name="Price" id="Price" required onchange="calOAmount(this.id)">
</div>
</div> <div class="col-md-3">
<div class="form-group"> <label for="Quantity" style="color: red;">數量</label>
<input class="form-control" type="number" step="any" name="Quantity" id="Quantity" value="1" required>
<div class="col-md-3"> </div>
<label for="FeeNoteShow" style="color: red;">費用說明</label> <div class="col-md-3">
<input class="form-control" type="text" name="FeeNoteShow" id="FeeNoteShow"> <label for="OAmount" style="color: red;">報銷金額 (原幣值含稅)</label>
</div> <input class="form-control" type="number" step="any" name="OAmount" id="OAmount" placeholder="單價x數量" required disabled>
<div class="col-md-3"> </div>
<label for="ProjectId">合約號</label>
<select name="ProjectId" id="ProjectId">
<option value=""></option>
<?php
foreach ($projects as $Project) {
?>
<option value="<?= $Project['ProjectId'] ?>"><?= $Project['ProjectId'] . $Project['ProjectName'] ?></option>
<?php
}
?>
</select>
</div>
<div class="col-md-3">
<label for="CU_MaterialId">作番號</label>
<select name="CU_MaterialId" id="CU_MaterialId">
<option value=""></option>
<?php
foreach ($materials as $material) {
?>
<option value="<?= $material['MaterialId'] ?>"><?= $material['MaterialId'] . $material['MaterialName'] ?></option>
<?php
}
?>
</select>
</div> </div>
<div class="form-group">
<div class="col-md-3">
<label for="TaxId">稅碼</label>
<select name="TaxId" class="form-control">
<option value="ST005" selected>營業稅5%</option>
<option value="ST101">零稅</option>
<option value="ST102">免稅</option>
</select>
</div>
<div class="col-md-3">
<label for="IsCounteract">抵扣</label>
<select name="IsCounteract" class="form-control">
<option value=1 selected>可抵扣</option>
<option value=0>不可抵扣</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="UnitId" style="color: red;">計量單位</label>
<select name="UnitId" class="form-control" required>
<?php
foreach ($unit as $key => $value) { ?>
<option value="<?php echo $value['UnitId']; ?>"><?php echo $value['UnitName']; ?></option>
<?php };
?>
</select>
</div>
<div class="col-md-3">
<label for="Price" style="color: red;">單價 (原幣值含稅)</label>
<input class="form-control" type="number" step="any" name="Price" id="Price" required onchange="calOAmount(this.id)">
</div>
<div class="col-md-3">
<label for="Quantity" style="color: red;">數量</label>
<input class="form-control" type="number" step="any" name="Quantity" id="Quantity" value="1" required>
</div>
<div class="col-md-3">
<label for="OAmount" style="color: red;">報銷金額 (原幣值含稅)</label>
<input class="form-control" type="number" step="any" name="OAmount" id="OAmount" placeholder="單價x數量" required disabled>
</div>
</div>
<div class="form-group">
<div class="col-md-3">
<label for="TaxId">稅碼</label>
<select name="TaxId" class="form-control">
<option value="ST005" selected>營業稅5%</option>
<option value="ST101">零稅</option>
<option value="ST102">免稅</option>
</select>
</div>
<div class="col-md-3">
<label for="IsCounteract">抵扣</label>
<select name="IsCounteract" class="form-control">
<option value=1 selected>可抵扣</option>
<option value=0>不可抵扣</option>
</select>
</div> </div>
<div class="form-group">
<div class="col-md-3">
<label for="VoucherCount">憑單張數</label>
<input class="form-control" type="number" name="VoucherCount" id="VoucherCount" max=5 value=1>
</div>
<div class="col-md-3">
<label for="VoucherType">憑單類型</label>
<select name="VoucherType" id="VoucherType" class="form-control">
<option value="0" selected>發票</option>
<option value="1">收據 </option>
<option value="2">支出證明</option>
<option value="3">其他</option>
</select>
</div>
<div class="col-md-3" id="NotInvoice1">
<label for="InvoiceId">發票聯式
<a onclick="ShowInvoice()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" />
</svg>
</a>
</label>
<select name="InvoiceId" id="InvoiceId" class="form-control">
<option value="">請選擇發票聯式</option>
<option value="25">一般電子發票-> 進項三聯式收銀機統一發票及一般稅額計算之電子發票</option>
<option value="21">三聯式手開發票-> 進項三聯式、電子計算機統一發票</option>
<option value="22">二聯式收銀機發票 -> 進項二聯式收銀機統一發票、載有稅額之其他憑證</option>
<?php if ($user_id == "M0056") { ?>
<option value="23">三聯式、電子計算機、三聯式收銀機統一發票及一般稅額計算之電子發票之進貨退出或折讓證明單</option>
<option value="24">二聯式收銀機統一發票及載有稅額之其他憑證之進貨退出或折讓證明單</option>
<option value="26">彙總登錄每張稅額伍佰元以下之進項三聯式、電子計算機統一發票</option>
<option value="27">彙總登錄每張稅額伍佰元以下之進項二聯式收銀機統一發票、載有稅額之其他憑證</option>
<option value="28">進項海關代徵營業稅繳納證</option>
<option value="29">進項海關退還溢繳營業稅申報單</option>
<?php } ?>
</select>
</div> </div>
<div class="form-group"> <div class="col-md-3" id="NotInvoice2">
<div class="col-md-3"> <label for="InvoiceNo">發票號碼</label>
<label for="VoucherCount">憑單張數</label> <input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo">
<input class="form-control" type="number" name="VoucherCount" id="VoucherCount" max=5 value=1> </div>
</div>
<div class="col-md-3">
<label for="VoucherType">憑單類型</label>
<select name="VoucherType" id="VoucherType" class="form-control">
<option value="0" selected>發票</option>
<option value="1">收據 </option>
<option value="2">支出證明</option>
<option value="3">其他</option>
</select>
</div> </div>
<div class="col-md-3" id="NotInvoice1">
<label for="InvoiceId">發票聯式
<a onclick="ShowInvoice()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" />
</svg>
</a>
</label>
<select name="InvoiceId" id="InvoiceId" class="form-control">
<option value="">請選擇發票聯式</option>
<option value="25">一般電子發票-> 進項三聯式收銀機統一發票及一般稅額計算之電子發票</option>
<option value="21">三聯式手開發票-> 進項三聯式、電子計算機統一發票</option>
<option value="22">二聯式收銀機發票 -> 進項二聯式收銀機統一發票、載有稅額之其他憑證</option>
<?php if ($user_id == "M0056") { ?>
<option value="23">三聯式、電子計算機、三聯式收銀機統一發票及一般稅額計算之電子發票之進貨退出或折讓證明單</option>
<option value="24">二聯式收銀機統一發票及載有稅額之其他憑證之進貨退出或折讓證明單</option>
<option value="26">彙總登錄每張稅額伍佰元以下之進項三聯式、電子計算機統一發票</option>
<option value="27">彙總登錄每張稅額伍佰元以下之進項二聯式收銀機統一發票、載有稅額之其他憑證</option>
<option value="28">進項海關代徵營業稅繳納證</option>
<option value="29">進項海關退還溢繳營業稅申報單</option>
<?php } ?>
</select>
<div class="form-group">
<div class="col-md-3">
<label for="comSupplierName">供應商</label>
<select name="comSupplierName" id="comSupplierName">
<option value=""></option>
<option value="雜項請款用">V0001雜項請款用</option>
<?php
foreach ($BizPartner as $BizKey => $BizValue) { ?>
<option value="<?= $BizValue['BizPartnerName'] ?>"><?= $BizValue['BizPartnerId'] . $BizValue['BizPartnerName'] ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-3" id="Tax">
<label for="TaxNo">統一編號 (供應商)</label>
<input type="text" name="TaxNo" id="TaxNo" class="form-control">
</div>
</div> </div>
<div class="col-md-3" id="NotInvoice2"> <div>
<label for="InvoiceNo">發票號碼</label>
<input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo">
</div>
</div>
<div class="form-group"> <input type="hidden" name="CurrId" value="<?= $CurrId ?>">
<div class="col-md-3">
<label for="comSupplierName">供應商</label>
<select name="comSupplierName" id="comSupplierName">
<option value=""></option>
<option value="雜項請款用">V0001雜項請款用</option>
<?php
foreach ($BizPartner as $BizKey => $BizValue) { ?>
<option value="<?= $BizValue['BizPartnerName'] ?>"><?=$BizValue['BizPartnerId'].$BizValue['BizPartnerName'] ?></option>
<?php } ?>
</select>
</div> </div>
<div class="col-md-3" id="Tax">
<label for="TaxNo">統一編號 (供應商)</label>
<input type="text" name="TaxNo" id="TaxNo" class="form-control">
</div>
</div>
<div>
<input type="hidden" name="CurrId" value="<?= $CurrId ?>">
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-7"> <div class="col-md-7">
</div> </div>
<div class="col-md-5" style="margin-top: 40px;"> <div class="col-md-5" style="margin-top: 40px;">
<button onclick="senddata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-bottom: 110px;">新增費用單據</button> <button onclick="senddata()" type="button" class="btn btn-primary btn-lg pull-right" style="margin-bottom: 110px;">新增費用單據</button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<link <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css" integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
rel="stylesheet" <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js" integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css"
integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js"
integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script> <script>
var TempArr = []; var TempArr = [];
$(document).ready(function(){ $(document).ready(function() {
$("#ProjectId").selectize(); $("#ProjectId").selectize();
$("#CU_MaterialId").selectize(); $("#CU_MaterialId").selectize();
$("#comSupplierName").selectize(); $("#comSupplierName").selectize();
})
$(function() {
$("#comSupplierName").change(function() {
if ($("#comSupplierName").val() == "雜項請款用") {
$("#Tax").show();
} else {
$("#Tax").hide();
}
}) })
$("#TaxNo").change(function() { $(function() {
if ($("#TaxNo").val().length !== 8) { $("#comSupplierName").change(function() {
alert("統一編號格式錯誤"); if ($("#comSupplierName").val() == "雜項請款用") {
} $("#Tax").show();
}) } else {
$("#VoucherType").change(function() { $("#Tax").hide();
if ($("#VoucherType").val() !== "0") { }
$("#NotInvoice1").hide(); })
$("#NotInvoice2").hide(); $("#TaxNo").change(function() {
} else { if ($("#TaxNo").val().length !== 8) {
$("#NotInvoice1").show(); alert("統一編號格式錯誤");
$("#NotInvoice2").show(); }
} })
}) $("#VoucherType").change(function() {
$('#FeeTypeGen').change(function() { if ($("#VoucherType").val() !== "0") {
console.log($('#FeeTypeGen').val()); $("#NotInvoice1").hide();
var FeeTypeId = document.getElementById("FeeTypeId") $("#NotInvoice2").hide();
var FeeType = [{}, { } else {
'400001': '交通費-捷利卡儲值', $("#NotInvoice1").show();
'400002': '交通費-油資', $("#NotInvoice2").show();
'400003': '交通費-ETC', }
'400004': '交通費-停車費' })
}, { $('#FeeTypeGen').change(function() {
'130101': '差旅費-膳雜費', console.log($('#FeeTypeGen').val());
'130102': '差旅費-住宿', var FeeTypeId = document.getElementById("FeeTypeId")
'130301': '差旅費-機票款', var FeeType = [{}, {
'130302': '差旅費-高鐵車資', '400001': '交通費-捷利卡儲值',
'130303': '差旅費-台鐵車資', '400002': '交通費-油資',
'130304': '差旅費-客運車資', '400003': '交通費-ETC',
'130305': '差旅費-捷運車資', '400004': '交通費-停車費'
'130306': '差旅費-計程車車資', }, {
'130307': '差旅費-國外交通費 ', '130101': '差旅費-膳雜費',
'130308': '差旅費-油資', '130102': '差旅費-住宿',
'130309': '差旅費-ETC', '130301': '差旅費-機票款',
'130310': '差旅費-停車費' '130302': '差旅費-高鐵車資',
}, { '130303': '差旅費-台鐵車資',
'200001': '交際便餐、飲品', '130304': '差旅費-客運車資',
'200002': '交際禮品費', '130305': '差旅費-捷運車資',
'200003': '禮金' '130306': '差旅費-計程車車資',
}, { '130307': '差旅費-國外交通費 ',
'120001': '文具用品', '130308': '差旅費-油資',
'120002': '影印紙', '130309': '差旅費-ETC',
'120003': '影印費', '130310': '差旅費-停車費'
'120004': '名片' }, {
}, { '200001': '交際便餐、飲品',
'150001': '郵資', '200002': '交際禮品費',
'150002': '電話費', '200003': '禮金'
'150003': '匯款手續費' }, {
}, { '120001': '文具用品',
'180101': '水費' '120002': '影印紙',
}, { '120003': '影印費',
'180201': '電費' '120004': '名片'
}, { }, {
'180301': '瓦斯費' '150001': '郵資',
}, { '150002': '電話費',
'140001': '運費/快遞' '150003': '匯款手續費'
}, { }, {
'140002': '堆高機費用' '180101': '水費'
}, { }, {
'390001': '材料費、五金用品' '180201': '電費'
}, { }, {
'160002': '汽車維修' '180301': '瓦斯費'
}, { }, {
'370004': '研發打樣費', '140001': '運費/快遞'
'370005': '研發測試費' }, {
}, { '140002': '堆高機費用'
'220001': '牌照稅', }, {
'220002': '燃料費', '390001': '材料費、五金用品'
'220005': '印花稅', }, {
}, { '160002': '汽車維修'
'880004': '其他雜項支出' }, {
}]; '370004': '研發打樣費',
for (var q = 0; q < (FeeType.length); q++) { '370005': '研發測試費'
if ($('#FeeTypeGen').val() == (q)) { }, {
$("#FeeTypeId").empty(); '220001': '牌照稅',
for (const key in FeeType[q]) { '220002': '燃料費',
FeeTypeId.add(new Option(FeeType[q][key], key)); '220005': '印花稅',
}, {
'880004': '其他雜項支出'
}];
for (var q = 0; q < (FeeType.length); q++) {
if ($('#FeeTypeGen').val() == (q)) {
$("#FeeTypeId").empty();
for (const key in FeeType[q]) {
FeeTypeId.add(new Option(FeeType[q][key], key));
}
} }
} }
} })
}) $('#FeeDeptId').change(function() {
$('#FeeDeptId').change(function() { changeWriteOffId($('#FeeDeptId').val());
changeWriteOffId($('#FeeDeptId').val()); })
}) $("#Price").change(function() {
$("#Price").change(function() { $("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#OAmount").val($("#Quantity").val() * $("#Price").val()); });
}); $("#Quantity").change(function() {
$("#Quantity").change(function() { $("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#OAmount").val($("#Quantity").val() * $("#Price").val()); });
}); $("#FeeDate").change(function() {
$("#FeeDate").change(function() { if ($("#FeeDate").val().length != 8) {
if ($("#FeeDate").val().length != 8) { alert("輸入格式錯誤");
alert("輸入格式錯誤");
$("#FeeDate").val('');
} else {
let year = $("#FeeDate").val().substr(0, 4);
let month = $("#FeeDate").val().substr(4, 2);
let day = $("#FeeDate").val().substr(6, 2);
let feedate = new Date(year, month, day);
feedate.setMonth(feedate.getMonth() - 1);
let now = new Date();
if (feedate > now) {
alert("費用日期不可大於今天");
$("#FeeDate").val(''); $("#FeeDate").val('');
} else { } else {
now.setMonth(now.getMonth() - 2); let year = $("#FeeDate").val().substr(0, 4);
now.setDate(01); let month = $("#FeeDate").val().substr(4, 2);
now.setDate(now.getDate() - 1) let day = $("#FeeDate").val().substr(6, 2);
if (feedate < now) { let feedate = new Date(year, month, day);
alert("超過兩個月的費用無法進行報銷"); feedate.setMonth(feedate.getMonth() - 1);
let now = new Date();
if (feedate > now) {
alert("費用日期不可大於今天");
$("#FeeDate").val(''); $("#FeeDate").val('');
} else {
now.setMonth(now.getMonth() - 2);
now.setDate(01);
now.setDate(now.getDate() - 1)
if (feedate < now) {
alert("超過兩個月的費用無法進行報銷");
$("#FeeDate").val('');
}
} }
} }
} })
}) })
}) function ShowInvoice() {
window.open('rib02-invoice.php', '發票範例', config = 'height=600, width=600');
function ShowInvoice() { }
window.open('rib02-invoice.php', '發票範例', config = 'height=600, width=600');
} function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-';
for (var i = 0; i < WriteOffId.options.length; i++) {
WriteOffId.options[i].selected = false;
let thisid = WriteOffId.options[i].id
if (thisid.search(SelectDeptId) === 0) {
WriteOffId.options[i].style['display'] = '';
} else {
WriteOffId.options[i].style['display'] = 'none';
};
function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-';
for (var i = 0; i < WriteOffId.options.length; i++) {
WriteOffId.options[i].selected = false;
let thisid = WriteOffId.options[i].id
if (thisid.search(SelectDeptId) === 0) {
WriteOffId.options[i].style['display'] = '';
} else {
WriteOffId.options[i].style['display'] = 'none';
}; };
}; };
};
function senddata() { function senddata() {
if ($("#FeeDate").val() == "" || $("#FeeNoteShow").val() == "" || $("#Price").val() == "" || $("#Quantity").val() == "") { if ($("#FeeDate").val() == "" || $("#FeeNoteShow").val() == "" || $("#Price").val() == "" || $("#Quantity").val() == "") {
alert("請確認紅字部分皆有填寫"); alert("請確認紅字部分皆有填寫");
} else if ($("#OAmount").val() <= 0) { } else if ($("#OAmount").val() <= 0) {
alert("金額必須大於零"); alert("金額必須大於零");
} else { } else {
$("#OAmount").prop("disabled", false); $("#OAmount").prop("disabled", false);
$('#ribsubform').submit(); $('#ribsubform').submit();
} }
} }
</script> </script>

26
wms/rib02-check.php

@ -34,18 +34,10 @@ $unit_query = mysqli_query($link, $sql_unit);
$unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC); $unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC);
// 連線T8MASADA 取得供應商 // 連線T8MASADA 取得供應商
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $sql = "SELECT * FROM comBusinessPartner";
if ($conn) { $BizPartner = $conn->query($sql);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $sql = "INSERT INTO glFeeWriteOff(BillNo, IsTaxBill) VALUES ('M0122220811',1)";
$sql = "SELECT * FROM comBusinessPartner";
$BizPartner = $conn->query($sql);
}
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
}
?> ?>
<div style="width: 90%;"> <div style="width: 90%;">
@ -297,13 +289,17 @@ try {
<div class="col-md-3"> <div class="col-md-3">
<label for="comSuppliername">供應商</label> <label for="comSuppliername">供應商</label>
<select name="comSuppliername" id="comSuppliername" class="form-control" disabled> <select name="comSuppliername" id="comSuppliername" class="form-control" disabled>
<option value="" <?php if($ribsub['comSupplierName']==""){echo "selected";} ?>> </option> <option value="" <?php if ($ribsub['comSupplierName'] == "") {
<option value="雜項請款用" <?php if($ribsub['comSupplierName']=="雜項請款用"){echo "selected";} ?>>V0001雜項請款用</option> echo "selected";
} ?>> </option>
<option value="雜項請款用" <?php if ($ribsub['comSupplierName'] == "雜項請款用") {
echo "selected";
} ?>>V0001雜項請款用</option>
<?php <?php
foreach ($BizPartner as $BizKey => $BizValue) { ?> foreach ($BizPartner as $BizKey => $BizValue) { ?>
<option value="<?= $BizValue['BizPartnerId'] ?>" <?php if ($ribsub['comSupplierName'] == $BizValue['BizPartnerName']) { <option value="<?= $BizValue['BizPartnerId'] ?>" <?php if ($ribsub['comSupplierName'] == $BizValue['BizPartnerName']) {
echo "selected"; echo "selected";
} ?>><?= $BizValue['BizPartnerId'].$BizValue['BizPartnerName'] ?></option> } ?>><?= $BizValue['BizPartnerId'] . $BizValue['BizPartnerName'] ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>

96
wms/rib02-create.php

@ -21,45 +21,38 @@ if (mysqli_num_rows($rib_query) > 0) {
$RowCode = $_GET['RowCode']; $RowCode = $_GET['RowCode'];
//取得費用項目代碼 //取得費用項目代碼
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if(isset($member["$personid"])){
array_push($member["$personid"], "$depart");}
}
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
$conn=null;
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
$conn = null;
//取得幣別 //取得幣別
$CurrId = $_GET['CurrId']; $CurrId = $_GET['CurrId'];
@ -70,7 +63,7 @@ $unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC);
// 連線T8MASADA 取得供應商、合約跟作番號 // 連線T8MASADA 取得供應商、合約跟作番號
try { try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $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);
$sql_Biz = "SELECT * FROM comBusinessPartner"; $sql_Biz = "SELECT * FROM comBusinessPartner";
@ -79,7 +72,7 @@ try {
$projects = $conn->query($sql_Project); $projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup"; $sql_Material = "SELECT * FROM comMaterialGroup";
$materials = $conn->query($sql_Material); $materials = $conn->query($sql_Material);
$conn= null; $conn = null;
} }
} catch (PDOException $e) { } catch (PDOException $e) {
echo "fail"; echo "fail";
@ -162,9 +155,9 @@ try {
<?php <?php
foreach ($deptype as $dept) { ?> foreach ($deptype as $dept) { ?>
<option value="<?php echo $dept['DeptId']; ?>" <?php <option value="<?php echo $dept['DeptId']; ?>" <?php
if ($dept['DeptId'] == $FeeDeptId) { if ($dept['DeptId'] == $FeeDeptId) {
echo "selected"; echo "selected";
} ?>><?php echo $dept['DeptName']; ?></option> } ?>><?php echo $dept['DeptName']; ?></option>
<?php }; <?php };
?> ?>
</select> </select>
@ -181,8 +174,8 @@ try {
<?php <?php
foreach ($member as $key => $value) { ?> foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $WrtieOffId) { <option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $WrtieOffId) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php }; ?> <?php }; ?>
</select> </select>
</div> </div>
@ -316,7 +309,7 @@ try {
<option value="雜項請款用">V0001雜項請款用</option> <option value="雜項請款用">V0001雜項請款用</option>
<?php <?php
foreach ($BizPartner as $BizKey => $BizValue) { ?> foreach ($BizPartner as $BizKey => $BizValue) { ?>
<option value="<?= $BizValue['BizPartnerName'] ?>"><?=$BizValue['BizPartnerId'].$BizValue['BizPartnerName'] ?></option> <option value="<?= $BizValue['BizPartnerName'] ?>"><?= $BizValue['BizPartnerId'] . $BizValue['BizPartnerName'] ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -343,22 +336,11 @@ try {
</form> </form>
</div> </div>
<link <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css" integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
rel="stylesheet" <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js" integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css"
integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js"
integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script> <script>
var TempArr = []; var TempArr = [];
$(document).ready(function(){ $(document).ready(function() {
$("#ProjectId").selectize(); $("#ProjectId").selectize();
$("#CU_MaterialId").selectize(); $("#CU_MaterialId").selectize();
$("#comSupplierName").selectize(); $("#comSupplierName").selectize();

85
wms/rib02-edit.php

@ -9,44 +9,37 @@ $ribsub = mysqli_fetch_assoc($rib_query);
//取得費用項目代碼 //取得費用項目代碼
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$member = array();
//取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if(isset($member["$personid"])){
array_push($member["$personid"], "$depart");}
}
//取得部門代碼 $sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; $feetype = $conn->query($sql_feetype);
$deptype = $conn->query($sql_department); $member = array();
$conn = null; //取得人員名單與使用者的部門
$sql_mydept = "SELECT UserId, Username FROM capMembership";
$deptmem = $conn->query($sql_mydept);
foreach ($deptmem as $mem) {
$userid = $mem['UserId'];
$username = $mem['Username'];
$member["$userid"] = [$username];
};
$sql_dept = "SELECT DeptId, PersonId FROM comPerson WHERE DeptId!='0001'";
$allpeople = $conn->query($sql_dept);
foreach ($allpeople as $man) {
if ($man['PersonId'] == $user_id) {
$mydepart = $man['DeptId'];
}
$personid = $man['PersonId'];
$depart = $man['DeptId'];
if (isset($member["$personid"])) {
array_push($member["$personid"], "$depart");
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
$conn = null;
//取得計量單位 //取得計量單位
$sql_unit = "SELECT * FROM unit"; $sql_unit = "SELECT * FROM unit";
$unit_query = mysqli_query($link, $sql_unit); $unit_query = mysqli_query($link, $sql_unit);
@ -54,7 +47,7 @@ $unit = mysqli_fetch_all($unit_query, MYSQLI_ASSOC);
// 連線T8MASADA 取得供應商、合約跟作番號 // 連線T8MASADA 取得供應商、合約跟作番號
try { try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $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);
$sql_Biz = "SELECT * FROM comBusinessPartner"; $sql_Biz = "SELECT * FROM comBusinessPartner";
@ -188,9 +181,9 @@ try {
<?php <?php
foreach ($deptype as $dept) { ?> foreach ($deptype as $dept) { ?>
<option value="<?php echo $dept['DeptId']; ?>" <?php <option value="<?php echo $dept['DeptId']; ?>" <?php
if ($dept['DeptId'] == $ribsub['FeeDeptId']) { if ($dept['DeptId'] == $ribsub['FeeDeptId']) {
echo "selected"; echo "selected";
} ?>><?php echo $dept['DeptName']; ?></option> } ?>><?php echo $dept['DeptName']; ?></option>
<?php }; <?php };
?> ?>
</select> </select>
@ -207,8 +200,8 @@ try {
<?php <?php
foreach ($member as $key => $value) { ?> foreach ($member as $key => $value) { ?>
<option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $ribsub['WriteOffId']) { <option value="<?php echo $key; ?>" style="display:none" id="<?= 'WriteOff' . $value[1] . '-' . $value[0] ?>" <?php if ($key == $ribsub['WriteOffId']) {
echo "selected"; echo "selected";
} ?>> <?php echo $value[0]; ?> </option> } ?>> <?php echo $value[0]; ?> </option>
<?php }; ?> <?php }; ?>
</select> </select>
</div> </div>
@ -429,7 +422,9 @@ try {
<div class="col-md-3"> <div class="col-md-3">
<label for="comSupplierName">供應商</label> <label for="comSupplierName">供應商</label>
<select name="comSupplierName" id="comSupplierName"> <select name="comSupplierName" id="comSupplierName">
<option value="" <?php if($ribsub['comSupplierId']==""){echo "selected";} ?>> </option> <option value="" <?php if ($ribsub['comSupplierId'] == "") {
echo "selected";
} ?>> </option>
<option value="雜項請款用" <?php if ($ribsub['comSupplierName'] == "雜項請款用") { <option value="雜項請款用" <?php if ($ribsub['comSupplierName'] == "雜項請款用") {
echo "selected"; echo "selected";
} ?>>V0001雜項請款用</option> } ?>>V0001雜項請款用</option>
@ -437,7 +432,7 @@ try {
foreach ($BizPartner as $BizKey => $BizValue) { ?> foreach ($BizPartner as $BizKey => $BizValue) { ?>
<option value="<?= $BizValue['BizPartnerName'] ?>" <?php if ($BizValue['BizPartnerName'] == $ribsub['comSupplierName']) { <option value="<?= $BizValue['BizPartnerName'] ?>" <?php if ($BizValue['BizPartnerName'] == $ribsub['comSupplierName']) {
echo "selected"; echo "selected";
} ?>><?= $BizValue['BizPartnerId'].$BizValue['BizPartnerName'] ?></option> } ?>><?= $BizValue['BizPartnerId'] . $BizValue['BizPartnerName'] ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -605,7 +600,7 @@ try {
$("#OAmount").val($("#Quantity").val() * $("#Price").val()); $("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val()); $("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") { if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val()-($("#OAmount").val() /1.05)); $("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val()); $("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05); $("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()); $("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
@ -621,7 +616,7 @@ try {
$("#OAmount").val($("#Quantity").val() * $("#Price").val()); $("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val()); $("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") { if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val()-($("#OAmount").val()/ 1.05)); $("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val()); $("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05); $("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()); $("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
@ -637,7 +632,7 @@ try {
$("#OAmount").val($("#Quantity").val() * $("#Price").val()); $("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val()); $("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") { if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val()-($("#OAmount").val()/ 1.05)); $("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val()); $("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05); $("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()); $("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());

22
wms/rib02-submit.php

@ -37,22 +37,14 @@ $LAmount = isset($_POST['LAmount']) ? $_POST['LAmount'] : null;
$TaxNo = empty($_POST['TaxNo']) ? '' : $_POST['TaxNo']; $TaxNo = empty($_POST['TaxNo']) ? '' : $_POST['TaxNo'];
if (isset($comSupplierName) && ($comSupplierName != "雜項請款用")) { if (isset($comSupplierName) && ($comSupplierName != "雜項請款用")) {
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); $sql = "SELECT * FROM comBusinessPartner";
if ($conn) { $BizPartner = $conn->query($sql);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); foreach ($BizPartner as $company) {
$sql = "SELECT * FROM comBusinessPartner"; if ($company['BizPartnerName'] == $comSupplierName) {
$BizPartner = $conn->query($sql); $TaxNo = $company['TaxNo'];
foreach ($BizPartner as $company) { $comSupplierId = $company['BizPartnerId'];
if ($company['BizPartnerName'] == $comSupplierName) {
$TaxNo = $company['TaxNo'];
$comSupplierId = $company['BizPartnerId'];
}
}
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
} else { } else {
$comSupplierId = "V0001"; $comSupplierId = "V0001";

23
wms/rib03-download.php

@ -16,25 +16,14 @@ $sql = "SELECT * FROM rib WHERE rib_id=$rib_id";
$rib = mysqli_query($link, $sql); $rib = mysqli_query($link, $sql);
$rib = mysqli_fetch_assoc($rib); $rib = mysqli_fetch_assoc($rib);
$today = "列印日期:" . date('Y-m-d'); $today = "列印日期:" . date('Y-m-d');
// 取得部門代碼
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//取得部門代碼 //取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'"; $sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department); $deptype = $conn->query($sql_department);
foreach ($deptype as $department) { foreach ($deptype as $department) {
if ($department['DeptId'] == $rib['DeptId']) { if ($department['DeptId'] == $rib['DeptId']) {
$dept = $department['DeptName']; $dept = $department['DeptName'];
}
}
$conn = null;
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }

364
wms/rib03-submit.php

@ -21,38 +21,17 @@ if ($state == 1) {
$rib = mysqli_query($link, $rib_query); $rib = mysqli_query($link, $rib_query);
$rib = mysqli_fetch_assoc($rib); $rib = mysqli_fetch_assoc($rib);
$OAmountWithTax = 0; $OAmountWithTax = 0;
//取得部門代碼
// 取得部門代碼 $sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
// $dept = ""; $deptype = $conn->query($sql_department);
// $sql_depid = "SELECT DISTINCT department_id, name from department"; foreach ($deptype as $department) {
// $dept_query = mysqli_query($link, $sql_depid); if ($department['DeptId'] == $rib['DeptId']) {
// $deptype = mysqli_fetch_all($dept_query, MYSQLI_ASSOC); $dept = $department['DeptName'];
// foreach ($deptype as $key => $value) {
// if ($value['department_id'] == $rib['DeptId']) {
// $dept = $value['name'];
// }
// }
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234");
if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//取得部門代碼
$sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001'";
$deptype = $conn->query($sql_department);
foreach ($deptype as $department) {
if ($department['DeptId'] == $rib['DeptId']) {
$dept = $department['DeptName'];
}
}
$conn = null;
} }
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
// 爬蟲--匯率 // 爬蟲--匯率
function htmlContentGet($url) function htmlContentGet($url)
{ {
@ -238,219 +217,172 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan
$rib = mysqli_query($link, $rib_query); $rib = mysqli_query($link, $rib_query);
$rib = mysqli_fetch_assoc($rib); $rib = mysqli_fetch_assoc($rib);
// 產生mysql單據編號
// $MaxBillNo = 0;
// $curreny_date = date('ym');
// $query_rib = array();
// $sqlname = $rib['TransactId'];
// $sqlname .= $curreny_date;
// $BillNo = $sqlname;
// $date_sql = "SELECT BillNo from rib WHERE (BillNo LIKE '$sqlname%') &&CurrentState==2";
// $query_rib = mysqli_query($link, $date_sql);
// $myNo = mysqli_fetch_all($query_rib);
// foreach ($myNo as $thisMyNo) {
// $thisMyNo = (int)substr($thisMyNo[0], -2);
// if ($thisMyNo > $MaxBillNo) {
// $MaxBillNo = $thisMyNo;
// }
// }
// 連線T8MASADA 取得單據編號
// try {
// $conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8TEST", "masada", "ZXCVasdf1234");
// if ($conn) {
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $sql = "SELECT BillNo FROM glFeeWriteOff WHERE (BillNo LIKE '$sqlname%')";
// $Noo = $conn->query($sql);
// foreach ($Noo as $maxMs) {
// $thisMsMax = (int)substr($maxMs['BillNo'], -2);
// if ($thisMsMax > $MaxBillNo) {
// $MaxBillNo = $thisMsMax;
// }
// }
// }
// } catch (PDOException $e) {
// echo "fail";
// echo $e->getMessage();
// }
// $MaxBillNo += 1;
// if ($MaxBillNo < 10) {
// $BillNo .= "0" . strval($MaxBillNo);
// } else {
// $BillNo .= strval($MaxBillNo);
// }
$BillNo = $rib['BillNo']; $BillNo = $rib['BillNo'];
//連線T8資料庫 //連線T8資料庫
try {
$conn = new PDO("sqlsrv:Server=60.244.87.101;Database=T8MASADA", "masada", "ZXCVasdf1234"); // // 表頭
if ($conn) { $BillDate = $rib['BillDate'];
// // 表頭 $TypeId = $rib['TypeId'];
$BillDate = $rib['BillDate']; $CurrId = ($rib['CurrId'] == "CNY") ? "RMB" : $rib['CurrId'];
$TypeId = $rib['TypeId']; $TransactId = $rib['TransactId'];
$CurrId = ($rib['CurrId'] == "CNY") ? "RMB" : $rib['CurrId']; $WriteOffType = $rib['WriteOffType'];
$TransactId = $rib['TransactId']; $WriteOffId = $rib['WriteOffId'];
$WriteOffType = $rib['WriteOffType']; $WriteOffDescribe = empty($rib['WriteOffDescribe']) ? null : $rib['WriteOffDescribe'];
$WriteOffId = $rib['WriteOffId']; $DeptId = $rib['DeptId'];
$WriteOffDescribe = empty($rib['WriteOffDescribe']) ? null : $rib['WriteOffDescribe']; $CostCenterId = empty($rib['CostCenterId']) ? Null : $rib['CostCenterId'];
$DeptId = $rib['DeptId']; $HadPayOAmount = $rib['HadPayOAmount'];
$CostCenterId = empty($rib['CostCenterId']) ? Null : $rib['CostCenterId']; $HadPayLAmount = $rib['HadPayLAmount'];
$HadPayOAmount = $rib['HadPayOAmount']; $UnPayOAmount = $rib['UnPayOAmount'];
$HadPayLAmount = $rib['HadPayLAmount']; $UnPayLAmount = $rib['UnPayLAmount'];
$UnPayOAmount = $rib['UnPayOAmount']; $PaymentState = $rib['PaymentState'];
$UnPayLAmount = $rib['UnPayLAmount']; $Balance = $rib['Balance'];
$PaymentState = $rib['PaymentState']; $LBalance = $rib['LBalance'];
$Balance = $rib['Balance']; $GatheringPersonId = $rib['GatheringPersonId'];
$LBalance = $rib['LBalance']; $GatheringPersonDescribe = empty($rib['GatheringPersonDescribe']) ? Null : $rib['GatheringPersonDescribe'];
$GatheringPersonId = $rib['GatheringPersonId']; $BankId = empty($rib['BankId']) ? Null : $rib['BankId'];
$GatheringPersonDescribe = empty($rib['GatheringPersonDescribe']) ? Null : $rib['GatheringPersonDescribe']; $BankName = empty($rib['BankName']) ? Null : $rib['BankName'];
$BankId = empty($rib['BankId']) ? Null : $rib['BankId']; if (isset($BankId) && isset($BankName)) {
$BankName = empty($rib['BankName']) ? Null : $rib['BankName']; $totalBankName = $BankId . $BankName;
if (isset($BankId) && isset($BankName)) { }
$totalBankName = $BankId . $BankName; $BankAccount = empty($rib['BankAccount']) ? Null : $rib['BankAccount'];
} $BankAccountName = empty($rib['BankAccountName']) ? Null : $rib['BankAccountName'];
$BankAccount = empty($rib['BankAccount']) ? Null : $rib['BankAccount']; $IsTaxBill = $rib['IsTaxBill'];
$BankAccountName = empty($rib['BankAccountName']) ? Null : $rib['BankAccountName']; $OAmount = $rib['OAmount'];
$IsTaxBill = $rib['IsTaxBill']; $LAmount = $rib['LAmount'];
$OAmount = $rib['OAmount']; $OTax = $rib['OTax'];
$LAmount = $rib['LAmount']; $LTax = $rib['LTax'];
$OTax = $rib['OTax']; $LAmountWithTax = $rib['LAmountWithTax'];
$LTax = $rib['LTax']; $OAmountWithTax = $rib['OAmountWithTax'];
$LAmountWithTax = $rib['LAmountWithTax']; $IsContainTax = $rib['IsContainTax'];
$OAmountWithTax = $rib['OAmountWithTax']; $AdvanceOAmount = $rib['AdvanceOAmount'];
$IsContainTax = $rib['IsContainTax']; $AdvanceLAmount = $rib['AdvanceLAmount'];
$AdvanceOAmount = $rib['AdvanceOAmount']; $PrePayWriteOffAmount = $rib['PrePayWriteOffAmount'];
$AdvanceLAmount = $rib['AdvanceLAmount']; $WriteOffAmount = $rib['WriteOffAmount'];
$PrePayWriteOffAmount = $rib['PrePayWriteOffAmount']; $TelNo = empty($rib['TelNo']) ? Null : $rib['TelNo'];
$WriteOffAmount = $rib['WriteOffAmount']; $UnPaymentLAmt = empty($rib['UnPaymentLAmt']) ? null : $rib['UnPaymentLAmt'];
$TelNo = empty($rib['TelNo']) ? Null : $rib['TelNo'];
$UnPaymentLAmt = empty($rib['UnPaymentLAmt']) ? null : $rib['UnPaymentLAmt'];
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO glFeeWriteOff(BillNo, BillDate, OrgId,FOrgId,TypeId,PayOrgId,
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO glFeeWriteOff(BillNo, BillDate, OrgId,FOrgId,TypeId,PayOrgId,
CurrId,TransactId,WriteOffType,BizOrgId,WriteOffId,DeptId, CurrId,TransactId,WriteOffType,BizOrgId,WriteOffId,DeptId,
HadPayOAmount,HadPayLAmount,UnPayOAmount,UnPayLAmount,PaymentState,Balance,LBalance, HadPayOAmount,HadPayLAmount,UnPayOAmount,UnPayLAmount,PaymentState,Balance,LBalance,
FillUp,GatheringBizOrgId, GatheringPersonId, IsTaxBill, OAmount,LAmount,OTax,LTax,LAmountWithTax,OAmountWithTax, FillUp,GatheringBizOrgId, GatheringPersonId, IsTaxBill, OAmount,LAmount,OTax,LTax,LAmountWithTax,OAmountWithTax,
IsContainTax,AdvanceOAmount,AdvanceLAmount,PrePayWriteOffAmount,WriteOffAmount, IsContainTax,AdvanceOAmount,AdvanceLAmount,PrePayWriteOffAmount,WriteOffAmount,
CompId,UnPaymentOAmt,UnPaymentLAmt,IsPayment, CurrentState,PermitState"; CompId,UnPaymentOAmt,UnPaymentLAmt,IsPayment, CurrentState,PermitState";
$sql2 = ") VALUES ('$BillNo',$BillDate,'1000','1000','$TypeId','1000', $sql2 = ") VALUES ('$BillNo',$BillDate,'1000','1000','$TypeId','1000',
'$CurrId','$TransactId',$WriteOffType,'1000','$WriteOffId','$DeptId', '$CurrId','$TransactId',$WriteOffType,'1000','$WriteOffId','$DeptId',
$HadPayOAmount,$HadPayLAmount,$UnPayOAmount,$UnPayLAmount,$PaymentState,$Balance,$LBalance, $HadPayOAmount,$HadPayLAmount,$UnPayOAmount,$UnPayLAmount,$PaymentState,$Balance,$LBalance,
0,'1000','$GatheringPersonId',$IsTaxBill,$OAmount,$LAmount,$OTax,$LTax,$LAmountWithTax,$OAmountWithTax, 0,'1000','$GatheringPersonId',$IsTaxBill,$OAmount,$LAmount,$OTax,$LTax,$LAmountWithTax,$OAmountWithTax,
$IsContainTax,$AdvanceOAmount,$AdvanceLAmount,$PrePayWriteOffAmount,$WriteOffAmount, $IsContainTax,$AdvanceOAmount,$AdvanceLAmount,$PrePayWriteOffAmount,$WriteOffAmount,
'1001',$WriteOffAmount,$UnPaymentLAmt,0,2,2"; '1001',$WriteOffAmount,$UnPaymentLAmt,0,2,2";
$sql .= empty($CostCenterId) ? "" : ",CostCenterId"; $sql .= empty($CostCenterId) ? "" : ",CostCenterId";
$sql2 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'"; $sql2 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'";
$sql .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe"; $sql .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe";
$sql2 .= empty($WriteOffDescribe) ? "" : ",'" . $WriteOffDescribe . "'"; $sql2 .= empty($WriteOffDescribe) ? "" : ",'" . $WriteOffDescribe . "'";
$sql .= empty($GatheringPersonDescribe) ? "" : ",GatheringPersonDescribe"; $sql .= empty($GatheringPersonDescribe) ? "" : ",GatheringPersonDescribe";
$sql2 .= empty($GatheringPersonDescribe) ? "" : ",'" . $GatheringPersonDescribe . "'"; $sql2 .= empty($GatheringPersonDescribe) ? "" : ",'" . $GatheringPersonDescribe . "'";
$sql .= empty($totalBankName) ? "" : ",BankName"; $sql .= empty($totalBankName) ? "" : ",BankName";
$sql2 .= empty($totalBankName) ? "" : ",'" . $totalBankName . "'"; $sql2 .= empty($totalBankName) ? "" : ",'" . $totalBankName . "'";
$sql .= empty($BankAccount) ? "" : ",BankAccount"; $sql .= empty($BankAccount) ? "" : ",BankAccount";
$sql2 .= empty($BankAccount) ? "" : ",'" . $BankAccount . "'"; $sql2 .= empty($BankAccount) ? "" : ",'" . $BankAccount . "'";
$sql .= empty($BankAccountName) ? "" : ",BankAccountName"; $sql .= empty($BankAccountName) ? "" : ",BankAccountName";
$sql2 .= empty($BankAccountName) ? "" : ",'" . $BankAccountName . "'"; $sql2 .= empty($BankAccountName) ? "" : ",'" . $BankAccountName . "'";
$sql .= empty($TelNo) ? "" : ",TelNo"; $sql .= empty($TelNo) ? "" : ",TelNo";
$sql2 .= empty($TelNo) ? "" : ",'" . $TelNo . "'"; $sql2 .= empty($TelNo) ? "" : ",'" . $TelNo . "'";
$sql .= $sql2; $sql .= $sql2;
$sql .= ")"; $sql .= ")";
$result = $conn->query($sql); $result = $conn->query($sql);
// 更改WMS RIB狀態 // 更改WMS RIB狀態
$rib_sql = "UPDATE rib SET BillNo='$BillNo',CurrentState=2, PermitState=2 WHERE rib_id =$rib_id"; $rib_sql = "UPDATE rib SET BillNo='$BillNo',CurrentState=2, PermitState=2 WHERE rib_id =$rib_id";
mysqli_query($link, $rib_sql); mysqli_query($link, $rib_sql);
//取得表身資料 //取得表身資料
$ribsub_query = "SELECT * FROM rib_sub WHERE rib_id = $rib_id"; $ribsub_query = "SELECT * FROM rib_sub WHERE rib_id = $rib_id";
$ribsub_data = mysqli_query($link, $ribsub_query); $ribsub_data = mysqli_query($link, $ribsub_query);
$RowCode = 0; $RowCode = 0;
while ($ribsub = mysqli_fetch_assoc($ribsub_data)) { while ($ribsub = mysqli_fetch_assoc($ribsub_data)) {
$RowCode += 1; $RowCode += 1;
$RowNo = $ribsub['RowNo']; $RowNo = $ribsub['RowNo'];
$FeeDate = $ribsub['FeeDate']; $FeeDate = $ribsub['FeeDate'];
$FeeTypeId = $ribsub['FeeTypeId']; $FeeTypeId = $ribsub['FeeTypeId'];
$WriteOffType = $ribsub['WriteOffType']; $WriteOffType = $ribsub['WriteOffType'];
$WriteOffId = $ribsub['WriteOffId']; $WriteOffId = $ribsub['WriteOffId'];
$WriteOffDescribe = empty($ribsub['WriteOffDescribe']) ? Null : $ribsub['WriteOffDescribe']; $WriteOffDescribe = empty($ribsub['WriteOffDescribe']) ? Null : $ribsub['WriteOffDescribe'];
$FeeDeptId = $ribsub['FeeDeptId']; $FeeDeptId = $ribsub['FeeDeptId'];
$CostCenterId = empty($ribsub['CostCenterId']) ? Null : $ribsub['CostCenterId']; $CostCenterId = empty($ribsub['CostCenterId']) ? Null : $ribsub['CostCenterId'];
$UnitId = $ribsub['UnitId']; $UnitId = $ribsub['UnitId'];
$Quantity = $ribsub['Quantity']; $Quantity = $ribsub['Quantity'];
$Price = $ribsub['Price']; $Price = $ribsub['Price'];
$CurrOAmount = $ribsub['CurrOAmount']; $CurrOAmount = $ribsub['CurrOAmount'];
$CurrLAmount = $ribsub['CurrentLAmount']; $CurrLAmount = $ribsub['CurrentLAmount'];
$TaxId = $ribsub['TaxId']; $TaxId = $ribsub['TaxId'];
$TaxRate = $ribsub['TaxRate']; $TaxRate = $ribsub['TaxRate'];
$OTax = $ribsub['OTax']; $OTax = $ribsub['OTax'];
$LTax = $ribsub['LTax']; $LTax = $ribsub['LTax'];
$LAmountUnWithTax = $ribsub['LAmountUnWithTax']; $LAmountUnWithTax = $ribsub['LAmountUnWithTax'];
$OAmountUnWithTax = $ribsub['OAmountUnWithTax']; $OAmountUnWithTax = $ribsub['OAmountUnWithTax'];
$OAmount = $ribsub['OAmount']; $OAmount = $ribsub['OAmount'];
$LAmount = $ribsub['LAmount']; $LAmount = $ribsub['LAmount'];
$FeeBalance = $ribsub['FeeBalance']; $FeeBalance = $ribsub['FeeBalance'];
$VoucherCount = $ribsub['VoucherCount']; $VoucherCount = $ribsub['VoucherCount'];
$FeeNoteShow = empty($ribsub['FeeNoteShow']) ? Null : $ribsub['FeeNoteShow']; $FeeNoteShow = empty($ribsub['FeeNoteShow']) ? Null : $ribsub['FeeNoteShow'];
$ProjectId = empty($ribsub['ProjectId']) ? null : $ribsub['ProjectId']; $ProjectId = empty($ribsub['ProjectId']) ? null : $ribsub['ProjectId'];
$InvoiceNo = empty($ribsub['InvoiceNo']) ? null : $ribsub['InvoiceNo']; $InvoiceNo = empty($ribsub['InvoiceNo']) ? null : $ribsub['InvoiceNo'];
$InvoiceNo = trim($InvoiceNo); $InvoiceNo = trim($InvoiceNo);
$InvoiceNo = str_replace('-', '', $InvoiceNo); $InvoiceNo = str_replace('-', '', $InvoiceNo);
$comSupplierId = empty($ribsub['comSupplierId']) ? null : $ribsub['comSupplierId']; $comSupplierId = empty($ribsub['comSupplierId']) ? null : $ribsub['comSupplierId'];
$VoucherType = empty($ribsub['VoucherType']) ? null : $ribsub['VoucherType']; $VoucherType = empty($ribsub['VoucherType']) ? null : $ribsub['VoucherType'];
$InvoiceId = empty($ribsub['InvoiceId']) ? null : $ribsub['InvoiceId']; $InvoiceId = empty($ribsub['InvoiceId']) ? null : $ribsub['InvoiceId'];
$CurrId = ($ribsub['CurrId'] == "CNY") ? "RMB" : $rib['CurrId']; $CurrId = ($ribsub['CurrId'] == "CNY") ? "RMB" : $rib['CurrId'];
$WriteOffAmount = $ribsub['WriteOffAmount']; $WriteOffAmount = $ribsub['WriteOffAmount'];
$IsCounteract = $ribsub['IsCounteract']; $IsCounteract = $ribsub['IsCounteract'];
$CU_MaterialId = empty($ribsub['CU_MaterialId']) ? null : $ribsub['CU_MaterialId']; $CU_MaterialId = empty($ribsub['CU_MaterialId']) ? null : $ribsub['CU_MaterialId'];
$TaxNo = empty($ribsub['TaxNo']) ? null : $ribsub['TaxNo']; $TaxNo = empty($ribsub['TaxNo']) ? null : $ribsub['TaxNo'];
$sqlsub = "INSERT INTO glFeeWriteOffSub (BillNo, RowCode,RowNo,FeeDate,FeeTypeId, WriteOffType, $sqlsub = "INSERT INTO glFeeWriteOffSub (BillNo, RowCode,RowNo,FeeDate,FeeTypeId, WriteOffType,
BizOrgId, WriteOffId, FeeOrgId, FeeDeptId, FeeCompanyId, UnitId , BizOrgId, WriteOffId, FeeOrgId, FeeDeptId, FeeCompanyId, UnitId ,
Quantity, Price, CurrOAmount,CurrLAmount,TaxId,TaxRate,OTax,LTax,LAmountUnWithTax Quantity, Price, CurrOAmount,CurrLAmount,TaxId,TaxRate,OTax,LTax,LAmountUnWithTax
,OAmountUnWithTax,OAmount,LAmount,FeeBalance,VoucherCount,CurrId,WriteOffAmount,SupplyOrgId,IsCounteract,IsKeyByFeeInfo ,OAmountUnWithTax,OAmount,LAmount,FeeBalance,VoucherCount,CurrId,WriteOffAmount,SupplyOrgId,IsCounteract,IsKeyByFeeInfo
"; ";
$sqlsub2 = ") VALUES ('$BillNo',$RowCode, $RowNo,$FeeDate,'$FeeTypeId',$WriteOffType, $sqlsub2 = ") VALUES ('$BillNo',$RowCode, $RowNo,$FeeDate,'$FeeTypeId',$WriteOffType,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId', '1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',
$Quantity, $Price, $CurrOAmount, $CurrLAmount,'$TaxId',$TaxRate,$OTax,$LTax,$LAmountUnWithTax $Quantity, $Price, $CurrOAmount, $CurrLAmount,'$TaxId',$TaxRate,$OTax,$LTax,$LAmountUnWithTax
,$OAmountUnWithTax,$OAmount,$LAmount,$FeeBalance,$VoucherCount,'$CurrId',$WriteOffAmount,'1000',$IsCounteract,0 ,$OAmountUnWithTax,$OAmount,$LAmount,$FeeBalance,$VoucherCount,'$CurrId',$WriteOffAmount,'1000',$IsCounteract,0
"; ";
$sqlsub .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe"; $sqlsub .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe";
$sqlsub2 .= empty($WriteOffDescribe) ? "" : ",'" . $WriteOffDescribe . "'"; $sqlsub2 .= empty($WriteOffDescribe) ? "" : ",'" . $WriteOffDescribe . "'";
$sqlsub .= empty($CostCenterId) ? "" : ",CostCenterId"; $sqlsub .= empty($CostCenterId) ? "" : ",CostCenterId";
$sqlsub2 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'"; $sqlsub2 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'";
$sqlsub .= empty($FeeNoteShow) ? "" : ",FeeNoteShow"; $sqlsub .= empty($FeeNoteShow) ? "" : ",FeeNoteShow";
$sqlsub2 .= empty($FeeNoteShow) ? "" : ",'" . $FeeNoteShow . "'"; $sqlsub2 .= empty($FeeNoteShow) ? "" : ",'" . $FeeNoteShow . "'";
$sqlsub .= empty($ProjectId) ? "" : ",ProjectId"; $sqlsub .= empty($ProjectId) ? "" : ",ProjectId";
$sqlsub2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'"; $sqlsub2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'";
$sqlsub .= empty($InvoiceNo) ? "" : ",InvoiceNo"; $sqlsub .= empty($InvoiceNo) ? "" : ",InvoiceNo";
$sqlsub2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'"; $sqlsub2 .= empty($InvoiceNo) ? "" : ",'" . $InvoiceNo . "'";
$sqlsub .= empty($CU_MaterialId) ? "" : ",CU_MaterialId"; $sqlsub .= empty($CU_MaterialId) ? "" : ",CU_MaterialId";
$sqlsub2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'"; $sqlsub2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";
$sqlsub .= empty($comSupplierId) ? "" : ",comSupplierId"; $sqlsub .= empty($comSupplierId) ? "" : ",comSupplierId";
$sqlsub2 .= empty($comSupplierId) ? "" : ",'" . $comSupplierId . "'"; $sqlsub2 .= empty($comSupplierId) ? "" : ",'" . $comSupplierId . "'";
$sqlsub .= empty($VoucherType) ? "" : ",VoucherType"; $sqlsub .= empty($VoucherType) ? "" : ",VoucherType";
$sqlsub2 .= empty($VoucherType) ? "" : ",'" . $VoucherType . "'"; $sqlsub2 .= empty($VoucherType) ? "" : ",'" . $VoucherType . "'";
$sqlsub .= empty($InvoiceId) ? "" : ",InvoiceId"; $sqlsub .= empty($InvoiceId) ? "" : ",InvoiceId";
$sqlsub2 .= empty($InvoiceId) ? "" : ",'" . $InvoiceId . "'"; $sqlsub2 .= empty($InvoiceId) ? "" : ",'" . $InvoiceId . "'";
$sqlsub .= empty($TaxNo) ? "" : ",TaxNo"; $sqlsub .= empty($TaxNo) ? "" : ",TaxNo";
$sqlsub2 .= empty($TaxNo) ? "" : ",'" . $TaxNo . "'"; $sqlsub2 .= empty($TaxNo) ? "" : ",'" . $TaxNo . "'";
$sqlsub .= $sqlsub2; $sqlsub .= $sqlsub2;
$sqlsub .= ")"; $sqlsub .= ")";
$result2 = $conn->query($sqlsub); $result2 = $conn->query($sqlsub);
}
}
} catch (PDOException $e) {
echo "fail";
echo $e->getMessage();
} }
$content = "需要審核的費用報銷單為:"; $content = "需要審核的費用報銷單為:";
$notice_rib_sql = "SELECT BillNo FROM rib WHERE CurrentState = 1"; $notice_rib_sql = "SELECT BillNo FROM rib WHERE CurrentState = 1";
$notice_rib = mysqli_query($link, $notice_rib_sql); $notice_rib = mysqli_query($link, $notice_rib_sql);

Loading…
Cancel
Save