Subversion Repositories SmartDukaan

Rev

Rev 14098 | Rev 14561 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13646 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Exceptionalnlcs Controller
5
 *
6
 * @property Exceptionalnlc $Exceptionalnlc
7
 * @property PaginatorComponent $Paginator
8
 */
9
class ExceptionalnlcsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
	public function beforeFilter() {
19
		parent::beforeFilter();
13946 anikendra 20
//		Configure::load('live');
13646 anikendra 21
		$this->apihost = Configure::read('pythonapihost');
22
	}
23
/**
24
 * admin_index method
25
 *
26
 * @return void
27
 */
28
	public function admin_index() {
14098 anikendra 29
		$page = $this->request->query('page');
30
		if(!isset($page)){
31
			$page = 1;
32
		}
33
		$limit = Configure::read('admindashboardlimit');
34
		$offset = ($page - 1)*$limit;
35
		$url = $this->apihost."exceptionalNlc/getExceptionalNlc/?limit=$limit&offset=$offset";
13646 anikendra 36
		$response = $this->make_request($url,null);
37
		$this->set('exceptionalnlcs', $response);
14098 anikendra 38
		$this->set('page',$page);
13646 anikendra 39
	}
40
 
41
/**
42
 * admin_view method
43
 *
44
 * @throws NotFoundException
45
 * @param string $id
46
 * @return void
47
 */
14517 anikendra 48
	public function admin_search() {
49
		$type = $this->request->query('type');
50
		$search = $this->request->query('search');				
51
		$url = $this->apihost."Catalog/searchProducts/?class=ExceptionalNlc&$type=$search";
52
		$response = $this->make_request($url,null);
53
		$this->set('exceptionalnlcs', $response);
54
		$this->set('page',1);
55
		$this->render('admin_index');
13646 anikendra 56
	}
57
 
58
/**
59
 * admin_add method
60
 *
61
 * @return void
62
 */
63
	public function admin_add() {
64
		if ($this->request->is('post')) {
65
			$url = $this->apihost."exceptionalNlc/addExceptionalNlc";
66
			$jsonVar = json_encode($this->request->data['Exceptionalnlc'], JSON_NUMERIC_CHECK );
67
			$response = $this->make_request($url,$jsonVar);
68
			if (key($response)) {
69
				$this->Session->setFlash(current($response));
70
				return $this->redirect(array('action' => 'index'));
71
			} else {
72
				$this->Session->setFlash(current($response));
73
			}	
74
		}
75
	}
76
 
77
/**
78
 * admin_edit method
79
 *
80
 * @throws NotFoundException
81
 * @param string $id
82
 * @return void
83
 */
84
	public function admin_edit($id = null) {
85
		if (!$this->Exceptionalnlc->exists($id)) {
86
			throw new NotFoundException(__('Invalid exceptionalnlc'));
87
		}
88
		if ($this->request->is(array('post', 'put'))) {
89
			if ($this->Exceptionalnlc->save($this->request->data)) {
90
				$this->Session->setFlash(__('The exceptionalnlc has been saved.'));
91
				return $this->redirect(array('action' => 'index'));
92
			} else {
93
				$this->Session->setFlash(__('The exceptionalnlc could not be saved. Please, try again.'));
94
			}
95
		} else {
96
			$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
97
			$this->request->data = $this->Exceptionalnlc->find('first', $options);
98
		}
99
	}
100
 
101
/**
102
 * admin_delete method
103
 *
104
 * @throws NotFoundException
105
 * @param string $id
106
 * @return void
107
 */
14517 anikendra 108
 
109
	public function admin_delete($id = null) {		
110
		if ($this->remove($id,'Exceptionalnlc')) {
111
			$this->Session->setFlash(__('The sku scheme deal has been deleted.'));
13646 anikendra 112
		} else {
14517 anikendra 113
			$this->Session->setFlash(__('The sku scheme could not be deleted. Please, try again.'));
13646 anikendra 114
		}
115
		return $this->redirect(array('action' => 'index'));
14517 anikendra 116
	}
117
}