Browse Source

修改費用報銷單會計取T8費用項目的內容,應收帳款明細新增該階段應收金額

gary
Ellin 1 year ago
parent
commit
083d7ce4e8
  1. 2
      mkt/database.php
  2. 55
      wms/account-receivable-index.php
  3. 2
      wms/rib01-check.php
  4. 2
      wms/rib02-check.php
  5. 216
      wms/rib02-create.php
  6. 2
      wms/rib02-edit.php

2
mkt/database.php

@ -1,5 +1,5 @@
<?php <?php
$envFile = __DIR__ . '/../.env'; // .env 文件的路径 $envFile = __DIR__ . '\.env'; // .env 文件的路径
if (file_exists($envFile)) { if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

55
wms/account-receivable-index.php

@ -8,7 +8,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$arrayData = []; $arrayData = [];
echo "合約號,部門,經理,營業員,客戶名稱,簽約款,二次款,貨抵工地款,安裝款,試車款,交車款,取得許可證約交款,取得許可函後6個月約交款,狀態</br>"; echo "合約號;部門;經理;營業員;客戶名稱;簽約款;二次款;貨抵工地款;安裝款;試車款;交車款;取得許可證約交款;取得許可函後6個月約交款;目前應收;總作番數;貨抵;安裝;試車;移交數;狀態</br>";
// $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC); // $T8_array = mysqli_fetch_all($T8_array, MYSQLI_ASSOC);
@ -25,7 +25,13 @@ $contract = $conn->query($sql_contract);
foreach ($contract as $cont) { foreach ($contract as $cont) {
// print_r($cont); // print_r($cont);
// echo "<br>"; // echo "<br>";
$BillNo = $cont['BillNo']; if ($cont['BillNo'] == 'SO20230801001') {
$BillNo = 'M230947';
}elseif ($cont['BillNo'] == 'SO20230801002'){
$BillNo = 'M231067';
}else{
$BillNo = $cont['BillNo'];
};
$PayStage = $cont['PayStage']; $PayStage = $cont['PayStage'];
$PayAmount = $cont['PlanPayAmt']; $PayAmount = $cont['PlanPayAmt'];
$partnerName = $cont['BizPartnerName']; $partnerName = $cont['BizPartnerName'];
@ -110,27 +116,56 @@ FROM department
) AS d ) AS d
ON d.department_id = tmp2.department_id"; ON d.department_id = tmp2.department_id";
$facitities = ""; $facitities = "";
$total_facility_num = 0;
$arrive_num = 0;
$install_num = 0;
$tryrun_num = 0;
$delivery_num = 0;
$wipwhole_array = mysqli_query($link, $sql); $wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) { foreach ($wipwhole_array as $wip) {
$value[0] = $wip['depart_name']; $value[0] = $wip['depart_name'];
$value[1] = $wip['manager_name']; $value[1] = $wip['manager_name'];
$value[2] = $wip['name']; $value[2] = $wip['name'];
if ($wip['delivery_date'] != NULL) { if ($wip['delivery_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['delivery_date'] . "已移交);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['delivery_date'] . "已移交),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
$tryrun_num += 1;
$delivery_num += 1;
} elseif ($wip['tryrun_end_date'] != NULL) { } elseif ($wip['tryrun_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['tryrun_end_date'] . "試車完畢);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['tryrun_end_date'] . "試車完畢),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
$tryrun_num += 1;
} elseif ($wip['install_end_date'] != NULL) { } elseif ($wip['install_end_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['install_end_date'] . "安裝完畢);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['install_end_date'] . "安裝完畢),\n";
$total_facility_num += 1;
$arrive_num += 1;
$install_num += 1;
} elseif ($wip['real_arrival_date'] != NULL) { } elseif ($wip['real_arrival_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['real_arrival_date'] . "貨抵工地);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['real_arrival_date'] . "貨抵工地),\n";
$total_facility_num += 1;
$arrive_num += 1;
} elseif ($wip['actual_tofactory_date'] != NULL) { } elseif ($wip['actual_tofactory_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['actual_tofactory_date'] . "實際到觀音日);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['actual_tofactory_date'] . "實際到觀音日),\n";
$total_facility_num += 1;
} elseif ($wip['estimated_shipping_date'] != NULL) { } elseif ($wip['estimated_shipping_date'] != NULL) {
$facitities .= $wip['facilityno'] . "(" . $wip['estimated_shipping_date'] . "預計到港);\n"; $facitities .= $wip['facilityno'] . "(" . $wip['estimated_shipping_date'] . "預計到港),\n";
$total_facility_num += 1;
} else { } else {
$facitities .= $wip['facilityno'] . "(預計到港日待確認);\n"; $facitities .= $wip['facilityno'] . "(預計到港日待確認),\n";
$total_facility_num += 1;
} }
} }
echo $key . "," . $value[0] . "," . $value[1] . "," . $value[2] . "," . $value[3] . "," . $value[4] . "," . $value[5] . "," . $value[6] . "," . $value[7] . "," . $value[8] . "," . $value[9] . "," . $value[10] . "," . $value[11] . "," . $facitities . "<br>"; if ($total_facility_num > 0) {
$receivable_budget = $value[4] + ($value[5] + $value[6]) * ($arrive_num / $total_facility_num) +
($value[7]) * ($install_num / $total_facility_num) + ($value[8]) * ($tryrun_num / $total_facility_num)
+ ($value[9] + $value[10] + $value[11]) * ($delivery_num / $total_facility_num);
}
echo $key . ";" . $value[0] . ";" . $value[1] . ";" . $value[2] . ";" . $value[3] . ";" . $value[4] . ";" . $value[5] . ";" . $value[6] . ";" . $value[7] . ";" . $value[8] . ";" . $value[9] . ";" . $value[10] . ";" . $value[11] . ";" . $receivable_budget . ";" . $total_facility_num . ";" . $arrive_num . ";" . $install_num . ";" . $tryrun_num . ";" . $delivery_num . ";" . $facitities . "<br>";
} }

2
wms/rib01-check.php

@ -335,7 +335,7 @@ $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);
?> ?>
<div style="width: 80%;"> <div style="width: 80%;">
<?php <?php
if ($state == 0) : if (($state == 0)||($user_id='M0056') || $user_id=='M0209') :
?> ?>
<a href="rib02-create.php?id=<?php echo $data['rib_id'] ?>&RowCode=<?= $RowCode ?>&CurrId=<?= $CurrId ?>&<?= $token_link ?>" class="btn btn-info btn-lg pull-right" style="margin: 1 rem;"> <a href="rib02-create.php?id=<?php echo $data['rib_id'] ?>&RowCode=<?= $RowCode ?>&CurrId=<?= $CurrId ?>&<?= $token_link ?>" class="btn btn-info btn-lg pull-right" style="margin: 1 rem;">
<span class=" glyphicon glyphicon-plus"></span> <span class=" glyphicon glyphicon-plus"></span>

2
wms/rib02-check.php

@ -7,7 +7,7 @@ $rib_query = mysqli_query($link, $sql_ribsub);
$ribsub = mysqli_fetch_assoc($rib_query); $ribsub = mysqli_fetch_assoc($rib_query);
//取得費用項目代碼 //取得費用項目代碼
$sql_feetype = "SELECT * from feetype"; $sql_feetype = "SELECT FeeTypeId, FeeTypeName FROM comFeeType WHERE (FeeTypeId NOT LIKE 'A%') AND(FeeTypeId NOT LIKE 'Z%')";
$feetype_query = mysqli_query($link, $sql_feetype); $feetype_query = mysqli_query($link, $sql_feetype);
$feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC); $feetype = mysqli_fetch_all($feetype_query, MYSQLI_ASSOC);

216
wms/rib02-create.php

@ -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>
<div class="form-group"> <?php
<div class="col-md-3"> if ($user_id == "M0056" || $user_id == "M0209") {
<label for="TaxId">稅碼</label> ?>
<select name="TaxId" class="form-control"> <div class="form-group">
<option value="ST005" selected>營業稅5%</option> <div class="col-md-3">
<option value="ST101">零稅</option> <label for="CurrId">幣別</label>
<option value="ST102">免稅</option> <input class="form-control" type="text" name="CurrId" id="CurrId" value="<?php if ($CurrId == "TWD") {
</select> echo "台幣";
} elseif ($CurrId == "CNY") {
echo "人民幣";
} elseif ($CurrId == "EUR") {
echo "歐元";
} elseif ($CurrId == "HKD") {
echo "港幣";
} else {
echo "美元";
} ?>" disabled>
</div>
<div class="col-md-3">
<label for="CurrLAmount">匯率</label>
<input class="form-control" type="number" name="CurrLAmount" id="CurrLAmount" value="<?= $CurrLAmount ?>" disabled>
</div>
<div class="col-md-3">
<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>
<div class="col-md-3">
<label for="IsCounteract">抵扣</label>
<select name="IsCounteract" class="form-control"> <div class="form-group">
<option value=1 selected>可抵扣</option> <div class="col-md-3">
<option value=0>不可抵扣</option> <label for="OAmountUnWithTax">未稅報銷金額 (原幣值)</label>
</select> <input class="form-control" type="number" name="OAmountUnWithTax" id="OAmountUnWithTax" value="<?= $ribsub['OAmountUnWithTax'] ?>" disabled>
</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 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> </div>
<?php
} ?>
</div>
<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,25 +427,26 @@ $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) {
alert("供應商認證成功")
} else {
alert("T8內無此供應商")
} }
} }
if (answer==1){
alert("供應商認證成功")
}else{
alert("T8內無此供應商")
}
}
} }
$(function() { $(function() {
@ -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(01); 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();
} }

2
wms/rib02-edit.php

@ -10,7 +10,7 @@ $ribsub = mysqli_fetch_assoc($rib_query);
//取得費用項目代碼 //取得費用項目代碼
$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();
//取得人員名單與使用者的部門 //取得人員名單與使用者的部門

Loading…
Cancel
Save