<?php

Yii::import("application.vendors.fpdf.*", true);

class PDF_MC_Table extends FPDF
{
    var $widths;
    var $aligns;

    function SetWidths($w){
        //Set the array of column widths
        $this->widths=$w;
    }

    function SetAligns($a){
        //Set the array of column alignments
        $this->aligns=$a;
    }

    
    
    function Rows($data){
        //Calculate the height of the row
        $nb=0;
        for($i=0;$i<count($data);$i++){
            $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
        }
        $h=9*$nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for($i=0;$i<count($data);$i++){
            $w=$this->widths[$i];
            $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x=$this->GetX();
            $y=$this->GetY();
            //Draw the border
            $this->Rect($x,$y,$w,$h,'DF');
            //Print the text
            
            
            
            if($i==0){
             $this->SetFillColor(133, 193, 233 ); 
             $this->SetFont('Arial','B',12);  
            
             }elseif ($i==1){
             //COLOR DE DIA
             $this->SetFillColor(118, 215, 196  );
             $this->SetFont('Arial','B',12);  
             }elseif ($i==2){
             //COLOR DE DIA
             $this->SetFillColor(245, 183, 177  );
             $this->SetFont('Arial','B',12);  
             }elseif ($i==3){
             //COLOR DEL ESTATUS
             $this->SetFillColor(245, 183, 177 ); 
             //FUENTE DE DIAS
             $this->SetFont('Arial','B',12);  
             }
             
            $this->MultiCell($w,8,$data[$i],0,$a,0);
            //Put the position to the right of the cell
            $this->SetXY($x+$w,$y);
        }
        //Go to the next line
        $this->Ln($h);
    }
    
    
    
    
    
    
    function Row($data){
        //Calculate the height of the row
        $nb=0;
        for($i=0;$i<count($data);$i++){
            $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
        }
        $h=8*$nb;
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for($i=0;$i<count($data);$i++){
            $w=$this->widths[$i];
            $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            //Save the current position
            $x=$this->GetX();
            $y=$this->GetY();
            //Draw the border
            $this->Rect($x,$y,$w,$h,'DF');
            //Print the text
            $this->MultiCell($w,6,$data[$i],0,$a,0);
            //Put the position to the right of the cell
            $this->SetXY($x+$w,$y);
        }
        //Go to the next line
        $this->Ln($h);
    }

    function CheckPageBreak($h){
        //If the height h would cause an overflow, add a new page immediately
        if($this->GetY()+$h>$this->PageBreakTrigger){
            $this->AddPage($this->CurOrientation);
        }
    }

    function NbLines($w,$txt){
        //Computes the number of lines a MultiCell of width w will take
        $cw=&$this->CurrentFont['cw'];
        if($w==0){
            $w=$this->w-$this->rMargin-$this->x;
        }
        $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
        $s=str_replace("\r",'',$txt);
        $nb=strlen($s);
        if($nb>0 and $s[$nb-1]=="\n"){
            $nb--;
        }
        $sep=-1;
        $i=0;
        $j=0;
        $l=0;
        $nl=1;
        while($i<$nb){
            $c=$s[$i];
            if($c=="\n"){
                $i++;
                $sep=-1;
                $j=$i;
                $l=0;
                $nl++;
                continue;
            }
            if($c==' '){
                $sep=$i;
            }
            $l+=$cw[$c];
            if($l>$wmax){
                if($sep==-1){
                    if($i==$j){
                        $i++;
                    }
                }else{
                    $i=$sep+1;
                }
                $sep=-1;
                $j=$i;
                $l=0;
                $nl++;
            }else{
                $i++;
            }
        }
        return $nl;
    }
}
class PDF extends PDF_MC_Table
{
	function Header()
	{
                 $this->Image('public/images/logo.jpeg',10,10,20);
		$this->SetFont('Arial','B',15);
		$this->Cell(80);
		$this->SetX(12);
		$this->Cell(280,10,'RELACION DE PAGOS',0,0,'C');
		$this->Ln(20);
		$this->SetFont('Arial','',10);
		$this->SetFont('Arial','B',11);
		$this->SetFillColor(207,207,207);
		$this->SetTextColor(0);
		$this->SetDrawColor(0);
		$this->SetLineWidth(.3);       
		$this->SetWidths(array(35,35,55,55,55,55,32,32,55,55));
                $this->SetAligns(array('C',  'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));
		$this->Row(array(utf8_decode('FECHA'),
                                 'HORA',
                        
                                 'NOMBRES',
                                 'APELLIDOS',
                                 utf8_decode('Nº ATRASOS'),
                                 'DIA',
                           
                                 'CUOTA',
                                 'MORA',
                                 'ESTATUS',
                                 'GESTOR',
                    
                    
                    
                    ));
		$this->SetWidths(array(35,35,55,55,55,55,32,32,55,55));
                    $this->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));         
	}

	function Footer()
	{
	$this->SetY(-25);
        $this->Ln();
        $this->SetX(10);
        $this->SetFont('Arial', '', 6);
        $this->Cell(180, 10, utf8_decode('GENERADO A TRAVES DEL SISTEMA CREDIYAN EN FECHA ' . date('d/m/Y') . ' POR EL USUARIO: ' . rtrim(Yii::app()->user->name)), 0, 0, 'L');
        $this->Cell(20, 10, utf8_decode('Página ' . $this->PageNo() . '/{nb}'), 0, 0, 'R');
	}
        
        function fichas($data)
	{
            set_time_limit(0); 


		$fila_tabla=1;

		$visitante=0;
		$total=0;
		$this->SetFillColor(207,207,207);
		$this->SetTextColor(0);
		$this->SetDrawColor(0);
		$this->SetLineWidth(.3);

		if ($data){
            
                $this->SetFont('Arial','B',12);
			$this->SetFillColor(207,207,207);
			$this->SetTextColor(0);
			$this->SetDrawColor(0);
			$this->SetLineWidth(0.3);
		
          
                  $n=0;
               $recibo=0;
               $baucher=0;
               $totalrb=0;
               $totalr=0;
               $totalb=0;
               $cuota=0;
               $mora=0;
               $aldia=0;
               $atraso1=0;
               $atraso2=0;
               $atraso3=0;
               $atraso4=0;
               $atraso5=0;
               $atraso6=0;
               $atraso7=0;
               $atraso8=0;
               $atraso9=0;
               $atraso10=0;
               $atraso11=0;
               $atraso12=0;
               $atraso13=0;
               $atraso14=0;
               $atraso15=0;
               $atraso16=0;
               $atraso17=0;
               $atraso18=0;
               $atraso19=0;
               $atraso20=0;
               $atraso21=0;
               $atraso22=0;
               $atraso23=0;
               $atraso24=0;
               $atraso25=0;
               $atraso26=0;
               $atraso27=0;
               $atraso28=0;
               $atraso29=0;
               $atraso30=0;
               $atraso31=0;
               $atraso32=0;
               $atraso33=0;
               $atraso34=0;
               $atraso35=0;
               $atraso36=0;
               $atraso37=0;
               $atraso38=0;
               $atraso39=0;
               $atraso40=0;
               $vencido=0;
               $vencido1=0;
               $vencido2=0;
               $vencido3=0;
               $vencido4=0;
               $vencido5=0;
               $vencido6=0;
               $vencido7=0;
               $vencido8=0;
               $vencido9=0;
               $vencido10=0;
               $vencido11=0;
               $vencido12=0;
               $vencido13=0;
               $vencido14=0;
               $vencido15=0;
               $vencido16=0;
               $vencido17=0;
               $vencido18=0;
               $vencido19=0;
               $vencido20=0;
               $vencido21=0;
               $vencido22=0;
               $vencido23=0;
               $vencido24=0;
               $vencido25=0;
               $vencido26=0;
               $vencido27=0;
               $vencido28=0;
               $vencido29=0;
               $vencido30=0;
               $vencido31=0;
               $vencido32=0;
               $vencido33=0;
               $vencido34=0;
               $vencido35=0;
               $vencido36=0;
               $vencido37=0;
               $vencido38=0;
               $vencido39=0;
               $vencido40=0;       
               $moras=0;
               $cancelado=0;
               
                for ($i= 0; $i < count($data); $i++){
                        $n=$n+1;  
                        $cuota=$cuota+$data[$i]["cuota"];
                        $mora=$mora+$data[$i]["mora"];
                        
                        if($data[$i]["estatusp"]=='AL DIA'){
                          $aldia=$aldia+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==1)  ){
                          $atraso1=$atraso1+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==2)  ){
                          $atraso2=$atraso2+1;  
                        }
                        
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==3)  ){
                          $atraso3=$atraso3+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==4)  ){
                          $atraso4=$atraso4+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==5)  ){
                          $atraso5=$atraso5+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==6)  ){
                          $atraso6=$atraso6+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==7)  ){
                          $atraso7=$atraso7+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==8)  ){
                          $atraso8=$atraso8+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==9)  ){
                          $atraso9=$atraso9+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==10)  ){
                          $atraso10=$atraso10+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==11)  ){
                          $atraso11=$atraso11+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==12)  ){
                          $atraso12=$atraso12+1;  
                        }
                        
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==13)  ){
                          $atraso13=$atraso13+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==14)  ){
                          $atraso14=$atraso14+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==15)  ){
                          $atraso15=$atraso15+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==16)  ){
                          $atraso16=$atraso16+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==17)  ){
                          $atraso17=$atraso17+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==18)  ){
                          $atraso18=$atraso18+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==19)  ){
                          $atraso19=$atraso19+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==20)  ){
                          $atraso20=$atraso20+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==21)  ){
                          $atraso21=$atraso21+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==22)  ){
                          $atraso22=$atraso22+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==23)  ){
                          $atraso23=$atraso23+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==24)  ){
                          $atraso24=$atraso24+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==25)  ){
                          $atraso25=$atraso25+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==26)  ){
                          $atraso26=$atraso26+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==27)  ){
                          $atraso27=$atraso27+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==28)  ){
                          $atraso28=$atraso28+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==29)  ){
                          $atraso29=$atraso29+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==30)  ){
                          $atraso30=$atraso30+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==31)  ){
                          $atraso31=$atraso31+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==32)  ){
                          $atraso32=$atraso32+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==33)  ){
                          $atraso33=$atraso33+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==34)  ){
                          $atraso34=$atraso34+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==35)  ){
                          $atraso35=$atraso35+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==36)  ){
                          $atraso36=$atraso36+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==37)  ){
                          $atraso37=$atraso37+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==38)  ){
                          $atraso38=$atraso38+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==39)  ){
                          $atraso39=$atraso39+1;  
                        }
                        if(($data[$i]["estatusp"]=='ATRASO') and ($data[$i]["atrasosp"]==40)  ){
                          $atraso40=$atraso40+1;  
                        }
                        
                        
                        //vencido
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==0)  ){
                          $vencido=$vencido+1;  
                        }
                        
                         if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==1)  ){
                          $vencido1=$vencido1+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==2)  ){
                          $vencido2=$vencido2+1;  
                        }
                        
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==3)  ){
                          $vencido3=$vencido3+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==4)  ){
                          $vencido4=$vencido4+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==5)  ){
                          $vencido5=$vencido5+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==6)  ){
                          $vencido6=$vencido6+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==7)  ){
                          $vencido7=$vencido7+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==8)  ){
                          $vencido8=$vencido8+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==9)  ){
                          $vencido9=$vencido9+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==10)  ){
                          $vencido10=$vencido10+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==11)  ){
                          $vencido11=$vencido11+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==12)  ){
                          $vencido12=$vencido12+1;  
                        }
                        
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==13)  ){
                          $vencido13=$vencido13+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==14)  ){
                          $vencido14=$vencido14+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==15)  ){
                          $vencido15=$vencido15+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==16)  ){
                          $vencido16=$vencido16+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==17)  ){
                          $vencido17=$vencido17+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==18)  ){
                          $vencido18=$vencido18+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==19)  ){
                          $vencido19=$vencido19+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==20)  ){
                          $vencido20=$vencido20+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==21)  ){
                          $vencido21=$vencido21+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==22)  ){
                          $vencido22=$vencido22+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==23)  ){
                          $vencido23=$vencido23+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==24)  ){
                          $vencido24=$vencido24+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==25)  ){
                          $vencido25=$vencido25+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==26)  ){
                          $vencido26=$vencido26+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==27)  ){
                          $vencido27=$vencido27+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==28)  ){
                          $vencido28=$vencido28+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==29)  ){
                          $vencido29=$vencido29+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==30)  ){
                          $vencido30=$vencido30+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==31)  ){
                          $vencido31=$vencido31+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==32)  ){
                          $vencido32=$vencido32+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==33)  ){
                          $vencido33=$vencido33+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==34)  ){
                          $vencido34=$vencido34+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==35)  ){
                          $vencido35=$vencido35+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==36)  ){
                          $vencido36=$vencido36+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==37)  ){
                          $vencido37=$vencido37+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==38)  ){
                          $vencido38=$vencido38+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==39)  ){
                          $vencido39=$vencido39+1;  
                        }
                        if(($data[$i]["estatusp"]=='VENCIDO') and ($data[$i]["atrasosp"]==40)  ){
                          $vencido40=$vencido40+1;  
                        }
                        
                        if($data[$i]["id_modalidad_pago"]==1){
                            $recibo=$recibo+$data[$i]["cuota"]+$data[$i]["mora"];
                            $totalr=$totalr+1;
                        }
                        if($data[$i]["id_modalidad_pago"]==2){
                            $baucher=$baucher+$data[$i]["cuota"]+$data[$i]["mora"];
                            $totalb=$totalb+1;
                        }
                        
                        if($data[$i]["estatusp"]=='MORAS'){
                          $moras=$moras+1;  
                        }
                        if($data[$i]["estatusp"]=='CANCELADO'){
                          $cancelado=$cancelado+1;  
                        }
                    
					$total++;
					$this->SetFont('Arial','',10);
					$this->SetFillColor(255,255,255);
					$this->SetTextColor(0);
                    $this->SetWidths(array(35,35,55,55,55,55,32,32,55,55));
                    $this->SetAligns(array('C',  'C', 'C',  'C', 'C', 'C', 'C', 'C', 'C', 'C'));
                    $this->Row(array(
                              $data[$i]["fecha"]!=NULL?Utility::fecha($data[$i]["fecha"]):''  , 
                              $data[$i]["hora"],
                           
                              $data[$i]["nombre"],
                              $data[$i]["apellido"],
                              $data[$i]["atrasosp"],
                              $data[$i]["dia"],
                           
                              $data[$i]["cuota"],
                              $data[$i]["mora"],
                              $data[$i]["estatusp"],
                              Gestor::descripcion($data[$i]["id_gestor"]),
                            ));
			}
            $totalrb=$recibo+$baucher;            
                        
         
            $this->Ln(20);
            $this->SetFont('Arial','B',10);
            $this->Cell(80, 10, utf8_decode('SOLES'), 1, 0, 'C');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(80, 10, utf8_decode('CANTIDAD DE PAGOS'), 1, 0, 'C');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(80, 10, utf8_decode('TOTALES SOLES'), 1, 0, 'C');
            
            $this->Ln();
            $this->Cell(40, 10, utf8_decode('BAUCHER'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($baucher,2,',','.'), 1, 0, 'R');
            
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            
            $this->Cell(40, 10, utf8_decode('BAUCHER'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($totalb,0,'.','.'), 1, 0, 'C');
            
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(40, 10, utf8_decode('TOTAL CUOTA'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($cuota,2,',','.'), 1, 0, 'R');
            
            
            $this->Ln();
            $this->Cell(40, 10, utf8_decode('RECIBOS'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($recibo,2,',','.'), 1, 0, 'R');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(40, 10, utf8_decode('RECIBOS'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($totalr,0,'.','.'), 1, 0, 'C');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(40, 10, utf8_decode('TOTAL MORA'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($mora,2,',','.'), 1, 0, 'R');
            
            $this->Ln();
            $this->Cell(40, 10, utf8_decode('TOTAL'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($totalrb,2,',','.'), 1, 0, 'R');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(40, 10, utf8_decode('TOTALES'), 1, 0, 'L');
            $this->Cell(40, 10, number_format($totalb+$totalr,0,'.','.'), 1, 0, 'C');
            $this->Cell(10, 10, utf8_decode(''), 0, 0, 'C');
            $this->Cell(40, 10, utf8_decode('TOTAL GENERAL'), 1, 0, 'L');
            $this->Cell(40, 10,  number_format($cuota+$mora,2,',','.'), 1, 0, 'R');
            
            
            $this->Ln(20);
            
            $this->Cell(80, 10, utf8_decode('ESTATUS'), 1, 0, 'C');
            $this->Ln();
            if($aldia>0){
            $this->Cell(40, 10, utf8_decode('AL DIA'), 1, 0, 'L');
            $this->Cell(40, 10, $aldia, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso1>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 1'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso1, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($atraso2>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 2'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso2, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso3>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 3'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso3, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso4>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 4'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso4, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($atraso5>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 5'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso5, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso6>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 6'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso6, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso7>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 7'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso7, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso8>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 8'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso8, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso9>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 9'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso9, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso10>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 10'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso10, 1, 0, 'C');
            $this->Ln();  
            }
            
             if($atraso11>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 11'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso11, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso12>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 12'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso12, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso13>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 13'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso13, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso14>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 14'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso14, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso15>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 15'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso15, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso16>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 16'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso16, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso17>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 17'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso17, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso18>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 18'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso18, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso19>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 19'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso19, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso20>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 20'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso20, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($atraso21>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 21'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso21, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso22>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 22'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso22, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso23>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 23'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso23, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso24>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 24'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso24, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso25>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 25'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso25, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso26>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 26'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso26, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso27>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 27'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso27, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso28>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 28'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso28, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso29>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 29'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso29, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso30>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 30'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso30, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso31>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 31'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso31, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso32>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 32'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso32, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso33>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 33'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso33, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso34>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 34'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso34, 1, 0, 'C');
            $this->Ln();  
            }
             if($atraso35>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 35'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso35, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso36>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 36'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso36, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso37>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 37'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso37, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso38>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 38'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso38, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso39>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 39'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso38, 1, 0, 'C');
            $this->Ln();  
            }
            if($atraso40>0){
            $this->Cell(40, 10, utf8_decode('ATRASOS DE 40'), 1, 0, 'L');
            $this->Cell(40, 10, $atraso40, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 0'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido1>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 1'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido1, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido2>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 2'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido2, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido3>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 3'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido3, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido4>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 4'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido4, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido5>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 5'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido5, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido6>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 6'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido6, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido7>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 7'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido7, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido8>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 8'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido8, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido9>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 9'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido9, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido10>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 10'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido10, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido11>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 11'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido11, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido12>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 12'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido12, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido13>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 13'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido13, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido14>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 14'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido14, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido15>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 15'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido15, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido16>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 16'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido16, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido17>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 17'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido17, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido18>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 18'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido18, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido19>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 19'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido19, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido20>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 20'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido20, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido21>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 21'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido21, 1, 0, 'C');
            $this->Ln();  
            }
            
            
            if($vencido22>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 22'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido22, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido23>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 23'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido23, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido24>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 24'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido24, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido25>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 25'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido25, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido26>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 26'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido26, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido27>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 27'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido27, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido28>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 28'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido28, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido29>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 29'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido29, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($vencido30>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 30'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido30, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido31>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 31'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido31, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido32>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 32'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido32, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido33>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 33'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido33, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido34>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 34'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido34, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido35>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 35'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido35, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido36>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 36'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido36, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido37>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 37'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido37, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido38>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 38'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido38, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido39>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 39'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido39, 1, 0, 'C');
            $this->Ln();  
            }
            if($vencido40>0){
            $this->Cell(40, 10, utf8_decode('VENCIDO DE 40'), 1, 0, 'L');
            $this->Cell(40, 10, $vencido40, 1, 0, 'C');
            $this->Ln();  
            }
            
            
            if($moras>0){
            $this->Cell(40, 10, utf8_decode('MORAS'), 1, 0, 'L');
            $this->Cell(40, 10, $moras, 1, 0, 'C');
            $this->Ln();  
            }
            
            if($cancelado>0){
            $this->Cell(40, 10, utf8_decode('CANCELADO'), 1, 0, 'L');
            $this->Cell(40, 10, $cancelado, 1, 0, 'C');
            $this->Ln();  
            }
            
            
            
            $this->Output();
	}else{
            echo "<script>alert('No existen registros para mostrar');window.close(this);</script>";
        }
        }
}

		
	
		
?>