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