Browse Source

價審新梯MI、牌價、BUG 解決 0117

main
10994015 1 year ago
parent
commit
8568a7ab8a
  1. 2
      wms/contract/insertMi.php
  2. BIN
      wms/contract/mi/mi1.xlsx
  3. BIN
      wms/contract/mi/mi2.xlsx
  4. BIN
      wms/contract/mi/mi3.xlsx
  5. BIN
      wms/contract/mi/mi4.xlsx
  6. BIN
      wms/contract/mi/mi5.xlsx
  7. BIN
      wms/contract/mi/mi6.xlsx
  8. BIN
      wms/contract/mi/電梯設備MI資訊需求欄位(2).xlsx
  9. BIN
      wms/contract/option/f1.xlsx
  10. BIN
      wms/contract/option/facility.xlsx
  11. 151
      wms/contract/restoremi.php
  12. 49
      wms/mkt/pricereview-check.php
  13. 4
      wms/mkt/pricereview_facility-api.php
  14. 5
      wms/mkt/pricereview_mi-api.php

2
wms/contract/insertMi.php

@ -160,7 +160,7 @@ foreach ($sheet->getRowIterator() as $key => $row) {
if (isset($_GET['miid'])) {
try {
$quotation_no = 'Q2401002';
$quotation_no = 'Q2401003';
//VALUES (:elevator_type, :model_no, :min_weight, :max_weight, :min_speed, :max_speed, :min_floors, :max_floors, :base_floor, :purchase_cost, :material_plus, :design_hour, :export_fee, :equip_profit, :customs_shipping, :unloading, :transport_site, :install_price, :install_plus, :install_coef, :trial_price, :trial_plus, :trial_coef, :free1y, :crane, :wooden_box, :consume, :consumables, :option_price, :quotation_no, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type);

BIN
wms/contract/mi/mi1.xlsx

Binary file not shown.

BIN
wms/contract/mi/mi2.xlsx

Binary file not shown.

BIN
wms/contract/mi/mi3.xlsx

Binary file not shown.

BIN
wms/contract/mi/mi4.xlsx

Binary file not shown.

BIN
wms/contract/mi/mi5.xlsx

Binary file not shown.

BIN
wms/contract/mi/mi6.xlsx

Binary file not shown.

BIN
wms/contract/mi/電梯設備MI資訊需求欄位(2).xlsx

Binary file not shown.

BIN
wms/contract/option/f1.xlsx

Binary file not shown.

BIN
wms/contract/option/facility.xlsx

Binary file not shown.

151
wms/contract/restoremi.php

@ -0,0 +1,151 @@
<?php
require_once('./conn.php');
require 'vendor/autoload.php';
ini_set('date.timezone', 'Asia/Taipei');
$id = $_GET['id'];
use PhpOffice\PhpSpreadsheet\IOFactory;
if($id == 999){
$filePath = './option/f1.xlsx';
try {
$spreadsheet = IOFactory::load($filePath);
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
die('Error loading file: ' . $e->getMessage());
}
// 獲取活動工作表
$sheet = $spreadsheet->getActiveSheet();
$status = "Y";
$create_at = date('Y-m-d H:i:s');
$sql_str = "INSERT INTO facility_price (kind, model, seat, numberofstop, speed, price, price_mi, status, create_dt)
VALUES (:kind, :model, :seat, :numberofstop, :speed, :price, :price_mi, :status, :create_at)";
// 遍歷工作表中的每一行
$inserttotal = 0;
foreach ($sheet->getRowIterator() as $key => $row) {
// 獲得單元格迭代器
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // This loops through all cells,
// even if a cell value is not set.
// By default, only cells that have a value set will be iterated.
foreach ($cellIterator as $idx => $cell) {
if ($cell !== null) {
// 打印單元格數據
// echo $cell->getValue() . '///';
}
if ($idx == 'A') {
$model = $cell->getValue();
$kind = explode("-", $model)[0];
$seat = explode("*", explode("-", $model)[1])[0];
$numberofstop = explode("*", explode("-", $model)[1])[1];
$spec = explode("-", $model)[2];
if(stripos($spec, "09")){
$speed = 9;
}elseif(stripos($spec, "24")){
$speed = 24;
$openfn = str_replace("24", "", $spec);
}elseif(stripos($spec, "45")){
$speed = 45;
$openfn = str_replace("45", "", $spec);
}elseif(stripos($spec, "60")){
$speed = 60;
$openfn = str_replace("60", "", $spec);
}elseif(stripos($spec, "90")){
$speed = 90;
$openfn = str_replace("90", "", $spec);
}elseif(stripos($spec, "105")){
$speed = 105;
$openfn = str_replace("105", "", $spec);
}elseif(stripos($spec, "120")){
$speed = 120;
$openfn = str_replace("120", "", $spec);
}elseif(stripos($spec, "150")){
$speed = 150;
$openfn = str_replace("150", "", $spec);
}elseif(stripos($spec, "180")){
$speed = 180;
$openfn = str_replace("180", "", $spec);
}
$speed = trim($speed);
$openfn = trim($openfn);
echo "種類:".$kind;
echo "規格:".$model;
echo "人乘:".$seat;
echo "停數".$numberofstop;
echo "速度:".$speed;
echo "開門方式:" . $openfn;
} elseif($idx == "B"){
$price = (float)$cell->getValue() *10000;
echo "價錢:".$price;
}elseif($idx == "C"){
$add = (float)$cell->getValue() *10000;
echo "+-1停:".$add;
}elseif($idx == "D"){
$min_stop = $cell->getValue();
echo "最低停數:".$min_stop;
}
}
echo "-------><br>";
try{
for($i=2;$i<$numberofstop;$i++){
$stop = ($i <= $min_stop) ? $min_stop : $i;
echo $kind . "-" . $seat . "*" . $i . "-" . $openfn . $speed;
$new_model = $kind . "-" . $seat . "*" . $i . "-" . $openfn . $speed;
$calc_price = $price + $add * ($stop-$numberofstop);
echo "價錢:" . $calc_price;
//kind, :model, :seat, :numberofstop, :speed, :price, :price_mi, :status, :create_at
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':kind', $kind);
$stmt->bindParam(':model', $new_model);
$stmt->bindParam(':seat', $seat);
$stmt->bindParam(':numberofstop', $i);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':price', $calc_price);
$stmt->bindParam(':price_mi', $calc_price);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
$inserttotal++;
echo "OK";
echo "<br>";
}
for($i=$numberofstop;$i<=30;$i++){
$stop = ($i <= $min_stop) ? $min_stop : $i;
$new_model = $kind . "-" . $seat . "*" . $i . "-" . $openfn . $speed;
echo $new_model;
$calc_price = $price + $add * ($stop-$numberofstop);
echo "價錢:" . $calc_price;
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':kind', $kind);
$stmt->bindParam(':model', $new_model);
$stmt->bindParam(':seat', $seat);
$stmt->bindParam(':numberofstop', $i);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':price', $calc_price);
$stmt->bindParam(':price_mi', $calc_price);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':create_at', $create_at);
$stmt->execute();
$inserttotal++;
echo "OK";
echo "<br>";
}
}
catch (PDOException $e) {
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
echo "<br>"; // 換行,以分隔不同的行
}
echo $inserttotal;
}

49
wms/mkt/pricereview-check.php

@ -316,6 +316,7 @@ foreach ($res as $data) {
}
return num;
}
let total_mi = 0;
function getMI(id) {
var formdata = new FormData();
formdata.append('pa', id);
@ -328,9 +329,8 @@ foreach ($res as $data) {
//alert(data.err);
return false;
}
Object.keys(data.content).forEach(function(k) {
console.log(data.content);
console.log('k=>', k);
//console.log(data.content[k][0]);
// 有值表示先前已寫入MI
if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") {
@ -340,6 +340,7 @@ foreach ($res as $data) {
}
$("#tb1").find("input[name=mi_fix]").eq(k).keyup();
var mihtml = "";
total_mi = 0;
mihtml += "<h5>電梯設備</h5>";
mihtml += "<li>設備" + data.content[k][8] + ":" + commafy(data.content[k][1]) + "</li>";
mihtml += "<li>報關+運輸費:" + commafy(data.content[k][2]) + "</li>";
@ -352,7 +353,8 @@ foreach ($res as $data) {
mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台";
mihtml += "<hr>";
mihtml += "<h5>OPTION</h5>";
total_mi = total_mi + data.content[k][12];
console.log(data.content[k][12]);
Object.keys(data.content[k][14]).forEach(function(m) {
if (data.content[k][14][m][0] != '') {
mihtml += "<li>" + data.content[k][14][m][0]+ ":" + commafy(data.content[k][14][m][1]) + "</li>";
@ -368,16 +370,23 @@ foreach ($res as $data) {
});
mihtml += "<li>" + data.content[k][19][0] + ":" + commafy(data.content[k][19][1]) + "</li>";
mihtml += "以上合計:" + commafy(data.content[k][13]) + "<br>";
mifix += (data.content[k][12] + data.content[k][13])
total_mi = total_mi + data.content[k][13];
console.log(data.content[k][13]);
$("#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);
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
});
}
}
xhr.open('POST', 'pricereview_mi-api.php', true);
xhr.send(formdata);
}
$(function() {
<?php if ($viewmi) { ?>
getMI('<?php echo $id; ?>');
@ -414,18 +423,22 @@ foreach ($res as $data) {
$("#specModal .modal-body").html(plink);
$("#specModal").modal('show');
});
});
$('#tb1').on('keyup', 'input[name=mi_fix]', function() {
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var mf = $(this).val().replace(/[,]+/g, "");
// var mf = $(this).val().replace(/[,]+/g, "");
var mf = $(this).closest('td').parent().find('input[name=mi_fix]').val().replace(/[,]+/g, "");
var ct = $(this).closest('td').parent().find('input[name=item_price_ct]').val().replace(/[,]+/g, "");
console.log(mf);
console.log(ct);
console.log(ct - mf);
$(this).closest('td').parent().find('input[name=gross_profit]').val(commafy(ct - mf));
if (ct == 0) $(this).closest('td').parent().find('input[name=gross_profit_rate]').val(0.0);
else $(this).closest('td').parent().find('input[name=gross_profit_rate]').val((((ct - mf) / ct) * 100).toFixed(1));
});
$('button[name=status]').click(function() {
var itemNoArr = [];
@ -475,7 +488,9 @@ foreach ($res as $data) {
$('#tb5').on('keyup', 'input[name=final_price_total]', function() {
$(this).val(commafy($(this).val()));
});
});
</script>
<style>
.container {
@ -555,11 +570,7 @@ foreach ($res as $data) {
<?php
$item_amt_A_all = 0;
$idx = 1;
print_r($item_arr);
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"];
if ($viewmi) {
// for ($i = 0; $i < $val["item_qty"]; $i++) {
@ -570,13 +581,13 @@ foreach ($res as $data) {
<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="<?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"] * $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="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="mi_fix" class="form-control dollar-right total_mi_fix" size="9" value="<?php echo ($val["mi_fix"]) ? number_format($val["mi_fix"] +$data["special_fee"] ) : ""; ?>" disabled></td>
<td><input type="text" name="item_price_ct" class="form-control dollar-right item_price_ct" 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="pv_rate" class="form-control" size="1" value="<?= $val["pv_rate"]; ?>"></td>
<td><input type="text" name="allocate" class="form-control" size="6" value="<?= $val["allocate"]; ?>"></td>-->
<td><input type="text" name="gross_profit" class="form-control dollar-right" size="9" value="<?= number_format($val["gross_profit"]); ?>"></td>
<td><input type="text" name="gross_profit_rate" class="form-control" size="6" value="<?= number_format($val["gross_profit_rate"], 1); ?>"></td>
<td><input type="text" name="gross_profit" class="form-control dollar-right gross_profit" size="9" value="<?= number_format($val["gross_profit"]); ?>"></td>
<td><input type="text" name="gross_profit_rate" class="form-control gross_profit_rate" size="6" value="<?= number_format($val["gross_profit_rate"], 1); ?>"></td>
<!--<td><input type="text" name="note" class="form-control" size="17" value="<?= $val["note"]; ?>"></td>-->
</tr>
<tr name="facil_templ2">
@ -969,7 +980,7 @@ foreach ($res as $data) {
</div>
<div>
<label for="price_rate">價率%(B/A)</label>
<input type="text" name="price_rate" id="price_rate" value="<?= number_format($data["price_rate"], 1); ?>">
<input type="text" name="price_rate" id="price_rate" value="<?php echo number_format((int)$data["price_total"]/(int)$data["price_lowest"] * 100, 1); ?>">
</div>
<div>
<label for="price_broken">破價(台)</label>
@ -1125,4 +1136,8 @@ foreach ($res as $data) {
mysqli_free_result($res);
mysqli_close($link);
include "../footer.php";
?>
?>
<script>
console.log("------", document.getElementById('mi_fix_all').value);
</script>

4
wms/mkt/pricereview_facility-api.php

@ -27,13 +27,13 @@ try {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
echo $fval;
list($source, $kind, $seat, $numberofstop, $speed, $op) = explode(",", $fval);
if (!$source || !$kind || !$seat) throw new \Exception("parameter empty[2]");
if ($source == "F") {
$db_query = "select id, price, price_mi, model from facility_price where kind = '$kind' and seat = '$seat' and numberofstop = '$numberofstop' ";
$db_query .= "and speed = '$speed' and status = 'Y'";
$db_query .= "and speed = '$speed' and status = 'Y' order by id desc";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
$id = $row[0];

5
wms/mkt/pricereview_mi-api.php

@ -212,6 +212,7 @@ try {
continue;
}
// 電梯MI
$quotation_no = "Q2401003";
$elevator_type = $v['etype'];
$floor = $v['floors'];
$speed = $v['speed'];
@ -219,11 +220,13 @@ try {
$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 ";
elevator_mi_option.min_weight = :min_weight AND elevator_mi_option.min_speed = :speed
AND elevator_mi_option.quotation_no = :quotation_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type);
$stmt->bindParam(':speed', $speed);
$stmt->bindParam(':min_weight', $min_weight);
$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 ";

Loading…
Cancel
Save