Exemplo n.º 1
0
 /**
  * Display a list of all option groups
  *
  * @return  void
  */
 public function displayTask()
 {
     $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->optionGroups('count', $this->view->filters);
     // Get records
     $this->view->rows = $obj->optionGroups('list', $this->view->filters);
     //print_r($this->view->rows); die;
     // For all records here get options
     $options = new \stdClass();
     $warehouse = new Warehouse();
     foreach ($this->view->rows as $r) {
         $key = $r->ogId;
         $allOptions = $warehouse->getOptionGroupOptions($key, 'rows', false);
         //print_r($allOptions); die;
         // Count how many active and how many inactive options there are
         $optionCounter = new \stdClass();
         $optionCounter->active = 0;
         $optionCounter->inactive = 0;
         foreach ($allOptions as $optionInfo) {
             if ($optionInfo->oActive) {
                 $optionCounter->active++;
             } else {
                 $optionCounter->inactive++;
             }
         }
         $options->{$key} = $optionCounter;
     }
     //print_r($options); die;
     $this->view->options = $options;
     // 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
 /**
  * Edit a category
  *
  * @return  void
  */
 public function editTask($row = null)
 {
     Request::setVar('hidemainmenu', 1);
     $obj = new Archive();
     // Get types
     $this->view->types = $obj->getProductTypes();
     // Get collections
     $this->view->collections = $obj->collections('list', array('sort' => 'cType'));
     // Get all option groups
     $this->view->optionGroups = $obj->optionGroups('list', array('sort' => 'ogName'));
     if (is_object($row)) {
         $id = $row->getId();
         $this->view->row = $row;
         $this->view->task = 'edit';
     } else {
         // Incoming
         $id = Request::getVar('id', array(0));
         if (is_array($id) && !empty($id)) {
             $id = $id[0];
         }
         // Load product
         $this->view->row = $obj->product($id);
     }
     // Get product option groups
     $this->view->productOptionGroups = $this->view->row->getOptionGroups();
     $this->view->config = $this->config;
     // Check if meta is needed for this product
     $pType = $this->view->row->getType();
     $this->view->metaNeeded = false;
     // Only software needs meta
     if ($pType == 30) {
         $this->view->metaNeeded = true;
     }
     // Get number of downloads
     $downloaded = CartDownload::countProductDownloads($id);
     $this->view->downloaded = $downloaded;
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }