Example #1
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $model = new Sp4kModulesProductModelsItem(new Joomla\Registry\Registry($jsonInput->getArray()));
         $model->execute();
         //initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false) !== false) {
             $model = new Sp4kModulesProductModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $model->execute();
             $model->item->config = $model->item->config;
             $response = $model->item;
         } else {
             $limit = $this->input->get('limit', false, 'RAW');
             $filters = $this->input->get('filters', false, 'RAW');
             $limit = $limit ? json_decode($limit) : null;
             $filters = $filters ? json_decode($filters) : null;
             $paging = $this->input->getBool('paging', false);
             $count = $this->input->getBool('count', false);
             $nest = $this->input->getWord('nest', false);
             $plugins = $this->input->getWord('plugins', false);
             $model = new Sp4kModulesProductModelsItems(new Joomla\Registry\Registry(['limit' => $limit, 'filters' => $filters, 'paging' => $paging, 'count' => $count, 'nest' => $nest, 'plugins' => $plugins]));
             $response = $model->items;
         }
     }
     echo json_encode($response);
 }
Example #2
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $model = new Sp4kModulesOrderModelsItem(new Joomla\Registry\Registry($jsonInput->getArray()));
         $model->execute();
         //initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false) !== false) {
             $model = new Sp4kModulesOrderModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $model->execute();
             $response = $model->item;
         } else {
             $limit = $this->input->get('limit', false, 'RAW');
             $filters = $this->input->get('filters', false, 'RAW');
             $paging = $this->input->getBool('paging', false);
             $count = $this->input->getBool('count', false);
             $limit = $limit ? json_decode($limit) : null;
             $filters = $filters ? json_decode($filters) : null;
             $joins = false;
             if (isset($filters->orderTotal)) {
                 if (!isset($filters->orderTotal->min) && isset($filters->orderTotal->max)) {
                     $filters->total = ['operator' => ' <= ', 'value' => $filters->orderTotal->max, 'skipquote' => true];
                 } elseif (isset($filters->orderTotal->min) && !isset($filters->orderTotal->max)) {
                     $filters->total = ['operator' => ' >= ', 'value' => $filters->orderTotal->min, 'skipquote' => true];
                 } elseif (isset($filters->orderTotal->min) && isset($filters->orderTotal->max)) {
                     $filters->total = ['operator' => ' BETWEEN ', 'value' => (int) $filters->orderTotal->min . ' AND ' . (int) $filters->orderTotal->max, 'skipquote' => true];
                 }
                 unset($filters->orderTotal);
             }
             if (isset($filters->orderDate)) {
                 if (!isset($filters->orderDate->min) && isset($filters->orderDate->max) && $filters->orderDate->max > 0) {
                     $filters->created = ['operator' => ' <= ', 'value' => $filters->orderDate->max, 'skipquote' => true];
                 } elseif (isset($filters->orderDate->min) && !isset($filters->orderDate->max)) {
                     $filters->created = ['operator' => ' >= ', 'value' => $filters->orderDate->max, 'skipquote' => true];
                 } elseif (isset($filters->orderDate->min) && isset($filters->orderDate->max) && $filters->orderDate->max > 0) {
                     $filters->created = ['operator' => ' BETWEEN ', 'value' => (int) $filters->orderDate->min . ' AND ' . (int) $filters->orderDate->max, 'skipquote' => true];
                 }
                 unset($filters->orderDate);
             }
             if (isset($filters->parent_id)) {
                 $joins[] = ['type' => 'inner', 'condition' => '#__sp4k_parent_items as p on p.account_id = order.account_id'];
                 $filters->id = ['value' => $filters->parent_id, 'alias' => 'p'];
                 unset($filters->parent_id);
             }
             $model = new Sp4kModulesOrderModelsItems(new Joomla\Registry\Registry(['limit' => $limit, 'filters' => $filters, 'paging' => $paging, 'count' => $count, 'joins' => $joins]));
             if ($count) {
                 $response = [];
                 $response['items'] = $model->items;
                 $response['count'] = $model->count;
             } else {
                 $response = $model->items;
             }
         }
     }
     echo json_encode($response);
 }
Example #3
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $model = new Sp4kModulesCoachModelsItem(new Joomla\Registry\Registry($jsonInput->getArray()));
         $model->execute();
         //initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false) !== false) {
             $model = new Sp4kModulesCoachModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $model->execute();
             $response = $model->item;
         } else {
             $limit = $this->input->get('limit', false, 'RAW');
             $filters = $this->input->get('filters', false, 'RAW');
             $paging = $this->input->getBool('paging', false);
             $count = $this->input->getBool('count', false);
             $limit = $limit ? json_decode($limit) : null;
             $filters = $filters ? json_decode($filters) : null;
             $joins = false;
             foreach ($filters as $index => $value) {
                 if ($value === 'any') {
                     unset($filters->{$index});
                 }
             }
             if (isset($filters->driving)) {
                 //$filters->driving = (int)$filters->driving; //cast to integer
             }
             if (isset($filters->doftw)) {
                 foreach ($filters->doftw as $doftw) {
                     $filters->{$doftw} = 1;
                 }
                 unset($filters->doftw);
             }
             if (isset($filters->role)) {
                 if (count($filters->role) > 0) {
                     $roleFilter = ['operator' => ' IN ', 'value' => '(' . implode(',', $filters->role) . ')'];
                     $filters->role = $roleFilter;
                 } else {
                     unset($filters->role);
                 }
             }
             $model = new Sp4kModulesCoachModelsItems(new Joomla\Registry\Registry(['limit' => $limit, 'filters' => $filters, 'paging' => $paging, 'count' => $count, 'joins' => $joins]));
             if ($count) {
                 $response = [];
                 $response['items'] = $model->items;
                 $response['count'] = $model->count;
             } else {
                 $response = $model->items;
             }
         }
     }
     echo json_encode($response);
 }
Example #4
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $model = new Sp4kModulesAccountModelsItem(new Joomla\Registry\Registry($jsonInput->getArray()));
         $model->execute();
         //initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false) !== false) {
             $model = new Sp4kModulesAccountModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $model->execute();
             $response = $model->item;
         } else {
             $limit = $this->input->get('limit', false, 'RAW');
             $limit = $limit ? json_decode($limit) : null;
             $filters = $this->input->get('filters', false, 'RAW');
             $filters = $filters ? json_decode($filters) : null;
             $paging = $this->input->getBool('paging', false);
             $count = $this->input->getBool('count', false);
             $joins = false;
             if (isset($filters->parent_id)) {
                 $joins[] = ['type' => 'inner', 'condition' => '#__sp4k_parent_items as p on p.account_id = account.id'];
                 $filters->id = ['value' => $filters->parent_id, 'alias' => 'p'];
                 unset($filters->parent_id);
             }
             if (isset($filters->child_id)) {
                 $joins[] = ['type' => 'inner', 'condition' => '#__sp4k_child_items as c on c.account_id = account.id'];
                 $filters->id = ['value' => $filters->child_id, 'alias' => 'c'];
                 unset($filters->child_id);
             }
             $model = new Sp4kModulesAccountModelsItems(new Joomla\Registry\Registry(['limit' => $limit, 'filters' => $filters, 'paging' => $paging, 'count' => $count, 'joins' => $joins]));
             if ($count) {
                 $response = [];
                 $response['items'] = $model->items;
                 $response['count'] = $model->count;
             } else {
                 $response = $model->items;
             }
         }
     }
     echo json_encode($response);
 }
Example #5
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $postdata = $jsonInput->getArray();
         $model = new Sp4kModulesEventModelsItem(new Joomla\Registry\Registry($postdata));
         //$model->execute();//initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false)) {
             $model = new Sp4kModulesEventModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $response = $model->item;
         } else {
             $model = new Sp4kModulesEventModelsItems(new Joomla\Registry\Registry($this->input->getArray()));
             $response = $model->items;
         }
     }
     echo json_encode($response);
 }
Example #6
0
 public function execute()
 {
     if ($this->input->getMethod() == 'POST') {
         $jsonInput = new JInputJSON();
         $postdata = $jsonInput->getArray();
         $model = new Sp4kModulesChildModelsItem(new Joomla\Registry\Registry($postdata));
         //$model->execute();//initialize the model with the data we've injected
         $model->update();
         $response = $model->item;
     } elseif ($this->input->getMethod() == 'GET') {
         if ($this->input->get('id', false) !== false) {
             $model = new Sp4kModulesChildModelsItem(new Joomla\Registry\Registry($this->input->getArray()));
             $response = $model->item;
         } else {
             if ($q = $this->input->get('q', false, 'RAW')) {
                 $stateVars = ['limit' => $this->input->get('limit', false, 'RAW'), 'paging' => $this->input->getBool('paging', false), 'count' => $this->input->getBool('count', false), 'q' => json_decode($q)];
                 $state = new Joomla\Registry\Registry($stateVars);
             } else {
                 $limit = $this->input->get('limit', false, 'RAW');
                 $filters = $this->input->get('filters', false, 'RAW');
                 $paging = $this->input->getBool('paging', false);
                 $count = $this->input->getBool('count', false);
                 $limit = $limit ? json_decode($limit) : null;
                 $filters = $filters ? json_decode($filters) : null;
                 $state = new Joomla\Registry\Registry(['limit' => $limit, 'filters' => $filters, 'paging' => $paging, 'count' => $count]);
             }
             $model = new Sp4kModulesChildModelsItems($state);
             if ($count) {
                 $response = [];
                 $response['items'] = $model->items;
                 $response['count'] = $model->count;
             } else {
                 $response = $model->items;
             }
         }
     }
     echo json_encode($response);
 }