Subversion Repositories SmartDukaan

Rev

Rev 16932 | 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');
16934 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";
27
		$sql = "SELECT u.id,u.first_name,u.email,u.mobile_number FROM users u JOIN (select o.user_id, o.created from orders o where o.id not in (select order_id from paytm_coupon_usages) and store_id=6 and status='ORDER_CREATED')p on p.user_id=u.id where u.referrer not like '%emp%' order by p.created";
16475 anikendra 28
		$users = $this->PaytmCalling->query($sql);
29
		$this->set('users', $users);
30
	}
31
 
32
/**
33
 * admin_view method
34
 *
35
 * @throws NotFoundException
36
 * @param string $id
37
 * @return void
38
 */
39
	public function admin_view($id = null) {
40
		if (!$this->PaytmCalling->exists($id)) {
41
			throw new NotFoundException(__('Invalid paytm calling'));
42
		}
43
		$options = array('conditions' => array('PaytmCalling.' . $this->PaytmCalling->primaryKey => $id));
44
		$this->set('paytmCalling', $this->PaytmCalling->find('first', $options));
45
	}
46
 
47
/**
48
 * admin_add method
49
 *
50
 * @return void
51
 */
52
	public function admin_add() {
53
		if ($this->request->is('post')) {
54
			$this->PaytmCalling->create();
55
			if ($this->PaytmCalling->save($this->request->data)) {
56
				$this->Session->setFlash(__('The paytm calling has been saved.'));
57
				return $this->redirect(array('action' => 'index'));
58
			} else {
59
				$this->Session->setFlash(__('The paytm calling could not be saved. Please, try again.'));
60
			}
61
		}
62
	}
63
 
64
/**
65
 * admin_edit method
66
 *
67
 * @throws NotFoundException
68
 * @param string $id
69
 * @return void
70
 */
71
	public function admin_edit($id = null) {
72
		if (!$this->PaytmCalling->exists($id)) {
73
			throw new NotFoundException(__('Invalid paytm calling'));
74
		}
75
		if ($this->request->is(array('post', 'put'))) {
76
			if ($this->PaytmCalling->save($this->request->data)) {
77
				$this->Session->setFlash(__('The paytm calling has been saved.'));
78
				return $this->redirect(array('action' => 'index'));
79
			} else {
80
				$this->Session->setFlash(__('The paytm calling could not be saved. Please, try again.'));
81
			}
82
		} else {
83
			$options = array('conditions' => array('PaytmCalling.' . $this->PaytmCalling->primaryKey => $id));
84
			$this->request->data = $this->PaytmCalling->find('first', $options);
85
		}
86
	}
87
 
88
/**
89
 * admin_delete method
90
 *
91
 * @throws NotFoundException
92
 * @param string $id
93
 * @return void
94
 */
95
	public function admin_delete($id = null) {
96
		$this->PaytmCalling->id = $id;
97
		if (!$this->PaytmCalling->exists()) {
98
			throw new NotFoundException(__('Invalid paytm calling'));
99
		}
100
		$this->request->onlyAllow('post', 'delete');
101
		if ($this->PaytmCalling->delete()) {
102
			$this->Session->setFlash(__('The paytm calling has been deleted.'));
103
		} else {
104
			$this->Session->setFlash(__('The paytm calling could not be deleted. Please, try again.'));
105
		}
106
		return $this->redirect(array('action' => 'index'));
107
	}}