Rev 16840 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** UserAppInstalls Controller** @property UserAppInstall $UserAppInstall* @property PaginatorComponent $Paginator*/class UserAppInstallsController extends AppController {/*** Components** @var array*/public $components = array('Paginator');/*** admin_index method** @return void*/public function admin_index() {$this->UserAppInstall->recursive = 0;$this->set('userAppInstalls', $this->Paginator->paginate());}/*** admin_view method** @throws NotFoundException* @param string $id* @return void*/public function admin_view($id = null) {if (!$this->UserAppInstall->exists($id)) {throw new NotFoundException(__('Invalid user app install'));}$options = array('conditions' => array('UserAppInstall.' . $this->UserAppInstall->primaryKey => $id));$this->set('userAppInstall', $this->UserAppInstall->find('first', $options));}/*** admin_add method** @return void*/public function admin_add() {if ($this->request->is('post')) {$this->UserAppInstall->create();if ($this->UserAppInstall->save($this->request->data)) {$this->Session->setFlash(__('The user app install has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user app install could not be saved. Please, try again.'));}}}/*** admin_edit method** @throws NotFoundException* @param string $id* @return void*/public function admin_edit($id = null) {if (!$this->UserAppInstall->exists($id)) {throw new NotFoundException(__('Invalid user app install'));}if ($this->request->is(array('post', 'put'))) {if ($this->UserAppInstall->save($this->request->data)) {$this->Session->setFlash(__('The user app install has been saved.'));return $this->redirect(array('action' => 'index'));} else {$this->Session->setFlash(__('The user app install could not be saved. Please, try again.'));}} else {$options = array('conditions' => array('UserAppInstall.' . $this->UserAppInstall->primaryKey => $id));$this->request->data = $this->UserAppInstall->find('first', $options);}}/*** admin_delete method** @throws NotFoundException* @param string $id* @return void*/public function admin_delete($id = null) {$this->UserAppInstall->id = $id;if (!$this->UserAppInstall->exists()) {throw new NotFoundException(__('Invalid user app install'));}$this->request->onlyAllow('post', 'delete');if ($this->UserAppInstall->delete()) {$this->Session->setFlash(__('The user app install has been deleted.'));} else {$this->Session->setFlash(__('The user app install could not be deleted. Please, try again.'));}return $this->redirect(array('action' => 'index'));}public function getDateInstalls($date) {// $conditions = array('user_id'=>$this->Auth->User('id'),'transaction_date'=>$date);// $fields = array('app_name','sum(installCount) AS installs','sum(payoutAmount) AS amount');// $installs = $this->UserAppInstall->find('all',array('fields'=>$fields,'conditions'=>$conditions,'group'=>'app_id'));// if(!empty($installs)){// foreach ($installs as $key => $value) {// $result[$value['UserAppInstall']['app_name']] = $value[0];// }// $response = array('installs' => $result,'success'=>true);// }else{// $response = array('installs' => null,'success'=>false);// }// $this->response->type('json');// $this->layout = 'ajax';// $this->set(array(// 'result' => $response,// // 'callback' => $callback,// '_serialize' => array('result')// ));// $this->render('/Elements/json');$this->autoRender = false;$this->request->onlyAllow('ajax');$url = $this->apihost.'appUserBatchDateDrillDown/'.$this->Auth->User('id').'/'.$date;$getApp = $this->make_request($url,null);return json_encode($getApp);}}