Subversion Repositories SmartDukaan

Rev

Rev 15051 | Details | Compare with Previous | Last modification | View Log | RSS feed

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