<!doctype html>
<html class="no-js" lang="zxx">
<head>
	<meta charset="utf-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title>Sudila Printers - Kurunegala Sri Lanka</title>
	<meta name="description" content="Buddist books online; best online Buddist book store in Sri Lanka. Our collection include Sri Lankan Buddhist books, Buddhist Information and Online Books from Sri Lanka.">
	<meta name="keywords" content="Sudila Printers">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- Favicons -->
	<link rel="shortcut icon" href="images/favicon.ico">

	<!-- Google font (font-family: 'Roboto', sans-serif; Poppins ; Satisfy) -->
	<link type="text/css" href="css/font_opensans.css" rel="stylesheet">
	<link type="text/css" href="css/font_poppins.css" rel="stylesheet">
	<link type="text/css" href="css/font_roboto.css" rel="stylesheet">
	<!-- Stylesheets -->
	<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
	<link type="text/css" rel="stylesheet" href="css/plugins.css">
	<link type="text/css" rel="stylesheet" href="css/style.css">
	<!-- Cusom css -->
	<link type="text/css" rel="stylesheet" href="css/custom.css">
	<!-- Modernizer js -->
	<script type="text/javascript" src="js/vendor/modernizr-3.5.0.min.js"></script>
	<style type="text/css">
		.table-content table td {
			text-align: right;
			text-transform: uppercase;
			line-height: 20px;
		}
		.table-content table td.bname {
			text-align: left;
		}
		.total__amount li {
			font-size: 22px;
		}




		.accordion-heading .accordion-toggle {
			display: block;
			padding: 8px 15px;
		}
		.accordion-heading a {
			color: #428bca;
			font-size: 15px;
			outline: none;
		}
		.accordion-toggle {
			cursor: pointer;
		}
		.accordion-heading {
			background: #f3f3f3;
			border-bottom: 1px solid #e5e5e5;
		}
		.accordion-heading a {
			color: #428bca;
		}
		.accordion-heading a:hover {
			text-decoration: none
		}
		.payment_box {
			display: none
		}
		.payment_box.payment_method_bacs {
			box-shadow: none !important;
			text-shadow: none !important;
		}
		input[type="radio"], input[type="checkbox"]{margin: 0;height: 15px;width: 15px;}

		.btext {
			font-weight: 600;
			font-size: 14px;
			color: #144775;
		}

	</style>
</head>
<body>
	<!-- Main wrapper -->
	<div class="wrapper" id="wrapper">
		<div id="pre_loader"></div>
		<!-- Header -->
		<?php include 'common/header.php';
		if (isset($_SESSION['temp_user_bb']) && isset($_SESSION['guest_user_bb'])) {
			$user_id = htmlspecialchars(strip_tags(trim($_SESSION['temp_user_bb'])), ENT_QUOTES, 'UTF-8');
			$whr = 'temp_id';

			if(empty($user_id)) {
				$redirectUrl = "index";
				echo "<script type=\"text/javascript\">";
				echo "window.location.href = '$redirectUrl'";
				echo "</script>";

			} else {
				$sqlt = mysqli_query($conn, "SELECT * FROM live_cart WHERE temp_id=$user_id");
				if(mysqli_num_rows($sqlt) > 0) {
					$row_inv = mysqli_fetch_assoc($sqlt);
					$g_inv = $row_inv['inv_no'];
					$sql_up = mysqli_query($conn, "UPDATE live_cart SET User_ID='G$g_inv', inv_no='$g_inv' WHERE temp_id=$user_id");
				}
				$guest = 1;
			}

		} else {
			if (!isset($_SESSION['normal_user_bb']) || empty($_SESSION['normal_user_bb'])) {
				$redirectUrl = "sign-in";
				echo "<script type=\"text/javascript\">";
				echo "window.location.href = '$redirectUrl'";
				echo "</script>";

			} else {
				$user_id = htmlspecialchars(strip_tags(trim($_SESSION['normal_user_bb'])), ENT_QUOTES, 'UTF-8');
				$whr = 'User_ID';
				$guest = 0;
			}
		}

		$sql = mysqli_query($conn, "SELECT inv_no, SUM(price*Qty) AS sub_tot, SUM(item_price*Qty) AS item_tot, SUM(weight*Qty) AS tot_weight FROM live_cart WHERE $whr=$user_id");
		if(mysqli_num_rows($sql) == 0) {
			$redirectUrl = "index";
			echo "<script type=\"text/javascript\">";
			echo "window.location.href = '$redirectUrl'";
			echo "</script>";	

		} else {
			$row = mysqli_fetch_assoc($sql);
			$item_tot = $row['item_tot'];
			$sub_tot = $row['sub_tot'];
			$tot_discount = $item_tot-$sub_tot;
			$tot_weight = $row['tot_weight'];
			$inv_no = $row['inv_no'];

			if(empty($inv_no)) {
				$redirectUrl = "index";
				echo "<script type=\"text/javascript\">";
				echo "window.location.href = '$redirectUrl'";
				echo "</script>";

			} else {
				$sqlu = "SELECT * FROM order_details_temp WHERE user_id=$user_id AND inv_no='$inv_no' AND guest=$guest";
				$resultu = mysqli_query($conn, $sqlu);
				$countu = mysqli_num_rows($resultu);

				if($countu == 0) {
					$redirectUrl = "index";
					echo "<script type=\"text/javascript\">";
					echo "window.location.href = '$redirectUrl'";
					echo "</script>";		

				} else {
					$sqltmp = mysqli_fetch_assoc($resultu);
					$del_fee = $flag = 0;
					$country = $sqltmp['country'];

					$sql_cou = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM courier_charges"));

					if($tot_weight > 0) {
					if($sqltmp['delivery_type'] == 1 && $country == 'Sri Lanka') { // Postal
						$sql_del_chg = mysqli_query($conn, "SELECT fee FROM postal_charges WHERE low_w < '$tot_weight' AND high_w >='$tot_weight'");	
						
						if($tot_weight > 20000) { // Max Out 2kg
							$flag = 1;
							
						} else {
							if(mysqli_num_rows($sql_del_chg) == 0) {
								$flag = 1;
								
							} else {
								$row_del_chg = mysqli_fetch_assoc($sql_del_chg);
								$del_fee = $row_del_chg['fee'];
							}
						}

					} else if($sqltmp['delivery_type'] == 2 && $country == 'Sri Lanka') { // Courier
						$a = floor($tot_weight/1000);
						
						if($tot_weight > 0 && $tot_weight <= 1000) {
							$del_fee = $sql_cou['courier_fee'];

						} else {
							$del_fee = $sql_cou['courier_fee'] + ($a * $sql_cou['courier_1kg']);
						}
						
					} else if($sqltmp['delivery_type'] == 4 && $country == 'Sri Lanka') { // Cash on Delivery
						$a = floor($tot_weight/1000);

						if($tot_weight >= 0 && $tot_weight <= 1000) {
							$del_fee = $sql_cou['cash_on_del'];

						} else {
							$del_fee = $sql_cou['cash_on_del'] + ($a * $sql_cou['cash_on_1kg']);
						}

					} else if($sqltmp['delivery_type'] == 3 && $country != 'Sri Lanka') { // EMS
						$sql_wgt = mysqli_query($conn, "SELECT * FROM ems_charges WHERE country='$country'");
						if(mysqli_num_rows($sql_wgt) == 0) {
							$del_fee = 0;
							$flag = 1;

						} else {
							$row_wgt = mysqli_fetch_assoc($sql_wgt);
							$max_w = $row_wgt['max_kg']*1000;
							
							if($row_wgt['max_kg'] == 20) {
								if($tot_weight > $max_w) {
									$del_fee = 0;
									$flag = 1;

								} else {
									if($tot_weight > 10000) { // 10001-20000 Grams
										$f = $row_wgt['kg_20'];
										
										$r = $tot_weight - 1000;
										$w = ceil($r/500);
										$del_fee = $row_wgt['kg_1'] + ($w * $f);

									} else if($tot_weight > 1000) { // 1001-10000 Grams
										$f = $row_wgt['kg_10'];
										
										$r = $tot_weight - 1000;
										$w = ceil($r/500);
										$del_fee = $row_wgt['kg_1'] + ($w * $f);

									} else if($tot_weight > 500) { // 501-1000 Grams
										$del_fee = $row_wgt['kg_1'];

									} else if($tot_weight > 250) { // 251-500 Grams
										$del_fee = $row_wgt['g_500'];

									} else { // 0-250 Grams
										$del_fee = $row_wgt['g_250'];
									}
									
									$del_fee += 250; // Packing Charges
								}

							} else if($row_wgt['max_kg'] == 30) {
								if($tot_weight > $max_w) {
									$del_fee = 0;
									$flag = 1;

								} else {
									if($tot_weight > 20000) { // 20001-30000 Grams
										$f = $row_wgt['kg_30'];
										
										$r = $tot_weight - 1000;
										$w = ceil($r/500);
										$del_fee = $row_wgt['kg_1'] + ($w * $f);

									} else if($tot_weight > 10000) { // 10001-20000 Grams
										$f = $row_wgt['kg_20'];
										
										$r = $tot_weight - 1000;
										$w = ceil($r/500);
										$del_fee = $row_wgt['kg_1'] + ($w * $f);

									} else if($tot_weight > 1000) { // 1001-10000 Grams
										$f = $row_wgt['kg_10'];
										
										$r = $tot_weight - 1000;
										$w = ceil($r/500);
										$del_fee = $row_wgt['kg_1'] + ($w * $f);

									} else if($tot_weight > 500) { // 501-1000 Grams
										$del_fee = $row_wgt['kg_1'];

									} else if($tot_weight > 250) { // 251-500 Grams
										$del_fee = $row_wgt['g_500'];

									} else { // 0-250 Grams
										$del_fee = $row_wgt['g_250'];
									}
									
									$del_fee += 250; // Packing Charges
								}
								
							} else {
								$del_fee = 0;
								$flag = 1;
							}
						}			

					} else {
						$del_fee = 0;
						$flag = 1;
					}

				} else {
					$del_fee = 0;
					$flag = 1;
				}
			}
		}
	}
	?>
	<!-- //Header --> 
	<!-- Start Bradcaump area -->
	<div class="ht__bradcaump__area bg-image--4">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="bradcaump__inner text-center">
						<h2 class="bradcaump-title">confirm order</h2>
						<nav class="bradcaump-content"> <a class="breadcrumb_item" href="index">Home</a> <span class="brd-separetor">/</span> <a class="breadcrumb_item" href="my-cart">My Cart</a><span class="brd-separetor">/</span><a class="breadcrumb_item" href="checkout">Checkout Details</a><span class="brd-separetor">/</span> <a class="breadcrumb_item" href="order-summary">Order Summary</a> <span class="brd-separetor">/</span> <span class="breadcrumb_item active">Confirm Order</span> </nav>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- End Bradcaump area --> 
	<!-- Start Checkout Area -->
	<section class="wn__checkout__area pt--30 pb--30 bg__white">
		<div class="container">
			<div class="row" style="display:none">
				<div class="col-lg-12 col-12">
					<div class="account__form">
						<h4><u>RECIPIENT INFORMATION</u></h4>
						<div class="customar__field mt--30">
							<table width="100%" border="0">
								<tr>
									<td width="25%"><b>Name</b></td>
									<td width="75%"><?php echo $sqltmp['f_name'].' '.$sqltmp['l_name']; ?></td>
								</tr>
								<tr>
									<td><b>Contact Number</b></td>
									<td><?php echo $sqltmp['tel_no']; ?></td>
								</tr>
								<tr>
									<td><b>Email Address</b></td>
									<td><?php echo $sqltmp['email']; ?></td>
								</tr>
								<tr>
									<td><b>Delivery Address</b></td>
									<td><?php echo $sqltmp['address_1'].' '.$sqltmp['address_2'].' '.$sqltmp['city']; ?></td>
								</tr>
								<tr>
									<td><b>Country</b></td>
									<td><?php echo $country; ?></td>
								</tr>
								<tr>
									<td><b>Postal Code</b></td>
									<td><?php echo $sqltmp['postal_code']; ?></td>
								</tr>
								<tr>
									<td><b>Special Instructions</b></td>
									<td><?php echo $sqltmp['special_msg']; ?></td>
								</tr>
								<tr>
									<td><b>Delivery Method</b></td>
								  <td><?php //if($sqltmp['delivery_type'] == 1) { echo 'Postal'; } else if($sqltmp['delivery_type'] == 2) { echo 'Courier Service'; } else if($sqltmp['delivery_type'] == 3) { echo 'Expedited Mail Service (EMS)'; }
								  
								  $delType = $sqltmp['delivery_type'];

								  $cashOnDisable = 'disabled';
								  $bankDisable = '';
								  $errTxt = '<strong class="text-danger">(Only valid for deliver via Cash on Delivery)</strong>';
								  $errMsg = '<p class="mt--10 mb--10"><b>You have selected Postal or Courier Service or EMS delivery method. Cash on Delivery not allowed for this type of delivery methods.</b></p>';

								  if($delType == 1) {
								  	echo 'Postal';
								  	echo '<style>.payment_box.payment_method_bacs1{display:block;}</style>';

								  } else if($delType == 2) {
								  	echo 'Courier Service';
								  	echo '<style>.payment_box.payment_method_bacs1{display:block;}</style>';

								  } else if($delType == 3) {
								  	echo 'Expedited Mail Service (EMS)';
								  	echo '<style>.payment_box.payment_method_bacs1{display:block;}</style>';

								  } else if($delType == 4) {
								  	echo 'Cash on Delivery';
								  	$bankDisable = 'disabled';
								  	$cashOnDisable = 'checked';
								  	$errTxt = '';
								  	$errMsg = '<p class="mt--10 mb--10"><b>Your personal data will be used to process your order, support your experience throughout this website.</b></p>';
								  }
								  
								  ?></td>
								</tr>
								<tr>
									<td><b>Sub Total</b></td>
									<td>LKR <?php echo number_format($sub_tot, 2); ?></td>
								</tr>
								<tr>
									<td><b>Delivery Charges</b></td>
									<td>LKR <?php echo number_format($del_fee, 2); ?> &nbsp;<b>(Total Weight: <?php echo $tot_weight; ?>g)</b></td>
								</tr>
								<tr>
									<td><h4>Grand Total</h4></td>
									<td><h4>LKR
										<?php $g_tot = $sub_tot + $del_fee; echo number_format($g_tot, 2); ?>
									</h4></td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-12">
					<div class="wn__order__box" style="display:none">
						<h3 class="onder__title">order summary - Invoice ID: <?php echo $inv_no; ?></h3>
						<div class="table-content wnro__table table-responsive">
							<table>
								<tr class="title-top">
									<th width="25%">Product Name</th>
									<th width="15%">Weight</th>
									<th width="15%">Unit Price (lkr)</th>
									<th width="15%">Discounted Price (lkr)</th>
									<th width="12%">Quantity</th>
									<th width="18%">Subtotal (lkr)</th>
								</tr>
								<?php $sql_c = mysqli_query($conn, "SELECT * FROM live_cart WHERE live_cart.$whr =  $user_id");
								while($row_c = mysqli_fetch_array($sql_c)) { ?>
									<tr>
										<td class="bname"><?php echo $row_c['name']; ?></td>
										<td><?php echo $row_c['weight']; ?>g</td>
										<td><?php echo $row_c['item_price']; ?></td>
										<td><?php echo $row_c['price']; ?></td>
										<td><?php echo $row_c['Qty']; ?></td>
										<td><?php echo number_format($row_c['price']*$row_c['Qty'], 2); ?></td>
									</tr>
								<?php }
								// Update Grand Total
								mysqli_query($conn, "UPDATE order_details_temp SET price_total='$item_tot', tot_discount='$tot_discount', sub_total='$sub_tot', delivery_chg='$del_fee', grand_total='$g_tot' WHERE user_id='$user_id' AND inv_no='$inv_no' AND guest=$guest");
								?>
							</table>
						</div>
						<ul class="shipping__method">
							<li>Cart Total <span>LKR <?php echo number_format($item_tot, 2); ?></span></li>
							<li>Total Discount <span>LKR <?php echo number_format($tot_discount, 2); ?></span></li>
							<li>Total Subtotal <span>LKR <?php echo number_format($item_tot-$tot_discount, 2); ?></span></li>
							<li>Delivery Charges (<?php echo $tot_weight; ?>g) <span>LKR <?php echo number_format($del_fee, 2); ?></span></li>
						</ul>
						<ul class="total__amount">
							<li>GRAND Total <span>LKR <?php echo number_format($g_tot, 2); ?></span></li>
						</ul>
					</div>
					<div class="account__form">
						<h6 class="mb--10">SELECT PAYMENT METHOD</h6><hr>
						<div id="accordion" class="checkout_accordion mt--20" role="tablist">

								<!--<div class="payment">
									<div class="che__header" role="tab" id="headingOne">
										<a class="checkout__title">
											<input name="payment_method" value="1" type="radio"><span> Direct Bank Transfer/Bank Deposit</span>
										</a>
									</div>
									<div id="collapseOne" class="collapse">
										<div class="payment-body">Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order won’t be shipped until the funds have cleared in our account.
										<h6><b>Bank: Sampath Bank <br>
										Account Number: 000610013880</b></h6>
										<h6>After making your deposit please send the bank slip via Fax, WhatsApp, Viber or Email.</h6>
										<h6><b>Fax:</b> +94 37 223 4447<br>
										<b>WhatsApp/Viber:</b> +94 710 122 122<br>
										<b>Email:</b> info@samudrabooks.com<br>
										<b>Contact:</b> +94 70 2255 666</h6>
										</div>
									</div>
								</div>
								<div class="payment">
									<div class="che__header" role="tab" id="headingTwo">
										<a class="collapsed checkout__title">
											<input name="payment_method" value="2" type="radio" checked> <span>Credit/Debit Card</span>
										</a>
									</div>
								</div>
								<div class="payment">
									<div class="che__header" role="tab" id="headingThree">
										<a class="collapsed checkout__title">
											<input name="payment_method" value="3" type="radio"> <span> mCash/eZCash</span>
										</a>
									</div>
								</div>-->
								
								
								<div class="accordion-heading"> <a class="accordion-toggle">
									<input type="radio" name="payment_method" id="" value="1" <?php echo $bankDisable; ?> checked> &nbsp;&nbsp;&nbsp;Credit/Debit Card</a> </div>
									<div id="" class="accordion-body">
										<div class="payment_box payment_method_bacs1">
											<div style="padding:15px" class="table-responsive">
												<img src="images/logo/master.png" alt="master card" width="55"> <img src="images/logo/visa.png" alt="visa card" width="60"> <img src="images/logo/amex.png" alt="American Express" width="60"> <img src="images/logo/discover.png" alt="discover" width="60">
											</div>
										</div>
									</div>

									<div class="accordion-heading"> <a class="accordion-toggle">
										<input type="radio" name="payment_method" id="" value="2" <?php echo $bankDisable; ?>> &nbsp;&nbsp;&nbsp;Mobile Wallet</a> </div>
										<div id="" class="accordion-body">
											<div class="payment_box payment_method_bacs2">
												<div style="padding:15px" class="table-responsive">
													<img src="images/logo/ezcash.png" alt="eZcash" width="55"> <img src="images/logo/mcash.png" alt="mcash" width="70"> <img src="images/logo/genie.png" alt="genie" width="50"> 
												</div>
											</div>
										</div>

										<div class="accordion-heading"> <a class="accordion-toggle">
											<input type="radio" name="payment_method" id="" value="5" <?php echo $bankDisable; ?>> &nbsp;&nbsp;&nbsp;Sampath Vishwa</a> </div>
											<div id="" class="accordion-body">
												<div class="payment_box payment_method_bacs5">
													<div style="padding:15px" class="table-responsive">
														<img src="images/logo/sampathb.png" alt="sampath" width="45"> <img src="images/logo/vishwa.png" alt="vishwa" width="80">
													</div>
												</div>
											</div>

											<div class="accordion-heading"> <a class="accordion-toggle">
												<input type="radio" name="payment_method" id="" value="4" <?php echo $cashOnDisable; if($delType == 2 || $delType == 4) {} else {echo 'disabled'; } ?>> &nbsp;&nbsp;&nbsp;Cash on Delivery <?php echo $errTxt; if($delType != 2) { echo '<strong class="text-red">(Only valid for deliver via Courier Service)</strong>'; }?></a></div>
												<div id="" class="accordion-body">
													<div class="payment_box payment_method_bacs4">
														<div style="padding:15px" class="table-responsive">

															<?php echo $errMsg;

					 /*if($delType == 2 || $delType == 4) { // Courier/Exhibition 
						 echo '<h5>Your personal data will be used to process your order, support your experience throughout this website.</h5>';
					
					} else { //Postal/EMS 
						 echo '<h5>You have selected Postal/EMS delivery method. Cash on Delivery not allowed for this type of delivery methods.</h5>';
						 
						 echo '<style>.payment_box.payment_method_bacs4{display:block;}</style>';
						}*/ ?>

					</div>
				</div>
			</div>

			<div class="accordion-heading"> <a class="accordion-toggle">
				<input type="radio" name="payment_method" id="" value="3" <?php echo $bankDisable; ?>> &nbsp;&nbsp;&nbsp;Direct Bank Deposit</a> </div>
				<div id="" class="accordion-body">
					<div class="payment_box payment_method_bacs3">
						<div style="padding:15px" class="table-responsive">
							<p>Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order won’t be shipped until the funds have cleared in our account.</p>
							<p class="mt--10"><span class="btext">Account Name:</span> Samudra Consolidated (pvt) Ltd. </p>
							<p class="mt--10"><span class="btext">Bank:</span> Sampath Bank <br>
								<span class="btext">Account Number:</span> 000610013880</p>
								<p class="mt--10"><span class="btext">Bank:</span> Bank of Ceylon (BOC) <br>
									<span class="btext">Account Number:</span> 0082369147</p>
									<p class="mt--10"><span class="btext">Bank:</span> People's Bank <br>
										<span class="btext">Account Number:</span> 334100150106529</p>

										<p class="mt--10">After making your deposit please send the bank slip via Fax, WhatsApp, Viber or Email.</p>

										<p class="mt--10"><span class="btext">Fax:</span> +94 37 223 4447<br>
											<span class="btext">WhatsApp/Viber:</span> +94 70 2255 666<br>
											<span class="btext">Email:</span> info@samudrabooks.com<br>
											<span class="btext">Contact:</span> +94 70 2255 666</p>
										</div>
									</div>
								</div>
								
								
								
								
								
								
							</div>
							<hr class="mt--30">
							<div class="mt--30 row">
								<div class="col-md-12 d-flex justify-content-between">
									<div class="submite__btn">
										<a href="order-summary">BACK</a>
									</div>
									<?php if($flag == 0 && $del_fee > 0) { ?>
										<div class="product-add-to-cart chkt">
											<a href="javascript:void(0);"  class="btn_order" id="btn_order">CONFIRM ORDER</a>
											<!-- <button class="btn btn-inverse btn-inline btn_order" id="btn_order" style="float:right">CONFIRM ORDER</button> -->
										</div>
									<?php } else { echo '<div class="alert alert-danger">Total Weight is Exceeded or Invalid Delivery Method. <a href="checkout" class="text-primary">Please Edit Your Checkout Details.</a></div>'; }  ?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
		<!-- <form method="post" action="https://sandbox.payhere.lk/pay/checkout" id="form_sandbox" style="display:none"> SandBox URL-->
			<!-- <form method="post" action="https://www.payhere.lk/pay/checkout" id="form_sandbox" style="display:none"> -->
				<!-- <input type="hidden" name="merchant_id" value="1211441" readonly> SandBox ID-->

				<?php
				// $hash = '212230';
				// $hash .= $inv_no;
				// $hash .= number_format($g_tot, 2, '.', '');
				// $hash .= 'LKR';
				// $hash .= strtoupper(md5('0bbcbbf7db847bfc9fb633dd00e5d647'));
				// $hash = strtoupper(md5($hash)); 
				?>
				<!-- <input type="hidden" name="merchant_id" value="212230" readonly> --> <!-- SandBox ID-->
				<!-- <input type="hidden" name="return_url" value="https://buddhistbooksonline.com/order-confirm" readonly>
				<input type="hidden" name="cancel_url" value="https://buddhistbooksonline.com/order-cancel" readonly>
				<input type="hidden" name="notify_url" value="https://buddhistbooksonline.com/connection/payment_verify_online" readonly>
				<br>
				<br> -->
			<!-- 	Item Details<br> -->
				<input type="hidden" name="order_id" id="order_id" value="<?php echo $inv_no; ?>" readonly>
				<input type="hidden" name="items" value="Sudila Printers" readonly>
				<br>
				<input type="hidden" name="currency" value="LKR" readonly>
				<input type="hidden" name="amount" id="tot_amnt" value="<?php echo $g_tot; ?>" readonly>
				<br>
				<br>
				<!-- Customer Details<br> -->
				<input type="hidden" name="first_name" value="<?php echo $sqltmp['f_name']; ?>" readonly>
				<input type="hidden" name="last_name" value="<?php echo $sqltmp['l_name']; ?>" readonly>
				<br>
				<input type="hidden" name="email" value="<?php echo $sqltmp['email']; ?>" readonly>
				<input type="hidden" name="phone" value="<?php echo $sqltmp['tel_no']; ?>" readonly>
				<br>
				<input type="hidden" name="address" value="<?php echo $sqltmp['address_1'].' '.$sqltmp['address_2']; ?>" readonly>
				<input type="hidden" name="city" value="<?php echo $sqltmp['city']; ?>" readonly>
				<input type="hidden" name="country" value="<?php echo $country; ?>" readonly>
		<!-- 		<input type="hidden" name="hash" value="<?php echo $hash; ?>">  -->
				<br>
				<br>
	<!-- 		</form> -->
			<!-- End Checkout Area -->
			<!-- Footer Area -->
			<?php include 'common/footer.php'; ?>
			<!-- //Footer Area --> 
		</div>
		<!-- //Main wrapper -->
		<!-- JS Files --> 
		<script type="text/javascript" src="js/vendor/jquery-3.2.1.min.js"></script> 
		<script type="text/javascript" src="js/popper.min.js"></script> 
		<script type="text/javascript" src="js/bootstrap.min.js"></script> 
		<script type="text/javascript" src="js/plugins.js"></script> 
		<script type="text/javascript" src="js/active.js"></script>
		<script type="text/javascript" src="js/jquery.validate.min.js"></script>
		<script type="text/javascript" src="js/add-to-cart.js"></script>
		<script type="text/javascript">

/*$("input[name='payment_method']").on('change', function() {
	var val = $(this).val();
	if(val == '1') {
		$("#collapseOne").addClass("show");
	} else {
		$("#collapseOne").removeClass("show");
	}
});*/

$(document).ready(function () {
	$(".payment_box.payment_method_bacs4").css("display", "block");
});

$("input[name='payment_method']").on('change', function() {
	var val = $(this).val();
	$(".payment_box").css("display", "none");
	
	if(val == '1') {
		$(".payment_box.payment_method_bacs1").css("display", "block");

	} else if(val == '2'){
		$(".payment_box.payment_method_bacs2").css("display", "block");

	} else if(val == '3'){
		$(".payment_box.payment_method_bacs3").css("display", "block");

	} else if(val == '4'){
		$(".payment_box.payment_method_bacs4").css("display", "block");

	} else if(val == '5'){
		$(".payment_box.payment_method_bacs5").css("display", "block");
	}
});


$("#btn_order").click(function() {
	$("#pre_loader").show();
	var tot_amnt = $('#tot_amnt').val();
	if (tot_amnt > 0) {
		var pay_type = $("input[name='payment_method']:checked").val();
		if(pay_type === undefined) {
			$("#pre_loader").fadeOut("slow");
			alert('Please Select Your Payment Method.');

		} else {
			if (pay_type === '3' || pay_type === '4') { // Bank Deposit
				$.post('connection/payment_confirm_bank', {'payment_confirm_bank': 'data', pay_type: pay_type}, function (data) {
					if (data.status === 'success') {
						var inv = data.inv_no;
						window.location.href = 'order-confirm?order_id='+inv;
						
					} else if (data.status === 'mysql error') {
						alert('Something Went Wrong. Please Try Again');
						window.location.href = 'checkout';	

					} else if (data.status === 'empty') {
						$("#pre_loader").fadeOut("slow");
						alert('Please Select Your Payment Method.');

					} else {
						window.location.href = 'sign-in';
					}
				}, "json");
				
			} else if (pay_type === '1' || pay_type === '2' || pay_type === '5') {
				var inv = $("#order_id").val();
					$.post('connection/payment_confirm_bank', {'edit_payment_method': 'data', inv: inv, pay_type: pay_type}, function (data) {
					if (data.status === 'success') {
																				inv = $("#order_id").val();	
																				name = $("#name").val();
																				phone = $("#phone").val();
																				address = $("#address").val();
																				city = $("#city").val();

																				$.post("connection/payment-verify", { 
																					inv_id: inv,
																					name: name,
																					phone: phone,
																					address: address,
																					city: city
																				}, function(data) {
																					if ($.trim(data.status) === '1000') {
																						window.location.assign($.trim(data.gateway_url));
																					} else if ($.trim(data.status) === '1001') {
																						alert('Invalid Request!');
																					} else if ($.trim(data.status) === '1002') {
																						alert('Invalid user credentials!');
																					} else if ($.trim(data.status) === '1016') {
																						alert('Invalid phone number! Please use +947xxxxxxxx format');
																					} else if ($.trim(data.status) === '1017') {
																						alert('Invalid email address');

																					} else if (data.status === '2') {
																						$("#pre_loader").fadeOut("slow");
																						alert('Session Expired. Please Try Again!');
																					} else if (data.status === '' || data.status === null) {
																						$("#pre_loader").fadeOut("slow");
																						alert('Error! Please Try Again later!');
																					} else {
																						$("#pre_loader").fadeOut("slow");
																						$('#errorDiv').slideDown(200, function() {
																							$('#errorDiv').html('<div class="alert alert-danger style2">' + data.message + '</div>');
																							$('#errorDiv').delay(5000).slideUp(100);
																						});
																					}

																				}, "json");

																			} else if (data.status === 'error') {
																				alert('Something Went Wrong. Please Try Again');
																				// window.location.href = 'checkout';

																			} else {
																				window.location.href = 'sign-in';
																			}
																		}, "json");

																	} else {
																		$("#pre_loader").fadeOut("slow");
																		alert('Please Select Your Payment Method.');
																	}
																}

	} else {
		$("#pre_loader").fadeOut("slow");
		alert('Invalid Total Amount');
	}
});

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