| 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/marketing/controllers/ |
Upload File : |
<?php
class Marketing_FunnelController extends Catabatic_ValidateGtx {
private $baseUrl = '';
private $intLoggedinUserId = 0;
private $intLoggedinUserAgencySysId = 0;
public $_HtmlPurifier;
public $_crmcustomerObj;
public function init() {
parent::init();
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->baseUrl = $BootStrap['siteUrl'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->_HtmlPurifier = new Zend_Filter_HtmlPurifier();
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
}
public function indexAction() {
$agencySysId = $this->intLoggedinUserAgencySysId;
$this->marketingMdl = new Marketing_Model_Marketing();
$getLeadFunnelList = $this->marketingMdl->getLeadFunnelList($agencySysId);
$paginator = Zend_Paginator::factory($getLeadFunnelList);
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->getLeadFunnelList = $paginator;
$this->view->baseUrl = $this->baseUrl;
}
public function addFunnelAction() {
$AgencyUserId = $this->intLoggedinUserId;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
// $getWhatsappMessageTemplate = $objAgency->getOnlyWhatsappAPITemplate($AgencySysId);
// $this->view->getWhatsappMessageTemplate = $getWhatsappMessageTemplate;
$objCountry = new Travel_Model_TblCountry();
$countryList = $objCountry->getCountryList();
$this->view->countryList = $countryList;
$this->view->AgencySysId = $AgencySysId;
$param = $this->getRequest()->getParams();
$id = isset($param['id']) && !empty($param['id'])? base64_decode($param['id']):null;
if($id){
$getLeadFunnelByid = $this->marketingMdl->getLeadFunnelByid($AgencySysId,$id);
if($getLeadFunnelByid['LocationType']==3){
$getLeadFunnelDestination_Covered = $this->marketingMdl->getLeadFunnelDestination_CoveredCity($id);
} else if($getLeadFunnelByid['LocationType']==2) {
$getLeadFunnelDestination_Covered = $this->marketingMdl->getLeadFunnelDestination_CoveredState($id);
} else if($getLeadFunnelByid['LocationType']==1) {
$getLeadFunnelDestination_Covered = $this->marketingMdl->getLeadFunnelDestination_Covered($id);
}
$this->view->getLeadFunnelByid = $getLeadFunnelByid;
$this->view->getLeadFunnelDestination_Covered = $getLeadFunnelDestination_Covered;
}
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$FunnelId = isset($param['FunnelId']) && !empty($param['FunnelId'])? (int) $param['FunnelId']:0;
$funnelName = trim($param['funnelname']);
$templateid = isset($param['templateid']) && !empty($param['templateid'])? (int) $param['templateid']:null;
$ServiceType = $param['service'];
$leadSource = $param['leadSource'];
$audiencecategory = $param['audiencecategory'];
$targetaudience = $param['targetaudience'];
$daydefore = isset($param['daydefore']) && !empty($param['daydefore'])? $param['daydefore']:0;
$destinationtype = $param['destinationtype'];
$country = isset($param['country']) && !empty($param['country'])? $param['country']:null;
$StateId = isset($param['StateId']) && !empty($param['StateId'])? $param['StateId']:null;
$CityId = isset($param['CityId']) && !empty($param['CityId'])? $param['CityId']:null;
$remark = isset($param['remark']) && !empty($param['remark'])? trim($param['remark']):null;
if (isset($funnelName) && ($funnelName == '')) {
$response = array('status' => false, 'message' => "Please Enter Funnel Name");
echo json_encode($response);
exit;
}
if (isset($ServiceType) && ($ServiceType == '')) {
$response = array('status' => false, 'message' => "Please Select Service");
echo json_encode($response);
exit;
}
if (isset($leadSource) && ($leadSource == '')) {
$response = array('status' => false, 'message' => "Please Select Lead Source");
echo json_encode($response);
exit;
}
if (isset($targetaudience) && ($targetaudience == '')) {
$response = array('status' => false, 'message' => "Please Select Target Audience");
echo json_encode($response);
exit;
}
if(isset($country) && ($country == '') && $destinationtype==1){
$response = array('status' => false, 'message' => "Please Select Country");
echo json_encode($response);
exit;
}
if(isset($StateId) && ($StateId == '') && $destinationtype==2){
$response = array('status' => false, 'message' => "Please Select State");
echo json_encode($response);
exit;
}
if(isset($CityId) && ($CityId == '') && $destinationtype==3){
$response = array('status' => false, 'message' => "Please Select City");
echo json_encode($response);
exit;
}
// if (isset($templateid) && ($templateid == '')) {
// $response = array('status' => false, 'message' => "Please Select Template");
// echo json_encode($response);
// exit;
// }
$savedata = array(
'FunnelName' => $funnelName,
'LeadSourceSysId' => $leadSource,
'ServiceType' => $ServiceType,
'TemplateId' => 0,
'TargetAudience' => $targetaudience,
'BeforeDay' => $daydefore,
'LocationType' => $destinationtype,
'AudienceCategory' => $audiencecategory,
'Remark' => $remark,
'CreateDate' => date("Y-m-d H:i:s"),
'UpdateDate' => date("Y-m-d H:i:s"),
'IsMarkForDel' => 0,
'IsActive' => 1,
'AgencySysId' => $AgencySysId,
'AgentSysId' => $AgencyUserId,
);
if(!empty($FunnelId)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $FunnelId);
$objAgency->updateData('Tb_Agency_Marketing_Lead_Generation_Funnel', $savedata,$where);
$this->marketingMdl->deleteLeadFunnelDestination_Covered($FunnelId);
$returnid = $FunnelId;
} else {
$returnid = $objAgency->insertData('Tb_Agency_Marketing_Lead_Generation_Funnel', $savedata);
}
if(!empty($returnid)){
if(isset($country) && $destinationtype==1){
$cityArray = array(
'DestinationId' => $country,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Lead_Generation_Funnel_Destination_Covered', $cityArray);
}
if(isset($StateId) && $destinationtype==2){
$cityArray = array(
'DestinationId' => $StateId,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Lead_Generation_Funnel_Destination_Covered', $cityArray);
}
if(isset($CityId) && $destinationtype==3){
$cityArray = array(
'DestinationId' => $CityId,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Lead_Generation_Funnel_Destination_Covered', $cityArray);
}
}
$response = array('status' => true, 'message' => "Successfully Added");
echo json_encode($response);
exit;
}
}
public function salesFunnelAction() {
$agencySysId = $this->intLoggedinUserAgencySysId;
$this->marketingMdl = new Marketing_Model_Marketing();
$getSalesFunnel = $this->marketingMdl->getSalesFunnelList($agencySysId);
$paginator = Zend_Paginator::factory($getSalesFunnel);
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->getSalesFunnel = $paginator;
$this->view->baseUrl = $this->baseUrl;
}
public function addSalesFunnelAction() {
$AgencyUserId = $this->intLoggedinUserId;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$IsWhatsApp = $sessionLogin_user->IsWhatsApp;
if(isset($IsWhatsApp) && $IsWhatsApp==1){
$getWhatsappMessageTemplate = $objAgency->getOnlyWhatsappAPITemplate($AgencySysId);
$this->view->getWhatsappMessageTemplate = $getWhatsappMessageTemplate;
}
$objCountry = new Travel_Model_TblCountry();
$countryList = $objCountry->getCountryList();
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
$this->view->agencyUser = $agencyUser;
$this->view->countryList = $countryList;
$this->view->AgencySysId = $AgencySysId;
$this->view->IsWhatsApp = $IsWhatsApp;
$param = $this->getRequest()->getParams();
$id = isset($param['id']) && !empty($param['id'])? base64_decode($param['id']):null;
if($id){
$getSalesFunnelByid = $this->marketingMdl->getSalesFunnelByid($AgencySysId,$id);
$getSalesFunnelLead_Stage = $this->marketingMdl->getSalesFunnelLead_Stage($id);
if($getSalesFunnelByid['ServiceType']==1 || $getSalesFunnelByid['ServiceType']==3){
$getSalesFunnelDestination_Covered = $this->marketingMdl->getSalesFunnelDestination_CoveredCity($id);
} else if($getSalesFunnelByid['ServiceType']==2) {
$getSalesFunnelDestination_Covered = $this->marketingMdl->getSalesFunnelDestination_CoveredAirport($id);
} else{
$getSalesFunnelDestination_Covered = $this->marketingMdl->getSalesFunnelDestination_Covered($id);
}
$this->view->getSalesFunnelByid = $getSalesFunnelByid;
$this->view->getSalesFunnelLead_Stage = $getSalesFunnelLead_Stage;
$this->view->getSalesFunnelDestination_Covered = $getSalesFunnelDestination_Covered;
}
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
// echo "<pre>";
// print_r($param); die();
// error_reporting(E_ALL);
$FunnelId = isset($param['FunnelId']) && !empty($param['FunnelId'])? (int) $param['FunnelId']:0;
$funnelName = trim($param['funnelname']);
$FunnelType = $param['Stagetype'];
$templateid = isset($param['templateid']) && !empty($param['templateid'])? (int) $param['templateid']:null;
$ServiceType = $param['service'];
$leadSource = isset($param['leadSource']) && !empty($param['leadSource'])? $param['leadSource']:array();
$qStage = isset($param['qStage']) && !empty($param['qStage'])? $param['qStage']:array();
$lStage = isset($param['lStage']) && !empty($param['lStage'])? $param['lStage']:array();
$AudienceCategory = $param['audiencecategory'];
$DayAfter = isset($param['DayAfter']) && !empty($param['DayAfter'])? $param['DayAfter']:0;
$TriggerType = $param['TriggerType'];
$TriggerTime = $param['TriggerTime'];
$DateType = $param['DateType'];
$DayAfter2 = isset($param['DayAfter2']) && !empty($param['DayAfter2'])? $param['DayAfter2']:0;
$TriggerTime2 = $param['TriggerTime2'];
$DateType2 = $param['DateType2'];
$remark = isset($param['remark']) && !empty($param['remark'])? trim($param['remark']):null;
$city_multi = isset($param['city_multi']) && !empty($param['city_multi'])? $param['city_multi']:null;
$country = isset($param['country']) && !empty($param['country'])? $param['country']:null;
$AirportCode = isset($param['AirportCode']) && !empty($param['AirportCode'])? $param['AirportCode']:null;
$CityId = isset($param['CityId']) && !empty($param['CityId'])? $param['CityId']:null;
$Othercity = null;
if (isset($funnelName) && ($funnelName == '')) {
$response = array('status' => false, 'message' => "Please Enter Funnel Name");
echo json_encode($response);
exit;
}
if (isset($leadSource) && ($leadSource == '')) {
$response = array('status' => false, 'message' => "Please Select Lead Source");
echo json_encode($response);
exit;
}
if (isset($targetaudience) && ($targetaudience == '')) {
$response = array('status' => false, 'message' => "Please Select Target Audience");
echo json_encode($response);
exit;
}
// if (isset($templateid) && ($templateid == '')) {
// $response = array('status' => false, 'message' => "Please Select Template");
// echo json_encode($response);
// exit;
// }
if($TriggerType==1){
$DayAfter = $DayAfter2;
$TriggerTime = $TriggerTime2;
$DateType = $DateType2;
} else{
$DayAfter = $DayAfter;
$TriggerTime = $TriggerTime;
$DateType = $DateType;
}
$savedata = array(
'FunnelName' => $funnelName,
'FunnelType' => $FunnelType,
'LeadSourceSysId' => $leadSource[0],
'ServiceType' => $ServiceType,
'TemplateId' => 0,
'TriggerType' => $TriggerType,
'TriggerTime' => $TriggerTime,
'DayAfter' => $DayAfter,
'dateType' => $DateType,
'AudienceCategory' => $AudienceCategory,
'Remark' => $remark,
'CreateDate' => date("Y-m-d H:i:s"),
'UpdateDate' => date("Y-m-d H:i:s"),
'IsMarkForDel' => 0,
'IsActive' => 1,
'AgencySysId' => $AgencySysId,
'AgentSysId' => $AgencyUserId,
);
if(!empty($FunnelId)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $FunnelId);
$objAgency->updateData('Tb_Agency_Marketing_Sales_Funnel', $savedata,$where);
$this->marketingMdl->deleteSalesFunnelLead_Stage($FunnelId);
$this->marketingMdl->deleteSalesFunnelDestination_Covered($FunnelId);
$returnid = $FunnelId;
}else{
$returnid = $objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel', $savedata);
}
if(!empty($returnid)){
if($FunnelType==1 && !empty($qStage)){
foreach($qStage as $key => $ls){
$qStageArr = array(
'LeadStageId' => $ls,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Lead_Stage', $qStageArr);
}
}
if($FunnelType==2 && !empty($lStage)){
foreach($lStage as $key => $ls){
$LeadStageArr = array(
'LeadStageId' => $ls,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Lead_Stage', $LeadStageArr);
}
}
if(!empty($city_multi) && ($ServiceType==1)){
$citymulti = explode(',',$city_multi);
foreach($citymulti as $ckey => $city){
$cityArray = array(
'DestinationId' => $city,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Destination_Covered', $cityArray);
}
}
if(!empty($country) && ($ServiceType==4)){
$cityArray = array(
'DestinationId' => $country,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Destination_Covered', $cityArray);
}
if(!empty($AirportCode) && ($ServiceType==2)){
$cityArray = array(
'DestinationId' => $AirportCode,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Destination_Covered', $cityArray);
}
if(!empty($CityId) && ($ServiceType==3)){
$cityArray = array(
'DestinationId' => $CityId,
'SalesFunnelSysId' => $returnid
);
$objAgency->insertData('Tb_Agency_Marketing_Sales_Funnel_Destination_Covered', $cityArray);
}
}
$response = array('status' => true, 'message' => "Successfully Added");
echo json_encode($response);
exit;
}
}
public function updatestausleadfunnelAction(){
$this->_helper->layout->disableLayout();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
$Id = base64_decode($this->getRequest()->getParam('id'));
$val = $this->getRequest()->getParam('val');
$updateData = array('IsActive' => ($val == 1) ? 0 : 1);
if(!empty($Id)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $Id);
$objAgency->updateData('Tb_Agency_Marketing_Lead_Generation_Funnel', $updateData,$where);
$response = array('status' => true);
echo json_encode($response);
exit;
}
}
public function deleteleadfunnelAction(){
$this->_helper->layout->disableLayout();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
$Id = base64_decode($this->getRequest()->getParam('id'));
$updateData = array('IsMarkForDel' => 1);
if(!empty($Id)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $Id);
$objAgency->updateData('Tb_Agency_Marketing_Lead_Generation_Funnel', $updateData,$where);
$this->marketingMdl->deleteLeadFunnelDestination_Covered($id);
$response = array('status' => true);
echo json_encode($response);
exit;
}
}
public function updatestaussalesfunnelAction(){
$this->_helper->layout->disableLayout();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
$Id = base64_decode($this->getRequest()->getParam('id'));
$val = $this->getRequest()->getParam('val');
$updateData = array('IsActive' => ($val == 1) ? 0 : 1);
if(!empty($Id)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $Id);
$objAgency->updateData('Tb_Agency_Marketing_Sales_Funnel', $updateData,$where);
$response = array('status' => true);
echo json_encode($response);
exit;
}
}
public function deletesalesfunnelAction(){
$this->_helper->layout->disableLayout();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$this->marketingMdl = new Marketing_Model_Marketing();
$Id = base64_decode($this->getRequest()->getParam('id'));
$updateData = array('IsMarkForDel' => 1);
if(!empty($Id)){
$where = array('AgencySysId = ? ' => $AgencySysId, 'Id = ? ' => $Id);
$objAgency->updateData('Tb_Agency_Marketing_Sales_Funnel', $updateData,$where);
$this->marketingMdl->deleteSalesFunnelLead_Stage($id);
$this->marketingMdl->deleteSalesFunnelDestination_Covered($id);
$response = array('status' => true);
echo json_encode($response);
exit;
}
}
public function getAutosuggestStateAction(){
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$typevalue = $this->_HtmlPurifier->filter($this->getRequest()->getParam("query"));
$objState = new Travel_Model_TblState();
if (isset($typevalue) && $typevalue != '') {
$objState->strCondition .= " AND (TB_Master_Geo_State.Title like '" . $typevalue . "%') ";
}
$stateList = $objState->getStateList();
$response = array();
if (!empty($stateList)) {
foreach ($stateList as $row) {
$response[] = array('StateId' => $row['StateId'], 'label' => $row['Title']);
}
}
echo json_encode($response);
exit();
}
}
public function getAutosuggestCityAction(){
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$typevalue = $this->_HtmlPurifier->filter($this->getRequest()->getParam("query"));
$objCity = new Travel_Model_TblCity();
if (isset($typevalue) && $typevalue != '') {
$objCity->strCondition .= " AND (TB_Master_Geo_City.Title like '" . $typevalue . "%' or TB_Master_Geo_City.Alias like '" . $typevalue . "%') ";
}
$cityList = $objCity->getCityList();
$response = array();
if (!empty($cityList)) {
foreach ($cityList as $row) {
$response[] = array('CityId' => $row['CityId'], 'label' => $row['Title']);
}
}
echo json_encode($response);
exit();
}
}
}