19 changed files with 1517 additions and 26 deletions
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 245 KiB |
@ -0,0 +1,63 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* 客戶資料 |
||||
|
* @url /pricereview_contractno-api.php |
||||
|
* @method POST |
||||
|
* @return JSON |
||||
|
* |
||||
|
* request |
||||
|
* { |
||||
|
* "pa" |
||||
|
* } |
||||
|
* pa : 合約號 |
||||
|
* respons json |
||||
|
* { |
||||
|
* "st" : "ok", |
||||
|
* "err" : "" |
||||
|
* } |
||||
|
**/ |
||||
|
ob_start(); |
||||
|
include "../header.php"; |
||||
|
ob_end_clean(); |
||||
|
$rarr = array("st" => "ok", "err" => ""); |
||||
|
|
||||
|
try { |
||||
|
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty"); |
||||
|
|
||||
|
foreach ($_POST as $k => $v) { |
||||
|
$$k = htmlspecialchars(stripslashes(trim($v))); |
||||
|
} |
||||
|
|
||||
|
// 基本資料 |
||||
|
$db_query = "select a.address, a.repairerid, c.contractno, c.company, c.taxid from account a, contract c "; |
||||
|
$db_query .= "where a.accountid = c.customerid and c.contractno = '$pa'"; |
||||
|
$res = mysqli_query($link, $db_query); |
||||
|
if ($row = mysqli_fetch_row($res)) { |
||||
|
$rarr["address"] = $row[0]; |
||||
|
$rarr["repairerid"] = $row[1]; |
||||
|
$rarr["contractno"] = $row[2]; |
||||
|
$rarr["company"] = $row[3]; |
||||
|
$rarr["taxid"] = $row[4]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 電梯編號 |
||||
|
$db_query = "select facilityno from facility where contractno = '$pa' order by facilityno"; |
||||
|
$res = mysqli_query($link, $db_query); |
||||
|
while ($row = mysqli_fetch_row($res)) { |
||||
|
$rarr["faci"][] = $row[0]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
if (!isset($rarr["contractno"])) { |
||||
|
$rarr["st"] = "err"; |
||||
|
$rarr["err"] = "無資料!"; |
||||
|
} |
||||
|
}catch(\Exception $e) { |
||||
|
$rarr["st"] = "err"; |
||||
|
$rarr["err"] = $e->getMessage(); |
||||
|
} |
||||
|
//print_r($rarr);exit; |
||||
|
echo json_encode($rarr, JSON_UNESCAPED_UNICODE); |
||||
|
exit; |
||||
|
?> |
@ -0,0 +1,268 @@ |
|||||
|
<?php |
||||
|
include "../header.php"; |
||||
|
require_once '../cont/wf_common.php'; |
||||
|
$form_key = isset($_GET['form_key']) ? $_GET['form_key'] : ""; |
||||
|
if ($form_key == "") $id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.'); |
||||
|
|
||||
|
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); |
||||
|
|
||||
|
// 目前簽核進度 |
||||
|
$pstatus = ""; |
||||
|
$db_query = "select pstatus from pricereview_repair_main where id = '$id'"; |
||||
|
$res_r = mysqli_query($link ,$db_query); |
||||
|
if ($row_r = mysqli_fetch_row($res_r)) { |
||||
|
$pstatus = $row_r[0]; |
||||
|
} |
||||
|
mysqli_free_result($res_r); |
||||
|
if ($pstatus != "A") { |
||||
|
echo "<script>"; |
||||
|
echo "alert('請勿重覆簽核!!');"; |
||||
|
echo "window.close();"; |
||||
|
echo "</script>"; |
||||
|
exit; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$assign_status = '<option>請選擇</option><option value="F6">呈核</option><option value="Y1">不同意</option>'; |
||||
|
|
||||
|
$data = []; |
||||
|
$db_query = "select * from pricereview_repair_main where id = '$id'"; |
||||
|
$data = mysqli_query($link, $db_query); |
||||
|
|
||||
|
foreach($data as $data) : |
||||
|
// 公司站點 |
||||
|
$sql = "select content from code where field_name = 'masada_addr' and code_name = '".$data["masada_addr"]."'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
if ($row = mysqli_fetch_row($res)) { |
||||
|
$data["maddr"] = $row[0]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 保養人員 |
||||
|
$repairer_arr = []; |
||||
|
$sql = "select name from account where accounttype = 'B' and accountid = '".$data["repairerid"]."'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
if ($row = mysqli_fetch_row($res)) { |
||||
|
$data["repair"] = $row[0]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 價審明細 |
||||
|
$item_arr = []; |
||||
|
$sql = "select * from pricereview_repair_item where rid = '$id' order by item_no"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
while ($row = mysqli_fetch_assoc($res)) { |
||||
|
$item_arr[$row["item_no"]]["title"] = $row["title"]; |
||||
|
$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"]]["memo"] = $row["memo"]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// get form_key |
||||
|
$sql = "select max(form_key) from assign where assign_opinion = '".$data["repair_no"]."'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
$form_key = $row[0]; |
||||
|
mysqli_free_result($res); |
||||
|
?> |
||||
|
<style> |
||||
|
.nextline { |
||||
|
width: 100%; |
||||
|
height: 0; |
||||
|
} |
||||
|
input[type=submit], input[type=button] { |
||||
|
width: 100%; |
||||
|
background-color: #1E74FD; |
||||
|
color: white; |
||||
|
padding: 14px 20px; |
||||
|
margin: 8px 0; |
||||
|
border: none; |
||||
|
border-radius: 4px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
.dollar-right { |
||||
|
text-align: right; |
||||
|
} |
||||
|
</style> |
||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> |
||||
|
<script> |
||||
|
$(function(){ |
||||
|
$(":input").prop("disabled", true); |
||||
|
$("#assign_status").prop("disabled", false); |
||||
|
$("#next_users").prop("disabled", false); |
||||
|
$("#submit").prop("disabled", false); |
||||
|
$("#assign_status").change(function(){ |
||||
|
if ($(this).val() == "F6") $("#next_users").html('<option value="00000">00000</option>'); |
||||
|
else if ($(this).val() == "Y1") $("#next_users").html('<option value="X">退回</option>'); |
||||
|
else $("#next_users").html(''); |
||||
|
}); |
||||
|
|
||||
|
$('input[name=submit]').click(function(){ |
||||
|
$("#id").prop("disabled", false); |
||||
|
$("#form_key").prop("disabled", false); |
||||
|
$("#token").prop("disabled", false); |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
<div class="container"> |
||||
|
<form class="form-inline" method="post" action="pricereview_repair-record-check.php" enctype="multipart/form-data"> |
||||
|
<div> |
||||
|
<label for="contractno">客戶合約號</label> |
||||
|
<input type="text" name="contractno" id="contractno" value="<?php echo $data["contractno"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="repair_no">報價單編號</label> |
||||
|
<input type="text" name="repair_no" id="repair_no" value="<?php echo $data["repair_no"]; ?>"> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="sign_date">簽訂日期</label><br> |
||||
|
<input type="text" name="sign_date" id="sign_date" value="<?php echo $data["sign_date"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="company">公司地址</label> |
||||
|
<input type="text" name="masada_addr" id="masada_addr" size="46" value="<?php echo $data["maddr"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="company">客戶名稱</label> |
||||
|
<input type="text" name="company" id="company" size="30" value="<?php echo $data["company"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="facilityno">電梯編號</label> |
||||
|
<input type="text" name="facilityno" value="<?php echo $data["facilityno"]; ?>"> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="address">工程地址</label> |
||||
|
<input type="text" name="address" id="address" size="46" value="<?php echo $data["address"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="taxid">客戶統一編號</label> |
||||
|
<input type="text" name="taxid" id="taxid" value="<?php echo $data["taxid"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="invoice">客戶發票抬頭</label> |
||||
|
<input type="text" name="invoice" id="invoice" size="30" value="<?php echo $data["invoice"]; ?>"> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="repairerid">申請人</label> |
||||
|
<input type="text" name="repairerid" id="repairerid" value="<?php echo $data["repair"]; ?>"> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="memo">備註</label><br> |
||||
|
<textarea name="memo" id="memo" cols="60" rows="4"><?php echo $data["memo"]; ?></textarea> |
||||
|
</div> |
||||
|
|
||||
|
<div class="nextline"></div> |
||||
|
<br> |
||||
|
|
||||
|
<div class="table-responsive"> |
||||
|
<table id="tb1" class="table table-bordered"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>項次</th> |
||||
|
<th>名稱</th> |
||||
|
<th>數量</th> |
||||
|
<th>單價</th> |
||||
|
<th>合計</th> |
||||
|
<th>備註</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php |
||||
|
foreach ($item_arr as $k => $v) { |
||||
|
?> |
||||
|
<tr name="main_templ"> |
||||
|
<td> |
||||
|
<input type="text" name="item_no" class="form-control" size="3" value="<?php echo $k; ?>"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_title" class="form-control" size="40" value="<?php echo $v["title"]; ?>"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_qty" class="form-control dollar-right" size="3" value="<?php echo number_format($v["item_qty"]); ?>"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_unit_price" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_unit_price"]); ?>"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_price_bp" class="form-control dollar-right" size="10" value="<?php echo number_format($v["item_price_bp"]); ?>"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_memo" class="form-control" value="<?php echo $v["memo"]; ?>"> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<?php |
||||
|
} |
||||
|
?> |
||||
|
<tr> |
||||
|
<td colspan="3"><h5>營業稅</h5></td> |
||||
|
<td> |
||||
|
<input type="text" name="sales_tax" class="dollar-right" size="10" value="<?php echo number_format($data["sales_tax"]); ?>"> |
||||
|
</td> |
||||
|
<td colspan="2"></td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td colspan="3"><h5>總價</h5></td> |
||||
|
<td> |
||||
|
<input type="text" name="total_price" class="dollar-right" size="10" value="<?php echo number_format($data["total_price"]); ?>"> |
||||
|
</td> |
||||
|
<td colspan="2"></td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
|
||||
|
<div class="nextline"></div> |
||||
|
<?php |
||||
|
if (($data["checker"] == $user_id) && ($data["pstatus"] == "A")) { |
||||
|
?> |
||||
|
<div class="table-responsive"> |
||||
|
<table class="table table-bordered"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th colspan="10">簽核操作</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td><b style='float:right'>簽核狀態</b></td> |
||||
|
<td> |
||||
|
<select name="assign_status" id="assign_status" required class="form-control form-control form-control-sm"> |
||||
|
<?php echo $assign_status; ?> |
||||
|
</select> |
||||
|
</td> |
||||
|
<td><b>下位簽核者</b></td> |
||||
|
<td> |
||||
|
<select name="next_users" id="next_users" class="form-control form-control-sm" required></select> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="submit" name="submit" id="submit" value="提交"> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>"> |
||||
|
<input type="hidden" name="form_key" id="form_key" value="<?php echo $form_key; ?>"> |
||||
|
<input type="hidden" name="token" id="token" value="<?php echo $token; ?>"> |
||||
|
<?php |
||||
|
} |
||||
|
?> |
||||
|
</form> |
||||
|
</div> |
||||
|
<?php |
||||
|
endforeach; |
||||
|
?> |
||||
|
<?php |
||||
|
include "../footer.php"; |
||||
|
?> |
@ -0,0 +1,514 @@ |
|||||
|
<?php |
||||
|
include "../header.php"; |
||||
|
require_once '../cont/wf_common.php'; |
||||
|
|
||||
|
// 報價單編號 |
||||
|
$repair_no_a = date("Ymd"); |
||||
|
$sql = "select max(repair_no) from pricereview_repair_main where SUBSTRING(repair_no, 1, 8) = '$repair_no_a'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
if (empty($row[0])) $serial = "001"; |
||||
|
else $serial = str_pad(substr($row[0]+1, -3), 3, 0, STR_PAD_LEFT); |
||||
|
$repair_no = $repair_no_a.$serial; |
||||
|
|
||||
|
// 公司站點 |
||||
|
$maddr_arr = []; |
||||
|
$sql = "select code_name, content, remark from code where field_name = 'masada_addr' order by code_name"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
while ($row = mysqli_fetch_row($res)) { |
||||
|
$maddr_arr[$row[0]] = $row[2]."(".$row[1].")"; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 保養人員 |
||||
|
$repairer_arr = []; |
||||
|
$sql = "select accountid, name from account where accounttype = 'B' and accountid not in ('B000000001', 'M0008') order by accountid"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
while ($row = mysqli_fetch_row($res)) { |
||||
|
$repairer_arr[$row[0]] = $row[1]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 備品項目 |
||||
|
$item_arr = []; |
||||
|
$sql = "select * from supplies where ver = '20231103'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
while ($row = mysqli_fetch_assoc($res)) { |
||||
|
$item_arr[$row["id"]]["title"] = $row["title"]; |
||||
|
$item_arr[$row["id"]]["stype"] = $row["stype"]; |
||||
|
$item_arr[$row["id"]]["unit"] = $row["unit"]; |
||||
|
$item_arr[$row["id"]]["price"] = $row["price"]; |
||||
|
$item_arr[$row["id"]]["memo"] = $row["memo"]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
$item_str = '<table id="table_index2" class="table table-striped table-bordered" style="width:100%">'; |
||||
|
$item_str .= '<thead> |
||||
|
<tr class="kind-col"> |
||||
|
<th scope="col" nowrap>序號</th> |
||||
|
<th scope="col" nowrap>名稱</th> |
||||
|
<th scope="col" nowrap>類別</th> |
||||
|
<th scope="col" nowrap>單位</th> |
||||
|
<th scope="col" nowrap>售價</th> |
||||
|
<th scope="col" nowrap>備註</th> |
||||
|
</tr></thead><tbody>'; |
||||
|
foreach ($item_arr as $k => $v) { |
||||
|
$item_str .= "<tr>"; |
||||
|
$item_str .= "<td>".$k."</td>"; |
||||
|
$item_str .= "<td>".$v["title"]."</td>"; |
||||
|
$item_str .= "<td>".$v["stype"]."</td>"; |
||||
|
$item_str .= "<td>".$v["unit"]."</td>"; |
||||
|
$item_str .= "<td>".number_format($v["price"])."</td>"; |
||||
|
$item_str .= "<td>".$v["memo"]."</td>"; |
||||
|
$item_str .= "</tr>"; |
||||
|
} |
||||
|
$item_str .= "</tbody></table>"; |
||||
|
|
||||
|
/* |
||||
|
#獲取簽核意見 |
||||
|
$assign_opinions = Assign::get_records($form_key); |
||||
|
$assigner = $wf->getAssignerList(); |
||||
|
$assign_status = $wf->getAssignStatus($assigner); |
||||
|
*/ |
||||
|
$assign_status = '<option value="FH">指派</option>' |
||||
|
?> |
||||
|
<style> |
||||
|
#btnadd, a[name=btndel] { |
||||
|
margin-left: 4px; |
||||
|
} |
||||
|
.nextline { |
||||
|
width: 100%; |
||||
|
height: 0; |
||||
|
} |
||||
|
input[type=submit], input[type=button] { |
||||
|
width: 100%; |
||||
|
background-color: #1E74FD; |
||||
|
color: white; |
||||
|
padding: 14px 20px; |
||||
|
margin: 8px 2px; |
||||
|
border: none; |
||||
|
border-radius: 4px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
.kind-col { |
||||
|
color:brown; |
||||
|
} |
||||
|
.modal-dialog { |
||||
|
width: 1200px; |
||||
|
} |
||||
|
.modal-content { |
||||
|
height:660px; |
||||
|
} |
||||
|
#itemModal .modal-body { |
||||
|
height: 540px; |
||||
|
overflow-y: auto; |
||||
|
} |
||||
|
#table_index2_filter label { |
||||
|
width: 30%; |
||||
|
} |
||||
|
#table_index2 { |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
.row .form_row_header { |
||||
|
background-color: #6d9eeb; |
||||
|
line-height: 30px; |
||||
|
font-size: 16px; |
||||
|
} |
||||
|
.dollar-right { |
||||
|
text-align: right; |
||||
|
} |
||||
|
</style> |
||||
|
<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; |
||||
|
} |
||||
|
|
||||
|
function getCont(o) { |
||||
|
var fp = o.parent().parent(); |
||||
|
//console.log(fp.html()); |
||||
|
var pa = fp.find('input[name=contractno]').val().trim(); |
||||
|
if (pa !== '') { |
||||
|
var formdata = new FormData(); |
||||
|
formdata.append('pa', pa); |
||||
|
var xhr = new XMLHttpRequest(); |
||||
|
var str = ''; |
||||
|
xhr.onreadystatechange = function(){ |
||||
|
if(this.readyState == 4 && this.status == 200){ |
||||
|
data = JSON.parse(this.responseText); |
||||
|
if (data.st == 'err') { |
||||
|
//alert(data.err); |
||||
|
alert('查無資料,請自行輸入資料!'); |
||||
|
fp.find('input[name=company]').val(''); |
||||
|
fp.find('input[name=invoice]').val(''); |
||||
|
fp.find('input[name=address]').val(''); |
||||
|
fp.find('select[name=repairerid]').val(''); |
||||
|
fp.find('select[name=taxid]').val(''); |
||||
|
fp.find('select[name=invoice]').val(''); |
||||
|
fp.find('textarea[name=memo]').val(''); |
||||
|
fp.find('input[name=facilityno]').val(''); |
||||
|
fp.find('select[name=facilityno]').html('<option value=""></option>'); |
||||
|
fp.find('select[name=facilityno]').removeAttr("required"); |
||||
|
fp.find('select[name=facilityno]').hide(); |
||||
|
fp.find('input[name=facilityno]').prop('required',true); |
||||
|
fp.find('input[name=facilityno]').show(); |
||||
|
return false; |
||||
|
} |
||||
|
fp.find('input[name=company]').val(data.company); |
||||
|
fp.find('input[name=invoice]').val(data.company); |
||||
|
fp.find('input[name=contractno]').val(data.contractno); |
||||
|
fp.find('input[name=address]').val(data.address); |
||||
|
fp.find('select[name=repairerid]').val(data.repairerid); |
||||
|
Object.keys(data.faci).forEach(function(k){ |
||||
|
str += '<option value="'+data.faci[k]+'">'+data.faci[k]+'</option>'; |
||||
|
}); |
||||
|
fp.find('input[name=facilityno]').removeAttr("required"); |
||||
|
fp.find('input[name=facilityno]').hide(); |
||||
|
fp.find('select[name=facilityno]').append(str); |
||||
|
fp.find('select[name=facilityno]').prop('required',true); |
||||
|
fp.find('select[name=facilityno]').show(); |
||||
|
} |
||||
|
} |
||||
|
xhr.open('POST','pricereview_contractno-api.php',true); |
||||
|
xhr.send(formdata); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function dataFormat() { |
||||
|
var amtAll = 0; |
||||
|
$("input[name='item_price_bp']").each(function(){ |
||||
|
amtAll += Number($(this).val().replace(/[,]+/g,"")); |
||||
|
}); |
||||
|
var tax = Math.round(amtAll*0.05); |
||||
|
$('#sales_tax').val(commafy(tax)); |
||||
|
$('#total_price').val(commafy(amtAll+tax)); |
||||
|
} |
||||
|
|
||||
|
function cacl(o) { |
||||
|
var fp = o.parent().parent(); |
||||
|
fp.find('input[name=item_price_bp]').val(commafy(fp.find('input[name=item_unit_price]').val().replace(/[,]+/g,"")*o.val().replace(/[,]+/g,""))); |
||||
|
dataFormat(); |
||||
|
} |
||||
|
|
||||
|
$(function(){ |
||||
|
//$('#assign_status').change(function() { |
||||
|
$("#next_users").empty(); |
||||
|
//var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態 |
||||
|
var _option_tmp = ""; //獲取下拉列表 |
||||
|
/*for (a in assigner) { //遍曆assigner |
||||
|
if (assigner[a][0] == _selected_status) { |
||||
|
_tmp = assigner[a][1].split(','); |
||||
|
for (var b in _tmp) { |
||||
|
if (_tmp[b] == '') { |
||||
|
continue; |
||||
|
} |
||||
|
_uname = _tmp[b].split('-')[1]; |
||||
|
_uid = _tmp[b].split('-')[0]; |
||||
|
_option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>'; |
||||
|
} |
||||
|
} |
||||
|
}*/ |
||||
|
_option_tmp = '<option value=""></option>'; |
||||
|
_option_tmp += '<option value="M0026">M0026-張莉凱</option>'; |
||||
|
_option_tmp += '<option value="M0033">M0033-吳育宗</option>'; |
||||
|
_option_tmp += '<option value="M0054">M0054-陳志文</option>'; |
||||
|
_option_tmp += '<option value="M0086">M0086-李烘銘</option>'; |
||||
|
_option_tmp += '<option value="M0137">M0137-劉永德</option>'; |
||||
|
$("#next_users").append(_option_tmp); |
||||
|
//}); |
||||
|
$('#table_index2').DataTable({ |
||||
|
"language": { |
||||
|
"zeroRecords": "沒有符合的結果", |
||||
|
"search": "查詢", |
||||
|
}, |
||||
|
"searching": true, |
||||
|
"pageLength": 300, |
||||
|
}); |
||||
|
$('#table_index2_length').hide(); |
||||
|
$("#table_index2_paginate").hide(); |
||||
|
|
||||
|
/*$("#repair_no").prop("disabled", true); |
||||
|
$("#sales_tax").prop("disabled", true); |
||||
|
$("#total_price").prop("disabled", true); |
||||
|
*/ |
||||
|
$("select[name=facilityno]").hide(); |
||||
|
$("select[name=facilityno]").removeAttr("required"); |
||||
|
$("input[name=item_unit_price], input[name=item_price_bp]").each(function(){ |
||||
|
//$(this).prop("disabled", true); |
||||
|
}); |
||||
|
$('#query').click(function(){ |
||||
|
getCont($(this)); |
||||
|
}); |
||||
|
$('#btnadd').click(function(){ |
||||
|
$('#tb1 tr:last').prev().prev().after($("tr[name='main_templ']").last().clone().find('input').val('').end()); |
||||
|
$('#tb1 tr:last').prev().prev().find('td a[name=item_href]').html('點選'); |
||||
|
}); |
||||
|
$('#tb1').on('click', 'a[name=btndel]', function(){ |
||||
|
if ($('tr[name=main_templ]').length > 1) { |
||||
|
$(this).closest('tr').remove(); |
||||
|
dataFormat(); |
||||
|
} |
||||
|
}); |
||||
|
// 關閉modal時 |
||||
|
$("#itemModal").on("hidden.bs.modal", function() { |
||||
|
$('#table_index2_filter input').val(''); // 清空search |
||||
|
$('#table_index2_filter input').keyup(); // 恢復search前狀態 |
||||
|
}); |
||||
|
$('#tb1').on('focus', 'tr[name=main_templ] a[name=item_href]', function(){ |
||||
|
$("#itemModal").modal('show'); |
||||
|
var jobj = $(this); // 父視窗 |
||||
|
$("#itemModal .modal-body td").unbind().click(function(){ |
||||
|
var pobj = $(this).closest('td').parent(); |
||||
|
var jTitle = pobj.find('td').eq(1).html(); |
||||
|
var re = /主龬索 調速機/; |
||||
|
var found = jTitle.match(re); |
||||
|
//console.log(found);return; |
||||
|
jobj.html(jTitle); |
||||
|
jobj.closest('td').parent().find('input[name=item_qty]').val(''); |
||||
|
jobj.closest('td').parent().find('input[name=item_unit_price]').val(''); |
||||
|
jobj.closest('td').parent().find('input[name=item_memo]').val(''); |
||||
|
jobj.closest('td').parent().find('input[name=item_price_bp]').val(''); |
||||
|
jobj.closest('td').parent().find('input[name=item_unit_price]').val(pobj.find('td').eq(4).html()); |
||||
|
jobj.closest('td').parent().find('input[name=supplies_id]').val(pobj.find('td').eq(0).html()); |
||||
|
jobj.closest('td').parent().find('input[name=item_title_txt]').val(jTitle); |
||||
|
$("#itemModal").modal('hide'); |
||||
|
}); |
||||
|
}); |
||||
|
$('#tb1').on('click', 'input[name=item_qty]', function(){ |
||||
|
$(this).unbind().keyup(function(){ |
||||
|
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); |
||||
|
cacl($(this)); |
||||
|
}); |
||||
|
}); |
||||
|
$('input[name=submit]').click(function(){ |
||||
|
var itemTitleArr = []; |
||||
|
$("input[name=item_title_txt]").each(function(){ if ($(this).val() != '') itemTitleArr.push($(this).val()); }) |
||||
|
$('#item_title_all').val(itemTitleArr); |
||||
|
var itemQtyArr = []; |
||||
|
$("input[name=item_qty]").each(function(){ if ($(this).val() != '') itemQtyArr.push($(this).val().replace(/[,]+/g,"")); }) |
||||
|
$('#item_qty_all').val(itemQtyArr); |
||||
|
var itemUnitPriceArr = []; |
||||
|
$("input[name=item_unit_price]").each(function(){ if ($(this).val() != '') itemUnitPriceArr.push($(this).val().replace(/[,]+/g,"")); }) |
||||
|
$('#item_unit_price_all').val(itemUnitPriceArr); |
||||
|
var itemPriceBpArr = []; |
||||
|
$("input[name=item_price_bp]").each(function(){ if ($(this).val() != '') itemPriceBpArr.push($(this).val().replace(/[,]+/g,"")); }) |
||||
|
$('#item_price_bp_all').val(itemPriceBpArr); |
||||
|
var itemMemoArr = []; |
||||
|
$("input[name=item_memo]").each(function(){ if ($(this).val() != '') itemMemoArr.push($(this).val()+"@@"); }) |
||||
|
$('#item_memo_all').val(itemMemoArr); |
||||
|
if ($("#sales_tax").val() == "" || $("#total_price").val() == "") { |
||||
|
alert("請新增報價項目!"); |
||||
|
return false; |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
<!--子窗:備品項目--> |
||||
|
<div class="modal fade" id="itemModal" tabindex="-1" role="dialog" aria-labelledby="itemModalTitle" aria-hidden="true"> |
||||
|
<div class="modal-dialog" role="document"> |
||||
|
<div class="modal-content"> |
||||
|
<div class="modal-header"> |
||||
|
<h4 class="modal-title" id="itemModalTitle">供應商備品備料</h4> |
||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
||||
|
<span aria-hidden="true">×</span> |
||||
|
</button> |
||||
|
</div> |
||||
|
<div class="modal-body"> |
||||
|
<?php echo $item_str; ?> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<div class="container"> |
||||
|
<?php |
||||
|
include "pricereview_repair-record-submit.php"; |
||||
|
/* |
||||
|
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
||||
|
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ |
||||
|
echo "<p class='error'>Please fill up the required field!</p>"; |
||||
|
} else { |
||||
|
echo "<p class='success'>Record has added successfully</p>"; |
||||
|
} |
||||
|
} |
||||
|
*/ |
||||
|
?> |
||||
|
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> |
||||
|
<div> |
||||
|
<label for="contractno">客戶合約號</label> |
||||
|
<input type="text" name="contractno" id="contractno" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<br> |
||||
|
<input type="button" name="query" id="query" value="查詢"> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="repair_no">報價單編號</label> |
||||
|
<input type="text" name="repair_no" id="repair_no" value="<?php echo $repair_no; ?>" readonly> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="sign_date">簽訂日期</label><br> |
||||
|
<input type="date" name="sign_date" id="sign_date" value="<?php echo date('Y-m-d'); ?>" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="company">公司地址</label> |
||||
|
<select name="masada_addr" id="masada_addr" required> |
||||
|
<option value=""></option> |
||||
|
<?php |
||||
|
foreach ($maddr_arr as $k => $v) { |
||||
|
echo "<option value=\"".$k."\">".$v."</option>"; |
||||
|
} |
||||
|
?> |
||||
|
</select> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="company">客戶名稱</label> |
||||
|
<input type="text" name="company" id="company" size="30" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="facilityno">電梯編號</label> |
||||
|
<input type="text" name="facilityno" required> |
||||
|
<select name="facilityno" required> |
||||
|
<option value=""></option> |
||||
|
</select> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="address">工程地址</label> |
||||
|
<input type="text" name="address" id="address" size="50" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="taxid">客戶統一編號</label> |
||||
|
<input type="text" name="taxid" id="taxid" maxlength="8" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="invoice">客戶發票抬頭</label> |
||||
|
<input type="text" name="invoice" id="invoice" size="30" required> |
||||
|
</div> |
||||
|
<div> |
||||
|
<label for="repairerid">申請人</label> |
||||
|
<select name="repairerid" id="repairerid" required> |
||||
|
<option value=""></option> |
||||
|
<?php |
||||
|
foreach ($repairer_arr as $k => $v) { |
||||
|
echo "<option value=\"".$k."\">".$v."</option>"; |
||||
|
} |
||||
|
?> |
||||
|
</select> |
||||
|
</div> |
||||
|
<div class="nextline"></div> |
||||
|
<div> |
||||
|
<label for="memo">備註</label><br> |
||||
|
<textarea name="memo" id="memo" cols="60" rows="4"></textarea> |
||||
|
</div> |
||||
|
|
||||
|
<div class="nextline"></div> |
||||
|
<br> |
||||
|
|
||||
|
<div class="table-responsive"> |
||||
|
<table id="tb1" class="table table-bordered"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th colspan="10"><a href="javascript:void(0);" id="btnadd" class="btn btn-primary btn-sm">新增</a></th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th nowrap>名稱</th> |
||||
|
<th>數量</th> |
||||
|
<th>單價</th> |
||||
|
<th>合計</th> |
||||
|
<th>備註</th> |
||||
|
<th>操作</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr name="main_templ"> |
||||
|
<td name="item_title" nowrap> |
||||
|
<a href="" name="item_href" data-toggle="modal">點選</a> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_qty" class="form-control dollar-right" size="4"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_unit_price" class="form-control dollar-right" size="8" readonly> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_price_bp" class="form-control dollar-right" size="10" readonly> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="text" name="item_memo" class="form-control"> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="hidden" name="supplies_id"> |
||||
|
<input type="hidden" name="item_title_txt"> |
||||
|
<a href="javascript:void(0);" name="btndel" class="btn btn-danger btn-sm">X</a> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td colspan="3"><h5>營業稅</h5></td> |
||||
|
<td> |
||||
|
<input type="text" name="sales_tax" id="sales_tax" class="dollar-right" size="8" readonly> |
||||
|
</td> |
||||
|
<td colspan="2"></td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td colspan="3"><h5>總價</h5></td> |
||||
|
<td> |
||||
|
<input type="text" name="total_price" id="total_price" class="dollar-right" size="8" readonly> |
||||
|
</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="10">簽核操作</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td><b style='float:right'>簽核狀態</b></td> |
||||
|
<td> |
||||
|
<select name="assign_status" id="assign_status" required class="form-control form-control form-control-sm"> |
||||
|
<?php echo $assign_status; ?> |
||||
|
</select> |
||||
|
</td> |
||||
|
<td><b>下位簽核者</b></td> |
||||
|
<td> |
||||
|
<select name="next_users" id="next_users" class="form-control form-control-sm" required></select> |
||||
|
</td> |
||||
|
<td> |
||||
|
<input type="submit" name="submit" id="submit" value="提交"> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
|
||||
|
<!--<div><input type="submit" name="submit" id="submit" value="提交"></div>--> |
||||
|
<input type="hidden" name="item_title_all" id="item_title_all"> |
||||
|
<input type="hidden" name="item_qty_all" id="item_qty_all"> |
||||
|
<input type="hidden" name="item_unit_price_all" id="item_unit_price_all"> |
||||
|
<input type="hidden" name="item_price_bp_all" id="item_price_bp_all"> |
||||
|
<input type="hidden" name="item_memo_all" id="item_memo_all"> |
||||
|
<input type="hidden" name="token" value="<?php echo $token; ?>"> |
||||
|
</form> |
||||
|
</div> |
||||
|
|
||||
|
<?php |
||||
|
include "../footer.php"; |
||||
|
?> |
@ -0,0 +1,185 @@ |
|||||
|
<?php |
||||
|
include "../header.php"; |
||||
|
//require_once 'vendor/autoload.php'; |
||||
|
require_once '../../common/composer/vendor/autoload.php'; |
||||
|
|
||||
|
// use PhpOffice\PhpSpreadsheet\IOFactory; |
||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet; |
||||
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as xls; |
||||
|
//use PhpOffice\PhpSpreadsheet\Reader\Xls; |
||||
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; |
||||
|
// use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf; |
||||
|
|
||||
|
$id = $_GET["id"]; |
||||
|
$accountname_arr = accountid2name(); |
||||
|
$data = []; |
||||
|
$db_query = "select * from pricereview_repair_main where id = '$id'"; |
||||
|
$data = mysqli_query($link, $db_query); |
||||
|
|
||||
|
foreach($data as $data) : |
||||
|
// 公司站點 |
||||
|
$sql = "select content from code where field_name = 'masada_addr' and code_name = '".$data["masada_addr"]."'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
if ($row = mysqli_fetch_row($res)) { |
||||
|
$data["maddr"] = $row[0]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 保養人員 |
||||
|
$repairer_arr = []; |
||||
|
$sql = "select name from account where accounttype = 'B' and accountid = '".$data["repairerid"]."'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
if ($row = mysqli_fetch_row($res)) { |
||||
|
$data["repair"] = $row[0]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
// 價審明細 |
||||
|
$item_arr = []; |
||||
|
$sql = "select * from pricereview_repair_item where rid = '$id' order by item_no"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
while ($row = mysqli_fetch_assoc($res)) { |
||||
|
$item_arr[$row["item_no"]]["title"] = $row["title"]; |
||||
|
$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"]]["memo"] = $row["memo"]; |
||||
|
} |
||||
|
mysqli_free_result($res); |
||||
|
|
||||
|
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); |
||||
|
$spreadsheet = $reader->load("repair-sample.xlsx"); |
||||
|
$sheet = $spreadsheet->getActiveSheet(); |
||||
|
$sheet->getProtection()->setSheet(true); |
||||
|
$sheet->getStyle('A5:J10')->getFont()->setSize(14); |
||||
|
$sheet->setCellValue('C5', $data["maddr"]); |
||||
|
$sheet->setCellValue('C6', $data["company"]); |
||||
|
$sheet->setCellValue('J6', $data["invoice"]); |
||||
|
$sheet->setCellValue('C7', $data["facilityno"]); |
||||
|
$sheet->setCellValue('C8', $data["address"]); |
||||
|
$sheet->setCellValue('J8', $data["taxid"]); |
||||
|
$sheet->setCellValue('C10', substr($data["sign_date"], 0, 10)); |
||||
|
$sheet->setCellValue('J10', $data["repair_no"]); |
||||
|
$st = 12; |
||||
|
foreach ($item_arr as $k => $v) { |
||||
|
//$sheet->setCellValue('A'.$st, $k); |
||||
|
$sheet->setCellValue('B'.$st, $v["title"]); |
||||
|
$sheet->setCellValue('H'.$st, $v["item_qty"]); |
||||
|
$sheet->setCellValue('I'.$st, $v["item_unit_price"]); |
||||
|
$sheet->setCellValue('J'.$st, $v["item_price_bp"]); |
||||
|
$sheet->setCellValue('M'.$st, $v["memo"]); |
||||
|
$st++; |
||||
|
} |
||||
|
$sheet->setCellValue('J18', $data["sales_tax"]); |
||||
|
$sheet->setCellValue('J19', $data["total_price"]); |
||||
|
$sheet->setCellValue('A20', "合計:新台幣 ".numberToChinese($data["total_price"])." 整(含稅)"); |
||||
|
$sheet->setCellValue('B23', $data["memo"]); |
||||
|
$sheet->setCellValue('M36', $data["repair"]); |
||||
|
//$sheet->setCellValue('I35', mb_substr($accountname_arr[$data["checker"]],0,1).mb_substr($accountname_arr[$data["checker"]],1)); |
||||
|
|
||||
|
$writer = new Xls($spreadsheet); |
||||
|
$file_path = 'WriteOffRepair.xlsx'; |
||||
|
$writer->save('WriteOffRepair.xlsx'); |
||||
|
echo $file_path; |
||||
|
endforeach; |
||||
|
|
||||
|
function numberToChinese($num) { |
||||
|
$chineseNumbers = ['零', '壹', '貮', '參', '肆', '伍', '陸', '㭍', '捌', '玖','拾']; |
||||
|
$units = [' 元', ' 拾 ', ' 佰 ', ' 仟 ', ' 萬 ', ' 拾 ']; |
||||
|
|
||||
|
$num = str_pad($num, 6, "0", STR_PAD_LEFT); |
||||
|
if ($num <= 10) { |
||||
|
return $chineseNumbers[$num]; |
||||
|
} elseif ($num < 20) { |
||||
|
return $units[1] . $chineseNumbers[$num % 10]; |
||||
|
} elseif ($num < 100) { |
||||
|
return $chineseNumbers[intval($num / 10)] . $units[1] . ($num % 10 > 0 ? $chineseNumbers[$num % 10] : ''); |
||||
|
} else { |
||||
|
$result = ''; |
||||
|
$strNum = strval($num); |
||||
|
$length = strlen($strNum); |
||||
|
for ($i = 0; $i < $length; $i++) { |
||||
|
$currentDigit = intval($strNum[$i]); |
||||
|
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1]; |
||||
|
/* |
||||
|
if ($currentDigit > 0) { |
||||
|
$result .= $chineseNumbers[$currentDigit] . $units[$length - $i - 1]; |
||||
|
} else { |
||||
|
$result .= $chineseNumbers[$currentDigit]; |
||||
|
} |
||||
|
*/ |
||||
|
} |
||||
|
return $result; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
exit; |
||||
|
|
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
//print_r($_POST);exit; |
||||
|
foreach ($_POST as $k => $v) { |
||||
|
$$k = htmlspecialchars(stripslashes(trim($v))); |
||||
|
} |
||||
|
|
||||
|
if ($assign_status == "F6") $pstatus = "B1"; |
||||
|
elseif ($assign_status == "Y1") $pstatus = "X"; |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
|
||||
|
/* |
||||
|
// 檢查報價單編號 |
||||
|
$sql = "select count(*) from pricereview_main where contractno = '$contractno' and status in ('Y1', 'YS', 'YY')"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
if ($row[0] > 0) { |
||||
|
echo "<script>"; |
||||
|
echo "alert('請勿重覆價審!');"; |
||||
|
echo "history.go(-1);"; |
||||
|
echo "</script>"; |
||||
|
exit; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
// 更新狀態 |
||||
|
$db_query = "update pricereview_repair_main set pstatus = '$pstatus', check_date = '$tds' "; |
||||
|
$db_query .= "where id = '$id'"; |
||||
|
$result = mysqli_query($link, $db_query); |
||||
|
$affected = mysqli_affected_rows($link); |
||||
|
if ($affected > 0) { |
||||
|
// 更新待簽表 |
||||
|
$sql = "update subflow set current_assigner = '00000', update_date = '$tds' where form_key = '$form_key'"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = "update flow set flow_code = 'Z' where system_id = 'prm' and flow_id = 'prm03' and form_id = '$id' and form_key = '$form_key'"; |
||||
|
mysqli_query($link, $sql); |
||||
|
|
||||
|
/* |
||||
|
// 寄信給下位簽核人 |
||||
|
$mail_list = []; |
||||
|
$ret = accountid2email($next_signer); |
||||
|
if (!empty($ret)) { |
||||
|
foreach ($ret as $uid => $uemail) { |
||||
|
$mail_list[] = [$uid, $uemail]; |
||||
|
} |
||||
|
$mail_list[] = ['M0044', 'jrbin@masada.com.tw']; |
||||
|
include dirname(__DIR__)."/class/Cmail.php"; |
||||
|
$sendmail = new Cmail; |
||||
|
$title = "【新梯價審通知】卷號:".$contractno; |
||||
|
$content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_新梯</a>,點擊「待簽核」進行作業,謝謝!</p>"; |
||||
|
$sendmail->sendx($title, $content, $mail_list); |
||||
|
} |
||||
|
*/ |
||||
|
} |
||||
|
|
||||
|
mysqli_close($link); |
||||
|
if ($affected > 0) { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('簽核完成');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} else { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('簽核失敗,請重新操作');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} |
||||
|
} |
||||
|
?> |
@ -0,0 +1,272 @@ |
|||||
|
<?php |
||||
|
include "../header.php"; |
||||
|
|
||||
|
// 員工編號對應姓名表 |
||||
|
$accountname_arr = accountid2name(); |
||||
|
|
||||
|
$psta_arr = ["A" => "簽核中", "B1" => "已同意", "B2" => "已完工", "X" => "不同意"]; |
||||
|
|
||||
|
// 設置一個空陣列來放資料 |
||||
|
$data = array(); |
||||
|
// sql語法存在變數中 |
||||
|
$sql_cmd = sql_myself($user_id, "repairerid"); |
||||
|
$is_manager = 0; |
||||
|
// 宜:M0054-陳志文 |
||||
|
$repman_arr[0] = ["M0177"]; |
||||
|
// 北:M0137-劉永德 |
||||
|
$repman_arr[1] = ["M0059","M0083","M0084","M0090","M0064","M0106","M0092","M0120","M0147","M0139","M0194","M0210"]; |
||||
|
// 桃:M0026-張莉凱 |
||||
|
$repman_arr[2] = ["M0018", "M0045","M0089","M0104","M0111"]; |
||||
|
// 中:M0086-李烘銘 |
||||
|
$repman_arr[3] = ["M0148","M0114","M0161"]; |
||||
|
// 南:M0033-吳育宗 |
||||
|
$repman_arr[4] = ["M0196","M0195","M0190","M0094","M0123","M0124"]; |
||||
|
if ($user_id == "M0054") { $is_manager = 1; $sql_cmd = "where repairerid in ('".implode("','", $repman_arr[0])."')"; } |
||||
|
elseif ($user_id == "M0137") { $is_manager = 1; $sql_cmd = "where repairerid in ('".implode("','", $repman_arr[1])."')"; } |
||||
|
elseif ($user_id == "M0026") { $is_manager = 1; $sql_cmd = "where repairerid in ('".implode("','", $repman_arr[2])."')"; } |
||||
|
elseif ($user_id == "M0086") { $is_manager = 1; $sql_cmd = "where repairerid in ('".implode("','", $repman_arr[3])."')"; } |
||||
|
elseif ($user_id == "M0033") { $is_manager = 1; $sql_cmd = "where repairerid in ('".implode("','", $repman_arr[4])."')"; } |
||||
|
elseif ($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(6).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"; |
||||
|
?> |
@ -0,0 +1,40 @@ |
|||||
|
<?php |
||||
|
include "../header.php"; |
||||
|
|
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
//print_r($_POST);exit; |
||||
|
foreach ($_POST as $k => $v) { |
||||
|
$$k = htmlspecialchars(stripslashes(trim($v))); |
||||
|
} |
||||
|
|
||||
|
if ($assign_status == "F6") $pstatus = "B1"; |
||||
|
elseif ($assign_status == "Y1") $pstatus = "X"; |
||||
|
$tds = date("Y-m-d H:i:s"); |
||||
|
|
||||
|
// 更新狀態 |
||||
|
$db_query = "update pricereview_repair_main set pstatus = '$pstatus', check_date = '$tds' "; |
||||
|
$db_query .= "where id = '$id'"; |
||||
|
$result = mysqli_query($link, $db_query); |
||||
|
$affected = mysqli_affected_rows($link); |
||||
|
if ($affected > 0) { |
||||
|
// 更新待簽表 |
||||
|
$sql = "update subflow set current_assigner = '00000', update_date = '$tds' where form_key = '$form_key'"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = "update flow set flow_code = 'Z' where system_id = 'prm' and flow_id = 'prm03' and form_id = '$id' and form_key = '$form_key'"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
mysqli_close($link); |
||||
|
if ($affected > 0) { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('簽核完成');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} else { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('簽核失敗,請重新操作');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} |
||||
|
} |
||||
|
?> |
@ -0,0 +1,78 @@ |
|||||
|
<?php |
||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
||||
|
//print_r($_POST);exit; |
||||
|
foreach ($_POST as $k => $v) { |
||||
|
$$k = htmlspecialchars(stripslashes(trim($v))); |
||||
|
} |
||||
|
|
||||
|
$sales_tax = str_replace(",", "", $sales_tax); |
||||
|
$total_price = str_replace(",", "", $total_price); |
||||
|
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
||||
|
$create_at = date("Y-m-d H:i:s"); |
||||
|
|
||||
|
// 避免報價單編號重覆 |
||||
|
$repair_no_a = date("Ymd"); |
||||
|
$sql = "select max(repair_no) from pricereview_repair_main where SUBSTRING(repair_no, 1, 8) = '$repair_no_a'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$row = mysqli_fetch_row($res); |
||||
|
if (empty($row[0])) $serial = "001"; |
||||
|
else $serial = str_pad(substr($row[0]+1, -3), 3, 0, STR_PAD_LEFT); |
||||
|
$new_repair_no = $repair_no_a.$serial; |
||||
|
if ($new_repair_no != $repair_no) $repair_no = $new_repair_no; |
||||
|
|
||||
|
// 價審單-主文 pricereview_repair_main |
||||
|
$db_query = "insert into pricereview_repair_main(repair_no, contractno, masada_addr, company, taxid, invoice, facilityno, "; |
||||
|
$db_query .= "address, sales_tax, total_price, sign_date, memo, repairerid, pstatus, checker, creater, create_at) values ("; |
||||
|
$db_query .= "'$repair_no', '$contractno', '$masada_addr', '$company', '$taxid', '$invoice', '$facilityno', "; |
||||
|
$db_query .= "'$address', $sales_tax, $total_price, '$sign_date', '$memo', '$repairerid', 'A', '$next_users', '$user_id', '$create_at')"; |
||||
|
$result = mysqli_query($link, $db_query); |
||||
|
$affected = mysqli_affected_rows($link); |
||||
|
if ($rid = mysqli_insert_id($link)) { |
||||
|
// 價審單-明細項目 pricereview_repair_item |
||||
|
$item_title_all = str_replace("點選", "", $item_title_all); |
||||
|
$item_title_arr = explode(",", $item_title_all); |
||||
|
$item_qty_arr = explode(",", $item_qty_all); |
||||
|
$item_unit_price_arr = explode(",", $item_unit_price_all); |
||||
|
$item_price_bp_arr = explode(",", $item_price_bp_all); |
||||
|
$item_memo_arr = explode("@@,", rtrim($item_memo_all, "@@")); |
||||
|
$item_no = 1; |
||||
|
for ($i=0; $i<count($item_title_arr); $i++) { |
||||
|
$item_qty_arr[$i] = str_replace(",", "", $item_qty_arr[$i]); |
||||
|
$item_unit_price_arr[$i] = str_replace(",", "", $item_unit_price_arr[$i]); |
||||
|
$item_price_bp_arr[$i] = str_replace(",", "", $item_price_bp_arr[$i]); |
||||
|
$db_query = "insert into pricereview_repair_item (rid, item_no, title, item_unit_price, item_qty, item_price_bp, memo) values ("; |
||||
|
$db_query .= "'$rid', '$item_no', '$item_title_arr[$i]', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_memo_arr[$i]')"; |
||||
|
$result = mysqli_query($link, $db_query); |
||||
|
$item_no++; |
||||
|
} |
||||
|
|
||||
|
// 更新待簽表 |
||||
|
#係統ID |
||||
|
$system_id = 'prm'; |
||||
|
#流程ID |
||||
|
$flow_id = 'prm03'; |
||||
|
#表單號 $form_id; |
||||
|
$form_id = $rid; |
||||
|
$wf = new WorkFlow($system_id, $flow_id, $form_id); |
||||
|
$wf->initWorkFlow($user_id); |
||||
|
$form_key = $wf->flowContext->getFormKey(); |
||||
|
$sql = "insert into assign (form_key, seq, assigner, assign_opinion) values ('$form_key', 1, '$next_users', '$repair_no')"; |
||||
|
mysqli_query($link, $sql); |
||||
|
$sql = "update subflow set seq = seq+1, current_assigner = '$next_users', update_date = '$create_at' where form_key = '$form_key'"; |
||||
|
mysqli_query($link, $sql); |
||||
|
} |
||||
|
|
||||
|
mysqli_close($link); |
||||
|
if ($affected > 0) { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('提交成功');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} else { |
||||
|
echo "<script type = 'text/JavaScript'>"; |
||||
|
echo "alert('提交失敗,請重新操作');"; |
||||
|
echo "location.href='pricereview_repair-index.php?function_name=pricereview_repair&".$token_link."';"; |
||||
|
echo "</script>"; |
||||
|
} |
||||
|
} |
||||
|
?> |
@ -0,0 +1,56 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* 修理價審結案 |
||||
|
* @url /wms/mkt/pricereview_repair_end-api.php |
||||
|
* @method POST |
||||
|
* @return JSON |
||||
|
* |
||||
|
* request |
||||
|
* { |
||||
|
* "pa" |
||||
|
* } |
||||
|
* pa : 價審單序號##總價##議價金額##完工日 |
||||
|
* respons json |
||||
|
* { |
||||
|
* "st" : "ok", |
||||
|
* "err" : "" |
||||
|
* } |
||||
|
**/ |
||||
|
ob_start(); |
||||
|
include "../header.php"; |
||||
|
ob_end_clean(); |
||||
|
$rarr = array('st' => 'ok', 'err' => ''); |
||||
|
|
||||
|
try { |
||||
|
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty"); |
||||
|
|
||||
|
foreach ($_POST as $k => $v) { |
||||
|
$$k = htmlspecialchars(stripslashes(trim($v))); |
||||
|
} |
||||
|
|
||||
|
list($id, $total_price, $final_price, $finish_date) = explode("##", $pa); |
||||
|
if (!$id || !$final_price || !$finish_date) throw new \Exception("parameter empty[2]"); |
||||
|
$create_at = date("Y-m-d H:i:s"); |
||||
|
|
||||
|
$final_price = str_replace(",", "", $final_price); |
||||
|
$sql = "update pricereview_repair_main set final_price = '$final_price', finish_date = '$finish_date', pstatus = 'B2', "; |
||||
|
$sql .= "creater = '$user_id', create_at = '$create_at' where id = '$id'"; |
||||
|
$res = mysqli_query($link, $sql); |
||||
|
$affected = mysqli_affected_rows($link); |
||||
|
if ($affected > 0) { |
||||
|
$rarr['tp'] = $total_price; |
||||
|
$rarr['fp'] = number_format($final_price); |
||||
|
$rarr['fp'] = number_format($final_price); |
||||
|
$rarr['fd'] = $finish_date; |
||||
|
} else { |
||||
|
$rarr['st'] = 'err'; |
||||
|
$rarr['err'] = '無更新'; |
||||
|
} |
||||
|
}catch(\Exception $e) { |
||||
|
$rarr['st'] = 'err'; |
||||
|
$rarr['err'] = $e->getMessage(); |
||||
|
} |
||||
|
|
||||
|
echo json_encode($rarr, JSON_UNESCAPED_UNICODE); |
||||
|
exit; |
||||
|
?> |
Binary file not shown.
Loading…
Reference in new issue