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

if($operation=='save'){

	$form_data2=array(
		'branch_id'=>$branchid,
		'name'=>$roaster_name,
		'description'=>$roaster_descrption,
		'start_time'=>$start_time,
		'end_time'=>$end_time,
		'create_time'=>time()
		);

	$entry1=$obj->Insert_Data_By_Cond("hr_roaster_setup", $form_data2,"branch_id='$branchid' AND name='$roaster_name'");

	}


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(
		'name'=>$roaster_name,
		'description'=>$roaster_descrption,
		'start_time'=>$start_time,
		'end_time'=>$end_time,
		'status'=>$status,
		'update_time'=>time()
		);

	$update1=$obj->Update_Data("hr_roaster_setup", $form_data12,"WHERE id='$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>Roaster</th>
			<th>Start Time</th>
			<th>End Time</th>
			<th>Status</th>
			<th>Action</th>
		</thead>
		<tbody>
			
			<?php
			$i='0';
			foreach($obj->View_colmn_By_Cond("hr_roaster_setup","id,name,start_time,end_time,status","branch_id='$branchid' AND status!='1'") AS $value1){
			$i++;
			extract($value1);
			?>
			<tr>
				<td><?php echo $i; ?></td>
				<td><?php echo $value1['name']; ?></td>				
				<td><?php echo $value1['start_time']; ?></td>
				<td><?php echo $value1['end_time']; ?></td>
				<td><?php if($value1['status']=='0'){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>