public function configReportSample($type = 'pdf', $options = false) { set_time_limit(3200); $moduleName = $this->getRequest()->getModuleName(); $controllerName = $this->getRequest()->getControllerName(); /** * Configuração do estilos padrão */ $dnsEmpresas = array(); $dnsEmpresas['tanet.com.br'] = 'TA'; $dnsEmpresas['talog.com.br'] = 'TAL'; $dnsEmpresas['taexpress.com.br'] = 'TAE'; $dnsEmpresas['windexpress.com.br'] = 'TAE'; $dnsEmpresas['tawind.com.br'] = 'TAE'; $domain = ZendT_Url::getDomain(); $empresa = 'TA'; if (isset($dnsEmpresas[$domain])) { $empresa = $dnsEmpresas[$domain]; } $default = array('title' => array('fontSize' => 10, 'bold' => true, 'width' => 160, 'align' => 'center', 'value' => utf8_decode($this->_translate->_($moduleName . '.' . $controllerName . '.grid'))), 'default' => array('fontSize' => 8, 'bold' => false, 'fontName' => 'Arial'), 'cellsTitle' => array('fontSize' => 8, 'bold' => true, 'align' => 'center'), 'empresa' => $empresa, 'maxPerLine' => 4, 'orientation' => 'P'); if (is_array($options)) { $options = ZendT_Functions::array_merge_recursive_distinct($default, $options); } else { $options = $default; } $title = $this->_translate->_($moduleName . '.' . $controllerName . '.grid'); if (is_array($options['title'])) { $options['title'] = new ZendT_Report_Cell($options['title']); $options['title']->setStyleName('title'); } if (is_array($options['footer'])) { $options['footer'] = new ZendT_Report_Cell($options['footer']); $options['footer']->setStyleName('footer'); } /** * Tratamento para buscar os dados no banco de dados */ $postData = $this->getRequest()->getParams(); $postData['page'] = false; $postData['count'] = false; $whereGroup = $this->getWherePostData(); $mapperView = get_class($this->_mapper); $logReport = new ZendT_Log_Report($mapperView, $title); if ($this->_mapper instanceof ZendT_Db_View) { $dataGrid = $this->getMapper()->getDataGrid($whereGroup, $postData); } else { $dataGrid = $this->getModel()->getDataGrid($whereGroup, $postData); } $logReport->finishDb(); /** * Instancia do objeto de relat�rio */ $report = ZendT_Report::factory($type, $options); $report->addPage(); /** * Configuração da coluna de título */ $celulas = array(); foreach ($this->getColumns() as $column) { if (!$column->getHidden()) { $key = $column->getName(); $celulas[$key] = new ZendT_Report_Cell($options['cellsTitle']); $celulas[$key]->setTextAlign($column->getAlign())->setWidth($column->getWidth())->setValue($column->getHeaderTitle()); $celulas[$key]->setStyleName('cellsTitle-' . $key); $report->addCell($celulas[$key]); } } $report->printCells(); /** * Impressão dos registros detalhe */ $callStylesRow = method_exists($this->getMapper(), 'getStylesRow'); $celulas = array(); $numRows = 0; while ($row = $dataGrid->getRow()) { $stylesRow = array(); if ($callStylesRow) { $stylesRow = $this->getMapper()->getStylesRow($row); } foreach ($this->getColumns() as $column) { if (!$column->getHidden()) { $key = $column->getName(); $cellOptions = $column->getOptions(); if ($dataGrid->getType()) { $value = $row[strtolower($key)]; $type = $value->getType(); if (isset($cellOptions['expandTree'])) { $newValue = $value->get(); $newValue = str_repeat(' ', $row['tree_level']->toPhp() * 4) . $newValue; $value->set($newValue); } } elseif ($dataGrid->isRowFormated()) { $value = $row[strtolower($key)]; $type = $column->getSorttype(); } else { $value = $column->format($row[strtolower($key)]); $type = $column->getSorttype(); } $celName = $key; if (isset($stylesRow[$key])) { if (!$stylesRow[$key]['suffix']) { $stylesRow[$key]['suffix'] = 'plus'; } $celName .= '-' . $stylesRow[$key]['suffix']; } if (!isset($celulas[$celName])) { $celulas[$celName] = new ZendT_Report_Cell($options['default']); $celulas[$celName]->setTextAlign($column->getAlign())->setWidth($column->getWidth())->setType($type); $celulas[$celName]->setStyleName('default-' . $celName); if (isset($stylesRow[$key])) { $celulas[$celName]->setStyles($stylesRow[$key]); } } $celulas[$celName]->setValue($value); $report->addCell($celulas[$celName]); } } $report->printCells(); $numRows++; } /** * Impressão/Saída do relatório */ $result = array('name' => str_replace(' ', '-', $title), 'content' => $report->output(ZendT_Lib::getTableDesc(), 'S')); $logReport->finish($numRows); return $result; }