5 changed files with 1324 additions and 91 deletions
@ -0,0 +1,545 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once('./conn.php'); |
|||
//買賣1、2、3,安裝5、6 (4跟7很少有) |
|||
if (isset($_GET['id']) && $_GET['id'] != "") { |
|||
try { |
|||
$id = $_GET['id']; |
|||
$sql_str = "SELECT pricereview_main.*, pricereview_pay.*, pricereview_item.note, pricereview_item.item_qty, account.name as accountname, account.id as accountid |
|||
FROM pricereview_main |
|||
JOIN pricereview_pay ON pricereview_main.id = pricereview_pay.mid |
|||
JOIN pricereview_item ON pricereview_main.id = pricereview_item.mid |
|||
JOIN account ON pricereview_main.person = account.accountid |
|||
WHERE pricereview_main.id = :id AND pricereview_item.item_group = 'A' ORDER BY pay_kind ASC"; |
|||
// $stmt = $conn->prepare($sql_str); |
|||
// $stmt->bindParam(':id',$id); |
|||
// $stmt->execute(); |
|||
// $contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$sql_str = "SELECT contract_new_apply.*, |
|||
contract_new_apply_pays.pay_kind, contract_new_apply_pays.pay_scale, contract_new_apply_pays.pay_amount, contract_new_apply_pays.pay_period, contract_new_apply_pays.condition_date |
|||
FROM contract_new_apply |
|||
JOIN contract_new_apply_pays ON contract_new_apply.id = contract_new_apply_pays.contract_apply_id |
|||
WHERE contract_new_apply.mid = :id"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id', $id); |
|||
$stmt->execute(); |
|||
$contracts = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$contract = $contracts[0]; |
|||
$contract_apply_id = $contract['id']; |
|||
if (($contract['status'] !== "YY" && $user_id != 'M0107') && $user_id != 'M0174') { |
|||
echo '<script type="text/javascript"> |
|||
alert("非法訪問。"); |
|||
window.history.back(); |
|||
</script>'; |
|||
exit; |
|||
} |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contract['contractno']); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
if (count($customer) <= 0) { |
|||
echo "<script> |
|||
alert('資料不齊或合約書已生成過。'); |
|||
window.history.back(); |
|||
</script>"; |
|||
exit; |
|||
} |
|||
$buyArr = []; |
|||
$buyNo2Pay = false; |
|||
$buy_total_price = 0; |
|||
$installArr = []; |
|||
$install_total_price = 0; |
|||
// $noteArr = explode(",", $contracts[0]['note']); |
|||
$noteArr = array(1, 1, 1, 1, 1); |
|||
$qty = $contracts[0]['total_items']; |
|||
foreach ($contracts as $idx => $amount) { |
|||
$isset = false; |
|||
if ($amount['pay_kind'] == 5 || $amount['pay_kind'] == 6) { |
|||
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'], 'pay_period' => $amount['pay_period']]; |
|||
} |
|||
} |
|||
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']; |
|||
foreach ($buyArr as $buy) { |
|||
if ($buy['installment'] == $amount['pay_kind']) { |
|||
$isset = true; |
|||
} |
|||
} |
|||
if (!$isset) { { |
|||
$buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; |
|||
} |
|||
if ($amount['pay_kind'] == 2) { |
|||
$buyNo2Pay = true; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
$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) { |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
} |
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<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> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.3/html2canvas.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script> |
|||
<main x-data="contractDownload"> |
|||
<div class="sidebar"> |
|||
<ul> |
|||
<button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button> |
|||
<button :class="!isbuyShow ?'active' : ''" @click="isbuyShow = false">電梯安裝合約書</button> |
|||
<a href="../mkt/pricereview-index.php?function_name=pricereview&<?php echo $token_link; ?>">回列表</a> |
|||
</ul> |
|||
</div> |
|||
<div class="inputDiv" x-show="isbuyShow && isBuyInputIng"> |
|||
<!-- <label for=""> |
|||
<p>交貨期限(日)</p> |
|||
<input type="number" x-model="buyfill1" @keyup="sendBuyInputKeyupFn($event)" /> |
|||
</label> --> |
|||
<?php if ($buyNo2Pay) { ?> |
|||
<!-- <label for=""> |
|||
<p>第二期款交貨期限(日)</p> |
|||
<input type="number" x-model="buyfill2"> |
|||
</label> --> |
|||
<?php } ?> |
|||
<!-- <label for=""> |
|||
<p>附件數</p> |
|||
<select x-model="buyAffix"> |
|||
<option value="1">1</option> |
|||
<option value="2">2</option> |
|||
<option value="3">3</option> |
|||
<option value="4">4</option> |
|||
<option value="5">5</option> |
|||
</select> |
|||
</label> --> |
|||
<label for=""> |
|||
<button @click="sendBuyInputFn()">生成買賣合約書</button> |
|||
</label> |
|||
</div> |
|||
<div class="contract-material-component" x-show="isbuyShow && !isBuyInputIng"> |
|||
<div class="btn-list"> |
|||
<label for="standardBuyBtn"> |
|||
<p>制式合約</p> |
|||
<input type="checkbox" class="scorll" x-model="toggleBuyStandard"> |
|||
<!-- <input type="radio" checked id="standardBuyBtn" name="standardBuyBtn" @change="toggleBuyStandard = true" /> --> |
|||
</label> |
|||
<!-- <label for="noStandardBuyBtn"> |
|||
<input type="radio" id="noStandardBuyBtn" name="standardBuyBtn" @change="toggleBuyStandard = false" /> |
|||
非制式合約 |
|||
</label> --> |
|||
</div> |
|||
<button @click="isBuyInputIng = true" class="rebtn">重新輸入</button> |
|||
<button @click="exportFn(1)" class="prviewbtn">預覽</button> |
|||
<div class="contract" id="noStandardBuyContract" x-show="!toggleBuyStandard"> |
|||
<table class="my-2 contract" x-ref="contract1" id="contract1"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯買賣合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="onstandardViewData.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="buyonstandardViewData.illustrate.editshow ? 'mouseover' : '' " x-on:mouseover="mouseover('illustrate', false)" x-on:mouseout="mouseout('illustrate')"> |
|||
<td> |
|||
<span x-html='buydata.illustrate.plaintext'></span> |
|||
<div class="buttons" x-show="buyonstandardViewData.illustrate.editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('更新合約書內容', 'illustrate', false, false)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="delete"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in buyonstandardViewData.list.plaintext" :key="item.id"> |
|||
<tr :class="buyonstandardViewData.list.plaintext[idx].editshow ? 'mouseover' : '' " @mouseover="mouseoverlist(idx, false)" @mouseout="mouseoutlist(idx)"> |
|||
<td class="list"> |
|||
<div class="buttons" x-show="buyonstandardViewData.list.plaintext[idx].editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('update contract list', idx, true, false)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="add" @click="modelshowAddUpFn(idx, false)"><i class="glyphicon glyphicon-arrow-up"></i></button> |
|||
<button class="add" @click="modelshowAddDownFn(idx, false)"><i class="glyphicon glyphicon-arrow-down"></i></button> |
|||
<button class="delete" @click="deleteEditor(idx, false)"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="buyonstandardViewData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
<div class="contract" id="standardBuyContract" x-show="toggleBuyStandard"> |
|||
<table class="my-2 contract" id="contract0"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯買賣合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="data.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="data.partyA.plaintext"> </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="buystandardData.illustrate.editshow ? 'mouseover' : '' "> |
|||
<td> |
|||
<span x-html='buystandardData.illustrate.plaintext'></span> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in buystandardData.list.plaintext" :key="item.id"> |
|||
<tr :class="buystandardData.list.plaintext[idx].editshow ? 'mouseover' : '' "> |
|||
<td class="list"> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="buystandardData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<div class="contract-model" x-show="modelshow" x-cloak> |
|||
<div class="contract-back"></div> |
|||
<div class="contract-content"> |
|||
<div class="model-header"><span x-text='modelText'></span><i @click='modelcloseFn()' class="glyphicon glyphicon-remove"></i></div> |
|||
<div class="content"> |
|||
<textarea name="content" id="editor" x-ref="editor"></textarea> |
|||
<input type="submit" value="update" @click='updateEditor()' /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="inputDiv" x-show="!isbuyShow && isInstallInputIng"> |
|||
<!-- <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 for=""> |
|||
<p>附件數</p> |
|||
<select x-model="installAffix" @keyup="sendInstallInputKeyupFn($event)"> |
|||
<option value="1">1</option> |
|||
<option value="2">2</option> |
|||
<option value="3">3</option> |
|||
<option value="4">4</option> |
|||
<option value="5">5</option> |
|||
</select> |
|||
</label> --> |
|||
<label for=""> |
|||
<button @click="sendInstallInputFn()">生成安裝合約書</button> |
|||
</label> |
|||
</div> |
|||
<div class="contract-install-component" x-show="!isbuyShow && !isInstallInputIng" x-cloak> |
|||
|
|||
<div class="btn-list"> |
|||
<label for="standardBtn"> |
|||
<p>制式合約</p> |
|||
<input type="checkbox" class="scorll" x-model="toggleBuyStandard"> |
|||
<!-- <input type="radio" checked id="standardBtn" name="standardBtn" @change="toggleInstallStandard = true" /> --> |
|||
</label> |
|||
<!-- <label for="noStandardBtn"> |
|||
<input type="radio" id="noStandardBtn" name="standardBtn" @change="toggleInstallStandard = false" /> |
|||
非制式合約 |
|||
</label> --> |
|||
</div> |
|||
<button @click="isInstallInputIng = true" class="rebtn">重新輸入</button> |
|||
<button @click="exportFn(2)" class="prviewbtn">預覽</button> |
|||
|
|||
|
|||
<div class="contract" id="noStandardContract" x-show="!toggleInstallStandard"> |
|||
<table class="my-2 contract" x-ref="contract1" id="contract1"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯安裝合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="onstandardViewData.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="onstandardViewData.illustrate.editshow ? 'mouseover' : '' " x-on:mouseover="mouseover('illustrate')" x-on:mouseout="mouseout('illustrate')"> |
|||
<td> |
|||
<span x-html='onstandardViewData.illustrate.plaintext'></span> |
|||
<div class="buttons" x-show="onstandardViewData.illustrate.editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('更新合約書內容', 'illustrate', false, true)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="delete"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in onstandardViewData.list.plaintext" :key="item.text"> |
|||
<tr :class="onstandardViewData.list.plaintext[idx].editshow ? 'mouseover' : '' " @mouseover="mouseoverlist(idx)" @mouseout="mouseoutlist(idx)"> |
|||
<td class="list"> |
|||
<div class="buttons" x-show="onstandardViewData.list.plaintext[idx].editshow" x-cloak> |
|||
<button class="edit" @click="modelshowEditFn('update contract list', idx, true, true)"><i class="glyphicon glyphicon-pencil"></i></button> |
|||
<button class="add" @click="modelshowAddUpFn(idx)"><i class="glyphicon glyphicon-arrow-up"></i></button> |
|||
<button class="add" @click="modelshowAddDownFn(idx)"><i class="glyphicon glyphicon-arrow-down"></i></button> |
|||
<button class="delete" @click="deleteEditor(idx)"><i class="glyphicon glyphicon-trash"></i></button> |
|||
</div> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="onstandardViewData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="contract" id="standardContract" x-show="toggleInstallStandard"> |
|||
<table class="my-2 contract" id="contract0"> |
|||
<tr> |
|||
<td class="center"> |
|||
<h2 style="text-align:center">電梯安裝合約書</h2> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="1"> |
|||
合約書編號:<article x-html="data.partyAcontractno.plaintext"></article> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p x-html="data.partyA.plaintext">一二營造有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即買方,以下簡稱為甲方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>立合約書人</td> |
|||
</tr> |
|||
<tr> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
<p>永佳捷科技股份有限公司 </p> |
|||
</div> |
|||
<div style="margin-left: auto;margin-right:200px">(即賣方,以下簡稱為乙方)</div> |
|||
</td> |
|||
</tr> |
|||
<tr :class="standardData.illustrate.editshow ? 'mouseover' : '' "> |
|||
<td> |
|||
<span x-html='standardData.illustrate.plaintext'></span> |
|||
</td> |
|||
</tr> |
|||
<template x-for="(item, idx) in standardData.list.plaintext"> |
|||
<tr :class="standardData.list.plaintext[idx].editshow ? 'mouseover' : '' "> |
|||
<td class="list"> |
|||
<span x-text="'第' + chineseNumbers(idx+1) + '條'"></span> |
|||
<article x-html="standardData.list.plaintext[idx].text"></article> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
</table> |
|||
</div> |
|||
|
|||
<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="prviewType" id="prview-type" /> |
|||
<input type="hidden" name="standardList" id="standard-prview-list" /> |
|||
<input type="hidden" name="illustrate" id="illustrate" /> |
|||
<input type="hidden" name="standardIllustrate" id="standard-illustrate" /> |
|||
<input type="hidden" name="partyA" id="partyA" /> |
|||
<input type="hidden" name="partyAcontractno" id="partyAcontractno" /> |
|||
<input type="hidden" name="buystandard" x-model="toggleBuyStandard" /> |
|||
<input type="hidden" name="installstandard" x-model="toggleInstallStandard" /> |
|||
<input type="hidden" name="total_price" x-model="total_price" id="total_price" /> |
|||
<input type="hidden" name="person" id="person" value="<?php echo $contract['accountname']; ?>" /> |
|||
<input type="hidden" name="personid" id="personid" value="<?php echo $contract['accountid']; ?>" /> |
|||
<input type="hidden" name="delivery_term" id="delivery_term" x-model="buyfill1" /> |
|||
<input type="hidden" name="install_period" id="install_period" x-model="installfill1" /> |
|||
<input type="hidden" name="free_maintainance" id="free_maintainance" x-model="installfill2" /> |
|||
</form> |
|||
|
|||
</div> |
|||
</main> |
|||
<!-- <script src="../ckeditor4/ckeditor.js"></script> --> |
|||
<script> |
|||
const partyAcompany = <?php echo json_encode($contract['customer']); ?>; |
|||
const partyAcontractno = <?php echo json_encode($contract['contractno']); ?>; |
|||
const partyAaddress = <?php echo json_encode($contract['contact_address']); ?>; |
|||
const totalPrice = <?php echo $contract['total_price']; ?>; |
|||
const totalInstallPrice = <?php echo $install_total_price; ?>; |
|||
const totalBuyPrice = <?php echo $buy_total_price; ?>; |
|||
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 = ['零', '一', '二', '三', '四', '五', '六', '七'] |
|||
const bigChineseArr = ['零', '壹', '貳', '參', '肆', '伍', '陸', '柒', '捌', '玖', '拾']; |
|||
const num = <?php echo $qty; ?>; |
|||
const people = <?php echo $noteArr[1]; ?>; |
|||
const floor = <?php echo $noteArr[2]; ?>; |
|||
const speed = <?php echo $noteArr[3]; ?>; |
|||
const buyAffix = ' <?php echo $files_count; ?>'; |
|||
console.log(buyAffix); |
|||
console.log(installArr); |
|||
buyArr.forEach((item, idx) => { |
|||
if (item.scale > 0) { |
|||
if (item.installment == 1) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:合約簽定時,甲方應付合約定金新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 2) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:合約簽訂後 ____ 天付第二期款新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 3) { |
|||
buy_pay_text = `${buy_pay_text}第${chineseArr[idx+1]}期款:產品貨到工地時應付新台幣 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )( 含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} |
|||
} |
|||
});; |
|||
buy_pay_text += '以上期款若以票據支付時,發票人需為本合約甲方,票面金額同於各期應付款項,票期於各期付款日三十日內,票據須屬有效並得兌現。<br>乙方收款帳戶名稱:永佳捷科技股份有限公司;收款銀行:兆豐國際商業銀行(桃興分行);帳戶號碼:207-09-08688-2。' |
|||
buy_pay_text = buy_pay_text.replace(/\n/g, "").replace(/\s+/g, '').trim(); |
|||
installArr.forEach((item, idx) => { |
|||
if (item.scale > 0) { |
|||
if (item.installment == 5) { |
|||
install_pay_text = `${install_pay_text}第${chineseArr[idx+1]}期款:甲方應於安裝及試車完成後給付安裝費用 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} else if (item.installment == 6) { |
|||
install_pay_text = `${install_pay_text}第二期款:甲方應於交車後給付 ${numberToChinese(item.amount)} 元整( ${numberWithCommas(item.amount)} )(含5%加值型營業稅)(${item.pay_period}天期票)。<br>` |
|||
} |
|||
} |
|||
}) |
|||
install_pay_text += '以上期款若以票據支付時,發票人需為本合約甲方,票面金額同於各期應付款項,票期於各期付款日三十日內,票據須屬有效並得兌現。<br> 乙方收款帳戶名稱:永佳捷科技股份有限公司;收款銀行:兆豐國際商業銀行(桃興分行);帳戶號碼:207-09-08688-2。' |
|||
install_pay_text = install_pay_text.replace(/\n/g, "").replace(/\s+/g, '').trim(); |
|||
|
|||
function numberWithCommas(x) { |
|||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
|||
} |
|||
|
|||
function numberToChinese(n) { |
|||
if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) return "Invalid number."; |
|||
let unit = "仟佰拾億仟佰拾萬仟佰拾元角分"; |
|||
let str = ""; |
|||
n += "00"; |
|||
let pos = n.indexOf('.'); |
|||
if (pos >= 0) { |
|||
n = n.substring(0, pos) + n.substr(pos + 1, 2); |
|||
} |
|||
unit = unit.substr(unit.length - n.length); |
|||
for (let i = 0; i < n.length; i++) { |
|||
str += '零壹貳參肆伍陸柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i); |
|||
} |
|||
str = ('_' + str + '_'); |
|||
return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(萬|億|元)/g, "$1").replace(/(億)萬|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "").replace("元", "").replace(/^\s+|\s+$/g, ''); |
|||
} |
|||
|
|||
function numberToSmallChinese(num) { |
|||
const chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; |
|||
const chineseUnits = ['', '十', '百', '千']; |
|||
|
|||
const numStr = num.toString(); |
|||
const numLength = numStr.length; |
|||
let chineseStr = ''; |
|||
|
|||
for (let i = 0; i < numLength; i++) { |
|||
const digit = parseInt(numStr.charAt(i)); |
|||
const unitPos = numLength - i - 1; |
|||
|
|||
if (digit !== 0) { |
|||
chineseStr += chineseNumbers[digit] + chineseUnits[unitPos]; |
|||
} else { |
|||
// 处理连续的零,只添加一个零到结果中 |
|||
if (i < numLength - 1 && parseInt(numStr.charAt(i + 1)) !== 0) { |
|||
chineseStr += chineseNumbers[digit]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return chineseStr; |
|||
} |
|||
</script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
const axiosClient = axios.create({ |
|||
baseURL: './', |
|||
}); |
|||
|
|||
|
|||
axiosClient.interceptors.request.use((config) => { |
|||
config.headers.Authorization = 'Bearer <?php echo $token ?>' |
|||
return config; |
|||
}, (error) => { |
|||
return Promise.reject(error); |
|||
}); |
|||
|
|||
axiosClient.interceptors.response.use((response) => { |
|||
return response; |
|||
}, (error) => { |
|||
if (error.response.status === 401) { |
|||
console.error(error); |
|||
} |
|||
throw error; |
|||
}); |
|||
</script> |
|||
<script> |
|||
</script> |
@ -0,0 +1,662 @@ |
|||
<?php |
|||
include_once("../header.php"); |
|||
require_once("./conn.php"); |
|||
// if (!(isset($_GET['id']) && !empty($_GET['id']))) { |
|||
// $para = "function_name=pricereview&" . $token_link; |
|||
// echo "<script>alert('非法訪問!!!');</script>"; |
|||
// echo "<script>window.history.go(-1);</script>"; |
|||
// exit; |
|||
// } |
|||
$id = $_GET["id"]; |
|||
|
|||
$sql_str = "SELECT contract_new_apply.*, account.name as review_person_name |
|||
FROM contract_new_apply |
|||
LEFT JOIN account ON contract_new_apply.review_person_id = account.accountid |
|||
WHERE contract_new_apply.mid = :mid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $id); |
|||
$stmt->execute(); |
|||
$contract_new_apply = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$contract = $contract_new_apply; |
|||
$isFirst = empty($contract_new_apply) ? 1 : 0; |
|||
if (empty($contract_new_apply)) { |
|||
$sql_str = "SELECT pricereview_main.contractno, pricereview_main.ekind, pricereview_main.person, pricereview_main.company, pricereview_main.case_name, pricereview_main.address, pricereview_main.price_lowest, pricereview_main.price_total, pricereview_main.price_rate, pricereview_main.status as priceview_status, pricereview_main.id as mainid, account.name as accountname |
|||
FROM pricereview_main |
|||
JOIN account ON pricereview_main.person = account.accountid |
|||
WHERE pricereview_main.id = :id"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':id', $id); |
|||
$stmt->execute(); |
|||
$contract = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
// print_r($contract); |
|||
$accounttype = "M"; |
|||
$sql_str = "SELECT * FROM account WHERE accounttype = :accounttype"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->execute(); |
|||
$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contract['contractno']); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
|
|||
$mid = $contract['mainid']; |
|||
|
|||
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$total_items = 0; |
|||
foreach ($items as $item) { |
|||
$total_items += $item['item_qty']; |
|||
} |
|||
$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); |
|||
$price_a = 0; |
|||
$price_b = 0; |
|||
foreach ($pays as $pay) { |
|||
if ($pay['pay_kind'] <= 4) { |
|||
$price_a = $price_a + $pay['pay_amount']; |
|||
} else { |
|||
$price_b = $price_b + $pay['pay_amount']; |
|||
} |
|||
} |
|||
} else { |
|||
$mid = $contract['mid']; |
|||
$contract_new_apply_id = $contract_new_apply['id']; |
|||
$sql_str = "SELECT * FROM contract_new_apply_pays 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); |
|||
|
|||
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':mid', $mid); |
|||
$stmt->execute(); |
|||
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
$price_a = 0; |
|||
$price_b = 0; |
|||
foreach ($pays as $pay) { |
|||
if ($pay['pay_kind'] <= 4) { |
|||
$price_a = $price_a + $pay['pay_amount']; |
|||
} else { |
|||
$price_b = $price_b + $pay['pay_amount']; |
|||
} |
|||
} |
|||
|
|||
$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); |
|||
} |
|||
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0; |
|||
$status = isset($contract['status']) ? $contract['status'] : -1; |
|||
$person = $contract['person']; |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="./styles/style.css"> |
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|||
<link rel="stylesheet" href="semantic/dist/semantic.min.css"> |
|||
<script defer src="./js/alpinejs/cdn.min.js"></script> |
|||
<script src="./js/axios/axios.min.js"></script> |
|||
<div class="contract-new-apply-component" x-data="contractNewApply"> |
|||
<div class="form" method="post" id="form" enctype="multipart/form-data"> |
|||
<input type="hidden" name='form_name' value="main_form" /> |
|||
<div> |
|||
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%"> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>合約書申請(新梯)</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1"> |
|||
<tr> |
|||
<td colspan="7" style='vertical-align: middle;border-right:0px;'> |
|||
<h4>業務確認項</h4> |
|||
</td> |
|||
<td class="text-right" style='border-left:0px;'> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button> |
|||
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">卷號</td> |
|||
<td> |
|||
<div class="fixed" x-text="data.vol_no"></div> |
|||
<!-- <input class="form-control disabled_select" type="text" x-model="data.vol_no" > --> |
|||
<!-- <p class="alerttext" x-show="data.vol_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> --> |
|||
</td> |
|||
<td style="vertical-align: middle">統一編號</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="text" x-model="data.vat"> |
|||
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">合約書申請日期</td> |
|||
<td> |
|||
<input class="form-control disabled_select" type="date" x-model="data.apply_date"> |
|||
<p class="alerttext" x-show="data.apply_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">申請類別</td> |
|||
<td style="vertical-align: middle"> |
|||
<select class="" id="apply_type" x-model="data.apply_type"> |
|||
<option value="A">制式新合約</option> |
|||
</select> |
|||
<p class="alerttext" x-show="data.apply_type==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">案件名稱</td> |
|||
<td style="vertical-align: middle" colspan="3"> |
|||
<input class="form-control disabled_select" type="text" x-model="data.case_name"> |
|||
<p class="alerttext" x-show="data.case_name==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">立約人</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select" type="text" x-model="data.company"> |
|||
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">負責人</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select" type="text" x-model="data.manager"> |
|||
<p class="alerttext" x-show="data.manager==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">含稅給約總價</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.total_price"> |
|||
<p class="alerttext" x-show="data.total_price==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">含稅貸款(A)</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.price_a"> |
|||
<p class="alerttext" x-show="data.price_a==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">含稅安裝款(A)</td> |
|||
<td style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="data.price_b"> |
|||
<p class="alerttext" x-show="data.price_b==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">聯絡地址</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<input class="form-control disabled_select" type="text" x-model="data.address"> |
|||
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">完工期限</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
貨抵工地 |
|||
</div> |
|||
<input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a"> |
|||
<div class="ui label"> |
|||
天內安裝完成,甲方應於貨底工地前 |
|||
</div> |
|||
<input type="text" placeholder="7" style="width:45px;padding:0 12px;" x-model="data.workdeadline_b"> |
|||
<div class="ui label"> |
|||
天完成並整理完善。 |
|||
</div> |
|||
</div> |
|||
<!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > --> |
|||
<p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">附則</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
乙方應於 |
|||
</div> |
|||
<input type="text" placeholder="10" style="width:45px;padding:0 12px;" x-model="data.regulations"> |
|||
<div class="ui label"> |
|||
天內試車完成 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.regulations==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">免保期限</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<input type="text" placeholder="18" style="width:45px;padding:0 12px;" x-model="data.freedeadline"> |
|||
<div class="ui label"> |
|||
個月 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.freedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
|
|||
</tr> |
|||
<tr> |
|||
<td style="vertical-align: middle">交貨地點</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<input class="form-control disabled_select" type="text" x-model="data.tradeaddress"> |
|||
<p class="alerttext" x-show="data.tradeaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle">交貨期限</td> |
|||
<td style="vertical-align: middle" colspan=3> |
|||
<div class="ui labeled input"> |
|||
<div class="ui label"> |
|||
圖色確認第 |
|||
</div> |
|||
<input type="text" placeholder="90" style="width:45px;padding:0 12px;" x-model="data.tradedeadline"> |
|||
<div class="ui label"> |
|||
天出貨 |
|||
</div> |
|||
</div> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</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> |
|||
<td colspan="1"> |
|||
<p style='text-align:center'>項次</p> |
|||
</td> |
|||
<td colspan="3"> |
|||
<p style='text-align:center'>規格</p> |
|||
</td> |
|||
<td colspan="1"> |
|||
<p style='text-align:center'>數量</p> |
|||
</td> |
|||
<td colspan="3"> |
|||
<p style='text-align:center'>金額</p> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<template x-for="(item, idx) in data.items"> |
|||
<tr> |
|||
<td style="vertical-align: middle"> |
|||
<p x-text="idx+1"></p> |
|||
</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="text" x-model="item.item_spec"> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td style="vertical-align: middle"> |
|||
<span x-text="item.item_qty + '台'" style="padding:0 20px"></span> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
<td colspan="3" style="vertical-align: middle"> |
|||
<input class="form-control disabled_select lock" type="number" x-model="item.item_price_ct"> |
|||
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
</template> |
|||
<tr> |
|||
<td colspan=4></td> |
|||
<td>電梯總數</td> |
|||
<td colspan='3'> <span x-text="data.total_items + '台'" style="padding:0 20px"></span></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> |
|||
<td> |
|||
<p style='text-align:center'>合約類別</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>款別</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>條件名稱</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>收款條件日期區分</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>條件日期</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>票期</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>付款比率</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'>金額</p> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody style="font-weight: bolder;margin-bottom: 20px"> |
|||
<?php |
|||
$day = 0; |
|||
$styles = [ |
|||
1 => "訂金", |
|||
2 => "二次款", |
|||
3 => "貨到款", |
|||
4 => "", |
|||
5 => "安裝款", |
|||
6 => "尾款", |
|||
7 => "", |
|||
]; |
|||
$paydate = [ |
|||
1 => "合約日", |
|||
2 => "合約日", |
|||
3 => "出貨日", |
|||
4 => "", |
|||
5 => "竣檢日", |
|||
6 => "交車日", |
|||
7 => "" |
|||
]; |
|||
?> |
|||
<?php foreach ($pays as $pay) : |
|||
if ($pay['pay_scale'] == 0) continue; |
|||
?> |
|||
<tr> |
|||
<td> |
|||
<p style='text-align:center'><?php echo ($pay['pay_kind'] <= 4) ? "銷售" : "按裝"; ?></p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'><?php echo $styles[$pay['pay_kind']]; ?></p> |
|||
</td> |
|||
<td> |
|||
<?php if ($pay['pay_kind'] == 1) { ?> |
|||
<template x-if="pays[1] > 0"> |
|||
<p style='text-align:center'>簽約後<span x-text="pays[1]"></span>天付訂金</p> |
|||
</template> |
|||
<template x-if="pays[1] <= 0"> |
|||
<p style='text-align:center'>簽約後付訂金</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 2) { ?> |
|||
<template x-if="pays[2] > 0"> |
|||
<p style='text-align:center'>簽約後<span x-text="pays[2]"></span>天付二次款</p> |
|||
</template> |
|||
<template x-if="pays[2] <= 0"> |
|||
<p style='text-align:center'>簽約後付二次款</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 3) { ?> |
|||
<p style='text-align:center'>貨抵工地付貨到款</p> |
|||
<?php } elseif ($pay['pay_kind'] == 5) { ?> |
|||
<template x-if="pays[5] > 0"> |
|||
<p style='text-align:center'>安裝完成後<span x-text="pays[5]"></span>天收款</p> |
|||
</template> |
|||
<template x-if="pays[5] <= 0"> |
|||
<p style='text-align:center'>安裝完成後收款</p> |
|||
</template> |
|||
<?php } elseif ($pay['pay_kind'] == 6) { ?> |
|||
<template x-if="pays[6] > 0"> |
|||
<p style='text-align:center'>交車後<span x-text="pays[6]"></span>天付尾款</p> |
|||
</template> |
|||
<template x-if="pays[6] <= 0"> |
|||
<p style='text-align:center'>交車後付尾款</p> |
|||
</template> |
|||
<?php } else { ?> |
|||
<p style='text-align:center'>-</p> |
|||
<?php } ?> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center'><?php echo $paydate[$pay['pay_kind']]; ?></p> |
|||
</td> |
|||
<td> |
|||
<div class="ui labeled input"> |
|||
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].condition_date"> |
|||
<div class="ui label"> |
|||
天 |
|||
</div> |
|||
</div> |
|||
</td> |
|||
<td> |
|||
<div class="ui labeled input"> |
|||
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind']; ?>].pay_period"> |
|||
<div class="ui label"> |
|||
天 |
|||
</div> |
|||
</div> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center' x-text="pays[<?php echo $pay['pay_kind']; ?>].scale + '%'"><?php echo $pay['pay_scale'] ?>%</p> |
|||
</td> |
|||
<td> |
|||
<p style='text-align:center' x-text="localnumber(data.total_price * pays[<?php echo $pay['pay_kind']; ?>].scale/100)"></p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
<template x-if="pays[2].pay_period > 0"> |
|||
<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" /> |
|||
<p class="alerttext" x-show="data.secondPayDeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</template> |
|||
<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> |
|||
<td colspan=8> |
|||
<h4 style='text-align:center;font-weight: bolder'>附件上傳</h4> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
|
|||
<tbody> |
|||
<tr> |
|||
<td colspan="4">附件上傳</td> |
|||
<td colspan="4"> |
|||
<?php if ($status < 1) : ?> |
|||
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> |
|||
<?php endif; ?> |
|||
<?php foreach ($files as $file) : ?> |
|||
<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; ?> |
|||
</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> |
|||
<td colspan=8> |
|||
<h4 style='text-align:center;font-weight: bolder'>簽核流程</h4> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<td>審核</td> |
|||
<td>審核人</td> |
|||
<td>結果</td> |
|||
<td colspan=2>意見</td> |
|||
<td>時間</td> |
|||
<td colspan=2><?php if ($user_id === "M0174" && $status == 1) : ?>審核意見<?php endif; ?></td> |
|||
</tr> |
|||
<tr> |
|||
<td>營業員</td> |
|||
<td><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td> |
|||
<td> |
|||
<?php if ($status >= 1) : ?><span class="successtext">已送審</span><?php endif; ?> |
|||
<?php if ($status == 0) : ?><span class="readtext">暫存</span><?php endif; ?> |
|||
<?php if ($status == -1) : ?><span class="">未提交</span><?php endif; ?> |
|||
</td> |
|||
<td colspan=2>---</td> |
|||
<td><?php echo ($contract['submit_date']) ?? "---"; ?> </td> |
|||
<td colspan=2 rowspan="2"> |
|||
<?php if ($user_id === "M0174" && $status == 1) : ?> |
|||
<textarea class="form-control opinion" x-model="data.review_comment"></textarea> |
|||
<?php endif; ?> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>業務承辦人</td> |
|||
<td><span><?php echo (isset($contract['review_person_name']) || empty($contract['review_person_name'])) ? "---" : $contract['review_person_name'] . "(" . $contract['review_person_id'] . ")"; ?></span></td> |
|||
<td> |
|||
<?php if ($status == 3) : ?><span class="successtext">結案同意</span><?php endif; ?> |
|||
<?php if ($status == 2) : ?><span class="failtext">結案不同意</span><?php endif; ?> |
|||
<?php if ($status < 2) : ?><span>---</span><?php endif; ?> |
|||
</td> |
|||
<td colspan=2><?php echo $contract['review_comment'] ?? "---"; ?></td> |
|||
<td><?php echo $contract['review_date'] ?? "---"; ?></td> |
|||
</tr> |
|||
<!-- <tr> |
|||
<td colspan="2" style="font-weight:bold">業務部承辦人</td> |
|||
<td colspan="2"> |
|||
<template x-if="false"> |
|||
<span class="failtext">已退件</span> |
|||
</template> |
|||
<?php if ($status == 1) : ?> |
|||
<span class="readtext">審核中...</span> |
|||
<?php endif; ?> |
|||
<template x-if="false"> |
|||
<span class="successtext">已通過</span> |
|||
</template> |
|||
</td> |
|||
<td colspan="2" style="font-weight:bold">營業員</td> |
|||
<td colspan="2"><span x-text="data.salesmanname + '(' + data.salesman + ')'"></span></td> |
|||
</tr> --> |
|||
</tbody> |
|||
</table> |
|||
<button @click="window.history.go(-1)" type="button" class="btn btn-primary btn-lg pull-right savebtn">回前頁</button> |
|||
<?php if (($isFirst == 1 && ($person == $user_id || $user_id == "M0174")) || ($isFirst == 0 && $status == 0 && ($person == $user_id || $user_id == "M0174"))) : ?> |
|||
<button x-show="true" x-on:click="submit()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>送審</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="true" x-on:click="storageFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>暫存</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<?php endif; ?> |
|||
<?php if ($status == 1 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0174")) : ?> |
|||
<button x-show="true" x-on:click="agree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>同意(結案)</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<button x-show="true" x-on:click="disagree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn"> |
|||
<template x-if="!isLoading"> |
|||
<span>不同意(退回)</span> |
|||
</template> |
|||
<template x-if="isLoading"> |
|||
<div class="loader"></div> |
|||
</template> |
|||
</button> |
|||
<?php endif; ?> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<script src="./js/jquery/jquery-3.1.1.min.js"></script> |
|||
<script src="semantic/dist/semantic.min.js"></script> |
|||
<script src="./js/alpine.js"></script> |
|||
<script> |
|||
window.onload = () => { |
|||
const lock = document.getElementsByClassName('lock'); |
|||
for (let i = 0; i < lock.length; i++) { |
|||
lock[i].disabled = true |
|||
} |
|||
} |
|||
</script> |
|||
<?php if (empty($contract_new_apply)) : ?> |
|||
<script> |
|||
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; |
|||
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; |
|||
const salesmanname = '<?php echo $contract['accountname'] ?? ''; ?>'; |
|||
const apply_date = '<?php echo date('Y-m-d') ?>'; |
|||
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; |
|||
const company = '<?php echo $contract['company'] ?? ''; ?>'; |
|||
const manager = '<?php echo $customer['manager'] ?? ''; ?>'; |
|||
const vat = '<?php echo $customer['uscc'] ?? ''; ?>'; |
|||
const price_total = <?php echo $contract['price_total'] ?? ''; ?>; |
|||
const address = '<?php echo $contract['address'] ?? ''; ?>'; |
|||
const price_a = <?php echo $price_a ?? ''; ?>; |
|||
const price_b = <?php echo $price_b ?? ''; ?>; |
|||
const items = [...<?php echo json_encode($items) ?? []; ?>]; |
|||
const user_id = '<?php echo $user_id ?>'; |
|||
const mid = '<?php echo $_GET['id']; ?>'; |
|||
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; |
|||
const secondPayDeadline = ''; |
|||
const tradeaddress = '<?php echo $contract['address'] ?? ''; ?>'; |
|||
const tradedeadline = 90 |
|||
const freedeadline = 18; |
|||
const regulations = 10; |
|||
const workdeadline_a = 60; |
|||
const workdeadline_b = 7; |
|||
const total_items = <?php echo $total_items ?? ''; ?>; |
|||
const isFirst = <?php echo $isFirst; ?>; |
|||
</script> |
|||
<?php else : ?> |
|||
<script> |
|||
const contractno = '<?php echo $contract['contractno'] ?? ''; ?>'; |
|||
const salesman = '<?php echo $contract['person'] ?? ''; ?>'; |
|||
const salesmanname = '<?php echo $contract['personname'] ?? ''; ?>'; |
|||
const apply_date = '<?php echo date('Y-m-d') ?>'; |
|||
const case_name = '<?php echo $contract['case_name'] ?? ''; ?>'; |
|||
const company = '<?php echo $contract['customer'] ?? ''; ?>'; |
|||
const manager = '<?php echo $contract['manager'] ?? ''; ?>'; |
|||
const vat = '<?php echo $contract['vat'] ?? ''; ?>'; |
|||
const price_total = <?php echo $contract['total_price'] ?? ''; ?>; |
|||
const address = '<?php echo $contract['contact_address'] ?? ''; ?>'; |
|||
const price_a = <?php echo $contract['buy_fee'] ?? ''; ?>; |
|||
const price_b = <?php echo $contract['install_fee'] ?? ''; ?>; |
|||
const items = [...<?php echo json_encode($items) ?? []; ?>]; |
|||
const user_id = '<?php echo $user_id ?? ''; ?>'; |
|||
const mid = '<?php echo $_GET['id']; ?>'; |
|||
const pays = [...<?php echo json_encode($pays) ?? []; ?>]; |
|||
const isFirst = <?php echo $isFirst; ?>; |
|||
const tradeaddress = '<?php echo $contract['trade_address'] ?? ''; ?>'; |
|||
const tradedeadline = '<?php echo $contract['tradedeadline'] ?? ''; ?>'; |
|||
const freedeadline = '<?php echo $contract['freedeadline'] ?? ''; ?>'; |
|||
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 $secondPayDeadline ?? ''; ?>; |
|||
const total_items = <?php echo $contract['total_items'] ?? ''; ?>; |
|||
const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>; |
|||
</script> |
|||
|
|||
|
|||
<?php endif; ?> |
|||
<?php if ($status > 0 || ($person != $user_id && $user_id != "M0174")) : ?> |
|||
<script> |
|||
window.onload = () => { |
|||
const input = document.querySelectorAll('input'); |
|||
const alerttext = document.querySelectorAll('p.alerttext'); |
|||
const select = document.querySelectorAll('select'); |
|||
for (let i = 0; i < input.length; i++) { |
|||
input[i].disabled = true |
|||
} |
|||
for (let i = 0; i < select.length; i++) { |
|||
select[i].disabled = true |
|||
} |
|||
for (let i = 0; i < alerttext.length; i++) { |
|||
alerttext[i].style.display = "none" |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<?php endif; ?> |
Loading…
Reference in new issue