public function listMenu(App_Model_Abstract $module, $selectedId = '', App_Grid_Filter $filter, $isLeftHide = false) { $this->_filter = $filter; $this->_isLeftHide = $isLeftHide; $backlink = $this->view->url(array('action' => 'index'), true); // หาว่า id นี้อยู่หน้าไหน $request = Zend_Controller_Front::getInstance()->getRequest(); $text .= "<div class='list-group listmenu-container left-menu1 hide-on-print' >"; $text .= "<a href='#' class='list-group-item active'>"; $names = explode("_Model_", get_class($module)); $dataName = str_replace("_", " ", $this->view->translate("" . $names[1])); $text .= $dataName; $text .= "</a>"; $list = $filter->getList(); foreach ($list as $item) { $itemLabel = "" . $item; $itemId = $item->{$item->getPKName()}; if ("" == $itemLabel) { $itemLabel = $dataName . ":" . $itemId; } $link = $this->_getSelectLink(array('id' => $itemId)); $liId = ''; if ($selectedId == $item->{$item->getPKName()}) { $liId = "current"; } $text .= "<a href='{$link}' id='{$liId}' title='{$itemLabel}' href='#' class='list-group-item'>{$itemLabel}</a>"; } $text .= "</div>"; $text .= "<div class='listmenu-pagination-container hide-on-print'>"; $text .= $this->_genPagination(); $text .= "</div>"; //$this->globalScript(); return $text; }
public function exportExcel(App_Grid_Filter $filter, $exportFileName) { ob_start(); //$filter->setRecordsPerPage($rowsPerPage); $filter->disableSort(); parent::Table($filter); ob_clean(); $list = $filter->getList(); $this->render($list, $filter->getheaderTitles(), $filter->getFields(), $exportFileName); }
public function tableAjax(App_Grid_Filter $filter, array $list = null) { $req = Zend_Controller_Front::getInstance()->getRequest(); $this->_request = $req; $filter->setRequest($req); $ui = $filter->getUiName(); $this->_modelName = $filter->getModelName(); $tableConfig = $this->getTableConfig($this->_modelName, $ui); $this->_columnConfig = $tableConfig['fields']; $this->_modelConfig = $this->getModelConfig($this->_modelName); //print_r($this->_columnConfig); $widths = $filter->getRowWidths(); $titles = $filter->getheaderTitles(); //print_r($titles); $tWidth = $filter->getTableWidth(); if ($list == null) { $list = $filter->getList(); } $this->_filter = $filter; $view = $this->view; if (!$filter->isDisableHeader()) { // $view->headLink()->appendStylesheet('/scripts/jq-ingrid/css/ingrid.css'); // $view->headScript()->appendFile('/scripts/jq-ingrid/js/jquery.ingrid.js'); // $view->headScript()->appendFile('/scripts/jq-ingrid/js/jquery.cookie.js'); //$view->headScript()->appendScript($this->_getScript()); } $gridwidth = $filter->getGridWidth(); $table = '<div id="issues-preview-table"><table style="width:' . $gridwidth . '" class="extensions listing" cellpadding="0" cellspacing="0">'; //if( !$filter->isDisableHeader() ){ $table .= $this->_getHeader($widths, $titles); //} if (is_array($list)) { $table .= $this->_getRows($list, $widths); } else { $table .= $this->_getBlankRows(count($titles)); } //if( !$filter->isDisableHeader() ){ // $table .= $this->_getFooter(count($titles)); //} $table .= '</table>'; $table .= '</div>'; $table .= $this->_genPagination(); //$table .= '</div>'; //if (! $filter->isDisableScript ()) { //$table .='<script type="text/javascript">'; $this->_genScript(); //$table .= '</script> '; //} return $table; }
public function indexAction() { $req = $this->getRequest(); $model = $this->getObject($this->_model); $filter = new App_Grid_Filter($model); $filter->setView($this->view); if (count($this->_helperFunctions) > 0) { foreach ($this->_helperFunctions as $propKey => $helperName) { $filter->addHelperFunction($propKey, $helperName); } } if ($this->_section != '') { $filter->addCondition('secid', $this->_section); } if ($this->_catigory != '') { $filter->addCondition('catid', $this->_catigory); } if (count($this->_conditions) > 0) { foreach ($this->_conditions as $condition) { $filter->addCondition(trim($condition[0]), trim($condition[1]), trim($condition[2])); } } if ($this->_gridHeaders != null) { $filter->setHeaderTitles($this->_gridHeaders); } $filter->setFields($this->_gridFields); $filter->setRowsWidth($this->_gridFieldWidth); $filter->setRequest($req); if ($this->_sort != null) { $filter->setSortBy($this->_sort); $filter->setDirection($this->_direction); } $filter->setRecordsPerPage($this->_recordsPerPage); #view config $this->view->layout()->btitle = "Content > " . $req->getControllerName(); $this->view->filter = $filter; if ($this->_htmlTabs != null and ($this->_showTabsOnView == null or $this->_showTabsOnView == 'index')) { $this->view->htmlTabs = $this->_htmlTabs; } // render action bar $buttons = $this->getButtons('index'); $buttons[] = $this->view->button('new'); $this->view->buttons = $buttons; if ($this->_noIndexView == true) { $this->render('index', null, true); } }
function preDispatch() { ob_start(); // and $this->getInnerLayout() ==self::LAYOUT_DEFAULT / if ($this->_helper->layout()->isEnabled()) { $layout = $this->_request->getParam('layout', ''); if ('fullsize-nonavi' == $layout) { $this->setLayout('fullsize-nonavi'); App_Env::setSession("sys_layout_detach", 'no-detach'); } elseif ('nodetach' == $layout) { App_Env::setSession("sys_layout_detach", 'no-detach'); } elseif ('detach' == $layout) { App_Env::setSession("sys_layout_detach", 'detach'); $this->setLayout('detach'); } elseif ('popup' == $layout) { $this->setLayout('popup'); } elseif ('detach' == App_Env::getSession("sys_layout_detach", '')) { $this->setLayout('detach'); } else { App_Env::setSession("sys_layout_detach", 'no-detach'); } $this->view->headTitle($this->view->printPageName()); // echo $this->_request->getParam('id'); if (method_exists($this, "getDefaultModel")) { if (App_Config_Controller::getInstance()->getConfig()->isListMenuEnabled() and $this->_disableListMenu == false) { if (!in_array($this->_request->getActionName(), array('index', 'new')) and $this->_request->getParam('id') != '') { $id = $this->getRequestId(); $model = $this->getDefaultModel($id); if (is_object($model)) { //echo die( "ss". get_class($model) ); $this->view->hideLeftMenu = $isLeftMenuHide = !$this->_isMenuLeftPaneStateShow(); $this->view->content()->captureStart('navPane'); $filter = new App_Grid_Filter($model); if ($filter instanceof App_Grid_Filter) { $filter->setRecordsPerPage($this->_recordsPerPage); if ($this->_request->getParam('filter', '') != 'reset') { if (count($this->_conditions) > 0) { foreach ($this->_conditions as $condition) { $field = trim($condition[0]); $field = $this->_modelProperties[$field]; $filter->addCondition($field, trim($condition[1]), trim($condition[2])); } } } $filter->setRequest($this->_request); $filter->setup('default'); } echo $this->view->listMenu($model, $id, $filter, $isLeftMenuHide); $this->view->content()->captureEnd(); $this->view->enabledListMenu = true; } } } } $moduleName = $this->_request->getModuleName(); $controllerName = $this->_request->getControllerName(); $actionName = $this->_request->getActionName(); $config = App_Config_Controller::getInstance()->getConfig($moduleName, $controllerName, $actionName); if (true != $config->isEmpty) { //$this->view->buttons = array(); $winlayout = $this->_request->getParam('layout', ''); foreach ($config->actionbuttons as $button) { switch ($button) { case 'print': $this->addPrintButton(); break; //case 'export' : $this->addExportButton(); // break; //case 'export' : $this->addExportButton(); // break; case 'new': $this->addNewButton(); break; case 'edit': $this->addEditButton(); break; case 'reset': $this->addResteFormButton(); break; case 'save': $this->addSaveButton(); break; case 'Back': if ($winlayout != 'popup') { $this->addCloseToIndexButton(); } break; case 'close': $this->addCloseButton(); break; case 'delete': $this->addDeleteButton(); break; } } } } $this->MyPostDispatch(); ob_end_clean(); }
function render(App_Grid_Filter $filter, $exportLayout, $page, $fileName) { $pdf = new mypdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->caption = $this->caption; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 048'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 048', PDF_HEADER_STRING); // set header and footer fonts //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(2, 0, 5); //$pdf->SetHeaderMargin(2); //$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings //$pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'B', 20); // add a page // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- $totalpage = $this->filter()->getTotalPage(); if ($page == 'all') { $startPage = 1; $endPage = $totalpage; } elseif (is_array($page)) { $startPage = (int) $page['0']; $endPage = (int) $page['1']; } elseif (is_numeric($page)) { $startPage = $endPage = (int) $page; } if ($startPage < 0) { $startPage = 1; } if ($endPage == '') { $endPage = $startPage; } if ($endPage > $totalpage) { $endPage = $totalpage; } for ($i = $startPage; $i <= $endPage; $i++) { $pdf->AddPage($exportLayout); $pdf->SetFont('freeserif', '', 7); $pdf->SetX(5); $pdf->SetY(10); $filter->setPage($i); $list = $filter->getList(); $tbl = $this->renderSimpleTable($filter, $list); $pdf->writeHTML($tbl, true, true, false, false, ''); } //Close and output PDF document if ('' == $fileName) { $fileName = uniqid(); } $filePath = App_Env::getPathOfUserTemporaryFolder() . "/" . $fileName . '.pdf'; $pdf->Output($filePath, 'F'); $pdf->Output(null, 'I'); //============================================================+ // END OF FILE //============================================================+ }
public function exportCsv(App_Grid_Filter $filter, $exportFileName) { $filter->setup(); $list = $filter->getList(); $this->render($list, $filter->getheaderTitles(), $filter->getFields(), $exportFileName); }
public function indexAction() { $this->view->gridParam = $this->_userparam; $this->view->gridRenderer = $this->_gridRenderer; //print_r($this->_modelProperties); $req = $this->getRequest(); $model = $this->getObject($this->_model); $filter = new App_Grid_Filter($model); $filter->setUiName($this->_uiConfig); if ($this->_gridSQL != '') { $filter->setSQL($this->_gridSQL); } $printMode = false; $this->view->printmode = false; if ($this->_request->getParam("print", '') != '') { $this->setPrintLayout(); $filter->disableAction(); $printMode = true; $this->view->printmode = true; } if ($this->_pdfClass != '' and class_exists($this->_pdfClass)) { $module = $this->_request->getModuleName(); $controller = $this->_request->getControllerName(); $this->addGridAction(array('action' => 'print', 'class' => 'btn-print-pdf', 'iconUrl' => '/images/icon/printer.png', 'tooltip' => 'พิมพ์รายละเอียด', 'onClickFunction' => "function(rowid,row,grid){\n \t\trow = \$(this).parent().parent();\n \t\tid = row.attr('id');\n \t\tvar link= '/{$module}/{$controller}/print/id/'+id;\n \t\topenPrintWindows(link,'print-pdf',450,600);\n }")); } //summayrow // print_r($this->_gridCellAligns); // $filter->addForm($this->_setForm($form)); $filter->setCellAligns($this->_gridCellAligns); // print_r($this->_summayFields); $filter->setSummayFields($this->_summayFields); //echo "269",$this->_gridSeparater; $filter->setSeparater($this->_gridSeparater); $filter->setGridWidth($this->_gridWidth); if ($this->_gridActionDisabled == true) { $filter->disableAction(); } $controller = $req->getControllerName(); $module = $req->getModuleName(); $resource = strtolower("{$module}:{$controller}"); $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'delete'); //echo ($isAllowed == true)? 'Y':'N'; //echo ($this->_disableDeleteButton == true)? 'DY':'DN'; if (!$this->_disableDeleteButton and $isAllowed) { $this->addGridAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE')); } if ($this->_gridActions) { $filter->setGridActions($this->_gridActions); } $filter->setView($this->view); if (count($this->_helperFunctions) > 0) { foreach ($this->_helperFunctions as $propKey => $helperName) { $filter->addHelperFunction($propKey, $helperName); } } if ($this->_section != '') { $filter->addCondition('secid', $this->_section); } if ($this->_catigory != '') { $filter->addCondition('catid', $this->_catigory); } if ($this->_request->getParam('filter', '') != 'reset') { if (count($this->_conditions) > 0) { foreach ($this->_conditions as $condition) { $field = trim($condition[0]); $field = $this->_modelProperties[$field]; $filter->addCondition($field, trim($condition[1]), trim($condition[2])); } } } if ($this->_gridHeaders != null) { $filter->setHeaderTitles($this->_gridHeaders); } $filter->setFields($this->_gridFields); $filter->setRowsWidth($this->_gridFieldWidth); $filter->setRequest($req); //echo $this->_sort; //if ($this->_sort != '') { //echo $this->_sort,$this->_direction ; $filter->setSortBy((int) $this->_sort); $filter->setDirection($this->_direction); //} $filter->setRecordsPerPage($this->_recordsPerPage); #view config //$controlname =$this->_translate($this->_request->getControllerName ()); //$modulename = $this->_translate( $this->_request->getModuleName() ); if ($this->_titleOfIndex != '') { $this->view->layout()->btitle = $this->_titleOfIndex; } if ($this->_subTitleOfIndex != '') { $this->view->layout()->subtitle = $this->_subTitleOfIndex; } $this->view->filter = $filter; if (!$printMode) { if ($this->_htmlTabs != null and ($this->_showTabsOnView == null or $this->_showTabsOnView == 'index')) { $this->view->htmlTabs = $this->_htmlTabs; } $buttons = $this->getButtons('index'); if ($this->_disableNewButton != true) { //button($action,$controller='',$label='', $id = '', $disabled = false, $title = '',$additionalClass='',$userParams=null,array $windowOptions = null) $url = $_SERVER['REQUEST_URI']; $uri_ep = explode("/", $_SERVER['REQUEST_URI']); $last = count($uri_ep) - 1; $uri_ep[$last] = 'new'; $url = join("/", $uri_ep); $buttons[] = $this->view->zbutton(array('action' => 'new-group-form', 'id' => 'AddButton', 'label' => 'Add', 'class' => 'new-button', 'params' => array('id' => $this->companyid), 'url' => $url, 'windowOptions' => array('width' => '500', 'height' => '500'))); //$buttons[]=$this->view->zbutton(array('action'=>'new','id'=>'NewButton',label=>'New','class'=>'new-button', // // //'onClickFunction'=>" onclick={location.href='$url'} ")); } $buttons2[] = $this->view->zbutton(array('action' => 'reload', 'label' => '', 'tooltip' => 'reload', 'params' => $this->_userparam, 'class' => 'refresh-zbutton')); $this->view->buttons = $buttons; } $this->view->layout()->actionbar = $this->view->actionbar3(null, $buttons2); $this->view->gridSelectedAction = $this->_gridSelectedAction; if ($this->_customsIndexView != '') { $this->render($this->_customsIndexView, null, false); } elseif ($this->_noIndexView == true) { $this->render('index', null, true); } }
public function renderSimpleTable(App_Grid_Filter $filter, array $list = null) { $columnConfig = $this->_columnConfig; $table = ''; if ($list == null) { $list = $filter->getList(); } $widths = $filter->getCalibateCellWidths(); $titles = $filter->getheaderTitles(); //print_r($titles); $tWidth = $filter->getTableWidth(); $view = $this->view; $gridwidth = $filter->getGridWidth(); $table .= '<table id="' . $this->_gridid . '" width="100%" style="width:100%" cellspacing="3" cellpadding="4" class="extensions" >'; $table .= "<thead><tr>"; $i = 0; foreach ($titles as $index => $title) { $width = $widths[$i]; $table .= '<th style=" width:' . $width . ';" >'; $table .= ucfirst(App_Util::splitByCaps($this->_translate($title))); $table .= '</th>'; ++$i; } $table .= "</tr></thead><tbody>"; if (is_array($list)) { foreach ($list as $id => $row) { $table .= "<tr>"; $fileds = $filter->getFields(); foreach ($fileds as $filed) { $align = in_array($columnConfig->fields[$filed]->align, App_Model_Config::$alignList) ? $columnConfig->fields[$filed]->align : 'left'; $filedValue = $this->filter()->fieldTranform($row, $filed); $table .= '<td style="text-align:' . $align . '" >' . $filedValue . '</td>'; } $table .= "</tr>"; } } else { $table .= $this->_getBlankRows(count($titles)); } $table .= '</tbody></table>'; return $table; }
function liteGridAction() { $this->disableLayout(); $this->view->gridParam = $this->_userparam; $this->view->gridRenderer = $this->_gridRenderer; //print_r($this->_modelProperties); $req = $this->getRequest(); $model = $this->getObject($this->_model); $filter = new App_Grid_Filter($model); $filter->setUiName($this->_uiConfig); if ($this->_gridSQL != '') { $filter->setSQL($this->_gridSQL); } $printMode = false; $this->view->printmode = false; if ($this->_request->getParam("print", '') != '') { $this->setPrintLayout(); $filter->disableAction(); $printMode = true; $this->view->printmode = true; } if ($this->_pdfClass != '' and class_exists($this->_pdfClass)) { $module = $this->_request->getModuleName(); $controller = $this->_request->getControllerName(); $this->addGridAction(array('action' => 'print', 'class' => 'btn-print-pdf', 'iconUrl' => '/images/icon/printer.png', 'tooltip' => 'พิมพ์รายละเอียด', 'onClickFunction' => "function(rowid,row,grid){\n \t\trow = \$(this).parent().parent();\n \t\tid = row.attr('id');\n \t\tvar link= '/{$module}/{$controller}/print/id/'+id;\n \t\topenPrintWindows(link,'print-pdf',450,600);\n }")); } //summayrow // print_r($this->_gridCellAligns); // $filter->addForm($this->_setForm($form)); $filter->setCellAligns($this->_gridCellAligns); // print_r($this->_summayFields); $filter->setSummayFields($this->_summayFields); //echo "269",$this->_gridSeparater; $filter->setSeparater($this->_gridSeparater); $filter->setGridWidth($this->_gridWidth); if ($this->_gridActionDisabled == true) { $filter->disableAction(); } $controller = $req->getControllerName(); $module = $req->getModuleName(); $resource = strtolower("{$module}:{$controller}"); $isAllowed = Sam_Acl::getInstance()->isAllowed($resource, 'delete'); //echo ($isAllowed == true)? 'Y':'N'; //echo ($this->_disableDeleteButton == true)? 'DY':'DN'; if (!$this->_disableDeleteButton and $isAllowed) { $this->addGridAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE')); } if ($this->_gridActions) { $filter->setGridActions($this->_gridActions); } $filter->setView($this->view); if (count($this->_helperFunctions) > 0) { foreach ($this->_helperFunctions as $propKey => $helperName) { $filter->addHelperFunction($propKey, $helperName); } } if (count($this->_conditions) > 0) { foreach ($this->_conditions as $condition) { $field = trim($condition[0]); $field = $this->_modelProperties[$field]; $filter->addCondition($field, trim($condition[1]), trim($condition[2])); } } if ($this->_gridHeaders != null) { $filter->setHeaderTitles($this->_gridHeaders); } $filter->setFields($this->_gridFields); $filter->setRowsWidth($this->_gridFieldWidth); $filter->setRequest($req); $filter->setSortBy((int) $this->_sort); $filter->setDirection($this->_direction); $filter->setRecordsPerPage($this->_recordsPerPage); $this->view->filter = $filter; $this->view->gridSelectedAction = $this->_gridSelectedAction; $this->render('ajaxgrid', null, true); }