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.
265 lines
9.6 KiB
265 lines
9.6 KiB
<?php
|
|
include "../header.php";
|
|
|
|
// 員工編號對應姓名表
|
|
$accountname_arr = accountid2name();
|
|
|
|
$psta_arr = ["A" => "簽核中", "B1" => "已同意", "B2" => "已完工", "X" => "不同意"];
|
|
|
|
// 設置一個空陣列來放資料
|
|
$data = array();
|
|
// sql語法存在變數中
|
|
$sql_cmd = "where (repairerid = '$user_id' or checker = '$user_id')";
|
|
$is_manager = 0;
|
|
// 宜:M0054-陳志文
|
|
// 北:M0137-劉永德
|
|
// 桃:M0026-張莉凱
|
|
// 中:M0086-李烘銘
|
|
// 南:M0033-吳育宗
|
|
$manager_arr = ["M0054", "M0137", "M0026", "M0086", "M0033"];
|
|
if (in_array($user_id, $manager_arr)) $is_manager = 1;
|
|
|
|
if ($user_id == "M0012") $sql_cmd = "";
|
|
$sql = "select * from pricereview_repair_main $sql_cmd order by id";
|
|
$data = mysqli_query($link,$sql);
|
|
$para = "function_name=pricereview_repair&".$token_link;
|
|
?>
|
|
<style>
|
|
#table_index_filter{
|
|
float:right;
|
|
}
|
|
#table_index_paginate{
|
|
float:right;
|
|
}
|
|
div.dataTables_scrollHead table.dataTable {
|
|
margin-bottom: 0 !important;
|
|
border-bottom-width: 0;
|
|
}
|
|
div.dataTables_scrollBody table.dataTable {
|
|
border-top-width: 0;
|
|
}
|
|
label {
|
|
display: inline-flex;
|
|
margin-bottom: .5rem;
|
|
margin-top: .5rem;
|
|
}
|
|
div a:hover {
|
|
text-decoration:none;
|
|
}
|
|
.btn-sm {
|
|
font-size:14px;
|
|
margin: 2px 0;
|
|
line-height: 90%;
|
|
}
|
|
.glyphicon-ok, .glyphicon-ban-circle {
|
|
font-size:130%;
|
|
}
|
|
.btn-secondary {
|
|
color: #fff;
|
|
background-color: #6c757d;
|
|
border-color: #6c757d;
|
|
}
|
|
.btn-secondary:hover {
|
|
color: #fff;
|
|
background-color: #5a6268;
|
|
border-color: #545b62;
|
|
}
|
|
.modal-dialog {
|
|
width: 600px;
|
|
}
|
|
.modal-content {
|
|
height:420px;
|
|
}
|
|
.modal-body {
|
|
font-size: 16px;
|
|
}
|
|
</style>
|
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
|
<script>
|
|
function myprint(s, r) {
|
|
var xhr = new XMLHttpRequest();
|
|
var url = window.location.origin + "/wms/mkt/pricereview_repair-download.php?id=" + s + "&<?= $token_link ?>";
|
|
xhr.open('GET', url, true);
|
|
xhr.send();
|
|
xhr.responseType = 'text';
|
|
xhr.onload = function() {
|
|
if (xhr.status === 200) {
|
|
var file_path = xhr.responseText;
|
|
var link = document.createElement('a');
|
|
link.setAttribute('href', window.location.origin + "/wms/mkt/WriteOffRepair.xlsx");
|
|
link.setAttribute('download', '報價單_'+r+'.xlsx');
|
|
link.style.display = 'none';
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
}
|
|
};
|
|
}
|
|
|
|
$(function () {
|
|
// Modal設定:
|
|
// 關閉modal時
|
|
$("#dateModal").on("hidden.bs.modal", function() {
|
|
$("#dateModal .modal-body").html('');
|
|
});
|
|
$('#table_index').on('click', 'tr a[name=finish]', function(){
|
|
var jobj = $(this); // 父視窗
|
|
var pobj = $(this).closest('td').parent();
|
|
var objLabel1 = document.createElement("label");
|
|
objLabel1.setAttribute("for", "total_price");
|
|
objLabel1.textContent = "總價";
|
|
var objInput1 = document.createElement("input");
|
|
objInput1.setAttribute("type", "text");
|
|
objInput1.setAttribute("name", "total_price");
|
|
objInput1.setAttribute("readonly", true);
|
|
objInput1.setAttribute("value", pobj.find('td').eq(5).html().trim());
|
|
var objLabel2 = document.createElement("label");
|
|
objLabel2.setAttribute("for", "final_price");
|
|
objLabel2.textContent = "議價後金額";
|
|
var objInput2 = document.createElement("input");
|
|
objInput2.setAttribute("type", "text");
|
|
objInput2.setAttribute("name", "final_price");
|
|
var objLabel3 = document.createElement("label");
|
|
objLabel3.setAttribute("for", "finish_date");
|
|
objLabel3.textContent = "完工日期";
|
|
var objInput3 = document.createElement("input");
|
|
objInput3.setAttribute("type", "date");
|
|
objInput3.setAttribute("name", "finish_date");
|
|
objInput3.setAttribute("value", "<?php echo date("Y-m-d"); ?>");
|
|
var objInput4 = document.createElement("input");
|
|
objInput4.setAttribute("type", "hidden");
|
|
objInput4.setAttribute("name", "id");
|
|
objInput4.setAttribute("value", pobj.find('td').eq(0).html().trim());
|
|
var objButton = document.createElement("button");
|
|
objButton.setAttribute("name", "save");
|
|
objButton.textContent = "儲存";
|
|
$("#dateModal .modal-body").append(objLabel1,objInput1,objLabel2,objInput2,objLabel3,"<br>",objInput3,objInput4,"<br><br>",objButton);
|
|
$("#dateModal").modal('show');
|
|
$("input[name=final_price]").keyup(function(){
|
|
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
|
|
});
|
|
$("button[name=save]").click(function(){
|
|
if ($('input[name=final_price]').val().trim() === "") {
|
|
alert("議價後金額不能為空!");
|
|
return false;
|
|
}
|
|
var formdata = new FormData();
|
|
formdata.append('pa', $('input[name=id]').val()+'##'+$('input[name=total_price]').val()+'##'+$('input[name=final_price]').val()+'##'+$('input[name=finish_date]').val());
|
|
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);
|
|
return false;
|
|
}
|
|
pobj.find('td').eq(6).html(data.fp+"<br>("+data.tp+")");
|
|
pobj.find('td').eq(8).html(data.fd);
|
|
pobj.find('a[name=finish]').hide();
|
|
$("#dateModal").modal('hide');
|
|
|
|
}
|
|
}
|
|
xhr.open('POST','pricereview_repair_end-api.php',true);
|
|
xhr.send(formdata);
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<?php if ($user_auth&2) { ?>
|
|
<p>
|
|
<a href="pricereview_repair-create.php?function_name=pricereview_repair&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
|
|
<span class="glyphicon glyphicon-plus"></span>
|
|
</a>
|
|
</p>
|
|
<?php
|
|
}
|
|
if ($data):
|
|
?>
|
|
<link rel="stylesheet" href="common.css">
|
|
<!--子窗-->
|
|
<div class="modal fade" id="dateModal" tabindex="-1" role="dialog" aria-labelledby="dateModalTitle" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h4 class="modal-title" id="dateModalTitle"></h4>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<table id="table_index" class="table table-striped table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:5%">項次</th>
|
|
<th style="width:8%">報價單編號</th>
|
|
<th style="width:7%">卷號</th>
|
|
<th>客戶名稱</th>
|
|
<th style="width:8%">電梯編號</th>
|
|
<th>總價</th>
|
|
<th style="width:8%">簽訂日</th>
|
|
<th style="width:8%">完工日</th>
|
|
<th>申請人</th>
|
|
<th>簽核主管</th>
|
|
<th>狀態</th>
|
|
<th style="width:8%">簽核時間</th>
|
|
<th style="width:8%">建立時間</th>
|
|
<th style="width:6%">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach($data as $data) :
|
|
?>
|
|
<tr>
|
|
<td><?php echo $data['id']; ?></td>
|
|
<td><?php echo $data['repair_no']; ?></td>
|
|
<td><?php echo $data['contractno']; ?></td>
|
|
<td><?php echo $data['company']; ?></td>
|
|
<td><?php echo $data['facilityno']; ?></td>
|
|
<td>
|
|
<?php
|
|
if ($data['final_price'] > 0) echo number_format($data['final_price'])."<br>(".number_format($data['total_price']).")";
|
|
else echo number_format($data['total_price']);
|
|
?>
|
|
</td>
|
|
<td><?php echo $data['sign_date']; ?></td>
|
|
<td><?php echo $data['finish_date']; ?></td>
|
|
<td><?php echo $accountname_arr[$data['repairerid']]; ?></td>
|
|
<td><?php echo $accountname_arr[$data['checker']]; ?></td>
|
|
<td><?php echo $psta_arr[$data['pstatus']]; ?></td>
|
|
<td><?php echo $data['check_date']; ?></td>
|
|
<td><?php echo $data['create_at']; ?></td>
|
|
<td>
|
|
<?php
|
|
$str = "<a href=\"pricereview_repair-check.php?id=".$data["id"]."&function_name=pricereview_repair&".$token_link;
|
|
if (($user_auth&2) && $data['pstatus'] == "A" && $is_manager) {
|
|
$str .= "\" class=\"btn btn-primary btn-sm\">簽核</a>";
|
|
} else $str .= "&view=1\" class=\"btn btn-warning btn-sm\">檢視</a>";
|
|
//if ($data['pstatus'][0] == 'B') $str .= "<br><a href=\"pricereview_repair-download.php?id=".$data["id"]."&function_name=pricereview_repair&".$token_link."\" class=\"btn btn-success btn-sm\" target=\"_blank\">列印</a>";
|
|
if ($data['pstatus'][0] == 'B') $str .= "<br><a href=\"javascript:void(0);\" onclick=\"myprint('".$data["id"]."','".$data['repair_no']."')\" class=\"btn btn-success btn-sm\">下載</a>";
|
|
if (($user_id=="M0012" || $user_id=="M0105") && $data['pstatus'] == 'B1') $str .= "<br><a href=\"javascript:void(0);\" name=\"finish\" class=\"btn btn-info btn-sm\">結案</a>";
|
|
echo $str;
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php
|
|
else:
|
|
echo "<h2>There is no record!</h2>";
|
|
endif;
|
|
|
|
#代表結束連線
|
|
mysqli_close($link);
|
|
|
|
include "../footer.php";
|
|
?>
|