| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/innoutstorage/webadmin/ |
Upload File : |
<?php
require_once('check_login.php');
//for renew contract, 20190129
if ((int)$_GET['renew'] == 1) {
$_SESSION["renew"] = 1;
$contract_id = (int)$_GET['contract_id'];
$customer_id = (int)$_GET['customer_id'];
//record warehousing order in session
$_SESSION["warehousing"][1]["new_customer"] = 0;
$_SESSION["warehousing"][1]["customer_id"] = $customer_id;
$this_customer_info = get_customer($customer_id);
$_SESSION["warehousing"][1]["customer_code"] = $this_customer_info["code"];
$_SESSION["warehousing"][1]["identity_type"] = $this_customer_info["typeid"];
$_SESSION["warehousing"][1]["identity_id"] = $this_customer_info["typeid"] == 'PERSONAL' ? rsa_crypt($this_customer_info["hkid"], 2) : rsa_crypt($this_customer_info["hkbr"], 2);
$_SESSION["warehousing"][1]["title"] = $this_customer_info["title"];
$_SESSION["warehousing"][1]["lastname"] = rsa_crypt($this_customer_info["lastname"], 2);
$_SESSION["warehousing"][1]["firstname"] = rsa_crypt($this_customer_info["firstname"], 2);
$_SESSION["warehousing"][1]["companyname"] = $this_customer_info["companyname"];
$_SESSION["warehousing"][1]["email"] = rsa_crypt($this_customer_info["email"], 2);
$_SESSION["warehousing"][1]["tel"] = rsa_crypt($this_customer_info["tel"], 2);
$_SESSION["warehousing"][1]["address"] = rsa_crypt($this_customer_info["address"], 2);
$_SESSION["warehousing"][1]["pass"] = true;
$sql = "select * from `order` where id = ? and deleted = ? order by id DESC";
$parameters = array($contract_id, 0);
$order_info = bind_pdo($sql, $parameters, "selectone");
$_SESSION["first_order_id"] = empty($order_info['first_order_id']) ? $contract_id : $order_info['first_order_id'];
$_SESSION["warehousing"][2]["renew_paymethod2"] = $order_info['paymethod2'];
$_SESSION["warehousing"][2]["renew_bank_name2"] = $order_info['bank_name2'];
$_SESSION["warehousing"][2]["renew_cheque_num2"] = $order_info['cheque_num2'];
$_SESSION["warehousing"][2]["renew_paymethod_order2"] = $order_info['paymethod_order2'];
$_SESSION["warehousing"][2]["renew_total_discounted_price"] = $order_info['total_discounted_price'];
//$_SESSION["warehousing"][1]["remark"] = '舊合約編號: ' . $order_info['code'];
$_SESSION["warehousing"][2]["renew_rent_month"] = $order_info['rent_month'];
/*if(date('Y-m-d') >= $order_info['enddate']){
$_SESSION["warehousing"][2]["renew_warehousing_date"] = date('Y-m-d');
}else{
$date = new DateTime($order_info['enddate']);
$_SESSION["warehousing"][2]["renew_warehousing_date"] = $date->modify('+1 day')->format('Y-m-d');
}*/
$date = new DateTime($order_info['enddate']);
$_SESSION["warehousing"][2]["renew_warehousing_date"] = $date->modify('+1 day')->format('Y-m-d');
$_SESSION["warehousing"][2]["renew_room_key"] = $order_info['room_key'];
$sql = "select code from `deposit` where order_id = ? and deleted = ? and (status = ? or status = ?) order by id DESC";
$parameters = array($contract_id, 0, 'NEW', 'PAID');
$deposit_info = bind_pdo($sql, $parameters, "selectone");
$remark = str_replace(array("\r\n", "\r", "\n"), "<br>", htmlspecialchars($order_info['remark'], ENT_QUOTES)).'\n舊合約編號: ' . $order_info['code'].', 舊合約按金金額: $'.$order_info['deposit'];;
/* PRINT deposit info in remark if deposit was returned */
$sql = "select * from `deposit` where order_id = ? and deleted = ? and status = ? order by id DESC";
$parameters = array($contract_id, 0, 'RETURNED');
$returned_deposit_info = bind_pdo($sql, $parameters, "selectone");
if ($returned_deposit_info) {
switch ($returned_deposit_info['status']) {
case "NEW":
$status = "新建";
break;
case "PAID":
$status = "已付";
break;
case "RETURNED":
$status = "已退還";
break;
case "CONFISCATE":
$status = "沒收";
break;
case "VOID":
$status = "取消";
break;
default:
$status = "未定義";
break;
}
$deposit_note = '\n*按金編號: ' . $returned_deposit_info['code'].', 按金金額: $' . $returned_deposit_info['amount'] . ' 狀態: ' . $status;
if (!strpos($remark, $deposit_note)) {
$remark .= $deposit_note;
}
}
$_SESSION["warehousing"][2]["renew_remark"] = $remark;
/* superseded
if (!$order_list) {
// $_SESSION["warehousing"][2]["renew_remark"] = str_replace(array("\r\n", "\r", "\n"), "<br>", htmlspecialchars($order_info['remark'], ENT_QUOTES)).'\n舊合約編號: ' . $order_info['code'].', 舊合約按金金額: $'.$order_info['deposit'];
$_SESSION["warehousing"][2]["renew_remark"] = $remark;
} else {
// $remark = str_replace(array("\r\n", "\r", "\n"), "<br>", htmlspecialchars($order_info['remark'], ENT_QUOTES)).'\n舊合約編號: ' . $order_info['code'].', 舊合約按金金額: $'.$order_info['deposit'];;
foreach ($order_list as $key => $value) {
switch ($value['status']) {
case "NEW":
$status = "新建";
break;
case "COMPLETED":
$status = "已完約";
break;
case "REVISED":
$status = "已轉倉";
break;
case "TERMINATION":
$status = "終止";
break;
case "VOID":
$status = "取消";
break;
default:
$status = "未定義";
break;
}
$sql = "select * from `deposit` where order_id = ? and deleted = ? and (status = ? or status = ?) order by id DESC";
$parameters = array($contract_id, 0, 'NEW', 'PAID');
$deposit_info = bind_pdo($sql, $parameters, "selectone");
if ($value['status'] === "COMPLETED" || $value['status'] === "TERMINATION") {
$remark .= '\n舊合約編號: ' . $value['code'].', 舊合約按金金額: $'.$value['deposit'] . ', 狀態: ' . $status;
}
// if ($key = 0) {
// $remark .= str_replace(array("\r\n", "\r", "\n"), "<br>", htmlspecialchars($order_info['remark'], ENT_QUOTES)).'\n舊合約編號: ' . $value['code'].', 舊合約按金金額: $'.$value['deposit'] . ', 狀態: ' . $status;
// } else {
// $remark .= '\n舊合約編號: ' . $value['code'].', 舊合約按金金額: $'.$value['deposit'] . ', 狀態: ' . $status;
// }
// die(var_dump($remark));
}
$_SESSION["warehousing"][2]["renew_remark"] = $remark;
}
*/
//copy from _ajax.php $_GET["for"] == "floor_plan_rent_room"
$_SESSION["selected_room_tr"] = '<!--<tr id="selected_room_tr">--><td style="vertical-align: middle;">選擇迷你倉</td>
<td>
<hr>
<table border="1" cellpadding="5" style="border-collapse: collapse;">
<caption class="tl required">已選取倉庫 <button type="button" onclick="window.location.href=\'_ajax.php?for=clear_selected_room\';" style="margin: 0 0 5px 30px;">清空已選取倉庫</button></caption>
<tbody><tr id="selected_room">
<td>倉庫編號</td>
<td>尺寸</td>
<td>原價(月)</td>
<td>優惠價(月)</td>
<td>預繳 / 指定倉庫優惠</td>
<td>價格</td>
<td>價格(折扣後)</td>
<td></td>
</tr>';
$order_room = get_order_room($contract_id);
foreach ($order_room as $selected_room) {
$room = get_room($selected_room["room_id"]);
$_SESSION["warehousing"][2]["renew_master_room_id"] = $room["master_room_id"];
$master_room_info = get_master_room($room["master_room_id"]);
$master_room_price = get_master_room_price($room["master_room_id"]);
$location_id = $master_room_info["location_id"];
//check if this room selected
$background = "background-color: #ffffff";
if (!empty($_SESSION["selected_room_tr"])) {
if (strpos($_SESSION["selected_room_tr"], $room["room_code"]) !== false) {
$background = "background-color: #7EBF3D";
}
}
//check if this room selected
$background = "background-color: #ffffff";
$available_room_selected_class = "";
$select_room_text = "選取";
if (!empty($_SESSION["selected_room_tr"])) {
if (strpos($_SESSION["selected_room_tr"], $room["room_code"]) !== false) {
$background = "background-color: #7EBF3D";
$select_room_text = "已選取";
$available_room_selected_class = "available_room_selected";
}
}
$_SESSION["selected_room_tr"] .= "<tr style='" . $background . "' id='" . $room["id"] . "' class='room_id_flag location_" . $location_id . " " . $available_room_selected_class . "'>
<td>" . $room["code"] . " <input type='hidden' name='room_id[]' value='" . $room["id"] . "'><input type='hidden' name='room_code[]' value='" . $room["code"] . "'><input type='hidden' name='location_id[]' value='" . $location_id . "'></td>
<td>" . $master_room_info["length"] . "X" . $master_room_info["width"] . "X" . $master_room_info["height"] . " <input type='hidden' name='room_size[]' value='" . ($master_room_info["length"] * $master_room_info["width"]) . "'></td>
<td>$" . numberformat($master_room_price["retail_price"], 2, "") . " <input type='hidden' name='retail_price[]' value='" . $master_room_price["retail_price"] . "'></td>
";
$nowdate = date("Y-m-d H:i:s");
//need to check if master room discount exist, if exist -> discounted price -> master room discount
if ($nowdate >= $master_room_price["effectivedate_from"] && $nowdate <= $master_room_price["effectivedate_to"]) {
//discounted price valid
$_SESSION["selected_room_tr"] .= "<td>$" . $master_room_price["discounted_price"] . " </td>";
$set_discounted_price = $master_room_price["discounted_price"];
} else {
$_SESSION["selected_room_tr"] .= "<td>N/A </td>";
$set_discounted_price = $master_room_price["retail_price"];
}
$discounted_price = $set_discounted_price;
//check if this kind of room has prepaid / specific discount
$sql = "select *, discount.id as master_room_discount_id from master_room_discount discount INNER JOIN master_type_code mtcode ON discount.payment_term = mtcode.code where discount.master_room_id = ? and discount.deleted = ? and mtcode.typeid = ? and ? >= effectivedate_from and ? <= effectivedate_to";
$parameters = array($room["master_room_id"], 0, "PAYMENT_TERM", date("Y-m-d"), date("Y-m-d"));
$master_room_discount_info = bind_pdo($sql, $parameters, "selectall");
$discount_message = "";
foreach ($master_room_discount_info as $master_room_discount) {
//$discount_message .= $master_room_discount["name_tc"] . " -" . $master_room_discount["discount"] . $master_room_discount["discount_type"] . " / ";
if ($master_room_discount["payment_term"] == "SPECIFIC_SIZE") {
$class = "SPECIFIC_SIZE_DISCOUNT _DISCOUNT DISCOUNT_ID_" . $master_room_discount["master_room_discount_id"];
$discounted_price = $set_discounted_price * (100 - $master_room_discount["discount"]) / 100;
} else {
$class = "PREPAID_DISCOUNT _DISCOUNT DISCOUNT_ID_" . $master_room_discount["master_room_discount_id"];
$discounted_price = $set_discounted_price;
}
$discount_message .= $master_room_discount["name_tc"] . " <input type='text' id='MONTH_" . $master_room_discount["config_value"] . "' value='" . $master_room_discount["discount"] . "' style='width: 40px;' class='" . $class . "' onkeyup=\"update_discounted_price($(this).closest('tr').attr('id'));data_calculation($(this).attr('class'));\"> % 折扣 / </br>";
}
$discount_message = substr_replace($discount_message, "", -7);
$_SESSION["selected_room_tr"] .= "<td>" . $discount_message . "</td>";
$_SESSION["selected_room_tr"] .= "<td>
<input type='text' name='set_discounted_price[]' class='set_discounted_price' value='" . numberformat($set_discounted_price, 2, "") . "' style='width: 70px;' onkeyup=\"update_discounted_price($(this).closest('tr').attr('id'));data_calculation($(this).attr('class'));\">
</td>";
$_SESSION["selected_room_tr"] .= "<td>
<input type='text' name='discounted_price[]' class='discounted_price' value='" . numberformat($discounted_price, 2, "") . "' style='width: 70px;' readonly>
</td>";
$_SESSION["selected_room_tr"] .= "<td class='select_room_td'>
<button type='button' class='delete_room' onclick='delete_room(this," . $room["id"] . ")'>刪除</button>
</td>";
$_SESSION["selected_room_tr"] .= "</tr>";
}
$_SESSION["selected_room_tr"] .= '<!-- display selected room here -->
</tbody></table>
</td>
<!--</tr>-->';
/*echo $_SESSION["selected_room_tr"];
exit;*/
header("Location: warehousing_step2.php?renew=1&contract_id=" . $contract_id . '&location_id=' . $order_info['location_id']);
}
//end: for renew contract, 20190129
$customer_type_info = get_master_type_code("CUSTOMER_TYPE");
?>
<!DOCTYPE html>
<html>
<head>
<?php require_once('html_head.php'); ?>
<script type="text/javascript">
function input_field_disable(new_customer) {
if (new_customer == "1") {
$(".exist_customer_code_tr").hide();
}
}
function ajax_customer_info() {
$(".exist_customer_code_tr").hide();
//ajax customer info
//loading
$("#ajax_matched_customer").hide();
$("#loading").show();
var identity_id = $("input[name='identity_id']").val();
/*if($("input[name='identity_id2']").val() != ""){
var identity_id = $("input[name='identity_id2']").val();
}else{
var identity_id = $("input[name='identity_id']").val();
}*/
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#loading").hide();
//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
//console.log(xmlhttp.responseText);
var result = $.trim(xmlhttp.responseText);
//console.log(1);
if (result == "" || result == null) {
$("#ajax_matched_customer").hide();
} else {
$("#ajax_matched_customer").show().html(result);
$("#ajax_matched_customer").show();
}
//when click existing customer info
$(".customer_info").on("click", function () {
//console.log(456);
var customer_id = this.id;
var code = $(this).find(".code").text();
var title = $(this).find(".title").text();
var firstname = $(this).find(".firstname").text();
var lastname = $(this).find(".lastname").text();
var identity_type = $(this).find(".identity_type").val();
var identity_id = $(this).find(".identity_id").text();
var tel = $(this).find(".tel").text();
var email = $(this).find(".email").text();
var address = $(this).find(".address").text();
//("#warehousing_step1 #old_customer").attr("checked", "checked");
$("#warehousing_step1 #old_customer").trigger("click");
input_field_disable(0);
$("#warehousing_step1 input[name='customer_id']").val(customer_id);
$(".exist_customer_code_tr").show();
$("#warehousing_step1 .exist_customer_code").text(code);
$("#warehousing_step1 select[name='title']").val(title);
$("#warehousing_step1 input[name='firstname']").val(firstname);
$("#warehousing_step1 input[name='lastname']").val(lastname);
$("#warehousing_step1 select[name='identity_type'] option").attr("disabled", true);
$("#warehousing_step1 select[name='identity_type'] option").each(function () {
if ($(this).val() == identity_type) {
$(this).attr("disabled", false).attr("selected", true);
}
});
$("#clicked_identity_type").val(identity_type);
//$("#warehousing_step1 select[name='identity_type']").val(identity_type);
//$("#warehousing_step1 input[name='identity_id']").val(identity_id);
$("#warehousing_step1 input[name='identity_id2']").val(identity_id);
$("#warehousing_step1 input[name='tel']").val(tel);
$("#warehousing_step1 input[name='email']").val(email);
$("#warehousing_step1 input[name='address']").val(address);
if (identity_type == "BUSINESS") {
$("#companyname").show();
var companyname = $(this).find(".companyname").val();
$("#warehousing_step1 input[name='companyname']").val(companyname);
} else {
$("#warehousing_step1 input[name='companyname']").val("");
$("#companyname").hide();
}
});
}
}
xmlhttp.open("POST", "_ajax.php?for=search_matched_customer", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("identity_id=" + identity_id);
}
function check_customer_type() {
var clicked_identity_type = $("#clicked_identity_type").val();
//console.log(clicked_identity_type);
$("#warehousing_step1 select[name='identity_type'] option").attr("disabled", true);
$("#warehousing_step1 select[name='identity_type'] option").each(function () {
if ($(this).val() == clicked_identity_type) {
$(this).attr("disabled", false).attr("selected", true);
}
});
}
$(function () {
/*$("input[name='identity_id'], input[name='identity_id2']").on('keyup paste', function () {
ajax_customer_info();
});
var identity_id_value = $("input[name='identity_id']").val();
if (identity_id_value != "" && identity_id_value != null) {
ajax_customer_info();
}*/
//identity_type change
$("select[name='identity_type']").on("change", function () {
if ($(this).val() == "BUSINESS") {
$("#companyname").show();
} else {
$("#companyname").hide();
}
});
var this_identity_type = $("select[name='identity_type']").val();
if (this_identity_type == "BUSINESS") {
$("#companyname").show();
} else {
$("#companyname").hide();
}
//identity_type change
$("input[name='new_customer']").on("change click", function () {
input_field_disable($(this).val());
if ($("#new_customer").prop("checked") == true) {
$("select[name='identity_type'] option").attr("disabled", false);
}
var this_identity_type = $("select[name='identity_type']").val();
if (this_identity_type == "BUSINESS") {
$("#companyname").show();
} else {
$("#companyname").hide();
}
});
if ($("#old_customer").prop("checked") == true) {
input_field_disable(0);
} else {
input_field_disable(1);
}
check_customer_type();
$("#old_customer").on("click", function () {
check_customer_type();
});
if ($("#new_customer").prop("checked") == true) {
$("select[name='identity_type'] option").attr("disabled", false);
}
});
</script>
<style>
table input[type='text'], table textarea {
width: 400px;
}
</style>
</head>
<body>
<table width="1200" height="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200" align="left" valign="top">
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="70" align="left" valign="middle"> </td>
</tr>
<tr>
<td width="200" align="left" valign="top"><!-- Main Menu -->
<?php require("menu.php"); ?><!-- End Main Menu --></td>
</tr>
</table>
</td>
<td width="1000" align="left" valign="top">
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="70" class="pagetitletxt"> </td>
<td width="50" align="center" class="icontxt"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="pagetitletxt">
<b><img src="images/iconList.jpg" width="48" height="48" align="absmiddle"/> 入倉 </b>
</td>
</tr>
<tr>
<td height="25" align="left" valign="middle" class="msg"></td>
</tr>
<!-- <tr>
<td class="pagetitletxt">
</td>
</tr>-->
<tr>
<td align="left" valign="middle">
<form action="warehousing_step1_post.php" method="post" enctype="multipart/form-data" class="form_field" id="warehousing_step1">
<table style="width: 100%;">
<tr>
<td style="width: 50px;">搜尋現有客戶:</td>
<td style="width: 400px;">
證件號碼/電話號碼 <input type="text" name="identity_id" style="width: 150px;">
<button type="button" onclick="ajax_customer_info();">提交</button>
</td>
</tr>
<tr>
<td colspan="2" id="matched_customer_info">
<div id="loading" style="display: none; width: 500px; text-align: center;">
<img src="../images/loading.gif"/></div>
<div class="block" id="ajax_matched_customer"></div>
</td>
</tr>
</table>
</form>
<hr>
<form action="warehousing_step1_post.php" method="post" enctype="multipart/form-data" class="form_field" id="warehousing_step1">
<input type="hidden" name="customer_id"/>
<table style="width: 100%;">
<tr>
<td colspan="2">
<p>步驟1 - 顧客資料</p>
</td>
</tr>
<tr>
<td style="width: 50px;"> </td>
<td style="width: 400px;">
<input type="radio" name="new_customer" value="1" id="new_customer"><label>新客戶</label>
<input type="radio" name="new_customer" value="0" id="old_customer"><label>現有客戶</label>
</td>
</tr>
<tr class="exist_customer_code_tr" style="display: none;">
<td>
<p class="">客戶編號: </p>
</td>
<td class="exist_customer_code"></td>
</tr>
<tr>
<td style="width: 50px;">
<p class="required">客戶類型: </p>
</td>
<td style="width: 400px;">
<input type="hidden" name="clicked_identity_type" id="clicked_identity_type" value=""/>
<select name="identity_type">
<?php
foreach ($customer_type_info as $customer_type) {
echo "<option value='" . $customer_type["code"] . "'>" . $customer_type["name_tc"] . "</option>";
}
?>
</select> <span style="font-size: 14px;">證件號碼:</span>
<input type="text" name="identity_id2" style="width: 260px;"/> <br>
<span class="msg">個人: 以身分證作認證 商業: 以商業登記證作認證 </span>
</td>
</tr>
<tr>
<td>
<p class="required">稱謂: </p>
</td>
<td>
<select name="title" style="width: 50px;">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>
</td>
</tr>
<tr>
<td>
<p class="required">姓氏: </p>
</td>
<td>
<input type="text" name="lastname">
</td>
</tr>
<tr>
<td>
<p class="required">名字: </p>
</td>
<td>
<input type="text" name="firstname">
</td>
</tr>
<tr id="companyname" style="display: none;">
<td>
<p class="required">公司名稱: </p>
</td>
<td>
<input type="text" name="companyname">
</td>
</tr>
<tr>
<td>
<p class="">聯絡電郵: </p>
</td>
<td>
<input type="text" name="email">
</td>
</tr>
<tr>
<td>
<p class="required">聯絡電話: </p>
</td>
<td>
<input type="text" name="tel">
</td>
</tr>
<tr>
<td>
<p class="required">聯絡地址: </p>
</td>
<td>
<input type="text" name="address">
</td>
</tr>
<tr>
<td colspan="2">
<p class="red">* 必須填寫</p>
</td>
</tr>
<tr>
<td colspan="2" class="tr">
<button type="submit">下一步</button>
</td>
</tr>
</table>
</form>
<br><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>