/**
  * 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 = FeesPaymentMethod::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
     //print_r($student_fees);  exit;
     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;
 }
 $out = $payable - $var;
 $ch_num = FeesPaymentCheque::model()->findByPk($f->fees_payment_cash_cheque_id)->fees_payment_cheque_number;
 echo "<tr class=" . $class . ">";
 echo "<td>" . $i . "</td>";
 echo "<td>" . AcademicTermPeriod::model()->findByPk($f->fees_academic_period_id)->academic_term_period . "</td>";
 echo "<td>" . AcademicTerm::model()->findByPk($f->fees_academic_term_id)->academic_term_name . "</td>";
 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>";
 $m = 1;
 $k = 0;
 $var = 0;
 $out = 0;
 $payable = 0;
 $payable1 = 0;
 $term_id = 0;
 $ch_num = "";
 $temp = 0;
 foreach ($fees as $f) {
     $flag = 0;
     $columns = array();
     $columns['id'] = $m;
     $columns['acdm_period'] = AcademicTermPeriod::model()->findByPk($f->fees_academic_period_id)->academic_term_period;
     $columns['sem'] = AcademicTerm::model()->findByPk($f->fees_academic_term_id)->academic_term_name;
     $columns['method'] = FeesPaymentMethod::model()->findByPk($f->fees_payment_method_id)->fees_payment_method_name;
     if ($f->fees_payment_method_id == 1) {
         if ($m == 1) {
             $term_id = $f->fees_academic_term_id;
         }
         if ($term_id == $f->fees_academic_term_id) {
             $var += FeesPaymentCash::model()->findByPk($f->fees_payment_cash_cheque_id)->fees_payment_cash_amount;
             $total = 0;
             $student_fees = StudentFeesMaster::model()->findAll('fees_master_table_id = :fees_master_id AND student_fees_master_student_transaction_id = :student_id', array(':fees_master_id' => $f->fees_payment_master_id, ':student_id' => $f->fees_student_id));
             //print_r($student_fees);  exit;
             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;
             if ($i == 1) {