Subversion Repositories SmartDukaan

Rev

Rev 16591 | Rev 16601 | 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') {
26
		$slug = $this->params['slug1'];
27
		$type = $this->params['slug2'];
16594 anikendra 28
		$me = $slug-1984;
16591 anikendra 29
		$appOffers = array();
30
		$url = "http://104.200.25.40:8057/appOffers/1";
31
		$appOffers = $this->make_request($url,null);
32
		$this->set(compact('appOffers','me','slug','type'));
33
		// $this->set('appOffers', $this->Paginator->paginate());
34
	}
35
 
36
/**
37
 * view method
38
 *
39
 * @throws NotFoundException
40
 * @param string $id
41
 * @return void
42
 */
43
	public function view($id = null) {
44
		if (!$this->AppOffer->exists($id)) {
45
			throw new NotFoundException(__('Invalid app offer'));
46
		}
47
		$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
48
		$this->set('appOffer', $this->AppOffer->find('first', $options));
49
	}
50
 
51
/**
52
 * add method
53
 *
54
 * @return void
55
 */
56
	public function add() {
57
		if ($this->request->is('post')) {
58
			$this->AppOffer->create();
59
			if ($this->AppOffer->save($this->request->data)) {
60
				$this->Flash->success(__('The app offer has been saved.'));
61
				return $this->redirect(array('action' => 'index'));
62
			} else {
63
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
64
			}
65
		}
66
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
67
		$this->set(compact('appAffiliates'));
68
	}
69
 
70
/**
71
 * edit method
72
 *
73
 * @throws NotFoundException
74
 * @param string $id
75
 * @return void
76
 */
77
	public function edit($id = null) {
78
		if (!$this->AppOffer->exists($id)) {
79
			throw new NotFoundException(__('Invalid app offer'));
80
		}
81
		if ($this->request->is(array('post', 'put'))) {
82
			if ($this->AppOffer->save($this->request->data)) {
83
				$this->Flash->success(__('The app offer has been saved.'));
84
				return $this->redirect(array('action' => 'index'));
85
			} else {
86
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
87
			}
88
		} else {
89
			$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
90
			$this->request->data = $this->AppOffer->find('first', $options);
91
		}
92
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
93
		$this->set(compact('appAffiliates'));
94
	}
95
 
96
/**
97
 * delete method
98
 *
99
 * @throws NotFoundException
100
 * @param string $id
101
 * @return void
102
 */
103
	public function delete($id = null) {
104
		$this->AppOffer->id = $id;
105
		if (!$this->AppOffer->exists()) {
106
			throw new NotFoundException(__('Invalid app offer'));
107
		}
108
		$this->request->allowMethod('post', 'delete');
109
		if ($this->AppOffer->delete()) {
110
			$this->Flash->success(__('The app offer has been deleted.'));
111
		} else {
112
			$this->Flash->error(__('The app offer could not be deleted. Please, try again.'));
113
		}
114
		return $this->redirect(array('action' => 'index'));
115
	}
116
}