Subversion Repositories SmartDukaan

Rev

Rev 13946 | Rev 14517 | 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
 */
48
	public function admin_view($id = null) {
49
		if (!$this->Exceptionalnlc->exists($id)) {
50
			throw new NotFoundException(__('Invalid exceptionalnlc'));
51
		}
52
		$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
53
		$this->set('exceptionalnlc', $this->Exceptionalnlc->find('first', $options));
54
	}
55
 
56
/**
57
 * admin_add method
58
 *
59
 * @return void
60
 */
61
	public function admin_add() {
62
		if ($this->request->is('post')) {
63
			$url = $this->apihost."exceptionalNlc/addExceptionalNlc";
64
			$jsonVar = json_encode($this->request->data['Exceptionalnlc'], JSON_NUMERIC_CHECK );
65
			$response = $this->make_request($url,$jsonVar);
66
			if (key($response)) {
67
				$this->Session->setFlash(current($response));
68
				return $this->redirect(array('action' => 'index'));
69
			} else {
70
				$this->Session->setFlash(current($response));
71
			}	
72
		}
73
	}
74
 
75
/**
76
 * admin_edit method
77
 *
78
 * @throws NotFoundException
79
 * @param string $id
80
 * @return void
81
 */
82
	public function admin_edit($id = null) {
83
		if (!$this->Exceptionalnlc->exists($id)) {
84
			throw new NotFoundException(__('Invalid exceptionalnlc'));
85
		}
86
		if ($this->request->is(array('post', 'put'))) {
87
			if ($this->Exceptionalnlc->save($this->request->data)) {
88
				$this->Session->setFlash(__('The exceptionalnlc has been saved.'));
89
				return $this->redirect(array('action' => 'index'));
90
			} else {
91
				$this->Session->setFlash(__('The exceptionalnlc could not be saved. Please, try again.'));
92
			}
93
		} else {
94
			$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
95
			$this->request->data = $this->Exceptionalnlc->find('first', $options);
96
		}
97
	}
98
 
99
/**
100
 * admin_delete method
101
 *
102
 * @throws NotFoundException
103
 * @param string $id
104
 * @return void
105
 */
106
	public function admin_delete($id = null) {
107
		$this->Exceptionalnlc->id = $id;
108
		if (!$this->Exceptionalnlc->exists()) {
109
			throw new NotFoundException(__('Invalid exceptionalnlc'));
110
		}
111
		$this->request->onlyAllow('post', 'delete');
112
		if ($this->Exceptionalnlc->delete()) {
113
			$this->Session->setFlash(__('The exceptionalnlc has been deleted.'));
114
		} else {
115
			$this->Session->setFlash(__('The exceptionalnlc could not be deleted. Please, try again.'));
116
		}
117
		return $this->redirect(array('action' => 'index'));
118
	}}