<?php
session_start();
// ============ this file shows all services based on users' preferences
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============
$branch_id=$_SESSION['LOGIN_BRANCH'];
$selected_session_for_fee_collection=addslashes(trim($_GET['session_fee_collection']));
$selected_exam_name_for_fee_collection=addslashes(trim($_GET['exam_name_fee_collection']));
$selected_payment_status_for_fee_collection=addslashes(trim($_GET['payment_status_fee_collection']));

$table_name="_exam_service_school_add a left join _exam_service_registration b on a._id=b._pid";
$column="a._school_name,b._id,b._exam_name,b._session,b._total_amount,b._due_amount,b._paid_amount,b._discount_amount,b._last_paid_amount,b._status";
$where_cond="b._session='".$selected_session_for_fee_collection."'";
if($selected_exam_name_for_fee_collection!="" && $selected_payment_status_for_fee_collection==""){
	$where_cond="b._session='".$selected_session_for_fee_collection."' and b._exam_name='".$selected_exam_name_for_fee_collection."'";
}
if($selected_exam_name_for_fee_collection=="" && $selected_payment_status_for_fee_collection!=""){
	$where_cond="b._session='".$selected_session_for_fee_collection."' and b._status='".$selected_payment_status_for_fee_collection."'";
}
if($selected_exam_name_for_fee_collection!="" && $selected_payment_status_for_fee_collection!=""){
	$where_cond="b._session='".$selected_session_for_fee_collection."' and b._exam_name='".$selected_exam_name_for_fee_collection."' and b._status='".$selected_payment_status_for_fee_collection."'";
}
$shift_list=$obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond);
?>
<style type="text/css">
i{
	cursor:pointer;
}

</style>
<div class="row-fluid">
								
								
	<table id="sample-table-22" class="table table-striped table-bordered table-hover">
		<thead>
			<th>Sl</th>
			<th>School Name</th>
            <th>Exam Name</th>
            <th>Session</th>
			<th>Total Amount</th>
			<th>Due Amount</th>
			<th>Paid Amount</th>
			<th>Discount Amount</th>
			<th>Payment Status</th>
			<th>Action</th>
		</thead>
		<tbody>
			<?php
				$sl=1;
				foreach($shift_list AS $index1=>$value1){
					
					
					
					echo "<tr>";
					echo "<td>".$sl."</td>";$sl++;
					echo "<td>".$value1['_school_name']."</td>";
					echo "<td>".$value1['_exam_name']."</td>";
					echo "<td>".$value1['_session']."</td>";
					echo "<td>".$value1['_total_amount']."</td>";
					echo "<td>".$value1['_due_amount']."</td>";
					echo "<td>".$value1['_paid_amount']."</td>";
					echo "<td>".$value1['_discount_amount']."</td>";
					$selected_id_to_edit_collection_fee_info = $value1['_id'];
					$show_payment_status = $value1['_status'];
					if($show_payment_status == 'P'){
						echo "<td style=\"color: green; font-weight: bold;\">Paid</td>";	
					}
					if($show_payment_status == 'U'){
						echo "<td style=\"color: red; font-weight: bold;\">Unpaid</td>";
					}
					if($show_payment_status == 'PR'){
						echo "<td style=\"color: blue; font-weight: bold;\">Partially Paid</td>";
					}
					echo "<td>";
								if($_SESSION['edit']=='Y'){
									if($show_payment_status == 'P'){
										$origin_page_input=1;
										echo '<i class="icon-list bigger-170" style="hover:cursor;" onclick="perform_show_paid_payment_history_data_table(\''.$selected_id_to_edit_collection_fee_info.'\',\''.$origin_page_input.'\')"></i>';
									}
									else{
										echo '<i class="icon-edit bigger-170" style="hover:cursor;" onclick="perform_show_selected_fee_collection_data(\''.$selected_id_to_edit_collection_fee_info.'\',\''.$show_payment_status.'\')"></i>';
									}
								}
					echo "</td>";
					echo "</tr>";
					
				}
			?>
		</tbody>	

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