|
@ -88,11 +88,10 @@ try { |
|
|
$special_fee = $row[0]; |
|
|
$special_fee = $row[0]; |
|
|
mysqli_free_result($res); |
|
|
mysqli_free_result($res); |
|
|
$specarr[0] = "服務費"; |
|
|
$specarr[0] = "服務費"; |
|
|
if($elev_qty_all == 0 ){ |
|
|
if ($elev_qty_all == 0) { |
|
|
$specarr[1] = 0; |
|
|
$specarr[1] = 0; |
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
|
|
|
} else { |
|
|
}else{ |
|
|
|
|
|
$specarr[1] = round($special_fee / $elev_qty_all, 0); |
|
|
$specarr[1] = round($special_fee / $elev_qty_all, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -133,7 +132,7 @@ try { |
|
|
$sql = "select id, item_spec, item_price_bp, option_relate_spec, item_qty 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); |
|
|
$res = mysqli_query($link, $sql); |
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
if($row[4] == 0){ |
|
|
if ($row[4] == 0) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
$mn_elev_arr[$row[0]]["item_spec"] = $row[1]; |
|
|
$mn_elev_arr[$row[0]]["item_spec"] = $row[1]; |
|
@ -154,14 +153,14 @@ try { |
|
|
$sql = "select id, item_spec, item_price_bp, item_qty 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); |
|
|
$res = mysqli_query($link, $sql); |
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
while ($row = mysqli_fetch_row($res)) { |
|
|
if($row[3] == 0){ |
|
|
if ($row[3] == 0) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
$exarr[$j][0] = $row[1]; |
|
|
$exarr[$j][0] = $row[1]; |
|
|
if($elev_qty_all == 0 || false){ |
|
|
if ($elev_qty_all == 0 || false) { |
|
|
$exarr[$j][1] = 0; |
|
|
$exarr[$j][1] = 0; |
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
$specarr[1] = round($special_fee / 1, 0); |
|
|
}else{ |
|
|
} else { |
|
|
$exarr[$j][1] = round($row[2] / $elev_qty_all, 0); |
|
|
$exarr[$j][1] = round($row[2] / $elev_qty_all, 0); |
|
|
} |
|
|
} |
|
|
$ex_fee += $exarr[$j][1]; |
|
|
$ex_fee += $exarr[$j][1]; |
|
@ -176,7 +175,7 @@ try { |
|
|
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; |
|
|
$sql3 = "select item_spec, item_qty, note from pricereview_item where mid = '$id' and item_group = 'C'"; |
|
|
$res_i = mysqli_query($link, $sql3); |
|
|
$res_i = mysqli_query($link, $sql3); |
|
|
while ($row_i = mysqli_fetch_assoc($res_i)) { |
|
|
while ($row_i = mysqli_fetch_assoc($res_i)) { |
|
|
if($row_i[1] == 0){ |
|
|
if ($row_i[1] == 0) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
$sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' "; |
|
|
$sql4 = "select min_floors, price, price_plus from dismantle_mi_option where spec = '" . $row_i["item_spec"] . "' "; |
|
@ -191,10 +190,10 @@ try { |
|
|
} |
|
|
} |
|
|
mysqli_free_result($res_i); |
|
|
mysqli_free_result($res_i); |
|
|
} |
|
|
} |
|
|
if($elev_qty_all == 0 || false){ |
|
|
if ($elev_qty_all == 0 || false) { |
|
|
$dismantle_fee = round($dismantle_amt / 1, 0); |
|
|
$dismantle_fee = round($dismantle_amt / 1, 0); |
|
|
$polishing_fee = round($polishing_amt / 1, 0); |
|
|
$polishing_fee = round($polishing_amt / 1, 0); |
|
|
}else{ |
|
|
} else { |
|
|
$dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); |
|
|
$dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); |
|
|
$polishing_fee = round($polishing_amt / $elev_qty_all, 0); |
|
|
$polishing_fee = round($polishing_amt / $elev_qty_all, 0); |
|
|
} |
|
|
} |
|
@ -208,8 +207,8 @@ try { |
|
|
// echo json_encode($elev_arr); |
|
|
// echo json_encode($elev_arr); |
|
|
require_once("./conn.php"); |
|
|
require_once("./conn.php"); |
|
|
// echo json_encode($elev_arr); |
|
|
// echo json_encode($elev_arr); |
|
|
foreach ((Array)$elev_arr as $item_no => $v) { |
|
|
foreach ((array)$elev_arr as $item_no => $v) { |
|
|
if($item_no == ""){ |
|
|
if ($item_no == "") { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
// 電梯MI |
|
|
// 電梯MI |
|
@ -230,7 +229,6 @@ try { |
|
|
$stmt->bindParam(':quotation_no', $quotation_no); |
|
|
$stmt->bindParam(':quotation_no', $quotation_no); |
|
|
$stmt->execute(); |
|
|
$stmt->execute(); |
|
|
$row_e = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
$row_e = $stmt->fetch(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
|
// $sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r "; |
|
|
// $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 .= "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[item_weight] between o.min_weight and o.max_weight) "; |
|
@ -245,8 +243,7 @@ try { |
|
|
if ($row_e) { |
|
|
if ($row_e) { |
|
|
// 加價:先不納入 |
|
|
// 加價:先不納入 |
|
|
$row_e["option_price"] = 0; |
|
|
$row_e["option_price"] = 0; |
|
|
if(!isset($row_e["purchase_cost"])){ |
|
|
if (!isset($row_e["purchase_cost"])) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// 基准采购成本+±1停材料费+设计费+出口费用 |
|
|
// 基准采购成本+±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"]; |
|
|
$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"]; |
|
@ -443,7 +440,7 @@ try { |
|
|
$mi_arr[$i][19] = $specarr; |
|
|
$mi_arr[$i][19] = $specarr; |
|
|
$i++; |
|
|
$i++; |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
} else { |
|
|
$rarr['err'] = "notfoundmi"; |
|
|
$rarr['err'] = "notfoundmi"; |
|
|
} |
|
|
} |
|
|
// mysqli_free_result($res_e); |
|
|
// mysqli_free_result($res_e); |
|
@ -476,45 +473,44 @@ try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$exceptArr = []; |
|
|
$exceptArr = []; |
|
|
foreach($items as $item){ |
|
|
foreach ($items as $item) { |
|
|
if($item['option_relate_spec'] != NULL){ |
|
|
if ($item['option_relate_spec'] != NULL) { |
|
|
$exceptArr[] = [ |
|
|
$exceptArr[] = [ |
|
|
'option_relate_spec'=> $item['option_relate_spec'], |
|
|
'option_relate_spec' => $item['option_relate_spec'], |
|
|
'item_spec'=>$item['item_spec'], |
|
|
'item_spec' => $item['item_spec'], |
|
|
'item_unit_price'=>$item['item_unit_price'], |
|
|
'item_unit_price' => $item['item_unit_price'], |
|
|
'item_qty'=>$item['item_qty'], |
|
|
'item_qty' => $item['item_qty'], |
|
|
'item_price_bp'=> $item['item_price_bp'], |
|
|
'item_price_bp' => $item['item_price_bp'], |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// $rarr["content"][] = $exceptArr; |
|
|
// $rarr["content"][] = $exceptArr; |
|
|
foreach($rarr["content"] as $idx=>&$item){ |
|
|
foreach ($rarr["content"] as $idx => &$item) { |
|
|
$newTotal = 0; |
|
|
$newTotal = 0; |
|
|
$item[16] = []; |
|
|
$item[16] = []; |
|
|
$item[14] = []; |
|
|
$item[14] = []; |
|
|
foreach($exceptArr as $except){ |
|
|
foreach ($exceptArr as $except) { |
|
|
if($idx+1 == $except['option_relate_spec']){ |
|
|
if ($idx + 1 == $except['option_relate_spec']) { |
|
|
$item[16][] = [ |
|
|
$item[16][] = [ |
|
|
$except['item_spec'], |
|
|
$except['item_spec'], |
|
|
$except['item_unit_price']* $except['item_qty'] |
|
|
$except['item_unit_price'] * $except['item_qty'] |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
foreach($itemoptions as $itemoption){ |
|
|
foreach ($itemoptions as $itemoption) { |
|
|
|
|
|
|
|
|
if($idx+1 == $itemoption['option_relate_spec']){ |
|
|
if ($idx + 1 == $itemoption['option_relate_spec']) { |
|
|
$item[14][] = [ |
|
|
$item[14][] = [ |
|
|
$itemoption['item_spec'], |
|
|
$itemoption['item_spec'], |
|
|
round($itemoption['option_mi'] * $itemoption['item_qty'], 0), |
|
|
round($itemoption['option_mi'] * $itemoption['item_qty'], 0), |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
foreach($item[14] as $option){ |
|
|
foreach ($item[14] as $option) { |
|
|
$newTotal += $option[1]; |
|
|
$newTotal += $option[1]; |
|
|
} |
|
|
} |
|
|
foreach($item[16] as $ex){ |
|
|
foreach ($item[16] as $ex) { |
|
|
$newTotal += $ex[1]; |
|
|
$newTotal += $ex[1]; |
|
|
} |
|
|
} |
|
|
$newTotal += $item[17]; |
|
|
$newTotal += $item[17]; |
|
@ -522,7 +518,6 @@ try { |
|
|
|
|
|
|
|
|
$item[13] = $newTotal; |
|
|
$item[13] = $newTotal; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
} catch (\Exception $e) { |
|
|
$rarr['st'] = 'err'; |
|
|
$rarr['st'] = 'err'; |
|
|
$rarr['err'] = $e->getMessage(); |
|
|
$rarr['err'] = $e->getMessage(); |
|
|