<?php 
$pgMod = "epf_esic";

	 if(isset($_POST['save_details'])){

 	     $allstaff = $_POST[idno];
 	     $i = 0;
	     foreach($allstaff as $idno){
            $epf = 0;
            $esic = 0;

            if($_POST["epf_$idno"]){$epf = 1;}
            if($_POST["esic_$idno"]){$esic = 1;}

	         $saveAry=array(
	                        "epf"       =>  $epf,
                            "esic"      =>  $esic
        					);

                $flg  = $db->updateAry("staff",   $saveAry,   "where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$idno."'");
            $i++;
	     }
	     
	      if(!is_null($flg))
 		{
 			$_SESSION['msg']='update Successfully';
 			redirect(URL_ADMIN_HOME.getQueryString(array("src"=>"Payroll", "page_id"=>$pgMod)));
 		}
	     
	 }
?>
  
	<form method="post" action="">
		<div class="row-fluid">
            <div class="span12">
            	<div class="top-bar">
					<h3><i class="icon-cog"></i>Staff List</h3>
                    <div>
						<button type="submit" name="save_details" class="btn btn-primary"> Save Details</button>
					</div>
				</div>
		<div class="well no-padding">
        	<div class="controls controls-row">

		<?php
		$whereC=array();

		$allstaff = $db->getRows("select * from staff where school_id='".$_SESSION["admin"]["school_id"]."' and status=1 order by name ");

		if(is_array($allstaff) && count($allstaff)>0){
			?><table class="table">
		    <thead>
    			<tr>
                    <th>S. No.</th>
                    <th>Name</th>
                    <th>Father Name</th>
                    <th>EPF</th>
                    <th>ESIC</th>
                </tr>
            </thead>
            <tbody id="myTable">
			<?php $i=0;
			foreach($allstaff as $staff){ $i++;
				?>
				<tr>
                	<td><?php echo $i; ?></td>
                	<td><?php echo $staff["name"]; ?></td>
					<td><?php echo $staff["fname"]; ?></td>
					<td><input type="checkbox" name="epf_<?php echo $staff['idno']; ?>" class="input-block-level" <?php if($staff['epf'] == 1)echo "checked"; ?> ></td>
					<td><input type="checkbox" name="esic_<?php echo $staff['idno']; ?>" class="input-block-level" <?php if($staff['esic'] == 1)echo "checked"; ?> ></td>

					<input type="hidden" name="idno[]" required  value="<?php echo $staff["idno"] ?>" readonly="readonly" />

                </tr>
				<?php
			}
			?></tbody></table><?php
		}
		?></div></div></div></div></form>