| 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');
$discount_type = (int)$_POST["discount_type"];
$discount_id = (int)$_POST["discount_id"];
$master_room_id = (int)$_POST["master_room_id"];
if (!empty($_POST["effectivedate_from"]) && !empty($_POST["effectivedate_to"]) && !empty($_POST["master_room_id"]) && !empty($_POST["payment_term"])) {
//bug
/*$result = same_size_master_room($master_room_id);
foreach ($result as $row) {
//need to check if this kind of prepaid discount exist or not
$sql = "select * from master_room_discount where master_room_id = ? and payment_term = ? and deleted = ? and effectivedate_from <= ? and ? <= effectivedate_to and id != ?";
$parameters = array($row["id"], $_POST["payment_term"], 0, $_POST["effectivedate_to"], $_POST["effectivedate_from"], $discount_id);
$master_room_discount_info = bind_pdo($sql, $parameters, "selectone");
if(!empty($master_room_discount_info)) {
$message = "相關的優惠設定已存在。";
echo "<script>alert('".$message."'); window.location.href='discount_modifyform.php?id=".$master_room_discount_info["id"]."&discount_type=".$_POST["discount_type"]."'; </script>";
exit;
}
}*/
//bug fix 20180823
$sql = "select * from master_room_discount where master_room_id = ? and payment_term = ? and deleted = ? and effectivedate_from <= ? and ? <= effectivedate_to and id != ?";
$parameters = array($master_room_id, $_POST["payment_term"], 0, $_POST["effectivedate_to"], $_POST["effectivedate_from"], $discount_id);
$master_room_discount_info = bind_pdo($sql, $parameters, "selectone");
if (!empty($master_room_discount_info)) {
$message = "相關的優惠設定已存在。";
echo "<script>alert('" . $message . "'); window.location.href='discount_modifyform.php?id=" . $master_room_discount_info["id"] . "&discount_type=" . $_POST["discount_type"] . "'; </script>";
exit;
}
}
$discount_type = $_POST["discount_type"];
$message = "";
if (empty($_POST["effectivedate_from"])) {
$message .= "請輸入正確的開始日期。\\n\\n";
}
if (empty($_POST["effectivedate_to"])) {
$message .= "請輸入正確的完結日期。\\n\\n";
}
if (!is_numeric($_POST["discount"]) || empty($_POST["discount"]) || $_POST["discount"] <= 0) {
$message .= "優惠折扣必須輸入正數數字。\\n\\n";
}
if (!empty($_POST["effectivedate_from"]) && !empty($_POST["effectivedate_to"]) && $_POST["effectivedate_from"] > $_POST["effectivedate_to"]) {
$message .= "開始日期不能大於完結日期。\\n\\n";
}
if (!empty($message)) {
echo "<script>alert('" . $message . "'); history.back(); </script>";
exit;
}
if (isset($_POST["is_final_discount"])) {
$is_final_discount = 1;
} else {
$is_final_discount = 0;
}
$sql = "update master_room_discount set is_final_discount=?, discount=?, effectivedate_from=?, effectivedate_to=?, lastupdate=?, lastupby=?, show_frontend=? where id=?";
$parameters = array($is_final_discount, $_POST["discount"], $_POST["effectivedate_from"], $_POST["effectivedate_to"], $nowdate, $_SESSION['cmsloginid'], (int)$_POST["show_frontend"], $discount_id);
bind_pdo($sql, $parameters);
$master_room_discount = get_master_room_discount($discount_id);
$result = same_size_master_room($master_room_id);
foreach ($result as $row) {
$master_room_id = $row["id"];
$sql = "update master_room_discount set is_final_discount=?, discount=?, effectivedate_from=?, effectivedate_to=?, lastupdate=?, lastupby=?, show_frontend=? where payment_term=? and master_room_id=? and pair_key=?";
$parameters = array($is_final_discount, $_POST["discount"], $_POST["effectivedate_from"], $_POST["effectivedate_to"], $nowdate, $_SESSION['cmsloginid'], (int)$_POST["show_frontend"], $_POST["payment_term"], $master_room_id, $master_room_discount["pair_key"]);
bind_pdo($sql, $parameters);
}
header("Location: discount_index.php?discount_type=$discount_type&msg=新增成功&location_id=" . (int)$_POST["location_id"]);