Browse Source

保養價沈

main
10994015 1 year ago
parent
commit
d2605b4609
  1. 38
      wms/cont/api/getElevatorPrice.php
  2. 181
      wms/cont/api/postElevatorPricereview.php
  3. 58
      wms/cont/api/postFlow.php
  4. 20
      wms/cont/api/postSystemNotice.php
  5. 107
      wms/cont/js/pricereviewAlpine.js
  6. 147
      wms/cont/pricereviewCreate.php
  7. 2
      wms/cont/window-modal/modalElevaotr.php
  8. 0
      wms/mkt/assets/js/pricereviewAlpine0311.js
  9. 9
      wms/mkt/pricereviewCheck.php
  10. 2
      wms/mkt/pricereviewCreate.php

38
wms/cont/api/getElevatorPrice.php

@ -2,29 +2,27 @@
require_once "../../mkt/conn.php"; require_once "../../mkt/conn.php";
$spec = $_GET['spec']; $spec = $_GET['spec'] ?? '';
$person = $_GET['person']; $person = $_GET['person'] ?? '';
$stop = $_GET['stop']; $stop = $_GET['stop'] ?? '';
$weight = $_GET['weight']; $weight = $_GET['weight'] ?? '';
$speed = $_GET['speed']; $speed = $_GET['speed'] ?? '';
$m1 = $_GET['m1']; $m1 = $_GET['m1'] ?? '';
$method = $_GET['method']; $method = $_GET['method'] ?? '';
$cycle = $_GET['cycle']; $cycle = $_GET['cycle'] ?? '';
if($spec == "MAE100"){ $elevator_type = match($spec){
$elevator_type = "A"; "MAE100" => "A",
}elseif($spec == "MAF100"){ "MAF100" => "B",
$elevator_type = "B"; "MAM200" => "D",
}elseif($spec == "MAM200"){ "MAH100" => "E",
$elevator_type = "D"; };
}elseif($spec == "MAH100"){ $sql_str = "SELECT * FROM maintain_standard_option
$elevator_type = "E"; WHERE elevator_type=:elevator_type AND min_speed<=:speed AND max_speed>=:speed AND min_persons <= :person AND max_persons >= :person AND is_m1_bundle=:m1
} ORDER bY id DESC";
$sql_str = "SELECT * FROM maintain_standard_option WHERE elevator_type=:elevator_type AND min_speed = :min_speed AND min_persons <= :person AND max_persons >= :person AND is_m1_bundle=:m1 ORDER bY id DESC";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type); $stmt->bindParam(':elevator_type', $elevator_type);
$stmt->bindParam(':min_speed', $speed);
$stmt->bindParam(':person', $person); $stmt->bindParam(':person', $person);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':m1', $m1); $stmt->bindParam(':m1', $m1);
$stmt->execute(); $stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC); $result = $stmt->fetch(PDO::FETCH_ASSOC);

181
wms/cont/api/postElevatorPricereview.php

@ -25,17 +25,23 @@ $pay_method = $_POST['pay_method'];
$status = $_POST['status']; $status = $_POST['status'];
$elevators = json_decode($_POST['elevators'], true); $elevators = json_decode($_POST['elevators'], true);
$otherOptions = json_decode($_POST['otherOptions'], true); $otherOptions = json_decode($_POST['otherOptions'], true);
$payment_kind = $_POST['pay_method'];
$current_date = date("Y-M-d H:i:s"); $current_date = date("Y-M-d H:i:s");
$sql_str = "SELECT status FROM con_maintance_examine_apply WHERE vol_no = :vol_no AND apply_key = :apply_key"; $total_price = $_POST['total_price'];
$total_sale_price = $_POST['total_sale_price'];
$sql_str = "SELECT status FROM con_maintance_examine_apply WHERE (vol_no, apply_key) = (:vol_no, :apply_key) ";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no); $stmt->bindParam(':vol_no', $vol_no);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->execute(); $stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC); $contract = $stmt->fetch(PDO::FETCH_ASSOC);
if(!$contract){
$conn->beginTransaction();
try{
if(!$contract){
$sql_str = "INSERT INTO con_maintance_examine_apply (apply_key, vol_no, customer, address, case_name ,brand, num, salesman, maintain_kind, contract_begin_date, contract_end_date, contract_kind, payment_kind, progress_remark, service_fee, total_price, total_sale_price, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, creater, create_at) $sql_str = "INSERT INTO con_maintance_examine_apply (apply_key, vol_no, customer, address, case_name ,brand, num, salesman, maintain_kind, contract_begin_date, contract_end_date, contract_kind, payment_kind, progress_remark, service_fee, total_price, total_sale_price, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, creater, create_at)
VALUES (:apply_key, :vol_no, :customer, :address, :case_name ,:brand, :num, :salesman, :maintain_kind, :contract_begin_date, :contract_end_date, :contract_kind, :payment_kind, :progress_remark, :service_fee, :total_price, :total_sale_price, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :creater, :create_at)"; VALUES (:apply_key, :vol_no, :customer, :address, :case_name ,:brand, :num, :salesman, :maintain_kind, :contract_begin_date, :contract_end_date, :contract_kind, :payment_kind, :progress_remark, :service_fee, :total_price, :total_sale_price, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :creater, :create_at)";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
@ -66,8 +72,8 @@ if(!$contract){
$stmt->bindParam(':create_at', $current_date); $stmt->bindParam(':create_at', $current_date);
$stmt->execute(); $stmt->execute();
$sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain__months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at) $sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, item_no, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain_months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at)
VALUES (:apply_key, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain__months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) "; VALUES (:apply_key, :item_no, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain_months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) ";
foreach($elevators as $elevator){ foreach($elevators as $elevator){
if(empty($elevator['permitNumber'])) $register_code = "A"; if(empty($elevator['permitNumber'])) $register_code = "A";
@ -83,7 +89,7 @@ if(!$contract){
$management_expense = null; $management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee; $service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y"; $cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $elevator['id']); $stmt->bindParam(':item_no', $elevator['id']);
@ -102,8 +108,8 @@ if(!$contract){
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense); $stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times); $stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']); $stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain__months', $elevator['months']); $stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $elevator['cycle']); $stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']); $stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']); $stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']); $stmt->bindParam(':contract_price', $elevator['sale_price']);
@ -115,20 +121,21 @@ if(!$contract){
$stmt->bindParam(':cmstatus', $cmstatus); $stmt->bindParam(':cmstatus', $cmstatus);
$stmt->bindParam(':updated_at', $updated_at); $stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':creater', $creater); $stmt->bindParam(':creater', $creater);
$stmt->bindParam(':created_at', $created_at); $stmt->bindParam(':created_at', $current_date);
$stmt->execute(); $stmt->execute();
} }
$sql_str = "INSERT INTO pricereview_maintain_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo) $sql_str = "INSERT INTO pricereview_maintain_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo)
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)"; VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)";
foreach($otherOptions as $option){ foreach($otherOptions as $option){
$item_price_bp = $option['price']*$option['num']; $item_price_bp = $option['price']*$option['num'];
$option_relate_spec = $option['toElevator'][0]['id']; $option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$item_group = "E"; $item_group = "E";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key); $stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':item_no', $option['pr_no']); $stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':item_group', $item_group); $stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']); $stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec); $stmt->bindParam(':option_relate_spec', $option_relate_spec);
@ -138,7 +145,7 @@ if(!$contract){
$stmt->bindParam(':memo', $option['memo']); $stmt->bindParam(':memo', $option['memo']);
$stmt->execute(); $stmt->execute();
} }
}else{ }else{
$sql_str = "UPDATE con_maintance_examine_apply SET $sql_str = "UPDATE con_maintance_examine_apply SET
case_name=:case_name, case_name=:case_name,
num=:num, num=:num,
@ -154,12 +161,13 @@ if(!$contract){
deposit_rate=:deposit_rate, deposit_rate=:deposit_rate,
keep_rate=:keep_rate, keep_rate=:keep_rate,
warranty_rate=:warranty_rate, warranty_rate=:warranty_rate,
remark=:remark, memo=:memo,
brand=:brand,
status=:status, status=:status,
updated_at=:updated_at updated_at=:updated_at,
progress_remark=:progress_remark progress_remark=:progress_remark
WHERE apply_key=:apply_key AND vol_no=:vol_no"; WHERE apply_key=:apply_key AND vol_no=:vol_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':vol_no', $vol_no); $stmt->bindParam(':vol_no', $vol_no);
$stmt->bindParam(':case_name', $case_name); $stmt->bindParam(':case_name', $case_name);
@ -178,17 +186,17 @@ if(!$contract){
$stmt->bindParam(':keep_rate', $keep_rate); $stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':warranty_rate', $warranty_rate); $stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':memo', $remark); $stmt->bindParam(':memo', $remark);
$stmt->bindParam(':brand', $brand);
$stmt->bindParam(':status', $status); $stmt->bindParam(':status', $status);
$stmt->bindParam(':updated_at', $current_date); $stmt->bindParam(':updated_at', $current_date);
$stmt->execute(); $stmt->execute();
//整機單價 //整機單價
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key=:apply_key AND vol_no=:vol_no"; $sql_str = "SELECT * FROM con_maintance_examine_clear WHERE (apply_key, cmstatus) = (:apply_key, 'Y')";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute(); $stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC); $oldElevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldItemsNo = (array)array_column($oldElevators, 'item_no'); $oldItemsNo = (array)array_column($oldElevators, 'item_no');
$newItemsNo = (array)array_column($elevators, 'id'); $newItemsNo = (array)array_column($elevators, 'id');
@ -197,16 +205,16 @@ if(!$contract){
$inBothIds = array_values(array_intersect($oldItemsNo, $newItemsNo)); //舊的跟新的都有,所以要更新(update) $inBothIds = array_values(array_intersect($oldItemsNo, $newItemsNo)); //舊的跟新的都有,所以要更新(update)
foreach($onlyInOldIds as $oldIdx){ foreach($onlyInOldIds as $oldIdx){
$sql_str = "DELETE FROM con_maintance_examine_clear WHERE apply_key = :apply_key AND item_no = :item_no AND vol_no=:vol_no"; // $sql_str = "DELETE FROM con_maintance_examine_clear WHERE apply_key=:apply_key AND item_no=:item_no";
$sql_str = "UPDATE con_maintance_examine_clear SET cmstatus = 'D' WHERE apply_key=:apply_key AND item_no=:item_no";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $oldidx); $stmt->bindParam(':item_no', $oldIdx);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute(); $stmt->execute();
} }
foreach($onlyInNewIds as $newidx){ foreach($onlyInNewIds as $newidx){
$sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain__months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at) $sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, item_no, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain_months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, created_at)
VALUES (:apply_key, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain__months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) "; VALUES (:apply_key, :item_no, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain_months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :created_at) ";
$elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $newidx))[0]; $elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $newidx))[0];
$register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber']; $register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber'];
if($elevator['spec'] == "MAE100") $elevator_kind = "A"; if($elevator['spec'] == "MAE100") $elevator_kind = "A";
@ -220,7 +228,7 @@ if(!$contract){
$management_expense = null; $management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee; $service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y"; $cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $elevator['id']); $stmt->bindParam(':item_no', $elevator['id']);
@ -239,8 +247,8 @@ if(!$contract){
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense); $stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times); $stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']); $stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain__months', $elevator['months']); $stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $elevator['cycle']); $stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']); $stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']); $stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']); $stmt->bindParam(':contract_price', $elevator['sale_price']);
@ -252,13 +260,10 @@ if(!$contract){
$stmt->bindParam(':cmstatus', $cmstatus); $stmt->bindParam(':cmstatus', $cmstatus);
$stmt->bindParam(':updated_at', $updated_at); $stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':creater', $creater); $stmt->bindParam(':creater', $creater);
$stmt->bindParam(':created_at', $created_at); $stmt->bindParam(':created_at', $current_date);
$stmt->execute(); $stmt->execute();
} }
foreach($inBothIds as $bothidx){ foreach($inBothIds as $bothidx){
$sql_str = "INSERT INTO con_maintance_examine_clear (apply_key, register_code, elevator_brand, elevator_kind, spec, weight, speed, stop, floors, persons, elevator_num, useful_years, last_check_date, speed_governors_check_expense, maintain_times, is_m1_bundle, maintain__months, maintain_period, maintain_method, stand_price, contract_price, sold_price, commission_expense, management_expense, annual_survey_expense, service_expense, cmstatus, updated_at, creater, creater, created_at)
VALUES (:apply_key, :register_code, :elevator_brand, :elevator_kind, :spec, :weight, :speed, :stop, :floors, :persons, :elevator_num, :useful_years, :last_check_date, :speed_governors_check_expense, :maintain_times, :is_m1_bundle, :maintain__months, :maintain_period, :maintain_method, :stand_price, :contract_price, :sold_price, :commission_expense, :management_expense, :annual_survey_expense, :service_expense, :cmstatus, :updated_at, :creater, :creater, :created_at) ";
$sql_str = "UPDATE con_maintance_examine_clear SET $sql_str = "UPDATE con_maintance_examine_clear SET
register_code=:register_code, register_code=:register_code,
elevator_brand=:elevator_brand, elevator_brand=:elevator_brand,
@ -275,7 +280,7 @@ if(!$contract){
speed_governors_check_expense=:speed_governors_check_expense, speed_governors_check_expense=:speed_governors_check_expense,
maintain_times=:maintain_times, maintain_times=:maintain_times,
is_m1_bundle=:is_m1_bundle, is_m1_bundle=:is_m1_bundle,
maintain__months=:maintain__months, maintain_months=:maintain_months,
maintain_period=:maintain_period, maintain_period=:maintain_period,
maintain_method=:maintain_method, maintain_method=:maintain_method,
stand_price=:stand_price, stand_price=:stand_price,
@ -287,7 +292,7 @@ if(!$contract){
service_expense=:service_expense, service_expense=:service_expense,
cmstatus=:cmstatus, cmstatus=:cmstatus,
updated_at=:updated_at updated_at=:updated_at
WHERE apply_key=:apply_key AND item_no=:item_no"; WHERE (apply_key, item_no) = (:apply_key, :item_no)";
$elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $bothidx))[0]; $elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $bothidx))[0];
$register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber']; $register_code = empty($elevator['permitNumber']) ? "A" : $elevator['permitNumber'];
@ -302,6 +307,7 @@ if(!$contract){
$management_expense = null; $management_expense = null;
$service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee; $service_expense = ($elevator['sale_price'] / $total_sale_price) * $serviceFee;
$cmstatus = "Y"; $cmstatus = "Y";
$cycle = (int)$elevator['cycle'];
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
@ -320,8 +326,8 @@ if(!$contract){
$stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense); $stmt->bindParam(':speed_governors_check_expense', $speed_governors_check_expense);
$stmt->bindParam(':maintain_times', $maintain_times); $stmt->bindParam(':maintain_times', $maintain_times);
$stmt->bindParam(':is_m1_bundle', $elevator['m1']); $stmt->bindParam(':is_m1_bundle', $elevator['m1']);
$stmt->bindParam(':maintain__months', $elevator['months']); $stmt->bindParam(':maintain_months', $elevator['months']);
$stmt->bindParam(':maintain_period', $elevator['cycle']); $stmt->bindParam(':maintain_period', $cycle);
$stmt->bindParam(':maintain_method', $elevator['method']); $stmt->bindParam(':maintain_method', $elevator['method']);
$stmt->bindParam(':stand_price', $elevator['price']); $stmt->bindParam(':stand_price', $elevator['price']);
$stmt->bindParam(':contract_price', $elevator['sale_price']); $stmt->bindParam(':contract_price', $elevator['sale_price']);
@ -338,22 +344,22 @@ if(!$contract){
} }
//除外項目 //除外項目
$sql_str = "SELECT * FROM pricereview_maintain_item WHERE mid = :apply_key AND item_group = 'E'"; $sql_str = "SELECT * FROM pricereview_maintain_item WHERE (mid, item_group) = (:apply_key, 'E')";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->execute(); $stmt->execute();
$item_other_options = $stmt->fetchAll(PDO::FETCH_ASSOC); $item_other_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldOtherOptionsNo = (array)array_column($item_other_options, 'item_no'); $oldOtherOptionsNo = (array)array_column($item_other_options, 'item_no');
$newOtherOptioinNo = (array)array_column($otherOptions, 'id'); $newOtherOptioinNo = (array)array_column($otherOptions, 'id');
$nlyInOtherOptionOldIds = array_values(array_diff($oldOtherOptionsNo, $newOtherOptioinNo)); $onlyInOtherOptionOldIds = array_values(array_diff($oldOtherOptionsNo, $newOtherOptioinNo));
$onlyInOtherOptionNewIds = array_values(array_diff($newOtherOptioinNo, $oldOtherOptionsNo)); $onlyInOtherOptionNewIds = array_values(array_diff($newOtherOptioinNo, $oldOtherOptionsNo));
$inBothOtherOptionIds = array_values(array_intersect($oldOtherOptionsNo, $newOtherOptioinNo)); $inBothOtherOptionIds = array_values(array_intersect($oldOtherOptionsNo, $newOtherOptioinNo));
foreach($onlyInOtherOptionOldIds as $oldotheroptionidx){ foreach($onlyInOtherOptionOldIds as $oldotheroptionidx){
$sql_str = "DELETE FROM pricereview_maintain_item WHERE mid = :apply_key AND item_no = :item_no AND item_group = 'E'"; $sql_str = "DELETE FROM pricereview_maintain_item WHERE (mid, item_no, item_group) = (:apply_key, :item_no, 'E')";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $oldotheroptionidx); $stmt->bindParam(':item_no', $oldotheroptionidx);
$stmt->execute(); $stmt->execute();
} }
@ -361,15 +367,16 @@ if(!$contract){
foreach($onlyInOtherOptionNewIds as $newotheroptionidx){ foreach($onlyInOtherOptionNewIds as $newotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $newotheroptionidx))[0]; $option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $newotheroptionidx))[0];
$sql_str = "INSERT INTO pricereview_maintain_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo) $sql_str = "INSERT INTO pricereview_maintain_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo)
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)"; VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :memo)";
$item_price_bp = $option['price']*$option['num']; $item_price_bp = $option['price']*$option['num'];
$option_relate_spec = $option['toElevator'][0]['id']; $option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$item_group = "E"; $item_group = "E";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key); $stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':item_no', $option['pr_no']); $stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':item_group', $item_group); $stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']); $stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec); $stmt->bindParam(':option_relate_spec', $option_relate_spec);
@ -382,16 +389,17 @@ if(!$contract){
foreach($inBothOtherOptionIds as $bothotheroptionidx){ foreach($inBothOtherOptionIds as $bothotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $bothotheroptionidx))[0]; $option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $bothotheroptionidx))[0];
$sql_str = "UPDATE pricereview_maintain_item SET item_spec=:item_spec, option_relate_spec=:option_relate_spec, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, memo = :memo $sql_str = "UPDATE pricereview_maintain_item SET item_spec=:item_spec, price_id=:price_id, option_relate_spec=:option_relate_spec, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, memo = :memo
WHERE mid = :apply_key AND item_no = :item_no AND item_group = 'E'"; WHERE (mid, item_no, item_group) = (:apply_key, :item_no, :item_group)";
$item_group = "E"; $item_group = "E";
$item_price_bp = $option['price']*$option['num']; $item_price_bp = $option['price']*$option['num'];
$option_relate_spec = $option['toElevator'][0]['id']; $option_relate_spec = (count($option['toElevator']) > 0) ? $option['toElevator'][0]['id'] : null;
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':item_no', $option['pr_no']); $stmt->bindParam(':item_no', $option['id']);
$stmt->bindParam(':price_id', $option['pr_no']);
$stmt->bindParam(':item_group', $item_group); $stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $option['name']); $stmt->bindParam(':item_spec', $option['name']);
$stmt->bindParam(':option_relate_spec', $option_relate_spec); $stmt->bindParam(':option_relate_spec', $option_relate_spec);
@ -401,11 +409,76 @@ if(!$contract){
$stmt->bindParam(':memo', $option['memo']); $stmt->bindParam(':memo', $option['memo']);
$stmt->execute(); $stmt->execute();
} }
} }
if($status == "YS"){
$sql_str = "SELECT * FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $creater);
$stmt->execute();
$account = $stmt->fetch(PDO::FETCH_ASSOC);
$manager = $account['manager'];
$sign1 = $manager . ",,";
$sign2 = "M0012,,";
$sign3 = "M0008,,";
$sign_total = 3;
//服務費大於0 或是 價率低於0.8送至總經理(M0006)
if(false && ($serviceFee > 0 || ($total_sale_price / $total_price) < 0.8)){
$sign4 = "M0006,,";
$sign_total = 4;
}
if($status == "YS"){ $sql_str = "INSERT INTO pricereview_maintain_sign (mid, sign1, sign1_note, sign2, sign2_note, sign3, sign3_note, sign4, sign4_note, sign_total, created_at, created_by)
$sql_str = "INSERT INTO pricereview_maintain_sign ()" VALUES (:mid, :sign1, :sign1_note, :sign2, :sign2_note, :sign3, :sign3_note, :sign4, :sign4_note, :sign_total, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $apply_key);
$stmt->bindParam(':sign1', $sign1);
$stmt->bindParam(':sign1_note', $sign1_note);
$stmt->bindParam(':sign2', $sign2);
$stmt->bindParam(':sign2_note', $sign2_note);
$stmt->bindParam(':sign3', $sign3);
$stmt->bindParam(':sign3_note', $sign3_note);
$stmt->bindParam(':sign4', $sign4);
$stmt->bindParam(':sign4_note', $sign4_note);
$stmt->bindParam(':sign_total', $sign_total);
$stmt->bindParam(':created_at', $current_date);
$stmt->bindParam(':created_by', $creater);
$stmt->execute();
include_once "./postFlow.php";
$form_key = null;
$createFlow = createFlow($apply_key, $manager, "A", "保養", $form_key);
include_once "./postSystemNotice.php";
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE apply_key = :apply_key ORDER BY create_at DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
$kind = 1;
$related_id = $apply_key;
$title = "保養價審待簽通知(".$vol_no."," .$customer. ")";
$content = "待簽核";
$content = "合約號:".$vol_no . "<br>";
$content .= "客戶名稱:" . $customer . "<br>";
$content .= "案件名稱:" . $case_name . "<br>";
$content .= "時間" . $current_date;
// $content .= "<a href='./mkt/pricreviewCheck.php?id=".$mid.">前往查看</a>";
$havaread = null;
$permissions = [$manager];
$creater = "system";
$create_at = $current_date;
$url = "cont/pricereviewCheck.php?id=" . $apply_key;
sendSystemNotice($kind, $related_id, $title, $content, $havaread, $permissions, $creater, $create_at, $url);
}
echo "success";
$conn->commit();
} catch (PDOException $e) {
$conn->rollBack();
echo $e->getMessage();
} }
echo "success";

58
wms/cont/api/postFlow.php

@ -0,0 +1,58 @@
<?php
require_once("../../mkt/conn.php");
function createFlow($mid, $current_assigner, $flow_code, $ekind, $form_key=null){
global $conn;
$form_id = $mid;
$seq = 0;
$system_id = "prm";
if($ekind == "新梯") $flow_id = "prm01";
if($ekind == "汰改") $flow_id = "prm02";
if($ekind == "保養") $flow_id = "prm03";
if($form_key == null){
$sql_str = "SELECT appwms.nextval('form_key') form_key";
$stmt = $conn->prepare($sql_str);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$form_key = $result['form_key'];
$seq = 0;
$sql_str = "INSERT INTO flow (system_id, flow_id, form_id, form_key, flow_code)
VALUES (:system_id, :flow_id, :form_id, :form_key, :flow_code)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':system_id', $system_id);
$stmt->bindParam(':flow_id', $flow_id);
$stmt->bindParam(':form_id', $form_id);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':flow_code', $flow_code);
$stmt->execute();
}else{
$sql_str = "UPDATE flow SET flow_code = :flow_code WHERE form_key = :form_key";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':flow_code', $flow_code);
$stmt->execute();
$sql_str = "SELECT MAX(seq) AS max_seq FROM subflow WHERE form_key = :form_key";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$seq = $result['max_seq'];
$seq ++;
}
$created_at = date("Y-m-d H:i:s");
$sql_str = "INSERT INTO subflow (form_key, seq, current_assigner, update_date,create_date)
VALUES (:form_key, :seq, :current_assigner, :update_date,:create_date)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':form_key', $form_key);
$stmt->bindParam(':seq', $seq);
$stmt->bindParam(':current_assigner', $current_assigner);
$stmt->bindParam(':update_date', $created_at);
$stmt->bindParam(':create_date', $created_at);
$stmt->execute();
return $form_key;
}

20
wms/cont/api/postSystemNotice.php

@ -0,0 +1,20 @@
<?php
require_once("../../mkt/conn.php");
function sendSystemNotice($kind, $related_id, $title, $content, $haveread, $permissions, $creater, $create_at, $url){
global $conn;
$sql_str = "INSERT INTO notice (kind, related_id, title, content, haveread, permission, url, creater, create_at)
VALUES (:kind, :related_id, :title, :content, :haveread, :permission, :url,:creater, :create_at)";
foreach($permissions as $permission){
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':kind', $kind);
$stmt->bindParam(':related_id', $related_id);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':content', $content);
$stmt->bindParam(':haveread', $haveread);
$stmt->bindParam(':permission', $permission);
$stmt->bindParam(':url', $url);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
}
}

107
wms/cont/js/pricereviewAlpine.js

@ -1,7 +1,6 @@
const pricereviewCreate = ()=>{ const pricereviewCreate = ()=>{
return { return {
init(){ init(){
console.log(123);
}, },
modalShow:{ modalShow:{
elevator: false, elevator: false,
@ -17,13 +16,14 @@ const pricereviewCreate = ()=>{
pre_order_date:pre_order_date, pre_order_date:pre_order_date,
address:address, address:address,
progress_status:progress_status, progress_status:progress_status,
total_spec:0, total_spec:total_spec,
elevators:[], elevators: hope_elevators,
case_name:'', //案件名稱 case_name:case_name, //案件名稱
contract_status:'', // 契約性質 contract_status:contract_kind, // 契約性質
pay_method:'', // 付款方式 pay_method:payment_kind, // 付款方式
startDate:'', //合約開始日期 startDate:contract_begin_date, //合約開始日期
endDate:'', // 合約結束日期 endDate:contract_end_date, // 合約結束日期
brand:brand,
modalElevatorInfo:{ modalElevatorInfo:{
spec:'', spec:'',
person:'', person:'',
@ -33,7 +33,7 @@ const pricereviewCreate = ()=>{
permitNumber:'', //許可證號碼 permitNumber:'', //許可證號碼
brand:'', //品牌 brand:'', //品牌
m1:'N', //贈送M1 m1:'N', //贈送M1
months:'', // 保養月數 months:12, // 保養月數
cycle:'', // 保養週期 cycle:'', // 保養週期
method:'', //保養方式 method:'', //保養方式
checkYear:'', //竣工檢查年度 checkYear:'', //竣工檢查年度
@ -43,7 +43,7 @@ const pricereviewCreate = ()=>{
qty:1, //電梯數量 qty:1, //電梯數量
sale_price:'', //契約報價 sale_price:'', //契約報價
}, },
otherOptions: [], otherOptions: otherOptions,
modalOtherOptionInfo:{ modalOtherOptionInfo:{
pr_no:"", pr_no:"",
name:"", name:"",
@ -51,16 +51,16 @@ const pricereviewCreate = ()=>{
num:"", num:"",
memo:"", memo:"",
}, },
otherOptionKey:0, otherOptionKey: otherOptionKey,
currentOtherOptionKey:'', currentOtherOptionKey:'',
toElevators:[], toElevators:[],
toElevatorNo:'', toElevatorNo:'',
serviceFee:0, serviceFee: service_fee,
remark:'', remark:memo,
penalty:'', penalty: penalty,
deposit_rate:'', deposit_rate: deposit_rate,
keep_rate:'', keep_rate: keep_rate,
warranty_rate:'', warranty_rate: warranty_rate,
openCreateElevatorModal(){ openCreateElevatorModal(){
this.modalShow.elevator = true; this.modalShow.elevator = true;
body.style.overflow = 'hidden'; body.style.overflow = 'hidden';
@ -77,7 +77,7 @@ const pricereviewCreate = ()=>{
permitNumber:'', //許可證號碼 permitNumber:'', //許可證號碼
brand:'', //品牌 brand:'', //品牌
m1:'N', //贈送M1 m1:'N', //贈送M1
months:'', // 保養月數 months:12, // 保養月數
cycle:'', // 保養週期 cycle:'', // 保養週期
method:'', //保養方式 method:'', //保養方式
checkYear:'', //竣工檢查年度 checkYear:'', //竣工檢查年度
@ -141,7 +141,6 @@ const pricereviewCreate = ()=>{
const price = this.elevators[idx].price; const price = this.elevators[idx].price;
const qty = this.elevators[idx].qty; const qty = this.elevators[idx].qty;
const sale_price = this.elevators[idx].sale_price; const sale_price = this.elevators[idx].sale_price;
this.total_spec ++; this.total_spec ++;
this.elevators.push({ this.elevators.push({
id: this.total_spec, id: this.total_spec,
@ -167,6 +166,15 @@ const pricereviewCreate = ()=>{
removeElevator(id){ removeElevator(id){
if(!confirm('確定刪除該電梯?')) return; if(!confirm('確定刪除該電梯?')) return;
this.elevators = this.elevators.filter(elevator=> elevator.id != id) this.elevators = this.elevators.filter(elevator=> elevator.id != id)
const issetElevators = [];
this.elevators.forEach(elevator=>{
issetElevators.push(elevator.id);
})
this.otherOptions.forEach(option=>{
option.toElevator = option.toElevator.filter(el=>{
return issetElevators.includes(el.id)
})
})
}, },
openCreateOtherOptionFn(){ openCreateOtherOptionFn(){
this.modalShow.other = true this.modalShow.other = true
@ -298,11 +306,29 @@ const pricereviewCreate = ()=>{
console.error("Error message:", error); console.error("Error message:", error);
} }
}, },
async getElevatorPrice(idx){
const spec = this.elevators[idx].spec
const person = this.elevators[idx].person
const stop = this.elevators[idx].stop
const weight = this.elevators[idx].weight
const speed = this.elevators[idx].speed
const m1 = this.elevators[idx].m1
const method = this.elevators[idx].method
const cycle = this.elevators[idx].cycle
try{
const res = await axios.get('./api/getElevatorPrice.php', {params: {spec: spec, person:person, weight: weight, stop: stop, speed: speed, m1: m1, method: method, cycle:cycle}})
this.elevators[idx].price = res.data;
console.log(res.data);
}catch (error) {
console.error("Error message:", error);
}
},
save(){ save(){
const form = new FormData(); const form = new FormData();
form.append('vol_no', this.vol_no); form.append('vol_no', this.vol_no);
form.append('apply_key', this.apply_key); form.append('apply_key', this.apply_key);
form.append('customer', this.customer); form.append('customer', this.customer);
form.append('brand', this.brand);
form.append('address', this.address); form.append('address', this.address);
form.append('case_name', this.case_name); form.append('case_name', this.case_name);
form.append('brand', this.brand); form.append('brand', this.brand);
@ -318,10 +344,12 @@ const pricereviewCreate = ()=>{
form.append('keep_rate', this.keep_rate); form.append('keep_rate', this.keep_rate);
form.append('warranty_rate', this.warranty_rate); form.append('warranty_rate', this.warranty_rate);
form.append('remark', this.remark); form.append('remark', this.remark);
form.append('creater', this.user_id); form.append('creater', user_id);
form.append('pay_method', this.pay_method); form.append('pay_method', this.pay_method);
form.append('status', 'Y1'); form.append('status', 'Y1');
form.append('total_price', this.totalPrice);
form.append('total_sale_price', this.totalSalePrice);
form.append('elevators', JSON.stringify(this.elevators)); form.append('elevators', JSON.stringify(this.elevators));
form.append('otherOptions', JSON.stringify(this.otherOptions)); form.append('otherOptions', JSON.stringify(this.otherOptions));
@ -330,12 +358,49 @@ const pricereviewCreate = ()=>{
console.log(res.data); console.log(res.data);
if(res.data == 'success'){ if(res.data == 'success'){
alert("保存成功!"); alert("保存成功!");
// window.location.reload(); window.location.reload();
} }
}) })
}, },
submit(){ submit(){
const form = new FormData();
form.append('vol_no', this.vol_no);
form.append('apply_key', this.apply_key);
form.append('customer', this.customer);
form.append('brand', this.brand);
form.append('address', this.address);
form.append('case_name', this.case_name);
form.append('brand', this.brand);
form.append('num', this.totalElevatorsNum);
form.append('salesman', this.salesman);
form.append('contract_begin_date', this.startDate);
form.append('contract_end_date', this.endDate);
form.append('contract_kind', this.contract_status);
form.append('progress_status', this.progress_status);
form.append('serviceFee', this.serviceFee);
form.append('penalty', this.penalty);
form.append('deposit_rate', this.deposit_rate);
form.append('keep_rate', this.keep_rate);
form.append('warranty_rate', this.warranty_rate);
form.append('remark', this.remark);
form.append('creater', user_id);
form.append('pay_method', this.pay_method);
form.append('status', 'YS');
form.append('total_price', this.totalPrice);
form.append('total_sale_price', this.totalSalePrice);
form.append('elevators', JSON.stringify(this.elevators));
form.append('otherOptions', JSON.stringify(this.otherOptions));
axios.post('./api/postElevatorPricereview.php', form).then(res=>{
console.log(res.data);
if(res.data == 'success'){
alert("送審成功!");
// window.location.reload();
// window.location.href = './pricereview-index.php?' + token;
}
})
}, },
async getUsername(user_id){ async getUsername(user_id){
if(user_id == '') return '---' if(user_id == '') return '---'

147
wms/cont/pricereviewCreate.php

@ -13,8 +13,90 @@ $stmt->bindParam(':vol_no', $vol_no);
$stmt->execute(); $stmt->execute();
$hope_customer = $stmt->fetch(PDO::FETCH_ASSOC); $hope_customer = $stmt->fetch(PDO::FETCH_ASSOC);
$apply_key = getApplyKey(date('ym'), 'cmea_apply_key');
echo $apply_key; $sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute();
$apply = $stmt->fetch(PDO::FETCH_ASSOC);
if($apply['status'] == 'D'){
echo "<script>alert('非法訪問');window.history.go(-1);</script>";
}
if($apply['status'] == 'YS'){
echo "<script>alert('此單正在審核中!');window.history.go(-1);</script>";
}
if($apply['status'] == 'YY' || $apply['status'] == 'YN'){
echo "<script>alert('此單已申請過!');window.history.go(-1);</script>";
}
$apply_key = $apply ? $apply['apply_key'] : getApplyKey(date('ym'), 'cmea_apply_key');
$sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key ORDER BY created_at ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$hope_elevators = [];
$total_spec = 0;
foreach($elevators as $elevator){
if($elevator['item_no'] > $total_spec){
$total_spec = $elevator['item_no'];
}
if($elevator['cmstatus'] == 'D') continue;
$hope_elevators[] = [
'id'=> $elevator['item_no'],
'spec'=> $elevator['spec'],
'person'=> $elevator['persons'],
'weight'=> $elevator['weight'],
'stop'=> $elevator['stop'],
'speed'=> $elevator['speed'],
'permitNumber'=> $elevator['register_code'],
'brand'=> $elevator['elevator_brand'],
'm1'=> $elevator['is_m1_bundle'],
'months'=> $elevator['maintain_months'],
'cycle'=> $elevator['maintain_period'],
'method'=> $elevator['maintain_method'],
'checkYear'=> $elevator['useful_years'],
'lastDate'=> $elevator['last_check_date'],
'yearCheckFee'=> $elevator['annual_survey_expense'],
'price'=> $elevator['stand_price'],
'qty'=> $elevator['elevator_num'],
'sale_price'=> $elevator['contract_price'],
];
}
$sql_str = "SELECT * FROM pricereview_maintain_item WHERE (mid, item_group) = (:apply_key, 'E') ORDER BY id ASC";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key);
$stmt->execute();
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$otherOptions = [];
$otherOptionKey = 0;
foreach($items as $item){
if($item['item_no'] > $otherOptionKey){
$otherOptionKey = (int)$item['item_no'];
}
if($item['option_relate_spec']!= 0 ){
}
$toElevator = $item['option_relate_spec']==0 ? [] : [[
'id'=>$item['option_relate_spec'],
'model'=> array_values(array_filter($hope_elevators, fn($val)=> $val['id'] == $item['option_relate_spec']))[0]['spec'],
]];
$otherOptions[] = [
'id'=> $item['item_no'],
'pr_no'=> $item['price_id'],
'name'=> $item['item_spec'],
'price' => $item['item_unit_price'],
'num'=> $item['item_qty'],
'memo'=> $item['memo'],
'toElevator'=>$toElevator,
];
}
function getApplyKey($p_yyyymm, $seq_name){ function getApplyKey($p_yyyymm, $seq_name){
if (empty($p_yyyymm) || empty($seq_name)) return null; if (empty($p_yyyymm) || empty($seq_name)) return null;
global $conn; global $conn;
@ -78,7 +160,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</tr> </tr>
<tr> <tr>
<th>電梯品牌</th> <th>電梯品牌</th>
<td><input class="form-control" type="text" disabled value="<?php echo $hope_customer['brand']; ?>" /></td> <td><input class="form-control" type="text" disabled x-model="brand" /></td>
<th>電梯數量</th> <th>電梯數量</th>
<td><input class="form-control" type="number" disabled value="<?php echo $hope_customer['num']; ?>" /></td> <td><input class="form-control" type="number" disabled value="<?php echo $hope_customer['num']; ?>" /></td>
<th>營業員</th> <th>營業員</th>
@ -106,6 +188,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<option value="2">免保轉有費</option> <option value="2">免保轉有費</option>
<option value="3">續約</option> <option value="3">續約</option>
</select> </select>
<span class="errortext" x-cloak data-type="errortext" x-show="contract_status == ''">請選擇契約性質</span>
</td> </td>
<th>付款方式</th> <th>付款方式</th>
<td> <td>
@ -117,13 +200,23 @@ function getApplyKey($p_yyyymm, $seq_name){
<option value="A40005">半年繳</option> <option value="A40005">半年繳</option>
<option value="A40006">年繳</option> <option value="A40006">年繳</option>
</select> </select>
<span class="errortext" x-cloak data-type="errortext" x-show="pay_method == ''">請選擇付款方式</span>
</td> </td>
<th>案件名稱</th> <th>案件名稱</th>
<td><input class="form-control" type="text" x-model="case_name" /></td> <td>
<input class="form-control" type="text" x-model="case_name" />
<span class="errortext" x-cloak data-type="errortext" x-show="!case_name">請填寫案件名稱</span>
</td>
<th>合約開始日期</th> <th>合約開始日期</th>
<td><input type="date" class="form-control" x-model="startDate" /></td> <td>
<input type="date" class="form-control" x-model="startDate" />
<span class="errortext" x-cloak data-type="errortext" x-show="!startDate || startDate == '0000-00-00'">請填寫合約開始日期</span>
</td>
<th>合約結束日期</th> <th>合約結束日期</th>
<td><input type="date" class="form-control" x-model="endDate" /></td> <td>
<input type="date" class="form-control" x-model="endDate" />
<span class="errortext" x-cloak data-type="errortext" x-show="!endDate || endDate == '0000-00-00'">請填寫合約結束日期</span>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -136,7 +229,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<tbody> <tbody>
<tr> <tr>
<td colspan=8> <td colspan=8>
<textarea class="form-control" name="progress" id="progress" cols="20" rows="5" disabled ><?php echo nl2br($hope_customer['progress_status']); ?></textarea> <textarea class="form-control" name="progress" id="progress" cols="20" rows="5" disabled x-html="progress_status"></textarea>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -179,28 +272,26 @@ function getApplyKey($p_yyyymm, $seq_name){
<tr> <tr>
<th >電梯</th> <th >電梯</th>
<td> <td>
<select class="form-control" x-model="elevator.spec"> <select class="form-control" x-model="elevator.spec" @change="getElevatorPrice(idx)">
<option value="">請選擇</option> <option value="">請選擇</option>
<option value="MAE100">MAE100有機房</option> <option value="MAE100">MAE100有機房</option>
<option value="MAM200">MAM200無機房</option> <option value="MAM200">MAM200無機房</option>
<option value="MAH100">MAH100小電梯</option> <option value="MAH100">MAH100小電梯</option>
<option value="MAF100">MAF100貨梯(有機房)</option> <option value="MAF100">MAF100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option>
</select> </select>
</td> </td>
<th>載重(KG)</th> <th>載重(KG)</th>
<td> <td>
<input type="number" class="form-control" x-model="elevator.weight" /> <input type="number" class="form-control" x-model="elevator.weight" @change="getElevatorPrice(idx)" @keyup="getElevatorPrice(idx)" />
</td> </td>
<th>停數</th> <th>停數</th>
<td> <td>
<input type="number" class="form-control" x-model="elevator.stop" /> <input type="number" class="form-control" x-model="elevator.stop" @keyup="getElevatorPrice(idx)" />
</td> </td>
<th>速度(m/min)</th> <th>速度(m/min)</th>
<td> <td>
<select name="" id="" class="form-control" style="width:93px" x-model="elevator.speed" @change="getElevatorPrice()" > <select name="" id="" class="form-control" style="width:93px" x-model="elevator.speed" @change="getElevatorPrice(idx)" >
<option value="">請選擇</option> <option value="">請選擇</option>
<option value="9">9</option> <option value="9">9</option>
<option value="24">24</option> <option value="24">24</option>
@ -215,7 +306,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td> </td>
<th>人乘</th> <th>人乘</th>
<td> <td>
<select class="form-control" x-model="elevator.person"> <select class="form-control" x-model="elevator.person" @change="getElevatorPrice(idx)">
<option value="">請選擇</option> <option value="">請選擇</option>
<option value="6">6</option> <option value="6">6</option>
<option value="8">8</option> <option value="8">8</option>
@ -296,7 +387,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td> </td>
<th>保養方式</th> <th>保養方式</th>
<td> <td>
<select class="form-control" x-model="elevator.method"> <select class="form-control" x-model="elevator.method" @change="getElevatorPrice(idx)">
<option value="">請選擇</option> <option value="">請選擇</option>
<option value="A">全包</option> <option value="A">全包</option>
<option value="B">半包</option> <option value="B">半包</option>
@ -305,7 +396,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</td> </td>
<th>贈送M1</th> <th>贈送M1</th>
<td> <td>
<select class="form-control" x-model="elevator.m1"> <select class="form-control" x-model="elevator.m1" @change="getElevatorPrice(idx)">
<option value="N"></option> <option value="N"></option>
<option value="Y"></option> <option value="Y"></option>
</select> </select>
@ -315,6 +406,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<th>公司發布價(月)</th> <th>公司發布價(月)</th>
<td> <td>
<input type="text" class="form-control" disabled x-model="elevator.price.toLocaleString()" /> <input type="text" class="form-control" disabled x-model="elevator.price.toLocaleString()" />
<span class="errortext" x-show="elevator.price <= 0">公司無提供此規格牌價</span>
</td> </td>
<th>保養月數</th> <th>保養月數</th>
<td> <td>
@ -387,7 +479,7 @@ function getApplyKey($p_yyyymm, $seq_name){
</template> </template>
<tr x-show="otherOptions.length > 0"> <tr x-show="otherOptions.length > 0">
<td colspan=3>小計</td> <td colspan=3>小計</td>
<td colspan=1 ><input type="number" class="form-control" disabled :value="totalOtherOptionsNum.toLocaleString()" style="width:100px" /></td> <td colspan=1 ><input type="text" class="form-control" disabled :value="totalOtherOptionsNum.toLocaleString()" style="width:100px" /></td>
<td colspan=1 ><input type="text" class="form-control" disabled :value="totalOtherOptionsPrice.toLocaleString()" ></td> <td colspan=1 ><input type="text" class="form-control" disabled :value="totalOtherOptionsPrice.toLocaleString()" ></td>
<td colspan=3 ></td> <td colspan=3 ></td>
</tr> </tr>
@ -484,4 +576,25 @@ function getApplyKey($p_yyyymm, $seq_name){
const user_id = '<?php echo $user_id ?>'; const user_id = '<?php echo $user_id ?>';
const user_name = '<?php echo $user_name ?>'; const user_name = '<?php echo $user_name ?>';
const progress_remark = `<?php echo nl2br($hope_customer['progress_status']); ?>`; const progress_remark = `<?php echo nl2br($hope_customer['progress_status']); ?>`;
const memo = `<?php echo nl2br($apply['memo']); ?>`;
const contract_kind = '<?php echo $apply ? $apply['contract_kind'] : '' ?>';
const payment_kind = '<?php echo $apply ? $apply['payment_kind'] : '' ?>';
const case_name = '<?php echo $apply ? $apply['case_name'] : '' ?>';
const contract_begin_date = '<?php echo $apply ? $apply['contract_begin_date'] : '' ?>';
const contract_end_date = '<?php echo $apply ? $apply['contract_end_date'] : '' ?>';
const total_spec = '<?php echo $total_spec; ?>';
const hope_elevators = [...<?php echo json_encode($hope_elevators); ?>];
const otherOptionKey = '<?php echo $otherOptionKey; ?>';
const otherOptions = [...<?php echo json_encode($otherOptions); ?>];
const token = '<?php echo $para = "function_name=pricereview&" . $token_link;; ?>';
const penalty = '<?php echo $apply['penalty']; ?>';
const deposit_rate = '<?php echo $apply['deposit_rate']; ?>';
const keep_rate = '<?php echo $apply['keep_rate']; ?>';
const warranty_rate = '<?php echo $apply['warranty_rate']; ?>';
const service_fee = '<?php echo $apply['service_fee']; ?>';
</script> </script>

2
wms/cont/window-modal/modalElevaotr.php

@ -110,7 +110,7 @@
<th colspan=2>保養方式</th> <th colspan=2>保養方式</th>
</tr> </tr>
<tr class="table-active"> <tr class="table-active">
<td colspan=2><input type="number" class="form-control" x-model="modalElevatorInfo.permitNumber" /></td> <td colspan=2><input type="text" class="form-control" x-model="modalElevatorInfo.permitNumber" /></td>
<td colspan=2> <td colspan=2>
<select class="form-control" x-model="modalElevatorInfo.method" @change="getModalElevatorPrice()"> <select class="form-control" x-model="modalElevatorInfo.method" @change="getModalElevatorPrice()">
<option value="">請選擇</option> <option value="">請選擇</option>

0
wms/mkt/assets/js/pricereviewAlpine.js → wms/mkt/assets/js/pricereviewAlpine0311.js

9
wms/mkt/pricereviewCheck.php

@ -264,7 +264,7 @@ function getSignerName($signer){
<link rel="stylesheet" href="./css/pricereview.css"> <link rel="stylesheet" href="./css/pricereview.css">
<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/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script defer src="./assets/js/alpinejs/cdn.min.js"></script> <script defer src="./assets/js/alpinejs/cdn.min.js"></script>
<script src="./assets/js/pricereviewAlpine.js"></script> <script src="./assets/js/pricereviewAlpine0311.js"></script>
<div id="pricereviewCheck" x-data=pricereviewCheck()> <div id="pricereviewCheck" x-data=pricereviewCheck()>
<?php include_once('./window-modal/historySignModal.php'); ?> <?php include_once('./window-modal/historySignModal.php'); ?>
@ -457,7 +457,7 @@ function getSignerName($signer){
</tbody> </tbody>
</table> </table>
<table class="table mi-table" border=1> <table class="table mi-table" border=1 x-show="false">
<thead> <thead>
<tr> <tr>
<th colspan=8>保固延長</th> <th colspan=8>保固延長</th>
@ -497,7 +497,7 @@ function getSignerName($signer){
</tbody> </tbody>
</table> </table>
<table class="table mi-table" border=1> <table class="table mi-table" border=1 x-show="is_renovate == '汰改'">
<thead> <thead>
<tr> <tr>
<th colspan=8>拆梯價格</th> <th colspan=8>拆梯價格</th>
@ -935,6 +935,7 @@ function getSignerName($signer){
const is_renovate = '<?php echo $contract['ekind']; ?>'; const is_renovate = '<?php echo $contract['ekind']; ?>';
const user_id = '<?php echo $user_id; ?>'; const user_id = '<?php echo $user_id; ?>';
const sign1 = '<?php echo ($sign) ? explode(',', $sign['sign1'])[0] : "---" ?>'; const sign1 = '<?php echo ($sign) ? explode(',', $sign['sign1'])[0] : "---" ?>';
@ -946,4 +947,6 @@ function getSignerName($signer){
const currentSignId = '<?php echo $currentSignId; ?>'; const currentSignId = '<?php echo $currentSignId; ?>';
const token = '<?php echo $para = "function_name=pricereview&" . $token_link;; ?>'; const token = '<?php echo $para = "function_name=pricereview&" . $token_link;; ?>';
const form_key = '<?php echo $form_key; ?>'; const form_key = '<?php echo $form_key; ?>';
console.log(is_renovate);
</script> </script>

2
wms/mkt/pricereviewCreate.php

@ -376,7 +376,7 @@ function convertDateTimeFormat($dateTimeStr) {
<link rel="stylesheet" href="./css/pricereview.css"> <link rel="stylesheet" href="./css/pricereview.css">
<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/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script defer src="./assets/js/alpinejs/cdn.min.js"></script> <script defer src="./assets/js/alpinejs/cdn.min.js"></script>
<script src="./assets/js/pricereviewAlpine.js"></script> <script src="./assets/js/pricereviewAlpine0311.js"></script>
<div id="pricereviewCreate" x-data=pricereviewCreate()> <div id="pricereviewCreate" x-data=pricereviewCreate()>
<?php <?php

Loading…
Cancel
Save