From 86b88c0ded1606194ecf3e999c3fcbb022f354b5 Mon Sep 17 00:00:00 2001 From: Cheng Date: Fri, 2 Feb 2024 10:05:32 +0800 Subject: [PATCH] 0202 --- wms/bonus/bonus.php | 2 +- wms/mkt/pricereview-check.php | 16 ++++---- wms/mkt/pricereview_mi-api.php | 67 ++++++++++++++++------------------ 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/wms/bonus/bonus.php b/wms/bonus/bonus.php index 829f29ad..c7ea8819 100644 --- a/wms/bonus/bonus.php +++ b/wms/bonus/bonus.php @@ -18,7 +18,7 @@ $bonus_type = [ $clause = ''; if (!empty($_GET['check'])) { if ($_GET['check'] == 1) { - $clause .= "AND pay_day > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; + $clause .= "AND pay_day_due > DATE_SUB(NOW(), INTERVAL 1 MONTH)"; } else if ($_GET['check'] == 2) { $clause .= "AND status = 1"; } else if ($_GET['check'] == 3) { diff --git a/wms/mkt/pricereview-check.php b/wms/mkt/pricereview-check.php index 64db1e44..6782e668 100644 --- a/wms/mkt/pricereview-check.php +++ b/wms/mkt/pricereview-check.php @@ -320,14 +320,14 @@ foreach ($res as $data) { function getMI(id) { var formdata = new FormData(); formdata.append('pa', id); - // formdata.append('user_id', ); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { + console.log(this.responseText); if (this.readyState == 4 && this.status == 200) { data = JSON.parse(this.responseText); console.log(data); - if(data.err == "notfoundmi"){ - for(let i=0;i', k); - console.log(data.content); + // console.log('k=>', k); + // console.log(data.content); //console.log(data.content[k][0]); // 有值表示先前已寫入MI if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") { @@ -361,7 +361,7 @@ foreach ($res as $data) { mihtml += "
  • 一年免保:" + commafy(data.content[k][6]) + "
  • "; mihtml += "
  • 起吊+木箱+耗材:" + commafy(data.content[k][7]) + "
  • "; //mihtml += "
  • 加價:"+commafy(data.content[k][9])+"
  • "; - mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台" ; + mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台"; mihtml += "
    "; mihtml += "
    OPTION
    "; total_mi = total_mi + data.content[k][12]; @@ -385,14 +385,14 @@ foreach ($res as $data) { total_mi += data.content[k][13]; - if(total_mi == ""){ + if (total_mi == "") { console.log("undefided!!!"); } $("#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); console.log(document.getElementsByClassName('total_mi_fix')[k]); document.getElementsByClassName('total_mi_fix')[k].value = commafy(total_mi) - + // document.getElementsByClassName('item_price_ct')[k].value =commafy(total_mi) document.getElementsByClassName('gross_profit')[k].value = commafy(Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) - total_mi) document.getElementsByClassName('gross_profit_rate')[k].value = Math.round((Number(document.getElementsByClassName('gross_profit')[k].value.replace(/[,]+/g, "")) / Number(document.getElementsByClassName('item_price_ct')[k].value.replace(/[,]+/g, "")) * 100) * 10) / 10 diff --git a/wms/mkt/pricereview_mi-api.php b/wms/mkt/pricereview_mi-api.php index 3784957b..ddc64d31 100644 --- a/wms/mkt/pricereview_mi-api.php +++ b/wms/mkt/pricereview_mi-api.php @@ -88,11 +88,10 @@ try { $special_fee = $row[0]; mysqli_free_result($res); $specarr[0] = "服務費"; - if($elev_qty_all == 0 ){ + if ($elev_qty_all == 0) { $specarr[1] = 0; $specarr[1] = round($special_fee / 1, 0); - - }else{ + } else { $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'"; $res = mysqli_query($link, $sql); while ($row = mysqli_fetch_row($res)) { - if($row[4] == 0){ + if ($row[4] == 0) { continue; } $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'"; $res = mysqli_query($link, $sql); while ($row = mysqli_fetch_row($res)) { - if($row[3] == 0){ + if ($row[3] == 0) { continue; } $exarr[$j][0] = $row[1]; - if($elev_qty_all == 0 || false){ + if ($elev_qty_all == 0 || false) { $exarr[$j][1] = 0; $specarr[1] = round($special_fee / 1, 0); - }else{ + } else { $exarr[$j][1] = round($row[2] / $elev_qty_all, 0); } $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'"; $res_i = mysqli_query($link, $sql3); while ($row_i = mysqli_fetch_assoc($res_i)) { - if($row_i[1] == 0){ + if ($row_i[1] == 0) { continue; } $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); } - if($elev_qty_all == 0 || false){ + if ($elev_qty_all == 0 || false) { $dismantle_fee = round($dismantle_amt / 1, 0); $polishing_fee = round($polishing_amt / 1, 0); - }else{ + } else { $dismantle_fee = round($dismantle_amt / $elev_qty_all, 0); $polishing_fee = round($polishing_amt / $elev_qty_all, 0); } @@ -208,8 +207,8 @@ try { // echo json_encode($elev_arr); require_once("./conn.php"); // echo json_encode($elev_arr); - foreach ((Array)$elev_arr as $item_no => $v) { - if($item_no == ""){ + foreach ((array)$elev_arr as $item_no => $v) { + if ($item_no == "") { continue; } // 電梯MI @@ -230,7 +229,6 @@ try { $stmt->bindParam(':quotation_no', $quotation_no); $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) "; @@ -245,8 +243,7 @@ try { if ($row_e) { // 加價:先不納入 $row_e["option_price"] = 0; - if(!isset($row_e["purchase_cost"])){ - + if (!isset($row_e["purchase_cost"])) { } // 基准采购成本+±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"]; @@ -316,7 +313,7 @@ try { $todo_opt_arr = $v["option"]; if (empty($todo_opt_arr)) $todo_opt_arr = $opt_nosel_id_arr; if (!empty($todo_opt_arr)) { - foreach ($todo_opt_arr as $val) { + foreach ($todo_opt_arr as $val) { $sql4 = "select o.base_floor, o.base_floor_plus, o.price, r.equipment, p.price 'OP' "; $sql4 .= "from option_mi o, elevator_quotation_rule r, option_price p "; $sql4 .= "where o.quotation_no = r.quotation_no and o.option_price_id = p.id "; @@ -443,8 +440,8 @@ try { $mi_arr[$i][19] = $specarr; $i++; } - }else{ - $rarr['err'] = "notfoundmi"; + } else { + $rarr['err'] = "notfoundmi"; } // mysqli_free_result($res_e); } @@ -476,45 +473,44 @@ try { $exceptArr = []; - foreach($items as $item){ - if($item['option_relate_spec'] != NULL){ + foreach ($items as $item) { + if ($item['option_relate_spec'] != NULL) { $exceptArr[] = [ - 'option_relate_spec'=> $item['option_relate_spec'], - 'item_spec'=>$item['item_spec'], - 'item_unit_price'=>$item['item_unit_price'], - 'item_qty'=>$item['item_qty'], - 'item_price_bp'=> $item['item_price_bp'], + 'option_relate_spec' => $item['option_relate_spec'], + 'item_spec' => $item['item_spec'], + 'item_unit_price' => $item['item_unit_price'], + 'item_qty' => $item['item_qty'], + 'item_price_bp' => $item['item_price_bp'], ]; } } // $rarr["content"][] = $exceptArr; - foreach($rarr["content"] as $idx=>&$item){ + foreach ($rarr["content"] as $idx => &$item) { $newTotal = 0; $item[16] = []; $item[14] = []; - foreach($exceptArr as $except){ - if($idx+1 == $except['option_relate_spec']){ + foreach ($exceptArr as $except) { + if ($idx + 1 == $except['option_relate_spec']) { $item[16][] = [ $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][] = [ $itemoption['item_spec'], round($itemoption['option_mi'] * $itemoption['item_qty'], 0), ]; } - - } + } - foreach($item[14] as $option){ + foreach ($item[14] as $option) { $newTotal += $option[1]; } - foreach($item[16] as $ex){ + foreach ($item[16] as $ex) { $newTotal += $ex[1]; } $newTotal += $item[17]; @@ -522,7 +518,6 @@ try { $item[13] = $newTotal; } - } catch (\Exception $e) { $rarr['st'] = 'err'; $rarr['err'] = $e->getMessage();