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.
168 lines
5.0 KiB
168 lines
5.0 KiB
<?php include "../header.php";
|
|
require_once "../database.php";
|
|
global $link;
|
|
|
|
if (empty($_GET["error_form_key"])) {
|
|
list($form_key) = mysqli_fetch_row(mysqli_query($link, "SELECT appwms.nextval('form_key') form_key"));
|
|
} else {
|
|
$form_key = $_GET["error_form_key"];
|
|
}
|
|
?>
|
|
<div style="margin: 0 auto;width:400px">
|
|
<h2>開票(請款單)資料上載</h2>
|
|
</div>
|
|
<div class="container">
|
|
|
|
<style>
|
|
form>div {
|
|
margin: 0;
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
.form-inline input {
|
|
vertical-align: middle;
|
|
margin: 0px auto;
|
|
padding: 5px;
|
|
background-color: #fff;
|
|
border: 1px solid #ddd;
|
|
}
|
|
</style>
|
|
|
|
<form class="form-inline" method="post" action="ec_purchase_order_submit.php" enctype="multipart/form-data">
|
|
<div>
|
|
<label for="yyyymm">單號</label>
|
|
<input class="form-control" type="text" name="form_key" value=<?= $form_key ?> readonly id="form_key" maxlength="12">
|
|
</div>
|
|
|
|
<div>
|
|
<label for="yyyymm">上載年月</label>
|
|
<input class="form-control" placeholder="YYYYMM" type="text" name="yyyymm" value=<?= date("Ym") ?> readonly id="yyyymm" maxlength="6">
|
|
</div>
|
|
|
|
<div>
|
|
<label for="file">附件</label>
|
|
<input class="form-control" type="file" name="file" id="file">
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
<br />
|
|
<button type="submit" name="submit">確定</button>
|
|
</div>
|
|
|
|
</form>
|
|
<?php
|
|
#加载重复的资料
|
|
if (!empty($_GET["error_form_key"])) {
|
|
$fields_mapping = array(
|
|
"cnt" => "笔数",
|
|
"date_seq" => "日期-號碼",
|
|
"customerid" => "客戶/供應商編碼",
|
|
"item_no" => "品項編碼",
|
|
"num" => "數量",
|
|
"unit_price" => "單價",
|
|
"pre_tax_price" => "稅前價格",
|
|
"business_tax" => "營業稅",
|
|
"summary_price" => "合計",
|
|
"enter_date" => "銷貨單最初輸入日期"
|
|
);
|
|
echo "<table id='' class='table table-striped table-bordered' style='width:100%'>
|
|
<thead><tr> <th style='text-align:center;color:red' colspan=" . count($fields_mapping) . ">异常!上传资料存在重复记录</th> </tr><tr>";
|
|
foreach (array_values($fields_mapping) as $val) {
|
|
echo "<th> $val</th>";
|
|
}
|
|
echo " </tr> </thead>";
|
|
echo " <tbody>";
|
|
$sql_group_epot = "
|
|
SELECT count(*) cnt,
|
|
date_seq,
|
|
customerid,
|
|
item_no,
|
|
num,
|
|
unit_price,
|
|
pre_tax_price,
|
|
business_tax,
|
|
summary_price,
|
|
enter_date From ec_purchase_order_tmp
|
|
WHERE form_key = '" . $_GET['error_form_key'] . "'
|
|
GROUP BY date_Seq, customerid, item_no, num, unit_price, pre_tax_price, business_tax, summary_price, enter_date
|
|
HAVING COUNT(*) > 1";
|
|
|
|
$res_group_epot = mysqli_fetch_all(mysqli_query($link, $sql_group_epot), MYSQLI_ASSOC);
|
|
|
|
foreach ($res_group_epot as $row) {
|
|
echo " <tr>";
|
|
foreach (array_keys($fields_mapping) as $val) {
|
|
echo "<th> " . $row[$val] . "</th>";
|
|
}
|
|
echo " </tr>";
|
|
}
|
|
|
|
$sql_group_epot = "
|
|
SELECT count(*) cnt,
|
|
date_seq,
|
|
customerid,
|
|
item_no,
|
|
num,
|
|
unit_price,
|
|
pre_tax_price,
|
|
business_tax,
|
|
summary_price,
|
|
enter_date From ec_purchase_order_tmp
|
|
WHERE form_key = '" . $_POST['form_key'] . "'
|
|
GROUP BY date_Seq, customerid, item_no, num, unit_price, pre_tax_price, business_tax, summary_price, enter_date
|
|
HAVING COUNT(*) > 1";
|
|
|
|
$res_group_epot = mysqli_fetch_row(mysqli_query($link, $sql_group_epot));
|
|
#存在重复的记录ec_purchase_order_import
|
|
if (!empty($res_group_epot)) {
|
|
header("location: ec_purchase_order_import.php?error_form_key=" . $_POST['form_key']);
|
|
exit();
|
|
}
|
|
$sql_group_epo = "
|
|
SELECT
|
|
count(*) cnt,
|
|
a.date_seq,
|
|
a.customerid,
|
|
a.item_no,
|
|
a.num,
|
|
a.unit_price,
|
|
a.pre_tax_price,
|
|
a.business_tax,
|
|
a.summary_price,
|
|
a.enter_date
|
|
FROM
|
|
ec_purchase_order a,
|
|
ec_purchase_order_tmp b
|
|
WHERE
|
|
a.date_seq = b.date_seq
|
|
AND a.customerid = b.customerid
|
|
AND a.item_no = b.item_no
|
|
AND a.num = b.num
|
|
AND a.unit_price = b.unit_price
|
|
AND a.pre_tax_price = b.pre_tax_price
|
|
AND a.business_tax = b.business_tax
|
|
AND a.summary_price = b.summary_price
|
|
AND a.enter_date = b.enter_date
|
|
GROUP BY a.date_seq, a.customerid, a.item_no, a.num, a.unit_price,
|
|
a.pre_tax_price, a.business_tax, a.summary_price, a.enter_date";
|
|
|
|
$res_group_epo = mysqli_fetch_all(mysqli_query($link, $sql_group_epo), MYSQLI_ASSOC);
|
|
|
|
foreach ($res_group_epo as $row) {
|
|
echo " <tr>";
|
|
foreach (array_keys($fields_mapping) as $val) {
|
|
echo "<th> " . $row[$val] . "</th>";
|
|
}
|
|
echo " </tr>";
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<?php include "../footer.php"; ?>
|