Browse Source

給子成合併

main
10994015 1 year ago
parent
commit
3f7479106a
  1. 2
      wms/contract-repair/insertFacility.php
  2. 8
      wms/contract/contract-download.php
  3. 114
      wms/contract/contract-maintainance-management.php
  4. 18
      wms/contract/contract-new-apply.php
  5. 1
      wms/contract/js/alpine.js
  6. BIN
      wms/contract/option/facility.xlsx
  7. 5
      wms/contract/prviewPdf.php
  8. 2
      wms/contract/restoremi.php
  9. 20
      wms/database.php
  10. 8
      wms/fun_global.php
  11. 1
      wms/mkt/assets/js/alpine.js
  12. 29
      wms/mkt/pricereview-index.php
  13. 90
      wms/mkt/pricereview_mi-api.php

2
wms/contract-repair/insertFacility.php

@ -5,7 +5,7 @@ ini_set('data.timezone', 'Asia/Taipei');
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
$filePath = './facility/facility.xlsx'; // $filePath = './facility/facility.xlsx';
try { try {
$spreadsheet = IOFactory::load($filePath); $spreadsheet = IOFactory::load($filePath);

8
wms/contract/contract-download.php

@ -24,6 +24,7 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
$stmt->bindParam(':id', $id); $stmt->bindParam(':id', $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']; $contract_apply_id = $contract['id'];
if (($contract['status'] !== "YY" && $user_id != 'M0107' && $user_id != "TEST02" && $user_id == "TEST01") && $user_id != 'M0174' && $user_id != 'M0225') { if (($contract['status'] !== "YY" && $user_id != 'M0107' && $user_id != "TEST02" && $user_id == "TEST01") && $user_id != 'M0174' && $user_id != 'M0225') {
@ -52,7 +53,8 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
$install_total_price = 0; $install_total_price = 0;
// $noteArr = explode(",", $contracts[0]['note']); // $noteArr = explode(",", $contracts[0]['note']);
$noteArr = array(1, 1, 1, 1, 1); $noteArr = array(1, 1, 1, 1, 1);
$qty = $contracts[0]['total_items']; // $qty = $contracts[0]['total_items'];
$qty = 1;
foreach ($contracts as $idx => $amount) { foreach ($contracts as $idx => $amount) {
$isset = false; $isset = false;
if ($amount['pay_kind'] == 5 || $amount['pay_kind'] == 6) { if ($amount['pay_kind'] == 5 || $amount['pay_kind'] == 6) {
@ -413,8 +415,8 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
<input type="hidden" name="buystandard" x-model="toggleBuyStandard" /> <input type="hidden" name="buystandard" x-model="toggleBuyStandard" />
<input type="hidden" name="installstandard" x-model="toggleInstallStandard" /> <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="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="person" id="person" value="<?php echo $contract['personname']; ?>" />
<input type="hidden" name="personid" id="personid" value="<?php echo $contract['accountid']; ?>" /> <input type="hidden" name="personid" id="personid" value="<?php echo $contract['person']; ?>" />
<input type="hidden" name="delivery_term" id="delivery_term" x-model="buyfill1" /> <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="install_period" id="install_period" x-model="installfill1" />
<input type="hidden" name="free_maintainance" id="free_maintainance" x-model="installfill2" /> <input type="hidden" name="free_maintainance" id="free_maintainance" x-model="installfill2" />

114
wms/contract/contract-maintainance-management.php

@ -0,0 +1,114 @@
<?php
include("../header.php");
require_once("./conn.php");
$sql_str = "SELECT * FROM contract_b_signed_back ";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$contracts= $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<link rel="stylesheet" href="./styles/style.css">
<link rel="stylesheet" href="semantic/dist/semantic.min.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" />
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js"></script>
<div style="overflow-x:auto;margin-top:12px">
<a href="contract-newelevator-input.php?function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>合約號</th>
<th>客戶名稱</th>
<th>統編</th>
<th>營業員</th>
<th>合約開始時間</th>
<th>合約終止時間</th>
<th>狀態</th>
<th>建檔者</th>
<th>建立時間</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($contracts as $contract): ?>
<tr>
<td><?php echo $contract['id']; ?></td>
<td><?php echo $contract['contract_no'] ?></td>
<td><?php echo $contract['company'] ?></td>
<td><?php echo $contract['customer_no'] ?></td>
<td><?php echo $contract['salesperson'] ?></td>
<td><?php echo $contract['contract_start_date'] ?></td>
<td><?php echo $contract['contract_end_date'] ?></td>
<td>
<?php
$endDate = new DateTime($contract['contract_end_date']);
$now = new DateTime();
$interval = $now->diff($endDate);
if ($interval->days <= 60) {
echo "60天以內。";
} else {
echo "指定日期與當前日期相差超過60天。";
}
?>
</td>
<td><?php echo $contract['created_by'] ?></td>
<td><?php echo $contract['created_at'] ?></td>
<td style="width:30px">
<p>
<a href="contract-newelevator-edit.php?contractid=<?php echo $contract['id']; ?>&function_name=repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a href="javascript:;" class="btn btn-info btn-sm" style="margin-left:10px;" @click="deleteFn(<?php echo $contract['id']; ?>)">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
width:125px;
}
.width_style_1 {
width:125px;
}
table{
width:100%;
}
#table_index_filter{
float:right;
}
#table_index_paginate{
float:right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>

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

@ -97,13 +97,14 @@ if (empty($contract_new_apply)) {
$stmt->bindParam(':contract_id', $id); $stmt->bindParam(':contract_id', $id);
$stmt->execute(); $stmt->execute();
$files = $stmt->fetchAll(PDO::FETCH_ASSOC); $files = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($files); // print_r($files);
} }
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0; $secondPayDeadline = $contract['secondPayDeadline'] ?? 0;
$status = isset($contract['status']) ? $contract['status'] : -1; $status = isset($contract['status']) ? $contract['status'] : -1;
$progress = isset($contract['progress']) ? $contract['progress'] : 0; $progress = isset($contract['progress']) ? $contract['progress'] : 0;
$person = $contract['person']; $person = $contract['person'];
$para = "function_name=pricereview&" . $token_link;
?> ?>
<link rel="stylesheet" href="./styles/style.css"> <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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
@ -129,7 +130,8 @@ $person = $contract['person'];
</td> </td>
<td class="text-right" style='border-left:0px;'> <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.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button> <button type="button" id="btn_close" class="btn btn-success" onclick="donwloadDraft()">下載草搞</button>
<!-- <a class="applybtn" href="./contract-download.php?id=<?php echo $id . '&' . $para ?>">下載草稿</a> -->
</td> </td>
</tr> </tr>
<tr> <tr>
@ -702,4 +704,14 @@ $person = $contract['person'];
} }
</script> </script>
<?php endif; ?> <?php endif; ?>
<script>
const donwloadDraft = () => {
if('<?php echo $status ?>' >=0 ){
window.location.href='./contract-download.php?id=<?php echo $id . '&' . $para ?>'
}else{
alert("請先暫存或送審文件!")
}
}
</script>

1
wms/contract/js/alpine.js

@ -1381,6 +1381,7 @@ const contractNewApply = () => {
form.append('status', 1); form.append('status', 1);
form.append('review_comment', this.data.review_comment); form.append('review_comment', this.data.review_comment);
form.append('description', this.data.description); form.append('description', this.data.description);
form.append('progress', 0);
for (var i = 0; i < this.data.files.length; i++) { for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]); form.append('files[]', this.data.files[i]);
} }

BIN
wms/contract/option/facility.xlsx

Binary file not shown.

5
wms/contract/prviewPdf.php

@ -19,6 +19,7 @@ if($_POST['list']){
$total_price = $_POST['total_price']; $total_price = $_POST['total_price'];
$person = $_POST['person']; $person = $_POST['person'];
$personid = $_POST['personid']; $personid = $_POST['personid'];
echo "----->" . $personid;
$delivery_term = $_POST['delivery_term']; $delivery_term = $_POST['delivery_term'];
$install_period = $_POST['install_period']; $install_period = $_POST['install_period'];
$free_maintainance = $_POST['free_maintainance']; $free_maintainance = $_POST['free_maintainance'];
@ -45,6 +46,10 @@ if($_POST['list']){
$stmt->bindParam(':vol_no', $partyAcontractno); $stmt->bindParam(':vol_no', $partyAcontractno);
$stmt->execute(); $stmt->execute();
$customer = $stmt->fetch(PDO::FETCH_ASSOC); $customer = $stmt->fetch(PDO::FETCH_ASSOC);
if(empty($customer)){
echo "有望客戶資料有誤!";
exit;
}
if(count($customer) <= 0 ){ if(count($customer) <= 0 ){
echo "<script> echo "<script>
alert('資料不齊或合約書已生成過。'); alert('資料不齊或合約書已生成過。');

2
wms/contract/restoremi.php

@ -9,7 +9,7 @@ $id = $_GET['id'];
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
if($id == 999){ if($id == 999){
$filePath = './option/f1.xlsx'; $filePath = './option/facility.xlsx';
try { try {
$spreadsheet = IOFactory::load($filePath); $spreadsheet = IOFactory::load($filePath);
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) { } catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {

20
wms/database.php

@ -19,21 +19,21 @@ $host = getenv('DB_HOST');
$dbuser = getenv('DB_USERNAME'); $dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD'); $dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE'); $dbname = getenv('DB_DATABASE');
$link = mysqli_connect($host, $dbuser, $dbpassword, $dbname); // $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname);
$sqlsrv = getenv('sqlsrv'); $sqlsrv = getenv('sqlsrv');
$Database = getenv('Database'); $Database = getenv('Database');
$Account = getenv('Account'); $Account = getenv('Account');
$Password = getenv('Password'); $Password = getenv('Password');
try { // try {
$conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password"); // $conn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", "$Account", "$Password");
if ($conn) { // if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} // }
} catch (PDOException $e) { // } catch (PDOException $e) {
echo "fail"; // echo "fail";
echo $e->getMessage(); // echo $e->getMessage();
} // }
if ($link) { if ($link) {
mysqli_query($link, 'SET NAMES utf8'); mysqli_query($link, 'SET NAMES utf8');
// echo "正確連接資料庫"; // echo "正確連接資料庫";

8
wms/fun_global.php

@ -102,7 +102,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0)
// 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。 // 若為第一層且使用者ID為區經理,直接訂好接下來的簽核人員並跳出。
if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) { if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) {
$ret[1] = $user_id . ",,"; $ret[1] = $user_id . ",,";
$ret[2] = "M0175,,<##>M0107,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理 $ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) { if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理 $ret[4] = "M0006,,"; // 總經理
@ -123,7 +123,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee, $i = 0)
} }
} else { } else {
$ret[2] = "M0175,,<##>M0107,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人) $ret[2] = "M0107,,<##>M0175,,"; // 業務部專員:M0175陳君敏、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理 $ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) { if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理 $ret[4] = "M0006,,"; // 總經理
@ -158,7 +158,7 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
} }
} }
// $ret[1] = "M0029"; // $ret[1] = "M0029";
mysqli_free_result($res);
$ret[2] = 'M0012'; $ret[2] = 'M0012';
if ($renovate_flag == "REN") { if ($renovate_flag == "REN") {
// $ret[2] = 'M0012'; // $ret[2] = 'M0012';
@ -169,7 +169,7 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
if ($rate <= 100) $ret[3] = "M0008"; // 詹總 if ($rate <= 100) $ret[3] = "M0008"; // 詹總
if ($rate < 80) $ret[4] = "M0006"; // 總經理 if ($rate < 80) $ret[4] = "M0006"; // 總經理
} }
mysqli_free_result($res);
return $ret; return $ret;
} }

1
wms/mkt/assets/js/alpine.js

@ -297,6 +297,7 @@ const pricereviewOptionSelect = () => {
this.options = this.orioptions this.options = this.orioptions
this.reloadOptions(); this.reloadOptions();
let val = (e== null) ? this.searchtext.toLowerCase() : e.target.value.toLowerCase() let val = (e== null) ? this.searchtext.toLowerCase() : e.target.value.toLowerCase()
console.log(val);
this.options.forEach(option=>{ this.options.forEach(option=>{
if(option.group_name == null) option.group_name = '' if(option.group_name == null) option.group_name = ''
if(option.spec == null) option.spec = '' if(option.spec == null) option.spec = ''

29
wms/mkt/pricereview-index.php

@ -125,6 +125,14 @@ if (!empty($res_get) || (!empty($_GET['check']) && $_GET['check'] == 1)) {
// echo $sql; // echo $sql;
} }
if($user_id === "M0137"){
$sql = "SELECT pricereview_main.*,contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress
FROM pricereview_main
left join contract_new_apply on contract_new_apply.mid = pricereview_main.id
JOIN account ON account.accountid = pricereview_main.creater
WHERE (account.manager = 'M0029' OR account.manager='M0137') AND pricereview_main.status <> 'D' AND pricereview_main.ekind = '新梯' order by pricereview_main.id";
}
$data = mysqli_query($link, $sql); $data = mysqli_query($link, $sql);
// 若結案不同意 // 若結案不同意
@ -323,9 +331,11 @@ function get_pending($token)
} }
$result = get_pending($token); $result = get_pending($token);
print_r($result); // print_r($result);
$result[1]['sid'] = !empty($result) ? $result[1]['sid'] : 'prm'; if(count($result) > 0){
$result[1]['fid'] = !empty($result) ? $result[1]['fid'] : 'prm01'; $result[1]['sid'] = !empty($result) ? $result[1]['sid'] : 'prm';
$result[1]['fid'] = !empty($result) ? $result[1]['fid'] : 'prm01';
}
if ($data) : if ($data) :
/* /*
@ -348,9 +358,13 @@ if ($data) :
</style> </style>
<link rel="stylesheet" href="common.css"> <link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;"> <div style="overflow-x:auto; white-space:nowrap;">
<?php if($user_id=== "M0060" || $user_id==="M0107" || $user_id==="M0175" || $user_id==="M0174" || $user_id==="M0225"){ ?> <?php if(($user_id=== "M0060" || $user_id==="M0107" || $user_id==="M0175" || $user_id==="M0174" || $user_id==="M0225")){ ?>
<a href="/wms/mkt/pricereview-index.php?&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['system_id']) && !isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有價審</a> <a href="/wms/mkt/pricereview-index.php?&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (!isset($_GET['system_id']) && !isset($_GET['check'])) ? "btn btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 所有價審</a>
<?php if(count($result) > 0): ?>
<a href="/wms/mkt/pricereview-index.php?system_id=<?= $result[1]['sid'] ?>&flow_id=<?= $result[1]['fid'] ?>&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a> <a href="/wms/mkt/pricereview-index.php?system_id=<?= $result[1]['sid'] ?>&flow_id=<?= $result[1]['fid'] ?>&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a>
<?php else: ?>
<a href="javascript:;" onclick="alert('無待簽資料')" class=" btn <?php echo (isset($_GET['system_id'])) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 待我簽核</a>
<?php endif ;?>
<a href="/wms/mkt/pricereview-index.php?check=1&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 簽核完畢</a> <a href="/wms/mkt/pricereview-index.php?check=1&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 1) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 簽核完畢</a>
<a href="/wms/mkt/pricereview-index.php?check=2&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案同意</a> <a href="/wms/mkt/pricereview-index.php?check=2&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 2) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案同意</a>
<a href="/wms/mkt/pricereview-index.php?check=3&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案不同意</a> <a href="/wms/mkt/pricereview-index.php?check=3&function_name=pricereview&token=<?php echo $token; ?>" class=" btn <?php echo (isset($_GET['check']) && $_GET['check'] == 3) ? "btn-primary" : "btn-secondary"; ?> btn-sm categoryBtn"> 結案不同意</a>
@ -698,13 +712,15 @@ if ($data) :
<?php if (($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3) : ?> <?php if (($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3) : ?>
<span style="font-size:13px;font-weight:600">待申請</span> <span style="font-size:13px;font-weight:600">待申請</span>
<?php elseif ($data['applystatus'] < 3) : ?> <?php elseif ($data['applystatus'] < 3) : ?>
<a class="applybtn" target="_blank" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>"> <a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<?php if ($data['applystatus'] < 1) { <?php if ($data['applystatus'] < 1) {
echo "申請"; echo "申請";
} else { } else {
echo "檢視"; echo "檢視";
} ?> } ?>
</a><br> </a><br>
<?php else : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">審請已通過</a><br>
<?php endif; ?> <?php endif; ?>
<?php else : ?> <?php else : ?>
@ -720,9 +736,6 @@ if ($data) :
<?php if (false && ($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?> <?php if (false && ($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a> <a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a>
<?php endif; ?> <?php endif; ?>
<?php if ($data['status'] === 'YY') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載草稿</a>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

90
wms/mkt/pricereview_mi-api.php

@ -167,6 +167,7 @@ try {
$ex_fee += $exarr[$j][1]; $ex_fee += $exarr[$j][1];
$j++; $j++;
} }
// print_r($exarr);
mysqli_free_result($res); mysqli_free_result($res);
// 拆梯&美容平均分到每台電梯 // 拆梯&美容平均分到每台電梯
@ -326,14 +327,14 @@ try {
LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id
LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no
WHERE option_price.status = 'Y' "; WHERE option_price.status = 'Y' ";
$sql4 = "SELECT option_price.id, elevator_quotation_rule.equipment, option_mi.base_floor, option_mi.quotation_no, option_mi.base_floor_plus, option_mi.price, option_price.price as OP //新的SQL
FROM option_price $sql4 = "SELECT option_price.id, elevator_quotation_rule.equipment, option_mi.base_floor, option_mi.quotation_no, option_mi.base_floor_plus, option_mi.price, option_price.price as OP
LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id FROM option_price
LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no LEFT JOIN option_mi ON option_price.id = option_mi.option_price_id
WHERE option_mi.option_price_id = " . $opt_elev_arr[$val]["price_id"] . " LEFT JOIN elevator_quotation_rule ON option_mi.quotation_no = elevator_quotation_rule.quotation_no
AND (" . $v["item_weight"] . " BETWEEN option_mi.min_weight AND option_mi.max_weight) WHERE option_mi.option_price_id = " . $opt_elev_arr[$val]["price_id"] . "
AND option_mi.open_kind = '" . $v["item_op"] . "'"; AND (" . $v["item_weight"] . " BETWEEN option_mi.min_weight AND option_mi.max_weight)
AND option_mi.open_kind = '" . $v["item_op"] . "'";
$res_om = mysqli_query($link, $sql4); $res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) { if ($row_om = mysqli_fetch_assoc($res_om)) {
@ -449,6 +450,79 @@ AND option_mi.open_kind = '" . $v["item_op"] . "'";
} }
$rarr["content"] = $mi_arr; $rarr["content"] = $mi_arr;
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'E'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT pricereview_item.*,option_mi.price as option_mi FROM pricereview_item LEFT JOIN option_mi ON pricereview_item.price_id = option_mi.option_price_id WHERE pricereview_item.mid = :mid AND pricereview_item.item_group = 'B'";
$sql_str = "SELECT
pricereview_item.*,
(SELECT option_mi.price
FROM option_mi
WHERE pricereview_item.price_id = option_mi.option_price_id
ORDER BY option_mi.id ASC LIMIT 1) AS option_mi
FROM
pricereview_item
WHERE
pricereview_item.mid = :mid
AND pricereview_item.item_group = 'B'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$itemoptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
$exceptArr = [];
foreach($items as $item){
if($item['option_relate_spec'] != NULL){
$exceptArr[] = [
'option_relate_spec'=> $item['option_relate_spec'],
'item_spec'=>$item['item_spec'],
'item_unit_price'=>$item['item_unit_price'],
'item_qty'=>$item['item_qty'],
'item_price_bp'=> $item['item_price_bp'],
];
}
}
// $rarr["content"][] = $exceptArr;
foreach($rarr["content"] as $idx=>&$item){
$newTotal = 0;
$item[16] = [];
$item[14] = [];
foreach($exceptArr as $except){
if($idx+1 == $except['option_relate_spec']){
$item[16][] = [
$except['item_spec'],
$except['item_unit_price']* $except['item_qty']
];
}
}
foreach($itemoptions as $itemoption){
if($idx+1 == $itemoption['option_relate_spec']){
$item[14][] = [
$itemoption['item_spec'],
round($itemoption['option_mi'] * $itemoption['item_qty'], 0),
];
}
}
foreach($item[14] as $option){
$newTotal += $option[1];
}
foreach($item[16] as $ex){
$newTotal += $ex[1];
}
$newTotal += $item[17];
$newTotal += $item[19][1];
$item[13] = $newTotal;
}
} catch (\Exception $e) { } catch (\Exception $e) {
$rarr['st'] = 'err'; $rarr['st'] = 'err';
$rarr['err'] = $e->getMessage(); $rarr['err'] = $e->getMessage();

Loading…
Cancel
Save