| 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/travelbrace.com/application/admin/controllers/ |
Upload File : |
<?php
/* * *************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : ContactusController.php
* File Desc. : Contactus controller managed all contact queries
* Created By : Piyush Tiwari <piyush@catpl.co.in>
* Created Date : 23 May 2018
* Updated Date : 23 May 2018
* ************************************************************* */
class Admin_TestimonialController extends Zend_Controller_Action {
public $dbAdapter;
public $perPageLimit;
public function init() {
/* Initialize db and session access */
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->siteurl = $aConfig['bootstrap']['siteUrl'];
$this->per_page_record = 20;
$this->dbAdapter = Zend_Db_Table::getDefaultAdapter();
$options = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('bootstrap');
$this->gtxagencysysid = $options['gtxagencysysid'];
$auth = Zend_Auth::getInstance();
$authStorage = $auth->getStorage()->read();
$this->username = $authStorage->username;
$this->admin_type = $authStorage->role;
$this->current_time = time();
$this->imageUrl = (($this->appmode == 'MODE_BETA') ? 'beta/' : '') . 'public/upload/testimonial/';
$_SERVER["DOCUMENT_ROOT"] = $_SERVER["DOCUMENT_ROOT"].'/holidaybazaar';
$this->DIR_WRITE_MODE = 0777;
}
/**
* index() method is used to admin login for form call
* @param Null
* @return Array
*/
public function indexAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'Title' => $getData['Title'],
'rows' => $getData['rows'],
'page' => $getData['page'],
);
$resulsetold = $crud->getCount('tbl_testimonials', [' '], 'id');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tbl_testimonials', ['id', 'name', 'message', 'Image', 'IsFeatured'], [''], ['id' => 'DESC']);
$result = Zend_Json::encode($resultset);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['id'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function edittestimonialAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$form = new Admin_Form_Edittestimonial();
$tId = (int) $this->getRequest()->getParam("id");
if (isset($tId) && !empty($tId)) {
// die("here");
$form->setAction("admin/testimonial/edittestimonial/".$tId);
$form->setMethod("POST");
$form->setName("edit_testimonial");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($tId) {
if (isset($getData['save']) == "Save") {
$testi_id = (int) @$getData['id'];
$images = $_FILES["TestiImage"]["name"];
try {
$page_id = $getData['sid'];
if (!empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["TestiImage"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
if ($fileName != "") {
$image_edit = $fileName;
}
$editPageData = [
'name' => ($getData['name']),
'message' => $getData['message'],
'status' => $getData['status'],
'created_at' => date('Y-m-d h:i:s')
];
if ($fileName) {
$editPageData['Image'] = $image_edit;
}
$crud->rv_update('tbl_testimonials', $editPageData, ['id =?' => $testi_id]);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been updated successfully.");
$this->_redirect("/admin/testimonial/index");
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
}
} else {
try {
$editPageData = [
'name' => ($getData['name']),
'message' => $getData['message'],
'status' => $getData['status'],
'created_at' => date('Y-m-d h:i:s')
];
$crud->rv_insert('tbl_testimonials', $editPageData);
$this->view->successMessage = "Page content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Page content has been Added successfully.");
$this->_redirect("/admin/testimonial/index");
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
// echo "<pre>";print_r($getData);die('fd');
}
}
} else {
$form->setAction("admin/testimonial/edittestimonial/");
$form->setMethod("POST");
$form->setName("add_testimonial");
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
if ($form->isValid($getData)) {
if (isset($getData['save']) == "Save") {
$images = $_FILES["TestiImage"]["name"];
if (!empty($images)) {
$orignalFolderName = $_SERVER["DOCUMENT_ROOT"] . "/" . $this->imageUrl;
$fileExt = $this->_helper->General->getFileExtension($images);
$fileName = $this->current_time . '.' . $fileExt;
if (!file_exists($orignalFolderName)) {
mkdir($orignalFolderName, $this->DIR_WRITE_MODE, true);
}
$temp_file_name = $_FILES["TestiImage"]["tmp_name"]; // temprary file name
@move_uploaded_file($temp_file_name, $orignalFolderName . "/" . $fileName);
}
$savePageData = [
'name' => ($getData['name']),
'message' => $getData['message'],
'Image' => ($fileName),
'status' => $getData['status'],
'created_at' => date('Y-m-d h:i:s')
];
$crud->rv_insert('tbl_testimonials', $savePageData);
$this->view->successMessage = "Content has been saved successfully.";
$this->_helper->flashMessenger->addMessage("Content has been added successfully.");
$this->_redirect("/admin/testimonial/index");
}
}
}
}
$result = $crud->rv_select_row('tbl_testimonials', ['*'], ['id' => $tId], ['id' => 'DESC']);
//print_r($result);die;
$editdata["id"] = @$result['id'];
$editdata["name"] = @$result['name'];
$editdata["message"] = @$result['message'];
$editdata["status"] = @$result['status'];
$editdata["TestiImage"] = @$result['Image'];
$form->populate($editdata);
$this->view->form = $form;
$this->view->TestiImage = @$result['Image'];
$this->view->messages = $this->_helper->flashMessenger->getMessages();
//die('ok');
}
public function deletetestiAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if ($tId) {
$checkdata = $crud->rv_select_row('tbl_testimonials', ['id'], ['id' => $tId], ['id' => 'asc']);
if (count($checkdata) > 0) {
$crud->rv_delete('tbl_testimonials', ['id =?' => $tId]);
$this->_helper->flashMessenger->addMessage("Delete successfully.");
$this->_redirect("/admin/testimonial/index");
} else {
die('Oops some thing wrong!!.');
}
}
}
public function ratingAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
if( $this->getRequest()->isPost() ) {
$getData = $this->getRequest()->getPost();
//echo "<pre>";print_r($getData);die;
if($getData) {
//-------Start Code for Approve and Publish content---------//
if (isset($getData['save']) == "Save") {
$pId = $getData['ratingid'];
// echo"<pre>";print_r($getData);die();
$google = isset($getData['google']) ? trim($getData['google']) : '';
$instagram = isset($getData['instagram']) ? trim($getData['instagram']) : '';
$justdial = isset($getData['justdial']) ? trim($getData['justdial']) : '';
$traveltraingle = isset($getData['traveltraingle']) ? trim($getData['traveltraingle']) : '';
$youtube = isset($getData['youtube']) ? trim($getData['youtube']) : '';
$googleurl = isset($getData['googleurl']) ? trim($getData['googleurl']) : '';
$instagramurl = isset($getData['instagramurl']) ? trim($getData['instagramurl']) : '';
$justdialurl = isset($getData['justdialurl']) ? trim($getData['justdialurl']) : '';
$traveltraingleurl = isset($getData['traveltraingleurl']) ? trim($getData['traveltraingleurl']) : '';
$youtubeurl = isset($getData['youtubeurl']) ? trim($getData['youtubeurl']) : '';
$editPageData = [
'google' =>$google,
'instagram' =>$instagram,
'justdial' =>$justdial,
'traveltraingle' =>$traveltraingle,
'youtube' =>$youtube,
'googleurl' =>$googleurl,
'instagramurl' =>$instagramurl,
'justdialurl' => $justdialurl,
'traveltraingleurl' => $traveltraingleurl,
'youtubeurl' => $youtubeurl,
'status' =>1
];
$prom_cat_id=$crud->rv_update('tbl_rating', $editPageData, ['AgencySysId =?' =>$this->gtxagencysysid]);
// echo"<pre>";print_r($prom_cat_id);die();
}
}
$this->view->successMessage = "Page content has been updated successfully.";
}
$result = $crud->getCmsdata('tbl_rating', ['*'], ['AgencySysId'=>$this->gtxagencysysid], ['ratingid'=>'DESC']);
//echo"<pre>";print_r($result);die();
$editdata["ratingid"] = $result->ratingid;
$editdata["google"] = $result->google;
$editdata["instagram"] = $result->instagram;
$editdata["justdial"] = $result->justdial;
$editdata["traveltraingle"] = $result->traveltraingle;
$editdata["youtube"] = $result->youtube;
$editdata["googleurl"] = $result->googleurl;
$editdata["instagramurl"] = $result->instagramurl;
$editdata["justdialurl"] = $result->justdialurl;
$editdata["traveltraingleurl"] = $result->traveltraingleurl;
$editdata["youtubeurl"] = $result->youtubeurl;
$this->view->editdata = $editdata;
}
public function activeAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'IsFeatured' => $val
];
$result = $crud->rv_update('tbl_testimonials', $updatedata, ['id =?' => $tId]);
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
echo Zend_Json::encode($result_message);
exit;
} else {
$result_message = ['status' => true, 'message' => 'Active successfully'];
echo Zend_Json::encode($result_message);
exit;
}
} catch (Exception $ex) {
$ex->getMessage();
}
}
}
public function sanitize_data($string) {
$searchArr = array("iframe", "script", "document", "write", "alert", "%", "@", "$", ";", "+", "|", "#", "<", ">", ")", "(", "'", "\'", ",", "and ", " &", "& ", "and", " and", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$input_data = strtolower($string);
$input_data = str_replace($searchArr, "", $input_data);
$input_data = str_replace(" ", "-", $input_data);
//echo $input_data; die;
return $input_data;
}
public function feedbackAction() {
//Check admin logedin or not
$this->checklogin();
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$crud = new Admin_Model_CRUD();
$getData = $resultsetFinal = array();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$searchArr = array(
'title'=>$getData['title'],
'rows'=>$getData['rows'],
'page'=>$getData['page'],
);
$resulsetold = $crud->getCount('tbl_feedback', ['feedbackId'], 'feedbackId');
$crud->searchArr = $searchArr;
$resultset = $crud->rv_select_static('tbl_feedback', ['*'], ['feedbackId'], ['feedbackId' => 'DESC']);
foreach($resultset as $key => $val){
$feedbackId = $val['FeedbackId'];
$checked = (isset($val['displayOnHome']) && $val['displayOnHome'] == 1) ? 'checked' : '';
$displayOnHome = '<input onclick="displayOnHome('.$feedbackId.')" type="checkbox" name="displayOnHome" id="displayOnHome_'.$feedbackId.'" '.$checked.' value="1"> ';
$action = '<a href="admin/testimonial/feedbackview/id/'.$feedbackId.'">View</a>';
$resultsetFinal[] = [
'feedbackId' => $val['FeedbackId'],
'Name' => $val['Name'],
'EmailId' => $val['EmailId'],
'Destination' => $val['Destination'],
'TravelMonth' => $val['TravelMonth'],
'ReviewStarValue' => $val['ReviewStarValue'].' Star',
'ReviewTitle' => $val['ReviewTitle'],
'Review' => $val['Review'],
'MobileNo' => $val['CountryCode'].$val['MobileNo'],
'TripImage' => $val['TripImage'],
'displayOnHome' => $displayOnHome,
'action' => $action,
];
}
$result = Zend_Json::encode($resultsetFinal);
$newResult = Zend_Json::decode($result, false);
$finalResult["total"] = $resulsetold[0]['feedbackId'];
$finalResult["rows"] = $newResult;
echo json_encode($finalResult);
exit;
}
}
public function activefeedbackAction() {
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
$val = (int) $this->getRequest()->getParam("val");
if ($tId) {
try {
$updatedata = [
'displayOnHome' => $val
];
$result = $crud->rv_update('tbl_feedback', $updatedata, ['feedbackId =?' => $tId]);
// echo "<pre>";print_r($result);die;
if (!$result) {
$result_message = ['status' => false, 'message' => 'Oops something wrong!!'];
echo Zend_Json::encode($result_message);
exit;
} else {
$result_message = ['status' => true, 'message' => 'Active successfully'];
echo Zend_Json::encode($result_message);
exit;
}
} catch (Exception $ex) {
$ex->getMessage();
}
}
}
public function feedbackviewAction() {
//Check admin logedin or not
$this->checklogin();
$crud = new Admin_Model_CRUD();
$tId = (int) $this->getRequest()->getParam("id");
if (isset($tId) && !empty($tId)) {
$result = $crud->rv_select_row('tbl_feedback', ['*'], ['FeedbackId' => $tId], ['FeedbackId' => 'DESC']);
$this->view->result = $result;
}
}
/**
* checklogin() method is used to check admin logedin or not
* @param Null
* @return Array
*/
public function checklogin() {
if (($this->admin_type == "superadmin") || ($this->admin_type == "admin")) {
$auth = Zend_Auth::getInstance();
$hasIdentity = $auth->hasIdentity();
/* * ************* check admin identity *********** */
if (!$hasIdentity) {
$this->_redirect('admin/index/index');
}
} else {
$this->_redirect('admin/index/index');
}
}
}