Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13637 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * StoreCashbacks Controller
5
 *
6
 * @property StoreCashback $StoreCashback
7
 * @property PaginatorComponent $Paginator
8
 */
9
class StoreCashbacksController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
/**
19
 * index method
20
 *
21
 * @return void
22
 */
23
	public function index() {
24
		$this->StoreCashback->recursive = 0;
25
		$this->set('storeCashbacks', $this->Paginator->paginate());
26
	}
27
 
28
/**
29
 * view method
30
 *
31
 * @throws NotFoundException
32
 * @param string $id
33
 * @return void
34
 */
35
	public function view($id = null) {
36
		if (!$this->StoreCashback->exists($id)) {
37
			throw new NotFoundException(__('Invalid store cashback'));
38
		}
39
		$options = array('conditions' => array('StoreCashback.' . $this->StoreCashback->primaryKey => $id));
40
		$this->set('storeCashback', $this->StoreCashback->find('first', $options));
41
	}
42
 
43
/**
44
 * add method
45
 *
46
 * @return void
47
 */
48
	public function add() {
49
		if ($this->request->is('post')) {
50
			$this->StoreCashback->create();
51
			if ($this->StoreCashback->save($this->request->data)) {
52
				$this->Session->setFlash(__('The store cashback has been saved.'));
53
				return $this->redirect(array('action' => 'index'));
54
			} else {
55
				$this->Session->setFlash(__('The store cashback could not be saved. Please, try again.'));
56
			}
57
		}
58
		$stores = $this->StoreCashback->Store->find('list');
59
		$categories = $this->StoreCashback->Category->find('list');
60
		$this->set(compact('stores', 'categories'));
61
	}
62
 
63
/**
64
 * edit method
65
 *
66
 * @throws NotFoundException
67
 * @param string $id
68
 * @return void
69
 */
70
	public function edit($id = null) {
71
		if (!$this->StoreCashback->exists($id)) {
72
			throw new NotFoundException(__('Invalid store cashback'));
73
		}
74
		if ($this->request->is(array('post', 'put'))) {
75
			if ($this->StoreCashback->save($this->request->data)) {
76
				$this->Session->setFlash(__('The store cashback has been saved.'));
77
				return $this->redirect(array('action' => 'index'));
78
			} else {
79
				$this->Session->setFlash(__('The store cashback could not be saved. Please, try again.'));
80
			}
81
		} else {
82
			$options = array('conditions' => array('StoreCashback.' . $this->StoreCashback->primaryKey => $id));
83
			$this->request->data = $this->StoreCashback->find('first', $options);
84
		}
85
		$stores = $this->StoreCashback->Store->find('list');
86
		$categories = $this->StoreCashback->Category->find('list');
87
		$this->set(compact('stores', 'categories'));
88
	}
89
 
90
/**
91
 * delete method
92
 *
93
 * @throws NotFoundException
94
 * @param string $id
95
 * @return void
96
 */
97
	public function delete($id = null) {
98
		$this->StoreCashback->id = $id;
99
		if (!$this->StoreCashback->exists()) {
100
			throw new NotFoundException(__('Invalid store cashback'));
101
		}
102
		$this->request->onlyAllow('post', 'delete');
103
		if ($this->StoreCashback->delete()) {
104
			$this->Session->setFlash(__('The store cashback has been deleted.'));
105
		} else {
106
			$this->Session->setFlash(__('The store cashback could not be deleted. Please, try again.'));
107
		}
108
		return $this->redirect(array('action' => 'index'));
109
	}
110
 
111
/**
112
 * admin_index method
113
 *
114
 * @return void
115
 */
116
	public function admin_index() {
117
		$this->StoreCashback->recursive = 0;
118
		$this->set('storeCashbacks', $this->Paginator->paginate());
119
	}
120
 
121
/**
122
 * admin_view method
123
 *
124
 * @throws NotFoundException
125
 * @param string $id
126
 * @return void
127
 */
128
	public function admin_view($id = null) {
129
		if (!$this->StoreCashback->exists($id)) {
130
			throw new NotFoundException(__('Invalid store cashback'));
131
		}
132
		$options = array('conditions' => array('StoreCashback.' . $this->StoreCashback->primaryKey => $id));
133
		$this->set('storeCashback', $this->StoreCashback->find('first', $options));
134
	}
135
 
136
/**
137
 * admin_add method
138
 *
139
 * @return void
140
 */
141
	public function admin_add() {
142
		if ($this->request->is('post')) {
143
			$this->StoreCashback->create();
144
			if ($this->StoreCashback->save($this->request->data)) {
145
				$this->Session->setFlash(__('The store cashback has been saved.'));
146
				return $this->redirect(array('action' => 'index'));
147
			} else {
148
				$this->Session->setFlash(__('The store cashback could not be saved. Please, try again.'));
149
			}
150
		}
151
		$stores = $this->StoreCashback->Store->find('list');
152
		$categories = $this->StoreCashback->Category->find('list');
153
		$this->set(compact('stores', 'categories'));
154
	}
155
 
156
/**
157
 * admin_edit method
158
 *
159
 * @throws NotFoundException
160
 * @param string $id
161
 * @return void
162
 */
163
	public function admin_edit($id = null) {
164
		if (!$this->StoreCashback->exists($id)) {
165
			throw new NotFoundException(__('Invalid store cashback'));
166
		}
167
		if ($this->request->is(array('post', 'put'))) {
168
			if ($this->StoreCashback->save($this->request->data)) {
169
				$this->Session->setFlash(__('The store cashback has been saved.'));
170
				return $this->redirect(array('action' => 'index'));
171
			} else {
172
				$this->Session->setFlash(__('The store cashback could not be saved. Please, try again.'));
173
			}
174
		} else {
175
			$options = array('conditions' => array('StoreCashback.' . $this->StoreCashback->primaryKey => $id));
176
			$this->request->data = $this->StoreCashback->find('first', $options);
177
		}
178
		$stores = $this->StoreCashback->Store->find('list');
179
		$categories = $this->StoreCashback->Category->find('list');
180
		$this->set(compact('stores', 'categories'));
181
	}
182
 
183
/**
184
 * admin_delete method
185
 *
186
 * @throws NotFoundException
187
 * @param string $id
188
 * @return void
189
 */
190
	public function admin_delete($id = null) {
191
		$this->StoreCashback->id = $id;
192
		if (!$this->StoreCashback->exists()) {
193
			throw new NotFoundException(__('Invalid store cashback'));
194
		}
195
		$this->request->onlyAllow('post', 'delete');
196
		if ($this->StoreCashback->delete()) {
197
			$this->Session->setFlash(__('The store cashback has been deleted.'));
198
		} else {
199
			$this->Session->setFlash(__('The store cashback could not be deleted. Please, try again.'));
200
		}
201
		return $this->redirect(array('action' => 'index'));
202
	}}