<?php

include ('../ro_head.php'); 
include('methodlist.php');
?>
<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>

<!-- <script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script> -->

<script type="text/javascript">

// $( document ).ready(function() {
// 	$('#sample_2').DataTable({

// 		"pageLength": -1,
//         "paging": false,
//         "info":     false,
// 		"dom": 'lBfrtip',
// 		buttons: [
// 	       {
// 	           extend: 'pdf',
// 	           //footer: true,
// 	           exportOptions: {
// 	                columns: [0,1,2,3,4,5,6,7,8]
// 	            }
// 	       },
// 	       {
// 	           extend: 'print',
// 	           exportOptions: {
// 	                columns: [0,1,2,3,4,5,6,7,8]
// 	            }

// 	       },
// 	       {
// 	           extend: 'excel',
// 	           exportOptions: {
// 	                columns: [0,1,2,3,4,5,6,7,8]
// 	            }
// 	       }
// 	    ]
// 	});
// });

</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;
    }
.backcol{
	background: #ececec;
}
tbody{
	font-size: 12px;
}
table.dataTable thead th {
    font-size: 12px;
}    
</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 


								$totalvisafee=0;
							  	$totalservicefee=0;
							  	$totalbankfee=0;

								$sql = "";

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

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

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

									//$sql="select * from qcareer where apply_date between '".$date1."' AND '".$date2."'";
									/*$sql="SELECT * FROM docpos_log_table, applicant_table WHERE docpos_log_table.docpos_log_dposid='$_REQUEST[doctype]' AND applicant_table.app_id=docpos_log_table.docpos_log_appid  
									AND DATE(`docpos_log_dt`) between '".$date1."' AND '".$date2."'";*/
									$sql = "select * from applicant_table where DATE(created_date) between '".$date1."' AND '".$date2."'";

									//var_dump($sql) or die();
						            //echo $sql;
						            $result = mysqli_query($con,$sql);

						            $printtitle="Document Tracker Report (Date: ".date('d-m-Y', strtotime($date1))." - ".date('d-m-Y', strtotime($date2)).")"; 
						        }

						   //      elseif($_REQUEST['date2']==NULL && $_REQUEST['doctype']!=NULL) {

						   //      	$sql="SELECT * FROM docpos_log_table, applicant_table WHERE docpos_log_table.docpos_log_dposid='$_REQUEST[doctype]' AND applicant_table.app_id=docpos_log_table.docpos_log_appid";

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

									// $printtitle="Document Tracker Report (Date: ".$dt->format('Y-m-d').")";
									
						   //      }

						        else {

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

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

									$printtitle="Document Tracker Report (Date: ".$dt->format('d-m-Y').")";
									
						        }

						        //echo $sql;
						        echo $printtitle;
								
								?>
								
							</div>
						</div>
						<div class="portlet-body">
							<div class="table-toolbar">
								<div class="row">
									<form class="form-inline col-md-12" action="report_doc_tracker.php" method="post">
									<div class="col-md-4">
									<!-- 	Select Document Position : <select name="doctype" class="form-control" required>
									  	<option value=""> - Select -</option>
								
										<?php    
				       //                      $urs = mysqli_query($con,"select docp_id, docp_name from doc_position_table order by docp_id ASC");
		         //                    		while($urow=mysqli_fetch_array($urs)){ 
		                                
		         //                         	  	echo "<option value=".$urow["docp_id"]."> ".$urow["docp_name"]." </option>";
											  	
											// } 
										?>	
									</select>	 -->
									</div>
									<div class="col-md-8">										
											Date : <div class="input-group input-large date-picker input-daterange" style="" data-date="10/11/2012" data-date-format="yyyy-mm-dd">
					                            <input type="text" class="form-control" name="date1">
					                            <span class="input-group-addon"> to </span>
					                            <input type="text" class="form-control" name="date2">					                           
					                        </div>
					                       
					                        	 <button class="btn green"> Search </button>
					                     			

									</div>
									</form>
								</div>
							</div>
							<br/><br/>
							<table class="table table-striped table-bordered table-hover" id="sample_2">
							<thead>
							<tr class="backcol">
								<!--<th class="table-checkbox">
									<input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
								</th>-->
								 			
								 			<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%">Visa Type</th>                                           
                                           
                                            <th style="width:10%">Passport No</th>

											<?php    
				                            $dhead = mysqli_query($con,"select * from doc_position_table where docp_status=1 order by docp_id ASC");
				                    		while($dheadrow=mysqli_fetch_array($dhead)){ 
				                        
				                         	  	echo "<th style='width:10%'>".$dheadrow["docp_name"]." Date</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 get_visatype_name($row['visa_type'],$con);?></td>
							
								<td><?php echo $row['passport_no'];?></td>
							
								<?php    
	                            $dbodyrs = mysqli_query($con,"select * from doc_position_table where docp_status=1 order by docp_id ASC");
	                    		while($dbodyrow=mysqli_fetch_array($dbodyrs)){ 
	                        
	                         	  	$sql="select * from docpos_log_table where docpos_log_appid='$row[app_id]' AND docpos_log_dposid='$dbodyrow[docp_id]'";
	                         	  	$dposdate = mysqli_query($con, $sql);
	                    			$dposdaterow=mysqli_fetch_array($dposdate);
	                         	  	echo "<td>";
	                         	  	if($dposdaterow["docpos_log_dt"]!=NULL) echo date('d-m-Y', strtotime($dposdaterow["docpos_log_dt"]));
	                         	  	echo "</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></td>";

                                echo "<td></td>";

                                echo "<td></td>";

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

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

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

                                echo "<td>".number_format($totalbankfee,2)."</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">

$( document ).ready(function() {	
	$('#sample_2').DataTable({
		
		"pageLength": -1,
        "paging": false,
        "info": false,
        "bSort": false,
        "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>
