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.
 
 
 
 
 
 

1151 lines
67 KiB

<?php
include "../header.php";
$fromsign = isset($_GET['fromsign']) ? $_GET['fromsign'] : 0;
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : "";
if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$st = (empty($_GET["st"])) ? "" : $_GET["st"];
//if ($st != 1 && $st != 2 && $st != 3) header("Location: pricereview-index.php");
if (!empty($form_key)) {
$sql = "select form_id from flow where form_key = '$form_key'";
$res = mysqli_query($link, $sql);
if ($row = mysqli_fetch_row($res)) {
$id = $row[0];
}
mysqli_free_result($res);
// 目前簽核進度:$st
$db_query = "select sign1, sign2, sign3, sign4 from pricereview_sign where mid = '$id'";
$res_s = mysqli_query($link, $db_query);
if ($row_s = mysqli_fetch_row($res_s)) {
list($sign1, $sign2, $sign3, $sign4) = $row_s;
$ss_arr = sign_status([$sign1, $sign2, $sign3, $sign4]);
$st = $ss_arr["sign_st"];
}
mysqli_free_result($res_s);
if (!in_array($user_id, $ss_arr["sign_nt"])) {
echo "<script>";
echo "alert('資料錯誤!!');";
echo "window.history.go(-1);";
echo "</script>";
exit;
}
}
// 員工編號對應姓名表
$accountname_arr = accountid2name();
// 審核按鈕開關
$sign_on = 0;
$data = $item_arr = $option_arr = $mn_arr = $ex_arr = $pay_arr = array();
$checker_1_result = $checker_2_result = $checker_3_result = $checker_4_result = "";
$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) {
// 上層主管
$sql = "select manager from account where accountid = '" . $data["person"] . "'";
$res_a = mysqli_query($link, $sql);
$row_a = mysqli_fetch_row($res_a);
$manager = $row_a[0];
mysqli_free_result($res_a);
// 瀏覽MI權限
$depart_id = accountidToDepartId($user_id);
if ($depart_id == "320" || $depart_id == "321" || $depart_id == "20" || $user_id == 'TEST04') $viewmi = 1;
else $viewmi = 0;
$sql = "select * from pricereview_sign where mid = '$id'";
$res_s = mysqli_query($link, $sql);
$row_s = mysqli_fetch_assoc($res_s);
mysqli_free_result($res_s);
if (!empty($row_s["sign1"])) list($person1, $status1, $dtte1) = explode(",", $row_s["sign1"]);
else $person1 = $status1 = $dtte1 = "";
if (!empty($row_s["sign2"])) {
if ($user_id == "TEST02") {
list($person2, $status2, $dtte2) = explode(",", $row_s["sign2"]);
} else {
if ($st == 2 && (preg_match("/Y/", $row_s["sign2"]) || preg_match("/N/", $row_s["sign2"]))) {
echo "<script>";
echo "alert('請勿重覆審核!');";
echo "location.href='pricereview-index.php?function_name=pricereview&" . $token_link . "';";
echo "</script>";
exit;
}
$sign2_arr = explode("<##>", $row_s["sign2"]); // M0024,,<##>M0175,,
$person2_arr = [];
foreach ($sign2_arr as $v) {
list($person2, $status2, $dtte2) = explode(",", $v);
if (strlen($v) == 7) { // 未審
$person2_arr[] = $person2;
} else {
unset($person2_arr);
break;
}
}
}
} else $person2 = $status2 = $dtte2 = "";
if (!empty($row_s["sign3"])) list($person3, $status3, $dtte3) = explode(",", $row_s["sign3"]);
else $person3 = $status3 = $dtte3 = "";
if (!empty($row_s["sign4"])) list($person4, $status4, $dtte4) = explode(",", $row_s["sign4"]);
else $person4 = $status4 = $dtte4 = "";
$sign1_note = (empty($row_s["sign1_note"])) ? "" : $row_s["sign1_note"];
$sign2_note = (empty($row_s["sign2_note"])) ? "" : $row_s["sign2_note"];
$sign3_note = (empty($row_s["sign3_note"])) ? "" : $row_s["sign3_note"];
$sign4_note = (empty($row_s["sign4_note"])) ? "" : $row_s["sign4_note"];
if ($status1 == "Y") {
$checker_1_result = "同意";
} elseif ($status1 == "N") {
$checker_1_result = "不同意";
}
if ($status2 == "Y") {
$checker_2_result = "同意";
} elseif ($status2 == "N") {
$checker_2_result = "不同意";
}
if ($status3 == "Y" || $status3 == "YY") {
$checker_3_result = "同意";
} elseif ($status3 == "N") {
$checker_3_result = "不同意";
}
if ($status4 == "Y") {
$checker_4_result = "同意";
} elseif ($status4 == "N") {
$checker_4_result = "不同意";
}
if ($st == 1 && ($person1 == $user_id) && ($status1 == "") || $user_id == 'TEST04') {
$sign_on = 1;
}
if ($st == 2 && ($person2 == $user_id || (isset($person2_arr) && in_array($user_id, $person2_arr))) && ($status2 == "") || $user_id == 'TEST02') {
$sign_on = 1;
}
if ($st == 3 && ($person3 == $user_id) && ($status3 == "") || $user_id == 'TEST03') {
$sign_on = 1;
}
if ($st == 4 && ($person4 == $user_id) && ($status4 == "") || $user_id == 'TEST05') {
$sign_on = 1;
}
// $sign_total=關卡數
if ($person4 == "") {
if ($person3 == "") {
$sign_total = 2;
} else {
$sign_total = 3;
}
} else {
$sign_total = 4;
}
/*
if (!$data["checker_1"] && !$data["checker_2"] && !$data["checker_3"]) $allow_st = 1;
else if (!$data["checker_2"] && !$data["checker_3"]) $allow_st = 2;
else if (!$data["checker_3"]) $allow_st = 3;
if ($data["checker_1_result"]) {
if ($data["checker_1_result"] == "Y") $checker_1_result = "通過";
else if ($data["checker_1_result"] == "N") {
$stopchk = 1;
$checker_1_result = "拒絕";
}
}
if ($data["checker_2_result"]) {
if ($data["checker_2_result"] == "Y") $checker_2_result = "通過";
else if ($data["checker_2_result"] == "N") {
$stopchk = 1;
$checker_2_result = "拒絕";
}
}
if ($data["checker_3_result"]) {
if ($data["checker_3_result"] == "Y") $checker_3_result = "通過";
else if ($data["checker_3_result"] == "N") {
$stopchk = 1;
$checker_3_result = "拒絕";
}
}
*/
/*
if ($st != $allow_st) {
mysqli_free_result($res);
mysqli_close($link);
echo "<script>";
echo "alert('請依序審核');";
echo "location.href='pricereview-index.php'";
echo "</script>";
}
*/
$mid = $data["id"];
$data["qty_total"] = 0;
$db_query = "select * from pricereview_item where mid = '$mid' order by item_group, item_no";
$res_i = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_assoc($res_i)) {
if ($row['item_group'] == "A") {
$item_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$item_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price'];
$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_ct'] = $row['item_price_ct'];
$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']]['allocate'] = $row['allocate'];
$item_arr[$row['item_no']]['gross_profit'] = $row['gross_profit'];
$item_arr[$row['item_no']]['gross_profit_rate'] = $row['gross_profit_rate'];
$item_arr[$row['item_no']]['note'] = $row['note'];
$item_arr[$row['item_no']]['mi_fix'] = $row['mi_fix'];
$data["qty_total"] += $row["item_qty"];
$sql_spec = "select sub_item_id from specsurvey_main where mid = '$mid' and pr_item_id = '" . $row['item_no'] . "' order by sub_item_id";
$res_spec = mysqli_query($link, $sql_spec);
while ($row_spec = mysqli_fetch_row($res_spec)) {
$item_arr[$row['item_no']]['sub_item_id'][] = $row_spec[0];
}
mysqli_free_result($res_spec);
} elseif ($row['item_group'] == "B") {
$option_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price'];
$option_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
$option_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp'];
$option_arr[$row['item_no']]['memo'] = $row['memo'];
$option_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec'];
} elseif ($row['item_group'] == "D") {
$mn_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$mn_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price'];
$mn_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
$mn_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp'];
$mn_arr[$row['item_no']]['note'] = $row['note'];
$mn_arr[$row['item_no']]['memo'] = $row['memo'];
$mn_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec'];
} elseif ($row['item_group'] == "E") {
$ex_arr[$row['item_no']]['item_spec'] = $row['item_spec'];
$ex_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price'];
$ex_arr[$row['item_no']]['item_qty'] = $row['item_qty'];
$ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp'];
$ex_arr[$row['item_no']]['note'] = $row['note'];
$ex_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec'];
}
}
mysqli_free_result($res_i);
$data["price_total_broken"] = $data["price_total"] - $data["price_lowest"];
$data["price_broken"] = ($data["qty_total"]) ? round($data["price_total_broken"] / $data["qty_total"], 1) : 0;
// 付款辦法
$pay_all_scale = $pay_all_amount = 0;
$sql = "select * from pricereview_pay where mid = '$mid' order by pay_kind";
$res_p = mysqli_query($link, $sql);
while ($row_p = mysqli_fetch_assoc($res_p)) {
$pay_arr[$row_p["pay_kind"]]["pay_scale"] = $row_p["pay_scale"];
$pay_arr[$row_p["pay_kind"]]["pay_amount"] = $row_p["pay_amount"];
$pay_arr[$row_p["pay_kind"]]["pay_period"] = $row_p["pay_period"];
$pay_arr[$row_p["pay_kind"]]["pay_note"] = $row_p["pay_note"];
$pay_all_scale += $row_p["pay_scale"];
$pay_all_amount += $row_p["pay_amount"];
}
mysqli_free_result($res_p);
function getMI($id)
{
$specarr = [];
$elno = [];
require_once("./conn.php");
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$price_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($price_items as $item) {
if ($item['item_group'] == "A") {
$openfn = trim(explode("-", $item['item_spec'])[2]);
$openname = "";
$speed = "";
if (str_contains($openfn, "2U")) {
$speed = str_replace("2U", "", $openfn);
$openname = "2U";
} elseif (str_contains($openfn, "4PCO")) {
$speed = str_replace("4PCO", "", $openfn);
$openname = "4PCO";
} elseif (str_contains($openfn, "6PCO")) {
$speed = str_replace("6PCO", "", $openfn);
$openname = "6PCO";
} elseif (str_contains($openfn, "2S")) {
$speed = str_replace("2S", "", $openfn);
$openname = "2S";
} elseif (str_contains($openfn, "CO")) {
$speed = str_replace("CO", "", $openfn);
$openname = "CO";
} else {
}
// specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", explode("-", $item['item_spec'])[1])[1]];
$specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", trim(explode("-", $item['item_spec'])[1]))[0], explode("*", trim(explode("-", $item['item_spec'])[1]))[1], $openname, $speed, $item['item_weight']];
$elno[] = trim("'" . explode("-", $item['item_spec'])[0] . "'");
}
}
$quotation_no = "Q2401002";
$jsonel = implode(",", $elno);
$sql_str = "SELECT * FROM elevator_mi_option WHERE elevator_type IN ($jsonel) AND quotation_no = :quotation_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':quotation_no', $quotation_no);
$stmt->execute();
$output_el_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$el_options = [];
foreach ($output_el_options as $el) {
foreach ($specarr as $spec) {
if ($el['min_weight'] == $spec['5'] && $el['min_speed'] == $spec['4']) {
$el_options[] = $el;
}
}
}
}
// getMI($id);
?>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
let total_mi = 0;
function getMI(id) {
var formdata = new FormData();
formdata.append('pa', id);
// formdata.append('user_id', <?= $user_id ?>);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText);
console.log(data);
//console.log(data);return false;
if (data.st == 'err') {
//alert(data.err);
return false;
}
// console.log(data.content);
Object.keys(data.content).forEach(function(k) {
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() == "") {
// $("#tb1").find("input[name=mi_fix]").eq(k).val(commafy(data.content[k][0]));
let a = data.content[k][0] + data.content[k][19][1];
$("#tb1").find("input[name=mi_fix]").eq(k).val(commafy(a));
}
let a = data.content[k][0] + data.content[k][19][1];
$("#tb1").find("input[name=mi_fix]").eq(k).val(commafy(a));
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>";
mihtml += "<li>工廠卸貨:" + commafy(data.content[k][3]) + "</li>";
mihtml += "<li>運輸至工地:" + commafy(data.content[k][4]) + "</li>";
mihtml += "<li>安裝成本:" + commafy(data.content[k][5]) + "</li>";
mihtml += "<li>一年免保:" + commafy(data.content[k][6]) + "</li>";
mihtml += "<li>起吊+木箱+耗材:" + commafy(data.content[k][7]) + "</li>";
//mihtml += "<li>加價:"+commafy(data.content[k][9])+"</li>";
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].replace("&lt;br&gt;", "").replace("&amp;", "").replace("amp;", "").replace("()", "").replace(/\s+/g, '') + ":" + commafy(data.content[k][14][m][1]) + "</li>";
}
});
Object.keys(data.content[k][16]).forEach(function(m) {
if (data.content[k][16][m][0] != '') {
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) {
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 += "以上合計:" + commafy(data.content[k][13]) +
"<br>";
total_mi += data.content[k][13];
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);
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; ?>');
<?php } ?>
$(":input").prop("disabled", true);
$("#checker").prop("disabled", false);
$("#status_n").prop("disabled", false);
$("#status_y").prop("disabled", false);
$("#status_yy").prop("disabled", false);
$("#id").prop("disabled", false);
$("#st").prop("disabled", false);
$('#btn_close').prop("disabled", false);
$("input[name=contractno_h]").prop("disabled", false);
$("button[name=btndownload]").prop("disabled", false);
<?php if ($sign_on) { ?>
$("input[name=pv_rate],input[name=allocate],input[name=note],textarea[name=sign_note],input[name=final_price_total]").prop("disabled", false);
<?php } ?>
$("input[name=token],input[name=item_no_all],input[name=item_price_all],input[name=pv_rate_all],input[name=allocate_all],input[name=gross_profit_all],input[name=gross_profit_rate_all],input[name=note_all],input[name=mi_fix_all]").prop("disabled", false);
//$('input[name=item_price]').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); });
//$('input[name=mi_fix]').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); });
$('#tb1').on('focus', 'tr[name=facil_templ] a', function() {
$(this).unbind().click(function() {
// 價審單序號,電梯項次,子項次
var pa = '';
pa = '<?php echo $id; ?>' + ',';
pa += $(this).closest('td').prev().find('input[name=item_no]').val() + ',';
pa += ',';
pa += $(this).closest('td').prev().find('input[name=sub_item_id]').val();
var plink = '<iframe src="specsurvey-view.php?pa=' + pa + '&noheader=1&<?php echo $token_link; ?>" width="100%" height="500" frameborder="0" title=""></iframe>';
$('.modal-footer').find('button').prop('disabled', false);
//$('.navbar').hide();
$("#specModal .modal-body").html(plink);
$("#specModal").modal('show');
});
});
$('#tb1').on('keyup', 'input[name=mi_fix]', function() {
// console.log($(this).val);
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/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, "");
$(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 = [];
$("input[name='item_no']").each(function() {
itemNoArr.push($(this).val());
})
$('#item_no_all').val(itemNoArr);
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 allocateArr = [];
$("input[name='allocate']").each(function() {
allocateArr.push($(this).val());
})
$('#allocate_all').val(allocateArr);
var grossProfitArr = [];
$("input[name='gross_profit']").each(function() {
grossProfitArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#gross_profit_all').val(grossProfitArr);
var grossProfitRateArr = [];
$("input[name='gross_profit_rate']").each(function() {
grossProfitRateArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#gross_profit_rate_all').val(grossProfitRateArr);
var noteArr = [];
$("input[name='note']").each(function() {
noteArr.push($(this).val());
})
$('#note_all').val(noteArr);
var miFixArr = [];
$("input[name='mi_fix']").each(function() {
miFixArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#mi_fix_all').val(miFixArr);
});
$('#btn_close').click(function() {
window.location.href = 'pricereview-index.php?function=pricereview&<?php echo $token_link; ?>';
});
$('#tb5').on('keyup', 'input[name=final_price_total]', function() {
$(this).val(commafy($(this).val()));
});
});
</script>
<style>
.container {
width: 1350px;
}
.nextline {
width: 100%;
height: 0;
}
.modal-dialog {
width: 1200px;
}
.modal-content {
height: 660px;
}
.dollar-right {
text-align: right;
}
hr {
border: 0;
border-bottom: 1px dashed #ccc;
background: #999;
margin: 10px 0;
}
</style>
<!--子窗:規格調查-->
<div class="modal fade" id="specModal" tabindex="-1" role="dialog" aria-labelledby="specModalTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="specModalTitle">規格調查</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
</div>
</div>
</div>
</div>
<div class="container">
<form class="form-inline" method="post" action="pricereview-record-check.php" enctype="multipart/form-data">
<input type="hidden" name="id" id="id" value="<?= $id; ?>">
<input type="hidden" name="st" id="st" value="<?= $st; ?>">
<input type="hidden" name="fromsign" value="<?php echo $fromsign; ?>">
<div class="table-responsive">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="5">整機單價</th>
<?php if ($viewmi) { ?>
<th colspan="5">業務部作業區</th>
<?php } ?>
</tr>
<tr>
<th nowrap>項次</th>
<th>規格</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<?php if ($viewmi) { ?>
<th>業務部MI</th>
<th>售價</th>
<!--<th>價審%</th>
<th>配賦(含稅)</th>-->
<th>利潤</th>
<th>利潤率(%)</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$item_amt_A_all = 0;
$idx = 1;
foreach ($item_arr as $item_no => $val) {
$item_amt_A_all += $val["item_price_bp"];
if ($viewmi) {
for ($i = 0; $i < $val["item_qty"]; $i++) {
?>
<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 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_qty" class="form-control" size="2" value="1"></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="mi_fix" class="form-control dollar-right total_mi_fix" 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 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 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">
<td colspan="5"></td>
<td colspan="4"></td>
</tr>
<?php
} #item_qty end.
} else {
?>
<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 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_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
<td><input type="text" name="item_price_bp" class="form-control dollar-right" size="9" value="<?= number_format($val["item_price_bp"]); ?>"></td>
</tr>
<?php
}
$idx++;
}
?>
<tr>
<td colspan="4">小計</td>
<td><input type="text" name="amt" id="amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_A_all); ?>"></td>
</tr>
</tbody>
</table>
</div>
<div class="nextline"></div>
<div class="table-responsive">
<table id="tb2" class="table table-bordered">
<thead>
<tr>
<th colspan="7">OPTION加價</th>
</tr>
<tr>
<th nowrap>項次</th>
<th>選配規格</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>備註</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<?php
$idx = 1;
$item_amt_B_all = 0;
$total_qty = 0;
foreach ($option_arr as $item_no => $val) {
if ($val['item_qty'] <= 0) {
continue;
}
$total_qty = $total_qty + $val['item_qty'];
$item_amt_B_all += $val["item_price_bp"];
?>
<tr>
<td><?php echo $idx; ?></td>
<td><input type="text" name="option_seat" class="form-control" size="30" value="<?= $val['item_spec']; ?>"></td>
<td><input type="text" name="option_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="option_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
<td><input type="text" name="option_price_bp" class="form-control dollar-right" size="8" value="<?= number_format($val["item_price_bp"]); ?>"></td>
<td><input type="text" name="option_memo" class="form-control" size="20" value="<?= $val["memo"]; ?>"></td>
<td><?php echo $val["option_relate_spec"]; ?></td>
</tr>
<?php
$idx++;
}
?>
<?php if ($total_qty > 0) : ?>
<tr>
<td colspan="4">小計</td>
<td colspan="3"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_B_all); ?>"></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<div class="nextline"></div>
<div class="table-responsive">
<table id="tb4" class="table table-bordered">
<thead>
<tr>
<th colspan="6">除外項目</th>
</tr>
<tr>
<th nowrap>項次</th>
<th>詢價單號</th>
<th>名稱</th>
<th>單價</th>
<th>數量</th>
<th>複價</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<?php
$item_amt_E_all = 0;
$idx = 1;
foreach ($ex_arr as $item_no => $val) {
$item_amt_E_all += $val["item_price_bp"];
?>
<tr>
<td><?php echo $idx; ?></td>
<td><input type="text" name="except_note" class="form-control" size="30" value="<?php echo $val['note']; ?>"></td>
<td><input type="text" name="except_spec" class="form-control" size="30" value="<?php echo $val['item_spec']; ?>"></td>
<td><input type="text" name="except_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="except_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
<td><input type="text" name="except_price_bp" class="form-control dollar-right" size="8" value="<?= number_format($val["item_price_bp"]); ?>"></td>
<td><?php echo $val["option_relate_spec"]; ?></td>
</tr>
<?php
$idx++;
}
?>
<tr>
<td colspan="5">小計</td>
<td><input type="text" name="ex_amt" id="ex_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_E_all); ?>"></td>
</tr>
</tbody>
</table>
</div>
<div class="nextline"></div>
<div class="table-responsive">
<table id="tb3" class="table table-bordered">
<thead>
<tr>
<th colspan="10">保固延長</th>
</tr>
<tr>
<th nowrap>項次</th>
<th>電梯</th>
<th>人乘/載重</th>
<th>停數</th>
<th>速度</th>
<th>單價</th>
<th>數量(月)</th>
<th>複價</th>
<th>備註</th>
<th>所屬電梯項次</th>
</tr>
</thead>
<tbody>
<?php
$item_amt_D_all = 0;
$idx = 1;
foreach ($mn_arr as $item_no => $val) {
$item_amt_D_all += $val["item_price_bp"];
if (!empty($val["note"])) list($mn_seat, $mn_numberofstop, $mn_speed) = explode(",", $val["note"]);
else $mn_seat = $mn_numberofstop = $mn_speed = "";
?>
<tr>
<td><?php echo $idx; ?></td>
<td><input type="text" name="mk_kind" class="form-control" value="<?php echo $val['item_spec']; ?>"></td>
<td><input type="text" name="mn_seat" class="form-control" size="6" value="<?php echo $mn_seat; ?>"></td>
<td><input type="text" name="mn_numberofstop" class="form-control" size="6" value="<?php echo $mn_numberofstop; ?>"></td>
<td><input type="text" name="mn_speed" class="form-control" size="6" value="<?php echo $mn_speed; ?>"></td>
<td><input type="text" name="mn_unit_price" class="form-control dollar-right" size="8" value="<?= number_format($val["item_unit_price"]); ?>"></td>
<td><input type="text" name="mn_qty" class="form-control" size="2" value="<?= number_format($val["item_qty"]); ?>"></td>
<td><input type="text" name="mn_price_bp" class="form-control dollar-right" size="8" value="<?= number_format($val["item_price_bp"]); ?>"></td>
<td><input type="text" name="mn_memo" class="form-control" size="20" value="<?= $val["memo"]; ?>"></td>
<td><?php echo $val["option_relate_spec"]; ?></td>
</tr>
<?php
$idx++;
}
?>
<tr>
<td colspan="7">小計</td>
<td><input type="text" name="mn_amt" id="mn_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_D_all); ?>"></td>
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="nextline"></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" value="<?= number_format($data["qty_total"]); ?>"></td>
<td><label>B/P(含稅)</label></td>
<td><input type="text" id="amt" value="<?= number_format($data["price_lowest"]); ?>"></td>
</tr>
</tbody>
</table>-->
<table class="table table-bordered">
<thead>
<tr>
<th>付款辦法</th>
<th>款別</th>
<th>比例%</th>
<th>金額</th>
<th>票期</th>
<!--<th>批示比例</th>-->
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4">材料</td>
<td>1、訂金<input type="hidden" name="pay_kind" value="1"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[1]['pay_scale'])) ? $pay_arr[1]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay1"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[1]['pay_amount'])) ? number_format($pay_arr[1]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[1]["pay_period"]) && $pay_arr[1]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td>2、二次款<input type="hidden" name="pay_kind" value="2"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[2]['pay_scale'])) ? $pay_arr[2]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay2"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[2]['pay_amount'])) ? number_format($pay_arr[2]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[2]["pay_period"]) && $pay_arr[2]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td>3、貨到工地款<input type="hidden" name="pay_kind" value="3"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[3]['pay_scale'])) ? $pay_arr[3]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay3"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[3]['pay_amount'])) ? number_format($pay_arr[3]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[3]["pay_period"]) && $pay_arr[3]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td>4、其它<input type="hidden" name="pay_kind" value="4"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[4]['pay_scale'])) ? $pay_arr[4]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay4"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[4]['pay_amount'])) ? number_format($pay_arr[4]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[4]["pay_period"]) && $pay_arr[4]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td rowspan="3">安裝</td>
<td>5、安裝完畢款<input type="hidden" name="pay_kind" value="5"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[5]['pay_scale'])) ? $pay_arr[5]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay5"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[5]['pay_amount'])) ? number_format($pay_arr[5]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[5]["pay_period"]) && $pay_arr[5]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td>6、驗收款<input type="hidden" name="pay_kind" value="6"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[6]['pay_scale'])) ? $pay_arr[6]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay6"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[6]['pay_amount'])) ? number_format($pay_arr[6]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[6]["pay_period"]) && $pay_arr[6]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td>7、其它<input type="hidden" name="pay_kind" value="7"></td>
<td><input type="text" name="pay_scale" value="<?php echo (isset($pay_arr[7]['pay_scale'])) ? $pay_arr[7]['pay_scale'] : 0; ?>" class="form-control" size="3"></td>
<td id="pay7"><input type="text" name="pay_amount" value="<?php echo (isset($pay_arr[7]['pay_amount'])) ? number_format($pay_arr[7]['pay_amount']) : 0; ?>" class="form-control dollar-right" size="8"></td>
<td>
<select name="pay_period" class="form-control">
<option value=""></option>
<option value="7" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "7") echo " selected"; ?>>7天</option>
<option value="30" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "30") echo " selected"; ?>>30天</option>
<option value="60" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "60") echo " selected"; ?>>60天</option>
<option value="90" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "90") echo " selected"; ?>>90天</option>
<option value="120" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "120") echo " selected"; ?>>120天</option>
<option value="180" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "180") echo " selected"; ?>>180天</option>
<option value="other" <?php if (isset($pay_arr[7]["pay_period"]) && $pay_arr[7]["pay_period"] == "other") echo " selected"; ?>>其它</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">合計</td>
<td><input type="text" class="form-control" size="3" value="<?php echo $pay_all_scale; ?>"></td>
<td><input type="text" id="pay_all_amount" name="pay_all_amount" value="<?php echo number_format($pay_all_amount); ?>" class="form-control dollar-right" size="8"></td>
<td></td>
</tr>
<tr>
<td colspan="2">備註</td>
<td colspan="3"><textarea name="pay_note" id="pay_note" rows="6" cols="70" class="form-control"><?php echo $pay_arr[1]["pay_note"]; ?></textarea></td>
</tr>
</tbody>
</table>
</div>
<div class="nextline"></div>
<div>
<label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" maxlength="7" value="<?= $data["contractno"]; ?>">
</div>
<div>
<label for="person">營業員</label>
<input type="text" name="person" id="person" value="<?= accountid2name($data["person"])[$data["person"]]; ?>">
</div>
<div>
<label for="company">客戶名稱</label>
<input type="text" name="company" id="company" value="<?= $data["company"]; ?>">
</div>
<div>
<label for="case_name">案件名稱</label>
<input type="text" name="case_name" id="case_name" value="<?= $data["case_name"]; ?>">
</div>
<div>
<label for="address">地址</label>
<input type="text" name="address" id="address" value="<?= $data["address"]; ?>" size="46">
</div>
<div>
<label for="price_lowest">牌價總額(A)</label>
<input type="text" name="price_lowest" id="price_lowest" class="dollar-right" value="<?= number_format($data["price_lowest"]); ?>">
</div>
<div>
<label for="price_total">售價總額(B)</label>
<input type="text" name="price_total" id="price_total" class="dollar-right" value="<?= number_format($data["price_total"]); ?>">
</div>
<div>
<label for="price_total_broken">破價總額(B-A)</label>
<input type="text" name="price_total_broken" id="price_total_broken" class="dollar-right" value="<?= number_format($data["price_total_broken"]); ?>">
</div>
<div>
<label for="qty_total">總台數</label>
<input type="text" name="qty_total" id="qty_total" value="<?= number_format($data["qty_total"]); ?>">
</div>
<div>
<label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>">
</div>
<div>
<label for="price_rate">價率%(B/A)</label>
<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>
<input type="text" name="price_broken" id="price_broken" class="dollar-right" value="<?= number_format($data["price_broken"]); ?>">
</div>
<div>
<label for="predeal_date">預定成交日</label><br>
<input type="date" name="predeal_date" id="predeal_date" value="<?= $data["predeal_date"]; ?>">
</div>
<div>
<label for="facilitok_date">預定出貨日</label><br>
<input type="date" name="facilitok_date" id="facilitok_date" value="<?= $data["facilitok_date"]; ?>">
</div>
<div class="nextline"></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="6" cols="100" class="form-control"><?= $data["memo"]; ?></textarea></td>
</tr>
</tbody>
</table>
<ul style="display:block">
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。</li>
</ul>
</div>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>審核</th>
<th>審核人</th>
<th>結果</th>
<th>意見</th>
<th>時間</th>
</tr>
</thead>
<tbody>
<tr>
<td>區經理</td>
<td><?php echo (empty($accountname_arr[$person1])) ? "---" : $accountname_arr[$person1]; ?></td>
<td><?php echo $checker_1_result; ?></td>
<td><?php echo nl2br($sign1_note); ?></td>
<td><?php echo $dtte1; ?></td>
</tr>
<tr>
<td>業務承辦人</td>
<td>
<?php
if (empty($person2_arr)) {
echo (empty($accountname_arr[$person2])) ? "---" : $accountname_arr[$person2];
} else {
$person2_name_str = "";
foreach ($person2_arr as $pv) {
$person2_name_str .= $accountname_arr[$pv] . "/";
}
echo rtrim($person2_name_str, "/");
}
?>
</td>
<td><?php echo $checker_2_result; ?></td>
<td><?php echo nl2br($sign2_note); ?></td>
<td><?php echo $dtte2; ?></td>
</tr>
<tr>
<td>業務部協理</td>
<td><?php echo (empty($accountname_arr[$person3])) ? "---" : $accountname_arr[$person3]; ?></td>
<td><?php echo $checker_3_result; ?></td>
<td><?php echo nl2br($sign3_note); ?></td>
<td><?php echo $dtte3; ?></td>
</tr>
<tr>
<td>總經理</td>
<td><?php echo (empty($accountname_arr[$person4])) ? "---" : $accountname_arr[$person4]; ?></td>
<td><?php echo $checker_4_result; ?></td>
<td><?php echo nl2br($sign4_note); ?></td>
<td><?php echo $dtte4; ?></td>
</tr>
</tbody>
</table>
<?php if ($sign_on) { ?>
<table id="tb5" class="table table-bordered">
<thead>
<tr>
<th>審核意見</th>
<th>批示售價</th>
</tr>
</thead>
<tbody>
<tr>
<td><textarea name="sign_note" id="sign_note" rows="6" cols="60" class="form-control"></textarea></td>
<td><input type="text" name="final_price_total" id="final_price_total" class="dollar-right" <?php if ($user_id != "M0006") {
echo " readonly";
} ?>></td>
</tr>
</tbody>
</table>
<label>審核人員</label>
<input type="text" name="checker" id="checker" value="<?= $user_id; ?>" readonly>
<button type="submit" name="status" id="status_n" value="N" onclick="if (!confirm('確定不同意?')) return false;"><?php echo ($sign_total == $st) ? "結案(不同意)" : "不同意(退回)"; ?></button>
<button type="submit" name="status" id="status_y" value="Y" onclick="if (!confirm('確定同意?')) return false;">同意(上呈)</button>
<?php if ($st == 3 || $st == 4) : ?>
<button type="submit" name="status" id="status_yy" value="YY" onclick="if (!confirm('確定同意?')) return false;">同意(結案)</button>
<?php endif; ?>
<?php } else { ?>
<button type="button" id="btn_close" class="btn btn-default">回上頁</button>
<?php } ?>
<?php
if (empty($data["attatch1"])) $price_dn_str = "alert('無檔案!');";
else $price_dn_str = "window.open('" . $data["attatch1"] . "');";
if (empty($data["attatch2"])) $appendix_dn_str = "alert('無檔案!');";
else $appendix_dn_str = "window.open('" . $data["attatch2"] . "');";
?>
<button type="button" name="btndownload" onclick="<?php echo $price_dn_str; ?>">下載報價單</button>
<button type="button" name="btndownload" onclick="<?php echo $appendix_dn_str; ?>">下載附表一</button>
</div>
<input type="hidden" name="item_no_all" id="item_no_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="allocate_all" id="allocate_all">
<input type="hidden" name="gross_profit_all" id="gross_profit_all">
<input type="hidden" name="gross_profit_rate_all" id="gross_profit_rate_all">
<input type="hidden" name="note_all" id="note_all">
<input type="hidden" name="mi_fix_all" id="mi_fix_all">
<input type="hidden" name="contractno_h" id="contractno_h" value="<?php echo $data["contractno"]; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
}
mysqli_free_result($res);
mysqli_close($link);
include "../footer.php";
?>
<script>
console.log("------", document.getElementById('mi_fix_all').value);
</script>