<?php
session_start();
if(!isset ($_SESSION['user_id'])){
    header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.php');	
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php
  include 'title.php';
  ?>
	
	<link type = "image/png" rel="icon" href="images/brvision.png" />
	
	<!-- Datatable CSS -->
    <link href='DataTables/datatables.min.css' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' href='https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css'>
    <!--<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">-->
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
	<!-- jQuery Library -->
    <!--<script src="jquery-3.3.1.min.js"></script>-->
	
	<!-- Datatable JS -->
    <script src="DataTables/datatables.min.js"></script>
    <script src='https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js'></script>
    <script src='https://cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js'></script>
    <script src='https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js'></script>
    <script src='https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js'></script>
    <script src='https://cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js'></script>
    <script src='https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js'></script>
	
	
	

    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	
	
  <!-- jquery ui -->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<script type="text/javascript">
$(document).ready(function(){
    $('#deptId').on('change',function(){
        var regID = $(this).val();
        if(regID){
            $.ajax({
                type:'POST',
                url:'ajaxData.php',
                data:'deptId='+regID,
                success:function(html){
                    $('#desId').html(html);
                }
            }); 
        }else{
            $('#desId').html('<option value="">Select Department First</option>');
        }
    });

});
</script>


<!--<script type="text/javascript">
$(document).ready(function(){
    $('#editdept').on('change',function(){
        var regID1 = $(this).val();
        if(regID1){
            $.ajax({
                type:'POST',
                url:'ajaxData1.php',
                data:'deptId='+regID1,
                success:function(html){
                    $('#editdes').html(html);
                }
            }); 
        }else{
            $('#editdes').html('<option value="">Select Department First</option>');
        }
    });

});
</script>-->
    
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
             <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>

           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="dashboard.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					</br></br>
					<font color="green">List Of Employees Salaries Payroll</font>
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                      
                    </ul>
                    <div class="clearfix"></div>
                  </div>
				  
				
				  
                 <div class="x_content" style="overflow: auto;">
				 
			    <div class="remove-messages"></div>
				
				
				
		    <table Style="width:100%; padding:10px;">
			
            <tr> <th>Search Staff</th><th>Filter By Department</th><th>Filter By Section</th><th>Filter By Marital Status</th></tr>
			
			<tr> 
                <td width="25%">
                    <input type='text' id="searchByStaffName"  class="form-control " placeholder='Enter Any Staff Detail'>
				</td>
				
				
                <td width="25%">
                    
					<select id='searchBydeptName' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql126 = "SELECT * FROM departments ORDER BY depart_name";
			  			$productData126 = $conn->query($productSql126);
			  			while($row126 = $productData126->fetch_array()){									 		
			  			  echo "<option value='".$row126['dept_id']."'>".$row126['depart_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
				<td width="25%">
                    
					<select id='searchBysectName' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql128 = "SELECT * FROM sections ORDER BY sect_name";
			  			$productData128 = $conn->query($productSql128);
			  			while($row128 = $productData128->fetch_array()){									 		
			  			  echo "<option value='".$row128['sect_id']."'>".$row128['sect_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
				
				<td width="25%">
                    
					<select id='searchByMarital' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql126381 = "SELECT * FROM marital_status ORDER BY marital_name";
			  			$productData126381 = $conn->query($productSql126381);
			  			while($row126381 = $productData126381->fetch_array()){									 		
			  			  echo "<option value='".$row126381['marital_id']."'>".$row126381['marital_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
            </tr>
			
			<tr><th>Filter By Designation</th><th>Filter By Staff Status</th><th>Filter By Gender</th><th>Filter By Staff Category</th></tr>
			
			<tr> 
               
				<td width="25%">
                    
					<select id='searchBydesName' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql1263 = "SELECT * FROM designation ORDER BY des_name";
			  			$productData1263 = $conn->query($productSql1263);
			  			while($row1263 = $productData1263->fetch_array()){									 		
			  			  echo "<option value='".$row1263['des_id']."'>".$row1263['des_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
				
				<td width="25%">
                    
					<select id='searchBystatusName' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql12638 = "SELECT * FROM status ORDER BY name";
			  			$productData12638 = $conn->query($productSql12638);
			  			while($row12638 = $productData12638->fetch_array()){									 		
			  			  echo "<option value='".$row12638['status_id']."'>".$row12638['name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
				
				
				<td width="25%">
                    
					<select id='searchByGender' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql1263813 = "SELECT * FROM gender ORDER BY gender_name";
			  			$productData1263813 = $conn->query($productSql1263813);
			  			while($row1263813 = $productData1263813->fetch_array()){									 		
			  			  echo "<option value='".$row1263813['gender_id']."'>".$row1263813['gender_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
			<td width="25%">
                    
					<select id='searchBystaffCate' class="form-control ">

                        <option value="">All</option>
						
						<?php
			  			$productSql12638c = "SELECT * FROM staff_category ORDER BY staffcate_name";
			  			$productData12638c = $conn->query($productSql12638c);
			  			while($row12638c = $productData12638c->fetch_array()){									 		
			  			  echo "<option value='".$row12638c['staffcate_id']."'>".$row12638c['staffcate_name']."</option>";
										 	} // /while 

			  			?>
                    </select> 

                </td>
				
            </tr>
			
			
        </table>

                  
				   
					<br/>
        <div id="buttons"></div>
		
		<!-- Table -->
        <table id='manageCategoriesTable' class='display dataTable hoverable  table-striped'>
            <thead>
                <tr>
                    <th>S/No:</th>
					<th>Employee</th>
					<th>Employee Id</th>
					<th>Basic Salary in Tsh.</th>
					<th>Employee NSSF Contribution in Tsh.</th>
					<th>Employee NHIF Contribution in Tsh.</th>
					<th>Employee HESLB Contribution in Tsh.</th>
					<th>Taxable Amount in Tsh.</th>
					<th>Paye in Tsh.</th>
					<th>NetPay in Tsh.</th>
					<th>Employer NHIF Contribution in Tsh.</th>
					<th>Employer NSSF Contribution in Tsh.</th>
					<th>Employer WCF Contribution in Tsh.</th>
                </tr>
            </thead>

        </table>
		
		  <!-- Script -->
    <script>
        $(document).ready(function () {
            var dataTable = $('#manageCategoriesTable').DataTable({
                'processing': true,
                'serverSide': true,
                'serverMethod': 'post',
                "lengthMenu": [[10, 25, 50, 100,500,1000], [10, 25, 50,100,500,1000]],
                'dom': 'Blfrtip',
        'buttons': [

									{
										"extend": 'pdf',
										"text": 'Export PDF',
										"className": 'btn btn-primary btn-sm ml-1'
									},
									{
										"extend": 'csv',
										"text": 'Export CSV',
										"className": 'btn btn-primary btn-sm ml-1'
									},


									{
										'extend': 'excel',
										"text": 'Export  Excel',
										'className': 'btn btn-primary btn-sm ml-1'
									}, {
										'extend': 'print',
										"text": 'Print',
										'className': 'btn btn-primary btn-sm ml-1'
									}

								], "language": 
{          
"processing": "<img style='width:300px; height:200px;' src='load.gif' />",
},
                
                'ajax': {
                    'url': 'php_action/salariesPayroll.php',
                    'data': function (data) {
                        
                        
						var searchByStaffName=$('#searchByStaffName').val();
						var searchBydeptName=$('#searchBydeptName').val();
						var searchBysectName=$('#searchBysectName').val();
						var searchBydesName=$('#searchBydesName').val();
						var searchBystatusName=$('#searchBystatusName').val();
                        var searchBystaffCate=$('#searchBystaffCate').val();
						var searchByMarital=$('#searchByMarital').val();
						var searchByGender=$('#searchByGender').val();
                       
                        
						data.searchByStaffName = searchByStaffName;
						data.searchBydeptName = searchBydeptName;
						data.searchBysectName = searchBysectName;
						data.searchBydesName = searchBydesName;
						data.searchBystatusName = searchBystatusName;
						data.searchBystaffCate = searchBystaffCate;
						data.searchByMarital = searchByMarital;
						data.searchByGender = searchByGender;
						
						
                    }
                },
                'columns': [
                    { data: 'staff_id'},
                    { data: 'Staff'},
					{ data: 'staffId'},
					{ data: 'BasicSalary'},
					{ data: 'NssfContri'},
					{ data: 'NhifContri'},
					{ data: 'HeslbContri'},
					{ data: 'taxableAmount'},
                    { data: 'paye'},
					{ data: 'NetPay'},
					{ data: 'employerNhifContri'},
					{ data: 'employerNssfContri'},
					{ data: 'employerWcfContri'},
                ]
                
            });

           $('#searchByStaffName').keyup(function () {
                dataTable.draw();
            }); 
			
           
           
			
			$('#searchBydeptName').change(function () {
                dataTable.draw();
            });
			
			$('#searchBysectName').change(function () {
                dataTable.draw();
            });
			
			$('#searchBydesName').change(function () {
                dataTable.draw();
            });
			
			$('#searchBystatusName').change(function () {
                dataTable.draw();
            });
			
			$('#searchBystaffCate').change(function () {
                dataTable.draw();
            });
			
			$('#searchByMarital').change(function () {
                dataTable.draw();
            });
			
			$('#searchByGender').change(function () {
                dataTable.draw();
            });
			
			
        });
       
    </script>
					
					
				</div>
                </div>
              </div>
            </div>
			
			<?php
			//include 'addStaffModal.php';
			//include 'editStaffModal.php';
			//include 'deleteStaffModal.php';
			?>
		
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	<script>
	// order date picker
		$("#birthDate").datepicker();
		
		// delivery date picker
		$("#employDate").datepicker();
		
		$("#editBirthDate").datepicker();
		
		$("#editEmployDate").datepicker();
	
	</script>
	
	<script>
	
		$(document).ready(function(){
    $('input[name="staffcate_id"]').on('click', function(){
        if ($(this).val() == 1){
			 $('#textboxes1').show();
			 $('#textboxes2').hide();
			 $('#textboxes3').hide();
			 $('#textboxes4').hide();
        }else if($(this).val() == 2){
			$('#textboxes4').show();
			$('#textboxes1').hide();
			$('#textboxes2').hide();
			$('#textboxes3').hide();
		}else if($(this).val() == 3){
			$('#textboxes2').show();
			$('#textboxes1').hide();
			$('#textboxes3').hide();
			$('#textboxes4').hide();
		}else{
			$('#textboxes3').show();
			$('#textboxes1').hide();
			$('#textboxes2').hide();
			$('#textboxes4').hide();
		}
	
		
    });
});
	
	
	
$(document).ready(function(){
    $('#dept_id').on('change', function(){
        var deptID = $(this).val();
        if(deptID){
            $.ajax({
                type:'POST',
                url:'ajax_Data.php',
                data:'dept_id='+deptID,
                success:function(html){
                    $('#sect_id').html(html);
                    $('#des_id').html('<option value="">Select Section first</option>'); 
                }
            }); 
        }else{
            $('#sect_id').html('<option value="">Select Department first</option>');
            $('#des_id').html('<option value="">Select Section first</option>'); 
        }
    });
    
    $('#sect_id').on('change', function(){
        var sectID = $(this).val();
        if(sectID){
            $.ajax({
                type:'POST',
                url:'ajax_Data.php',
                data:'sect_id='+sectID,
                success:function(html){
                    $('#des_id').html(html);
                }
            }); 
        }else{
            $('#des_id').html('<option value="">Select Section first</option>'); 
        }
    });
});


$(document).ready(function(){
    $('#depart_id').on('change', function(){
        var departID = $(this).val();
        if(departID){
            $.ajax({
                type:'POST',
                url:'ajax_Data1.php',
                data:'depart_id='+departID,
                success:function(html){
                    $('#section_id').html(html);
                    $('#desi_id').html('<option value="">Select Section first</option>'); 
                }
            }); 
        }else{
            $('#section_id').html('<option value="">Select Department first</option>');
            $('#desi_id').html('<option value="">Select Section first</option>'); 
        }
    });
    
    $('#section_id').on('change', function(){
        var sectiID = $(this).val();
        if(sectiID){
            $.ajax({
                type:'POST',
                url:'ajax_Data1.php',
                data:'section_id='+sectiID,
                success:function(html){
                    $('#desi_id').html(html);
                }
            }); 
        }else{
            $('#desi_id').html('<option value="">Select Section first</option>'); 
        }
    });
});


$(document).ready(function(){
    $('#editdept').on('change', function(){
        var dept_ID = $(this).val();
        if(dept_ID){
            $.ajax({
                type:'POST',
                url:'ajax_Data9.php',
                data:'editDept_id='+dept_ID,
                success:function(html){
                    $('#editSect').html(html);
                    $('#editdes').html('<option value="">Select Section first</option>'); 
                }
            }); 
        }else{
            $('#editSect').html('<option value="">Select Department first</option>');
            $('#editdes').html('<option value="">Select Section first</option>'); 
        }
    });
    
    $('#editSect').on('change', function(){
        var sect_ID = $(this).val();
        if(sect_ID){
            $.ajax({
                type:'POST',
                url:'ajax_Data9.php',
                data:'editSect_id='+sect_ID,
                success:function(html){
                    $('#editdes').html(html);
                }
            }); 
        }else{
            $('#editdes').html('<option value="">Select Section first</option>'); 
        }
    });
});

$(document).ready(function(){
    $('input[name="upl_status"]').on('click', function(){
        if ($(this).val() == 'Yes'){
			 $('#textboxes5').show();
        }else {
			$('#textboxes5').hide();
		}
	
		
    });
});

</script>

    <!-- Must -->
    <script src="custom/js/users.js"></script>
  
	
    <!-- Must Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	<!-- file input -->
	<script src="assests/plugins/fileinput/js/plugins/canvas-to-blob.min.js'); ?>" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/sortable.min.js" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/purify.min.js" type="text/javascript"></script>
	<script src="assests/plugins/fileinput/js/fileinput.min.js"></script>	
	
  </body>
</html>



<?php
}
?>