Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
16475 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * PaytmCallings Controller
5
 *
6
 * @property PaytmCalling $PaytmCalling
7
 * @property PaginatorComponent $Paginator
8
 */
9
class PaytmCallingsController 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
		$this->PaytmCalling->recursive = -1;
25
		$userIds = $this->PaytmCalling->find('list');
16932 amit.gupta 26
		$sql = "SELECT u.id,u.first_name,u.email,u.mobile_number FROM users u JOIN paytm_coupon_non_usages p on p.user_id=u.id order by p.created";
16475 anikendra 27
		$users = $this->PaytmCalling->query($sql);
28
		$this->set('users', $users);
29
	}
30
 
31
/**
32
 * admin_view method
33
 *
34
 * @throws NotFoundException
35
 * @param string $id
36
 * @return void
37
 */
38
	public function admin_view($id = null) {
39
		if (!$this->PaytmCalling->exists($id)) {
40
			throw new NotFoundException(__('Invalid paytm calling'));
41
		}
42
		$options = array('conditions' => array('PaytmCalling.' . $this->PaytmCalling->primaryKey => $id));
43
		$this->set('paytmCalling', $this->PaytmCalling->find('first', $options));
44
	}
45
 
46
/**
47
 * admin_add method
48
 *
49
 * @return void
50
 */
51
	public function admin_add() {
52
		if ($this->request->is('post')) {
53
			$this->PaytmCalling->create();
54
			if ($this->PaytmCalling->save($this->request->data)) {
55
				$this->Session->setFlash(__('The paytm calling has been saved.'));
56
				return $this->redirect(array('action' => 'index'));
57
			} else {
58
				$this->Session->setFlash(__('The paytm calling could not be saved. Please, try again.'));
59
			}
60
		}
61
	}
62
 
63
/**
64
 * admin_edit method
65
 *
66
 * @throws NotFoundException
67
 * @param string $id
68
 * @return void
69
 */
70
	public function admin_edit($id = null) {
71
		if (!$this->PaytmCalling->exists($id)) {
72
			throw new NotFoundException(__('Invalid paytm calling'));
73
		}
74
		if ($this->request->is(array('post', 'put'))) {
75
			if ($this->PaytmCalling->save($this->request->data)) {
76
				$this->Session->setFlash(__('The paytm calling has been saved.'));
77
				return $this->redirect(array('action' => 'index'));
78
			} else {
79
				$this->Session->setFlash(__('The paytm calling could not be saved. Please, try again.'));
80
			}
81
		} else {
82
			$options = array('conditions' => array('PaytmCalling.' . $this->PaytmCalling->primaryKey => $id));
83
			$this->request->data = $this->PaytmCalling->find('first', $options);
84
		}
85
	}
86
 
87
/**
88
 * admin_delete method
89
 *
90
 * @throws NotFoundException
91
 * @param string $id
92
 * @return void
93
 */
94
	public function admin_delete($id = null) {
95
		$this->PaytmCalling->id = $id;
96
		if (!$this->PaytmCalling->exists()) {
97
			throw new NotFoundException(__('Invalid paytm calling'));
98
		}
99
		$this->request->onlyAllow('post', 'delete');
100
		if ($this->PaytmCalling->delete()) {
101
			$this->Session->setFlash(__('The paytm calling has been deleted.'));
102
		} else {
103
			$this->Session->setFlash(__('The paytm calling could not be deleted. Please, try again.'));
104
		}
105
		return $this->redirect(array('action' => 'index'));
106
	}}