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; }
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() { $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); } }
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 Table(App_Grid_Filter $filter, array $list = null) { $this->_gridid = $this->getGridId(); $this->_formid = $this->getFormId(); $req = Zend_Controller_Front::getInstance()->getRequest(); $this->_request = $req; if ($filter->isPrepared() != true) { $filter->setup(); } $module = $req->getModuleName(); $controller = $req->getControllerName(); $resource = strtolower("{$module}:{$controller}"); $isAllowedEdit = Sam_Acl::getInstance()->isAllowed($resource, "edit"); $isAllowedNew = Sam_Acl::getInstance()->isAllowed($resource, "new"); $isAllowedDelete = Sam_Acl::getInstance()->isAllowed($resource, "delete"); if ($filter->isPrepared() == true) { $filter->setRequest($req); if (isset($filter->getGridConfig()->pagination) and trim($filter->getGridConfig()->pagination) == 'false') { //echo 'enabledPagination '; $this->_enabledPagination = false; } if (isset($filter->getGridConfig()->newrowMethod) and trim($filter->getGridConfig()->newrowMethod) == 'blankrow') { $this->_enabledAddNewRowAction = true; } elseif ($filter->getGridConfig()->newrowMethod == 'dialog' or $filter->getGridConfig()->newrowMethod == 'OpenNewDialog') { $this->_enabledOpenNewDialogAction = true; } $this->_tableType = $filter->getGridConfig()->type; // แก้ใน global 1 ด้วย if (trim($filter->getGridConfig()->type) == self::TABLE_TYPE_EDITINLINE) { $this->_enabledInlineEdit = true; $this->_enabledRowOnClicAction = false; $this->_tableType = self::TABLE_TYPE_EDITINLINE; if (!$isAllowedEdit) { $this->_tableType = self::TABLE_TYPE_DEFAULT; $this->_enabledInlineEdit = false; } } if (isset($filter->getGridConfig()->scrollbar) and in_array($filter->getGridConfig()->scrollbar, array('false', 'disabled'))) { $this->_enabledScollbar = false; } if ($filter->getGridConfig()->onRowClickAction == 'false' or $filter->getGridConfig()->onRowClickAction == 'disabled') { $this->_enabledRowOnClicAction = false; } if (true == $filter->isDeleteButtonDisabled() or false == $isAllowedDelete) { $this->_enabledDeleteAction = false; } if (true == $filter->isEditButtonDisabled()) { $this->_enabledEditIconOnClicAction = false; } else { $this->_enabledEditIconOnClicAction = true; $this->_openEditFormIn = trim($filter->getGridConfig()->editMethod) != '' ? $filter->getGridConfig()->editMethod : $this->_openEditFormIn; } // if(true ==$this->_enabledInlineEdit ){ // $this->_enabledEditIconOnClicAction =false; // } } if ($isAllowedNew) { if ($this->_enabledAddNewRowAction) { $this->addButonOnActionBar('addBlankRecord', array('class' => 'ui-icon-circle-plus', 'text' => 'New', 'width' => '100px')); } if ($this->_enabledOpenNewDialogAction) { $this->addButonOnActionBar('btnOpenNewDialog', array('class' => 'ui-icon-circle-plus', 'text' => 'New', 'width' => '100px')); } } if ($this->_enabledInlineEdit) { $this->addButonOnActionBar('btnSaveGrid', array('class' => 'ui-icon-disk', 'text' => 'Save', 'width' => '100px')); } $ui = $filter->getUiName(); $this->_modelName = $filter->getModelName(); if ($this->_tableType == self::TABLE_TYPE_TREETABLE) { $this->_tablebodyClass = " "; } // Add Action Button // เพิ่มปุ่ม edit กดแล้วไปหน้า edit เลย if ($this->_enabledEditIconOnClicAction == true and $isAllowedEdit == true) { $filter->addAction(array('action' => 'edit', 'iconUrl' => '/images/grid/edit.png', 'class' => 'IMG_ROW_EDIT')); //$filter->setGridActions($actions); $this->_enabledEditIconOnClicAction = true; } //เพิ่มปุ่ม delete if (true == $this->_enabledDeleteAction and true == $isAllowedDelete) { $filter->addAction(array('action' => 'delete', 'iconUrl' => '/images/grid/publish_x.png', 'class' => 'IMGDELETE')); } $tableConfig = $this->getTableConfig($this->_modelName, $ui); $this->_columnConfig = $tableConfig; $this->_modelConfig = $this->getModelConfig($this->_modelName); if ($list == null) { if ($this->_tableType == self::TABLE_TYPE_TREETABLE) { $list = $filter->getTreeList(); } else { $list = $filter->getList(); } } $this->_filter = $filter; if ($this->filter()->isActionDisabled()) { $this->_printMode = true; $x = $this->renderSimpleTable($filter, $list); } else { $x = $this->redertable($filter, $list); } return $x; }
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); }