Browse Source

Merge branch 'main' into gary

gary
gary_chen\gary_chen 1 year ago
parent
commit
038bde23ae
  1. BIN
      wms/WriteOff.xlsx
  2. 138
      wms/rib02-create.php
  3. 160
      wms/rib02-edit.php
  4. 37
      wms/rib02-submit.php
  5. 17
      wms/rib03-submit.php

BIN
wms/WriteOff.xlsx

Binary file not shown.

138
wms/rib02-create.php

@ -3,6 +3,7 @@ include "./header.php";
$rib_id = isset($_GET['id']) ? $_GET['id'] : null;
$BillNo = isset($_GET['BillNo']) ? $_GET['BillNo'] : null;
$CurrId = isset($_GET['CurrId']) ? $_GET['CurrId'] : null;
$sql_rib = "";
if (empty($rib_id)) {
$sql_rib = "SELECT * FROM rib WHERE BillNo = '$BillNo' && CurrentState=0";
@ -97,9 +98,6 @@ $sql_department = "SELECT DeptId,DeptName FROM comDepartment WHERE DeptId!='0001
$deptype = $conn->query($sql_department);
//取得幣別
$CurrId = $_GET['CurrId'];
//取得計量單位
$sql_unit = "SELECT * FROM unit";
$unit_query = mysqli_query($link, $sql_unit);
@ -286,7 +284,7 @@ $materials = $conn->query($sql_Material);
</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)">
<input class="form-control" type="number" step="any" name="Price" id="Price" required>
</div>
<div class="col-md-3">
<label for="Quantity" style="color: red;">數量</label>
@ -423,6 +421,7 @@ $materials = $conn->query($sql_Material);
<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>
var TempArr = [];
var CurrId = "<?= $CurrId ?>";
$(document).ready(function() {
$("#ProjectId").selectize();
$("#CU_MaterialId").selectize();
@ -530,52 +529,106 @@ $materials = $conn->query($sql_Material);
changeWriteOffId($('#FeeDeptId').val());
})
$("#Price").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
});
$("#Quantity").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
});
$("#TaxId").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
})
$("#FeeDate").change(function() {
if ($("#FeeDate").val().length != 8) {
@ -594,8 +647,15 @@ $materials = $conn->query($sql_Material);
} else {
now.setMonth(now.getMonth() - 2);
now.setDate(1);
now.setDate(now.getDate() - 1)
if (feedate < now) {
now.setDate(now.getDate() - 1);
console.log(now.getFullYear());
console.log(now.getMonth());
console.log(now.getDate());
console.log(feedate.getFullYear());
console.log(feedate.getMonth());
console.log(feedate.getDate());
if (feedate <= now) {
alert("超過兩個月的費用無法進行報銷");
$("#FeeDate").val('');
}

160
wms/rib02-edit.php

@ -52,8 +52,8 @@ $bizcount = 0;
foreach ($BizPartner as $biz) {
$bizKey = $biz['BizPartnerId'];
$bizValue = $biz['BizPartnerName'];
array_push($BusinessPartner,$bizKey);
$bizcount +=1;
array_push($BusinessPartner, $bizKey);
$bizcount += 1;
}
$BizJSON = json_encode($BusinessPartner);
$sql_Project = "SELECT * FROM comProject";
@ -418,8 +418,8 @@ $materials = $conn->query($sql_Material);
</div>
<div class="form-group">
<div class="col-md-3" id="Tax">
<label for="TaxNo">供應商統一編號</label>
<input type="text" name="TaxNo" id="TaxNo" class="form-control" onblur="checkBiz()" value="<?= $ribsub['TaxNo'] ?>">
<label for="TaxNo">供應商統一編號</label>
<input type="text" name="TaxNo" id="TaxNo" class="form-control" onblur="checkBiz()" value="<?= $ribsub['TaxNo'] ?>">
</div>
</div>
@ -437,29 +437,31 @@ $materials = $conn->query($sql_Material);
<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" />
<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>
var CurrId = "<?= $ribsub['CurrId'] ?>";
$(document).ready(function() {
$("#ProjectId").selectize();
$("#CU_MaterialId").selectize();
})
function checkBiz() {
if ($("#TaxNo").val().length !== 8) {
alert("統一編號格式錯誤");
}else{
var biz = $("#TaxNo").val();
var BizArray = <?php echo $BizJSON; ?>;
var answer = 0;
for (var partner = 0; partner < <?= $bizcount ?>; partner++){
var value = BizArray[partner];
if (biz == value){
answer +=1
alert("統一編號格式錯誤");
} else {
var biz = $("#TaxNo").val();
var BizArray = <?php echo $BizJSON; ?>;
var answer = 0;
for (var partner = 0; partner < <?= $bizcount ?>; partner++) {
var value = BizArray[partner];
if (biz == value) {
answer += 1
}
}
if (answer == 1) {
alert("供應商認證成功")
} else {
alert("T8內無此供應商")
}
}
if (answer==1){
alert("供應商認證成功")
}else{
alert("T8內無此供應商")
}
}
}
var TempArr = [];
@ -569,52 +571,106 @@ $materials = $conn->query($sql_Material);
})
$("#Price").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
});
$("#Quantity").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
});
$("#TaxId").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#LAmount").val($("#OAmount").val() * $("#CurrLAmount").val());
if ($("#TaxId").val() === "ST005") {
$("#OTax").val($("#OAmount").val() - ($("#OAmount").val() / 1.05));
$("#LTax").val($("#OTax").val() * $("#CurrLAmount").val());
$("#OAmountUnWithTax").val($("#OAmount").val() / 1.05);
$("#LAmountUnWithTax").val($("#OAmountUnWithTax").val() * $("#CurrLAmount").val());
if (CurrId === "TWD") {
$("#OAmount").val(Math.round($("#Quantity").val() * $("#Price").val()));
$("#LAmount").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(Math.round($("#OAmount").val() - ($("#OAmount").val() / 1.05)));
$("#LTax").val(Math.round($("#OTax").val() * $("#CurrLAmount").val()));
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val() / 1.05));
$("#LAmountUnWithTax").val(Math.round($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(Math.round($("#OAmount").val()));
$("#LAmountUnWithTax").val(Math.round($("#OAmount").val() * $("#CurrLAmount").val()));
}
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
$("#OAmount").val(($("#Quantity").val() * $("#Price").val()).toFixed(2));
$("#LAmount").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
if ($("#TaxId").val() === "ST005") {
$("#OTax").val(($("#OAmount").val() - ($("#OAmount").val() / 1.05)).toFixed(2));
$("#LTax").val(($("#OTax").val() * $("#CurrLAmount").val()).toFixed(2));
$("#OAmountUnWithTax").val(($("#OAmount").val() / 1.05).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmountUnWithTax").val() * $("#CurrLAmount").val()).toFixed(2));
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val(($("#OAmount").val()).toFixed(2));
$("#LAmountUnWithTax").val(($("#OAmount").val() * $("#CurrLAmount").val()).toFixed(2));
}
}
})

37
wms/rib02-submit.php

@ -7,7 +7,8 @@ $state = empty($_GET['state']) ? 0 : $_GET['state'];
// 取得供應商
$BusinessPartner = array();
$sql_Biz = "SELECT comBusinessPartner.BizPartnerId, comBusinessPartner.BizPartnerName FROM comBusinessPartner INNER JOIN comSupplier ON comBusinessPartner.BizPartnerId=comSupplier.BizPartnerId WHERE comBusinessPartner.BizPartnerId !='V0001'";
$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 $biz) {
$bizKey = $biz['BizPartnerId'];
@ -20,30 +21,40 @@ $FeeDate = $_POST['FeeDate'];
$FeeTypeGen = isset($_POST['FeeTypeGen']) ? $_POST['FeeTypeGen'] : null;
$FeeTypeId = $_POST['FeeTypeId'];
$FeeDeptId = $_POST['FeeDeptId'];
$CurrId = empty($_POST['CurrId']) ? null : $_POST['CurrId'];
$WriteOffId = $_POST['WriteOffId'];
$FeeNoteShow = $_POST['FeeNoteShow'];
$ProjectId = empty($_POST['ProjectId']) ? Null : $_POST['ProjectId'];
$CU_MaterialId = empty($_POST['CU_MaterialId']) ? null : $_POST['CU_MaterialId'];
$UnitId = $_POST['UnitId'];
$Price = $_POST['Price'];
$Price = $CurrId == "TWD" ? round($_POST['Price']) : round($_POST['Price'], 2);
$Quantity = $_POST['Quantity'];
$OAmount = $_POST['OAmount'];
$OAmount = $CurrId == "TWD" ? round($_POST['OAmount']) : round($_POST['OAmount'], 2);
$TaxId = $_POST['TaxId'];
$IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount'];
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0;
$InvoiceNo = empty($_POST['InvoiceNo']) ? NULL : $_POST['InvoiceNo'];
$CurrId = empty($_POST['CurrId']) ? null : $_POST['CurrId'];
$CurrLAmount = empty($_POST['CurrLAmount']) ? null : $_POST['CurrLAmount'];
// $comSupplierName = empty($_POST['comSupplierName']) ? null : $_POST['comSupplierName'];
$FromSourceTag = 0;
$TaxRate = ($TaxId == "ST005") ? 0.05 : 0;
$OTax = isset($_POST['OTax']) ? $_POST['OTax'] : NULL;
$LTax = isset($_POST['LTax']) ? $_POST['LTax'] : NULL;
$OAmountUnWithTax = isset($_POST['OAmountUnWithTax']) ? $_POST['OAmountUnWithTax'] : null;
$LAmountUnWithTax = isset($_POST['LAmountUnWithTax']) ? $_POST['LAmountUnWithTax'] : null;
$LAmount = isset($_POST['LAmount']) ? $_POST['LAmount'] : null;
if ($CurrId == "TWD") {
$OTax = isset($_POST['OTax']) ? round($_POST['OTax']) : NULL;
$LTax = isset($_POST['LTax']) ? round($_POST['LTax']) : NULL;
$OAmountUnWithTax = isset($_POST['OAmountUnWithTax']) ? round($_POST['OAmountUnWithTax']) : null;
$LAmountUnWithTax = isset($_POST['LAmountUnWithTax']) ? round($_POST['LAmountUnWithTax']) : null;
$LAmount = isset($_POST['LAmount']) ? round($_POST['LAmount']) : null;
}else{
$OTax = isset($_POST['OTax']) ? round($_POST['OTax'], 2) : NULL;
$LTax = isset($_POST['LTax']) ? round($_POST['LTax'], 2) : NULL;
$OAmountUnWithTax = isset($_POST['OAmountUnWithTax']) ? round($_POST['OAmountUnWithTax'], 2) : null;
$LAmountUnWithTax = isset($_POST['LAmountUnWithTax']) ? round($_POST['LAmountUnWithTax'], 2) : null;
$LAmount = isset($_POST['LAmount']) ? round($_POST['LAmount'], 2) : null;
}
$TaxNo = empty($_POST['TaxNo']) ? '' : $_POST['TaxNo'];
if (empty($TaxNo)) {
$comSupplierName = "雜項請款用";
@ -71,7 +82,7 @@ if (isset($comSupplierName) && ($comSupplierName != "雜項請款用")) {
$SQL1 = "";
if ($submit == "add") {
if (($user_id == "M0056" )|| ($user_id == "M0209")) {
if (($user_id == "M0056") || ($user_id == "M0209")) {
$SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`,
`BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`,
`Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`CurrentLAmount`,`OTax`,`LTax`,
@ -139,7 +150,7 @@ if ($submit == "add") {
?>
<script>
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=0&<?= $token_link ?>";
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=<?= $state ?>&<?= $token_link ?>";
</script>
<?php
} elseif ($submit == "edit") {
@ -201,7 +212,7 @@ if ($submit == "add") {
mysqli_query($link, $sql_rib);
?>
<script>
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=0&<?= $token_link ?>";
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=<?= $state ?>&<?= $token_link ?>";
</script>
<?php
@ -213,7 +224,7 @@ if ($submit == "add") {
?>
<script>
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=0&<?= $token_link ?>";
window.location.href = "rib01-check.php?id=<?php echo $rib_id ?>&state=<?= $state ?>&<?= $token_link ?>";
</script>
<?php

17
wms/rib03-submit.php

@ -87,13 +87,13 @@ if ($state == 1) {
while ($ribsub = mysqli_fetch_assoc($ribsub_data)) {
$count += 1;
$OAmountWithTax += $ribsub['OAmount'];
$LAmount = $ribsub['OAmount'] * $CurrLAmount;
$OAmountUnWithTax = $ribsub['OAmount'] / (1 + $ribsub['TaxRate']);
$LAmountUnWithTax = $OAmountUnWithTax * $CurrLAmount;
$sub_WriteOffAmount = $ribsub['OAmount'];
$sub_OTax = $ribsub['OAmount'] - $OAmountUnWithTax;
$LAmount = $rib['CurrId']=="TWD"? round($ribsub['OAmount'] * $CurrLAmount):round($ribsub['OAmount'] * $CurrLAmount,2);
$OAmountUnWithTax = $rib['CurrId']=="TWD"? round($ribsub['OAmount'] / (1 + $ribsub['TaxRate'])):round($ribsub['OAmount'] / (1 + $ribsub['TaxRate']),2);
$LAmountUnWithTax = $rib['CurrId']=="TWD"?round($OAmountUnWithTax * $CurrLAmount):round($OAmountUnWithTax * $CurrLAmount,2);
$sub_WriteOffAmount = $rib['CurrId']=="TWD"? round($ribsub['OAmount']):round($ribsub['OAmount'],2);
$sub_OTax = $rib['CurrId']=="TWD"? round(($ribsub['OAmount'] - $OAmountUnWithTax)):round(($ribsub['OAmount'] - $OAmountUnWithTax),2);
$OTax += $sub_OTax;
$sub_LTax = $LAmount - $LAmountUnWithTax;
$sub_LTax = $rib['CurrId']=="TWD"? round(($LAmount - $LAmountUnWithTax)):round(($LAmount - $LAmountUnWithTax),2);
$LTax += $sub_LTax;
$WriteOffAmount += $ribsub['OAmount'];
$OAmount += $OAmountUnWithTax;
@ -336,17 +336,18 @@ OAmount =$OAmount, UnPayOAmount=$UnPayOAmount, Balance = $OAmountWithTax, LBalan
$IsCounteract = $ribsub['IsCounteract'];
$CU_MaterialId = empty($ribsub['CU_MaterialId']) ? null : $ribsub['CU_MaterialId'];
$TaxNo = empty($ribsub['TaxNo']) ? null : $ribsub['TaxNo'];
$CreatorId = $ribsub['CreatorId'];
$sqlsub = "INSERT INTO glFeeWriteOffSub (BillNo, RowCode,RowNo,FeeDate,FeeTypeId, WriteOffType,
BizOrgId, WriteOffId, FeeOrgId, FeeDeptId, FeeCompanyId, UnitId ,
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,CreatorId
";
$sqlsub2 = ") VALUES ('$BillNo',$RowCode, $RowNo,$FeeDate,'$FeeTypeId',$WriteOffType,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',
$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,$CreatorId
";
$sqlsub .= empty($WriteOffDescribe) ? "" : ",WriteOffDescribe";

Loading…
Cancel
Save