Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
16591 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * AppOffers Controller
5
 *
6
 * @property AppOffer $AppOffer
7
 * @property PaginatorComponent $Paginator
8
 * @property FlashComponent $Flash
9
 * @property SessionComponent $Session
10
 */
11
class AppOffersController extends AppController {
12
 
13
/**
14
 * Components
15
 *
16
 * @var array
17
 */
18
	public $components = array('Paginator', 'Flash', 'Session');
19
 
20
/**
21
 * index method
22
 *
23
 * @return void
24
 */
25
	public function index($slug,$type='android') {
16601 anikendra 26
		$page = $this->request->query('page');
27
		if(!isset($page)){			
28
			$page = 1;
29
		}
16591 anikendra 30
		$slug = $this->params['slug1'];
31
		$type = $this->params['slug2'];
16594 anikendra 32
		$me = $slug-1984;
16591 anikendra 33
		$appOffers = array();
16720 anikendra 34
		$url = $this->apihost."appOffers/1";
16591 anikendra 35
		$appOffers = $this->make_request($url,null);
16601 anikendra 36
		$this->set(compact('appOffers','me','slug','type','page'));
16591 anikendra 37
		// $this->set('appOffers', $this->Paginator->paginate());
38
	}
39
 
40
/**
41
 * view method
42
 *
43
 * @throws NotFoundException
44
 * @param string $id
45
 * @return void
46
 */
47
	public function view($id = null) {
48
		if (!$this->AppOffer->exists($id)) {
49
			throw new NotFoundException(__('Invalid app offer'));
50
		}
51
		$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
52
		$this->set('appOffer', $this->AppOffer->find('first', $options));
53
	}
54
 
55
/**
56
 * add method
57
 *
58
 * @return void
59
 */
60
	public function add() {
61
		if ($this->request->is('post')) {
62
			$this->AppOffer->create();
63
			if ($this->AppOffer->save($this->request->data)) {
64
				$this->Flash->success(__('The app offer has been saved.'));
65
				return $this->redirect(array('action' => 'index'));
66
			} else {
67
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
68
			}
69
		}
70
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
71
		$this->set(compact('appAffiliates'));
72
	}
73
 
74
/**
75
 * edit method
76
 *
77
 * @throws NotFoundException
78
 * @param string $id
79
 * @return void
80
 */
81
	public function edit($id = null) {
82
		if (!$this->AppOffer->exists($id)) {
83
			throw new NotFoundException(__('Invalid app offer'));
84
		}
85
		if ($this->request->is(array('post', 'put'))) {
86
			if ($this->AppOffer->save($this->request->data)) {
87
				$this->Flash->success(__('The app offer has been saved.'));
88
				return $this->redirect(array('action' => 'index'));
89
			} else {
90
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
91
			}
92
		} else {
93
			$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
94
			$this->request->data = $this->AppOffer->find('first', $options);
95
		}
96
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
97
		$this->set(compact('appAffiliates'));
98
	}
99
 
100
/**
101
 * delete method
102
 *
103
 * @throws NotFoundException
104
 * @param string $id
105
 * @return void
106
 */
107
	public function delete($id = null) {
108
		$this->AppOffer->id = $id;
109
		if (!$this->AppOffer->exists()) {
110
			throw new NotFoundException(__('Invalid app offer'));
111
		}
112
		$this->request->allowMethod('post', 'delete');
113
		if ($this->AppOffer->delete()) {
114
			$this->Flash->success(__('The app offer has been deleted.'));
115
		} else {
116
			$this->Flash->error(__('The app offer could not be deleted. Please, try again.'));
117
		}
118
		return $this->redirect(array('action' => 'index'));
119
	}
120
}