Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15034 manas 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * SaholicLogs Controller
5
 *
6
 * @property SaholicLog $SaholicLog
7
 * @property PaginatorComponent $Paginator
8
 */
9
class SaholicLogsController 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->SaholicLog->recursive = 0;
25
		$this->set('saholicLogs', $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->SaholicLog->exists($id)) {
37
			throw new NotFoundException(__('Invalid saholic log'));
38
		}
39
		$options = array('conditions' => array('SaholicLog.' . $this->SaholicLog->primaryKey => $id));
40
		$this->set('saholicLog', $this->SaholicLog->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->SaholicLog->create();
51
			if ($this->SaholicLog->save($this->request->data)) {
52
				$this->Session->setFlash(__('The saholic log has been saved.'));
53
				return $this->redirect(array('action' => 'index'));
54
			} else {
55
				$this->Session->setFlash(__('The saholic log could not be saved. Please, try again.'));
56
			}
57
		}
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->SaholicLog->exists($id)) {
69
			throw new NotFoundException(__('Invalid saholic log'));
70
		}
71
		if ($this->request->is(array('post', 'put'))) {
72
			if ($this->SaholicLog->save($this->request->data)) {
73
				$this->Session->setFlash(__('The saholic log has been saved.'));
74
				return $this->redirect(array('action' => 'index'));
75
			} else {
76
				$this->Session->setFlash(__('The saholic log could not be saved. Please, try again.'));
77
			}
78
		} else {
79
			$options = array('conditions' => array('SaholicLog.' . $this->SaholicLog->primaryKey => $id));
80
			$this->request->data = $this->SaholicLog->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->SaholicLog->id = $id;
93
		if (!$this->SaholicLog->exists()) {
94
			throw new NotFoundException(__('Invalid saholic log'));
95
		}
96
		$this->request->onlyAllow('post', 'delete');
97
		if ($this->SaholicLog->delete()) {
98
			$this->Session->setFlash(__('The saholic log has been deleted.'));
99
		} else {
100
			$this->Session->setFlash(__('The saholic log 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->SaholicLog->recursive = 0;
112
		$this->Paginator->settings = array('order' => array('id'=>'desc'));
113
		$vari = $this->Paginator->paginate();
114
		$this->set('saholicLogs', $vari);
115
	}
116
 
117
/**
118
 * admin_view method
119
 *
120
 * @throws NotFoundException
121
 * @param string $id
122
 * @return void
123
 */
124
	public function admin_view($id = null) {
125
		if (!$this->SaholicLog->exists($id)) {
126
			throw new NotFoundException(__('Invalid saholic log'));
127
		}
128
		$options = array('conditions' => array('SaholicLog.' . $this->SaholicLog->primaryKey => $id));
129
		$this->set('saholicLog', $this->SaholicLog->find('first', $options));
130
	}
131
 
132
/**
133
 * admin_add method
134
 *
135
 * @return void
136
 */
137
	public function admin_add() {
138
		if ($this->request->is('post')) {
139
			$this->SaholicLog->create();
140
			if ($this->SaholicLog->save($this->request->data)) {
141
				$this->Session->setFlash(__('The saholic log has been saved.'));
142
				return $this->redirect(array('action' => 'index'));
143
			} else {
144
				$this->Session->setFlash(__('The saholic log could not be saved. Please, try again.'));
145
			}
146
		}
147
	}
148
 
149
/**
150
 * admin_edit method
151
 *
152
 * @throws NotFoundException
153
 * @param string $id
154
 * @return void
155
 */
156
	public function admin_edit($id = null) {
157
		if (!$this->SaholicLog->exists($id)) {
158
			throw new NotFoundException(__('Invalid saholic log'));
159
		}
160
		if ($this->request->is(array('post', 'put'))) {
161
			if ($this->SaholicLog->save($this->request->data)) {
162
				$this->Session->setFlash(__('The saholic log has been saved.'));
163
				return $this->redirect(array('action' => 'index'));
164
			} else {
165
				$this->Session->setFlash(__('The saholic log could not be saved. Please, try again.'));
166
			}
167
		} else {
168
			$options = array('conditions' => array('SaholicLog.' . $this->SaholicLog->primaryKey => $id));
169
			$this->request->data = $this->SaholicLog->find('first', $options);
170
		}
171
	}
172
 
173
/**
174
 * admin_delete method
175
 *
176
 * @throws NotFoundException
177
 * @param string $id
178
 * @return void
179
 */
180
	public function admin_delete($id = null) {
181
		$this->SaholicLog->id = $id;
182
		if (!$this->SaholicLog->exists()) {
183
			throw new NotFoundException(__('Invalid saholic log'));
184
		}
185
		$this->request->onlyAllow('post', 'delete');
186
		if ($this->SaholicLog->delete()) {
187
			$this->Session->setFlash(__('The saholic log has been deleted.'));
188
		} else {
189
			$this->Session->setFlash(__('The saholic log could not be deleted. Please, try again.'));
190
		}
191
		return $this->redirect(array('action' => 'index'));
192
	}
193
 
194
	public function admin_show($id=null){
195
		// $sqlQuery = "SELECT html FROM saholic_logs where id=$id" ;
196
		// $resul=$this->SaholicLog->query($sqlQuery);
197
		$this->set('id', $id);
198
	}
199
 
200
	public function admin_html($id=null){
201
		// $sqlQuery = "SELECT html FROM saholic_logs where id=$id" ;
202
		// $result=$this->SaholicLog->query($sqlQuery);
203
		$result = $this->SaholicLog->findById($id);
204
		$this->layout = 'ajax';
205
		$this->set('result', $result);
206
	}
207
}