| 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/v2.hellogtx.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 : Piyush Tiwari <piyush@catpl.co.in>
* Created Date : 05 Sep 2018
* Updated Date : 05 Sep 2018
***************************************************************/
class CustomerController extends Zend_Controller_Action
{
protected $objMdl;
protected $tablename;
protected $objHelperGeneral;
protected $per_page_record;
protected $_session;
protected $_sessionSocial;
protected $_sessionSocialFB;
public $customerbookinglistAPIUrl;
protected $objHelperLoginwithGoogle;
protected $objHelperLoginwithFacebook;
public $contactEmail;
public function init()
{
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
//echo "<pre>";print_r( $BootStrap );die;
$this->siteName = $BootStrap['siteName'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->busapi = $BootStrap['IsBusAPI'];
$this->carapi = $BootStrap['IsCarAPI'];
$this->view->stylecss = $this->stylecss = $BootStrap['stylecss'];
$this->view->gtxBtoBsite = $this->gtxbaseUrl = $BootStrap['gtxBtoBsite'];
$this->contactEmail = $BootStrap['contactEmail'];
$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->_user = new Zend_Session_Namespace('User');
$this->_sessionSocial = new Zend_Session_Namespace('SocialGoogle');
$this->_sessionSocialFB = new Zend_Session_Namespace('SocialFacebook');
$this->tablename = "TB_TBB2C_Packages_Master";
$this->tablenameTes = "tbl_testimonials";
$this->hotelTypeArr = ['Standard', 'Deluxe', 'Luxury'];
$this->objHelperGeneral = $this->_helper->General;
$this->objHelperLoginwithGoogle = $this->_helper->LoginwithGoogle;
$this->per_page_record = 50;
$this->_resetsession = new Zend_Session_Namespace('UserResetEmail');
$this->customerauthlogin = API_CUSTOMER_AUTH_LOGIN; // from constant file
$this->customerauthloginSocial = API_AGENT_AUTH_LOGIN_SOCIAL; // from constant file
$this->customerauthsignup = API_CUSTOMER_AUTH_SIGNUP; // from constant file
$this->customerbookinglistAPIUrl = API_CUSTOMER_LIST; // from constant file
$this->customerbookingFlightAPIUrl = API_CUSTOMER_FLIGHTLIST; // from constant file
$this->customerFlightInvoiceAPIUrl = API_CUSTOMER_FLIGHTINVOICE; // from constant file
$this->customerFlightVoucherAPIUrl = API_CUSTOMER_FLIGHTVOUCHER; // from constant file
$this->customerprofileAPIUrl = API_CUSTOMER_PROFILE; // from constant file
$this->customerprofilebyemailMobileAPIUrl = API_CUSTOMER_PROFILE_BYEMAIL_MOBILE; // 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();
// echo"<pre>";print_r($data);die;
$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;
}
//echo "<pre>";print_r($response);die('fsdfdsfdsf');
$response_decode = Zend_Json::decode($response, true);
if ($response_decode == 1) {
$reply = ['status' => false, 'message' => 'Invalid login credentials'];
echo Zend_Json::encode($reply);
exit;
} elseif ($response_decode == 2) {
$reply = ['status' => false, 'message' => 'Your account is inactive. Please Contact to the administrator.'];
echo Zend_Json::encode($reply);
exit;
} else {
echo Zend_Json::encode($response_decode);
exit;
}
} else {
die('oops wrong request');
}
}
public function agencycustomerloginapiAction()
{
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);
//echo "<pre>";print_r($response_decode);die('fsdfdsfdsf');
if ($response_decode == 1) {
$reply = ['status' => false, 'message' => 'Invalid login credentials'];
echo Zend_Json::encode($reply);
exit;
} elseif ($response_decode == 2) {
$reply = ['status' => false, 'message' => 'Your account is inactive. Please Contact to the administrator.'];
echo Zend_Json::encode($reply);
exit;
} else {
$data = [
'EmailId' => $response_decode['EmailId'],
'CustomerSysId' => $response_decode['CustomerSysId'],
'AgencySysId' => $response_decode['AgencySysId'],
'FirstName' => $response_decode['FirstName'],
'LastName' => $response_decode['LastName'],
'Password_cu' => $response_decode['Password'],
'ContactNo1' => $response_decode['Contacts'],
];
$this->_user->session = $data;
$this->_redirect($_SERVER['HTTP_REFERER']);
echo Zend_Json::encode($response_decode);
exit;
}
//} else {
// $reply = ['status' => false, 'message' => 'Please use post method'];
// echo Zend_Json::encode($reply);
// exit;
//}
}
public function usersignupAction()
{
header('Access-Control-Allow-Origin: *');
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getParams();
//echo"<pre>";print_r($data);die;
$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
$objFlight = new Travel_Model_FlightMaster();
$IsExistcustomer = $objFlight->GetCustomerData('tbl_customer', null, $data['mobilenum'], $data['EmailId']);
if ($IsExistcustomer) {
$reply = ['status' => false, 'message' => 'This email ID is <b>already registered!</b>
Please <b>login with existing user name and password</b> or try <b>Forgot Password<b> to generate your Password.'];
echo Zend_Json::encode($reply);
exit;
}
// echo"<pre>";print_r($IsExistcustomer);die;
if ($data['password'] !== $data['copassword']) {
$reply = ['status' => false, 'message' => "Confirm password does't matched"];
echo Zend_Json::encode($reply);
exit;
}
if (isset($data['firstName'])) {
$fbid = $data['fbid'];
} else {
$fbid = "";
}
$apiData = array(
'fname' => $data['firstName'],
'lname' => $data['lastName'],
'customerEmail' => $data['EmailId'],
'countrycode' => $data['countrycode'],
'mobilenumber' => ((isset($data['mobile'])) && !empty($data['mobile'])) ? (int)$data['mobile'] : (int)$data['mobilenum'],
'source' => 'website',
'password' => $data['password'],
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
try {
$curl_p = curl_init($this->customerauthsignup);
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);
// echo "<pre>";print_r($response_decode);die;
if ($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])) {
$reply = ['status' => false, 'message' => 'Email id "is already registered". Please sign in or use forgot password to generate new.'];
echo Zend_Json::encode($reply);
exit;
} else {
$signup_data = array(
'SecurityKey' => $response_decode['SecurityKey'],
'CustomerSysId' => base64_decode($response_decode['CustomerSysId']),
'EmailId' => $data['EmailId'],
'fbid' => $fbid,
'AgencySysId' => $this->gtxagencysysid,
'FirstName' => $response_decode['fname'],
'LastName' => $response_decode['lname'],
'Password' => md5($data['password']),
'Contacts' => ($response_decode['mobilenumber']),
);
$arrCustomer = array(
'fbid' => $fbid,
'FirstName' => $data['firstName'],
'LastName' => $data['lastName'],
'GTX_customerSysId' => base64_decode($response_decode['CustomerSysId']),
'EmailId' => $data['EmailId'],
'countryCode' => $data['countrycode'],
'Contacts' => ($response_decode['mobilenumber']),
'paxType' => 1,
'Salutation' => 1,
'Password' => md5($data['password']),
'AgencySysId' => $this->gtxagencysysid,
);
if ($IsExistcustomer) {
$where = "CustomerSysId =? " . $IsExistcustomer['CustomerSysId']; //exit;
$this->objMdl->rv_update('tbl_customer', $arrCustomer, $where);
} else {
//$data = $objFlight->InsertFlightData('tbl_customer',$arrCustomer);
$this->objMdl->rv_insert('tbl_customer', $arrCustomer);
//die($data);
}
$subject = "Register successful";
$message = '<table width="610" border="0" align="center" cellpadding="15" cellspacing="0">
<tr><td style="background:#f17524;"><table width="610" border="0" cellspacing="0" cellpadding="0">
<tr><td valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td colspan="2" align="center" style=" padding:18px 40px;vertical-align: middle;"><img src="' . $this->baseUrl . 'public/upload/' . $this->stylecss . '/images/logo.png" /></td>
</tr> <tr><td> </td></tr>
<tr><td><span style="font:bold 14px Tahoma, Geneva, sans-serif;">Dear Customer,</span></td>
</tr><tr><td> </td></tr>
<tr><td ><span style="font:bold 14px Tahoma, Geneva, sans-serif;">Greetings from ' . $this->siteName . '.</span></td>
</tr><tr> <td> </td>
</tr><tr> <td>Your registration has been successful!</td>
</tr><tr> <td> </td></tr>
<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td width="60%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td style="color:#7f7f7f; font:normal 14px Tahoma, Geneva, sans-serif;">Email Id: ' . $data['EmailId'] . '</td>
</tr><tr><td style="color:#7f7f7f; font:normal 14px Tahoma, Geneva, sans-serif;">Password : ' . $data['password'] . '</td>
</tr><tr><td> </td> </tr></table></td></tr></table></td>
</tr><tr><td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">In case of any assistance please feel free to reach us by email at ' . $contactDetail_mail['email'] . ' or call us at ' . $contactDetail_mail['phone'] . '</span></td>
</tr><tr> <td> </td></tr><tr><td> </td></tr>
<tr> <td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">Regards,</span></td>
</tr><tr><td> </td>
</tr><tr><td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">' . $this->siteName . '</span></td>
</tr> <tr> <td> </td></tr></table></td></tr></table></td></tr></table>';
$configs = [
'to' => $data['EmailId'],
// 'to' => 'mangal@catpl.co.in',
'fromName' => $this->siteName,
'fromEmail' => $contactDetail_mail['email'],
'subject' => $subject,
'bodyHtml' => $message,
];
$this->_helper->General->mailSentByElastice($configs, 'Registration');
$reply = ['status' => true, 'data' => $signup_data, 'message' => 'Register successfully. please wait redirecting for first time login!'];
echo Zend_Json::encode($reply);
exit;
}
} else {
die('oops wrong request');
}
}
public function myprofileAction()
{
$this->checklogin();
$salutation = unserialize($this->salutation);
$apiData = array(
'CustomerSysId' => $this->_user->session['CustomerSysId']
);
$API_URL = Catabatic_Helper::gtxBtoBsite() . "gtxwebservices/get-query/flight-Booking";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'SecurityKey:' . SECURITYKEY,
));
$output = curl_exec($ch);
curl_close($ch);
$response = json_decode($output, true);
$this->view->FlightBookingNew = $response;
// echo"<pre>";print_r($apiData);
// echo"<pre>";print_r($response);
// die();
/* Start Package Booking*/
$API_URL_PACKAGE = Catabatic_Helper::gtxBtoBsite() . "gtxwebservices/get-query/package-Booking";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL_PACKAGE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'SecurityKey:' . SECURITYKEY,
));
$outputPackage = curl_exec($ch);
curl_close($ch);
$responsePackage = json_decode($outputPackage, true);
$this->view->PackageBookingNew = $responsePackage;
/*End Package Booking*/
//echo SECURITYKEY;
//echo"<pre>"; print_r(http_build_query($apiData));echo"</pre>";
// echo"<pre>"; print_r($responsePackage);
// die;
// old code
$apiData = array(
"CustomerSysId" => $_SESSION['User']['session']['CustomerSysId'],
"AgencySysId" => !empty($_SESSION['User']['session']['AgencySysId'])?$_SESSION['User']['session']['AgencySysId']:$this->gtxagencysysid
);
// echo"<pre>"; print_r($_SESSION['User']['session']);die;
$email = $_SESSION['User']['session']['EmailId'];
$ContactNo1 = $_SESSION['User']['session']['ContactNo1'];
try {
$curl = curl_init($this->customerbookinglistAPIUrl);
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;
}
//die($this->customerbookingFlightAPIUrl);
//echo"<pre>";print_r($apiData);die;
try {
$curl = curl_init($this->customerbookingFlightAPIUrl);
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);
$responseFlight = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
// For profile
try {
$curl_p = curl_init($this->customerprofileAPIUrl);
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;
}
$objFlight = new Travel_Model_FlightMaster();
$cussysid = (int) $this->_user->session['CustomerSysId'];
$CustomerData = $this->objMdl->selectOne('tbl_customer', ['*'], ['GTX_customerSysId' => $this->_user->session['CustomerSysId'], 'IsMarkForDel' => 0, 'IsActive' => 1]);
$customersysid = $CustomerData->CustomerSysId;
$currentDate = date('Y-m-d');
$CustomerMember = $this->objMdl->rv_select_all('tbl_customer_member', ['CustomerMemberSysId'], ['CustomerSysId' => $CustomerData['CustomerSysId'], 'GTX_customerSysId' => $this->_user->session['CustomerSysId'], 'IsMarkForDel' => 0], ['CustomerMemberSysId' => 'DESC']);
$customerArr = [];
if ($CustomerMember) {
foreach ($CustomerMember as $k => $val) {
$customerArr[$k] = $val['CustomerMemberSysId'];
}
$customerArr[$k + 1] = $CustomerData['CustomerSysId'];
} else {
$customerArr[0] = $CustomerData['CustomerSysId'];
}
$customerArrHT[0] = $CustomerData['CustomerSysId'];
$hotel_booking = $objFlight->getHotelsBookingListCustomer('tbl_hotel_booking', $customerArr);
$objFlight = new Travel_Model_FlightMaster();
if ($this->busapi == '1') {
$bus_booking = $objFlight->getBusBookingListCustomer('tbl_bus_booking', $customerArr);
}
$flight_booking = $objFlight->getFlightBookingListCustomer('tbl_flight_booking', $customerArr);
$Post_flight_booking = $objFlight->getFlightBookingList('tbl_flight_booking', $customerArr, $currentDate);
//
if ($this->gtxagencysysid == '16486') {
// echo"<pre>";print_r($this->_user->session['CustomerSysId']);echo"</pre>";
// echo"<pre>";print_r($CustomerData['CustomerSysId']);echo"</pre>";
// echo"<pre>";print_r($CustomerData->CustomerSysId);echo"</pre>";
// echo"<pre>";print_r($customerArr);echo"</pre>";
//echo"<pre>";print_r($bus_booking);echo"</pre>";;
}
$page = $this->_getParam('page', 1);
$resultset = Zend_Paginator::factory($flight_booking);
$resultset->setItemCountPerPage($this->per_page_record);
$resultset->setCurrentPageNumber($page);
//echo '<pre>';print_r($flight_booking);die;
# End : Pagination
//echo"<pre>";print_r($resultset);die;
$this->view->per_page_record = $this->per_page_record;
$this->view->page = $page;
$this->view->resultset = $resultset;
//echo '<pre>';print_r($customerArr);die;
$objCar = new Car_Model_CarMaster();
$carsearch['customerEmail'] = $email;
if ($this->carapi == '1') {
$car_booking = $objCar->getCarBookingList('tbl_car_bookings', $carsearch);
//echo"<pre>";print_r();die;
}
// echo"<pre>";print_r($apiData);die;
$result = array();
$decodeJSON = Zend_Json::decode($response, true);
$decode_profile = Zend_Json::decode($response_pro, true);
$responseFlight = Zend_Json::decode($responseFlight, true);
if (count($decodeJSON['getdata']) > 0) {
foreach ($decodeJSON['getdata'] as $key => $val) {
$RoomInfoJson = Zend_Json::decode($val['RoomInfoJson'], true);
$result[] = [
'all' => $val,
'roominfo' => $RoomInfoJson
];
}
}
//die($this->_user->session['CustomerSysId']);
$customerQueryData = $this->objMdl->rv_select_all('tbl_my_query', ['*'], ['CustomerSysId' => $this->_user->session['CustomerSysId'], 'IsMarkForDel' => 0], ['query_id' => 'DESC']);
$bookconfirm = new Zend_Session_Namespace('bookingconfirm');
//echo"<pre>";print_r($bookconfirm->params);die;
$this->view->gtxagencysysid = $this->gtxagencysysid;
$bookconfirm->params = $car_booking;
$this->view->CarData = $car_booking;
$this->view->hotel_booking = $hotel_booking;
$this->view->bus_booking = $bus_booking;
$this->view->customerQueryData = $customerQueryData;
$this->view->alldata = $result;
$this->view->responseFlight = $responseFlight;
$this->view->salutation = $salutation;
$this->view->profile = $decode_profile['profile'];
$this->view->countryArr = $decode_profile['countryArr'];
}
public function updateprofileAction()
{
$this->checklogin();
if ($this->getRequest()->isPost()) {
$this->checklogin();
$data = $this->getRequest()->getParams();
$DOB = (isset($data['DOB']) && !empty($data['DOB']) ? explode('/', $data['DOB']) : explode('/', '01/01/1900'));
$PAE = (isset($data['PassportExpiry']) && !empty($data['PassportExpiry']) ? explode('/', $data['PassportExpiry']) : explode('/', '01/01/1900'));
$MAR = (isset($data['MarriageAnniversary']) && !empty($data['MarriageAnniversary']) ? explode('/', $data['MarriageAnniversary']) : explode('/', '01/01/1900'));
$apiData = array(
'Title' => $data['title'],
'FirstName' => $data['FirstName'],
'LastName' => $data['LastName'],
'contacts' => $data['contacts'],
'PassportNo' => $data['PassportNo'],
'PassportExpiry' => $PAE[2] . '-' . $PAE[1] . '-' . $PAE[0],
'DOB' => $DOB[2] . '-' . $DOB[1] . '-' . $DOB[0],
'MarriageAnniversary' => $MAR[2] . '-' . $MAR[1] . '-' . $MAR[0],
"CustomerSysId" => $this->_user->session['CustomerSysId'],
"AgencySysId" => $this->gtxagencysysid,
"country" => $data['country'],
"city" => $data['city'],
"GSTNo" => '',
);
// echo '<pre>';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 ($this->gtxagencysysid == '4539') {
// print_r($this->customerupdateprofilePIUrl);
// print_r($response_pro);
// die;
// }
if ($response_pro == 1) {
$reply = ['status' => true, 'message' => 'Your Profile has been successfully updated.'];
echo Zend_Json::encode($reply);
exit;
} else {
$reply = ['status' => false, 'message' => 'Unable to update your profile. try again'];
echo Zend_Json::encode($reply);
exit;
}
}
}
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_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);
$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" => $this->_user->session['CustomerSysId'],
"AgencySysId" => $this->gtxagencysysid,
);
//echo '<pre>';print_r($apiData);die;
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;
}
//echo '<pre>';print_r($response);die;
if ($response == 1) {
$reply = ['status' => false, 'message' => 'Old password does not match'];
echo Zend_Json::encode($reply);
exit;
} else if ($response == 2) {
$reply = ['status' => false, 'message' => 'Confirm password does not match with new password'];
echo Zend_Json::encode($reply);
exit;
} else if ($response == 3) {
$reply = ['status' => true, 'message' => 'Password has been changed successfully.'];
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();
$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
$apiData = array(
"forget" => $param['forget'],
"AgencySysId" => $this->gtxagencysysid,
"type" => 1
);
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($reseturlclick);die;
$name = $FirstName;
$customer_email = $EmailId;
$from_email = $contactDetail_mail['email'];
$subject = "Password Change Request ";
$message = "Hello $name<br><br>";
$message .= "Greetings from $this->siteName team.<br><br>";
$message .= "It is our pleasure to fulfill your request for new password.<br><br>";
$message .= "To change your account password at $this->siteName please click this link or copy and paste the following link into your browser. This link expire within 10 minutes: <br><br>";
$message .= " <a href='$reseturlclick'>Click here to reset your password</a> <br><br><br>";
$message .= "Thank you for customer with us.<br><br>";
$message .= "$this->siteName Team.";
$configs = [
'to' => $customer_email,
'fromName' => $this->siteName,
'fromEmail' => $from_email,
'subject' => $subject,
'bodyHtml' => $message,
];
// $this->_helper->General->mailSentByElastice( $configs , 'Forgot' );
// Mail it
$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;
}
} else {
echo 'Oops wrong request';
exit;
}
}
public function checkresetlinkAction()
{
if ($_SESSION['User']['session']) {
$this->_redirect('customer/myprofile');
}
$param = $this->getRequest()->getParams();
//echo "<pre>";print_r($param);die;
$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()
{
//print_r($_SESSION['UserResetEmail']);die;
if (isset($_SESSION['UserResetEmail']['resetpass'])) {
$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('/');
}
public function unsetdataAction()
{
$storage = new Zend_Session_Namespace('User');
$storage->unsetAll();
$this->_redirect('/');
}
/**
* 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('customer/account');
}
}
/******Google authentication code by sibo*****/
public function loginwithGoogleAction()
{
require_once __DIR__ . '../../../library/GoogleAPI/vendor/autoload.php';
$gClient = new Google_Client();
$gClient->setClientId(google_client_id);
$gClient->setClientSecret(google_client_secret);
$gClient->setRedirectUri($this->baseUrl . 'customer/loginwith-google');
$gClient->addScope('email');
$gClient->addScope('profile');
if (isset($_GET['code'])) {
// Get Token
$token = $gClient->fetchAccessTokenWithAuthCode($_GET['code']);
if (!isset($token['error'])) {
// Setting Access token
$gClient->setAccessToken($token['access_token']);
// store access token
$_SESSION['access_token'] = $token['access_token'];
// Get Account Profile using Google Service
$gservice = new Google_Service_Oauth2($gClient);
// Get User Data
$userData = $gservice->userinfo->get();
// $apiData__ = array(
// 'id' => $userData['id'],
// 'email' => $userData['email'],
// 'gender' => $userData['gender'],
// 'picture' => $userData['picture'],
// 'familyName' => $userData['familyName'],
// 'givenName' => $userData['givenName'],
// );
$contactDetail_mail = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getContactDetailForFooter();
$objFlight = new Travel_Model_FlightMaster();
$IsExistcustomer = $objFlight->GetCustomerData('tbl_customer', null, null, $userData['email']);
$passwordNew = date('Ymdhis');
$apiData = array(
'fname' => $userData['givenName'],
'lname' => $userData['familyName'],
'customerEmail' => $userData['email'],
'countrycode' => 0,
'mobilenumber' => 0,
'source' => 'website',
'password' => $passwordNew,
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
try {
$curl_p = curl_init($this->customerauthsignup);
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);
$encryptedData = new Travel_Model_AtomAES();
// echo "<pre>";
// print_r($response_decode);
// echo "<pre>";
// print_r($apiData);
// die('dd');
if ($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])) {
$redirecturl = $encryptedData->encrypt(json_encode($response_decode), SECURITYKEY, SECURITYKEY);
$this->_redirect('customer/social-authentication?data=' . $redirecturl);
} else {
$signup_data = array(
'SecurityKey' => $response_decode['SecurityKey'],
'CustomerSysId' => base64_decode($response_decode['CustomerSysId']),
'EmailId' => $userData['email'],
'fbid' => $userData['id'],
'AgencySysId' => $this->gtxagencysysid,
'FirstName' => $response_decode['fname'],
'LastName' => $response_decode['lname'],
'Password' => md5($passwordNew),
'Contacts' => ($response_decode['mobilenumber']),
);
$arrCustomer = array(
'fbid' => $userData['id'],
'FirstName' => $userData['givenName'],
'LastName' => $userData['familyName'],
'GTX_customerSysId' => base64_decode($response_decode['CustomerSysId']),
'EmailId' => $userData['email'],
'countryCode' => $response_decode['countrycode'],
'Contacts' => ($response_decode['mobilenumber']),
'paxType' => 1,
'Salutation' => 1,
'Password' => md5($passwordNew),
'AgencySysId' => $this->gtxagencysysid,
);
if ($IsExistcustomer) {
$where = "CustomerSysId =? " . $IsExistcustomer['CustomerSysId']; //exit;
$this->objMdl->rv_update('tbl_customer', $arrCustomer, $where);
} else {
//$data = $objFlight->InsertFlightData('tbl_customer',$arrCustomer);
$this->objMdl->rv_insert('tbl_customer', $arrCustomer);
//die($data);
}
$subject = "Register successful";
$message = '<table width="610" border="0" align="center" cellpadding="15" cellspacing="0">
<tr><td style="background:#f17524;"><table width="610" border="0" cellspacing="0" cellpadding="0">
<tr><td valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td colspan="2" align="center" style=" padding:18px 40px;vertical-align: middle;"><img src="' . $this->baseUrl . 'public/upload/' . $this->stylecss . '/images/logo.png" /></td>
</tr> <tr><td> </td></tr>
<tr><td><span style="font:bold 14px Tahoma, Geneva, sans-serif;">Dear Customer,</span></td>
</tr><tr><td> </td></tr>
<tr><td ><span style="font:bold 14px Tahoma, Geneva, sans-serif;">Greetings from ' . $this->siteName . '.</span></td>
</tr><tr> <td> </td>
</tr><tr> <td>Your registration has been successful!</td>
</tr><tr> <td> </td></tr>
<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td width="60%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td style="color:#7f7f7f; font:normal 14px Tahoma, Geneva, sans-serif;">Email Id: ' . $userData['email'] . '</td>
</tr><tr><td style="color:#7f7f7f; font:normal 14px Tahoma, Geneva, sans-serif;">Password : ' . $data['password'] . '</td>
</tr><tr><td> </td> </tr></table></td></tr></table></td>
</tr><tr><td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">In case of any assistance please feel free to reach us by email at ' . $contactDetail_mail['email'] . ' or call us at ' . $contactDetail_mail['phone'] . '</span></td>
</tr><tr> <td> </td></tr><tr><td> </td></tr>
<tr> <td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">Regards,</span></td>
</tr><tr><td> </td>
</tr><tr><td ><span style="font:normal 14px Tahoma, Geneva, sans-serif;">' . $this->siteName . '</span></td>
</tr> <tr> <td> </td></tr></table></td></tr></table></td></tr></table>';
$configs = [
'to' => $userData['email'],
'fromName' => $this->siteName,
'fromEmail' => $contactDetail_mail['email'],
'subject' => $subject,
'bodyHtml' => $message,
];
$this->_helper->General->mailSentByElastice($configs, 'Registration');
$redirecturl = $encryptedData->encrypt(json_encode($signup_data), SECURITYKEY, SECURITYKEY);
$this->_redirect('customer/social-authentication?data=' . $redirecturl);
}
} else {
$this->_redirect('/');
}
}
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
//$Loginwithgoogle = $this->objHelperLoginwithGoogle->Loginwithgoogle();
// echo"<pre>"; print_r($Loginwithgoogle);die('dd');
$this->_redirect($gClient->createAuthUrl());
}
public function socialAuthenticationAction()
{
$encryptedData = new Travel_Model_AtomAES();
$getData = $this->getRequest()->getParams();
if (isset($getData['data']) && !empty($getData['data'])) {
$data = $getData['data'];
$signup_data = $encryptedData->decrypt($data, SECURITYKEY, SECURITYKEY);
$signup_data = json_decode($signup_data, 1);
$this->view->data = $data;
$LoginDataSet = [];
if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->getPost()) {
$LoginDataSet['AgencySysId'] = isset($signup_data['AgencySysId'])?$signup_data['AgencySysId']:0;
$LoginDataSet['CustomerSysId'] = isset($signup_data['CustomerSysId'])?$signup_data['CustomerSysId']:0;
$LoginDataSet['EmailId'] = isset($signup_data['EmailId'])?$signup_data['EmailId']:'';
$LoginDataSet['FirstName'] = isset($signup_data['FirstName'])?$signup_data['FirstName']:'';
$LoginDataSet['LastName'] = isset($signup_data['LastName'])?$signup_data['LastName']:'';
$LoginDataSet['Password_cu'] = isset($signup_data['Password'])?$signup_data['Password']:'';
$LoginDataSet['Contacts'] = isset($signup_data['Contacts'])?$signup_data['Contacts']:'';
if ($signup_data['CustomerSysId'] == '' || empty($signup_data['CustomerSysId'])) {
$reply = ['status' => false, 'message' => 'Email id "is already registered". Please sign in or use forgot password to generate new.'];
echo Zend_Json::encode($reply);
exit;
} else {
$this->_user->session = $LoginDataSet;
$reply = ['status' => true, 'data' => $signup_data, 'message' => 'Register successfully. please wait redirecting for first time login!'];
echo Zend_Json::encode($reply);
exit;
}
}
}
}
public function googleAuthenticationAction()
{
$userData = $this->objHelperLoginwithGoogle->redirectgoogle();
$apiData = array(
'id' => $userData['id'],
'email' => $userData['email'],
'gender' => $userData['gender'],
'picture' => $userData['picture'],
'familyName' => $userData['familyName'],
'givenName' => $userData['givenName'],
);
if (isset($userData['email']) && !empty($userData['email'])) {
$mail = $userData['email'];
$customerdata = $this->objMdl->rv_select_row('tbl_customer', ['EmailId', 'Contacts'], ['EmailId' => $mail, 'IsMarkForDel' => 0], ['CustomerSysId' => 'DESC']);
}
//$this->_sessionSocial->sessionSocial = $apiData;
//$this->_user->session = $apiData;
if (isset($customerdata['EmailId']) && !empty($customerdata['EmailId'])) {
$this->_sessionSocial->sessionSocial = $apiData;
$this->_redirect('customer/login');
} elseif (!empty($userData['email'])) {
$apiData = array(
'id' => $userData['id'],
'email' => $userData['email'],
'gender' => $userData['gender'],
'picture' => $userData['picture'],
'familyName' => $userData['familyName'],
'givenName' => $userData['givenName'],
);
$this->_sessionSocial->sessionSocial = $apiData;
$this->_redirect('customer/login');
} else {
$apiData = array(
'id' => $userData['id'],
'email' => $userData['email'],
'gender' => $userData['gender'],
'picture' => $userData['picture'],
'familyName' => $userData['familyName'],
'givenName' => $userData['givenName'],
);
$this->_sessionSocial->sessionSocial = $apiData;
//$this->_user->session = $apiData;
$this->_redirect('customer/social-register');
}
}
public function loginAction()
{
if (isset($this->_sessionSocial->sessionSocial) && !empty($this->_sessionSocial->sessionSocial)) {
$password = rand(10000, 100000);
// $storage = new Zend_Session_Namespace('Social');
// $storage->unsetAll();
// $this->_redirect('/');
$apiData = array(
'fname' => $this->_sessionSocial->sessionSocial['givenName'],
'lname' => $this->_sessionSocial->sessionSocial['familyName'],
'customerEmail' => $this->_sessionSocial->sessionSocial['email'],
'countrycode' => '91',
'mobilenumber' => '',
'source' => '',
'password' => $password,
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
//echo '<pre>';print_r($apiData);die;
$this->view->apiData = $apiData;
// echo '<pre>';print_r($apiData);die;
//if($this->getRequest()->isPost()){
$param = $this->getRequest()->getParams();
//echo '<pre>';print_r($param);die;
$apiDataLogin = array(
'fname' => $this->_sessionSocial->sessionSocial['givenName'],
'lname' => $this->_sessionSocial->sessionSocial['familyName'],
'customerEmail' => $this->_sessionSocial->sessionSocial['email'],
'countrycode' => isset($param['ountryCode']) ? $param['ountryCode'] : '',
'mobilenumber' => isset($param['mobilenumber']) ? $param['mobilenumber'] : '',
'source' => '',
'password' => date('d-m-y h:s:i'),
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
//echo '<pre>';print_r($apiDataLogin);die;
try {
$curl_p = curl_init($this->customerauthsignup);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($apiDataLogin));
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);
if ($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])) {
$datas = array(
'CustomerEmail' => $response_decode['customerEmail'],
'CustomerMobile' => $response_decode['mobilenumber'],
'AgencySysId' => $this->gtxagencysysid,
);
try {
$curl_p = curl_init($this->customerprofilebyemailMobileAPIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($datas));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_user = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$users_decode = Zend_Json::decode($response_user, true);
if ($users_decode['status'] == '1') {
$Login_Data = array(
'userName' => $users_decode['profile']['EmailId'],
'userPassword' => $users_decode['profile']['Password'],
'AgencySysId' => $this->gtxagencysysid
);
}
} else {
//echo '<pre>';print_r($response_decode);die('ff');
if ($response_decode['status'] == 'success') {
$Login_Data = array(
'userName' => $response_decode['customerEmail'],
'userPassword' => $response_decode['_token'],
'AgencySysId' => $this->gtxagencysysid
);
}
}
try {
$curl_p = curl_init($this->customerauthloginSocial);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($Login_Data));
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_login_decode = Zend_Json::decode($response, true);
//echo '<pre>';print_r($response_login_decode );die;
if ($response_login_decode == 2) {
$reply = ['status' => false, 'message' => 'Your account is inactive. Please Contact to the administrator.'];
echo Zend_Json::encode($reply);
exit;
} else {
$this->_user->session = $response_login_decode;
$this->_redirect('/');
echo Zend_Json::encode($response_login_decode);
exit;
}
// }
//echo '<pre>';print_r($response_decode);die('ff');
} else {
die('Access Denied');
}
}
public function loginfacebookAction()
{
if (isset($this->_sessionSocialFB->_sessionSocialFB) && !empty($this->_sessionSocialFB->_sessionSocialFB)) {
$apiData = array(
'fname' => $this->_sessionSocialFB->_sessionSocialFB['givenName'],
'lname' => $this->_sessionSocialFB->_sessionSocialFB['familyName'],
'customerEmail' => $this->_sessionSocialFB->_sessionSocialFB['email'],
'fbid' => $this->_sessionSocialFB->_sessionSocialFB['id'],
'countrycode' => $this->_sessionSocialFB->_sessionSocialFB['countryCode'],
'Contacts' => $this->_sessionSocialFB->_sessionSocialFB['phone'],
'source' => '',
'password' => $this->_sessionSocialFB->_sessionSocialFB['password'],
'AgencySysId' => $this->gtxagencysysid,
'AgentSysId' => $this->gtxagentsysid
);
$apiData['customerEmail'] = $this->_sessionSocialFB->_sessionSocialFB['email'];
$apiData['Contacts'] = $this->_sessionSocialFB->_sessionSocialFB['phone'];
$apiData['countrycode'] = $this->_sessionSocialFB->_sessionSocialFB['countryCode'];
$apiData['password'] = $this->_sessionSocialFB->_sessionSocialFB['password'];
$this->view->apiData = $apiData;
try {
$curl_p = curl_init($this->customerauthsignup);
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;
}
echo '<pre>';
print_r($apiData);
echo '<pre>';
print_r($response);
die('ff');
$response_decode = Zend_Json::decode($response, true);
if ($response_decode['CustomerSysId'] == '' || empty($response_decode['CustomerSysId'])) {
$datas = array(
'CustomerEmail' => $response_decode['customerEmail'],
'CustomerMobile' => $response_decode['mobilenumber'],
'AgencySysId' => $this->gtxagencysysid,
);
try {
$curl_p = curl_init($this->customerprofilebyemailMobileAPIUrl);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($datas));
curl_setopt($curl_p, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_p, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_p, CURLOPT_TIMEOUT, 300);
$response_user = curl_exec($curl_p);
curl_close($curl_p);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$users_decode = Zend_Json::decode($response_user, true);
if ($users_decode['status'] == '1') {
$Login_Data = array(
'userName' => $users_decode['profile']['EmailId'],
'userPassword' => $users_decode['profile']['Password'],
'AgencySysId' => $this->gtxagencysysid
);
}
} else {
echo '<pre>';
print_r($response_decode);
die('ff');
if ($response_decode['status'] == 'success') {
$Login_Data = array(
'userName' => $response_decode['customerEmail'],
'userPassword' => $response_decode['_token'],
'AgencySysId' => $this->gtxagencysysid
);
}
}
try {
$curl_p = curl_init($this->customerauthloginSocial);
curl_setopt($curl_p, CURLOPT_POST, true);
curl_setopt($curl_p, CURLOPT_POSTFIELDS, http_build_query($Login_Data));
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_login_decode = Zend_Json::decode($response, true);
if ($response_login_decode == 2) {
$reply = ['status' => false, 'message' => 'Your account is inactive. Please Contact to the administrator.'];
echo Zend_Json::encode($reply);
exit;
} else {
$this->_user->session = $response_login_decode;
$this->_redirect('/');
echo Zend_Json::encode($response_login_decode);
exit;
}
//echo '<pre>';print_r($response_decode);die('ff');
} else {
die('Access Denied');
}
}
/*******Login with Facebook*********/
// public function loginwithFacebookAction()
// {
// $Loginwithgoogle = $this->objHelperLoginwithFacebook->Loginwithfacebook();
// print_r($Loginwithgoogle);die('dd');
// $this->_redirect($Loginwithgoogle);
// }
public function facebookAuthenticationAction()
{
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$response = json_encode($param);
$strFilePath = "customer/facebook/" . date('Y-m-d-H-i-s') . '_' . "_login_response";
Zend_Controller_Action_HelperBroker::getStaticHelper("General")->createApiCallLogs($strFilePath, $response);
$fbmail = $param['femail'];
//
if (!empty($fbmail)) {
$customerdata = $this->objMdl->rv_select_row('tbl_customer', ['EmailId', 'Contacts', 'FirstName', 'LastName', 'Password', 'countryCode'], ['EmailId' => $param['femail'], 'IsMarkForDel' => 0], ['CustomerSysId' => 'DESC']);
} elseif (isset($param['fbid']) && !empty($param['fbid'])) {
$fbid = $param['fbid'];
$customerdata = $this->objMdl->rv_select_row('tbl_customer', ['EmailId', 'Contacts', 'FirstName', 'LastName', 'Password', 'countryCode'], ['fbid' => $fbid, 'IsMarkForDel' => 0], ['CustomerSysId' => 'DESC']);
}
// echo"<pre>";print_r($customerdata);
// echo"<pre>";print_r($param);
die('Somethings went wrong');
if (isset($customerdata['EmailId']) && !empty($customerdata['EmailId'])) {
//echo"<pre>";print_r($customerdata);die;
$apiDatalogin = array(
'id' => $param['fbid'],
'email' => $customerdata['EmailId'],
'phone' => $customerdata['Contacts'],
'picture' => $param['profilephoto'],
'familyName' => $customerdata['FirstName'],
'givenName' => $customerdata['LastName'],
'password' => $customerdata['Password'],
'countryCode' => $customerdata['countryCode'],
);
$this->_sessionSocialFB->_sessionSocialFB = $apiDatalogin;
//$this->_user->session = $apiDatalogin;
$this->_redirect('customer/loginfacebook');
} elseif (!empty($fbmail)) {
$apiDatalogin = array(
'id' => $param['fbid'],
'email' => $param['femail'],
'picture' => $param['profilephoto'],
'familyName' => $param['ffirst_name'],
'givenName' => $param['flast_name'],
);
$this->_sessionSocialFB->_sessionSocialFB = $apiDatalogin;
$this->_user->session = $apiDatalogin;
$this->_redirect('customer/loginfacebook');
} else {
$apiDatalogin = array(
'id' => $param['fbid'],
'email' => $param['femail'],
'picture' => $param['profilephoto'],
'familyName' => $param['ffirst_name'],
'givenName' => $param['flast_name'],
);
$this->_sessionSocialFB->_sessionSocialFB = $apiDatalogin;
$this->_user->session = $apiDatalogin;
$this->_redirect('customer/social-register');
}
}
}
public function customerloginAction()
{
$request = Zend_Controller_Front::getInstance()->getRequest();
if ($this->getRequest()->isPost()) {
$data = $request->getPost();
// echo '<pre>';print_r($data);die('dd');
$redirect_link_r = isset($data['redirect_link_r']) ? $data['redirect_link_r'] : '/';
//echo '<pre>';print_r($data);die('dd');
$this->_user->session = $data;
$response = array('status' => true, 'msg' => 'success', 'redirect_link' => $redirect_link_r);
echo json_encode($response);
exit;
}
}
public function logoutAction()
{
$storage = new Zend_Session_Namespace('User');
$storage->unsetAll();
$SocialGoogle = new Zend_Session_Namespace('SocialGoogle');
$SocialGoogle->unsetAll();
$SocialFacebook = new Zend_Session_Namespace('SocialFacebook');
$SocialFacebook->unsetAll();
$redirecturl = $_SERVER['HTTP_REFERER'];
$this->_redirect($redirecturl);
}
public function socialRegisterAction()
{
//echo"<pre>";print_r($this->_sessionSocialFB->_sessionSocialFB);die;
//$this->_sessionSocial->sessionSocial;
//$this->_sessionSocialFB->_sessionSocialFB
//echo"<pre>";print_r($this->_sessionSocialFB->_sessionSocialFB);die;
if (isset($this->_sessionSocialFB->_sessionSocialFB['givenName']) && !empty($this->_sessionSocialFB->_sessionSocialFB['givenName'])) {
$apiData = array(
'fid' => $this->_sessionSocialFB->_sessionSocialFB['id'],
'fname' => $this->_sessionSocialFB->_sessionSocialFB['givenName'],
'lname' => $this->_sessionSocialFB->_sessionSocialFB['familyName'],
'Contacts' => $this->_sessionSocialFB->_sessionSocialFB['phone'],
'customerEmail' => $this->_sessionSocialFB->_sessionSocialFB['email'],
'password' => date('d-m-y h:s:i'),
);
} else {
$apiData = array(
'fid' => '',
'fname' => $this->_sessionSocial->sessionSocial['familyName'],
'lname' => $this->_sessionSocial->sessionSocial['givenName'],
'Contacts' => $this->_sessionSocial->sessionSocial['phone'],
'customerEmail' => $this->_sessionSocial->sessionSocial['email'],
'password' => date('d-m-y h:s:i'),
);
}
// echo"<pre>";print_r($apiData);die;
$this->view->apiData = $apiData;
}
public function downloadVoucherAction()
{
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$this->view->layout()->disableLayout();
$param = $this->getRequest()->getParams();
$TPSysId = $param['TPSysId'] ? $param['TPSysId'] : '';
//$fullName = $param['fullName'] ? trim($param['fullName']).'-Voucher' : '';
$fullName = $TPSysId . '-Voucher';
$AgencySysId = $this->gtxagencysysid;
$folderName = 'doc/' . $AgencySysId . '/vouchers/' . $TPSysId . '/' . $fullName . '.pdf';
$url111 = "https://img.hellogtx.com/image-upload/?document=" . $folderName . "&agency_id=" . $AgencySysId;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url111,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"gtxkey: DFRT5634@GHUYPO123458910RTY",
"postman-token: cea34a74-6e97-580c-d4fd-c8a20bdbba34"
),
));
$response = curl_exec($curl);
//echo "<pre>";print_r($response);die('dddd');
$responseArr = json_decode($response, 1);
$err = curl_error($curl);
curl_close($curl);
$document = isset($responseArr[0]['document']) ? trim($responseArr[0]['document']) : '';
if (!empty($document)) {
echo json_encode(array('status' => true, 'message' => '', 'document' => $document));
exit;
} else {
echo json_encode(array('status' => false, 'message' => 'Voucher Not Found, Please try after some time.'));
exit;
}
}
public function deleteAction()
{
//echo '<pre>';print_r($this->_user->session);die;
$apiData = array(
"AgencySysId" => $this->gtxagencysysid,
"CustomerSysId" => $this->_user->session['CustomerSysId'],
);
$apiUrl = $this->gtxbaseUrl . 'gtxwebservices/customerapi/delete-customer-profile';
try {
$curl = curl_init($apiUrl);
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);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'SecurityKey:' . $this->_user->session['SecurityKey'],
));
$response = curl_exec($curl);
curl_close($curl);
} catch (Exception $error) {
$this->view->error_msg = $error->getMessage();
die;
}
$ResponseDecode = Zend_Json::decode($response, true);
if ($ResponseDecode['status'] == true) {
$storage = new Zend_Session_Namespace('User');
$storage->unsetAll();
$SocialGoogle = new Zend_Session_Namespace('SocialGoogle');
$SocialGoogle->unsetAll();
$SocialFacebook = new Zend_Session_Namespace('SocialFacebook');
$SocialFacebook->unsetAll();
} else {
}
$redirecturl = $_SERVER['HTTP_REFERER'];
$this->_redirect($redirecturl);
}
public function accountAction()
{
$this->_helper->layout->disableLayout();
if ($_SESSION['User']['session']) {
$this->_redirect('customer/myprofile');
}
}
}