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

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_PaypalvalidstatusController extends Local_Controller_Action_Backend
0024 {
0025 
0026     const RESULT_OK = "OK";
0027     const RESULT_ERROR = "ERROR";
0028     const DATA_ID_NAME = 'id';
0029 
0030     /** @var Default_Model_Member */
0031     protected $_model;
0032 
0033     protected $_modelName = 'Default_Model_DbTable_PaypalValidStatus';
0034     protected $_pageTitle = 'Manage Paypal-Valid-Stati';
0035 
0036     public function init()
0037     {
0038         $this->_model = new $this->_modelName();
0039 
0040         $this->view->pageTitle = $this->_pageTitle;
0041 
0042         parent::init();
0043     }
0044 
0045     public function indexAction()
0046     {
0047     }
0048 
0049     public function createAction()
0050     {
0051         $jTableResult = array();
0052         try {
0053             $newRow = $this->_model->createRow($this->getAllParams());
0054             $result = $newRow->save();
0055 
0056             $jTableResult['Result'] = self::RESULT_OK;
0057             $jTableResult['Record'] = $newRow->toArray();
0058         } catch (Exception $e) {
0059             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0060             $translate = Zend_Registry::get('Zend_Translate');
0061             $jTableResult['Result'] = self::RESULT_ERROR;
0062             $jTableResult['Message'] = $translate->_('Error while processing data.');
0063         }
0064 
0065         $this->_helper->json($jTableResult);
0066     }
0067 
0068     public function updateAction()
0069     {
0070         $jTableResult = array();
0071         try {
0072             $values = $this->getAllParams();
0073 
0074             foreach ($values as $key => $value) {
0075                 if ($value == '') {
0076                     $values[$key] = new Zend_Db_Expr('NULL');
0077                 }
0078             }
0079 
0080             $record = $this->_model->save($values);
0081 
0082             $jTableResult = array();
0083             $jTableResult['Result'] = self::RESULT_OK;
0084             $jTableResult['Record'] = $record->toArray();
0085         } catch (Exception $e) {
0086             Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true));
0087             $translate = Zend_Registry::get('Zend_Translate');
0088             $jTableResult['Result'] = self::RESULT_ERROR;
0089             $jTableResult['Message'] = $translate->_('Error while processing data.');
0090         }
0091 
0092         $this->_helper->json($jTableResult);
0093     }
0094 
0095     public function deleteAction()
0096     {
0097         $dataId = (int)$this->getParam(self::DATA_ID_NAME, null);
0098 
0099         $this->_model->setDeleted($id);
0100 
0101         $jTableResult = array();
0102         $jTableResult['Result'] = self::RESULT_OK;
0103 
0104         $this->_helper->json($jTableResult);
0105     }
0106 
0107     public function listAction()
0108     {
0109         $startIndex = (int)$this->getParam('jtStartIndex');
0110         $pageSize = (int)$this->getParam('jtPageSize');
0111         $sorting = $this->getParam('jtSorting');
0112 
0113         $select = $this->_model->select()->order($sorting)->limit($pageSize, $startIndex);
0114 
0115         $reports = $this->_model->fetchAll($select);
0116 
0117         $reportsAll = $this->_model->fetchAll($select->limit(null, null)->reset('columns')
0118                                                      ->columns(array('countAll' => new Zend_Db_Expr('count(*)'))));
0119 
0120         $jTableResult = array();
0121         $jTableResult['Result'] = self::RESULT_OK;
0122         $jTableResult['Records'] = $reports->toArray();
0123         $jTableResult['TotalRecordCount'] = $reportsAll->current()->countAll;
0124 
0125         $this->_helper->json($jTableResult);
0126     }
0127 
0128 }