| 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 Place
*
* @name Place
* @author Shailender Joshi
* @editor Shailender Joshi
* @created 14 Oct 2016
* @updateed 09 Jan 2018 by Md sabir
* @version 1.0
* @copyright Catabatic India Pvt Ltd
* Handle Place Related function for Front end only
*
*/
class Admin_PlaceController extends Catabatic_ValidateAdmin {
public $imageUrl = NULL;
public $baseUrl = '';
public $tablename = '';
public $current_Modal = '';
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->current_Modal = new Travel_Model_TblPlace();
$this->GeneralFunction_Modal = new Travel_Model_GeneralFunction(); // Make object of generel function class
$this->tablename = 'TB_Master_Place';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->imageUrl = $this->baseUrl."/public/upload/place/";
}
public function indexAction()
{
$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))
{
$Title = (@$getData['Title']!='')? @$getData['Title'] : '';
$country = (@$getData['country']!='')? @$getData['country'] : '';
$Zone = (@$getData['Zone']!='')? @$getData['Zone'] : '';
$filter1 = (@$getData['filter1']!='All')? @$getData['filter1'] : ''; // status part
$searchArr = array(
'Title' => $Title,
'country' => $country,
'Zone' => $Zone,
'filter1' => $filter1,
);
// print_r($getData);
}
}else{
$Title = $this->_getParam('Title');
$country = $this->_getParam('country');
$Zone = $this->_getParam('Zone');
$filter1 = $this->_getParam('filter1');
$filter1 = (@$filter1!='All') ? $filter1 : '';
$searchArr = array(
'Title' => $Title,
'country' => $country,
'Zone'=> $Zone,
'filter1' => $filter1,
);
//print_r($searchArr);
}
//print_r($searchArr);
$objCountry = new Travel_Model_TblCountry();
$this->current_Modal->searchArr = $searchArr; // send Array - searchArr() to modal just for pagination
$this->view->searchArr = $searchArr;
// get zone list array
$this->view->zonelist = $this->GeneralFunction_Modal->getRecordListingaAdmin('TB_Master_Geo_Zone',array('ZoneId','Title'),1,1,0,'Title');
// get country list array
$this->view->countrylist = $this->GeneralFunction_Modal->getRecordListing('TB_Master_Geo_Country',array('ContId','Title'),1,1,0,'Title');
// pagination start
$page = $this->_request->getParam('page',1); //get curent page param, default 1 if param not available.
$data = $this->current_Modal->getPlaceListingRecord(); // get all getHotelAmenityCategory
$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->CountryList = $objCountry->getCountryList();
$this->view->currentPage = $this->_getParam('page');
}
public function addAction()
{
$form = new Travel_Form_Place();
$form->setAction($this->baseUrl."/admin/place/add")->setMethod("POST")->setName("addPlaceForm");
$this->view->form = $form;
$date = new Zend_Date();
$currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
if ($form->isValid($post)) {
try
{
$addData = array(
'Title' => trim($this->sanitize_data($post['Title'])),
'MasterPlaceSysId' => 0,
'Popularity' => 0,
'TBRating' => 0,
'PlaceCatMask' => 0,
'PlaceTypeMask' => 0,
'IATACode' => '',
'ICAO' => '',
'AirportCount' => '',
'ZoneType' => 0,
'ContSysId' => trim($this->sanitize_data($post['countryList'])),
'ZoneSysId' => trim($this->sanitize_data($post['zoneList'])),
'ShortCode' => trim($this->sanitize_data($post['shortCode'])),
'PinCode' => trim($this->sanitize_data($post['pinCode'])),
'SearchTags' => trim($this->sanitize_data($post['SearchTags'])),
'Meta' => trim($this->sanitize_data($post['Meta'])),
'PlaceOneliner' => trim($this->sanitize_data($post['PlaceOneliner'])),
'GeoLat' => trim($this->sanitize_data($post['Latitude'])),
'GeoLong' => trim($this->sanitize_data($post['Longitude'])),
'IsActive' => 1,
'IsMarkForDel' => 0,
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
);
//echo '<pre>';var_dump($addData);die;
// check Same Title name already exists or not ( Avoid duplicate hotel Amenity Category entry)
if(trim($this->sanitize_data($post['Title']))!='' && trim($this->sanitize_data($post['countryList']))!=''){
$entryDate = $this->GeneralFunction_Modal->getRecordListingWhere($this->tablename, array('Title'), array('Title'=>$addData['Title'], 'ContSysId'=>$addData['ContSysId']));
}
//print_r($entryDate); echo count($entryDate);die;
if(count($entryDate)>=1){
$this->view->eMsg = "Place already exists.";
}
else
{
$isinserted = $this->GeneralFunction_Modal->insertTable($this->tablename, $addData);
if($isinserted) {
$this->_helper->flashMessenger->addMessage("Record added successfully");
$this->_redirect("admin/place");
}
}
}
catch (Zend_file_transfer_exeception $e) {
$this->view->error_msg = $e->getMessage();
}
}
}
$this->view->others = array('baseUrl' => $this->baseUrl, 'action_name'=> 'add');
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
public function editAction()
{
$encodeId = ($this->getRequest()->getParam('id'));
$intId = (int)base64_decode($encodeId);
$page = $this->getRequest()->getParam('page');
$date = new Zend_Date();
$currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
if(!empty($intId) || !is_int($intId) )
{
# get listings of places
$colsArr = array('*');
$resultset = $this->GeneralFunction_Modal->getDetailsByUniqueId($this->tablename, $colsArr, 'PlaceSysId', $intId);
$form = new Travel_Form_Place();
$form->setMethod("POST")->setName("editPlaceForm");
$editFormdata = array(
'Title'=> $resultset['Title'],
'countryList'=> $resultset['ContSysId'],
'zoneList'=> $resultset['ZoneSysId'],
'shortCode'=> $resultset['ShortCode'],
'pinCode'=> $resultset['PinCode'],
'SearchTags'=> $resultset['SearchTags'],
'Meta'=> $resultset['Meta'],
'PlaceOneliner'=> $resultset['PlaceOneliner'],
'Latitude'=> $resultset['GeoLat'],
'Longitude'=> $resultset['GeoLong'],
);
$form->populate($editFormdata);
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
if ($form->isValid($post)) {
try {
$editData = array(
'Title' => trim($this->sanitize_data($post['Title'])),
'MasterPlaceSysId' => 0,
'Popularity' => 0,
'TBRating' => 0,
'PlaceCatMask' => 0,
'PlaceTypeMask' => 0,
'IATACode' => '',
'ICAO' => '',
'AirportCount' => '',
'ZoneType' => 0,
'ContSysId' => trim($this->sanitize_data($post['countryList'])),
'ZoneSysId' => trim($this->sanitize_data($post['zoneList'])),
'ShortCode' => trim($this->sanitize_data($post['shortCode'])),
'PinCode' => trim($this->sanitize_data($post['pinCode'])),
'SearchTags' => trim($this->sanitize_data($post['SearchTags'])),
'Meta' => trim($this->sanitize_data($post['Meta'])),
'PlaceOneliner' => trim($this->sanitize_data($post['PlaceOneliner'])),
'GeoLat' => trim($this->sanitize_data($post['Latitude'])),
'GeoLong' => trim($this->sanitize_data($post['Longitude'])),
'IsActive' => 1,
'IsMarkForDel' => 0,
'UpdateDate' => $currentDate,
);
$where = array('PlaceSysId =?'=> $intId);
$this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
$this->_helper->flashMessenger->addMessage("Record updated successfully");
$this->_redirect("admin/place/index/page/$page");
}
catch (Zend_Form_Exception $e) {
$this->view->error_msg = $e->getMessage();
}
}
}
$this->view->resultset = $resultset;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
}
}
public function deleteAction()
{
/* Disable Layout & set Render False */
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$id = base64_decode( $this->getRequest()->getParam('id'));
$currentPage = base64_decode( $this->getRequest()->getParam('page'));
if($id) {
$editData['IsMarkForDel'] = 1;
$where = array('PlaceSysId =?'=> $id);
$isupdated = $this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
if($isupdated)
{
$this->_helper->flashMessenger->addMessage("Record Deleted successfully.");
$this->_redirect("admin/place/index/page/$currentPage");
}
}
else {
$this->_redirect("admin/place/index/page/$currentPage");
}
}
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');
$id = base64_decode( $this->getRequest()->getParam('id'));
$currentPage = $this->getRequest()->getParam('page');
if($id && $filter) {
if($filter == 'filter1'){
$editData['IsActive'] = ($val == 0) ? 1 : 0;
}
if($filter == 'filter2'){
$editData['IsApprove'] = ($val == 0) ? 1 : 0;
}
$where = array('PlaceSysId =?'=> $id);
$isupdated = $this->GeneralFunction_Modal->updateTable($this->tablename, $editData, $where);
if($isupdated)
{
$this->_helper->flashMessenger->addMessage("Record Update successfully.");
$this->_redirect("admin/place/index/page/$currentPage");
}
}
else {
$this->_redirect("admin/place/index/page/$currentPage");
}
}
}