public function beforesave()
    {
        $student_id = $_REQUEST['student_id'];
        $criteria = new CDbCriteria();
        $stud_trans = StudentTransaction::model()->findByPk($student_id);
        $criteria->condition = 'fees_student_id =' . $student_id . ' AND fees_academic_period_id=' . $stud_trans['student_academic_term_period_tran_id'] . ' AND fees_academic_term_id=' . $stud_trans['student_academic_term_name_id'];
        $listofid = FeesPaymentTransaction::model()->findAll($criteria);
        $total_fees_amount = 0;
        $fees_stru = Yii::app()->db->createCommand()->select('fees.fees_master_id , fees.fees_master_name , fees.fees_branch_id , stud.student_transaction_branch_id , stud.student_transaction_organization_id , fees.fees_organization_id , stud.student_transaction_quota_id , fees.fees_quota_id ,stud.student_academic_term_period_tran_id , fees.fees_academic_term_id, fees.fees_academic_term_name_id, fees.fees_master_total')->from('student_transaction stud')->join('fees_master fees', 'stud.student_transaction_branch_id = fees.fees_branch_id
		AND stud.student_academic_term_period_tran_id = fees.fees_academic_term_id
		AND stud.student_academic_term_name_id = fees.fees_academic_term_name_id 	
		AND stud.student_transaction_organization_id = fees.fees_organization_id
		AND stud.student_transaction_quota_id = fees.fees_quota_id')->where('stud.student_transaction_id=:id', array(':id' => $student_id))->queryRow();
        $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' => $fees_stru['fees_master_id'], ':student_id' => $student_id));
        foreach ($student_fees as $fees_data) {
            $total_fees_amount += $fees_data->fees_details_amount;
        }
        $cash_total = 0;
        $cheque_total = 0;
        $total = 0;
        if ($listofid != null) {
            foreach ($listofid as $list) {
                if ($list->fees_payment_method_id == 1) {
                    $cash_total = $cash_total + FeesPaymentCash::model()->findByPk($list->fees_payment_cash_cheque_id)->fees_payment_cash_amount;
                } else {
                    $amount = FeesPaymentCheque::model()->findByAttributes(array('fees_payment_cheque_status' => 0, 'fees_payment_cheque_id' => $list->fees_payment_cash_cheque_id));
                    $cheque_total = $cheque_total + $amount['fees_payment_cheque_amount'];
                }
            }
            echo "<div class='total-amount'><h4>Total Paid Fees : <b>" . ($total = $cash_total + $cheque_total . '</b></h4></div>');
            //$total_fees_amount = FeesMaster::model()->findByPk($list->fees_payment_master_id)->fees_master_total;
            if ($this->isNewRecord) {
                $grand_total = $total + $this->fees_payment_cash_amount;
            } else {
                $update_total = FeesPaymentCash::model()->findByPk($_REQUEST['id'])->fees_payment_cash_amount;
                $grand_total = $total - $update_total + $this->fees_payment_cash_amount;
            }
            if ($total_fees_amount < $grand_total) {
                $this->addError('fees_payment_cash_amount', 'You can not take an advance fees for student.');
                return false;
            } else {
                return true;
            }
        } else {
            if ($this->fees_payment_cash_amount > $total_fees_amount) {
                $this->addError('fees_payment_cash_amount', 'You can not take an advance fees for student.');
                return false;
            } else {
                return true;
            }
        }
    }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new FeesPaymentCash();
     $fees_trans = new FeesPaymentTransaction();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['FeesPaymentCash'])) {
         $model->attributes = $_POST['FeesPaymentCash'];
         //$fees_trans->attributes=$_REQUEST['FeesPaymentTransaction'];
         if ($model->save()) {
             $fees_trans->fees_master_id = $_REQUEST['fees_master_id'];
         }
         $fees_trans->fees_payment_method_id = 1;
         $fees_trans->fees_payment_cash_cheque_id = $model->fees_payment_cash_id;
         $fees_trans->fees_receipt_id = 1;
         $fees_trans->fees_payment = $REQUEST['fees_payment'];
         $fees_trans->fees_received_user_id = Yii::app()->user->id;
         $fees_trans->fees_full_part_payment_id = $_REQUEST['fees_full_part_payment_id'];
         $fees_trans->fees_student_id = 1;
         $fees_trans->save();
         $this->redirect(array('view', 'id' => $model->fees_payment_cash_id));
     }
     $this->render('create', array('model' => $model));
 }
 public function beforeDelete()
 {
     $id = $this->student_transaction_id;
     $fees_check = FeesPaymentTransaction::model()->findAll(array('condition' => 'fees_student_id=' . $id));
     $att_check = Attendence::model()->findAll(array('condition' => 'st_id=' . $id));
     $mis_fees = MiscellaneousFeesPaymentTransaction::model()->findAll(array('condition' => 'student_fees_id=' . $id));
     $left_check = LeftDetainedPassStudentTable::model()->findAll(array('condition' => 'student_id=' . $id));
     $st_archive = StudentArchiveTable::model()->findAll(array('condition' => 'student_archive_stud_tran_id=' . $id));
     if (!empty($fees_check) || !empty($att_check) || !empty($mis_fees) || !empty($left_check) || !empty($st_archive)) {
         Yii::app()->user->setFlash('error', "You can not delete this record because it is used in another table.");
         return false;
     } else {
         Yii::app()->user->setFlash('success', "Deleted Sucessfully");
         return true;
     }
 }
}
//$salurl = Yii::app()->request->baseUrl."/css/sal.css";
//echo $salurl;
//echo "</br>".CHtml::link('Export to pdf', array('RecieptGeneratePdf'));
?>


<?php 
$f = 1;
$k = 1;
foreach ($fees_info as $my_list) {
    $org_id = Yii::app()->user->getState('org_id');
    //echo $org_id;
    //echo $end;
    //echo $list['fees_receipt_id'].'<br >';
    $data = FeesPaymentTransaction::model()->findByAttributes(array('fees_receipt_id' => $my_list, 'fees_payment_transaction_organization_id' => $org_id));
    $field1 = '-';
    $field2 = '-';
    $field3 = '-';
    $field4 = '-';
    $field5 = 'CASH';
    //var_dump($data);
    if ($data) {
        $f = 0;
        $stud_trans = StudentTransaction::model()->findByAttributes(array('student_transaction_id' => $data['fees_student_id']));
        $stud_model = StudentInfo::model()->findByAttributes(array('student_id' => $stud_trans['student_transaction_student_id']));
        $sem_name = AcademicTerm::model()->findByPk($data['fees_academic_term_id']);
        $branch = Branch::model()->findByPk($stud_trans['student_transaction_branch_id']);
        $acd_term = AcademicTermPeriod::model()->findByPk($data['fees_academic_period_id']);
        if ($data->fees_payment_method_id == 1) {
            $cash_amt = FeesPaymentCash::model()->findByPk($data->fees_payment_cash_cheque_id);
<style>
table, th, td {
  vertical-align: middle;
}
th, td, caption {
  padding: 4px 0 10px;
  text-align: center;
}

</style>
<?php 
$org_id = Yii::app()->user->getState('org_id');
$fees = FeesPaymentTransaction::model()->findAll('fees_student_id=' . $info_model[0]['student_transaction_id'] . ' and  	fees_payment_transaction_organization_id = ' . $org_id);
if (empty($fees)) {
    echo "<div class=\"block-error\">";
    echo "No fees record available for this student.";
    echo "</div>";
} else {
    $i = 1;
    echo "<h5>Student Roll Number : " . $info_model[0]['student_roll_no'] . "</h5>";
    echo "<h5>Student Enrollment Number : " . $info_model[0]['student_enroll_no'] . "</h5>";
    echo "<h5>Student Name : " . $info_model[0]['student_first_name'] . ' ' . $info_model[0]['student_middle_name'] . ' ' . $info_model[0]['student_last_name'] . "</h5>";
    echo "<h5>Branch: " . Branch::model()->findByPk($info_model[0]['student_transaction_branch_id'])->branch_name . "</h5>";
    echo "<h5>Current Semester: " . AcademicTerm::model()->findByPk($info_model[0]['student_academic_term_name_id'])->academic_term_name . "</h5>";
    ?>

	<table border="1">
		<tr class="table_header">
			<th>
				Sr No.
			</th>
	public function actionStudentFeesReport()
	{
		$model = array();
		$info_model = array();
		if(!empty($_POST['roll_no']))
		{						
			$info_model= Yii::app()->db->createCommand()
					->select('*')
					->from('student_transaction stud')
					->join('student_info stud_info', 'stud_info.student_id = stud.student_transaction_student_id')
					->where('stud_info.student_roll_no="'.$_POST['roll_no'].'"')
					->queryAll();

			$model=FeesPaymentTransaction::model()->findAll('fees_payment_student_id='.$info_model[0]['student_transaction_id']);
			if(empty($info_model))
			{
				Yii::app()->user->setFlash('no-student-found', "No student found with this Roll No.");
				$this->redirect(array('StudentFeesReport'));	
			}
		}
		if(isset($_REQUEST['excel'])) {
				 Yii::app()->request->sendFile(date('YmdHis').'.xls',
				    $this->renderPartial('student_fees_report_excel', array('roll_no'=>$_REQUEST['roll_no']
				    ), true)
				);
		}
		$this->render('student_fees_report',array(
				'model'=>$model,'info_model'=>$info_model,
				));	
	}
 $grandoutstandtotal = 0;
 foreach ($data as $info) {
     if ($m % 2 == 0) {
         $class = "odd";
     } else {
         $class = "even";
     }
     $detail = StudentInfo::model()->findByPk($info['student_transaction_student_id']);
     echo "<tr class=" . $class . "><td>" . ++$i . "</td>";
     echo "<td>" . $detail->student_enroll_no . "</td><td>" . $detail->student_roll_no . "</td>\n\t      <td>" . $detail->student_first_name . " " . $detail->student_middle_name . " " . $detail->student_last_name . "</td>";
     $amtdata = Yii::app()->db->createCommand()->select('sum(fees_details_amount) as total')->from('student_fees_master')->where('student_fees_master_student_transaction_id=' . $info['student_transaction_id'] . ' and fees_master_table_id=' . $fees_masterid)->queryRow();
     $var_amt = $amtdata['total'];
     echo "<td>" . $var_amt . "</td>";
     $grandpayable += $var_amt;
     $totalpaidamt = 0;
     $paid_amt = FeesPaymentTransaction::model()->findAll(array('condition' => 'fees_payment_master_id=' . $fees_masterid . ' and fees_student_id=' . $info['student_transaction_id']));
     foreach ($paid_amt as $list) {
         if ($list['fees_payment_method_id'] == 1) {
             $totalpaidcash = FeesPaymentCash::model()->findByPk($list['fees_payment_cash_cheque_id']);
             $totalpaidamt += $totalpaidcash->fees_payment_cash_amount;
         } else {
             $totalpaidchaque = FeesPaymentCheque::model()->findByPk($list['fees_payment_cash_cheque_id']);
             if ($totalpaidchaque->fees_payment_cheque_status == 0) {
                 $totalpaidamt += $totalpaidchaque->fees_payment_cheque_amount;
             }
         }
     }
     echo "<td>" . $totalpaidamt . "</td>";
     $grandpaidtotal += $totalpaidamt;
     $grandoutstandtotal += $amtdata['total'] - $totalpaidamt;
     echo "<td>" . ($amtdata['total'] - $totalpaidamt) . "</td></tr>";
	public function paidAmount()
	{
		$fees_trans=FeesPaymentTransaction::model()->findAll('fees_payment_student_id='.$_REQUEST['id']);
		$total=0;
		foreach($fees_trans as $fee){
			$total=$total+$fee->fees_payment_amount;
		}
		return $total;
	}
    public function actionMis_report()
    {
        $model = new FeesPaymentTransaction();
        $current_aca_term = AcademicTerm::model()->findAll(array('condition' => 'current_sem=1'));
        if ($current_aca_term) {
            $aca_data = array();
            foreach ($current_aca_term as $aca) {
                $aca_data[] = $aca['academic_term_id'];
                $current_aca_term = $aca->academic_term_period_id;
            }
            $acam_data = implode(",", $aca_data);
            //$current_aca_term = $current_aca_term->academic_term_period_id;
            $fees_data = Yii::app()->db->createCommand()->selectDistinct('fees_master_id, fees_branch_id, fees_academic_term_id,fees_quota_id, fees_academic_term_name_id')->from('fees_master')->where('fees_academic_term_name_id in(' . $acam_data . ') order by fees_branch_id,fees_academic_term_name_id')->queryAll();
            //print count($fees_data); exit;
            if (!empty($fees_data)) {
                foreach ($fees_data as $list) {
                    $ravi_paid = 0;
                    $ravi_total = 0;
                    $my_total = 0;
                    $receive_amount = 0;
                    if (!empty($list)) {
                        $sql = "SELECT COUNT(*) FROM student_transaction where student_transaction_quota_id=" . $list['fees_quota_id'] . " and student_transaction_branch_id = " . $list['fees_branch_id'] . " AND student_academic_term_period_tran_id = " . $list['fees_academic_term_id'] . " AND student_academic_term_name_id = " . $list['fees_academic_term_name_id'];
                        $numStud[] = Yii::app()->db->createCommand($sql)->queryScalar();
                        $ravi_total = Yii::app()->db->createCommand($sql)->queryScalar();
                        $paid_stud = Yii::app()->db->createCommand()->selectDistinct('fees.fees_student_id, stud.student_transaction_id,stud.student_transaction_student_id,stud.student_transaction_quota_id')->from('fees_payment_transaction fees')->join('student_transaction stud', 'fees.fees_student_id = stud.student_transaction_id')->where('stud.student_transaction_branch_id = :branch_id AND stud.student_transaction_quota_id=:quota AND stud.student_academic_term_period_tran_id = :acm_id AND fees.fees_academic_term_id = :acm_name_id', array(':branch_id' => $list['fees_branch_id'], ':acm_id' => $list['fees_academic_term_id'], ':acm_name_id' => $list['fees_academic_term_name_id'], ':quota' => $list['fees_quota_id']))->queryAll();
                        $paid_stud_count[] = count($paid_stud);
                        $ravi_paid = count($paid_stud);
                        $cash_amount = 0;
                        $cheque_amount = 0;
                        foreach ($paid_stud as $stud_id) {
                            $amount_data = FeesPaymentTransaction::model()->findAll('fees_student_id=' . $stud_id['student_transaction_id'] . ' and fees_academic_term_id=' . $list['fees_academic_term_name_id']);
                            foreach ($amount_data as $cash_cheque_list) {
                                if ($cash_cheque_list['fees_payment_method_id'] == 1) {
                                    $cash_amount += FeesPaymentCash::model()->findByPk($cash_cheque_list['fees_payment_cash_cheque_id'])->fees_payment_cash_amount;
                                } else {
                                    $amount = FeesPaymentCheque::model()->findByAttributes(array('fees_payment_cheque_status' => 0, 'fees_payment_cheque_id' => $cash_cheque_list->fees_payment_cash_cheque_id));
                                    $cheque_amount = $cheque_amount + $amount['fees_payment_cheque_amount'];
                                }
                            }
                        }
                        $total_receive_amount[] = $cash_amount + $cheque_amount;
                        $unpaid_stud = Yii::app()->db->createCommand()->selectDistinct('stud.student_transaction_id,stud.student_transaction_student_id,stud.student_transaction_quota_id')->from('student_transaction stud')->where('stud.student_transaction_id NOT IN (SELECT fees_student_id FROM fees_payment_transaction)
				AND stud.student_transaction_branch_id = :branch_id AND stud.student_academic_term_period_tran_id = :acm_id AND stud.student_academic_term_name_id = :acm_name_id', array(':branch_id' => $list['fees_branch_id'], ':acm_id' => $list['fees_academic_term_id'], ':acm_name_id' => $list['fees_academic_term_name_id']))->queryAll();
                        $unpaid_stud_count[] = $ravi_total - $ravi_paid;
                        //$unpaid_stud_count[] = count($unpaid_stud);
                        $total_amount_data = FeesMaster::model()->findAll('fees_branch_id =' . $list['fees_branch_id'] . ' AND
					  fees_academic_term_id =' . $list['fees_academic_term_id'] . ' AND
					  fees_academic_term_name_id =' . $list['fees_academic_term_name_id']);
                        $fees_stru = Yii::app()->db->createCommand()->select('fees.fees_master_id ,  stud.student_transaction_student_id, stud.student_academic_term_period_tran_id, stud.student_academic_term_name_id')->from('student_transaction stud')->join('fees_master fees', 'stud.student_transaction_branch_id = fees.fees_branch_id
		AND stud.student_academic_term_period_tran_id = fees.fees_academic_term_id
		AND stud.student_academic_term_name_id = fees.fees_academic_term_name_id 	

		AND stud.student_transaction_quota_id = fees.fees_quota_id')->where('stud.student_academic_term_period_tran_id = :term_p_id AND stud.student_academic_term_name_id = :term_name_id AND fees.fees_master_id = :fees_id', array(':fees_id' => $list['fees_master_id'], ':term_p_id' => $list['fees_academic_term_id'], ':term_name_id' => $list['fees_academic_term_name_id']))->queryAll();
                        //print_r($fees_stru); exit;
                        $total = 0;
                        foreach ($fees_stru as $fees_data1) {
                            $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' => $fees_data1['fees_master_id'], ':student_id' => $fees_data1['student_transaction_student_id']));
                            foreach ($student_fees as $fees_data1) {
                                $total += $fees_data1->fees_details_amount;
                            }
                        }
                        //print $total; exit;
                        $total_amount[] = $total;
                    }
                }
                if (isset($_REQUEST['MISexport'])) {
                    Yii::import('application.extensions.tcpdf.*');
                    require_once 'tcpdf/tcpdf.php';
                    require_once 'tcpdf/config/lang/eng.php';
                    $html = $this->renderPartial('report_view_pdf', array('numStud' => $numStud, 'fees_data' => $fees_data, 'paid_stud_count' => $paid_stud_count, 'unpaid_stud_count' => $unpaid_stud_count, 'total_amount' => $total_amount, 'total_receive_amount' => $total_receive_amount), true);
                    ob_clean();
                    $pdf = new TCPDF();
                    $pdf->SetCreator(PDF_CREATOR);
                    $pdf->SetAuthor(Yii::app()->name);
                    $pdf->SetTitle('MIS Report');
                    $pdf->SetSubject('MIS Report');
                    $pdf->SetKeywords('example, text, report');
                    $pdf->SetHeaderData('', 0, "Fees Summary", '');
                    //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Example Report by ".Yii::app()->name, "");
                    $pdf->setHeaderFont(array('helvetica', '', 8));
                    $pdf->setFooterFont(array('helvetica', '', 6));
                    $pdf->SetMargins(15, 18, 15);
                    $pdf->SetHeaderMargin(5);
                    $pdf->SetFooterMargin(10);
                    $pdf->SetAutoPageBreak(TRUE, 15);
                    $pdf->SetFont('dejavusans', '', 7);
                    $resolution = array(150, 150);
                    $pdf->AddPage('P', $resolution);
                    $pdf->writeHTML($html, true, false, true, false, '');
                    $pdf->LastPage();
                    $pdf->Output("MIS.pdf", "I");
                }
                if (isset($_REQUEST['MISexportexcel'])) {
                    Yii::app()->request->sendFile(date('YmdHis') . '.xlsx', $this->renderPartial('report_view_pdf', array('numStud' => $numStud, 'fees_data' => $fees_data, 'paid_stud_count' => $paid_stud_count, 'unpaid_stud_count' => $unpaid_stud_count, 'total_amount' => $total_amount, 'total_receive_amount' => $total_receive_amount), true));
                }
                $this->render('create_report', array('numStud' => $numStud, 'fees_data' => $fees_data, 'paid_stud_count' => $paid_stud_count, 'unpaid_stud_count' => $unpaid_stud_count, 'total_amount' => $total_amount, 'total_receive_amount' => $total_receive_amount));
            } else {
                $this->render('error_msg', array());
            }
        } else {
            echo "<font color=\"red\"><center>Data Not Available</center></font>";
        }
    }
<?php

$student_name = StudentInfo::model()->findByPk(StudentTransaction::model()->findByPk($_REQUEST['id'])->student_transaction_student_id);
$org_id = Yii::app()->user->getState('org_id');
$fees = FeesPaymentTransaction::model()->findAll('fees_student_id=' . $_REQUEST['id'] . ' and  	fees_payment_transaction_organization_id = ' . $org_id);
if (!empty($fees)) {
    ?>
	
		
		
		<?php 
    $i = 1;
    $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;
<?php

$this->breadcrumbs = array('Fees Payment Transactions' => array('/feesPaymentTransaction/addfees'), 'Add');
$this->menu = array();
?>

<h1>Collect Fees</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model, 'FeesMasterDetails' => $FeesMasterDetails));
$criteria = new CDbCriteria();
$stud_trans = StudentTransaction::model()->findByPk($_REQUEST['id']);
$criteria->condition = 'fees_student_id =' . $_REQUEST['id'] . ' AND fees_academic_period_id=' . $stud_trans['student_academic_term_period_tran_id'] . ' AND fees_academic_term_id=' . $stud_trans['student_academic_term_name_id'];
$listofid = FeesPaymentTransaction::model()->findAll($criteria);
$cash_total = 0;
$cheque_total = 0;
$amount;
$total = 0;
foreach ($listofid as $list) {
    if ($list->fees_payment_method_id == 1) {
        $cash_total = $cash_total + FeesPaymentCash::model()->findByPk($list->fees_payment_cash_cheque_id)->fees_payment_cash_amount;
    } else {
        //$cheque_total = $cheque_total + FeesPaymentCheque::model()->findByPk($list->fees_payment_cash_cheque_id)->fees_payment_cheque_amount;
        //$info_model=StudentInfo::model()->findByAttributes(array('student_enroll_no'=>$_POST['en_no']));
        $amount = FeesPaymentCheque::model()->findByAttributes(array('fees_payment_cheque_status' => 0, 'fees_payment_cheque_id' => $list->fees_payment_cash_cheque_id));
        $cheque_total = $cheque_total + $amount['fees_payment_cheque_amount'];
    }
}
echo "<div class='total-amount'><h4>Total Paid Fees : <b>" . ($total = $cash_total + $cheque_total . '</b></h4></div>');
Yii::app()->user->setState('student_paid_fees', $total);
?>
<?php
if(!empty($_REQUEST['roll_no']))
		{						
			$info_model= Yii::app()->db->createCommand()
					->select('*')
					->from('student_transaction stud')
					->join('student_info stud_info', 'stud_info.student_id = stud.student_transaction_student_id')
					->where('stud_info.student_roll_no="'.$_REQUEST['roll_no'].'"')
					->queryAll();

			$model=FeesPaymentTransaction::model()->findAll('fees_payment_student_id='.$info_model[0]['student_transaction_id']);
	}
	if(!empty($info_model))
	{
		if(empty($model))
		{
			echo "<div>";
			echo "No fees record available for this student.";
			echo "</div>";
		}
		else
		{
			$batch=Batch::model()->findByPk($info_model[0]['student_transaction_batch_id']);
			$student_name=StudentInfo::model()->findByPk($info_model[0]['student_transaction_student_id']);
			$course=Course::model()->findByPk($batch->course_id);
			$full_name = $student_name->student_first_name." ".$student_name->student_middle_name." ".$student_name->student_last_name;
			?>
			<table  border="2px">
			<tr class="row">
				<td class="col1">Name </td>
				<td class="col2"><?php echo $full_name;?></td>
            echo $stud->student_enroll_no;
            ?>
		</td>	
		<td>
			<?php 
            echo $stud->student_first_name . ' ' . $stud->student_middle_name . ' ' . $stud->student_last_name;
            ?>
		</td>
		<td>
			<?php 
            echo AcademicTerm::model()->findByPk(FeesPaymentTransaction::model()->findByAttributes(array("fees_payment_cash_cheque_id" => $v['fees_payment_cheque_id'], "fees_payment_transaction_organization_id" => Yii::app()->user->getState("org_id"), "fees_payment_method_id" => 2))->fees_academic_term_id)->academic_term_name;
            ?>
		</td>
		<td>
			<?php 
            echo AcademicTermPeriod::model()->findByPk(FeesPaymentTransaction::model()->findByAttributes(array("fees_payment_cash_cheque_id" => $v['fees_payment_cheque_id'], "fees_payment_transaction_organization_id" => Yii::app()->user->getState("org_id"), "fees_payment_method_id" => 2))->fees_academic_period_id)->academic_term_period;
            ?>
		</td>
		<td>
			<?php 
            echo date('d-m-Y', strtotime($v['fees_payment_cheque_date']));
            ?>
		</td>
		<td>
			<?php 
            echo $v['fees_payment_cheque_status'] = 1 ? 'Return Cheque' : '';
            ?>
		</td>
		<td>
			<?php 
            echo BankMaster::model()->findByPk($v['fees_payment_cheque_bank'])->bank_short_name;
        if ($data_student) {
            $student[] = $data_student['student_transaction_id'];
        }
    }
    if (!empty($branch) && empty($acdm_name) && !empty($acdm_period)) {
        $data_student = StudentTransaction::model()->findByAttributes(array('student_transaction_id' => $f['fees_student_id'], 'student_academic_term_period_tran_id' => $acdm_period, 'student_transaction_branch_id' => $branch, 'student_transaction_organization_id' => $org_id));
        if ($data_student) {
            $student[] = $data_student['student_transaction_id'];
        }
    }
}
for ($j = 0; $j < count($student); $j++) {
    if (!empty($acdm_period)) {
        $data1 = FeesPaymentTransaction::model()->findAllByAttributes(array(), $condition = 'fees_academic_period_id = :fees_academic_period_id AND fees_student_id = :fees_student_id', $params = array(':fees_academic_period_id' => $acdm_period, ':fees_student_id' => $student[$j]));
    } else {
        $data1 = FeesPaymentTransaction::model()->findAllByAttributes(array(), $condition = 'fees_student_id = :fees_student_id', $params = array(':fees_student_id' => $student[$j]));
    }
    if ($data1) {
        $flag = 0;
        foreach ($data1 as $data) {
            $stud_trans = StudentTransaction::model()->findByAttributes(array('student_transaction_id' => $data['fees_student_id']));
            $stud_model = StudentInfo::model()->findByAttributes(array('student_id' => $stud_trans['student_transaction_student_id']));
            $sem_name = AcademicTerm::model()->findByPk($data['fees_academic_term_id']);
            $branch = Branch::model()->findByPk($stud_trans['student_transaction_branch_id']);
            $acd_term = AcademicTermPeriod::model()->findByPk($data['fees_academic_period_id']);
            $field1 = '-';
            $field2 = '-';
            $field3 = '-';
            $field4 = '-';
            $field5 = 'CASH';
            if ($data->fees_payment_method_id == 1) {