You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.4 KiB
111 lines
4.4 KiB
<?php
|
|
include "./header.php";
|
|
|
|
|
|
$submit = $_GET['submit'];
|
|
$current_date = date('Y-m-d H:i:s');
|
|
$state = $_GET['state'];
|
|
|
|
$rib_id = empty($_POST['rib_id']) ? NULL : $_POST['rib_id'];
|
|
$BillNo = empty($_POST["BillNo"]) ? NULL : $_POST['BillNo'];
|
|
$BillDate = intval(date('Ymd'));
|
|
$CurrId = $_POST["CurrId"];
|
|
$TransactId = $_POST["TransactId"];
|
|
$pay_type = $_POST['pay_type'];
|
|
$WriteOffType = 2;
|
|
$DeptId = $_POST["DeptId"];
|
|
$WriteOffId = $_POST["WriteOffId"];
|
|
$GatheringPersonId = empty($_POST["GatheringPersonId"]) ? NULL : $_POST["GatheringPersonId"];
|
|
$OAmountWithTax = empty($_POST["OAmountWithTax"]) ? NULL : $_POST["OAmountWithTax"];
|
|
$CostCenterId = empty($_POST["CostCenterId"]) ? NULL : $_POST["CostCenterId"];
|
|
//連線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 = "SELECT * FROM comCompanyPersonAccountSetting WHERE PersonId='$GatheringPersonId'";
|
|
$bank = $conn->query($sql);
|
|
$conn = null;
|
|
while ($bankInfo = $bank->fetch(PDO::FETCH_ASSOC)) {
|
|
$BankId = $bankInfo['BankId'];
|
|
$BankName = $bankInfo['BankName'];
|
|
$BankAccount = $bankInfo['BankAccount'];
|
|
$BankAccountName = $bankInfo['AccountName'];
|
|
}
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "fail";
|
|
echo $e->getMessage();
|
|
}
|
|
$SQL1 = "";
|
|
|
|
if ($submit == "edit") {
|
|
$SQL1 = "UPDATE rib SET BillDate=$BillDate, CurrId='$CurrId', TransactId='$TransactId',
|
|
WriteOffType=$WriteOffType, DeptId='$DeptId', WriteOffId='$WriteOffId',GatheringPersonId='$GatheringPersonId',pay_type=$pay_type,LastOperatorId='$user_id'";
|
|
$SQL1 .= empty($BankId) ? "" : ", BankId= '$BankId'";
|
|
$SQL1 .= empty($BankName) ? "" : ", BankName= '$BankName'";
|
|
$SQL1 .= empty($BankAccount) ? "" : ", BankAccount= '$BankAccount'";
|
|
$SQL1 .= empty($BankAccountName) ? "" : ", BankAccountName= '$BankAccountName'";
|
|
$SQL1 .= empty($OAmountWithTax) ? "" : ", OAmountWithTax= '$OAmountWithTax'";
|
|
$SQL1 .= empty($rib_title) ? "" : ", rib_title= '$rib_title'";
|
|
$SQL1 .= " WHERE rib_id = '$rib_id'";
|
|
}
|
|
|
|
if ($submit == "add") {
|
|
$SQL1 = "INSERT INTO rib (`BillNo`,`BillDate`,`CurrId`,`TransactId`,`DeptId`,`WriteOffId`,`TypeId`,`IsTaxBill`,
|
|
`IsPayment`,`CurrentState`,`FlowState`,`VaryState`,`PermitState`,`HadPayOAmount`,`HadPayLAmount`,`IsContainTax`,`pay_type`,`OrgId`,`CreatorId`";
|
|
$SQL1 .= empty($WriteOffType) ? "" : ",`WriteOffType`";
|
|
$SQL1 .= empty($GatheringPersonId) ? "" : ",`GatheringPersonId`";
|
|
$SQL1 .= empty($BankId) ? "" : ",`BankId`";
|
|
$SQL1 .= empty($BankName) ? "" : ",`BankName`";
|
|
$SQL1 .= empty($BankAccount) ? "" : ",`BankAccount`";
|
|
$SQL1 .= empty($BankAccountName) ? "" : ",`BankAccountName`";
|
|
$SQL1 .= empty($rib_title) ? "" : ",`rib_title`";
|
|
$SQL1 .= empty($CostCenterId) ? "" : ",`CostCenterId`";
|
|
|
|
|
|
$SQL2 = ") VALUES ('$BillNo',$BillDate,'$CurrId','$TransactId','$DeptId','$WriteOffId','CF',1,0,0,0,0,0,0,0,1,$pay_type,'1000','$user_id'";
|
|
$SQL2 .= empty($WriteOffType) ? "" : "," . $WriteOffType;
|
|
$SQL2 .= empty($GatheringPersonId) ? "" : ",'" . $GatheringPersonId . "'";
|
|
$SQL2 .= empty($BankId) ? "" : ",'" . $BankId . "'";
|
|
$SQL2 .= empty($BankName) ? "" : ",'" . $BankName . "'";
|
|
$SQL2 .= empty($BankAccount) ? "" : ",'" . $BankAccount . "'";
|
|
$SQL2 .= empty($BankAccountName) ? "" : ",'" . $BankAccountName . "'";
|
|
$SQL2 .= empty($rib_title) ? "" : ",'" . $rib_title . "'";
|
|
$SQL1 .= empty($CostCenterId) ? "" : ",'" . $CostCenterId . "'";
|
|
$SQL2 .= ")";
|
|
|
|
$SQL1 .= $SQL2;
|
|
}
|
|
|
|
|
|
//上傳資料庫
|
|
mysqli_query($link, $SQL1);
|
|
if (mysqli_affected_rows($link)) {
|
|
//echo "success";
|
|
echo '<script>alert("新增/更新 成功")</script>';
|
|
} else {
|
|
echo '<script>alert("新增/更新 失敗")</script>';
|
|
}
|
|
|
|
//增加紀錄
|
|
if ($user_id == 'M0056') {
|
|
$sql_submit = str_replace("'", "", $SQL1);
|
|
$sql_rib = "UPDATE rib SET LastOperatorId = '$user_id', LastOperation='$sql_submit' WHERE rib_id=$rib_id";
|
|
mysqli_query($link, $sql_rib);
|
|
}
|
|
|
|
if ($submit == "edit") {
|
|
?>
|
|
<script>
|
|
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=<?= $state ?>&<?= $token_link ?>";
|
|
</script>
|
|
|
|
<?php
|
|
} else {
|
|
?>
|
|
<script>
|
|
window.location.href = "rib02-create.php?BillNo=<?php echo $BillNo ?>&RowCode=1&CurrId=<?= $CurrId ?>&<?= $token_link ?>";
|
|
</script>
|
|
<?php
|
|
}
|
|
|