Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
13591 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Mobileappsettings Controller
5
 *
6
 * @property Mobileappsetting $Mobileappsetting
7
 * @property PaginatorComponent $Paginator
8
 */
9
class MobileappsettingsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
13593 anikendra 18
	public function index() {	
19
		$this->layout = 'ajax';
14662 anikendra 20
		$t = $this->request->query('t');
21
		if(!empty($t) && $t >0){
22
			$options = array('conditions'=>array("unix_timestamp(modified) > "=>$t));
23
		}else{
24
			$options = null;
25
		}
26
		$settings = $this->Mobileappsetting->find('all',$options);
27
		$options = array('fields'=>array("unix_timestamp(modified) t"),'order'=>array('modified'=>'desc'));
28
		$lasttimestamp = $this->Mobileappsetting->find('first',$options);		
29
		$result = array('settings' => $settings,'t'=>$lasttimestamp[0]['t']);
13593 anikendra 30
		$this->set(array(
31
		    'result' => $result,
32
		    '_serialize' => array('result')
33
		));
34
		$this->render('/Elements/json');
35
	}
13591 anikendra 36
/**
37
 * admin_index method
38
 *
39
 * @return void
40
 */
41
	public function admin_index() {
42
		$this->Mobileappsetting->recursive = 0;
43
		$this->set('mobileappsettings', $this->Paginator->paginate());
44
	}
45
 
46
/**
47
 * admin_view method
48
 *
49
 * @throws NotFoundException
50
 * @param string $id
51
 * @return void
52
 */
53
	public function admin_view($id = null) {
54
		if (!$this->Mobileappsetting->exists($id)) {
55
			throw new NotFoundException(__('Invalid mobileappsetting'));
56
		}
57
		$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
58
		$this->set('mobileappsetting', $this->Mobileappsetting->find('first', $options));
59
	}
60
 
61
/**
62
 * admin_add method
63
 *
64
 * @return void
65
 */
66
	public function admin_add() {
67
		if ($this->request->is('post')) {
68
			$this->Mobileappsetting->create();
69
			if ($this->Mobileappsetting->save($this->request->data)) {
70
				$this->Session->setFlash(__('The mobileappsetting has been saved.'));
71
				return $this->redirect(array('action' => 'index'));
72
			} else {
73
				$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
74
			}
75
		}
76
	}
77
 
78
/**
79
 * admin_edit method
80
 *
81
 * @throws NotFoundException
82
 * @param string $id
83
 * @return void
84
 */
85
	public function admin_edit($id = null) {
86
		if (!$this->Mobileappsetting->exists($id)) {
87
			throw new NotFoundException(__('Invalid mobileappsetting'));
88
		}
89
		if ($this->request->is(array('post', 'put'))) {
90
			if ($this->Mobileappsetting->save($this->request->data)) {
91
				$this->Session->setFlash(__('The mobileappsetting has been saved.'));
92
				return $this->redirect(array('action' => 'index'));
93
			} else {
94
				$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
95
			}
96
		} else {
97
			$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
98
			$this->request->data = $this->Mobileappsetting->find('first', $options);
99
		}
100
	}
101
 
102
/**
103
 * admin_delete method
104
 *
105
 * @throws NotFoundException
106
 * @param string $id
107
 * @return void
108
 */
109
	public function admin_delete($id = null) {
110
		$this->Mobileappsetting->id = $id;
111
		if (!$this->Mobileappsetting->exists()) {
112
			throw new NotFoundException(__('Invalid mobileappsetting'));
113
		}
114
		$this->request->onlyAllow('post', 'delete');
115
		if ($this->Mobileappsetting->delete()) {
116
			$this->Session->setFlash(__('The mobileappsetting has been deleted.'));
117
		} else {
118
			$this->Session->setFlash(__('The mobileappsetting could not be deleted. Please, try again.'));
119
		}
120
		return $this->redirect(array('action' => 'index'));
121
	}}