<?php 
include ('../ro_head.php'); 
isauth_have("Document tracker list");
?>


<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]
	            }
	       },
	       {
	           extend: 'print',
	           exportOptions: {
	                columns: [0,1,2,3,4,5,6,7]
	            }
	          
	       },
	       {
	           extend: 'excel',
	           exportOptions: {
	                columns: [0,1,2,3,4,5,6,7]
	            }
	       }         
	    ]  
	});	

$(document).ready(function(){ 	
	$("button#posupdatesubmit").click(function(){

		
		$.ajax({
			type: "POST",
			url: "docposmodalupdate.php",
			data: $('form.feedback3').serialize(),
			success: function(message){
				$("#feedback3").html(message)
				$("#myModal_autocomplete3").modal('hide'); 

				location.reload();
			},
			error: function(){
				alert("Error");
			}
		});
	});


});


$("#docposModal").on("show.bs.modal", function(e) {
	var link = $(e.relatedTarget);
	$(this).find(".modal-body").load(link.attr("href"));
});

	
});


function statusFunction(str,sta) {
            
            if (confirm("Do you want to change current payment status?") == true) {
                window.location = 'status_crud.php?appid='+str+'&status='+sta;
                //window.location = 'status_crud.php?actionid=change&id='+str+'&status='+sta+'&table='+table+'&tableid='+tid+'&page='+page;
                //alert(url);
            }
            
        }


</script>

<script type="text/javascript">

// Fill modal with content from link href

  $( function() {
    $( ".datepicker" ).datepicker();
  } );

</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>Document Tracker
							</div>							
						</div>
						<div class="portlet-body">
							<div class="table-toolbar">
								<div class="row">
									<div class="col-md-4">
										<!-- <div class="btn-group">
											<a href="newlegalisation.php"><button id="sample_editable_1_new" class="btn green">
											Add New <i class="fa fa-plus"></i>
											</button></a>
										</div> -->
									</div>
									<div class="col-md-8">

										<form class="form-inline col-md-12" action="docposition_tracking.php" method="post">
											<div class="input-group input-large date-picker input-daterange" style="float: left;" 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>
					                        <div class="col-md-2">
					                        	 <button class="btn green"> Search </button>
					                        </div>												
													
										</form>

									</div>
									
								</div>
							</div>
							<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:15%">Reference No</th>
                                            <th style="width:15%">Applicant Name</th>                                                     
                                            <th style="width:20%">Passport No</th>                                             
                                            <th style="width:15%">Application Date</th>
                                            <th style="width:20%">Document Position</th>
                                           
<!--                                             <th style="width:10%">Payment</th> -->

                                          <?php if($newarr[6]=="Update Position status") {?>		
                                            <th style="width:10%">Update</th>
                                            <?php } ?>

                                            
							</tr>

							
							
							</thead>
							<tbody>

								<?php


								//include('db_con.php');

								$sql = "";

								// $sql = "SELECT * FROM `applicant_table`";

								//$sql = "select * from applicant_table,doc_table,doc_app_table where  applicant_table.app_id=doc_app_table.app_id and doc_app_table.doc_id = doc_table.doc_id";

								//$sql = "select * from applicant_table,ver_status_table where applicant_table.status = ver_status_table.vstatus_id";
								if(isset($_REQUEST['date1']) && $_REQUEST['date2']!=NULL) { 
						            //echo $_REQUEST['date1'].$_REQUEST['date2'];
						            
						            $var = $_REQUEST['date1'];
									$date1= date('Y-m-d', strtotime($var));
									//echo $date1;
									//$date = str_replace('/', '-', $date1);
									//echo $date;
									

									$var = $_REQUEST['date2'];
									//$date = str_replace('/', '-', $var);
									$date2= date('Y-m-d', strtotime($var));
									
									$sql = "select * from applicant_table where DATE(created_date) between '".$date1."' AND '".$date2."'";
									//$sql = "select * from applicant_table where DATE(created_date) between '".$date1."' AND '".$date2."' OR DATE(online_submissiondate) between '".$date1."' AND '".$date2."' OR DATE(pickedupdate) between '".$date1."' AND '".$date2."'";								

									//var_dump($sql) or die();
						            //echo $sql;
						            $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");
									//$result = mysqli_query($con,"select * from applicant_table");
						        	
									//$rs = mysqli_query($con,$sql);
						        }

								



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

								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 date('d-m-Y', strtotime(substr($row['created_date'], 0, 10)));?></td>
																							
								<td><?php 

								$vresult = mysqli_query($con,"SELECT docp_name FROM doc_position_table WHERE docp_id='".$row['doc_position']."'");
								$vrow=mysqli_fetch_array($vresult);
								echo $vrow['docp_name'];
								?></td>
							
						<?php if($newarr[6]=="Update Position status") {?>	
							<td>
							<a href="doc_position_modal.php?id=<?php echo $row['app_id'];  ?>" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#docposModal" data-remote="false">Update Status	</a>
							</td>

							<?php } ?>
								
							</tr>




							<?php

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






<!-- Status bootstrap modal example -->
<div class="modal fade" id="docposModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Update Document Position </h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" id="posupdatesubmit" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

<!-- Status bootstrap modal example -->
<!-- <div class="modal fade" id="payModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Update Payment Status</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" id="paysubmit" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div> -->

<!-- Status bootstrap modal example -->
<!-- <div class="modal fade" id="reportModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Report Status</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
       
      </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>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="../assets/js/table-managed.js" type="text/javascript"></script>
<script src="../assets/admin/layout/scripts/components-picker.js"></script>
<script type="text/javascript" src="../assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.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
     ComponentsPickers.init();
});
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>