<?php
include('../headertop.php');
//include('../datepicker.php');
include('../db.php');

$disp = '';
$pagetitle = 'Add Salary';

if(!isset($_POST['addsalarysubmit']))
{
echo '<meta http-equiv="refresh" content="0;URL=addsalary.php">';
exit;
}

$salary_month = $_POST['salary_month'];
$salary_year = $_POST['salary_year'];
$doe = $_POST['doe'];

if(empty($salary_month) or empty($salary_year) or empty($doe))
{
echo '<meta http-equiv="refresh" content="0;URL=addsalary.php?sm=Please fill all required fields">';
//echo $salary_month.','.$salary_year.','.$doe;
exit;
}

$q = "select * from employee";
$res = mysqli_query($dbcon,$q);
if(mysqli_num_rows($res)<1)
{
$sm = 'No employees found';
echo '<meta http-equiv="refresh" content="0;URL=addsalary.php?sm='.$sm.'">';
}

if(isset($_REQUEST['sm']))
$disp .= '<div class="col-md-7"><div class="smdiv">'.$_REQUEST['sm'].'</div></div>';
else
$disp .= '<div class="col-md-9"><div class="smdiv">Add Employee Salary for Month: '.$salary_month.', '.$salary_year.'</div></div>
';

 
$disp .= '
<form method="post" action="addsalary3.php" id="addsalaryform">
<div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             Please Add Employee Salary
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
											<th>Employee Name</th>
                                            <th>Father/Husband Name</th>
                                            <th>Phone</th>
											<th>Address</th>
                                            <th>Qualification</th>
                                            <th>Monthly Salary</th>
											<th>Amount Paid</th>
                                            
                                        </tr>
                                    </thead>
                                    <tbody>';
  while($row=mysqli_fetch_array($res))
{              

                    
   $disp .='<tr class="odd gradeX">
                                            <td>'.$row['name'].'</td>
                                            <td>'.$row['fname'].'</td>
                                            <td>'.$row['mobile'].'</td>
                                            <td class="center">'.$row['address'].'</td>
                                            <td class="center">'.$row['qualification'].'</td>
											<td class="center">'.$row['salary'].'</td>
											<td class="center"><input type="text" name="salary_paid['.$row['id'].']"></td>
                                        </tr>
                                       ';
} //end of while

$disp .='            </tbody>
                                </table>
                            </div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
					<input type="hidden" name="salary_month" value="'.$salary_month.'">
											<input type="hidden" name="salary_year" value="'.$salary_year.'">
											<input type="hidden" name="doe" value="'.$doe.'">
											
											
					<button type="submit" class="btn btn-primary" name="addsalary2submit"  style="margin-top:25px">Submit Button</button>
                </div>
            </div>
			
			 ';
		
			
			include('../header.php');
			?>
		
     <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>
    
 
          <?php
		 
			
			include('../template.php');
               