<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
	<link rel="stylesheet" type="text/css" href="src/plugins/datatables/media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="src/plugins/datatables/media/css/dataTables.bootstrap4.css">
	<link rel="stylesheet" type="text/css" href="src/plugins/datatables/media/css/responsive.dataTables.css">
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); ?>
	<div class="main-container">
		<div class="pd-ltr-20 customscroll customscroll-10-p height-100-p xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Empolyee Report</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<li class="breadcrumb-item"><a href="#">Report</a></li>
									<li class="breadcrumb-item active" aria-current="page">Employee Report</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							
						</div>
					</div>
				</div>
				
				<!-- Export Datatable start -->
				<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<div class="clearfix mb-20">
						<div class="pull-left">
						</div>
					</div>
	  				<?php include "employee_report_form.php"; ?>
					<div class="row">
		                <table class="stripe hover data-table-export nowrap">
			                <thead>
			                    <tr>                        
			                        <!-- <th >Sr. No</th> -->
			                        <th class="table-plus datatable-nosort" >Sr.No</th>
			                        <!-- <th>Action</th> -->
			                        <th>Employee First Name</th>
			                        <th>Employee Middle Name</th>
			                        <th>Employee Last Name</th>
			                        <th>Employee Id</th>
			                        <th>Created Date</th>
			                        <th>Modification Date</th>
			                    </tr>
			                </thead>
			                <tbody>
<?php 
 $query="SELECT * FROM `tbl_empolyee_details` WHERE fld_emp_details_delete='0'";
// $query="SELECT * FROM `tbl_empolyee_details` WHERE `fld_emp_fname` LIKE '%emp_name%' AND `fld_emp_mname` LIKE '%emp_name%' AND `fld_emp_lname` LIKE '%emp_name%' AND fld_emp_details_delete='0'";
if(isset($_POST['submit']))
{
	extract($_POST);
	$conditions=array();
	$conditions1=array();

	if((isset($_POST['emp_name'])) && ($_POST['emp_name']!=""))
	{
		$conditions[] = "fld_emp_fname LIKE '%".$emp_name."%' or fld_emp_mname LIKE '%".$emp_name."%' OR fld_emp_lname LIKE '%".$emp_name."%' and fld_emp_details_delete='0'";
	}

	// if((isset($_POST['emp_name'])) && ($_POST['emp_name']!=""))
	// {
	// 	$conditions[] = 'fld_emp_mname ='."'".$_POST['emp_name']."'";
	// }

	// if((isset($_POST['emp_name'])) && ($_POST['emp_name']!=""))
	// {
	// 	$conditions[] = 'fld_emp_lname ='."'".$_POST['emp_name']."'";
	// }
	if((isset($_POST['emp_id'])) && ($_POST['emp_id']!=""))
	{
		$conditions[] = 'fld_employee_id ='."'".$_POST['emp_id']."'";
	}
	
		if ($conditions)
		      {
		          $query .= " AND ".implode(" AND ", $conditions);
		      }
				 $query .= " group by fld_emp_details_id order by fld_emp_details_id desc";
}
else
{
		$query .=" group by fld_emp_details_id order by fld_emp_details_id desc";
} 

// echo $query ;                                      
				                    
				                    $asd = mysqli_query($connect,$query) or die (mysqli_error($connect)); 
				                    $count=0;
				                    while($row=mysqli_fetch_array($asd))
				                    {
				                    extract($row)
			                    ?>
			                    
				                    <tr>
				                    	<td><?php echo ++$count; ?></td>
				                    	<!-- <td>
				                    		<a href="view_customer.php?Customer_Id=<?php //echo $row['Customer_Id'];?>" class="fa fa-eye text-info" style="font-size: 20px"  aria-hidden="true" title="View Details"></a>&nbsp;&nbsp;

				                    		<a href="Print_customer_details.php?Customer_Id=<?php //echo $row['Customer_Id'];?>" class="fa fa-print text-warning" style="font-size: 20px"  aria-hidden="true" title="Print Customer Details"></a>&nbsp;&nbsp;
				                    	</td>	 -->								   
									    <td><?php echo $fld_employee_id; ?></td>
									    <td><?php echo $fld_emp_fname; ?></td> 
									    <td><?php echo $fld_emp_mname; ?></td>
									    <td><?php echo $fld_emp_lname; ?></td> 
									    <td><?php echo $fld_created_date; ?></td> 
									    <td><?php echo $fld_modified_date; ?></td> 
									</tr>
			    
								<?php } ?>
			                </tbody>
		                </table> 
                    </div>
				</div>
				<!-- Export Datatable End -->
			</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>
	<script src="src/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/dataTables.responsive.js"></script>
	<script src="src/plugins/datatables/media/js/responsive.bootstrap4.js"></script>
	<!-- buttons for Export datatable -->
	<script src="src/plugins/datatables/media/js/button/dataTables.buttons.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.bootstrap4.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.print.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.html5.js"></script>
	<script src="src/plugins/datatables/media/js/button/buttons.flash.js"></script>
	<script src="src/plugins/datatables/media/js/button/pdfmake.min.js"></script>
	<script src="src/plugins/datatables/media/js/button/vfs_fonts.js"></script>
	<script>
		$('document').ready(function(){
			$('.data-table').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
			});
			$('.data-table-export').DataTable({
				scrollCollapse: true,
				autoWidth: false,
				responsive: true,
				columnDefs: [{
					targets: "datatable-nosort",
					orderable: false,
				}],
				"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
				"language": {
					"info": "_START_-_END_ of _TOTAL_ entries",
					searchPlaceholder: "Search"
				},
				dom: 'Bfrtip',
				buttons: [
				'copy', 'csv', 'pdf', 'print'
				]
			});
			var table = $('.select-row').DataTable();
			$('.select-row tbody').on('click', 'tr', function () {
				if ($(this).hasClass('selected')) {
					$(this).removeClass('selected');
				}
				else {
					table.$('tr.selected').removeClass('selected');
					$(this).addClass('selected');
				}
			});
			var multipletable = $('.multiple-select-row').DataTable();
			$('.multiple-select-row tbody').on('click', 'tr', function () {
				$(this).toggleClass('selected');
			});
		});
	</script>
</body>
</html>