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.
171 lines
7.3 KiB
171 lines
7.3 KiB
<?php
|
|
include "header.php";
|
|
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
|
|
|
|
$data = $item_arr = $account_arr = [];
|
|
$kind_arr = ["A" => "機房", "B" => "車廂", "C" => "井道層場", "D" => "運行", "E" => "其它"];
|
|
$maintainance_arr = ["A" => "全包", "B" => "半包", "C" => "清包", "D" => "2個月保養一次"];
|
|
|
|
$db_query = "select * from schedule_check c where id = $id";
|
|
$data = mysqli_query($link, $db_query);
|
|
|
|
$db_query = "select * from schedule_check_item 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);
|
|
|
|
foreach($data as $data) :
|
|
$record_arr = json_decode($data["record"], true);
|
|
$sql = "select c.company, f.maintainance, f.facility_kind, f.takecertificatedate, f.repairerid from facility f, contract c where f.facilityno = '".$data["facilityno"]."' and f.contractno = c.contractno";
|
|
$res = mysqli_query($link, $sql);
|
|
$row = mysqli_fetch_array($res);
|
|
mysqli_free_result($res);
|
|
?>
|
|
<style>
|
|
#tb1 th,td:not(.desc){
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<script>
|
|
$(function() {
|
|
if ($('td[name=total_score]').html() == '' || $('td[name=total_score]').html() == 0) $('td[name=total_score]').html('100'); // default
|
|
|
|
$('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);
|
|
});
|
|
});
|
|
$('#update').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">
|
|
<form class="form-inline" method="post" action="schedule_check-record-update.php" enctype="multipart/form-data">
|
|
<input type="hidden" name="id" value="<?php echo $id; ?>">
|
|
<div>
|
|
<label for="facilityno">電梯ID</label>
|
|
<input type="text" name="facilityno" id="facilityno" value="<?php echo $data["facilityno"]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="check_date">抽查日期</label><br>
|
|
<input type="text" name="check_date" id="check_date" value="<?php echo $data["check_date"]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="address">現場名稱</label>
|
|
<input type="text" name="address" id="address" value="<?php echo $row["company"]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="combo_type">保養別</label>
|
|
<input type="text" name="combo_type" id="combo_type" value="<?php echo $maintainance_arr[$row["maintainance"]]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="facility_kind">機型</label>
|
|
<input type="text" name="facility_kind" id="facility_kind" value="<?php echo $row["facility_kind"]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="takecertificatedate">交車日期</label><br>
|
|
<input type="text" name="takecertificatedate" id="takecertificatedate" value="<?php echo $row["takecertificatedate"]; ?>" readonly>
|
|
</div>
|
|
<div>
|
|
<label for="repairerid">保養人員</label>
|
|
<input type="text" name="repairerid" id="repairerid" value="<?php echo $account_arr[$row["repairerid"]]; ?>" readonly>
|
|
</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);
|
|
if (!$record_arr) {
|
|
$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>";
|
|
}
|
|
} else {
|
|
foreach ($opt_arr as $key => $val) {
|
|
echo "<option value=\"".$k."-".$kk."-".$key."\"";
|
|
$no = str_pad($kk, 2, "0", STR_PAD_LEFT);
|
|
if ($record_arr[$k][$no] == $key) echo " selected";
|
|
echo ">".$val."</option>";
|
|
}
|
|
}
|
|
?>
|
|
</td>
|
|
<td name="td_score"><?php if (!$record_arr) echo $okey_first; else echo $record_arr[$k][$no]; ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td><label for="memo">備註</label></td>
|
|
<td colspan="3"><textarea name="memo" id="memo" rows="8" style="min-width: 100%"><?php echo $data["memo"]; ?></textarea></td>
|
|
<td>合計</td>
|
|
<td name="total_score"><?php echo $data["score"]; ?></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
<button type="submit" name="update" id="update">確定</button>
|
|
</div>
|
|
<input type="hidden" name="sel_option_all" id="sel_option_all">
|
|
<input type="hidden" name="db_total_score" id="db_total_score">
|
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
|
</form>
|
|
</div>
|
|
<?php
|
|
endforeach;
|
|
include "footer.php";
|
|
?>
|