<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============
extract($_GET);

//echo "section_id=".$section_id."<br/>session=".$session;
?>
<style>
.color_row {background-color: #f0f0f0;}
</style>

<div class="row-fluid">
	<div class='row-fluid'>
		<button class='btn btn-small btn-primary' id='print_cl_yearly_fee_sum_btn' style='float:right; margin-bottom:15px;' onclick='print_cl_yearly_fee_sum(<?php echo $section_id.','.$session; ?>)'>
			<i class='icon-print '></i>
				Print
		</button>
	</div>				
	<table id="sample-table-266" class="table table-bordered">
		<thead>
			<tr>
			<th>Sl</th>
			<th>Name</th>
			<th>Roll</th>
			<th>Amount<br/>Type</th>
			<th>Jan</th>
			<th>Feb</th>
			<th>Mar</th>
			<th>Apr</th>
			<th>May</th>
			<th>Jun</th>
			<th>Jul</th>
			<th>Aug</th>
			<th>Sept</th>
			<th>Oct</th>
			<th>Nov</th>
			<th>Dec</th>
			<th>Payment<br/>Summary</th>
			</tr>
		</thead>
		<tbody>
		<?php 
			$i=0;
			$std_info_table = "_pf_std_basic_info pbf LEFT JOIN _pf_std_personal_info psf ON pbf._pid=psf._id";
			$std_info_columns = "psf._id AS std_id,psf._full_name,psf._section_roll";
			$std_info_where_cond = "pbf._section_id=$section_id AND pbf._session=$session AND psf._status='A' ORDER BY psf._section_roll ASC";
			foreach($obj->View_colmn_By_Cond($std_info_table,$std_info_columns,$std_info_where_cond) as $std_info_res){
				$i++;
				extract($std_info_res);
				$std_id = $std_info_res['std_id'];
				$std_name = $std_info_res['_full_name'];
				$std_roll = $std_info_res['_section_roll'];
				
				$fee_info_where_cond = "_section_id=$section_id AND _year=$session AND _std_id=$std_id ORDER BY CONVERT(_month, DECIMAL) ASC";
				$j=0;
				$std_wise_fee_info = array(array());
				$std_wise_yearly_tot_amount = 0;
				$std_wise_yearly_paid_amount = 0;
				$std_wise_yearly_due_amount = 0;
				foreach($obj->View_colmn_By_Cond("_fee_master_invoice","_total_amount,_paid_amount,_due_amount",$fee_info_where_cond) as $fee_info_res){
					extract($fee_info_res);
					
					$std_wise_fee_info[$j][0] = $fee_info_res['_total_amount'];
					$std_wise_fee_info[$j][1] = $fee_info_res['_paid_amount'];
					$std_wise_fee_info[$j][2] = $fee_info_res['_due_amount'];
					
					$std_wise_yearly_tot_amount = $std_wise_yearly_tot_amount + $fee_info_res['_total_amount'];
					$std_wise_yearly_paid_amount = $std_wise_yearly_paid_amount + $fee_info_res['_paid_amount'];
					$std_wise_yearly_due_amount = $std_wise_yearly_due_amount + $fee_info_res['_due_amount'];
					$j++;
				}
				if(($i%2)==0){
						
				
			?>
			<tr class='color_row'>
				<td rowspan="3"><?php echo $i; ?></td>
				<td rowspan="3"><?php echo $std_name; ?></td>
				<td rowspan="3"><?php echo $std_roll; ?></td>
				<td><b>Total Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][0];?></td>
				<td><?php echo $std_wise_fee_info[1][0];?></td>
				<td><?php echo $std_wise_fee_info[2][0];?></td>
				<td><?php echo $std_wise_fee_info[3][0];?></td>
				<td><?php echo $std_wise_fee_info[4][0];?></td>
				<td><?php echo $std_wise_fee_info[5][0];?></td>
				<td><?php echo $std_wise_fee_info[6][0];?></td>
				<td><?php echo $std_wise_fee_info[7][0];?></td>
				<td><?php echo $std_wise_fee_info[8][0];?></td>
				<td><?php echo $std_wise_fee_info[9][0];?></td>
				<td><?php echo $std_wise_fee_info[10][0];?></td>
				<td><?php echo $std_wise_fee_info[11][0];?></td>
				<td><?php echo $std_wise_yearly_tot_amount;?></td>
			</tr>
			<tr class='color_row'>
				<td><b>Paid Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][1];?></td>
				<td><?php echo $std_wise_fee_info[1][1];?></td>
				<td><?php echo $std_wise_fee_info[2][1];?></td>
				<td><?php echo $std_wise_fee_info[3][1];?></td>
				<td><?php echo $std_wise_fee_info[4][1];?></td>
				<td><?php echo $std_wise_fee_info[5][1];?></td>
				<td><?php echo $std_wise_fee_info[6][1];?></td>
				<td><?php echo $std_wise_fee_info[7][1];?></td>
				<td><?php echo $std_wise_fee_info[8][1];?></td>
				<td><?php echo $std_wise_fee_info[9][1];?></td>
				<td><?php echo $std_wise_fee_info[10][1];?></td>
				<td><?php echo $std_wise_fee_info[11][1];?></td>
				<td><?php echo $std_wise_yearly_paid_amount;?></td>
			</tr>
			<tr class='color_row'>
				<td><b>Due Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][2];?></td>
				<td><?php echo $std_wise_fee_info[1][2];?></td>
				<td><?php echo $std_wise_fee_info[2][2];?></td>
				<td><?php echo $std_wise_fee_info[3][2];?></td>
				<td><?php echo $std_wise_fee_info[4][2];?></td>
				<td><?php echo $std_wise_fee_info[5][2];?></td>
				<td><?php echo $std_wise_fee_info[6][2];?></td>
				<td><?php echo $std_wise_fee_info[7][2];?></td>
				<td><?php echo $std_wise_fee_info[8][2];?></td>
				<td><?php echo $std_wise_fee_info[9][2];?></td>
				<td><?php echo $std_wise_fee_info[10][2];?></td>
				<td><?php echo $std_wise_fee_info[11][2];?></td>
				<td><?php echo $std_wise_yearly_due_amount;?></td>
			</tr>
		<?php }
			else{?>
			<tr>
				<td rowspan="3"><?php echo $i; ?></td>
				<td rowspan="3"><?php echo $std_name; ?></td>
				<td rowspan="3"><?php echo $std_roll; ?></td>
				<td><b>Total Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][0];?></td>
				<td><?php echo $std_wise_fee_info[1][0];?></td>
				<td><?php echo $std_wise_fee_info[2][0];?></td>
				<td><?php echo $std_wise_fee_info[3][0];?></td>
				<td><?php echo $std_wise_fee_info[4][0];?></td>
				<td><?php echo $std_wise_fee_info[5][0];?></td>
				<td><?php echo $std_wise_fee_info[6][0];?></td>
				<td><?php echo $std_wise_fee_info[7][0];?></td>
				<td><?php echo $std_wise_fee_info[8][0];?></td>
				<td><?php echo $std_wise_fee_info[9][0];?></td>
				<td><?php echo $std_wise_fee_info[10][0];?></td>
				<td><?php echo $std_wise_fee_info[11][0];?></td>
				<td><?php echo $std_wise_yearly_tot_amount;?></td>
			</tr>
			<tr>
				<td><b>Paid Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][1];?></td>
				<td><?php echo $std_wise_fee_info[1][1];?></td>
				<td><?php echo $std_wise_fee_info[2][1];?></td>
				<td><?php echo $std_wise_fee_info[3][1];?></td>
				<td><?php echo $std_wise_fee_info[4][1];?></td>
				<td><?php echo $std_wise_fee_info[5][1];?></td>
				<td><?php echo $std_wise_fee_info[6][1];?></td>
				<td><?php echo $std_wise_fee_info[7][1];?></td>
				<td><?php echo $std_wise_fee_info[8][1];?></td>
				<td><?php echo $std_wise_fee_info[9][1];?></td>
				<td><?php echo $std_wise_fee_info[10][1];?></td>
				<td><?php echo $std_wise_fee_info[11][1];?></td>
				<td><?php echo $std_wise_yearly_paid_amount;?></td>
			</tr>
			<tr>
				<td><b>Due Amount</b></td>
				<td><?php echo $std_wise_fee_info[0][2];?></td>
				<td><?php echo $std_wise_fee_info[1][2];?></td>
				<td><?php echo $std_wise_fee_info[2][2];?></td>
				<td><?php echo $std_wise_fee_info[3][2];?></td>
				<td><?php echo $std_wise_fee_info[4][2];?></td>
				<td><?php echo $std_wise_fee_info[5][2];?></td>
				<td><?php echo $std_wise_fee_info[6][2];?></td>
				<td><?php echo $std_wise_fee_info[7][2];?></td>
				<td><?php echo $std_wise_fee_info[8][2];?></td>
				<td><?php echo $std_wise_fee_info[9][2];?></td>
				<td><?php echo $std_wise_fee_info[10][2];?></td>
				<td><?php echo $std_wise_fee_info[11][2];?></td>
				<td><?php echo $std_wise_yearly_due_amount;?></td>
			</tr>	
		<?php }
				
		} ?>
		</tbody>	

	</table>
</div>
