</tr>


<?php 
    foreach ($var as $list) {
        $stud_data = StudentTransaction::model()->findByPk($list['fees_student_id']);
        echo '<tr><td>' . $i . '</td>';
        echo '<td>' . StudentInfo::model()->findByPk($stud_data->student_transaction_student_id)->student_enroll_no . '</td>';
        echo '<td>' . StudentInfo::model()->findByPk($stud_data->student_transaction_student_id)->student_roll_no . '</td>';
        echo '<td>' . StudentInfo::model()->findByPk($stud_data->student_transaction_student_id)->student_first_name . ' ' . StudentInfo::model()->findByPk($stud_data->student_transaction_student_id)->student_middle_name . ' ' . StudentInfo::model()->findByPk($stud_data->student_transaction_student_id)->student_last_name . '</td>';
        echo '<td>' . Branch::model()->findByPk($stud_data->student_transaction_branch_id)->branch_name . '</td>';
        echo '<td>' . AcademicTerm::model()->findByPk($stud_data->student_academic_term_name_id)->academic_term_name . '</td>';
        echo '<td>' . AcademicTermPeriod::model()->findByPk($stud_data->student_academic_term_period_tran_id)->academic_term_period . '</td>';
        echo '<td>' . Division::model()->findByPk($stud_data->student_transaction_division_id)->division_name . '</td>';
        echo '<td>' . $list['fees_received_date'] . '</td>';
        $rec_no = FeesReceipt::model()->findByPk($list['fees_receipt_id'])->fees_receipt_number;
        if ($list['fees_payment_method_id'] == '1') {
            $cash_id = $list['fees_payment_cash_cheque_id'];
            $amunt = FeesPaymentCash::model()->findByPk($cash_id)->fees_payment_cash_amount;
            $final_total += $amunt;
            $type = "Cash";
            echo '<td>' . $type . '</td>';
            echo '<td>-</td>';
            echo '<td>-</td>';
            echo '<td>' . $rec_no . '</td>';
            echo '<td>' . $amunt . '</td>';
        } else {
            $cheque_id = $list['fees_payment_cash_cheque_id'];
            $cheque_status = "Return cheque";
            $amunt1 = FeesPaymentCheque::model()->findByPk($cheque_id)->fees_payment_cheque_amount;
            $status = FeesPaymentCheque::model()->findByPk($cheque_id)->fees_payment_cheque_status;
        ?>
</div>
            </div>

	   <!------------------------content part------------------------->
   	
	    <div class="contentpart1">
	     
	 <div class="receipt">receipt</div>
           <div class="receipt_header"></div>   
		<div class="rcp_info">
			<div class="rcp_rno">
				<div class="rno">Receipt no.</div>
                       	        <div class="rnoline">
                                <span class="number output"><?php 
        echo FeesReceipt::model()->findByPk($data['fees_receipt_id'])->fees_receipt_number;
        ?>
</span></div>
			</div>

			<div class="rcp_date">
				<div class="rdate">date</div>
				<div class="dateline">
				<span class="output"><?php 
        echo date_format(new DateTime($data['fees_received_date']), "d-m-Y");
        ?>
</span></div>
			</div>
                        
		</div>
		
   
    		   </div>
 		</div>

	   <!------------------------content part------------------------->
   	
	    <div class="contentpart1">
	     
	 <div class="receipt">receipt</div>
           <div class="receipt_header"></div>   
		<div class="rcp_info">
			<div class="rcp_rno">
				<div class="rno">Receipt no.</div>
                       	        <div class="rnoline">
                                <span class="number output"><?php 
        echo FeesReceipt::model()->findByPk($my_list)->fees_receipt_number;
        ?>
</span></div>
			</div>

			<div class="rcp_date">
				<div class="rdate">date</div>
				<div class="dateline">
				<span class="output"><?php 
        echo date_format(new DateTime($data->fees_received_date), "d-m-Y");
        ?>
</span></div>
			</div>
                        
		</div>
		
                echo "<td>" . FeesPaymentMethod::model()->findByPk($f->fees_payment_method_id)->fees_payment_method_name . "</td>";
                //echo "<td>".FeesMaster::model()->findByPk($f->fees_payment_master_id)->fees_master_total."</td>";
                echo "<td>" . $payable1 . "</td>";
                $chqmodel = FeesPaymentCheque::model()->findByPk($f->fees_payment_cash_cheque_id);
                echo "<td>" . $chqmodel->fees_payment_cheque_amount . "</td>";
                //$var += FeesPaymentCheque::model()->findByPk($f->fees_payment_cash_cheque_id)->fees_payment_cheque_amount;
                $bank_model = BankMaster::model()->findByPk($chqmodel->fees_payment_cheque_bank);
                $bank_name = $bank_model->bank_short_name;
                $bank_branch = $bank_model->bank_short_name;
                $date = $f->fees_received_date;
                $new_date = date("d-m-Y", strtotime($date));
                echo "<td>" . $new_date . "</td>";
                echo "<td>" . $bank_name . "</td>";
                echo "<td>" . $bank_branch . "</td>";
                echo "<td>" . $ch_num . "</td>";
                echo "<td>" . FeesReceipt::model()->findByPk($f->fees_receipt_id)->fees_receipt_number . "</td>";
                ++$temp;
                $i += 1;
                $flag = 1;
            }
        }
        if ($temp != 0 && $flag == 1) {
            echo "<td>" . $out . "</td>";
            echo "</tr>";
        }
        $m++;
    }
    ?>
	</table>
<?php 
}
                    foreach ($student_fees as $fees_data) {
                        $total += $fees_data->fees_details_amount;
                    }
                    $payable = $total;
                    //$payable = FeesMaster::model()->findByPk($f->fees_payment_master_id)->fees_master_total;
                    $payable1 = $payable;
                }
                $out = $payable - $var;
                $ch_num = FeesPaymentCheque::model()->findByPk($f->fees_payment_cash_cheque_id)->fees_payment_cheque_number;
                $columns['payable'] = $payable1;
                $columns['paid'] = FeesPaymentCheque::model()->findByPk($f->fees_payment_cash_cheque_id)->fees_payment_cheque_amount;
                $date = $f->fees_received_date;
                $new_date = date("d-m-Y", strtotime($date));
                $columns['date'] = $new_date;
                $columns['cheque_no'] = $ch_num;
                $columns['receipt'] = FeesReceipt::model()->findByPk($f->fees_receipt_id)->fees_receipt_number;
                ++$temp;
                $flag = 1;
            }
        }
        if ($flag == 1 && $temp != 0) {
            $columns['out'] = $out;
            $dataArray[] = $columns;
            $i += 1;
            $m++;
        }
    }
    if ($temp != 0) {
        $dataProvider = new CArrayDataProvider($dataArray, array('pagination' => array('pageSize' => count($dataArray), 'pageVar' => 'page')));
        ?>
<div id="fees-cash-grid">
   
    		   </div>
 		</div>

	   <!------------------------content part------------------------->
   	
	    <div class="contentpart1">
	     
	 <div class="receipt">receipt</div>
           <div class="receipt_header"></div>   
		<div class="rcp_info">
			<div class="rcp_rno">
				<div class="rno">Receipt no.</div>
                       	        <div class="rnoline">
                                <span class="number output"><?php 
echo FeesReceipt::model()->findByPk($fees_payment->fees_receipt_id)->fees_receipt_number;
?>
</span></div>
			</div>

			<div class="rcp_date">
				<div class="rdate">date</div>
				<div class="dateline">
				<span class="output"><?php 
echo date_format(new DateTime($fees_payment->fees_received_date), "d-m-Y");
?>
</span></div>
			</div>
                        
		</div>
		
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = FeesReceipt::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }