<!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['pg'])) {
	$pg = htmlspecialchars(strip_tags(trim($_GET['pg'])), ENT_QUOTES, 'UTF-8');
	if($pg == 1) { // Pending Orders
		$result = mysqli_query($conn, "SELECT id, inv_no, order_date, order_status, grand_total, date_finish FROM order_details WHERE order_status = 0 AND user_id='$uid' AND guest=0 ORDER BY id DESC");
		$title = 'Pending Orders';
	
	} else if($pg == 2) { // Accepted Orders
		$result = mysqli_query($conn, "SELECT id, inv_no, order_date, order_status, grand_total, date_accept, date_finish FROM order_details WHERE order_status = 1 AND user_id='$uid' AND guest=0 ORDER BY id DESC");
		$title = 'Accepted Orders';
	
	} else if($pg == 3) { // Order History
		$result = mysqli_query($conn, "SELECT id, inv_no, order_date, order_status, grand_total, date_accept, date_finish, date_delivery, date_del_confirm  FROM order_details WHERE user_id='$uid' AND guest=0 ORDER BY id DESC");
		$title = 'Order History';
	
	} else {
		$redirectUrl = "index";
		echo "<script type=\"text/javascript\">";
		echo "window.location.href = '$redirectUrl'";
		echo "</script>";		
	}

} else {
	$redirectUrl = "index";
	echo "<script type=\"text/javascript\">";
	echo "window.location.href = '$redirectUrl'";
	echo "</script>";	
}
?>   
    <div class=row> 
    <!-- Start Row -->
      <div class=col-lg-12>
          <!-- Table1 -->
		  <div class="widget-container fluid-height clearfix">
			<div class=heading> <?php echo $title; ?></div>
			<div class="widget-content padded clearfix">
			  <div class=table-responsive>
				<table class="table table-bordered table-striped table-hover" id=dataTable1>
				  <thead>
				    <th>ID</th>
					<th>Order Date</th>
					<th>Invoice No</th>
					<th>Total Payment (Rs)</th>
					<?php if($pg == 2) { ?><th>Accepted Date</th><?php } ?>
					<?php if($pg == 3) { ?><th>Order Status</th>
					<?php } ?>
					<td>View Order</td>
				  </thead>
				  <tbody>
					<?php
					$xx = 0;
					while ($row = mysqli_fetch_array($result)){ $xx++;
					?>
					<tr>
					  <td><?php echo $xx; ?>.</td>
					  <td><?php echo $row['order_date']; ?></td>
					  <td><?php echo $oid = $row['inv_no']; ?></td>
					  <td><?php echo $row['grand_total']; ?></td>
					  <?php if($pg == 2) { ?><td><?php echo $row['date_accept']; ?></td><?php } ?>
					  <?php if($pg == 3) { ?><td><?php
					  if($row['order_status'] == 0) { echo '<span class="label label-warning">Pending</span>'; }
					  if($row['order_status'] == 1) { echo '<span class="label label-success">Accepted</span>'.' ('.$row['date_accept'].')'; }
					  if($row['order_status'] == 2) { echo '<span class="label label-danger">Rejected</span>'.' ('.$row['date_accept'].')'; }
					  if($row['order_status'] == 3) { echo '<span class="label label-info">Delivery Pending</span>'.' ('.$row['date_delivery'].')'; }
					  if($row['order_status'] == 4) { echo '<span class="label label-primary">Delivery Confirmed</span>'.' ('.$row['date_del_confirm'].')'; }
					  if($row['order_status'] == 5) { echo '<span class="label label-success">Finished Order</span>'.' ('.$row['date_finish'].')'; } ?></td><?php } ?>
					  <td align="center"><a href="order-details?inv=<?php echo $oid; ?>" class="btn btn-primary btn-sm">View</a></td>
					</tr>
					<?php  } ?>
				  </tbody>
				</table>
			  </div>
			</div>
		  </div>
		  <!-- End Table1 -->   
      </div>
    </div>
    <!-- End Row --> 
  </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>