Rev 13646 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** Skuschemes Controller** @property Skuscheme $Skuscheme* @property PaginatorComponent $Paginator*/class SkuschemesController 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() {$url = $this->apihost."discountInfo/getAllSkuSchemeDetails";$response = $this->make_request($url,null);$this->set('skuschemes',$response);// $this->Skuscheme->recursive = 0;// $this->set('skuschemes', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_view($id = null) {if (!$this->Skuscheme->exists($id)) {throw new NotFoundException(__('Invalid skuscheme'));}$options = array('conditions' => array('Skuscheme.' . $this->Skuscheme->primaryKey => $id));$this->set('skuscheme', $this->Skuscheme->find('first', $options));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$url = $this->apihost."discountInfo/addSkuSchemeDetails";$jsonVar = json_encode($this->request->data['Skuscheme'], 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));}/*$this->Skuscheme->create();if ($this->Skuscheme->save($this->request->data)) {$this->Session->setFlash(__('The skuscheme has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The skuscheme could not be saved. Please, try again.'));}*/}}/*** admin_edit method** @throws NotFoundException* @param string $id* @return void*/public function admin_edit($id = null) {if (!$this->Skuscheme->exists($id)) {throw new NotFoundException(__('Invalid skuscheme'));}if ($this->request->is(array('post', 'put'))) {if ($this->Skuscheme->save($this->request->data)) {$this->Session->setFlash(__('The skuscheme has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The skuscheme could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('Skuscheme.' . $this->Skuscheme->primaryKey => $id));$this->request->data = $this->Skuscheme->find('first', $options);}}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->Skuscheme->id = $id;if (!$this->Skuscheme->exists()) {throw new NotFoundException(__('Invalid skuscheme'));}$this->request->onlyAllow('post', 'delete');if ($this->Skuscheme->delete()) {$this->Session->setFlash(__('The skuscheme has been deleted.'));} else {$this->Session->setFlash(__('The skuscheme could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}}