| 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/indoasiaholidays.com/application/controllers/ |
Upload File : |
<?php
/***************************************************************
* Catabatic Technology Pvt. Ltd.
* File Name : CustomerController.php
* File Desc. : Customer controller for home page front end
* Created By : Md Sabir <sabir@catpl.co.in>
* Created Date : 06 July 2017
* Updated Date : 06 July 2017
***************************************************************/
class CustomerController extends Zend_Controller_Action
{
protected $objMdl;
protected $tablename;
protected $objHelperGeneral;
protected $per_page_record;
protected $_session;
protected $gtxagencysysid;
protected $gtxagentsysid;
public $customerbookinglistAPIUrl;
public function init() {
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->gtxbaseUrl = $BootStrap['gtxBtoBsite'];
$this->gtxagencysysid = $BootStrap['gtxagencysysid']; // get gtxagencysysid from application config
$this->gtxagentsysid = $BootStrap['gtxagentsysid']; // get gtxagentsysid from application config
$this->objMdl = new Admin_Model_CRUD();
$this->tablename = "tb_tbb2c_packages_master";
$this->tablenameTes = "tbl_testimonials";
$this->hotelTypeArr = ['Standard','Deluxe','Luxury'];
$this->objHelperGeneral = $this->_helper->General;
$this->per_page_record = 10;
$this->_resetsession = new Zend_Session_Namespace('UserResetEmail');
$this->customerauthlogin = API_CUSTOMER_AUTH_LOGIN; // from constant file
$this->customerbookinglistAPIUrl = API_CUSTOMER_LIST; // from constant file
$this->customerprofileAPIUrl = API_CUSTOMER_PROFILE; // from constant file
$this->customerchangepasswordAPIUrl = API_CUSTOMER_CHANGEPASSWORD; // from constant file
$this->customerforgotpasswordAPIUrl = API_CUSTOMER_FORGOTPASSWORD; // from constant file
$this->customerupdateforgotpasswordAPIUrl = API_CUSTOMER_UPDATE_FORGOTPASSWORD; // from constant file
$this->customerupdateprofilePIUrl = API_CUSTOMER_UPDATE_PROFILE; // from constant file
$this->getcitylistAPIUrl = API_CUSTOMER_CITYLIST; // from constant file
$this->salutation = ARR_SALUTION; // from constant file
}
public function indexAction()
{
die('index');
}
public function agencycustomerloginAction(){
header('Access-Control-Allow-Origin: *');
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getParams();
$apiData = array(
'userName' => $data['userName'],
'userPassword' => $data['userPassword'],
'AgencySysId' => $this->gtxagencysysid
);
try {
$curl_p = curl_init($this->customerauthlogin);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$response_decode = Zend_Json::decode($response, true);
print_r($response_decode);die('fsdfdsfdsf');
if($response_decode == 1){
$reply = ['status' => false, 'message' => 'Invalid login credentials'];
echo Zend_Json::encode($reply);exit;
//$reply = ['status' => true, 'message' => 'Login Successfully'];
//echo Zend_Json::encode($response_decode);exit;
}elseif($response_decode == 2){
$reply = ['status' => false, 'message' => 'Oops! Your Account is not activate.if urgent Please call to GTX customer care'];
echo Zend_Json::encode($reply);exit;
}else{
//$reply = ['status' => false, 'message' => 'Unable to login. try again'];
echo Zend_Json::encode($response_decode);exit;
// $this->view->errorMessage = "Unable to update your profile";
// $this->_redirect('customer/myprofile');
}
}else{
die('oops wrong request');
}
}
public function myprofileAction()
{
$this->checklogin();
$salutation = unserialize($this->salutation);
//$authStorage_ = Zend_Auth::getInstance()->getStorage();
//print_r($_SESSION['User']['session']);die;
$apiData = array(
"CustomerSysId" => $_SESSION['User']['session']['CustomerSysId'],
"AgencySysId" => $_SESSION['User']['session']['AgencySysId']
);
try {
$curl = curl_init($this->customerbookinglistAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
//echo '<pre>';print_r($response);exit;
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
//print_r($apiData);
//echo '<pre>';print_r($response);die('co');
// For profile
try {
$curl_p = curl_init($this->customerprofileAPIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_pro = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$result = array();
$decodeJSON = Zend_Json::decode($response, true);
$decode_profile = Zend_Json::decode($response_pro, true);
//echo '<pre>';print_r($decodeJSON);
if(count($decodeJSON['getdata']) >0) {
foreach($decodeJSON['getdata'] as $key=>$val){
$RoomInfoJson = Zend_Json::decode($val['RoomInfoJson'], true);
$result[] = [
'all'=>$val,
'roominfo'=>$RoomInfoJson
];
}
}
//echo '<pre>';print_r($decode_profile['profile']);exit;
$this->view->alldata = $result;
$this->view->salutation = $salutation;
$this->view->profile = $decode_profile['profile'];
$this->view->countryArr = $decode_profile['countryArr'];
}
public function updateprofileAction(){
if ($this->getRequest()->isPost()) {
$this->checklogin();
$data = $this->getRequest()->getParams();
$apiData = array(
'Title' => $data['title'],
'FirstName' => $data['FirstName'],
'LastName' => $data['LastName'],
'contacts' => $data['contacts'],
'PassportNo' => $data['PassportNo'],
'PassportExpiry' => $data['PassportExpiry'],
'DOB' => $data['DOB'],
'MarriageAnniversary' => $data['MarriageAnniversary'],
"CustomerSysId" => $data['CustomerSysId'],
"AgencySysId" => $data['AgencySysId'],
"country" => $data['country'],
"city" => $data['city']
);
//print_r($apiData);die;
try {
$curl_p = curl_init($this->customerupdateprofilePIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_pro = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
if($response_pro == 1){
$reply = ['status' => true, 'message' => 'Profile Update Successfully'];
echo Zend_Json::encode($reply);exit;
// $this->view->successMessage = "Profile Update Successfully";
// $this->_redirect('customer/myprofile');
}else{
$reply = ['status' => false, 'message' => 'Unable to update your profile. try again'];
echo Zend_Json::encode($reply);exit;
// $this->view->errorMessage = "Unable to update your profile";
// $this->_redirect('customer/myprofile');
}
}
}
public function getcitylistAction(){
if ($this->getRequest()->isPost()) {
$this->checklogin();
$param = $this->getRequest()->getParams();
$apiData = array(
"country" => $param['country']
);
try {
$curl = curl_init($this->getcitylistAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
//curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
//echo '<pre>';print_r($response);exit;
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$ResponseDecode = Zend_Json::decode($response, true);
$reply = ['status' => true, 'message' => 'Getting city list please wait...','countryId'=>$ResponseDecode];
echo Zend_Json::encode($reply);exit;
}
}
public function changepasswordAction(){
if ($this->getRequest()->isPost()) {
$this->checklogin();
$param = $this->getRequest()->getParams();
$apiData = array(
"cpass" => $param['cpass'],
"npass" => $param['npass'],
"copass" => $param['copass'],
"CustomerSysId" => $param['CustomerSysId'],
"AgencySysId" => $param['AgencySysId']
);
try {
$curl = curl_init($this->customerchangepasswordAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
if($response == 1){
$reply = ['status' => false, 'message' => 'Current password does not match'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 2){
$reply = ['status' => false, 'message' => 'Confirm password does not match with new password'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 3){
$reply = ['status' => true, 'message' => 'Password has been changed successfully. Please login again for security region!'];
echo Zend_Json::encode($reply);exit;
}else{
$reply = ['status' => false, 'message' => 'Oops there is no response'];
echo Zend_Json::encode($reply);exit;
}
}
}
/**
* forgotpassword() method is used to B2B customer can forgot password
* @param Null
* @return Array
*/
public function forgotpasswordAction(){
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiData = array(
"forget" => $param['forget'],
"AgencySysId" => $param['AgencySysId']
);
try {
$curl = curl_init($this->customerforgotpasswordAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$ResponseDecode = Zend_Json::decode($response, true);
//echo '<pre>';print_r($ResponseDecode);die;
if($ResponseDecode['status'] == 1){
$datetime = date('d-m-y h:i:s');
$time_str = strtotime($datetime);
$token = md5($ResponseDecode['data']['CustomerSysId']);
$CustomerSysId = base64_encode($ResponseDecode['data']['CustomerSysId']);
$EmailId = $ResponseDecode['data']['EmailId'];
$FirstName = $ResponseDecode['data']['FirstName'];
$CheckEmailId = base64_encode($ResponseDecode['data']['EmailId']);
$AgencySysId = $ResponseDecode['data']['AgencySysId'];
$reseturlclick = $this->baseUrl."customer/checkresetlink?token=$token&ag=$AgencySysId&eid=$CheckEmailId&CTR=$time_str&cd=$CustomerSysId";
//echo '<pre>';print_r($ResponseDecode);die;
$name = $FirstName;
$customer_email = $EmailId;
//$password = '1254';
$from_email = 'bhutanqueries@gmail.com';
$subject = "Password Change Request";
$message = "Hello $name<br><br>";
$message .= "Greetings from BhutanSikkim team.<br><br>";
$message .= "It is our pleasure to fulfill your request for new password.<br><br>";
$message .= "To change your account password at BhutanSikkim please click this link or copy and paste the following link into your browser. This link expire within 10 minutes: <br><br>";
$message .= " $reseturlclick <br><br><br>";
$message .= "Thank you for customer with us.<br><br>";
$message .= "BhutanSikkim Team.";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$name.' <'.$from_email.'>' . "\r\n";
// Mail it
@mail($customer_email, $subject, $message, $headers);
$reply = ['status' => true, 'message' => 'Email has been sent successfully.'];
echo Zend_Json::encode($reply);exit;
} else {
$reply = ['status' => false, 'message' => 'Invalid email. Please try again.'];
echo Zend_Json::encode($reply);exit;
}
//print_r($param);die;
}else{
echo 'Oops wrong request';exit;
}
}
public function checkresetlinkAction(){
$param = $this->getRequest()->getParams();
$datetime = date('d-m-y h:i:s');
$seconds = strtotime($datetime) - ($param['CTR']);
$days = floor($seconds / 86400);
$hours = floor(($seconds - ($days * 86400)) / 3600);
$minutes = floor(($seconds - ($days * 86400) - ($hours * 3600))/60);
if($minutes <= 10){
$eid = base64_decode($param['eid']);
$cd = base64_decode($param['cd']);
$token = ($param['token']);
$ag = ($param['ag']);
$SubmitData = array(
"eid" => $eid,
"cd" => $cd,
"ag" => $ag,
"token" => $token,
"CTR" => $param['CTR']
);
$this->_resetsession->resetpass = $SubmitData;
$this->_redirect('customer/resetpassword');
}else{
die('Oops your reset password link is expired!! try again.');
}
}
public function resetpasswordAction(){
if(isset($_SESSION['UserResetEmail']['resetpass'])){
//print_r($_SESSION['UserResetEmail']);die;
$datetime = date('d-m-y h:i:s');
$seconds = strtotime($datetime) - ($_SESSION['UserResetEmail']['resetpass']['CTR']);
$days = floor($seconds / 86400);
$hours = floor(($seconds - ($days * 86400)) / 3600);
$minutes = floor(($seconds - ($days * 86400) - ($hours * 3600))/60);
if($minutes <= 10){
$this->view->data = $_SESSION['UserResetEmail']['resetpass'];
}else{
$this->_redirect('customer/unsetresetdata');
}
if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
$apiData = array(
"npass" => $param['npass'],
"copass" => $param['copass'],
"email" => $_SESSION['UserResetEmail']['resetpass']['eid'],
"CustomerSysId" => $_SESSION['UserResetEmail']['resetpass']['cd'],
"AgencySysId" => $_SESSION['UserResetEmail']['resetpass']['ag']
);
try {
$curl = curl_init($this->customerupdateforgotpasswordAPIUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
//print_r($response);die;
if($response == 4){
$reply = ['status' => false, 'message' => 'All field required!!'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 3){
$reply = ['status' => false, 'message' => 'Confirm password does not match with new password'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 2){
$reply = ['status' => false, 'message' => 'Password update not response!!'];
echo Zend_Json::encode($reply);exit;
}elseif($response == 1){
$reply = ['status' => true, 'message' => 'Password has been reset successfully. Now Login and continue.'];
echo Zend_Json::encode($reply);exit;
}else{
$reply = ['status' => false, 'message' => 'Oops there is no response'];
echo Zend_Json::encode($reply);exit;
}
//print_r($response);die;
}
}else{
echo('Oops! There seems to be some problem in processing your request!');exit;
}
//print_r($_SESSION['UserResetEmail']['resetpass']);
//exit;
//print_r($param);die;
}
public function unsetresetdataAction()
{
$storage = new Zend_Session_Namespace('UserResetEmail');
$storage->unsetAll();
$this->_redirect('index');
}
/**
* checklogin() method is used to check admin logedin or not
* @param Null
* @return Array
*/
public function checklogin()
{
/*************** check admin identity ************/
if(!$_SESSION['User']['session'])
{
$this->_redirect('index');
}
}
}