Beispiel #1
0
 public function __construct($driver, $mapperView, $options)
 {
     $this->_options = $options;
     $params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
     if (!isset($this->_options['printLabelFilters'])) {
         $this->_options['printLabelFilters'] = true;
     }
     if (!isset($this->_options['log'])) {
         $this->_options['log'] = true;
     }
     $this->_options['log'] = false;
     $advanced = $options['advanced'];
     $this->_options['refresh'] = $advanced['refresh'];
     if ($driver == '' && $advanced['output']) {
         $driver = $advanced['output'];
     }
     if ($params['typeShow']) {
         $driver = $params['typeShow'];
     }
     $optionsReport = array();
     $optionsReport['printTitle'] = '1';
     $optionsReport['orientation'] = 'P';
     if ($advanced['orientation']) {
         $optionsReport['orientation'] = $advanced['orientation'];
     }
     if ($advanced['zebra']) {
         $optionsReport['zebra'] = $advanced['zebra'];
     }
     if (isset($advanced['printTitle'])) {
         $optionsReport['printTitle'] = $advanced['printTitle'];
     }
     if ($advanced['printParams']) {
         $optionsReport['printParams'] = $advanced['printParams'];
     }
     if ($advanced['empresa']) {
         $optionsReport['empresa'] = $advanced['empresa'];
     } else {
         /**
          * 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();
         if (isset($dnsEmpresas[$domain])) {
             $optionsReport['empresa'] = $dnsEmpresas[$domain];
         }
     }
     $this->_mapper = $mapperView;
     $configColumns = $this->_mapper->getColumns()->toArray();
     $this->_configColumns = $configColumns;
     $this->_mapper->parseExprProfile($options);
     $this->_columns = array();
     $this->_columnsGroup = array();
     $this->_columnsBreak = array();
     $this->_columnsBreakCount = array();
     // Validar
     $this->_styleRow = false;
     if (method_exists($mapperView, 'getStylesRow')) {
         $this->_styleRow = true;
     }
     $iCols = 'cols-lines';
     if (isset($options['cols-axis'])) {
         $iCols = 'cols-axis';
     }
     if ($options[$iCols]['fields']) {
         foreach ($options[$iCols]['fields'] as $columnName => $column) {
             $this->_columnsGroup[] = $columnName;
             if ($column['break']) {
                 $this->_columnsBreak[$columnName] = array();
                 $this->_columnsBreakCount[$columnName] = array();
             }
             $configColumn = $configColumns[$columnName];
             foreach ($column as $key => $value) {
                 if ($value) {
                     $configColumn[$key] = $value;
                 }
             }
             $this->_columns[$columnName] = $configColumn;
         }
     }
     $this->_columnsPivot = array();
     if ($options['cols-cols']['fields']) {
         foreach ($options['cols-cols']['fields'] as $field => $dataField) {
             $this->_columnsPivot[$field] = $dataField;
         }
     }
     $this->_columnsTotal = array();
     // Validar
     $iCols = 'cols-values';
     if (isset($options['cols-measures'])) {
         $iCols = 'cols-measures';
     }
     if ($options[$iCols]['fields']) {
         foreach ($options[$iCols]['fields'] as $columnName => &$column) {
             if ($column['tipo'] == '') {
                 $column['tipo'] = 'count';
             }
             /**
              * Se a coluna não for a representação de uma expressão
              */
             $this->_columnsTotal[$columnName] = array('column' => $columnName, 'func' => $column['tipo'], 'type' => 'line');
             $configColumn = $configColumns[$columnName];
             foreach ($column as $key => $value) {
                 $configColumn[$key] = $value;
             }
             $this->_columns[$columnName . '_' . $column['tipo']] = $configColumn;
         }
     }
     if ($driver == '') {
         $driver = 'PDF';
     }
     $this->_options['driver'] = $driver;
     $this->_report = ZendT_Report::factory($driver, $optionsReport);
     if ($optionsReport['printTitle'] == '1') {
         $this->_report->setTitle($options['title']);
     }
     $this->_report->addPage();
     $this->_fontSize = $options['fontSize'];
     if (!$this->_fontSize) {
         $this->_fontSize = 7;
     }
     if ($this->_options['log']) {
         $this->_log = new ZendT_Log_Report(get_class($this->_mapper), $options['title']);
     }
 }
Beispiel #2
0
 /**
  * Construtor da Classe
  * 
  * @param string $driver
  * @param Zend_Db_Mapper $mapperView
  * @param string $title 
  */
 public function __construct($driver, $mapperView, $options)
 {
     $this->_options = $options;
     if (!isset($this->_options['log'])) {
         $this->_options['log'] = true;
     }
     if ($driver == '') {
         $driver = 'PDF';
     }
     $this->_report = ZendT_Report::factory($driver, $options);
     $this->_report->setTitle($options['title']['value']);
     $this->_report->addPage();
     $this->_mapper = $mapperView;
     $this->_columns = $this->_mapper->getColumns()->toArray();
     $this->_fontSize = $options['fontSize'];
     if (!$this->_fontSize) {
         $this->_fontSize = 7;
     }
     if ($this->_options['log']) {
         $this->_log = new ZendT_Log_Report(get_class($this->_mapper), $options['title']['value']);
     }
     $this->_total = array();
     $this->_type = array();
     $this->_styleRow = false;
     if (method_exists($mapperView, 'getStylesRow')) {
         $this->_styleRow = true;
     }
     $this->_driver = $driver;
 }
Beispiel #3
0
 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;
 }