| 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/modules/gtxlead/controllers/ |
Upload File : |
<?php
class Gtxlead_CampaignUrlBuilderController extends Catabatic_ValidateGtx
{
public $baseUrl;
public $reportMdl;
private $intLoggedinUserId;
private $intLoggedinUserAgencySysId;
public $DIR_WRITE_MODE = '';
public $_crmcustomerObj;
public $_crmcusttravelplan;
public function init()
{
parent::init();
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->reportMdl = new Marketing_Model_Marketing();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->view->intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->DIR_WRITE_MODE = 0777;
}
public function indexAction()
{
$objAgency = new Travel_Model_TblAgency();
$this->view->baseUrl = $this->baseUrl;
$agencySysId = $this->intLoggedinUserAgencySysId;
$UserSysId = $this->intLoggedinUserId;
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($agencySysId);
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$TblAgencyStaff = new Travel_Model_TblAgencyStaff();
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($UserSysId);
$this->view->leadSource = $getleadSource;
$this->view->agentDetails = $agentDetails;
$AgencyStaff = $TblAgencyStaff->getAgencyUserList($agencySysId);
$AgencyMedium = $objAgency->getLeadMediumList($agencySysId);
$AgencyCampaign = $objAgency->getLeadCampaignList($agencySysId);
$this->view->AgencyStaff = $AgencyStaff;
$this->view->AgencyMedium = $AgencyMedium;
$this->view->AgencyCampaign = $AgencyCampaign;
}
// public function secureCode($agencySysId, $UserSysId, $TPSysId)
// {
// $finalCode = $agencySysId . $UserSysId . $TPSysId;
// $checkId = hash('sha256', "GTX-$finalCode");
// return $checkId;
// }
public function secureCodeT($agencySysId, $UserSysId, $GtxLeadSysId) {
$finalCode = $agencySysId . $UserSysId . $GtxLeadSysId;
$checkId = hash('sha256', "GTX-$finalCode");
return $checkId;
}
public function getencodedurlAction()
{
$this->view->layout()->disableLayout();
$this->view->baseUrl = $this->baseUrl;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$objPackage = new Travel_Model_TblPackage();
$resultArray = array();
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$ExploMasterCampSysId = (isset($param['MasterCampSysId']) && $param['MasterCampSysId'] != '' && $param['MasterCampSysId'] != 0) ? explode('~' , $param['MasterCampSysId']) : '';
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
$IsSiteType = trim($param['IsSiteType']);
$IsB2CUrl = trim($param['IsB2CUrl']);
$Url = trim($param['Url']);
$websiteUrl = trim($param['websiteUrl']);
$UserSysId = trim($param['UserSysId']);
$User = !empty(trim($param['UserSysId'])) ? 'UId=' . $UserSysId . '&' : '';
$LeadSourceSysId = '&source=' . urlencode(trim($param['LeadSourceSysId']));
$MediumName = '&utm_medium=' . urlencode(trim($param['MediumSysId']));
$CampaignName = 'utm_campaign=' . urlencode(trim($ExploMasterCampSysId['1']));
$MasterCampaignName = (isset($ExploMasterCampSysId['1']) && $ExploMasterCampSysId['1'] != '') ? trim($ExploMasterCampSysId['1']) : '';
$MasterCampSysId = (isset($ExploMasterCampSysId['0']) && $ExploMasterCampSysId['0'] != '') ? (int) ($ExploMasterCampSysId['0']) : '';
$checkCampaignData = array();
if ($MasterCampSysId != '' && $MasterCampSysId != 0) {
$checkCampaignData = $objPackage->getCampaignNameIdDataById($MasterCampSysId);
}
if (!empty($checkCampaignData)) {
$MasterCampSysId = $MasterCampSysId;
} else {
$saveData = array('CampaignName' => $MasterCampaignName, 'IsDefault' => 0, 'AgencySysId' => $AgencySysId, 'IsActive' => 1, 'IsMarkForDel' => 0);
$MasterCampSysId = $objPackage->insertData('TB_Agency_Campaign_Master', $saveData);
}
$campaignNameId = '&campId=' . trim($MasterCampSysId);
$leadpageId = trim($param['leadpageId']);
$code = $this->secureCodeT($AgencySysId, $UserSysId, $leadpageId);
if(!empty($leadpageId)){
$templatePageName = $objPackage->gettemplateNameById($leadpageId);
$addUrl = '?' . $User . 'lId=' . $leadpageId . $campaignNameId.$LeadSourceSysId;
$b2landingcurl = $websiteUrl .'lp/'. str_replace(' ', '-', strtolower($templatePageName['TemplatePageName'])) .'-'. $leadpageId.$addUrl;
$redirectUrl = $this->baseUrl . 'gtx.php?AId=' . $AgencySysId . '&UId=' . $UserSysId . '&lId=' . $leadpageId . '&code=' . $code . $campaignNameId;
}else{
$addUrl = '?' . $User . $CampaignName.$LeadSourceSysId.$MediumName;
$b2landingcurl = $websiteUrl .$addUrl;
$redirectUrl = $this->baseUrl . 'gtx.php?AId=' . $AgencySysId . '&UId=' . $UserSysId . '&code=' . $code . $CampaignName;
}
$URLBuilder = $redirectUrl.$LeadSourceSysId;
if ($agentDetails['IsB2CSite'] == 1) {
$URLBuilder = $websiteUrl . "detail/index/view/id/" . base64_encode($redirectUrl . $LeadSourceSysId);
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 1)) {
$URLBuilder = $websiteUrl . "hellogtx/index.html?id=" . base64_encode($redirectUrl . $LeadSourceSysId);
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 0)) {
$URLBuilder = $websiteUrl . "hellogtx/gtx.php?id=" . base64_encode($redirectUrl . $LeadSourceSysId);
}
if (isset($URLBuilder)) {
$BITLYLOGIN = 'gpurwar';
$BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($URLBuilder, $BITLYLOGIN, $BITLYAPIKEY);
$shortUrl = $bitly_response['results'][$URLBuilder]['shortUrl'];
$sessionUserData = new Zend_Session_Namespace('sessionLogin_user');
$Title = isset($sessionUserData->agencyDetails['Title']) ? (trim($sessionUserData->agencyDetails['Title'])) : '';
$FirstName = isset($sessionUserData->FirstName) ? (trim($sessionUserData->FirstName)) : '';
$LastName = isset($sessionUserData->LastName) ? (trim($sessionUserData->LastName)) : '';
$fullName = $FirstName . ' ' . $LastName;
$GetWhatsappUrl = Zend_Controller_Action_HelperBroker::getStaticHelper('GetWhatsappUrl')->GetWhatsappUrl();
$siteMsg = '%0a%0aPlease visit our brand new website and check latest deals at '.$agentDetails['Url'].' or call us for assistance to plan *Only Hotel Stays*, *Weekend trips*, *Family Picnic Arrangements* on all the locations.';
$whatsappText = 'Hi,%0a%0aThis is *'.$fullName.'* and I am working on improving customer experiences at * '.$Title.' *.%0a%0aWe request you to rate the services you received form us in the past by clicking on the link below:%0a%0a' . $shortUrl .$siteMsg.'%0a%0aRegards,%0aCustomer Experience Team';
$whatsapplink = $GetWhatsappUrl.'send?phone=&text='.$whatsappText;
echo json_encode(array('status' => true, 'URLBuilder' => $URLBuilder,'ShortUrl'=>$shortUrl,'whatsapptxt'=>$whatsapplink, 'b2clandingurl' => $b2landingcurl));
exit;
} else {
echo json_encode(array('status' => false));
exit;
}
}
}
public function getCampaignMasterNameAction()
{
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$strCampaignName = $this->getRequest()->getParam('term');
$strtype = $this->getRequest()->getParam('type');
$result = array();
$objPackage = new Travel_Model_TblPackage();
$agencySysId = $this->intLoggedinUserAgencySysId;
$result = $objPackage->getCampaignNameAutoSearchList($strCampaignName, $agencySysId, $strtype);
//echo "<pre>";print_r($result);die;
echo $this->_helper->json($result);
exit;
}
}
public function saveNewMasterCampaignAction()
{
$this->view->layout()->disableLayout();
$this->view->baseUrl = $this->baseUrl;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$objPackage = new Travel_Model_TblPackage();
$resultArray = array();
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$campaignName = (isset($param['CampaignNamePop'])) ? trim($param['CampaignNamePop']) : '';
$saveData = array('CampaignName' => $campaignName, 'IsDefault' => 0, 'AgencySysId' => $AgencySysId, 'IsActive' => 1, 'IsMarkForDel' => 0);
$MasterCampSysId = $objPackage->insertData('TB_Agency_Campaign_Master', $saveData);
if ($MasterCampSysId) {
$response = array('status' => true, 'MasterCampSysId' => $MasterCampSysId, 'MasterCampaignName' => $campaignName);
} else {
$response = array('status' => false, 'CampSysId' => 0);
}
echo json_encode($response);
exit;
}
}
public function shortUrlBuilderAction(){
}
public function generateShortUrlAction(){
$this->view->layout()->disableLayout();
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$URLBuilder = $param['url'];
if (isset($URLBuilder)) {
$BITLYLOGIN = 'gpurwar';
$BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($URLBuilder, $BITLYLOGIN, $BITLYAPIKEY);
$shortUrl = $bitly_response['results'][$URLBuilder]['shortUrl'];
$ShortUrlSegment = explode('/',$shortUrl);
echo json_encode(array('status' => true, 'URLBuilder' => $URLBuilder,'ShortUrl'=>$shortUrl,'ShortUrlId'=>$ShortUrlSegment[3]));
exit;
} else {
echo json_encode(array('status' => false));
exit;
}
}
}
}