Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
16614 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Appmasters Controller
5
 *
6
 * @property Appmaster $Appmaster
7
 * @property PaginatorComponent $Paginator
8
 */
9
class AppmastersController 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() {
16755 anikendra 24
		$type = $this->request->query('type');
25
		$search = $this->request->query('search');	
26
		$conditions = array();
27
		if(!empty($type) && !empty($search)){
28
			$conditions = array($type=>$search);
29
			$options['conditions'] = array($type.' LIKE ' =>"%$search%");			
30
			$this->Paginator->settings = $options;
31
		}
16614 anikendra 32
		$this->Appmaster->recursive = 0;
33
		$this->set('appmasters', $this->Paginator->paginate());
34
	}
35
 
36
/**
37
 * admin_view method
38
 *
39
 * @throws NotFoundException
40
 * @param string $id
41
 * @return void
42
 */
43
	public function admin_view($id = null) {
44
		if (!$this->Appmaster->exists($id)) {
45
			throw new NotFoundException(__('Invalid appmaster'));
46
		}
47
		$options = array('conditions' => array('Appmaster.' . $this->Appmaster->primaryKey => $id));
48
		$this->set('appmaster', $this->Appmaster->find('first', $options));
49
	}
50
 
51
/**
52
 * admin_add method
53
 *
54
 * @return void
55
 */
56
	public function admin_add() {
57
		if ($this->request->is('post')) {
58
			$this->Appmaster->create();
59
			if ($this->Appmaster->save($this->request->data)) {
60
				$this->Session->setFlash(__('The appmaster has been saved.'));
61
				return $this->redirect(array('action' => 'index'));
62
			} else {
63
				$this->Session->setFlash(__('The appmaster could not be saved. Please, try again.'));
64
			}
65
		}
66
	}
67
 
68
/**
69
 * admin_edit method
70
 *
71
 * @throws NotFoundException
72
 * @param string $id
73
 * @return void
74
 */
75
	public function admin_edit($id = null) {
76
		if (!$this->Appmaster->exists($id)) {
77
			throw new NotFoundException(__('Invalid appmaster'));
78
		}
79
		if ($this->request->is(array('post', 'put'))) {
80
			if ($this->Appmaster->save($this->request->data)) {
81
				$this->Session->setFlash(__('The appmaster has been saved.'));
82
				return $this->redirect(array('action' => 'index'));
83
			} else {
84
				$this->Session->setFlash(__('The appmaster could not be saved. Please, try again.'));
85
			}
86
		} else {
87
			$options = array('conditions' => array('Appmaster.' . $this->Appmaster->primaryKey => $id));
88
			$this->request->data = $this->Appmaster->find('first', $options);
89
		}
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->Appmaster->id = $id;
101
		if (!$this->Appmaster->exists()) {
102
			throw new NotFoundException(__('Invalid appmaster'));
103
		}
104
		$this->request->onlyAllow('post', 'delete');
105
		if ($this->Appmaster->delete()) {
106
			$this->Session->setFlash(__('The appmaster has been deleted.'));
107
		} else {
108
			$this->Session->setFlash(__('The appmaster could not be deleted. Please, try again.'));
109
		}
110
		return $this->redirect(array('action' => 'index'));
111
	}}