@ -15,6 +15,51 @@ if (mysqli_num_rows($rib_query) > 0) {
$rib_id = $rib['rib_id'];
$rib_id = $rib['rib_id'];
$WrtieOffId = $rib['WriteOffId'];
$WrtieOffId = $rib['WriteOffId'];
$FeeDeptId = $rib['DeptId'];
$FeeDeptId = $rib['DeptId'];
$CurrId = $rib['CurrId'];
if ($rib['CurrentState'] == 1) {
// 爬蟲--匯率
function htmlContentGet($url)
{
$opts = [
"http" => [
"method" => "GET",
"header" => "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36\r\n"
]
];
return file_get_contents($url, false, stream_context_create($opts));
}
$week = date("w");
$currency_day = date("Y-m-d", strtotime("-1 day"));
if ($week == 1) {
$currency_day = date("Y-m-d", strtotime("-3 day"));
} elseif ($week == 0) {
$currency_day = date("Y-m-d", strtotime("-2 day"));
}
$X = htmlContentGet('https://rate.bot.com.tw/xrt/all/' . $currency_day);
$string = strip_tags($X); // 先清掉 html tag, 以免 html tag 被破壞
//美金
$USD = explode(' ', stristr($string, '美金'))[298];
//人民幣
$RMB = explode(' ', stristr($string, '人民幣'))[298];
//歐元
$EUR = explode(' ', stristr($string, '歐元'))[298];
//港幣
$HKD = explode(' ', stristr($string, '港幣'))[298];
//整理要變更的數據 -表身
$CurrLAmount = 1;
if ($rib['CurrId'] == "CNY") {
$CurrLAmount = $RMB;
} elseif ($rib['CurrId'] == "EUR") {
$CurrLAmount = $EUR;
} elseif ($rib['CurrId'] == "HKD") {
$CurrLAmount = $HKD;
} elseif ($rib['CurrId'] == "USD") {
$CurrLAmount = $USD;
}
}
}
}
}
}
@ -22,7 +67,7 @@ $RowCode = $_GET['RowCode'];
//取得費用項目代碼
//取得費用項目代碼
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%')AND(FeeTypeId NOT LIKE 'M%') AND(FeeTypeId NOT LIKE 'Z%')";
$sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype = $conn->query($sql_feetype);
$feetype = $conn->query($sql_feetype);
$member = array();
$member = array();
//取得人員名單與使用者的部門
//取得人員名單與使用者的部門
@ -68,8 +113,8 @@ $bizcount = 0;
foreach ($BizPartner as $biz) {
foreach ($BizPartner as $biz) {
$bizKey = $biz['BizPartnerId'];
$bizKey = $biz['BizPartnerId'];
$bizValue = $biz['BizPartnerName'];
$bizValue = $biz['BizPartnerName'];
array_push($BusinessPartner,$bizKey);
array_push($BusinessPartner, $bizKey);
$bizcount +=1;
$bizcount += 1;
}
}
$BizJSON = json_encode($BusinessPartner);
$BizJSON = json_encode($BusinessPartner);
$sql_Project = "SELECT * FROM comProject";
$sql_Project = "SELECT * FROM comProject";
@ -209,6 +254,24 @@ $materials = $conn->query($sql_Material);
< / select >
< / select >
< / div >
< / 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 >
< div class = "form-group" >
< div class = "form-group" >
< div class = "col-md-3" >
< div class = "col-md-3" >
@ -234,24 +297,57 @@ $materials = $conn->query($sql_Material);
< input class = "form-control" type = "number" step = "any" name = "OAmount" id = "OAmount" placeholder = "單價x數量" required disabled >
< input class = "form-control" type = "number" step = "any" name = "OAmount" id = "OAmount" placeholder = "單價x數量" required disabled >
< / div >
< / div >
< / div >
< / div >
<?php
if ($user_id == "M0056" || $user_id == "M0209") {
?>
< div class = "form-group" >
< div class = "form-group" >
< div class = "col-md-3" >
< div class = "col-md-3" >
< label for = "TaxId" > 稅碼< / label >
< label for = "CurrId" > 幣別< / label >
< select name = "TaxId" class = "form-control" >
< input class = "form-control" type = "text" name = "CurrId" id = "CurrId" value = " <?php if ( $CurrId == "TWD" ) {
< option value = "ST005" selected > 營業稅5%< / option >
echo "台幣";
< option value = "ST101" > 零稅< / option >
} elseif ($CurrId == "CNY") {
< option value = "ST102" > 免稅< / option >
echo "人民幣";
< / select >
} elseif ($CurrId == "EUR") {
echo "歐元";
} elseif ($CurrId == "HKD") {
echo "港幣";
} else {
echo "美元";
} ?>" disabled>
< / div >
< / div >
< div class = "col-md-3" >
< div class = "col-md-3" >
< label for = "IsCounteract" > 抵扣< / label >
< label for = "CurrLAmount" > 匯率< / label >
< select name = "IsCounteract" class = "form-control" >
< input class = "form-control" type = "number" name = "CurrLAmount" id = "CurrLAmount" value = " <? = $CurrLAmount ?> " disabled >
< option value = 1 selected > 可抵扣< / option >
< / div >
< option value = 0 > 不可抵扣< / option >
< div class = "col-md-3" >
< / select >
< label for = "OTax" > 稅金 (原幣值)< / label >
< input class = "form-control" type = "number" name = "OTax" id = "OTax" value = " <? = $ribsub [ 'OTax' ] ?> " disabled >
< / div >
< div class = "col-md-3" >
< label for = "LTax" > 本幣稅金< / label >
< input class = "form-control" type = "number" step = "any" name = "LTax" id = "LTax" value = " <? = $ribsub [ 'LTax' ] ?> " disabled >
< / div >
< / div >
< div class = "form-group" >
< div class = "col-md-3" >
< label for = "OAmountUnWithTax" > 未稅報銷金額 (原幣值)< / label >
< input class = "form-control" type = "number" name = "OAmountUnWithTax" id = "OAmountUnWithTax" value = " <? = $ribsub [ 'OAmountUnWithTax' ] ?> " disabled >
< / div >
< / div >
< div class = "col-md-3" >
< label for = "LAmountUnWithTax" > 本幣未稅報銷金額< / label >
< input class = "form-control" type = "number" step = "any" name = "LAmountUnWithTax" id = "LAmountUnWithTax" value = " <? = $ribsub [ 'LAmountUnWithTax' ] ?> " disabled >
< / div >
< / div >
< div class = "col-md-3" >
< label for = "LAmount" > 本幣報銷金額< / label >
< input class = "form-control" type = "number" step = "any" name = "LAmount" id = "LAmount" value = " <? = $ribsub [ 'LAmount' ] ?> " disabled >
< / div >
< / div >
<?php
} ?>
< div class = "form-group" >
< div class = "form-group" >
< div class = "col-md-3" >
< div class = "col-md-3" >
< label for = "VoucherCount" > 憑單張數< / label >
< label for = "VoucherCount" > 憑單張數< / label >
@ -331,22 +427,23 @@ $materials = $conn->query($sql_Material);
$("#ProjectId").selectize();
$("#ProjectId").selectize();
$("#CU_MaterialId").selectize();
$("#CU_MaterialId").selectize();
})
})
function checkBiz() {
function checkBiz() {
if ($("#TaxNo").val().length !== 8) {
if ($("#TaxNo").val().length !== 8) {
alert("統一編號格式錯誤");
alert("統一編號格式錯誤");
}else{
} else {
var biz = $("#TaxNo").val();
var biz = $("#TaxNo").val();
var BizArray = <?php echo $BizJSON ; ?> ;
var BizArray = <?php echo $BizJSON ; ?> ;
var answer = 0;
var answer = 0;
for (var partner = 0; partner < <? = $bizcount ?> ; partner++){
for (var partner = 0; partner < <? = $bizcount ?> ; partner++) {
var value = BizArray[partner];
var value = BizArray[partner];
if (biz == value){
if (biz == value) {
answer +=1
answer += 1
}
}
}
}
if (answer==1){
if (answer == 1) {
alert("供應商認證成功")
alert("供應商認證成功")
}else{
} else {
alert("T8內無此供應商")
alert("T8內無此供應商")
}
}
}
}
@ -434,10 +531,52 @@ $materials = $conn->query($sql_Material);
})
})
$("#Price").change(function() {
$("#Price").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#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());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
});
});
$("#Quantity").change(function() {
$("#Quantity").change(function() {
$("#OAmount").val($("#Quantity").val() * $("#Price").val());
$("#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());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
});
});
$("#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());
} else {
$("#OTax").val(0);
$("#LTax").val(0);
$("#OAmountUnWithTax").val($("#OAmount").val());
$("#LAmountUnWithTax").val($("#OAmount").val() * $("#CurrLAmount").val());
}
})
$("#FeeDate").change(function() {
$("#FeeDate").change(function() {
if ($("#FeeDate").val().length != 8) {
if ($("#FeeDate").val().length != 8) {
alert("輸入格式錯誤");
alert("輸入格式錯誤");
@ -454,7 +593,7 @@ $materials = $conn->query($sql_Material);
$("#FeeDate").val('');
$("#FeeDate").val('');
} else {
} else {
now.setMonth(now.getMonth() - 2);
now.setMonth(now.getMonth() - 2);
now.setDate(0 1);
now.setDate(1);
now.setDate(now.getDate() - 1)
now.setDate(now.getDate() - 1)
if (feedate < now ) {
if (feedate < now ) {
alert("超過兩個月的費用無法進行報銷");
alert("超過兩個月的費用無法進行報銷");
@ -493,6 +632,15 @@ $materials = $conn->query($sql_Material);
} else {
} else {
$("#OAmount").prop("disabled", false);
$("#OAmount").prop("disabled", false);
<?php
if ($user_id == "M0056" || $user_id == "M0209") { ?>
$("#OTax").prop("disabled", false);
$("#LTax").prop("disabled", false);
$("#OAmountUnWithTax").prop("disabled", false);
$("#LAmountUnWithTax").prop("disabled", false);
$("#LAmount").prop("disabled", false);
$("#OAmount").prop("disabled", false);
<?php } ?>
$('#ribsubform').submit();
$('#ribsubform').submit();
}
}