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.
189 lines
7.1 KiB
189 lines
7.1 KiB
<?php
|
|
require_once "database.php";
|
|
include "header.php";
|
|
|
|
$item_arr = $account_arr = [];
|
|
$kind_arr = ["A" => "機房", "B" => "車廂", "C" => "井道層場", "D" => "運行", "E" => "其它"];
|
|
|
|
$db_query = "select * from schedule_check_item where status = 'Y' order by item_no";
|
|
$res = mysqli_query($link, $db_query);
|
|
while ($row = mysqli_fetch_array($res)) {
|
|
$key1 = $row["item_no"][0];
|
|
$key2 = str_replace("0", "", substr($row["item_no"], -2));
|
|
$item_arr[$key1][$key2]["title"] = $row["item_title"];
|
|
$item_arr[$key1][$key2]["option"] = $row["item_option"];
|
|
$item_arr[$key1][$key2]["score"] = $row["top_score"];
|
|
}
|
|
mysqli_free_result($res);
|
|
|
|
$db_query = "select accountid, name from account where accounttype = 'B' order by id";
|
|
$res = mysqli_query($link, $db_query);
|
|
while ($row = mysqli_fetch_array($res)) {
|
|
$account_arr[$row["accountid"]] = $row["name"];
|
|
}
|
|
mysqli_free_result($res);
|
|
?>
|
|
<style>
|
|
#tb1 th,td:not(.desc){
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<script>
|
|
$(function() {
|
|
$('#facilityno').keyup(function(){
|
|
if ($(this).val().length >=8) {
|
|
var formdata = new FormData();
|
|
formdata.append('fno', $(this).val());
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function(){
|
|
if(this.readyState == 4 && this.status == 200){
|
|
data = JSON.parse(this.responseText);
|
|
$('.form-inline input[name=address]').val(data.addr);
|
|
$('.form-inline select[name=repairerid]').val(data.rid);
|
|
$('.form-inline select[name=facility_kind]').val(data.kind);
|
|
}
|
|
}
|
|
xhr.open('POST', '/wms/schedule_check-facility.php', true);
|
|
xhr.send(formdata);
|
|
} else {
|
|
$('.form-inline input[name=address]').val('');
|
|
$('.form-inline select[name=repairerid]').val('');
|
|
$('.form-inline select[name=facility_kind]').val('');
|
|
}
|
|
});
|
|
$('select[name=sel_option]').change(function(){
|
|
var totalScore = 0;
|
|
var valArr = $(this).val().split("-");
|
|
$(this).parent().parent().find('td[name=td_score]').html(valArr[2]);
|
|
$('td[name=td_score]').each(function(){
|
|
totalScore += Number($(this).html());
|
|
$(this).parent().parent().find('td[name=total_score]').html(totalScore);
|
|
});
|
|
});
|
|
$('#submit').click(function(){
|
|
var selOptionArr = [];
|
|
$("select[name='sel_option']").each(function(){ selOptionArr.push($(this).val()); })
|
|
$('#sel_option_all').val(selOptionArr);
|
|
$('#db_total_score').val($('td[name=total_score]').html());
|
|
});
|
|
});
|
|
</script>
|
|
<div class="container">
|
|
<?php
|
|
include "schedule_check-record-submit.php";
|
|
?>
|
|
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
|
|
<div>
|
|
<label for="facilityno">電梯ID</label>
|
|
<input type="text" name="facilityno" id="facilityno" required>
|
|
</div>
|
|
<div>
|
|
<label for="check_date">抽查日期</label><br>
|
|
<input type="date" name="check_date" id="check_date" required>
|
|
</div>
|
|
<div>
|
|
<label for="address">現場名稱</label>
|
|
<input type="text" name="address" id="address">
|
|
</div>
|
|
<div>
|
|
<label for="combo_type">保養別</label>
|
|
<select name="combo_type" id="combo_type">
|
|
<option value="">請選擇</option>
|
|
<option value="1">全責</option>
|
|
<option value="2">半責</option>
|
|
<option value="3">清包</option>
|
|
<option value="9">其它</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="facility_kind">機型</label>
|
|
<select name="facility_kind" id="facility_kind">
|
|
<option value="">請選擇</option>
|
|
<option value="MAE100">MAE100小機房</option>
|
|
<option value="MAM200">MAM200無機房</option>
|
|
<option value="MAH100">MAH100小電梯</option>
|
|
<option value="MAQ100">MAQ100強驅家用</option>
|
|
<option value="MAF100">MAF100貨梯</option>
|
|
<option value="MAZ100">MAZ100雜物梯</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="facilitok_date">交車日期</label><br>
|
|
<input type="date" name="facilitok_date" id="facilitok_date">
|
|
</div>
|
|
<div>
|
|
<label for="repairerid">保養人員</label>
|
|
<select name="repairerid" id="repairerid">
|
|
<option value="">請選擇</option>
|
|
<?php
|
|
foreach ($account_arr as $k => $v) {
|
|
echo "<option value=\"".$k."\">".$v."</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="table-responsive" style="width:100%;margin-top:10px;">
|
|
<table id="tb1" class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th colspan="6">抽查項目明细與記錄</th>
|
|
</tr>
|
|
<tr>
|
|
<th>部位</th>
|
|
<th>NO.</th>
|
|
<th>抽查項目</th>
|
|
<th>滿分</th>
|
|
<th>記錄</th>
|
|
<th>得分</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach ($item_arr as $k => $v) {
|
|
$cnt = count($v);
|
|
$key_first = array_key_first($v);
|
|
foreach ($v as $kk => $vv) {
|
|
?>
|
|
<tr>
|
|
<?php
|
|
if ($key_first == $kk) echo "<td rowspan=\"".$cnt."\">".$kind_arr[$k]."</td>";
|
|
?>
|
|
<td><?php echo $kk; ?></td>
|
|
<td class="desc"><?php echo $vv["title"]; ?></td>
|
|
<td><?php echo $vv["score"]; ?></td>
|
|
<td>
|
|
<select name="sel_option">
|
|
<?php
|
|
$opt_arr = json_decode($vv["option"], true);
|
|
$okey_first = array_key_first($opt_arr);
|
|
foreach ($opt_arr as $key => $val) {
|
|
echo "<option value=\"".$k."-".$kk."-".$key."\"";
|
|
if ($okey_first == $key) echo " selected";
|
|
echo ">".$val."</option>";
|
|
}
|
|
?>
|
|
</td>
|
|
<td name="td_score"><?php echo $okey_first; ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td><label for="memo">備註</label></td>
|
|
<td colspan="3"><textarea name="memo" id="memo" rows="8" style="min-width: 100%"></textarea></td>
|
|
<td>合計</td>
|
|
<td name="total_score">100</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
<button type="submit" name="submit" id="submit">確定</button>
|
|
</div>
|
|
<input type="hidden" name="sel_option_all" id="sel_option_all">
|
|
<input type="hidden" name="db_total_score" id="db_total_score">
|
|
</form>
|
|
</div>
|
|
<?php include "footer.php"; ?>
|