<?php
session_start();
// ============
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============
extract($_POST);
$branchid = $_SESSION['LOGIN_BRANCH'];


$res = $obj->View_column_details_By_Cond("_int_institute_setup","_pid","_id='$branchid'");
extract($res);
$br_pid = $res['_pid'];

if($operation=='all'){
	foreach($obj->View_colmn_By_Cond("_int_institute_setup","_id","_pid='$br_pid'") as $value){
	extract($value);
	$br_ids = $value['_id'];

	$form_data2=array(
		'_br_id'=>$br_ids,
		'_grade_name'=>$grade,
		
		'_start_salary'=>$s_salary,
		'_end_salary'=>$e_salary,
		'_status'=>'A',
		'_entry_by'=>$_SESSION['LOGIN_USERID'],
		'_entry_date'=>date("Y:m:d h:i:s")
		);

	$entry1=$obj->Insert_Data_By_Cond(" _hr_gradding", $form_data2,"_br_id='$br_ids' AND _grade_name='$grade'");

	}

}


if($operation=='only'){

	$form_data2=array(
		'_br_id'=>$branchid,
		'_grade_name'=>$grade,
		
		'_start_salary'=>$s_salary,
		'_end_salary'=>$e_salary,
		'_status'=>'A',
		'_entry_by'=>$_SESSION['LOGIN_USERID'],
		'_entry_date'=>date("Y:m:d h:i:s")
		);

	$entry1=$obj->Insert_Data_By_Cond("_hr_gradding", $form_data2,"_br_id='$branchid' AND _grade_name='$grade'");

}

// ==================================


if($operation=='e_only'){

	$form_data12=array(
		'_grade_name'=>$e_grade,
		
		'_start_salary'=>$st_salary,
		'_end_salary'=>$ed_salary,
		'_status'=>$e_status,
		'_update_by'=>$_SESSION['LOGIN_USERID']
		);

	$update1=$obj->Update_Data("_hr_gradding", $form_data12,"WHERE _id='$e_grade_id'");

}


?>


<div class="row-fluid" style="margin-top: 15px;">
								
								
	<table id="sample-table-121" class="table table-striped table-bordered table-hover">
		<thead>
			<th>Sl</th>
			<th>Grade</th>
			
			<th>Start Salary</th>
			<th>End Salary</th>
			<th>Status</th>
			<th>Action</th>
		</thead>
		<tbody>
			
			<?php
			$i='0';
			foreach($obj->View_colmn_By_Cond(" _hr_gradding","_id,_grade_name,_start_salary,_end_salary,_status","_br_id='$branchid' AND _status!='D'") AS $value1){
			$i++;
			extract($value1);
			?>
			<tr>
				<td><?php echo $i; ?></td>
				<td><?php echo $value1['_grade_name']; ?></td>
				
				<td><?php echo $value1['_start_salary']; ?></td>
				<td><?php echo $value1['_end_salary']; ?></td>
				<td><?php if($value1['_status']=='A'){echo 'Active'; } else{echo 'Inactive';} ?></td>
				
				<td>
					<?php if($_SESSION['edit']=='Y'){ ?>
					<i class="icon-edit bigger-170" style="hover:cursor;" href="#modal-table" data-toggle="modal" onclick="show_edit_view(<?php echo $value1['_id']; ?>)"></i>&nbsp;&nbsp;
					<?php } ?>
				</td>
			</tr>
			<?php } ?>
			
		</tbody>	

	</table>
</div>
<script type="text/javascript">	
// var oTable2 = $('#sample-table-121').dataTable( {
// "aoColumns": [
//   { "bSortable": true },
//   null, null,null, null,null,
//   { "bSortable": true }
// ] } );
				
</script>