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.
 
 
 
 
 
 

375 lines
19 KiB

<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
$category_arr = ["A" => "生產設備", "B" => "建築工程類", "C" => "工業工程規劃", "D" => "修繕維保服務", "E" => "儀器設備", "F" => "辦公設備", "G" => "辦公家具", "H" => "IT類產品", "I" => "諮詢服務", "J" => "維保電梯配件"];
$db_query = "select * from bargain where id = '$id'";
$data = mysqli_query($link, $db_query);
$department_arr = [];
$sql = "select department_id, name from department";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_row($res)) {
$department_arr[$row[0]] = $row[1];
}
mysqli_free_result($res);
foreach($data as $data) :
$sql = "select name from account where accountid = '".$data['creater']."'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($creater_name) = $row;
mysqli_free_result($res);
$item_arr = [];
$sql = "select * from bargain_supplier where bid = '$id' order by supplier_id";
$res = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($res)) {
$item_arr[$row['supplier_id']]['id'] = $row['id'];
$item_arr[$row['supplier_id']]['supplier'] = $row['supplier'];
$item_arr[$row['supplier_id']]['supplier_attatch_be'] = $row['supplier_attatch_be'];
$item_arr[$row['supplier_id']]['quote_amt_be'] = $row['quote_amt_be'];
$item_arr[$row['supplier_id']]['note_be'] = $row['note_be'];
$item_arr[$row['supplier_id']]['supplier_attatch_ar'] = $row['supplier_attatch_ar'];
$item_arr[$row['supplier_id']]['quote_amt_ar'] = $row['quote_amt_ar'];
$item_arr[$row['supplier_id']]['note_ar'] = $row['note_ar'];
}
mysqli_free_result($res);
?>
<style>
</style>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
$(function(){
$('#quantity').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#lead_time').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$('#margin_day').keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); })
$("input[name=quote_amt_be]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$("input[name=quote_amt_ar]").each(function(){
$(this).keyup(function(){ $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); });
});
$('#btnadd').click(function(){
if ($('tr[name=supplier_templ]').is(':visible') == false) $('tr[name=supplier_templ]').show();
else {
$('#tb1 tr:last').prev().after($("tr[name='supplier_templ']").eq(0).clone().find('input').val('').end());
//$('#tb1 tr:last').find('td').first().html($("tr[name='supplier_templ']").length);
}
});
$('#update').click(function(){
var bsidArr = [];
$("input[name='bsid']").each(function(){ bsidArr.push($(this).val()); })
$('#bsid_all').val(bsidArr);
var supIdArr = [];
$("input[name='sup_id']").each(function(){ supIdArr.push($(this).val()); })
$('#sup_id_all').val(supIdArr);
var supplierArr = [];
$("input[name='supplier']").each(function(){ supplierArr.push($(this).val()); })
$('#supplier_all').val(supplierArr);
var supplierAttatchBeAllArr = [];
$("input[name='supplier_attatch_be']").each(function(){ supplierAttatchBeAllArr.push($(this).val()); })
$('#supplier_attatch_be_all').val(supplierAttatchBeAllArr);
var quoteAmtBeArr = [];
$("input[name='quote_amt_be']").each(function(){ quoteAmtBeArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_be_all').val(quoteAmtBeArr);
var noteBeArr = [];
$("input[name='note_be']").each(function(){ noteBeArr.push($(this).val()); })
$('#note_be_all').val(noteBeArr);
var supplierAttatchArArr = [];
$("input[name='supplier_attatch_ar']").each(function(){ supplierAttatchArArr.push($(this).val()); })
$('#supplier_attatch_ar_all').val(supplierAttatchArArr);
var quoteAmtArArr = [];
$("input[name='quote_amt_ar']").each(function(){ quoteAmtArArr.push($(this).val().replace(/[,]+/g,"")); })
$('#quote_amt_ar_all').val(quoteAmtArArr);
var noteArArr = [];
$("input[name='note_ar']").each(function(){ noteArArr.push($(this).val()); })
$('#note_ar_all').val(noteArArr);
//console.log(noteArArr);
//return false;
});
});
</script>
<div class="container">
<form class="form-inline" method="post" action="bargain-record-update.php" enctype="multipart/form-data">
<div>
<label for="bargainno">申請單號</label>
<input type="text" name="bargainno" id="bargainno" value="<?php echo $data['bargainno']; ?>" readonly>
</div>
<div>
<label for="department">作成單位</label>
<input type="text" name="department" id="department" value="<?php echo $department_arr[$data['department_id']]; ?>" disabled>
<input type="hidden" name="department_id" id="department_id" value="<?php echo $data['department_id']; ?>">
</div>
<div>
<label for="proposer">作成者</label>
<input type="text" name="proposer" id="proposer" value="<?php echo $creater_name; ?>" disabled>
</div>
<div>
<label for="receiver">收文單位</label>
<select name="receiver" id="receiver" required>
<option value="">請選擇</option>
<?php
foreach ($department_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["receiver"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="response_dt">回答期限</label><br>
<input type="date" name="response_dt" id="response_dt" value="<?php echo $data['response_dt']; ?>" required>
</div>
<div>
<label for="item">項目名稱</label>
<input type="text" name="item" id="item" size="60" maxlength="50" value="<?php echo $data['item']; ?>" required>
</div>
<div>
<label for="annual">年度議價件</label>
<select name="annual" id="annual">
<option value="Y"<?php if ($data['annual']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['annual']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="urgent">緊急件</label>
<select name="urgent" id="urgent">
<option value="Y"<?php if ($data['urgent']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['urgent']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="vendor">指定廠商</label>
<select name="vendor" id="vendor">
<option value="Y"<?php if ($data['vendor']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['vendor']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="prospecting">現場勘查</label>
<select name="prospecting" id="prospecting">
<option value="Y"<?php if ($data['prospecting']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['prospecting']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="category">類別</label>
<select name="category" id="category" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="dealer">原廠或原代理商</label>
<select name="dealer" id="dealer" required>
<option value="Y"<?php if ($data['dealer']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['dealer']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="reason">理由</label>
<input type="text" name="reason" id="reason" size="60" maxlength="50" value="<?php echo $data['reason']; ?>">
</div>
<div>
<label for="brand">品牌</label>
<input type="text" name="brand" id="brand" maxlength="25" value="<?php echo $data['brand']; ?>">
</div>
<div>
<label for="model">型號</label>
<input type="text" name="model" id="model" maxlength="25" value="<?php echo $data['model']; ?>">
</div>
<div>
<label for="quantity">預估數量</label>
<input type="text" name="quantity" id="quantity" value="<?php echo number_format($data['quantity']); ?>" required>
</div>
<div>
<label for="brandkeep">備選品牌</label>
<input type="text" name="brandkeep" id="brandkeep" size="60" maxlength="25" value="<?php echo $data['brandkeep']; ?>">
</div>
<div>
<label for="lead_time">交期/施工期(天)</label>
<input type="text" name="lead_time" id="lead_time" value="<?php echo number_format($data['lead_time']); ?>">
</div>
<div>
<label for="margin">質保金</label>
<select name="margin" id="margin">
<option value="Y"<?php if ($data['margin']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['margin']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="margin_day">質保期限(天)</label>
<input type="text" name="margin_day" id="margin_day" value="<?php echo number_format($data['margin_day']); ?>" required>
</div>
<div>
<label for="acceptance">驗收標準</label>
<input type="text" name="acceptance" id="acceptance" size="104" maxlength="50" value="<?php echo $data['acceptance']; ?>">
</div>
<div>
<label for="purchase_history">歷史購買記錄</label>
<select name="purchase_history" id="purchase_history">
<option value="Y"<?php if ($data['purchase_history']=="Y") echo " selected"; ?>>是</option>
<option value="N"<?php if ($data['purchase_history']=="N") echo " selected"; ?>>否</option>
</select>
</div>
<div>
<label for="attatch1">附件1</label>
<?php
if ($data["attatch1"]) echo "<a href=\"".$data["attatch1"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch1" id="attatch1">
</div>
</div>
<div>
<label for="attatch2">附件2</label>
<?php
if ($data["attatch2"]) echo "<a href=\"".$data["attatch2"]."\" target=\"_blank\" style=\"font-size:13px;\">".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)."</a>";
?>
<div>
<input type="file" name="attatch2" id="attatch2">
</div>
</div>
<div>
<label for="item_description">項目描述</label>
<input type="text" name="item_description" id="item_description" size="80" maxlength="120" value="<?php echo $data['item_description']; ?>">
</div>
<div>
<label for="repairno">設備維修單號</label>
<input type="text" name="repairno" id="repairno" maxlength="20" value="<?php echo $data['repairno']; ?>">
</div>
<div>
<label for="category_repair">類別</label>
<select name="category_repair" id="category_repair" required>
<option value="">請選擇</option>
<?php
foreach ($category_arr as $k => $v) {
echo "<option value=\"".$k."\"";
if ($data["category_repair"] == $k) echo " selected";
echo ">".$v."</option>";
}
?>
</select>
</div>
<div>
<label for="content">內容</label><br>
<textarea class="form-control2" name="content" id="content" rows="4" cols="100"><?php echo $data['content']; ?></textarea>
</div>
<div>
<label for="quotation">採購報價單</label>
<input type="text" name="quotation" id="quotation" value="<?php echo $data['quotation']; ?>" readonly>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th colspan="8"><h4>附件上傳及信息維護</h4></th>
</tr>
<tr>
<th rowspan="2" nowrap>序號</th>
<th colspan="4">作成單位提供◎維護信息</th>
<th colspan="3">配合單位提供◎維護信息</th>
</tr>
<tr>
<th nowrap>供應商名稱</th>
<th nowrap>供應商報價單上傳</th>
<th nowrap>報價</th>
<th nowrap>備註</th>
<th nowrap>議價後報價單上傳</th>
<th nowrap>議價後報價</th>
<th nowrap>備註</th>
</tr>
</thead>
<tbody>
<?php
foreach ($item_arr as $supplier_id => $val) {
?>
<tr>
<td><?php echo $supplier_id; ?><input type="hidden" name="sup_id" value="<?php echo $supplier_id; ?>"><input type="hidden" name="bsid" value="<?php echo $val['id']; ?>"></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10" value="<?php echo $val['supplier']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_be']) echo "<a href=\"".$val['supplier_attatch_be']."\" target=\"_blank\">".substr($val['supplier_attatch_be'], strrpos($val['supplier_attatch_be'],"/")+1)."</a>";
else echo "--";
?>
</td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_be']); ?>"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10" value="<?php echo $val['note_be']; ?>"></td>
<td>
<?php
if ($val['supplier_attatch_ar']) echo "<a href=\"".$val['supplier_attatch_ar']."\" target=\"_blank\">".substr($val['supplier_attatch_ar'], strrpos($val['supplier_attatch_ar'],"/")+1)."</a>";
else echo "--";
?>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3" value="<?php echo number_format($val['quote_amt_ar']); ?>"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10" value="<?php echo $val['note_ar']; ?>"></td>
</tr>
<?php
}
?>
<tr name="supplier_templ" style="display:none;">
<td></td>
<td><input type="text" name="supplier" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_be[]" multiple></td>
<td><input type="text" name="quote_amt_be" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_be" class="form-control input-sm" size="10"></td>
<td><input type="file" name="supplier_attatch_ar[]" multiple></td>
<td><input type="text" name="quote_amt_ar" class="form-control input-sm" size="3"></td>
<td><input type="text" name="note_ar" class="form-control input-sm" size="10"><input type="hidden" name="sup_id"></td>
</tr>
</tr>
<td colspan="8"><button type="button" id="btnadd" class="btn btn-primary btn-sm" style="float:left;">+供應商</button></td>
</tr>
</tbody>
</table>
</div>
<div>
<!-- <label for="create_at">create_at</label> -->
<input type="hidden" name="create_at" id="create_at" value="<?php echo date("Y-m-d H:i:s"); ?>">
<p class="error"><?php echo $create_at_error; ?></p>
</div>
<div>
<br>
<button type="submit" name="update" id="update">確定</button>
</div>
<input type="hidden" name="bsid_all" id="bsid_all">
<input type="hidden" name="sup_id_all" id="sup_id_all">
<input type="hidden" name="supplier_all" id="supplier_all">
<input type="hidden" name="supplier_attatch_be_all" id="supplier_attatch_be_all">
<input type="hidden" name="quote_amt_be_all" id="quote_amt_be_all">
<input type="hidden" name="note_be_all" id="note_be_all">
<input type="hidden" name="supplier_attatch_ar_all" id="supplier_attatch_ar_all">
<input type="hidden" name="quote_amt_ar_all" id="quote_amt_ar_all">
<input type="hidden" name="note_ar_all" id="note_ar_all">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>
</div>
<?php
endforeach;
include "footer.php";
?>