Ejemplo n.º 1
0
 public function storechangeAction()
 {
     /***********************************************************/
     $modelCountry = new Admin_Model_DbTable_Countries();
     $storeId = $this->_getParam('storeid');
     if (!empty($storeId)) {
         $country_info = $modelCountry->fetchRow("id='{$storeId}'");
         $storeId = $this->getRequest()->getCookie('sid');
         $storeName = $this->getRequest()->getCookie('sname');
         $curId = $this->getRequest()->getCookie('curId');
         if (!empty($storeId) && !empty($storeName)) {
             setcookie("sid", $country_info->id);
             setcookie("sname", $country_info->country);
             setcookie("curId", $country_info->currency_id);
             $storeSession = new Zend_Session_Namespace('storeInfo');
             $storeSession->sid = $country_info->id;
             $storeSession->sname = $country_info->country;
             $storeSession->curId = $country_info->currency_id;
         } else {
             setcookie("sid", $country_info->id);
             setcookie("sname", $country_info->country);
             setcookie("curId", $country_info->currency_id);
             $storeSession = new Zend_Session_Namespace('storeInfo');
             $storeSession->sid = $country_info->id;
             $storeSession->sname = $country_info->country;
             $storeSession->curId = $country_info->currency_id;
             //$publication_store = new Zend_Auth_Storage_Session('store_type');
             //$publication_store->write($country_info);
         }
         //exit;
     } else {
         $storeId = $this->getRequest()->getCookie('sid');
         $storeName = $this->getRequest()->getCookie('sname');
         $curId = $this->getRequest()->getCookie('curId');
         if (empty($storeId) && empty($storeName)) {
             $country_info = $modelCountry->fetchRow('country="Nigeria"');
             setcookie("sid", $country_info->id);
             setcookie("sname", $country_info->country);
             setcookie("curId", $country_info->currency_id);
             $storeSession = new Zend_Session_Namespace('storeInfo');
             $storeSession->sid = $country_info->id;
             $storeSession->sname = $country_info->country;
             $storeSession->cid = $country_info->id;
             $storeSession->cname = $country_info->country;
             $storeSession->curId = $country_info->currency_id;
         } else {
             $storeSession = new Zend_Session_Namespace('storeInfo');
             $storeSession->sid = $storeId;
             $storeSession->sname = $storeName;
             $storeSession->cid = $storeId;
             $storeSession->cname = $storeName;
             $storeSession->curId = $curId;
         }
         //exit;
     }
     $modelCurrency = new Admin_Model_DbTable_Currency();
     $currency_info = $modelCurrency->fetchRow("currency_id='{$storeSession->curId}'");
     $storeSession->curname = $currency_info->currency_sign;
     //echo ">>>>>".$storeSession->curname;
     //exit();
     /********************************************************************/
     $this->_redirect('/');
 }
Ejemplo n.º 2
0
 public function init()
 {
     /*********** To check for publisher session data *********************/
     $storage_publisher = new Zend_Auth_Storage_Session('publisher_type');
     $publisher_data = $storage_publisher->read();
     $storage_company = new Zend_Auth_Storage_Session('company_type');
     $company_data = $storage_company->read();
     $storage = new Zend_Auth_Storage_Session('account_type');
     $userSessData = $storage->read();
     if ($publisher_data && $publisher_data != null) {
         $this->modelPublisher = new Model_DbTable_Users();
         $this->sessPublisherInfo = $this->modelPublisher->getInfoByUserId($publisher_data->id);
         $this->view->sessPublisherInfo = $this->sessPublisherInfo;
     } elseif ($company_data && $company_data != null) {
         $this->modelCompany = new Model_DbTable_Companies();
         $this->sessCompanyInfo = $this->modelCompany->getInfoByUserId($company_data->id);
         $this->view->sessCompanyInfo = $this->sessCompanyInfo;
     } elseif ($userSessData && $userSessData != null) {
         $this->modelCompanies = new Company_Model_DbTable_Companies();
         $this->sessUserInfo = $this->modelCompanies->getInfoByCompanyId($userSessData->id);
         $this->view->sessUserInfo = $this->sessUserInfo;
     }
     /************* To Set The active section and links *******************/
     $controller = $this->_getParam('controller');
     $action = $this->_getParam('action');
     $this->view->currentController = $controller;
     $this->view->currentAction = $action;
     $this->view->class_active = 'class="active"';
     /************* To Set The active section and links *******************/
     $this->view->headScript()->appendFile($this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/js/banner_and_slider.js');
     /******************************************************************/
     //$storeId=$this->getRequest()->getCookie('sid');
     //$storeName=$this->getRequest()->getCookie('sname');
     $storeSession = new Zend_Session_Namespace('storeInfo');
     if (!empty($storeSession->sid) && !empty($storeSession->sid) && !empty($storeSession->sname) && !empty($storeSession->sid) && !empty($storeSession->cid) && !empty($storeSession->cname)) {
         //echo "there";
         /***********************************************************/
         /****** new code ***********/
         $modelCountry = new Admin_Model_DbTable_Countries();
         $storeId = $storeSession->sid;
         $country_info = $modelCountry->fetchRow("id='{$storeId}'");
         $storeSession->curId = $country_info->currency_id;
         $modelCurrency = new Admin_Model_DbTable_Currency();
         $currency_info = $modelCurrency->fetchRow("currency_id='{$storeSession->curId}'");
         $storeSession->curname = $currency_info->currency_sign;
         /******** end new Code *******/
         $this->view->storeId = $storeSession->sid;
         $this->view->storeName = $storeSession->sname;
         //$this->_redirect('/auth/storechange/');
     } else {
         //echo "here";
         //$modelCountry = new Admin_Model_DbTable_Countries();
         //$country_info = $modelCountry->fetchRow('country="Nigeria"');
         //$this->_redirect('/auth/storechange/storeid/'.$country_info->id);
         $this->_redirect('/auth/storechange/');
     }
     $this->modelBooks = new Publisher_Model_DbTable_Books();
     $this->view->modelBooks = $this->modelBooks;
     $allStored = $this->modelBooks->getAllStores();
     $this->view->allStored = $allStored;
     $this->modelCategories = new Admin_Model_DbTable_Categories();
     $categoriesList = $this->modelCategories->getList();
     $categoriesList = $categoriesList->toArray();
     foreach ($categoriesList as $key => $catArray) {
         $records = $this->modelBooks->getPublicationIdsByCategoryName($storeSession->sid, $catArray['category_name'], '1', '0');
         $categoriesList[$key]['total_publications'] = count($records);
     }
     $this->view->allcategories = $categoriesList;
     $this->modelGenres = new Admin_Model_DbTable_Genres();
     $query = $this->modelBooks->select();
     $query->setIntegrityCheck(false);
     //newspaper genres
     //$getnewspapers_genres =
     $db = Zend_Registry::get('db');
     /*$query->from(array("book"=>$this->modelBooks),array('DISTINCT(product_type)'));
     		$query->join(array("genre"=>$this->modelGenres), "book.product_type = genre.id", array('genre.genre'));
     		$query->where('book.cat_id = ?', 1);
     		$query->order('genre.genre asc');*/
     $query = "SELECT DISTINCT (prod.product_type), gen.genre FROM pclive_products prod\n\t\t\t\t  INNER JOIN pclive_genres gen ON prod.product_type = gen.id \n\t\t\t\t  WHERE prod.cat_id =1 ORDER BY gen.genre ASC ";
     $result = $db->query($query);
     $getnewspapers_genres = $result->fetchAll();
     //$getnewspapers_genres = $getnewspapers_genres->toArray();
     $this->view->getnewspapers_genres = $getnewspapers_genres;
     //magazine genres
     $query_mag = "SELECT DISTINCT (prod.product_type), gen.genre FROM pclive_products prod\n\t\t\t\t  INNER JOIN pclive_genres gen ON prod.product_type = gen.id \n\t\t\t\t  WHERE prod.cat_id =2 ORDER BY gen.genre ASC ";
     $result_mag = $db->query($query_mag);
     $getmagazine_genres = $result_mag->fetchAll();
     $this->view->getmagazine_genres = $getmagazine_genres;
     //ebook genres
     $query_ebook = "SELECT DISTINCT (prod.product_type), gen.genre FROM pclive_products prod\n\t\t\t\t  INNER JOIN pclive_genres gen ON prod.product_type = gen.id \n\t\t\t\t  WHERE prod.cat_id =2 ORDER BY gen.genre ASC ";
     $result_ebook = $db->query($query_ebook);
     $getebooks_genres = $result_ebook->fetchAll();
     $this->view->getebooks_genres = $getebooks_genres;
     /*$this->modelGenres = new Admin_Model_DbTable_Genres();		
     		for($x=0;$x<count($getnewspapers_genres);$x++)
     		{
     			
     			$genrename = $this->modelGenres->fetchAll('id="'.$getnewspapers_genres[$x]['product_type'].'"');
     			
     			
     		}
     		echo "<pre>";
     			print_r($genrename->toArray());
     			echo "</pre>";
     		//$data = $select->fetchAll();*/
     /******************************************************************/
     $storage_publisher = new Zend_Auth_Storage_Session('publisher_type');
     $publisher_data = $storage_publisher->read();
     if (count($publisher_data) > 0) {
         $user_id_comment = $publisher_data->id;
         $user_type = "4";
     }
     $storage_company = new Zend_Auth_Storage_Session('company_type');
     $company_data = $storage_company->read();
     if (count($company_data) > 0) {
         $user_id_comment = $company_data->id;
         $user_type = "1";
     }
     $storage_user = new Zend_Auth_Storage_Session('account_type');
     $data_user = $storage_user->read();
     if (count($data_user) > 0) {
         $user_id_comment = $data_user->id;
         $user_type = "2";
     }
 }