Subversion Repositories SmartDukaan

Rev

Rev 15226 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15219 manas 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Callhistories Controller
5
 *
6
 * @property Callhistory $Callhistory
7
 * @property PaginatorComponent $Paginator
8
 */
9
class CallhistoriesController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
/**
19
 * admin_index method
20
 *
21
 * @return void
22
 */
23
	public function admin_index() {
24
 
25
		$this->Callhistory->recursive = 0;
26
		$this->Paginator->settings = array('order' => array('id'=>'desc'));
27
		$this->set('callhistories', $this->Paginator->paginate());
28
	}
29
 
30
/**
31
 * admin_view method
32
 *
33
 * @throws NotFoundException
34
 * @param string $id
35
 * @return void
36
 */
37
	public function admin_view($id = null) {
38
		if (!$this->Callhistory->exists($id)) {
39
			throw new NotFoundException(__('Invalid callhistory'));
40
		}
41
		$options = array('conditions' => array('Callhistory.' . $this->Callhistory->primaryKey => $id));
42
		$this->set('callhistory', $this->Callhistory->find('first', $options));
43
	}
44
 
45
/**
46
 * admin_add method
47
 *
48
 * @return void
49
 */
50
	public function admin_add() {
51
		if ($this->request->is('post')) {
52
			$this->Callhistory->create();
53
			if ($this->Callhistory->save($this->request->data)) {
54
				$this->Session->setFlash(__('The callhistory has been saved.'));
55
				return $this->redirect(array('action' => 'index'));
56
			} else {
57
				$this->Session->setFlash(__('The callhistory could not be saved. Please, try again.'));
58
			}
59
		}
60
		$retailers = $this->Callhistory->Retailer->find('list');
61
		$agents = $this->Callhistory->Agent->find('list');
62
		$this->set(compact('retailers', 'agents'));
63
	}
64
 
65
/**
66
 * admin_edit method
67
 *
68
 * @throws NotFoundException
69
 * @param string $id
70
 * @return void
71
 */
72
	public function admin_edit($id = null) {
73
		if (!$this->Callhistory->exists($id)) {
74
			throw new NotFoundException(__('Invalid callhistory'));
75
		}
76
		if ($this->request->is(array('post', 'put'))) {
77
			if ($this->Callhistory->save($this->request->data)) {
78
				$this->Session->setFlash(__('The callhistory has been saved.'));
79
				return $this->redirect(array('action' => 'index'));
80
			} else {
81
				$this->Session->setFlash(__('The callhistory could not be saved. Please, try again.'));
82
			}
83
		} else {
84
			$options = array('conditions' => array('Callhistory.' . $this->Callhistory->primaryKey => $id));
85
			$this->request->data = $this->Callhistory->find('first', $options);
86
		}
87
		$retailers = $this->Callhistory->Retailer->find('list');
88
		$agents = $this->Callhistory->Agent->find('list');
89
		$this->set(compact('retailers', 'agents'));
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->Callhistory->id = $id;
101
		if (!$this->Callhistory->exists()) {
102
			throw new NotFoundException(__('Invalid callhistory'));
103
		}
104
		$this->request->onlyAllow('post', 'delete');
105
		if ($this->Callhistory->delete()) {
106
			$this->Session->setFlash(__('The callhistory has been deleted.'));
107
		} else {
108
			$this->Session->setFlash(__('The callhistory could not be deleted. Please, try again.'));
109
		}
110
		return $this->redirect(array('action' => 'index'));
111
	}}