|
|
@ -88,7 +88,13 @@ try { |
|
|
|
$special_fee = $row[0]; |
|
|
|
mysqli_free_result($res); |
|
|
|
$specarr[0] = "服務費"; |
|
|
|
if($elev_qty_all == 0 ){ |
|
|
|
$specarr[1] = 0; |
|
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
$specarr[1] = round($special_fee / $elev_qty_all, 0); |
|
|
|
} |
|
|
|
|
|
|
|
// 電梯所屬OPTION |
|
|
|
$opt_sel_id_arr = []; |
|
|
@ -124,9 +130,12 @@ try { |
|
|
|
|
|
|
|
// 電梯所屬保固延長 |
|
|
|
$mn_elev_arr = $mn_sel_id_arr = []; |
|
|
|
$sql = "select id, item_spec, item_price_bp, option_relate_spec from pricereview_item where mid = '$id' and item_group = 'D'"; |
|
|
|
$sql = "select id, item_spec, item_price_bp, option_relate_spec, item_qty from pricereview_item where mid = '$id' and item_group = 'D'"; |
|
|
|
$res = mysqli_query($link, $sql); |
|
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
|
if($row[4] == 0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
$mn_elev_arr[$row[0]]["item_spec"] = $row[1]; |
|
|
|
$mn_elev_arr[$row[0]]["item_price_bp"] = $row[2]; |
|
|
|
$tmp_arr = explode(",", $row[3]); |
|
|
@ -142,11 +151,19 @@ try { |
|
|
|
// 除外項目平均分到每台電梯 |
|
|
|
$exarr = []; |
|
|
|
$ex_fee = $j = 0; |
|
|
|
$sql = "select id, item_spec, item_price_bp from pricereview_item where mid = '$id' and item_group = 'E'"; |
|
|
|
$sql = "select id, item_spec, item_price_bp, item_qty from pricereview_item where mid = '$id' and item_group = 'E'"; |
|
|
|
$res = mysqli_query($link, $sql); |
|
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
|
if($row[3] == 0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
$exarr[$j][0] = $row[1]; |
|
|
|
if($elev_qty_all == 0 || false){ |
|
|
|
$exarr[$j][1] = 0; |
|
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
|
}else{ |
|
|
|
$exarr[$j][1] = round($row[2] / $elev_qty_all, 0); |
|
|
|
} |
|
|
|
$ex_fee += $exarr[$j][1]; |
|
|
|
$j++; |
|
|
|
} |
|
|
@ -158,6 +175,9 @@ try { |
|
|
|
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; |
|
|
|
$res_i = mysqli_query($link, $sql3); |
|
|
|
while ($row_i = mysqli_fetch_assoc($res_i)) { |
|
|
|
if($row_i[1] == 0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
$sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' "; |
|
|
|
$sql4 .= "and version_date = '2023-09-04'"; |
|
|
|
$sql4 .= "and ($row_i[note] between min_floors and max_floors) "; |
|
|
@ -170,8 +190,14 @@ try { |
|
|
|
} |
|
|
|
mysqli_free_result($res_i); |
|
|
|
} |
|
|
|
if($elev_qty_all == 0 || false){ |
|
|
|
$dismantle_fee = round($dismantle_amt / 1, 0); |
|
|
|
$polishing_fee = round($polishing_amt / 1, 0); |
|
|
|
}else{ |
|
|
|
$dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); |
|
|
|
$polishing_fee = round($polishing_amt / $elev_qty_all, 0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//print_r($elev_arr); |
|
|
|
//print_r($opt_elev_arr); |
|
|
@ -179,25 +205,47 @@ try { |
|
|
|
//print_r($mn_elev_arr); |
|
|
|
//print_r($ex_arr);exit; |
|
|
|
// echo json_encode($elev_arr); |
|
|
|
foreach ($elev_arr as $item_no => $v) { |
|
|
|
require_once("./conn.php"); |
|
|
|
// echo json_encode($elev_arr); |
|
|
|
foreach ((Array)$elev_arr as $item_no => $v) { |
|
|
|
if($item_no == ""){ |
|
|
|
echo "null!!!!!"; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 電梯MI |
|
|
|
$sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r "; |
|
|
|
$sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '" . $v['etype'] . "' "; |
|
|
|
$sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) "; |
|
|
|
$sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) "; |
|
|
|
$sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) "; |
|
|
|
if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") { |
|
|
|
$sql2 .= "and (o.model_no = '" . $v["persons"] . "') "; |
|
|
|
} |
|
|
|
// echo $sql2; |
|
|
|
$res_e = mysqli_query($link, $sql2); |
|
|
|
if ($row_e = mysqli_fetch_assoc($res_e)) { |
|
|
|
$elevator_type = $v['etype']; |
|
|
|
$floor = $v['floors']; |
|
|
|
$speed = $v['speed']; |
|
|
|
$min_weight = $v['item_weight']; |
|
|
|
$sql_str = "SELECT elevator_mi_option.*,elevator_quotation_rule.* FROM elevator_mi_option |
|
|
|
JOIN elevator_quotation_rule ON elevator_mi_option.quotation_no = elevator_quotation_rule.quotation_no |
|
|
|
WHERE elevator_mi_option.elevator_type = :elevator_type AND |
|
|
|
elevator_mi_option.min_weight = :min_weight AND elevator_mi_option.min_speed = :speed "; |
|
|
|
$stmt = $conn->prepare($sql_str); |
|
|
|
$stmt->bindParam(':elevator_type', $elevator_type); |
|
|
|
$stmt->bindParam(':speed', $speed); |
|
|
|
$stmt->bindParam(':min_weight', $min_weight); |
|
|
|
$stmt->execute(); |
|
|
|
$row_e = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
// $sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r "; |
|
|
|
// $sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '" . $v['etype'] . "' "; |
|
|
|
// $sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) "; |
|
|
|
// $sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) "; |
|
|
|
// $sql2 .= "and ($v[speed] between o.min_speed and o.max_speed) "; |
|
|
|
// if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") { |
|
|
|
// $sql2 .= "and (o.model_no = '" . $v["persons"] . "') "; |
|
|
|
// } |
|
|
|
// // echo $sql2; |
|
|
|
// $res_e = mysqli_query($link, $sql2); |
|
|
|
//$row_e = mysqli_fetch_assoc($res_e) |
|
|
|
if ($row_e || true) { |
|
|
|
// 加價:先不納入 |
|
|
|
$row_e["option_price"] = 0; |
|
|
|
// 基准采购成本+±1停材料费+设计费+出口费用 |
|
|
|
$part1 = $row_e["purchase_cost"] + ($v["floors"] - $row_e["base_floor"]) * $row_e["material_plus"] + $row_e["design"] * $row_e["design_hour"] + $row_e["export_fee"]; |
|
|
|
// 利潤 |
|
|
|
$profit = round($part1 * $row_e["profit"] + $row_e["equip_profit"], 0); |
|
|
|
$profit = 0; |
|
|
|
// $profit = round($part1 * $row_e["profit"] + $row_e["equip_profit"], 0); |
|
|
|
// 設備 |
|
|
|
$equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0); |
|
|
|
// 報關+運輸 |
|
|
@ -375,7 +423,7 @@ try { |
|
|
|
$i++; |
|
|
|
} |
|
|
|
} |
|
|
|
mysqli_free_result($res_e); |
|
|
|
// mysqli_free_result($res_e); |
|
|
|
} |
|
|
|
|
|
|
|
$rarr["content"] = $mi_arr; |
|
|
|