<?php

include("dbconnect.php");
require("pdf_gen/fpdf2.php");
require("word2.php");
class PDF extends FPDF {
function Footer(){
include("dbconnect.php");
require("fpdf1.php");
		$this->SetFont('Times', '', 9);  
		$this->SetTextColor(0,33,56);
		$this->Cell(0,30,'Licensed to '.$vjhvkbnl, 0, 0, 'C');

    }
function RotatedText($x, $y, $txt, $angle)
{
	//Text rotated around its origin
	$this->Rotate($angle,$x,$y);
	$this->Text($x,$y,$txt);
	$this->Rotate(0);
}
function Header() {
include("dbconnect.php");
$rec=@$_GET['receipt'];
$sql1 = 'SELECT * FROM school_info';
$result1 = mysqli_query($con,$sql1);
$row1 = mysqli_fetch_array($result1);

        $data2='Address: P.O BOX '.$row1['address'].' '.$row1['city'];
		$data3='Mobile No: '.$row1['phone'];
		$data4='Email:'.$row1['email'];
		$data5=$row1['logo'];
		$data55=$row1['signature'];
		$dat=date('d-m-Y');
		$data6='Fees Receipt generated on date : '.$dat;
		$data7='__________________________________________________________________________';

		$dec=$row1['school_name'];
		$ttype=$row1['type'];
		
//$sql2 = '';
		$line_thickness=0.04;
		$line_thickness_thicker= 0.6;
		$line_thickness_thick= 0.2;
		$this->SetFont('Times','',11);
		$dat1=date('d-m-Y');
		$paydateqw=strtotime($dat1);
		$payyear=date("Y",$paydateqw);
		
        $w = $this->GetStringWidth($this->title)+150;

        $this->SetTextColor(0);

        //$this->SetLineWidth(0);
		$this->SetFont('Times','',6);
		$this->SetFillColor(976,245,458);
		$this->Rect(0, 0, 300, 500, 'F');
		$this->SetFillColor(200,120,400);
		$this->Rect(10, 37, 130, 18, 'F');
		$this->SetFont('Times','',10);
		
        $this->Image($data5,10,10,20,'L');
		$this->Image($data5,120,10,20,'R');
		
       $this->Cell($w,9,$this->title,0,0,'C');
	    $this->Ln(5);
		/*$this->SetLineWidth(0.4);
		$this->Line(5,5,143,5);
		$this->SetLineWidth(0.4);
		$this->Line(5,205,143,205);
		$this->SetLineWidth(0.4);
		$this->Line(5,5,1,205);*/
		$this->SetTextColor(0,0,255);
       $this->Cell(130,0,"MINISTRY OF EDUCATION" ,0 ,0 ,'C');
	   $this->Ln(5);
		$this->SetTextColor(0,0,255);
       $this->Cell(130,0,$dec ,0 ,0 ,'C');
	    $this->Ln(5);
		$this->SetTextColor(0,0,0);
	   $this->Cell(130,0,strtoupper($data2) ,0 ,0 ,'C');
	    $this->Ln(5);
	   $this->Cell(130,0,strtoupper($data3) ,0 ,0 ,'C');
	    $this->Ln(5);
	   $this->Cell(130,0,$data4 ,0 ,0 ,'C');
        $this->Ln(5);
		$this->SetLineWidth(0.2);
		$this->Line(10,37,140,37);
		$this->SetFont('Times','',10);
		
		$sqlqq47=mysqli_query($con,"select *,(SELECT mode FROM pmodes WHERE pmodes.id=feepayments.modeofpayment) AS modes,
        (SELECT bankname FROM banks WHERE banks.id=feepayments.bank) AS bankname,
        (SELECT fullname FROM finance_users WHERE finance_users.id=feepayments.user_id) AS users,(SELECT academicyear FROM academicyears WHERE academicyears.id=feepayments.years) AS academicy,(select periods from academicyearsperiods where academicyearsperiods.id=feepayments.periods) as period,(select form from forms where forms.id=feepayments.form_id) as form,(select stream from streams where streams.id=feepayments.stream_id) as stream,(SELECT CONCAT(fname,' ',sname,' ',tname) from students where students.adm_no=feepayments.adm_no) as studentname,(SELECT s_type from students where students.adm_no=feepayments.adm_no) as studenttype from  feepayments where `receiptno`='$rec'");
		$rowas414=mysqli_fetch_array($sqlqq47);
		$yeearactive=$rowas414['years'];
		$studenttype=$rowas414['studenttype'];
		$periods=$rowas414['periods'];
		$formsidds=$rowas414['form_id'];
		$admno=$rowas414['adm_no'];
		$this->Cell(25,0,'Admission No:' ,0 ,0 ,'L');
        $this->Cell(60,0,'#'.$rowas414['adm_no'] ,0 ,0 ,'L');
        $this->Cell(23,0,'Receipt No:' ,0 ,0 ,'L');
        $this->Cell(0,0,'#'.$rec ,0 ,0 ,'L');
        $this->Ln(5);
		$this->SetFont('Times','',10);
		$this->Cell(25,5,'Student Name:' ,0 ,0 ,'L');
        $this->Cell(60,5,$rowas414['studentname'] ,0 ,0 ,'L');
        $this->Cell(23,5,'Receipt Date:' ,0 ,0 ,'L');
		$date=date_create($rowas414['created_at']);
        $this->Cell(0,5,date_format($date,"Y/m/d"),0 ,0 ,'L');
        $this->Ln(5);
		$this->SetFont('Arial','',8);
		$this->RotatedText(148,170,$rec,90.5);
		$this->RotatedText(148,150,number_format($rowas414['amount_paid'],2),90.5);
		$this->RotatedText(148,100,$dec,90.5);
		$this->SetFont('Times','',10);
		$this->Cell(20,5,'Class:' ,0 ,0 ,'L');
        $this->Cell(40,5,$ttype.$rowas414['form'].' '.$rowas414['stream'] ,0 ,0 ,'L');
        $this->Cell(10,5,'Term:' ,0 ,0 ,'L');
		$this->Cell(15,5,$rowas414['period'] ,0 ,0 ,'L');
		$this->Cell(15,5,'Time:' ,0 ,0 ,'L');
		$this->Cell(0,5,strtoupper(date_format($date,"H:i:sa")) ,0 ,0 ,'L');
        $this->Ln(5);
		$this->SetLineWidth(0.2);
		//$this->Line(10,57,140,57);
		$this->SetFont('Times','B',11);
	   $this->Cell(10,5,'' ,1 ,0 ,'L');
		$this->Cell(20,5,'Votehead' ,1 ,0 ,'L');
		$this->Cell(20,5, 'Term Fee',1 ,0 ,'R');
		$this->Cell(20,5, 'Year Fee',1 ,0 ,'R');
		$this->Cell(20,5, 'RPT AMT',1 ,0 ,'R');
		$this->Cell(20,5, 'T Paid',1 ,0 ,'R');
		$this->Cell(20,5, 'Balance',1 ,0 ,'R');
		$this->SetFont('Times','',10);
		$this->SetLineWidth(0.4);
		//$this->Line(10,62,140,62);
		$this->SetFont('Arial','',8);
		$this->Ln(5);		
		$totaltermnfee=0;
		$totalyearfee=0;
		$totalereceipt=0;
		$totalpaid=0;
		$totalbalance=0;
		$FFF=1;
		$erer=1;
		$sqlqq=mysqli_query($con,"select * from  voteheads where `academicyear`='$yeearactive' order by priority ASC");
		while($rowasasa=mysqli_fetch_array($sqlqq)){
		$FDFGGDFG=$rowasasa['id'];
		$FDFGGDFGnam=$rowasasa['votehead'];
		$voteheadiddd=$rowasasa['id']; 
		$sqlqq14=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where adm_no='$admno' and `academicyear`='$yeearactive' and academicperiod='{$periods}' and votehead='$voteheadiddd' and transaction_type='1'");
		$rowasasa14=mysqli_fetch_array($sqlqq14);
		$sqlqq141=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where adm_no='$admno' and `academicyear`='$yeearactive'  and votehead='$voteheadiddd' and transaction_type='1'");
		$rowasasa141=mysqli_fetch_array($sqlqq141);
		$sqlqq141s=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where adm_no='$admno' and `academicyear`='$yeearactive'  and votehead='$voteheadiddd' and transaction_type='2'");
		$rowasasa141s=mysqli_fetch_array($sqlqq141s);
		$sqlqq141s1=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where `transaction`='$rec'  and votehead='$voteheadiddd' and transaction_type='2'");
		$rowasasa141s1=mysqli_fetch_array($sqlqq141s1);
		$totaltermnfee=$totaltermnfee+$rowasasa14['amt'];
		$totalyearfee=$totalyearfee+$rowasasa141['amt'];
		$totalereceipt=$totalereceipt+$rowasasa141s1['amt'];
		$totalpaid=$totalpaid+$rowasasa141s['amt'];
		$balance=$rowasasa141['amt']-$rowasasa141s['amt'];
		$totalbalance=$totalbalance+$balance;
		$this->Cell(10,5,$FFF ,1 ,0 ,'L');
		$this->Cell(20,5,$FDFGGDFGnam ,1 ,0 ,'L');	
		$this->Cell(20,5, number_format($rowasasa14['amt'],2),1 ,0 ,'R');	
		$this->Cell(20,5, number_format($rowasasa141['amt'],2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($rowasasa141s1['amt'],2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($rowasasa141s['amt'],2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($balance,2),1 ,0 ,'R');
		$this->Ln(5);
		$FFF++;
		}
		$this->SetFont('arial','B',9);
		$this->Cell(10,5,'' ,1 ,0 ,'L');
		$this->Cell(20,5,'Totals' ,1 ,0 ,'L');	
		$this->Cell(20,5, number_format($totaltermnfee,2),1 ,0 ,'R');	
		$this->Cell(20,5, number_format($totalyearfee,2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($totalereceipt,2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($totalpaid,2),1 ,0 ,'R');
		$this->Cell(20,5, number_format($totalbalance,2),1 ,0 ,'R');
		$this->Ln(5);
		$sqll090=mysqli_query($con,"select orders from academicyearsperiods where id='$periods'");
		$rooowsasss=mysqli_fetch_array($sqll090);
		$oooerders=$rooowsasss['orders'];
		
		$sqlqq14yyyyyyy=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where adm_no='$admno' and `academicyear`='$yeearactive' and transaction_type='1' and academicperiod IN (SELECT id from academicyearsperiods where orders<='$oooerders' and academicyear='$yeearactive')");
		$rowasasa14yyy=mysqli_fetch_array($sqlqq14yyyyyyy);
		$totalbalancefee1=$rowasasa14yyy['amt'];
		
		$sqlqq14yyyyyyy1=mysqli_query($con,"select SUM(amount) as amt from  studentsfee where adm_no='$admno' and `academicyear`='$yeearactive' and transaction_type='2' and transaction<='$rec' and academicperiod IN (SELECT id from academicyearsperiods where orders<='$oooerders' and academicyear='$yeearactive')");
		$rowasasa14yyyy=mysqli_fetch_array($sqlqq14yyyyyyy1);
		$totalbalancefee2=$rowasasa14yyyy['amt'];
		$totalbalancefee=$totalbalancefee1-$totalbalancefee2;
		$this->SetFont('arial','',9);
		$this->Cell(76,5,' ' ,0 ,0 ,'L');
		$this->Cell(34,5,'Total Expected ' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($totalyearfee,2),1 ,0 ,'R');
		$this->Ln(5);
		$ssqlfeeo=mysqli_query($con,"SELECT SUM(amount) AS amt FROM `overpayments` WHERE adm_no='$admno' and `academicyear`='$yeearactive' AND receipt_no<='$rec'"); 
        $rowasa75474=mysqli_fetch_array($ssqlfeeo);
		$amtoverpay=$rowasa75474['amt'];
		$totalpaid45=$amtoverpay+$totalpaid;
		$this->SetFont('Times','',9);
		$this->Cell(76,0,'Amount in word: ' ,0 ,0 ,'L');
		$this->SetFont('arial','',9);
		$this->Cell(34,5,'Total Fees Paid' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($totalpaid45,2),1 ,0 ,'R');
		$this->Ln(5);
		$this->SetFont('Times','',9);
		$this->Cell(76,5,' #'.convert_number_to_words($rowas414['amount_paid']).' only.#' ,0 ,0 ,'L');
		$this->SetFont('arial','',9);
		$this->Cell(34,5,'Rec. Paid Amount' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($rowas414['amount_paid'],2),1 ,0 ,'R');
		$this->Ln(5);
		$this->Cell(76,5,' ' ,0 ,0 ,'L');
		$this->Cell(34,5,'Term Fee Balance' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($totalbalancefee,2),1 ,0 ,'R');
		$this->Ln(5);
		$this->Cell(76,5,' ' ,0 ,0 ,'L');
		$this->Cell(34,5,'Year Fee Balance' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($totalbalance,2),1 ,0 ,'R');
		$this->Ln(5);
		$this->Cell(76,5,' ' ,0 ,0 ,'L');
		$this->Cell(34,5,'Total Overpayment' ,1 ,0 ,'L');
		$this->Cell(20,5, number_format($amtoverpay,2),1 ,0 ,'R');
		$this->Ln(5);
		$this->Ln(5);
		$this->Cell(30,5,'Payment Mode:',1 ,0 ,'L');
		$this->Cell(30,5,$rowas414['modes'],1 ,0 ,'L');
		$this->Cell(20,5,'',0 ,0 ,'L');
		$this->Cell(0,5,'Bursar',0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,5,'Paid by:' ,1 ,0 ,'L');
		$this->Cell(30,5,$rowas414['paidby'],1 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,5,'Served by:' ,1 ,0 ,'L');
		$this->Cell(30,5,$rowas414['users'],1 ,0 ,'L');
		$this->Cell(20,5,'',0 ,0 ,'L');
		$this->Image($data55,95,101+5*$FFF,30,'R');
		$this->Cell(0,5,'________________________',0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,5,'Bank :' ,1 ,0 ,'L');
		$this->Cell(30,5,$rowas414['bankname'],1 ,0 ,'L');
		$this->Ln(5);
		$dateposted=date_create($rowas414['datedeposited']);
		$this->Cell(30,5,'Date Deposited:',1 ,0 ,'L');
		$this->Cell(30,5,date_format($dateposted,"Y/m/d"),1 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,5,'Bank Slip:' ,1 ,0 ,'L');
		$this->Cell(30,5,$rowas414['bankslipno'],1 ,0 ,'L');
		$this->Ln(5);
		$this->SetLineWidth(0.3);
		$this->Line(10,60+(5*$FFF),10,94+(5*$FFF));
		$this->Line(80,60+(5*$FFF),80,94+(5*$FFF));
		$this->Line(10,94+(5*$FFF),80,94+(5*$FFF));
		
		$this->SetLineWidth(0.3);
		$this->Line(71,95+(5*$FFF),71,125+(5*$FFF));
		$this->Line(71,95+(5*$FFF),140,95+(5*$FFF));
		$this->Line(140,95+(5*$FFF),140,125+(5*$FFF));
		$this->Line(71,125+(5*$FFF),140,125+(5*$FFF));
		/*$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(87,52,87,88+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(140,52,140,88+(5*$FFF));
		$this->SetFont('Times','',11);*/
		/*if($rowasasa['priority']==1001){
		@$sqlwe112=mysqli_query($con,"select * from  voteheadpay where admno='{$admno}' and RecNo='{$rec}' and Term='{$dat1term}' and vid='{$voteheadiddd}'");
		@$row22qw12=mysqli_fetch_array($sqlwe112);
		$amsdasasdqwq=$row22qw12['Amount'];
		@$sqlwe112s=mysqli_query($con,"select SUM(Amount) as amt from  voteheadpay where admno='{$admno}' and Term='{$dat1term}' and vid='{$voteheadiddd}' and RecNo<='{$rec}'");
		@$row22qw12s=mysqli_fetch_array($sqlwe112s);
		$amsdasasdqwq1=$row22qw12s['amt'];
		$nowbalance=$amsdasasdqwq1-$amsdasasdqwq;
		$ii=0;
		$daffaspppo=mysqli_query($con,"select * from surcharge where admno='{$admno}'and term='{$dat1term}' and class='{$classid}' and year='{$yearr}' order by id ASC");
		while($rppff=mysqli_fetch_array($daffaspppo)){
			$balalnbvc=$rppff['balance'];
			if($nowbalance>=$balalnbvc){
		$this->Cell(10,0,$FFF ,0 ,0 ,'L');
		$this->Cell(20,0,$rppff['reason'] ,0 ,0 ,'L');	
		$this->Cell(47,0, number_format($rppff['balance'],2),0 ,0 ,'R');	
		$this->Cell(26,0, number_format(0,2),0 ,0 ,'R');
		$this->Cell(27,0, number_format(0,2),0 ,0 ,'R');
		$balla=$ammountbalance1;
		$this->Ln(5);
		$this->SetLineWidth(0.2);
		$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
		$this->SetFont('Times','',10);
		$ammount1=$ammount1+0;
		$ammexpe=$ammexpe+$rppff['balance'];
		$ammbal=$ammbal+0;
			$FFF++;
			$nowbalance=$nowbalance-$balalnbvc;
			}
			else{
				if($ii>0){
					
				}
				else{
			$nowbalance=$nowbalance+$amsdasasdqwq;
				}
				
				if($nowbalance>=$balalnbvc){
				if($rppff['balance']>$amsdasasdqwq){
					$paid=$amsdasasdqwq;
					$bball=$rppff['balance']-$nowbalance;
				}
				elseif($amsdasasdqwq>$rppff['balance']){
					$paid=$amsdasasdqwq;
					$bball=0;
				}
				$this->Cell(10,0,$FFF ,0 ,0 ,'L');
				$this->Cell(20,0,$rppff['reason'] ,0 ,0 ,'L');	
				$this->Cell(47,0, number_format($rppff['balance'],2),0 ,0 ,'R');	
				$this->Cell(26,0, number_format($paid,2),0 ,0 ,'R');
				$this->Cell(27,0, number_format($bball,2),0 ,0 ,'R');
				$balla=$ammountbalance1;
				$this->Ln(5);
				$this->SetLineWidth(0.2);
				$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
				$this->SetFont('Times','',10);
				$ammount1=$ammount1+$paid;
				$ammexpe=$ammexpe+$rppff['balance'];
				$ammbal=$ammbal+$bball;
					$FFF++;
				$nowbalance=$nowbalance-$balalnbvc;
				}
				elseif($balalnbvc>$nowbalance && $nowbalance !=0){
				$ballanc=$balalnbvc-$nowbalance;
				$this->Cell(10,0,$FFF ,0 ,0 ,'L');
				$this->Cell(20,0,$rppff['reason'] ,0 ,0 ,'L');	
				$this->Cell(47,0, number_format($rppff['balance'],2),0 ,0 ,'R');	
				$this->Cell(26,0, number_format($amsdasasdqwq,2),0 ,0 ,'R');
				$this->Cell(27,0, number_format($ballanc,2),0 ,0 ,'R');
				$balla=$ammountbalance1;
				$this->Ln(5);
				$this->SetLineWidth(0.2);
				$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
				$this->SetFont('Times','',10);
				$ammount1=$ammount1+$amsdasasdqwq;
				$ammexpe=$ammexpe+$rppff['balance'];
				$ammbal=$ammbal+$ballanc;
					$FFF++;
					$nowbalance=0;
				}
			else{
				$this->Cell(10,0,$FFF ,0 ,0 ,'L');
				$this->Cell(20,0,$rppff['reason'] ,0 ,0 ,'L');	
				$this->Cell(47,0, number_format($rppff['balance'],2),0 ,0 ,'R');	
				$this->Cell(26,0, number_format(0,2),0 ,0 ,'R');
				$this->Cell(27,0, number_format($rppff['balance'],2),0 ,0 ,'R');
				$balla=$ammountbalance1;
				$this->Ln(5);
				$this->SetLineWidth(0.2);
				$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
				$this->SetFont('Times','',10);
				$ammount1=$ammount1+0;
				$ammexpe=$ammexpe+$rppff['balance'];
				$ammbal=$ammbal+$rppff['balance'];
					$FFF++;
					$nowbalance=0;
			}
				$ii++;
			}
			
		}
		}
		else{
		$sqlqq1=mysqli_query($con,"select * from  voteheadpay where vid='{$FDFGGDFG}' and RecNo='{$rec}'");
		$rowasasa1=mysqli_fetch_array($sqlqq1);
		//if(mysql_num_rows($sqlqq1)>0){
		$sqlqq1wew=mysqli_query($con,"select * from  setvotehead where vid='{$FDFGGDFG}' and class='{$classid}' and stype='$estype1'");
		$rowasasa1wew=mysqli_fetch_array($sqlqq1wew);
        $expected=$rowasasa1wew[$dat1term];
		$tookjghhh=0;
		$sqlqq1wew12=mysqli_query($con,"select * from  voteheadpay where Term='{$dat1term}' and vid='{$FDFGGDFG}' and class='{$classid}' and admno='{$admno}'");
		while($rowasasa1wew12=mysqli_fetch_array($sqlqq1wew12)){
		$tookjghhh=$tookjghhh+$rowasasa1wew12['Amount'];
		}
        $ammount=$rowasasa1['Amount'];///if(mysql_num_rows($sqlqq1)>0){                                                                                                                                                                                                                                                                                                                                                                                                                                          if($data1==$dec){ $ammount=$ammount;} else{ $ammount=($ammount*2);}
		$ammountbalance=$rowasasa1['balance'];
		$balance=$expected-$tookjghhh;
		@$sqlrr=mysqli_query($con,"select * from balBF where admno='{$admno}'and term='{$dat1term}' and class='{$classid}'");
		$rowrr=mysqli_fetch_array($sqlrr);
		$expectedpay1=$rowrr['balance'];
		$balance1=$expectedpay1-$tookjghhh;
		@$sqlrrsss=mysqli_query($con,"select SUM(balance) as balance from surcharge where admno='{$admno}'and term='{$dat1term}' and class='{$classid}'");
		$rowrrsss=mysqli_fetch_array($sqlrrsss);
		$expectedpay1sss=$rowrrsss['balance'];
		$balance1ss=$expectedpay1sss-$tookjghhh;
		@$sqlrr12=mysqli_query($con,"select * from specialvote where admno='{$admno}'and term='{$dat1term}' and class='{$dat1form}'");
		$rowrr12=mysqli_fetch_array($sqlrr12);
		$expectedpay112=$rowrr12['balance'];
		$balance1=$expectedpay112-$tookjghhh;
		$ammountbalance1=$ammountbalance;
		if($rowasasa['priority']==1000){
			$totfffddpaid111=0;
			$totfffbalaa=0;
			$totfffaammmt=0;
			$totalammmtt=0;
			//$totfffddpaid1111=0;
		@$sqlrr12=mysqli_query($con,"select * from svotehead order by priority");
			while($rowrr12=mysqli_fetch_array($sqlrr12)){
			$VVVidssd=$rowrr12['id'];
			$sqlqq11212=mysqli_query($con,"select * from  svoteheadpay where vid='{$VVVidssd}' and RecNo='{$rec}'");
			$rowasasa1QQQ=mysqli_fetch_array($sqlqq11212);
			$totfffddpaid1111=0;
			@$sqlrr1ereert=mysqli_query($con,"select * from asssetvotehead where vid='$VVVidssd' and term='{$dat1term}' and admno='{$admno}' and year='$yearr'");
			if(mysql_num_rows($sqlrr1ereert)>0)
			{
			$this->Cell(10,0,$FFF ,0 ,0 ,'L');
			$this->Cell(20,0,$rowrr12['votename'] ,0 ,0 ,'L');
			$rowrr12dddd=mysqli_fetch_array($sqlrr1ereert);
			$VVVid=$rowrr12dddd['vid'];
			@$sqlrr1fg2=mysqli_query($con,"select * from ssetvotehead where vid='{$VVVid}'");
			$rowrr12dddd34=mysqli_fetch_array($sqlrr1fg2);
			$totfffddpaid111=$totfffddpaid111+$rowrr12dddd34['amount'];
			$totfffddpaid1111=$rowrr12dddd34['amount'];
			$this->Cell(47,0, number_format($totfffddpaid1111,2),0 ,0 ,'R');
			$dsadsdsdd=0;
			@$sqlrmmmmm=mysqli_query($con,"select * from svoteheadpay where vid='$VVVidssd' and term='{$dat1term}' and admno='{$admno}'");
			while($rrrrred=mysqli_fetch_array($sqlrmmmmm)){
			$dsadsdsdd=$dsadsdsdd+$rrrrred['Amount'];
			}
			$balalala=$totfffddpaid1111-$dsadsdsdd;
			$amsdasasdqwq=$dsadsdsdd;
			$balalnbvc=$balalala;
			$totfffaammmt=$totfffaammmt+$amsdasasdqwq;
			$totfffbalaa=$totfffbalaa+$balalnbvc;
			$ammount12=$rowasasa1QQQ['Amount'];
			$totalammmtt=$totalammmtt+$rowasasa1QQQ['Amount'];
			///if(mysql_num_rows($sqlqq1)>0){                                                                                                                                                                                                                                                                                                                                                                                                                                          if($data1==$dec){ $ammount12=$ammount12;} else{ $ammount12=($ammount12*2);}
			$this->Cell(26,0, number_format($ammount12,2),0 ,0 ,'R');
			$this->Cell(27,0, number_format($balalnbvc,2),0 ,0 ,'R');	
		$this->Ln(5);
		$this->SetLineWidth(0.2);
		$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
		$this->SetFont('Times','',10);
		$FFF++;
		}
			
		}
		}
		else{
			$balla=0;
		if($rowasasa['priority']==1){
				$this->Cell(10,0,$FFF ,0 ,0 ,'L');
		$this->Cell(20,0,$FDFGGDFGnam ,0 ,0 ,'L');	
		
		$this->Cell(47,0, number_format($expectedpay1,2),0 ,0 ,'R');	
		$this->Cell(26,0, number_format($ammount,2),0 ,0 ,'R');
		if($ammountbalance1==0){
				$balla=$expectedpay1;
			$this->Cell(27,0, number_format($ammountbalance1,2),0 ,0 ,'R');
			}
			else{
		$this->Cell(27,0, number_format($ammountbalance1,2),0 ,0 ,'R');
		$balla=$ammountbalance1;
			}
			$this->Ln(5);
			$FFF++;
		}
		else{
		$this->Cell(10,0,$FFF ,0 ,0 ,'L');
		$this->Cell(20,0,$FDFGGDFGnam ,0 ,0 ,'L');	
		
		$this->Cell(47,0, number_format($expected,2),0 ,0 ,'R');
		$this->Cell(26,0, number_format($ammount,2),0 ,0 ,'R');
		$this->Cell(27,0, number_format($ammountbalance,2),0 ,0 ,'R');
			$this->Ln(5);
				
		$balla=$ammountbalance;	
		$FFF++;	
		}
		$this->SetLineWidth(0.2);
		$this->Line(10,52+(5*$FFF),140,52+(5*$FFF));
		$this->SetFont('Times','',10);
		//}
		$ammount1=$ammount1+$ammount;
		$ammexpe=$ammexpe+$expected;
		$ammbal=$ammbal+$balla;
		
		}
		}
		}*/
		/*@$sqlrr=mysqli_query($con,"select * from balBF where admno='{$admno}'and term='{$dat1term}' and class='{$classid}'");
		$rowrr=mysqli_fetch_array($sqlrr);
		$expectedpay1=$rowrr['balance'];
		@$sqlrr12=mysqli_query($con,"select * from specialvote where admno='{$admno}'and term='{$dat1term}' and class='{$dat1form}'");
		$rowrr12=mysqli_fetch_array($sqlrr12);
		$expectedpay112=$rowrr12['balance'];
		$ammexpe=$ammexpe+$expectedpay1+@$totfffddpaid111;
		$ammount11=$ammount1+@$totalammmtt;
		$ammbal1=$ammbal+@$totfffbalaa;
		$this->SetLineWidth(0.5);
		$this->Line(10,57+(5*$FFF),140,57+(5*$FFF));
		$this->SetFont('Times','B',11);
	   $this->Cell(10,0,'' ,0 ,0 ,'L');
		$this->Cell(20,0,'Totals' ,0 ,0 ,'L');
		$this->Cell(47,0, number_format($ammexpe,2),0 ,0 ,'R');
		$this->Cell(26,0, number_format($ammount11,2),0 ,0 ,'R');
		$this->Cell(27,0, number_format($ammbal1,2),0 ,0 ,'R');
		$this->Ln(5);
		$this->SetLineWidth(0.3);
		$this->SetFont('Times','',10);
		$this->Line(113,52,113,57+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(19,52,19,57+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(60,52,60,57+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.2);
		$this->Line(10,88+(5*$FFF),140,88+(5*$FFF));
		$this->SetFont('Times','',10);
		$this->Cell(76,0,' ' ,0 ,0 ,'L');
		$this->Cell(34,0,'Total Expected ' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format($ammexpe,2),0 ,0 ,'R');
		$this->Ln(5);
		$this->SetFont('Times','',9);
		$this->Cell(76,0,'Amount in word: ' ,0 ,0 ,'L');
		$this->SetFont('Times','',10);
		$this->Cell(34,0,'Total Fees Paid' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format($ammexpe-$ammbal,2),0 ,0 ,'R');
		$this->Ln(5);
		if($iddfee_balance<0){
			$iddnmmces=0;
		}
		else{
		$iddnmmces=$iddfee_balance;
		}
		$this->SetFont('Times','',9);
		$this->Cell(76,0,' #'.convert_number_to_words($iddnmmc).' only.#' ,0 ,0 ,'L');
		$this->SetFont('Times','',10);
		$this->Cell(34,0,'Rec. Paid Amount' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format($iddnmmc,2),0 ,0 ,'R');
		$this->Ln(5);
		$this->SetFont('Times','',9);
		$this->Cell(76,0,'' ,0 ,0 ,'L');
		$this->SetFont('Times','',10);
		$this->Cell(34,0,'Transaction Charge' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format(0,2),0 ,0 ,'R');
		$this->Ln(5);
		$this->Cell(76,0,' ' ,0 ,0 ,'L');
		$this->Cell(34,0,'Total Fee Balance' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format($ammbal1,2),0 ,0 ,'R');
		$this->Ln(5);
		$ddfddffaffagah=$tootalass-$ammexpe;
		if($ddfddffaffagah>0){
			$ovvvvverpay=$ddfddffaffagah;
		}
		else{
			$ovvvvverpay=0;
		}
		$this->Cell(76,0,' ' ,0 ,0 ,'L');
		$this->Cell(34,0,'Total Overpayment' ,0 ,0 ,'L');
		$this->Cell(20,0, number_format($iddnmmces123,2),0 ,0 ,'R');
		$this->Ln(5);
		$this->Ln(5);
		$this->Cell(30,0,'Payment Mode:',0 ,0 ,'L');
		$this->Cell(60,0,$rowas414['modes'],0 ,0 ,'L');
		$this->Cell(0,0,'Bursar',0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,0,'Paid by:' ,0 ,0 ,'L');
		$this->Cell(0,0,$rowas414['paidby'],0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(30,0,'Served by:' ,0 ,0 ,'L');
		$this->Cell(50,0,$rowas414['users'],0 ,0 ,'L');
		 $this->Image($data55,100,97+5*$FFF,30,'R');
		$this->Cell(0,0,'________________________',0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(20,0,'Bank :' ,0 ,0 ,'L');
		$this->Cell(30,0,$rowas414['bankname'],0 ,0 ,'L');
		$this->Cell(25,0,'Date Deposited:',0 ,0 ,'L');
		$this->Cell(20,0,$rowas414['datepaid'],0 ,0 ,'L');
		$this->Cell(25,0,'',0 ,0 ,'L');
		$this->Cell(30,0,'',0 ,0 ,'L');
		$this->Ln(5);
		$this->Cell(25,0,'Bank Slip:' ,0 ,0 ,'L');
		$this->Cell(30,0,$bankslip,0 ,0 ,'L');
		$this->Cell(15,0,'',0 ,0 ,'L');
		$this->Cell(25,0,'',0 ,0 ,'L');
		$this->Cell(25,0,'',0 ,0 ,'L');
		$this->Cell(30,0,'',0 ,0 ,'L');
		$this->Ln(5);
		$this->SetLineWidth(0.3);
		$this->Line(10,52,10,88+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(87,52,87,88+(5*$FFF));
		$this->SetFont('Times','',11);
		$this->SetLineWidth(0.3);
		$this->Line(140,52,140,88+(5*$FFF));
		$this->SetFont('Times','',11);*/
		


}

}




$pdf = new PDF();



//Column titles

$header=array('Class','Term One','Term Two','Term Three','Total Fee Per Year');



$pdf->SetFont('Arial','',12);

$pdf->AddPage();

// call the table creation method
//$pdf->Cell(0,5,$data1 ,1 ,0 ,'L');
//$pdf->BuildTable($header,$data);
$pdf->Output();

?>