<?php 
    include "head.php" ;
    session_start();
    $page = "Package" ;
    date_default_timezone_set("Asia/Kolkata");

    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") ;
    }
?>
	<body>

		<!-- Main Wrapper -->
		<div class="main-wrapper">
		
			<!-- Header -->
			<?php include "header.php" ; ?>
			<!-- /Header -->
			
			<!-- 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="d-flex justify-content-between align-items-start">
									    <h4 class="mb-4">Our Packages</h4>
    									<a href="#" class="btn btn-sm bg-info-light" data-toggle="modal" data-target="#buypack">
    										<i class="fas fa-money-check"></i> Buy Pack
    									</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>Package</th>
																		<th>Category</th>
																		<th>Duration</th>
																		<th></th>
																		<th>Commission</th>
																		<th class="text-center">Paid Amount</th>
																	</tr>
																</thead>
																<tbody>
																    <?php 
                                    						            $sql = "SELECT * FROM package_master WHERE pack_status = 1 " ;
                                    							        $res = $config->query($sql);
                                    							        while($row = $res->fetch_assoc()){
                                    							            $sub_cate = $row['pack_sub_cate'];
                                    							    ?>
																	<tr>
																		<td>
																			<h2 class="table-avatar">
																				<!--<a href="patient-profile.html" class="avatar avatar-sm mr-2"><img class="avatar-img rounded-circle" src="assets/img/patients/patient.jpg" alt="User Image"></a>-->
																				<a href="patient-profile.html"><?= $row['pack_name'] ?></a>
																			</h2>
																		</td>
																		<td>
																		    <?php 
                                            						            $sub_sql = "SELECT * FROM sub_category WHERE Sub_Category_id = '$sub_cate' AND Sub_Category_Status = 1 " ;
                                            							        $sub_res = $config->query($sub_sql);
                                            							        $sub = $sub_res->fetch_assoc();
                                            							    ?>
																		    <span class="d-block text-info"><?= $sub['Sub_Category_Name'] ?></span></td>
																		<td><?= $row['pack_duration'] ?></td>
																		<td>
																			<div class="table-action">
																				<button href="javascript:void(0);" class="btn btn-sm bg-success-light request" value="<?= $row['pack_id']; ?>">
																					<i class="fas fa-check-circle"></i> Request
																				</button>
																			</div>
																		</td>
																		<td><?= $row['pack_commission'] ?> %</td>
																		<td class="text-center">Rs.<?= $row['pack_cost'] ?></td>
																		
																	</tr>
																	<?php } ?>
																</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 -->
	    <!-- Appointment Details Modal -->
		<div class="modal fade custom-modal" id="buypack">
			<div class="modal-dialog modal-dialog-centered">
				<div class="modal-content">
					<div class="modal-header">
						<h5 class="modal-title">Scan To Pay</h5>
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
					</div>
					<div class="modal-body">
						<ul class="info-details">
						    
							<li>
								<div class="details-header">
									<div class="row">
										<div class="col-md-12">
										    <img class="qrcode img-fluid" src="assets/img/qrcode/qrcode.jpg" alt="payment QR-Code">
										</div>
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<!-- /Appointment Details Modal -->

		<!-- 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>
		
		<!-- Custom JS -->
		<script src="assets/js/script.js"></script>
		
		<script>
            $('.request').on('click', function() {
                let rid = $(this).val();
                let userId = <?php echo $_SESSION['user_id']; ?>;
                let ticket = <?php echo rand(999999,111111); ?>;
                swal({
                    title: "Request to activate package",
                    text: "Enter your transaction id",
                    content: "input",
                    icon: "info",
                    buttons: true,
                    dangerMode: true,
                }).then((value) => {
                    if(value) {
                        $.ajax({
                            type: "POST",
                            url: "order_confirm.php",
                            data: {rid:rid,userId:userId,ticket:ticket,tran_id:value},
                            success: function(data){
                                swal({
                                    title: "Your ticket "+ticket, 
                                    text: "Our team will contact you soon.If you have any emergency contact admin!",
                                    icon: "success",
                                    button: {
                                        className: "agree",
                                    },
                                });
                                $('.agree').on('click', function() {
                                    window.location.href="vendor_dashboard.php";
                                });
                            }
                        });
                  } else {
                    swal("Request Cancelled.",{
                        icon: "error",
                    });
                  }
                });
            });
            
		</script>
		<script>
    		<?php if(isset($_SESSION['check']) && !empty($_SESSION['check'])) { ?>
    		    swal({
                    title: "<?= $_SESSION['check'] ?>", 
                    text: "",
                    icon: "<?= $_SESSION['alert'] ?>",
                    button: {
                        className: "agree",
                    },
                });
            <?php unset($_SESSION['check']) ; } ?>
        </script>

	</body>

<!-- doccure/my-patients.html  30 Nov 2019 04:12:09 GMT -->
</html>



