Ellin 1 year ago
parent
commit
55ad03d4d8
  1. 29
      wms/contract/contract-download.php
  2. 2
      wms/contract/contract-new-apply.php
  3. 10
      wms/contract/js/alpine.js
  4. 24
      wms/contract/prviewPdf.php

29
wms/contract/contract-download.php

@ -25,6 +25,7 @@ if(isset($_GET['id']) && $_GET['id']!=""){
$stmt->execute(); $stmt->execute();
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC);
$contract = $contracts[0]; $contract = $contracts[0];
$contract_apply_id = $contract['id'];
if(($contract['status'] !== "YY" && $user_id != 'M0107') && $user_id != 'M0174'){ if(($contract['status'] !== "YY" && $user_id != 'M0107') && $user_id != 'M0174'){
echo '<script type="text/javascript"> echo '<script type="text/javascript">
alert("非法訪問。"); alert("非法訪問。");
@ -79,13 +80,17 @@ if(isset($_GET['id']) && $_GET['id']!=""){
} }
} }
print_r($buyArr); $sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL";
$sql_str = "SELECT contract_apply_files.*, contract_new_apply.id as apply_id FROM contract_apply_files LEFT JOIN contract_new_apply ON contract_apply_files.contract_id = contract_new_apply.id WHERE contract_new_apply.mid = :mid AND contract_apply_files.deleted_at IS NULL";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$files = $stmt->fetchAll(PDO::FETCH_ASSOC);
$files_count = count($files);
} }
catch (PDOException $e ){ catch (PDOException $e ){
die("ERROR!!!: ". $e->getMessage()); die("ERROR!!!: ". $e->getMessage());
} }
echo $buy_total_price;
} }
?> ?>
<link rel="stylesheet" href="./styles/style.css"> <link rel="stylesheet" href="./styles/style.css">
@ -113,7 +118,7 @@ if(isset($_GET['id']) && $_GET['id']!=""){
<input type="number" x-model="buyfill2"> <input type="number" x-model="buyfill2">
</label> --> </label> -->
<?php } ?> <?php } ?>
<label for=""> <!-- <label for="">
<p>附件數</p> <p>附件數</p>
<select x-model="buyAffix"> <select x-model="buyAffix">
<option value="1">1</option> <option value="1">1</option>
@ -122,9 +127,9 @@ if(isset($_GET['id']) && $_GET['id']!=""){
<option value="4">4</option> <option value="4">4</option>
<option value="5">5</option> <option value="5">5</option>
</select> </select>
</label> </label> -->
<label for=""> <label for="">
<button @click="sendBuyInputFn()">確認</button> <button @click="sendBuyInputFn()">生成買賣合約書</button>
</label> </label>
</div> </div>
<div class="contract-material-component" x-show="isbuyShow && !isBuyInputIng"> <div class="contract-material-component" x-show="isbuyShow && !isBuyInputIng">
@ -238,7 +243,7 @@ if(isset($_GET['id']) && $_GET['id']!=""){
<p>免費保養月數(月)</p> <p>免費保養月數(月)</p>
<input type="number" x-model="installfill2" @keyup="sendInstallInputKeyupFn($event)" /> <input type="number" x-model="installfill2" @keyup="sendInstallInputKeyupFn($event)" />
</label> --> </label> -->
<label for=""> <!-- <label for="">
<p>附件數</p> <p>附件數</p>
<select x-model="installAffix" @keyup="sendInstallInputKeyupFn($event)"> <select x-model="installAffix" @keyup="sendInstallInputKeyupFn($event)">
<option value="1">1</option> <option value="1">1</option>
@ -247,9 +252,9 @@ if(isset($_GET['id']) && $_GET['id']!=""){
<option value="4">4</option> <option value="4">4</option>
<option value="5">5</option> <option value="5">5</option>
</select> </select>
</label> </label> -->
<label for=""> <label for="">
<button @click="sendInstallInputFn()">確認</button> <button @click="sendInstallInputFn()">生成安裝合約書</button>
</label> </label>
</div> </div>
<div class="contract-install-component" x-show="!isbuyShow && !isInstallInputIng" x-cloak > <div class="contract-install-component" x-show="!isbuyShow && !isInstallInputIng" x-cloak >
@ -348,7 +353,8 @@ if(isset($_GET['id']) && $_GET['id']!=""){
</table> </table>
</div> </div>
<form action="prviewPdf.php?&<?php echo $token_link; ?>" id="form" method="post" x-ref="form" style="display:none"> <form action="prviewPdf.php?id=<?php echo $id; ?>&<?php echo $token_link; ?>" id="form" method="post" x-ref="form" style="display:none">
<input type="hidden" name="contract_apply_id" id="contract_apply_id" value="<?php echo $contract_apply_id; ?>" />
<input type="hidden" name="list" id="prview-list" /> <input type="hidden" name="list" id="prview-list" />
<input type="hidden" name="prviewType" id="prview-type" /> <input type="hidden" name="prviewType" id="prview-type" />
<input type="hidden" name="standardList" id="standard-prview-list" /> <input type="hidden" name="standardList" id="standard-prview-list" />
@ -390,7 +396,8 @@ if(isset($_GET['id']) && $_GET['id']!=""){
const people = <?php echo $noteArr[1]; ?>; const people = <?php echo $noteArr[1]; ?>;
const floor = <?php echo $noteArr[2]; ?>; const floor = <?php echo $noteArr[2]; ?>;
const speed = <?php echo $noteArr[3]; ?>; const speed = <?php echo $noteArr[3]; ?>;
console.log(buyArr); const buyAffix =' <?php echo $files_count; ?>';
console.log(buyAffix);
console.log(installArr); console.log(installArr);
buyArr.forEach((item, idx) => { buyArr.forEach((item, idx) => {
if(item.scale > 0){ if(item.scale > 0){

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

@ -460,7 +460,7 @@ $person = $contract['person'];
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> <input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
<?php endif; ?> <?php endif; ?>
<?php foreach($files as $file): ?> <?php foreach($files as $file): ?>
<a href="./images/contracts_new_files/<?php echo $file['file_name']; ?>" download ?><?php echo $file['file_name']; ?></a> <a href="./images/contracts_new_files/<?php echo $file['file_name']; ?>" download><?php echo $file['file_name']; ?></a> <?php if($status < 1): ?><span style="margin-left:10px;cursor:pointer;color:#f019">X</span><?php endif; ?><br />
<?php endforeach; ?> <?php endforeach; ?>
</td> </td>
</tr> </tr>

10
wms/contract/js/alpine.js

@ -18,7 +18,7 @@ const contractDownload = ()=> {
installAffix:1, installAffix:1,
buyfill1: buyfill1, buyfill1: buyfill1,
buyfill2: secondPayDeadline, buyfill2: secondPayDeadline,
buyAffix:1, buyAffix: buyAffix,
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; }`, 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:{ data:{
illustrate:{ illustrate:{
@ -686,8 +686,8 @@ const contractDownload = ()=> {
alert('請輸入免費保養月數'); alert('請輸入免費保養月數');
return; return;
} }
if(this.installfill1 < 45){ if(this.installfill1 < 10){
alert('安裝試車期限不得低於45日'); alert('安裝試車期限不得低於10日');
return; return;
} }
if(this.installfill1 < 1){ if(this.installfill1 < 1){
@ -1305,11 +1305,11 @@ const contractNewApply = ()=>{
if(res.status === 201){ if(res.status === 201){
alert('暫存成功'); alert('暫存成功');
console.log(res.data); console.log(res.data);
// window.location.reload(); window.location.reload();
}else if(res.status === 200){ }else if(res.status === 200){
alert('更新成功'); alert('更新成功');
console.log(res.data); console.log(res.data);
// window.location.reload(); window.location.reload();
} }
this.isLoading = false this.isLoading = false
}).catch(error=>{ }).catch(error=>{

24
wms/contract/prviewPdf.php

@ -2,6 +2,7 @@
include "../header.php"; include "../header.php";
require_once('./conn.php'); require_once('./conn.php');
if($_POST['list']){ if($_POST['list']){
$contract_id = $_POST['contract_apply_id'];
if($_POST['prviewType'] == 1){ if($_POST['prviewType'] == 1){
$isStand = ($_POST['buystandard']=="true") ? 1 : 0; $isStand = ($_POST['buystandard']=="true") ? 1 : 0;
}else{ }else{
@ -50,6 +51,11 @@ if($_POST['list']){
window.history.back(); window.history.back();
</script>"; </script>";
} }
$sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contract_id', $contract_id);
$stmt->execute();
$files = $stmt->fetchAll(PDO::FETCH_ASSOC);
function numberToChinese($num) { function numberToChinese($num) {
$chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九','十']; $chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九','十'];
$units = ['', '十', '百', '千', '万']; $units = ['', '十', '百', '千', '万'];
@ -157,12 +163,12 @@ if($_POST['list']){
background-color: #40C474; background-color: #40C474;
} }
</style> </style>
<div>123132132132</div>
<div class="container" x-data="{ <div class="container" x-data="{
css:'', css:'',
random:'', random:'',
init(){ init(){
const characters = '012345678901234567890123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const characters = '012345678901234567890123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const charactersLength = characters.length; const charactersLength = characters.length;
let randomString = ''; let randomString = '';
@ -172,7 +178,8 @@ if($_POST['list']){
const randomIndex = Math.floor(Math.random() * charactersLength); const randomIndex = Math.floor(Math.random() * charactersLength);
randomString += characters.charAt(randomIndex); randomString += characters.charAt(randomIndex);
} }
this.random = randomString this.random = randomString;
console.log(files);
}, },
exportFn(){ exportFn(){
@ -224,6 +231,16 @@ if($_POST['list']){
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
this.store(newtoken, formattedDate) this.store(newtoken, formattedDate)
for(let i=0;i<files.length;i++){
let filename = document.createElement('a');
filename.href = './images/contracts_new_files/' + files[i].file_name;
filename.setAttribute('download', filename.href); // 指定下载的文件名
document.body.appendChild(filename);
filename.click();
document.body.removeChild(filename);
}
}) })
}, },
store(newtoken, formattedDate){ store(newtoken, formattedDate){
@ -583,6 +600,7 @@ if($_POST['list']){
<script> <script>
const files = <?php echo json_encode($files); ?>;
const axiosClient = axios.create({ const axiosClient = axios.create({
baseURL : ``, baseURL : ``,
}); });
@ -605,7 +623,7 @@ if($_POST['list']){
const btn =document.getElementById('btn') const btn =document.getElementById('btn')
console.log(<?php echo $contract_id; ?>);
</script> </script>
<?php <?php
}else{ }else{

Loading…
Cancel
Save