Browse Source

服務費+MI

main
10994015 1 year ago
parent
commit
1a17c3d4e3
  1. 33
      wms/mkt/pricereview-check.php
  2. 6
      wms/mkt/pricereview-create.php
  3. 8
      wms/mkt/pricereview-index.php
  4. 88
      wms/mkt/pricereview_mi-api.php

33
wms/mkt/pricereview-check.php

@ -304,7 +304,7 @@ foreach ($res as $data) {
} }
} }
getMI($id); // getMI($id);
?> ?>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script> <script>
@ -325,14 +325,14 @@ foreach ($res as $data) {
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText); data = JSON.parse(this.responseText);
//console.log(data);return false; // console.log(data);return false;
if (data.st == 'err') { if (data.st == 'err') {
//alert(data.err); //alert(data.err);
return false; return false;
} }
console.log(data.content); console.log(data.content);
Object.keys(data.content).forEach(function(k) { Object.keys(data.content).forEach(function(k) {
console.log(data.content); console.log(k);
//console.log(data.content[k][0]); //console.log(data.content[k][0]);
// 有值表示先前已寫入MI // 有值表示先前已寫入MI
if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") { if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") {
@ -355,19 +355,20 @@ foreach ($res as $data) {
console.log(data.content[k]); console.log(data.content[k]);
Object.keys(data.content[k][14]).forEach(function(m) { Object.keys(data.content[k][14]).forEach(function(m) {
if (data.content[k][14][m][0] != '') { if (data.content[k][14][m][0] != '') {
mihtml += "<li>" + data.content[k][14][m][0] + ":" + commafy(data.content[k][14][m][1]) + "</li>"; mihtml += "<li>" + data.content[k][14][m][0]+ ":" + commafy(data.content[k][14][m][1]) + "</li>";
} }
}); });
Object.keys(data.content[k][16]).forEach(function(m) { Object.keys(data.content[k][16]).forEach(function(m) {
if (data.content[k][16][m][0] != '') { if (data.content[k][16][m][0] != '') {
mihtml += "<li>" + data.content[k][16][m][0] + ":" + commafy(data.content[k][16][m][1]) + "</li>"; mihtml += "<li>" + data.content[k][16][m][0]+ ":" + commafy(data.content[k][16][m][1]) + "</li>";
} }
}); });
Object.keys(data.content[k][18]).forEach(function(m) { Object.keys(data.content[k][18]).forEach(function(m) {
mihtml += "<li>" + data.content[k][18][m][0] + ":" + commafy(data.content[k][18][m][1]) + "</li>"; mihtml += "<li>" + data.content[k][18][m][0]+ ":" + commafy(data.content[k][18][m][1]) + "</li>";
}); });
mihtml += "<li>" + data.content[k][19][0] + ":" + commafy(data.content[k][19][1]) + "</li>"; mihtml += "<li>" + data.content[k][19][0] + ":" + commafy(data.content[k][19][1]) + "</li>";
mihtml += "以上合計:" + commafy(data.content[k][13]) + "<br>"; mihtml += "以上合計:" + commafy(data.content[k][13]) + "<br />" ;
mihtml = mihtml.replace("<br>", "").replace("&lt;br&gt;", "")
$("#tb1").find("tr[name=facil_templ2]").eq(k).find('td').eq(1).html(mihtml); $("#tb1").find("tr[name=facil_templ2]").eq(k).find('td').eq(1).html(mihtml);
//$("#tb1").find("input[name=mi_fix]").eq(k).closest('td').append(mihtml); //$("#tb1").find("input[name=mi_fix]").eq(k).closest('td').append(mihtml);
}); });
@ -539,11 +540,11 @@ foreach ($res as $data) {
<th>數量</th> <th>數量</th>
<th>複價</th> <th>複價</th>
<?php if ($viewmi) { ?> <?php if ($viewmi) { ?>
<th>業務部MI</th> <th>業務部MI(台)</th>
<th>售價</th> <th>售價(台)</th>
<!--<th>價審%</th> <!--<th>價審%</th>
<th>配賦(含稅)</th>--> <th>配賦(含稅)</th>-->
<th>利潤</th> <th>利潤(台)</th>
<th>利潤率(%)</th> <th>利潤率(%)</th>
<?php } ?> <?php } ?>
</tr> </tr>
@ -552,18 +553,20 @@ foreach ($res as $data) {
<?php <?php
$item_amt_A_all = 0; $item_amt_A_all = 0;
$idx = 1; $idx = 1;
print_r($item_arr);
foreach ($item_arr as $item_no => $val) { foreach ($item_arr as $item_no => $val) {
echo $val["item_price_ct"];
echo "------";
echo $val["item_qty"];
$item_amt_A_all += $val["item_price_bp"]; $item_amt_A_all += $val["item_price_bp"];
if ($viewmi) { if ($viewmi) {
for ($i = 0; $i < $val["item_qty"]; $i++) { // for ($i = 0; $i < $val["item_qty"]; $i++) {
?> ?>
<tr name="facil_templ"> <tr name="facil_templ">
<td><?php echo $idx; ?><input type="hidden" name="item_no" value="<?php echo $item_no; ?>"><input type="hidden" name="sub_item_id" value="<?php if (isset($val["sub_item_id"])) echo implode("@", $val["sub_item_id"]); ?>"></td> <td><?php echo $idx; ?><input type="hidden" name="item_no" value="<?php echo $item_no; ?>"><input type="hidden" name="sub_item_id" value="<?php if (isset($val["sub_item_id"])) echo implode("@", $val["sub_item_id"]); ?>"></td>
<td nowrap><a href="" data-toggle="modal"><?= $val["item_spec"]; ?> [規調]</a></td> <td nowrap><a href="" data-toggle="modal"><?= $val["item_spec"]; ?> [規調]</a></td>
<td><input type="text" name="item_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td> <td><input type="text" name="item_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="item_qty" class="form-control" size="2" value="1"></td> <td><input type="text" name="item_qty" class="form-control" size="2" value="<?php echo $val["item_qty"]; ?>"></td>
<td><input type="text" name="item_price_bp" class="form-control dollar-right" size="9" value="<?= number_format($val["item_unit_price"]); ?>"></td> <td><input type="text" name="item_price_bp" class="form-control dollar-right" size="9" value="<?= number_format($val["item_unit_price"] * $val["item_qty"]); ?>"></td>
<td><input type="text" name="mi_fix" class="form-control dollar-right" size="9" value="<?php echo ($val["mi_fix"]) ? number_format($val["mi_fix"]) : ""; ?>" disabled></td> <td><input type="text" name="mi_fix" class="form-control dollar-right" size="9" value="<?php echo ($val["mi_fix"]) ? number_format($val["mi_fix"]) : ""; ?>" disabled></td>
<td><input type="text" name="item_price_ct" class="form-control dollar-right" size="9" value="<?= number_format($val["item_price_ct"] / $val["item_qty"]); ?>"></td> <td><input type="text" name="item_price_ct" class="form-control dollar-right" size="9" value="<?= number_format($val["item_price_ct"] / $val["item_qty"]); ?>"></td>
<!--<td><input type="text" name="item_price" class="form-control dollar-right" size="8" value="<?php echo ($val["item_price"]) ? number_format($val["item_price"]) : ""; ?>"></td> <!--<td><input type="text" name="item_price" class="form-control dollar-right" size="8" value="<?php echo ($val["item_price"]) ? number_format($val["item_price"]) : ""; ?>"></td>
@ -578,7 +581,7 @@ foreach ($res as $data) {
<td colspan="4"></td> <td colspan="4"></td>
</tr> </tr>
<?php <?php
} #item_qty end. //} #item_qty end.
} else { } else {
?> ?>
<tr name="facil_templ"> <tr name="facil_templ">

6
wms/mkt/pricereview-create.php

@ -757,9 +757,9 @@ $option_str .= "</tbody></table>";
// console.log(pobj.find('input[name=optionID]').val()); // console.log(pobj.find('input[name=optionID]').val());
// console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html())); // console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()));
console.log(pobj.find('td').eq(0).html()); console.log(pobj.find('td').eq(0).html());
jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html() + '<br />(' + pobj.find('td').eq(2).html() + ')'); jobj.html(pobj.find('td').eq(1).html() + " " +pobj.find('td').eq(2).html() + '<br />(' + pobj.find('td').eq(3).html() + ')');
jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(5).html()); jobj.closest('td').parent().find('input[name=option_unit_price]').val(pobj.find('td').eq(6).html());
jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(5).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, ""))); jobj.closest('td').parent().find('input[name=option_price_bp]').val(commafy(pobj.find('td').eq(6).html().replace(/[,]+/g, "") * jobj.closest('td').parent().find('input[name=option_qty]').val().replace(/[,]+/g, "")));
jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('td').eq(0).html()); jobj.closest('td').parent().find('input[name=op_id]').val(pobj.find('td').eq(0).html());
$("#optionModal").modal('hide'); $("#optionModal").modal('hide');

8
wms/mkt/pricereview-index.php

@ -1,6 +1,12 @@
<?php <?php
include "../header.php"; include "../header.php";
// if($user_id == "M0107" || $user_id == "M0174" || $user_id == "M0225"){
// }else{
// echo "維護中..";
// exit;
// }
// 員工編號對應姓名表 // 員工編號對應姓名表
$accountname_arr = accountid2name(); $accountname_arr = accountid2name();
@ -195,7 +201,7 @@ if ($data) :
?> ?>
<link rel="stylesheet" href="common.css"> <link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;"> <div style="overflow-x:auto; white-space:nowrap;">
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> <table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead> <thead>
<tr> <tr>
<th>項次</th> <th>項次</th>

88
wms/mkt/pricereview_mi-api.php

@ -88,7 +88,13 @@ try {
$special_fee = $row[0]; $special_fee = $row[0];
mysqli_free_result($res); mysqli_free_result($res);
$specarr[0] = "服務費"; $specarr[0] = "服務費";
$specarr[1] = round($special_fee / $elev_qty_all, 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 // 電梯所屬OPTION
$opt_sel_id_arr = []; $opt_sel_id_arr = [];
@ -124,9 +130,12 @@ try {
// 電梯所屬保固延長 // 電梯所屬保固延長
$mn_elev_arr = $mn_sel_id_arr = []; $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); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { 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_spec"] = $row[1];
$mn_elev_arr[$row[0]]["item_price_bp"] = $row[2]; $mn_elev_arr[$row[0]]["item_price_bp"] = $row[2];
$tmp_arr = explode(",", $row[3]); $tmp_arr = explode(",", $row[3]);
@ -142,11 +151,19 @@ try {
// 除外項目平均分到每台電梯 // 除外項目平均分到每台電梯
$exarr = []; $exarr = [];
$ex_fee = $j = 0; $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); $res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) { while ($row = mysqli_fetch_row($res)) {
if($row[3] == 0){
continue;
}
$exarr[$j][0] = $row[1]; $exarr[$j][0] = $row[1];
$exarr[$j][1] = round($row[2] / $elev_qty_all, 0); 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]; $ex_fee += $exarr[$j][1];
$j++; $j++;
} }
@ -158,6 +175,9 @@ 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){
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"] . "' ";
$sql4 .= "and version_date = '2023-09-04'"; $sql4 .= "and version_date = '2023-09-04'";
$sql4 .= "and ($row_i[note] between min_floors and max_floors) "; $sql4 .= "and ($row_i[note] between min_floors and max_floors) ";
@ -170,8 +190,14 @@ try {
} }
mysqli_free_result($res_i); mysqli_free_result($res_i);
} }
$dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); if($elev_qty_all == 0 || false){
$polishing_fee = round($polishing_amt / $elev_qty_all, 0); $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($elev_arr);
//print_r($opt_elev_arr); //print_r($opt_elev_arr);
@ -179,25 +205,47 @@ try {
//print_r($mn_elev_arr); //print_r($mn_elev_arr);
//print_r($ex_arr);exit; //print_r($ex_arr);exit;
// echo json_encode($elev_arr); // echo json_encode($elev_arr);
foreach ($elev_arr as $item_no => $v) { require_once("./conn.php");
// 電梯MI // echo json_encode($elev_arr);
$sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r "; foreach ((Array)$elev_arr as $item_no => $v) {
$sql2 .= "where o.quotation_no = r.quotation_no and o.elevator_type = '" . $v['etype'] . "' "; if($item_no == ""){
$sql2 .= "and ($v[item_weight] between o.min_weight and o.max_weight) "; echo "null!!!!!";
$sql2 .= "and ($v[floors] between o.min_floors and o.max_floors) "; continue;
$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; // 電梯MI
$res_e = mysqli_query($link, $sql2); $elevator_type = $v['etype'];
if ($row_e = mysqli_fetch_assoc($res_e)) { $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; $row_e["option_price"] = 0;
// 基准采购成本+±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"];
// 利潤 // 利潤
$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); $equipment_ntd = round(($part1 + $profit) * $row_e["equipment"], 0);
// 報關+運輸 // 報關+運輸
@ -375,7 +423,7 @@ try {
$i++; $i++;
} }
} }
mysqli_free_result($res_e); // mysqli_free_result($res_e);
} }
$rarr["content"] = $mi_arr; $rarr["content"] = $mi_arr;

Loading…
Cancel
Save