<?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-4">
													<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>POST ADD</h6>
															<?php
            											        $post_sql = "SELECT (SELECT count(event_id) FROM event_post WHERE vendor_id = '$user_id' And e_status = 2)as appr,
            											                    (SELECT count(event_id) FROM event_post WHERE vendor_id = '$user_id' And e_status = 1 ) as pend FROM event_post WHERE vendor_id = '$user_id' " ;
            											        $post_res = $config->query($post_sql);
            											        $post = $post_res->fetch_assoc();
            											    ?>
															<h3><?= $post['pend']; ?> / <?= $post['appr'] ?></h3>
														</div>
													</div>
												</div>
												
												<!--<div class="col-md-12 col-lg-4">-->
												<!--	<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>Today Visit</h6>-->
												<!--			<h3>0</h3>-->
												<!--		</div>-->
												<!--	</div>-->
												<!--</div>-->
												
												<div class="col-md-12 col-lg-4">
													<div class="dash-widget dct-border-rht">
														<div class="circle-bar circle-bar3">
															<div class="circle-graph3" data-percent="50">
																<img src="assets/img/icon-03.png" class="img-fluid" alt="Patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6>Enquiry</h6>
															<h3>
															<?php
            											        $sql_list = $config->query("SELECT count(apply_id) as tot FROM apply_request WHERE event_id = '$evt_id' ");
            											        $res_list = $sql_list->fetch_assoc();
            											        echo $res_list['tot'];
        											        ?>
															</h3>
														</div>
													</div>
												</div>
												<div class="col-md-12 col-lg-4">
													<div class="dash-widget">
														<div class="circle-bar circle-bar2">
															<div class="circle-graph2" data-percent="60">
																<img src="assets/img/icon-03.png" class="img-fluid" alt="Patient">
															</div>
														</div>
														<div class="dash-widget-info">
															<h6 style="font-size: 12px;">Pending / Approved</h6>
															<?php
            											        $sql = "SELECT (SELECT count(order_id) as tot FROM order_master WHERE customer_id = '$user_id' And order_status = 1 ) as tot 
            											        ,(SELECT count(order_id) as tot FROM order_master WHERE customer_id = '$user_id' And order_status = 2 ) as approve FROM order_master " ;
            											        $res = $config->query($sql);
            											        if($res->num_rows > 0){
            											        $row = $res->fetch_assoc();
            											    ?>
															<h3><?= $row['tot']; ?> / <?= $row['approve']; ?> </h3>
															<?php }else{ ?>
															<p class="text-muted">No Requests</p>
															<?php } ?>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							
							<div class="row">
								<div class="col-md-12">
								    <div class="d-flex justify-content-between align-items-start">
								        <h4 class="mb-4">Total Enquiry</h4>
									    <!--<a class="btn btn-sm bg-info-light" data-target="#payRequest" data-toggle="modal"><i class="fas fa-wallet"></i> Pay Request</a>-->
								    </div>
									<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>Event</th>
																		<!--<th>Category</th>-->
																		<!--<th>View</th>-->
																		<th>Request</th>
																		<th>Status</th>
																		<th>Amount</th>
																	</tr>
																</thead>
																<tbody>
																    <tr>
																	    <?php
																	        $sno = 1;
            																$sql = "SELECT * FROM event_post WHERE vendor_id = '$user_id' AND e_status = 2 ORDER BY event_id DESC" ;
                        											        $res = $config->query($sql);
                        											        if($res->num_rows > 0){
                        											        while($list = $res->fetch_assoc()){
                        											            $status = $list['e_status'];
                        											            $cate_id = $list['sub_cate_id'];
                        											            $evt_id = $list['event_id'];
                        											            $pack_id = $list['pack_id'];
																	    ?>
																	    <td><?= $sno;?></td>
																	    <td><?= $list['e_title'] ?></td>
																		<?php
                        											     //   $sub_sql = "SELECT * FROM sub_category WHERE Sub_Category_Id = '$cate_id' AND Sub_Category_status = 1 " ;
                        											     //   $sub_res = $config->query($sub_sql);
                        											     //   $sub = $sub_res->fetch_assoc();
                    											        ?>
                    											        <!--<td><?#= $sub['Sub_Category_Name'] ?></td>-->
																		<!--<td>-->
																		<!--    <a href="javascript:void(0);" class="btn btn-sm bg-info-light" style="cursor: unset;">0</a>-->
																		<!--</td>-->
																		<td>
																		    <a href="applied.php?event=<?= $evt_id ?>" class="btn btn-sm bg-primary-light" >
																		        <?php
                                											        $sql_list = $config->query("SELECT COUNT(apply_id) as tot, SUM(comm_amt) as total_comm, SUM(entry_fees) as amt FROM apply_request WHERE event_id = '$evt_id' ");
                                											        $res_list = $sql_list->fetch_assoc();
                                											        echo $res_list['tot'];
                            											        ?>   
																		    </a>
																		</td>
																	    <?php
																	       // $pack_sql = $config->query("SELECT * FROM package_master WHERE pack_id = '$pack_id' AND pack_status = 1 ");
                        // 											        $pack = $pack_sql->fetch_assoc();
                        // 											        $app_sql = $config->query("SELECT count(user_id) as tot FROM apply_request WHERE event_id = '$evt_id' ");
                        // 											        $app = $app_sql->fetch_assoc();
                        // 											        $comm = ($app['tot'] * $list['entry_fees']) * ($pack['pack_commission']/100);
                        // 											        $amt = (($app['tot'] * $list['entry_fees']) - $comm);
                        // 											        $total += $amt ;
                    											        ?> 
																	    <?php
																	       // $pack_sql = $config->query("SELECT * FROM package_master WHERE pack_id = '$pack_id' AND pack_status = 1 ");
                        // 											        $pack = $pack_sql->fetch_assoc();
                        // 											        $amt = $pack['pack_commission'];
                        											     //   $app_sql = $config->query("SELECT count(user_id) as tot FROM apply_request WHERE event_id = '$evt_id' ");
                        											     //   $app = $app_sql->fetch_assoc();
                        											     //   $comm = ($app['tot'] * $list['entry_fees']) * ($pack['pack_commission']/100);
                        											     //   $amt = (($app['tot'] * $list['entry_fees']) - $comm);
                        											     //   $total += $amt ;
                    											        ?> 
																		<td>
                        											        <?php 
                                        								        if($status == 1){
                                        								            $cur_status = "Pending";
                                        								            $btn_color = "info" ;
                                        								        }else if($status == 2){
                                        								            $cur_status = "Active";
                                        								            $btn_color = "success" ;
                                        								        }else if($status == 0){
                                        								            $cur_status = "Rejected";
                                        								            $btn_color = "danger" ;
                                        								        }
                                        								    ?>
																		    <a href="#" class="btn btn-sm bg-<?= $btn_color; ?>-light" > <?= $cur_status; ?></a>
																		</td>
											                            <td><?=$res_list['amt']-=$res_list['total_comm']?> 
											                            <input type="hidden" class="amt" value="<?=$res_list['amt']-=$res_list['total_comm']?>">
											                            </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>