<?php 
include ('../ro_head.php'); 
include('methodlist.php');
?>

<!-- PAGE STYLES -->
<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.dataTable.no-footer {

       border-bottom: 1px solid #b1bdbd;
}	
</style>


<script type="text/javascript">

$( document ).ready(function() {	
	$('#sample_2').DataTable({
		
		"pageLength": -1,
        "paging": false,
        "info":     true,
		"dom": 'lBfrtip',
		buttons: [
	       {
	           extend: 'pdf',
	           //footer: true,
	           exportOptions: {
	                columns: [1,2,3,4]
	            }
	       },
	       {
	           extend: 'print',
	           exportOptions: {
	                columns: [1,2,3,4]
	            }
	          
	       },
	       {
	           extend: 'excel',
	           exportOptions: {
	                columns: [1,2,3,4]
	            }
	       }         
	    ]  
	});	
});


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

</script>

<!-- END PAGE LEVEL STYLES -->
<?php //include("ro_header.php"); ?>

<!-- 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>Reciept List
							</div>
							
						</div>
						<div class="portlet-body">
							<div class="table-toolbar">
								<div class="row">
									<div class="col-md-4"></div>
									<div class="col-md-8">
									<form class="form-inline col-md-12" action="application_reciept.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>
							<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%">Taken By</th>                                           
                                        <th style="width:10%">Application Date</th>                                           
                                        <th style="width:20%">Total Fee (BDT)</th>
                                        <th style="width:10%">View detail</th>
							</tr>

							
							
							</thead>
							<tbody>

								<?php								

								$total_fee=0;

								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 qcareer where apply_date between '".$date1."' AND '".$date2."'";
									$sql = "select * from applicant_table where DATE(created_date) between '".$date1."' AND '".$date2."'";								

									//var_dump($sql) or die();
						            //echo $sql;
						            $date_range="(From ".$date1." to ".$date2.")";
						            $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");
						        	//$sql = "select * from qcarrerorder,customer where c_id=customer_id ORDER BY `customer_order`.`ostatus` DESC";
									//$rs = mysqli_query($con,$sql);
									 $date_range="(On ".date('d-m-Y').")";
						        }

							//	$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";
								
//
								//$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 get_session_user_name($row['takenby'],$con);?></td>
								<td><?php echo substr($row['created_date'], 0, 10);?></td>
								<td>
									<?php

									if($row["paystatus"]==0){
                                    	echo "<span style='color:red;'>".number_format($row["total_fee"],2)."</span>";
                                    }
                                    else{									
                                    	echo "<span style='color:green;'>".number_format($row["total_fee"],2)."</span>";
                                    }
                                    $total_fee=$total_fee+$row['total_fee'];
                                ?>
                                </td> 							
								
								<td>
								<a href="reciept_print.php?appid=<?php echo get_parent_id($row['app_id'],$con);  ?>" class="btn btn-sm btn-primary" target="_blank">Print Reciept</a>	
								
								</td>
							</tr>

							<?php


								}
							?>
							 
							</tbody>
							</table>

							<h3 style="float: right; background-color: aliceblue; padding: 10px;"><?php echo $date_range." <b>Total Paid : ". number_format($total_fee,2)." BDT</b>"; ?></h3>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</div>
				</div>
			</div>


			<!-- END PAGE CONTENT-->
		</div>
	</div>
	<!-- END CONTENT -->
	
	<?php //include_once("ro_qksidebar.php"); ?>
</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> -->

<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
  // TableManaged.init();
   ComponentsPickers.init();
});
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>