<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
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(
		'_branch_id'=>$br_ids,
		'_fee_head'=>$fee_name,
		'_fee_type'=>$fee_type,
		'_status'=>'A',
		'_entry_by'=>$_SESSION['LOGIN_USERID'],
		'_entry_date'=>date("Y:m:d h:i:s")
		);

	$entry1=$obj->Insert_Data_By_Cond("_int_fee_head", $form_data2,"_branch_id='$br_ids' AND _fee_head='$fee_name'");

	}

}


if($operation=='only'){

	$form_data2=array(
		'_branch_id'=>$branchid,
		'_fee_head'=>$fee_name,
		'_fee_type'=>$fee_type,
		'_status'=>'A',
		'_entry_by'=>$_SESSION['LOGIN_USERID'],
		'_entry_date'=>date("Y:m:d h:i:s")
		);

	echo $entry1 = $obj->Insert_Data_By_Cond("_int_fee_head", $form_data2,"_branch_id='$branchid' AND _fee_head='$fee_name'");

}

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


if($operation=='e_only'){

	$form_data12=array(
		'_fee_head'=>$e_fee_head,
		'_fee_type'=>$e_fee_type,
		'_status'=>$e_status,
		'_update_by'=>$_SESSION['LOGIN_USERID']
		);

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

}

if($operation=='e_all'){

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

	foreach($obj->View_colmn_By_Cond("_int_fee_head","_id","_branch_id='$br_pid'") as $value1){
	extract($value1);
	$trm_id = $value1['_id'];

		$form_data13=array(
			'_fee_head'=>$e_fee_head,
			'_fee_type'=>$e_fee_type,
			'_status'=>$e_status,
			'_update_by'=>$_SESSION['LOGIN_USERID']
			);

		$update1=$obj->Update_Data("_int_fee_head", $form_data13,"WHERE _id='$e_fee_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>Fee Head Name</th>
			<th>Fee Type</th>
			<th>Status</th>
			<th>Action</th>
		</thead>
		<tbody>
			
			<?php
			$i='0';
			foreach($obj->View_colmn_By_Cond("_int_fee_head","_id,_fee_head,_fee_type,_status","_branch_id='$branchid' AND _status!='D'") AS $value1){
			$i++;
			extract($value1);
			?>
			<tr>
				<td><?php echo $i; ?></td>
				<td><?php echo $value1['_fee_head']; ?></td>
				<td><?php if($value1['_fee_type']=='M'){echo 'Monthly'; }else if($value1['_fee_type']=='Y'){echo 'Yearly';}else if($value1['_fee_type']=='O'){echo 'Others';} ?></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,
  { "bSortable": true }
] } );
				
</script>