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
 * ProductCashbacks Controller
5
 *
6
 * @property ProductCashback $ProductCashback
7
 * @property PaginatorComponent $Paginator
8
 */
9
class ProductCashbacksController 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->ProductCashback->recursive = 0;
25
		$this->set('productCashbacks', $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->ProductCashback->exists($id)) {
37
			throw new NotFoundException(__('Invalid product cashback'));
38
		}
39
		$options = array('conditions' => array('ProductCashback.' . $this->ProductCashback->primaryKey => $id));
40
		$this->set('productCashback', $this->ProductCashback->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->ProductCashback->create();
51
			if ($this->ProductCashback->save($this->request->data)) {
52
				$this->Session->setFlash(__('The product cashback has been saved.'));
53
				return $this->redirect(array('action' => 'index'));
54
			} else {
55
				$this->Session->setFlash(__('The product cashback could not be saved. Please, try again.'));
56
			}
57
		}
58
		$stores = $this->ProductCashback->Store->find('list');
59
		$this->set(compact('stores'));
60
	}
61
 
62
/**
63
 * edit method
64
 *
65
 * @throws NotFoundException
66
 * @param string $id
67
 * @return void
68
 */
69
	public function edit($id = null) {
70
		if (!$this->ProductCashback->exists($id)) {
71
			throw new NotFoundException(__('Invalid product cashback'));
72
		}
73
		if ($this->request->is(array('post', 'put'))) {
74
			if ($this->ProductCashback->save($this->request->data)) {
75
				$this->Session->setFlash(__('The product cashback has been saved.'));
76
				return $this->redirect(array('action' => 'index'));
77
			} else {
78
				$this->Session->setFlash(__('The product cashback could not be saved. Please, try again.'));
79
			}
80
		} else {
81
			$options = array('conditions' => array('ProductCashback.' . $this->ProductCashback->primaryKey => $id));
82
			$this->request->data = $this->ProductCashback->find('first', $options);
83
		}
84
		$stores = $this->ProductCashback->Store->find('list');
85
		$this->set(compact('stores'));
86
	}
87
 
88
/**
89
 * delete method
90
 *
91
 * @throws NotFoundException
92
 * @param string $id
93
 * @return void
94
 */
95
	public function delete($id = null) {
96
		$this->ProductCashback->id = $id;
97
		if (!$this->ProductCashback->exists()) {
98
			throw new NotFoundException(__('Invalid product cashback'));
99
		}
100
		$this->request->onlyAllow('post', 'delete');
101
		if ($this->ProductCashback->delete()) {
102
			$this->Session->setFlash(__('The product cashback has been deleted.'));
103
		} else {
104
			$this->Session->setFlash(__('The product cashback could not be deleted. Please, try again.'));
105
		}
106
		return $this->redirect(array('action' => 'index'));
107
	}
108
 
109
/**
110
 * admin_index method
111
 *
112
 * @return void
113
 */
114
	public function admin_index() {
115
		$this->ProductCashback->recursive = 0;
116
		$this->set('productCashbacks', $this->Paginator->paginate());
117
	}
118
 
119
/**
120
 * admin_view method
121
 *
122
 * @throws NotFoundException
123
 * @param string $id
124
 * @return void
125
 */
126
	public function admin_view($id = null) {
127
		if (!$this->ProductCashback->exists($id)) {
128
			throw new NotFoundException(__('Invalid product cashback'));
129
		}
130
		$options = array('conditions' => array('ProductCashback.' . $this->ProductCashback->primaryKey => $id));
131
		$this->set('productCashback', $this->ProductCashback->find('first', $options));
132
	}
133
 
134
/**
135
 * admin_add method
136
 *
137
 * @return void
138
 */
139
	public function admin_add() {
140
		if ($this->request->is('post')) {
141
			$this->ProductCashback->create();
142
			if ($this->ProductCashback->save($this->request->data)) {
143
				$this->Session->setFlash(__('The product cashback has been saved.'));
144
				return $this->redirect(array('action' => 'index'));
145
			} else {
146
				$this->Session->setFlash(__('The product cashback could not be saved. Please, try again.'));
147
			}
148
		}
149
		$stores = $this->ProductCashback->Store->find('list');
150
		$this->set(compact('stores'));
151
	}
152
 
153
/**
154
 * admin_edit method
155
 *
156
 * @throws NotFoundException
157
 * @param string $id
158
 * @return void
159
 */
160
	public function admin_edit($id = null) {
161
		if (!$this->ProductCashback->exists($id)) {
162
			throw new NotFoundException(__('Invalid product cashback'));
163
		}
164
		if ($this->request->is(array('post', 'put'))) {
165
			if ($this->ProductCashback->save($this->request->data)) {
166
				$this->Session->setFlash(__('The product cashback has been saved.'));
167
				return $this->redirect(array('action' => 'index'));
168
			} else {
169
				$this->Session->setFlash(__('The product cashback could not be saved. Please, try again.'));
170
			}
171
		} else {
172
			$options = array('conditions' => array('ProductCashback.' . $this->ProductCashback->primaryKey => $id));
173
			$this->request->data = $this->ProductCashback->find('first', $options);
174
		}
175
		$stores = $this->ProductCashback->Store->find('list');
176
		$this->set(compact('stores'));
177
	}
178
 
179
/**
180
 * admin_delete method
181
 *
182
 * @throws NotFoundException
183
 * @param string $id
184
 * @return void
185
 */
186
	public function admin_delete($id = null) {
187
		$this->ProductCashback->id = $id;
188
		if (!$this->ProductCashback->exists()) {
189
			throw new NotFoundException(__('Invalid product cashback'));
190
		}
191
		$this->request->onlyAllow('post', 'delete');
192
		if ($this->ProductCashback->delete()) {
193
			$this->Session->setFlash(__('The product cashback has been deleted.'));
194
		} else {
195
			$this->Session->setFlash(__('The product cashback could not be deleted. Please, try again.'));
196
		}
197
		return $this->redirect(array('action' => 'index'));
198
	}}