File indexing completed on 2024-12-22 05:33:26

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class Backend_GhnsexcludedController extends Local_Controller_Action_Backend
0024 {
0025     const RESULT_OK = "OK";
0026     const RESULT_ERROR = "ERROR";
0027 
0028     /** @var Default_Model_DbTable_ProjectCategory */
0029     protected $_model;
0030 
0031     protected $_authMember;
0032 
0033     protected $_modelName = 'Default_Model_Project';
0034 
0035     public function init()
0036     {
0037         parent::init();
0038 
0039         $this->_model = new $this->_modelName();
0040 
0041         $this->view->pageTitle = 'Manage GHNS-Excluded Projects';
0042         $this->view->author = $this->_authMember->username;
0043     }
0044 
0045     public function indexAction()
0046     {
0047 
0048     }
0049 
0050     public function createAction()
0051     {
0052         
0053     }
0054 
0055     public function updateAction()
0056     {
0057         $jTableResult = array();
0058         try {
0059             $params = $this->getAllParams();
0060             $parent = 0;
0061 
0062             if (empty($params['project_category_id'])) {
0063                 $params['project_category_id'] = null;
0064             }
0065 
0066             $record = $this->_model->save($params);
0067 
0068             $jTableResult = array();
0069             $jTableResult['Result'] = self::RESULT_OK;
0070             $jTableResult['Record'] = $record->toArray();
0071         } catch (Exception $e) {
0072             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0073             $translate = Zend_Registry::get('Zend_Translate');
0074             $jTableResult['Result'] = self::RESULT_ERROR;
0075             $jTableResult['Message'] = $translate->_('Error while processing data.');
0076         }
0077 
0078         $this->_helper->json($jTableResult);
0079     }
0080 
0081     public function deleteAction()
0082     {
0083         
0084     }
0085 
0086     public function listAction()
0087     {
0088         $startIndex = (int)$this->getParam('jtStartIndex');
0089         $pageSize = (int)$this->getParam('jtPageSize');
0090         $sorting = $this->getParam('jtSorting');
0091         
0092         $records = $this->_model->fetchGhnsExcludedProjects();
0093 
0094         $pagination = Zend_Paginator::factory($records);
0095         $pagination->setItemCountPerPage($pageSize);
0096         $pagination->setCurrentPageNumber(($startIndex / $pageSize) + 1);
0097 
0098         $jTableResult = array();
0099         $jTableResult['Result'] = self::RESULT_OK;
0100         $jTableResult['Records'] = (array)$pagination->getCurrentItems();
0101         $jTableResult['TotalRecordCount'] = count($records);
0102 
0103         $this->_helper->json($jTableResult);
0104     }
0105 
0106 }