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(); }
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); } }
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); }