Subversion Repositories SmartDukaan

Rev

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

<?php
App::uses('AppController', 'Controller');
/**
 * Exceptionalnlcs Controller
 *
 * @property Exceptionalnlc $Exceptionalnlc
 * @property PaginatorComponent $Paginator
 */
class MasterDatasController extends AppController {

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

        public function beforeFilter() {
                parent::beforeFilter();
//              Configure::load('live');
                $this->apihost = Configure::read('pythonapihost');
        }

        public function admin_index() {
                /*$page = $this->request->query('page');
                if(!isset($page)){
                        $page = 1;
                }
                $limit = Configure::read('admindashboardlimit');
                $params = array(
                        'fields' => array('_id','brand','source_product_name', 'available_price', 'thumbnail','category','category_id','in_stock','marketPlaceUrl','mrp','rank','source_id','source_product_name','url'),
                        'conditions' => array('source_id' => array('$ne' => 0)),
                        'order' => array('_id' => -1),
                        'limit' => $limit,
                        'page' => $page,
                );
                $masterdata = $this->MasterData->find('all', $params);
                $this->loadModel('Category');
                $categories = $this->Category->find('list');
                $storemapping = Configure::read('storemapping');
                $this->set(compact('masterdata','categories','page','storemapping'));*/
                $page = $this->request->query('page');
                if(!isset($page)){
                        $page = 1;
                }
                $limit = Configure::read('admindashboardlimit');
                $offset = ($page - 1)*$limit;
                $search = '';
                $url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
                $response = $this->make_request($url,null);
                $storemapping = Configure::read('storemapping');
                $this->set('masterdata', $response);
                $this->set(compact('page','search','storemapping'));
        }

        public function admin_edit($id = null) {
                $id = (integer) $id;
                if (!$id && empty($this->data)) {
                        $this->flash(__('Invalid Post', true), array('action' => 'index'));
                }
                if (!empty($this->data)) {
                        if ($this->MasterData->save($this->data)) {
                                $this->flash(__('The data has been saved.', true), array('action' => 'index'));
                        } else {
                        }
                }
                if (empty($this->data)) {
                        $this->data = $this->MasterData->read(null, $id);
                        debug($this->data);
                }
        }

        public function admin_search(){
                $page = $this->request->query('page');
                if(!isset($page)){
                        $page = 1;
                }
                $limit = Configure::read('admindashboardlimit');
                $offset = ($page - 1)*$limit;
                $search = urlencode($this->request->query('search'));
                $url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
                $response = $this->make_request($url,null);
                $storemapping = Configure::read('storemapping');
                $this->set('masterdata', $response);
                $this->set(compact('page','search','storemapping'));
        }
}