| 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/admin/controllers/ |
Upload File : |
<?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 Admin_CityController extends Catabatic_ValidateAdmin {
public $imageUrl = NULL;
public $baseUrl = '';
public $tablename = '';
public $cityMdl = '';
public $per_page_record = GRID_PER_PAGE_RECORD_COUNT;
public function init() {
parent::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;
$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("admin/city/index/page/$currentPage");
}
} else {
$this->_redirect("admin/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", $markForDel = 0);
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
// echo "<pre>";print_r($post);die;
try {
$addData = array();
$addData['Title'] = (@$post['cityname']) ? trim($this->sanitize_data($post['cityname'])) : '';
$addData['Alias'] = (@$post['Alias']) ? trim($this->sanitize_data($post['Alias'])) : $addData['Title'];
$addData['Code'] = (@$post['Code']) ? trim($this->sanitize_data($post['Code'])) : '';
$addData['StateOrZone'] = (@$post['StateOrZone']) ? trim($this->sanitize_data($post['StateOrZone'])) : 0;
$addData['Country'] = (@$post['Country']) ? trim($this->sanitize_data($post['Country'])) : '';
$addData['CityCategoryMask'] = "";
if (isset($post['citycategory']) && !empty($post['citycategory'])) {
$addData['CityCategoryMask'] = implode(',', $post['citycategory']);
} else {
$addData['CityCategoryMask'] = ' ';
}
$addData['Synonyms'] = (@$post['Synonyms']) ? trim($this->sanitize_data($post['Synonyms'])) : '';
$addData['ThumbnailImg'] = (@$post['ThumbnailImg']) ? trim($this->sanitize_data($post['ThumbnailImg'])) : '';
$addData['BannerImg'] = (@$post['BannerImg']) ? trim($this->sanitize_data($post['BannerImg'])) : '';
$addData['AltTag'] = (@$post['AltTag']) ? trim($this->sanitize_data($post['AltTag'])) : '';
$addData['ShortDesc'] = (@$post['ShortDesc']) ? trim($this->sanitize_data($post['ShortDesc'])) : '';
$addData['LongDesc'] = (@$post['LongDesc']) ? trim($this->sanitize_data($post['LongDesc'])) : '';
$addData['HowToReachDesc'] = (@$post['HowToReachDesc']) ? trim($this->sanitize_data($post['HowToReachDesc'])) : '';
$addData['XRefAirportCode'] = (@$post['XRefAirportCode']) ? trim($this->sanitize_data($post['XRefAirportCode'])) : '';
$addData['TravelByAirDesc'] = (@$post['TravelByAirDesc']) ? trim($this->sanitize_data($post['TravelByAirDesc'])) : '';
$addData['CanTravelByTrain'] = (@$post['CanTravelByTrain']) ? trim($this->sanitize_data($post['CanTravelByTrain'])) : '';
$addData['TravelByTrainDesc'] = (@$post['TravelByTrainDesc']) ? trim($this->sanitize_data($post['TravelByTrainDesc'])) : '';
$addData['CanTravelByBus'] = (@$post['CanTravelByBus']) ? trim($this->sanitize_data($post['CanTravelByBus'])) : '';
$addData['TravelByBusDesc'] = (@$post['TravelByBusDesc']) ? trim($this->sanitize_data($post['TravelByBusDesc'])) : '';
$addData['CanTravelByCar'] = (@$post['CanTravelByCar']) ? trim($this->sanitize_data($post['CanTravelByCar'])) : '';
$addData['TravelByCarDesc'] = (@$post['TravelByCarDesc']) ? trim($this->sanitize_data($post['TravelByCarDesc'])) : '';
$addData['TimeToVisitMask'] = (@$post['TimeToVisitMask']) ? trim($this->sanitize_data($post['TimeToVisitMask'])) : '';
$addData['ActivityMask'] = (@$post['ActivityMask']) ? trim($this->sanitize_data($post['ActivityMask'])) : '';
$addData['SeasonMask'] = (@$post['SeasonMask']) ? trim($this->sanitize_data($post['SeasonMask'])) : '';
$addData['GetLat'] = (@$post['GetLat']) ? trim($this->sanitize_data($post['GetLat'])) : '';
$addData['GetLong'] = (@$post['GetLong']) ? trim($this->sanitize_data($post['GetLong'])) : '';
$addData['StateSysId'] = (@$post['state_listing']) ? trim($this->sanitize_data($post['state_listing'])) : '';
$addData['ZoneSysId'] = (@$post['ZoneSysId']) ? trim($this->sanitize_data($post['ZoneSysId'])) : '';
$addData['ContSysId'] = (@$post['country_id']) ? trim($this->sanitize_data($post['country_id'])) : '';
$addData['PIN'] = (@$post['PIN']) ? trim($this->sanitize_data($post['PIN'])) : '';
$addData['IsHaveAirPort'] = (@$post['IsHaveAirPort']) ? trim($this->sanitize_data($post['IsHaveAirPort'])) : '';
$addData['CreateDate'] = date('Y-m-d h:i:s');
$addData['UpdateDate'] = date('Y-m-d h:i:s');
$addData['isActive'] = 1;
$addData['TBBCityId'] = 0;
// check city name already exists or not ( Avoid duplicate city entry)
if (trim($this->sanitize_data($post['cityname'])) != '' && trim($this->sanitize_data($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);die;
if (count($cityName) >= 1) {
$this->_helper->flashMessenger->addMessage("City already exists.");
$this->_redirect("admin/city/add");
} else {
// echo '<pre>';print_r($addData); die;
$isinserted = $this->cityMdl->insertTable($this->tablename, $addData);
//print_r($isinserted); die;
if ($isinserted) {
$this->_helper->flashMessenger->addMessage("Record inserted successfully.");
$this->_redirect("admin/city/index");
}
}
} catch (Zend_Db_Exception $error) {
echo $this->view->error_msg = $error->getMessage();
die;
}
}
}
public function editAction() {
$cityid = base64_decode($this->_getParam('id'));
if (!empty($cityid) || !is_int($cityid)) {
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
try {
$editData = array();
$editData['Title'] = (@$post['cityname']) ? trim($this->sanitize_data($post['cityname'])) : '';
$editData['Alias'] = (@$post['Alias']) ? trim($this->sanitize_data($post['Alias'])) : '';
$editData['Code'] = (@$post['Code']) ? trim($this->sanitize_data($post['Code'])) : '';
$editData['StateOrZone'] = (@$post['StateOrZone']) ? trim($this->sanitize_data($post['StateOrZone'])) : 0;
$editData['Country'] = (@$post['Country']) ? trim($this->sanitize_data($post['Country'])) : '';
// $editData['CityCategoryMask'] = (@$post['citycategory']) ? implode(',',$post['citycategory']) : ' ';
$editData['CityCategoryMask'] = "";
if (isset($post['citycategory']) && !empty($post['citycategory'])) {
$addData['CityCategoryMask'] = implode(',', $post['citycategory']);
} else {
$addData['CityCategoryMask'] = ' ';
}
$editData['Synonyms'] = (@$post['Synonyms']) ? trim($this->sanitize_data($post['Synonyms'])) : '';
$editData['ThumbnailImg'] = (@$post['ThumbnailImg']) ? trim($this->sanitize_data($post['ThumbnailImg'])) : '';
$editData['BannerImg'] = (@$post['BannerImg']) ? trim($this->sanitize_data($post['BannerImg'])) : '';
$editData['AltTag'] = (@$post['AltTag']) ? trim($this->sanitize_data($post['AltTag'])) : '';
$editData['ShortDesc'] = (@$post['ShortDesc']) ? trim($this->sanitize_data($post['ShortDesc'])) : '';
$editData['LongDesc'] = (@$post['LongDesc']) ? trim($this->sanitize_data($post['LongDesc'])) : '';
$editData['HowToReachDesc'] = (@$post['HowToReachDesc']) ? trim($this->sanitize_data($post['HowToReachDesc'])) : '';
$editData['XRefAirportCode'] = (@$post['XRefAirportCode']) ? trim($this->sanitize_data($post['XRefAirportCode'])) : '';
$editData['TravelByAirDesc'] = (@$post['TravelByAirDesc']) ? trim($this->sanitize_data($post['TravelByAirDesc'])) : '';
$editData['CanTravelByTrain'] = (@$post['CanTravelByTrain']) ? trim($this->sanitize_data($post['CanTravelByTrain'])) : '';
$editData['TravelByTrainDesc'] = (@$post['TravelByTrainDesc']) ? trim($this->sanitize_data($post['TravelByTrainDesc'])) : '';
$editData['CanTravelByBus'] = (@$post['CanTravelByBus']) ? trim($this->sanitize_data($post['CanTravelByBus'])) : '';
$editData['TravelByBusDesc'] = (@$post['TravelByBusDesc']) ? trim($this->sanitize_data($post['TravelByBusDesc'])) : '';
$editData['CanTravelByCar'] = (@$post['CanTravelByCar']) ? trim($this->sanitize_data($post['CanTravelByCar'])) : '';
$editData['TravelByCarDesc'] = (@$post['TravelByCarDesc']) ? trim($this->sanitize_data($post['TravelByCarDesc'])) : '';
$editData['TimeToVisitMask'] = (@$post['TimeToVisitMask']) ? trim($this->sanitize_data($post['TimeToVisitMask'])) : '';
$editData['ActivityMask'] = (@$post['ActivityMask']) ? trim($this->sanitize_data($post['ActivityMask'])) : '';
$editData['SeasonMask'] = (@$post['SeasonMask']) ? trim($this->sanitize_data($post['SeasonMask'])) : '';
$editData['GetLat'] = (@$post['GetLat']) ? trim($this->sanitize_data($post['GetLat'])) : '';
$editData['GetLong'] = (@$post['GetLong']) ? trim($this->sanitize_data($post['GetLong'])) : '';
$editData['StateSysId'] = (@$post['state_listing']) ? trim($this->sanitize_data($post['state_listing'])) : '';
$editData['ZoneSysId'] = (@$post['ZoneSysId']) ? trim($this->sanitize_data($post['ZoneSysId'])) : '';
$editData['ContSysId'] = (@$post['country_id']) ? trim($this->sanitize_data($post['country_id'])) : '';
$editData['PIN'] = (@$post['PIN']) ? trim($this->sanitize_data($post['PIN'])) : '';
$editData['IsHaveAirPort'] = (@$post['IsHaveAirPort']) ? trim($this->sanitize_data($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("admin/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', 'ContSysId', '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("admin/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); die;
try {
$editData = array();
$editData['Title'] = ($post['Title']) ? trim($this->sanitize_data($post['Title'])) : '';
$editData['CityCategoryMask'] = implode(",", isset($post['CityCategoryMask']) ? ($this->sanitize_data($post['CityCategoryMask'])) : array());
$editData['Synonyms'] = ($post['Synonyms']) ? trim($this->sanitize_data($post['Synonyms'])) : '';
$editData['AltTag'] = ($post['AltTag']) ? trim($this->sanitize_data($post['AltTag'])) : '';
$editData['ImageTitle'] = ($post['ImageTitle']) ? trim($this->sanitize_data($post['ImageTitle'])) : '';
$editData['ImageReference'] = ($post['ImageReference']) ? trim($this->sanitize_data($post['ImageReference'])) : '';
$editData['ShortDesc'] = ($post['ShortDesc']) ? trim($this->sanitize_data($post['ShortDesc'])) : '';
$editData['LongDesc'] = ($post['LongDesc']) ? trim($this->sanitize_data_html($post['LongDesc'])) : '';
$editData['HowToReachDesc'] = ($post['HowToReachDesc']) ? trim($this->sanitize_data($post['HowToReachDesc'])) : '';
$editData['XRefAirportCode'] = ($post['XRefAirportCode']) ? trim($this->sanitize_data($post['XRefAirportCode'])) : '';
$editData['TravelByAirDesc'] = ($post['TravelByAirDesc']) ? trim($this->sanitize_data($post['TravelByAirDesc'])) : '';
$editData['CanTravelByAir'] = (@$post['CanTravelByAir']) ? trim($this->sanitize_data($post['CanTravelByAir'])) : '';
$editData['IsHaveAirPort'] = (@$post['CanTravelByAir']) ? trim($this->sanitize_data($post['CanTravelByAir'])) : '';
$editData['CanTravelByTrain'] = (@$post['CanTravelByTrain']) ? trim($this->sanitize_data($post['CanTravelByTrain'])) : '';
$editData['TravelByTrainDesc'] = ($post['TravelByTrainDesc']) ? trim($this->sanitize_data($post['TravelByTrainDesc'])) : '';
$editData['CanTravelByBus'] = (@$post['CanTravelByBus']) ? trim($this->sanitize_data($post['CanTravelByBus'])) : '';
$editData['TravelByBusDesc'] = ($post['TravelByBusDesc']) ? trim($this->sanitize_data($post['TravelByBusDesc'])) : '';
$editData['CanTravelByCar'] = (@$post['CanTravelByCar']) ? trim($this->sanitize_data($post['CanTravelByCar'])) : '';
$editData['TravelByCarDesc'] = ($post['TravelByCarDesc']) ? trim($this->sanitize_data($post['TravelByCarDesc'])) : '';
$editData['TimeToVisitMask'] = implode(",", isset($post['TimeToVisitMask']) ? ($this->sanitize_data($post['TimeToVisitMask'])) : array());
$editData['ActivityMask'] = implode(",", isset($post['ActivityMask']) ? ($this->sanitize_data($post['ActivityMask'])) : array());
// $editData['SeasonMask'] = ($post['SeasonMask']) ? $post['SeasonMask'] : '';
$editData['GetLat'] = ($post['GetLat']) ? trim($this->sanitize_data($post['GetLat'])) : '';
$editData['GetLong'] = ($post['GetLong']) ? trim($this->sanitize_data($post['GetLong'])) : '';
$editData['StateSysId'] = ($post['StateSysId']) ? trim($this->sanitize_data($post['StateSysId'])) : '';
// $editData['ZoneSysId'] = ($post['ZoneSysId']) ? $post['ZoneSysId'] : '';
$editData['ContSysId'] = ($post['ContSysId']) ? trim($this->sanitize_data($post['ContSysId'])) : '';
$editData['PIN'] = ($post['PIN']) ? trim($this->sanitize_data($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
//echo $cityid;
//echo '<pre>';print_r($editData);die;
$where = array('CityId =?' => $cityid);
// echo "<pre>"; print_r($editData); die;
$isupdated = $this->cityMdl->updateTable($this->tablename, $editData, $where);
if ($isupdated) {
$this->_helper->flashMessenger->addMessage("Record updated successfully.");
$this->_redirect("admin/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', 'ContSysId', '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);
//echo '<pre>';print_r($resultset);die;
# 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 . "/admin/city/places-to-eat-new/cityid/" . $cityid)->setMethod("POST")->setName("placesToEatForm");
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
//print_r($_FILES['ThumnailImg']);
//echo '<pre>';print_r($post);die;
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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'CitySysId' => trim($this->sanitize_data($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("admin/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 . "/admin/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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'ThumnailImg' => trim($this->sanitize_data($updateimage)),
'UpdateDate' => date('Y-m-d H:i:s'),
);
//echo '<pre>';print_r($editDataPlaceToEat);die;
$tablename = 'TB_IC_City_PlaceToEat';
$where = array('PlaceToEatSysId =?' => $intId);
$this->cityMdl->updateTable($tablename, $editDataPlaceToEat, $where);
$this->_helper->flashMessenger->addMessage("Record updated successfully");
$this->_redirect("admin/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("admin/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 . "/admin/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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'CitySysId' => trim($this->sanitize_data($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("admin/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 . "/admin/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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'ThumnailImg' => trim($this->sanitize_data($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("admin/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("admin/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 . "/admin/city/places-for-activities-new/cityid/" . $cityid)->setMethod("POST")->setName("placesForActivitiesForm");
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
//echo '<pre>';print_r($post);die;
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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'CitySysId' => trim($this->sanitize_data($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("admin/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 . "/admin/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' => trim($this->sanitize_data($post['Title'])),
'Address1' => trim($this->sanitize_data($post['Address1'])),
'Address2' => trim($this->sanitize_data($post['Address2'])),
'Timing' => trim($this->sanitize_data($post['Timing'])),
'Latitude' => trim($this->sanitize_data($post['Latitude'])),
'Longitude' => trim($this->sanitize_data($post['Longitude'])),
'Speciality' => trim($this->sanitize_data($post['Speciality'])),
'Rate' => trim($this->sanitize_data($post['Rate'])),
'ImgTitle' => trim($this->sanitize_data($post['ImgTitle'])),
'ImgReference' => trim($this->sanitize_data($post['ImgReference'])),
'Alttag' => trim($this->sanitize_data($post['Alttag'])),
'ThumnailImg' => trim($this->sanitize_data($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("admin/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("admin/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']) ? trim($this->sanitize_data($post['title'])) : '';
$addData['Address1'] = (@$post['address1']) ? trim($this->sanitize_data($post['address1'])) : '';
$addData['Address2'] = (@$post['address2']) ? trim($this->sanitize_data($post['address2'])) : '';
$addData['Timing'] = (@$post['timing']) ? trim($this->sanitize_data($post['timing'])) : 0;
$addData['Latitude'] = (@$post['latitude']) ? trim($this->sanitize_data($post['latitude'])) : '';
$addData['Longitude'] = (@$post['longitude']) ? trim($this->sanitize_data($post['longitude'])) : '';
$addData['Speciality'] = (@$post['speciality']) ? trim($this->sanitize_data($post['speciality'])) : '';
$addData['Rate'] = (@$post['rate']) ? trim($this->sanitize_data($post['rate'])) : '';
$addData['ImgTitle'] = (@$post['img_title']) ? trim($this->sanitize_data($post['img_title'])) : '';
$addData['ThumnailImg'] = trim($this->sanitize_data($updateimage));
$addData['ImgReference'] = (@$post['img_reference']) ? trim($this->sanitize_data($post['img_reference'])) : '';
$addData['Alttag'] = (@$post['img_alt']) ? trim($this->sanitize_data($post['img_alt'])) : '';
$addData['CitySysId'] = trim($this->sanitize_data($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("admin/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("admin/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']) ? trim($this->sanitize_data($post['title'])) : '';
$editData['Address1'] = (@$post['address1']) ? trim($this->sanitize_data($post['address1'])) : '';
$editData['Address2'] = (@$post['address2']) ? trim($this->sanitize_data($post['address2'])) : '';
$editData['Timing'] = (@$post['timing']) ? trim($this->sanitize_data($post['timing'])) : 0;
$editData['Latitude'] = (@$post['latitude']) ? trim($this->sanitize_data($post['latitude'])) : '';
$editData['Longitude'] = (@$post['longitude']) ? trim($this->sanitize_data($post['longitude'])) : '';
$editData['Speciality'] = (@$post['speciality']) ? trim($this->sanitize_data($post['speciality'])) : '';
$editData['Rate'] = (@$post['rate']) ? trim($this->sanitize_data($post['rate'])) : '';
$editData['ImgTitle'] = (@$post['img_title']) ? trim($this->sanitize_data($post['img_title'])) : '';
$editData['ThumnailImg'] = trim($this->sanitize_data($updateimage));
$editData['ImgReference'] = (@$post['img_reference']) ? trim($this->sanitize_data($post['img_reference'])) : '';
$editData['Alttag'] = (@$post['img_alt']) ? trim($this->sanitize_data($post['img_alt'])) : '';
$editData['CitySysId'] = trim($this->sanitize_data($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("admin/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("admin/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("admin/city/index/page/$currentPage");
}
} else {
$this->_redirect("admin/city/index/page/$currentPage");
}
}
}