Browse Source

新梯/汰改價審更新 0226 ,差上傳報價單

main
10994015 1 year ago
parent
commit
cd7677d15a
  1. BIN
      wms/contract/option/facility.xlsx
  2. 2
      wms/crm/crmm01-index.php
  3. 2
      wms/database.php
  4. 21
      wms/mkt/api/getDemolishPrice.php
  5. 7
      wms/mkt/api/getElevatorMi.php
  6. 4
      wms/mkt/api/getElevatorPrice.php
  7. 5
      wms/mkt/api/getUsername.php
  8. 785
      wms/mkt/api/postNewElevatorPricereview.php
  9. 56
      wms/mkt/api/putNewElevatorPriceview.php
  10. 444
      wms/mkt/assets/js/pricereviewAlpine.js
  11. 15
      wms/mkt/css/pricereview.css
  12. 2
      wms/mkt/css/pricereview.css.map
  13. 15
      wms/mkt/css/pricereview.scss
  14. BIN
      wms/mkt/files/MAF200.xlsx
  15. BIN
      wms/mkt/files/MAQ100.xlsx
  16. 248
      wms/mkt/price_normal-index.php
  17. 2
      wms/mkt/pricereview-index.php
  18. 261
      wms/mkt/pricereviewCheck.php
  19. 641
      wms/mkt/pricereviewCreate.php
  20. 4
      wms/mkt/pricereview_renovate-index.php

BIN
wms/contract/option/facility.xlsx

Binary file not shown.

2
wms/crm/crmm01-index.php

@ -197,7 +197,7 @@ if ($data) :
$pricereview_url = "../mkt/pricereview_renovate-create.php"; $pricereview_url = "../mkt/pricereview_renovate-create.php";
$fname = "pricereview_renovate"; $fname = "pricereview_renovate";
} else { } else {
$pricereview_url = "../mkt/pricereview-create.php"; $pricereview_url = "../mkt/pricereviewCreate.php";
$fname = "pricereview"; $fname = "pricereview";
} }
} }

2
wms/database.php

@ -19,7 +19,7 @@ $host = getenv('DB_HOST');
$dbuser = getenv('DB_USERNAME'); $dbuser = getenv('DB_USERNAME');
$dbpassword = getenv('DB_PASSWORD'); $dbpassword = getenv('DB_PASSWORD');
$dbname = getenv('DB_DATABASE'); $dbname = getenv('DB_DATABASE');
// $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname); $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname);
$sqlsrv = getenv('sqlsrv'); $sqlsrv = getenv('sqlsrv');
$Database = getenv('Database'); $Database = getenv('Database');

21
wms/mkt/api/getDemolishPrice.php

@ -0,0 +1,21 @@
<?php
require_once('../conn.php');
$person = $_GET['person'];
$floor = $_GET['floor'];
$sql_str = "SELECT id, price FROM demolition_price WHERE seat = :person AND floor = :floor AND status = 'Y' ORDER BY id DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':person', $person);
$stmt->bindParam(':floor', $floor);
$stmt->execute();
$demolish = $stmt->fetch(PDO::FETCH_ASSOC);
if($demolish){
echo json_encode(['price'=> $demolish['price'], 'id'=> $demolish['id']]);
}else{
echo false;
}

7
wms/mkt/api/getElevatorMi.php

@ -31,8 +31,10 @@ $unloading_fee = round($mi['unloading']);
$transport_site_fee = round($mi['transport_site']); $transport_site_fee = round($mi['transport_site']);
$install_fee = round(($mi['install_price'] + ($stop - $mi['base_floor']) * $mi['install_plus']) + $mi['trial_price'] + ($stop - $mi['base_floor']) * $mi['trial_plus']); $install_fee = round(($mi['install_price'] + ($stop - $mi['base_floor']) * $mi['install_plus']) + $mi['trial_price'] + ($stop - $mi['base_floor']) * $mi['trial_plus']);
$free1y_fee = round($mi['free1y']); $free1y_fee = round($mi['free1y']);
$other_fee = round($mi['crane'] + $mi['wooden_box'] + $mi['consumables']); $other_fee = round($mi['crane'] + $mi['wooden_box'] + $mi['consume'] + $mi['consumables']);
$add_price = 0;
if($spec == 'MAH100') $add_price = 13500;
$newMI = [ $newMI = [
'equipment_fee'=>$equipment_fee, 'equipment_fee'=>$equipment_fee,
@ -41,6 +43,7 @@ $newMI = [
'transport_site_fee'=>$transport_site_fee, 'transport_site_fee'=>$transport_site_fee,
'install_fee'=>$install_fee, 'install_fee'=>$install_fee,
'free1y_fee'=>$free1y_fee, 'free1y_fee'=>$free1y_fee,
'other_fee'=>$other_fee 'other_fee'=>$other_fee,
'add_price'=>$add_price,
]; ];
echo json_encode($newMI); echo json_encode($newMI);

4
wms/mkt/api/getElevatorPrice.php

@ -3,10 +3,12 @@
require_once("../conn.php"); require_once("../conn.php");
$model = $_GET['model']; $model = $_GET['model'];
$kind = $_GET['kind'];
$sql_str = "SELECT id, model, price FROM facility_price WHERE model = :model ORDER BY id DESC"; $sql_str = "SELECT id, model, price FROM facility_price WHERE model = :model AND kind = :kind ORDER BY id DESC";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':model', $model); $stmt->bindParam(':model', $model);
$stmt->bindParam(':kind', $kind);
$stmt->execute(); $stmt->execute();
$el = $stmt->fetch(PDO::FETCH_ASSOC); $el = $stmt->fetch(PDO::FETCH_ASSOC);
if($el){ if($el){

5
wms/mkt/api/getUsername.php

@ -3,7 +3,10 @@
require_once('../conn.php'); require_once('../conn.php');
$accountid = $_GET['user_id']; $accountid = $_GET['user_id'];
if($accountid == "---"){
echo "---";
exit;
}
$sql_str = "SELECT name FROM account WHERE accountid = :accountid"; $sql_str = "SELECT name FROM account WHERE accountid = :accountid";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accountid', $accountid); $stmt->bindParam(':accountid', $accountid);

785
wms/mkt/api/postNewElevatorPricereview.php

@ -14,6 +14,7 @@ $price_total = $_POST['price_total'];
$price_rate = $_POST['price_rate']; $price_rate = $_POST['price_rate'];
$special_fee = $_POST['special_fee']; $special_fee = $_POST['special_fee'];
$predeal_date = $_POST['predeal_date']; $predeal_date = $_POST['predeal_date'];
$facilitok_date = $_POST['facilitok_date'];
$penalty = $_POST['penalty']; $penalty = $_POST['penalty'];
$deposit_rate = $_POST['deposit_rate']; $deposit_rate = $_POST['deposit_rate'];
$warranty_rate = $_POST['warranty_rate']; $warranty_rate = $_POST['warranty_rate'];
@ -22,213 +23,647 @@ $memo = $_POST['memo'];
$status = $_POST['status']; $status = $_POST['status'];
$attatch1 = $_POST['attatch1'] =='' ? NULL : $_POST['attatch1']; $attatch1 = $_POST['attatch1'] =='' ? NULL : $_POST['attatch1'];
$attatch2 = $_POST['attatch2'] =='' ? NULL : $_POST['attatch2']; $attatch2 = $_POST['attatch2'] =='' ? NULL : $_POST['attatch2'];
$creater = "M0174"; $creater = $_POST['user_id'];
$create_at = date("Y-m-d H:i:s"); $create_at = date("Y-m-d H:i:s");
$elevators = $_POST['elevators']; $elevators = json_decode($_POST['elevators'], true);
$options = $_POST['options']; $options = json_decode($_POST['options'], true);
$otherOptions = $_POST['otherOptions']; $otherOptions = json_decode($_POST['otherOptions'], true);
$demolishOptions = json_decode($_POST['demolishOptions'], true);
$maintainOptions = $_POST['maintainOptions']; $maintainOptions = $_POST['maintainOptions'];
$paymentRatio = $_POST['paymentRatio']; $paymentRatio = json_decode($_POST['paymentRatio'], true);
$conn->beginTransaction(); $conn->beginTransaction();
$sql_str = "SELECT id FROM pricereview_main WHERE contractno = :contractno ORDER BY id DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->execute();
$main = $stmt->fetch(PDO::FETCH_ASSOC);
try{ if($main){
try{
$sql_str = "INSERT INTO pricereview_main (contractno, ekind, person, company, case_name, address, compete, price_lowest, price_total, price_rate, special_fee, predeal_date, facilitok_date, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, attatch1, attatch2, creater, create_at) $mid = $main["id"];
VALUES (:contractno, :ekind, :person, :company, :case_name, :address, :compete, :price_lowest, :price_total, :price_rate, :special_fee, :predeal_date, :facilitok_date, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :attatch1, :attatch2, :creater, :create_at)"; $sql_str = "UPDATE pricereview_main SET price_lowest=:price_lowest, price_total=:price_total, price_rate=:price_rate, special_fee=:special_fee, predeal_date=:predeal_date, facilitok_date=:facilitok_date, penalty=:penalty, deposit_rate=:deposit_rate, keep_rate=:keep_rate, warranty_rate=:warranty_rate, memo=:memo,status=:status, attatch1=:attatch1, attatch2=:attatch2 WHERE id = :id ";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':ekind', $ekind);
$stmt->bindParam(':person', $person);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':compete', $compete);
$stmt->bindParam(':price_lowest', $price_lowest);
$stmt->bindParam(':price_total', $price_total);
$stmt->bindParam(':price_rate', $price_rate);
$stmt->bindParam(':special_fee', $special_fee);
$stmt->bindParam(':predeal_date', $predeal_date);
$stmt->bindParam(':facilitok_date', $facilitok_date);
$stmt->bindParam(':penalty', $penalty);
$stmt->bindParam(':deposit_rate', $deposit_rate);
$stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':memo', $memo);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':attatch1', $attatch1);
$stmt->bindParam(':attatch2', $attatch2);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
$mid = $conn->lastInsertId();
//insert 整機單價
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, item_weight, item_op, item_unit_price, item_qty, item_price_bp, item_price_ct, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :item_weight, :item_op, :item_unit_price, :item_qty, :item_price_bp, :item_price_ct, :note)";
foreach(json_decode($elevators, true) as $elevator){
$price_id = $elevator['facility_id'];
$item_no = $elevator['id'];
$item_group = "A";
$item_spec = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed'];
$item_weight = "";
$item_op = $elevator['open_converted'];
$item_unit_price = $elevator['price'];
$item_qty = (int)$elevator['spec_num'];
$item_price_bp = (int)$elevator['price'] * (int)$elevator['spec_num'];
$item_price_ct = $elevator['spec_price'];
$note = $elevator['specifications'] . ',' . $elevator['person'] . ',' . $elevator['stop'] . ',' . $elevator['speed'];
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid); $stmt->bindParam(':id', $mid);
$stmt->bindParam(':price_id', $price_id); $stmt->bindParam(':price_lowest', $price_lowest);
$stmt->bindParam(':item_no', $item_no); $stmt->bindParam(':price_total', $price_total);
$stmt->bindParam(':item_group', $item_group); $stmt->bindParam(':price_rate', $price_rate);
$stmt->bindParam(':item_spec', $item_spec); $stmt->bindParam(':special_fee', $special_fee);
$stmt->bindParam(':item_weight', $item_weight); $stmt->bindParam(':predeal_date', $predeal_date);
$stmt->bindParam(':item_op', $item_op); $stmt->bindParam(':facilitok_date', $facilitok_date);
$stmt->bindParam(':item_unit_price', $item_unit_price); $stmt->bindParam(':penalty', $penalty);
$stmt->bindParam(':item_qty', $item_qty); $stmt->bindParam(':deposit_rate', $deposit_rate);
$stmt->bindParam(':item_price_bp', $item_price_bp); $stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':item_price_ct', $item_price_ct); $stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':note', $note); $stmt->bindParam(':memo', $memo);
$stmt->execute(); $stmt->bindParam(':status', $status);
} $stmt->bindParam(':attatch1', $attatch1);
$stmt->bindParam(':attatch2', $attatch2);
//insert options 加價
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)";
foreach(json_decode($options, true) as $option){ $stmt->execute();
$price_id = $option['id'];
$item_no = $option['key'] + 1;
$item_group = "B";
$item_spec = $option['name'] . $option['memo'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['qty'];
$item_price_bp = $option['price'] * $option['qty'];
//整機單價
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid); $stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute(); $stmt->execute();
} $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldElevators = array_filter($items, fn($el)=> $el['item_group'] == "A");
$oldItemsNo = (array)array_column($oldElevators, 'item_no');
$newItemsNo = (array)array_column($elevators, 'id');
$onlyInOldIds = array_values(array_diff($oldItemsNo, $newItemsNo)); // 只有舊的有,新傳入的沒有,所以刪除(delete)
$onlyInNewIds = array_values(array_diff($newItemsNo, $oldItemsNo)); //只有新傳入的有,舊的沒有,所以新增(insert)
$inBothIds = array_values(array_intersect($oldItemsNo, $newItemsNo)); //舊的跟新的都有,所以要更新(update)
foreach($onlyInOldIds as $oldidx){
$sql_str = "DELETE FROM pricereview_item WHERE mid = :mid AND item_no = :item_no AND item_group='A'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $oldidx);
$stmt->execute();
}
foreach($onlyInNewIds as $newidx){
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, item_weight, item_op, item_unit_price, item_qty, item_price_bp, item_price_ct, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :item_weight, :item_op, :item_unit_price, :item_qty, :item_price_bp, :item_price_ct, :note)";
//insert 除外項目 $elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $newidx))[0];
$sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp) $price_id = $elevator['facility_id'];
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; $item_no = $elevator['id'];
$item_group = "A";
$item_spec = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed'];
$item_weight = "";
$item_op = $elevator['open_converted'];
foreach(json_decode($otherOptions, true) as $option){ $item_unit_price = $elevator['price'];
$item_no = $option['id'] + 1; $item_qty = (int)$elevator['spec_num'];
$item_group = "E"; $item_price_bp = (int)$elevator['price'] * (int)$elevator['spec_num'];
$item_spec = $option['name']; $item_price_ct = $elevator['spec_price'];
$option_relate_spec = $option['toElevator'][0]['id']; $note = $elevator['specifications'] . ',' . $elevator['person'] . ',' . $elevator['stop'] . ',' . $elevator['speed'];
$item_unit_price = $option['price']; $stmt = $conn->prepare($sql_str);
$item_qty = $option['num']; $stmt->bindParam(':mid', $mid);
$item_price_bp = $option['price'] * $option['num']; $stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':item_weight', $item_weight);
$stmt->bindParam(':item_op', $item_op);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':item_price_ct', $item_price_ct);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
foreach($inBothIds as $bothidx){
$elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $bothidx))[0];
$price_id = $elevator['facility_id'];
$item_no = $elevator['id'];
$item_group = "A";
$item_spec = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed'];
$item_weight = "";
$item_op = $elevator['open_converted'];
$item_unit_price = $elevator['price'];
$item_qty = (int)$elevator['spec_num'];
$item_price_bp = (int)$elevator['price'] * (int)$elevator['spec_num'];
$item_price_ct = $elevator['spec_price'];
$note = $elevator['specifications'] . ',' . $elevator['person'] . ',' . $elevator['stop'] . ',' . $elevator['speed'];
$sql_str = "UPDATE pricereview_item SET price_id=:price_id, item_spec=:item_spec, item_weight=:item_weight, item_op=:item_op, item_unit_price=:item_unit_price, item_qty=:item_qty, item_price_bp=:item_price_bp, item_price_ct=:item_price_ct, note=:note WHERE item_no = :item_no AND mid = :mid AND item_group='A' ";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':item_no', $bothidx);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':item_weight', $item_weight);
$stmt->bindParam(':item_op', $item_op);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':item_price_ct', $item_price_ct);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
//Option加價
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'B'";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid); $stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute(); $stmt->execute();
} $item_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldOptionsNo = (array)array_column($item_options, 'item_no');
$newOptioinNo = (array)array_column($options, 'key');
$onlyInOptionOldIds = array_values(array_diff($oldOptionsNo, $newOptioinNo));
$onlyInOptionNewIds = array_values(array_diff($newOptioinNo, $oldOptionsNo));
$inBothOptionIds = array_values(array_intersect($oldOptionsNo, $newOptioinNo));
foreach($onlyInOptionOldIds as $oldoptionidx){
$sql_str = "DELETE FROM pricereview_item WHERE mid = :mid AND item_no = :item_no AND item_group='B'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $oldoptionidx);
$stmt->execute();
}
foreach($onlyInOptionNewIds as $newoptionidx){
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, item_weight, item_op, item_unit_price, item_qty, item_price_bp, item_price_ct, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :item_weight, :item_op, :item_unit_price, :item_qty, :item_price_bp, :item_price_ct, :note)";
$option = array_values(array_filter($options, fn($el)=> $el['key'] == $newoptionidx))[0];
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)";
$sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp) $price_id = $option['id'];
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; $item_no = $option['key'];
//insert 保養延長 $item_group = "B";
foreach(json_decode($maintainOptions, true) as $option){ $item_spec = $option['name'] . $option['memo'];
$item_no = $option['id'] + 1; $option_relate_spec = $option['toElevator'][0]['id'];
$item_group = "D"; $item_unit_price = $option['price'];
$item_spec = $option['toElevator'][0]['model']; $item_qty = $option['qty'];
$option_relate_spec = $option['toElevator'][0]['id']; $item_price_bp = $option['price'] * $option['qty'];
$item_unit_price = $option['price'];
$item_qty = $option['num']; $stmt = $conn->prepare($sql_str);
$item_price_bp = $option['price'] * $option['num']; $stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute();
}
foreach($inBothOptionIds as $bothoptionidx){
$option = array_values(array_filter($options, fn($el)=> $el['key'] == $bothoptionidx))[0];
$price_id = $option['id'];
$item_no = $option['key'];
$item_group = "B";
$item_spec = $option['name'] . $option['memo'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['qty'];
$item_price_bp = $option['price'] * $option['qty'];
$sql_str = "UPDATE pricereview_item SET price_id = :price_id, item_spec=:item_spec, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, option_relate_spec=:option_relate_spec WHERE mid = :mid AND item_no = :item_no AND item_group='B'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute();
}
//除外項目
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'E'";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid); $stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute(); $stmt->execute();
} $item_other_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldOtherOptionsNo = (array)array_column($item_other_options, 'item_no');
$newOtherOptioinNo = (array)array_column($otherOptions, 'id');
$onlyInOtherOptionOldIds = array_values(array_diff($oldOtherOptionsNo, $newOtherOptioinNo));
$onlyInOtherOptionNewIds = array_values(array_diff($newOtherOptioinNo, $oldOtherOptionsNo));
$inBothOtherOptionIds = array_values(array_intersect($oldOtherOptionsNo, $newOtherOptioinNo));
// echo "old:".json_encode($onlyInOtherOptionOldIds); //delete
// echo "new:".json_encode($onlyInOtherOptionNewIds); //insert
// echo "both:".json_encode($inBothOtherOptionIds); // update
foreach($onlyInOtherOptionOldIds as $oldotheroptionidx){
$sql_str = "DELETE FROM pricereview_item WHERE mid = :mid AND item_no = :item_no AND item_group='E'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $oldotheroptionidx);
$stmt->execute();
}
foreach($onlyInOtherOptionNewIds as $newotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $newotheroptionidx))[0];
$sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note)
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :note)";
$sql_str = "INSERT INTO pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period) $item_no = $option['id'];
VALUES (:mid, :pay_kind, :pay_scale, :pay_amount, :pay_period)"; $item_group = "E";
$item_spec = $option['name'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['num'];
$item_price_bp = $option['price'] * $option['num'];
$note = $option['pr_no'];
foreach(json_decode($paymentRatio, true) as $key=>$pay){ $stmt = $conn->prepare($sql_str);
$pay_kind = $key +1; $stmt->bindParam(':mid', $mid);
$pay_scale = $pay['scale'] == '' ? 0 : $pay['scale']; $stmt->bindParam(':item_no', $item_no);
$pay_amount = $pay['scale']/100 * $price_total; $stmt->bindParam(':item_group', $item_group);
$pay_period = ($pay['scale'] == '' || $pay['scale'] == 0) ? '' :$pay['ticket']; $stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
foreach($inBothOtherOptionIds as $bothotheroptionidx){
$option = array_values(array_filter($otherOptions, fn($el)=> $el['id'] == $bothotheroptionidx))[0];
$item_no = $option['id'];
$item_group = "E";
$item_spec = $option['name'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['num'];
$item_price_bp = $option['price'] * $option['num'];
$note = $option['pr_no'];
$sql_str = "UPDATE pricereview_item SET item_spec=:item_spec, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, option_relate_spec=:option_relate_spec, note=:note WHERE mid = :mid AND item_no = :item_no AND item_group='E'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
//拆梯價格
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'C'";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid); $stmt->bindParam(':mid', $mid);
$stmt->bindParam(':pay_kind', $pay_kind);
$stmt->bindParam(':pay_scale', $pay_scale);
$stmt->bindParam(':pay_amount', $pay_amount);
$stmt->bindParam(':pay_period', $pay_period);
$stmt->execute(); $stmt->execute();
} $item_demolish_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$oldDemolishOptionsNo = (array)array_column($item_demolish_options, 'item_no');
$newDemolishOptioinNo = (array)array_column($demolishOptions, 'id');
$onlyInDemolishOptionOldIds = array_values(array_diff($oldDemolishOptionsNo, $newDemolishOptioinNo));
$onlyInDemolishOptionNewIds = array_values(array_diff($newDemolishOptioinNo, $oldDemolishOptionsNo));
$inBothDemolishOptionIds = array_values(array_intersect($oldDemolishOptionsNo, $newDemolishOptioinNo));
// echo "old:".json_encode($onlyInDemolishOptionOldIds); //delete
// echo "new:".json_encode($onlyInDemolishOptionNewIds); //insert
// echo "both:".json_encode($inBothDemolishOptionIds); // update
foreach($onlyInDemolishOptionOldIds as $olddemolishoptionidx){
$sql_str = "DELETE FROM pricereview_item WHERE mid = :mid AND item_no = :item_no AND item_group='C'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $olddemolishoptionidx);
$stmt->execute();
}
foreach($onlyInDemolishOptionNewIds as $newdemolishoptionidx){
$option = array_values(array_filter($demolishOptions, fn($el)=> $el['id'] == $newdemolishoptionidx))[0];
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :note)";
$sql_str = "SELECT * FROM account WHERE accountid = :accountid"; $item_no = $option['id'];
$stmt = $conn->prepare($sql_str); $item_group = "C";
$stmt->bindParam(':accountid', $creater); $item_spec = $option['person'];
$stmt->execute(); $option_relate_spec = $option['toElevator'][0]['id'];
$account = $stmt->fetch(PDO::FETCH_ASSOC); $item_unit_price = $option['price'];
$manager = $account['manager']; $item_qty = (int)$option['qty'];
$item_price_bp = (int)$option['price'] * (int)$option['qty'];
$sign1 = "$manager,,"; //區處長 $note = $option['floor'];
$sign2 = NULL; // 業務承辦人 $price_id = $option['demolish_id'];
$sign3 = "M0060,,"; //業務部協理
$stmt = $conn->prepare($sql_str);
//是否呈核至總經理(M0006) $stmt->bindParam(':mid', $mid);
if($price_rate < 80 || $special_fee > 0){ $stmt->bindParam(':item_no', $item_no);
$sign4 = "M0006,,"; $stmt->bindParam(':item_group', $item_group);
$sign_total = 4; $stmt->bindParam(':item_spec', $item_spec);
}else{ $stmt->bindParam(':option_relate_spec', $option_relate_spec);
$sign4 = NULL; $stmt->bindParam(':item_unit_price', $item_unit_price);
$sign_total = 3; $stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':price_id', $price_id);
$stmt->execute();
}
foreach($inBothDemolishOptionIds as $bothdemolishoptionidx){
$option = array_values(array_filter($demolishOptions, fn($el)=> $el['id'] == $bothdemolishoptionidx))[0];
$item_no = $option['id'];
$item_group = "C";
$item_spec = $option['person'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['qty'];
$item_price_bp = $option['price'] * $option['qty'];
$note = $option['floor'];
$price_id = $option['demolish_id'];
$sql_str = "UPDATE pricereview_item SET item_spec=:item_spec, price_id=:price_id, item_unit_price = :item_unit_price, item_qty = :item_qty, item_price_bp = :item_price_bp, option_relate_spec=:option_relate_spec, note=:note WHERE mid = :mid AND item_no = :item_no AND item_group='C'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':price_id', $price_id);
$stmt->execute();
}
$sql_str = "UPDATE pricereview_pay SET pay_scale = :pay_scale, pay_amount = :pay_amount, pay_period = :pay_period WHERE mid = :mid AND pay_kind = :pay_kind";
foreach($paymentRatio as $key=>$pay){
$pay_kind = $key +1;
$pay_scale = $pay['scale'] == '' ? 0 : $pay['scale'];
$pay_amount = $pay['scale']/100 * $price_total;
$pay_period = ($pay['scale'] == '' || $pay['scale'] == 0) ? '' :$pay['ticket'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':pay_kind', $pay_kind);
$stmt->bindParam(':pay_scale', $pay_scale);
$stmt->bindParam(':pay_amount', $pay_amount);
$stmt->bindParam(':pay_period', $pay_period);
$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 = NULL; // 業務承辦人
$sign3 = "M0060,,"; //業務部協理
//是否呈核至總經理(M0006)
if($price_rate < 80 || $special_fee > 0){
$sign4 = "M0006,,";
$sign_total = 4;
}else{
$sign4 = NULL;
$sign_total = 3;
}
$sql_str = "INSERT INTO pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total)
VALUES (:mid, :sign1, :sign2, :sign3, :sign4, :sign_total)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':sign1', $sign1);
$stmt->bindParam(':sign2', $sign2);
$stmt->bindParam(':sign3', $sign3);
$stmt->bindParam(':sign4', $sign4);
$stmt->bindParam(':sign_total', $sign_total);
$stmt->execute();
}
$conn->commit();
echo "success";
}catch (PDOException $e) {
$conn->rollback();
echo $e->getMessage();
die('Error!:' . $e->getMessage());
} }
}else{
try{
$sql_str = "INSERT INTO pricereview_main (contractno, ekind, person, company, case_name, address, compete, price_lowest, price_total, price_rate, special_fee, predeal_date, facilitok_date, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, attatch1, attatch2, creater, create_at)
VALUES (:contractno, :ekind, :person, :company, :case_name, :address, :compete, :price_lowest, :price_total, :price_rate, :special_fee, :predeal_date, :facilitok_date, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :attatch1, :attatch2, :creater, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->bindParam(':ekind', $ekind);
$stmt->bindParam(':person', $person);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':compete', $compete);
$stmt->bindParam(':price_lowest', $price_lowest);
$stmt->bindParam(':price_total', $price_total);
$stmt->bindParam(':price_rate', $price_rate);
$stmt->bindParam(':special_fee', $special_fee);
$stmt->bindParam(':predeal_date', $predeal_date);
$stmt->bindParam(':facilitok_date', $facilitok_date);
$stmt->bindParam(':penalty', $penalty);
$stmt->bindParam(':deposit_rate', $deposit_rate);
$stmt->bindParam(':keep_rate', $keep_rate);
$stmt->bindParam(':warranty_rate', $warranty_rate);
$stmt->bindParam(':memo', $memo);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':attatch1', $attatch1);
$stmt->bindParam(':attatch2', $attatch2);
$stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
$mid = $conn->lastInsertId();
//insert 整機單價
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, item_weight, item_op, item_unit_price, item_qty, item_price_bp, item_price_ct, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :item_weight, :item_op, :item_unit_price, :item_qty, :item_price_bp, :item_price_ct, :note)";
foreach($elevators as $elevator){
$price_id = $elevator['facility_id'];
$item_no = $elevator['id'];
$item_group = "A";
$item_spec = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed'];
$item_weight = "";
$item_op = $elevator['open_converted'];
$item_unit_price = $elevator['price'];
$item_qty = (int)$elevator['spec_num'];
$item_price_bp = (int)$elevator['price'] * (int)$elevator['spec_num'];
$item_price_ct = $elevator['spec_price'];
$note = $elevator['specifications'] . ',' . $elevator['person'] . ',' . $elevator['stop'] . ',' . $elevator['speed'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':item_weight', $item_weight);
$stmt->bindParam(':item_op', $item_op);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':item_price_ct', $item_price_ct);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
//insert options 加價
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)";
foreach($options as $option){
$price_id = $option['id'];
$item_no = $option['key'];
$item_group = "B";
$item_spec = $option['name'] . $option['memo'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['qty'];
$item_price_bp = $option['price'] * $option['qty'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':price_id', $price_id);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute();
}
//insert 除外項目
$sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note)
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :note)";
foreach($otherOptions as $option){
$item_no = $option['id'];
$item_group = "E";
$item_spec = $option['name'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['num'];
$item_price_bp = $option['price'] * $option['num'];
$note = $option['pr_no'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->execute();
}
$sql_str = "INSERT INTO pricereview_item (mid, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp)
VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)";
//insert 保養延長
foreach(json_decode($maintainOptions, true) as $option){
$item_no = $option['id'] + 1;
$item_group = "D";
$item_spec = $option['toElevator'][0]['model'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = $option['num'];
$item_price_bp = $option['price'] * $option['num'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->execute();
}
//insert 拆梯價格 demolishOptions
$sql_str = "INSERT INTO pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note)
VALUES (:mid, :price_id, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp, :note)";
foreach($demolishOptions as $option){
$item_no = $option['id'];
$item_group = "C";
$item_spec = $option['person'];
$option_relate_spec = $option['toElevator'][0]['id'];
$item_unit_price = $option['price'];
$item_qty = (int)$option['qty'];
$item_price_bp = $option['price'] * (int)$option['qty'];
$note = $option['floor'];
$price_id = $option['demolish_id'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':item_no', $item_no);
$stmt->bindParam(':item_group', $item_group);
$stmt->bindParam(':item_spec', $item_spec);
$stmt->bindParam(':option_relate_spec', $option_relate_spec);
$stmt->bindParam(':item_unit_price', $item_unit_price);
$stmt->bindParam(':item_qty', $item_qty);
$stmt->bindParam(':item_price_bp', $item_price_bp);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':price_id', $price_id);
$stmt->execute();
}
//insert 付款比例
$sql_str = "INSERT INTO pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period)
VALUES (:mid, :pay_kind, :pay_scale, :pay_amount, :pay_period)";
foreach($paymentRatio as $key=>$pay){
$pay_kind = $key +1;
$pay_scale = $pay['scale'] == '' ? 0 : $pay['scale'];
$pay_amount = $pay['scale']/100 * $price_total;
$pay_period = ($pay['scale'] == '' || $pay['scale'] == 0) ? '' :$pay['ticket'];
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':pay_kind', $pay_kind);
$stmt->bindParam(':pay_scale', $pay_scale);
$stmt->bindParam(':pay_amount', $pay_amount);
$stmt->bindParam(':pay_period', $pay_period);
$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 = NULL; // 業務承辦人
$sign3 = "M0060,,"; //業務部協理
//是否呈核至總經理(M0006)
if($price_rate < 80 || $special_fee > 0){
$sign4 = "M0006,,";
$sign_total = 4;
}else{
$sign4 = NULL;
$sign_total = 3;
}
$sql_str = "INSERT INTO pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total)
VALUES (:mid, :sign1, :sign2, :sign3, :sign4, :sign_total)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':sign1', $sign1);
$stmt->bindParam(':sign2', $sign2);
$stmt->bindParam(':sign3', $sign3);
$stmt->bindParam(':sign4', $sign4);
$stmt->bindParam(':sign_total', $sign_total);
$stmt->execute();
}
$conn->commit();
echo "success";
}catch (PDOException $e) {
$conn->rollback();
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
$sql_str = "INSERT INTO pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total)
VALUES (:mid, :sign1, :sign2, :sign3, :sign4, :sign_total)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':sign1', $sign1);
$stmt->bindParam(':sign2', $sign2);
$stmt->bindParam(':sign3', $sign3);
$stmt->bindParam(':sign4', $sign4);
$stmt->bindParam(':sign_total', $sign_total);
$stmt->execute();
echo "success";
$conn->commit();
}catch (PDOException $e) {
$conn->rollback();
echo $e->getMessage();
die('Error!:' . $e->getMessage());
} }

56
wms/mkt/api/putNewElevatorPriceview.php

@ -0,0 +1,56 @@
<?php
require_once("../conn.php");
date_default_timezone_set('Asia/Taipei');
$contractno = $_POST['contractno'];
$ekind = $_POST['ekind'];
$person = $_POST['person'];
$company = $_POST['company'];
$case_name = $_POST['case_name'];
$address = $_POST['address'];
$compete = "";
$price_lowest = $_POST['price_lowest'];
$price_total = $_POST['price_total'];
$price_rate = $_POST['price_rate'];
$special_fee = $_POST['special_fee'];
$predeal_date = $_POST['predeal_date'];
$penalty = $_POST['penalty'];
$deposit_rate = $_POST['deposit_rate'];
$warranty_rate = $_POST['warranty_rate'];
$keep_rate = $_POST['keep_rate'];
$memo = $_POST['memo'];
$status = $_POST['status'];
$attatch1 = $_POST['attatch1'] =='' ? NULL : $_POST['attatch1'];
$attatch2 = $_POST['attatch2'] =='' ? NULL : $_POST['attatch2'];
$creater = "M0174";
$create_at = date("Y-m-d H:i:s");
$elevators = $_POST['elevators'];
$options = $_POST['options'];
$otherOptions = $_POST['otherOptions'];
$maintainOptions = $_POST['maintainOptions'];
$paymentRatio = $_POST['paymentRatio'];
$sql_str = "SELECT id FROM pricereview_main WHERE contractno = :contractno ORDER BY id DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contractno', $contractno);
$stmt->execute();
$main = $stmt->fetch(PDO::FETCH_ASSOC);
if(!$main){
insertPricereview();
}else{
updatePricereview();
}
$mid = $main['id'];
function insertPricereview(){
}
function updatePricereview(){
}

444
wms/mkt/assets/js/pricereviewAlpine.js

@ -2,10 +2,11 @@ const pricereviewCreate = ()=>{
return { return {
init(){ init(){
this.elevators = elevators; this.elevators = elevators;
console.log(this.elevators); this.is_renovation = is_renovation
console.log(this.total_spec); this.selectedOptions = selectedOptions;
this.otherOptions = otherOptions;
console.log(this.selectedOptions);
}, },
openFn:{ openFn:{
4:'2U', 4:'2U',
5:"4PCO", 5:"4PCO",
@ -33,9 +34,11 @@ const pricereviewCreate = ()=>{
currentOptionKey: '', currentOptionKey: '',
currentOtherOptionKey: '', currentOtherOptionKey: '',
currentMaintainOptionKey: '', currentMaintainOptionKey: '',
optionKey:0, currentDemolishOptionKey: '',
otherOptionKey:0, optionKey: optionKey,
maintainOptionKey:0, otherOptionKey: otherOptionKey,
maintainOptionKey:1,
demolishOptionKey: demolishOptionKey,
modalElevatorInfo:{ modalElevatorInfo:{
spec:'', spec:'',
person:'', person:'',
@ -46,6 +49,7 @@ const pricereviewCreate = ()=>{
price:'', price:'',
sale_price:'', sale_price:'',
facility_id: '', facility_id: '',
model:'',
}, },
otherOptions: [], otherOptions: [],
modalOtherOptionInfo:{ modalOtherOptionInfo:{
@ -60,49 +64,63 @@ const pricereviewCreate = ()=>{
num:"", num:"",
memo:"", memo:"",
}, },
paymentRatio:[ demolishOptions: demolishOptions,
{ modalDemolishOptionsInfo:{
scale: 20, person:"",
ticket: 30, floor:"",
}, price: 0,
{ qty:"",
scale: 0, },
ticket: '', paymentRatio:paymentRatio,
}, serviceFee: serviceFee,
{ transactionDate: transactionDate,
scale: 50, shippingDate: shippingDate,
ticket: 30, remark: remark,
}, penalty: penalty,
{ deposit_rate: deposit_rate,
scale: 0, keep_rate: keep_rate,
ticket: '', warranty_rate: warranty_rate,
}, customerInfo:{
{ contractno: contractno,
scale: 20, company: customer,
ticket: 30, manager: manager,
}, address: address,
{ case_name: case_name,
scale: 10, uscc: uscc,
ticket: 30, person: salesman,
}, },
{ weightArr: {
scale: 0, 6: 450,
ticket: '', 8: 550,
}, 9: 600,
], 10: 700,
serviceFee:0, 11:750,
transactionDate: pre_order_date, 12:800,
shippingDate:'', 13:900,
remark:'', 15:1000,
17:1150,
20:1350,
24:1600,
},
is_renovation: is_renovation,
async getElevatorPrice(idx){ async getElevatorPrice(idx){
const spec = this.elevators[idx].specifications const spec = this.elevators[idx].specifications
const person = this.elevators[idx].person const person = this.elevators[idx].person
const stop = this.elevators[idx].stop const stop = this.elevators[idx].stop
const open_converted = this.elevators[idx].open_converted const open_converted = this.elevators[idx].open_converted
const speed = this.elevators[idx].speed const speed = this.elevators[idx].speed
const model = spec + '-' + person + '*' + stop + '-' + open_converted + speed; let model= "";
if(spec == 'M1' || spec=='M1+M4(1:1)' || spec == 'M1+M4(2:1)'){
model = "P" + person + "-" + this.weightArr[person] + "-" + open_converted + "-" + speed + "-" + stop
this.elevators[idx].model = model
}
else{
model = spec + '-' + person + '*' + stop + '-' + open_converted + speed;
this.elevators[idx].model = model
}
try{ try{
const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model}}) const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind: spec}})
console.log(res.data); console.log(res.data);
if(res.data.id == null || res.data.id == ""){ if(res.data.id == null || res.data.id == ""){
console.log("公司並無提供此規格!!"); console.log("公司並無提供此規格!!");
@ -115,9 +133,17 @@ const pricereviewCreate = ()=>{
}, },
async getModalElevatorPrice(){ async getModalElevatorPrice(){
let model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed; let model = "";
let kind = this.modalElevatorInfo.spec;
if(kind == 'M1' || kind=='M1+M4(1:1)' || kind == 'M1+M4(2:1)'){
model = "P" + this.modalElevatorInfo.person + "-" + this.weightArr[this.modalElevatorInfo.person] + "-" + this.modalElevatorInfo.open + "-" + this.modalElevatorInfo.speed + "-" + this.modalElevatorInfo.stop
this.modalElevatorInfo.model = "P" + this.modalElevatorInfo.person + "-" + this.weightArr[this.modalElevatorInfo.person] + "-" + this.modalElevatorInfo.open + "-" + this.modalElevatorInfo.speed + "-" + this.modalElevatorInfo.stop
}else{
model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed;
this.modalElevatorInfo.model = this.modalElevatorInfo.spec + '-' + this.modalElevatorInfo.person + '*' + this.modalElevatorInfo.stop + '-' + this.modalElevatorInfo.open + this.modalElevatorInfo.speed;
}
try{ try{
const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model}}) const res = await axios.get("./api/getElevatorPrice.php", {params: {model: model, kind:kind}})
console.log(res.data); console.log(res.data);
if(res.data.id == null || res.data.id == ""){ if(res.data.id == null || res.data.id == ""){
console.log("公司並無提供此規格!!"); console.log("公司並無提供此規格!!");
@ -128,6 +154,40 @@ const pricereviewCreate = ()=>{
console.error("Error fetching elevator price:", error); console.error("Error fetching elevator price:", error);
} }
}, },
async getModalDemolishPrice(){
let person = this.modalDemolishOptionsInfo.person
let floor = this.modalDemolishOptionsInfo.floor
try{
const res = await axios.get('./api/getDemolishPrice.php', {params: {person:person, floor:floor}});
console.log(res.data);
if(!res.data){
this.modalDemolishOptionsInfo.price = 0
this.modalDemolishOptionsInfo.demolish_id = ''
return;
}
this.modalDemolishOptionsInfo.price = res.data.price
this.modalDemolishOptionsInfo.demolish_id = res.data.id
}catch (error) {
console.error("Error fetching demolish price:", error);
}
},
async getDemolishPrice(idx){
let person = this.demolishOptions[idx].person
let floor = this.demolishOptions[idx].floor
try{
const res = await axios.get('./api/getDemolishPrice.php', {params: {person:person, floor:floor}});
console.log(res.data);
if(!res.data){
this.demolishOptions[idx].price = 0
this.demolishOptions[idx].demolish_id = ''
return;
}
this.demolishOptions[idx].price = res.data.price
this.demolishOptions[idx].demolish_id = res.data.id
}catch (error) {
console.error("Error fetching demolish price:", error);
}
},
initButtons(kind) { initButtons(kind) {
if (kind == 'A') { if (kind == 'A') {
this.buttons = [ this.buttons = [
@ -223,7 +283,6 @@ const pricereviewCreate = ()=>{
Object.keys(this.modalSelectedOptions).forEach(option=>{ Object.keys(this.modalSelectedOptions).forEach(option=>{
this.selectedOptions.push(this.modalSelectedOptions[option]) this.selectedOptions.push(this.modalSelectedOptions[option])
}) })
console.log(this.modalSelectedOptions);
console.log(this.selectedOptions); console.log(this.selectedOptions);
this.hideOptionsModal(); this.hideOptionsModal();
}, },
@ -243,6 +302,10 @@ const pricereviewCreate = ()=>{
this.$refs.toMaintainOptionElevatorModal.style.display = 'none'; this.$refs.toMaintainOptionElevatorModal.style.display = 'none';
body.style.overflow = 'auto' body.style.overflow = 'auto'
}, },
hideToDemolishOptionElevatorModal(){
this.$refs.toDemolishOptionElevatorModal.style.display = 'none';
body.style.overflow = 'auto'
},
hideCreateElevatorModal(){ hideCreateElevatorModal(){
this.$refs.createElevatorModal.style.display = 'none'; this.$refs.createElevatorModal.style.display = 'none';
body.style.overflow = 'auto' body.style.overflow = 'auto'
@ -255,6 +318,7 @@ const pricereviewCreate = ()=>{
num: 1, num: 1,
price:'', price:'',
sale_price:'', sale_price:'',
model:'',
}; };
}, },
hideCreateOtherOptionModal(){ hideCreateOtherOptionModal(){
@ -265,6 +329,10 @@ const pricereviewCreate = ()=>{
this.$refs.createMaintainModal.style.display = 'none'; this.$refs.createMaintainModal.style.display = 'none';
body.style.overflow = 'auto' body.style.overflow = 'auto'
}, },
hideCreateDemolishModal(){
this.$refs.createDemolishModal.style.display = 'none';
body.style.overflow = 'auto'
},
openCreateElevatorModal(){ openCreateElevatorModal(){
this.$refs.createElevatorModal.style.display = 'block'; this.$refs.createElevatorModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
@ -277,6 +345,10 @@ const pricereviewCreate = ()=>{
this.$refs.createMaintainModal.style.display = 'block'; this.$refs.createMaintainModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
openCreateDemolishOptionModal(){
this.$refs.createDemolishModal.style.display = 'block';
body.style.overflow = 'hidden'
},
totalElevatorsPrice(){ totalElevatorsPrice(){
return this.elevators.reduce((total, elevator) => { return this.elevators.reduce((total, elevator) => {
return total + (elevator.spec_num * elevator.price); return total + (elevator.spec_num * elevator.price);
@ -321,6 +393,7 @@ const pricereviewCreate = ()=>{
open:'', open:'',
spec_num: this.modalElevatorInfo.num, spec_num: this.modalElevatorInfo.num,
facility_id: this.modalElevatorInfo.facility_id, facility_id: this.modalElevatorInfo.facility_id,
model: this.modalElevatorInfo.model,
}); });
console.log(this.elevators); console.log(this.elevators);
this.hideCreateElevatorModal(); this.hideCreateElevatorModal();
@ -336,6 +409,7 @@ const pricereviewCreate = ()=>{
const spec_num = this.elevators[idx].spec_num const spec_num = this.elevators[idx].spec_num
const price = this.elevators[idx].price const price = this.elevators[idx].price
const facility_id = this.elevators[idx].facility_id const facility_id = this.elevators[idx].facility_id
const model = this.elevators[idx].model
this.total_spec ++; this.total_spec ++;
this.elevators.push({ this.elevators.push({
@ -350,21 +424,59 @@ const pricereviewCreate = ()=>{
open: open, open: open,
spec_num: spec_num, spec_num: spec_num,
facility_id: facility_id, facility_id: facility_id,
model: model,
}); });
console.log(this.elevators); console.log(this.elevators);
}, },
copyOption(key){
const copyOption = this.selectedOptions.filter(option=> option.key === key)[0]
console.log(copyOption);
this.selectedOptions.push({
id: copyOption.id,
idx: copyOption.idx,
name: copyOption.name,
price: copyOption.price,
memo: copyOption.memo,
toElevator: [],
key: this.optionKey,
qty: copyOption.qty
})
this.optionKey++
console.log(this.selectedOptions);
},
copyOtherOption(id){
const copyOption = this.otherOptions.filter(option=> option.id === id)[0]
console.log(copyOption);
this.otherOptions.push({
id: this.otherOptionKey,
name: copyOption.name,
price: copyOption.price,
num: copyOption.num,
toElevator: [],
pr_no: copyOption.pr_no
})
console.log(this.otherOptions);
this.otherOptionKey++;
},
addOptionToElevator(key){ addOptionToElevator(key){
this.currentOptionKey = key; this.currentOptionKey = key;
this.toElevators = []; this.toElevators = [];
this.toElevatorNo = ""; this.toElevatorNo = "";
const matchElevators = this.selectedOptions.filter(option=> option.key == key)[0].toElevator.map(elevator=> elevator.id) const matchElevators = this.selectedOptions.filter(option=> option.key == key)[0].toElevator.map(elevator=> elevator.id)
console.log(matchElevators);
this.toElevatorNo = matchElevators[0] this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{ this.elevators.forEach(elevator=>{
if(elevator.price > 0){ if(elevator.price > 0){
let bool = elevator.specifications=='M1' || elevator.specifications=='M1+M4(1:1)' || elevator.specifications=='M1+M4(2:1)' ;
let model = ''
if(bool){
model = 'P' + elevator.person + '-' + this.weightArr[elevator.person] + '-' + elevator.open_converted + '-' + elevator.speed + '-' + elevator.stop
}else{
model = elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed
}
this.toElevators.push({ this.toElevators.push({
id: elevator.id, id: elevator.id,
model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, model: model ,
checked: matchElevators.includes(elevator.id) ? 1: 0, checked: matchElevators.includes(elevator.id) ? 1: 0,
}) })
} }
@ -380,30 +492,31 @@ const pricereviewCreate = ()=>{
this.toElevatorNo = matchElevators[0] this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{ this.elevators.forEach(elevator=>{
if(elevator.price > 0){ if(elevator.price > 0){
let bool = elevator.specifications=='M1' || elevator.specifications=='M1+M4(1:1)' || elevator.specifications=='M1+M4(2:1)' ;
let model = ''
if(bool){
model = 'P' + elevator.person + '-' + this.weightArr[elevator.person] + '-' +elevator.open_converted + '-' + elevator.speed + '-' + elevator.stop
}else{
model = elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed
}
this.toElevators.push({ this.toElevators.push({
id: elevator.id, id: elevator.id,
model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, model: model,
checked: matchElevators.includes(elevator.id) ? 1: 0, checked: matchElevators.includes(elevator.id) ? 1: 0,
}) })
} }
}) })
this.$refs.toOtherOptionElevatorModal.style.display = 'block'; this.$refs.toOtherOptionElevatorModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
chkOptionToElevators(){ chkOptionToElevators(){
const checkedOptions = []; const checkedOptions = [];
// this.toElevators.forEach(elevator=>{
// if(elevator.checked){
// checkedOptions.push({
// id: elevator.id,
// model: elevator.model,
// });
// }
// })
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
checkedOptions.push({ checkedOptions.push({
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], model: matchElevators['model'] ,
}) })
this.selectedOptions.forEach(option=>{ this.selectedOptions.forEach(option=>{
if(option.key == this.currentOptionKey){ if(option.key == this.currentOptionKey){
@ -416,18 +529,11 @@ const pricereviewCreate = ()=>{
}, },
chkOtherOptionToElevators(){ chkOtherOptionToElevators(){
const checkedOptions = []; const checkedOptions = [];
// this.toElevators.forEach(elevator=>{
// if(elevator.checked){
// checkedOptions.push({
// id: elevator.id,
// model: elevator.model,
// });
// }
// })
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
checkedOptions.push({ checkedOptions.push({
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], model: matchElevators['model'],
}) })
this.otherOptions.forEach(option=>{ this.otherOptions.forEach(option=>{
if(option.id == this.currentOtherOptionKey){ if(option.id == this.currentOtherOptionKey){
@ -506,6 +612,25 @@ const pricereviewCreate = ()=>{
this.maintainOptionKey ++; this.maintainOptionKey ++;
this.hideCreateMaintainModal(); this.hideCreateMaintainModal();
}, },
createDemolishOptionFn(){
this.demolishOptions.push({
id: this.demolishOptionKey,
price: this.modalDemolishOptionsInfo.price,
qty: this.modalDemolishOptionsInfo.qty,
person: this.modalDemolishOptionsInfo.person,
floor: this.modalDemolishOptionsInfo.floor,
demolish_id: this.modalDemolishOptionsInfo.demolish_id,
toElevator:[],
})
this.modalDemolishOptionsInfo = {
person:"",
floor:"",
price: 0,
qty:"",
}
this.demolishOptionKey ++;
this.hideCreateDemolishModal();
},
totalMaintainOptionsPrice(){ totalMaintainOptionsPrice(){
return this.maintainOptions.reduce((total, option) => { return this.maintainOptions.reduce((total, option) => {
return total + (Number(option.num) * Number(option.price)); return total + (Number(option.num) * Number(option.price));
@ -516,20 +641,23 @@ const pricereviewCreate = ()=>{
return total + Number(option.num); return total + Number(option.num);
}, 0); }, 0);
}, },
totalDemolishOptionsPrice(){
return this.demolishOptions.reduce((total, option) => {
return total + (Number(option.qty) * Number(option.price));
}, 0);
},
totalDemolishOptionsNum(){
return this.demolishOptions.reduce((total, option) => {
return total + Number(option.qty);
}, 0);
},
chkMaintainOptionToElevators(){ chkMaintainOptionToElevators(){
const checkedOptions = []; const checkedOptions = [];
// this.toElevators.forEach(elevator=>{
// if(elevator.checked){
// checkedOptions.push({
// id: elevator.id,
// model: elevator.model,
// });
// }
// })
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0] const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
checkedOptions.push({ checkedOptions.push({
id: this.toElevatorNo, id: this.toElevatorNo,
model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], model: matchElevators['model'],
}) })
this.maintainOptions.forEach(option=>{ this.maintainOptions.forEach(option=>{
if(option.id == this.currentMaintainOptionKey){ if(option.id == this.currentMaintainOptionKey){
@ -540,6 +668,22 @@ const pricereviewCreate = ()=>{
this.currentMaintainOptionKey = '' this.currentMaintainOptionKey = ''
this.hideToMaintainOptionElevatorModal(); this.hideToMaintainOptionElevatorModal();
}, },
chkDemolishOptionToElevators(){
const checkedOptions = [];
const matchElevators = this.elevators.filter(elevator=> elevator.id == this.toElevatorNo)[0]
checkedOptions.push({
id: this.toElevatorNo,
model: matchElevators['model'],
})
this.demolishOptions.forEach(option=>{
if(option.id == this.currentDemolishOptionKey){
option.toElevator = [];
option.toElevator.push(...checkedOptions)
}
})
this.currentDemolishOptionKey = ''
this.hideToDemolishOptionElevatorModal();
},
addMaintainOptionToElevator(id){ addMaintainOptionToElevator(id){
this.currentMaintainOptionKey = id; this.currentMaintainOptionKey = id;
this.toElevators = []; this.toElevators = [];
@ -548,9 +692,16 @@ const pricereviewCreate = ()=>{
this.toElevatorNo = matchElevators[0] this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{ this.elevators.forEach(elevator=>{
if(elevator.price > 0){ if(elevator.price > 0){
let bool = elevator.specifications=='M1' || elevator.specifications=='M1+M4(1:1)' || elevator.specifications=='M1+M4(2:1)' ;
let model = ''
if(bool){
model = 'P' + elevator.person + '-' + this.weightArr[elevator.person] + '-' +elevator.open_converted + '-' + elevator.speed + '-' + elevator.stop
}else{
model = elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed
}
this.toElevators.push({ this.toElevators.push({
id: elevator.id, id: elevator.id,
model: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, model: model,
checked: matchElevators.includes(elevator.id) ? 1: 0, checked: matchElevators.includes(elevator.id) ? 1: 0,
}) })
} }
@ -559,9 +710,38 @@ const pricereviewCreate = ()=>{
this.$refs.toMaintainOptionElevatorModal.style.display = 'block'; this.$refs.toMaintainOptionElevatorModal.style.display = 'block';
body.style.overflow = 'hidden' body.style.overflow = 'hidden'
}, },
addDemolishOptionToElevator(id){
this.currentDemolishOptionKey = id;
this.toElevators = [];
this.toElevatorNo = "";
const matchElevators = this.demolishOptions.filter(option=> option.id == id)[0].toElevator.map(elevator=> elevator.id)
this.toElevatorNo = matchElevators[0]
this.elevators.forEach(elevator=>{
if(elevator.price > 0){
let bool = elevator.specifications=='M1' || elevator.specifications=='M1+M4(1:1)' || elevator.specifications=='M1+M4(2:1)' ;
let model = ''
if(bool){
model = 'P' + elevator.person + '-' + this.weightArr[elevator.person] + '-' +elevator.open_converted + '-' + elevator.speed + '-' + elevator.stop
}else{
model = elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed
}
this.toElevators.push({
id: elevator.id,
model: model,
checked: matchElevators.includes(elevator.id) ? 1: 0,
})
}
})
this.$refs.toDemolishOptionElevatorModal.style.display = 'block';
body.style.overflow = 'hidden'
},
removeMaintainOption(id){ removeMaintainOption(id){
this.maintainOptions = this.maintainOptions.filter(option=> option.id != id) this.maintainOptions = this.maintainOptions.filter(option=> option.id != id)
}, },
removeDemolishOption(id){
this.demolishOptions = this.demolishOptions.filter(option=> option.id != id)
},
totalPrice(){ totalPrice(){
return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice(); return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice();
}, },
@ -584,19 +764,6 @@ const pricereviewCreate = ()=>{
return total; return total;
}, },
customerInfo:{
contractno: contractno,
company: customer,
manager: manager,
address: address,
case_name: case_name,
uscc: uscc,
person: salesman,
},
penalty:"",
deposit_rate:0,
keep_rate:0,
warranty_rate:0,
error: [], error: [],
submit(){ submit(){
this.error = [] this.error = []
@ -641,7 +808,7 @@ const pricereviewCreate = ()=>{
const form = new FormData(); const form = new FormData();
form.append('contractno', contractno); form.append('contractno', contractno);
form.append('ekind', "新梯"); form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯");
form.append('person', this.customerInfo.person); form.append('person', this.customerInfo.person);
form.append('company', this.customerInfo.company); form.append('company', this.customerInfo.company);
form.append('case_name', this.customerInfo.case_name); form.append('case_name', this.customerInfo.case_name);
@ -660,13 +827,14 @@ const pricereviewCreate = ()=>{
form.append('status', "YS"); form.append('status', "YS");
form.append('attatch1', ""); form.append('attatch1', "");
form.append('attatch2', ""); form.append('attatch2', "");
form.append('user_id', user_id);
form.append('elevators', JSON.stringify(this.elevators)); form.append('elevators', JSON.stringify(this.elevators));
form.append('options', JSON.stringify(this.selectedOptions)); form.append('options', JSON.stringify(this.selectedOptions));
form.append('otherOptions', JSON.stringify(this.otherOptions)); form.append('otherOptions', JSON.stringify(this.otherOptions));
form.append('maintainOptions', JSON.stringify(this.maintainOptions)); form.append('maintainOptions', JSON.stringify(this.maintainOptions));
form.append('demolishOptions', JSON.stringify(this.demolishOptions));
form.append('paymentRatio', JSON.stringify(this.paymentRatio)); form.append('paymentRatio', JSON.stringify(this.paymentRatio));
@ -680,7 +848,50 @@ const pricereviewCreate = ()=>{
console.error(err); console.error(err);
}) })
}, },
save(){
const form = new FormData();
form.append('contractno', contractno);
form.append('ekind', (is_renovation=="Y") ? "汰改" : "新梯");
form.append('person', this.customerInfo.person);
form.append('company', this.customerInfo.company);
form.append('case_name', this.customerInfo.case_name);
form.append('address', this.customerInfo.address);
form.append('price_lowest', this.totalPrice());
form.append('price_total', this.totalSalePrice());
form.append('price_rate', Math.round(this.totalSalePrice() / this.totalPrice() * 100 *10) / 10);
form.append('special_fee', this.serviceFee);
form.append('predeal_date', this.transactionDate);
form.append('facilitok_date', this.shippingDate);
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('memo', this.remark);
form.append('status', "Y1");
form.append('attatch1', "");
form.append('attatch2', "");
form.append('user_id', user_id);
form.append('elevators', JSON.stringify(this.elevators));
form.append('options', JSON.stringify(this.selectedOptions));
form.append('otherOptions', JSON.stringify(this.otherOptions));
form.append('maintainOptions', JSON.stringify(this.maintainOptions));
form.append('demolishOptions', JSON.stringify(this.demolishOptions));
form.append('paymentRatio', JSON.stringify(this.paymentRatio));
axios.post('./api/postNewElevatorPricereview.php', form).then(res=>{
console.log(res.status);
if(res.data == "success"){
alert("保存成功!");
window.location.reload();
// window.location.href = './pricereview-index.php?' + token_link;
}
}).catch(err=>{
console.error(err);
})
},
} }
} }
@ -688,7 +899,7 @@ const pricereviewCreate = ()=>{
const pricereviewCheck = ()=>{ const pricereviewCheck = ()=>{
return { return {
init(){ init(){
this.elevators = items.filter(item=> item.item_group =='A'); this.elevators = elevators
this.elevators.forEach(el=>{ this.elevators.forEach(el=>{
el.options = [] el.options = []
el.optionsTotalPrice = 0; el.optionsTotalPrice = 0;
@ -696,14 +907,15 @@ const pricereviewCheck = ()=>{
el.otherOptionsTotalPrice = 0; el.otherOptionsTotalPrice = 0;
el.maintainOptions = [] el.maintainOptions = []
el.maintainOptionsTotalPrice = 0; el.maintainOptionsTotalPrice = 0;
el.demolishOptions = []
el.demolishOptionsTotalPrice = 0;
}) })
this.options = options; this.options = options;
this.otherOptions = items.filter(item=> item.item_group =='E'); this.demolishOptions = items.filter(item=> item.item_group =='C');
this.maintainOptions = items.filter(item=> item.item_group =='D'); this.maintainOptions = items.filter(item=> item.item_group =='D');
console.log(this.options); this.otherOptions = items.filter(item=> item.item_group =='E');
console.log("optionnnn=>", this.options);
this.elevators.forEach((elevator, idx)=>{ this.elevators.forEach((elevator, idx)=>{
this.options.forEach(option=>{ this.options.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){ if(option.option_relate_spec == elevator.item_no){
elevator.optionsTotalPrice += option.option_mi * option.item_qty elevator.optionsTotalPrice += option.option_mi * option.item_qty
@ -713,6 +925,7 @@ const pricereviewCheck = ()=>{
'item_unit_price': option.item_unit_price, 'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty, 'item_qty': option.item_qty,
'mi': Math.round(option.option_mi), 'mi': Math.round(option.option_mi),
'option_memo': option.option_memo,
}) })
} }
}) })
@ -735,7 +948,19 @@ const pricereviewCheck = ()=>{
elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty elevator.maintainOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].maintainOptions.push({ this.elevators[idx].maintainOptions.push({
'id': option.id, 'id': option.id,
'item_spec': option.item_spe.trim(), 'item_spec': option.item_spec.trim(),
'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty,
'mi': Math.round(option.item_unit_price),
})
}
})
this.demolishOptions.forEach(option=>{
if(option.option_relate_spec == elevator.item_no){
elevator.demolishOptionsTotalPrice += option.item_unit_price * option.item_qty
this.elevators[idx].demolishOptions.push({
'id': option.id,
'item_spec': option.item_spec.trim(),
'item_unit_price': option.item_unit_price, 'item_unit_price': option.item_unit_price,
'item_qty': option.item_qty, 'item_qty': option.item_qty,
'mi': Math.round(option.item_unit_price), 'mi': Math.round(option.item_unit_price),
@ -743,7 +968,7 @@ const pricereviewCheck = ()=>{
} }
}) })
this.qty += Number(elevator.item_qty); this.qty += Number(elevator.item_qty);
this.elevators_total_price += Number(elevator.item_qty) * Number(elevator.item_unit_price); this.elevators_total_price += Number(elevator.item_qty) * Number(elevator.price);
//MAE100-15*24-CO105 //MAE100-15*24-CO105
const model = elevator.item_spec; const model = elevator.item_spec;
let spec = model.split('-')[0]; let spec = model.split('-')[0];
@ -767,9 +992,10 @@ const pricereviewCheck = ()=>{
this.sign3 = this.getUsername(sign3) this.sign3 = this.getUsername(sign3)
this.sign4 = this.getUsername(sign4) this.sign4 = this.getUsername(sign4)
console.log(this.elevators);
}, },
async getElevatorMi(idx, spec, person, stop, open, speed, item_weight){ async getElevatorMi(idx, spec, person, stop, open, speed, item_weight){
console.log("載重=====>",item_weight);
try{ try{
const res = await axios.get('./api/getElevatorMi.php', {params: { const res = await axios.get('./api/getElevatorMi.php', {params: {
spec: spec, spec: spec,
@ -782,7 +1008,7 @@ const pricereviewCheck = ()=>{
console.log('---->',res.data); console.log('---->',res.data);
if(res.data){ if(res.data){
this.elevators[idx].mi = res.data this.elevators[idx].mi = res.data
this.elevators[idx].totalMi = res.data['equipment_fee'] + res.data['customs_shipping_fee'] + res.data['free1y_fee'] + res.data['install_fee'] + res.data['other_fee'] + res.data['transport_site_fee'] + res.data['unloading_fee']; this.elevators[idx].totalMi = res.data['equipment_fee'] + res.data['customs_shipping_fee'] + res.data['free1y_fee'] + res.data['install_fee'] + res.data['other_fee'] + res.data['transport_site_fee'] + res.data['unloading_fee'] + res.data['add_price'];
}else{ }else{
this.isNotfoundMi = true; this.isNotfoundMi = true;
this.elevators[idx].mi = { this.elevators[idx].mi = {
@ -792,7 +1018,8 @@ const pricereviewCheck = ()=>{
'install_fee': 0, 'install_fee': 0,
'other_fee': 0, 'other_fee': 0,
'transport_site_fee': 0, 'transport_site_fee': 0,
'unloading_fee': 0 'unloading_fee': 0,
'add_price':0,
} }
} }
@ -834,6 +1061,7 @@ const pricereviewCheck = ()=>{
options: [], options: [],
otherOptions: [], otherOptions: [],
maintainOptions: [], maintainOptions: [],
demolishOptions:[],
mid: mid, mid: mid,
user_id: user_id, user_id: user_id,
reviewcomment:'', reviewcomment:'',
@ -852,11 +1080,24 @@ const pricereviewCheck = ()=>{
return total + (option.item_qty * option.item_unit_price); return total + (option.item_qty * option.item_unit_price);
}, 0); }, 0);
}, },
demolishOptionsTotalPrice(){
return this.demolishOptions.reduce((total, option) => {
return total + (option.item_qty * option.item_unit_price);
}, 0);
},
totalScale(){ totalScale(){
return this.pays.reduce((total, option) => { return this.pays.reduce((total, option) => {
return total + Number(option.pay_scale ); return total + Number(option.pay_scale );
}, 0); }, 0);
}, },
totalElevatorsPrice(){
return this.elevators.reduce((total, elevator) => {
return total + (elevator.item_qty * elevator.price);
}, 0);
},
totalStandardPrice(){
return this.totalElevatorsPrice() + this.otherOptionsTotalPrice() + this.optionsTotalPrice() + this.maintainOptionsTotalPrice() + this.demolishOptionsTotalPrice();
},
check(sign, status){ check(sign, status){
console.log(sign); console.log(sign);
const form = new FormData(); const form = new FormData();
@ -873,6 +1114,7 @@ const pricereviewCheck = ()=>{
} }
}) })
}, },
async getUsername(user_id){ async getUsername(user_id){
if(user_id == '') return '---' if(user_id == '') return '---'
const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}}) const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}})

15
wms/mkt/css/pricereview.css

@ -50,7 +50,8 @@
width: 55px; width: 55px;
height: 30px; height: 30px;
padding: 0; padding: 0;
margin-left: 10px; margin-left: 6px;
margin-bottom: 2px;
font-size: 13px; font-size: 13px;
} }
#pricereviewCreate .container .pricreviewmain button.addbtn { #pricereviewCreate .container .pricreviewmain button.addbtn {
@ -99,6 +100,10 @@
#pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .deleteBtn, #pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .copyBtn { #pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .deleteBtn, #pricereviewCreate .container .pricreviewmain > .divitem table tr:hover .copyBtn {
opacity: 1; opacity: 1;
} }
#pricereviewCreate .container .pricreviewmain > .divitem table .copyBtn {
width: 30px;
height: 30px;
}
#pricereviewCreate .container .pricreviewmain > .divitem table .saletd { #pricereviewCreate .container .pricreviewmain > .divitem table .saletd {
position: relative; position: relative;
} }
@ -210,7 +215,7 @@
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
position: absolute; position: absolute;
width: 1200px; width: 90%;
padding: 30px; padding: 30px;
top: 50%; top: 50%;
left: 50%; left: 50%;
@ -219,13 +224,13 @@
animation: fade-in 0.2s linear; animation: fade-in 0.2s linear;
} }
.window-modal .window-modal-content.modal-xl { .window-modal .window-modal-content.modal-xl {
width: 1200px; max-width: 1200px;
} }
.window-modal .window-modal-content.modal-lg { .window-modal .window-modal-content.modal-lg {
width: 800px; max-width: 800px;
} }
.window-modal .window-modal-content.modal-m { .window-modal .window-modal-content.modal-m {
width: 450px; max-width: 450px;
} }
.window-modal .window-modal-content .window-modal-header { .window-modal .window-modal-content .window-modal-header {
display: flex; display: flex;

2
wms/mkt/css/pricereview.css.map

@ -1 +1 @@
{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,WAAA;ACAR;ADEI;EACI,gBAAA;ACAR;ADEI;EACI,aAAA;ACAR;ADCQ;EACI,sBAAA;ACCZ;ADCQ;EACI,cAAA;ACCZ;ADCQ;EACI,yBAAA;ACCZ;ADKQ;EACI,sBAAA;EACA,aAAA;ACHZ;ADIY;EACI,YAAA;ACFhB;ADMY;EACI,yBAAA;ACJhB;ADOgB;EACI,eAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACLpB;ADQY;EACI,eAAA;ACNhB;ADSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ACPZ;ADQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,iBAAA;EACA,eAAA;ACNhB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACPhB;ADQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACNpB;ADOoB;EACI,gBAAA;ACLxB;ADSgB;EACI,eAAA;EACA,6BAAA;ACPpB;ADQoB;EACI,eAAA;ACNxB;ADQoB;;;;EAEA,wBAAA;EACA,SAAA;ACJpB;ADQoB;EACI,UAAA;ACNxB;ADQoB;EACI,kBAAA;ACNxB;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACL5B;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ACL5B;ADQoB;EACI,YAAA;EACA,gBAAA;ACNxB;ADUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ACRhB;ADSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ACPpB;ADQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ACNxB;ADQoB;EACI,YAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ACNxB;;ADcA;EACI,4BAAA;EACA,WAAA;ACXJ;ADYI;EACI,gBAAA;ACVR;ADYI;EACI,yBAAA;ACVR;;ADcA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;ACXJ;ADYI;EACI;IACI,gCAAA;IACA,UAAA;ECVV;EDYM;IACI,gCAAA;IACA,UAAA;ECVV;AACF;ADYI;EACI,sBAAA;ACVR;ADYI;EACI,cAAA;ACVR;ADYI;EACI,yBAAA;ACVR;ADYI;EACI,gBAAA;ACVR;ADWQ;EACI,aAAA;EACA,kBAAA;ACTZ;ADYI;EACI,iBAAA;EACA,YAAA;ACVR;ADWQ;EACI,YAAA;ACTZ;ADYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,aAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ACVR;ADWQ;EACI,aAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,YAAA;ACTZ;ADWQ;EACI,aAAA;EACA,sBAAA;ACTZ;ADUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACRhB;ADUY;EACI,YAAA;ACRhB;ADYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ACVR;;ADeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ACZR;ADaQ;EACI,gBAAA;ACXZ;ADaQ;EACI,sBAAA;ACXZ;ADaQ;EACI,uBAAA;ACXZ;ADYY;EACI,uBAAA;ACVhB;ADcY;EACI,yBAAA;ACZhB;ADgBY;EACI,gBAAA;ACdhB;ADgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ACdhB;ADgBY;EACI,eAAA;ACdhB;ADegB;EACI,eAAA;EACA,gBAAA;ACbpB;ADegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ACbpB","file":"pricereview.css"} {"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"AACI;EACI,WAAA;ACAR;ADEI;EACI,gBAAA;ACAR;ADEI;EACI,aAAA;ACAR;ADCQ;EACI,sBAAA;ACCZ;ADCQ;EACI,cAAA;ACCZ;ADCQ;EACI,yBAAA;ACCZ;ADKQ;EACI,sBAAA;EACA,aAAA;ACHZ;ADIY;EACI,YAAA;ACFhB;ADMY;EACI,yBAAA;ACJhB;ADOgB;EACI,eAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,eAAA;EACA,iBAAA;EACA,gBAAA;EACA,kBAAA;ACLpB;ADQY;EACI,eAAA;ACNhB;ADSQ;EACI,yBAAA;EACA,aAAA;EACA,kBAAA;EACA,cAAA;ACPZ;ADQY;EACI,WAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;EACA,gBAAA;EACA,kBAAA;EACA,eAAA;ACNhB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;EACA,eAAA;EACA,WAAA;ACLpB;ADOgB;EACI,yBAAA;EACA,WAAA;ACLpB;ADSY;EACI,sBAAA;EACA,aAAA;EACA,kBAAA;ACPhB;ADQgB;EACI,aAAA;EACA,mBAAA;EACA,6BAAA;EACA,eAAA;EACA,mBAAA;ACNpB;ADOoB;EACI,gBAAA;ACLxB;ADSgB;EACI,eAAA;EACA,6BAAA;ACPpB;ADQoB;EACI,eAAA;ACNxB;ADQoB;;;;EAEA,wBAAA;EACA,SAAA;ACJpB;ADQoB;EACI,UAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;ACNxB;ADQoB;EACI,kBAAA;ACNxB;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,UAAA;EACA,UAAA;EACA,gBAAA;ACL5B;ADOwB;EACI,kBAAA;EACA,QAAA;EACA,2BAAA;EACA,WAAA;EACA,UAAA;EACA,gBAAA;EACA,WAAA;EACA,YAAA;ACL5B;ADQoB;EACI,YAAA;EACA,gBAAA;ACNxB;ADUY;EACI,aAAA;EACA,sBAAA;EACA,gBAAA;ACRhB;ADSgB;EACI,aAAA;EACA,mBAAA;EACA,cAAA;ACPpB;ADQoB;EACI,YAAA;EACA,eAAA;EACA,gBAAA;ACNxB;ADQoB;EACI,YAAA;ACNxB;ADQoB;EACI,WAAA;EACA,YAAA;EACA,SAAA;EACA,kBAAA;EACA,gBAAA;ACNxB;;ADcA;EACI,4BAAA;EACA,WAAA;ACXJ;ADYI;EACI,gBAAA;ACVR;ADYI;EACI,yBAAA;ACVR;;ADcA;EACI,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,aAAA;EACA,oCAAA;EACA,UAAA;EACA,aAAA;EACA,aAAA;ACXJ;ADYI;EACI;IACI,gCAAA;IACA,UAAA;ECVV;EDYM;IACI,gCAAA;IACA,UAAA;ECVV;AACF;ADYI;EACI,sBAAA;ACVR;ADYI;EACI,cAAA;ACVR;ADYI;EACI,yBAAA;ACVR;ADYI;EACI,gBAAA;ACVR;ADWQ;EACI,aAAA;EACA,kBAAA;ACTZ;ADYI;EACI,iBAAA;EACA,YAAA;ACVR;ADWQ;EACI,YAAA;ACTZ;ADYI;EACI,UAAA;EACA,sBAAA;EACA,mBAAA;EACA,kBAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,SAAA;EACA,gCAAA;EACA,0BAAA;EACA,8BAAA;ACVR;ADWQ;EACI,iBAAA;ACTZ;ADWQ;EACI,gBAAA;ACTZ;ADWQ;EACI,gBAAA;ACTZ;ADWQ;EACI,aAAA;EACA,sBAAA;ACTZ;ADUY;EACI,kBAAA;EACA,SAAA;EACA,WAAA;EACA,6BAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACRhB;ADUY;EACI,YAAA;ACRhB;ADYI;EACI,kBAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,6BAAA;ACVR;;ADeI;EACI,yBAAA;EACA,mBAAA;EACA,aAAA;ACZR;ADaQ;EACI,gBAAA;ACXZ;ADaQ;EACI,sBAAA;ACXZ;ADaQ;EACI,uBAAA;ACXZ;ADYY;EACI,uBAAA;ACVhB;ADcY;EACI,yBAAA;ACZhB;ADgBY;EACI,gBAAA;ACdhB;ADgBY;EACI,yBAAA;EACA,mBAAA;EACA,iBAAA;EACA,eAAA;ACdhB;ADgBY;EACI,eAAA;ACdhB;ADegB;EACI,eAAA;EACA,gBAAA;ACbpB;ADegB;EACI,WAAA;EACA,aAAA;EACA,cAAA;EACA,sBAAA;ACbpB","file":"pricereview.css"}

15
wms/mkt/css/pricereview.scss

@ -57,7 +57,8 @@
width: 55px; width: 55px;
height: 30px; height: 30px;
padding: 0; padding: 0;
margin-left: 10px; margin-left: 6px;
margin-bottom: 2px;
font-size: 13px; font-size: 13px;
&.addbtn{ &.addbtn{
background-color: #337AB7; background-color: #337AB7;
@ -106,6 +107,10 @@
tr:hover .deleteBtn ,tr:hover .copyBtn{ tr:hover .deleteBtn ,tr:hover .copyBtn{
opacity: 1; opacity: 1;
} }
.copyBtn{
width: 30px;
height: 30px;
}
.saletd{ .saletd{
position: relative; position: relative;
>.deleteBtn{ >.deleteBtn{
@ -221,7 +226,7 @@
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
position: absolute; position: absolute;
width:1200px; width:90%;
padding: 30px; padding: 30px;
top: 50%; top: 50%;
left:50%; left:50%;
@ -229,13 +234,13 @@
box-shadow: 0 5px 5px #222; box-shadow: 0 5px 5px #222;
animation: fade-in .2s linear; animation: fade-in .2s linear;
&.modal-xl{ &.modal-xl{
width:1200px; max-width:1200px;
} }
&.modal-lg{ &.modal-lg{
width:800px; max-width:800px;
} }
&.modal-m{ &.modal-m{
width:450px; max-width:450px;
} }
.window-modal-header{ .window-modal-header{
display: flex; display: flex;

BIN
wms/mkt/files/MAF200.xlsx

Binary file not shown.

BIN
wms/mkt/files/MAQ100.xlsx

Binary file not shown.

248
wms/mkt/price_normal-index.php

@ -36,6 +36,8 @@ include "../header.php";
<li><a href="#4a" data-toggle="tab">高速梯</a></li> <li><a href="#4a" data-toggle="tab">高速梯</a></li>
<li><a href="#5a" data-toggle="tab">小機房貨梯</a></li> <li><a href="#5a" data-toggle="tab">小機房貨梯</a></li>
<li><a href="#6a" data-toggle="tab">平台梯</a></li> <li><a href="#6a" data-toggle="tab">平台梯</a></li>
<li><a href="#7a" data-toggle="tab">無機房貨梯</a></li>
<li><a href="#8a" data-toggle="tab">強趨梯</a></li>
</ul> </ul>
<div class="tab-content clearfix"> <div class="tab-content clearfix">
<div class="tab-pane active" id="1a"> <div class="tab-pane active" id="1a">
@ -813,6 +815,252 @@ include "../header.php";
<![endif]> <![endif]>
</table> </table>
</div> </div>
<div class="tab-pane" id="7a">
<a href="./files/MAF200.xlsx" download class="btn btn-success" style="margin:16px 0 ">下載電子檔(無機房貨梯)</a>
<table border=0 cellpadding=0 cellspacing=0 width=783 style='border-collapse:
collapse;table-layout:fixed;width:588pt'>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl123 width=261 style='height:38.0pt;width:196pt'></td>
<td class=xl123 width=261 style='width:196pt'>無機房貨梯</td>
<td class=xl123 width=261 style='width:196pt'>單位:萬元</td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl95 style='height:38.0pt'><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>                </span></td>
<td class=xl88 style='border-left:none'>標準價</td>
<td class=xl92 style='border-left:none'>(±1S)<span style='mso-spacerun:yes'> </span></td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-750*3-2S45</td>
<td class=xl109 style='border-top:none;border-left:none'>113.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>5.3 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-750*3-2S60</td>
<td class=xl109 style='border-top:none;border-left:none'>115.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>5.3 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-1000*3-2S45</td>
<td class=xl109 style='border-top:none;border-left:none'>136.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>5.3 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-1500*3-2S45</td>
<td class=xl109 style='border-top:none;border-left:none'>165.7 </td>
<td class=xl110 style='border-top:none;border-left:none'>9.8 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-1500*3-2S60</td>
<td class=xl109 style='border-top:none;border-left:none'>169.2 </td>
<td class=xl110 style='border-top:none;border-left:none'>9.8 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-2000*3-2S45</td>
<td class=xl109 style='border-top:none;border-left:none'>186.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>10.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-2000*3-2S60</td>
<td class=xl109 style='border-top:none;border-left:none'>188.7 </td>
<td class=xl110 style='border-top:none;border-left:none'>10.0 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-2500*3-4PCO45</td>
<td class=xl109 style='border-top:none;border-left:none'>263.3 </td>
<td class=xl110 style='border-top:none;border-left:none'>14.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-2500*3-4PCO60</td>
<td class=xl109 style='border-top:none;border-left:none'>265.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>14.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-3000*3-4PCO45</td>
<td class=xl109 style='border-top:none;border-left:none'>281.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>15.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-3000*3-4PCO60</td>
<td class=xl109 style='border-top:none;border-left:none'>283.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>15.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-3500*3-4PCO45</td>
<td class=xl109 style='border-top:none;border-left:none'>330.6 </td>
<td class=xl110 style='border-top:none;border-left:none'>18.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAF200-3500*3-4PCO60</td>
<td class=xl109 style='border-top:none;border-left:none'>333.2 </td>
<td class=xl110 style='border-top:none;border-left:none'>18.2 </td>
</tr>
<tr class=xl66 height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'></td>
<td class=xl109 style='border-top:none;border-left:none'> </td>
<td class=xl110 style='border-top:none;border-left:none'> </td>
</tr>
<tr class=xl67 height=33 style='mso-height-source:userset;height:25.25pt'>
<td height=33 class=xl99 style='height:25.25pt'>註:<br>1、最低為2停</td>
<td class=xl99></td>
<td class=xl99></td>
</tr>
<tr class=xl67 height=33 style='mso-height-source:userset;height:25.25pt'>
<td height=33 class=xl99 colspan=2 style='height:25.25pt;mso-ignore:colspan'>2、處長權限為發佈價之80%。</td>
<td class=xl99></td>
</tr>
<![if supportMisalignedColumns]>
<tr height=0 style='display:none'>
<td width=261 style='width:196pt'></td>
<td width=261 style='width:196pt'></td>
<td width=261 style='width:196pt'></td>
</tr>
<![endif]>
</table>
</div>
<div class="tab-pane" id="8a">
<a href="./files/MAQ100.xlsx" download class="btn btn-success" style="margin:16px 0 ">下載電子檔(強趨梯)</a>
<table border=0 cellpadding=0 cellspacing=0 width=783 style='border-collapse:
collapse;table-layout:fixed;width:588pt'>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl123 width=200 style='height:38.0pt;width:196pt'></td>
<td class=xl123 width=200 style='width:150pt'>強趨梯</td>
<td class=xl123 width=200 style='width:150pt'>單位:萬元</td>
<td class=xl123 width=200 style='width:150pt'></td>
<td class=xl123 width=200 style='width:150pt'></td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl95 style='height:38.0pt'><span style='mso-spacerun:yes'> </span><span style='mso-spacerun:yes'>                </span></td>
<td class=xl88 style='border-left:none'>產品系列</td>
<td class=xl88 style='border-left:none'>樓層</td>
<td class=xl88 style='border-left:none'>標準價</td>
<td class=xl92 style='border-left:none'>(±1S)<span style='mso-spacerun:yes'> </span></td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G5 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>70.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G6 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>70.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G10 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>72.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G20 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>72.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A2 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>77.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A3 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>78.7 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A6</td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>77.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-4PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A8 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>78.7 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G5 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>68.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G6 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>68.0 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G10 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>70.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>G20 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>70.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A2 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>75.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A3 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>76.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A6</td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>75.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr height=51 style='mso-height-source:userset;height:38.0pt'>
<td height=51 class=xl89 style='height:38.0pt;border-top:none'>MAQ100-4*-2PCO24</td>
<td class=xl109 style='border-top:none;border-left:none'>A8 </td>
<td class=xl109 style='border-top:none;border-left:none'>4 </td>
<td class=xl109 style='border-top:none;border-left:none'>76.5 </td>
<td class=xl110 style='border-top:none;border-left:none'>2.0 </td>
</tr>
<tr class=xl67 height=33 style='mso-height-source:userset;height:25.25pt'>
<td height=33 class=xl99 colspan=2 style='height:25.25pt;mso-ignore:colspan'><br>1、處長權限為發佈價之80%<br>
2、開門改2PCO,井道不變時,出入口寬需由800mm變成為600mm;或井道需加寬400mm</td>
<td class=xl99></td>
</tr>
<![if supportMisalignedColumns]>
<tr height=0 style='display:none'>
<td width=261 style='width:196pt'></td>
<td width=261 style='width:196pt'></td>
<td width=261 style='width:196pt'></td>
</tr>
<![endif]>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>

2
wms/mkt/pricereview-index.php

@ -484,7 +484,7 @@ if ($data) :
if ($data["status"] == "Y1") { if ($data["status"] == "Y1") {
?> ?>
<a href="pricereview-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a> <a href="pricereviewCreate.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a>
<a href="pricereview-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a> <a href="pricereview-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a>
<?php <?php
} elseif ($data["status"] == "YS") { } elseif ($data["status"] == "YS") {

261
wms/mkt/pricereviewCheck.php

@ -28,12 +28,27 @@ $sql_str = "SELECT pricereview_item.*, option_mi.price AS option_mi, option_pric
FROM pricereview_item FROM pricereview_item
LEFT JOIN option_mi ON option_mi.option_price_id = pricereview_item.price_id LEFT JOIN option_mi ON option_mi.option_price_id = pricereview_item.price_id
LEFT JOIN option_price ON option_price.id = pricereview_item.price_id LEFT JOIN option_price ON option_price.id = pricereview_item.price_id
WHERE pricereview_item.mid = :mid AND option_mi.open_kind = 'CO' ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC"; WHERE pricereview_item.mid = :mid AND pricereview_item.item_group = 'B' AND option_mi.open_kind = 'CO' ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id); $stmt->bindParam(':mid', $id);
$stmt->execute(); $stmt->execute();
$options = $stmt->fetchAll(PDO::FETCH_ASSOC); $options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT pricereview_item.*, fp.price
FROM pricereview_item
LEFT JOIN (
SELECT fp1.*
FROM facility_price fp1
LEFT JOIN facility_price fp2
ON (fp1.model = fp2.model AND fp1.id < fp2.id)
WHERE fp2.id IS NULL
) AS fp ON fp.model = pricereview_item.item_spec
WHERE pricereview_item.mid = :mid AND pricereview_item.item_group = 'A'
";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id);
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql_str = "SELECT * FROM pricereview_item $sql_str = "SELECT * FROM pricereview_item
WHERE pricereview_item.mid = :mid ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC"; WHERE pricereview_item.mid = :mid ORDER BY pricereview_item.item_group, pricereview_item.item_no ASC";
@ -47,69 +62,78 @@ $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $id); $stmt->bindParam(':mid', $id);
$stmt->execute(); $stmt->execute();
$sign = $stmt->fetch(PDO::FETCH_ASSOC); $sign = $stmt->fetch(PDO::FETCH_ASSOC);
$currentSigner = ''; $currentSigner = '';
$currentSign = 0; $currentSign = 0;
// Y:已同意 N:不同意 W:待簽 if($sign){
// sign1 => 處長, sign2 => 業務承辦人, sign3 => 協理, sign4 => 總經理 // Y:已同意 N:不同意 W:待簽
if($sign['sign1'] == NULL || $sign['sign1'] ==''){ // sign1 => 處長, sign2 => 業務承辦人, sign3 => 協理, sign4 => 總經理
$sign1 = NULL; if($sign['sign1'] == NULL || $sign['sign1'] ==''){
}else{ $sign1 = NULL;
if( explode(",", $sign['sign1'])[1] != ''){
$sign1 = explode(",", $sign['sign1'])[1] == 'Y' ? 'Y' : 'N';
}else{ }else{
$sign1 = 'W'; if( explode(",", $sign['sign1'])[1] != ''){
$sign1 = explode(",", $sign['sign1'])[1] == 'Y' ? 'Y' : 'N';
}else{
$sign1 = 'W';
}
} }
}
if($sign['sign2'] == NULL || $sign['sign2'] ==''){ if($sign['sign2'] == NULL || $sign['sign2'] ==''){
$sign2 = NULL; $sign2 = NULL;
}else{
if( explode(",", $sign['sign2'])[1] != ''){
$sign2 = explode(",", $sign['sign2'])[1] == 'Y' ? 'Y' : 'N';
}else{ }else{
$sign2 = 'W'; if( explode(",", $sign['sign2'])[1] != ''){
$sign2 = explode(",", $sign['sign2'])[1] == 'Y' ? 'Y' : 'N';
}else{
$sign2 = 'W';
}
} }
}
if($sign['sign3'] == NULL || $sign['sign3'] ==''){ if($sign['sign3'] == NULL || $sign['sign3'] ==''){
$sign3 = NULL; $sign3 = NULL;
}else{
if( explode(",", $sign['sign3'])[1] != ''){
// $sign3 = explode(",", $sign['sign3'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign3'])[1] == 'YY') $sign3 = 'YY';
if(explode(",", $sign['sign3'])[1] == 'Y') $sign3 = 'Y';
}else{ }else{
$sign3 = 'W'; if( explode(",", $sign['sign3'])[1] != ''){
// $sign3 = explode(",", $sign['sign3'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign3'])[1] == 'YY') $sign3 = 'YY';
if(explode(",", $sign['sign3'])[1] == 'Y') $sign3 = 'Y';
if(explode(",", $sign['sign3'])[1] == 'N') $sign3 = 'N';
}else{
$sign3 = 'W';
}
} }
} if($sign['sign4'] == NULL || $sign['sign4'] ==''){
if($sign['sign4'] == NULL || $sign['sign4'] ==''){ $sign4 = NULL;
$sign4 = NULL;
}else{
if( explode(",", $sign['sign4'])[1] != ''){
// $sign4 = explode(",", $sign['sign4'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign4'])[1] == 'YY') $sign4 = 'YY';
if(explode(",", $sign['sign4'])[1] == 'Y') $sign4 = 'Y';
}else{ }else{
$sign4 = 'W'; if( explode(",", $sign['sign4'])[1] != ''){
// $sign4 = explode(",", $sign['sign4'])[1] == 'Y' ? 'Y' : 'N';
if(explode(",", $sign['sign4'])[1] == 'YY') $sign4 = 'YY';
if(explode(",", $sign['sign4'])[1] == 'Y') $sign4 = 'Y';
if(explode(",", $sign['sign4'])[1] == 'N') $sign4 = 'N';
}else{
$sign4 = 'W';
}
} }
}
if($sign1 == 'W'){ if($sign1 == 'W'){
$currentSigner = explode(",", $sign['sign1'])[0]; $currentSigner = explode(",", $sign['sign1'])[0];
$currentSign = 1; $currentSign = 1;
}elseif($sign2 == 'W'){ }elseif($sign2 == 'W'){
$currentSigner = explode(",", $sign['sign2'])[0]; $currentSigner = explode(",", $sign['sign2'])[0];
$currentSign = 2; $currentSign = 2;
}elseif($sign3 == 'W'){ }elseif($sign3 == 'W'){
$currentSigner = explode(",", $sign['sign3'])[0]; $currentSigner = explode(",", $sign['sign3'])[0];
$currentSign = 3; $currentSign = 3;
}elseif($sign4 == 'W'){ }elseif($sign4 == 'W'){
$currentSigner = explode(",", $sign['sign4'])[0]; $currentSigner = explode(",", $sign['sign4'])[0];
$currentSign = 4; $currentSign = 4;
}
}else{
$sign1 = NULL;
$sign2 = NULL;
$sign3 = NULL;
$sign4 = NULL;
} }
// $sql_str = "SELECT * FROM account WHERE accountid = :accountid"; // $sql_str = "SELECT * FROM account WHERE accountid = :accountid";
// $stmt = $conn->prepare($sql_str); // $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':accountid', $sign['sign']); // $stmt->bindParam(':accountid', $sign['sign']);
@ -186,9 +210,9 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<tr> <tr>
<td x-html="'<b>' + elevator.item_no + '</b>'"></td> <td x-html="'<b>' + elevator.item_no + '</b>'"></td>
<td > <a href="javascript:;" x-text="elevator.item_spec"></a></td> <td > <a href="javascript:;" x-text="elevator.item_spec"></a></td>
<td><input type="text" class="form-control" x-model="Number(elevator.item_unit_price).toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="Number(elevator.price).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="elevator.item_qty" disabled /></td> <td><input type="text" class="form-control" x-model="elevator.item_qty" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(elevator.item_unit_price * elevator.item_qty).toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="Number(elevator.price * elevator.item_qty).toLocaleString()" disabled /></td>
<?php if($permissions): ?> <?php if($permissions): ?>
<td> <td>
<input x-show="isNotfoundMi" type="text" class="form-control" value="公司無此規格"> <input x-show="isNotfoundMi" type="text" class="form-control" value="公司無此規格">
@ -202,7 +226,7 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<?php if($permissions): ?> <?php if($permissions): ?>
<tr> <tr>
<td colspan=5></td> <td colspan=5></td>
<td colspan=4> <td colspan=4 style="max-width:400px">
<div class="mi-info"> <div class="mi-info">
<span>電梯設備</span> <span>電梯設備</span>
<ul> <ul>
@ -213,13 +237,14 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<li x-html="'安裝成本:<b>' + (elevator.mi.install_fee * elevator.item_qty).toLocaleString() + '</b>'"></li> <li x-html="'安裝成本:<b>' + (elevator.mi.install_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'一年免保:<b>' + (elevator.mi.free1y_fee * elevator.item_qty).toLocaleString() + '</b>'"></li> <li x-html="'一年免保:<b>' + (elevator.mi.free1y_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-html="'起吊+木箱+耗材:<b>' + (elevator.mi.other_fee * elevator.item_qty).toLocaleString() + '</b>'"></li> <li x-html="'起吊+木箱+耗材:<b>' + (elevator.mi.other_fee * elevator.item_qty).toLocaleString() + '</b>'"></li>
<li x-show="elevator.mi.add_price > 0" x-html="'加價:<b>' + (elevator.mi.add_price * elevator.item_qty).toLocaleString() + '</b>'"></li>
</ul> </ul>
<p x-html="'以上合計:<b>' + (elevator.totalMi * elevator.item_qty).toLocaleString() + '</b>'"></p> <p x-html="'以上合計:<b>' + (elevator.totalMi * elevator.item_qty).toLocaleString() + '</b>'"></p>
<div class="line"></div> <div class="line"></div>
<span>OPTION</span> <span>OPTION</span>
<ul> <ul>
<template x-for="option in elevator.options"> <template x-for="option in elevator.options">
<li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li> <li x-html="option.item_spec + (option.option_memo ? ('(' + option.option_memo + ')') : '') + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template> </template>
<template x-for="option in elevator.otherOptions"> <template x-for="option in elevator.otherOptions">
<li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li> <li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
@ -227,8 +252,11 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<template x-for="option in elevator.maintainOptions"> <template x-for="option in elevator.maintainOptions">
<li x-html="option.item_spec + '(' + option.item_qty + '月):<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li> <li x-html="option.item_spec + '(' + option.item_qty + '月):<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template> </template>
<template x-for="option in elevator.demolishOptions">
<li x-html="option.item_spec + '*' + option.item_qty + ':<b>' + (option.mi * option.item_qty).toLocaleString() + '</b>'"></li>
</template>
</ul> </ul>
<p x-html="'以上合計:<b>' + (Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice))).toLocaleString() + '</b>'"></p> <p x-html="'以上合計:<b>' + (Math.round(Number(elevator.optionsTotalPrice) + Number(elevator.otherOptionsTotalPrice) + Number(elevator.maintainOptionsTotalPrice)) + Number(elevator.demolishOptionsTotalPrice)).toLocaleString() + '</b>'"></p>
</div> </div>
</td> </td>
@ -271,13 +299,16 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<td x-text="option.option_relate_spec"></td> <td x-text="option.option_relate_spec"></td>
</tr> </tr>
</template> </template>
<tr> <template x-if="options.length > 0">
<td colspan=5>小計</td> <tr>
<td > <td colspan=5>小計</td>
<input type="text" x-model="optionsTotalPrice().toLocaleString()" disabled class="form-control"> <td >
</td> <input type="text" x-model="optionsTotalPrice().toLocaleString()" disabled class="form-control">
<td colspan=3></td> </td>
</tr> <td colspan=3></td>
</tr>
</template>
</tbody> </tbody>
</table> </table>
@ -308,13 +339,15 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<td x-text="option.option_relate_spec"></td> <td x-text="option.option_relate_spec"></td>
</tr> </tr>
</template> </template>
<tr> <template x-if="otherOptions.length > 0">
<td colspan=5>小計</td> <tr>
<td > <td colspan=5>小計</td>
<input type="text" x-model="otherOptionsTotalPrice().toLocaleString()" disabled class="form-control"> <td >
</td> <input type="text" x-model="otherOptionsTotalPrice().toLocaleString()" disabled class="form-control">
<td colspan=3></td> </td>
</tr> <td colspan=3></td>
</tr>
</template>
</tbody> </tbody>
</table> </table>
@ -346,13 +379,55 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
</tr> </tr>
</template> </template>
<template x-if="maintainOptions.length > 0">
<tr>
<td colspan=4>小計</td>
<td >
<input type="text" x-model="maintainOptionsTotalPrice().toLocaleString()" disabled class="form-control">
</td>
<td colspan=2></td>
</tr>
</template>
</tbody>
</table>
<table class="table mi-table" border=1>
<thead>
<tr> <tr>
<td colspan=4>小計</td> <th colspan=8>拆梯價格</th>
<td > </tr>
<input type="text" x-model="maintainOptionsTotalPrice().toLocaleString()" disabled class="form-control"> <tr>
</td> <th>項次</th>
<td colspan=2></td> <th>人乘/載重</th>
<th>樓層</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>所屬電梯項次</th>
</tr> </tr>
</thead>
<tbody>
<template x-for="option in demolishOptions">
<tr>
<td x-text="option.item_no"></td>
<td x-text="option.item_spec"></td>
<td x-text="option.note"></td>
<td x-text="Number(option.item_unit_price).toLocaleString()"></td>
<td x-text="option.item_qty"></td>
<td x-text="(option.item_qty * option.item_unit_price).toLocaleString()"></td>
<td x-text="option.option_relate_spec"></td>
</tr>
</template>
<template x-if="demolishOptions.length > 0">
<tr>
<td colspan=4>小計</td>
<td >
<input type="text" x-model="demolishOptionsTotalPrice().toLocaleString()" disabled class="form-control">
</td>
<td colspan=2></td>
</tr>
</template>
</tbody> </tbody>
</table> </table>
@ -526,12 +601,12 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<th>價率%(B/A)</th> <th>價率%(B/A)</th>
</tr> </tr>
<tr> <tr>
<td><input type="text" class="form-control" x-model="Number(price_lowest).toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="Number(totalStandardPrice()).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="Number(price_total).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="(price_total - price_lowest).toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="(price_total - price_lowest).toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="qty" disabled /></td> <td><input type="text" class="form-control" x-model="qty" disabled /></td>
<td><input type="text" class="form-control" x-model="special_fee.toLocaleString()" disabled /></td> <td><input type="text" class="form-control" x-model="special_fee.toLocaleString()" disabled /></td>
<td><input type="text" class="form-control" x-model="Math.round(price_total/price_lowest * 1000)/10" disabled /></td> <td><input type="text" class="form-control" x-model="Math.round(price_total/totalStandardPrice() * 1000)/10" disabled /></td>
</tr> </tr>
<tr> <tr>
<th>預定成交日</th> <th>預定成交日</th>
@ -604,8 +679,8 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
} }
?> ?>
</td> </td>
<td><?php echo $sign['sign1_note'] ?></td> <td><?php echo isset($sign['sign1_note']) ? $sign['sign1_note'] : "---" ?></td>
<td><?php echo explode(',', $sign['sign1'])[2] ?></td> <td><?php echo isset($sign['sign1']) ? explode(',', $sign['sign1'])[2] : "---" ?></td>
</tr> </tr>
<tr> <tr>
<td>業務承辦人</td> <td>業務承辦人</td>
@ -623,8 +698,8 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
} }
?> ?>
</td> </td>
<td><?php echo $sign['sign2']!=NULL ? $sign['sign2_note'] : '---'?></td> <td><?php echo (isset($sign['sign2']) && $sign['sign2']!=NULL) ? $sign['sign2_note'] : '---'?></td>
<td><?php echo $sign['sign2']!=NULL ? explode(',', $sign['sign2'])[2] : '---' ?></td> <td><?php echo (isset($sign['sign2']) && $sign['sign2']!=NULL) ? explode(',', $sign['sign2'])[2] : '---' ?></td>
</tr> </tr>
<tr> <tr>
<td>業務部協理</td> <td>業務部協理</td>
@ -644,8 +719,8 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
} }
?> ?>
</td> </td>
<td><?php echo $sign['sign3']!=NULL ? $sign['sign3_note'] : '---'?></td> <td><?php echo (isset($sign['sign3']) && $sign['sign3']!=NULL) ? $sign['sign3_note'] : '---'?></td>
<td><?php echo $sign['sign3']!=NULL ? explode(',', $sign['sign3'])[2] : '---' ?></td> <td><?php echo (isset($sign['sign3']) && $sign['sign3']!=NULL) ? explode(',', $sign['sign3'])[2] : '---' ?></td>
</tr> </tr>
<tr> <tr>
<td>總經理</td> <td>總經理</td>
@ -659,11 +734,11 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
echo "結案同意"; echo "結案同意";
} }
}else{ }else{
if($sign4 == 'Y'){ if($sign4 == 'Y' && $contract['status'] == 'YY'){
echo "同意"; echo "同意";
}elseif($sign4 == 'N'){ }elseif($sign4 == 'N' && $contract['status'] == 'YN'){
echo "不同意"; echo "不同意";
}elseif($sign4 == 'W'){ }elseif($sign4 == 'W' && $contract['status'] == 'YS'){
echo "待簽核"; echo "待簽核";
}else{ }else{
echo "---"; echo "---";
@ -671,8 +746,8 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
} }
?> ?>
</td> </td>
<td><?php echo $sign['sign4']!=NULL ? $sign['sign4_note'] : '---'?></td> <td><?php echo (isset($sign['sign4']) && $sign['sign4']!=NULL) ? $sign['sign4_note'] : '---'?></td>
<td><?php echo $sign['sign4']!=NULL ? explode(',', $sign['sign4'])[2] : '---' ?></td> <td><?php echo (isset($sign['sign4']) && $sign['sign4']!=NULL) ? explode(',', $sign['sign4'])[2] : '---' ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -705,8 +780,8 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
<button class="btn btn-primary" @click="check(<?php echo $currentSign; ?>, 'YY')">同意(結案)</button> <button class="btn btn-primary" @click="check(<?php echo $currentSign; ?>, 'YY')">同意(結案)</button>
<?php endif; ?> <?php endif; ?>
<?php } ?> <?php } ?>
<button class="btn btn-primary">下載報價單</button> <a class="btn btn-primary" href="./<?php echo $contract['attatch1']; ?>" download="<?php echo $contract['contractno'] . "報價單"; ?>">下載報價單</a>
<button class="btn btn-primary">下載附表一</button> <a class="btn btn-primary" href="./<?php echo $contract['attatch2']; ?>" download="<?php echo $contract['contractno'] . "附表一"; ?>">下載附表一</a>
</div> </div>
</div> </div>
@ -728,20 +803,20 @@ if($user_id == "M0174" || $user_id == "M0175" || $user_id == "M0060"){
const deposit_rate = '<?php echo $contract['deposit_rate']; ?>'; const deposit_rate = '<?php echo $contract['deposit_rate']; ?>';
const keep_rate = '<?php echo $contract['keep_rate']; ?>'; const keep_rate = '<?php echo $contract['keep_rate']; ?>';
const warranty_rate = '<?php echo $contract['warranty_rate']; ?>'; const warranty_rate = '<?php echo $contract['warranty_rate']; ?>';
const memo = '<?php echo $contract['memo']; ?>'; const memo = `<?php echo str_replace('\n', '\\n', $contract['memo']); ?>`;
const pays = [...<?php echo json_encode($pays); ?>]; const pays = [...<?php echo json_encode($pays); ?>];
const items = [...<?php echo json_encode($items); ?>]; const items = [...<?php echo json_encode($items); ?>];
const options = [...<?php echo json_encode($options); ?>]; const options = [...<?php echo json_encode($options); ?>];
const elevators = [...<?php echo json_encode($elevators); ?>];
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 explode(',', $sign['sign1'])[0] ?>'; const sign1 = '<?php echo ($sign) ? explode(',', $sign['sign1'])[0] : "---" ?>';
const sign2 = '<?php echo explode(',', $sign['sign2'])[0] ?>'; const sign2 = '<?php echo ($sign) ? explode(',', $sign['sign2'])[0] : "---" ?>';
console.log('sign2====>', sign2); console.log('sign2====>', sign2);
const sign3 = '<?php echo explode(',', $sign['sign3'])[0] ?>'; const sign3 = '<?php echo ($sign) ? explode(',', $sign['sign3'])[0] : "---" ?>';
const sign4 = '<?php echo explode(',', $sign['sign4'])[0] ?>'; const sign4 = '<?php echo ($sign) ? explode(',', $sign['sign4'])[0] : "---" ?>';
</script> </script>

641
wms/mkt/pricereviewCreate.php

@ -12,8 +12,25 @@ foreach ($options as $key => $option) {
$options[$key]['isShow'] = 1; $options[$key]['isShow'] = 1;
$options[$key]['selected'] = 0; $options[$key]['selected'] = 0;
} }
$vol_no = $_GET['vol_no']; $vol_no = "";
if(isset($_GET['vol_no'])){
$vol_no = $_GET['vol_no'];
}
$main = false;
if(isset($_GET['id'])){
$id = $_GET['id'];
$sql_str = "SELECT * FROM pricereview_main WHERE id=:id ORDER BY id DESC LIMIT 1";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$main = $stmt->fetch(PDO::FETCH_ASSOC);
$vol_no = $main['contractno'];
}
if($main && $main['status'] == 'YS'){
echo "<script>alert('此單正在審核中!');window.history.go(-1);</script>";
exit;
}
$hope_status = [ $hope_status = [
'A'=>'有望簽約(已報價)', 'A'=>'有望簽約(已報價)',
'B'=>'觀望考慮(等待時機報價)', 'B'=>'觀望考慮(等待時機報價)',
@ -31,52 +48,262 @@ $stmt->bindParam(':vol_no', $vol_no);
$stmt->execute(); $stmt->execute();
$hope_customer = $stmt->fetch(PDO::FETCH_ASSOC); $hope_customer = $stmt->fetch(PDO::FETCH_ASSOC);
//獲取有望客戶電梯規格 if($user_id !== $hope_customer['salesman'] && $user_id !== "M0174"){
$sql_str = "SELECT echo "<script>alert('無權限編輯此紀錄!您不是該單營業員。');window.history.go(-1);</script>";
hope_project_elevator_spec.specifications, exit;
hope_project_elevator_spec.person, }
hope_project_elevator_spec.stop,
hope_project_elevator_spec.speed, $hope_elevators = [];
hope_project_elevator_spec.open,
hope_project_elevator_spec.spec_price,
hope_project_elevator_spec.spec_num,
fp.price AS price,
fp.id AS facility_id,
CASE hope_project_elevator_spec.open
WHEN 4 THEN '2U'
WHEN 5 THEN '4PCO'
WHEN 7 THEN '6PCO'
WHEN 8 THEN '2S'
WHEN 9 THEN 'CO'
ELSE hope_project_elevator_spec.open
END AS open_converted
FROM hope_project_elevator_spec
LEFT JOIN (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY model ORDER BY create_dt DESC) as rn
FROM facility_price
) fp ON fp.model = CONCAT(hope_project_elevator_spec.specifications, '-', hope_project_elevator_spec.person, '*', hope_project_elevator_spec.stop, '-', CASE hope_project_elevator_spec.open
WHEN 4 THEN '2U'
WHEN 5 THEN '4PCO'
WHEN 7 THEN '6PCO'
WHEN 8 THEN '2S'
WHEN 9 THEN 'CO'
ELSE hope_project_elevator_spec.open
END, hope_project_elevator_spec.speed)
AND fp.rn = 1
WHERE hope_project_elevator_spec.vol_no = :vol_no
ORDER BY hope_project_elevator_spec.seq ASC;";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute();
$hope_elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total_spec = 0; $total_spec = 0;
foreach ($hope_elevators as $key => $elevator) { $selectedOptions = [];
$hope_elevators[$key]['id'] = $key+1; $optionKey = 0;
$total_spec ++; $otherOptions = [];
$otherOptionKey = 0;
$demolishOptions = [];
$demolishOptionKey = 0;
if($main){
$mid = $main["id"];
$sql_str = "SELECT
pricereview_item.*,
fp.price AS price,
fp.id AS facility_id,
pricereview_item.item_op AS open_converted
FROM
pricereview_item
LEFT JOIN
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY model ORDER BY create_dt DESC) as rn
FROM
facility_price
) fp
ON fp.model = pricereview_item.item_spec AND fp.rn = 1
WHERE
mid = :mid AND
item_group = 'A'
";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($elevators as $key=>$elevator){
$open = "";
if($elevator['item_op'] == "2U"){
$open = 4;
}elseif($elevator['item_op'] == "4PCO"){
$open = 5;
}elseif($elevator['item_op'] == "6PCO"){
$open = 7;
}elseif($elevator['item_op'] == "2S"){
$open = 8;
}elseif($elevator['item_op'] == "CO"){
$open = 9;
}
$hope_elevators[] = [
'id' => $elevator['item_no'],
'model' => $elevator['item_spec'],
'specifications' => explode(",", $elevator['note'])[0],
'person' => explode(",", $elevator['note'])[1],
'stop' => explode(",", $elevator['note'])[2],
'speed' => explode(",", $elevator['note'])[3],
'open_converted' => $elevator['item_op'],
'open' => $open,
'spec_price' => $elevator['item_price_ct'],
'price' => $elevator['price'],
'spec_num' => $elevator['item_qty'],
'facility_id' => $elevator['facility_id'],
];
if($elevator['item_no'] > $total_spec){
$total_spec = $elevator['item_no'];
}
}
$sql_str = "SELECT pricereview_item.price_id, pricereview_item.item_qty, pricereview_item.option_relate_spec, pricereview_item.item_no, option_price.* FROM pricereview_item
LEFT JOIN option_price ON option_price.id = pricereview_item.price_id
WHERE mid = :mid AND item_group = 'B'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$oldOptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($oldOptions as $oldoption){
$selectedOptions[] = [
'id'=>$oldoption['price_id'],
'idx'=>0,
'key'=>$oldoption['item_no'],
'qty'=>$oldoption['item_qty'],
'name'=>$oldoption['group_name'],
'price'=>$oldoption['price'],
'memo'=>$oldoption['memo'],
'toElevator'=>[
[
'id'=>$oldoption['option_relate_spec'],
'model'=> array_values(array_filter($hope_elevators, fn($val)=> $val['id'] == $oldoption['option_relate_spec']))[0]['model'],
]
]
];
if($oldoption['item_no'] > $optionKey){
$optionKey = $oldoption['item_no'];
}
}
//除外項目
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group='E'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$oldOtherOptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($oldOtherOptions as $oldotheroption){
$otherOptions[] = [
'id'=>$oldotheroption['item_no'],
'name'=>$oldotheroption['item_spec'],
'num'=>$oldotheroption['item_qty'],
'price'=>$oldotheroption['item_unit_price'],
'pr_no'=>$oldotheroption['note'],
'toElevator'=>[
[
'id'=>$oldotheroption['option_relate_spec'],
'model'=> array_values(array_filter($hope_elevators, fn($val)=> $val['id'] == $oldotheroption['option_relate_spec']))[0]['model'],
]
]
];
if($oldotheroption['item_no'] > $otherOptionKey){
$otherOptionKey = $oldotheroption['item_no'];
}
}
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group='C'";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->execute();
$oldDemolishOptions = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($oldDemolishOptions as $olddemolishoption){
$demolishOptions[] = [
'id'=>$olddemolishoption['item_no'],
'price'=>$olddemolishoption['item_unit_price'],
'qty'=>$olddemolishoption['item_qty'],
'floor'=>$olddemolishoption['note'],
'person'=>$olddemolishoption['item_spec'],
'demolish_id'=>$olddemolishoption['price_id'],
'toElevator'=>[
[
'id'=>$olddemolishoption['option_relate_spec'],
'model'=> array_values(array_filter($hope_elevators, fn($val)=> $val['id'] == $olddemolishoption['option_relate_spec']))[0]['model'],
]
]
];
if($demolishOptionKey < $olddemolishoption['item_no']){
$demolishOptionKey = $olddemolishoption['item_no'];
}
}
$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);
$paymentRatio = [];
if($pays){
foreach($pays as $pay){
$paymentRatio[] = [
'scale'=>$pay['pay_scale'],
'ticket'=>$pay['pay_period'],
];
}
}else{
$paymentRatio = [
[
'scale'=>20,
'ticket'=>30,
],
[
'scale'=>0,
'ticket'=>'',
],
[
'scale'=>50,
'ticket'=>30,
],
[
'scale'=>0,
'ticket'=>'',
],
[
'scale'=>20,
'ticket'=>30,
],
[
'scale'=>10,
'ticket'=>30,
],
[
'scale'=>0,
'ticket'=>'',
],
];
}
}else{
//獲取有望客戶電梯規格
$sql_str = "SELECT
hope_project_elevator_spec.specifications,
hope_project_elevator_spec.person,
hope_project_elevator_spec.stop,
hope_project_elevator_spec.speed,
hope_project_elevator_spec.open,
hope_project_elevator_spec.spec_price,
hope_project_elevator_spec.spec_num,
fp.price AS price,
fp.id AS facility_id,
CASE hope_project_elevator_spec.open
WHEN 4 THEN '2U'
WHEN 5 THEN '4PCO'
WHEN 7 THEN '6PCO'
WHEN 8 THEN '2S'
WHEN 9 THEN 'CO'
ELSE hope_project_elevator_spec.open
END AS open_converted
FROM hope_project_elevator_spec
LEFT JOIN (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY model ORDER BY create_dt DESC) as rn
FROM facility_price
) fp ON fp.model = CONCAT(hope_project_elevator_spec.specifications, '-', hope_project_elevator_spec.person, '*', hope_project_elevator_spec.stop, '-', CASE hope_project_elevator_spec.open
WHEN 4 THEN '2U'
WHEN 5 THEN '4PCO'
WHEN 7 THEN '6PCO'
WHEN 8 THEN '2S'
WHEN 9 THEN 'CO'
ELSE hope_project_elevator_spec.open
END, hope_project_elevator_spec.speed)
AND fp.rn = 1
WHERE hope_project_elevator_spec.vol_no = :vol_no
ORDER BY hope_project_elevator_spec.seq ASC;";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':vol_no', $vol_no);
$stmt->execute();
$hope_elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($hope_elevators as $key => $elevator) {
$hope_elevators[$key]['id'] = $key+1;
$spec = $elevator['specifications'];
if($spec == 'M1' || $spec == 'M1+M4(1:1)' || $spec == 'M1+M4(2:1)'){
//稍後再處理
}else{
$hope_elevators[$key]['model'] = $elevator['specifications'] . "-" . $elevator['person'] . "*" . $elevator['stop'] . "-" . $elevator['open_converted'] . $elevator['speed'];
}
$total_spec ++;
}
} }
function convertDateTimeFormat($dateTimeStr) { function convertDateTimeFormat($dateTimeStr) {
// 使用 DateTime::createFromFormat 解析给定格式的日期时间 // 使用 DateTime::createFromFormat 解析给定格式的日期时间
$date = DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeStr); $date = DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeStr);
@ -264,131 +491,49 @@ function convertDateTimeFormat($dateTimeStr) {
</div> </div>
<div class="window-back" @click="hideToMaintainOptionElevatorModal()"></div> <div class="window-back" @click="hideToMaintainOptionElevatorModal()"></div>
</div> </div>
<div class="window-modal" x-ref="createElevatorModal" id="createElevatorModal"> <div class="window-modal" x-ref="toDemolishOptionElevatorModal" id="toDemolishOptionElevatorModal">
<div class="window-modal-content modal-xl"> <div class="window-modal-content modal-m">
<div class="window-modal-header"> <div class="window-modal-header">
<h4>新增電梯規格</h4> <h4>配對電梯</h4>
<button class="btn btn-close" @click="hideCreateElevatorModal()">X</button> <button class="btn btn-close" @click="hideToDemolishOptionElevatorModal()">X</button>
</div> </div>
<div class="window-modal-body"> <div class="window-modal-body">
<div> <div>
<table class="table"> <table class="table">
<tr class="table-active">
<th>電梯</th>
<th>人乘/載重</th>
<th>停數</th>
<th>速度</th>
</tr>
<tr> <tr>
<td> <th>項次</th>
<select name="" id="" class="form-control" x-model="modalElevatorInfo.spec" @change="getModalElevatorPrice()">
<option value="">請選擇</option>
<option value="MAE100">MAE100有機房</option>
<option value="MAM200">MAM200無機房</option>
<option value="MAH100">MAH100小電梯</option>
<option value="MAF100">MAE100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option>
</select>
</td>
<td>
<select name="" id="" class="form-control" x-model="modalElevatorInfo.person" @change="getModalElevatorPrice()">
<option value="">請選擇</option>
<option value="6">6</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="15">15</option>
<option value="17">17</option>
<option value="20">20</option>
<option value="24">24</option>
</select>
</td>
<td>
<input type="number" class="form-control" style="width:83px" x-model="modalElevatorInfo.stop" @keyup="getModalElevatorPrice()" @change="getModalElevatorPrice()" />
</td>
<td>
<select name="" id="" class="form-control" x-model="modalElevatorInfo.speed" @change="getModalElevatorPrice()" >
<option value="">請選擇</option>
<option value="9">9</option>
<option value="24">24</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="60">60</option>
<option value="90">90</option>
<option value="105">105</option>
<option value="120">120</option>
<option value="150">150</option>
</select>
</td>
</tr>
<tr class="table-active">
<th>開門方式</th>
<th>規格</th> <th>規格</th>
<th>數量</th> <th>選擇</th>
<th></th>
</tr>
<tr>
<td>
<select name="" id="" class="form-control" style="width:83px" x-model="modalElevatorInfo.open" @change="getModalElevatorPrice()">
<option value="CO">CO</option>
<option value="2S">2S</option>
<option value="2U">CO</option>
<option value="4PCO">4PCO</option>
<option value="6PCO">6PCO</option>
</select>
</td>
<td>
<input type="text" x-show="!modalElevatorInfo.price || modalElevatorInfo.price ==''" class="form-control" disabled />
<input type="text" x-show="modalElevatorInfo.price > 0" class="form-control" disabled x-model="modalElevatorInfo.spec + '-' + modalElevatorInfo.person + '*' + modalElevatorInfo.stop + '-' + modalElevatorInfo.open + modalElevatorInfo.speed">
</td>
<td>
<input type="number" class="form-control" style="width:83px" x-model="modalElevatorInfo.num" >
</td>
<td></td>
</tr>
<tr class="table-active">
<th>公司發布價(單價)</th>
<th>公司發布價(複價)</th>
<th>自定售價(台)</th>
<th>自定售價(總價)</th>
</tr> </tr>
<tr> <template x-for="elevator in toElevators">
<td> <tr>
<input type="text" disabled class="form-control" x-model="(modalElevatorInfo.price).toLocaleString()"> <td x-text="elevator.id"></td>
</td> <td x-text="elevator.model"></td>
<td> <td><input type="radio" name="demolishOptionToElevator" :value="elevator.id" class="form-check-input" x-model="toElevatorNo" /></td>
<input type="text" disabled class="form-control" x-model="(modalElevatorInfo.price * modalElevatorInfo.num).toLocaleString()"> </tr>
</td> </template>
<td> <tr x-show="toElevators.length == 0">
<input type="number" class="form-control" x-model="modalElevatorInfo.sale_price"> <td colspan="3">
</td> <small class="text-danger" style="font-size:13px;font-weight:600">暫無可選電梯,請先新增電梯規格!</small>
<td>
<input type="text" disabled class="form-control" x-model="(modalElevatorInfo.sale_price * modalElevatorInfo.num).toLocaleString()">
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" @click="hideCreateElevatorModal()">關閉</button> <button type="button" class="btn btn-secondary" @click="hideToDemolishOptionElevatorModal()">關閉</button>
<button type="button" class="btn btn-primary" @click="createElevatorFn()">新增</button> <button type="button" class="btn btn-primary" @click="chkDemolishOptionToElevators()">確認</button>
</div> </div>
</div> </div>
<div class="window-back" @click="hideCreateElevatorModal()"></div> <div class="window-back" @click="hideToDemolishOptionElevatorModal()"></div>
</div> </div>
<!-- <div class="modal fade modal-dialog-scrollable modal-lg" id="createElevatorModal" tabindex="-1" aria-labelledby="createElevatorModalLabel" aria-hidden="true"> <div class="window-modal" x-ref="createElevatorModal" id="createElevatorModal">
<div class="modal-dialog"> <div class="window-modal-content modal-xl">
<div class="modal-content"> <div class="window-modal-header">
<div class="modal-header d-flex flex-column align-items-start"> <h4>新增電梯規格</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button class="btn btn-close" @click="hideCreateElevatorModal()">X</button>
<h5 class="modal-title" id="">新增電梯規格</h5>
</div> </div>
<div class="modal-body"> <div class="window-modal-body">
<div> <div>
<table class="table"> <table class="table">
<tr class="table-active"> <tr class="table-active">
@ -407,6 +552,11 @@ function convertDateTimeFormat($dateTimeStr) {
<option value="MAF100">MAE100貨梯(有機房)</option> <option value="MAF100">MAE100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option> <option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option> <option value="MAP100">MAP100平台梯</option>
<?php if($hope_customer['is_renovation']): ?>
<option value="M1">M1(系統更新)</option>
<option value="M1+M4(1:1)">M1+M4(1:1)系統+主機</option>
<option value="M1+M4(2:1)">M1+M4(2:1)系統+主機</option>
<?php endif; ?>
</select> </select>
</td> </td>
<td> <td>
@ -461,7 +611,7 @@ function convertDateTimeFormat($dateTimeStr) {
</td> </td>
<td> <td>
<input type="text" x-show="!modalElevatorInfo.price || modalElevatorInfo.price ==''" class="form-control" disabled /> <input type="text" x-show="!modalElevatorInfo.price || modalElevatorInfo.price ==''" class="form-control" disabled />
<input type="text" x-show="modalElevatorInfo.price > 0" class="form-control" disabled x-model="modalElevatorInfo.spec + '-' + modalElevatorInfo.person + '*' + modalElevatorInfo.stop + '-' + modalElevatorInfo.open + modalElevatorInfo.speed"> <input type="text" x-show="modalElevatorInfo.price > 0" class="form-control" disabled x-model="modalElevatorInfo.model">
</td> </td>
<td> <td>
<input type="number" class="form-control" style="width:83px" x-model="modalElevatorInfo.num" > <input type="number" class="form-control" style="width:83px" x-model="modalElevatorInfo.num" >
@ -492,12 +642,12 @@ function convertDateTimeFormat($dateTimeStr) {
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" x-ref="closeCreateElevatorModalBtn">關閉</button> <button type="button" class="btn btn-secondary" @click="hideCreateElevatorModal()">關閉</button>
<button type="button" class="btn btn-primary" @click="createElevatorFn()">新增</button> <button type="button" class="btn btn-primary" @click="createElevatorFn()">新增</button>
</div> </div>
</div>
</div> </div>
</div> --> <div class="window-back" @click="hideCreateElevatorModal()"></div>
</div>
<div class="window-modal" x-ref="createOtherOptionModal" id="createOtherOptionModal"> <div class="window-modal" x-ref="createOtherOptionModal" id="createOtherOptionModal">
<div class="window-modal-content modal-xl"> <div class="window-modal-content modal-xl">
<div class="window-modal-header"> <div class="window-modal-header">
@ -531,41 +681,6 @@ function convertDateTimeFormat($dateTimeStr) {
</div> </div>
<div class="window-back" @click="hideCreateOtherOptionModal()"></div> <div class="window-back" @click="hideCreateOtherOptionModal()"></div>
</div> </div>
<!-- <div class="modal fade modal-dialog-scrollable modal-xl" id="createOtherOptionModal" tabindex="-1" aria-labelledby="createElevatorModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header d-flex flex-column align-items-start">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<h5 class="modal-title" id="">新增除外項目</h5>
</div>
<div class="modal-body">
<div>
<table class="table">
<tr class="table-active">
<th>詢價單號</th>
<th>項目名稱</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
</tr>
<tr>
<td><input type="text" class="form-control" x-model="modalOtherOptionInfo.pr_no"></td>
<td><input type="text" class="form-control" x-model="modalOtherOptionInfo.name"></td>
<td><input type="number" class="form-control" x-model="modalOtherOptionInfo.price"></td>
<td><input type="number" class="form-control" x-model="modalOtherOptionInfo.num"></td>
<td><input type="text" disabled class="form-control" x-model="(modalOtherOptionInfo.price * modalOtherOptionInfo.num).toLocaleString()"></td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" x-ref="closeCreateOtherOptionModalBtn">關閉</button>
<button type="button" class="btn btn-primary" @click="createOtherOptionFn()">新增</button>
</div>
</div>
</div>
</div> -->
<div class="window-modal" x-ref="createMaintainModal" id="createMaintainModal"> <div class="window-modal" x-ref="createMaintainModal" id="createMaintainModal">
<div class="window-modal-content modal-xl"> <div class="window-modal-content modal-xl">
<div class="window-modal-header"> <div class="window-modal-header">
@ -597,41 +712,54 @@ function convertDateTimeFormat($dateTimeStr) {
</div> </div>
<div class="window-back" @click="hideCreateMaintainModal()"></div> <div class="window-back" @click="hideCreateMaintainModal()"></div>
</div> </div>
<!-- <div class="modal fade modal-dialog-scrollable modal-lg" id="createMaintainModal" tabindex="-1" aria-labelledby="createElevatorModalLabel" aria-hidden="true"> <div class="window-modal" x-ref="createDemolishModal" id="createDemolishModal">
<div class="modal-dialog"> <div class="window-modal-content modal-xl">
<div class="modal-content"> <div class="window-modal-header">
<div class="modal-header d-flex flex-column align-items-start"> <h4>新增拆梯價格</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button class="btn btn-close" @click="hideCreateDemolishModal()">X</button>
<h5 class="modal-title" id="">新增保固延長</h5>
</div> </div>
<div class="modal-body"> <div class="window-modal-body">
<div> <div>
<table class="table"> <table class="table">
<tr class="table-active"> <tr class="table-active">
<th>人乘/載重</th>
<th>樓層</th>
<th>單價</th> <th>單價</th>
<th>數量(月)</th> <th>數量</th>
<th>總價</th> <th>總價</th>
<th>備註</th>
</tr> </tr>
<tr> <tr>
<td><input type="number" class="form-control" x-model="modalMaintainInfo.price"></td> <td>
<td><input type="number" class="form-control" x-model="modalMaintainInfo.num"></td> <select class="form-control" x-model="modalDemolishOptionsInfo.person" @change="getModalDemolishPrice()">
<td><input type="text" disabled class="form-control" x-model="(modalMaintainInfo.price * modalMaintainInfo.num).toLocaleString()"></td> <option value="">請選擇</option>
<td><input type="text" class="form-control" x-model="modalMaintainInfo.memo"></td> <option value="15人(含)以下">15人(含)以下/1000KGS</option>
<option value="16~24人">16~24人/1001~1600KGS</option>
<option value="25~30人">25~30人/1601~2500KGS</option>
</select>
</td>
<td>
<select class="form-control" x-model="modalDemolishOptionsInfo.floor" @change="getModalDemolishPrice()">
<option value="">請選擇</option>
<?php for($i=4;$i<=40;$i++): ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</td>
<td><input type="text" disabled class="form-control" x-model="Number(modalDemolishOptionsInfo.price).toLocaleString()"></td>
<td><input type="number" class="form-control" x-model="modalDemolishOptionsInfo.qty"></td>
<td><input type="text" disabled class="form-control" x-model="(modalDemolishOptionsInfo.price * modalDemolishOptionsInfo.qty).toLocaleString()"></td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" x-ref="closeCreateMaintainOptionModalBtn">關閉</button> <button type="button" class="btn btn-secondary" @click="hideCreateDemolishModal()">關閉</button>
<button type="button" class="btn btn-primary" @click="createMaintainOptionFn()">新增</button> <button type="button" class="btn btn-primary" @click="createDemolishOptionFn()">新增</button>
</div>
</div> </div>
</div> </div>
</div> --> <div class="window-back" @click="hideCreateDemolishModal()"></div>
</div>
<div class="container"> <div class="container">
<table class="table" border="1"> <table class="table" border="1">
<thead > <thead >
<tr class="" > <tr class="" >
@ -758,6 +886,11 @@ function convertDateTimeFormat($dateTimeStr) {
<option value="MAF100">MAE100貨梯(有機房)</option> <option value="MAF100">MAE100貨梯(有機房)</option>
<option value="MAQ100">MAQ100強趨梯</option> <option value="MAQ100">MAQ100強趨梯</option>
<option value="MAP100">MAP100平台梯</option> <option value="MAP100">MAP100平台梯</option>
<?php if($hope_customer['is_renovation']): ?>
<option value="M1">M1(系統更新)</option>
<option value="M1+M4(1:1)">M1+M4(1:1)系統+主機</option>
<option value="M1+M4(2:1)">M1+M4(2:1)系統+主機</option>
<?php endif; ?>
</select> </select>
</td> </td>
<td> <td>
@ -804,7 +937,7 @@ function convertDateTimeFormat($dateTimeStr) {
</td> </td>
<td> <td>
<input type="text" x-show="elevator.specifications==''||elevator.person==''||elevator.stop==''||elevator.speed==''||elevator.open_converted==''" disabled class="form-control" /> <input type="text" x-show="elevator.specifications==''||elevator.person==''||elevator.stop==''||elevator.speed==''||elevator.open_converted==''" disabled class="form-control" />
<input type="text" style="width:150px" x-show="elevator.specifications!='' && elevator.person!='' && elevator.stop!='' && elevator.speed!='' && elevator.open_converted!=''" class="form-control" disabled x-model="elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed"> <input type="text" style="width:150px" x-show="elevator.specifications!='' && elevator.person!='' && elevator.stop!='' && elevator.speed!='' && elevator.open_converted!=''" class="form-control" disabled x-model="elevator.model">
</td> </td>
<td> <td>
<input type="text" class="form-control" disabled :value="Number(elevator.price).toLocaleString()"><span x-show="elevator.price==''" style="font-size:12px;color:red;font-weight:600">請填寫正確規格</span> <input type="text" class="form-control" disabled :value="Number(elevator.price).toLocaleString()"><span x-show="elevator.price==''" style="font-size:12px;color:red;font-weight:600">請填寫正確規格</span>
@ -869,6 +1002,7 @@ function convertDateTimeFormat($dateTimeStr) {
</td> </td>
<td> <td>
<div class="d-flex"> <div class="d-flex">
<button class="copyBtn btn btn-secondary" @click="copyOption(option.key)">+</button>
<button class="selectElevator btn btn-danger" @click="addOptionToElevator(option.key)">電梯</button> <button class="selectElevator btn btn-danger" @click="addOptionToElevator(option.key)">電梯</button>
<button class="deleteBtn btn btn-danger" @click="removeOption(option.key)">X</button> <button class="deleteBtn btn btn-danger" @click="removeOption(option.key)">X</button>
</div> </div>
@ -915,6 +1049,7 @@ function convertDateTimeFormat($dateTimeStr) {
</td> </td>
<td> <td>
<div class="d-flex"> <div class="d-flex">
<button class="copyBtn btn btn-secondary" @click="copyOtherOption(option.id)">+</button>
<button class="selectElevator btn btn-danger" @click="addOtherOptionToElevator(option.id)">電梯</button> <button class="selectElevator btn btn-danger" @click="addOtherOptionToElevator(option.id)">電梯</button>
<button class="deleteBtn btn btn-danger" @click="removeOtherOption(option.id)">X</button> <button class="deleteBtn btn btn-danger" @click="removeOtherOption(option.id)">X</button>
</div> </div>
@ -930,7 +1065,7 @@ function convertDateTimeFormat($dateTimeStr) {
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="divitem"> <div class="divitem" x-show="false">
<div class="title"> <div class="title">
<h4>保固延長</h4> <h4>保固延長</h4>
<button class="addbtn btn" @click="openCreateMaintainModal()">+</button> <button class="addbtn btn" @click="openCreateMaintainModal()">+</button>
@ -975,6 +1110,69 @@ function convertDateTimeFormat($dateTimeStr) {
</tbody> </tbody>
</table> </table>
</div> </div>
<template x-if="is_renovation == 'Y'">
<div class="divitem">
<div class="title">
<h4>拆梯價格</h4>
<button class="addbtn btn" @click="openCreateDemolishOptionModal()">+</button>
</div>
<table class="table" border=1>
<thead x-show="demolishOptions.length > 0">
<tr>
<td>人乘/載重</td>
<td>樓層</td>
<td>單價</td>
<td>數量</td>
<td>複價</td>
<td>所屬電梯</td>
<td>功能</td>
</tr>
</thead>
<tbody>
<template x-for="(option, idx) in demolishOptions" :key="option.id">
<tr>
<td>
<select class="form-control" x-model="option.person" @change="getDemolishPrice(idx)">
<option value="">請選擇</option>
<option value="15人(含)以下">15人(含)以下/1000KGS</option>
<option value="16~24人">16~24人/1001~1600KGS</option>
<option value="25~30人">25~30人/1601~2500KGS</option>
</select>
</td>
<td>
<select class="form-control" x-model="option.floor" @change="getDemolishPrice(idx)">
<option value="">請選擇</option>
<?php for($i=4;$i<=40;$i++): ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</td>
<td><input type="text" disabled class="form-control" x-model="Number(option.price).toLocaleString()"></td>
<td><input type="number" class="form-control" x-model="option.qty"></td>
<td><input type="text" disabled class="form-control" x-model="(option.price * option.qty).toLocaleString()"></td>
<td>
<template x-for="el in option.toElevator">
<p x-html="'<b>' + el.id + '</b>、' + el.model"></p>
</template>
</td>
<td>
<div class="d-flex">
<button class="selectElevator btn btn-danger" @click="addDemolishOptionToElevator(option.id)">電梯</button>
<button class="deleteBtn btn btn-danger" @click="removeDemolishOption(option.id)">X</button>
</div>
</td>
</tr>
</template>
<tr x-show="demolishOptions.length > 0">
<td colspan=3>小計</td>
<td colspan=1 ><input type="text" class="form-control" disabled x-model="totalDemolishOptionsNum()" ></td>
<td colspan=1 ><input type="text" class="form-control" disabled x-model="Number(totalDemolishOptionsPrice()).toLocaleString()" ></td>
<td colspan=2 ></td>
</tr>
</tbody>
</table>
</div>
</template>
<div class="divitem"> <div class="divitem">
<table style="width:800px" class="table" border=1> <table style="width:800px" class="table" border=1>
<thead> <thead>
@ -1197,7 +1395,7 @@ function convertDateTimeFormat($dateTimeStr) {
<input type="file" class="form-control" /> <input type="file" class="form-control" />
</label> </label>
<label for=""> <label for="">
<button class="btn btn-primary">保存</button> <button class="btn btn-primary" @click="save()">保存</button>
<button class="btn btn-primary" @click="submit()">送審</button> <button class="btn btn-primary" @click="submit()">送審</button>
</label> </label>
</div> </div>
@ -1222,4 +1420,21 @@ function convertDateTimeFormat($dateTimeStr) {
const pre_order_date = '<?php echo convertDateTimeFormat($hope_customer['pre_order_date']); ?>'; const pre_order_date = '<?php echo convertDateTimeFormat($hope_customer['pre_order_date']); ?>';
const is_renovation = '<?php echo $hope_customer['is_renovation']; ?>'; const is_renovation = '<?php echo $hope_customer['is_renovation']; ?>';
const token_link = '<?php echo $token_link; ?>'; const token_link = '<?php echo $token_link; ?>';
const selectedOptions = [...<?php echo json_encode($selectedOptions); ?>];
const optionKey = <?php echo $optionKey+1 ?>;
const otherOptions = [...<?php echo json_encode($otherOptions); ?>];
const otherOptionKey = <?php echo $otherOptionKey+1 ?>;
const demolishOptions = [...<?php echo json_encode($demolishOptions); ?>];
const demolishOptionKey = <?php echo $demolishOptionKey+1 ?>;
const serviceFee = <?php echo $main ? $main['special_fee'] : 0; ?>;
const transactionDate = '<?php echo $main ? $main['predeal_date'] : convertDateTimeFormat($hope_customer['pre_order_date']) ?>';
const shippingDate = '<?php echo $main ? $main['facilitok_date'] : "" ?>';
const remark = `<?php echo $main ? str_replace("\n", "\\n", $main['memo']) : ""; ?>`;
const penalty = '<?php echo $main ? $main['penalty'] : "" ?>';
const deposit_rate = '<?php echo $main ? $main['deposit_rate'] : 0 ?>';
const keep_rate = '<?php echo $main ? $main['keep_rate'] : 0 ?>';
const warranty_rate = '<?php echo $main ? $main['warranty_rate'] : 0 ?>';
const paymentRatio = [...<?php echo json_encode($paymentRatio); ?>];
const user_id = '<?php echo $user_id; ?>';
</script> </script>

4
wms/mkt/pricereview_renovate-index.php

@ -277,7 +277,7 @@ if ($data) :
// echo '</pre>'; // echo '</pre>';
if ($data["status"] == "Y1") { if ($data["status"] == "Y1") {
?> ?>
<a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a> <a href="pricereviewCreate.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a>
<a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a> <a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a>
<?php <?php
} elseif ($data["status"] == "YS" && $countContract == 0) { } elseif ($data["status"] == "YS" && $countContract == 0) {
@ -286,7 +286,7 @@ if ($data) :
<?php <?php
} elseif ($data['status'] == "YN" && $data['id'] == $maxContractID) { } elseif ($data['status'] == "YN" && $data['id'] == $maxContractID) {
?> ?>
<a href="pricereview_renovate-create.php?vol_no=<?= $data['contractno']; ?>&id=<?= $data['id'] ?>&function_name=pricereview_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填價審</a> <a href="pricereviewCreate.php?id=<?= $data['id'] ?>&function_name=pricereview_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填價審</a>
<?php <?php
} }

Loading…
Cancel
Save