Rev 14561 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** Exceptionalskudiscounts Controller** @property Exceptionalskudiscount $Exceptionalskudiscount* @property PaginatorComponent $Paginator*/class ExceptionalskudiscountsController extends AppController {/*** Components** @var array*/public $components = array('Paginator');public $apihost;public function beforeFilter() {parent::beforeFilter();//Configure::load('live');$this->apihost = Configure::read('pythonapihost');}/*** admin_index method** @return void*/public function admin_index() {$page = $this->request->query('page');if(!isset($page)){$page = 1;}$limit = Configure::read('admindashboardlimit');$offset = ($page - 1)*$limit;$url = $this->apihost."discountInfo/getAllExceptionalSkuDiscount/?limit=$limit&offset=$offset";$response = $this->make_request($url,null);$this->set('exceptionalskudiscounts', $response);$this->set('page',$page);}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_search() {$type = $this->request->query('type');$search = $this->request->query('search');$url = $this->apihost."Catalog/searchProducts/?class=SkuDiscountInfo&$type=$search";$response = $this->make_request($url,null);$this->set('exceptionalskudiscounts', $response);$this->set('page',1);$this->render('admin_index');}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$data = $this->request->data['Exceptionalskudiscount'];$url = $this->apihost."discountInfo/addExceptionalSkuDiscount";$url = $this->generateMultiUrl($url,$data);$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );$response = $this->make_request($url,$jsonVar);if (key($response)) {$this->Session->setFlash(current($response));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(current($response));}}}/*** admin_edit method** @throws NotFoundException* @param string $id* @return void*/public function admin_edit($id = null) {if (!$this->Exceptionalskudiscount->exists($id)) {throw new NotFoundException(__('Invalid exceptionalskudiscount'));}if ($this->request->is(array('post', 'put'))) {if ($this->Exceptionalskudiscount->save($this->request->data)) {$this->Session->setFlash(__('The exceptionalskudiscount has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The exceptionalskudiscount could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('Exceptionalskudiscount.' . $this->Exceptionalskudiscount->primaryKey => $id));$this->request->data = $this->Exceptionalskudiscount->find('first', $options);}}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$response = $this->remove($id,'SkuDiscountInfo');if ($response) {$this->Session->setFlash(current($response));} else {$this->Session->setFlash(current($response));}return $this->redirect(array('action' => 'index'));}}