Subversion Repositories SmartDukaan

Rev

Rev 13946 | Go to most recent revision | Details | 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();
20
		Configure::load('live');
21
		$this->apihost = Configure::read('pythonapihost');
22
	}
23
/**
24
 * admin_index method
25
 *
26
 * @return void
27
 */
28
	public function admin_index() {
29
		$url = $this->apihost."exceptionalNlc/getExceptionalNlc";
30
		$response = $this->make_request($url,null);
31
		$this->set('exceptionalnlcs', $response);
32
	}
33
 
34
/**
35
 * admin_view method
36
 *
37
 * @throws NotFoundException
38
 * @param string $id
39
 * @return void
40
 */
41
	public function admin_view($id = null) {
42
		if (!$this->Exceptionalnlc->exists($id)) {
43
			throw new NotFoundException(__('Invalid exceptionalnlc'));
44
		}
45
		$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
46
		$this->set('exceptionalnlc', $this->Exceptionalnlc->find('first', $options));
47
	}
48
 
49
/**
50
 * admin_add method
51
 *
52
 * @return void
53
 */
54
	public function admin_add() {
55
		if ($this->request->is('post')) {
56
			$url = $this->apihost."exceptionalNlc/addExceptionalNlc";
57
			$jsonVar = json_encode($this->request->data['Exceptionalnlc'], JSON_NUMERIC_CHECK );
58
			$response = $this->make_request($url,$jsonVar);
59
			if (key($response)) {
60
				$this->Session->setFlash(current($response));
61
				return $this->redirect(array('action' => 'index'));
62
			} else {
63
				$this->Session->setFlash(current($response));
64
			}	
65
		}
66
	}
67
 
68
/**
69
 * admin_edit method
70
 *
71
 * @throws NotFoundException
72
 * @param string $id
73
 * @return void
74
 */
75
	public function admin_edit($id = null) {
76
		if (!$this->Exceptionalnlc->exists($id)) {
77
			throw new NotFoundException(__('Invalid exceptionalnlc'));
78
		}
79
		if ($this->request->is(array('post', 'put'))) {
80
			if ($this->Exceptionalnlc->save($this->request->data)) {
81
				$this->Session->setFlash(__('The exceptionalnlc has been saved.'));
82
				return $this->redirect(array('action' => 'index'));
83
			} else {
84
				$this->Session->setFlash(__('The exceptionalnlc could not be saved. Please, try again.'));
85
			}
86
		} else {
87
			$options = array('conditions' => array('Exceptionalnlc.' . $this->Exceptionalnlc->primaryKey => $id));
88
			$this->request->data = $this->Exceptionalnlc->find('first', $options);
89
		}
90
	}
91
 
92
/**
93
 * admin_delete method
94
 *
95
 * @throws NotFoundException
96
 * @param string $id
97
 * @return void
98
 */
99
	public function admin_delete($id = null) {
100
		$this->Exceptionalnlc->id = $id;
101
		if (!$this->Exceptionalnlc->exists()) {
102
			throw new NotFoundException(__('Invalid exceptionalnlc'));
103
		}
104
		$this->request->onlyAllow('post', 'delete');
105
		if ($this->Exceptionalnlc->delete()) {
106
			$this->Session->setFlash(__('The exceptionalnlc has been deleted.'));
107
		} else {
108
			$this->Session->setFlash(__('The exceptionalnlc could not be deleted. Please, try again.'));
109
		}
110
		return $this->redirect(array('action' => 'index'));
111
	}}