<?php
    session_start();
    if(isset($_SESSION['user_id']) && isset($_SESSION['user_name']) && $_SESSION['user_cate'] === "vendor"){
        $user_id = $_SESSION['user_id'] ;
        $username = $_SESSION['user_name'] ;
        $ticket = $_SESSION['last_ticket'] ;
        $company = $_SESSION['company'] ;
        $vendor_image = $_SESSION['vendor_image'] ;
    }else{
        header("Location:vendor_login.php") ;
    }
?>

<?php include "head.php" ; ?>
<body>
	<!-- Main Wrapper -->

	<div class="main-wrapper">

		<!-- Header -->

		<?php include "header.php" ; ?>

		<!-- /Header -->
	<body>

		
			<!-- Breadcrumb -->
			<?php include "breadcrumb.php" ; ?>
			<!-- /Breadcrumb -->
			
			<!-- Page Content -->
			<div class="content">
				<div class="container-fluid">
                    <div class="row">
						<div class="col-md-5 col-lg-4 col-xl-3 theiaStickySidebar">
							
							<!-- Profile Sidebar -->
							<?php include "vendor_sidebar.php" ; ?>
							<!-- /Profile Sidebar -->
							
						</div>
						
						<div class="col-md-7 col-lg-8 col-xl-9">
							<div class="row">
								<div class="col-md-12">
									<div class="card dash-card">
										<div class="card-body">
											<div class="row">
												<div class="col-md-12 col-lg-3">
													<div class="dash-widget dct-border-rht">
														<div class="circle-bar circle-bar1">
															<div class="circle-graph1" data-percent="75">
																<img src="assets/img/icon-01.png" class="img-fluid" alt="patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6>Total</h6>
															<h3><?= $his['tot'] ?></h3>
														</div>
													</div>
												</div>
												
												<div class="col-md-12 col-lg-3">
													<div class="dash-widget dct-border-rht">
														<div class="circle-bar circle-bar2">
															<div class="circle-graph2" data-percent="65">
																<img src="assets/img/icon-02.png" class="img-fluid" alt="Patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6>Approved</h6>
															<h3>
															<?php 
            											        $his_sql = $config->query(" SELECT count(order_id) as app FROM order_master WHERE customer_id = '$user_id' AND order_status = 2") ;
            											        $his = $his_sql->fetch_assoc();
            											        echo $his['app'];
            											    ?>
															</h3>
														</div>
													</div>
												</div>
												
												<div class="col-md-12 col-lg-3">
													<div class="dash-widget dct-border-rht">
														<div class="circle-bar circle-bar3">
															<div class="circle-graph3" data-percent="85">
																<img src="assets/img/icon-03.png" class="img-fluid" alt="Patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6>Pending</h6>
															<h3>
															<?php 
            											        $his_sql = $config->query(" SELECT count(order_id) as pen FROM order_master WHERE customer_id = '$user_id' AND order_status = 1") ;
            											        $his = $his_sql->fetch_assoc();
            											        echo $his['pen'];
            											    ?>
															</h3>
														</div>
													</div>
												</div>
												
												<div class="col-md-12 col-lg-3">
													<div class="dash-widget ">
														<div class="circle-bar circle-bar2">
															<div class="circle-graph2" data-percent="50">
																<img src="assets/img/icon-03.png" class="img-fluid" alt="Patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6>Rejected</h6>
															<h3>
															<?php 
            											        $his_sql = $config->query(" SELECT count(order_id) as rej FROM order_master WHERE customer_id = '$user_id' AND order_status = 0") ;
            											        $his = $his_sql->fetch_assoc();
            											        echo $his['rej'];
            											    ?>
															</h3>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
	                        <div class="row">
								<div class="col-md-12">
									<h4 class="mb-4">Order Histoy</h4>
									<div class="appointment-tab">
										
										<div class="tab-content">
										
											<!-- Upcoming Appointment Tab -->
											<div class="tab-pane show active" id="upcoming-appointments">
												<div class="card card-table mb-0">
													<div class="card-body">
														<div class="table-responsive">
															<table class="table table-hover table-center mb-0">
																<thead>
																	<tr>
																		<th>S.No</th>
																		<th>Order</th>
																		<th>Transaction Id</th>
																		<th>Paid Amount</th>
																		<th>Order Date</th>
																		<th>Status</th>
																	</tr>
																</thead>
																<tbody>
																    <?php 
																        $sno = 1;
                    											        $sql = "SELECT * FROM order_master WHERE customer_id = '$user_id' ORDER BY order_id DESC" ;
                    											        $res = $config->query($sql);
                    											        while($s_row = $res->fetch_assoc()){
                    											            $status = $s_row['order_status'];
                    											    ?>
																	<tr>
																		<td><?= $sno; ?></td>
																		<td><?= $s_row['ticket']; ?></td>
																		<td><?= $s_row['transaction_id']; ?></td>
																		<td><?= $s_row['order_price'] + $s_row['add_on']; ?></td>
																		<td><?= date('d-m-Y',strtotime($s_row['order_on'])); ?></td>
																		<td>
																		    <?php
																		        if($status == 2){
																		            $o_status = "Success" ;
																		            $btn = "success" ;
																		        }else if($status == 1){
																		            $o_status = "Pending" ;
																		            $btn = "warning" ;
																		        }else{
																		            $o_status = "Failed" ;
																		            $btn = "danger" ;
																		        }
																		    ?>
																			<div class="table-action">
																				<a href="javascript:void(0);" class="btn btn-sm bg-<?= $btn; ?>-light"><?= $o_status; ?></a>
																			</div>
																		</td>
																	</tr>
																	<?php $sno++; } ?>
																</tbody>
															</table>		
														</div>
													</div>
												</div>
											</div>
											<!-- /Upcoming Appointment Tab -->
									   
											
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>


				</div>

			</div>		
			<!-- /Page Content -->
   	<!-- Footer -->

		<?php include "footer.php" ; ?>

		<!-- /Footer -->
	</div>

	<!-- /Main Wrapper -->

	<!-- jQuery -->

	<script src="assets/js/jquery.min.js"></script>

	<!-- Bootstrap Core JS -->

	<script src="assets/js/popper.min.js"></script>

	<script src="assets/js/bootstrap.min.js"></script>

	<!-- Sticky Sidebar JS -->
    <script src="assets/plugins/theia-sticky-sidebar/ResizeSensor.js"></script>
    <script src="assets/plugins/theia-sticky-sidebar/theia-sticky-sidebar.js"></script>
	
	<!-- Circle Progress JS -->
	<script src="assets/js/circle-progress.min.js"></script>
		
	<!-- Slick JS -->

	<script src="assets/js/slick.js"></script>

	<!-- Custom JS -->

	<script src="assets/js/script.js"></script>

</body>

<!-- doccure/  30 Nov 2019 04:11:53 GMT -->

</html>