Exemplo n.º 1
0
 /**
  * Display a list of all categories
  *
  * @return  void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('access' => -1);
     $this->view->filters['sort'] = trim($app->getUserStateFromRequest($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'));
     $this->view->filters['sort_Dir'] = trim($app->getUserStateFromRequest($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
     // Get paging variables
     $this->view->filters['limit'] = $app->getUserStateFromRequest($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int');
     $this->view->filters['start'] = $app->getUserStateFromRequest($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int');
     //print_r($this->view->filters);
     $obj = new Archive();
     // Get record count
     $this->view->total = $obj->products('count', $this->view->filters);
     // Get records
     $this->view->rows = $obj->products('list', $this->view->filters);
     //print_r($this->view->rows); die;
     // Set any errors
     if ($this->getError()) {
         foreach ($this->getErrors() as $error) {
             $this->view->setError($error);
         }
     }
     // Output the HTML
     //print_r($this->view); die;
     $this->view->display();
 }
Exemplo n.º 2
0
 /**
  * Display a list of all categories
  *
  * @return  void
  */
 public function displayTask()
 {
     // Get filters
     $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'));
     $obj = new Archive();
     // Get record count
     $this->view->total = $obj->products('count', $this->view->filters);
     // Get records
     $this->view->rows = $obj->products('list', $this->view->filters);
     // For all records here get SKUs
     $skus = new \stdClass();
     $warehouse = new Warehouse();
     foreach ($this->view->rows as $r) {
         $key = $r->pId;
         $allSkus = $warehouse->getProductSkus($r->pId, 'all', false);
         // Count how many active and how many inactive SKUs there are
         $skuCounter = new \stdClass();
         $skuCounter->active = 0;
         $skuCounter->inactive = 0;
         foreach ($allSkus as $skuInfo) {
             if ($skuInfo->sActive) {
                 $skuCounter->active++;
             } else {
                 $skuCounter->inactive++;
             }
         }
         $skus->{$key} = $skuCounter;
     }
     $this->view->skus = $skus;
     // access groups
     $accessGroups = array();
     if ($this->config->get('productAccess')) {
         $ag = \Hubzero\Access\Group::all()->rows();
         $accessGroups[0] = 'None';
         foreach ($ag as $obj) {
             $accessGroups[$obj->get('id')] = $obj->get('title');
         }
     } else {
         $ag = Access::assetgroups();
         $accessGroups[0] = 'All';
         foreach ($ag as $obj) {
             $accessGroups[$obj->value] = $obj->text;
         }
     }
     $this->view->ag = $accessGroups;
     // Output the HTML
     $this->view->set('config', $this->config)->display();
 }