Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public function exportCsv(App_Grid_Filter $filter, $exportFileName)
 {
     $filter->setup();
     $list = $filter->getList();
     $this->render($list, $filter->getheaderTitles(), $filter->getFields(), $exportFileName);
 }
Ejemplo n.º 4
0
 /**
  * @return App_Grid_Filter
  * Enter description here ...
  */
 public function _getfilter()
 {
     $req = $this->getRequest();
     $model = $this->getObject($this->_model);
     $filter = new App_Grid_Filter($model);
     if ($this->_gridSQL != '') {
         $filter->setSQL($this->_gridSQL);
     }
     $filter->setView($this->view);
     if ($this->_gridPreparation == true) {
         $filter->setup($this->_uiConfig);
     } else {
         /** manul **/
         if ('' != trim($this->_uiConfig)) {
             $filter->setUiName($this->_uiConfig);
         }
         if (isset($this->_gridCellAligns)) {
             $filter->setCellAligns($this->_gridCellAligns);
         }
         if (isset($this->_summayFields)) {
             $filter->setSummayFields($this->_summayFields);
         }
         if ('' != trim($this->_gridSeparater)) {
             $filter->setSeparater($this->_gridSeparater);
         }
         if ('' != trim($this->_gridWidth)) {
             $filter->setGridWidth($this->_gridWidth);
         }
         if ('' != trim($this->_sort)) {
             $filter->setSortBy((int) $this->_sort);
         }
         if ('' != trim($this->_direction)) {
             $filter->setDirection($this->_direction);
         }
         if ('' != trim($this->_recordsPerPage)) {
             $filter->setRecordsPerPage($this->_recordsPerPage);
         }
         if (isset($this->_gridFields)) {
             $filter->setFields($this->_gridFields);
         }
         if (isset($this->_gridFieldWidth)) {
             $filter->setRowsWidth($this->_gridFieldWidth);
         }
         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);
         }
         /** END Manul **/
     }
     $filter->setView($this->view);
     if ($this->_gridActionDisabled == true) {
         $filter->disableAction();
     }
     if ($this->_gridHeaders != null) {
         $filter->setHeaderTitles($this->_gridHeaders);
     }
     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]));
             }
         }
     }
     return $filter;
 }