<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
extract($_GET);
 
$br_id = $_SESSION['LOGIN_BRANCH'];
// ============

$section_id = isset($_GET['section_id'])? $_GET['section_id']:NULL; 
$student_type_id = isset($_GET['student_type_id'])? $_GET['student_type_id']:NULL; 
$department_id = isset($_GET['department_id'])? $_GET['department_id']:NULL;
$class_id = isset($_GET['class_id'])? $_GET['class_id']:NULL;
$medium_id = isset($_GET['medium_id'])? $_GET['medium_id']:NULL;
$shift_id = isset($_GET['shift_id'])? $_GET['shift_id']:NULL;

//===============================================================
if($section_id != '')
 {$where = "inv._month='$month' AND inv._year='$year' AND section_id='$section_id' GROUP BY ins.section_id";
  $where_c = "minv._month='$month' AND minv._year='$year' AND ins.section_id='$section_id' ";

  $where_g = "_section_id";


}
 
else
if($student_type_id!='')
{$where = "inv._month='$month' AND inv._year='$year' AND student_type_id='$student_type_id' GROUP BY ins.section_id";
$where_c = "minv._month='$month' AND minv._year='$year' AND student_type_id='$student_type_id' ";
$where_g = "student_type_id";
}
else		 
if($department_id!=NULL)
{ $where = "inv._month='$month' AND inv._year='$year' AND department_id='$department_id' GROUP BY ins.section_id";
  $where_c = "minv._month='$month' AND minv._year='$year' AND department_id='$department_id' ";
  $where_g = "department_id";


 }
else
 if($class_id!=NULL)
{ $where = "inv._month='$month' AND inv._year='$year' AND class_id='$class_id' GROUP BY ins.section_id";
  $where_c = "minv._month='$month' AND minv._year='$year' AND class_id='$class_id' ";
  $where_g = "class_id";


}
else
if($medium_id!=NULL)
{ $where = "inv._month='$month' AND inv._year='$year' AND medium_id='$medium_id' GROUP BY ins.section_id";
  $where_c = "minv._month='$month' AND minv._year='$year' AND medium_id='$medium_id' ";
  $where_g = "medium_id";

   }
else
 if($shift_id!=NULL)
{ $where = "inv._month='$month' AND inv._year='$year' AND shift_id='$shift_id' GROUP BY ins.section_id"; 
  $where_c = "minv._month='$month' AND minv._year='$year' AND shift_id='$shift_id' ";
$where_g = "shift_id";

}

else
{   
$where = "inv._month='$month' AND inv._year='$year' AND branch_id='$branchid' GROUP BY ins.section_id";
$where_c = "minv._month='$month' AND minv._year='$year' AND branch_id='$branchid' ";
$where_g = "branch_id";

}




if($month=='01'){$mo = 'January';}
if($month=='02'){$mo = 'February';}
if($month=='03'){$mo = 'March';}
if($month=='04'){$mo = 'April';}
if($month=='05'){$mo = 'May';}
if($month=='06'){$mo = 'June';}
if($month=='07'){$mo = 'July';}
if($month=='08'){$mo = 'August';}
if($month=='09'){$mo = 'September';}
if($month=='10'){$mo = 'October';}
if($month=='11'){$mo = 'November';}
if($month=='12'){$mo = 'December';}


?>

<style type="text/css">

th{

   font-size:13px;
   text-align: center;

}

i{
	cursor:pointer;
}

.select_list{
	width: 200px;
}

.input_sub{
	width: 185px;
}
.select_list1{
	width: 100px;
	float: left;
	margin-left: 3px;
	margin-right: 3px;
}


</style>



<div class="page-content" id="tab">
    <legend style="text-align:center;">
    Fee Colletion Report (<?php echo $mo."-".$year;?>)
    </legend>


    
<div class="row-fluid"  style="margin-top: 15px;" >

        
			

	<table id="sample-table-121" class="table table-striped table-bordered table-hover"  >
		<thead style="">
			<th>Sl</th>
			<th>Shift</th>
			<th>Medium</th>
			<th>Class</th>
			<th>Depertment</th>
			<th>Student Type</th>
			<th>Section</th>
			
			<th>Total Amount (.TK)</th>
			<th>Paid Amount (.TK)</th>
			<th>Due Amount (.TK)</th>
			
			
			<th>Action</th>
		</thead>
		<tbody>
<?php
$i=0;
foreach($obj->fee_collect_report($where) as $value_head){
			extract($value_head);
			$i++;
?>								
	
		<tr>
		    <td><?php echo  $i; ?></td>
			<td><?php echo  $value_head['shift']; ?></td>
			<td><?php echo  $value_head['medium']; ?></td>
			<td><?php echo  $value_head['class']; ?></td>
			<td><?php echo  $value_head['department']; ?></td>
			<td><?php echo  $value_head['student_type']; ?></td>
			<td><?php echo  $value_head['section']; ?></td>
			
			<td style="text-align:center;"><?php if($value_head['_total']!=NULL){ echo $value_head['_total'];} else {echo '-';} ?></td>
			<td style="text-align:center;"><?php if($value_head['_paid']!=NULL){ echo $value_head['_paid'];} else {echo '-';}?></td>
			<td style="text-align:center;"><?php if($value_head['_due']!=NULL){ echo $value_head['_due'];} else {echo '-';} ?></td>
			<td><button type="button" class="btn btn-mini btn-warning no-border" onclick="section_fee_details('<?php echo $value_head['branch_id']; ?>','<?php echo $value_head['_section_id']; ?>','<?php echo $value_head['_month']; ?>','<?php echo $value_head['_year']; ?>')">
						<i class="icon-reply icon-only bigger-150"></i>
						Details
				</button>
			</td>

		</tr>
			
<?php } ?>			
			
		</tbody>
		<tfoot>
<?php
foreach($obj->total_fee($where_c) as $value_total){
			extract($value_total);
			
?>

		    <tr style="background-color: #e0e0d1;">
		      <td colspan="7" style="text-align:center;">Total</td>
		      <td style="text-align:center;"><?php echo $value_total['_total']; ?></td>
		      <td style="text-align:center;"><?php echo $value_total['_p_total']; ?></td>
		      
		      <td style="text-align:center;"><?php echo $value_total['_unp_total']; ?></td>
		      <td></td>
		    </tr>
		    <?php } ?>
		</tfoot>	

	</table>

</div><!--/row-->


</div>
<div class="row-fluid" id="part2">
         
      
</div>

<!--//////////////////////////////////////////////////////////-->

<script type="text/javascript">
	
function section_fee_details(br_id,sc_id,month,year){

//alert(id);
var datastr="br_id="+br_id+"&sc_id="+sc_id+"&month="+month+"&year="+year;
// alert(datastr);
// exit();
$('#tab').css('display','none');

$.ajax({
type:"post",
url:"module/fees/section_fee_coll_details.php",
data:datastr,
success:function(st){

//alert(st);
$("#part2").html(st);
}

}); 		
}


</script>
