diff --git a/wms/contract/option/facility.xlsx b/wms/contract/option/facility.xlsx new file mode 100644 index 00000000..f51a3944 Binary files /dev/null and b/wms/contract/option/facility.xlsx differ diff --git a/wms/crm/crmm01-index.php b/wms/crm/crmm01-index.php index 58dfaba4..de61475f 100644 --- a/wms/crm/crmm01-index.php +++ b/wms/crm/crmm01-index.php @@ -197,7 +197,7 @@ if ($data) : $pricereview_url = "../mkt/pricereview_renovate-create.php"; $fname = "pricereview_renovate"; } else { - $pricereview_url = "../mkt/pricereview-create.php"; + $pricereview_url = "../mkt/pricereviewCreate.php"; $fname = "pricereview"; } } diff --git a/wms/database.php b/wms/database.php index bc99328c..a5a7046d 100644 --- a/wms/database.php +++ b/wms/database.php @@ -19,7 +19,7 @@ $host = getenv('DB_HOST'); $dbuser = getenv('DB_USERNAME'); $dbpassword = getenv('DB_PASSWORD'); $dbname = getenv('DB_DATABASE'); -// $link = mysqli_connect($host, $dbuser, $dbpassword, $dbname); +$link = mysqli_connect($host, $dbuser, $dbpassword, $dbname); $sqlsrv = getenv('sqlsrv'); $Database = getenv('Database'); diff --git a/wms/mkt/api/getDemolishPrice.php b/wms/mkt/api/getDemolishPrice.php new file mode 100644 index 00000000..160047e3 --- /dev/null +++ b/wms/mkt/api/getDemolishPrice.php @@ -0,0 +1,21 @@ +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; +} diff --git a/wms/mkt/api/getElevatorMi.php b/wms/mkt/api/getElevatorMi.php index fbea22cc..c7b493ec 100644 --- a/wms/mkt/api/getElevatorMi.php +++ b/wms/mkt/api/getElevatorMi.php @@ -31,8 +31,10 @@ $unloading_fee = round($mi['unloading']); $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']); $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 = [ 'equipment_fee'=>$equipment_fee, @@ -41,6 +43,7 @@ $newMI = [ 'transport_site_fee'=>$transport_site_fee, 'install_fee'=>$install_fee, 'free1y_fee'=>$free1y_fee, - 'other_fee'=>$other_fee + 'other_fee'=>$other_fee, + 'add_price'=>$add_price, ]; echo json_encode($newMI); diff --git a/wms/mkt/api/getElevatorPrice.php b/wms/mkt/api/getElevatorPrice.php index 64b3098c..e31e62b2 100644 --- a/wms/mkt/api/getElevatorPrice.php +++ b/wms/mkt/api/getElevatorPrice.php @@ -3,10 +3,12 @@ require_once("../conn.php"); $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->bindParam(':model', $model); +$stmt->bindParam(':kind', $kind); $stmt->execute(); $el = $stmt->fetch(PDO::FETCH_ASSOC); if($el){ diff --git a/wms/mkt/api/getUsername.php b/wms/mkt/api/getUsername.php index d959b5aa..2386329d 100644 --- a/wms/mkt/api/getUsername.php +++ b/wms/mkt/api/getUsername.php @@ -3,7 +3,10 @@ require_once('../conn.php'); $accountid = $_GET['user_id']; - +if($accountid == "---"){ + echo "---"; + exit; +} $sql_str = "SELECT name FROM account WHERE accountid = :accountid"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':accountid', $accountid); diff --git a/wms/mkt/api/postNewElevatorPricereview.php b/wms/mkt/api/postNewElevatorPricereview.php index 5ba7e342..fcfe1c26 100644 --- a/wms/mkt/api/postNewElevatorPricereview.php +++ b/wms/mkt/api/postNewElevatorPricereview.php @@ -14,6 +14,7 @@ $price_total = $_POST['price_total']; $price_rate = $_POST['price_rate']; $special_fee = $_POST['special_fee']; $predeal_date = $_POST['predeal_date']; +$facilitok_date = $_POST['facilitok_date']; $penalty = $_POST['penalty']; $deposit_rate = $_POST['deposit_rate']; $warranty_rate = $_POST['warranty_rate']; @@ -22,213 +23,647 @@ $memo = $_POST['memo']; $status = $_POST['status']; $attatch1 = $_POST['attatch1'] =='' ? NULL : $_POST['attatch1']; $attatch2 = $_POST['attatch2'] =='' ? NULL : $_POST['attatch2']; -$creater = "M0174"; +$creater = $_POST['user_id']; $create_at = date("Y-m-d H:i:s"); -$elevators = $_POST['elevators']; -$options = $_POST['options']; -$otherOptions = $_POST['otherOptions']; +$elevators = json_decode($_POST['elevators'], true); +$options = json_decode($_POST['options'], true); +$otherOptions = json_decode($_POST['otherOptions'], true); +$demolishOptions = json_decode($_POST['demolishOptions'], true); $maintainOptions = $_POST['maintainOptions']; -$paymentRatio = $_POST['paymentRatio']; +$paymentRatio = json_decode($_POST['paymentRatio'], true); $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{ - - $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(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']; +if($main){ + try{ + $mid = $main["id"]; + $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(':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)"; + $stmt->bindParam(':id', $mid); + $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); - foreach(json_decode($options, true) as $option){ - $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']; + + $stmt->execute(); + //整機單價 + $sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A'"; $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(); - } + $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) - //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) - VALUES (:mid, :item_no, :item_group, :item_spec, :option_relate_spec, :item_unit_price, :item_qty, :item_price_bp)"; + 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)"; + + $elevator = array_values(array_filter($elevators, fn($el)=> $el['id'] == $newidx))[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']; + $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(); + } + 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']; - foreach(json_decode($otherOptions, true) as $option){ - $item_no = $option['id'] + 1; - $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']; + $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->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(); - } + $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)"; + + $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(); + } + + 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 = "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']; + //除外項目 + $sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'E'"; $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(); - } + $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)"; + + $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(); + } + + 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'"; - $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)"; + $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(); + } - foreach(json_decode($paymentRatio, true) 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']; + //拆梯價格 + $sql_str = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'C'"; $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(); - } + $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)"; + + $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 = (int)$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(); + } + 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 = "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()); -} \ No newline at end of file diff --git a/wms/mkt/api/putNewElevatorPriceview.php b/wms/mkt/api/putNewElevatorPriceview.php new file mode 100644 index 00000000..f255b9dd --- /dev/null +++ b/wms/mkt/api/putNewElevatorPriceview.php @@ -0,0 +1,56 @@ +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(){ + +} diff --git a/wms/mkt/assets/js/pricereviewAlpine.js b/wms/mkt/assets/js/pricereviewAlpine.js index c839c4b5..3465236d 100644 --- a/wms/mkt/assets/js/pricereviewAlpine.js +++ b/wms/mkt/assets/js/pricereviewAlpine.js @@ -2,10 +2,11 @@ const pricereviewCreate = ()=>{ return { init(){ this.elevators = elevators; - console.log(this.elevators); - console.log(this.total_spec); + this.is_renovation = is_renovation + this.selectedOptions = selectedOptions; + this.otherOptions = otherOptions; + console.log(this.selectedOptions); }, - openFn:{ 4:'2U', 5:"4PCO", @@ -33,9 +34,11 @@ const pricereviewCreate = ()=>{ currentOptionKey: '', currentOtherOptionKey: '', currentMaintainOptionKey: '', - optionKey:0, - otherOptionKey:0, - maintainOptionKey:0, + currentDemolishOptionKey: '', + optionKey: optionKey, + otherOptionKey: otherOptionKey, + maintainOptionKey:1, + demolishOptionKey: demolishOptionKey, modalElevatorInfo:{ spec:'', person:'', @@ -46,6 +49,7 @@ const pricereviewCreate = ()=>{ price:'', sale_price:'', facility_id: '', + model:'', }, otherOptions: [], modalOtherOptionInfo:{ @@ -60,49 +64,63 @@ const pricereviewCreate = ()=>{ num:"", memo:"", }, - 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: '', - }, - ], - serviceFee:0, - transactionDate: pre_order_date, - shippingDate:'', - remark:'', + demolishOptions: demolishOptions, + modalDemolishOptionsInfo:{ + person:"", + floor:"", + price: 0, + qty:"", + }, + paymentRatio:paymentRatio, + serviceFee: serviceFee, + transactionDate: transactionDate, + shippingDate: shippingDate, + remark: remark, + penalty: penalty, + deposit_rate: deposit_rate, + keep_rate: keep_rate, + warranty_rate: warranty_rate, + customerInfo:{ + contractno: contractno, + company: customer, + manager: manager, + address: address, + case_name: case_name, + uscc: uscc, + person: salesman, + }, + weightArr: { + 6: 450, + 8: 550, + 9: 600, + 10: 700, + 11:750, + 12:800, + 13:900, + 15:1000, + 17:1150, + 20:1350, + 24:1600, + }, + is_renovation: is_renovation, async getElevatorPrice(idx){ const spec = this.elevators[idx].specifications const person = this.elevators[idx].person const stop = this.elevators[idx].stop const open_converted = this.elevators[idx].open_converted 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{ - 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); if(res.data.id == null || res.data.id == ""){ console.log("公司並無提供此規格!!"); @@ -115,9 +133,17 @@ const pricereviewCreate = ()=>{ }, 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{ - 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); if(res.data.id == null || res.data.id == ""){ console.log("公司並無提供此規格!!"); @@ -128,6 +154,40 @@ const pricereviewCreate = ()=>{ 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) { if (kind == 'A') { this.buttons = [ @@ -223,7 +283,6 @@ const pricereviewCreate = ()=>{ Object.keys(this.modalSelectedOptions).forEach(option=>{ this.selectedOptions.push(this.modalSelectedOptions[option]) }) - console.log(this.modalSelectedOptions); console.log(this.selectedOptions); this.hideOptionsModal(); }, @@ -243,6 +302,10 @@ const pricereviewCreate = ()=>{ this.$refs.toMaintainOptionElevatorModal.style.display = 'none'; body.style.overflow = 'auto' }, + hideToDemolishOptionElevatorModal(){ + this.$refs.toDemolishOptionElevatorModal.style.display = 'none'; + body.style.overflow = 'auto' + }, hideCreateElevatorModal(){ this.$refs.createElevatorModal.style.display = 'none'; body.style.overflow = 'auto' @@ -255,6 +318,7 @@ const pricereviewCreate = ()=>{ num: 1, price:'', sale_price:'', + model:'', }; }, hideCreateOtherOptionModal(){ @@ -265,6 +329,10 @@ const pricereviewCreate = ()=>{ this.$refs.createMaintainModal.style.display = 'none'; body.style.overflow = 'auto' }, + hideCreateDemolishModal(){ + this.$refs.createDemolishModal.style.display = 'none'; + body.style.overflow = 'auto' + }, openCreateElevatorModal(){ this.$refs.createElevatorModal.style.display = 'block'; body.style.overflow = 'hidden' @@ -277,6 +345,10 @@ const pricereviewCreate = ()=>{ this.$refs.createMaintainModal.style.display = 'block'; body.style.overflow = 'hidden' }, + openCreateDemolishOptionModal(){ + this.$refs.createDemolishModal.style.display = 'block'; + body.style.overflow = 'hidden' + }, totalElevatorsPrice(){ return this.elevators.reduce((total, elevator) => { return total + (elevator.spec_num * elevator.price); @@ -321,6 +393,7 @@ const pricereviewCreate = ()=>{ open:'', spec_num: this.modalElevatorInfo.num, facility_id: this.modalElevatorInfo.facility_id, + model: this.modalElevatorInfo.model, }); console.log(this.elevators); this.hideCreateElevatorModal(); @@ -336,6 +409,7 @@ const pricereviewCreate = ()=>{ const spec_num = this.elevators[idx].spec_num const price = this.elevators[idx].price const facility_id = this.elevators[idx].facility_id + const model = this.elevators[idx].model this.total_spec ++; this.elevators.push({ @@ -350,21 +424,59 @@ const pricereviewCreate = ()=>{ open: open, spec_num: spec_num, facility_id: facility_id, + model: model, }); 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){ this.currentOptionKey = key; this.toElevators = []; this.toElevatorNo = ""; const matchElevators = this.selectedOptions.filter(option=> option.key == key)[0].toElevator.map(elevator=> elevator.id) - console.log(matchElevators); 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: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + model: model , checked: matchElevators.includes(elevator.id) ? 1: 0, }) } @@ -380,30 +492,31 @@ const pricereviewCreate = ()=>{ 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: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + model: model, checked: matchElevators.includes(elevator.id) ? 1: 0, }) } }) + this.$refs.toOtherOptionElevatorModal.style.display = 'block'; body.style.overflow = 'hidden' }, chkOptionToElevators(){ 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] + checkedOptions.push({ id: this.toElevatorNo, - model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + model: matchElevators['model'] , }) this.selectedOptions.forEach(option=>{ if(option.key == this.currentOptionKey){ @@ -416,18 +529,11 @@ const pricereviewCreate = ()=>{ }, chkOtherOptionToElevators(){ 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] checkedOptions.push({ id: this.toElevatorNo, - model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + model: matchElevators['model'], }) this.otherOptions.forEach(option=>{ if(option.id == this.currentOtherOptionKey){ @@ -435,7 +541,7 @@ const pricereviewCreate = ()=>{ option.toElevator.push(...checkedOptions) } }) - + this.currentOtherOptionKey = '' this.hideToOtherOptionElevatorModal(); @@ -506,6 +612,25 @@ const pricereviewCreate = ()=>{ this.maintainOptionKey ++; 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(){ return this.maintainOptions.reduce((total, option) => { return total + (Number(option.num) * Number(option.price)); @@ -516,20 +641,23 @@ const pricereviewCreate = ()=>{ return total + Number(option.num); }, 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(){ 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] checkedOptions.push({ id: this.toElevatorNo, - model: matchElevators['specifications'] + '-' + matchElevators['person'] + '*' + matchElevators['stop'] + '-' + matchElevators['open_converted'] + matchElevators['speed'], + model: matchElevators['model'], }) this.maintainOptions.forEach(option=>{ if(option.id == this.currentMaintainOptionKey){ @@ -540,6 +668,22 @@ const pricereviewCreate = ()=>{ this.currentMaintainOptionKey = '' 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){ this.currentMaintainOptionKey = id; this.toElevators = []; @@ -548,9 +692,16 @@ const pricereviewCreate = ()=>{ 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: elevator.specifications + '-' + elevator.person + '*' + elevator.stop + '-' + elevator.open_converted + elevator.speed, + model: model, checked: matchElevators.includes(elevator.id) ? 1: 0, }) } @@ -559,9 +710,38 @@ const pricereviewCreate = ()=>{ this.$refs.toMaintainOptionElevatorModal.style.display = 'block'; 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){ this.maintainOptions = this.maintainOptions.filter(option=> option.id != id) }, + removeDemolishOption(id){ + this.demolishOptions = this.demolishOptions.filter(option=> option.id != id) + }, totalPrice(){ return this.totalElevatorsPrice() + this.totalOptionsPrice() + this.totalOtherOptionsPrice() + this.totalMaintainOptionsPrice(); }, @@ -584,19 +764,6 @@ const pricereviewCreate = ()=>{ 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: [], submit(){ this.error = [] @@ -641,7 +808,7 @@ const pricereviewCreate = ()=>{ const form = new FormData(); form.append('contractno', contractno); - form.append('ekind', "新梯"); + 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); @@ -660,13 +827,14 @@ const pricereviewCreate = ()=>{ form.append('status', "YS"); 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)); @@ -680,7 +848,50 @@ const pricereviewCreate = ()=>{ 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 = ()=>{ return { init(){ - this.elevators = items.filter(item=> item.item_group =='A'); + this.elevators = elevators this.elevators.forEach(el=>{ el.options = [] el.optionsTotalPrice = 0; @@ -696,14 +907,15 @@ const pricereviewCheck = ()=>{ el.otherOptionsTotalPrice = 0; el.maintainOptions = [] el.maintainOptionsTotalPrice = 0; + el.demolishOptions = [] + el.demolishOptionsTotalPrice = 0; }) 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'); - console.log(this.options); - + this.otherOptions = items.filter(item=> item.item_group =='E'); + console.log("optionnnn=>", this.options); this.elevators.forEach((elevator, idx)=>{ - this.options.forEach(option=>{ if(option.option_relate_spec == elevator.item_no){ elevator.optionsTotalPrice += option.option_mi * option.item_qty @@ -713,6 +925,7 @@ const pricereviewCheck = ()=>{ 'item_unit_price': option.item_unit_price, 'item_qty': option.item_qty, '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 this.elevators[idx].maintainOptions.push({ '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_qty': option.item_qty, 'mi': Math.round(option.item_unit_price), @@ -743,7 +968,7 @@ const pricereviewCheck = ()=>{ } }) 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 const model = elevator.item_spec; let spec = model.split('-')[0]; @@ -767,9 +992,10 @@ const pricereviewCheck = ()=>{ this.sign3 = this.getUsername(sign3) this.sign4 = this.getUsername(sign4) - + console.log(this.elevators); }, async getElevatorMi(idx, spec, person, stop, open, speed, item_weight){ + console.log("載重=====>",item_weight); try{ const res = await axios.get('./api/getElevatorMi.php', {params: { spec: spec, @@ -782,7 +1008,7 @@ const pricereviewCheck = ()=>{ console.log('---->',res.data); if(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{ this.isNotfoundMi = true; this.elevators[idx].mi = { @@ -792,7 +1018,8 @@ const pricereviewCheck = ()=>{ 'install_fee': 0, 'other_fee': 0, 'transport_site_fee': 0, - 'unloading_fee': 0 + 'unloading_fee': 0, + 'add_price':0, } } @@ -834,6 +1061,7 @@ const pricereviewCheck = ()=>{ options: [], otherOptions: [], maintainOptions: [], + demolishOptions:[], mid: mid, user_id: user_id, reviewcomment:'', @@ -852,11 +1080,24 @@ const pricereviewCheck = ()=>{ return total + (option.item_qty * option.item_unit_price); }, 0); }, + demolishOptionsTotalPrice(){ + return this.demolishOptions.reduce((total, option) => { + return total + (option.item_qty * option.item_unit_price); + }, 0); + }, totalScale(){ return this.pays.reduce((total, option) => { return total + Number(option.pay_scale ); }, 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){ console.log(sign); const form = new FormData(); @@ -873,6 +1114,7 @@ const pricereviewCheck = ()=>{ } }) }, + async getUsername(user_id){ if(user_id == '') return '---' const res = await axios.get('./api/getUsername.php', {params: {user_id: user_id}}) diff --git a/wms/mkt/css/pricereview.css b/wms/mkt/css/pricereview.css index 5986f447..3a399437 100644 --- a/wms/mkt/css/pricereview.css +++ b/wms/mkt/css/pricereview.css @@ -50,7 +50,8 @@ width: 55px; height: 30px; padding: 0; - margin-left: 10px; + margin-left: 6px; + margin-bottom: 2px; font-size: 13px; } #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 { opacity: 1; } +#pricereviewCreate .container .pricreviewmain > .divitem table .copyBtn { + width: 30px; + height: 30px; +} #pricereviewCreate .container .pricreviewmain > .divitem table .saletd { position: relative; } @@ -210,7 +215,7 @@ background-color: #fff; border-radius: 10px; position: absolute; - width: 1200px; + width: 90%; padding: 30px; top: 50%; left: 50%; @@ -219,13 +224,13 @@ animation: fade-in 0.2s linear; } .window-modal .window-modal-content.modal-xl { - width: 1200px; + max-width: 1200px; } .window-modal .window-modal-content.modal-lg { - width: 800px; + max-width: 800px; } .window-modal .window-modal-content.modal-m { - width: 450px; + max-width: 450px; } .window-modal .window-modal-content .window-modal-header { display: flex; diff --git a/wms/mkt/css/pricereview.css.map b/wms/mkt/css/pricereview.css.map index d113f93f..c9d78202 100644 --- a/wms/mkt/css/pricereview.css.map +++ b/wms/mkt/css/pricereview.css.map @@ -1 +1 @@ -{"version":3,"sources":["pricereview.scss","pricereview.css"],"names":[],"mappings":"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","file":"pricereview.css"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/wms/mkt/css/pricereview.scss b/wms/mkt/css/pricereview.scss index ea3c48bc..4f2df50f 100644 --- a/wms/mkt/css/pricereview.scss +++ b/wms/mkt/css/pricereview.scss @@ -57,7 +57,8 @@ width: 55px; height: 30px; padding: 0; - margin-left: 10px; + margin-left: 6px; + margin-bottom: 2px; font-size: 13px; &.addbtn{ background-color: #337AB7; @@ -106,6 +107,10 @@ tr:hover .deleteBtn ,tr:hover .copyBtn{ opacity: 1; } + .copyBtn{ + width: 30px; + height: 30px; + } .saletd{ position: relative; >.deleteBtn{ @@ -221,7 +226,7 @@ background-color: #fff; border-radius: 10px; position: absolute; - width:1200px; + width:90%; padding: 30px; top: 50%; left:50%; @@ -229,13 +234,13 @@ box-shadow: 0 5px 5px #222; animation: fade-in .2s linear; &.modal-xl{ - width:1200px; + max-width:1200px; } &.modal-lg{ - width:800px; + max-width:800px; } &.modal-m{ - width:450px; + max-width:450px; } .window-modal-header{ display: flex; diff --git a/wms/mkt/files/MAF200.xlsx b/wms/mkt/files/MAF200.xlsx new file mode 100644 index 00000000..885d31f2 Binary files /dev/null and b/wms/mkt/files/MAF200.xlsx differ diff --git a/wms/mkt/files/MAQ100.xlsx b/wms/mkt/files/MAQ100.xlsx new file mode 100644 index 00000000..8b06fd8f Binary files /dev/null and b/wms/mkt/files/MAQ100.xlsx differ diff --git a/wms/mkt/price_normal-index.php b/wms/mkt/price_normal-index.php index acd7b3af..2362eb1e 100644 --- a/wms/mkt/price_normal-index.php +++ b/wms/mkt/price_normal-index.php @@ -36,6 +36,8 @@ include "../header.php";
+ | 無機房貨梯 | +單位:萬元 | +
規 格 | +標準價 | +(±1S) | +
MAF200-750*3-2S45 | +113.0 | +5.3 | +
MAF200-750*3-2S60 | +115.0 | +5.3 | +
MAF200-1000*3-2S45 | +136.0 | +5.3 | +
MAF200-1500*3-2S45 | +165.7 | +9.8 | +
MAF200-1500*3-2S60 | +169.2 | +9.8 | +
MAF200-2000*3-2S45 | +186.0 | +10.0 | +
MAF200-2000*3-2S60 | +188.7 | +10.0 | +
MAF200-2500*3-4PCO45 | +263.3 | +14.2 | +
MAF200-2500*3-4PCO60 | +265.0 | +14.2 | +
MAF200-3000*3-4PCO45 | +281.5 | +15.2 | +
MAF200-3000*3-4PCO60 | +283.0 | +15.2 | +
MAF200-3500*3-4PCO45 | +330.6 | +18.2 | +
MAF200-3500*3-4PCO60 | +333.2 | +18.2 | +
+ | + | + |
註: 1、最低為2停 |
+ + | + |
2、處長權限為發佈價之80%。 | ++ |
+ | 強趨梯 | +單位:萬元 | ++ | + |
規 格 | +產品系列 | +樓層 | +標準價 | +(±1S) | +
MAQ100-4*-4PCO24 | +G5 | +4 | +70.0 | +2.0 | +
MAQ100-4*-4PCO24 | +G6 | +4 | +70.0 | +2.0 | +
MAQ100-4*-4PCO24 | +G10 | +4 | +72.5 | +2.0 | +
MAQ100-4*-4PCO24 | +G20 | +4 | +72.5 | +2.0 | +
MAQ100-4*-4PCO24 | +A2 | +4 | +77.5 | +2.0 | +
MAQ100-4*-4PCO24 | +A3 | +4 | +78.7 | +2.0 | +
MAQ100-4*-4PCO24 | +A6 | +4 | +77.5 | +2.0 | +
MAQ100-4*-4PCO24 | +A8 | +4 | +78.7 | +2.0 | +
MAQ100-4*-2PCO24 | +G5 | +4 | +68.0 | +2.0 | +
MAQ100-4*-2PCO24 | +G6 | +4 | +68.0 | +2.0 | +
MAQ100-4*-2PCO24 | +G10 | +4 | +70.5 | +2.0 | +
MAQ100-4*-2PCO24 | +G20 | +4 | +70.5 | +2.0 | +
MAQ100-4*-2PCO24 | +A2 | +4 | +75.5 | +2.0 | +
MAQ100-4*-2PCO24 | +A3 | +4 | +76.5 | +2.0 | +
MAQ100-4*-2PCO24 | +A6 | +4 | +75.5 | +2.0 | +
MAQ100-4*-2PCO24 | +A8 | +4 | +76.5 | +2.0 | +
註 1、處長權限為發佈價之80% +2、開門改2PCO,井道不變時,出入口寬需由800mm變成為600mm;或井道需加寬400mm |
+ + |
小計 | -- - | -+ | 拆梯價格 | +|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
項次 | +人乘/載重 | +樓層 | +單價 | +數量 | +複價 | +所屬電梯項次 | ||||||||
+ | + | + | + | + | + | + | ||||||||
小計 | ++ + | ++ |
@@ -804,7 +937,7 @@ function convertDateTimeFormat($dateTimeStr) { | - + | 請填寫正確規格 @@ -869,6 +1002,7 @@ function convertDateTimeFormat($dateTimeStr) { |
+
@@ -915,6 +1049,7 @@ function convertDateTimeFormat($dateTimeStr) {
|
+
@@ -930,7 +1065,7 @@ function convertDateTimeFormat($dateTimeStr) {
|
人乘/載重 | +樓層 | +單價 | +數量 | +複價 | +所屬電梯 | +功能 | +
+ + | ++ + | ++ | + | + | + + + + | +
+
+
+
+
+ |
+
小計 | ++ | + | + |