Browse Source

合約書申請、合約書下載測試版上傳

gary
10994015 1 year ago
parent
commit
411eb4c1ef
  1. 11
      wms/contract/api/postContractNewApplyData.php
  2. 46
      wms/contract/contract-download.php
  3. 13
      wms/contract/contract-new-apply.php
  4. 19
      wms/contract/js/alpine.js
  5. 114
      wms/contract/prviewPdf.php

11
wms/contract/api/postContractNewApplyData.php

@ -4,6 +4,10 @@ require_once("../conn.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
//暫存、送審
if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0 || $_POST['status'] == 1) ){
if($_POST['regulations'] < 45){
header("HTTP/1.1 500 傳送失敗!!試車時間不得低於45天");
exit;
}
$mid = $_POST['mid'];
$vol_no = $_POST['vol_no'];
$salesman = $_POST['salesman'];
@ -24,6 +28,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$freedeadline = $_POST['freedeadline'];
$trade_address = $_POST['tradeaddress'];
$tradedeadline = $_POST['tradedeadline'];
$secondPayDeadline = $_POST['secondPayDeadline'];
$pays = $_POST['pays'];
$status = $_POST['status']; // 0:暫存 1:送審 2:退回 3:完成
$pays = json_decode($pays, true);
@ -40,7 +45,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$conn->beginTransaction();
try{
if($isFirst == 1){
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, progress, status, person, personname, submit_date, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :progress, :status, :person, :personname, :submit_date, :created_at, :created_by)";
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, secondPayDeadline, progress, status, person, personname, submit_date, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :secondPayDeadline, :progress, :status, :person, :personname, :submit_date, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':contractno', $vol_no);
@ -61,6 +66,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$stmt ->bindParam(':freedeadline', $freedeadline);
$stmt ->bindParam(':trade_address', $trade_address);
$stmt ->bindParam(':tradedeadline', $tradedeadline);
$stmt ->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':person', $salesman);
@ -89,7 +95,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
header("HTTP/1.1 201 success!");
$conn->commit();
}else{
$sql_str = "UPDATE contract_new_apply SET status = :status, apply_date=:apply_date, apply_type=:apply_type, case_name=:case_name, customer=:customer, manager=:manager, vat=:vat, total_price=:total_price, buy_fee=:buy_fee, install_fee=:install_fee, contact_address=:contact_address, trade_address=:trade_address, workdeadline_a=:workdeadline_a, workdeadline_b=:workdeadline_b, test_time=:test_time, freedeadline=:freedeadline, trade_address=:trade_address, trade_address=:trade_address, tradedeadline=:tradedeadline, progress=:progress, person=:person, personname=:personname, submit_date=:submit_date, updated_at=:updated_at, updated_by=:updated_by WHERE mid = :mid";
$sql_str = "UPDATE contract_new_apply SET status = :status, apply_date=:apply_date, apply_type=:apply_type, case_name=:case_name, customer=:customer, manager=:manager, vat=:vat, total_price=:total_price, buy_fee=:buy_fee, install_fee=:install_fee, contact_address=:contact_address, trade_address=:trade_address, workdeadline_a=:workdeadline_a, workdeadline_b=:workdeadline_b, test_time=:test_time, freedeadline=:freedeadline, trade_address=:trade_address, trade_address=:trade_address, tradedeadline=:tradedeadline, secondPayDeadline=:secondPayDeadline, progress=:progress, person=:person, personname=:personname, submit_date=:submit_date, updated_at=:updated_at, updated_by=:updated_by WHERE mid = :mid";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':status', $status);
@ -109,6 +115,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$stmt ->bindParam(':freedeadline', $freedeadline);
$stmt ->bindParam(':trade_address', $trade_address);
$stmt ->bindParam(':tradedeadline', $tradedeadline);
$stmt ->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':person', $salesman);
$stmt ->bindParam(':personname', $salesmanname);

46
wms/contract/contract-download.php

@ -44,9 +44,7 @@ if(isset($_GET['id']) && $_GET['id']!=""){
</script>";
exit;
}
$buyArr = [];
$buyNo2Pay = false;
$buy_total_price = 0;
$installArr = [];
@ -55,9 +53,16 @@ if(isset($_GET['id']) && $_GET['id']!=""){
$noteArr = array(1,1,1,1,1);
$qty = $contracts[0]['item_qty'];
// print_r($contracts);
print_r($contracts);exit;
// print_r($buyArr);
foreach($contracts as $idx=>$amount){
$isset = false;
if($amount['pay_kind']==5 || $amount['pay_kind']==6){
echo "111111";
if($amount['pay_scale'] >= 0){
$install_total_price = $install_total_price + $amount['pay_amount'];
$installArr[] = ['installment'=> $amount['pay_kind'], 'scale'=> $amount['pay_scale'], 'amount'=> $amount['pay_amount'], 'note'=>$amount['note']];
}
}
if($amount['pay_kind']==1 || $amount['pay_kind']==2 || $amount['pay_kind']==3){
if($amount['pay_scale'] > 0){
$buy_total_price = $buy_total_price + $amount['pay_amount'];
@ -73,20 +78,14 @@ if(isset($_GET['id']) && $_GET['id']!=""){
$buyNo2Pay = true;
}
}
}
if($amount['pay_kind']==5 || $amount['pay_kind']==6){
echo "111111";
if($amount['pay_scale'] > 0){
$install_total_price = $install_total_price + $amount['pay_amount'];
$installArr[] = ['installment'=> $amount['pay_kind'], 'scale'=> $amount['pay_scale'], 'amount'=> $amount['pay_amount'], 'note'=>$amount['note']];
}
}
}
// print_r($buyArr);
}
}catch (PDOException $e ){
catch (PDOException $e ){
die("ERROR!!!: ". $e->getMessage());
}
echo $buy_total_price;
@ -107,15 +106,15 @@ if(isset($_GET['id']) && $_GET['id']!=""){
</ul>
</div>
<div class="inputDiv" x-show="isbuyShow && isBuyInputIng">
<label for="">
<!-- <label for="">
<p>交貨期限(日)</p>
<input type="number" x-model="buyfill1" @keyup="sendBuyInputKeyupFn($event)" />
</label>
</label> -->
<?php if($buyNo2Pay){ ?>
<label for="">
<!-- <label for="">
<p>第二期款交貨期限(日)</p>
<input type="number" x-model="buyfill2">
</label>
</label> -->
<?php } ?>
<label for="">
<p>附件數</p>
@ -234,14 +233,14 @@ if(isset($_GET['id']) && $_GET['id']!=""){
</div>
</div>
<div class="inputDiv" x-show="!isbuyShow && isInstallInputIng">
<label for="">
<!-- <label for="">
<p>安裝試車期限(日)</p>
<input type="number" x-model="installfill1" @keyup="sendInstallInputKeyupFn($event)" />
</label>
<label for="">
<p>免費保養月數(月)</p>
<input type="number" x-model="installfill2" @keyup="sendInstallInputKeyupFn($event)" />
</label>
</label> -->
<label for="">
<p>附件數</p>
<select x-model="installAffix" @keyup="sendInstallInputKeyupFn($event)">
@ -372,7 +371,7 @@ if(isset($_GET['id']) && $_GET['id']!=""){
</div>
</main>
<script src="../ckeditor4/ckeditor.js"></script>
<!-- <script src="../ckeditor4/ckeditor.js"></script> -->
<script>
const partyAcompany = <?php echo json_encode($contract['customer']); ?>;
const partyAcontractno = <?php echo json_encode($contract['contractno']); ?>;
@ -380,9 +379,12 @@ if(isset($_GET['id']) && $_GET['id']!=""){
const totalPrice = <?php echo $contract['total_price']; ?>;
const totalInstallPrice = <?php echo $install_total_price; ?>;
const totalBuyPrice = <?php echo $buy_total_price; ?>;
let buyInputArr = ["<input id='buyfill1' />"];
const buyArr = <?php echo json_encode($buyArr); ?>;
const installArr = <?php echo json_encode($installArr); ?>;
const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>;
const buyfill1 = <?php echo $contract['tradedeadline']; ?>;
const installfill1 = "<?php echo $contract['test_time']; ?>";
const installfill2 = "<?php echo $contract['freedeadline']; ?>";
const buyArr = [...<?php echo json_encode($buyArr); ?>];
const installArr = [...<?php echo json_encode($installArr); ?>];
let install_pay_text = '付款方式:<br> ';
let buy_pay_text = ''
const chineseArr = ['零','一','二','三','四','五','六','七']

13
wms/contract/contract-new-apply.php

@ -45,14 +45,12 @@ if(empty($contract_new_apply)){
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($items);
$sql_str = "SELECT * FROM pricereview_pay WHERE mid = :mid ORDER BY pay_kind ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$pays = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($pays);
$price_a = 0;
$price_b = 0;
foreach($pays as $pay){
@ -296,6 +294,7 @@ $status = isset($contract['status']) ? $contract['status'] : -1;
</template>
</tbody>
</table>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead style="font-weight: bolder;margin-bottom: 20px">
<tr>
@ -421,6 +420,14 @@ $status = isset($contract['status']) ? $contract['status'] : -1;
<?php endforeach; ?>
</tbody>
</table>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<tbody style="font-weight: bolder;margin-bottom: 20px">
<tr>
<td>第二期款交貨期限(日)</td>
<td><input type="number" class="form-control" x-model="data.secondPayDeadline" /></td>
</tr>
</tbody>
</table>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead style="font-weight: bolder;margin-bottom: 20px;">
<tr>
@ -544,6 +551,7 @@ $status = isset($contract['status']) ? $contract['status'] : -1;
const user_id = '<?php echo $user_id ?>';
const mid = '<?php echo $_GET['id']; ?>';
const pays = [...<?php echo json_encode($pays); ?>];
const secondPayDeadline = '';
const tradeaddress = "";
const tradedeadline = 90
const freedeadline = 18;
@ -578,6 +586,7 @@ $status = isset($contract['status']) ? $contract['status'] : -1;
const regulations = '<?php echo $contract['test_time'] ?>';
const workdeadline_a = '<?php echo $contract['workdeadline_a'] ?>';
const workdeadline_b = '<?php echo $contract['workdeadline_b'] ?>';
const secondPayDeadline = <?php echo $contract['secondPayDeadline'] ?>;
const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>;
</script>

19
wms/contract/js/alpine.js

@ -13,11 +13,11 @@ const contractDownload = ()=> {
// filebrowserUploadUrl:'./ckeditor_upload.php'
// });
},
installfill1:'',
installfill2:'',
installfill1: installfill1,
installfill2: installfill2,
installAffix:1,
buyfill1:'',
buyfill2:'',
buyfill1: buyfill1,
buyfill2: secondPayDeadline,
buyAffix:1,
css: `table { background-color: #fff; border: none; margin-top: 30px; font-family: '標楷體'; width: 600px; } table tr:nth-child(even), table tr:nth-child(odd) { background-color: #fff; } table tr { font-size: 12pt; width: 100%; } table tr h2 { font-size: 18pt; } table tr td { width: 100%; height: 100%; line-height: 2; display: flex; } table tr td.center { display: flex; justify-content: center; align-items: center; } table tr td.list { width: 100%; height: 100%; white-space: nowrap; display: flex; } table tr td.list span { width: 60px; min-height: 100%; display: block; } table tr td.list > p { display: block; text-align: justify; } table tr td.list div { max-width: calc(100% - 60px); white-space: normal; } table tr td.list div.text-justify { display: flex; width: 100%; justify-content: space-between; } table tr.date td > div { width: 100%; text-align: right; } table tr.date td > div.text-justify { display: flex; justify-content: space-between; } table td, table th { padding: 8px; }`,
data:{
@ -1208,6 +1208,7 @@ const contractNewApply = ()=>{
items: items,
salesman_comment:'',
review_comment:'',
secondPayDeadline: secondPayDeadline,
},
pays:{
1:{
@ -1257,6 +1258,10 @@ const contractNewApply = ()=>{
return num.toLocaleString();
},
storageFn(){
if(this.data.regulations < 45){
alert('試車時間不能低於45天')
return;
}
this.isLoading = true
const form = new FormData();
form.append('mid', this.data.mid);
@ -1279,6 +1284,7 @@ const contractNewApply = ()=>{
form.append('freedeadline', this.data.freedeadline);
form.append('tradeaddress', this.data.tradeaddress);
form.append('tradedeadline', this.data.tradedeadline);
form.append('secondPayDeadline', this.data.secondPayDeadline);
form.append('isFirst', isFirst);
form.append('user_id', user_id);
form.append('pays', JSON.stringify(this.pays));
@ -1304,6 +1310,10 @@ const contractNewApply = ()=>{
if(!confirm("確定送審嗎?")){
return;
}
if(this.data.regulations < 45){
alert('試車時間不能低於45天')
return;
}
this.isLoading = true
const form = new FormData();
form.append('mid', this.data.mid);
@ -1326,6 +1336,7 @@ const contractNewApply = ()=>{
form.append('freedeadline', this.data.freedeadline);
form.append('tradeaddress', this.data.tradeaddress);
form.append('tradedeadline', this.data.tradedeadline);
form.append('secondPayDeadline', this.data.secondPayDeadline);
form.append('isFirst', isFirst);
form.append('user_id', user_id);
form.append('pays', JSON.stringify(this.pays));

114
wms/contract/prviewPdf.php

@ -1,7 +1,7 @@
<?php
require_once('./conn.php');
include "../header.php";
if(isset($_POST['list'])){
require_once('./conn.php');
if($_POST['list']){
if($_POST['prviewType'] == 1){
$isStand = ($_POST['buystandard']=="true") ? 1 : 0;
}else{
@ -50,40 +50,39 @@ if(isset($_POST['list'])){
window.history.back();
</script>";
}
function numberToChinese($num) {
$chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九','十'];
$units = ['', '十', '百', '千', '万'];
if ($num <= 10) {
return $chineseNumbers[$num];
} elseif ($num < 20) {
return $units[1] . $chineseNumbers[$num % 10];
} elseif ($num < 100) {
return $chineseNumbers[intval($num / 10)] . $units[1] . ($num % 10 > 0 ? $chineseNumbers[$num % 10] : '');
} else {
// 處理大於 99 的数字
$result = '';
$strNum = strval($num);
$length = strlen($strNum);
for ($i = 0; $i < $length; $i++) {
$currentDigit = intval($strNum[$i]);
if ($currentDigit > 0) {
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1];
} else {
$result .= $chineseNumbers[$currentDigit];
function numberToChinese($num) {
$chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九','十'];
$units = ['', '十', '百', '千', '万'];
if ($num <= 10) {
return $chineseNumbers[$num];
} elseif ($num < 20) {
return $units[1] . $chineseNumbers[$num % 10];
} elseif ($num < 100) {
return $chineseNumbers[intval($num / 10)] . $units[1] . ($num % 10 > 0 ? $chineseNumbers[$num % 10] : '');
} else {
// 處理大於 99 的数字
$result = '';
$strNum = strval($num);
$length = strlen($strNum);
for ($i = 0; $i < $length; $i++) {
$currentDigit = intval($strNum[$i]);
if ($currentDigit > 0) {
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1];
} else {
$result .= $chineseNumbers[$currentDigit];
}
}
return $result;
}
return $result;
}
}
function removeTrailingBr($string) {
//刪除字串尾巴的<br><br />
return preg_replace('/(<br\s*\/?>)+$/', '', $string);
}
function removeTrailingBr($string) {
//刪除字串尾巴的<br><br />
return preg_replace('/(<br\s*\/?>)+$/', '', $string);
}
?>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.3/purify.min.js"></script>
@ -158,7 +157,7 @@ function removeTrailingBr($string) {
background-color: #40C474;
}
</style>
<div>123132132132</div>
<div class="container" x-data="{
css:'',
@ -600,63 +599,16 @@ function removeTrailingBr($string) {
return response;
}, (error)=>{
if(error.response.status === 401){
// store.commit('setToken', null)
// sessionStorage.removeItem('TOKEN')
// router.push({name:'login'})
}
throw error;
});
createFloatWater()
function createFloatWater(){
}
const btn =document.getElementById('btn')
// btn.addEventListener('click', exportFn)
// exportFn();
function exportFn(){
const now = new Date();
// 獲取年、月、日、小時、分鐘、秒
const year = now.getFullYear();
const month = now.getMonth() + 1; // 月份是從0開始的,所以要加1
const day = now.getDate();
const hours = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
// 格式化日期和時間
const formattedDate = `${year}${month}${day}${hours}${minutes}${seconds}`;
let html = document.getElementById('prview').innerHTML
let footer = document.getElementById('prview').innerHTML
console.log(html);
// axios.post('./export-pdf.php', {'html':html}).then(res=>{
// console.log(res);
// })
const form = new FormData();
form.append('html', html);
form.append('css','');
axiosClient({
method:'post',
responseType:'blob',
url:'./export-pdf.php',
data:form
}).then(response=>{
const url = window.URL.createObjectURL(new Blob([response.data]));
console.log(url);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', formattedDate + '.pdf'); // 指定下载的文件名
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
}
const btn =document.getElementById('btn')
</script>
<?php
}else{
echo "<script>alert('非法訪問!');history.back() </script>";
echo "<script>alert('非法訪問!');window.history.back();</script>";
}
?>
Loading…
Cancel
Save