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.
 
 
 
 
 
 

251 lines
10 KiB

<?php
include "header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
require_once "database.php"; // get $link
$ratio_arr = ["20%", "40%", "20%", "10%", "10%"];
$status_arr = ["I" => "申請中", "P" => "在途中", "Y" => "已完成", "X" => "作廢"];
$data = $pritem = array();
$db_query = "select * from contractapply_main where id = '$id'";
$res = mysqli_query($link, $db_query);
foreach ($res as $data) {
// 明細
$db_query = "select id, item_no, item_group, item_spec, item_qty, item_price_bp from pricereview_item where mid = '".$data["pr_main_id"]."' order by id";
$res_p = mysqli_query($link, $db_query);
foreach ($res_p as $v) {
$pritem[] = $v;
}
mysqli_free_result($res_p);
?>
<script>
$(function () {
$(":input").prop("disabled", true);
$('#id').prop("disabled", false);
$('#update').prop("disabled", false);
$('#contract_status').prop("disabled", false);
var originalModal = '<div id="myModal" class="modal fade"><div class="modal-dialog" style="width:80%;"><div class="modal-content"></div></div></div>';
$('body').on('hidden.bs.modal', function(){
$('#myModal').remove();
$('.container').prepend(originalModal);
$('#contract_status').prop("disabled", false);
});
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<!-- Modal HTML -->
<div id="myModal" class="modal fade">
<div class="modal-dialog" style="width:80%;">
<div class="modal-content">
<!-- Content will be loaded here from "remote.php" file -->
</div>
</div>
</div>
<form class="form-inline" method="post" action="contractapply-record-update.php" enctype="multipart/form-data">
<input type="hidden" name="id" id="id"value="<?=$id;?>">
<div>
<label for="apply_no">申請號</label>
<input type="text" name="apply_no" id="apply_no" value="<?=$data["apply_no1"].$data["apply_no2"];?>">
</div>
<div>
<label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" value="<?=$data["contractno"];?>">
</div>
<div>
<label for="person">營業員</label>
<input type="text" name="person" id="person" value="<?=$data["person"];?>">
</div>
<div>
<label for="apply_number">合約書號</label>
<input type="text" name="apply_number" id="apply_number" value="<?=$data["apply_number"];?>">
</div>
<div>
<label for="apply_date">申請日期</label><br>
<input type="date" name="apply_date" id="apply_date" value="<?=$data["apply_date"];?>">
</div>
<div>
<label for="promiser">立約人</label>
<input type="text" name="promiser" id="promiser" value="<?=$data["promiser"];?>">
</div>
<div>
<label for="apply_type">申請類別</label>
<select name="apply_type" id="apply_type">
<option value="A"<?php if ($data["apply_type"]=="A") echo " selected"; ?>>制式新合約</option>
<option value="B"<?php if ($data["apply_type"]=="B") echo " selected"; ?>>非制式新合約</option>
</select>
</div>
<div>
<label for="case_name">案件名稱</label>
<input type="text" name="case_name" id="case_name" value="<?=$data["case_name"];?>">
</div>
<div>
<label for="pay">含稅貨款</label>
<input type="text" name="pay" id="pay" value="<?php echo number_format($data["pay"]); ?>">
</div>
<div>
<label for="pay_install">含稅按裝款</label>
<input type="text" name="pay_install" id="pay_install" value="<?php echo number_format($data["pay_install"]); ?>">
</div>
<div>
<label for="pay_total">含稅給約總價</label>
<input type="text" name="pay_total" id="pay_total" style="background-color:#eee5e5" value="<?php echo number_format($data["pay_total"]); ?>">
</div>
<div>
<label for="pay_second">二次款</label>
<select name="pay_second" id="pay_second">
<option value="">-</option>
<option value="30"<?php if ($data["pay_second"]=="30") echo " selected"; ?>>30天</option>
<option value="60"<?php if ($data["pay_second"]=="60") echo " selected"; ?>>60天</option>
<option value="90"<?php if ($data["pay_second"]=="90") echo " selected"; ?>>90天</option>
<option value="120"<?php if ($data["pay_second"]=="120") echo " selected"; ?>>120天</option>
</select>
</div>
<div>
<label for="delivery_date">交貨期限</label>
<input type="text" name="delivery_date" id="delivery_date" value="<?=$data["delivery_date"];?>">
</div>
<div>
<label for="predeal_date">完工期限</label>
<textarea name="completion_date" id="completion_date" rows="10"><?=$data["completion_date"];?></textarea>
</div>
<div>
<label for="note">附則</label>
<textarea name="note" id="note" rows="10"><?=$data["note"];?></textarea>
</div>
<div>
<label for="address">交貨地點</label>
<input type="text" name="address" id="address" value="<?=$data["address"];?>">
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table class="table">
<thead>
<tr>
<th><label for="memo">備註</label></th>
</tr>
</thead>
<tbody>
<tr>
<td><textarea name="memo" id="memo" rows="10"><?=$data["memo"];?></textarea></td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive" style="width:100%;margin-top:10px;">
<table id="tb1" class="table table-bordered">
<thead>
<tr>
<th>項次</th>
<th>規格</th>
<th>數量</th>
<th>金額</th>
</tr>
</thead>
<tbody>
<?php
foreach ($pritem as $val) {
?>
<tr>
<td><?php echo $val["item_no"]; ?></td>
<?php
if ($val["item_group"] == "A") {
?>
<td><a href="/mkt/specsurvey-edit.php?itemid=<?php echo $val["id"]; ?>" class="modal-toggle" data-toggle="modal" data-target="#myModal"><?php echo $val["item_spec"]; ?></a></td>
<td><?php echo number_format($val["item_qty"]); ?></td>
<?php
} else {
echo "<td>".$val["item_spec"]."</td>";
echo "<td></td>";
}
?>
<td><?php echo number_format($val["item_price_bp"]); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>合約類別</th>
<th>款別</th>
<th>條件名稱</th>
<th>收款條件日期區分</th>
<th>條件日數</th>
<th>票期</th>
<th>銷售比率</th>
<th>金額</th>
</tr>
</thead>
<tbody>
<?php
$detail_arr = json_decode($data["detail"], true);
foreach ($detail_arr as $key => $val) {
?>
<tr>
<td><?=$val[0];?></td>
<td><?=$val[1];?></td>
<td><?=$val[2];?></td>
<td><?=$val[3];?></td>
<td><?=$val[4];?></td>
<td><?=$val[5];?></td>
<td><?=$ratio_arr[$key];?></td>
<td><?=number_format($val[6]);?></td>
</tr>
<?php
}
?>
</tr>
</tbody>
</table>
<label for="contract_status">合約狀態:<?php echo $status_arr[$data["status"]]; ?></label>
<?php
switch ($data["status"]) {
case "P":
$select_str = '<select name="contract_status" id="contract_status" required>
<option value="">請選擇</option>
<option value="Y">已完成簽約</option>
<option value="X">作廢</option>
</select><br>
<button type="submit" name="update" id="update">確定</button>';
break;
case "I":
$select_str = '<select name="contract_status" id="contract_status" required>
<option value="">請選擇</option>
<option value="P">在途中</option>
<option value="Y">已完成簽約</option>
<option value="X">作廢</option>
</select><br>
<button type="submit" name="update" id="update">確定</button>';
break;
default:
$select_str = "";
}
echo $select_str;
?>
</div>
<!--
<div class="bottom-margin">
<label for="fileToUpload">上傳合約書</label>
<div>
<input type="file" name="fileToUpload" id="fileToUpload">
</div>
</div>
-->
</form>
</div>
<?php
}
mysqli_free_result($res);
mysqli_close($link);
include "footer.php";
?>