/**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         $data = $this->form->getData();
         $this->form->validate();
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/forms.pdf.xml');
         $designer->replace('{name}', $data->name);
         $designer->generate();
         $designer->gotoAnchorXY('anchor1');
         $designer->SetFontColorRGB('#FF0000');
         $designer->SetFont('Arial', 'B', 18);
         $designer->Write(20, 'Dynamic text !');
         $file = 'app/output/pdf_shapes.pdf';
         if (!file_exists($file) or is_writable($file)) {
             $designer->save($file);
             parent::openFile($file);
         } else {
             throw new Exception(_t('Permission denied') . ': ' . $file);
         }
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
     }
 }
 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // load all customers
         $repository = new TRepository('Customer');
         $criteria = new TCriteria();
         $customers = $repository->load($criteria);
         $data = $this->form->getData();
         $this->form->validate();
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/report.pdf.xml');
         $designer->generate();
         $fill = TRUE;
         $designer->gotoAnchorXY('details');
         $designer->SetFont('Arial', '', 10);
         $designer->setFillColorRGB('#F9F9FF');
         if ($customers) {
             foreach ($customers as $customer) {
                 $designer->gotoAnchorX('details');
                 $designer->Cell(34, 12, $customer->id, 1, 0, 'C', $fill);
                 $designer->Cell(160, 12, utf8_decode($customer->name), 1, 0, 'L', $fill);
                 $designer->Cell(152, 12, utf8_decode($customer->address), 1, 0, 'L', $fill);
                 $designer->Cell(152, 12, utf8_decode($customer->city_name), 1, 0, 'L', $fill);
                 $designer->Ln(12);
                 // grid background
                 $fill = !$fill;
             }
         }
         $file = 'app/output/pdf_report.pdf';
         if (!file_exists($file) or is_writable($file)) {
             $designer->save($file);
             parent::openFile($file);
         } else {
             throw new Exception(_t('Permission denied') . ': ' . $file);
         }
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         TTransaction::rollback();
     }
 }
 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/nfe.pdf.xml');
         $designer->generate();
         $designer->SetFont('Arial', 'B', 8);
         $designer->setFontColorRGB('#4C4491');
         $designer->writeAtAnchor('for_ie', '23234234234');
         $designer->writeAtAnchor('for_cnpj', '001.111.222.0001/00');
         $designer->writeAtAnchor('nome', utf8_decode('Cliente demonstração da silva'));
         $designer->writeAtAnchor('endereco', utf8_decode('Rua das demonstrações'));
         $designer->writeAtAnchor('bairro', 'Centro');
         $designer->writeAtAnchor('municipio', 'Cidade teste');
         $designer->writeAtAnchor('fone', '(11) 1234-5678');
         $designer->writeAtAnchor('uf', 'RS');
         $designer->writeAtAnchor('ie', '45645645656');
         $designer->writeAtAnchor('cep', '00.0000-000');
         $designer->writeAtAnchor('cnpjcpf', '000.000.000-00');
         $designer->writeAtAnchor('dataemissao', '12/12/1912');
         $designer->writeAtAnchor('dataentrada', '12/12/1912');
         $designer->writeAtAnchor('datasaida', '12/12/1912');
         $designer->writeAtAnchor('protocolo', '1234567890');
         $designer->writeAtAnchor('valor_produtos', '1.000,00');
         $designer->writeAtAnchor('frete', '100,00');
         $designer->writeAtAnchor('desconto', '50,00');
         $designer->writeAtAnchor('valor_nota', '1.050,00');
         $designer->writeAtAnchor('complementares', utf8_decode('Obs: Esta é a observação.'));
         $designer->gotoAnchorXY('details');
         $designer->SetFont('Arial', '', 8);
         $designer->Cell(62, 10, '12121212', 1, 0, 'C');
         $designer->Cell(140, 10, utf8_decode('Guaraná'), 1, 0, 'L');
         $designer->Cell(30, 10, '999', 1, 0, 'C');
         $designer->Cell(15, 10, '', 1, 0, 'C');
         $designer->Cell(20, 10, '', 1, 0, 'C');
         $designer->Cell(20, 10, 'PC', 1, 0, 'C');
         $designer->Cell(35, 10, '100', 1, 0, 'C');
         $designer->Cell(30, 10, '5,00', 1, 0, 'R');
         $designer->Cell(24, 10, '0,25', 1, 0, 'R');
         $designer->Cell(24, 10, '500', 1, 0, 'R');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '0', 1, 0, 'R');
         $designer->Cell(20, 10, '0', 1, 0, 'R');
         $designer->Cell(20, 10, '0', 1, 0, 'R');
         $designer->Ln(10);
         $designer->gotoAnchorX('details');
         $designer->Cell(62, 10, '12121212', 1, 0, 'C');
         $designer->Cell(140, 10, utf8_decode('Chocolate'), 1, 0, 'L');
         $designer->Cell(30, 10, '999', 1, 0, 'C');
         $designer->Cell(15, 10, '', 1, 0, 'C');
         $designer->Cell(20, 10, '', 1, 0, 'C');
         $designer->Cell(20, 10, 'PC', 1, 0, 'C');
         $designer->Cell(35, 10, '100', 1, 0, 'C');
         $designer->Cell(30, 10, '5,00', 1, 0, 'R');
         $designer->Cell(24, 10, '0,25', 1, 0, 'R');
         $designer->Cell(24, 10, '500', 1, 0, 'R');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '', 1, 0, 'L');
         $designer->Cell(24, 10, '0', 1, 0, 'R');
         $designer->Cell(20, 10, '0', 1, 0, 'R');
         $designer->Cell(20, 10, '0', 1, 0, 'R');
         $file = 'app/output/nfe.pdf';
         if (!file_exists($file) or is_writable($file)) {
             $designer->save($file);
             parent::openFile($file);
         } else {
             throw new Exception(_t('Permission denied') . ': ' . $file);
         }
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
     }
 }