Rev 16755 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** AppOffers Controller** @property AppOffer $AppOffer* @property PaginatorComponent $Paginator*/class AppOffersController extends AppController {/*** Components** @var array*/public $components = array('Paginator');/*** index method** @return void*/public function index() {$this->AppOffer->recursive = 0;$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->Session->setFlash(__('The app offer has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The app offer could not be saved. Please, try again.'));}}}/*** 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->Session->setFlash(__('The app offer has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('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);}}/*** 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->onlyAllow('post', 'delete');if ($this->AppOffer->delete()) {$this->Session->setFlash(__('The app offer has been deleted.'));} else {$this->Session->setFlash(__('The app offer could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}/*** admin_index method** @return void*/public function admin_index() {$type = $this->request->query('type');$search = $this->request->query('search');$conditions = array('offer_active'=>1);$offer_active = $this->request->query('offer_active');if(strlen($offer_active)>0){print_r($offer_active);$conditions = array('offer_active'=>$offer_active);}if(!empty($type) && !empty($search)){$conditions[] = array($type .' LIKE ' => "%$search%");// $options['conditions'][] = array($type.' LIKE ' =>"%$search%");// $this->Paginator->settings = $options;}$options['conditions'] = $conditions;$this->Paginator->settings = $options;$this->AppOffer->recursive = 0;$this->set('appOffers', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_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));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$this->AppOffer->create();if ($this->AppOffer->save($this->request->data)) {$this->Session->setFlash(__('The app offer has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The app offer could not be saved. Please, try again.'));}}$affiliate_ids = $this->AppOffer->AppAffiliate->find('list');$this->set(compact('affiliate_ids'));}/*** admin_edit method** @throws NotFoundException* @param string $id* @return void*/public function admin_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->Session->setFlash(__('The app offer has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('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);$affiliate_ids = $this->AppOffer->AppAffiliate->find('list');$this->set(compact('affiliate_ids'));}}public function admin_update($appmasterid = null) {if ($this->request->is(array('post', 'put'))) {if ($this->AppOffer->save($this->request->data)) {$this->Session->setFlash(__('The app offer has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The app offer could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('AppOffer.appmaster_id' => $appmasterid,'AppOffer.offer_active'=>1));$this->request->data = $this->AppOffer->find('first', $options);$affiliate_ids = $this->AppOffer->AppAffiliate->find('list');$this->set(compact('affiliate_ids'));$this->render('admin_edit');}}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->AppOffer->id = $id;if (!$this->AppOffer->exists()) {throw new NotFoundException(__('Invalid app offer'));}$this->request->onlyAllow('post', 'delete');if ($this->AppOffer->delete()) {$this->Session->setFlash(__('The app offer has been deleted.'));} else {$this->Session->setFlash(__('The app offer could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}}