Ejemplo n.º 1
0
 public function __construct(Asso $asso, $title = 'BDE-UTC: Outil de trésorerie', $culture = 'en')
 {
     $this->config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($culture);
     $this->pdf = new simdePdf($asso, 'Association ' . $asso->getName(), $title);
     $this->asso = $asso;
     $this->pdf->SetCreator(PDF_CREATOR . 'e');
     $this->pdf->SetAuthor(PDF_AUTHOR . 'd');
     $this->pdf->SetTitle($title . 'a');
     $this->pdf->SetSubject($title . 'b');
     $this->pdf->SetKeywords($title . 'c');
     $this->pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     $this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $this->pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $this->pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $this->pdf->setFooterMargin(20);
 }
Ejemplo n.º 2
0
 /**
  * Full test.
  */
 public function executeTest2()
 {
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($this->getUser()->getCulture());
     $doc_title = "test title";
     $doc_subject = "test description";
     $doc_keywords = "test keywords";
     $htmlcontent = "&lt; € &euro; &#8364; &amp; è &egrave; &copy; &gt;<br /><h1>heading 1</h1><h2>heading 2</h2><h3>heading 3</h3><h4>heading 4</h4><h5>heading 5</h5><h6>heading 6</h6>ordered list:<br /><ol><li><b>bold text</b></li><li><i>italic text</i></li><li><u>underlined text</u></li><li><a href=\"http://www.tecnick.com\">link to http://www.tecnick.com</a></li><li>test break<br />second line<br />third line</li><li><font size=\"+3\">font + 3</font></li><li><small>small text</small></li><li>normal <sub>subscript</sub> <sup>superscript</sup></li></ul><hr />table:<br /><table border=\"1\" cellspacing=\"1\" cellpadding=\"1\"><tr><th>#</th><th>A</th><th>B</th></tr><tr><th>1</th><td bgcolor=\"#cccccc\">A1</td><td>B1</td></tr><tr><th>2</th><td>A2 € &euro; &#8364; &amp; è &egrave; </td><td>B2</td></tr><tr><th>3</th><td>A3</td><td><font color=\"#FF0000\">B3</font></td></tr></table><hr />image:<br /><img src=\"sfTCPDFPlugin/images/logo_example.png\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" />";
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle($doc_title);
     $pdf->SetSubject($doc_subject);
     $pdf->SetKeywords($doc_keywords);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->setLanguageArray($l);
     //set language items
     //initialize document
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // set barcode
     $pdf->SetBarcode(date("Y-m-d H:i:s", time()));
     // output some HTML code
     $pdf->writeHTML($htmlcontent, true, 0);
     // output two html columns
     $first_column_width = 80;
     $current_y_position = $pdf->getY();
     $pdf->writeHTMLCell($first_column_width, 0, 0, $current_y_position, "<b>hello</b>", 0, 0, 0);
     $pdf->writeHTMLCell(0, 0, $first_column_width, $current_y_position, "<i>world</i>", 0, 1, 0);
     // output some content
     $pdf->Cell(0, 10, "TEST Bold-Italic Cell", 1, 1, 'C');
     // output some UTF-8 test content
     $pdf->AddPage();
     $pdf->SetFont("FreeSerif", "", 12);
     $utf8text = file_get_contents(K_PATH_CACHE . "utf8test.txt", false);
     // get utf-8 text form file
     $pdf->SetFillColor(230, 240, 255, true);
     $pdf->Write(5, $utf8text, '', 1);
     // remove page header/footer
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     // Two HTML columns test
     $pdf->AddPage();
     $right_column = "<b>right column</b> right column right column right column right column\n    right column right column right column right column right column right column\n    right column right column right column right column right column right column";
     $left_column = "<b>left column</b> left column left column left column left column left\n    column left column left column left column left column left column left column\n    left column left column left column left column left column left column left\n    column";
     $first_column_width = 80;
     $second_column_width = 80;
     $column_space = 20;
     $current_y_position = $pdf->getY();
     $pdf->writeHTMLCell($first_column_width, 0, 0, 0, $left_column, 1, 0, 0);
     $pdf->Cell(0);
     $pdf->writeHTMLCell($second_column_width, 0, $first_column_width + $column_space, $current_y_position, $right_column, 0, 0, 0);
     // add page header/footer
     $pdf->setPrintHeader(true);
     $pdf->setPrintFooter(true);
     $pdf->AddPage();
     // Multicell test
     $pdf->MultiCell(40, 5, "A test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
     $pdf->MultiCell(40, 5, "B test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
     $pdf->MultiCell(40, 5, "C test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
     $pdf->MultiCell(40, 5, "D test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 2);
     $pdf->MultiCell(40, 5, "F test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
     //Close and output PDF document
     $pdf->Output();
     return sfView::NONE;
 }
 public function executeCalidadServicio()
 {
     //Obtener los datos para el reporte
     if ($this->getUser()->getAttribute('esValido') === 'no') {
         $this->redirect('reportes/error');
     } else {
         $datepicker = $this->getUser()->getAttribute('datepicker');
         $datepicker2 = $this->getUser()->getAttribute('datepicker2');
         $date2 = Operaciones::convertirFecha($datepicker2);
         $date = Operaciones::convertirFecha($datepicker);
         $carreras = Doctrine_Core::getTable('carrera')->createQuery('a')->where('a.fecha>=?', $date)->andWhere('a.fecha<=?', $date2)->andWhereNotIn('a.calidad', array(-1, -2))->execute();
         // Configurar el reporte
         $doc_title = "Reporte de Carreras - Radiotaxi \"Benjamín Carrión\" ";
         $doc_subject = "Reporte de Carreras - Radiotaxi \"Benjamín Carrión\"";
         $doc_keywords = "Reporte";
         $config = sfTCPDFPluginConfigHandler::loadConfig();
         sfTCPDFPluginConfigHandler::includeLangFile($this->getUser()->getCulture());
         //crear nuevo documento PDF (unidades del documento se establecen de forma predeterminada en milímetros)
         $pdf = new sfTCPDF("l", PDF_UNIT, PDF_PAGE_FORMAT, true);
         // configurar la información del documento
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor('Cooperativa de taxis "Benjamín Carrión"');
         $pdf->SetTitle('INFORME GENERAL DE CARRERAS REALIZADAS');
         $pdf->SetSubject('Radio-taxi');
         $pdf->SetKeywords('Radio-taxi, PDF, Benjamín Carrión, reporte carreras');
         $pdf->SetHeaderData("", 0, PDF_HEADER_TITLE, PDF_HEADER_STRING);
         //establecer los margenes
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         //establecer saltos de página automático
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
         //establecido factor de escala de imagen
         $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
         $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
         //inicializar el documento
         $pdf->AliasNbPages();
         $pdf->AddPage();
         //diseñar el contenido del reporte
         $htmlcontent = "<h1 style=\"text-align:center;\"> Informe de Calidad de Carreras Realizadas</h1> \n    <p>Carreras realizadas desde {$datepicker} hasta {$datepicker2}.</p> ";
         //Detalle de carreras
         $htmlcontent .= "<h3>Detalle de Carreras</h3>\n            <table style=\"font:normal 76%/150% \"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif;border-collapse:separate;border-spacing:0;border-left:1px solid #686868;    border-right:1px solid #686868;    border-bottom: 1px solid #686868;    color:#000;\">    \n        <thead>\n            <tr bgcolor=\"#ffff73\" style=\"font-weight:bold;line-height:normal;padding:0.25em 0.5em;text-align:left;\">\n                <th style=\"border:1px solid #523A0B;border-width:1px 0; width:6%;text-align: center;\">N° </th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Código</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Unidad</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Fecha</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Hora</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Tiempo</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Atención</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Aproximado<br />Destino</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Llegada</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Calificación<br />Cliente</th>\n            </tr>\n        </thead>\n        <tbody>";
         foreach ($carreras as $i => $carrera) {
             $htmlcontent .= "<tr ";
             if (fmod($i, 2)) {
                 $htmlcontent .= "bgcolor=\"#fcfca0\"";
             } else {
                 $htmlcontent .= "";
             }
             $htmlcontent .= " style= \"border-color:#EBE5D9;padding:0.25em 0.5em;text-align:left;vertical-align:top;\"> \n                <td  style= \"border:1px solid #523A0B;border-width:1px 0;width:6%;\">" . ($i + 1) . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . $carrera->getNumCodigo() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . $carrera->getVehiculo() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getFecha() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . substr($carrera->getHora(), 0, 5) . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">" . $carrera->getTiempo() . " min</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getAtencion() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">" . $carrera->getTiempoAproxDest() . " min</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getLlegada() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">" . $carrera->getCalidad() . "</td>\n            </tr>";
         }
         $htmlcontent .= "</tbody>\n        </table>";
         $pdf->writeHTML($htmlcontent, true, 0);
         // Cerrar y presentar el documento PDF
         $pdf->Output('Reporte.pdf', 'I');
         // Detener el proceso de Symfony
         throw new sfStopException();
     }
 }
Ejemplo n.º 4
0
 protected function doGeneratePdf(sfContext $context, $chartBuilder, $file)
 {
     // definition of chart builder class
     $this->setChartBuilder($chartBuilder);
     // creation of a context
     $context->getConfiguration()->loadHelpers('Partial');
     $context->getRequest()->setRequestFormat('html');
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($context->getUser()->getCulture());
     $doc_title = $this->getName() . " Report";
     $doc_subject = $this->getName() . " Report generated by Otokou";
     $doc_keywords = "report, otokou";
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle($doc_title);
     $pdf->SetSubject($doc_subject);
     $pdf->SetKeywords($doc_keywords);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     //initialize document
     $pdf->AliasNbPages();
     // report informations
     $pdf->AddPage();
     $html = get_partial('report/general_info', array('report' => $this));
     $pdf->writeHTML($html, true, false, true, false, '');
     // vehicles overall performances
     $html = '<h1>Vehicles performances</h1>' . '<p>The values presented below are calculated overall the entire life period of the vehicle(s).</p>' . get_partial('report/vehicles_performances', array('vehicles' => $this->getVehicles()));
     $pdf->writeHTML($html, true, false, true, false, '');
     // charts
     $pdf->AddPage();
     $html = '<h1>Costs</h1>';
     $pdf->writeHTML($html, true, false, true, false, '');
     $counter = 0;
     $options = array();
     $attributes = array('absolute' => true);
     $charts = $this->defineCharts($options, $attributes);
     $nc = count($charts);
     foreach ($charts as $c) {
         $counter++;
         //$html = get_partial('report/chart', array('chart' => $c));
         //$pdf->writeHTML($html, true, false, true, false, '');
         $html = '<h2>' . $c['title'] . '</h2><p>' . $c['comment'] . '</p>';
         $pdf->writeHTML($html);
         $c['chart']->generate();
         $pdf->Image($c['chart']->getChartFileSystemPath());
         if ($counter < $nc) {
             $pdf->AddPage();
         }
     }
     // Close and output PDF document
     $pdf->Output($file, 'F');
 }