Esempio n. 1
0
 /**
  * Busca os dados da consulta
  */
 protected function _make()
 {
     $rs = $this->_getRecordset();
     $this->_printParams();
     $this->_verifyLineJump($this->_columns);
     $this->_addRow($this->_columns, true);
     if ($this->_options['driver'] == 'PDF') {
         #$this->_report->drawLine();
     }
     $row = $rs->getRow();
     if ($this->_options['log']) {
         $this->_log->finishDb();
     }
     $numRows = 0;
     if ($row) {
         if (count($this->_columnsBreak) > 0) {
             $current = '';
             $orderBreak = array();
             foreach ($this->_columnsBreak as $columnName => &$columnBreak) {
                 $orderBreak[] = $columnName;
                 $current .= $row[$columnName]->get();
                 $columnBreak['prev'] = $current;
             }
             $orderBreakReverse = array_reverse($orderBreak);
         }
         do {
             $numRows++;
             if (count($this->_columnsBreak) > 0) {
                 $current = '';
                 foreach ($this->_columnsBreak as $columnName => &$columnBreak) {
                     $current .= $row[$columnName]->get();
                     $columnBreak['current'] = $current;
                 }
                 foreach ($orderBreakReverse as $columnName) {
                     if ($this->_columnsBreak[$columnName]['current'] != $this->_columnsBreak[$columnName]['prev']) {
                         if ($this->_options['advanced']['order_column'] == '' && $this->_columnsBreak[$columnName]['subtotal']) {
                             $rowBreak = array();
                             $this->_labelBreak = 'Subtotal';
                             $rowBreak[$columnName] = $this->_labelBreak;
                             foreach ($this->_columnsBreak[$columnName]['subtotal'] as $column => $total) {
                                 $rowBreak[$column] = $total->getTotal($this->_mapper->getModel()->getAdapter());
                                 $this->_columnsBreak[$columnName]['subtotal'] = null;
                             }
                             $this->_addRow($rowBreak, false, true, array(), false);
                             /**
                              * Pula uma linha
                              */
                             foreach ($rowBreak as &$value) {
                                 $value = '';
                             }
                             $this->_addRow($rowBreak, false, true, array(), true);
                             #$this->_report->drawLine();
                         }
                         $this->_columnsBreak[$columnName]['prev'] = $this->_columnsBreak[$columnName]['current'];
                     }
                 }
             }
             $this->_verifyLineJump($row);
             $this->_addRow($row, false);
         } while ($row = $rs->getRow());
     }
     if ($this->_options['log']) {
         $this->_log->finish($numRows);
     }
     if (count($this->_columnsBreak) > 0) {
         foreach ($orderBreakReverse as $columnName) {
             if ($this->_options['advanced']['order_column'] == '' && $this->_columnsBreak[$columnName]['subtotal']) {
                 $rowBreak = array();
                 $this->_labelBreak = 'Subtotal';
                 $rowBreak[$columnName] = $this->_labelBreak;
                 foreach ($this->_columnsBreak[$columnName]['subtotal'] as $column => $total) {
                     $rowBreak[$column] = $total->getTotal($this->_mapper->getModel()->getAdapter());
                     $this->_columnsBreak[$columnName]['subtotal'] = null;
                 }
                 $this->_addRow($rowBreak, false, true);
                 #$this->_report->drawLine();
             }
         }
     }
     if (count($this->_total) > 0) {
         #$this->_report->drawLine();
         $row = array();
         foreach ($this->_columns as $column => $atributes) {
             break;
         }
         $this->_labelBreak = 'Total';
         $row[$column] = $this->_labelBreak;
         foreach ($this->_total as $columnName => $total) {
             $row[$columnName] = $total->getTotal($this->_mapper->getModel()->getAdapter());
         }
         $this->_addRow($row, false, true);
     }
 }