/**
  * 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();
     }
 }
 public function onGenerateKambam()
 {
     try {
         TTransaction::open('atividade');
         $object = $this->form->getData();
         $desenvolvimento = new RequisitoDesenvolvimento(1);
         $cliente_id = $desenvolvimento->ticket->solicitante_id;
         $responsavel_id = $desenvolvimento->ticket->responsavel_id;
         $pessoa = new Pessoa($cliente_id);
         $cliente = $pessoa->pessoa_nome;
         $pessoa = new Pessoa($responsavel_id);
         $responsavel = $pessoa->pessoa_nome;
         $string = new StringsUtil();
         $data = $desenvolvimento->data_cadastro;
         $data = explode('-', $data);
         $data_prevista = '___/___/___';
         if ($desenvolvimento->ticket->data_prevista) {
             $data_prevista = $string->formatDateBR($desenvolvimento->ticket->data_prevista);
         }
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/kanban.pdf.xml');
         $designer->replace('{ID_DTR}', $desenvolvimento->id . '/' . $data[0]);
         $designer->replace('{CADASTRO}', $string->formatDateBR($desenvolvimento->data_cadastro));
         $designer->replace('{INICIO}', date('d/m/Y'));
         $designer->replace('{PREVISTA}', $data_prevista);
         $designer->replace('{SISTEMA}', $desenvolvimento->ticket->sistema->nome);
         $designer->replace('{TICKET}', $desenvolvimento->ticket_id);
         $designer->replace('{TITULO}', $desenvolvimento->titulo);
         $designer->replace('{SOLICITANTE}', $cliente);
         $designer->replace('{RESPONSAVEL}', $responsavel);
         $designer->generate();
         $file = 'app/output/DTR011-' . $desenvolvimento->id . '-' . $data[0] . '.pdf';
         $designer->save($file);
         parent::openFile($file);
         new TMessage('info', 'Cartão kambam gerado com sucesso!');
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage);
     }
 }
 /**
  * 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());
     }
 }
 public function onGenerateKanban()
 {
     try {
         TTransaction::open('atividade');
         $object = $this->form->getData();
         $desenvolvimento = new RequisitoDesenvolvimento($object->id);
         $cliente_id = $desenvolvimento->ticket->solicitante_id;
         $responsavel_id = $desenvolvimento->ticket->responsavel_id;
         $pessoa = new Pessoa($cliente_id);
         $cliente = $pessoa->pessoa_nome;
         $pessoa = new Pessoa($responsavel_id);
         $responsavel = $pessoa->pessoa_nome;
         $data = $desenvolvimento->data_cadastro;
         $data = explode('-', $data);
         $data_prevista = '___/___/___';
         if ($desenvolvimento->ticket->data_prevista) {
             $data_prevista = $this->string->formatDateBR($desenvolvimento->ticket->data_prevista);
         }
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/kanban.pdf.xml');
         $designer->replace('{ID_DTR}', $desenvolvimento->ticket_id . '/' . $data[0]);
         $designer->replace('{CADASTRO}', $this->string->formatDateBR($desenvolvimento->data_cadastro));
         $designer->replace('{INICIO}', date('d/m/Y'));
         $designer->replace('{PREVISTA}', $data_prevista);
         $designer->replace('{SISTEMA}', utf8_decode($desenvolvimento->ticket->sistema->nome));
         $designer->replace('{TICKET}', $desenvolvimento->ticket_id);
         $designer->replace('{TITULO}', utf8_decode($desenvolvimento->titulo));
         $designer->replace('{SOLICITANTE}', utf8_decode($cliente));
         $designer->replace('{RESPONSAVEL}', utf8_decode($responsavel));
         $designer->generate();
         $tipo = array(4 => 'D', 5 => 'A', 6 => 'C');
         $nome = 'DTR011' . $tipo[$desenvolvimento->ticket->tipo_ticket_id] . $desenvolvimento->ticket_id . '-' . $data[0] . ' - ' . $desenvolvimento->titulo;
         $file = 'app/output/' . $nome . '.pdf';
         $designer->save($file);
         parent::openFile($file);
         TButton::enableField('form_RequisitoDesenvolvimento', 'save');
         $this->form->setData($object);
         // define the onEdit action
         $action = new TAction(array($this, 'onEdit'));
         $param['key'] = $object->id;
         $action->setParameters($param);
         // pass the key parameter ahead
         new TMessage('info', 'Cartão kambam gerado com sucesso!', $action);
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage);
     }
 }