403Webshell
Server IP : 103.234.187.230  /  Your IP : 216.73.216.216
Web Server : Apache
System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/b2bzend/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/controllers//CityController.php
<?php
/**
 * Class City
 *
 * @name		City
 * @author		Ravi Khare
 * @editor		Ranvir Singh
 * @created		13 Sep 2016
 * @updated		27 Sep 2016
 * @version		1.0
 * @copyright   Catabatic India Pvt Ltd
 * 
 * Handle City Related function for Front end only
 *
 */

class CityController extends Zend_Controller_Action {
    
    public $imageUrl = NULL;
    
    public $baseUrl = '';
    
    public $tablename   = '';
    public $cityMdl     = '';
    
    public $per_page_record = GRID_PER_PAGE_RECORD_COUNT;


    public function init()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();

        
        $this->cityMdl = new Travel_Model_TblCity();
        
        $this->tablename    = 'TB_Master_Geo_City';
        
        $sessionLogin_user  = new Zend_Session_Namespace('sessionLogin_user');
        $this->intLoggedinUserId            = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserAgencySysId   = $sessionLogin_user->intLoggedinUserAgencySysId;
        
        if(empty($this->intLoggedinUserId)) {
            $this->_redirect('/login/');
        }
        
        $this->imageUrl = $this->baseUrl."/public/upload/city/";
        
    }
    
    public function autosuggestAction()
    {
        $arrResponse = array();
        
        if($this->getRequest()->getParam("term")) {
            $term = $this->getRequest()->getParam("term");
            $objCity = new Travel_Model_TblCity();
            $arrResponse = $objCity->getAutoSuggest($term);
        }
        
        echo json_encode( $arrResponse );
        exit;
    }
    
    public function indexAction()
    {
        // get country list array
		$objCountry = new Travel_Model_TblCountry();
        $this->view->countrylist = $objCountry->getCountryList();
		
		// display flash msg 
		$this->view->messages = $this->_helper->flashMessenger->getMessages(); 
		
		
		//Start Search Code
        $searchArr = array();
        $getData = array();
		  
        if($this->getRequest()->isPost())
        {
			$getData = $this->getRequest()->getPost();
            
            if(!empty($getData))
            {
                $dateFrom       = (@$getData['dateFrom']!='')         ? @$getData['dateFrom']       : '';
			    $dateTo         = (@$getData['dateTo']!='')           ? $this->_helper->general->plusOneDay(@$getData['dateTo'])  : '';   // add one day extra while fetching result date results
				$Synonyms       = (@$getData['Synonyms']!='')         ? @$getData['Synonyms']       : '';
				$country_id     = (@$getData['country_id']!=0)        ? @$getData['country_id']     : '';
				$state_id       = (@$getData['state_listing']!=0)     ? @$getData['state_listing']  : '';
				$cityName       = (@$getData['cityName']!='')         ? @$getData['cityName']       : '';
				$filter1        = (@$getData['filter1']!='All')       ? @$getData['filter1']        : '';    // status part
				$filter2        = (@$getData['filter2']!='All')       ? @$getData['filter2']        : '';    // verified part
               
			   $searchArr = array(
                            'dateFrom' => $dateFrom,
							'dateTo'   => $dateTo,
							'Synonyms' => $Synonyms,
							'cityName' => $cityName,
                            'stateId'  => $state_id,
                            'countryId'=> $country_id,
							'filter1'  => $filter1,
							'filter2'  => $filter2
                            
               );
			  // print_r($getData);
			} 
		} 
		else
		{
				
			$dateFrom   = $this->_getParam('dateFrom');
			$dateTo     = $this->_getParam('dateTo');
			$Synonyms   = $this->_getParam('Synonyms');
			$cityName   = $this->_getParam('cityName');   // _getParam( $searchArr('Key') );
			$state_id   = $this->_getParam('stateId');
			$country_id = $this->_getParam('countryId');
			$filter1    = $this->_getParam('filter1');
			$filter2    = $this->_getParam('filter2');
							 
			$dateFrom   = (@$dateFrom!='') ? $dateFrom : '';
			$dateTo     = (@$dateTo!='') ? $dateTo : '';
			$Synonyms   = (@$Synonyms!='') ? $Synonyms : '';
			$cityName   = (@$cityName!='') ? $cityName : '';
			$state_id   = (@$state_id!=0) ? $state_id : '';
			$country_id = (@$country_id!=0) ? $country_id : '';
			$filter1    = (@$filter1!='All') ? $filter1 : '';
			$filter2    = (@$filter2!='All') ? $filter2 : '';
			
			$searchArr = array(
						'dateFrom' => $dateFrom,
						'dateTo'   => $dateTo,
						'Synonyms' => $Synonyms,
						'cityName' => $cityName,
						'stateId'  => $state_id,
						'countryId'=> $country_id,
						'filter1'  => $filter1,
						'filter2'  => $filter2
						
			);
			
			//print_r($searchArr);
				
		}
			//print_r($searchArr);
			$this->cityMdl->searchArr = $searchArr; // send Array - searchArr() to modal just for pagination
			$this->view->searchArr = $searchArr;	
		
		
		// pagination start
		$page = $this->_request->getParam('page',1); //get curent page param, default 1 if param not available.
		
		$data = $this->cityMdl->getCityListingRecord(); // get all cities
		
		$page=$this->_getParam('page',1);
        $paginator = Zend_Paginator::factory($data);      
        $paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
        $perPage = $paginator->setItemCountPerPage($this->per_page_record); // number of items to show per page
        $this->view->paginator = $paginator;
        $this->view->totalrec = $paginator->getTotalItemCount();
		$this->view->currentPage = $this->_getParam('page');
		
		
    }
	
    public function deleteCityAction() {

        /* Disable Layout & set Render False */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $CityId  = base64_decode( $this->getRequest()->getParam('id'));
			$currentPage  = base64_decode( $this->getRequest()->getParam('page'));

		
		if($CityId) {
			$editData['IsMarkForDel']  = 1;           
			$tablename  = "TB_Master_Geo_City";
			$where      = array('CityId =?'=> $CityId);
			$isupdated  = $this->cityMdl->updateTable($this->tablename, $editData, $where);
			if($isupdated)
			{
				$this->_helper->flashMessenger->addMessage("Record Deleted successfully.");
				$this->_redirect("city/index/page/$currentPage");
			}
        }
        else {
			$this->_redirect("city/index/page/$currentPage");
        }
	}
	
	
    public function addAction()
    {
        
		// display flash msg 
		$this->view->messages = $this->_helper->flashMessenger->getMessages(); 
					
		$objCountry = new Travel_Model_TblCountry();
        $this->view->countrylist = $objCountry->getCountryList();
		
		$uniqueId       = "IsActive";
        $uniqueIdVal    = 1;
		$tablename  = "TB_Master_PlaceType";
		
		$this->view->cityCategoryListing = $this->cityMdl->getRecordListing($tablename, array('Title','PlaceType','IsActive'), $uniqueId, $uniqueIdVal, "Title", "ASC");
		 
		if($this->getRequest()->isPost())
            {
                $post   = $this->getRequest()->getPost();
               // echo "<pre>"; print_r($post); die;
				
                try {

                    $addData   = array();

                    $addData['Title']              = (@$post['cityname']) ? $post['cityname'] : '';
                    $addData['Alias']              = (@$post['Alias']) ? $post['Alias'] : '';
                    $addData['Code']               = (@$post['Code']) ? $post['Code'] : '';
                    $addData['StateOrZone']        = (@$post['StateOrZone']) ? $post['StateOrZone'] : 0;
                    $addData['Country']            = (@$post['Country']) ? $post['Country'] : '';

                    $addData['CityCategoryMask']   = (@$post['citycategory']) ? implode(',',$post['citycategory']) : '';
                    $addData['Synonyms']           = (@$post['Synonyms']) ? $post['Synonyms'] : '';
                    $addData['ThumbnailImg']       = (@$post['ThumbnailImg']) ? $post['ThumbnailImg'] : '';
                    $addData['BannerImg']          = (@$post['BannerImg']) ? $post['BannerImg'] : '';
                    $addData['AltTag']             = (@$post['AltTag']) ? $post['AltTag'] : '';

                    $addData['ShortDesc']          = (@$post['ShortDesc']) ? $post['ShortDesc'] : '';
                    $addData['LongDesc']           = (@$post['LongDesc']) ? $post['LongDesc'] : '';
                    $addData['HowToReachDesc']     = (@$post['HowToReachDesc']) ? $post['HowToReachDesc'] : '';
                    $addData['XRefAirportCode']    = (@$post['XRefAirportCode']) ? $post['XRefAirportCode'] : '';
                    $addData['TravelByAirDesc']    = (@$post['TravelByAirDesc']) ? $post['TravelByAirDesc'] : '';

                    $addData['CanTravelByTrain']   = (@$post['CanTravelByTrain']) ? $post['CanTravelByTrain'] : '';
                    $addData['TravelByTrainDesc']  = (@$post['TravelByTrainDesc']) ? $post['TravelByTrainDesc'] : '';
                    $addData['CanTravelByBus']     = (@$post['CanTravelByBus']) ? $post['CanTravelByBus'] : '';
                    $addData['TravelByBusDesc']    = (@$post['TravelByBusDesc']) ? $post['TravelByBusDesc'] : '';
                    $addData['CanTravelByCar']     = (@$post['CanTravelByCar']) ? $post['CanTravelByCar'] : '';

                    $addData['TravelByCarDesc']    = (@$post['TravelByCarDesc']) ? $post['TravelByCarDesc'] : '';
                    $addData['TimeToVisitMask']    = (@$post['TimeToVisitMask']) ? $post['TimeToVisitMask'] : '';
                    $addData['ActivityMask']       = (@$post['ActivityMask']) ? $post['ActivityMask'] : '';
                    $addData['SeasonMask']         = (@$post['SeasonMask']) ? $post['SeasonMask'] : '';
                    $addData['GetLat']             = (@$post['GetLat']) ? $post['GetLat'] : '';

                    $addData['GetLong']            = (@$post['GetLong']) ? $post['GetLong'] : '';
                    $addData['StateSysId']         = (@$post['state_listing']) ? $post['state_listing'] : '';
                    $addData['ZoneSysId']          = (@$post['ZoneSysId']) ? $post['ZoneSysId'] : '';
                    $addData['ContSysId']          = (@$post['country_id']) ? $post['country_id'] : '';
                    $addData['PIN']                = (@$post['PIN']) ? $post['PIN'] : '';

                    $addData['IsHaveAirPort']      = (@$post['IsHaveAirPort']) ? $post['IsHaveAirPort'] : '';
                    $addData['CreateDate']         = date('Y-m-d h:i:s');
					$addData['isActive']           = 1;

					
					// check city name already exists or not ( Avoid duplicate city entry)
					
					if($post['cityname']!='' && $post['state_listing']!='' ){
						$cityName    = $this->cityMdl->getRecordListingWhere('TB_Master_Geo_City', array('Title'), array('IsActive'=>1,'Title'=>$addData['Title'],'StateSysId'=>$addData['StateSysId']),'Title');
					}
					
					//print_r($cityName); echo count($cityName);
					if(count($cityName)>=1){
						
							$this->_helper->flashMessenger->addMessage("City already exists.");
							$this->_redirect("city/add");
					} 
					else
					{
						$isinserted = $this->cityMdl->insertTable($this->tablename, $addData); 
						if($isinserted) {
							$this->_helper->flashMessenger->addMessage("Record inserted successfully.");
							$this->_redirect("city/index");
						}
						
					}
					
									
					
					
                }
                catch (Zend_Db_Exception $error)
                {
                    $this->view->error_msg = $error->getMessage(); 
                }

			}                    
    }
	
    public function editAction()
    {
        $cityid = base64_decode($this->_getParam('id'));
		
		if(!empty($cityid) || !is_int($cityid) )
        {
            if($this->getRequest()->isPost())
            {
                $post   = $this->getRequest()->getPost();
//                echo "<pre>"; print_r($post); die;
                
                try {

                    $editData   = array();

                    $editData['Title']              = (@$post['cityname']) ? $post['cityname'] : '';
                    $editData['Alias']              = (@$post['Alias']) ? $post['Alias'] : '';
                    $editData['Code']               = (@$post['Code']) ? $post['Code'] : '';
                    $editData['StateOrZone']        = (@$post['StateOrZone']) ? $post['StateOrZone'] : 0;
                    $editData['Country']            = (@$post['Country']) ? $post['Country'] : '';

                    $editData['CityCategoryMask']   = (@$post['citycategory']) ? implode(',',$post['citycategory']) : '';
                    $editData['Synonyms']           = (@$post['Synonyms']) ? $post['Synonyms'] : '';
                    $editData['ThumbnailImg']       = (@$post['ThumbnailImg']) ? $post['ThumbnailImg'] : '';
                    $editData['BannerImg']          = (@$post['BannerImg']) ? $post['BannerImg'] : '';
                    $editData['AltTag']             = (@$post['AltTag']) ? $post['AltTag'] : '';

                    $editData['ShortDesc']          = (@$post['ShortDesc']) ? $post['ShortDesc'] : '';
                    $editData['LongDesc']           = (@$post['LongDesc']) ? $post['LongDesc'] : '';
                    $editData['HowToReachDesc']     = (@$post['HowToReachDesc']) ? $post['HowToReachDesc'] : '';
                    $editData['XRefAirportCode']    = (@$post['XRefAirportCode']) ? $post['XRefAirportCode'] : '';
                    $editData['TravelByAirDesc']    = (@$post['TravelByAirDesc']) ? $post['TravelByAirDesc'] : '';

                    $editData['CanTravelByTrain']   = (@$post['CanTravelByTrain']) ? $post['CanTravelByTrain'] : '';
                    $editData['TravelByTrainDesc']  = (@$post['TravelByTrainDesc']) ? $post['TravelByTrainDesc'] : '';
                    $editData['CanTravelByBus']     = (@$post['CanTravelByBus']) ? $post['CanTravelByBus'] : '';
                    $editData['TravelByBusDesc']    = (@$post['TravelByBusDesc']) ? $post['TravelByBusDesc'] : '';
                    $editData['CanTravelByCar']     = (@$post['CanTravelByCar']) ? $post['CanTravelByCar'] : '';

                    $editData['TravelByCarDesc']    = (@$post['TravelByCarDesc']) ? $post['TravelByCarDesc'] : '';
                    $editData['TimeToVisitMask']    = (@$post['TimeToVisitMask']) ? $post['TimeToVisitMask'] : '';
                    $editData['ActivityMask']       = (@$post['ActivityMask']) ? $post['ActivityMask'] : '';
                    $editData['SeasonMask']         = (@$post['SeasonMask']) ? $post['SeasonMask'] : '';
                    $editData['GetLat']             = (@$post['GetLat']) ? $post['GetLat'] : '';

                    $editData['GetLong']            = (@$post['GetLong']) ? $post['GetLong'] : '';
                    $editData['StateSysId']         = (@$post['state_listing']) ? $post['state_listing'] : '';
                    $editData['ZoneSysId']          = (@$post['ZoneSysId']) ? $post['ZoneSysId'] : '';
                    $editData['ContSysId']          = (@$post['country_id']) ? $post['country_id'] : '';
                    $editData['PIN']                = (@$post['PIN']) ? $post['PIN'] : '';

                    $editData['IsHaveAirPort']      = (@$post['IsHaveAirPort']) ? $post['IsHaveAirPort'] : '';
                    $editData['UpdateDate']         = date('Y-m-d h:i:s');
					$editData['isActive']           = 1;

					
					$where      = array('CityId =?'=> $cityid);
					$isupdated  = $this->cityMdl->updateTable($this->tablename, $editData, $where);
                    
                    if($isupdated) {
                        $this->_helper->flashMessenger->addMessage("City updated successfully.");
						$this->_redirect("city/");
                    }
					
                }
                catch (Zend_Db_Exception $error)
                {
                    $this->view->error_msg = $error->getMessage(); 
                }

			} 
				
			// get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $result     = $this->cityMdl->getDetailsByUniqueId($this->tablename, array('*'), $uniqueId, $uniqueIdVal);
			
            $tablename      = "TB_Master_PlaceType";
            $uniqueId       = "IsActive";
            $uniqueIdVal    = 1;
            $cityCategoryListing   = $this->cityMdl->getRecordListing($tablename, array('Title','PlaceType','IsActive'), $uniqueId, $uniqueIdVal, "Title", "ASC");
            
            // get country and state
            $countrylist    = $this->cityMdl->getRecordListingWhere('TB_Master_Geo_Country', array('Title','ContId','IsActive'), array('IsActive'=>1));
            $state          = $this->cityMdl->getRecordListingWhere('TB_Master_Geo_State', array('Title','StateId','IsActive'), array('IsActive'=>1));
            
						
			// echo "<pre>"; print_r($state); die;
            
            $this->view->messages               = $this->_helper->flashMessenger->getMessages();
            $this->view->result                 = $result;
            $this->view->country                = $countrylist;
            $this->view->state                  = $state;
            $this->view->cityCategoryListing    = $cityCategoryListing;	
		 }
        else 
		{
            $this->_redirect("city/");
        }	
    }
	
	
    public function getstateajaxAction()
    {
        $this->_helper->layout()->disableLayout('');
        if ($this->_request->isXmlHttpRequest()) { 
            $country_id = $this->getRequest()->getParam('countrycode');
            $tablename  = "TB_Master_Geo_State";
            $uniqueId   = "ContSysId";
            $uniqueIdVal= $country_id;
			
			$stateList     = $this->cityMdl->getRecordListing($tablename, array('StateId','Title'), $uniqueId, $uniqueIdVal);
			//echo "<pre>";print_r($stateList);die;
			
            $select = '<option value="">--Select--</option>';
            
			if($stateList!=""){
                foreach($stateList as $val){ 
					$select .= '<option value="'.$val['StateId'].'">'.$val['Title'].'</option>';
				}
            }    
                       
            echo $select;  
        }
        exit;
    }
	
    public function getcityajaxAction()
    {
        $this->_helper->layout()->disableLayout('');
        if ($this->_request->isXmlHttpRequest()) { 
            $country_id = $this->getRequest()->getParam('countryid');
			$state_id = $this->getRequest()->getParam('stateid');
            
			$where = array('IsMarkForDel'=>'0', 'ContSysId'=>$country_id, 'StateSysId'=>$state_id);
			
			$cityList = $this->cityMdl->getRecordListingWhere($this->tablename,array('CityId','Title'),$where,"Title", "ASC"); // call Method	
			//echo "<pre>";print_r($stateList);die;
			
            $select = '<option value="">--Select--</option>';
            
			if($cityList!=""){
                foreach($cityList as $val){ 
                 $select .= '<option value="'.$val['CityId'].'">'.$val['Title'].'</option>';
				}
            }    
                       
            echo $select;  
        }
        exit;
    }
	

    public function overviewAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $result     = $this->cityMdl->getDetailsByUniqueId($this->tablename, array('*'), $uniqueId, $uniqueIdVal);
            
            if($this->getRequest()->isPost())
            {
                $post   = $this->getRequest()->getPost();
//                echo "<pre>"; print_r($post['seasons']); die;
                
                try {

                    $editData   = array();
                    $editData['Title']              = ($post['Title']) ? $post['Title'] : '';

                    $editData['CityCategoryMask']   = implode(",", $post['CityCategoryMask']);
                    $editData['Synonyms']           = ($post['Synonyms']) ? $post['Synonyms'] : '';
                    $editData['AltTag']             = ($post['AltTag']) ? $post['AltTag'] : '';
                    
                    $editData['ImageTitle']         = ($post['ImageTitle']) ? $post['ImageTitle'] : '';
                    $editData['ImageReference']     = ($post['ImageReference']) ? $post['ImageReference'] : '';
                    $editData['ShortDesc']          = ($post['ShortDesc']) ? $post['ShortDesc'] : '';
                    $editData['LongDesc']           = ($post['LongDesc']) ? $post['LongDesc'] : '';
                    $editData['HowToReachDesc']     = ($post['HowToReachDesc']) ? $post['HowToReachDesc'] : '';

                    $editData['XRefAirportCode']    = ($post['XRefAirportCode']) ? $post['XRefAirportCode'] : '';
                    $editData['TravelByAirDesc']    = ($post['TravelByAirDesc']) ? $post['TravelByAirDesc'] : '';
                    $editData['CanTravelByAir']     = (@$post['CanTravelByAir']) ? $post['CanTravelByAir'] : '';
                    $editData['IsHaveAirPort']      = (@$post['CanTravelByAir']) ? $post['CanTravelByAir'] : '';
                    
                    $editData['CanTravelByTrain']   = (@$post['CanTravelByTrain']) ? $post['CanTravelByTrain'] : '';
                    $editData['TravelByTrainDesc']  = ($post['TravelByTrainDesc']) ? $post['TravelByTrainDesc'] : '';
                    $editData['CanTravelByBus']     = (@$post['CanTravelByBus']) ? $post['CanTravelByBus'] : '';
                    $editData['TravelByBusDesc']    = ($post['TravelByBusDesc']) ? $post['TravelByBusDesc'] : '';
                    $editData['CanTravelByCar']     = (@$post['CanTravelByCar']) ? $post['CanTravelByCar'] : '';

                    $editData['TravelByCarDesc']    = ($post['TravelByCarDesc']) ? $post['TravelByCarDesc'] : '';
                    $editData['TimeToVisitMask']    = implode(",", $post['TimeToVisitMask']);
                    $editData['ActivityMask']       = implode(",", $post['ActivityMask']);
//                    $editData['SeasonMask']         = ($post['SeasonMask']) ? $post['SeasonMask'] : '';
                    $editData['GetLat']             = ($post['GetLat']) ? $post['GetLat'] : '';

                    $editData['GetLong']            = ($post['GetLong']) ? $post['GetLong'] : '';
                    $editData['StateSysId']         = ($post['StateSysId']) ? $post['StateSysId'] : '';
//                    $editData['ZoneSysId']          = ($post['ZoneSysId']) ? $post['ZoneSysId'] : '';
                    $editData['ContSysId']          = ($post['ContSysId']) ? $post['ContSysId'] : '';
                    $editData['PIN']                = ($post['PIN']) ? $post['PIN'] : '';

//                    $editData['page_title']         = ($post['page_title']) ? $post['page_title'] : '';
//                    $editData['meta_key']           = ($post['meta_key']) ? $post['meta_key'] : '';
//                    $editData['meta_desc']          = ($post['meta_desc']) ? $post['meta_desc'] : '';

                    $editData['UpdateDate']         = date('Y-m-d h:i:s');

// start : image upload 
                $strCityName            = $editData['Title'];
                $orignalFileName        = $_FILES['ThumbnailImg']['name'];
                $orignalBannerFileName  = $_FILES['BannerImg']['name'];


                /********************  city Image Starts *****************/
                if(!empty($orignalFileName)) {
                    
                    // remove old file
                    $originalThumbFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/images/thumb";
                    @unlink($originalThumbFolder. '/' .trim($result['ThumbnailImg']));
                    
                    $originalSmallFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/images/small";
                    @unlink($originalSmallFolder. '/' .trim($result['ThumbnailImg']));
                    
                    /* Get File Extension */
                    $fileExt        = $this->_helper->General->getFileExtension($orignalFileName);
                    $fileName       =  $strCityName . '_' . $cityid. '.'.$fileExt;

                    /* Create directory if not exists */
                    if (!file_exists($originalThumbFolder)) {
                        @mkdir($originalThumbFolder, 0777, true);
                    }
                    if (!file_exists($originalSmallFolder)) {
                        @mkdir($originalSmallFolder, 0777, true);
                    }
                    
                    $temp_file_name = $_FILES["ThumbnailImg"]["tmp_name"]; // temprary file name
                    
                    @move_uploaded_file($temp_file_name, $originalSmallFolder . "/" . $fileName);
                    $objImageResize = new Catabatic_Imageresize($originalSmallFolder . '/' . $fileName);
                    $objImageResize->resizeImage(250,250, 'exact');
                    $objImageResize->saveImage($originalSmallFolder.'/'.$fileName);

                    @copy($originalSmallFolder.'/'.$fileName, $originalThumbFolder . "/" . $fileName); // copy uploaded file into this location directory
                    $objImageResize1 = new Catabatic_Imageresize($originalThumbFolder . '/' . $fileName);
                    $objImageResize1->resizeImage(130,130, 'exact');
                    $objImageResize1->saveImage($originalThumbFolder.'/'.$fileName);
                    
                    $editData['ThumbnailImg']       = $fileName;
                }
                /********************  city Image Ends *****************/

                if(!empty($orignalBannerFileName)) {
                    // remove old file
                    $originalBannerFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/images/banner";
                    @unlink($originalBannerFolder. '/' .trim($result['BannerImg']));

                    /* Get File Extension */
                    $bannerFileExt  = $this->_helper->General->getFileExtension($orignalBannerFileName);
                    $bannerFileName	=  $strCityName . '_' . $cityid. '.'.$bannerFileExt;
                
                    $originalBannerFolder = $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/images/banner";

                    /* Create directory if not exists */
                    if (!file_exists($originalBannerFolder)) {
                        @mkdir($originalBannerFolder, 0777, true);
                    }
                    move_uploaded_file($_FILES["BannerImg"]["tmp_name"], $originalBannerFolder . "/" . $bannerFileName);

                    $objImageResize = new Catabatic_Imageresize($originalBannerFolder . '/' . $bannerFileName);
                    $objImageResize->resizeImage(600,300, 'exact');
                    $objImageResize->saveImage($originalBannerFolder.'/'.$bannerFileName);
                    
                    $editData['BannerImg']          = $bannerFileName;

                }
                /********************  Banner Image Ends *****************/
                
// end : image upload 
                    

                    
                    $where      = array('CityId =?'=> $cityid);
                    $isupdated  = $this->cityMdl->updateTable($this->tablename, $editData, $where);
                    
                    if($isupdated) {
                        $this->_helper->flashMessenger->addMessage("Record updated successfully.");
	                $this->_redirect("city/overview/cityid/$cityid");
                    }
                    
                }
                catch (Zend_Db_Exception $error)
                {
                    $this->view->error_msg = $error->getMessage();
                }

            }

            $tablename      = "TB_Master_PlaceType";
            $uniqueId       = "IsActive";
            $uniqueIdVal    = 1;
            $placeCategoryListing   = $this->cityMdl->getRecordListing($tablename, array('Title','PlaceType','IsActive'), $uniqueId, $uniqueIdVal, '', "Title", "ASC");
            
            // get country and state
            $country    = $this->cityMdl->getRecordListingWhere('TB_Master_Geo_Country', array('Title','ContId','IsActive'), array('IsActive'=>1));
            
//            print_r($country); die;
            
            $state      = $this->cityMdl->getRecordListingWhere('TB_Master_Geo_State', array('Title','StateId','IsActive'), array('IsActive'=>1));
            $activities = $this->cityMdl->getRecordListingWhere('TB_IC_Activity', array('ActivitySysId','Title','ActivityType','CitySysId'), array('CitySysId'=>$cityid));
            
            $t1             = 'TB_Master_Airport';
            $t2             = 'TB_Master_Geo_City';
            $colsArr1       = array('AirportCode','AirportTitle','CityId','ISO');
            $colsArr2       = array('Title as cityname');
            $joinGlueArr    = array('CityId','CityId');
            $whereArr       = array('IsActive'=>1, 'CountrySysId'=>$result['ContSysId']);
            $whereFromTbl   = 1; // where condition in which table
            
//            $airports   = $this->cityMdl->getRecordListingWhere('TB_Master_Airport', array('AirportCode','AirportTitle','CityId','ISO'), array('IsActive'=>1, 'CountrySysId'=>$result['ContSysId']));
            $airports   = $this->cityMdl->getRecordListingFromTwoTablesWhere($t1, $colsArr1, $t2, $colsArr2, $joinGlueArr, $whereArr, $whereFromTbl);
            
//            $seasons        = $this->cityMdl->getRecordListingWhere('TB_Master_Seasons', array('SeasonId','Title'), array('IsActive'=>1));
//            $city_seasons   = $this->cityMdl->getRecordListingWhere('TB_Master_City_Seasons', array('SeasonId','CitySysId','CitySeasonMask'), array('IsActive'=>1, 'CitySysId'=> $cityid));
            
            
            
            
            $t1             = 'TB_Master_Seasons';
            $t2             = 'TB_Master_City_Seasons';
            $colsArr1       = array('SeasonId','Title as seasonTitle');
            $colsArr2       = array('CitySysId','CitySeasonMask','IsActive');
            $joinGlueArr    = array('SeasonId','SeasonId');
            $whereArr       = array('CitySysId'=> $cityid);
            $whereFromTbl   = 2;
            
            $seasons    = $this->cityMdl->getRecordListingFromTwoTablesWhere($t1, $colsArr1, $t2, $colsArr2, $joinGlueArr, $whereArr, $whereFromTbl);
            
//            echo "<pre>"; print_r($seasons); die;

            $this->view->messages               = $this->_helper->flashMessenger->getMessages();
            $this->view->result                 = $result;
            $this->view->country                = $country;
            $this->view->state                  = $state;
            $this->view->placeCategoryListing   = $placeCategoryListing;
            $this->view->activities             = $activities;
            $this->view->airports               = $airports;

            $this->view->seasons                = $seasons;

            $this->view->others = array('baseUrl' => $this->baseUrl,
                'action_name'=> 'overview',
                'noimgUrl'=> $this->_helper->Image->getNoImageUrl('general', 'thumb'),
                'imageUrl'=> $this->imageUrl
                );
            
        }
        else {
            $this->_redirect("city/");
        }
        
    }

    public function placesToEatAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, "IsMarkForDel"=>0, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceToEat";
            $colsArr    = array('Title', 'Address1', 'Timing', 'Speciality', 'Rate', 'ThumnailImg','PlaceToEatSysId');
            $whereArr   = array("IsActive"=>1 , "IsMarkForDel"=>0,);
            $orderby    = "PlaceToEatSysId";
            $order      = "DESC";
            
            $searchArr  = array();
            if($this->getRequest()->isPost()) {
                $keywords   = trim($this->getRequest()->getPost('keywords'));
                if(!empty($keywords))
                $searchArr  = array('Title' => $keywords, 'Speciality' => $keywords, 'Address1' => $keywords);
            }

            $resultset  = $this->cityMdl->getRecordListingWhere($table, $colsArr, $whereArr, $orderby, $order, $searchArr);

            # Start : Pagination 
            $page       = $this->_getParam('page', 1);
            $resultset  = Zend_Paginator::factory($resultset);
            $resultset->setItemCountPerPage($this->per_page_record);
            $resultset->setCurrentPageNumber($page);
            # End : Pagination 

            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-eat', 'searchArr' => $searchArr);
            $this->view->resultset      = $resultset;
            $this->view->messages = $this->_helper->flashMessenger->getMessages(); 
        }
        
    }
    
    
    public function placesToEatNewAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
                    
            $form = new Travel_Form_PlacesToEat();
        
            $form->setAction($this->baseUrl."/city/places-to-eat-new/cityid/" . $cityid)->setMethod("POST")->setName("placesToEatForm");
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                    $strFileName        = $this->_helper->General->toTitle($post['Title']);
                    $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                    $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                    $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-to-eat/thumb";
                    
                    /* Create directory if not exists */
                    if (!file_exists($originalThumbFolder)) {
                        @mkdir($originalThumbFolder, 0777, true);
                    }
                    
                    $upload = new Zend_File_Transfer_Adapter_Http();
                    $upload->setDestination("public/upload/city/".$cityid."/places-to-eat/thumb/");
                    $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-to-eat/thumb/".$fileName);
                    $file = $upload->getFileName();
                    
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = "";
                    }

                    try {
                    $upload->receive();

                    $addDataPlaceToEat = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'CitySysId'=> $cityid,
                                 'ZoneSysId'=> 0,
                                 'StateSysId'=> 0,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                                 'CreateDate'=> date('Y-m-d H:i:s'),
                                 'IsApproved'=> true,
                                 'IsActive'=> true,
                                 'IsMarkForDel'=> false,
                               );

                        if(!empty($updateimage))
                          $addDataPlaceToEat['ThumnailImg']  = $updateimage;
                    
                        $tablename  = 'TB_IC_City_PlaceToEat';
                        $this->cityMdl->insertTable($tablename, $addDataPlaceToEat);

                        $this->_helper->flashMessenger->addMessage("Record added successfully");
                        $this->_redirect("city/places-to-eat/cityid/$cityid");
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');
                    }                    
                    catch (Zend_Form_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                    }                    

                }
                
            }

        }
        
        $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-eat');
        $this->view->resultset      = array('CitySysId'=> $cityid);
        $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
    }
    
    
    public function placesToEatEditAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        $encodeId   = ($this->getRequest()->getParam('id'));
        $intId      = (int)base64_decode($encodeId);

        $this->_helper->viewRenderer("places-to-eat-new");
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceToEat";
            $colsArr    = array('*');
            $resultset  = $this->cityMdl->getDetailsByUniqueId($table, $colsArr, 'PlaceToEatSysId', $intId);

            $form = new Travel_Form_PlacesToEat();
        
            $form->setAction($this->baseUrl."/city/places-to-eat-edit/cityid/$cityid/id/$encodeId")->setMethod("POST")->setName("placesToEatForm");

            $editdata = array(
                        'Title'=> $resultset['Title'],
                        'Address1'=> $resultset['Address1'],
                        'Address2'=> $resultset['Address2'],
                        'Timing'=> $resultset['Timing'],
                        'Latitude'=> $resultset['Latitude'],
                        'Longitude'=> $resultset['Longitude'],
                        'Speciality'=> $resultset['Speciality'],
                        'Rate'=> $resultset['Rate'],
                        'ImgTitle'=> $resultset['ImgTitle'],
                        'ImgReference'=> $resultset['ImgReference'],
                        'Alttag'=> $resultset['Alttag'],
                      );

            $form->populate($editdata);
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    if(!empty($_FILES['ThumnailImg']['name'])) {
                        $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                        $strFileName        = $this->_helper->General->toTitle($post['Title']);
                        $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                        $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                        $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-to-eat/thumb";

                        /* Create directory if not exists */
                        if (!file_exists($originalThumbFolder)) {
                            @mkdir($originalThumbFolder, 0777, true);
                        }

                        $upload = new Zend_File_Transfer_Adapter_Http();
                        $upload->setDestination("public/upload/city/".$cityid."/places-to-eat/thumb/");
                        $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-to-eat/thumb/".$fileName);
                        $file = $upload->getFileName();
                
                    }
                
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = $resultset['ThumnailImg'];
                    }

                    try {
                        if(!empty($_FILES['ThumnailImg']['name'])) {
                            $upload->receive();
                        }
                        $editDataPlaceToEat = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'ThumnailImg'=> $updateimage,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                               );

                        $tablename  = 'TB_IC_City_PlaceToEat';
                        $where      = array('PlaceToEatSysId =?'=> $intId);
                        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

                        $this->_helper->flashMessenger->addMessage("Record updated successfully");
                        $this->_redirect("city/places-to-eat/cityid/$cityid");
                        
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');                          
                    }
                    
                }
            }


            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-eat');
            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->resultset      = $resultset;

        }
        
    }
    
    
    public function placesToEatDeleteAction()
    {
        // disable layout...
        $this->_helper->layout->disableLayout();
        $intId = base64_decode($this->getRequest()->getParam('id'));
        $cityid = ($this->getRequest()->getParam('cityid'));
        $editDataPlaceToEat = array(
                    "IsMarkForDel" => 1
                );
        $tablename  = 'TB_IC_City_PlaceToEat';
        $where      = array('PlaceToEatSysId =?'=> $intId);
        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

        $this->_helper->flashMessenger->addMessage("Record deleted successfully.");
        $this->_redirect("city/places-to-eat/cityid/$cityid");
        
    }
    
    
    
    public function placesToShopAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, "IsMarkForDel"=>0, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceToShop";
            $colsArr    = array('Title', 'Address1', 'Timing', 'Speciality', 'Rate', 'ThumnailImg','PlaceToShopSysId');
            $whereArr   = array("IsActive"=>1 , "IsMarkForDel"=>0,);
            $orderby    = "PlaceToShopSysId";
            $order      = "DESC";
            
            $searchArr  = array();
            if($this->getRequest()->isPost()) {
                $keywords   = trim($this->getRequest()->getPost('keywords'));
                if(!empty($keywords))
                $searchArr  = array('Title' => $keywords, 'Speciality' => $keywords, 'Address1' => $keywords);
            }

            $resultset  = $this->cityMdl->getRecordListingWhere($table, $colsArr, $whereArr, $orderby, $order, $searchArr);

            # Start : Pagination 
            $page       = $this->_getParam('page', 1);
            $resultset  = Zend_Paginator::factory($resultset);
            $resultset->setItemCountPerPage($this->per_page_record);
            $resultset->setCurrentPageNumber($page);
            # End : Pagination 

            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-shop', 'searchArr' => $searchArr);
            $this->view->resultset      = $resultset;
            $this->view->messages       = $this->_helper->flashMessenger->getMessages(); 
        }
        
    }
    
    
    public function placesToShopNewAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
                    
            $form = new Travel_Form_PlacesToShop();
        
            $form->setAction($this->baseUrl."/city/places-to-shop-new/cityid/" . $cityid)->setMethod("POST")->setName("placesToShopForm");
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                    $strFileName        = $this->_helper->General->toTitle($post['Title']);
                    $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                    $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                    $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-to-shop/thumb";
                    
                    /* Create directory if not exists */
                    if (!file_exists($originalThumbFolder)) {
                        @mkdir($originalThumbFolder, 0777, true);
                    }
                    
                    $upload = new Zend_File_Transfer_Adapter_Http();
                    $upload->setDestination("public/upload/city/".$cityid."/places-to-shop/thumb/");
                    $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-to-shop/thumb/".$fileName);
                    $file = $upload->getFileName();
                    
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = "";
                    }

                    try {
                    $upload->receive();

                    $addDataPlaceToShop = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'CitySysId'=> $cityid,
                                 'ZoneSysId'=> 0,
                                 'StateSysId'=> 0,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                                 'CreateDate'=> date('Y-m-d H:i:s'),
                                 'IsApproved'=> true,
                                 'IsActive'=> true,
                                 'IsMarkForDel'=> false,
                               );

                        if(!empty($updateimage))
                          $addDataPlaceToShop['ThumnailImg']  = $updateimage;
                    
                        $tablename  = 'TB_IC_City_PlaceToShop';
                        $this->cityMdl->insertTable($tablename, $addDataPlaceToShop);

                        $this->_helper->flashMessenger->addMessage("Record added successfully");
                        $this->_redirect("city/places-to-shop/cityid/$cityid");
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');
                    }                    
                    catch (Zend_Form_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                    }                    

                }
                
            }

        }
        
        $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-shop');
        $this->view->resultset      = array('CitySysId'=> $cityid);
        $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
    }
    
    
    public function placesToShopEditAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        $encodeId   = ($this->getRequest()->getParam('id'));
        $intId      = (int)base64_decode($encodeId);

        $this->_helper->viewRenderer("places-to-shop-new");
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceToShop";
            $colsArr    = array('*');
            $resultset  = $this->cityMdl->getDetailsByUniqueId($table, $colsArr, 'PlaceToShopSysId', $intId);

            $form = new Travel_Form_PlacesToEat();
        
            $form->setAction($this->baseUrl."/city/places-to-shop-edit/cityid/$cityid/id/$encodeId")->setMethod("POST")->setName("placesToShopForm");

            $editdata = array(
                        'Title'=> $resultset['Title'],
                        'Address1'=> $resultset['Address1'],
                        'Address2'=> $resultset['Address2'],
                        'Timing'=> $resultset['Timing'],
                        'Latitude'=> $resultset['Latitude'],
                        'Longitude'=> $resultset['Longitude'],
                        'Speciality'=> $resultset['Speciality'],
                        'Rate'=> $resultset['Rate'],
                        'ImgTitle'=> $resultset['ImgTitle'],
                        'ImgReference'=> $resultset['ImgReference'],
                        'Alttag'=> $resultset['Alttag'],
                      );

            $form->populate($editdata);
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    if(!empty($_FILES['ThumnailImg']['name'])) {
                        $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                        $strFileName        = $this->_helper->General->toTitle($post['Title']);
                        $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                        $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                        $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-to-shop/thumb";

                        /* Create directory if not exists */
                        if (!file_exists($originalThumbFolder)) {
                            @mkdir($originalThumbFolder, 0777, true);
                        }

                        $upload = new Zend_File_Transfer_Adapter_Http();
                        $upload->setDestination("public/upload/city/".$cityid."/places-to-shop/thumb/");
                        $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-to-shop/thumb/".$fileName);
                        $file = $upload->getFileName();
                
                    }
                
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = $resultset['ThumnailImg'];
                    }

                    try {
                        if(!empty($_FILES['ThumnailImg']['name'])) {
                            $upload->receive();
                        }
                        $editDataPlaceToEat = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'ThumnailImg'=> $updateimage,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                               );

                        $tablename  = 'TB_IC_City_PlaceToShop';
                        $where      = array('PlaceToShopSysId =?'=> $intId);
                        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

                        $this->_helper->flashMessenger->addMessage("Record updated successfully");
                        $this->_redirect("city/places-to-shop/cityid/$cityid");
                        
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');                          
                    }
                    
                }
            }


            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-to-shop');
            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->resultset      = $resultset;

        }
        
    }
    
    
    public function placesToShopDeleteAction()
    {
        // disable layout...
        $this->_helper->layout->disableLayout();
        $intId = base64_decode($this->getRequest()->getParam('id'));
        $cityid = ($this->getRequest()->getParam('cityid'));
        $editDataPlaceToEat = array(
                    "IsMarkForDel" => 1
                );
        $tablename  = 'TB_IC_City_PlaceToShop';
        $where      = array('PlaceToShopSysId =?'=> $intId);
        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

        $this->_helper->flashMessenger->addMessage("Record deleted successfully.");
        $this->_redirect("city/places-to-shop/cityid/$cityid");
        
    }
    
    
    public function placesForActivitiesAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, "IsMarkForDel"=>0, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceForActivity";
            $colsArr    = array('Title', 'Address1', 'Timing', 'Speciality', 'Rate', 'ThumnailImg','PlaceForActivitySysId');
            $whereArr   = array("IsActive"=>1 , "IsMarkForDel"=>0,);
            $orderby    = "PlaceForActivitySysId";
            $order      = "DESC";
            
            $searchArr  = array();
            if($this->getRequest()->isPost()) {
                $keywords   = trim($this->getRequest()->getPost('keywords'));
                if(!empty($keywords))
                $searchArr  = array('Title' => $keywords, 'Speciality' => $keywords, 'Address1' => $keywords);
            }

            $resultset  = $this->cityMdl->getRecordListingWhere($table, $colsArr, $whereArr, $orderby, $order, $searchArr);

            # Start : Pagination 
            $page       = $this->_getParam('page', 1);
            $resultset  = Zend_Paginator::factory($resultset);
            $resultset->setItemCountPerPage($this->per_page_record);
            $resultset->setCurrentPageNumber($page);
            # End : Pagination 

            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-activities', 'searchArr' => $searchArr);
            $this->view->resultset      = $resultset;
            $this->view->messages       = $this->_helper->flashMessenger->getMessages(); 
        }
        
    }
    
    
    public function placesForActivitiesNewAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
                    
            $form = new Travel_Form_PlacesForActivities();
        
            $form->setAction($this->baseUrl."/city/places-for-activities-new/cityid/" . $cityid)->setMethod("POST")->setName("placesForActivitiesForm");
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                    $strFileName        = $this->_helper->General->toTitle($post['Title']);
                    $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                    $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                    $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-for-activities/thumb";
                    
                    /* Create directory if not exists */
                    if (!file_exists($originalThumbFolder)) {
                        @mkdir($originalThumbFolder, 0777, true);
                    }
                    
                    $upload = new Zend_File_Transfer_Adapter_Http();
                    $upload->setDestination("public/upload/city/".$cityid."/places-for-activities/thumb/");
                    $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-for-activities/thumb/".$fileName);
                    $file = $upload->getFileName();
                    
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = "";
                    }

                    try {
                    $upload->receive();

                    $addDataPlaceForActivities = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'CitySysId'=> $cityid,
                                 'ZoneSysId'=> 0,
                                 'StateSysId'=> 0,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                                 'CreateDate'=> date('Y-m-d H:i:s'),
                                 'IsApproved'=> true,
                                 'IsActive'=> true,
                                 'IsMarkForDel'=> false,
                               );

                        if(!empty($updateimage))
                          $addDataPlaceForActivities['ThumnailImg']  = $updateimage;
                    
                        $tablename  = 'TB_IC_City_PlaceForActivity';
                        $this->cityMdl->insertTable($tablename, $addDataPlaceForActivities);

                        $this->_helper->flashMessenger->addMessage("Record added successfully");
                        $this->_redirect("city/places-for-activities/cityid/$cityid");
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');
                    }                    
                    catch (Zend_Form_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                    }                    

                }
                
            }

        }
        
        $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-activities');
        $this->view->resultset      = array('CitySysId'=> $cityid);
        $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
    }
    
    
    public function placesForActivitiesEditAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        $encodeId   = ($this->getRequest()->getParam('id'));
        $intId      = (int)base64_decode($encodeId);

        $this->_helper->viewRenderer("places-for-activities-new");
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place to eat
            $table      = "TB_IC_City_PlaceForActivity";
            $colsArr    = array('*');
            $resultset  = $this->cityMdl->getDetailsByUniqueId($table, $colsArr, 'PlaceForActivitySysId', $intId);

            $form = new Travel_Form_PlacesForActivities();
        
            $form->setAction($this->baseUrl."/city/places-for-activities-edit/cityid/$cityid/id/$encodeId")->setMethod("POST")->setName("placesForActivitiesForm");

            $editdata = array(
                        'Title'=> $resultset['Title'],
                        'Address1'=> $resultset['Address1'],
                        'Address2'=> $resultset['Address2'],
                        'Timing'=> $resultset['Timing'],
                        'Latitude'=> $resultset['Latitude'],
                        'Longitude'=> $resultset['Longitude'],
                        'Speciality'=> $resultset['Speciality'],
                        'Rate'=> $resultset['Rate'],
                        'ImgTitle'=> $resultset['ImgTitle'],
                        'ImgReference'=> $resultset['ImgReference'],
                        'Alttag'=> $resultset['Alttag'],
                      );

            $form->populate($editdata);
        
            $this->view->form = $form;
            
            
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();

                if ($form->isValid($post)) {

                    if(!empty($_FILES['ThumnailImg']['name'])) {
                        $orignalFileName    = $_FILES['ThumnailImg']['name']; 
                        $strFileName        = $this->_helper->General->toTitle($post['Title']);
                        $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                        $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;
                        $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-for-activities/thumb";

                        /* Create directory if not exists */
                        if (!file_exists($originalThumbFolder)) {
                            @mkdir($originalThumbFolder, 0777, true);
                        }

                        $upload = new Zend_File_Transfer_Adapter_Http();
                        $upload->setDestination("public/upload/city/".$cityid."/places-for-activities/thumb/");
                        $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-for-activities/thumb/".$fileName);
                        $file = $upload->getFileName();
                
                    }
                
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = $resultset['ThumnailImg'];
                    }

                    try {
                        if(!empty($_FILES['ThumnailImg']['name'])) {
                            $upload->receive();
                        }
                        $editDataPlaceToEat = array(
                                 'Title'=> $post['Title'],
                                 'Address1'=> $post['Address1'],
                                 'Address2'=> $post['Address2'],
                                 'Timing'=> $post['Timing'],
                                 'Latitude'=> $post['Latitude'],
                                 'Longitude'=> $post['Longitude'],
                                 'Speciality'=> $post['Speciality'],
                                 'Rate'=> $post['Rate'],
                                 'ImgTitle'=> $post['ImgTitle'],
                                 'ImgReference'=> $post['ImgReference'],
                                 'Alttag'=> $post['Alttag'],
                                 'ThumnailImg'=> $updateimage,
                                 'UpdateDate'=> date('Y-m-d H:i:s'),
                               );

                        $tablename  = 'TB_IC_City_PlaceForActivity';
                        $where      = array('PlaceForActivitySysId =?'=> $intId);
                        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

                        $this->_helper->flashMessenger->addMessage("Record updated successfully");
                        $this->_redirect("city/places-for-activities/cityid/$cityid");
                        
                    }
                    catch (Zend_File_Transfer_Exception $e) {
                        $this->view->error_msg  = $e->getMessage();
                        $this->renderScript('error/error_technical.phtml');                          
                    }
                    
                }
            }


            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-activities');
            $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->resultset      = $resultset;

        }
        
    }
    
    
    public function placesForActivitiesDeleteAction()
    {
        // disable layout...
        $this->_helper->layout->disableLayout();
        $intId = base64_decode($this->getRequest()->getParam('id'));
        $cityid = ($this->getRequest()->getParam('cityid'));
        $editDataPlaceToEat = array(
                    "IsMarkForDel" => 1
                );
        $tablename  = 'TB_IC_City_PlaceForActivity';
        $where      = array('PlaceForActivitySysId =?'=> $intId);
        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

        $this->_helper->flashMessenger->addMessage("Record deleted successfully.");
        $this->_redirect("city/places-for-activities/cityid/$cityid");
        
    }
    
    
    
    
    
    
    
    
    public function placesForEventsAction()
    {
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
         if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, "IsMarkForDel"=>0, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
        /********** SEARCH CODE START   *****************/
        $searchArr = array();
        $getData = array();

		if($this->getRequest()->isPost())
        {
			$getData = $this->getRequest()->getPost();
            if(!empty($getData))
            {
                $search_data  = (@$getData['search']!='') ? @$getData['search'] : '';
			    $searchArr = array('search' => $search_data);
			    //print_r($getData);
			} 
			
		} 
		else
		{ 	$this->getRequest()->getParam('search');
			$search_data   = $this->_getParam('search');
			$search_data   = (@$search_data!='') ? $search_data : '';
			$searchArr = array('search' => $search_data);
			//print_r($searchArr);
		}
			//print_r($searchArr);
			$this->cityMdl->searchArr = $searchArr; // send Array - searchArr() to modal just for pagination
			$this->view->searchArr = $searchArr;
		
		/********** SEARCH CODE END   *****************/
        
		
		# get listings of place to eat
            $table      = "TB_IC_City_PlaceForEvent";
            $colsArr    = array('Title', 'Address1', 'Timing', 'Speciality', 'Rate', 'ThumnailImg','Alttag','PlaceForEventSysId');
            $whereArr   = array("IsActive"=>1 , "IsMarkForDel"=>0,);
            $orderby    = "PlaceForEventSysId";
            $order      = "DESC";
            
            $resultset  = $this->cityMdl->getRecordListingWhereWithSearch($table, $colsArr, $whereArr, $orderby, $order);

		# Start : Pagination 
            $page       = $this->_getParam('page', 1);
            $resultset  = Zend_Paginator::factory($resultset);
            $resultset->setItemCountPerPage($this->per_page_record);
            $resultset->setCurrentPageNumber($page);
        # End : Pagination 
			
			$this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
            $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-events');
            $this->view->resultset      = $resultset;
            $this->view->messages       = $this->_helper->flashMessenger->getMessages(); 
        }
		
    }
	
    
    public function placesForEventsNewAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        
        if(!empty($cityid) || !is_int($cityid) )
        {
            
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);

            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();
				
				/*************** Image Uploading Start ***************/
					$orignalFileName    = $_FILES['upload']['name']; 
                    $strFileName        = $this->_helper->General->toTitle($post['title']);
                    $fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
                    $fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;

                    $originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-for-events/thumb";

                    /* Create directory if not exists */
                    if (!file_exists($originalThumbFolder)) {
                        @mkdir($originalThumbFolder, 0777, true);
                    }
                    
                    $upload = new Zend_File_Transfer_Adapter_Http();

                    $upload->setDestination("public/upload/city/".$cityid."/places-for-events/thumb/");
                    $upload->addFilter('Rename', "public/upload/city/".$cityid."/places-for-events/thumb/".$fileName);

                    $file = $upload->getFileName();
                    
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = "";
                    }
				/*************** Image Uploading End *****************/
				try {
					
					$upload->receive(); // Upload image
					
                    $addData   = array();

                    $addData['Title']          = (@$post['title']) ? $post['title'] : '';
                    $addData['Address1']       = (@$post['address1']) ? $post['address1'] : '';
                    $addData['Address2']       = (@$post['address2']) ? $post['address2'] : '';
                    $addData['Timing']         = (@$post['timing']) ? $post['timing'] : 0;
                    $addData['Latitude']       = (@$post['latitude']) ? $post['latitude'] : '';
					$addData['Longitude']      = (@$post['longitude']) ? $post['longitude'] : '';
					$addData['Speciality']     = (@$post['speciality']) ? $post['speciality'] : '';
					$addData['Rate']           = (@$post['rate']) ? $post['rate'] : '';
					$addData['ImgTitle']       = (@$post['img_title']) ? $post['img_title'] : '';
					$addData['ThumnailImg']    = $updateimage;
					$addData['ImgReference']   = (@$post['img_reference']) ? $post['img_reference'] : '';
					$addData['Alttag']         = (@$post['img_alt']) ? $post['img_alt'] : '';
					$addData['CitySysId']      = $cityid;
					$addData['ZoneSysId']      = 0;
					$addData['ZoneType']       = 0;
					$addData['StateSysId']     = $city_details['StateId'];
					$addData['CreateDate']     = date('Y-m-d h:i:s');
					$addData['IsApproved']     = 1;
					$addData['IsActive']       = 1;
					$addData['IsMarkForDel']   = 0;

					
					// check city name already exists or not ( Avoid duplicate city entry)
					
					if($cityid!=''){
						$placeEventName    = $this->cityMdl->getRecordListingWhere('TB_IC_City_PlaceForEvent', array('Title'), array('IsActive'=>1,'Title'=>$addData['Title'],'CitySysId'=>$addData['CitySysId'], 'Address1'=>$addData['Address1'],'Latitude'=>$addData['Latitude'], 'Longitude'=>$addData['Longitude']),'Title');
					}
					
					//print_r($placeEventName); echo count($placeEventName);
					if(count($placeEventName)>=1){
						
							$this->_helper->flashMessenger->addMessage("Place for event already exists.");
							$this->_redirect("city/places-for-events-new/cityid/$cityid");
					} 
					else
					{
						$isinserted = $this->cityMdl->insertTable('TB_IC_City_PlaceForEvent', $addData); 
						if($isinserted) {
							$this->_helper->flashMessenger->addMessage("Record inserted successfully.");
							$this->_redirect("city/places-for-events/cityid/$cityid");
						}
						
					}
					
				}
                catch (Zend_Db_Exception $error)
                {
                    $this->view->error_msg = $error->getMessage(); 
                }
            }

        }
        
        $this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-events');
        $this->view->resultset      = array('CitySysId'=> $cityid);
        $this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
		
    }
    
	public function placesForEventsEditAction()
    {
        
        $cityid     = (int)$this->getRequest()->getParam('cityid');
        $encodeId   = ($this->getRequest()->getParam('id'));
        $intId      = (int)base64_decode($encodeId);
        
        if(!empty($cityid) || !is_int($cityid) )
        {
             
			 
            // get City record details
            $uniqueId   = "CityId";
            $uniqueIdVal= $cityid;
            $table1     = "TB_Master_Geo_City";
            $table2     = "TB_Master_Geo_State";
            $table3     = "TB_Master_Geo_Country";
            $colsArr1   = array('Title as cityname','GetLat','GetLong','CityId');
            $colsArr2   = array('Title as statename','StateId');
            $colsArr3   = array('Title as countryname');
            $joinCols1  = array("StateSysId","StateId"); // ON First and Second table
            $joinCols2  = array("ContSysId","ContId"); // ON Second and Third table
            $whereArr   = array("IsActive"=>1, 'CityId'=> $cityid);
            $orderby    = "CityId";
            $order      = "DESC";

            $city_details   = $this->cityMdl->getRecordFromThreeTablesById($table1, $colsArr1, $table2, $colsArr2, $table3, $colsArr3, $joinCols1, $joinCols2, $whereArr, $orderby, $order);
            
            # get listings of place for events
			$table      = "TB_IC_City_PlaceForEvent";
            $colsArr    = array('*');
            $resultset  = $this->cityMdl->getDetailsByUniqueId($table, $colsArr, 'PlaceForEventSysId', $intId);
			
            if ($this->getRequest()->isPost()) {

                $post = $this->getRequest()->getPost();
				
				/*************** Image Uploading Start ***************/
					if(!empty($_FILES['upload']['name'])) {
						$orignalFileName    = $_FILES['upload']['name']; 
						$strFileName        = $this->_helper->General->toTitle($post['title']);
						$fileExt            = $this->_helper->General->getFileExtension($orignalFileName);
						$fileName           = $strFileName . '_' . $cityid. '_' .time(). '.'.$fileExt;

						$originalThumbFolder= $_SERVER["DOCUMENT_ROOT"] . "/public/upload/city/".$cityid."/places-for-events/thumb";

						/* Create directory if not exists */
						if (!file_exists($originalThumbFolder)) {
							@mkdir($originalThumbFolder, 0777, true);
						}
						
						$upload = new Zend_File_Transfer_Adapter_Http();

						$upload->setDestination("public/upload/city/".$cityid."/places-for-events/thumb/");
						$upload->addFilter('Rename', "public/upload/city/".$cityid."/places-for-events/thumb/".$fileName);

						$file = $upload->getFileName();
					}	
                    
                    if(isset($orignalFileName) && $orignalFileName!="")
                    {
                        $updateimage = $fileName;
                    } else {
                        $updateimage = $resultset['ThumnailImg'];
                    }
					
				/*************** Image Uploading End *****************/
				try {
					
						if(!empty($_FILES['upload']['name'])) {
                            $upload->receive(); // Upload image
                        }
					
                    $editData   = array();

                    $editData['Title']          = (@$post['title']) ? $post['title'] : '';
                    $editData['Address1']       = (@$post['address1']) ? $post['address1'] : '';
                    $editData['Address2']       = (@$post['address2']) ? $post['address2'] : '';
                    $editData['Timing']         = (@$post['timing']) ? $post['timing'] : 0;
                    $editData['Latitude']       = (@$post['latitude']) ? $post['latitude'] : '';
					$editData['Longitude']      = (@$post['longitude']) ? $post['longitude'] : '';
					$editData['Speciality']     = (@$post['speciality']) ? $post['speciality'] : '';
					$editData['Rate']           = (@$post['rate']) ? $post['rate'] : '';
					$editData['ImgTitle']       = (@$post['img_title']) ? $post['img_title'] : '';
					$editData['ThumnailImg']    = $updateimage;
					$editData['ImgReference']   = (@$post['img_reference']) ? $post['img_reference'] : '';
					$editData['Alttag']         = (@$post['img_alt']) ? $post['img_alt'] : '';
					$editData['CitySysId']      = $cityid;
					$editData['ZoneSysId']      = 0;
					$editData['ZoneType']       = 0;
					$editData['StateSysId']     = $resultset['StateSysId'];
					$editData['UpdateDate']     = date('Y-m-d h:i:s');
					$editData['IsApproved']     = 1;
					$editData['IsActive']       = 1;
					$editData['IsMarkForDel']   = 0;

					//print_r($placeEventName); echo count($placeEventName);
					$tablename  = 'TB_IC_City_PlaceForEvent';
					$where      = array('PlaceForEventSysId =?'=> $intId);
					$this->cityMdl->updateTable($tablename, $editData, $where);

					$this->_helper->flashMessenger->addMessage("Record updated successfully");
					$this->_redirect("city/places-for-events/cityid/$cityid");
						
						
					
					
				}
                catch (Zend_Db_Exception $error)
                {
                    $this->view->error_msg = $error->getMessage(); 
                }
				
			}
			
			$this->view->messages  = $this->_helper->flashMessenger->getMessages();
			$this->view->others         = array('baseUrl' => $this->baseUrl, 'action_name'=> 'places-for-events');
			$this->view->basic_info     = array('CityId' => $city_details['CityId'], 'city' => $city_details['cityname'], 'state'=> $city_details['statename'], 'country'=> $city_details['countryname'], 'lat'=> $city_details['GetLat'], 'long'=> $city_details['GetLong']);
			$this->view->resultset      = $resultset;

        }
        
        		
    }
    
	public function placesForEventsDeleteAction()
    {
        // disable layout...
        $this->_helper->layout->disableLayout();
        $intId = base64_decode($this->getRequest()->getParam('id'));
        $cityid = ($this->getRequest()->getParam('cityid'));
        $editDataPlaceToEat = array(
                    "IsMarkForDel" => 1
                );
        $tablename  = 'TB_IC_City_PlaceForEvent';
        $where      = array('PlaceForEventSysId =?'=> $intId);
        $this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);

        $this->_helper->flashMessenger->addMessage("Record deleted successfully.");
        $this->_redirect("city/places-for-events/cityid/$cityid");
        
    }
	
    
    public function getlocationAction()
	{
        if ($this->getRequest()->isXmlHttpRequest())
		{
             /* Disable layout */
            $this->_helper->viewRenderer->setNoRender(true);

            $this->_helper->layout->disableLayout();
            $strAddress = $this->getRequest()->getPost('address');
            $arrLocation = $this->getHelper('General')->getLatitudeLongitude($strAddress);
            echo Zend_Json::encode($arrLocation);
            exit;
        }
    }
	
	public function filterStatusAction()
    {
        /* Disable Layout & set Render False */
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $filter  = $this->getRequest()->getParam('filter');
		$val     = $this->getRequest()->getParam('val');
		$CityId  = base64_decode( $this->getRequest()->getParam('id'));
        $currentPage  = $this->getRequest()->getParam('page');

		if($CityId && $filter) {
			if($filter == 'filter1'){
				$editData['IsActive']  = ($val == 0) ? 1 : 0;           
			}
			if($filter == 'filter2'){
				$editData['IsApproved']  = ($val == 0) ? 1 : 0;                
			}	
			
			$where      = array('CityId =?'=> $CityId);
			$isupdated  = $this->cityMdl->updateTable($this->tablename, $editData, $where);
			if($isupdated)
				{
					$this->_helper->flashMessenger->addMessage("Record Update successfully.");
					$this->_redirect("city/index/page/$currentPage");
				}
        }
        else {
                $this->_redirect("city/index/page/$currentPage");
         }   
        
    }

    
    
}

Youez - 2016 - github.com/yon3zu
LinuXploit