<?php
include ('../ro_head.php'); 
isauth_have("Embassy report");
?>
<link href="../assets/css/daterangepicker.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../assets/global/plugins/select2/select2.css"/>
<link rel="stylesheet" type="text/css" href="../assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/dt/jq-2.1.4,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.9,af-2.0.0,b-1.0.3,b-colvis-1.0.3,b-html5-1.0.3,b-print-1.0.3,se-1.0.1/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/r/dt/jq-2.1.4,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.9,af-2.0.0,b-1.0.3,b-colvis-1.0.3,b-html5-1.0.3,b-print-1.0.3,se-1.0.1/datatables.min.js"></script>

<style type="text/css">
	h3{
		background-color: #c6deef;
		padding: 10px 0px 10px 20px;
		font-size: 18px;
	}
.table-scrollable {
    overflow-x: initial;
    overflow-y: initial;
    }
    
</style>
<!-- END PAGE LEVEL STYLES -->

<!-- BEGIN CONTAINER -->
<div class="page-container">
<?php include_once("../ro_sidebar.php"); ?>
    <!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">


			<!-- BEGIN PAGE HEADER-->

			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="portlet box grey-cascade">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-globe"></i>
								<?php 

                                $_REQUEST['date1']=substr($_REQUEST["dates"], 0, 10);
                                $_REQUEST['date2']=substr($_REQUEST["dates"], -10);
                                
								$totalvisafee=0;
							  	$totalservicefee=0;
							  	$totalbankfee=0;

								$sql = "";

								if(isset($_REQUEST['date1']) && $_REQUEST['date2']!=NULL && $_REQUEST['location']!=NULL) {

						            $var = $_REQUEST['date1'];
									$date1= date('Y-m-d', strtotime($var));

									$var = $_REQUEST['date2'];									
									$date2= date('Y-m-d', strtotime($var));


									if($_REQUEST['location']!=0) { 
										
										$sql = "select * from applicant_table where applicant_table.deliverycenter='$_REQUEST[location]' AND DATE(created_date) between '".$date1."' AND '".$date2."'"; 
										$printtitle="Delivery Type Report for ".get_deliverycenter_name($_REQUEST['location'],$con)." (Date: ".date('d-m-Y', strtotime($date1))." - ".date('d-m-Y', strtotime($date2)).")"; 
									}

									else{ 
										$sql = "select * from applicant_table where DATE(created_date) between '".$date1."' AND '".$date2."'"; 
										$printtitle="Delivery Type Report for All Location (Date: ".date('d-m-Y', strtotime($date1))." - ".date('d-m-Y', strtotime($date2)).")"; 
									}

						            $result = mysqli_query($con,$sql);

						            
						        }

						        elseif($_REQUEST['date1']==NULL && $_REQUEST['date2']==NULL && $_REQUEST['location']!=NULL) {

						        	if($_REQUEST['location']==0) { 

						        		$sql="select * from applicant_table"; 
						        		$printtitle="Delivery Type Report for All location";
						        	}

						        	else { 
						        		$sql="select * from applicant_table where applicant_table.deliverycenter='$_REQUEST[location]'"; 
						        		$printtitle="Delivery Type Report for ".get_deliverycenter_name($_REQUEST['location'],$con);
						        	}

									$result = mysqli_query($con,$sql);

									
									
						        }

					
						        else {

									$result = mysqli_query($con,"select * from applicant_table WHERE DATE(created_date) >= CURDATE() AND DATE(created_date) < CURDATE() + INTERVAL 1 DAY");

									$printtitle="Delivery Type Report (Date: ".$dt->format('d-m-Y').")";
									
						        }
						        
						        echo $printtitle;
								
								?>
								
							</div>
						</div>
						<div class="portlet-body">
							<div class="table-toolbar">

								<?php get_location_daterange($con,"report_daily_delimode.php"); ?>	

							</div>
							
							<table class="table table-striped table-bordered table-hover" id="sample_2">
							<thead>
							<tr class="backcol">
								
								 			<th style="width:05%">Seq No</th>
								 			<th style="width:05%">Reference No</th>
                                            <th style="width:10%">Applicant Name</th>
                                            <th style="width:10%">Passport No</th>
                                            <th style="width:10%">Visa Category</th> 
                                            
                                            <th style="width:10%">Visa Type</th>
                                            <th style="width:10%">Delivery Mode</th>
                                           
                                                        
                                            
							</tr>

							</thead>
							<tbody>

								<?php

								while($row = mysqli_fetch_array($result)){
							?>


								<tr  class='odd gradeX'>
								<td><?php echo $row['v_uid'];?></td>
								<td><?php echo $row['refer_no'];?></td>
								
								<td><?php echo $row['surname']." ".$row['givenname'];?></td>
								<td><?php echo $row['passport_no'];?></td>
								<td><?php echo get_parent_mainvisatype_name($row['visa_type'],$con);?></td>
								<td><?php echo get_visatype_name($row['visa_type'],$con);?></td>

								<td>
									<?php echo get_deliverymode_name($row['delitypeid'],$con); ?>
								</td>
								
							
															
							</tr>
						
							<?php }	
						/*	echo "<tr class='odd gradeX'>";
                               
                                echo "<td></td>";

                                echo "<td></td>";                          

                                echo "<td></td>";

                                echo "<td></td>";

                                echo "<td></td>";
                                
                                echo "<td><b>Total</b></td>";

                                echo "<td><b>".number_format($totalvisafee,2)."</b></td>";

                               echo "<td></td>";

                                echo "</tr>";*/

                                ?>
							</tbody>
							</table>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</div>
				</div>
			</div>

	


			<!-- END PAGE CONTENT-->
		</div>
	</div>
	<!-- END CONTENT -->

</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<?php include_once("../ro_footer.php"); ?>

<!-- END FOOTER -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<?php include_once("../ro_js.php"); ?>
<!-- <script src="../assets/global/plugins/jquery.min.js" type="text/javascript"></script> -->

<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="../assets/global/plugins/select2/select2.min.js"></script>
<script type="text/javascript" src="../assets/global/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="../assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="../assets/js/table-managed.js" type="text/javascript"></script>
<!-- <script src="../assets/global/plugins/bootstrap-daterangepicker/daterangepicker.min.js" type="text/javascript"></script> -->
<script src="../assets/admin/layout/scripts/components-picker.js"></script>
<script>
jQuery(document).ready(function() {
   Metronic.init(); // init metronic core components
Layout.init(); // init current layout
QuickSidebar.init(); // init quick sidebar
Demo.init(); // init demo features
  // TableManaged.init();
  ComponentsPickers.init();
});
</script>
<script type="text/javascript">
$(function() {

    var start = moment().subtract(1, 'days');
    var end = moment();

    function cb(start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
    }

    $('#reportrange').daterangepicker({
        startDate: start,
        endDate: end,
        ranges: {
           'Today': [moment(), moment()],
           'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
           'Last 7 Days': [moment().subtract(6, 'days'), moment()],
           'Last 30 Days': [moment().subtract(29, 'days'), moment()],
           'This Month': [moment().startOf('month'), moment().endOf('month')],
           'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        }
    }, cb);

    cb(start, end);
    
});

$( document ).ready(function() {	
	$('#sample_2').DataTable({
		
		"pageLength": -1,
        "paging": false,
        "info": true,
      	  "order": [[ 0, "desc" ]],
        "bFilter": false, 
        "bHeader": false,       
		"dom": 'lBfrtip',
		
		buttons: [
	       {
	           extend: 'pdf',
	           title: '<?php echo $printtitle;?>',	
	           orientation: 'landscape',
	           exportOptions: {
	                //columns: [0,1,2,3,4,5,6,7,8,9]
	            }
	       },
	       {
	           extend: 'excel',
	           title: '<?php echo $printtitle;?>',	
	           orientation: 'landscape',
	           exportOptions: {
	                //columns: [0,1,2,3,4,5,6,7,8,9]
	            }
	       },
	       {
	           extend: 'print',
	           title: '<?php echo $printtitle;?>',	          
	           exportOptions: {
	                //columns: [0,1,2,3,4,5,6,7,8,9]
	            }
	          
	       }
	            
	    ]  
	});	
});

</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
