Subversion Repositories SmartDukaan

Rev

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

<?php
App::uses('AppController', 'Controller');
/**
 * AppOffers Controller
 *
 * @property AppOffer $AppOffer
 * @property PaginatorComponent $Paginator
 * @property FlashComponent $Flash
 * @property SessionComponent $Session
 */
class AppOffersController extends AppController {

/**
 * Components
 *
 * @var array
 */
        public $components = array('Paginator', 'Flash', 'Session');

/**
 * index method
 *
 * @return void
 */
        public function index($slug,$type='android') {
                $page = $this->request->query('page');
                if(!isset($page)){                      
                        $page = 1;
                }
                $slug = $this->params['slug1'];
                $type = $this->params['slug2'];
                $me = $slug-1984;
                $appOffers = array();
                $url = $this->apihost."appOffers/1";
                $appOffers = $this->make_request($url,null);
                $this->set(compact('appOffers','me','slug','type','page'));
                // $this->set('appOffers', $this->Paginator->paginate());
        }

/**
 * view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function view($id = null) {
                if (!$this->AppOffer->exists($id)) {
                        throw new NotFoundException(__('Invalid app offer'));
                }
                $options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
                $this->set('appOffer', $this->AppOffer->find('first', $options));
        }

/**
 * add method
 *
 * @return void
 */
        public function add() {
                if ($this->request->is('post')) {
                        $this->AppOffer->create();
                        if ($this->AppOffer->save($this->request->data)) {
                                $this->Flash->success(__('The app offer has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Flash->error(__('The app offer could not be saved. Please, try again.'));
                        }
                }
                $appAffiliates = $this->AppOffer->AppAffiliate->find('list');
                $this->set(compact('appAffiliates'));
        }

/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function edit($id = null) {
                if (!$this->AppOffer->exists($id)) {
                        throw new NotFoundException(__('Invalid app offer'));
                }
                if ($this->request->is(array('post', 'put'))) {
                        if ($this->AppOffer->save($this->request->data)) {
                                $this->Flash->success(__('The app offer has been saved.'));
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Flash->error(__('The app offer could not be saved. Please, try again.'));
                        }
                } else {
                        $options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
                        $this->request->data = $this->AppOffer->find('first', $options);
                }
                $appAffiliates = $this->AppOffer->AppAffiliate->find('list');
                $this->set(compact('appAffiliates'));
        }

/**
 * delete method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function delete($id = null) {
                $this->AppOffer->id = $id;
                if (!$this->AppOffer->exists()) {
                        throw new NotFoundException(__('Invalid app offer'));
                }
                $this->request->allowMethod('post', 'delete');
                if ($this->AppOffer->delete()) {
                        $this->Flash->success(__('The app offer has been deleted.'));
                } else {
                        $this->Flash->error(__('The app offer could not be deleted. Please, try again.'));
                }
                return $this->redirect(array('action' => 'index'));
        }
}