?>
</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>
		
</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;
                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 
}
 public function actionPayfeescheque()
 {
     $model = new FeesPaymentTransaction();
     $pay_cheque = new FeesPaymentCheque();
     $pay_trans = new FeesPaymentTransaction();
     $receipt = new FeesReceipt();
     if (isset($_POST['FeesPaymentTransaction'])) {
         Yii::app()->user->setState('student_id', $_POST['FeesPaymentTransaction']['student_id']);
         Yii::app()->user->setState('fees_master_id', $_POST['FeesPaymentTransaction']['fees_master_id']);
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation_cheque(array($model, $pay_cheque));
     if (isset($_POST['FeesPaymentCheque'])) {
         $pay_cheque->attributes = $_POST['FeesPaymentCheque'];
         $cheque_date = $_POST['FeesPaymentCheque']['fees_payment_cheque_date'];
         $chequedate = date("Y-m-d", strtotime($cheque_date));
         $pay_cheque->fees_payment_cheque_date = $chequedate;
         $pay_cheque->fees_payment_cheque_organization_id = Yii::app()->user->getState('org_id');
         if ($pay_cheque->save()) {
             $last_receipt_id = Yii::app()->db->createCommand()->select('MAX(fees_receipt_number) as lastid')->from('fees_receipt')->where('fees_receipt_org_id=:id', array(':id' => Yii::app()->user->getState('org_id')))->queryRow();
             $receipt->fees_receipt_number = $last_receipt_id['lastid'] + 1;
             $receipt->fees_receipt_org_id = Yii::app()->user->getState('org_id');
             $receipt->save();
             $pay_trans->fees_payment_master_id = Yii::app()->user->getState('fees_master_id');
             $pay_trans->fees_payment_method_id = 2;
             $pay_trans->fees_payment_cash_cheque_id = $pay_cheque->fees_payment_cheque_id;
             $pay_trans->fees_receipt_id = $receipt->fees_receipt_id;
             $pay_trans->fees_payment = 1;
             $pay_trans->fees_received_user_id = Yii::app()->user->id;
             $pay_trans->fees_full_part_payment_id = 1;
             $pay_trans->fees_student_id = Yii::app()->user->getState('student_id');
             $pay_trans->fees_payment_transaction_organization_id = Yii::app()->user->getState('org_id');
             $pay_trans->fees_received_date = new CDbExpression('NOW()');
             $stud_trans = StudentTransaction::model()->findByAttributes(array('student_transaction_id' => Yii::app()->user->getState('student_id')));
             $pay_trans->fees_academic_period_id = $stud_trans->student_academic_term_period_tran_id;
             $pay_trans->fees_academic_term_id = $stud_trans->student_academic_term_name_id;
             $pay_trans->save();
             $stud_add_id = $stud_trans->student_transaction_student_address_id;
             $stud_info_id = $stud_trans->student_transaction_student_id;
             $stud_add_mobile = StudentInfo::model()->findByPk($stud_info_id)->student_mobile_no;
             $stud_email_id = StudentInfo::model()->findByPk($stud_info_id)->student_email_id_1;
             $this->redirect(array('create', 'id' => $pay_trans->fees_student_id));
         }
     }
     $this->render('payfeescheque', array('model' => $model, 'pay_cheque' => $pay_cheque));
 }
                    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;
 }