<?php

Yii::createComponent('application.extensions.tcpdf.tcpdf');
$query= MayorAnaliticoDetalle::model()->findAll();

class MiPdf extends TCPDF
{
    
     public function Header()
    {
        $this->SetFont('helvetica', 'B', 16);
        $this->Cell(0, 0, 'Iglesia Linda Vista Shanka', 0, 1, 'C', 0, '', 1);
        $this->Cell(15);
        $this->Cell(0, 0, 'Distrito Adonaí', 0, 1, 'C', 0, '', 1);
        $this->Cell(15);
        $this->Cell(0, 0, 'Club de Conquistadores Zohet', 0, 1, 'C', 0, '', 1);
        $this->SetFont('helvetica','',16);
        $this->Cell(20);
        $this->Cell(0, 0, 'Miembros del Club', 0, 1, 'C', 0, '', 1);
        //$this->Image($image_young,320,10,25,'','PNG','','T', false, 300,'', false, false,0, false, false, false);
       
        
    }
    
    
      public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 10, 'Pagina '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
    
    
    
    
    //load table data from dataProvider
   
    public function ColoredTable($header,$data){
        $this->SetFillColor(255,0,0);
        $this->SetTextColor(255);
        $this->SetDrawColor(128,0,0);
        $this->SetLineWidth(0.3);
        $this->SetFont('','B');
        $this->AddPage();
        $this->Ln(40);
        
        //Header
        $width= array(45,35,40,60,19,25,29,29,30);
        $num_headers = count($header);
        for($i=0;$i<$num_headers;$i++){
            $this->Cell($width[$i], 7, $header[$i], 1, 0, 'C', 1);
        }
        $this->Ln();
        
        $this->SetFillColor(224,235,255);
        $this->SetTextColor(0);
        $this->SetFont('');
        
        //data
          
        
          $fill=0;
         
          
          foreach($query as$q)
          {
          
                
            $this->Cell($width[0], 6, $q->fecha, 'LR', 0, 'L', $fill);
            /*$this->Cell($width[1], 6, $data[$i]["apPaterno"], 'LR', 0, 'L', $fill);
            $this->Cell($width[2], 6, $data[$i]["apMaterno"], 'LR', 0, 'L', $fill);
            $this->Cell($width[3], 6, $fechaNacimiento, 'LR', 0, 'L', $fill);
            $this->Cell($width[4], 6, $edad, 'LR', 0, 'C', $fill);
            $this->Cell($width[5], 6, $estatus_bautizado, 'LR', 0, 'C', $fill);
            $this->Cell($width[6], 6, $data[$i]["numCelular"], 'LR', 0, 'C', $fill);
            $this->Cell($width[6], 6, $data[$i]["numTelefono"], 'LR', 0, 'C', $fill);
            $this->Cell($width[7], 6, $data[$i]["Clase"]["nombre"], 'LR', 0, 'C', $fill);*/
            $this->Ln();
            //$fill=!$fill;
           // $i++;
            
          }
          
          $this->Cell(array_sum($width), 0, '', 'T');
          
        
        
    }
}
    
    $pdf = new MiPdf('L', PDF_UNIT, 'Legal', true, 'UTF-8', false);
    $pdf->SetAutoPageBreak(TRUE, 0);
    
    
    $pdf->SetFont('helvetica','',12);
    
    
    $header = array('Nombres','Apellido paterno', 'Apellido materno', 'Fecha Nacimiento','Edad','Bautizado','Celular','Teléfono','Clase');
    //$pdf->ColoredTable($header, $dataProvider);
    $pdf->Ln(40);
    $pdf->Output();
    exit;
    
    
    
 ?> 