24 changed files with 5776 additions and 4224 deletions
@ -1,140 +1,143 @@ |
|||
<?php |
|||
include "header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
require_once "database.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from contractapply_main order by id"; |
|||
$data = mysqli_query($link,$sql); |
|||
$apply_type_arr = ["A" => "制式新合約", "B" => "非制式新合約"]; |
|||
$status_arr = ["I" => "申請中", "P" => "在途中", "Y" => "已完成", "X" => "作廢"]; |
|||
?> |
|||
<p> |
|||
<a href="contractapply-create.php" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if($data): |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>含稅貨款</th> |
|||
<th>含稅按裝款</th> |
|||
<th>含稅給約總價</th> |
|||
<th>二次款</th> |
|||
<!--<th>交貨期限</th> |
|||
<th>完工期限</th>--> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach($data as $data) : |
|||
switch ($data["status"]) { |
|||
case "I": |
|||
$status_dt = $data["status_1_dt"]; |
|||
break; |
|||
case "P": |
|||
$status_dt = $data["status_2_dt"]; |
|||
break; |
|||
case "Y": |
|||
$status_dt = $data["status_3_dt"]; |
|||
break; |
|||
case "X": |
|||
$status_dt = $data["status_4_dt"]; |
|||
break; |
|||
} |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['apply_no1'].$data['apply_no2']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['apply_number']; ?></td> |
|||
<td><?php echo $data['apply_date']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $apply_type_arr[$data['apply_type']]; ?></td> |
|||
<td> |
|||
<?php echo $status_arr[$data['status']]; ?> |
|||
<p> |
|||
<a href="contractapply-edit.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td><?php echo $status_dt; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['pay']); ?></td> |
|||
<td><?php echo number_format($data['pay_install']); ?></td> |
|||
<td><?php echo number_format($data['pay_total']); ?></td> |
|||
<td><?php echo $data['pay_second']; ?>天</td> |
|||
<!--<td><?php echo $data['delivery_date']; ?></td>
|
|||
<td><?php echo $data['completion_date']; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_dt']; ?></td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
<?php |
|||
include "header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
require_once "database.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql = "select * from contractapply_main order by id"; |
|||
$data = mysqli_query($link, $sql); |
|||
$apply_type_arr = ["A" => "制式新合約", "B" => "非制式新合約"]; |
|||
$status_arr = ["I" => "申請中", "P" => "在途中", "Y" => "已完成", "X" => "作廢"]; |
|||
?> |
|||
<p> |
|||
<a href="contractapply-create.php" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
|
|||
<?php |
|||
if ($data) : |
|||
?> |
|||
<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> |
|||
<div style="overflow-x:auto;"> |
|||
<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> |
|||
<th>含稅貨款</th> |
|||
<th>含稅按裝款</th> |
|||
<th>含稅給約總價</th> |
|||
<th>二次款</th> |
|||
<!--<th>交貨期限</th> |
|||
<th>完工期限</th>--> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $data) : |
|||
switch ($data["status"]) { |
|||
case "I": |
|||
$status_dt = $data["status_1_dt"]; |
|||
break; |
|||
case "P": |
|||
$status_dt = $data["status_2_dt"]; |
|||
break; |
|||
case "Y": |
|||
$status_dt = $data["status_3_dt"]; |
|||
break; |
|||
case "X": |
|||
$status_dt = $data["status_4_dt"]; |
|||
break; |
|||
} |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['apply_no1'] . $data['apply_no2']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['apply_number']; ?></td> |
|||
<td><?php echo $data['apply_date']; ?></td> |
|||
<td><?php echo $data['promiser']; ?></td> |
|||
<td><?php echo $apply_type_arr[$data['apply_type']]; ?></td> |
|||
<td> |
|||
<?php echo $status_arr[$data['status']]; ?> |
|||
<p> |
|||
<a href="contractapply-edit.php?id=<?php echo $data['id']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td> |
|||
<td><?php echo $status_dt; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['pay']); ?></td> |
|||
<td><?php echo number_format($data['pay_install']); ?></td> |
|||
<td><?php echo number_format($data['pay_total']); ?></td> |
|||
<td><?php echo $data['pay_second']; ?>天</td> |
|||
<!--<td><?php echo $data['delivery_date']; ?></td>
|
|||
<td><?php echo $data['completion_date']; ?></td>--> |
|||
<td><?php echo $data['creater']; ?></td> |
|||
<td><?php echo $data['create_dt']; ?></td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
?> |
@ -1,322 +1,324 @@ |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MICalculator |
|||
{ |
|||
/** |
|||
* 計算MI |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯報價 maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建MI' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MICalculator |
|||
{ |
|||
/** |
|||
* 計算MI |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯報價 maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯報價 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_mi_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
// echo $sql_get_price; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建MI' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
|
@ -1,322 +1,322 @@ |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯成本maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @param array $param |
|||
* @return void |
|||
*/ |
|||
public function cal(array $param) |
|||
{ |
|||
$elevator_type = $param['elevator_type']; |
|||
$func = $elevator_type . "_price"; |
|||
if (method_exists($this, $elevator_type . "_price")) { |
|||
|
|||
return call_user_func([$this, $func], $param); |
|||
} |
|||
return self::error(); |
|||
} |
|||
/** |
|||
* 客梯成本maintain_kind='A' |
|||
* 1.每月2次保養價格*1.25倍 |
|||
* 2.全包價格按半包價+1500元/臺 |
|||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
|||
* @return void |
|||
*/ |
|||
public function A_price(array $item) |
|||
{ |
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['speed'] . " between min_speed and max_speed |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
|
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 貨梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function B_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
* 病床梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function C_price($item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['weight'] . " between min_weight and max_weight |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
|
|||
/** |
|||
* 無機房成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function D_price($item) |
|||
{ |
|||
|
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_months= " . $item['maintain_months'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
/** |
|||
*家用梯成本 |
|||
* |
|||
* @return void |
|||
*/ |
|||
|
|||
public function E_price(array $item) |
|||
{ |
|||
|
|||
$floors = $item['floors']; |
|||
$maintain_times = $item['maintain_times']; |
|||
|
|||
$sql_get_price = " |
|||
select |
|||
elevator_type, |
|||
base_price, |
|||
floors_price, |
|||
min_floors, |
|||
min_maintain_times, |
|||
maintain_months, |
|||
maintain_kind, |
|||
maintain_period, |
|||
is_m1_bundle, |
|||
all_inclusive_fee, |
|||
maintenance_fee_coefficient, |
|||
m1_bundle_fee |
|||
from maintain_standard_option where |
|||
elevator_type='" . $item['elevator_type'] . "' |
|||
and " . $item['floors'] . " between min_floors and max_floors |
|||
and " . $item['persons'] . " between min_persons and max_persons |
|||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
|||
and maintain_period= " . $item['maintain_period'] . " |
|||
and maintain_kind='" . $item['maintain_kind'] . "' |
|||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
|||
"; |
|||
list($row) = DB::result($sql_get_price); |
|||
if (empty($row)) return self::error(); |
|||
#1基礎價格 |
|||
$floors = $item['floors'] - $row['min_floors']; |
|||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
|||
// echo $price1; |
|||
#判斷是否全包 |
|||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
|||
// echo $price2; |
|||
#判斷是否五年M1套餐 |
|||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
|||
// echo $price3; |
|||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
|||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
|||
$price4 = $price3; |
|||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
|||
|
|||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
|||
} |
|||
return self::success($price4); |
|||
} |
|||
public function error() |
|||
{ |
|||
return [ |
|||
'status' => 'fail', |
|||
'message' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
|
@ -0,0 +1,42 @@ |
|||
<?php |
|||
$envFile = __DIR__ . '/.env'; // .env 文件的路径 |
|||
|
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
// 设置环境变量 |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
$db_hostname = getenv('DB_HOST'); //資料庫主機名稱 |
|||
$db_username = getenv('DB_USERNAME'); //登入資料庫的管理者的帳號 |
|||
$db_password = getenv('DB_PASSWORD'); //登入密碼 |
|||
$db_name = getenv('DB_DATABASE'); //使用的資料庫 |
|||
$db_charset = 'utf8'; //設定字元編碼 |
|||
|
|||
//建立PDO的指定工作 |
|||
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; |
|||
|
|||
try { |
|||
//使用PDO連接到MySQL資料庫,建立PDO物件 |
|||
$conn = new PDO($dsn, $db_username, $db_password); |
|||
|
|||
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) |
|||
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 |
|||
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 |
|||
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 |
|||
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 |
|||
//設定主動以警告的形式報錯 |
|||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|||
//如果連接錯誤,將抛出一個PDOException異常對象 |
|||
} catch (PDOException $e) { |
|||
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 |
|||
die("ERROR!!!: " . $e->getMessage()); |
|||
} |
|||
|
|||
//$conn = null; //關閉資料庫的連線 |
File diff suppressed because it is too large
@ -1,84 +1,84 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
/* //客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
/* //货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
|
|||
/*//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
];*/ |
|||
|
|||
/*//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
*/ |
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
//客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
|
@ -0,0 +1,567 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once('./conn.php'); |
|||
//買賣1、2、3,安裝5、6 (4跟7很少有) |
|||
if (!empty($_GET['apply_key'])) { |
|||
try { |
|||
$apply_key = $_GET['apply_key']; |
|||
// $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"; |
|||
|
|||
// 價審資料 |
|||
$sql = "SELECT * FROM con_maintance_examine_apply AS a LEFT JOIN hope_contract_customer AS b ON a.vol_no = b.vol_no WHERE a.apply_key = :apply_key"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(':apply_key', $apply_key); |
|||
$stmt->execute(); |
|||
$contract_maintance = $stmt->fetchALL(PDO::FETCH_ASSOC); |
|||
echo '<pre>'; |
|||
print_r($contract_maintance); |
|||
echo '</pre>'; |
|||
// echo $contract_maintance; |
|||
// $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' || $user_id != 'M0225') { |
|||
// echo '<script type="text/javascript"> |
|||
// alert("非法訪問。"); |
|||
// window.history.back(); |
|||
// </script>'; |
|||
// exit; |
|||
// } |
|||
|
|||
// 抓有望客戶的資料 |
|||
$sql_str = "SELECT * FROM hope_contract_customer WHERE vol_no = :vol_no"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $contract_maintance['vol_no']); |
|||
$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 = $contract_maintance[0]['num']; |
|||
// echo $qty; |
|||
// foreach ($contract_maintance as $idx => $amount) { |
|||
// $isset = false; |
|||
// if ($amount['payment_kind'] == 5 || $amount['payment_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="..wms/cont/sign_list.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> |
|||
<td> |
|||
<div style="margin-left: 100px"> |
|||
乙方:<article x-html="onstandardViewData.partyAcontractno.plaintext"></article> |
|||
</div> |
|||
</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_maintance['customer']); ?>; |
|||
const partyAcontractno = <?php echo json_encode($contract_maintance['apply_key']); ?>; |
|||
const partyAaddress = <?php echo json_encode($contcontract_maintanceract['address']); ?>; |
|||
const totalPrice = 0; |
|||
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_maintance['test_time']; ?>"; |
|||
// const installfill2 = "<?php echo $contract_maintance['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; ?> |
@ -0,0 +1,649 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
require_once('./conn.php'); |
|||
if ($_POST['list']) { |
|||
$contract_id = $_POST['contract_apply_id']; |
|||
if ($_POST['prviewType'] == 1) { |
|||
$isStand = ($_POST['buystandard'] == "true") ? 1 : 0; |
|||
} else { |
|||
$isStand = $_POST['installstandard'] == "true" ? 1 : 0; |
|||
} |
|||
$type = $_POST['prviewType'] == '1' ? "電梯買賣合約書" : "電梯安裝合約書"; |
|||
$list = json_decode($_POST['list']); |
|||
$standardList = json_decode($_POST['standardList']); |
|||
$illustrate = $_POST['illustrate']; |
|||
$updatedIllustrate = false; |
|||
$standardIllustrate = $_POST['standardIllustrate']; |
|||
$partyA = $_POST['partyA']; |
|||
$partyAcontractno = $_POST['partyAcontractno']; |
|||
$total_price = $_POST['total_price']; |
|||
$person = $_POST['person']; |
|||
$personid = $_POST['personid']; |
|||
$delivery_term = $_POST['delivery_term']; |
|||
$install_period = $_POST['install_period']; |
|||
$free_maintainance = $_POST['free_maintainance']; |
|||
// $originArr = array_filter(json_decode(json_encode($list), true), fn($item)=> $item['origin'] == 1); |
|||
$standardArr = json_decode(json_encode($standardList), true); |
|||
$nostandardArr = json_decode(json_encode($list), true); |
|||
$newlist = array_values(array_filter($list, fn ($item) => $item->deleted == 0)); |
|||
foreach ($nostandardArr as $idx => &$item) { |
|||
if ($item['origin'] === 1) { |
|||
if (strip_tags($item['text']) != strip_tags($standardArr[$item['id']]['text'])) { |
|||
$item['updated'] = 1; |
|||
} else { |
|||
$item['updated'] = 0; |
|||
} |
|||
} |
|||
} |
|||
unset($item); |
|||
if (strip_tags($illustrate) != strip_tags($standardIllustrate)) { |
|||
$updatedIllustrate = true; |
|||
} |
|||
$sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':vol_no', $partyAcontractno); |
|||
$stmt->execute(); |
|||
$customer = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
if (count($customer) <= 0) { |
|||
echo "<script> |
|||
alert('資料不齊或合約書已生成過。'); |
|||
window.history.back(); |
|||
</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) |
|||
{ |
|||
$chineseNumbers = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']; |
|||
$units = ['', '十', '百', '千', '万']; |
|||
|
|||
if ($num <= 10) { |
|||
return $chineseNumbers[$num]; |
|||
} elseif ($num < 20) { |
|||
return $units[1] . $chineseNumbers[$num % 10]; |
|||
} elseif ($num < 100) { |
|||
return $chineseNumbers[intval($num / 10)] . $units[1] . ($num % 10 > 0 ? $chineseNumbers[$num % 10] : ''); |
|||
} else { |
|||
// 處理大於 99 的数字 |
|||
$result = ''; |
|||
$strNum = strval($num); |
|||
$length = strlen($strNum); |
|||
for ($i = 0; $i < $length; $i++) { |
|||
$currentDigit = intval($strNum[$i]); |
|||
if ($currentDigit > 0) { |
|||
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1]; |
|||
} else { |
|||
$result .= $chineseNumbers[$currentDigit]; |
|||
} |
|||
} |
|||
return $result; |
|||
} |
|||
} |
|||
function removeTrailingBr($string) |
|||
{ |
|||
//刪除字串尾巴的<br>或<br /> |
|||
return preg_replace('/(<br\s*\/?>)+$/', '', $string); |
|||
} |
|||
|
|||
?> |
|||
|
|||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.3/purify.min.js"></script> |
|||
<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> |
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js" integrity="sha512-E8QSvWZ0eCLGk4km3hxSsNmGWbLtSCSUcewDQPQWZF6pEU8GlT8a5fF32wOl1i8ftdMhssTrF/OhyGWwonTcXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|||
<style> |
|||
.container { |
|||
background-color: transparent !important; |
|||
width: 100% !important; |
|||
} |
|||
|
|||
.prview, |
|||
.footer { |
|||
width: 800px; |
|||
border: 1px #ccc solid; |
|||
padding: 20px; |
|||
font-family: '標楷體'; |
|||
} |
|||
|
|||
.prview.none { |
|||
display: none; |
|||
} |
|||
|
|||
.prview h2 { |
|||
font-size: 18pt; |
|||
text-align: center; |
|||
} |
|||
|
|||
.prview p { |
|||
font-size: 12pt; |
|||
margin: 0; |
|||
padding: 0; |
|||
} |
|||
|
|||
td tr table th { |
|||
border: none !important; |
|||
background-color: #fff !important; |
|||
} |
|||
|
|||
tr:nth-child(even) { |
|||
background-color: #fff !important; |
|||
} |
|||
|
|||
.colorDiv { |
|||
display: flex; |
|||
margin: 10px 0; |
|||
} |
|||
|
|||
.colorDiv .block { |
|||
width: 18px; |
|||
height: 18px; |
|||
} |
|||
|
|||
.colorDiv span { |
|||
font-size: 15px; |
|||
margin: 0 5px 0 2px; |
|||
font-weight: 600; |
|||
} |
|||
|
|||
.colorDiv .block.gray { |
|||
background-color: #DDDDDD; |
|||
} |
|||
|
|||
.colorDiv .block.green { |
|||
background-color: #00B900; |
|||
} |
|||
|
|||
.colorDiv .block.red { |
|||
background-color: #D11919; |
|||
} |
|||
|
|||
#btn, |
|||
.pre { |
|||
background-color: #0D559D; |
|||
color: #fff; |
|||
outline: none; |
|||
border: none; |
|||
border: 1px #ccc solid; |
|||
width: 100px; |
|||
height: 32px; |
|||
font-weight: 600; |
|||
border-radius: 6px; |
|||
margin-right: 5px; |
|||
} |
|||
|
|||
.pre { |
|||
background-color: #40C474; |
|||
} |
|||
</style> |
|||
|
|||
<div class="container" x-data="{ |
|||
css:'', |
|||
random:'', |
|||
init(){ |
|||
|
|||
const characters = '012345678901234567890123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
|||
const charactersLength = characters.length; |
|||
let randomString = ''; |
|||
const length = 15; |
|||
|
|||
for (let i = 0; i < length; i++) { |
|||
const randomIndex = Math.floor(Math.random() * charactersLength); |
|||
randomString += characters.charAt(randomIndex); |
|||
} |
|||
this.random = randomString; |
|||
console.log(files); |
|||
}, |
|||
exportFn(){ |
|||
|
|||
const now = new Date(); |
|||
|
|||
// 獲取年、月、日、小時、分鐘、秒 |
|||
const year = now.getFullYear(); |
|||
const month = now.getMonth() + 1; // 月份是從0開始的,所以要加1 |
|||
const day = now.getDate(); |
|||
const hours = now.getHours(); |
|||
const minutes = now.getMinutes(); |
|||
const seconds = now.getSeconds(); |
|||
// 格式化日期和時間 |
|||
const formattedDate = `${year}${month}${day}${hours}${minutes}${seconds}`; |
|||
|
|||
let token = formattedDate + '<?php echo $partyAcontractno; ?><?php echo $partyA; ?>永佳捷<?php echo $total_price; ?>' |
|||
let newtoken = formattedDate + '-' + CryptoJS.MD5(CryptoJS.SHA256(CryptoJS.SHA256(CryptoJS.MD5(token).toString()).toString() + this.random).toString()).toString() |
|||
console.log(newtoken); |
|||
let html = this.$refs.prview.innerHTML |
|||
let footer = this.$refs.footer.innerHTML |
|||
let affix1 = this.$refs.affix1.innerHTML |
|||
// html = this.$refs.footer.innerHTML |
|||
// axios.post('./export-pdf.php', {'html':html}).then(res=>{ |
|||
// console.log(res); |
|||
// }) |
|||
const form = new FormData(); |
|||
form.append('html', html); |
|||
form.append('footer', footer); |
|||
form.append('affix1', affix1); |
|||
form.append('css',this.css); |
|||
form.append('user_name', '<?php echo $user_name; ?>'); |
|||
form.append('contract_no', '<?php echo $partyAcontractno; ?>'); |
|||
form.append('party_a', '<?php echo $partyA; ?>'); |
|||
form.append('total_price', '<?php echo $total_price; ?>'); |
|||
form.append('person', '<?php echo $person; ?>'); |
|||
form.append('token', newtoken); |
|||
form.append('formattedDate', formattedDate); |
|||
axiosClient({ |
|||
method:'post', |
|||
responseType:'blob', |
|||
url:'./export-pdf.php', |
|||
data:form |
|||
}).then(response=>{ |
|||
const url = window.URL.createObjectURL(new Blob([response.data])); |
|||
const link = document.createElement('a'); |
|||
link.href = url; |
|||
link.setAttribute('download', formattedDate + '.pdf'); // 指定下载的文件名 |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
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){ |
|||
const form = new FormData(); |
|||
form.append('contract_id', '<?php echo $partyAcontractno; ?>') |
|||
form.append('uscc', '<?php echo $customer['uscc']; ?>') |
|||
form.append('ekind', '新梯') |
|||
form.append('new_elevator', '<?php $_POST['prviewType'] == '1' ? "買賣" : "安裝"; ?>') |
|||
form.append('party_a', '<?php echo $partyA; ?>') |
|||
form.append('total_price', <?php echo (int)$total_price; ?>) |
|||
form.append('accound_id', '<?php echo $personid; ?>') |
|||
form.append('times', 1) |
|||
form.append('random', this.random) |
|||
form.append('hash', newtoken) |
|||
form.append('url', formattedDate+'.pdf' ); |
|||
form.append('created_by', '<?php echo $user_id; ?>') |
|||
form.append('delivery_term', '<?php echo $delivery_term; ?>') |
|||
form.append('install_period', '<?php echo $install_period; ?>') |
|||
form.append('free_maintainance', '<?php echo $free_maintainance; ?>') |
|||
axiosClient({ |
|||
method:'post', |
|||
url:'./store-contract.php', |
|||
data:form |
|||
}).then(res=>{ |
|||
console.log(res); |
|||
}) |
|||
}, |
|||
}"> |
|||
|
|||
|
|||
<button @click="history.go(-1)" class="pre">回前頁</button> |
|||
<button id="btn" @click="exportFn()">點我下載</button> |
|||
<?php if ($isStand == 0) { ?> |
|||
<div class="colorDiv"> |
|||
<div class="block gray"></div> |
|||
<span>修改的條列</span> |
|||
<div class="block green"></div> |
|||
<span>新增的條列</span> |
|||
<div class="block red"></div> |
|||
<span>刪除的條列</span> |
|||
</div> |
|||
<?php } ?> |
|||
<div class="prview" id="prview" x-ref="prview" style="font-family:'標楷體'" x-show="false"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table> |
|||
<tr> |
|||
<td style="width:100px"></td> |
|||
<td style="width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td>(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table> |
|||
<tr> |
|||
<td style="width:100px"></td> |
|||
<td style="width:200px">永佳捷科技股份有限公司</td> |
|||
<td>(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;width:440px"><?php echo $illustrate; ?></p> |
|||
<table style="width:100%"> |
|||
<?php foreach ($newlist as $idx => $item) { |
|||
?> |
|||
<tr style="display:block;"> |
|||
<td style="width:60px;">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<td style="width:445px;"><?php echo nl2br(removeTrailingBr(json_decode(json_encode($item), true)['text'])); ?></td> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
|
|||
|
|||
<section style="display:flex;justify-content:center;"> |
|||
<div class="prview" style="font-family:'標楷體';background-color:#fff;"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px;"></td> |
|||
<td style="border:none;width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td style="border:none">(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px"></td> |
|||
<td style="border:none;width:200px">永佳捷科技股份有限公司</td> |
|||
<td style="border:none">(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;width:800px"><?php echo $standardIllustrate; ?></p> |
|||
<table style="width:100%;border:none"> |
|||
<?php foreach ($standardList as $idx => $item) { |
|||
?> |
|||
<tr style="margin-bottom:10px;display:block;border:none"> |
|||
<td style="width:100px;border:none">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<td style="border:none"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
<?php if ($isStand == 0) { ?> |
|||
<div class="prview nostandard" style="font-family:'標楷體'" x-ref="nostandard"> |
|||
<h2 style="text-align:center;font-size:18pt;"><?php echo $type; ?></h2> |
|||
<p style="font-size: 12pt;">合約書編號:<?php echo $_POST['partyAcontractno'] ?></p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px;"></td> |
|||
<td style="border:none;width:200px"><?php echo $_POST['partyA'] ?></td> |
|||
<td style="border:none">(即買方,以下簡稱為甲方)</td> |
|||
</tr> |
|||
</table> |
|||
<p style="font-size: 12pt;">立合約書人</p> |
|||
<table style="border:none"> |
|||
<tr style="border:none;"> |
|||
<td style="border:none;width:100px"></td> |
|||
<td style="border:none;width:200px">永佳捷科技股份有限公司</td> |
|||
<td style="border:none">(即賣方,以下簡稱為乙方)</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
<p style="font-size: 12pt;width:800px;<?php if ($updatedIllustrate) { |
|||
echo 'background-color:#ddd'; |
|||
} ?>"><?php echo $illustrate; ?></p> |
|||
<table style="width:100%;border:none"> |
|||
<?php foreach ($nostandardArr as $idx => $item) { |
|||
?> |
|||
|
|||
<tr style="margin-bottom:10px;display:block;border:none"> |
|||
<td style="width:100px;border:none">第<?php echo numberToChinese($idx + 1); ?>條</td> |
|||
<?php if ($item['updated'] == 1) { ?> |
|||
<td style="border:none;background-color:#ddd;"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } elseif ($item['deleted'] == 1) { ?> |
|||
<td style="border:none;background-color:#D11919;text-decoration:line-through"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } elseif ($item['id'] > 15) { ?> |
|||
<td style="border:none;background-color:#00B900;"><?php echo nl2br(json_decode(json_encode($item), true)['text']); ?></td> |
|||
<?php } else { ?> |
|||
<td style="border:none"><?php echo nl2br(removeTrailingBr(json_decode(json_encode($item), true)['text'])); ?></td> |
|||
<?php } ?> |
|||
</tr> |
|||
<?php } ?> |
|||
</table> |
|||
</div> |
|||
<?php } ?> |
|||
</section> |
|||
<div class="footer" x-ref="footer" x-show="false"> |
|||
<br /> |
|||
<p> 立合約書人:</p> |
|||
<table> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none">甲</td> |
|||
<td style="width:30px;border:none;text-align:right">方</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> <?php echo $_POST['partyA']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:20px;border:none;">代</td> |
|||
<td style="width:20px;border:none;text-align:center">表</td> |
|||
<td style="width:20px;border:none;text-align:right">人</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['manager']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:15px;border:none;">統</td> |
|||
<td style="width:15px;border:none;text-align:center">一</td> |
|||
<td style="width:15px;border:none;text-align:center">編</td> |
|||
<td style="width:15px;border:none;text-align:right">號</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['uscc']; ?></td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none;">地</td> |
|||
<td style="width:30px;border:none;text-align:right">址</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
<td style="border:none"> <?php echo $customer['address']; ?></td> |
|||
</tr> |
|||
</table> |
|||
<p style="line-height:0.1"> </p> |
|||
<table> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none">乙</td> |
|||
<td style="width:30px;border:none;text-align:right">方</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 永佳捷科技股份有限公司</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:20px;border:none;">總</td> |
|||
<td style="width:20px;border:none;text-align:center">經</td> |
|||
<td style="width:20px;border:none;text-align:right">理</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 蔡定憲</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:15px;border:none;">統</td> |
|||
<td style="width:15px;border:none;text-align:center">一</td> |
|||
<td style="width:15px;border:none;text-align:center">編</td> |
|||
<td style="width:15px;border:none;text-align:right">號</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 90493119</td> |
|||
</tr> |
|||
<tr style="line-height:2"> |
|||
<td style="width:100px;border:none"> |
|||
<table> |
|||
<tr> |
|||
<td style="width:30px;border:none;">地</td> |
|||
<td style="width:30px;border:none;text-align:right">址</td> |
|||
<td style="width:10px;border:none;text-align:right">:</td> |
|||
</tr> |
|||
</table> |
|||
</td> |
|||
<td style="border:none"> 臺北市中山區敬業一路128巷39號3樓之1</td> |
|||
</tr> |
|||
</table> |
|||
<p> </p> |
|||
<!-- <table> |
|||
<tr> |
|||
<td style="width:200px;border:none;text-align:justify">中華民國</td> |
|||
<td style="width:100px;border:none;text-align:right">年</td> |
|||
<td style="width:100px;border:none;text-align:right">月</td> |
|||
<td style="width:100px;border:none;text-align:right">日</td> |
|||
</tr> |
|||
</table> --> |
|||
</div> |
|||
<div class="affix1" x-ref="affix1" x-show="false"> |
|||
<h1 style="text-align:center">升降設備除外工程表</h1> |
|||
<table> |
|||
<tr> |
|||
<td style="width:40px">一、</td> |
|||
<td>機械室之建造,含預留出入口、通風照明、自動閉鎖裝置,及天花板上之保養用吊鉤。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">二、</td> |
|||
<td style="width:460px">通往機械室之樓梯及加護欄杆工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">三、</td> |
|||
<td style="width:460px">機械室基礎台需用防濕之瀝青鐵筋混凝土及地板防塵工事。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">四、</td> |
|||
<td style="width:460px">機械室及升降路中間之橫樑或工字樑之安裝工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">五、</td> |
|||
<td style="width:460px">自屋外至機械室之動力及照明用配線電源開關插座,及接地線等電路工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">六、</td> |
|||
<td style="width:460px">升降路及機械室以外監視盤、電鈴、電話之配管與配線工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">七、</td> |
|||
<td style="width:460px">升降路之建造及底部之防水工程及緩衝器水泥台工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">八、</td> |
|||
<td style="width:460px">機坑照明保養用之開關及插座,鐵爬梯。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">九、</td> |
|||
<td style="width:460px">各樓按鈕開關之留洞工程及安裝後之固定與週邊裝飾工程。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十、</td> |
|||
<td style="width:460px">升降路內甲方不得裝設有任何與升降設備無關之配線、電線配管、水管、風管等設備。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十一、</td> |
|||
<td style="width:460px">安裝所需水泥、砂石、水電與供試車用動力電源。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十二、</td> |
|||
<td style="width:460px">升降路及機房之建造,電源設備之容量及位置等,需符合國家標準(CNS-2866)及建築法規等規定。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:40px">十三、</td> |
|||
<td style="width:460px">機械運抵工地後供給儲存倉庫。</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="2">備註:CNS-2866國家標準建築物電梯有關之法規: </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">1.</td> |
|||
<td style="width:475px">機械室內應設有照明及通風設備,以利管理檢查,照明應在100LUX(米一燭光)以上,通風設備應能使室內溫度保持在攝氏40度以下。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">2.</td> |
|||
<td style="width:475px">機械室之出入口應加鎖,其裝置應良好。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">3.</td> |
|||
<td style="width:475px">由機械室至走廊,樓梯間應便於通行,樓梯應加裝扶手,其與水平面之傾斜角度,應不超過60度。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">4.</td> |
|||
<td style="width:475px">機械室出入門之構造,應有下述裝置: <br> |
|||
A:能自動關閉者。 <br> |
|||
B:有彈簧鎖或其類似裝置,以便室內不用鎖匙,而能開門。 <br> |
|||
C:除屋頂開口部份以外,機械式牆壁,應能耐火。(二小時防火時效) |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">5.</td> |
|||
<td style="width:475px">升降路內不得設置與升降機無關之配管及配線。 </td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">6.</td> |
|||
<td style="width:475px">任一升降路下部之任何部份,供人使用或類似使用時配重側比照車廂,同樣必須裝設緊急安全裝置。</td> |
|||
</tr> |
|||
<tr> |
|||
<td style="width:25px">7.</td> |
|||
<td style="width:475px">若有火警受信總機時,甲方需提供"火警受信總機"檢出信號及通往升降道內之配管配線(0.75MM² × 3) </td> |
|||
</tr> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<script> |
|||
const files = <?php echo json_encode($files); ?>; |
|||
const axiosClient = axios.create({ |
|||
baseURL: ``, |
|||
}); |
|||
|
|||
|
|||
axiosClient.interceptors.request.use((config) => { |
|||
config.headers.Authorization = `Bearer ${123}` |
|||
return config; |
|||
}, (error) => { |
|||
return Promise.reject(error); |
|||
}); |
|||
|
|||
axiosClient.interceptors.response.use((response) => { |
|||
return response; |
|||
}, (error) => { |
|||
if (error.response.status === 401) {} |
|||
throw error; |
|||
}); |
|||
|
|||
|
|||
const btn = document.getElementById('btn') |
|||
console.log(<?php echo $contract_id; ?>); |
|||
</script> |
|||
<?php |
|||
} else { |
|||
echo "<script>alert('非法訪問!');window.history.back();</script>"; |
|||
} |
|||
?> |
@ -1,180 +1,196 @@ |
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
#錶 |
|||
$table = 'hope_contract_customer'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'vol_no' => "卷號", |
|||
'customer_no' => "客戶編號", |
|||
'customer' => "客戶名稱", |
|||
'manager' => "負責人", |
|||
'source' => "客戶來源", |
|||
'linkman' => "聯係人", |
|||
'lm_tel' => "手機", |
|||
'salesman' => "營業員", |
|||
'num' => "数量", |
|||
'pre_order_date' => "預定成交日", |
|||
'status' => "有望客戶狀態", |
|||
'next_visit_date' => "下次拜訪時間", |
|||
'brand' => "廠牌", |
|||
'quote_date' => "報價日期", |
|||
'created_at' => "建立時間", |
|||
|
|||
]; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["501"]; |
|||
$sql = "SELECT department_id FROM account WHERE accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; |
|||
$where = " and vol_no like '$vol_no'"; |
|||
$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; |
|||
$where .= " and salesman like '$salesman'"; |
|||
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; |
|||
$where .= " and linkman like '$lm_name'"; |
|||
$sql_cmd = sql_myself($user_id, "salesman"); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149" || $user_id =="M0189") $sql_cmd = ""; // M0060:Max,鄭伊岑 |
|||
if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd); |
|||
|
|||
$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source, |
|||
linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, |
|||
f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
|
|||
$data = mysqli_query($link, $sql); |
|||
|
|||
// echo '<pre>'; |
|||
// print_r($sql); |
|||
// echo '</pre>'; |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout: fixed; |
|||
/*width: 100%;*/ |
|||
display: inline-block; |
|||
} |
|||
|
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
|
|||
.pagination { |
|||
margin: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function() { |
|||
$('#table_index2').DataTable({ |
|||
order: [ |
|||
[14, 'desc'] |
|||
] |
|||
}); |
|||
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋"; |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>有望客戶(契約)資料維護</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>卷號</th> |
|||
<td><input type="text" class='form-control' name='vol_no'></td> |
|||
<th>營業員</th> |
|||
<td><input type="text" class='form-control' name='salesman'></td> |
|||
<th>下單地區</th> |
|||
<td><input type="text" class='form-control' name='order_province'></td> |
|||
<th>聯係人姓名</th> |
|||
<td><input type="text" class='form-control' name='lm_name'></td> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>'> |
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button> |
|||
<a href="crmm06-edit.php?<?= $token_link ?>" class="btn btn-info btn-sm">新增</a> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<table id="table_index" class="table table-striped table-bordered"> |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<th>$val</th>"; |
|||
} |
|||
echo "<th>編輯</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<td>" . (!empty($row[$key]) ? $row[$key] : '') . "</td>"; |
|||
} |
|||
?> |
|||
<td> |
|||
<p> |
|||
<a href="crmm05-edit.php?function_name=customer&<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
|
|||
<a href="../cont/apply_form.php?<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
轉價審 |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
#錶 |
|||
$table = 'hope_contract_customer'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'vol_no' => "卷號", |
|||
'customer_no' => "客戶編號", |
|||
'customer' => "客戶名稱", |
|||
'manager' => "負責人", |
|||
'source' => "客戶來源", |
|||
'linkman' => "聯係人", |
|||
'lm_tel' => "手機", |
|||
'salesman' => "營業員", |
|||
'num' => "数量", |
|||
'pre_order_date' => "預定成交日", |
|||
'status' => "有望客戶狀態", |
|||
'next_visit_date' => "下次拜訪時間", |
|||
'brand' => "廠牌", |
|||
'quote_date' => "報價日期", |
|||
'created_at' => "建立時間", |
|||
|
|||
]; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["501"]; |
|||
$sql = "SELECT department_id FROM account WHERE accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; |
|||
$where = " and vol_no like '$vol_no'"; |
|||
$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; |
|||
$where .= " and salesman like '$salesman'"; |
|||
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; |
|||
$where .= " and linkman like '$lm_name'"; |
|||
$sql_cmd = sql_myself($user_id, "salesman"); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $sql_cmd = ""; // M0060:Max,鄭伊岑 |
|||
if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd); |
|||
|
|||
$sql = "SELECT vol_no,customer,manager,salesman,f_return_content('customer_source',source ) source, |
|||
linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, |
|||
f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
|
|||
$data = mysqli_query($link, $sql); |
|||
|
|||
// echo '<pre>'; |
|||
// print_r($sql); |
|||
// echo '</pre>'; |
|||
|
|||
// echo '<pre>'; |
|||
// print_r($data); |
|||
// echo '</pre>'; |
|||
|
|||
// $sql = "SELECT * FROM hope_contract_customer WHERE 1=1 $where"; |
|||
// $result = mysqli_query($link, $sql); |
|||
// echo '<pre>'; |
|||
// print_r($result); |
|||
// echo '</pre>'; |
|||
// echo $data['salesman']; |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout: fixed; |
|||
/*width: 100%;*/ |
|||
display: inline-block; |
|||
} |
|||
|
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
|
|||
.pagination { |
|||
margin: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function() { |
|||
$('#table_index2').DataTable({ |
|||
order: [ |
|||
[14, 'desc'] |
|||
] |
|||
}); |
|||
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋"; |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>有望客戶(契約)資料維護</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>卷號</th> |
|||
<td><input type="text" class='form-control' name='vol_no'></td> |
|||
<th>營業員</th> |
|||
<td><input type="text" class='form-control' name='salesman'></td> |
|||
<th>下單地區</th> |
|||
<td><input type="text" class='form-control' name='order_province'></td> |
|||
<th>聯係人姓名</th> |
|||
<td><input type="text" class='form-control' name='lm_name'></td> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>'> |
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button> |
|||
<a href="crmm06-edit.php?<?= $token_link ?>" class="btn btn-info btn-sm">新增</a> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<table id="table_index" class="table table-striped table-bordered"> |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<th>$val</th>"; |
|||
} |
|||
echo "<th>編輯</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
|
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
// echo '<pre>'; |
|||
// print_r($row['salesman']); |
|||
// echo '</pre>'; |
|||
echo "<td>" . (!empty($row[$key]) ? $row[$key] : '') . "</td>"; |
|||
} |
|||
?> |
|||
<td> |
|||
<p> |
|||
<a href="crmm05-edit.php?function_name=customer&<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
<?php if ($user_name === $row['salesman'] || $user_id = 'M0225') : ?> |
|||
<a href="../cont/apply_form.php?<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
轉價審 |
|||
</a> |
|||
<?php endif ?> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
?> |
@ -1,224 +1,228 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", "On"); |
|||
|
|||
require_once './FormHelper.php'; |
|||
require_once './wf_common.php'; |
|||
|
|||
|
|||
//錶單數據 |
|||
#客戶錶 |
|||
#1.電梯品牌選項 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc "; |
|||
$elevator_brand_opt = DB::result($sql); |
|||
#2.客戶來源 |
|||
$sql = "select code_name value ,content label from code where field_name='customer_source'"; |
|||
$customer_source_opt = DB::result($sql); |
|||
#3.電梯類型 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; |
|||
$elevator_kind_opt = DB::result($sql); |
|||
#4.營業員 |
|||
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514')"; |
|||
$salesman_opt = DB::result($sql); |
|||
#5.有望客戶狀態 |
|||
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'"; |
|||
$hope_customer_status_opt = DB::result($sql); |
|||
#6.是否改造 |
|||
$is_renovation_opt = [ |
|||
['label' => '是', 'value' => 'Y'], |
|||
['label' => '否', 'value' => 'N'], |
|||
|
|||
]; |
|||
#7.开门方式 |
|||
$sql = "select code_name value ,content label from code where field_name='open_kind'"; |
|||
$open_kind_opt = DB::result($sql); |
|||
#生成新梯卷号 |
|||
$vol_no = get_sequnece_no('qy_vol_no', date('ym')); |
|||
|
|||
#抓取有望客戶資料 |
|||
$table_hope_contract_customer = 'hope_contract_customer'; |
|||
|
|||
$hope_contract_customer_column = [ |
|||
'vol_no' => ['label' => "卷號(B)", "tag" => 'text', 'attr' => ['required','readonly', "value" => "$vol_no", 'class' => 'form-control form-control-sm']], |
|||
//'form_key' => ['label' => "錶單號","tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]], |
|||
'customer' => ['label' => "客戶名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $customer_source_opt], |
|||
//'linkman' => ['label' => "聯係人", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'lm_tel' => ['label' => "手機", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $salesman_opt], |
|||
'num' => ['label' => "数量", "tag" => 'number', 'attr' => ['min=1','class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']], |
|||
// 'case_name' => ['label' => "现场名称", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']], |
|||
'floors' => ['label' => '樓層', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'persons' => ['label' => '人乘', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'speed' => ['label' => '速度', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'completed_date' => ['label' => '竣工(民國年)', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'pre_order_date' => ['label' => "預定成交日", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
'status' => ['label' => "有望客戶狀態", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $hope_customer_status_opt], |
|||
'next_visit_date' => ['label' => "下次拜訪時間", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
// 'brand' => ['label' => "廠牌", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm '], 'options' => $elevator_brand_opt], |
|||
'quote_date' => ['label' => "報價日期", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required','class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt], |
|||
|
|||
]; |
|||
|
|||
|
|||
$where = " and vol_no='$vol_no'"; |
|||
|
|||
$sql = " SELECT vol_no,customer,manager,source, |
|||
linkman,lm_tel,salesman,num,address,floors,persons,speed,completed_date, |
|||
date_format(pre_order_date,'%Y-%m-%d') pre_order_date, |
|||
status, date_format(next_visit_date,'%Y-%m-%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y-%m-%d') quote_date ,is_renovation FROM $table_hope_contract_customer where 1=1 $where "; |
|||
$hope_contract_customer = DB::result($sql); |
|||
|
|||
|
|||
|
|||
function base_url($url) |
|||
{ |
|||
return "https://www.masada.com.tw/static/" . $url; |
|||
} |
|||
|
|||
#生成卷号 |
|||
function get_sequnece_no($seq_name = '', $p_yyyymm = '') |
|||
{ |
|||
|
|||
if (empty($p_yyyymm) || empty($seq_name)) return null; |
|||
#當前年月 |
|||
|
|||
//echo "select yyyymm from sequence where seq_name='$seq_name' "; |
|||
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); |
|||
if ($p_yyyymm != $yyyymm) { |
|||
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); |
|||
} |
|||
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; |
|||
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); |
|||
// echo "SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "; |
|||
|
|||
return $seq_no; |
|||
} |
|||
?> |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|||
<html> |
|||
|
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF8" /> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<title>有望客戶新增</title> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" /> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"></script> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" /> |
|||
|
|||
<script type="text/javascript"> |
|||
$(document).ready(function() { |
|||
|
|||
|
|||
// $('#cmecTbody').append(cmecRow); |
|||
$('.sp_element_box').attr("disabled", true); |
|||
$("#assign_opinion").cleditor({ |
|||
height: 100, // height not including margins, borders or padding |
|||
controls: // controls to add to the toolbar |
|||
"bold italic underline strikethrough subscript superscript | font size " + |
|||
"style | color highlight removeformat | bullets numbering | outdent " + |
|||
"indent | alignleft center alignright justify | undo redo | " |
|||
}); |
|||
|
|||
$("#form").validate(); |
|||
|
|||
}); |
|||
</script> |
|||
|
|||
</head> |
|||
|
|||
<body> |
|||
<div id="toolbarmenu"> |
|||
<ul class="nav nav-tabs" role="tablist" id="tablist"> |
|||
<li class=" nav-item "> |
|||
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">申请單</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
<div class="tab-content "> |
|||
<div class="tab-pane active assign_content " id="tabassign"> |
|||
<form action="crmm06_submit.php" id='form' method="post" style='width:98%;margin:0 auto'> |
|||
<!-- hidden域 --> |
|||
<input type='hidden' name='vol_no' value='<?= $vol_no ?>'> |
|||
<input type='hidden' name='token' value='<?= $_GET['token'] ?>' /> |
|||
|
|||
<!--錶單start--> |
|||
<div class=" form container-fluid pt-5"> |
|||
<div class="row form_head "> |
|||
<div class=" col-12 form_head_title "> |
|||
<h4> 有望客戶(契约)</h4> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row " style='padding-top:30px;'> |
|||
<div class=" col-lg-12 form_row_header "> |
|||
<b>有望客戶資料</b> |
|||
</div> |
|||
</div> |
|||
|
|||
<?php |
|||
//一行顯示三列 |
|||
$i = 0; |
|||
echo " <div class='row '>"; |
|||
foreach ($hope_contract_customer_column as $key => $val) { |
|||
$j = (($i++) % 4); |
|||
$fieldVal = empty($hope_contract_customer) ? "" : $hope_contract_customer[0][$key]; |
|||
|
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
if ($i != 1 && $j == 0) { |
|||
echo " |
|||
</div> |
|||
<div class='row'> |
|||
"; |
|||
} |
|||
echo " <div class='col-1 form_field_title'> |
|||
" . $val['label'] . " |
|||
</div> |
|||
<div class=' col-2 form_field_content ' > |
|||
$_input |
|||
</div> |
|||
"; |
|||
} |
|||
echo "</div>"; |
|||
|
|||
?> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>洽商進度</b> |
|||
</div> |
|||
<div class="col-12 " style="padding:0"> |
|||
|
|||
<textarea class='form-control textarea' id="progress_status" name="progress_status" value='' rows='6'></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<button style='margin:20px auto;width:50px' type="submit" class="btn btn-primary btn-sm">保存</button> |
|||
</div> |
|||
|
|||
</form> |
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", "On"); |
|||
require_once '../header_nomenu.php'; |
|||
|
|||
require_once './FormHelper.php'; |
|||
require_once './wf_common.php'; |
|||
|
|||
|
|||
//錶單數據 |
|||
#客戶錶 |
|||
#1.電梯品牌選項 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc "; |
|||
$elevator_brand_opt = DB::result($sql); |
|||
#2.客戶來源 |
|||
$sql = "select code_name value ,content label from code where field_name='customer_source'"; |
|||
$customer_source_opt = DB::result($sql); |
|||
#3.電梯類型 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_kind'"; |
|||
$elevator_kind_opt = DB::result($sql); |
|||
#4.營業員 |
|||
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514')"; |
|||
$salesman_opt = DB::result($sql); |
|||
#5.有望客戶狀態 |
|||
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'"; |
|||
$hope_customer_status_opt = DB::result($sql); |
|||
#6.是否改造 |
|||
$is_renovation_opt = [ |
|||
['label' => '是', 'value' => 'Y'], |
|||
['label' => '否', 'value' => 'N'], |
|||
|
|||
]; |
|||
#7.开门方式 |
|||
$sql = "select code_name value ,content label from code where field_name='open_kind'"; |
|||
$open_kind_opt = DB::result($sql); |
|||
#生成新梯卷号 |
|||
$vol_no = get_sequnece_no('qy_vol_no', date('ym')); |
|||
|
|||
#抓取有望客戶資料 |
|||
$table_hope_contract_customer = 'hope_contract_customer'; |
|||
|
|||
$hope_contract_customer_column = [ |
|||
'vol_no' => ['label' => "卷號(B)", "tag" => 'text', 'attr' => ['required', 'readonly', "value" => "$vol_no", 'class' => 'form-control form-control-sm']], |
|||
//'form_key' => ['label' => "錶單號","tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]], |
|||
'customer' => ['label' => "客戶名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $customer_source_opt], |
|||
//'linkman' => ['label' => "聯係人", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'lm_tel' => ['label' => "手機", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "tag" => 'select', 'attr' => ["value" => "$user_id", 'class' => 'form-control form-control-sm'], 'options' => $salesman_opt], |
|||
'num' => ['label' => "数量", "tag" => 'number', 'attr' => ['min=1', 'class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']], |
|||
// 'case_name' => ['label' => "现场名称", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']], |
|||
'floors' => ['label' => '樓層', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'persons' => ['label' => '人乘', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'speed' => ['label' => '速度', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'completed_date' => ['label' => '竣工(民國年)', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'pre_order_date' => ['label' => "預定成交日", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
'status' => ['label' => "有望客戶狀態", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $hope_customer_status_opt], |
|||
'next_visit_date' => ['label' => "下次拜訪時間", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
// 'brand' => ['label' => "廠牌", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm '], 'options' => $elevator_brand_opt], |
|||
'quote_date' => ['label' => "報價日期", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']], |
|||
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required','class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt], |
|||
|
|||
]; |
|||
$data = [ |
|||
'salesman' => $user_id |
|||
]; |
|||
|
|||
$where = " and vol_no='$vol_no'"; |
|||
|
|||
$sql = " SELECT vol_no,customer,manager,source, |
|||
linkman,lm_tel,salesman,num,address,floors,persons,speed,completed_date, |
|||
date_format(pre_order_date,'%Y-%m-%d') pre_order_date, |
|||
status, date_format(next_visit_date,'%Y-%m-%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y-%m-%d') quote_date ,is_renovation FROM $table_hope_contract_customer where 1=1 $where "; |
|||
$hope_contract_customer = DB::result($sql); |
|||
|
|||
|
|||
|
|||
function base_url($url) |
|||
{ |
|||
return "https://www.masada.com.tw/static/" . $url; |
|||
} |
|||
|
|||
#生成卷号 |
|||
function get_sequnece_no($seq_name = '', $p_yyyymm = '') |
|||
{ |
|||
|
|||
if (empty($p_yyyymm) || empty($seq_name)) return null; |
|||
#當前年月 |
|||
|
|||
//echo "select yyyymm from sequence where seq_name='$seq_name' "; |
|||
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); |
|||
if ($p_yyyymm != $yyyymm) { |
|||
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); |
|||
} |
|||
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; |
|||
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); |
|||
// echo "SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "; |
|||
|
|||
return $seq_no; |
|||
} |
|||
?> |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|||
<html> |
|||
|
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF8" /> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<title>有望客戶新增</title> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" /> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"></script> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" /> |
|||
|
|||
<script type="text/javascript"> |
|||
$(document).ready(function() { |
|||
|
|||
|
|||
// $('#cmecTbody').append(cmecRow); |
|||
$('.sp_element_box').attr("disabled", true); |
|||
$("#assign_opinion").cleditor({ |
|||
height: 100, // height not including margins, borders or padding |
|||
controls: // controls to add to the toolbar |
|||
"bold italic underline strikethrough subscript superscript | font size " + |
|||
"style | color highlight removeformat | bullets numbering | outdent " + |
|||
"indent | alignleft center alignright justify | undo redo | " |
|||
}); |
|||
|
|||
$("#form").validate(); |
|||
|
|||
}); |
|||
</script> |
|||
|
|||
</head> |
|||
|
|||
<body> |
|||
<div id="toolbarmenu"> |
|||
<ul class="nav nav-tabs" role="tablist" id="tablist"> |
|||
<li class=" nav-item "> |
|||
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">申请單</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
<div class="tab-content "> |
|||
<div class="tab-pane active assign_content " id="tabassign"> |
|||
<form action="crmm06_submit.php" id='form' method="post" style='width:98%;margin:0 auto'> |
|||
<!-- hidden域 --> |
|||
<input type='hidden' name='vol_no' value='<?= $vol_no ?>'> |
|||
<input type='hidden' name='token' value='<?= $_GET['token'] ?>' /> |
|||
|
|||
<!--錶單start--> |
|||
<div class=" form container-fluid pt-5"> |
|||
<div class="row form_head "> |
|||
<div class=" col-12 form_head_title "> |
|||
<h4> 有望客戶(契约)</h4> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row " style='padding-top:30px;'> |
|||
<div class=" col-lg-12 form_row_header "> |
|||
<b>有望客戶資料</b> |
|||
</div> |
|||
</div> |
|||
|
|||
<?php |
|||
//一行顯示三列 |
|||
$i = 0; |
|||
echo " <div class='row '>"; |
|||
foreach ($hope_contract_customer_column as $key => $val) { |
|||
$j = (($i++) % 4); |
|||
$fieldVal = (empty($data) or !array_key_exists($key, $data)) ? "" : $data[$key]; |
|||
// $fieldVal = empty($hope_contract_customer) ? "" : $hope_contract_customer[0][$key]; |
|||
|
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
if ($i != 1 && $j == 0) { |
|||
echo " |
|||
</div> |
|||
<div class='row'> |
|||
"; |
|||
} |
|||
echo " <div class='col-1 form_field_title'> |
|||
" . $val['label'] . " |
|||
</div> |
|||
<div class=' col-2 form_field_content ' > |
|||
$_input |
|||
</div> |
|||
"; |
|||
} |
|||
echo "</div>"; |
|||
|
|||
?> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>洽商進度</b> |
|||
</div> |
|||
<div class="col-12 " style="padding:0"> |
|||
|
|||
<textarea class='form-control textarea' id="progress_status" name="progress_status" value='' rows='6'></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<button style='margin:20px auto;width:50px' type="submit" class="btn btn-primary btn-sm">保存</button> |
|||
</div> |
|||
|
|||
</form> |
|||
|
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
</body> |
File diff suppressed because it is too large
Loading…
Reference in new issue