Example #1
0
 /**
  * Adiciona uma celula
  * 
  * @param ZendT_Report_Cell $_cell 
  * @return ZendT_Report_Abstract
  */
 public function addCell(ZendT_Report_Cell $_cell)
 {
     $this->_cells[] = $_cell;
     if (substr($_cell->getName(), 0, 6) == 'title_') {
         $this->_tableWidth += $_cell->getWidth();
     }
     return $this;
 }
Example #2
0
 /**
  * Cria linhas no relatório
  * 
  * @param array $columns
  * @param bool $title
  */
 protected function _addRow($columns, $title = false, $subtotal = false, $columnsTitle = array(), $borderTop = true)
 {
     $styles = array();
     if ($this->_styleRow && !$title) {
         $styles = $this->_mapper->getStylesRow($columns, $this->_options['id'], $subtotal);
     }
     if ($title && count($this->_columnsTitle) > 0) {
         foreach ($this->_columnsTitle as $column) {
             $_cell = new ZendT_Report_Cell();
             $_cell->setValue($column['label']);
             $_cell->setWidth($column['width']);
             if ($column['colspan']) {
                 $_cell->setColspan($column['colspan'] - 1);
             }
             $_cell->setTextAlign('center');
             $_cell->setFontWeight(true);
             $_cell->setFontSize($this->_fontSize);
             //$this->_configBorder($_cell,$column['border']);
             $this->_report->addCell($_cell);
         }
         $this->_report->printCells(false, $title);
     }
     /* echo '<pre>';
        print_r($columns);
        echo '</pre>';
        $this->count++;
        if ($this->count > 3) {
        exit;
        } */
     foreach ($this->_columns as $column => $atributes) {
         /**
          * @todo Verificar qual o melhor lugar para colocar o replace abaixo 
          */
         $column = str_replace('-distinct', '', $column);
         $column = str_replace('_distinct', '', $column);
         if ($title) {
             $value = $atributes['label'];
         } else {
             if (isset($columns[$column])) {
                 $value = $columns[$column];
             } else {
                 $value = '';
             }
         }
         $_cell = new ZendT_Report_Cell();
         if ($title) {
             $column = 'title_' . $column;
         }
         if ($subtotal) {
             $column = 'total_' . $column;
         }
         $_cell->setName($column);
         $_cell->setValue($value);
         $parseUrl = false;
         if ($value instanceof ZendT_Type) {
             $valueColumn = $value->getValueToDb();
             if (isset($this->_columnsJumped[$column])) {
                 $jumpedRow = in_array($valueColumn, $this->_columnsJumped[$column]);
             }
             if ($atributes['first_record'] && $valueColumn) {
                 if ($this->_columnsRepeat[$column] == $valueColumn) {
                     $_cell->setValue(NULL);
                 }
                 $this->_columnsRepeat[$column] = $valueColumn;
             }
             $parseUrl = true;
         }
         $url = str_replace("?", "&", $atributes['url']);
         $urlView = current(explode('&', $url));
         if ($urlView) {
             $isUrlView = strpos($urlView, "view=") || is_numeric($urlView);
             if ($isUrlView) {
                 $urlParams = explode('&', substr($url, strpos($url, "&") + 1));
                 $newParams = '';
                 foreach ($urlParams as $key => $val) {
                     $data = explode("=", $urlParams[$key]);
                     if ($data[0] && $data[1]) {
                         $newParams[$data[0]] = $data[1];
                     }
                 }
                 $urlView = end(explode("view=", $urlView));
                 $urlParams = $newParams;
                 $atributes['url'] = '';
                 foreach ($this->_params as $param => $key) {
                     $atributes['url'] .= "&{$param}=:{$param}";
                 }
                 if (!$this->_arrayUrl) {
                     foreach ($this->_columnsOrig as $param => $key) {
                         if (!$key['subtotal']) {
                             $this->_arrayUrl[] = $param;
                         }
                     }
                 }
                 if ($subtotal) {
                     if ($this->_labelBreak == 'Subtotal') {
                         foreach ($this->_columnsBreak as $param => $key) {
                             $atributes['url'] .= "&{$param}=:{$param}";
                         }
                     } else {
                         if ($this->_labelBreak == 'Total') {
                         }
                     }
                 } else {
                     foreach ($this->_arrayUrl as $key => $param) {
                         $atributes['url'] .= "&{$param}=:{$param}";
                     }
                 }
                 if ($urlParams) {
                     foreach ($urlParams as $key => $val) {
                         if ($key == $val) {
                             $val = ":{$val}";
                         }
                         $atributes['url'] .= "&{$key}={$val}";
                     }
                 }
             }
         }
         if ($atributes['input'] && $this->_configColumns[$column]['input'] != null) {
             $atributes['input'] = $this->_configColumns[$column]['input'];
         }
         $_cell->setInput($atributes['input']);
         if ($atributes['url'] && !$title && $parseUrl) {
             $url = trim($atributes['url']);
             if (strpos($url, ':') !== false) {
                 preg_match_all("/\\:(.*?)\\&/", $url . "&", $params);
                 #print_r($params);die;
                 list($aliasName, $aliasName2) = explode('_', $column);
                 $paramKey = array();
                 $paramValues = array();
                 foreach ($params[1] as $paramName) {
                     $paramValue = '';
                     if (isset($this->_columnsOrig[$paramName])) {
                         $paramValue = $this->_columnsOrig[$paramName];
                     } else {
                         if (isset($columns[$paramName])) {
                             $paramValue = $columns[$paramName];
                         } else {
                             if (isset($this->_columnsPivot[$paramName]['labels'][$aliasName])) {
                                 $paramValue = $this->_columnsPivot[$paramName]['labels'][$aliasName];
                             } else {
                                 if (isset($this->_columnsPivot[$paramName]['labels'][$aliasName2])) {
                                     $paramValue = $this->_columnsPivot[$paramName]['labels'][$aliasName2];
                                 } else {
                                     if (isset($this->_params[$paramName])) {
                                         $paramValue = $this->_params[$paramName];
                                     } else {
                                         foreach ($this->_columns as $column => $keys) {
                                             if ($keys['columnName'] == $paramName) {
                                                 $subtotalColumn = $paramName . "_" . $keys['subtotal'];
                                                 if ($columns[$paramName]) {
                                                     $paramValue = $columns[$paramName]->get();
                                                 } else {
                                                     if ($columns[$subtotalColumn]) {
                                                         $paramValue = $columns[$subtotalColumn]->get();
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     /* if (substr($paramName,0,3) == 'exp'){
                        $paramValue = utf8_decode($paramValue);
                        } */
                     $paramKey[] = ':' . $paramName;
                     $paramValues[] = utf8_decode($paramValue);
                 }
                 $url = str_replace($paramKey, $paramValues, $url);
             } else {
                 $url .= $value;
             }
             if ($isUrlView) {
                 $url = ZendT_Url::getUri() . "?profile=" . $urlView . $url;
             }
             $url = str_replace('{host}', ZendT_Url::getHostName(), $url);
             $url = str_replace('{baseUrl}', ZendT_Url::getHostName() . ZendT_Url::getBaseUrl(), $url);
             $_cell->setUrl($url);
         }
         if ($atributes['width']) {
             if (strpos($atributes['width'], ',') !== false) {
                 $atributes['width'] = (double) str_replace(array('.', ','), array('', '.'), $atributes['width']);
             }
             $_cell->setWidth($atributes['width']);
         } else {
             $_cell->setWidth($atributes['width']);
         }
         $_cell->setTextAlign($atributes['align']);
         $_cell->setFontWeight($title || $subtotal || $jumpedRow);
         $this->_configBorder($_cell, $atributes['border']);
         if ($title) {
             $_cell->setBorderBottom(0.4, 'solid', '#000000');
         }
         if ($this->firstLine) {
             $_cell->setBorderTop(0.2, 'solid', '#000000');
         }
         if ($subtotal && $borderTop) {
             $_cell->setBorderTop(0.2, 'solid', '#000000');
         }
         if ($atributes['font-size']) {
             if (strpos($atributes['font-size'], ',') !== false) {
                 $atributes['font-size'] = (double) str_replace(array('.', ','), array('', '.'), $atributes['font-size']);
             }
             $_cell->setFontSize($atributes['font-size']);
         } else {
             $_cell->setFontSize($this->_fontSize);
         }
         if (isset($styles[$column])) {
             $_cell->setStyles($styles[$column]);
         }
         $this->_report->addCell($_cell);
         if ($atributes['subtotal'] && $subtotal == false && ($value instanceof ZendT_Type_Number || $value instanceof ZendT_Type_NumberTime)) {
             if (!isset($this->_total[$column])) {
                 $this->_total[$column] = clone $value;
             }
             if (isset($atributes['calctotal'])) {
                 $this->_total[$column]->setTotalCalc($columns, $atributes['calctotal']);
             } else {
                 $this->_total[$column]->setTotal($value, $atributes['subtotal']);
             }
             if (count($this->_columnsBreak) > 0) {
                 foreach ($this->_columnsBreak as &$columnBreak) {
                     if (!isset($columnBreak['subtotal'][$column])) {
                         $columnBreak['subtotal'][$column] = clone $value;
                     }
                     if (isset($atributes['calctotal'])) {
                         $columnBreak['subtotal'][$column]->setTotalCalc($columns, $atributes['calctotal']);
                     } else {
                         $columnBreak['subtotal'][$column]->setTotal($value, $atributes['subtotal']);
                     }
                 }
             }
         }
     }
     $zebra = true;
     if ($subtotal && $borderTop) {
         $zebra = false;
     }
     if ($title) {
         $this->firstLine = true;
         $zebra = false;
     } else {
         $this->firstLine = false;
     }
     $this->_report->printCells($zebra, $title);
 }
Example #3
0
 /**
  * Adiciona uma celula
  * 
  * @param ZendT_Report_Cell $_cell 
  * @return ZendT_Report_Abstract
  */
 public function addCell(ZendT_Report_Cell $_cell)
 {
     $value = $_cell->getValue();
     if ($value instanceof ZendT_Type_FileSystem) {
         /* $pagecount = $this->_driver->setSourceFile($value->getFile()->getFilename());
            for ($page = 1; $page <= $pagecount; $page++) {
            $this->_driver->AddPage();
            $tplidx = $this->_driver->importPage($page);
            $s = $this->_driver->getTemplatesize($tplidx);
            $this->_driver->useTemplate($tplidx, 0.5, 0.5, $s['w'], $s['h']);
            } */
         $value = utf8_decode($value->get());
     } else {
         if ($value instanceof ZendT_Type) {
             $value = utf8_decode($value->get());
         } else {
             $value = utf8_decode($value);
         }
     }
     $this->_driver->SetFont($_cell->getFontName(), $_cell->getStyle(), $_cell->getFontSize());
     if (strtoupper($value) == $value) {
         $width = $this->_driver->GetStringWidth('Z');
     } else {
         $width = $this->_driver->GetStringWidth('z');
     }
     if ($_cell->getWidth()) {
         $space = $_cell->getWidth();
     } else {
         $space = $this->_pageWidth / $this->_maxPerLine;
     }
     $numCaracter = round($this->_pxToCm($space) / $width);
     $arrayValues = array();
     $this->_wordWrap($value, $numCaracter, $arrayValues);
     if (count($arrayValues) > $this->_cells['maxLine']) {
         $this->_cells['maxLine'] = count($arrayValues);
     }
     $this->_cells['values'][] = $arrayValues;
     $this->_cells['cell'][] = $_cell;
     return $this;
 }
Example #4
0
 /**
  *
  * @param array $colsBreaker
  * @param array $colsDetail
  * @param type $report 
  */
 function setReportHeader(array $colsBreaker, array $valBreaker, array $colsDetail, &$report, &$options)
 {
     foreach ($colsBreaker as $column) {
         $celula = new ZendT_Report_Cell($options['cellsTitle']);
         $celula->setTextAlign($column->getAlign())->setWidth($column->getWidth())->setValue($column->getHeaderTitle() . ': ' . $valBreaker[$column->getName()])->setStyleName('cellsTitle-' . $column->getName());
         $report->addCell($celula);
     }
     $report->printCells();
     $report->drawLine();
     foreach ($colsDetail as $column) {
         $celula = new ZendT_Report_Cell($options['cellsTitle']);
         $celula->setTextAlign($column->getAlign())->setWidth($column->getWidth())->setValue($column->getHeaderTitle())->setStyleName('cellsTitle' . $column->getName());
         $report->addCell($celula);
     }
     $report->printCells();
 }
Example #5
0
 /**
  * Esta função pega uma ZendT_Report_Cell e transforma um array pronto para ser impresso como celula
  * 
  * @param ZendT_Report_Cell $cell
  * @return array 
  */
 public function makeCell($celula, $options = false)
 {
     if (!$celula instanceof ZendT_Report_Cell) {
         $celula = new ZendT_Report_Cell($celula);
     }
     $borders = $celula->getBorders();
     $this->SetFont($celula->getFontName(), $celula->getStyle(), $celula->getFontSize());
     $corFonteCelula = $this->hex2RGB($celula->getColor());
     $this->SetTextColor($corFonteCelula['red'], $corFonteCelula['green'], $corFonteCelula['blue']);
     if ($borders['borders']) {
         if (!$borders['color']) {
             $borders['color'] = '#000000';
         }
         $corBorda = $this->hex2RGB($borders['color']);
         $this->SetDrawColor($corBorda['red'], $corBorda['green'], $corBorda['blue']);
         $this->SetLineWidth($borders['width'] . 'px');
     }
     $backgroundColor = $celula->getBackgroundColor();
     if ($backgroundColor) {
         $colorFill = 1;
         $backgroundColor = $this->hex2RGB($backgroundColor);
         $this->SetFillColor($backgroundColor['red'], $backgroundColor['green'], $backgroundColor['blue']);
     } else {
         if (isset($options['backgroundColor'])) {
             $backgroundColor = $this->hex2RGB($options['backgroundColor']);
             $this->SetFillColor($backgroundColor['red'], $backgroundColor['green'], $backgroundColor['blue']);
             $colorFill = 1;
         } else {
             $colorFill = 0;
         }
     }
     return array('celula' => $celula, 'color' => $colorFill, 'border' => $borders['borders']);
 }
Example #6
0
 protected function _dateLine()
 {
     $_cell = new ZendT_Report_Cell();
     $_cell->setTextAlign('center');
     $_cell->setFontSize(7);
     $_cell->setTaStyle($this->_checkStyle($_cell));
     $styleId = $_cell->getTaStyle();
     if (!$styleId) {
         $styleId = 'String';
     }
     $date = ZendT_Type_Date::nowDateTime()->get();
     $this->_memObject->value .= "<Row>\n";
     $this->_memObject->value .= '<Cell ss:StyleID="' . $styleId . '"><Data ss:Type="String">' . $this->_escapeString($date) . '</Data></Cell>' . "\n";
     $this->_memObject->value .= "</Row>\n\n";
     $this->_rows++;
 }