<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
<title>Sudila Printers - Kurunegala Sri Lanka</title>
<link href="stylesheets/font_css.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap.min.css" media=all rel=stylesheet />
<link href="stylesheets/font-awesome.min.css" media=all rel=stylesheet />
<link href="stylesheets/hightop-font.css" media=all rel=stylesheet />
<link href="stylesheets/isotope.css" media=all rel=stylesheet />
<link href="stylesheets/jquery.fancybox.css" media=all rel=stylesheet />
<link href="stylesheets/fullcalendar.css" media=all rel=stylesheet />
<link href="stylesheets/wizard.css" media=all rel=stylesheet />
<link href="stylesheets/select2.css" media=all rel=stylesheet />
<link href="stylesheets/morris.css" media=all rel=stylesheet />
<link href="stylesheets/datatables.css" media=all rel=stylesheet />
<link href="stylesheets/datepicker.css" media=all rel=stylesheet />
<link href="stylesheets/timepicker.css" media=all rel=stylesheet />
<link href="stylesheets/colorpicker.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap-switch.css" media=all rel=stylesheet />
<link href="stylesheets/bootstrap-editable.css" media=all rel=stylesheet />
<link href="stylesheets/daterange-picker.css" media=all rel=stylesheet />
<link href="stylesheets/typeahead.css" media=all rel=stylesheet />
<link href="stylesheets/summernote.css" media=all rel=stylesheet />
<link href="stylesheets/ladda-themeless.min.css" media=all rel=stylesheet />
<link href="stylesheets/social-buttons.css" media=all rel=stylesheet />
<link href="stylesheets/jquery.fileupload-ui.css" media=screen rel=stylesheet />
<link href="stylesheets/dropzone.css" media=screen rel=stylesheet />
<link href="stylesheets/nestable.css" media=screen rel=stylesheet />
<link href="stylesheets/pygments.css" media=all rel=stylesheet />
<link href="stylesheets/style.css" media=all rel=stylesheet />
<link href="stylesheets/color/green.css" media=all rel="alternate stylesheet" title=green-theme />
<link href="stylesheets/color/orange.css" media=all rel="alternate stylesheet" title=orange-theme />
<link href="stylesheets/color/magenta.css" media=all rel="alternate stylesheet" title=magenta-theme />
<link href="stylesheets/color/gray.css" media=all rel="alternate stylesheet" title=gray-theme />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name=viewport>
<link rel="shortcut icon" type="image/x-icon" href="../image/favicon.ico">
</head>

<body class="page-header-fixed bg-1">
<div class=modal-shiftfix>
<?php include "common/header.php"; ?>
  <div class="container-fluid main-content"> 
 
<?php 
if(isset($_GET['inv'])) {
	$inv = htmlspecialchars(strip_tags(trim($_GET['inv'])), ENT_QUOTES, 'UTF-8');	
	if(empty($inv)) {
		$redirectUrl = "online-orders?pg=3";
		echo "<script type=\"text/javascript\">";
		echo "window.location.href = '$redirectUrl'";
		echo "</script>";
	
	} else {
		$sql_ord = mysqli_query($conn, "SELECT * FROM order_details WHERE inv_no='$inv' AND user_id='$uid' AND guest=0");
		if(mysqli_num_rows($sql_ord) == 0) { ?>

		<div class=invoice>
      <div class=row>

          <div class="col-md-3">
          </div>
		  
		  <div class="col-md-6">
            <form action="order-details" class="form-horizontal" id="frm" method="get">
              <div class="form-group" style="margin-bottom:5px">
                <input type="text" class="form-control pull-left" id="inv" name="inv" autocomplete="off" placeholder="Enter Order ID" style="width:65%; margin-right:8px;" required>
                <button class="btn btn-primary" type="submit">Search</button>
              </div>
            </form><br>
			<p> Invalid Order ID.</p>
          </div>		
		

          </div>
        </div>
<?php	} else {
			$sql_inv = mysqli_fetch_assoc($sql_ord); 
		 	$order_st = $sql_inv['order_status']; ?>
		
	<div class=page-title>
      <h1> Order Details </h1>
    </div>
    <div class=invoice>
      <div class=row>
        <div class=col-lg-12>
          <div class="row invoice-header">
            <div class="col-md-6">
              <h2> Order ID: <?php echo $inv; ?> </h2>
              <p> <?php echo $sql_inv['order_date']; ?> </p>
            </div>
          </div>
        </div>
      </div>
      <div class=row>
        <div class=col-md-6>
          <div class=well> <strong>Delivery Address</strong>
            <h3> <?php echo $sql_inv['f_name'].' '.$sql_inv['l_name']; ?> </h3>
            <p> <?php echo $sql_inv['address_1'].', '.$sql_inv['address_2'].', '.$sql_inv['city']; ?><br>
              <?php if(!empty($sql_inv['district'])) { echo $sql_inv['district'].', '; } echo $sql_inv['country']; ?><br>
              <?php if(!empty($sql_inv['postal_code'])) { echo $sql_inv['postal_code']; }?>
			 <br>
             <?php echo $sql_inv['tel_no']; ?><br>
              <?php echo $sql_inv['email']; ?></p>
          </div>
        </div>

      </div>
      <div class=row>
        <div class=col-lg-12>
          <div class="widget-container fluid-height">
            <div class="widget-content padded clearfix">
			<b>Delivery Method:</b> <?php
				if($sql_inv['delivery_type'] == 1) {
					$del_type = 'Postal';

				} else if($sql_inv['delivery_type'] == 2) {
					$del_type = 'Courier Service';

				} else if($sql_inv['delivery_type'] == 3) {
					$del_type = 'Expedited Mail Service (EMS)';

				} else if($sql_inv['delivery_type'] == 4) {
					$del_type = 'Cash on Delivery';

				} else {
					$del_type = '';
				}
				echo $del_type;
			?><br>
			<b>Payment Method:</b> <?php
			if($sql_inv['pay_method'] == 1) {
				$pay_type = 'Credit/Debit Card';

			} else if($sql_inv['pay_method'] == 2) {
				$pay_type = 'Mobile Wallet';
			
			} else if($sql_inv['pay_method'] == 3) {
				$pay_type = 'Bank Deposit';
			
			} else if($sql_inv['pay_method'] == 4) {
				$pay_type = 'Cash on Delivery';
			
			} else if($sql_inv['pay_method'] == 5) {
				$pay_type = 'Internet Banking';
			
			} else {
				$pay_type = '';
			}
			echo $pay_type;
			?>
			<b class="pull-right">Order Status: <?php
			if($sql_inv['order_status'] == 0) { echo 'Pending'; }
			if($sql_inv['order_status'] == 1) { echo 'Accepted'.' ('.$sql_inv['date_accept'].')'; }
			if($sql_inv['order_status'] == 2) { echo 'Rejected'; }
			if($sql_inv['order_status'] == 3) { echo 'Delivery Pending'.' ('.$sql_inv['date_delivery'].')'; }
			if($sql_inv['order_status'] == 4) { echo 'Delivery Confirmed'.' ('.$sql_inv['date_del_confirm'].')'; }
			if($sql_inv['order_status'] == 5) { echo 'Order Finish'.' ('.$sql_inv['date_finish'].')'; }
			?></b>
			<hr>
              <div class=table-responsive>
			  <table class="table table-striped invoice-table">
                <thead>
					<th class="center">#</th>
					<th>Image</th>
					<th>Name</th>
					<th>ISBN</th>
					<th>Weight (g)</th>
					<th>Unit Price (Rs)</th>
					<th>Discounted Price (Rs)</th>
					<th>Qty</th>
					<th>Subtotal (Rs)</th>
                    </thead>
					<tbody>
					<?php $sql_c = mysqli_query($conn, "SELECT * FROM cart_details WHERE inv_no = '$inv'");
					$x = 0;
					$s_tot = $dis_tot = $w_tot = 0;
					while($row_c = mysqli_fetch_array($sql_c)) { $x++; ?>
						<tr>
							<td class="center"><?php echo $x; ?>.</td>
							<td><img src="../image/books/thumb/<?php echo $row_c['img']; ?>" width="50px"></td>
							<td><?php echo $row_c['name']; ?></td>
							<td><?php echo $row_c['isbn']; ?></td>
							<td><?php echo $row_c['weight']; ?></td>
							<td align="right"><?php echo $row_c['item_price']; ?></td>
							<td align="right"><?php echo $row_c['price']; ?></td>
							<td align="right"><?php echo $row_c['Qty']; ?></td>
							<td align="right"><?php $subtot = $row_c['price']*$row_c['Qty']; echo number_format($subtot, 2);  ?></td>
						</tr>
					<?php 
					$w_tot += $row_c['weight'];
					$dis_tot += $subtot; $s_tot += $row_c['item_price']*$row_c['Qty']; } ?>
					</tbody>
                <tfoot>
                  <tr>
                    <td class=text-right colspan=7><strong>Subtotal</strong></td>
                    <td class=text-right colspan=2> LKR <?php echo number_format($s_tot, 2); ?> </td>
                  </tr>
                  <tr>
                    <td class=text-right colspan=7><strong>Total Discount</strong></td>
                    <td class=text-right colspan=2> LKR  <?php echo number_format($s_tot-$dis_tot, 2); ?> </td>
                  </tr>
				  <tr>
                    <td class=text-right colspan=7><strong>Total Amount</strong></td>
                    <td class=text-right colspan=2> LKR  <?php echo number_format($dis_tot, 2); ?> </td>
                  </tr>
				  <tr>
                    <td class=text-right colspan=7><strong>Delivery Charges (<?php echo $w_tot; ?>g)</strong></td>
                    <td class=text-right colspan=2> LKR  <?php echo number_format($sql_inv['delivery_chg'], 2); ?> </td>
                  </tr>
                  <tr>
                    <td class=text-right colspan=7><h4 class=text-primary> GRAND TOTAL </h4></td>
                    <td class=text-right colspan=2><h4 class=text-primary>LKR  <?php echo number_format($sql_inv['grand_total'], 2); ?> </h4></td>
                  </tr>
                </tfoot>
              </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
	
<?php		}
	}

} else {
	$redirectUrl = "index";
	echo "<script type=\"text/javascript\">";
	echo "window.location.href = '$redirectUrl'";
	echo "</script>";	
}
?>

  </div>

</div>
<script src="javascripts/jquery-1.10.2.min.js"></script> 
<script src="javascripts/jquery-ui.js"></script> 
<script src="javascripts/bootstrap.min.js"></script> 
<script src="javascripts/raphael.min.js"></script> 
<script src="javascripts/selectivizr-min.js"></script> 
<script src="javascripts/jquery.mousewheel.js"></script> 
<script src="javascripts/jquery.vmap.min.js"></script> 
<script src="javascripts/jquery.vmap.sampledata.js"></script> 
<script src="javascripts/jquery.vmap.world.js"></script> 
<script src="javascripts/jquery.bootstrap.wizard.js"></script> 
<script src="javascripts/fullcalendar.min.js"></script> 
<script src="javascripts/gcal.js"></script> 
<script src="javascripts/jquery.dataTables.min.js"></script> 
<script src="javascripts/datatable-editable.js"></script> 
<script src="javascripts/jquery.easy-pie-chart.js"></script> 
<script src="javascripts/excanvas.min.js"></script> 
<script src="javascripts/jquery.isotope.min.js"></script> 
<script src="javascripts/isotope_extras.js"></script> 
<script src="javascripts/modernizr.custom.js"></script> 
<script src="javascripts/jquery.fancybox.pack.js"></script> 
<script src="javascripts/select2.js"></script> 
<script src="javascripts/styleswitcher.js"></script> 
<script src="javascripts/wysiwyg.js"></script> 
<script src="javascripts/typeahead.js"></script> 
<script src="javascripts/summernote.min.js"></script> 
<script src="javascripts/jquery.inputmask.min.js"></script> 
<script src="javascripts/jquery.validate.js"></script> 
<script src="javascripts/bootstrap-fileupload.js"></script> 
<script src="javascripts/bootstrap-datepicker.js"></script> 
<script src="javascripts/bootstrap-timepicker.js"></script> 
<script src="javascripts/bootstrap-colorpicker.js"></script> 
<script src="javascripts/bootstrap-switch.min.js"></script> 
<script src="javascripts/typeahead.js"></script> 
<script src="javascripts/spin.min.js"></script> 
<script src="javascripts/ladda.min.js"></script> 
<script src="javascripts/moment.js"></script> 
<script src="javascripts/mockjax.js"></script> 
<script src="javascripts/bootstrap-editable.min.js"></script> 
<script src="javascripts/xeditable-demo-mock.js"></script> 
<script src="javascripts/xeditable-demo.js"></script> 
<script src="javascripts/address.js"></script> 
<script src="javascripts/daterange-picker.js"></script> 
<script src="javascripts/date.js"></script> 
<script src="javascripts/morris.min.js"></script> 
<script src="javascripts/skycons.js"></script> 
<script src="javascripts/fitvids.js"></script> 
<script src="javascripts/jquery.sparkline.min.js"></script> 
<script src="javascripts/dropzone.js"></script> 
<script src="javascripts/jquery.nestable.js"></script> 
<script src="javascripts/main.js"></script> 
<script src="javascripts/respond.js"></script>
</body>
</html>