<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============
$emp_id			= $_GET['emp_id'];
//$tr_date		= $_GET['tr_date'];
//$tr_date = explode('-',$tr_date);
$year 	= $year;
//$month 	= $month;
$class_id 	= $class_id;
$shift_id 	= $shift_id;
$medium_id 	= $medium_id;
/*$emp_cndtn = '';
if($emp_id!='')
	$emp_cndtn = " and _emp_id='$emp_id'";*/
?>
<!--<script src="module/pay_roll/js/add_emp_sub_set.js" type="text/javascript"></script>-->

<script src="module/fees/js/invoice_print.js" type="text/javascript"></script>

<table class="table table-striped table-bordered table-hover" id="dataTables_emp">
		<thead>
			
            <th style="width:10%">SL</th>
            <th align="center" style="text-align:center;">Class&nbsp;Name</th>
            <th align="center" style="text-align:center;">Total Payable Amount</th>
            <th align="center" style="text-align:center;">Total Receive Amount</th>
            <th align="center" style="text-align:center;">Total Due Amount</th>
            
		</thead>
		<tbody>
        
    <?php
	$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","shift_id='$shift_id' and medium_id='$medium_id' and class_id='$class_id'");
	$class_name 			= $det_in['class'];
	
	$class_ids 			= $det_in['class_id'];
	
	$table_name	= "_fee_master_invoice";
	$column		= "_class_id,_year";
	$where_cond	= "_class_id='$class_ids' and _year='$year' group by _class_id";
	$emp_sub_set_list=$obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond);
	$x=0;
	$total_amounts = 0;
	$paid_amounts = 0;
	$due_amounts = 0;
    foreach($emp_sub_set_list AS $index1=>$data4_sub){
	$x++;
	$_class_id 			= $data4_sub['_class_id'];
	//$_month 			= $data4_sub['_month'];
	$_year 				= $data4_sub['_year'];
	
	$res_head = $obj->View_column_details_By_Cond("_fee_master_invoice","sum(_total_amount) as total_amount,sum(_paid_amount) as paid_amount,sum(_due_amount) as due_amount","_class_id='$_class_id' and _year='$_year'");
	extract($res_head);
	$total_amount 			= $res_head['total_amount'];
	$total_amounts 			+= $res_head['total_amount'];
	
	$paid_amount 			= $res_head['paid_amount'];
	$paid_amounts 			+= $res_head['paid_amount'];
	
	$due_amount 			= $res_head['due_amount'];
	$due_amounts 			+= $res_head['due_amount'];
	
	
	
	//$res_receive = $obj->View_column_details_By_Cond("_fee_total_receive","sum(_receive_amount) as receive_amount","_class_id='$_class_id' and _year='$year'");
	//extract($res_head);
	//$receive_amount 				= $res_receive['receive_amount'];
	?>

    <tr>
    	<td style="width:10%"><?php echo $x; ?></td>
        <td ><?php echo $class_name; ?></td>
        <td style="text-align:right;"><?php echo number_format($total_amount,2); ?></td>
        <td style="text-align:right;"><?php echo number_format($paid_amount,2); ?></td>
        <td style="text-align:right;"><?php echo number_format($due_amount,2); ?></td>
     </tr>
   <?php }?>
   
</tbody> 
	<tfoot>
    	<tr>
        	<th colspan="2" style="text-align:right;">Total:</th>
            <td style="text-align:right;"><?php echo number_format($total_amounts,2); ?></td>
        	<td style="text-align:right;"><?php echo number_format($paid_amounts,2); ?></td>
        	<td style="text-align:right;"><?php echo number_format($due_amounts,2); ?></td>
        </tr>
    </tfoot>

</tfoot>
</table> 

 
<script>
  $(function() {
    $( ".datepick" ).datepicker();
  });
 </script>  