You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

610 lines
31 KiB

<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
require_once "database.php"; // get $link
$data = $item_arr = $facil_arr = array();
$fp_id_str = "";
$db_query = "select * from pricereview_main where id = '$id'";
/*
if ($res = mysqli_query($link, $db_query)) {
while ($row = mysqli_fetch_row($res)) {
list($id, $version, $company)
}
}
*/
$res = mysqli_query($link, $db_query);
foreach ($res as $data) {
$mid = $data["id"];
$db_query = "select * from pricereview_item where mid = '$mid' order by item_no";
$res_i = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res_i)) {
$item_arr[$row['item_no']]['fp_id'] = $row['fp_id'];
$item_arr[$row['item_no']]['item_group'] = $row['item_group'];
$item_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$item_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
$item_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp'];
$item_arr[$row['item_no']]['item_price'] = $row['item_price'];
$item_arr[$row['item_no']]['pv_rate'] = $row['pv_rate'];
$item_arr[$row['item_no']]['note'] = $row['note'];
$data["qty_total"] += $row["item_qty"];
if ($row['item_group'] == "A") $fp_id_str .= $row['fp_id'].",";
}
mysqli_free_result($res_i);
$fp_id_str = rtrim($fp_id_str, ",");
if ($fp_id_str) {
$db_query = "select * from facility_price where id in ($fp_id_str)";
$res_f = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res_f)) {
$facil_arr[$row['id']]['kind'] = $row['kind'];
$facil_arr[$row['id']]['seat'] = $row['seat'];
$facil_arr[$row['id']]['numberofstop'] = $row['numberofstop'];
$facil_arr[$row['id']]['speed'] = $row['speed'];
}
mysqli_free_result($res_f);
}
$data["price_total_broken"] = $data["price_total"] - $data["price_lowest"];
$data["price_rate"] = ($data["price_lowest"]) ? round(($data["price_total"]/$data["price_lowest"])*100, 2) : 0;
$data["price_broken"] = ($data["qty_total"]) ? round($data["price_total_broken"]/$data["qty_total"], 1) : 0;
?>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
function dataFormat() {
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
}
function selFacil(o) {
var fp = o.parent().parent();
var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val();
var f3 = fp.find('input[name=fp_numberofstop]').val();
var f4 = fp.find('select[name=fp_speed]').val();
var f5 = fp.find('input[name=item_qty]').val();
if (f1 !== '' && f2 !== '' && f3 !== '' && f4 !== '' && f5 !== '') {
let fAry = [f1, f2, f3, f4, f5];
//console.log(fAry);
var formdata = new FormData();
formdata.append('fval', fAry);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
data = JSON.parse(this.responseText);
if (data.st == 'err') {
alert(data.err);
fp.find('input[name=item_price_bp]').val(0);
dataFormat();
return false;
}
fp.find('input[name=item_price_bp]').val(commafy(data.amt));
fp.find('input[name=fp_id]').val(data.id);
fp.find('input[name=item_spec]').val(data.model);
fp.find('input[name=item_group]').val(data.group);
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g,"")/pl)*100).toFixed(2)));
}
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2)));
dataFormat();
/*
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
*/
}
}
xhr.open('POST','/mkt/pricereview-facility.php',true);
xhr.send(formdata);
}
}
function tt(){
$("input[name='item_price_bp']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
});
}
$(function () {
/*
$('#tb1').on('click', $("tr[name='facil_templ']"), function(){
$('[data-submenu]').submenupicker();
$("button[name='floor']").click(function(){
//$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
$(this).closest('td').next().find('input').val($(this).parent().parent().find("button").html());
$(this).closest('td').parent().find('input[name=item_price_bp]').val(commafy($(this).val()));
$(this).closest('td').parent().find('input[name=item_qty]').val(1);
//$(this).e.targetclosest('td').parent().find('input[name=item_price_bp]').focus();
//console.log($(this).attr('name'));
//tt($(this));
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g,"")/pl)*100).toFixed(2)));
}
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2)));
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
});
});
$('.table-responsive').on('show.bs.dropdown', function () {
$('.table-responsive').css( "overflow", "inherit" );
});
$('.table-responsive').on('hide.bs.dropdown', function () {
$('.table-responsive').css( "overflow", "auto" );
});
*/
$('#tb1').on('click', 'input[name=fp_numberofstop], input[name=item_qty]', function(){
$(this).unbind().keyup(function(){
// console.log('a');
selFacil($(this));
});
});
$('#tb1').on('click', 'select[name=fp_kind], select[name=fp_seat], select[name=fp_speed]', function(){
$(this).unbind().change(function(){
selFacil($(this));
});
});
$('#deposit_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); });
$('#keep_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); });
$('#warranty_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); });
/*
// for 動態表格的作法:event delegation
$('#tb1').on('click', $("input[name='item_qty']"), function(){
$("input[name='item_qty']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g,"")/pl)*100).toFixed(2)));
}
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2)));
});
});
*/
//$('#tb1').on('click', tt);
/*
$('#tb1').on('click', $("input[name='item_price_bp']"), function(){
$("input[name='item_price_bp']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
});
});
*/
$('#tb1').on('keyup', 'input[name=item_price_bp]', function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
dataFormat();
});
$('#tb1').on('keyup', 'input[name=fp_numberofstop], input[name=item_qty], input[name=item_price]', function(){
//$("input[name='item_price']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//});
});
$('#tb1').on('keyup', 'input[name=pv_rate]', function(){
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
});
$("#price_total").on("input", function(){
var pt = parseInt($(this).val().replace(/[,]+/g,"")) || 0;
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//var pl = ('NaN'==$('#price_lowest').val() || ''==$('#price_lowest').val().trim())?0:parseInt($('#price_lowest').val());
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
$('#price_total_broken').val(commafy(pt-pl));
if (pl) {
//if ('' != $('#price_lowest').val().trim()) {
$('#price_rate').val(((pt/pl)*100).toFixed(2));
}
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy((parseInt($('#price_total_broken').val().replace(/[,]+/g,""))/qt).toFixed(0)));
}
$('#pay1').html(commafy((pt*0.2).toFixed(0)));
$('#pay2').html(commafy((pt*0.4).toFixed(0)));
$('#pay3').html(commafy((pt*0.2).toFixed(0)));
$('#pay4').html(commafy((pt*0.1).toFixed(0)));
$('#pay5').html(commafy((pt*0.1).toFixed(0)));
});
$('#btnadd').click(function(){
$('#tb1 tr:last').prev().after($("tr[name='facil_templ']").eq(0).clone().find('input,select').val('').end());
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='facil_templ']").length+'<input type="hidden" name="item_id" value="-">');
/*
var facilTemp = '';
facilTemp+= '<tr name="facil_templ">';
facilTemp+= '<td>'+($('tr[name=facil_templ]').length+1)+'<input type="hidden" name="item_id" value="-"></td>';
facilTemp+= '<td>';
facilTemp+= '<?php include_once "facility_price.php"; ?>';
facilTemp+= '</td>';
facilTemp+= '<td><input type="text" name="item_spec"></td>';
facilTemp+= '<td><input type="text" name="item_qty"></td>';
facilTemp+= '<td><input type="text" name="item_price_bp"></td>';
facilTemp+= '<td><input type="text" name="item_price"></td>';
facilTemp+= '<td><input type="text" name="pv_rate"></td>';
facilTemp+= '<td colspan="2"><input type="text" name="note"><input type="hidden" name="item_group" value="A"></td>';
facilTemp+= '</tr>';
$('#tb1 tr:last').prev().after(facilTemp);
*/
});
$('#update').click(function(){
var itemFpidArr = [];
$("input[name='fp_id']").each(function(){ itemFpidArr.push($(this).val()); })
$('#fp_id_all').val(itemFpidArr);
var itemSpecArr = [];
$("input[name='item_spec']").each(function(){ itemSpecArr.push($(this).val()); })
$('#item_spec_all').val(itemSpecArr);
var itemGroupArr = [];
$("input[name='item_group']").each(function(){ itemGroupArr.push($(this).val()); })
$('#item_group_all').val(itemGroupArr);
var itemQtyArr = [];
$("input[name='item_qty']").each(function(){ itemQtyArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_qty_all').val(itemQtyArr);
var itemPriceBpArr = [];
$("input[name='item_price_bp']").each(function(){ itemPriceBpArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_price_bp_all').val(itemPriceBpArr);
var itemPriceArr = [];
$("input[name='item_price']").each(function(){ itemPriceArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_price_all').val(itemPriceArr);
var pvRateArr = [];
$("input[name='pv_rate']").each(function(){ pvRateArr.push($(this).val()); })
$('#pv_rate_all').val(pvRateArr);
var noteArr = [];
$("input[name='note']").each(function(){ noteArr.push($(this).val()); })
$('#note_all').val(noteArr);
var itemIdArr = [];
$("input[name='item_id']").each(function(){ itemIdArr.push($(this).val()); })
$('#item_id_all').val(itemIdArr);
//console.log(itemNameArr);
//return false;
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="pricereview-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?=$id;?>">
<div>
<label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" maxlength="7" value="<?=$data["contractno"];?>" required>
</div>
<div>
<label for="person">營業員</label>
<input type="text" name="person" id="person" value="<?=$data["person"];?>">
</div>
<div>
<label for="company">客戶名稱</label>
<input type="text" name="company" id="company" value="<?=$data["company"];?>" required>
</div>
<div>
<label for="case_name">案件名稱</label>
<input type="text" name="case_name" id="case_name" value="<?=$data["case_name"];?>" required>
</div>
<div>
<label for="address">工地地址</label>
<input type="text" name="address" id="address" value="<?=$data["address"];?>" required>
</div>
<div>
<label for="compete">競爭對手</label>
<input type="text" name="compete" id="compete" value="<?=$data["compete"];?>">
</div>
<div>
<label for="price_lowest">底價總額</label>
<input type="text" name="price_lowest" id="price_lowest" value="<?=number_format($data["price_lowest"]);?>" style="background-color:#eee5e5" readonly>
</div>
<div>
<label for="price_total">售價總額</label>
<input type="text" name="price_total" id="price_total" value="<?=number_format($data["price_total"]);?>" required>
</div>
<div>
<label for="price_total_broken">破價總額</label>
<input type="text" name="price_total_broken" id="price_total_broken" value="<?=number_format($data["price_total_broken"]);?>" style="background-color:#eee5e5" readonly>
</div>
<div>
<label for="price_rate">價率%</label>
<input type="text" name="price_rate" id="price_rate" value="<?=$data["price_rate"];?>" style="background-color:#eee5e5" readonly>
</div>
<div>
<label for="qty_total">總台數</label>
<input type="text" name="qty_total" id="qty_total" value="<?=number_format($data["qty_total"]);?>" style="background-color:#eee5e5" readonly>
</div>
<div>
<label for="inquire_no">詢價單號</label>
<input type="text" name="inquire_no" id="inquire_no" value="<?=$data["inquire_no"];?>">
</div>
<div>
<label for="price_broken">破價(台)</label>
<input type="text" name="price_broken" id="price_broken" value="<?=number_format($data["price_broken"]);?>" style="background-color:#eee5e5" readonly>
</div>
<div>
<label for="predeal_date">預定成交日</label><br>
<input type="date" name="predeal_date" id="predeal_date" value="<?=$data["predeal_date"];?>" required>
</div>
<div>
<label for="facilitok_date">預定交期</label><br>
<input type="date" name="facilitok_date" id="facilitok_date" value="<?=$data["facilitok_date"];?>" required>
</div>
<div>
<label for="penalty">罰則</label>
<input type="text" name="penalty" id="penalty" value="<?=$data["penalty"];?>">
</div>
<div>
<label for="deposit_rate">訂金保證金(函)%</label>
<input type="text" name="deposit_rate" id="deposit_rate" value="<?=$data["deposit_rate"];?>">
</div>
<div>
<label for="keep_rate">履約保證金(函)%</label>
<input type="text" name="keep_rate" id="keep_rate" value="<?=$data["keep_rate"];?>">
</div>
<div>
<label for="warranty_rate">保固保證金(函)%</label>
<input type="text" name="warranty_rate" id="warranty_rate" value="<?=$data["warranty_rate"];?>">
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table class="table">
<thead>
<tr>
<th><label for="memo">說明</label></th>
</tr>
</thead>
<tbody>
<tr>
<td><textarea name="memo" id="memo" rows="10"><?=$data["memo"];?></textarea></td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th nowrap>項次</th>
<th style="width:13%">電梯</th>
<th style="width:11%">人乘</th>
<th>停數</th>
<th style="width:11%">速度</th>
<th>數量</th>
<th style="width:11%">B/P(含稅)</th>
<th style="width:11%">金額(含稅)</th>
<th>價審%</th>
<th nowrap>備註</th>
<th><button type="button" id="btnadd" class="btn btn-primary btn-sm">新增</button></th>
</tr>
</thead>
<tbody>
<?php
foreach ($item_arr as $item_no => $val) {
if ($val["item_group"] == "A") {
?>
<tr name="facil_templ">
<td><?php echo $item_no; ?><input type="hidden" name="item_id" value="<?=$item_no;?>"></td>
<td>
<select name="fp_kind">
<option value="">請選擇</option>
<option value="MAE100"<?php if ($facil_arr[$val["fp_id"]]["kind"]=="MAE100") echo " selected"; ?>>MAE100</option>
<option value="MAM200"<?php if ($facil_arr[$val["fp_id"]]["kind"]=="MAM200") echo " selected"; ?>>MAM200</option>
<option value="MAH100"<?php if ($facil_arr[$val["fp_id"]]["kind"]=="MAH100") echo " selected"; ?>>MAH100</option>
<option value="MAQ100"<?php if ($facil_arr[$val["fp_id"]]["kind"]=="MAQ100") echo " selected"; ?>>MAQ100</option>
<!--<option value="MAF100">MAF100</option>
<option value="MAZ100">MAZ100</option>-->
</select>
</td>
<td>
<select name="fp_seat">
<option value="">請選擇</option>
<option value="6"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="6") echo " selected"; ?>>6</option>
<option value="8"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="8") echo " selected"; ?>>8</option>
<option value="9"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="9") echo " selected"; ?>>9</option>
<option value="10"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="10") echo " selected"; ?>>10</option>
<option value="11"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="11") echo " selected"; ?>>11</option>
<option value="12"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="12") echo " selected"; ?>>12</option>
<option value="13"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="13") echo " selected"; ?>>13</option>
<option value="15"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="15") echo " selected"; ?>>15</option>
<option value="17"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="17") echo " selected"; ?>>17</option>
<option value="20"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="20") echo " selected"; ?>>20</option>
<option value="24"<?php if ($facil_arr[$val["fp_id"]]["seat"]=="24") echo " selected"; ?>>24</option>
</select>
</td>
<td style="padding-top:0px;">
<input type="text" name="fp_numberofstop" value="<?php echo $facil_arr[$val["fp_id"]]["numberofstop"]; ?>">
</td>
<td>
<select name="fp_speed">
<option value="">請選擇</option>
<option value="30"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="30") echo " selected"; ?>>30m/min</option>
<option value="45"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="45") echo " selected"; ?>>45m/min</option>
<option value="60"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="60") echo " selected"; ?>>60m/min</option>
<option value="90"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="90") echo " selected"; ?>>90m/min</option>
<option value="105"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="105") echo " selected"; ?>>105m/min</option>
<option value="120"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="120") echo " selected"; ?>>120m/min</option>
<option value="150"<?php if ($facil_arr[$val["fp_id"]]["speed"]=="150") echo " selected"; ?>>150m/min</option>
</select>
</td>
<td style="padding-top:0px;"><input type="text" name="item_qty" maxlength="2" value="<?php echo number_format($val["item_qty"]); ?>"></td>
<td style="padding-top:0px;"><input type="text" name="item_price_bp" value="<?php echo number_format($val["item_price_bp"]); ?>"></td>
<td style="padding-top:0px;"><input type="text" name="item_price" value="<?php echo number_format($val["item_price"]); ?>"></td>
<td style="padding-top:0px;"><input type="text" name="pv_rate" value="<?php echo $val["pv_rate"]; ?>"></td>
<td style="padding-top:0px;" colspan="2"><input type="text" name="note" value="<?php echo $val["note"]; ?>"><input type="hidden" name="item_group" value="A"><input type="hidden" name="fp_id" value="<?php echo $val["fp_id"]; ?>"><input type="hidden" name="item_spec" value="<?php echo $val["item_spec"]; ?>"></td>
</tr>
<?php
} elseif ($val["item_group"] == "B") {
?>
<tr>
<td><input type="hidden" name="item_id" value="<?=$item_no;?>"></td>
<td colspan="5"><input type="text" name="item_spec" value="<?=$val["item_spec"];?>"></td>
<td><input type="text" name="item_price_bp" value="<?=number_format($val["item_price_bp"]);?>"></td>
<td><input type="text" name="item_price" value="<?=number_format($val["item_price"]);?>"></td>
<td><input type="text" name="pv_rate" value="<?=$val["pv_rate"];?>"></td>
<td colspan="2"><input type="text" name="note" value="<?=$val["note"];?>"><input type="hidden" name="item_group" value="B"></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th colspan="4">合計</th>
</tr>
</thead>
<tbody>
<tr>
<td><label>數量</label></td>
<td><input type="text" id="cnt" style="background-color:#eee5e5" value="<?=number_format($data["qty_total"]);?>" readonly></td>
<td><label>B/P(含稅)</label></td>
<td><input type="text" id="amt" style="background-color:#eee5e5" value="<?=number_format($data["price_lowest"]);?>" readonly></td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<thead>
<tr>
<th colspan="4">付款辦法</th>
</tr>
</thead>
<tbody>
<tr>
<td>1、訂金</td>
<td>20%</td>
<td id="pay1"><?=number_format($data["price_total"]*0.2);?></td>
<td>30天期票,簽約後30日內兌現</td>
</tr>
<tr>
<td>2、二次款</td>
<td>40%</td>
<td id="pay2"><?=number_format($data["price_total"]*0.4);?></td>
<td>30天期票,電梯出貨前兌現</td>
</tr>
<tr>
<td>3、貨到付款</td>
<td>20%</td>
<td id="pay3"><?=number_format($data["price_total"]*0.2);?></td>
<td>30天期票,電梯使用前兌現</td>
</tr>
<tr>
<td>4、安裝完畢款</td>
<td>10%</td>
<td id="pay4"><?=number_format($data["price_total"]*0.1);?></td>
<td>30天期票,電梯交車前兌現</td>
</tr>
<tr>
<td>5、尾款</td>
<td>10%</td>
<td id="pay5"><?=number_format($data["price_total"]*0.1);?></td>
<td>30天期票,取得許可函後30日內兌現</td>
</tr>
</tbody>
</table>
<?php if (!$data["checker_1"] && !$data["checker_1_dt"]) { ?>
<button type="submit" name="update" id="update">儲存</button>
</div>
<?php } ?>
<input type="hidden" name="fp_id_all" id="fp_id_all">
<input type="hidden" name="item_spec_all" id="item_spec_all">
<input type="hidden" name="item_group_all" id="item_group_all">
<input type="hidden" name="item_qty_all" id="item_qty_all">
<input type="hidden" name="item_price_bp_all" id="item_price_bp_all">
<input type="hidden" name="item_price_all" id="item_price_all">
<input type="hidden" name="pv_rate_all" id="pv_rate_all">
<input type="hidden" name="note_all" id="note_all">
<input type="hidden" name="item_id_all" id="item_id_all">
</form>
</div>
<?php
}
mysqli_free_result($res);
mysqli_close($link);
include "footer.php";
?>