Browse Source

合約書生成 附件上傳完成

main
10994015 1 year ago
parent
commit
39ce14a8d6
  1. 27
      wms/contract/contract-download.php
  2. 2
      wms/contract/contract-new-apply.php
  3. 2
      wms/contract/js/alpine.js
  4. 22
      wms/contract/prviewPdf.php

27
wms/contract/contract-download.php

@ -79,13 +79,19 @@ 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";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contract_id', $id);
$stmt->execute();
$files = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($files);
echo "count=>" . count($files);
$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 +119,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 +128,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 +244,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 +253,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 +354,7 @@ 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="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>

2
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:{

22
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 = $_GET['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,12 @@ 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 = ['', '十', '百', '千', '万'];
@ -163,6 +170,7 @@ if($_POST['list']){
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 +180,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 +233,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 +602,7 @@ if($_POST['list']){
<script> <script>
const files = <?php echo json_encode($files); ?>;
const axiosClient = axios.create({ const axiosClient = axios.create({
baseURL : ``, baseURL : ``,
}); });

Loading…
Cancel
Save