当前位置: 首页>>代码示例>>PHP>>正文


PHP TPage::openFile方法代码示例

本文整理汇总了PHP中TPage::openFile方法的典型用法代码示例。如果您正苦于以下问题:PHP TPage::openFile方法的具体用法?PHP TPage::openFile怎么用?PHP TPage::openFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TPage的用法示例。


在下文中一共展示了TPage::openFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onGenerate

 /**
  * 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());
     }
 }
开发者ID:jfrank1500,项目名称:curso_php,代码行数:29,代码来源:PDFDesignShapesView.class.php

示例2: onGenerate

 /**
  * 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();
     }
 }
开发者ID:jfrank1500,项目名称:curso_php,代码行数:49,代码来源:PDFDesignReportView.class.php

示例3: onGenerate


//.........这里部分代码省略.........
             $tipoClientes = array();
             $objects = Atividade::retornaClientesPeriodo($formdata->colaborador_id, $formdata->ano_atividade_inicial . '-' . str_pad($formdata->mes_atividade_inicial, 2, '0', STR_PAD_LEFT) . '-01', $formdata->ano_atividade_final . '-' . str_pad($formdata->mes_atividade_final, 2, '0', STR_PAD_LEFT) . '-' . cal_days_in_month(CAL_GREGORIAN, str_pad($formdata->mes_atividade_final, 2, '0', STR_PAD_LEFT), $formdata->ano_atividade_final), $tickets);
             foreach ($objects as $row) {
                 $cliente = new Pessoa($row['solicitante_id']);
                 if ($cliente->origem == 1) {
                     $ind = $cliente->codigo_cadastro_origem;
                 } else {
                     $ind = 999;
                 }
                 $tipoClientes[$ind] += $this->string->time_to_sec($row['sum']);
             }
             arsort($tipoClientes);
             $colour = FALSE;
             foreach ($tipoClientes as $key => $value) {
                 $style = $colour ? 'datap' : 'datai';
                 $i = 0;
                 $totalClientes = null;
                 $arrayClientes = array();
                 $labelCliente = '';
                 if ($key == '999') {
                     $labelCliente = '999 - ECS';
                 } else {
                     $entidade = new Entidade($key);
                     $labelCliente = str_pad($key, 3, '0', STR_PAD_LEFT) . ' - ' . $entidade->entnomfan;
                 }
                 $tr->addRow();
                 $tr->addCell(utf8_decode($labelCliente), 'left', $style);
                 foreach ($meses as $mes) {
                     $cri = new TCriteria();
                     if ($formdata->colaborador_id > 0) {
                         $cri->add(new TFilter("colaborador_id", "=", $formdata->colaborador_id));
                     }
                     if (!$tickets) {
                         $cliente = Pessoa::getPessoasEntidade($key);
                         $retorno = Ticket::getTicketsCliente($cliente);
                         $arrayTickets = $retorno;
                     }
                     $cri->add(new TFilter("ticket_id", "IN", $arrayTickets));
                     $cri->add(new TFilter("extract('month' from data_atividade)", "=", substr($mes, 3, 2)));
                     $cri->add(new TFilter("extract('year' from data_atividade)", "=", substr($mes, 6, 4)));
                     $cri->add(new TFilter("ticket_id", "not in", array(328, 514)));
                     $repo = new TRepository('Atividade');
                     $count = $repo->count($cri);
                     $tempo = 0;
                     if ($count) {
                         $horas = $repo->load($cri);
                         foreach ($horas as $h) {
                             $tempo += $this->string->time_to_sec($h->hora_fim) - $this->string->time_to_sec($h->hora_inicio);
                         }
                     }
                     $arrayClientes[$i] = $tempo;
                     $totalClientes += $tempo;
                     $tempo = $this->string->sec_to_time($tempo);
                     $tr->addCell($this->string->retira_segundos($tempo), 'center', $style);
                     $tr->addCell(round($arrayClientes[$i] * 100 / $arrayAtividadeTotal[$i]) . '%', 'center', $style);
                     $tr->addCell('&nbsp;&nbsp;&nbsp;&nbsp;', 'center', 'datai');
                     $i++;
                     $colour = !$colour;
                 }
                 $totalClientes = $this->string->sec_to_time($totalClientes);
                 $tr->addCell($this->string->retira_segundos($totalClientes), 'center', $style);
                 $tr->addCell(round($this->string->time_to_sec($totalClientes) * 100 / $this->string->time_to_sec($totalAtividadeTotal)) . '%', 'center', $style);
             }
             //row total
             $i = 0;
             $tr->addRow();
             $tr->addCell(utf8_decode('<b>Total:</b>'), 'left', 'footer');
             foreach ($meses as $mes) {
                 $total = $this->string->sec_to_time($arrayAtividadeTotal[$i]);
                 $tr->addCell($this->string->retira_segundos($total), 'center', 'footer');
                 $tr->addCell('100%', 'center', 'footer');
                 $tr->addCell('&nbsp;&nbsp;&nbsp;&nbsp;', 'center', 'datai');
                 $i++;
             }
             $tr->addCell($this->string->retira_segundos($totalAtividadeTotal), 'center', 'footer');
             $tr->addCell('100%', 'center', 'footer');
             // stores the file
             if (!file_exists("app/output/Atividade.{$format}") or is_writable("app/output/Atividade.{$format}")) {
                 $tr->save("app/output/Atividade.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/Atividade.{$format}");
             }
             // open the report file
             parent::openFile("app/output/Atividade.{$format}");
             // shows the success message
             new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         } else {
             new TMessage('error', 'No records found');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:101,代码来源:AtividadeClienteReport.class.php

示例4: onGenerate

 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'atividade'
         TTransaction::open('atividade');
         $string = new StringsUtil();
         // get the form data into an active record
         $formdata = $this->form->getData();
         $repository = new TRepository('RegistroLogin');
         $criteria = new TCriteria();
         if ($formdata->login) {
             $criteria->add(new TFilter('login', '=', "{$formdata->login}"));
         }
         if ($formdata->data_ponto) {
             $criteria->add(new TFilter('data_ponto', '>=', "{$string->formatDate($formdata->data_ponto)}"));
         }
         $newparam['order'] = 'data_ponto';
         $newparam['direction'] = 'desc';
         $criteria->setProperties($newparam);
         // order, offset
         $objects = $repository->load($criteria);
         $format = $formdata->output_type;
         if ($objects) {
             $widths = array(20, 200, 50, 80, 80);
             switch ($format) {
                 case 'html':
                     $tr = new TTableWriterHTML($widths);
                     break;
                 case 'pdf':
                     $tr = new TTableWriterPDF($widths);
                     break;
                 case 'rtf':
                     if (!class_exists('PHPRtfLite_Autoloader')) {
                         PHPRtfLite::registerAutoloader();
                     }
                     $tr = new TTableWriterRTF($widths);
                     break;
             }
             // create the document styles
             $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#6B6B6B');
             $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#E5E5E5');
             $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff');
             $tr->addStyle('header', 'Times', '16', 'B', '#4A5590', '#C0D3E9');
             $tr->addStyle('footer', 'Times', '12', 'BI', '#4A5590', '#C0D3E9');
             // add a header row
             $tr->addRow();
             $tr->addCell('Registro de acessos ao sistema', 'center', 'header', 5);
             // add titles row
             $tr->addRow();
             $tr->addCell('Seq.', 'center', 'title');
             $tr->addCell('Nome', 'center', 'title');
             $tr->addCell('Data', 'center', 'title');
             $tr->addCell('Hora inicial', 'center', 'title');
             $tr->addCell('Hora final', 'center', 'title');
             // controls the background filling
             $colour = FALSE;
             $seq = 1;
             // data rows
             foreach ($objects as $object) {
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($seq++, 'right', $style);
                 $tr->addCell($object->name, 'left', $style);
                 $tr->addCell($string->formatDateBR($object->data_ponto), 'center', $style);
                 $tr->addCell($object->hora_inicial, 'center', $style);
                 $tr->addCell($object->hora_final, 'center', $style);
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell(date('d/m/Y h:i:s'), 'center', 'footer', 5);
             // stores the file
             if (!file_exists("app/output/RegistroLogin.{$format}") or is_writable("app/output/RegistroLogin.{$format}")) {
                 $tr->save("app/output/RegistroLogin.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/RegistroLogin.{$format}");
             }
             // open the report file
             parent::openFile("app/output/RegistroLogin.{$format}");
             // shows the success message
             new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).');
         } else {
             new TMessage('error', 'No records found');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:99,代码来源:RegistroLoginReport.class.php

示例5: onGenerate

 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'library'
         TTransaction::open('library');
         // get the form data into an active record Member
         $object = $this->form->getData();
         $repository = new TRepository('Member');
         $criteria = new TCriteria();
         if ($object->name) {
             $criteria->add(new TFilter('name', 'like', "%{$object->name}%"));
         }
         if ($object->city_id) {
             $criteria->add(new TFilter('city_id', '=', "{$object->city_id}"));
         }
         if ($object->category_id) {
             $criteria->add(new TFilter('category_id', '=', "{$object->category_id}"));
         }
         $members = $repository->load($criteria);
         $format = $object->output_type;
         if ($members) {
             $widths = array(40, 150, 80, 140, 80);
             switch ($format) {
                 case 'pdf':
                     $tr = new TTableWriterPDF($widths);
                     break;
                 case 'rtf':
                     if (!class_exists('PHPRtfLite_Autoloader')) {
                         PHPRtfLite::registerAutoloader();
                     }
                     $tr = new TTableWriterRTF($widths);
                     break;
             }
             // create the document styles
             $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#7C81BA');
             $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#DFEAF6');
             $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff');
             $tr->addStyle('header', 'Times', '16', 'BI', '#ff0000', '#FFF1B2');
             $tr->addStyle('footer', 'Times', '12', 'BI', '#2B2B2B', '#B5FFB4');
             // add a header row
             $tr->addRow();
             $tr->addCell(_t('Members'), 'center', 'header', 5);
             // add titles row
             $tr->addRow();
             $tr->addCell(_t('Code'), 'left', 'title');
             $tr->addCell(_t('Name'), 'left', 'title');
             $tr->addCell(_t('Category'), 'left', 'title');
             $tr->addCell(_t('Email'), 'left', 'title');
             $tr->addCell(_t('Phone'), 'left', 'title');
             // controls the background filling
             $colour = FALSE;
             // data rows
             foreach ($members as $member) {
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($member->id, 'left', $style);
                 $tr->addCell($member->name, 'left', $style);
                 $tr->addCell($member->category_description, 'left', $style);
                 $tr->addCell($member->email, 'left', $style);
                 $tr->addCell($member->phone_number, 'left', $style);
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell(date('Y-m-d h:i:s'), 'center', 'footer', 5);
             // stores the file
             $tr->save("app/output/members.{$format}");
             if (OS == 'WIN') {
                 parent::openFile("app\\output\\members.{$format}");
             } else {
                 parent::openFile("app/output/members.{$format}");
             }
             // shows the success message
             new TMessage('info', _t('Report generated'));
         } else {
             new TMessage('error', _t('No records found'));
         }
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jfrank1500,项目名称:curso_php,代码行数:92,代码来源:MemberReport.class.php

示例6: onGenerate


//.........这里部分代码省略.........
                     $x = $this->retornaPonto($pessoa->pessoa_codigo, $dia);
                     if ($this->string->time_to_sec($x) > 0) {
                         $totalAtividades += $this->string->time_to_sec($horas);
                         $arrayAtividades[$dia] += $this->string->time_to_sec($horas);
                     }
                     $tr->addCell(substr($horas, 0, -3), 'center', $style);
                 }
                 $arrayAtividades['total'] += $totalAtividades;
                 $tr->addCell(substr($this->string->sec_to_time($totalAtividades), 0, -3), 'center', $style);
                 $tr->addRow();
                 $tr->addCell('', 'left', $style);
                 $tr->addCell('Produtividade', 'left', $style);
                 foreach ($arrayDias as $dia) {
                     $campo = $this->calculaPercentualProdutividade($pessoa->pessoa_codigo, $dia);
                     $tr->addCell($campo, 'center', $style);
                 }
                 $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($totalAtividades, $totalPonto), 'center', $style);
                 $tr->addRow();
                 $tr->addCell($break, 'left', $style, 33);
                 $count++;
                 $colour = !$colour;
             }
             // totais row
             $tr->addRow();
             $tr->addCell($count, 'left', 'totais');
             $tr->addCell('TOTAIS', 'left', 'totais', 33);
             $tr->addRow();
             $tr->addCell('', 'left', 'totais');
             $tr->addCell('Ponto', 'left', 'totais');
             foreach ($arrayDias as $dia) {
                 $tr->addCell(substr($this->string->sec_to_time($arrayPonto[$dia]), 0, -3), 'center', 'totais');
             }
             $tr->addCell(substr($this->string->sec_to_time($arrayPonto['total']), 0, -3), 'center', 'totais');
             $tr->addRow();
             $tr->addCell('', 'left', 'totais');
             $tr->addCell('Atividades', 'left', 'totais');
             foreach ($arrayDias as $dia) {
                 $tr->addCell(substr($this->string->sec_to_time($arrayAtividades[$dia]), 0, -3), 'center', 'totais');
             }
             $tr->addCell(substr($this->string->sec_to_time($arrayAtividades['total']), 0, -3), 'center', 'totais');
             $tr->addRow();
             $tr->addCell('', 'left', 'totais');
             $tr->addCell('Produtividade', 'left', 'totais');
             foreach ($arrayDias as $dia) {
                 $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($arrayAtividades[$dia], $arrayPonto[$dia]), 'center', 'totais');
             }
             $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($arrayAtividades['total'], $arrayPonto['total']), 'center', 'totais');
             // footer row
             $tr->addRow();
             $var = rand(0, 1000);
             $tr->addCell(date('d/m/Y H:i:s'), 'center', 'footer', 33);
             foreach ($arrayAtividades as $key => $value) {
                 if ($key != 'total') {
                     $yAtividades[substr($key, -2)] = $this->string->sec_to_time($value);
                     $xLabel[substr($key, -2)] = substr($key, -2);
                 }
             }
             foreach ($arrayPonto as $key => $value) {
                 if ($key != 'total') {
                     $yPonto[substr($key, -2)] = $this->string->sec_to_time($value);
                 }
             }
             ksort($yAtividades);
             ksort($yPonto);
             ksort($xLabel);
             $chart = new TLineChart(new TPChartDesigner());
             $chart->setTitle('Totais', NULL, NULL);
             $chart->setSize(1100, 600);
             $chart->setXLabels($xLabel);
             $chart->setYLabel('Horas');
             $chart->setOutputPath('app/output/linechart_{$var}.png');
             $chart->addData('Atividades', $yAtividades);
             $chart->addData('Ponto', $yPonto);
             $chart->generate();
             $tr->addRow();
             $tr->addCell(new TImage('app/output/linechart_{$var}.png'), 'center', 'datai', 33);
             // stores the file
             if (!file_exists("app/output/Ponto_{$var}.{$format}") or is_writable("app/output/Ponto_{$var}.{$format}")) {
                 $tr->save("app/output/Ponto_{$var}.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/Ponto_{$var}.{$format}");
             }
             // open the report file
             parent::openFile("app/output/Ponto_{$var}.{$format}");
             // shows the success message
             new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).');
         } else {
             new TMessage('error', 'No records found');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:101,代码来源:PontoReport.class.php

示例7: onGenerate

    public function onGenerate()
    {
        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;
            if (!class_exists('PHPRtfLite_Autoloader')) {
                PHPRtfLite::registerAutoloader();
            }
            $tr = new TTableWriterRTF(array(500));
            $tr->addStyle('title', 'Arial', '10', 'BI', '#000000', '#ffffff');
            $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#ffffff');
            $string = new StringsUtil();
            $data = $desenvolvimento->data_cadastro;
            $data = explode('-', $data);
            $desenvolvimento->ticket->data_prevista ? $data_prevista = $string->formatDateBR($desenvolvimento->ticket->data_prevista) : '___/___/___';
            $cabecalho = 'DTR010 - Solicitação de Desenvolvimento
Número: ' . $desenvolvimento->id . '/' . $data[0] . ' Data: ' . $string->formatDateBR($desenvolvimento->data_cadastro) . ' Prazo de entrega: ' . $data_prevista . ' Qtde de Horas: ' . strstr($desenvolvimento->ticket->orcamento_horas, ':', true) . ' Ticket: ' . $desenvolvimento->ticket_id . '
Benefício: ( )+Receita ( )-Despesa ( )+Eficiência ( )-NDA
Título: ' . $desenvolvimento->titulo . '
Sistema: ' . $desenvolvimento->ticket->sistema->nome . '      Módulo:                                   Rotina: ' . $desenvolvimento->rotina . '
Cliente: ' . $cliente . ' Solicitante/Dpto: ' . $responsavel;
            $tr->addRow();
            $tr->addCell($cabecalho, 'left', 'title');
            $tr->addRow();
            $tr->addCell('<br /><b>Objetivo:</b> <br />' . $desenvolvimento->objetivo, 'left', 'datap');
            $tr->addRow();
            $tr->addCell('<br /><b>Entrada: </b><br />' . $desenvolvimento->entrada, 'left', 'datap');
            $tr->addRow();
            $tr->addCell('<br /><b>Processamento: </b><br />' . $desenvolvimento->processamento, 'left', 'datap');
            $tr->addRow();
            $tr->addCell('<br /><b>Saida: </b><br />' . $desenvolvimento->saida, 'left', 'datap');
            $nome = 'DTR010 ' . $desenvolvimento->id . ' - ' . $data[0] . ' - ' . $desenvolvimento->titulo;
            $tr->save("app/output/{$nome}.rtf");
            parent::openFile("app/output/{$nome}.rtf");
            new TMessage('info', 'DTR gerado com sucesso!');
            TTransaction::close();
        } catch (Exception $e) {
            new TMessage('error', $e->getMessage);
        }
    }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:47,代码来源:GeradorDescricao.class.php

示例8: onGenerate


//.........这里部分代码省略.........
                     }
                 }
                 $tr->addRow();
                 $tr->addCell($seq++, 'center', $style);
                 $tr->addCell($object['id'], 'center', $style);
                 $tr->addCell(substr($object['status'], 0, 1), 'center', $style);
                 $tr->addCell(substr($object['prioridade'], 0, 1), 'center', $style);
                 $tr->addCell(substr($object['orcamento_horas'], 0, -3), 'center', $style);
                 $tr->addCell(substr($object['horas_atividade'], 0, -3), 'center', $style);
                 $tr->addCell(substr($object['horas_saldo'], 0, -3), 'center', $horasStyle);
                 $tr->addCell($object['data_prevista'] ? $data_prevista = $string->formatDateBR($object['data_prevista']) : null, 'center', $style);
                 $tr->addCell($dias, 'center', $dataStyle);
                 $tr->addCell(utf8_decode($object['titulo']), 'left', $style);
                 $tr->addCell(utf8_decode($pessoa[$object['responsavel_id']]), 'left', $style);
                 $tr->addCell($object['origem'], 'center', $style);
                 $tr->addCell(utf8_decode($cliente->origem_nome), 'left', $style);
                 $tr->addCell($object['valor_total'], 'right', $style);
                 $tr->addCell($object['valor_total_pago'], 'right', $style);
                 $tr->addCell($object['saldo'], 'right', $style);
                 $totalDias += $dias;
                 $totalOrcado += $object['valor_total'];
                 $totalPago += $object['valor_total_pago'];
                 $totalSaldo += $object['saldo'];
                 $totalHorasOrcadas += $string->time_to_sec($object['orcamento_horas']);
                 $totalHorasAtividades += $string->time_to_sec($object['horas_atividade']);
                 $totalHorasSaldo += $string->time_to_sec($object['horas_saldo']);
                 if ($formdata->tipo == 'a') {
                     $atividades = Ticket::relatorioAnalitico($object['id'], $where);
                     if ($atividades) {
                         $seqA = 1;
                         foreach ($atividades as $atividade) {
                             $stylea = $colour ? 'datapa' : 'dataia';
                             $tr->addRow();
                             $tr->addCell('', 'center', $stylea);
                             $tr->addCell($seqA++, 'center', $stylea);
                             $tr->addCell($string->formatDateBR($atividade['data_atividade']), 'center', $stylea, 3);
                             //$tr->addCell(substr($object['prioridade'], 0, 1), 'center', $style);
                             //$tr->addCell($object['orcamento_horas'], 'center', $style);
                             $tr->addCell(substr($atividade['tempo'], 0, -3), 'center', $stylea);
                             $tr->addCell('', 'center', $stylea);
                             $tr->addCell($object['data_prevista'] ? $data_prevista = $string->formatDateBR($object['data_prevista']) : null, 'center', $stylea);
                             $tr->addCell('', 'center', $stylea);
                             $tr->addCell('das ' . substr($atividade['hora_inicio'], 0, -3) . ' as ' . substr($atividade['hora_fim'], 0, -3), 'left', $stylea);
                             $tr->addCell(utf8_decode($pessoa[$atividade['colaborador_id']]), 'left', $stylea);
                             $tr->addCell('', 'center', $stylea);
                             $tr->addCell(utf8_decode($atividade['tipo_atividade']), 'left', $stylea);
                             $tr->addCell('', 'right', $stylea);
                             $tr->addCell('', 'right', $stylea);
                             $tr->addCell('', 'right', $stylea);
                         }
                     }
                 }
                 $tr->addRow();
                 $tr->addCell('&nbsp; ', 'center', $style, 16);
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell('Totais:', 'center', 'footer', 4);
             //$tr->addCell('', 'center', 'footer');
             //$tr->addCell('', 'center', 'footer');
             //$tr->addCell('', 'center', 'footer');
             $tr->addCell(substr($string->sec_to_time($totalHorasOrcadas), 0, -3), 'center', 'footer');
             $tr->addCell(substr($string->sec_to_time($totalHorasAtividades), 0, -3), 'center', 'footer');
             $tr->addCell(substr($string->sec_to_time($totalHorasSaldo), 0, -3), 'center', 'footer');
             $tr->addCell('', 'center', 'footer');
             $tr->addCell('', 'center', 'footer');
             $tr->addCell('', 'left', 'footer');
             $tr->addCell('', 'left', 'footer');
             $tr->addCell('', 'center', 'footer');
             $tr->addCell('', 'left', 'footer');
             $tr->addCell($totalOrcado, 'right', 'footer');
             $tr->addCell($totalPago, 'right', 'footer');
             $tr->addCell($totalSaldo, 'right', 'footer');
             $tr->addRow();
             $tr->addCell(date('d/m/Y H:i:s'), 'center', 'footer', 16);
             // stores the file
             if (!file_exists("app/output/Ticket.{$format}") or is_writable("app/output/Ticket.{$format}")) {
                 $tr->save("app/output/Ticket.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/Ticket.{$format}");
             }
             // open the report file
             parent::openFile("app/output/Ticket.{$format}");
             // shows the success message
             new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).');
         } else {
             new TMessage('error', 'Não foram encontrados registros!');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:101,代码来源:TicketReport.class.php

示例9: onGenerate

 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'library'
         TTransaction::open('library');
         // get the form data into an active record Loan
         $object = $this->form->getData();
         $repository = new TRepository('Loan');
         $criteria = new TCriteria();
         if ($object->member_id) {
             $criteria->add(new TFilter('member_id', '=', "{$object->member_id}"));
         }
         if ($object->barcode_input) {
             $criteria->add(new TFilter('barcode', '=', "{$object->barcode_input}"));
         }
         if ($object->loan_date1) {
             $criteria->add(new TFilter('loan_date', '>=', "{$object->loan_date1}"));
         }
         if ($object->loan_date2) {
             $criteria->add(new TFilter('loan_date', '<=', "{$object->loan_date2}"));
         }
         $loans = $repository->load($criteria);
         $format = $object->output_type;
         if ($loans) {
             $widths = array(70, 190, 100, 70, 70);
             switch ($format) {
                 case 'pdf':
                     $tr = new TTableWriterPDF($widths);
                     break;
                 case 'rtf':
                     if (!class_exists('PHPRtfLite_Autoloader')) {
                         PHPRtfLite::registerAutoloader();
                     }
                     $tr = new TTableWriterRTF($widths);
                     break;
             }
             // create the document styles
             $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#7C81BA');
             $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#DFEAF6');
             $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff');
             $tr->addStyle('header', 'Times', '16', 'BI', '#ff0000', '#FFF1B2');
             $tr->addStyle('footer', 'Times', '12', 'BI', '#2B2B2B', '#B5FFB4');
             // add a header row
             $tr->addRow();
             $tr->addCell(_t('Loans'), 'center', 'header', 5);
             // add titles row
             $tr->addRow();
             $tr->addCell(_t('Barcode'), 'left', 'title');
             $tr->addCell(_t('Title'), 'left', 'title');
             $tr->addCell(_t('Name'), 'left', 'title');
             $tr->addCell(_t('Loan date'), 'left', 'title');
             $tr->addCell(_t('Arrive date'), 'left', 'title');
             // controls the background filling
             $colour = FALSE;
             // data rows
             foreach ($loans as $loan) {
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($loan->barcode, 'left', $style);
                 $tr->addCell($loan->book_title, 'left', $style);
                 $tr->addCell($loan->member_name, 'left', $style);
                 $tr->addCell($loan->loan_date, 'left', $style);
                 $tr->addCell($loan->arrive_date, 'left', $style);
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell(date('Y-m-d h:i:s'), 'center', 'footer', 5);
             // stores the file
             $tr->save("app/output/loans.{$format}");
             if (OS == 'WIN') {
                 parent::openFile("app\\output\\loans.{$format}");
             } else {
                 parent::openFile("app/output/loans.{$format}");
             }
             // shows the success message
             new TMessage('info', _t('Report generated'));
         } else {
             new TMessage('error', _t('No records found'));
         }
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:crmbf,代码行数:95,代码来源:LoanReport.class.php

示例10: onPDF

 /**
  * method onPDF()
  * executed whenever the user clicks at the pdf button
  */
 function onPDF($param)
 {
     try {
         TTransaction::open('permission');
         // open transaction
         $conn = TTransaction::get();
         // get PDO connection
         // run query
         $result = $conn->query('SELECT id, name from system_user order by id');
         // get the form data into an active record Customer
         $widths = array(60, 125, 125, 150, 70);
         $tr = new TTableWriterPDF($widths);
         // create the document styles
         $tr->addStyle('title', 'Arial', '12', 'B', '#000000', '#CDCDCD');
         $tr->addStyle('par', 'Arial', '10', '', '#000000', '#CFCFCF');
         $tr->addStyle('impar', 'Arial', '10', '', '#000000', '#FFFFFF');
         $tr->addStyle('header', 'Times', '16', 'B', '#000000', '#CDCDCD');
         $tr->addStyle('footer', 'Times', '12', 'B', '#000000', '#CDCDCD');
         // add a header row
         $tr->addRow();
         $tr->addCell('Employees', 'center', 'header', 5);
         // add titles row
         $tr->addRow();
         $tr->addCell('DNI', 'center', 'title');
         $tr->addCell('Name', 'center', 'title');
         $tr->addCell('Address', 'center', 'title');
         $tr->addCell('Email', 'center', 'title');
         $tr->addCell('Phone', 'center', 'title');
         // controls the background filling
         $colour = FALSE;
         foreach ($result as $row) {
             $style = $colour ? 'par' : 'impar';
             $tr->addRow();
             $tr->addCell('53321548G', 'left', $style);
             $tr->addCell('Jordi Aguilà Cortés', 'left', $style);
             $tr->addCell('Pere Massallach 21 1 2', 'left', $style);
             $tr->addCell('jac274@gmail.com', 'left', $style);
             $tr->addCell('617186879', 'left', $style);
             $colour = !$colour;
         }
         // footer row
         $tr->addRow();
         $tr->addCell(date('l jS \\of F Y h:i:s A'), 'center', 'footer', 5);
         $tr->Footer('This document contains information about employees of the company.');
         if (!file_exists("app/output/employees_" . date("Ymd") . ".pdf") or is_writable("app/output/employees_" . date("Ymd") . ".pdf")) {
             $tr->save("app/output/employees_" . date("Ymd") . ".pdf");
         } else {
             throw new Exception(_t('Permission denied') . ': ' . "app/output/employees_" . date("Ymd") . ".pdf");
         }
         parent::openFile("app/output/employees_" . date("Ymd") . ".pdf");
         // shows the success message
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         TTransaction::close();
         // close transaction
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
     }
 }
开发者ID:kiibe,项目名称:linkERP,代码行数:63,代码来源:SystemEmployeesList.class.php

示例11: onGenerate

 /**
  * 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());
     }
 }
开发者ID:jfrank1500,项目名称:curso_php,代码行数:82,代码来源:PDFDesignNFEView.class.php

示例12: onPDF

 /**
  * method onPDF()
  * executed whenever the user clicks at the pdf button
  */
 function onPDF($param)
 {
     $pdf = new pdf_invoice();
     if (!file_exists("app/output/charge_" . date("Ymd") . ".pdf") or is_writable("app/output/charge_" . date("Ymd") . ".pdf")) {
         $pdf->Output('app/output/charge_' . date('Ymd') . '.pdf');
     } else {
         throw new Exception(_t('Permission denied') . ': ' . "app/output/charge_" . date("Ymd") . ".pdf");
     }
     parent::openFile("app/output/charge_" . date("Ymd") . ".pdf");
     // shows the success message
     new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
 }
开发者ID:kiibe,项目名称:linkERP,代码行数:16,代码来源:SystemChargeList.class.php

示例13: onPDF

 /**
  * method onPDF()
  * executed whenever the user clicks at the pdf button
  */
 function onPDF($param)
 {
     try {
         TTransaction::open('permission');
         // open transaction
         $conn = TTransaction::get();
         // get PDO connection
         // run query
         $result = $conn->query('SELECT nif, name from system_providers order by id');
         // get the form data into an active record Customer -> tocar las columnas
         $widths = array(270, 270);
         $tr = new TTableWriterPDF($widths);
         // create the document styles
         $tr->addStyle('title', 'Arial', '12', 'B', '#000000', '#A0B2BC');
         $tr->addStyle('par', 'Arial', '10', '', '#000000', '#ECE9E9');
         $tr->addStyle('impar', 'Arial', '10', '', '#000000', '#FFFFFF');
         $tr->addStyle('header', 'Times', '16', 'B', '#FFFFFF', '#4C5976');
         $tr->addStyle('footer', 'Times', '12', 'B', '#000000', '#88BACF');
         // add a header row
         $tr->addRow();
         $tr->addCell('Providers', 'center', 'header', 2);
         // add titles row
         $tr->addRow();
         $tr->addCell('NIF', 'center', 'title');
         $tr->addCell('Name', 'center', 'title');
         // controls the background filling
         $colour = FALSE;
         foreach ($result as $row) {
             $style = $colour ? 'par' : 'impar';
             $tr->addRow();
             $tr->addCell($row['nif'], 'left', $style);
             $tr->addCell($row['name'], 'left', $style);
             $colour = !$colour;
         }
         // footer row
         $tr->addRow();
         $tr->addCell(date('l jS \\of F Y h:i:s A'), 'center', 'footer', 2);
         $tr->Footer('This document contains information about clients of the company.');
         if (!file_exists("app/output/providersList_" . date("Ymd") . "pdf") or is_writable("app/output/providersList_" . date("Ymd") . ".pdf")) {
             $tr->save("app/output/providersList_" . date("Ymd") . ".pdf");
         } else {
             throw new Exception(_t('Permission denied') . ': ' . "app/output/providersList_" . date("Ymd") . ".pdf");
         }
         parent::openFile("app/output/providersList_" . date("Ymd") . ".pdf");
         // shows the success message
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         TTransaction::close();
         // close transaction
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
     }
 }
开发者ID:kiibe,项目名称:linkERP,代码行数:57,代码来源:SystemProvidersList.class.php

示例14: onGenerate


//.........这里部分代码省略.........
             $tr->addCell('Por Sistema', 'center', 'header');
             $tr->addCell('Horas', 'center', 'header');
             $tr->addCell('%', 'center', 'header');
             // controls the background filling
             $colour = FALSE;
             $seq = 1;
             // data rows
             foreach ($objects as $row) {
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($seq, 'center', $style);
                 $tr->addCell(utf8_decode($row['nome']), 'left', $style);
                 $tr->addCell($this->string->retira_segundos($row['total']), 'right', $style);
                 $tr->addCell(round($this->string->time_to_sec($row['total']) / $this->string->time_to_sec($total) * 100) . '%', 'right', $style);
                 $seq++;
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell('', 'right', 'footer');
             $tr->addCell('Total:', 'left', 'footer');
             $tr->addCell($this->string->retira_segundos($total), 'right', 'footer');
             $tr->addCell('100%', 'right', 'footer');
             // division row
             $tr->addRow();
             $tr->addCell($break, 'center', 'datai', 4);
             $objects = Atividade::retornaAtividadesClienteColaborador($formdata->colaborador_id, $formdata->mes_atividade, $formdata->ano_atividade, $tickets);
             foreach ($objects as $row) {
                 $cliente = new Pessoa($row['solicitante_id']);
                 if ($cliente->origem == 1) {
                     $ind = $cliente->codigo_cadastro_origem;
                 } else {
                     $ind = 999;
                 }
                 $array[$ind] += $this->string->time_to_sec($row['total']);
             }
             ksort($array);
             // add a header row
             $tr->addRow();
             $tr->addCell('', 'center', 'header');
             $tr->addCell('Por Cliente', 'center', 'header');
             $tr->addCell('Horas', 'center', 'header');
             $tr->addCell('%', 'center', 'header');
             // controls the background filling
             $colour = FALSE;
             $seq = 1;
             // data rows
             foreach ($array as $key => $value) {
                 if ($key < 999) {
                     $etd = new Entidade($key);
                     $nome = $key . ' - ' . $etd->entnomfan;
                 } else {
                     $nome = $key . ' - ECS';
                 }
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($seq, 'center', $style);
                 $tr->addCell(utf8_decode($nome), 'left', $style);
                 $tr->addCell($this->string->retira_segundos($this->string->sec_to_time($value)), 'right', $style);
                 $tr->addCell(round($value / $this->string->time_to_sec($total) * 100) . '%', 'right', $style);
                 $seq++;
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell('', 'right', 'footer');
             $tr->addCell('Total:', 'left', 'footer');
             $tr->addCell($this->string->retira_segundos($total), 'right', 'footer');
             $tr->addCell('100%', 'right', 'footer');
             // division row
             $tr->addRow();
             $tr->addCell($break, 'center', 'datai', 4);
             // footer row
             $tr->addRow();
             $tr->addCell(date('d/m/Y H:i:s'), 'center', 'footer', 4);
             // stores the file
             $var = rand(0, 1000);
             if (!file_exists("app/output/Atividade{$var}_{$formdata->mes_atividade}_{$formdata->colaborador_id}.{$format}") or is_writable("app/output/Atividade.{$format}")) {
                 $tr->save("app/output/Atividade{$var}_{$formdata->mes_atividade}_{$formdata->colaborador_id}.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/Atividade_{$formdata->mes_atividade}_{$formdata->colaborador_id}.{$format}");
             }
             // open the report file
             parent::openFile("app/output/Atividade{$var}_{$formdata->mes_atividade}_{$formdata->colaborador_id}.{$format}");
             // shows the success message
             new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).');
         } else {
             new TMessage('error', 'Sem atividade no periodo cadastrado!');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jhonleandres,项目名称:Atividades,代码行数:101,代码来源:AtividadeReport.class.php

示例15: onGenerate

 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // get the form data into an active record Customer
         $object = $this->form->getData();
         $repository = new TRepository('Customer');
         $criteria = new TCriteria();
         if ($object->name) {
             $criteria->add(new TFilter('name', 'like', "%{$object->name}%"));
         }
         if ($object->city_id) {
             $criteria->add(new TFilter('city_id', '=', "{$object->city_id}"));
         }
         if ($object->category_id) {
             $criteria->add(new TFilter('category_id', '=', "{$object->category_id}"));
         }
         $customers = $repository->load($criteria);
         $format = $object->output_type;
         if ($customers) {
             $widths = array(40, 150, 80, 120, 80);
             switch ($format) {
                 case 'html':
                     $tr = new TTableWriterHTML($widths);
                     break;
                 case 'pdf':
                     $tr = new TTableWriterPDF($widths);
                     break;
                 case 'rtf':
                     if (!class_exists('PHPRtfLite_Autoloader')) {
                         PHPRtfLite::registerAutoloader();
                     }
                     $tr = new TTableWriterRTF($widths);
                     break;
             }
             // create the document styles
             $tr->addStyle('title', 'Arial', '10', 'BI', '#ffffff', '#407B49');
             $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#869FBB');
             $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff');
             $tr->addStyle('header', 'Times', '16', 'BI', '#ff0000', '#FFF1B2');
             $tr->addStyle('footer', 'Times', '12', 'BI', '#2B2B2B', '#B5FFB4');
             // add a header row
             $tr->addRow();
             $tr->addCell('Customers', 'center', 'header', 5);
             // add titles row
             $tr->addRow();
             $tr->addCell('Code', 'left', 'title');
             $tr->addCell('Name', 'left', 'title');
             $tr->addCell('Category', 'left', 'title');
             $tr->addCell('Email', 'left', 'title');
             $tr->addCell('Birthdate', 'left', 'title');
             // controls the background filling
             $colour = FALSE;
             // data rows
             foreach ($customers as $customer) {
                 $style = $colour ? 'datap' : 'datai';
                 $tr->addRow();
                 $tr->addCell($customer->id, 'left', $style);
                 $tr->addCell($customer->name, 'left', $style);
                 $tr->addCell($customer->category_name, 'left', $style);
                 $tr->addCell($customer->email, 'left', $style);
                 $tr->addCell($customer->birthdate, 'left', $style);
                 $colour = !$colour;
             }
             // footer row
             $tr->addRow();
             $tr->addCell(date('Y-m-d h:i:s'), 'center', 'footer', 5);
             // stores the file
             if (!file_exists("app/output/tabular.{$format}") or is_writable("app/output/tabular.{$format}")) {
                 $tr->save("app/output/tabular.{$format}");
             } else {
                 throw new Exception(_t('Permission denied') . ': ' . "app/output/tabular.{$format}");
             }
             parent::openFile("app/output/tabular.{$format}");
             // shows the success message
             new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         } else {
             new TMessage('error', 'No records found');
         }
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
开发者ID:jfrank1500,项目名称:curso_php,代码行数:95,代码来源:TabularReportView.class.php


注:本文中的TPage::openFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。