<?php

use_helper('UtilFunctions');
ViewResponse::getInstance()->setMethodAjax();


$a_dia = getDia();
$a_diaT = getDiaT();

/*
$data = new DateTime("2018-04-01");
echo  $data->format('W');

echo "<br>----------";
*/


//pintarReporte("pv",$a_dimensiones,$a_semana,$a_dia,$a_diaT,$a_dm,1);
//PDF = 1

$o_SucursalBean = new SucursalBean();
$o_SucursalBean->setIdSucursal($cboSucursal);
$o_SucursalBL = new SucursalBL();
$a_o_sucursal = $o_SucursalBL->busquedaSucursal($o_SucursalBean);
if(is_object($a_o_sucursal[0])){
	$Sucursal = $a_o_sucursal[0]->getDescripcion();
	
}

$a_dm = datosMes($cboAno,$cboMes);


$a_dimensiones = getDimensiones($cboSucursal,$a_dm['primerFecha'],$a_dm['ultimoFecha']);


$a_semana = datosFechaMes ($cboAno,$cboMes, $a_dm);
class MYPDF extends TCPDF {
// Page footer
public function Header() {
    //set text color
$this->SetTextColor(255,0,0);

}
}


$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 005');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

//$pdf->SetHeaderData("ca_logo.jpg", 50, "Resumen","");



// set font
$pdf->SetFont('times', '', 8);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

$pdf->SetAuthor('');
$pdf->SetTitle('Reporte de Prestamos Morosos');
$pdf->SetSubject('TCPDF Tutorial');

// set margins
//echo PDF_MARGIN_FOOTER;
$pdf->SetMargins(2, 16, 2);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(5);


// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Reporte de Prestamos Morosos ", "Sucursal: ".$Sucursal." | Periodo: ".$cboAno." - ".$cboMes."",array(0,51,153),array(179,179,179));

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 5);

ob_start();	
pintarReporte("pm",$a_dimensiones,$a_semana,$a_dia,$a_diaT,$a_dm,0,1,1,0,"avg");
// add a page
$pdf->AddPage();
ob_implicit_flush(0);

$tbl .= "<html>";
$tbl .= "<body>";
$tbl .= ob_get_clean();
$tbl .= "</body>";
$tbl .= "</html>";
//echo $tbl;
$pdf->writeHTML($tbl, true, false, false, false, '');


$pdf->Output('example_005.pdf', 'I');

?>