File indexing completed on 2024-12-22 05:33:33
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 ProductcategoryController extends Local_Controller_Action_DomainSwitch 0024 { 0025 0026 const CATEGORY_ID = 'cat_id'; 0027 0028 public function init() 0029 { 0030 parent::init(); 0031 0032 $this->auth = Zend_Auth::getInstance(); 0033 } 0034 0035 public function fetchchildrenAction() 0036 { 0037 $this->_helper->layout->disableLayout(); 0038 $this->_helper->viewRenderer->setNoRender(true); 0039 0040 $identifier = $this->_request->getParam(self::CATEGORY_ID); 0041 0042 $tabCategories = new Default_Model_DbTable_ProjectCategory(); 0043 0044 if (is_array($identifier)) { 0045 $result_array = array(); 0046 foreach ($identifier as $element) { 0047 $result = $tabCategories->fetchImmediateChildren($element, $tabCategories::ORDERED_TITLE); 0048 $result_array = array_merge($result_array, $result); 0049 } 0050 $this->_helper->json($result_array); 0051 } else { 0052 $this->_helper->json($tabCategories->fetchImmediateChildren($identifier, $tabCategories::ORDERED_TITLE)); 0053 } 0054 } 0055 0056 public function fetchsourceneededAction() 0057 { 0058 $this->_helper->layout->disableLayout(); 0059 $this->_helper->viewRenderer->setNoRender(true); 0060 0061 $identifier = $this->_request->getParam(self::CATEGORY_ID); 0062 0063 $tabCategories = new Default_Model_DbTable_ProjectCategory(); 0064 0065 $this->_helper->json($tabCategories->findCategory($identifier)); 0066 0067 } 0068 0069 public function fetchcategoriesAction() 0070 { 0071 $this->_helper->layout->disableLayout(); 0072 $this->_helper->viewRenderer->setNoRender(true); 0073 0074 $tableCategories = new Default_Model_DbTable_ProjectCategory(); 0075 $categories = $tableCategories->fetchTree(true, false, 1); 0076 0077 $paginator = Zend_Paginator::factory($categories); 0078 $paginator->setItemCountPerPage(5); 0079 $paginator->setCurrentPageNumber(1); 0080 0081 $this->_helper->json((array)$paginator->getCurrentItems()); 0082 } 0083 0084 public function fetchcategoryproductsAction() 0085 { 0086 $this->_helper->layout->disableLayout(); 0087 $this->_helper->viewRenderer->setNoRender(true); 0088 0089 $identifier = $this->_request->getParam(self::CATEGORY_ID); 0090 0091 $tableProject = new Default_Model_Project(); 0092 $products = $tableProject->fetchProductsByCategory($identifier, 5); 0093 0094 0095 $this->_helper->json($products); 0096 } 0097 0098 }