Subversion Repositories SmartDukaan

Rev

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

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