/** * Deploys content * * @see library/Bvb/Bvb_Grid::deploy() * @return void */ public function deploy() { $this->setRecordsPerPage(0); parent::deploy(); header('Content-Type', 'application/json'); $grid = array('titles' => $this->buildTitles(), 'rows' => $this->buildGrid(), 'sqlexp' => $this->buildSqlexp()); die(Zend_Json::encode($grid)); }
public function deployGrid($select = null) { if ($select === null) { $select = $this->db->select()->from('unit'); } $this->grid->setSource(new Bvb_Grid_Source_Zend_Select($select)); $grid = $this->grid->deploy(); $this->controller->getResponse()->setBody($grid); return $grid; }
/** * Deploys content * * @see library/Bvb/Bvb_Grid::deploy() * @return void */ public function deploy() { $this->setRecordsPerPage(0); parent::deploy(); header('Content-Type', 'application/json'); $grid = array('titles' => $this->buildTitles(), 'rows' => $this->buildGrid(), 'sqlexp' => $this->buildSqlexp()); if (!$this->getDeployOption('return', false)) { echo Zend_Json::encode($grid); die; } else { return Zend_Json::encode($grid); } }
public function deploy() { $this->checkExportRights(); $this->setRecordsPerPage(0); parent::deploy(); $grid = '<?xml version="1.0" encoding="' . $this->getCharEncoding() . '"?>' . "\n"; $grid .= "<grid>\n"; $grid .= $this->buildTitles(); $grid .= $this->buildGrid(); $grid .= $this->buildSqlexp(); $grid .= "</grid>"; 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: application/xml"); } if (!isset($this->_deploy['save']) && !isset($this->options['download'])) { echo $grid; die; } if (empty($this->_deploy['name'])) { $this->_deploy['name'] = date('H_m_d_H_i_s'); } if (substr($this->_deploy['name'], -4) == '.xml') { $this->_deploy['name'] = substr($this->_deploy['name'], 0, -4); } $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'] . ".xml", $grid); if ($this->_deploy['download'] == 1) { header('Content-Disposition: attachment; filename="' . $this->_deploy['name'] . '.xml"'); readfile($this->_deploy['dir'] . $this->_deploy['name'] . '.xml'); } if ($this->_deploy['save'] != 1) { unlink($this->_deploy['dir'] . $this->_deploy['name'] . '.xml'); } die; }
/** * Deploy method * * @return boolean FALSE if error */ public function deploy() { // prepare data $this->_prepareOptions(); parent::deploy(); if ($this->getDeployOption('download')) { // send first headers ob_end_clean(); header('Content-Description: File Transfer'); header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 header('Pragma: public'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header("Content-Type: application/csv"); header('Content-Disposition: attachment; filename="' . $this->getFileName() . '"'); header('Content-Transfer-Encoding: binary'); } if ($this->getDeployOption('store')) { // open file handler $this->_outFile = fopen($this->_deploy['dir'] . $this->getFileName(), "w"); } // export header if (!$this->getDeployOption('skipHeaders')) { $this->csvAddData($this->buildTitles()); } $i = 0; do { $i += $this->_recordsPerPage; $this->csvAddData($this->buildGrid()); $this->csvAddData($this->buildSqlexp()); // get next page $this->getSource()->buildQueryLimit($this->_recordsPerPage, $i); $this->_result = $this->getSource()->execute(); } while (count($this->_result)); if ($this->getDeployOption('store')) { // close file handler fclose($this->_outFile); } if ($this->getDeployOption('download')) { // we set special headers and uploaded data, there is nothing more we could do die; } return true; }
/** * 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; }
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; }
/** * Here we go.... * * @return string */ public function deploy() { if ($this->getSource() === null) { throw new Bvb_Grid_Exception('Please Specify your source'); } if ($this->getRequest()->isPost() && $this->getRequest()->getPost('postMassIds' . $this->getGridId())) { $this->_redirect($this->getUrl(array('zfmassedit', 'send_', 'gridAction_', 'massActionsAll_'))); die; } if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || $this->_allowAdd == 1) { $this->setAjax(false); } $this->_view = $this->getView(); $this->_placePageAtRecord(); if (isset($this->_ctrlParams['_zfgid']) && $this->_ctrlParams['_zfgid'] != $this->getGridId()) { return; } parent::deploy(); $this->_applyConfigOptions(array()); $this->_processForm(); if (!$this->_temp['table'] instanceof Bvb_Grid_Template_Table) { $this->setTemplate('table', 'table', $this->_templateParams); } else { $this->setTemplate($this->_temp['table']->options['name'], 'table', $this->_templateParams); } $images = $this->_temp['table']->images($this->getImagesUrl()); if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || is_array($this->_detailColumns)) { $pkUrl = $this->getSource()->getIdentifierColumns($this->_data['table']); $urlFinal = ''; $failPk = false; $pkUrl2 = $pkUrl; foreach ($pkUrl as $key => $value) { foreach ($this->getFields(true) as $field) { if ($field['field'] == $value) { unset($pkUrl2[$key]); break 2; } } // throw new Bvb_Grid_Exception("You don't have your primary key in your query. // So it's not possible to perform CRUD operations. // Change your select object to include your Primary Key: " . implode(';', $pkUrl2)); } foreach ($pkUrl as $value) { if (strpos($value, '.') !== false) { $urlFinal .= '{{' . substr($value, strpos($value, '.') + 1) . '}}-'; } else { $urlFinal .= '{{' . $value . '}}-'; } } $urlFinal = trim($urlFinal, '-'); } $removeParams = array('add', 'edit'); $url = $this->getUrl($removeParams); if ($this->_allowEdit == 1 && is_object($this->_crud) && $this->_crud->getBulkEdit() !== true) { $urlEdit = $url; $this->_actionsUrls['edit'] = "{$urlEdit}/edit" . $this->getGridId() . "/" . $urlFinal; if ($this->_crud->getEditColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'E', 'decorator' => "<a href=\"" . $this->_actionsUrls['edit'] . "\" > " . $images['edit'] . "</a>", 'edit' => true, 'order' => -2)); } } if ($this->_allowDelete && is_object($this->_crud) && $this->_crud->getBulkDelete() !== true) { if ($this->_deleteConfirmationPage == true) { $this->_actionsUrls['delete'] = "{$url}/delete" . $this->getGridId() . "/{$urlFinal}" . "/detail" . $this->getGridId() . "/1"; if ($this->_crud->getDeleteColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['delete'] . "\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3)); } } else { $this->_actionsUrls['delete'] = "{$url}/delete/" . $urlFinal; if ($this->_crud->getDeleteColumn() !== false) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'D', 'class' => 'gridDeleteColumn', 'decorator' => "<a href=\"#\" onclick=\"_" . $this->getGridId() . "confirmDel('" . $this->__('Are you sure?') . "','" . $this->_actionsUrls['delete'] . "');\" > " . $images['delete'] . "</a>", 'delete' => true, 'order' => -3)); } } } if (is_array($this->_detailColumns) && $this->_isDetail == false) { $removeParams = array('add', 'edit'); $url = $this->getUrl($removeParams); $this->_actionsUrls['detail'] = "{$url}/detail" . $this->getGridId() . "/" . $urlFinal; if ($this->_showDetailColumn === true) { $this->addExtraColumn(array('position' => $this->getCrudColumnsPosition(), 'name' => 'V', 'class' => 'gridDetailColumn', 'decorator' => "<a href=\"" . $this->_actionsUrls['detail'] . "\" >" . $images['detail'] . "</a>", 'detail' => true, 'order' => -1)); } } if ($this->_allowAdd == 0 && $this->_allowDelete == 0 && $this->_allowEdit == 0) { $this->_gridSession->unsetAll(); } if (!in_array('add' . $this->getGridId(), array_keys($this->getParams())) && !in_array('edit' . $this->getGridId(), array_keys($this->getParams()))) { if ($this->_gridSession->correct === null || $this->_gridSession->correct === 0) { $this->_gridSession->unsetAll(); } } if (strlen($this->_gridSession->message) > 0) { $this->_render['message'] = $this->_temp['table']->formMessage($this->_gridSession->messageOk, $this->_gridSession->message); $this->_renderDeploy['message'] = $this->_render['message']; } if ($this->getParam('edit') && $this->_allowEdit == 1 || $this->getParam('add') && $this->_allowAdd == 1 || $this->getInfo("doubleTables") == 1) { if ($this->_allowAdd == 1 || $this->_allowEdit == 1) { // Remove the unnecessary URL params $removeParams = array('filters', 'add'); $url = $this->getUrl($removeParams); $this->_orderFormElements(); $this->_renderDeploy['form'] = $this->_form->render(); $this->_render['form'] = $this->_form->render(); $this->_showsForm = true; } } $showsForm = $this->getWillShow(); if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_renderDeploy['start'] = $this->_render['start']; } if (!$this->getParam('edit') && !$this->getParam('add') || $this->getInfo("doubleTables") == 1) { if ($this->_isDetail == true || $this->_deleteConfirmationPage == true && $this->getParam('delete')) { $columnsTemp = $this->getSource()->fetchDetail($this->getIdentifierColumnsFromUrl()); $columns = array(); foreach ($this->_fields as $orderValue) { $columns[$orderValue] = $columnsTemp[$orderValue]; } $this->_render['detail'] = $this->_temp['table']->globalStart(); if (count($this->_detailColumns) > 0) { $columns = array_intersect_key($columns, array_flip($this->_detailColumns)); } foreach ($columns as $field => $options) { $this->updateColumn($field, array('hidden' => false)); } $result = array($columns); $result = parent::_buildGrid($result); $this->_render['detail'] .= $this->_temp['table']->startDetail($this->getDetailViewTitle()); foreach ($result[0] as $value) { if (!isset($value['field'])) { continue; } if ($value['type'] == 'extraField' && !in_array($value['field'], $this->_detailColumns)) { continue; } $field = $value['field']; if (isset($value['field']) && isset($this->_data['fields'][$value['field']]['title'])) { $field = $this->__($this->_data['fields'][$value['field']]['title']); } else { $field = $this->__(ucwords(str_replace('_', ' ', $field))); } $this->_render['detail'] .= $this->_temp['table']->detail($field, $value['value']); } if ($this->getParam('delete')) { $localCancel = $this->getUrl(array('detail', 'delete')); $localDelete = $this->getUrl(array('delete', 'detail')) . "/delete" . $this->getGridId() . "/" . str_replace("view", 'delete', $this->getParam('delete')); $buttonRemove = $this->getView()->formButton('delRecordGrid', $this->__('Remove Record'), array('onclick' => "window.location='{$localDelete}'")); $buttonCancel = $this->getView()->formButton('delRecordGrid', $this->__('Cancel'), array('onclick' => "window.location='{$localCancel}'")); $this->_render['detail'] .= $this->_temp['table']->detailDelete($buttonRemove . ' ' . $buttonCancel); } else { $this->_render['detail'] .= $this->_temp['table']->detailEnd($this->getUrl(array('detail')), $this->__($this->getDetailViewReturnLabel())); } $this->_render['detail'] .= $this->_temp['table']->globalEnd(); $this->_renderDeploy['detail'] = $this->_render['detail']; } else { $this->_buildGridRender(); } } else { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_buildGridRender(false); $this->_render['end'] = $this->_temp['table']->globalEnd(); } if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['end'] = $this->_temp['table']->globalEnd(); $this->_renderDeploy['end'] = $this->_render['end']; } //Build JS $this->_printScript(); $gridId = $this->getGridId(); if (strlen($gridId) == 0) { $gridId = 'grid'; } if ($this->getParam('gridmod') == 'ajax' && $this->getInfo("ajax") !== false || $this->getRequest()->isXmlHttpRequest()) { $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->clearBody(); $response->setBody(implode($this->_renderDeploy))->sendHeaders()->sendResponse(); die; } if ($this->getInfo("ajax") !== false) { $gridId = $this->getInfo("ajax"); } $grid = "<div id='{$gridId}'>" . implode($this->_renderDeploy) . "</div>"; if ($this->_gridSession->correct == 1) { $this->_gridSession->unsetAll(); } $this->_deploymentContent = $grid; return $this; }
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; }
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; }
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; }
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; }
public function deploy() { $this->checkExportRights(); if ($this->_filesLocation === null) { throw new Bvb_Grid_Exception($this->__("Please set Javascript and Flash file locations using SetFilesLocation()")); } $grid = array(); $newData = array(); $label = array(); $result = array(); parent::deploy(); $data = parent::_buildGrid(); if (count($data) == 0) { $this->_deploymentContent = ''; return; } foreach ($data as $value) { foreach ($value as $final) { $result[$final['field']][] = is_numeric($final['value']) ? $final['value'] : strip_tags($final['value']); } } if (is_string($this->_xLabels) && isset($result[$this->_xLabels])) { $this->_xLabels = $result[$this->_xLabels]; } $graph = new OFC_Chart(); $title = new OFC_Elements_Title($this->_title); $title->set_style($this->_style); $graph->set_title($title); foreach ($this->_chartOptions as $key => $value) { $graph->{$key}($value); } if (count($this->_xLabels) > 0) { $x = new OFC_Elements_Axis_X(); $x_axis_labels = new OFC_Elements_Axis_X_Label_Set(); foreach ($this->_xAxisOptions as $key => $value) { $x_axis_labels->{$key}($value); } $x_axis_labels->set_labels($this->_xLabels); $x->set_labels($x_axis_labels); foreach ($this->_xLabelsOptions as $key => $value) { $x->{$key}($value); } $graph->set_x_axis($x); } if (!empty($this->_xLegendText) && !empty($this->_xLegendStyle)) { $x_legend = new OFC_Elements_Legend_X($this->_xLegendText); $x_legend->set_style($this->_xLegendStyle); $graph->set_x_legend($x_legend); } $min = 0; $max = 0; if (count($this->_values) == 0) { $this->setValues(key($result)); } foreach ($this->_values as $key => $value) { if (is_array($value)) { $support = $value; sort($support); if (reset($support) < $min) { $min = reset($support); } if (end($support) > $max) { $max = end($support); } unset($support); $options = $this->_chartOptionsValues[$value]; if (isset($options['chartType'])) { $this->setChartType($options['chartType']); } $bar = new $this->_type(); foreach ($options as $key => $prop) { $bar->{$key}($prop); } $this->_type(); $pie = array(); if ($this->_type == 'Pie') { foreach ($value as $key => $title) { $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]); } $bar->set_values($pie); } else { $bar->set_values($value); } $graph->add_element($bar); } elseif (is_string($value) && isset($result[$value])) { $options = $this->_chartOptionsValues[$value]; if (isset($options['chartType'])) { $this->setChartType($options['chartType']); } $bar = new $this->_type(); foreach ($options as $key => $prop) { $bar->{$key}($prop); } $value = array_map(create_function('$item', ' return (float)$item; '), $result[$value]); $support = $value; sort($support); if (reset($support) < $min) { $min = reset($support); } if (end($support) > $max) { $max = end($support); } unset($support); $pie = array(); if ($this->_type == 'OFC_Charts_Pie') { foreach ($value as $key => $title) { $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]); } $bar->set_values($pie); } else { $bar->set_values($value); } $graph->add_element($bar); } } $max = $max * 1.05; $y = new OFC_Elements_Axis_Y(); $y->set_range($min, $max, ceil($max / 4)); $graph->add_y_axis($y); $final = $graph->toPrettyString(); if (!is_string($this->_chartId)) { $this->_chartId = 'chart_' . rand(1, 10000); } $script = ' swfobject.embedSWF( "' . $this->_filesLocation['flash'] . '", "' . $this->_chartId . '", "' . $this->_chartDimensions['x'] . '", "' . $this->_chartDimensions['y'] . '", "9.0.0", "expressInstall.swf",{"id":"' . $this->_chartId . '"},{"z-index":"1","wmode":"transparent"} ); function open_flash_chart_data(id) { return JSON.stringify(window[id]); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } var ' . $this->_chartId . ' = ' . $final . ';'; $final = '<div id="' . $this->_chartId . '" > loading... <br/> <p> Please note that this content requires flash player 9.0.0</br> To test for your version of flash, <a href="http://www.bobbyvandersluis.com/swfobject/testsuite_2_1/test_api_getflashplayerversion.html" target="_blank">click here</a> </p> </div>'; if (!$this->_multiple) { $final = '<div style="width: 100%;text-align: center">' . $final . '</div>'; } $this->getView()->headScript()->appendFile($this->_filesLocation['js']); $this->getView()->headScript()->appendFile($this->_filesLocation['json']); $this->getView()->headScript()->appendScript($script); $this->_deploymentContent = $final; return $this; }
/** * Here we go.... * * @return string */ public function deploy() { if ($this->getSource() === null) { throw new Bvb_Grid_Exception('Please Specify your source'); } if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || $this->_allowAdd == 1) { $this->setAjax(false); } $this->_view = $this->getView(); $this->_placePageAtRecord(); if (isset($this->_ctrlParams['_zfgid']) && $this->_ctrlParams['_zfgid'] != $this->getGridId()) { return; } parent::deploy(); $this->_applyConfigOptions(array()); $this->_processForm(); if (!$this->_temp['table'] instanceof Bvb_Grid_Template_Table) { $this->setTemplate('table', 'table', $this->_templateParams); } else { $this->setTemplate($this->_temp['table']->options['name'], 'table', $this->_templateParams); } $images = $this->_temp['table']->images($this->getImagesUrl()); if ($this->_allowDelete == 1 || $this->_allowEdit == 1 || is_array($this->_detailColumns) && $this->_isDetail == false) { $pkUrl = $this->getSource()->getIdentifierColumns($this->_data['table']); $urlFinal = ''; $failPk = false; $pkUrl2 = $pkUrl; foreach ($pkUrl as $key => $value) { foreach ($this->getFields(true) as $field) { if ($field['field'] == $value) { unset($pkUrl2[$key]); break 2; } } // throw new Bvb_Grid_Exception("You don't have your primary key in your query. // So it's not possible to perform CRUD operations. // Change your select object to include your Primary Key: " . implode(';', $pkUrl2)); } foreach ($pkUrl as $value) { if (strpos($value, '.') !== false) { $urlFinal .= $value . ':{{' . substr($value, strpos($value, '.') + 1) . '}}-'; } else { $urlFinal .= $value . ':{{' . $value . '}}-'; } } $urlFinal = trim($urlFinal, '-'); } $removeParams = array('add', 'edit', 'comm'); $url = $this->getUrl($removeParams); if ($this->_allowEdit == 1 && is_object($this->_crud) && $this->_crud->getBulkEdit() !== true) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } if ($this->_allowEdit == 1 && $this->getInfo("ajax") !== false) { $urlEdit = $this->_baseUrl . '/' . str_replace("/gridmod" . $this->getGridId() . "/ajax", "", $url); } else { $urlEdit = $url; } $this->_actionsUrls['edit'] = "{$urlEdit}/edit" . $this->getGridId() . "/1/comm" . $this->getGridId() . "/" . "mode:edit;[" . $urlFinal . "]"; if ($this->_crud->getEditColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'E', 'decorator' => "<a href=\"" . $this->_actionsUrls['edit'] . "\" > " . $images['edit'] . "</a>", 'edit' => true)); } } if ($this->_allowDelete && is_object($this->_crud) && $this->_crud->getBulkDelete() !== true) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } if ($this->_deleteConfirmationPage == true) { $this->_actionsUrls['delete'] = "{$url}/comm" . $this->getGridId() . "/" . "mode:view;[" . $urlFinal . "]/gridDetail" . $this->getGridId() . "/1/gridRemove" . $this->getGridId() . "/1"; if ($this->_crud->getDeleteColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'D', 'decorator' => "<a href=\"" . $this->_actionsUrls['delete'] . "\" > " . $images['delete'] . "</a>", 'delete' => true)); } } else { $this->_actionsUrls['delete'] = "{$url}/comm" . $this->getGridId() . "/" . "mode:delete;[" . $urlFinal . "]"; if ($this->_crud->getDeleteColumn() !== false) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'D', 'decorator' => "<a href=\"#\" onclick=\"_" . $this->getGridId() . "confirmDel('" . $this->__('Are you sure?') . "','" . $this->_actionsUrls['delete'] . "');\" > " . $images['delete'] . "</a>", 'delete' => true)); } } } if (is_array($this->_detailColumns) && $this->_isDetail == false) { if (!is_array($this->_extraFields)) { $this->_extraFields = array(); } $removeParams = array('add', 'edit', 'comm'); $url = $this->getUrl($removeParams, false); $this->_actionsUrls['detail'] = "{$url}/gridDetail" . $this->getGridId() . "/1/comm" . $this->getGridId(); $this->_actionsUrls['detail'] .= "/" . "mode:view;[" . $urlFinal . "]/"; if ($this->_showDetailColumn === true) { array_unshift($this->_extraFields, array('position' => 'left', 'name' => 'V', 'decorator' => "<a href=\"" . $this->_actionsUrls['detail'] . "\" >" . $images['detail'] . "</a>", 'detail' => true)); } } if ($this->_allowAdd == 0 && $this->_allowDelete == 0 && $this->_allowEdit == 0) { $this->_gridSession->unsetAll(); } if (!in_array('add' . $this->getGridId(), array_keys($this->getAllParams())) && !in_array('edit' . $this->getGridId(), array_keys($this->getAllParams()))) { if ($this->_gridSession->correct === null || $this->_gridSession->correct === 0) { $this->_gridSession->unsetAll(); } } if (strlen($this->_gridSession->message) > 0) { $this->_render['message'] = str_replace("{{value}}", $this->_gridSession->message, $this->_temp['table']->formMessage($this->_gridSession->messageOk)); $this->_renderDeploy['message'] = $this->_render['message']; } if ($this->getParam('edit') == 1 && $this->_allowEdit == 1 || $this->getParam('add') == 1 && $this->_allowAdd == 1 || $this->getInfo("doubleTables") == 1) { if ($this->_allowAdd == 1 || $this->_allowEdit == 1) { // Remove the unnecessary URL params $removeParams = array('filters', 'add'); $url = $this->getUrl($removeParams); $this->_orderFormElements(); $this->_renderDeploy['form'] = $this->_form->render(); $this->_render['form'] = $this->_form->render(); $this->_showsForm = true; } } $showsForm = $this->willShow(); if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_renderDeploy['start'] = $this->_render['start']; } if ((!$this->getParam('edit') || $this->getParam('edit') != 1) && (!$this->getParam('add') || $this->getParam('add') != 1) || $this->getInfo("doubleTables") == 1) { if ($this->_isDetail == true || $this->_deleteConfirmationPage == true && $this->getParam('gridRemove') == 1) { $columns = parent::_buildGrid(); $this->_willShow['detail'] = true; $this->_willShow['detailId'] = $this->getIdentifierColumnsFromUrl(); $this->_render['detail'] = $this->_temp['table']->globalStart(); foreach ($columns[0] as $value) { if (!isset($value['field'])) { continue; } if (isset($this->_data['fields'][$value['field']]['title'])) { $value['field'] = $this->__($this->_data['fields'][$value['field']]['title']); } else { $value['field'] = $this->__(ucwords(str_replace('_', ' ', $value['field']))); } $this->_render['detail'] .= str_replace(array('{{field}}', '{{value}}'), array($value['field'], $value['value']), $this->_temp['table']->detail()); } if ($this->getParam('gridRemove') == 1) { $localCancel = $this->getUrl(array('comm', 'gridDetail', 'gridRemove')); $localDelete = $this->getUrl(array('gridRemove', 'gridDetail', 'comm')) . "/comm" . $this->getGridId() . "/" . str_replace("view", 'delete', $this->getParam('comm')); $buttonRemove = $this->getView()->formButton('delRecordGrid', $this->__('Remove Record'), array('onclick' => "window.location='{$localDelete}'")); $buttonCancel = $this->getView()->formButton('delRecordGrid', $this->__('Cancel'), array('onclick' => "window.location='{$localCancel}'")); $this->_render['detail'] .= str_replace('{{button}}', $buttonRemove . ' ' . $buttonCancel, $this->_temp['table']->detailDelete()); } else { $this->_render['detail'] .= str_replace(array('{{url}}', '{{return}}'), array($this->getUrl(array('gridDetail', 'comm'), false), $this->__('Return')), $this->_temp['table']->detailEnd()); } $this->_render['detail'] .= $this->_temp['table']->globalEnd(); $this->_renderDeploy['detail'] = $this->_render['detail']; } else { $this->_willShow['grid'] = true; $this->_buildGridRender(); } $this->_showsGrid = true; } else { $this->_render['start'] = $this->_temp['table']->globalStart(); $this->_buildGridRender(false); $this->_render['end'] = $this->_temp['table']->globalEnd(); } if (isset($showsForm['form']) && $showsForm['form'] == 1 && $this->getInfo("doubleTables") == 1 || !isset($showsForm['form'])) { $this->_render['end'] = $this->_temp['table']->globalEnd(); $this->_renderDeploy['end'] = $this->_render['end']; } //Build JS $this->_printScript(); $gridId = $this->getGridId(); if ($this->getParam('gridmod') == 'ajax' && $this->getInfo("ajax") !== false) { $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->clearBody(); $response->setBody(implode($this->_renderDeploy)); $response->sendResponse(); die; } if ($this->getInfo("ajax") !== false) { $gridId = $this->getInfo("ajax"); } $grid = "<div id='{$gridId}'>" . implode($this->_renderDeploy) . "</div>"; if ($this->_gridSession->correct == 1) { $this->_gridSession->unsetAll(); } $this->_deploymentContent = $grid; return $this; }
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; }
/** * Build grid. Will output HTML definition for grid and add js/css to view. * * Use __toString() function to receive the result and place it in view where you want to display the grid. * * @return Bvb_Grid_Deploy_JqGrid */ public function deploy() { // check if setAjax() function was called if (!$this->_ajaxFuncCalled) { $this->log("setAjax() function was not called before deploy()", Zend_Log::WARN); } // it would not work correctly if deploy() is called more times if ($this->_deployFuncCalled) { return $this; } // prepare internal Bvb data parent::deploy(); // prepare access to view $view = $this->getView(); // defines ID property of html tags related to this jqGrid $id = $this->getId(); // initialize jQuery $this->jqInit(); // prepare options used to build jqGrid element $this->prepareOptions(); // build definition of columns, which will manipulate _options $this->_jqgParams['colModel'] = $this->jqgGetColumnModel(); // build final JavaScript code and return HTML code to display $this->jqAddOnLoad($this->renderPartJavascript()); $this->_deploymentContent = $this->renderPartHtml(); $this->_deployFuncCalled = true; return $this; }