コード例 #1
0
ファイル: Excel.php プロジェクト: robjacoby/xlr8u
    /**
     * Deploys
     *
     * @return void
     * @see library/Bvb/Bvb_Grid::deploy()
     */
    public function deploy()
    {
        $this->setRecordsPerPage(0);
        parent::deploy();
        if (!isset($this->options['title'])) {
            $this->options['title'] = 'ZFDatagrid';
        }
        $titles = parent::_buildTitles();
        $wsData = parent::_buildGrid();
        $sql = parent::_buildSqlExp();
        if (is_array($wsData) && count($wsData) > 65569) {
            throw new Bvb_Grid_Exception('Maximum number of records allowed is 65569');
        }
        $xml = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>
<Workbook xmlns:x="urn:schemas-microsoft-com:office:excel"
  xmlns="urn:schemas-microsoft-com:office:spreadsheet"
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">';
        $xml .= '<Worksheet ss:Name="' . $this->options['title'] . '" ss:Description="' . $this->options['title'] . '"><ss:Table>';
        $xml .= '<ss:Row>';
        foreach ($titles as $value) {
            $type = !is_numeric($value['value']) ? 'String' : 'Number';
            $xml .= '<ss:Cell><Data ss:Type="' . $type . '">' . $value['value'] . '</Data></ss:Cell>';
        }
        $xml .= '</ss:Row>';
        if (is_array($wsData)) {
            foreach ($wsData as $row) {
                $xml .= '<ss:Row>';
                $a = 1;
                foreach ($row as $value) {
                    $value['value'] = strip_tags($value['value']);
                    $type = !is_numeric($value['value']) ? 'String' : 'Number';
                    $xml .= '<ss:Cell><Data ss:Type="' . $type . '">' . $value['value'] . '</Data></ss:Cell>';
                    $a++;
                }
                $xml .= '</ss:Row>';
            }
        }
        if (is_array($sql)) {
            $xml .= '<ss:Row>';
            foreach ($sql as $value) {
                $type = !is_numeric($value['value']) ? 'String' : 'Number';
                $xml .= '<ss:Cell><Data ss:Type="' . $type . '">' . $value['value'] . '</Data></ss:Cell>';
            }
            $xml .= '</ss:Row>';
        }
        $xml .= '</ss:Table></Worksheet>';
        $xml .= '</Workbook>';
        if (!isset($this->_deploy['save'])) {
            $this->_deploy['save'] = false;
        }
        if (!isset($this->_deploy['download'])) {
            $this->_deploy['download'] = false;
        }
        if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
            throw new Exception('Nothing to do. Please specify download&&|save options');
        }
        if (empty($this->_deploy['name'])) {
            $this->_deploy['name'] = date('H_m_d_H_i_s');
        }
        if (substr($this->_deploy['name'], -4) == '.xls') {
            $this->_deploy['name'] = substr($this->_deploy['name'], 0, -4);
        }
        $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
        if (!is_dir($this->_deploy['dir']) && $this->_deploy['save'] == 1) {
            throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
        }
        if (!is_writable($this->_deploy['dir']) && $this->_deploy['save'] == 1) {
            throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
        }
        if ($this->_deploy['save'] == 1) {
            file_put_contents($this->_deploy['dir'] . $this->_deploy['name'] . ".xls", $xml);
        }
        if ($this->_deploy['download'] == 1) {
            header('Content-type: application/excel');
            header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.xls"');
            echo $xml;
        }
        die;
    }
コード例 #2
0
ファイル: Table.php プロジェクト: ocpyosep78/Booking
 /**
  * Combines all parts from the output
  * To deploy or to render()
  *
  * @param bool $deploy IF this is the deploy and not a render part
  *
  * @return void
  */
 private function _buildGridRender($deploy = true)
 {
     $bHeader = $this->_buildExtraRows('beforeHeader') . $this->_buildHeader() . $this->_buildExtraRows('afterHeader');
     $bTitles = $this->_buildExtraRows('beforeTitles') . $this->_buildMassActions() . $this->_buildTitlesTable(parent::_buildTitles(), true) . $this->_buildExtraRows('afterTitles');
     $bFilters = $this->_buildExtraRows('beforeFilters') . $this->_buildFiltersTable(parent::_buildFilters()) . $this->_buildExtraRows('afterFilters');
     $bGrid = $this->_buildGridTable(parent::_buildGrid());
     if (!$this->getInfo("hRow,title")) {
         $bSqlExp = $this->_buildExtraRows('beforeSqlExpTable') . $this->_buildSqlexpTable(parent::_buildSqlExp()) . $this->_buildExtraRows('afterSqlExpTable');
     } else {
         $bSqlExp = '';
     }
     $bPagination = $this->_buildExtraRows('beforePagination') . $this->_buildPagination() . $this->_buildExtraRows('afterPagination');
     if ($deploy == true) {
         $this->_renderDeploy['header'] = $bHeader;
         $this->_renderDeploy['titles'] = $bTitles;
         $this->_renderDeploy['filters'] = $bFilters;
         $this->_renderDeploy['grid'] = $bGrid;
         $this->_renderDeploy['sqlExp'] = $bSqlExp;
         $this->_renderDeploy['pagination'] = $bPagination;
     }
     $this->_render['header'] = $bHeader;
     $this->_render['titles'] = $bTitles;
     $this->_render['filters'] = $bFilters;
     $this->_render['grid'] = $bGrid;
     $this->_render['sqlExp'] = $bSqlExp;
     $this->_render['pagination'] = $bPagination;
 }
コード例 #3
0
ファイル: Pdf.php プロジェクト: nandorodpires2/gallery
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     $this->_width = 0;
     $colors = array('title' => '#000000', 'subtitle' => '#111111', 'footer' => '#111111', 'header' => '#AAAAAA', 'row1' => '#EEEEEE', 'row2' => '#FFFFFF', 'sqlexp' => '#BBBBBB', 'lines' => '#111111', 'hrow' => '#E4E4F6', 'text' => '#000000', 'filters' => '#F9EDD2', 'filtersBox' => '#DEDEDE');
     $this->_deploy['colors'] = array_merge($colors, (array) $this->_deploy['colors']);
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         throw new Exception('Nothing to do. Please specify download&&|save options');
     }
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -4) == '.xls') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -4);
     }
     if (!isset($this->_deploy['noPagination'])) {
         $this->_deploy['noPagination'] = 0;
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     if (!isset($this->_deploy['dir']) || !is_dir($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     $this->_la = 0;
     $titles = parent::_buildTitles();
     $grid = parent::_BuildGrid();
     $sqlExp = parent::_buildSqlExp();
     $larg = $this->calculateCellSize($titles, $sqlExp, $grid);
     $lengthTotal = array_sum($larg['larg']);
     $this->_cellFontSize = $this->getDeployOption('cellFontSize', 8);
     if (!$this->getInfo('hRow,field')) {
         $this->_info['hRow']['field'] = '';
     }
     if (strtoupper($this->_deploy['orientation']) == 'LANDSCAPE' && strtoupper($this->_deploy['size']) == 'A4') {
         $this->_totalPages = ceil(count($grid) / 26);
     } elseif (strtoupper($this->_deploy['orientation']) == 'LANDSCAPE' && strtoupper($this->_deploy['size']) == 'LETTER') {
         $this->_totalPages = ceil(count($grid) / 27);
     } else {
         $this->_totalPages = ceil(count($grid) / 37);
     }
     if ($this->_totalPages < 1) {
         $this->_totalPages = 1;
     }
     $this->_pdf = new Zend_Pdf();
     $this->_styles['style'] = new Zend_Pdf_Style();
     $this->_styles['style']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['lines']));
     $this->_styles['topo'] = new Zend_Pdf_Style();
     $this->_styles['topo']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['header']));
     $this->_styles['td'] = new Zend_Pdf_Style();
     $this->_styles['td']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['row2']));
     $this->_styles['styleFilters'] = new Zend_Pdf_Style();
     $this->_styles['styleFilters']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['filters']));
     $this->_styles['styleFiltersBox'] = new Zend_Pdf_Style();
     $this->_styles['styleFiltersBox']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['filtersBox']));
     $this->_styles['td2'] = new Zend_Pdf_Style();
     $this->_styles['td2']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['row1']));
     $this->_styles['hRowStyle'] = new Zend_Pdf_Style();
     $this->_styles['hRowStyle']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['hrow']));
     $this->_styles['styleSql'] = new Zend_Pdf_Style();
     $this->_styles['styleSql']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['sqlexp']));
     $this->_styles['styleText'] = new Zend_Pdf_Style();
     $this->_styles['styleText']->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['text']));
     $this->buildPageStructure($titles, true);
     $pageWidth = $this->_page->getWidth() - 80;
     $i = 0;
     foreach ($larg['larg'] as $final) {
         $this->_cell[$i] = ceil($final * $pageWidth / $lengthTotal);
         $i++;
     }
     $needed = 0;
     $fix = $larg['fix'];
     $larg = $larg['larg'];
     $perc = array();
     $i = 0;
     foreach ($this->_cell as $key => $value) {
         $perc[$key] = $value - $fix[$key];
         $i++;
     }
     $perc = array();
     foreach ($this->_cell as $key => $value) {
         if ($value + 2 < $fix[$key]) {
             $needed = ceil($fix[$key] - $value);
             $this->_cell[$key] = $fix[$key];
         }
         if ($value > $fix[$key] + 2 + $needed) {
             $this->_cell[$key] = $this->_cell[$key] - $needed;
             $needed = 0;
             $perc[$key] = $this->_cell[$key] - $fix[$key];
         }
     }
     if (array_sum($this->_cell) > $pageWidth) {
         $totalToRemove = array_sum($this->_cell) - $pageWidth;
         foreach ($perc as $key => $value) {
             $this->_cell[$key] = $this->_cell[$key] - round($totalToRemove * $value / array_sum($perc));
         }
     }
     $cellsCount = count($titles);
     if ($this->getInfo('hRow,title') != '') {
         $cellsCount--;
     }
     $largura = ($this->_page->getWidth() - 80) / $cellsCount;
     $this->_height = $this->_page->getHeight() - 120;
     $this->buildPageStructure($titles);
     $this->_page->setFont($this->_font, $this->_cellFontSize);
     $this->_page->setStyle($this->_styles['style']);
     if (is_array($grid)) {
         if ($this->getInfo('hRow,title') != '') {
             $bar = $grid;
             $hbar = trim($this->getInfo('hRow,field'));
             $p = 0;
             foreach ($grid[0] as $value) {
                 if ($value['field'] == $hbar) {
                     $hRowIndex = $p;
                 }
                 $p++;
             }
             $aa = 0;
         }
         $ia = 0;
         $aa = 0;
         foreach ($grid as $value) {
             if ($this->_height <= 80) {
                 $this->buildPageStructure($titles);
             }
             $this->_la = 0;
             $this->_height = $this->_height - 16;
             $i = 0;
             $tdf = $ia % 2 ? $this->_styles['td'] : $this->_styles['td2'];
             $a = 1;
             if ($this->getInfo('hRow,title') != '') {
                 if ($bar[$aa][$hRowIndex]['value'] != @$bar[$aa - 1][$hRowIndex]['value']) {
                     $centrar = $this->_page->getWidth() - 80;
                     $centrar = round($centrar / 2) + 30;
                     if ((int) $this->_la == 0) {
                         $largura1 = 40;
                     } else {
                         $largura1 = $this->_cell[$i - 1] + $largura1;
                     }
                     $this->_page->setStyle($this->_styles['hRowStyle']);
                     $this->_page->drawRectangle($largura1, $this->_height - 8, $this->_page->getWidth() - 39, $this->_height + 16);
                     $this->_page->setStyle($this->_styles['styleText']);
                     $this->_page->drawText($bar[$aa][$hRowIndex]['value'], $centrar, $this->_height + 2, $this->getCharEncoding());
                     $this->_la = 0;
                     $this->_height = $this->_height - 16;
                 }
             }
             $nl = 0;
             $tLines = $this->calculateNumerOfLinesForRecord($value);
             $cellPos = 0;
             foreach ($value as $value1) {
                 $value1['value'] = strip_tags(trim($value1['value']));
                 if ($value1['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                     if ((int) $this->_la == 0) {
                         $largura1 = 40;
                     } else {
                         $largura1 = $this->_cell[$i - 1] + $largura1;
                     }
                     $this->_page->setStyle($tdf);
                     $this->_page->drawRectangle($largura1, $this->_height + 8, $largura1 + $this->_cell[$i] + 1, $this->_height - 8);
                     $this->_page->setStyle($this->_styles['styleText']);
                     $textToShow = $this->getArrayForPdfRecord($value1['value'], $cellPos, $tLines);
                     $heightSupport = 0;
                     for ($ti = 0; $ti < $tLines; $ti++) {
                         if (!isset($textToShow[$ti])) {
                             continue;
                         }
                         if (count($textToShow) == 1) {
                             $extraHeight = round($tLines / count($textToShow)) + 2;
                         } else {
                             $extraHeight = 0;
                         }
                         $this->_page->drawText($textToShow[$ti], $largura1 + 2, $this->_height - $extraHeight - $heightSupport * 8, $this->getCharEncoding());
                         $heightSupport++;
                     }
                     $this->_la = $largura1;
                     $i++;
                     $nl++;
                     $cellPos++;
                 }
                 $a++;
             }
             $aa++;
             $ia++;
         }
     }
     $this->buildSqlPdf($sqlExp);
     $this->buildShowFiltersInExport();
     $this->_pdf->save($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     if ($this->_deploy['download'] == 1) {
         header('Content-type: application/pdf');
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.pdf"');
         readfile($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     }
     if ($this->_deploy['save'] != 1) {
         unlink($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     }
     die;
 }
コード例 #4
0
ファイル: Print.php プロジェクト: ocpyosep78/Booking
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     if (!$this->_temp['print'] instanceof Bvb_Grid_Template_Print) {
         $this->setTemplate('print', 'print');
     }
     $titles = parent::_buildTitles();
     $wsData = parent::_buildGrid();
     $sql = parent::_buildSqlExp();
     if (!isset($this->_deploy['title'])) {
         $this->_deploy['title'] = '';
     }
     $print = $this->_temp['print']->globalStart();
     $print .= $this->_temp['print']->header();
     //[PT] Títulos
     $print .= $this->_temp['print']->titlesStart();
     foreach ($titles as $value) {
         if (isset($value['field']) && $value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             $print .= str_replace("{{value}}", $value['value'], $this->_temp['print']->titlesLoop());
         }
     }
     $print .= $this->_temp['print']->titlesEnd();
     if (is_array($wsData)) {
         if ($this->getInfo('hRow,title') != '') {
             $bar = $wsData;
             $hbar = trim($this->getInfo('hRow,field'));
             $p = 0;
             foreach ($wsData[0] as $value) {
                 if ($value['field'] == $hbar) {
                     $hRowIndex = $p;
                 }
                 $p++;
             }
             $aa = 0;
         }
         $i = 1;
         $aa = 0;
         foreach ($wsData as $row) {
             //horizontal row
             if ($this->getInfo('hRow,title') != '') {
                 if (!isset($bar[$aa - 1][$hRowIndex])) {
                     $bar[$aa - 1][$hRowIndex]['value'] = '';
                 }
                 if ($bar[$aa][$hRowIndex]['value'] != $bar[$aa - 1][$hRowIndex]['value']) {
                     $print .= str_replace("{{value}}", $bar[$aa][$hRowIndex]['value'], $this->_temp['print']->hRow());
                 }
             }
             $i++;
             $print .= $this->_temp['print']->loopStart();
             $a = 1;
             foreach ($row as $value) {
                 $value['value'] = strip_tags($value['value']);
                 if (isset($value['field']) && $value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                     $print .= str_replace("{{value}}", $value['value'], $this->_temp['print']->loopLoop());
                 }
             }
             $print .= $this->_temp['print']->loopEnd();
             $aa++;
             $i++;
         }
     }
     // SQL EXPRESSIONS
     if (is_array($sql)) {
         $print .= $this->_temp['print']->sqlExpStart();
         foreach ($sql as $value) {
             $print .= str_replace("{{value}}", $value['value'], $this->_temp['print']->sqlExpLoop());
         }
         $print .= $this->_temp['print']->sqlExpEnd();
     }
     $print .= $this->_temp['print']->globalEnd();
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         header("Content-type: text/html");
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         echo $print;
         die;
     }
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -5) == '.html') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -5);
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     if (!is_dir($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     file_put_contents($this->_deploy['dir'] . $this->_deploy['name'] . ".html", $print);
     if ($this->_deploy['download'] == 1) {
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.html"');
         readfile($this->_deploy['dir'] . $this->_deploy['name'] . '.html');
     }
     if ($this->_deploy['save'] != 1) {
         unlink($this->_deploy['dir'] . $this->_deploy['name'] . '.html');
     }
     die;
 }
コード例 #5
0
ファイル: Wordx.php プロジェクト: ocpyosep78/Booking
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     if (!$this->_temp['wordx'] instanceof Bvb_Grid_Template_Wordx) {
         $this->setTemplate('wordx', 'wordx');
     }
     $this->templateInfo = $this->_temp['wordx']->options;
     if (!isset($this->_deploy['title'])) {
         $this->_deploy['title'] = '';
     }
     if (!isset($this->_deploy['subtitle'])) {
         $this->_deploy['subtitle'] = '';
     }
     if (!isset($this->_deploy['logo'])) {
         $this->_deploy['logo'] = '';
     }
     if (!isset($this->_deploy['footer'])) {
         $this->_deploy['footer'] = '';
     }
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         throw new Exception('Nothing to do. Please specify download&&|save options');
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     $this->inicialDir = $this->_deploy['dir'];
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -5) == '.docx') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -5);
     }
     if (!is_dir($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     $this->templateDir = explode('/', $this->_deploy['dir']);
     array_pop($this->templateDir);
     $this->templateDir = ucfirst(end($this->templateDir));
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/' . ucfirst($this->_deploy['name']) . '/';
     if (!defined('APPLICATION_PATH')) {
         $pathTemplate = substr($this->templateInfo['dir'], 0, -4) . '/';
     } else {
         $pathTemplate = APPLICATION_PATH . '/../' . rtrim($this->getLibraryDir(), '/') . '/' . substr($this->templateInfo['dir'], 0, -4) . '/';
     }
     Bvb_Grid_Deploy_Helper_File::deldir($this->_deploy['dir']);
     Bvb_Grid_Deploy_Helper_File::copyDir($pathTemplate, $this->_deploy['dir']);
     $xml = $this->_temp['wordx']->globalStart();
     $titles = parent::_buildTitles();
     $wsData = parent::_buildGrid();
     $sql = parent::_buildSqlExp();
     # HEADER
     if (file_exists($this->_deploy['logo'])) {
         $data = explode("/", $this->_deploy['logo']);
         copy($this->_deploy['logo'], $this->_deploy['dir'] . 'word/media/' . end($data));
         $logo = $this->_temp['wordx']->logo();
         file_put_contents($this->dir . "word/_rels/header1.xml.rels", $logo);
         $header = str_replace(array('{{title}}', '{{subtitle}}'), array($this->_deploy['title'], $this->_deploy['subtitle']), $this->_temp['wordx']->header());
     } else {
         $header = str_replace(array('{{title}}', '{{subtitle}}'), array($this->_deploy['title'], $this->_deploy['subtitle']), $this->_temp['wordx']->header());
     }
     file_put_contents($this->_deploy['dir'] . "word/header1.xml", $header);
     #BEGIN FOOTER
     $footer = str_replace("{{value}}", $this->_deploy['footer'], $this->_temp['wordx']->footer());
     file_put_contents($this->_deploy['dir'] . "word/footer2.xml", $footer);
     #START DOCUMENT.XML
     $xml = $this->_temp['wordx']->globalStart();
     $xml .= $this->_temp['wordx']->titlesStart();
     foreach ($titles as $value) {
         if (isset($value['field']) && $value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             $xml .= str_replace("{{value}}", utf8_encode($value['value']), $this->_temp['wordx']->titlesLoop());
         }
     }
     $xml .= $this->_temp['wordx']->titlesEnd();
     if (is_array($wsData)) {
         if ($this->getInfo('hRow,title') != '') {
             $bar = $wsData;
             $hbar = trim($this->getInfo('hRow,title'));
             $p = 0;
             foreach ($wsData[0] as $value) {
                 if (isset($value['field']) && $value['field'] == $hbar) {
                     $hRowIndex = $p;
                 }
                 $p++;
             }
             $aa = 0;
         }
         $i = 1;
         $aa = 0;
         foreach ($wsData as $row) {
             //A linha horizontal
             if (@$this->getInfo('hRow,title') != '') {
                 if (@$bar[$aa][$hRowIndex]['value'] != @$bar[$aa - 1][$hRowIndex]['value']) {
                     $xml .= str_replace("{{value}}", utf8_encode(@$bar[$aa][$hRowIndex]['value']), $this->_temp['wordx']->hRow());
                 }
             }
             $xml .= $this->_temp['wordx']->loopStart();
             $a = 1;
             foreach ($row as $value) {
                 $value['value'] = strip_tags($value['value']);
                 if (isset($value['field']) && $value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                     $xml .= str_replace("{{value}}", utf8_encode($value['value']), $this->_temp['wordx']->loopLoop());
                 }
                 $a++;
             }
             $xml .= $this->_temp['wordx']->loopEnd();
             $aa++;
             $i++;
         }
     }
     if (is_array($sql)) {
         $xml .= $this->_temp['wordx']->sqlExpStart();
         foreach ($sql as $value) {
             $xml .= str_replace("{{value}}", utf8_encode($value['value']), $this->_temp['wordx']->sqlExpLoop());
         }
         $xml .= $this->_temp['wordx']->sqlExpEnd();
     }
     $xml .= $this->_temp['wordx']->globalEnd();
     file_put_contents($this->_deploy['dir'] . "word/document.xml", $xml);
     $final = Bvb_Grid_Deploy_Helper_File::scan_directory_recursively($this->_deploy['dir']);
     $f = explode('|', Bvb_Grid_Deploy_Helper_File::zipPaths($final));
     array_pop($f);
     $zip = new ZipArchive();
     $filename = $this->_deploy['dir'] . $this->_deploy['name'] . ".zip";
     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
         exit("cannot open <{$filename}>\n");
     }
     foreach ($f as $value) {
         $zip->addFile($value, str_replace($this->_deploy['dir'], '', $value));
     }
     $zip->close();
     rename($filename, $this->inicialDir . $this->_deploy['name'] . '.docx');
     if ($this->_deploy['download'] == 1) {
         header('Content-type: application/word');
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.docx"');
         readfile($this->inicialDir . $this->_deploy['name'] . '.docx');
     }
     if ($this->_deploy['save'] != 1) {
         unlink($this->inicialDir . $this->_deploy['name'] . '.docx');
     }
     Bvb_Grid_Deploy_Helper_File::deldir($this->_deploy['dir']);
     die;
 }
コード例 #6
0
ファイル: Word.php プロジェクト: Aeryris/grid
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     if (!$this->_temp['word'] instanceof Bvb_Grid_Template_Word) {
         $this->setTemplate('word', 'word');
     }
     $titles = parent::_buildTitles();
     $wsData = parent::_buildGrid();
     $sql = parent::_buildSqlExp();
     $xml = $this->_temp['word']->globalStart();
     $xml .= $this->_temp['word']->titlesStart();
     foreach ($titles as $value) {
         if ($value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             $xml .= str_replace("{{value}}", $value['value'], $this->_temp['word']->titlesLoop());
         }
     }
     $xml .= $this->_temp['word']->titlesEnd();
     if (is_array($wsData)) {
         if ($this->getInfo('hRow,title') != '') {
             $bar = $wsData;
             $hbar = trim($this->getInfo('hRow,title'));
             $p = 0;
             foreach ($wsData[0] as $value) {
                 if ($value['field'] == $hbar) {
                     $hRowIndex = $p;
                 }
                 $p++;
             }
             $aa = 0;
         }
         $i = 1;
         $aa = 0;
         foreach ($wsData as $row) {
             //A linha horizontal
             if ($this->getInfo('hRow,title') != '') {
                 if (!isset($bar[$aa - 1][$hRowIndex])) {
                     $bar[$aa - 1][$hRowIndex]['value'] = '';
                 }
                 if ($bar[$aa][$hRowIndex]['value'] != $bar[$aa - 1][$hRowIndex]['value']) {
                     $xml .= str_replace("{{value}}", $bar[$aa][$hRowIndex]['value'], $this->_temp['word']->hRow());
                 }
             }
             $xml .= $this->_temp['word']->loopStart();
             $a = 1;
             foreach ($row as $value) {
                 $value['value'] = strip_tags($value['value']);
                 if (@$value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                     $xml .= str_replace("{{value}}", $value['value'], $this->_temp['word']->loopLoop(2));
                 }
                 $a++;
             }
             $xml .= $this->_temp['word']->loopEnd();
             $aa++;
             $i++;
         }
     }
     if (is_array($sql)) {
         $xml .= $this->_temp['word']->sqlExpStart();
         foreach ($sql as $value) {
             $xml .= str_replace("{{value}}", $value['value'], $this->_temp['word']->sqlExpLoop());
         }
         $xml .= $this->_temp['word']->sqlExpEnd();
     }
     $xml .= $this->_temp['word']->globalEnd();
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         throw new Exception('Nothing to do. Please specify download&&|save options');
     }
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -4) == '.doc') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -4);
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     if (!is_dir($this->_deploy['dir']) && $this->_deploy['save'] == 1) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir']) && $this->_deploy['save'] == 1) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     if ($this->_deploy['save'] == 1) {
         file_put_contents($this->_deploy['dir'] . $this->_deploy['name'] . ".doc", $xml);
     }
     if ($this->_deploy['download'] == 1) {
         header('Content-type: application/word');
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.doc"');
         echo $xml;
     }
     die;
 }
コード例 #7
0
ファイル: Ods.php プロジェクト: ocpyosep78/Booking
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     if (!$this->_temp['ods'] instanceof Bvb_Grid_Template_Ods) {
         $this->setTemplate('ods', 'ods');
     }
     $this->templateInfo = $this->_temp['ods']->options;
     if (!isset($this->_deploy['title'])) {
         $this->_deploy['title'] = '';
     }
     if (!isset($this->_deploy['subtitle'])) {
         $this->_deploy['subtitle'] = '';
     }
     if (!isset($this->_deploy['logo'])) {
         $this->_deploy['logo'] = '';
     }
     if (!isset($this->_deploy['footer'])) {
         $this->_deploy['footer'] = '';
     }
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         throw new Exception('Nothing to do. Please specify download&&|save options');
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     $this->inicialDir = $this->_deploy['dir'];
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -5) == '.docx') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -5);
     }
     if (!is_dir($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     $this->templateDir = explode('/', $this->templateInfo['dir']);
     array_pop($this->templateDir);
     $this->templateDir = ucfirst(end($this->templateDir));
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/' . ucfirst($this->_deploy['name']) . '/';
     if (!defined(APPLICATION_PATH)) {
         $pathTemplate = substr($this->templateInfo['dir'], 0, -4) . '/';
     } else {
         $pathTemplate = APPLICATION_PATH . '/../' . rtrim($this->getLibraryDir(), '/') . '/' . substr($this->templateInfo['dir'], 0, -4) . '/';
     }
     Bvb_Grid_Deploy_Helper_File::deldir($this->_deploy['dir']);
     Bvb_Grid_Deploy_Helper_File::copyDir($pathTemplate, $this->_deploy['dir']);
     $xml = $this->_temp['ods']->globalStart();
     $titles = parent::_buildTitles();
     $wsData = parent::_buildGrid();
     $sql = parent::_buildSqlExp();
     // START CONTENT.XML
     $xml = $this->_temp['ods']->globalStart();
     $xml .= $this->_temp['ods']->titlesStart();
     foreach ($titles as $value) {
         $xml .= str_replace("{{value}}", utf8_encode($value['value']), $this->_temp['ods']->titlesLoop());
     }
     $xml .= $this->_temp['ods']->titlesEnd();
     if (is_array($wsData)) {
         foreach ($wsData as $row) {
             $xml .= $this->_temp['ods']->loopStart();
             foreach ($row as $value) {
                 $xml .= str_replace("{{value}}", utf8_encode(strip_tags($value['value'])), $this->_temp['ods']->loopLoop());
             }
             $xml .= $this->_temp['ods']->loopEnd();
         }
     }
     if (is_array($sql)) {
         $xml .= $this->_temp['ods']->sqlExpStart();
         foreach ($sql as $value) {
             $xml .= str_replace("{{value}}", utf8_encode($value['value']), $this->_temp['ods']->sqlExpLoop());
         }
         $xml .= $this->_temp['ods']->sqlExpEnd();
     }
     $xml .= $this->_temp['ods']->globalEnd();
     file_put_contents($this->_deploy['dir'] . "content.xml", $xml);
     $final = Bvb_Grid_Deploy_Helper_File::scan_directory_recursively($this->_deploy['dir']);
     $f = explode('|', Bvb_Grid_Deploy_Helper_File::zipPaths($final));
     array_pop($f);
     $zip = new ZipArchive();
     $filename = $this->_deploy['dir'] . $this->_deploy['name'] . ".zip";
     if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
         exit("cannot open <{$filename}>\n");
     }
     foreach ($f as $value) {
         $zip->addFile($value, str_replace($this->_deploy['dir'], '', $value));
     }
     $zip->close();
     rename($filename, $this->inicialDir . $this->_deploy['name'] . '.ods');
     if ($this->_deploy['download'] == 1) {
         header('Content-type: application/vnd.oasis.opendocument.spreadsheet');
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.ods"');
         readfile($this->inicialDir . $this->_deploy['name'] . '.ods');
     }
     if ($this->_deploy['save'] != 1) {
         unlink($this->inicialDir . $this->_deploy['name'] . '.ods');
     }
     Bvb_Grid_Deploy_Helper_File::deldir($this->_deploy['dir']);
     die;
 }
コード例 #8
0
ファイル: Pdf.php プロジェクト: robjacoby/xlr8u
 public function deploy()
 {
     $this->checkExportRights();
     $this->setRecordsPerPage(0);
     parent::deploy();
     $width = 0;
     $colors = array('title' => '#000000', 'subtitle' => '#111111', 'footer' => '#111111', 'header' => '#AAAAAA', 'row1' => '#EEEEEE', 'row2' => '#FFFFFF', 'sqlexp' => '#BBBBBB', 'lines' => '#111111', 'hrow' => '#E4E4F6', 'text' => '#000000', 'filters' => '#F9EDD2', 'filtersBox' => '#DEDEDE');
     $this->_deploy['colors'] = array_merge($colors, (array) $this->_deploy['colors']);
     $la = '';
     if (!isset($this->_deploy['save'])) {
         $this->_deploy['save'] = false;
     }
     if (!isset($this->_deploy['download'])) {
         $this->_deploy['download'] = false;
     }
     if ($this->_deploy['save'] != 1 && $this->_deploy['download'] != 1) {
         throw new Exception('Nothing to do. Please specify download&&|save options');
     }
     if (empty($this->_deploy['name'])) {
         $this->_deploy['name'] = date('H_m_d_H_i_s');
     }
     if (substr($this->_deploy['name'], -4) == '.xls') {
         $this->_deploy['name'] = substr($this->_deploy['name'], 0, -4);
     }
     if (!isset($this->_deploy['noPagination'])) {
         $this->_deploy['noPagination'] = 0;
     }
     $this->_deploy['dir'] = rtrim($this->_deploy['dir'], '/') . '/';
     if (!isset($this->_deploy['dir']) || !is_dir($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not a dir');
     }
     if (!is_writable($this->_deploy['dir'])) {
         throw new Bvb_Grid_Exception($this->_deploy['dir'] . ' is not writable');
     }
     $larg = self::calculateCellSize();
     $lengthTotal = array_sum($larg);
     $cellFontSize = 8;
     //set font
     $titulos = parent::_buildTitles();
     $sql = parent::_buildSqlExp();
     $grid = parent::_BuildGrid();
     if (!$this->getInfo('hRow,field')) {
         $this->_info['hRow']['field'] = '';
     }
     if (strtoupper($this->_deploy['orientation']) == 'LANDSCAPE' && strtoupper($this->_deploy['size']) == 'A4') {
         $totalPaginas = ceil(count($grid) / 26);
     } elseif (strtoupper($this->_deploy['orientation']) == 'LANDSCAPE' && strtoupper($this->_deploy['size']) == 'LETTER') {
         $totalPaginas = ceil(count($grid) / 27);
     } else {
         $totalPaginas = ceil(count($grid) / 37);
     }
     if ($totalPaginas < 1) {
         $totalPaginas = 1;
     }
     $pdf = new Zend_Pdf();
     // Create new Style
     $style = new Zend_Pdf_Style();
     $style->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['lines']));
     $topo = new Zend_Pdf_Style();
     $topo->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['header']));
     $td = new Zend_Pdf_Style();
     $td->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['row2']));
     $styleFilters = new Zend_Pdf_Style();
     $styleFilters->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['filters']));
     $styleFiltersBox = new Zend_Pdf_Style();
     $styleFiltersBox->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['filtersBox']));
     $td2 = new Zend_Pdf_Style();
     $td2->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['row1']));
     $hRowStyle = new Zend_Pdf_Style();
     $hRowStyle->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['hrow']));
     $styleSql = new Zend_Pdf_Style();
     $styleSql->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['sqlexp']));
     $styleText = new Zend_Pdf_Style();
     $styleText->setFillColor(new Zend_Pdf_Color_Html($this->_deploy['colors']['text']));
     // Add new page to the document
     if (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
     } elseif (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) != 'LANDSCAPE') {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
     } elseif (strtoupper($this->_deploy['size'] != 'A4') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     } else {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     }
     $page->setStyle($style);
     $pdf->pages[] = $page;
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $page->setFont($font, 14);
     //$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     if (file_exists($this->_deploy['logo'])) {
         $image = Zend_Pdf_Image::imageWithPath($this->_deploy['logo']);
         list($width, $height, $type, $attr) = getimagesize($this->_deploy['logo']);
         $page->drawImage($image, 40, $page->getHeight() - $height - 40, 40 + $width, $page->getHeight() - 40);
     }
     $page->drawText($this->__($this->_deploy['title']), $width + 70, $page->getHeight() - 70, $this->getCharEncoding());
     $page->setFont($font, $cellFontSize);
     $page->drawText($this->__($this->_deploy['subtitle']), $width + 70, $page->getHeight() - 80, $this->getCharEncoding());
     //Iniciar a contagem de páginas
     $pagina = 1;
     $page->drawText($this->_deploy['footer'], 40, 40, $this->getCharEncoding());
     if (@$this->_deploy['noPagination'] != 1) {
         $page->drawText($this->__($this->_deploy['page']) . ' ' . $pagina . '/' . $totalPaginas, $page->getWidth() - strlen($this->__($this->_deploy['page'])) * $cellFontSize - 50, 40, $this->getCharEncoding());
     }
     $page->setFont($font, $cellFontSize);
     $pl = $page->getWidth() - 80;
     $i = 0;
     foreach ($larg as $final) {
         $cell[$i] = round($final * $pl / $lengthTotal);
         $i++;
     }
     $cellsCount = count($titulos);
     if ($this->getInfo('hRow,title') != '') {
         $cellsCount--;
     }
     $largura = ($page->getWidth() - 80) / $cellsCount;
     $altura = $page->getHeight() - 120;
     $i = 0;
     $page->setFont($font, $cellFontSize + 1);
     foreach ($titulos as $value) {
         if ($value['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             if ((int) $la == 0) {
                 $largura1 = 40;
             } else {
                 $largura1 = $cell[$i - 1] + $largura1;
             }
             $page->setStyle($topo);
             $page->drawRectangle($largura1, $altura - 4, $largura1 + $cell[$i] + 1, $altura + 12);
             $page->setStyle($styleText);
             $page->drawText($value['value'], $largura1 + 2, $altura, $this->getCharEncoding());
             $la = $largura1;
             $i++;
         }
     }
     $page->setFont($font, $cellFontSize);
     $page->setStyle($style);
     if (is_array($grid)) {
         if ($this->getInfo('hRow,title') != '') {
             $bar = $grid;
             $hbar = trim($this->getInfo('hRow,field'));
             $p = 0;
             foreach ($grid[0] as $value) {
                 if ($value['field'] == $hbar) {
                     $hRowIndex = $p;
                 }
                 $p++;
             }
             $aa = 0;
         }
         $ia = 0;
         $aa = 0;
         foreach ($grid as $value) {
             if ($altura <= 80) {
                 // Add new page to the document
                 if (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
                     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
                 } elseif (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) != 'LANDSCAPE') {
                     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
                 } elseif (strtoupper($this->_deploy['size'] != 'A4') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
                     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
                 } else {
                     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 }
                 $page->setStyle($style);
                 $pdf->pages[] = $page;
                 $pagina++;
                 $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
                 $page->setFont($font, 14);
                 //$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
                 if (file_exists($this->_deploy['logo'])) {
                     $image = Zend_Pdf_Image::imageWithPath($this->_deploy['logo']);
                     list($width, $height, $type, $attr) = getimagesize($this->_deploy['logo']);
                     $page->drawImage($image, 40, $page->getHeight() - $height - 40, 40 + $width, $page->getHeight() - 40);
                 }
                 $page->drawText($this->__($this->_deploy['title']), $width + 70, $page->getHeight() - 70, $this->getCharEncoding());
                 $page->setFont($font, $cellFontSize);
                 $page->drawText($this->__($this->_deploy['subtitle']), $width + 70, $page->getHeight() - 80, $this->getCharEncoding());
                 //set font
                 $altura = $page->getHeight() - 120;
                 $page->drawText($this->__($this->_deploy['footer']), 40, 40, $this->getCharEncoding());
                 if ($this->_deploy['noPagination'] != 1) {
                     $page->drawText($this->__($this->_deploy['page']) . ' ' . $pagina . '/' . $totalPaginas, $page->getWidth() - strlen($this->__($this->_deploy['page'])) * $cellFontSize - 50, 40, $this->getCharEncoding());
                 }
                 //
                 reset($titulos);
                 $i = 0;
                 $largura1 = 40;
                 $page->setFont($font, $cellFontSize + 1);
                 foreach ($titulos as $title) {
                     if ($title['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                         if ((int) $la == 0) {
                             $largura1 = 40;
                         } else {
                             $largura1 = $cell[$i - 1] + $largura1;
                         }
                         $page->setStyle($topo);
                         $page->drawRectangle($largura1, $altura - 4, $largura1 + $cell[$i] + 1, $altura + 12);
                         $page->setStyle($style);
                         $page->drawText($title['value'], $largura1 + 2, $altura, $this->getCharEncoding());
                         $la = $largura1;
                         $i++;
                     }
                 }
                 $page->setFont($font, $cellFontSize);
             }
             $la = 0;
             $altura = $altura - 16;
             $i = 0;
             $tdf = $ia % 2 ? $td : $td2;
             $a = 1;
             //A linha horizontal
             if ($this->getInfo('hRow,title') != '') {
                 if ($bar[$aa][$hRowIndex]['value'] != $bar[$aa - 1][$hRowIndex]['value']) {
                     $centrar = $page->getWidth() - 80;
                     $centrar = round($centrar / 2) + 30;
                     if ((int) $la == 0) {
                         $largura1 = 40;
                     } else {
                         $largura1 = $cell[$i - 1] + $largura1;
                     }
                     $page->setStyle($hRowStyle);
                     $page->drawRectangle($largura1, $altura - 4, $page->getWidth() - 40, $altura + 12);
                     $page->setStyle($styleText);
                     $page->drawText($bar[$aa][$hRowIndex]['value'], $centrar, $altura, $this->getCharEncoding());
                     $la = 0;
                     $altura = $altura - 16;
                 }
             }
             ////////////
             //Vamos saber qauntas linhas tem este registo
             $nlines = array();
             $nl = 0;
             foreach ($value as $lines) {
                 $line = $this->widthForStringUsingFontSize(strip_tags(trim($lines['value'])), $font, 8);
                 $nlines[] = ceil($line / $cell[$nl]);
                 $nl++;
             }
             sort($nlines);
             $totalLines = end($nlines);
             $nl = 0;
             foreach ($value as $value1) {
                 $value1['value'] = strip_tags(trim($value1['value']));
                 if ($value1['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
                     if ((int) $la == 0) {
                         $largura1 = 40;
                     } else {
                         $largura1 = $cell[$i - 1] + $largura1;
                     }
                     $page->setStyle($tdf);
                     $page->drawRectangle($largura1, $altura - 4, $largura1 + $cell[$i] + 1, $altura + 12);
                     $page->setStyle($styleText);
                     $page->drawText($value1['value'], $largura1 + 2, $altura, $this->getCharEncoding());
                     $la = $largura1;
                     $i++;
                     $nl++;
                 }
                 $a++;
             }
             $aa++;
             $ia++;
         }
     }
     $la = 0;
     $altura = $altura - 16;
     $i = 0;
     if (is_array($sql)) {
         foreach ($sql as $value) {
             if ((int) $la == 0) {
                 $largura1 = 40;
             } else {
                 $largura1 = $cell[$i - 1] + $largura1;
             }
             $page->setStyle($styleSql);
             $page->drawRectangle($largura1, $altura - 4, $largura1 + $cell[$i], $altura + 12);
             $page->setStyle($styleText);
             $page->drawText($value['value'], $largura1 + 2, $altura, $this->getCharEncoding());
             $la = $largura1;
             $la = $largura1;
             $i++;
         }
     }
     $la = 0;
     $altura = $altura - 16;
     $i = 0;
     if (is_array($this->_showFiltersInExport) || $this->_showFiltersInExport == true) {
         if (is_array($this->_showFiltersInExport) && is_array($this->_filtersValues)) {
             $this->_showFiltersInExport = array_merge($this->_showFiltersInExport, $this->_filtersValues);
         } elseif (is_array($this->_showFiltersInExport)) {
             $this->_showFiltersInExport = $this->_showFiltersInExport;
         } elseif (is_array($this->_filtersValues)) {
             $this->_showFiltersInExport = $this->_filtersValues;
         }
         if (count($this->_showFiltersInExport) > 0) {
             $page->setStyle($styleFilters);
             $page->drawRectangle(40, $altura - 4, array_sum($cell) + 41, $altura + 12);
             $page->setStyle($styleText);
             $tLarg = $this->widthForStringUsingFontSize($this->__('Filtered by:'), $font);
             $i = 0;
             $page->setStyle($styleFiltersBox);
             $page->drawRectangle(40, $altura - 4, $tLarg + 50, $altura + 12);
             $page->setStyle($styleText);
             $text = '     ' . $this->__('Filtered by:') . '     ';
             foreach ($this->_showFiltersInExport as $key => $value) {
                 if ($keyHelper = $this->getField($key)) {
                     $key = $keyHelper['title'];
                 }
                 if (is_array($value)) {
                     foreach ($value as $newName => $newValue) {
                         $text .= $this->__($key) . ' - ' . $this->__(ucfirst($newName)) . ': ' . $this->__($newValue) . '    |    ';
                     }
                 } else {
                     $text .= $this->__($key) . ': ' . $this->__($value) . '    |    ';
                 }
                 $i++;
             }
             $page->drawText($text, $tLarg + 3, $altura, $this->getCharEncoding());
         }
     }
     $pdf->save($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     if ($this->_deploy['download'] == 1) {
         header('Content-type: application/pdf');
         header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.pdf"');
         readfile($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     }
     if ($this->_deploy['save'] != 1) {
         unlink($this->_deploy['dir'] . $this->_deploy['name'] . '.pdf');
     }
     die;
 }