| 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/controllers/ |
Upload File : |
<?php
#error_reporting(-1);
#error_reporting(E_ALL);
#ini_set('error_reporting', E_ALL);
#ini_set("display_errors", 1);
/* * ***************
* Zend Framework
* @category Zend
* @package Zend_Controller_Action
* @copyright Copyright (c) 2008-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DbTable.php 8862 2012-03-16 15:36:00Z thomas $
* @author Prashant Kr Gupta
* Create Date 27-07-2016
* Update Date 27-07-2016
* CustomerControoler (It will allow users to add different masters)
* *** */
class CustomerController extends Catabatic_ValidateGtx {
private $intLoggedinUserId;
private $intLoggedinUserGroupSysId;
private $intLoggedinUserAgencySysId;
private $intLoggedinUserTrxCurrency;
private $manageNotifications;
public $baseUrl;
private $IsSMSApi;
public $_crmcustomerObj;
public $_crmagencyleadaccountObj;
public $_travelplanObj;
public $_travelplanitenaryObj;
public $_travelitenaryaccom;
public $_travelitenaryair;
public $_travelplanevents;
public $_travelplanplaces;
public $_travelplansight;
public $_travelplanmarketwiserate;
public $_travelinsuranceobj;
public $_travelinsumemberobj;
public $_travelplancostsheet;
public $_crmcustomertodoObj;
public $_crmcusttravelplan;
public $_crmcusttravelplanItenaryAccom;
public $_crmcusttravelplanAir;
public $_crmcusttravelplanHotel;
public $_crmcustomertravelItenary;
public $_crmcustomertravelFixed;
public $_crmcustomertravelItenaryEvents;
public $_crmcustomertravelItenaryPlaces;
public $_crmcustomertravelMarketPlaces;
public $_crmcustomertravelPlanRate;
public $_crmcustomertravelSightSeeing;
public $_crmcustomertravelTransport;
public $_crmcustomertravelTerm;
public $_crmremarkObj;
public $_searchhotelObj;
public $_objAirport;
public $_agencycustomerObj;
public $_customermemberObj;
public $_agencyObj;
public $_objPkg;
public $_HtmlPurifier;
private $smtpUserName;
private $smtpPassword;
private $smtpPort;
private $smtpHost;
private $fromEmail;
private $fromName;
public $_agencyuserroleObj;
public $BITLYLOGIN;
public $BITLYAPIKEY;
public $arrCustomerSysId = array();
public $statustypeIDForExpiredArr = [5, 6, 7, 8, 13, 17];
public $statustypenameForExpiredArr = [
'Confirmed - Payment Pending',
'Confirmed - PaymentFailed',
'Confirmed - Booking Pending',
'Confirmed - Payment made',
'Confirmed - Partial Payment',
'Proposal Booked',
];
public $agencyDetails = [];
public function init() {
parent::init();
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->baseUrl = $request->getScheme() . '://' . $request->getHttpHost();
$this->view->headScript()->appendFile($this->baseUrl . '/public/assets/js/jquery-ui.js');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->manageNotifications = $sessionLogin_user->manageNotifications;
$this->IsSMSApi = $sessionLogin_user->agencyDetails['IsSMSApi'];
$this->agencyDetails = $sessionLogin_user->agencyDetails;
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$this->_travelplanObj = new Travel_Model_Package_PackageModel();
$this->_travelplanitenaryObj = new Travel_Model_Package_TravelPlanItenary();
$this->_travelitenaryaccom = new Travel_Model_Package_TravelPlanItenaryAccom();
$this->_travelitenaryair = new Travel_Model_Package_TravelPlanItenaryAir();
$this->_travelplanevents = new Travel_Model_Package_TravelPlanItenaryEvents();
$this->_travelplanplaces = new Travel_Model_Package_TravelPlanItenaryPlaces();
$this->_travelplansight = new Travel_Model_Package_TravelPlanItenarySight();
$this->_travelplanmarketwiserate = new Travel_Model_Package_TravelPlanItenaryMarketWise();
$this->_travelinsuranceobj = new Travel_Model_CRM_CustomerTravelInsurance();
$this->_travelinsumemberobj = new Travel_Model_CRM_CustomerTravelInsuranceMember();
$this->_travelplancostsheet = new Travel_Model_CRM_CostSheet();
$this->_crmcustomertodoObj = new Travel_Model_CRM_AgencyCustomerTodo();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$this->_custquerytravelObj = new Travel_Model_TblCustomerTravelPlanQuery();
$this->_crmcusttravelplanItenaryAccom = new Travel_Model_CRM_CustomerTravelPlanAccom();
$this->_crmcusttravelplanAir = new Travel_Model_CRM_CustomerTravelPlanAir();
$this->_crmcusttravelplanHotel = new Travel_Model_CRM_CustomerTravelPlanHotel();
$this->_crmcustomertravelItenary = new Travel_Model_CRM_CustomerTravelItenary();
$this->_crmcustomertravelFixed = new Travel_Model_CRM_CustomerTravelPlanFixed();
$this->_crmcustomertravelItenaryEvents = new Travel_Model_CRM_CustomerTravelItenaryEvents();
$this->_crmcustomertravelItenaryPlaces = new Travel_Model_CRM_CustomerTravelItenaryPlaces();
$this->_crmcustomertravelMarketPlaces = new Travel_Model_CRM_CustomerTravelItenaryMarketRate();
$this->_crmcustomertravelPlanRate = new Travel_Model_CRM_CustomerTravelPackRate();
$this->_crmcustomertravelSightSeeing = new Travel_Model_CRM_CustomerTravelItenarySightSeeing();
$this->_crmcustomertravelTransport = new Travel_Model_CRM_CustomerTravelTransport();
$this->_crmcustomertravelTerm = new Travel_Model_CRM_CustomerTravelTerm();
$this->_crmremarkObj = new Travel_Model_CRM_Remark();
$this->_searchhotelObj = new Travel_Model_TblHotel();
$this->_objAirport = new Travel_Model_TblAirport();
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$this->_customermemberObj = new Travel_Model_CRM_CustomerMember();
$this->_agencyObj = new Travel_Model_TblAgency();
$objFlight = new Travel_Model_TblFlight();
$this->_objPkg = new Travel_Model_PackageSearch();
// this->_objPackage = new Travel_Model_PackageSearch();
// $packageInclusionList = $objPackage->getPackageInclusionList();
############## For HTML Purifer ####################
$this->_HtmlPurifier = new Zend_Filter_HtmlPurifier();
// unlocking read-only lock
/* if ($sessionLogin_user->isLocked()) {
$sessionLogin_user->unLock();
} */
#### Script to send email ####
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$this->smtpUserName = $aConfig['smtpUserName'];
$this->smtpPassword = $aConfig['smtpPassword'];
$this->smtpPort = $aConfig['smtpPort'];
$this->smtpHost = $aConfig['smtpHost'];
$this->fromEmail = $aConfig['fromEmail'];
$this->fromName = $aConfig['fromName'];
//for country list
$objCountry = new Travel_Model_TblCountry();
$countryList = $objCountry->getCountryList();
$this->view->countryList = $countryList;
#### Script to send email End ####
$this->BITLYLOGIN = 'gpurwar';
$this->BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
//echo "<pre>";print_r($_SESSION);exit;
}
public function indexAction() {
//echo 'test';
}
public function senddataAction() {
// error_reporting(E_ALL);
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$AgencyCRMLeadSysId = 0;
$detail = array();
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
$leadsource = $this->_HtmlPurifier->filter($this->_request->getParam('leadsource'));
if (isset($passexpiry) && !empty($passexpiry)) {
$passexpiry = explode('/', $passexpiry);
$passexpiry = $passexpiry[2] . "-" . $passexpiry[1] . "-" . $passexpiry[0];
}
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
if (isset($custanniversary) && !empty($custanniversary)) {
$custanniversary = explode('/', $custanniversary);
$custanniversary = $custanniversary[2] . "-" . $custanniversary[1] . "-" . $custanniversary[0];
}
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
if (isset($custdob) && !empty($custdob)) {
$custdob = explode('/', $custdob);
$custdob = $custdob[2] . "-" . $custdob[1] . "-" . $custdob[0];
}
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$B2BAgencySysId = (NULL != $this->_request->getParam('SelectedAgencySysId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('SelectedAgencySysId')) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (isset($leadsource) && is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$updatedate = date('Y-m-d H:i:s');
if ($source == "mainPage") {
echo $mobilenum = $this->_request->getParam('mobilenum');
echo $customername = $this->_request->getParam('customername');
echo $emailID = $this->_request->getParam('emailID');
exit;
} else {
$editID = base64_decode($this->_request->getParam('editID'));
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$countrycode = $this->_request->getParam('countrycode');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
//$address = $this->_request->getParam('address');
//$PinCode = $this->_request->getParam('PinCode');
$StateOrZoneSysId = $this->_request->getParam('StateOrZoneSysId');
$SecondaryEmail = $this->_request->getParam('SecondaryEmail');
$ContactNo1 = $this->_request->getParam('ContactNo1');
$salution = $this->_request->getParam('salution');
$customeraddress = $this->_request->getParam('customeraddress');
$customerpincode = $this->_request->getParam('customerpincode');
$SelectedAgentId = trim($this->_request->getParam('SelectedAgentId'));
$leadStage = trim($this->_request->getParam('leadStage'));
$IsB2BAgent = 0;
if (isset($SelectedAgentId) && !empty($SelectedAgentId) && $SelectedAgentId > 0) {
$CreatedByUserSysId = $SelectedAgentId;
$IsB2BAgent = 1;
} else {
$CreatedByUserSysId = $this->intLoggedinUserId;
}
$userUpdateArray = array(
//'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
//'PrimaryContactNumber' => $mobilenumber,
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
if ($editID) {
//$where = "CRMCustSysId = ". $editID;
//$customerRcord = $this->_crmcustomerObj->UpdateCustomer($userUpdateArray,$where);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city,
'StateOrZoneSysId' => !empty($StateOrZoneSysId) ? $StateOrZoneSysId : 0,
'CountrySysId' => $country,
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsB2BAgent' => $IsB2BAgent,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
'SecondaryEmail' => (isset($SecondaryEmail) && !empty($SecondaryEmail) ? $SecondaryEmail : ''),
'ContactNo1' => (isset($ContactNo1) && !empty($ContactNo1) ? $ContactNo1 : ''),
);
//echo '<pre>';print_r($agencyuserArray);die('ddd');
$where = "CustomerSysId = " . $editID;
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($editID) && !empty($editID)) ? base64_encode($editID) : '';
$detail['CustomerSysIdNew'] = (isset($editID) && !empty($editID)) ? $editID : '';
} else {
if ($B2BAgencySysId != '') {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B(trim($customerEmail), $B2BAgencySysId);
} else {
if ((int) $CustomerSysId > 0) {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailByCustomerSysId(trim($CustomerSysId), $AgencySysId);
} else {
if (trim($customerEmail) != '') {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerEmail), $AgencySysId);
}
if (!empty(trim($mobilenumber)) && empty($getcustomerdetails)) {
$getcustomerdetails = $this->_crmcustomerObj->ChkMobileExistInAgency(trim($mobilenumber), $AgencySysId, '');
}
// echo"<pre>";print_r($getcustomerdetails);die('data');
}
}
$customerRcord = $getcustomerdetails['CustomerSysId'];
$leadStage = (isset($leadStage) && !empty($leadStage)) ? $leadStage : 53;
if ($leadStage == 53) {
if ($CRMCustSysId == '' && empty($getcustomerdetails['CustomerSysId'])) {
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
//echo '<pre>';print_r($userArray);die('dddhh');
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
}
if (empty($getcustomerdetails['CustomerSysId'])) {
//create new lead agency account
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber,
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadStage,
'AssignUserSysId' => $this->intLoggedinUserId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => isset(Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId) ? Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId : 0
);
//for create new customer
//echo '<pre>';print_r($userLeadArray);die('www');
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => trim($customerEmail),
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => isset($city) ? $city : '',
'StateOrZoneSysId' => (isset($StateOrZoneSysId) && !empty($StateOrZoneSysId)) ? $StateOrZoneSysId : 0,
'CountrySysId' => isset($country) ? $country : '',
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'JoinDate' => $updatedate,
'IsApproved' => '0',
'CreatedByUserSysId' => $CreatedByUserSysId,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
'SecondaryEmail' => (isset($SecondaryEmail) && !empty($SecondaryEmail) ? $SecondaryEmail : ''),
'ContactNo1' => (isset($ContactNo1) && !empty($ContactNo1) ? $ContactNo1 : ''),
'IsActive' => '1',
'paxType' => '1',
// 'IsMarkForDelete' => '0',
'LeadSourceSysId' => $leadsource,
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
} else {
$agencyCustomerData = $getcustomerdetails['CustomerSysId'];
}
} else {
$CRMCustSysId = !empty($getcustomerdetails['CustomerSysId']) ? $getcustomerdetails['CustomerSysId'] : $CRMCustSysId;
$mobilenumber = !empty($getcustomerdetails['Contacts']) ? $getcustomerdetails['Contacts'] : $mobilenumber;
$countrycode = !empty($getcustomerdetails['countrycode']) ? trim($getcustomerdetails['countrycode']) : $countrycode;
$fname = !empty($getcustomerdetails['FirstName']) ? trim($getcustomerdetails['FirstName']) : $fname;
$lname = !empty($getcustomerdetails['FirstName']) ? trim($getcustomerdetails['LastName']) : $lname;
$salution = (isset($getcustomerdetails['Salutation']) && !empty($getcustomerdetails['Salutation'])) ? $getcustomerdetails['Salutation'] : $salution;
$customerEmail = (isset($getcustomerdetails['EmailId']) && !empty($getcustomerdetails['EmailId'])) ? $getcustomerdetails['EmailId'] : $customerEmail;
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber,
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadStage,
'AssignUserSysId' => $this->intLoggedinUserId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => isset(Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId) ? Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId : 0
);
//for create lead
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyCustomerData = $getcustomerdetails['CustomerSysId'];
}
$detail['status'] = 'success';
$detail['mobilenumber'] = trim($mobilenumber);
$detail['countrycode'] = trim($countrycode);
$detail['fname'] = trim($fname);
$detail['lname'] = trim($lname);
$detail['customerEmail'] = trim($customerEmail);
$detail['CustomerSysId'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? base64_encode($agencyCustomerData) : '';
$detail['CustomerSysIdNew'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? $agencyCustomerData : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($detail['CustomerSysId']), 1);
$detail['SecureCode'] = $secureCode;
}
$detail['SelectedAgentId'] = trim($SelectedAgentId);
$detail['SelectedAgencySysId'] = trim($B2BAgencySysId);
$detail['LeadId'] = trim($AgencyCRMLeadSysId);
//$detail['customerDetails']=$customerDetails;
// echo "<pre>";print_r($detail);die;
echo json_encode($detail);
}
}
public function senddataOldAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$AgencyCRMLeadSysId = 0;
$detail = array();
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
$leadsource = $this->_HtmlPurifier->filter($this->_request->getParam('leadsource'));
if (isset($passexpiry) && !empty($passexpiry)) {
$passexpiry = explode('/', $passexpiry);
$passexpiry = $passexpiry[2] . "-" . $passexpiry[1] . "-" . $passexpiry[0];
}
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
if (isset($custanniversary) && !empty($custanniversary)) {
$custanniversary = explode('/', $custanniversary);
$custanniversary = $custanniversary[2] . "-" . $custanniversary[1] . "-" . $custanniversary[0];
}
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
if (isset($custdob) && !empty($custdob)) {
$custdob = explode('/', $custdob);
$custdob = $custdob[2] . "-" . $custdob[1] . "-" . $custdob[0];
}
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$B2BAgencySysId = (NULL != $this->_request->getParam('SelectedAgencySysId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('SelectedAgencySysId')) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (isset($leadsource) && is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$updatedate = date('Y-m-d H:i:s');
if ($source == "mainPage") {
echo $mobilenum = $this->_request->getParam('mobilenum');
echo $customername = $this->_request->getParam('customername');
echo $emailID = $this->_request->getParam('emailID');
exit;
} else {
$editID = base64_decode($this->_request->getParam('editID'));
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$countrycode = $this->_request->getParam('countrycode');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
//$address = $this->_request->getParam('address');
//$PinCode = $this->_request->getParam('PinCode');
$StateOrZoneSysId = $this->_request->getParam('StateOrZoneSysId');
$SecondaryEmail = $this->_request->getParam('SecondaryEmail');
$ContactNo1 = $this->_request->getParam('ContactNo1');
$salution = $this->_request->getParam('salution');
$customeraddress = $this->_request->getParam('customeraddress');
$customerpincode = $this->_request->getParam('customerpincode');
$SelectedAgentId = trim($this->_request->getParam('SelectedAgentId'));
$IsB2BAgent = 0;
if (isset($SelectedAgentId) && !empty($SelectedAgentId) && $SelectedAgentId > 0) {
$CreatedByUserSysId = $SelectedAgentId;
$IsB2BAgent = 1;
} else {
$CreatedByUserSysId = $this->intLoggedinUserId;
}
$userUpdateArray = array(
//'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
//'PrimaryContactNumber' => $mobilenumber,
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
if ($editID) {
//$where = "CRMCustSysId = ". $editID;
//$customerRcord = $this->_crmcustomerObj->UpdateCustomer($userUpdateArray,$where);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city,
'StateOrZoneSysId' => !empty($StateOrZoneSysId) ? $StateOrZoneSysId : 0,
'CountrySysId' => $country,
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsB2BAgent' => $IsB2BAgent,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
'SecondaryEmail' => (isset($SecondaryEmail) && !empty($SecondaryEmail) ? $SecondaryEmail : ''),
'ContactNo1' => (isset($ContactNo1) && !empty($ContactNo1) ? $ContactNo1 : ''),
);
//echo '<pre>';print_r($agencyuserArray);die('ddd');
$where = "CustomerSysId = " . $editID;
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($editID) && !empty($editID)) ? base64_encode($editID) : '';
$detail['CustomerSysIdNew'] = (isset($editID) && !empty($editID)) ? $editID : '';
} else {
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
//$leadstage = (isset($getStageList[0]['LeadStageSysId']) && !empty($getStageList[0]['LeadStageSysId']))?$getStageList[0]['LeadStageSysId']:0;
if ($B2BAgencySysId != '') {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B(trim($customerEmail), $B2BAgencySysId);
} else {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerEmail), $AgencySysId);
}
//print_r($getcustomerdetails);die;
$customerRcord = $getcustomerdetails['CustomerSysId'];
//code for customer check added by amit
if ($CRMCustSysId == '' && empty($getcustomerdetails['CustomerSysId'])) {
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
//echo '<pre>';print_r($userArray);die('dddhh');
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
}
if (empty($getcustomerdetails['CustomerSysId'])) {
//create new lead agency account
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber,
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $this->intLoggedinUserId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => isset(Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId) ? Travel_Model_AgencyAuth::getIdentity()->DefaultCampaignId : 0
);
//for create new customer
//echo '<pre>';print_r($userLeadArray);die('www');
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => trim($customerEmail),
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => isset($city) ? $city : '',
'StateOrZoneSysId' => (isset($StateOrZoneSysId) && !empty($StateOrZoneSysId)) ? $StateOrZoneSysId : 0,
'CountrySysId' => isset($country) ? $country : '',
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'JoinDate' => $updatedate,
'IsApproved' => '0',
'CreatedByUserSysId' => $CreatedByUserSysId,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
'SecondaryEmail' => (isset($SecondaryEmail) && !empty($SecondaryEmail) ? $SecondaryEmail : ''),
'ContactNo1' => (isset($ContactNo1) && !empty($ContactNo1) ? $ContactNo1 : ''),
'IsActive' => '1',
'paxType' => '1',
'IsMarkForDelete' => '0',
'LeadSourceSysId' => $leadsource,
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
}
$detail['status'] = 'success';
$detail['mobilenumber'] = trim($mobilenumber);
$detail['countrycode'] = trim($countrycode);
$detail['fname'] = trim($fname);
$detail['lname'] = trim($lname);
$detail['customerEmail'] = trim($customerEmail);
$detail['CustomerSysId'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? base64_encode($agencyCustomerData) : '';
$detail['CustomerSysIdNew'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? $agencyCustomerData : '';
}
$detail['SelectedAgentId'] = trim($SelectedAgentId);
$detail['SelectedAgencySysId'] = trim($B2BAgencySysId);
$detail['LeadId'] = trim($AgencyCRMLeadSysId);
//$detail['customerDetails']=$customerDetails;
echo json_encode($detail);
}
}
public function verifyphoneAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$mobilenum = $this->_request->getParam('mobilenum');
//echo $mobilenum;
$customerID = $this->_crmcustomerObj->ChkMobileNum($mobilenum);
if ($customerID) {
$msg = 'Mobile number found';
} else {
$msg = 'Mobile number not found';
}
echo $msg;
}
public function verifyemailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$email = $this->_request->getParam('emailID');
//echo $mobilenum;
$customerID = $this->_crmcustomerObj->ChkEmail($email);
if ($customerID) {
$response = array('success' => true, 'msg' => 'Email Found.', 'lastID' => $customerID);
} else {
$response = array('success' => true, 'msg' => 'Email not found.', 'lastID' => '');
}
echo json_encode($response);
}
public function customerProfileAction() {
$CRMCustSysId = $this->getRequest()->getParam('id');
$CRMCustSysId = base64_decode($CRMCustSysId);
$CRMCustSysId = $this->_HtmlPurifier->filter($CRMCustSysId);
if (isset($CRMCustSysId) && !empty($CRMCustSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CRMCustSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getPendingPaymentLeadList = $this->_crmcusttravelplan->GetPendingPaymentLeadList($CRMCustSysId, $AgencySysId);
$getLatestLeadList = $this->_crmcusttravelplan->GetLeadList($CRMCustSysId, $AgencySysId);
//this function is used to remove duplicate with sum of adults and childs created by Amit Kumar Dubey on 14 August 2016 at 11:35 AM
$newData = array();
$getLatestLeadList = array_reduce($getLatestLeadList, array($this, 'reduceArray'), $newData);
$this->aasort($getLatestLeadList, "TPSysId");
$getLatestLeadList = array_slice($getLatestLeadList, 0, 5);
/* $result = array();
$desiredKeyName = "TPSysId";
foreach ($getLatestLeadList as $key => $aValue) {
if(!isset($result['TPSysId'])){
$result['TPSysId']=$getLatestLeadList[$key]['TPSysId'];
}else{
if($result['TPSysId']==$getLatestLeadList[$key]['TPSysId']){
$result[]['MatchedData']=$getLatestLeadList[$key]['TPSysId'];
}
}
}
echo "<pre>";
print_r($result);
die;
*/ //end of remove duplicates
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CRMCustSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
//$cityListArray = $this->_objPkg->getCityList();
$cityListArray = array();
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
$this->view->cityListArray = $cityListArray;
$this->view->customerId = $CRMCustSysId;
$this->view->customerDetail = $getCustomerDetail;
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
$this->view->getPendingPaymentLeadList = $getPendingPaymentLeadList;
$this->view->getLatestLeadList = $getLatestLeadList;
}
}
public function aasort($array, $key) {
$sorter = array();
$ret = array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii] = $va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii] = $array[$ii];
}
$array = $ret;
}
public function savequeryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
if ($this->getRequest()->isPost()) {
$leadID = $this->getRequest()->getPost('leadID');
$tpintsysID = $this->getRequest()->getPost('tpintsysID');
$planbookingID = 'Q/' . date('y');
$agencySysID = $this->intLoggedinUserAgencySysId;
$customersysID = $this->getRequest()->getPost('customerID');
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customersysID);
$addrequirement = $this->getRequest()->getPost('addrequirement');
$startdate = date('Y-m-d');
$status = '1';
$createDate = date('Y-m-d H:i:s');
$from = $this->getRequest()->getPost('from');
$to = $this->getRequest()->getPost('to');
$departure_dates_string = $this->getRequest()->getPost('departure_dates');
if (!empty($departure_dates_string)) {
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
}
$adults = $this->getRequest()->getPost('adults');
$flight_class = $this->getRequest()->getPost('flight_class');
$route = $this->getRequest()->getPost('route');
$tpsysID = $this->getRequest()->getPost('tpsysID');
$VersionId = $this->getRequest()->getPost('VersionId');
$return_dates_string = $this->getRequest()->getPost('return_dates');
$explode_return_date = explode("/", $return_dates_string);
$return_dates = $this->getRequest()->getPost('return_dates') ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '01/01/1900';
$adults = $this->getRequest()->getPost('adults');
$child = $this->getRequest()->getPost('child');
$infant = $this->getRequest()->getPost('infant');
$oneway_origin_text = $this->getRequest()->getPost('oneway_origin_text');
$oneway_destination_text = $this->getRequest()->getPost('oneway_destination_text');
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
//create json for roominfo json column created by amit on 28 feb 2017
$childcount = $child;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
for ($c = 1; $c <= $childcount; $c++) {
$childsage = $infant;
$roomjson[1]['ChildAge_' . $c] = $childsage;
}
$roomjson[1]['bedtype'] = '';
$RoomInfoJson = json_encode($roomjson);
#### Flight Validation #########
if (empty($from)) {
$response = array('success' => false, 'msg' => 'Please select source city.');
echo json_encode($response);
exit;
}
if (empty($to)) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if ($from == $to) {
$response = array('success' => false, 'msg' => 'The \'Departure City\' and \'Destination City\' cannot be same. Please re-type.');
echo json_encode($response);
exit;
}
if (empty($departure_dates) || trim($departure_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select departure date');
echo json_encode($response);
exit;
}
if (empty($adults)) {
$response = array('success' => false, 'msg' => 'Please select the number of adults.');
echo json_encode($response);
exit;
}
if (empty($flight_class)) {
$response = array('success' => false, 'msg' => 'Please select the class.');
echo json_encode($response);
exit;
}
if ($route == 'twoway') {
if (empty($return_dates) || trim($return_dates) == EMPTY_DATE_FIELD) {
$response = array('success' => false, 'msg' => 'Please select return date');
echo json_encode($response);
exit;
}
}
#### Flight Validation End #########
$agentsysID = $this->intLoggedinUserId;
$data = array(
'PlanBookingId' => $planbookingID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customersysID,
'PlanType' => 1,
'RoomInfoJson' => $RoomInfoJson,
'AdditionalReq' => $addrequirement,
'StartDate' => $createDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
if (empty($leadID)) {
########### Start Add Data in Travel Table(Base Table) ###################
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->leadID = $lastID;
$sessionLogin_lead_customer->FirstName = $getCustomerDetail['FirstName'] ? $getCustomerDetail['FirstName'] : '';
$sessionLogin_lead_customer->EmailId = $getCustomerDetail['EmailId'] ? $getCustomerDetail['EmailId'] : '';
$sessionLogin_lead_customer->PrimaryContactNumber = $getCustomerDetail['Contacts'] ? $getCustomerDetail['Contacts'] : '';
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $lastID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
########### End Add Data in Travel Air Table ###################
} else {
$agentsysID = $this->intLoggedinUserId;
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($tpsysID);
$versionIDD = $getlatestversion[0]['VersionId'] + 1;
$versionnum = $versionIDD;
$updateddata = array(
'VersionId' => $versionnum,
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $tpsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customersysID,
'RoomInfoJson' => $RoomInfoJson,
'PlanType' => 1,
'AdditionalReq' => $addrequirement,
'StartDate' => $createDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customersysID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $tpsysID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
$lastupdatedID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($updateddata);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->leadID = $lastupdatedID;
$sessionLogin_lead_customer->FirstName = $getCustomerDetail['FirstName'] ? $getCustomerDetail['FirstName'] : '';
$sessionLogin_lead_customer->EmailId = $getCustomerDetail['EmailId'] ? $getCustomerDetail['EmailId'] : '';
$sessionLogin_lead_customer->PrimaryContactNumber = $getCustomerDetail['Contacts'] ? $getCustomerDetail['Contacts'] : '';
}
}
}
public function saveRemarkAction() {
$this->_helper->layout->disableLayout();
$result = '';
if ($this->getRequest()->isPost()) {
$remarks = $this->getRequest()->getParam('remark');
$customerid = $this->getRequest()->getParam('customerId');
$customerid = base64_decode($customerid);
$remarks = $this->_HtmlPurifier->filter($remarks);
$customerid = $this->_HtmlPurifier->filter($customerid);
// query for insert data in db created by amit kumar dubey on 16 august 2016 at 12:40 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$date = date('Y-m-d H:i:s');
$remarkArray = array(
'AgencySysId' => $AgencySysId,
'CustomerSysId' => $customerid,
'AgentSysId' => $AgentSysId,
'Remarks' => $remarks,
'IsActive' => '1',
'CreatedDate' => $date,
'IsMarkForDelete' => '0'
);
$customerRcord = $this->_crmremarkObj->addRemark($remarkArray);
//update customer
$date = date('Y-m-d H:i:s');
$userQueryArray = array(
'UpdateDate' => $date,
);
$whereQuery = "CustomerSysId = " . $customerid . "";
$updatetravelPlan = $this->_agencycustomerObj->UpdateAgencyCustomer($userQueryArray, $whereQuery);
#end
//return $customerRcord;
$result = "success";
}
$status = array('response' => $result);
return $this->_helper->json($status);
}
public function saveLeadRemarkAction() {
$this->_helper->layout->disableLayout();
$result = '';
if ($this->getRequest()->isPost()) {
$remarks = $this->getRequest()->getParam('remark');
$leadRemark = $this->_HtmlPurifier->filter($remarks);
$leadId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('leadId'));
// query for insert data in db created by amit kumar dubey on 16 august 2016 at 12:40 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$leadDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($leadId, 'Query');
$createDate = date('Y-m-d H:i:s');
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $AgencySysId,
'CustomerSysId' => $leadDetails[0]['CustomerSysId'],
'AgentSysId' => $AgentSysId,
'Remarks' => $leadRemark,
'TPSysId' => $leadId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
//update customer
$date = date('Y-m-d H:i:s');
$userQueryArray = array(
'UpdateDate' => $date,
);
$whereQuery = "CustomerSysId = " . $leadDetails[0]['CustomerSysId'] . "";
$updatetravelPlan = $this->_agencycustomerObj->UpdateAgencyCustomer($userQueryArray, $whereQuery);
#end
}
$result = "success";
}
$status = array('response' => $result);
return $this->_helper->json($status);
}
public function customerLeadAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
;
$getHotelResult = $this->_searchhotelObj->getBuyHotelAutoSuggest($term = '');
//$arrResponse = $objHotel->getBuyHotelAutoSuggest($term);
$this->view->searchHotelResult = $getHotelResult;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
//$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$airportlist = '';
$this->view->sourceCity = $airportlist;
}
$getdata = array('IsDraft' => 1);
$AgentSysId = $this->intLoggedinUserId;
if ($this->checkIsAdmin() == true) {
$AgentSysId = '';
} else {
$AgentSysId = $AgentSysId . (isset($ReportingToSysId) && !empty($ReportingToSysId) ? ',' . $ReportingToSysId : '');
}
$AgentSysId = '';
if ((int) $CustomerSysId > 0) {
try {
$getLeadlist = $this->_crmcusttravelplan->GetAgencyLeadList($AgencySysId, $AgentSysId, $getdata, $CustomerSysId);
//echo "<pre>";print_r($getLeadlist);exit;
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
} else {
$getLeadlist = array();
}
//this function is used to remove duplicate with sum of adults and childs created by Amit Kumar Dubey on 14 August 2016 at 11:35 AM
//$newData = array();
//$getLeadlist = array_reduce($getLeadlist,array($this,'reduceArray'),$newData);
//echo "<pre>";
//print_r($getLeadlist);
//end of remove duplicates
$sumArray = array();
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getLeadlist);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
//GRID_PER_PAGE_RECORD_COUNT
$perPage = $paginator->setItemCountPerPage(10); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
### Added For Packge Information By Shobhit ###
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
// $cityListArray = $this->_objPkg->getCityList();
$cityListArray = array();
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
$this->view->cityListArray = $cityListArray;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
$this->view->getleadSource = $getleadSource;
}
public function reduceArray($newData, $value) {
$key = $value['TPSysId'];
if ($key != '') {
if (!isset($newData[$key])) {
$newData[$key] = $value;
} else {
$newData[$key]['adultsinHotel'] += $value['adultsinHotel'];
$newData[$key]['childsinHotel'] += $value['childsinHotel'];
}
}
return $newData;
}
public function array_unique_by_key(&$array, $key) {
$tmp = array();
$result = array();
foreach ($array as $value) {
if (!in_array($value[$key], $tmp)) {
array_push($tmp, $value[$key]);
array_push($result, $value);
}
}
return $array = $result;
}
public function customerContactAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$this->view->code = $code;
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerMemberDetail = $this->_crmcustomerObj->GetCustomerMembersById($getCustomerDetail['AgencySysId'], $getCustomerDetail['CustomerSysId']);
//echo "<pre>";print_r($getCustomerMemberDetail);die;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$this->view->AgencySysId = $AgencySysId;
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getCustomerMemberDetail);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
//this function used for all customer tab beacuse functionlity added in flightsearch lead
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
//echo "<pre>"; print_r($airportlist);die;
//end of flight search lead
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$this->view->ARR_SALUTION = $ARR_SALUTION;
$AgencyWhatsappEnabled = $this->_helper->General->getWhatsappEnabledSetting();
$this->view->whatsappEnabled = $AgencyWhatsappEnabled;
}
}
public function customerPaymentHistoryAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getPaymentHistoryLeadList = $this->_crmcusttravelplan->GetPaymentHistoryLeadList($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$this->view->customerId = $CustomerSysId;
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
;
$this->view->customerDetail = $getCustomerDetail;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getPaymentHistoryLeadList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//this function used for all customer tab beacuse functionlity added in flightsearch lead
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
//echo "<pre>"; print_r($airportlist);die;
//end of flight search lead
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function updateleadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$createDate = date('Y-m-d H:i:s');
$leadID = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadID'));
$flightValues = $this->getRequest()->getPost('flightValues');
$markupprice = $this->getRequest()->getPost('markupprice');
$cardcharges = $this->getRequest()->getPost('cardcharges');
//$travelPlanDetails=$this->_crmcusttravelplan->GetFlightProposal($leadId);
//echo "<pre>";print_r($travelPlanDetails);die;
############ Update Status Of Queries ##########
$agentsysID = $this->intLoggedinUserId;
$agencySysID = $this->intLoggedinUserAgencySysId;
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
############ Get Itenary ID ####################
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->GetItenaryId($leadID);
//$TPIntSysId = $lasttravelitenaryID['TPIntSysId'];
$objFlight = new Travel_Model_TblFlight();
$getflightData = $objFlight->getFlightSearchListForProposal($flightValues);
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
$adults = $sessionFlightSearchParams->params['adults'];
$child = $sessionFlightSearchParams->params['child'];
$infant = $sessionFlightSearchParams->params['infant'];
$roomjson = array();
$childcount = $child;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
for ($c = 1; $c <= $childcount; $c++) {
$childsage = $infant;
$roomjson[1]['ChildAge_' . $c] = $childsage;
}
$roomjson[1]['bedtype'] = '';
$RoomInfoJson = json_encode($roomjson);
$session_customerlead = new Zend_Session_Namespace('customerlead');
//print_r($getflightData->customerlead);die;
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail($session_customerlead->EmailId);
for ($i = 0; $i < count($getflightData); $i++) {
$planbookingID = 'Q/' . date('y');
$data = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $leadID,
'StatusType' => '4',
'InventoryType' => 1,
'PlanType' => 1,
'CurrencyType' => $getflightData[0]['CurrencyType'],
'CustomerSysId' => $getcustomerdetails['CustomerSysId'],
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaces' => $getflightData[$i]['SourcePlaceName'],
'DestinationPlaces' => $getflightData[$i]['DestPlaceName'],
'Cities' => $getflightData[$i]['SourcePlaceName'] . "-" . $getflightData[$i]['DestPlaceName'],
'RoomInfoJson' => $RoomInfoJson,
'Price' => $getflightData[$i]['PublishedFare'] + $getflightData[$i]['CommissionEarned'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => 3,
'IsHotelFromApi' => 1,
'StartDate' => $createDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
########### Start Add Data in Travel Table(Base Table) ###################
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
//$sessionLogin_lead_customer->leadID = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
$arrival_date = $getflightData[$i]['ArrivalTime'];
$departure_date = $getflightData[$i]['DepartureTime'];
$airData = array(
'TPIntSysId' => $lasttravelitenaryID,
'AgencySysId' => $agencySysID,
'FlightNumber' => $getflightData[$i]['FlightNumber'],
'AirlineSysId' => $getflightData[$i]['AirlineSysId'],
'MarkUp' => isset($markupprice[$i]) ? $markupprice[$i] : 0,
'CreateDate' => $createDate,
'FlightCabinClass' => $sessionFlightSearchParams->params['flight_class'],
'AdultPax' => $sessionFlightSearchParams->params['adults'],
'LocalFromTime' => $departure_date->format('Y-m-d'),
'LocalToTime' => $arrival_date->format('Y-m-d'),
'ChildPax' => $sessionFlightSearchParams->params['child'],
'InfentPax' => $sessionFlightSearchParams->params['infant'],
'SourceAirportCode' => $getflightData[$i]['OriginAirportCode'],
'DestAirportCode' => $getflightData[$i]['DestinationAirportCode'],
'UpdateDate' => $createDate,
'IsSelectedOnPkg' => 1,
);
//echo "<pre>";print_r($airData);
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
########### End Add Data in Travel Air Table ###################
//Mail code to send login link to staff
}
$sessionLogin_agnet_details = new Zend_Session_Namespace('sessionLogin_user');
$agentname = $sessionLogin_agnet_details->FirstName . ' ' . $sessionLogin_agnet_details->LastName;
$agentcontact = $sessionLogin_agnet_details->contactnum ? $sessionLogin_agnet_details->contactnum : 'N/A';
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$customername = isset($sessionLogin_lead_customer->FirstName) ? trim($sessionLogin_lead_customer->FirstName) : '';
$customeremail = isset($sessionLogin_lead_customer->EmailId) ? trim($sessionLogin_lead_customer->EmailId) : '';
$customernumber = isset($sessionLogin_lead_customer->PrimaryContactNumber) ? trim($sessionLogin_lead_customer->PrimaryContactNumber) : '';
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $getflightData[0]['SourceAirportCode'];
$OriginAirportArray = $objAirport->getAirportList();
$Origincity = $OriginAirportArray[0]['CityName'];
$objAirport->strAirportCode = $getflightData[0]['DestAirportCode'];
$DestinationAirportArray = $objAirport->getAirportList();
$DestinationCity = $DestinationAirportArray[0]['CityName'];
$path = $_SERVER['SERVER_NAME'] . '/public/assets/images/logo-global-travel.jpg';
//die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// render view
$bodyText = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>
<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #e5e5e5;">
<tr>
<td height="40" align="left" valign="middle" style="border-bottom:1px solid #e5e5e5; color:#333333; font:normal 18px Arial, Helvetica, sans-serif;"> Preview</td>
</tr>
<tr>
<td align="center" style="padding:10px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" align="left" valign="top"><table width="170" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle" style="border:1px solid #e3dfd8; padding:15px 0px;"><img src="http://local.b2bzend.com/public/assets/images/logo-global-travel.jpg"/></td>
</tr>
</table></td>
<td width="67%" align="right" valign="top"><table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" style="border:1px solid #e3dfd8; padding:15px; background:#fafafa; color:#333333; font:normal 14px/20px Arial, Helvetica, sans-serif;">Agent Name : ' . $agentname . '<br />
Agent Contact : ' . $agentcontact . '<br />
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="font:normal 14px/20px Arial, Helvetica, sans-serif; padding:15px 0px; color:#333333;">Dear ' . $customername . '<br /><br />
As per your request, we are forwarding itineraries from ' . $Origincity . ' - ' . $DestinationCity . ' on ' . $departure_date->format('d-M-y') . '</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" style="background:#d9edf7; border-bottom:1px solid #bce8f1; border-top:1px solid #bce8f1; padding:15px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="49%" align="left" valign="top" style="color:#31708f; font:normal 14px/20px Arial, Helvetica, sans-serif;"><strong></strong><br />
' . $Origincity . '-' . $DestinationCity . '</td>
<td width="51%" align="right" valign="top" style="color:#31708f; font:normal 14px/20px Arial, Helvetica, sans-serif;">All | ' . $sessionFlightSearchParams->params['adults'] . ' Adult(s), ' . $sessionFlightSearchParams->params['child'] . ' Child</td>
</tr>
</table></td>
</tr>';
for ($j = 0; $j < count($getflightData); $j++) {
$totalrate = $getflightData[$j]['PublishedFare'] + $getflightData[$j]['CommissionEarned'] + $markupprice[$j];
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $getflightData[$j]['SourceAirportCode'];
$OriginAirportArr = $objAirport->getAirportList();
$OriginAirportCity = $OriginAirportArr[0]['CityName'];
$OriginAirportName = $OriginAirportArr[0]['AirportTitle'];
$objAirport->strAirportCode = $getflightData[$j]['DestAirportCode'];
$DestinationAirportArr = $objAirport->getAirportList();
$DestinationAirportCity = $DestinationAirportArr[0]['CityName'];
$DestinationAirportName = $DestinationAirportArr[0]['AirportTitle'];
$bodyText .= '<tr>
<td align="center" style="padding:20px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="background:#428bca;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" height="40" align="left" valign="middle" style="color:#ffffff; font:normal 15px Arial, Helvetica, sans-serif;"><strong>Flight : ' . $getflightData[$j]['AirlineName'] . '</strong> <span style="font-size:10px;">' . $getflightData[$j]['AirlineCode'] . '-' . $getflightData[$j]['FlightNumber'] . '</span></td>
<td width="50%" height="40" align="right" valign="middle" style="color:#ffffff; font:normal 15px Arial, Helvetica, sans-serif;">Fare : ' . $totalrate . '</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" style="border:1px solid #428bca; padding:10px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Depart:</strong> ' . $OriginAirportCity . ' (' . $OriginAirportName . ')</td>
<td width="50%" height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Arrive:</strong> ' . $DestinationAirportCity . ' (' . $DestinationAirportName . ')</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Time:</strong> 14:20</td>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Time:</strong> 16:15</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Total Flight Time:</strong>' . $getflightData[$j]['FlightDuration'] . '</td>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"> </td>
</tr>
<tr>
<td height="30" align="left" valign="middle"> </td>
<td height="30" align="right" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><a href="#" style="color:#31708f; font:normal 14px Arial, Helvetica, sans-serif;">Book Now</a> | <a href="#" style="color:#31708f; font:normal 14px Arial, Helvetica, sans-serif;">Enquire</a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>';
}
$bodyText .= '<p align="left">Regards,<br/>' . $agentname . '</p><p align="right">Technology By - globaltravelexchange.com</p></table>
</body>
</html>';
$emailId = trim($customeremail);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $leadID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $getcustomerdetails['CustomerSysId']);
echo 'Email has sent to customer';
} catch (Exception $err) {
print_r($err, true);
}
}
public function addnewleadAction() {
//error_reporting(1);
$this->_helper->layout->disableLayout();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$createDate = date('Y-m-d H:i:s');
$flightremark = $this->getRequest()->getPost('remarks');
$flightValues = $this->getRequest()->getPost('flightValues');
$customerEmail = $this->getRequest()->getPost('email');
$customername = $this->getRequest()->getPost('customername');
$markupprice = $this->getRequest()->getPost('markupprice');
$cardcharges = $this->getRequest()->getPost('cardcharges');
$editLeadId = $this->getRequest()->getPost('editLeadId');
$flightSearchType = $this->getRequest()->getPost('flightSearchType');
$tripType = $this->getRequest()->getPost('tripType');
$isInternational = $this->getRequest()->getPost('isInternational');
$MarkupArray = json_decode($this->getRequest()->getPost('MarkupArray'));
$agencySysID = $this->intLoggedinUserAgencySysId;
$CustomerSysId = !empty($this->getRequest()->getPost('CustomerSysId')) ? trim($this->getRequest()->getPost('CustomerSysId')) : 0;
$CustomerSysIdSel = !empty($this->getRequest()->getPost('customerSysIdSel')) ? base64_decode(trim($this->getRequest()->getPost('customerSysIdSel'))) : 0;
$SACCode = !empty($this->getRequest()->getPost('sac_code')) ? $this->getRequest()->getPost('sac_code') : 440063; // default value 440063 for Tour Oprators..
$gsttype = !empty($this->getRequest()->getPost('gsttype')) ? $this->getRequest()->getPost('gsttype') : '';
$ccemail = !empty($this->getRequest()->getPost('ccemail')) ? $this->getRequest()->getPost('ccemail') : '';
$sendersEmailId = !empty($this->getRequest()->getPost('senderEmailID')) ? $this->getRequest()->getPost('senderEmailID') : trim($sessionLogin_user->EmailId);
if ($CustomerSysId != $CustomerSysIdSel) {
$CustomerSysIdNew = $CustomerSysIdSel;
} else {
$CustomerSysIdNew = $CustomerSysId;
}
$post = $this->getRequest()->getPost();
//echo "<pre>";print_r($post);die;
//$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail($customerEmail,$agencySysID);
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerById($CustomerSysIdNew);
//echo "<pre>";print_r($getcustomerdetails);die;
$customerRcord = $getcustomerdetails['CustomerSysId'];
$customeremail = trim($getcustomerdetails['EmailId']);
$date = date('Y-m-d H:i:s');
//code for customer check added by amit
/* if(empty($getcustomerdetails['CustomerSysId'])){
if(!is_numeric($leadsource) && !empty($leadsource)){
$leadsource=$leadsource;
}else{
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId,'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId']))?$intgetLeadSourceSysId[0]['LeadSourceSysId']:0;
}
if(isset($customerEmail) && !empty($customerEmail)){
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponse($customerEmail,$agencySysID);
}
if(isset($custphone) && !empty($custphone)){
$customerDetails = $this->_crmcustomerObj->ChkMobileWithResponse($custphone,$agencySysID,'','');
}
if(count($customerDetails) == 0){
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => 1,
'AgencySysId' => 0,
'PrimaryContactNumber' => $custphone,
'FullName' => $customername,
'FirstName' => $customername,
'LastName' => (isset($lname) && !empty($lname))?$lname:'',
'LeadSourceSysId' => trim($leadsource),
'ActiveDate' => date('Y-m-d'),
'UpdatedDate' => $createDate,
'CreatedDate' => $createDate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
} else {
$CRMCustSysId = $customerDetails['CRMCustSysId'];
}
//create new lead agency account
$userLeadArray = array(
'AgencySysId' => $agencySysID,
'EmailId' => $customerEmail,
'Salutation' => 1,
'PrimaryContactNumber' => (isset($custphone) && !empty($custphone))?$custphone:'',
'FullName' => $customername,
'FirstName' => $customername?$customername:'',
'LastName' => (isset($lname) && !empty($lname))?$lname:'',
'LeadSourceSysId' => trim($leadsource),
'ActiveDate' => date('Y-m-d'),
'UpdatedDate' => $createDate,
'CreatedDate' => $createDate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $agencySysID,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => $customerEmail,
'Title' => 1,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => (isset($city) && !empty($city))?$city:'',
'StateOrZoneSysId' => 0,
'CountrySysId' => (isset($country) && !empty($country))?$country:'',
'IsEmployee' => '0',
'Contacts' => (isset($custphone) && !empty($custphone))?$custphone:'',
'JoinDate' => date('Y-m-d'),
'UserName' => $customername,
'FirstName' => (isset($customername) && !empty($customername))?$customername:'',
'LastName' => (isset($lname) && !empty($lname))?$lname:'',
'Relation' => 0,
'PassportNo' => (isset($passnumber) && !empty($passnumber))?$passnumber:'',
'PassportExpiry' => (isset($passexpiry) && !empty($passexpiry))?$passexpiry:'',
'DOB' => (isset($custdob) && !empty($custdob))?$custdob:'',
'MarriageAnniversary' => (isset($custanniversary) && !empty($custanniversary))?$custanniversary:'',
'RegisterDate' => date('Y-m-d'),
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//echo "<pre>";print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$customerRcord = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
}
$getCustomerDetailById = $this->_crmcustomerObj->GetCustomerById($customerRcord);
$customeremail = $getCustomerDetailById['EmailId'];
if(count($getCustomerDetailById)==0){
echo "Please try another emailId.";
exit;
} */
//print_r($getCustomerDetailById);die;
//end of code added by amit
############ Update Status Of Queries ##########
$agentsysID = $this->intLoggedinUserId;
//$tpintsysID = $this->getRequest()->getPost('tpintsysID');
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN ($flightValues) ";
$getflightData = $objFlight->getSelectedFlightDetails();
//$getflightData = $objFlight->getFlightSearchListForProposal($flightValues);
$sessionFlightSearchParams = new Zend_Session_Namespace('sessionFlightSearchParams');
##### Code For Creating New Lead #####
//$addrequirement = $sessionFlightSearchParams->params['from'];
$startdate = date('Y-m-d H:i:s');
$status = '2';
$createDate = date('Y-m-d H:i:s');
$from = $sessionFlightSearchParams->params['from'];
$to = $sessionFlightSearchParams->params['to'];
$departure_dates_string = $sessionFlightSearchParams->params['departure_dates'];
$explode_date = explode("/", $departure_dates_string);
$departure_dates = $explode_date[2] . '-' . $explode_date[1] . '-' . $explode_date[0];
$adults = $sessionFlightSearchParams->params['adults'];
$flight_class = $sessionFlightSearchParams->params['flight_class'];
$route = $sessionFlightSearchParams->params['route'];
$return_dates_string = $sessionFlightSearchParams->params['return_dates'];
$explode_return_date = explode("/", $return_dates_string);
$return_dates = (isset($sessionFlightSearchParams->params['return_dates']) && !empty($sessionFlightSearchParams->params['return_dates'])) ? $explode_return_date[2] . '-' . $explode_return_date[1] . '-' . $explode_return_date[0] : '1900-01-01';
$adults = $sessionFlightSearchParams->params['adults'];
$child = $sessionFlightSearchParams->params['child'];
$infant = $sessionFlightSearchParams->params['infant'];
$oneway_origin_text = isset($sessionFlightSearchParams->params['oneway_origin_text']) ? $sessionFlightSearchParams->params['oneway_origin_text'] : $sessionFlightSearchParams->params['sourceCityAirportCode'];
$oneway_destination_text = isset($sessionFlightSearchParams->params['oneway_destination_text']) ? $sessionFlightSearchParams->params['oneway_destination_text'] : $sessionFlightSearchParams->params['destinationCityAirportCode'];
$intCountryCode = $sessionFlightSearchParams->params['intCountryCode'];
$IsInterNational = $sessionFlightSearchParams->params['interNationalSearch'];
if ($IsInterNational) {
$intCountryCode = "INTERNATIONAL";
} else {
$intCountryCode = "IN";
}
$roomjson = array();
$childcount = $child;
$roomjson[1]['Adult'] = $adults;
$roomjson[1]['Child'] = $child;
$roomjson[1]['Infant'] = $infant;
$roomjson[1]['ChildAge_1'] = $infant;
$roomjson[1]['departuredate'] = $departure_dates_string;
$roomjson[1]['returndate'] = $return_dates_string;
$roomjson[1]['fromaircode'] = $oneway_origin_text;
$roomjson[1]['toaircode'] = $oneway_destination_text;
$roomjson[1]['airclass'] = $flight_class;
$RoomInfoJson = json_encode($roomjson);
if (($CustomerSysId != $CustomerSysIdSel)) {
$planbookingID = 'QS/' . date('y');
$data = array(
'PlanBookingId' => $planbookingID,
'StatusType' => $status,
'CustomerSysId' => $customerRcord,
'AdditionalReq' => '',
'PlanType' => 1,
'InventoryType' => 1,
'TemplatePckSysId' => !empty($editLeadId) ? trim($editLeadId) : 0,
'CurrencyType' => $getflightData[0]['CurrencyType'],
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaceSysId' => $getflightData[0]['SourcePlaceSysId'],
'DestinationPlacesSysId' => (int) $getflightData[0]['DestPlaceSysId'],
'SourcePlaces' => $getflightData[0]['SourcePlaceName'],
'DestinationPlaces' => $getflightData[0]['DestPlaceName'],
'Cities' => $getflightData[0]['SourcePlaceName'] . "-" . $getflightData[0]['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => 3,
'IsHotelFromApi' => 1,
'CreateDate' => $createDate,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent'])
);
//print_r($data);
########### Start Add Data in Travel Table(Base Table) ###################
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
########### End Add Data in Travel Table(Base Table) ###################
} else {
$leadID = trim($editLeadId);
}
//echo "<pre>";print_r($flightValues);echo "</pre>";
//echo "<pre>";print_r($getflightData);echo "</pre>";die('aaaa');
########### End Add Data in Travel Air Table and Query Section ###################
//$where = "TPSysId = ".$leadID;
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
########## Start Updating in proposal section if there is prooposal exist against this Lead ###########
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
$intAdultsCT = $sessionFlightSearchParams->params['adults'];
$intChildsCT = $sessionFlightSearchParams->params['child'];
$intInfantsCT = $sessionFlightSearchParams->params['infant'];
$intTatalPaxCTForMarkUp = $intAdultsCT + $intChildsCT + $intInfantsCT;
//echo "<pre>";print_r($getflightData);exit;
for ($i = 0; $i < count($getflightData); $i++) {
$planbookingID = 'QS/' . date('y');
//$agencySysID = $this->intLoggedinUserAgencySysId ;
$agentMarkup = $MarkupArray[$i];
$arrAllCommissions = array(
'intCommissionEarned' => $getflightData[$i]['CommissionEarned'],
'intPLBEarned' => $getflightData[$i]['PLBEarned'],
'intIncentiveEarned' => $getflightData[$i]['IncentiveEarned']
);
$arrPriceAndMarkUps = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->getApiPriceWithMarkupAndServiceTax($arrAllCommissions, $getflightData[$i]['OfferedFare'], $intCountryCode);
//echo "<pre>";print_r($arrPriceAndMarkUps);echo "</pre>";
$intOfferedFare = $arrPriceAndMarkUps['intOfferedFare'];
if ($IsInterNational) {
$intGTXMarkUp = (($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnGTXMarkUp = (($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intAgencyFixMarkUp = (($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
$intSTaxOnAgencyFixMarkUp = (($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp) * $route);
} else {
$intGTXMarkUp = ($arrPriceAndMarkUps['intGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnGTXMarkUp = ($arrPriceAndMarkUps['intSTaxOnGTXMarkUp'] * $intTatalPaxCTForMarkUp);
$intAgencyFixMarkUp = ($arrPriceAndMarkUps['intAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
$intSTaxOnAgencyFixMarkUp = ($arrPriceAndMarkUps['intSTaxOnAgencyFixMarkUp'] * $intTatalPaxCTForMarkUp);
}
$intCommisionEarnedForAgency = $arrPriceAndMarkUps['intCommisionEarnedForAgency'];
$intPLBEarnedForAgency = $arrPriceAndMarkUps['intPLBEarnedForAgency'];
$intIncentiveEarnedForAgency = $arrPriceAndMarkUps['intIncentiveEarnedForAgency'];
$intTotalEarningsForAgency = $intAgencyFixMarkUp + $intCommisionEarnedForAgency + $intPLBEarnedForAgency + $intIncentiveEarnedForAgency;
$intGSTOnAgencyCommisionEarned = $arrPriceAndMarkUps['intGSTOnAgencyCommisionEarned'];
$intGSTOnAgencyPLBEarned = $arrPriceAndMarkUps['intGSTOnAgencyPLBEarned'];
$intGSTOnAgencyIncentiveEarned = $arrPriceAndMarkUps['intGSTOnAgencyIncentiveEarned'];
$intTotalGSTAgencyEarnings = $intSTaxOnAgencyFixMarkUp + $intGSTOnAgencyCommisionEarned + $intGSTOnAgencyPLBEarned + $intGSTOnAgencyIncentiveEarned;
$publishFareForAgency = $intOfferedFare + $intGTXMarkUp;
$intPublishFare = $publishFareForAgency + $intTotalEarningsForAgency + $intTotalGSTAgencyEarnings;
//service tax for base fare
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($arrPriceAndMarkUps['intOfferedFare'], "F", 0);
//$netPriceArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount'])?$arrServiceTaxOnNetPayable['serviceTaxAmount']:0;
$netPriceArrayServiceTax = 0;
//service tax for GTX MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($arrPriceAndMarkUps['intGTXMarkUp'], "F", 0);
$GTXMarkupArrayServiceTax = 0;
//service tax for Agency MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax(@$arrPriceAndMarkUps['intAgencyMarkUp'], "F", 0);
$AgencyMarkupArrayServiceTax = $intSTaxOnAgencyFixMarkUp;
//service tax for Agent MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Flight')->getApiServiceTax($MarkupArray[$i], "F", 0);
$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//end of service tax
$Taxes = 0;
//$totalCost = $intOfferedFare+$MarkupArray[$i]+$intGTXMarkUp+@$intAgencyFixMarkUp+$Taxes+$GTXMarkupArrayServiceTax+$AgencyMarkupArrayServiceTax+$MarkupArrayServiceTax+$arrPriceAndMarkUps['intTotalEarningsForAgency'];
$totalCost = $intPublishFare + $agentMarkup + $MarkupArrayServiceTax;
$totalCostArray[$i] = $totalCost;
$TPId = trim($getflightData[$i]['AirlineSysId']);
$isPriceShared = 1;
$data = array(
'PlanBookingId' => $planbookingID,
'TPId' => $TPId,
'MasterTPSysId' => $leadID,
'Price' => $intOfferedFare,
'TotalCost' => $totalCost,
'NetPrice' => $totalCost,
'StatusType' => '4',
'ProposalEmailTo' => $customeremail,
'PlanType' => 1,
'InventoryType' => 1,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'RoomInfoJson' => $RoomInfoJson,
'IsCardChrgToCustomer' => $cardcharges,
'SourcePlaces' => $getflightData[$i]['SourcePlaceName'],
'SourcePlaceSysId' => $getflightData[$i]['SourcePlaceSysId'],
'DestinationPlacesSysId' => (int) $getflightData[$i]['DestPlaceSysId'],
'DestinationPlaces' => $getflightData[$i]['DestPlaceName'],
'Cities' => $getflightData[$i]['SourcePlaceName'] . "-" . $getflightData[$i]['DestPlaceName'],
'CreatorSysId' => $agentsysID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'SupplierSysId' => 3,
'IsHotelFromApi' => 1,
'CustomerSysId' => $customerRcord,
'StartDate' => $departure_dates,
'ValidTill' => $return_dates,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => trim($getcustomerdetails['IsB2BAgent']),
'IsPriceShared' => trim($isPriceShared),
'GSTSharedMode' => trim($gsttype),
'SACCode' => trim($SACCode),
'ProposalEmailFrom' => trim($sendersEmailId),
);
########### Start Add Data in Travel Table(Base Table) ###################
if ($i == 0) {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
} else {
$lastID = $lastID;
}
//$sessionLogin_lead_customer->leadID = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Itenary Table ###################
########### Start Add Data in Travel Air Table ###################
$arrival_date = $getflightData[$i]['ArrivalTime'];
$departure_date = $getflightData[$i]['DepartureTime'];
$airData = array(
'TPIntSysId' => $lasttravelitenaryID,
'AgencySysId' => $agencySysID,
'FlightNumber' => $getflightData[$i]['FlightNumber'],
'AirlineSysId' => $getflightData[$i]['AirlineSysId'],
'CreateDate' => $createDate,
'Cost' => $intOfferedFare,
'XServiceTaxAmount' => $intTotalGSTAgencyEarnings,
'GTXServiceTaxAmount' => $GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => $AgencyMarkupArrayServiceTax,
'AgentsCustomServiceTaxAmount' => $MarkupArrayServiceTax,
'TotalCost' => $totalCost,
'MarkUp' => $agentMarkup > 0 ? $agentMarkup : 0,
'AgencyMarkUp' => isset($intAgencyFixMarkUp) ? $intAgencyFixMarkUp : 0,
'AgencyCommission' => $intTotalEarningsForAgency - $intAgencyFixMarkUp,
'GTXMarkUp' => $intGTXMarkUp,
'FlightCabinClass' => $sessionFlightSearchParams->params['flight_class'],
'AdultPax' => $sessionFlightSearchParams->params['adults'],
'LocalFromTime' => $departure_date->format('Y-m-d H:i:s'),
'LocalToTime' => $arrival_date->format('Y-m-d H:i:s'),
'FromUTCTime' => $departure_date->format('Y-m-d H:i:s'),
'ToUTCTime' => $arrival_date->format('Y-m-d H:i:s'),
'ChildPax' => $sessionFlightSearchParams->params['child'],
'InfentPax' => $sessionFlightSearchParams->params['infant'],
'SourceAirportCode' => $getflightData[$i]['SourceAirportCode'],
'DestAirportCode' => $getflightData[$i]['DestAirportCode'],
'TripType' => $tripType,
'CurrencyType' => $getflightData[$i]['CurrencyType'],
'SupplierSysId' => 3,
'ICSourceSysId' => 3,
'InvnItemSysId' => $getflightData[$i]['AirInvenSysId'],
'IsFromAPI' => 1,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
);
//echo "<pre>";print_r($airData);exit;
$lastairID = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airData);
########### End Add Data in Travel Air Table ###################
}
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
// $customername = isset($sessionLogin_lead_customer->FirstName) ? trim($sessionLogin_lead_customer->FirstName) : '';
$customernumber = isset($sessionLogin_lead_customer->PrimaryContactNumber) ? trim($sessionLogin_lead_customer->PrimaryContactNumber) : '';
$objAirport = new Travel_Model_TblAirport();
$objAirport->strAirportCode = $getflightData[0]['SourceAirportCode'];
$OriginAirportArray = $objAirport->getAirportList();
$Origincity = $OriginAirportArray[0]['CityName'];
$objAirport->strAirportCode = $getflightData[0]['DestAirportCode'];
$DestinationAirportArray = $objAirport->getAirportList();
$DestinationCity = $DestinationAirportArray[0]['CityName'];
$sessionLogin_agnet_details = new Zend_Session_Namespace('sessionLogin_user');
$agentname = $sessionLogin_agnet_details->FirstName . ' ' . $sessionLogin_agnet_details->LastName;
$agentcontact = $sessionLogin_agnet_details->contactnum ? $sessionLogin_agnet_details->contactnum : 'N/A';
$agentemail = trim($sessionLogin_agnet_details->EmailId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencySysID);
$agencyName = trim($getAgencyDetail['DisplayName']) ? trim($getAgencyDetail['DisplayName']) : trim($getAgencyDetail['Title']);
########### End Updating in proposal section if there is prooposal exist against this Lead ###########
$path = $_SERVER['SERVER_NAME'] . '/public/assets/images/logo-global-travel.jpg';
$childDetails = ($sessionFlightSearchParams->params['child'] > 0) ? ', ' . $sessionFlightSearchParams->params['child'] . ' Child(ren) ' : '';
$InfantDetails = ($sessionFlightSearchParams->params['infant'] > 0) ? ', ' . $sessionFlightSearchParams->params['infant'] . ' Infant' : '';
$bookingUrl = $this->view->baseUrl('flight-proposal/view-flight-proposal/id/' . base64_encode($leadID));
$getAgentDetail = array('AgentName' => $sessionLogin_agnet_details->FirstName . " " . $sessionLogin_agnet_details->LastName, 'AgentContact' => $sessionLogin_agnet_details->contactnum, 'AgentEmailId' => $sessionLogin_agnet_details->EmailId);
//send booking email to customer . added by Er Amit Kumar Dubey on 15 jan 2018 at 1:29 PM
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// render view
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencySysID);
//echo $desc=base64_encode($this->getDec($uid));die;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$arrAgentDetail = $this->_crmcusttravelplan->getAgentDetails($this->intLoggedinUserId);
if ($arrAgentDetail['IsB2CSite'] == 1) {
$bookingUrl = $arrAgentDetail['Url'] . "detail/index/view/id/" . base64_encode($bookingUrl);
}
$getAgentDetail = array(
'AgentName' => $arrAgentDetail['FirstName'] . " " . $arrAgentDetail['LastName'],
'AgentContact' => $sessionLogin_user->contactnum,
'AgentEmailId' => $sessionLogin_user->EmailId,
'ContactNo1' => $arrAgentDetail['ContactNo1'],
'Signature' => $arrAgentDetail['Signature'],
'Logo' => $arrAgentDetail['Logo'],
'AgencySysId' => $arrAgentDetail['AgencySysId']
);
$html->assign('IsDisplayHelloGTX', (int) $getAgencyDetail['IsDisplayHelloGTX']);
$html->assign('type', 'flightPreviewEmailForm');
$html->assign('customerDetails', $getcustomerdetails);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('getAgencyDetail', $getAgencyDetail);
$html->assign('Origincity', $Origincity);
$html->assign('DestinationCity', $DestinationCity);
$html->assign('departure_date', $departure_date);
$html->assign('getflightData', $getflightData);
$html->assign('childDetails', $childDetails);
$html->assign('InfantDetails', $InfantDetails);
$html->assign('sessionFlightSearchParams', $sessionFlightSearchParams);
$html->assign('isInternational', $isInternational);
$html->assign('flightValues', $flightValues);
$html->assign('getflightData', $getflightData);
$html->assign('tripType', $tripType);
$html->assign('totalCostArray', $totalCostArray);
$html->assign('totalCost', $totalCost);
$html->assign('remark', $flightremark);
$html->assign('bookingUrl', $bookingUrl);
$bodyText = $html->render('ajax-html.phtml');
//echo "<pre>";print_r($getflightData);die;
//#end of send email to customer
//$emailSendId=(isset($getAgencyDetail['EmailIdForCustomer']) && !empty($getAgencyDetail['EmailIdForCustomer']) && ($getAgencyDetail['IsEmailIdForCustVarified']==1))?trim($getAgencyDetail['EmailIdForCustomer']):trim($agentemail);
$emailSendId = (isset($sendersEmailId) && $sendersEmailId != '') ? $sendersEmailId : trim($agentemail);
$mailToCC = array();
if ($ccemail != '') {
$mailToCC = explode(',', $ccemail);
}
$mailCustmail = array(trim($customerEmail));
$toArray = array_merge($mailToCC, $mailCustmail);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailId = trim($customerEmail);
$subject = trim($getcustomerdetails['FirstName']) . " your " . $Origincity . " to " . $DestinationCity . " Flight details from " . trim($getAgencyDetail['DisplayName']);
$emailData = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => $subject, 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_cc = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => $subject, 'to' => array(trim($emailSendId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_senderCC = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => $subject, 'to' => $mailToCC, 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $lastID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$arrEmailStatisticsAgent = $arrEmailStatistics;
$arrEmailStatisticsAgent["Source"] = $arrEmailStatisticsType[2];
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $getcustomerdetails['CustomerSysId'], $mailToCC);
// $this->mailSentByElastice($emailDataA, $arrEmailStatisticsAgent, 0, '',array(trim($emailSendId)),array(trim($emailId)));
$this->mailSentByElastice($emailData_cc, $arrEmailStatisticsAgent, 0, '', array(trim($emailSendId)), $toArray);
if (!empty($mailToCC)) {
Catabatic_ValidateCustomer::mailSentByElastice($emailData_senderCC, $arrEmailStatisticsAgent, 0, 0, $mailToCC, $mailCustmail);
}
//update acustomer
if ($leadID) {
$agencyuserArray = array(
'UpdateDate' => date('Y-m-d H:s:i')
);
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$whereAgencyCustomer = " AgencySysId=" . $this->intLoggedinUserAgencySysId . " AND CustomerSysId=" . $customerRcord . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$adultDetails = ($sessionFlightSearchParams->params['adults']) ? $sessionFlightSearchParams->params['adults'] : '';
$childDetails = ($sessionFlightSearchParams->params['child'] > 0) ? ', ' . $sessionFlightSearchParams->params['child'] . ' Child(s)' : '';
$InfantDetails = ($sessionFlightSearchParams->params['infant'] > 0) ? ', ' . $sessionFlightSearchParams->params['infant'] . ' Infant(s)' : '';
$NoofPax = '%0a%0a*No. of Pax:* ' . $adultDetails . ' Adult(s)' . $childDetails . $InfantDetails;
$TravelDate = ($departure_date) ? '%0a%0a*Travel Date:* ' . $departure_date->format('d-M-y') : '';
$whatsappmessageFlight = '';
$navarrow = ($tripType == 1) ? "→" : "⇄";
$getflightDataTripType = $priceCostArray = array();
foreach ($getflightData as $dKey1 => $fVal1) {
$getflightDataTripType[trim($fVal1['TripType'])][] = $fVal1;
$priceCostArray[trim($fVal1['TripType'])][] = $totalCostArray[$dKey1];
}
foreach ($getflightDataTripType as $getflightKey => $getflightData) {
$finalHtml = '';
foreach ($getflightData as $dKey => $fVal) {
if (count($getflightData) > 1) {
$finalHtml .= '%0a%0a*' . ($dKey + 1) . '.* ';
} else {
$finalHtml .= '%0a%0a';
}
$hours = floor($fVal['FlightDuration'] / 60);
$minutes = ($fVal['FlightDuration'] % 60);
$duration = '%0a%0a*Duration:* ' . $hours . 'h ' . $minutes . 'm,';
$routeDetail = '%0a' . trim($fVal['SourceAirportCode']) . ' - ' . trim($fVal['DestAirportCode']) . ' on ' . $fVal['DepartureTime']->format('H:i M d, Y') . ' - ' . $fVal['ArrivalTime']->format('H:i M d, Y');
$finalHtml .= '*' . trim($fVal['AirlineName']) . '(' . trim($fVal['FlightNumber']) . '):*' . $routeDetail . $duration . '%0a*Total Cost:* ' . trim($fVal['CurrencySymbol']) . ' ' . round($priceCostArray[$getflightKey][$dKey]) . '/-';
}
$objAirport->strAirportCode = $getflightData[0]['SourceAirportCode'];
$OriginAirportArr = $objAirport->getAirportList();
$SourcePlaceName = $OriginAirportArr[0]['CityName'];
$objAirport->strAirportCode = $getflightData[0]['DestAirportCode'];
$DestinationAirportArr = $objAirport->getAirportList();
$DestPlaceName = $DestinationAirportArr[0]['CityName'];
$OrigincityTitle = $SourcePlaceName . ' (' . trim($getflightData[0]['SourceAirportCode']) . ')';
$DestinationCityTitle = $DestPlaceName . ' (' . trim($getflightData[0]['DestAirportCode']) . ')';
$whatsappmessageFlight .= "%0a%0a*------* *$SourcePlaceName* *$navarrow* *$DestPlaceName* *------*%0a%0a*To Destination:* $DestinationCityTitle %0a%0a*From Destination:* $OrigincityTitle $NoofPax $finalHtml ";
}
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$primarycontact = $sessionLogin_user->ContactNo1 ? $sessionLogin_user->ContactNo1 : 'N/A';
$agencyDisplayName = $fromName;
$custname = $getcustomerdetails['FirstName'] ? trim($getcustomerdetails['FirstName']) . ' ' . trim($getcustomerdetails['LastName']) : 'Customer';
$custname = trim($custname);
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($bookingUrl, $this->BITLYLOGIN, $this->BITLYAPIKEY);
if ($bitly_response['errorCode'] == 0) {
$bookingUrl = $bitly_response['results'][trim($bookingUrl)]['shortUrl'];
}
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your Flight query for $DestinationCity from $Origincity.$whatsappmessageFlight %0a%0aTo view flight details and *book online* click on the below link:%0a$bookingUrl %0a%0aYou can also call $firstname at $primarycontact or email at $emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
//#end of update customer
$response = array('status' => 'success', 'whatsapp' => $whatsappmessage, 'contactno' => trim($getcustomerdetails['countrycode']) . trim($getcustomerdetails['Contacts']), 'message' => 'Proposal sent to customer successfully.');
//#end of update customer
echo json_encode($response);
exit;
echo 'Proposal sent to customer successfully';
} catch (Exception $err) {
print_r($err, true);
}
}
public function customerChatAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
;
$chatList = $this->_crmcusttravelplan->GetProposalCustomerChat($CustomerSysId);
//remove duplicacy from array
$IdsListArray = array();
$resultArray = array();
if (!empty($chatList)) {
foreach ($chatList as $key => $value) {
if (!in_array($value['TPSysId'], $IdsListArray)) {
$IdsListArray[] = $value['TPSysId'];
$resultArray[] = $chatList[$key];
}
}
$chatList = $resultArray;
}
//end of remove duplicacy
//echo "<pre>";print_r($resultArray);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($chatList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
//this function used for all customer tab beacuse functionlity added in flightsearch lead
//$airportlist = $this->_objAirport->getAirportListWithCountryCode();
//$this->view->sourceCity = $airportlist;
//end of flight search lead
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function customerBookingAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
//this function used for all customer tab beacuse functionlity added in flightsearch lead
//$airportlist = $this->_objAirport->getAirportListWithCountryCode();
//$this->view->sourceCity = $airportlist;
//end of flight search lead
}
$this->view->controller = $this;
//get booking list
$objPackageViewList = new Travel_Model_TblAgencyCustomerTrx();
$getData = array();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$customerBookingRecord = $objPackageViewList->getBookedPackageDetailByCust($AgencySysId, $CustomerSysId);
//$miscBookingRecord = $objPackageViewList->getMiscellaneousListByCust($CustomerSysId);
//echo "<pre>";print_r($miscBookingRecord);
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($customerBookingRecord);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//$this->view->miscBookingRecord = $miscBookingRecord;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function customerInvoiceAction() {
$CRMCustSysId = $this->getRequest()->getParam('id');
$CRMCustSysId = base64_decode($CRMCustSysId);
$CRMCustSysId = $this->_HtmlPurifier->filter($CRMCustSysId);
if (isset($CRMCustSysId) && !empty($CRMCustSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CRMCustSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CRMCustSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$this->view->customerId = $CRMCustSysId;
$this->view->customerDetail = $getCustomerDetail;
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function customerPinvoiceAction() {
$CRMCustSysId = $this->getRequest()->getParam('id');
$CRMCustSysId = base64_decode($CRMCustSysId);
$CRMCustSysId = $this->_HtmlPurifier->filter($CRMCustSysId);
if (isset($CRMCustSysId) && !empty($CRMCustSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CRMCustSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CRMCustSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$this->view->customerId = $CRMCustSysId;
$this->view->customerDetail = $getCustomerDetail;
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function listcustomerAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
// $type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
// $orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
$orderDetails = '';
$columnNameOrder = 'tb2.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$this->view->order = $orderBy;
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 1) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 0) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'DESC';
} else {
$orderQueryDate = 'DESC';
}
$orderDetails = $columnNameOrder . " " . $orderQueryDate . "";
}
//echo $orderDetails;
$this->_crmcustomerObj->ReportingToSysId = $ReportingToSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$orderBy = $getData['order'];
$orderDetails = '';
$columnNameOrder = 'tb2.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$this->view->order = $orderBy;
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 1) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 0) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'DESC';
} else {
$orderQueryDate = 'DESC';
}
$orderDetails = $columnNameOrder . " " . $orderQueryDate . "";
}
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmcustomerObj->getCustomerListAll($agencysysID, $getData, $orderDetails, 0, $ReportingToSysId);
} else {
$getData = array();
//for superadmin
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
//end for superadmin
if ($getRoleDetail['IsAdmin'] == true) {
$getData['AgentSysId'] = '';
$userAgentSysId = '';
} else {
$getData['AgentSysId'] = $sessionLogin_user->intLoggedinUserId;
$userAgentSysId = $ReportingToSysId;
}
$getCustomerList = $this->_crmcustomerObj->getCustomerListAll($agencysysID, $getData, $orderDetails, 0, $userAgentSysId);
}
if ($sessionLogin_user->UserRoleTitle == 'Owner') {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID, $ReportingToSysId);
}
//$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
$page = $this->getRequest()->getParam('page') != '' ? $this->getRequest()->getParam('page') : 1;
if (!empty($getData)) {
$page = isset($getData['page']) ? $getData['page'] : $page;
} else {
$page = $this->_getParam('page', $page);
}
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($getCustomerList));
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//echo "<pre>";print_r($getCustomerList);die;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->agencyUser = $agencyUser;
$this->view->AgencySysId = $agencysysID;
}
public function getRoomsFamilyAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$roomCount = $this->getRequest()->getParam('roomCount');
$getData = $this->_HtmlPurifier->filter($roomCount);
$this->view->roomCount = $getData;
$this->view->type = 'room';
$this->render('ajaxDropdown');
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function getChildrenDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$roomCount = $this->getRequest()->getParam('roomCount');
$rowNum = $this->getRequest()->getParam('rowNum');
$getData = $this->_HtmlPurifier->filter($roomCount);
$this->view->roomCount = $getData;
$this->view->rowNum = $this->_HtmlPurifier->filter($rowNum);
$this->view->type = 'child';
$this->render('ajaxDropdown');
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function saveHotelSearchQueryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$queryType = '';
$SearchTraceId = implode('-', str_split(substr(strtolower(md5(time() . rand(1000, 9999))), 0, 20), 5));
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
$searchType = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('searchType')));
$queryType = $this->_HtmlPurifier->filter($this->getRequest()->getPost('saveQuery'));
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
$search_food = (!empty($this->getRequest()->getPost('search_food'))) ? $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('search_food')) : '';
$currentOwnerSysId = $this->_HtmlPurifier->filter($this->getRequest()->getPost('currentOwnerSysId'));
$modifyQuery = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('modifyQuery')));
$countrySysId = (NULL !== $this->getRequest()->getPost('ContSysId')) ? $this->getRequest()->getPost('ContSysId') : '';
$IsOperationalLead = $this->getRequest()->getPost('IsOperationalLead') ? $this->getRequest()->getPost('IsOperationalLead') : 0;
$OpsAgentSysId = ($this->getRequest()->getPost('OpsAgentSysId') && $IsOperationalLead == 1) ? $this->getRequest()->getPost('OpsAgentSysId') : '';
$ExpectedClosureDate = $this->getRequest()->getPost('ExpectedClosureDate');
$ExpectedValue = $this->getRequest()->getPost('ExpectedValue');
$leadsource = (NULL !== $this->getRequest()->getPost('lead_source')) ? $this->getRequest()->getPost('lead_source') : '';
$searchData = array();
$memberdata = array();
$hotelTotalRooms = $this->_HtmlPurifier->filter($this->getRequest()->getPost('roomlp'));
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$foodpreference = isset($gsearch_food) ? $search_food : '';
if (!empty($search_food)) {
$search_food = $search_food;
for ($i = 0; $i < count($search_food); $i++) {
$search_food_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_food[$i], $packageFoodPreferenceList, 'CuisineSysId');
}
}
if (!empty($search_food_list)) {
$foodmask = '1';
$char = '';
for ($k = 0; $k < count($packageFoodPreferenceList); $k++) {
$char = in_array(@$packageFoodPreferenceList[$k]['CuisineSysId'], @$search_food_list) ? '1' : '0';
$foodmask .= $char;
}
}
if (isset($search_food)) {
$FoodTypeMask = $search_food ? $foodmask : '';
} else {
$FoodTypeMask = '';
}
$f = 1;
$TotAdultCount = 0;
$TotChildCount = 0;
for ($k = 1; $k <= $hotelTotalRooms; $k++) {
$childAgeArr = array();
$roomjson[$k]['Adult'] = $this->_request->getParam('adult_' . $k);
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $this->_request->getParam('adultcl_extrabed_' . $k . '_3');
}
$roomjson[$k]['Child'] = $this->_request->getParam('child_' . $k);
$roomjson[$k]['Infant'] = $this->_request->getParam('infant_' . $k);
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $this->_request->getParam('child_age_' . $k . '_' . $j);
$roomjson[$k]['ChildBedType_' . $j] = $this->_request->getParam('child_extrabed_' . $k . '_' . $j);
$childAgeArr[] = $this->_request->getParam('child_age_' . $k . '_' . $j);
}
$roomjson[$k]['departuredate'] = $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekInDate'));
$roomjson[$k]['returndate'] = $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekOutDate'));
$roomaarayinfo[$k]['adult'] = $this->_request->getParam('adult_' . $k);
$roomaarayinfo[$k]['child']['childcount'] = $this->_request->getParam('child_' . $k);
$roomaarayinfo[$k]['child']['childage'] = implode(',', $childAgeArr);
$memberdata[] = array('AdultPax' => $roomjson[$k]['Adult'],
'ChildPax' => $roomjson[$k]['Child'],
'ChildsAge' => $roomaarayinfo[$k]['child']['childage']
);
}
$roomArrayProposal = json_encode($roomjson);
$roomaarayinfo = json_encode($roomaarayinfo);
$customerId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('customerId')));
if (null != $customerId && !empty($customerId) && $searchType == 'CRMHOTELSEARCH') {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerId);
}
$createDate = date('Y-m-d H:i:s');
$customerEmailId = isset($getCustomerDetail['EmailId']) ? $getCustomerDetail['EmailId'] : '';
//update crm lead account record when created new query
if (isset($getCustomerDetail['AgencyCRMLeadSysId']) && !empty($getCustomerDetail['AgencyCRMLeadSysId'])) {
$userleadAccountArray = array(
'LeadStageSysId' => 50, //50 id for change status in create query for crm lead account table
'UpdatedDate' => $createDate,
);
$whereleadAccount = "AgencyCRMLeadSysId = " . $getCustomerDetail['AgencyCRMLeadSysId'];
$customercrmRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userleadAccountArray, $whereleadAccount);
}
//#end of record
if (isset($leadsource) && is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($this->intLoggedinUserAgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$totalMemberCount = Zend_Controller_Action_HelperBroker::getStaticHelper('ArrayCalculation')->calculateArrayValues($memberdata);
$searchData = array(
'hotelCityTitle' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('Hotel_name_city')),
'hotelFromDateSession' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekInDate')),
'hotelToDateSession' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekOutDate')),
'hotelTotalNights' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('nights')),
'selectNationality' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectNationality')),
'countryCode' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('countryCode')),
'searchType' => $searchType,
'leadRemark' => $leadRemark,
'customername' => isset($getCustomerDetail['FullName']) ? $getCustomerDetail['FullName'] : '',
'emailID' => $customerEmailId,
'searchType' => $searchType,
'customerId' => $customerId,
'TPSysId' => $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('editLeadId'))),
'TPIntSysId' => $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('editTravelItenaryId'))),
'hotelTotalRooms' => $hotelTotalRooms,
'hotelStarRating' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectStarRating')),
'hotelXrefCityId' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_cityid')),
'hidden_selected_hotel_id' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_id')),
'CityName' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('CityName')),
'countryTitle' => $this->_HtmlPurifier->filter($this->getRequest()->getPost('countryTitle')),
'totalMemberCount' => $totalMemberCount,
'RoomMemInfoJson' => $roomaarayinfo,
'RoomInfoJson' => $roomArrayProposal,
'currentOwnerSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? $currentOwnerSysId : '',
'memberDetails' => $memberdata,
'lead_source' => $leadsource
);
$CityName = $this->_HtmlPurifier->filter($this->getRequest()->getPost('CityName', ''));
$countryTitle = $this->_HtmlPurifier->filter($this->getRequest()->getPost('countryTitle', ''));
$hidden_selected_hotel_cityid = $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_cityid'));
$citynameOnly = (explode("(", $searchData['hotelCityTitle']));
if ($CityName != "" && $countryTitle != "") {
$modelCity = new Travel_Model_TblCity();
$getGTXCityArray = $modelCity->getCityIdWithCountryDetail($CityName, $countryTitle);
$hidden_selected_hotel_cityid = isset($getGTXCityArray[0]['CityId']) ? $getGTXCityArray[0]['CityId'] : $hidden_selected_hotel_cityid;
}
$getTboCityDetail = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->searchcitydata(trim($CityName), 3, $countryTitle);
$tboCityId = isset($getTboCityDetail[0]['TBBCityId']) ? $getTboCityDetail[0]['TBBCityId'] : '';
$tboCountryCode = isset($getTboCityDetail[0]['CountryCode']) ? $getTboCityDetail[0]['CountryCode'] : '';
$searchData['tboCityId'] = $tboCityId;
$searchData['tboCountryCode'] = $tboCountryCode;
$searchData['countrySysId'] = $countrySysId;
$sessionhotelDirectSearchData = new Zend_Session_Namespace('sessionHotelDirectSearchData');
$sessionhotelDirectSearchData->params = $searchData;
if (isset($searchType) && !empty($searchType) && $searchType == 'DIRECTHOTELSEARCH') {
} else {
$planbookingID = 'Q/' . date('y');
$agencySysID = $this->intLoggedinUserAgencySysId;
$customersysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('customerId')));
$Hotel_name_city = $this->_HtmlPurifier->filter($this->getRequest()->getPost('Hotel_name_city'));
$chekInDate = $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekInDate'));
$chekOutDate = $this->_HtmlPurifier->filter($this->getRequest()->getPost('chekOutDate'));
$hidden_selected_hotel_id = $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_id'));
$nights = $this->_HtmlPurifier->filter($this->getRequest()->getPost('nights'));
//$noOfAdults1 = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults1'));
//$selectnoOfChild1 = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild1'));
$selectNationality = $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectNationality'));
$countryCode = $this->_HtmlPurifier->filter($this->getRequest()->getPost('countryCode'));
$selectRoom = $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectRoom'));
$selectStarRating = $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectStarRating'));
$additionalRequirement = $this->_HtmlPurifier->filter($this->getRequest()->getPost('additionalRequirement'));
$editLeadId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('editLeadId')));
$editTravelItenaryId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('editTravelItenaryId')));
$totalNoOfAdult = 0;
$totalNoOfChild = 0;
for ($i = 1; $i <= $selectRoom; $i++) {
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $i));
$selectnoOfChild = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild' . $i));
$totalNoOfAdult = $noOfAdults + $totalNoOfAdult;
$totalNoOfChild = $selectnoOfChild + $totalNoOfChild;
}
$selectStarRating = intval($selectStarRating);
$chekInDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekInDate)));
$validTillDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekOutDate)));
$status = '1';
$updateMasterTPSysId = '';
// code for only modify query
//end of code for modify
if (isset($editLeadId) && !empty($editLeadId)) {
$existLeadDetail = $this->_crmcusttravelplan->CheckCustomerWithLeadId($editLeadId, 'Query');
$nextVersionId = $existLeadDetail[0]['VersionId'] + 1;
/* $data = array(
'VersionId' => $nextVersionId,
'UpdateDate' => $createDate,
);
$where = "TPSysId = " . $editLeadId;
$customerRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($data, $where); */
//end for updation data
}
$ExpectedClosureDate = (isset($ExpectedClosureDate) && !empty($ExpectedClosureDate)) ? implode('-', array_reverse(explode('/', $ExpectedClosureDate))) : '';
$ExpectedValue = (isset($ExpectedValue) && !empty($ExpectedValue)) ? (float) trim($ExpectedValue) : 0;
########### Start Add Data in Travel Table(Base Table) ###################
$AgentSysId = $this->intLoggedinUserId;
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $AgentSysId,
'StatusType' => $this->_HtmlPurifier->filter($status),
'CustomerSysId' => $this->_HtmlPurifier->filter($customersysID),
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'PlanType' => 2,
'HotelPreference' => $selectStarRating,
'CuisineMask' => $FoodTypeMask,
'RoomInfoJson' => $roomArrayProposal,
'validTill' => $validTillDate,
'SourcePlaces' => $Hotel_name_city,
'SourcePlaceSysId' => $hidden_selected_hotel_id,
'DestinationPlaces' => $Hotel_name_city,
'DestinationPlacesSysId' => (int) $hidden_selected_hotel_cityid,
'CityIds' => $hidden_selected_hotel_cityid,
'Cities' => $Hotel_name_city,
'Countries' => $countrySysId,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsHotelFromAPI' => 1,
'IsAprooved' => 1,
'IsB2Bproposal' => $getCustomerDetail['IsB2BAgent'],
'selectNationality' => $selectNationality,
'NoofNight' => $nights,
'LeadSourceSysId' => $leadsource,
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
'ExpectedClosureDate' => $ExpectedClosureDate,
'ExpectedValue' => $ExpectedValue,
);
$createNewQuery = (NULL != $this->getRequest()->getPost('createNewQuery')) ? $this->getRequest()->getPost('createNewQuery') : '';
if (isset($editLeadId) && !empty($editLeadId)) {
$data['TemplatePckSysId'] = $editLeadId;
//$data['MasterTPSysId']= $editLeadId;
$data['VersionId'] = $nextVersionId;
$data['UpdateDate'] = $createDate;
$where = "TPSysId = " . $editLeadId;
//deleted previous quey
$NewQueryLeadHiddenId = (NULL != $this->getRequest()->getPost('NewQueryLeadHiddenId')) ? trim($this->getRequest()->getPost('NewQueryLeadHiddenId')) : '';
//echo $editLeadId."/".$createNewQuery."/".$NewQueryLeadHiddenId;die;
if (($createNewQuery == 'false' || $createNewQuery == '')) {
$where = "TPSysId = " . $editLeadId;
unset($data['CreateDate']);
unset($data['IsB2Bproposal']);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($data, $where);
$lastID = $editLeadId;
} else {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
}
} else {
//deleted previous quey
$NewQueryLeadHiddenId = (NULL != $this->getRequest()->getPost('NewQueryLeadHiddenId')) ? trim($this->getRequest()->getPost('NewQueryLeadHiddenId')) : '';
// echo $createNewQuery."/".$NewQueryLeadHiddenId;die;
if (($NewQueryLeadHiddenId != "") && ($createNewQuery == 'false' || $createNewQuery == '')) {
$where = "TPSysId = " . $NewQueryLeadHiddenId;
$updatetravelplan = array(
"IsMarkForDel" => true,
'IsActive' => False
);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
}
//#end
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
//start for customer profile history data
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$checkrecord = $custtravelhistoryObj->getCustomerTravelHistoryForCity($customersysID, $agencySysID, $hidden_selected_hotel_cityid);
if (count($checkrecord) == 0) {
$customerHistoryArray = array(
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $AgentSysId,
'CustomerSysId' => $customersysID,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => isset($chekInDate) ? $chekInDate : $createDate,
'ContSysId' => $countrySysId ? $countrySysId : '',
'CitySysId' => $hidden_selected_hotel_cityid ? $hidden_selected_hotel_cityid : '',
'PlanType' => 2,
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => '0'
);
//print_r($customerHistoryArray);die;
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
}
//#end of customer profile data
//save lead remarks action
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'CustomerSysId' => $customerId,
'AgentSysId' => $AgentSysId,
'Remarks' => $leadRemark,
'TPSysId' => $lastID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
//end of save remarks
}
/* if (isset($editLeadId) && !empty($editLeadId)) {
$data['TemplatePckSysId']= $editLeadId;
//$data['MasterTPSysId']= $editLeadId;
$data['VersionId']= $nextVersionId;
}
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
*/ $sessionhotelDirectSearchData->params['TPSysId'] = $lastID;
########### End Add Data in Travel Table(Base Table) ###################
########### Start Add Data in Travel Itenary Table ###################
//create search history for query created by Er Amit Kumar Dubey on 12 april 2017 at 10:52 PM
$historyData = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agencySysID,
'CustomerSysId' => $customersysID,
'PlanType' => 2,
'SourcePlaces' => isset($Hotel_name_city) ? trim($Hotel_name_city) : '',
'SourcePlaceSysId' => isset($hidden_selected_hotel_id) ? $hidden_selected_hotel_id : '',
'DestinationPlaces' => isset($Hotel_name_city) ? trim($Hotel_name_city) : '',
'DestinationPlaceSysId' => isset($hidden_selected_hotel_cityid) ? $hidden_selected_hotel_cityid : '',
'PackTypeMask' => '',
'InclusionMark' => '',
'Rooms' => $hotelTotalRooms,
'TotAdultCount' => $TotAdultCount,
'TotChildCount' => $TotChildCount,
'TotInfantCount' => 0,
'PriceRangeFrom' => '',
'PriceRangeTo' => '',
'AdditionalSrvMark' => '',
'StartDate' => isset($chekInDate) ? $chekInDate : $createDate,
'ValidTill' => isset($validTillDate) ? $validTillDate : $createDate,
'Rating' => $selectStarRating,
"SearchDate" => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$this->_crmcusttravelplanhistory = new Travel_Model_CRM_CustomerTravelPlanSearchHistory();
$this->_crmcusttravelplanhistory->addCustomerTravelPlanSearchHistory($historyData);
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults1' . $f));
$selectnoOfChild = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild' . $f));
if ($selectnoOfChild > 0) {
$ageOfChild = array();
for ($g = 1; $g <= $selectnoOfChild; $g++) {
$ageOfChild[] = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-childAge_' . $f . '_' . $g));
}
$commaSeperatedChildAge = implode(',', $ageOfChild);
} else {
$commaSeperatedChildAge = 0;
}
}
}
$lastID = isset($lastID) ? base64_encode($lastID) : '';
$TPSysId = [];
$arrData['SearchParams'] = $sessionhotelDirectSearchData->params;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => base64_decode($lastID),
'APIBookingData' => json_encode($arrData),
);
if (isset($queryType) && $queryType == 'saveQuery') {
$mCustomerFirstName = isset($_SESSION['sessionHotelDirectSearchData']['params']['customername']) ? trim($_SESSION['sessionHotelDirectSearchData']['params']['customername']) : '';
$mCustomerLastName = '';
$mCustomerEmailId = isset($_SESSION['sessionHotelDirectSearchData']['params']['emailID']) ? trim($_SESSION['sessionHotelDirectSearchData']['params']['emailID']) : '';
$hotelCityTitle = isset($_SESSION['sessionHotelDirectSearchData']['params']['hotelCityTitle']) ? trim($_SESSION['sessionHotelDirectSearchData']['params']['hotelCityTitle']) : '';
if ($hotelCityTitle != '') {
$hotelCityTitle = explode('(', $hotelCityTitle);
$destinationCityText = $hotelCityTitle[0];
}
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$getSenderEmailID = $this->_agencyObj->getSenderEmailIDBySenderSysId($agencySysID, $SenderEmailSysId);
$companyLogo = trim($_SESSION['sessionLogin_user']['Logo']);
$agencyTitle = trim($_SESSION['sessionLogin_user']['agencyDetails']['Title']);
$agencyPrimaryEmail = (isset($getSenderEmailID['SenderEmailID']) && !empty($getSenderEmailID['SenderEmailID'])) ? $getSenderEmailID['SenderEmailID'] : trim($_SESSION['AgencyUser']['user']->EmailId);
$agencyContactNo1 = trim($_SESSION['AgencyUser']['user']->ContactNo1);
$agencyContactNo2 = trim($_SESSION['sessionLogin_user']['contactnum']);
$PrimaryContactName = trim($_SESSION['sessionLogin_user']['FirstName']) . ' ' . trim($_SESSION['sessionLogin_user']['LastName']);
$agencyUrl = trim($_SESSION['sessionLogin_user']['agencyDetails']['Url']);
$travelDate = isset($_SESSION['sessionHotelDirectSearchData']['params']['hotelFromDateSession']) ? trim($_SESSION['sessionHotelDirectSearchData']['params']['hotelFromDateSession']) : '';
$nooftravelerArr = isset($_SESSION['sessionHotelDirectSearchData']['params']['totalMemberCount']) ? ($_SESSION['sessionHotelDirectSearchData']['params']['totalMemberCount']) : '';
$CountryCode = isset($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) . '-' : '+91-';
$nooftraveler = $nooftravelerArr['AdultPax'] + $nooftravelerArr['ChildPax'];
$params = array('CountryCode' => $CountryCode, 'customerName' => ucfirst($mCustomerFirstName . ' ' . $mCustomerLastName), 'emailId' => $mCustomerEmailId, 'logo' => $companyLogo, 'agencyTitle' => $agencyTitle, 'destination' => $destinationCityText, 'noofPax' => $nooftraveler, 'travelDate' => $travelDate, 'agencyPrimaryEmail' => $agencyPrimaryEmail, 'agencyContactNo1' => $agencyContactNo1, 'agencyContactNo2' => $agencyContactNo2, 'Url' => $agencyUrl, 'queryID' => base64_decode($lastID), 'PKqueryType' => 'Hotel');
#Set subject
$subject = $mCustomerFirstName . ' ' . $mCustomerLastName . ' Thanks for your Query for ' . $destinationCityText;
if (empty($editLeadId) && in_array('queryacknowledgement', $this->manageNotifications)) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('masterTemplateMailinfo.phtml');
$emailMasterData = array('fromEmail' => trim($agencyPrimaryEmail), 'fromName' => trim($PrimaryContactName), 'subject' => $subject, 'to' => array($mCustomerEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $agencySysID,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$checkStatusEmail = $this->mailSentByElastice($emailMasterData, $arrEmailStatistics);
}
$TPSysIdDecode = base64_decode($lastID);
$secureCode = Catabatic_ValidateCustomer::secureCode($lastID, 1);
echo json_encode(array('redirection' => false, 'TPSysId' => $lastID, 'TPSysIdDecode' => $TPSysIdDecode, 'code' => $secureCode));
} else {
//if ($this->intLoggedinUserAgencySysId == 1 || $this->intLoggedinUserAgencySysId == 2656) {
$SearchParams = $arrData['SearchParams'];
$hotelCityTitle = $SearchParams['hotelCityTitle'];
$CityName = $SearchParams['CityName'];
$countrySysId = $SearchParams['countrySysId'];
$selectNationality = $SearchParams['selectNationality'];
$memberDetails = $SearchParams['memberDetails'];
$hotelStarRating = (int) $SearchParams['hotelStarRating'];
$nights = (int) $SearchParams['hotelTotalNights'];
$rooms = (int) $SearchParams['hotelTotalRooms'];
$AdultPax = (int) $SearchParams['totalMemberCount']['AdultPax'];
$ChildPax = (int) $SearchParams['totalMemberCount']['ChildPax'];
$MemberCount = ($AdultPax + $ChildPax);
if ($countrySysId == '101') {
$interNationalSearch = false;
} else {
$interNationalSearch = true;
}
$strCheckInDate = $SearchParams['hotelFromDateSession'];
$strCheckOutDate = $SearchParams['hotelToDateSession'];
if (!empty($strCheckInDate)) {
$arrCheckInDate = explode("/", $strCheckInDate);
if (!empty($arrCheckInDate)) {
$strCheckInDateNew = $arrCheckInDate[2] . "-" . $arrCheckInDate[1] . "-" . $arrCheckInDate[0];
}
}
if (!empty($strCheckOutDate)) {
$arrCheckOutDate = explode("/", $strCheckOutDate);
if (!empty($arrCheckOutDate)) {
$strCheckOutDateNew = $arrCheckOutDate[2] . "-" . $arrCheckOutDate[1] . "-" . $arrCheckOutDate[0];
}
}
$residence = '106';
$roominfo = [];
$RoomGuests = [];
$memberdata = [];
$stars = [];
if ($memberDetails) {
foreach ($memberDetails as $key => $value) {
$adult = (int) $value['AdultPax'];
$child = (int) $value['ChildPax'];
$childArray = explode(',', $value['ChildsAge']);
$roominfo[$key] = array(
'numberOfAdults' => $adult,
'numberOfChild' => $child,
);
if ($child > 0) {
$roominfo[$key]['childAge'] = $childArray;
}
$RoomGuests[] = ['NoOfAdults' => $adult, 'NoOfChild' => $child, 'ChildAge' => $childArray];
$childAges = [];
if (isset($childArray[0]) && !empty($childArray[0] && $child == '1')) {
$childAges[0] = $childArray[0];
}
if (isset($childArray[0]) && !empty($childArray[0] && $child == '2')) {
$childAges[0] = $childArray[0];
$childAges[1] = $childArray[1];
}
$memberdata[] = array(
'NoOfAdults' => (int) $adult,
'NoOfChild' => (int) $child,
'ChildAge' => $childAges
);
}
}
$searchCriteria['city'] = $SearchParams['hidden_selected_hotel_id'];
$searchCriteria['currency'] = 'INR';
$searchCriteria['nationality'] = $residence;
for ($i = 1; $i < $hotelStarRating; $i++) {
$stars[] = (int) $i;
}
$fsc = true;
if (isset($SearchParams['special']) && $SearchParams['special'] == 'on') {
$fsc = true;
}
$searchPreferences['ratings'] = ($hotelStarRating == 6) ? [3, 4, 5] : $stars;
$searchPreferences['fsc'] = $fsc;
$searchQuery = array(
'checkinDate' => date('Y-m-d', strtotime($strCheckInDateNew)),
'checkoutDate' => date('Y-m-d', strtotime($strCheckOutDateNew)),
'roomInfo' => $roominfo,
'searchCriteria' => $searchCriteria,
'searchPreferences' => $searchPreferences,
);
$B2BSearch = [];
if ($getCustomerDetail['IsB2BAgent'] == 1) {
$B2BSearch = array(
'B2BAgencySysIdKey' => $getCustomerDetail['SecurityKey'],
'B2CAgencySysIdKey' => $this->agencyDetails['SecurityKey'],
'MasterAgencySysId' => $this->agencyDetails['AgencySysId'],
);
}
$searchdata = array(
'APIpost' => array('searchQuery' => $searchQuery, 'sync' => true),
'searchID' => $SearchTraceId,
'MemberCount' => $MemberCount,
'destination' => $CityName,
'CountryId' => $countrySysId,
'GuestNationality' => $selectNationality,
'PlanType' => 2,
'MPType' => ($getCustomerDetail['IsB2BAgent'] == 1) ? 2 : 1,
'interNationalSearch' => $interNationalSearch,
'B2B' => $B2BSearch,
'APIMode' => ($this->intLoggedinUserAgencySysId == 1) ? 1 : 0,
);
$checkinDate = date('mdY', strtotime($searchQuery['checkinDate']));
$checkoutDate = date('mdY', strtotime($searchQuery['checkoutDate']));
$makemytrip = '?checkin=' . $checkinDate . '&checkout=' . $checkoutDate . '&locusType=city&_uCurrency=INR&reference=hotel&type=city&searchText=' . $CityName . '&country=' . $selectNationality . '&locusId=&city=';
$makemytripurl = 'https://www.makemytrip.com/hotels/hotel-listing/' . $makemytrip;
$objTempFlight = new Travel_Model_TblFlight();
$CheckApiActive = $objTempFlight->checkActiveAPI($this->intLoggedinUserAgencySysId, 2);
if(empty($CheckApiActive)){
$getData['SecurityKey'] = trim($_SESSION['sessionLogin_user']['agencyDetails']['SecurityKey']);
$URL = GTX_API_URL . '/hotel/v2/searchquery';
$apiResponse = Zend_Controller_Action_HelperBroker::getStaticHelper("Hotel")->apiHttpRequest($searchdata, $getData, $URL);
$searchids = (isset($apiResponse['searchids']) && $apiResponse['searchids']) ? $apiResponse['searchids'] : [];
}else{
$TraceId = 'GTX'.floor(microtime(true) * 1000);
$searchids = [$TraceId];
}
$arrData['searchids'] = $searchids;
$arrData['B2BSearch'] = $B2BSearch;
$arrData['searchdata'] = $searchdata;
$arrData['IsB2Bproposal'] = isset($getCustomerDetail['IsB2BAgent']) ? $getCustomerDetail['IsB2BAgent'] : 0;
$tempData = array(
'TraceId' => $SearchTraceId,
'TPSysId' => base64_decode($lastID),
'APIBookingData' => json_encode($arrData),
);
//}
$objFlight = new Travel_Model_TblFlight();
$objFlight->deleteFlightTempData($SearchTraceId);
$objFlight->insertFlightTempData($tempData);
echo json_encode(array('redirection' => true, 'TPSysId' => $lastID, 'SearchTraceId' => $SearchTraceId, 'makemytripurl' => $makemytripurl));
}
}
public function addCustomerFromHotelAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
if ($source == "mainPage") {
echo $mobilenum = $this->_request->getParam('mobilenum');
echo $customername = $this->_request->getParam('customername');
echo $emailID = $this->_request->getParam('emailID');
exit;
} else {
$editID = $this->_request->getParam('editID');
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
$salution = $this->_request->getParam('salution');
$date = date('Y-m-d');
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => (isset($mobilenumber) && !empty($mobilenumber)) ? $mobilenumber : '',
'FullName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => (isset($lname) && !empty($lname)) ? $lname : 1,
'ActiveDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if ($editID) {
$where = "CRMCustSysId = " . $editID;
echo $customerRcord = $this->_crmcustomerObj->UpdateCustomer($userArray, $where);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'IsEmployee' => '0',
'Contacts' => $mobilenumber,
'JoinDate' => $date,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'RegisterDate' => $date,
'IsApproved' => '0',
);
echo $agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
} else {
$customerRcord = $this->_crmcustomerObj->addCustomer($userArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'CRMCustSysId' => $customerRcord,
'EmailId' => $customerEmail,
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'IsEmployee' => '0',
'Contacts' => isset($mobilenumber) ? $mobilenumber : '',
'JoinDate' => $date,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => (isset($lname) && !empty($lname)) ? $lname : 1,
'RegisterDate' => $date,
'IsApproved' => '0',
);
### Insert Record in to Agency Table as well ########
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
}
echo json_encode(array('CRMCustSysId' => base64_encode($customerRcord)));
//return $customerRcord;
}
}
public function getCustomerDetailbyleadAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$getData = $this->getRequest()->getPost();
$email = $this->_HtmlPurifier->filter($this->_request->getParam('emailID'));
$AgencyCRMLeadSysId = (NULL != $this->_request->getParam('AgencyCRMLeadSysId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('AgencyCRMLeadSysId')) : ''; // for get b2b agency
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (!empty($AgencyCRMLeadSysId)) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsApproved' => '1',
'UpdatedDate' => $date
);
$customerDetails = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
if (!empty($customerDetails)) {
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$getAgencyCustomerExist = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerDetails['EmailId']), $AgencySysId);
if (empty($getcustomerdetails)) {
$userArray = array(
'EmailId' => trim($customerDetails['EmailId']),
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($customerDetails['PrimaryContactNumber']),
'countrycode' => trim($customerDetails['countrycode']),
'FullName' => trim($customerDetails['FullName']),
'FirstName' => trim($customerDetails['FirstName']),
'LastName' => trim($customerDetails['LastName']),
'ActiveDate' => $date,
'UpdatedDate' => $date,
'CreatedDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
} else {
$CRMCustSysId = $getcustomerdetails['CRMCustSysId'];
}
if (empty($getcustomerdetails)) {
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'CRMCustSysId' => $CRMCustSysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'EmailId' => trim($customerDetails['EmailId']),
'Title' => $customerDetails['Salutation'],
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => 0,
'StateOrZoneSysId' => 0,
'CountrySysId' => 0,
'IsEmployee' => '0',
'Contacts' => trim($customerDetails['PrimaryContactNumber']),
'countrycode' => trim($customerDetails['countrycode']),
'JoinDate' => $date,
'UserName' => trim($customerDetails['FirstName']) . '' . trim($customerDetails['LastName']),
'FirstName' => trim($customerDetails['FirstName']),
'LastName' => trim($customerDetails['LastName']),
'Relation' => '',
'PassportNo' => '',
'PassportExpiry' => '',
'DOB' => '',
'MarriageAnniversary' => '',
'CreatedByUserSysId' => isset($customerDetails['AssignUserSysId']) ? (int) $customerDetails['AssignUserSysId'] : (int) $this->intLoggedinUserId,
'RegisterDate' => $date,
'UpdateDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
);
$CustomerSysId = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
} else {
$CustomerSysId = $getAgencyCustomerExist['CustomerSysId'];
}
}
$detail['status'] = 'success';
$detail['CustomerSysId'] = base64_encode($CustomerSysId);
$detail['CRMCustSysId'] = base64_encode($CRMCustSysId);
} else {
$detail['status'] = 'failed';
$detail['CustomerSysId'] = '';
$detail['CRMCustSysId'] = '';
}
echo json_encode($detail);
exit;
}
public function getCustomerDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$getData = $this->getRequest()->getPost();
$action = (isset($getData['action']) && !empty($getData['action'])) ? $getData['action'] : '';
$email = $this->_HtmlPurifier->filter($this->_request->getParam('emailID'));
$aId = (NULL != $this->_request->getParam('aId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('aId')) : ''; // for get b2b agency
$mobilenum = $this->_HtmlPurifier->filter($this->_request->getParam('mobilenum'));
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
//echo $mobilenum;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (isset($email) && !empty($email)) {
if ($aId != '') {
$customerDetails = $customerByEmail = $this->_crmcustomerObj->ChkEmailWithResponseB2B($email, $aId);
} else {
$customerDetails = $customerByEmail = $this->_crmcustomerObj->ChkEmailWithResponse($email, $AgencySysId);
}
}
if (isset($mobilenum) && !empty($mobilenum)) {
if ($aId != '') {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgencyB2B($mobilenum, $aId, '');
} else {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgency($mobilenum, $AgencySysId, '');
}
}
if ($action == 'offlineFlight' && !empty($customerByEmail) && empty($customerDetails)) {
$customerDetails = $customerByEmail;
}
if ($customerDetails) {
$status = 'success';
} else {
$status = 'failure';
}
$detail['status'] = $status;
//$detail['customerDetails']=$customerDetails;
$detail['CustomerUserName'] = (isset($customerDetails['UserName']) && !empty($customerDetails['UserName'])) ? $customerDetails['UserName'] : '';
$detail['CustomerEmail'] = (isset($customerDetails['EmailId']) && !empty($customerDetails['EmailId'])) ? $customerDetails['EmailId'] : '';
$detail['CustomerSysId'] = (isset($customerDetails['CustomerSysId']) && !empty($customerDetails['CustomerSysId'])) ? base64_encode($customerDetails['CustomerSysId']) : '';
$detail['CRMCustSysId'] = (isset($customerDetails['CRMCustSysId']) && !empty($customerDetails['CRMCustSysId'])) ? base64_encode($customerDetails['CRMCustSysId']) : '';
$detail['Contacts'] = (isset($customerDetails['Contacts']) && !empty($customerDetails['Contacts'])) ? $customerDetails['Contacts'] : '';
$detail['Title'] = (isset($customerDetails['Title']) && !empty($customerDetails['Title'])) ? $customerDetails['Title'] : '';
$detail['FirstName'] = (isset($customerDetails['FirstName']) && !empty($customerDetails['FirstName'])) ? trim($customerDetails['FirstName']) : '';
$detail['LastName'] = (isset($customerDetails['LastName']) && !empty($customerDetails['LastName'])) ? trim($customerDetails['LastName']) : '';
$detail['Countrycode'] = (isset($customerDetails['countrycode']) && !empty($customerDetails['countrycode'])) ? trim($customerDetails['countrycode']) : '+91';
$secureCode = Catabatic_ValidateCustomer::secureCode($detail['CustomerSysId'], 1);
$detail['SecureCode'] = $secureCode;
echo json_encode($detail);
}
public function savepackagequerybyoAction() {
$objPackage = new Travel_Model_TblPackage();
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclList = $this->_objPkg->getPackageInclusionList();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getData = $this->getRequest()->getPost();
$TPSysId = $getData['TPSysId'];
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
$tpintsysID = $getData['itenaryID'];
$nooftraveler = $getData['travelers'];
$search_going_to = $getData['search_going_to'];
$get_cityname = rtrim($getData['multicities'], ',');
$getcityvalue = @$getData['search_multi_from'];
$currentOwnerSysId = $getData['currentOwnerSysId'];
$hotelpreference = @$getData['hotelpreference'];
$PKqueryType = (isset($getData['PKqueryType']) && !empty($getData['PKqueryType']) ? $getData['PKqueryType'] : '0'); //
if (isset($hotelpreference)) {
$hotelpreference = implode(",", $hotelpreference);
} else {
$hotelpreference = '';
}
$roomjson = array();
for ($k = 1; $k <= $getData['roomlp']; $k++) {
$roomjson[$k]['Adult'] = $this->_request->getParam('adult_' . $k);
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $this->_request->getParam('adultcl_extrabed_' . $k . '_3');
}
$roomjson[$k]['Child'] = $this->_request->getParam('child_' . $k);
$roomjson[$k]['Infant'] = $this->_request->getParam('infant_' . $k);
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $this->_request->getParam('child_age_' . $k . '_' . $j);
$roomjson[$k]['ChildBedType_' . $j] = $this->_request->getParam('child_extrabed_' . $k . '_' . $j);
}
$roomjson[$k]['departuredate'] = $getData['search_specific_date'];
$roomjson[$k]['returndate'] = '';
}
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityname = $search_going_to_dest[0];
$going_to_cityid = $search_going_to_dest[1];
}
$search_going_from = $getData['search_going_from'];
if (!empty($search_going_from)) {
$search_going_to_source = explode('__', $search_going_from);
$going_from_cityid = $search_going_to_source[0];
$going_from_cityname = $search_going_to_source[1];
}
// echo $DestinationPlaces;
$customerID = $getData['customerID'];
if (empty($getData['search_going_to'])) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if (empty($getData['search_specific_date'])) {
$response = array('success' => false, 'msg' => 'Please select date range.');
echo json_encode($response);
exit;
}
/*
if(empty($getData['multicities'])) {
$response = array('success' => false, 'msg' => 'Please select Multiple Destination.');
echo json_encode($response);
exit;
}
/*
if($getData['search_inclusions']) {
$response = array('success' => false, 'msg' => 'Please select Inclusion.');
echo json_encode($response);
exit;
}
if($getData['search_theme']) {
$response = array('success' => false, 'msg' => 'Please select Theme.');
echo json_encode($response);
exit;
}
*/
if (!empty($getData['search_theme'])) {
$search_theme = $getData['search_theme'];
for ($i = 0; $i < count($search_theme); $i++) {
$search_theme_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_theme[$i], $packageThemeList, 'PackType');
}
}
if (!empty($getData['search_inclusions'])) {
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($search_theme_list)) {
$thememask = '1';
$char = '';
for ($k = 0; $k < count($packageThemeList); $k++) {
$char = in_array(@$packageThemeList[$k]['PackType'], @$search_theme_list) ? '1' : '0';
$thememask .= $char;
}
}
$char = '';
if (!empty($search_inclusion_list)) {
$inclmask = '1';
for ($k = 0; $k < count($packageInclList); $k++) {
$char = in_array(@$packageInclList[$k]['InclId'], @$search_inclusion_list) ? '1' : '0';
$inclmask .= $char;
}
}
if (isset($getData['search_theme'])) {
$PackTypeMask = $getData['search_theme'] ? $thememask : '';
} else {
$PackTypeMask = '';
}
if (isset($getData['search_inclusions'])) {
$InclMask = $getData['search_inclusions'] ? $inclmask : '';
} else {
$InclMask = '';
}
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', @$getData['search_price_range']);
}
$min_price = $getData['search_price_range'] ? $search_price_range[0] : 0;
$max_price = $getData['search_price_range'] ? $search_price_range[1] : 0;
$planbookingID = 'Q/' . date('y');
$createDate = date('Y-m-d H:s:i');
if (!empty($getData['search_specific_date'])) {
$search_specific_date = explode('/', @$getData['search_specific_date']);
$plan_start_date = $search_specific_date[2] . '-' . $search_specific_date[1] . '-' . $search_specific_date[0];
}
$status = 1;
$sessionPackageQueryData = new Zend_Session_Namespace('sessionPackageQueryData');
if (!empty($sessionPackageQueryData->searchData)) {
$packageSearchResult = $getData;
$this->view->packageSearchResult = $packageSearchResult;
} else {
//$this->_redirect('/packagesearch');
}
$roominfojson = json_encode($roomjson);
$agentsysID = $this->intLoggedinUserId;
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
############ StartDate ###############
$data = array(
'PlanBookingId' => $planbookingID,
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'InclMask' => $InclMask,
'SourcePlaces' => isset($going_from_cityname) ? trim($going_from_cityname) : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'DestinationPlaces' => $going_to_cityid,
'DestinationPlacesSysId' => (int) $going_to_cityname,
'Cities' => $citiesText . $going_to_cityid,
'CityIds' => $getcityvalue ? $getcityvalue : '',
'PlanType' => 5,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'MinPax' => $nooftraveler,
'RoomInfoJson' => $roominfojson,
'StartDate' => isset($plan_start_date) ? $plan_start_date : '',
'InventoryType' => 5,
'PKqueryType' => $PKqueryType,
"CreatorSysId" => $agentsysID,
'HotelPreference' => $hotelpreference,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 0
);
if (empty($TPSysId)) {
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $AgentSysId,
'Remarks' => $leadRemark,
'TPSysId' => $lastID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $lastID;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
);
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $lastID);
echo json_encode($response);
exit;
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
//if($lasttravelitenaryID){
//$response = array('success' => true, 'msg' => 'Package Search.' ,'lastID' => $lastID);
// echo json_encode($response);
// exit;
//}
}
} else if ($TPSysId > 0) {
############## Update TPSysID ######################################
$data = array(
'Readymade' => '0'
);
$where = array('TPSysId = ? ' => $TPSysId);
$updateId = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($data, $where);
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $AgentSysId,
'Remarks' => $leadRemark,
'TPSysId' => $TPSysId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
$agentsysID = $this->intLoggedinUserId;
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $TPSysId;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
if ($TPSysId) {
$travelitenary = array(
'TPSysId' => $TPSysId,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
);
}
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $TPSysId);
echo json_encode($response);
exit;
}
}
public function savepackagequeryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$param = $getData = $this->getRequest()->getPost();
$TPSysId = $getData['TPSysId'];
$AdditionalReq = (isset($getData['AdditionalReq']) && !empty($getData['AdditionalReq'])) ? $getData['AdditionalReq'] : '';
$PlanType = isset($getData['PlanType']) ? $getData['PlanType'] : 5;
$isFromSearchResult = $getData['isFromSearchResult'];
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
$tpintsysID = $getData['itenaryID'];
$nooftraveler = $getData['travelers'];
$ContSysId = (isset($getData['ContSysId'])) ? (int) $getData['ContSysId'] : '';
$search_going_to = $getData['search_going_to'];
$get_cityname = rtrim($getData['multicities'], ',');
$getcityvalue = @$getData['search_going_to_id'];
$noofdaysfrom = @$getData['noofdaysfrom'];
$noofdaysto = @$getData['noofdaysto'];
$currentOwnerSysId = isset($getData['currentOwnerSysId']) ? $getData['currentOwnerSysId'] : '';
$PKqueryType = (isset($getData['PKqueryType']) && !empty($getData['PKqueryType'])) ? $getData['PKqueryType'] : '0'; //
$packageTypeCategory = (isset($getData['packageTypeCategory']) && !empty($getData['packageTypeCategory']) ? $getData['packageTypeCategory'] : 0); //
$hotelpreference = @$getData['hotelpreference'];
$IsOperationalLead = isset($getData['IsOperationalLead']) ? $getData['IsOperationalLead'] : 0;
$OpsAgentSysId = (isset($getData['OpsAgentSysId']) && $IsOperationalLead == 1) ? $getData['OpsAgentSysId'] : '';
//echo "<pre>";print_r($getData);die;
if (isset($hotelpreference)) {
$hotelpreference = implode(",", $hotelpreference);
} else {
$hotelpreference = '';
}
$roomjson = array();
$childsage = '';
$TotAdultCount = 0;
$TotChildCount = 0;
$TotInfantCount = 0;
$childWithBed = $param['childWithBed'];
$childWithBedCalculate = $param['childWithBed'];
$childWithOutBed = $param['childWithOutBed'];
$childWithOutBedCalculate = $param['childWithOutBed'];
$infant1 = $TotInfantCount = (int) $param['infant1'];
$infant1Calculate = (int) $param['infant1'];
$adultTwinSharing = $param['adultTwinSharing'];
$adultTripleSharing = $param['adultTripleSharing'];
$adultSingleSharing = $param['adultSingleSharing'];
$adultQuadSharing = $param['adultQuadSharing'];
$adultQuintSharing = $param['adultQuintSharing'];
$adultHexaSharing = $param['adultHexaSharing'];
$adultTwinSharing1 = floor($adultTwinSharing / 2);
$adultTwinSharing2 = $adultTwinSharing % 2;
$adultTripleSharing1 = floor($adultTripleSharing / 3);
$adultTripleSharing2 = $adultTripleSharing % 3;
$adultQuadSharing1 = floor($adultQuadSharing / 4);
$adultQuadSharing2 = $adultQuadSharing % 4;
$adultQuintSharing1 = floor($adultQuintSharing / 5);
$adultQuintSharing2 = $adultQuintSharing % 5;
$adultHexaSharing1 = floor($adultHexaSharing / 6);
$adultHexaSharing2 = $adultHexaSharing % 6;
for ($m = 1; $m <= $adultTwinSharing1; $m++) {
$param['adult'][] = 2;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'twin';
}
if ($adultTwinSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'twin';
}
for ($m = 1; $m <= $adultTripleSharing1; $m++) {
$param['adult'][] = 3;
$param['adult_bed_type'][] = 'extrabed';
$param['adult_type'][] = 'triple';
}
if ($adultTripleSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_bed_type'][] = 'triple';
$param['adult_type'][] = 'triple';
} else if ($adultTripleSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'triple';
}
for ($m = 1; $m <= $adultSingleSharing; $m++) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'single';
}
for ($m = 1; $m <= $adultQuadSharing1; $m++) {
$param['adult'][] = 4;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
}
if ($adultQuadSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
} else if ($adultQuadSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
} else if ($adultQuadSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
}
for ($m = 1; $m <= $adultQuintSharing1; $m++) {
$param['adult'][] = 5;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
}
if ($adultQuintSharing2 == 4) {
$param['adult'][] = 4;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
}
for ($m = 1; $m <= $adultHexaSharing1; $m++) {
$param['adult'][] = 6;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
}
if ($adultHexaSharing2 == 5) {
$param['adult'][] = 5;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 4) {
$param['adult'][] = 4;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
}
$mn = $mncw = $mncwo = 0;
foreach ($param['adult'] as $adkey => $advalue) {
$adult_type = (isset($param['adult_type'][$adkey])) ? trim($param['adult_type'][$adkey]) : '';
if ($advalue == 3 && $adult_type != 'quad' && $adult_type != 'quint' && $adult_type != 'hexa') {
if ($childWithOutBedCalculate > 0) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
$mncwo++;
} else if ($childWithBedCalculate > 0) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$childWithBedCalculate = $childWithBedCalculate - 1;
$mncw++;
} else if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mn++;
}
if (($advalue != 3 || $adult_type == 'quad' || $adult_type == 'quint' || $adult_type == 'hexa') && $mn < ($childWithOutBed + $childWithBed + $infant1)) {
if ($childWithOutBedCalculate > 0 || $childWithBedCalculate > 0 || $infant1Calculate > 0) {
if ($childWithOutBedCalculate > 0 && $childWithBedCalculate > 0) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$mncw++;
$mn++;
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
$childWithBedCalculate = $childWithBedCalculate - 1;
} else if ($childWithOutBedCalculate > 0 && $childWithBedCalculate < 1) {
if ($childWithOutBedCalculate == 1) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mncwo++;
$mn++;
}
if ($childWithOutBedCalculate > 1) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$mn++;
$childWithOutBedCalculate = $childWithOutBedCalculate - 2;
}
} else if ($childWithBedCalculate > 0 && $childWithOutBedCalculate < 1) {
if ($childWithBedCalculate == 1) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$childWithBedCalculate = $childWithBedCalculate - 1;
if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mncw++;
$mn++;
}
if ($childWithBedCalculate > 1) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$mncw++;
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$mncw++;
$mn++;
$childWithBedCalculate = $childWithBedCalculate - 2;
}
} else if ($childWithBedCalculate == 0 && $childWithOutBedCalculate == 0 && $infant1Calculate > 0) {
if ($infant1Calculate == 1) {
$param['infant'][$mn] = 1;
$mn++;
$infant1Calculate = $infant1Calculate - 1;
}
if ($infant1Calculate > 1) {
$param['infant'][$mn] = 2;
$mn++;
$infant1Calculate = $infant1Calculate - 2;
}
}
}
}
}
if ($adultTripleSharing2 == 2) {
$adultTripleSharing2 = 1;
}
if ($adultQuadSharing2 == 3 || $adultQuadSharing2 == 2 || $adultQuadSharing2 == 1) {
$adultQuadSharing2 = 1;
}
if ($adultQuintSharing2 == 4 || $adultQuintSharing2 == 3 || $adultQuintSharing2 == 2 || $adultQuintSharing2 == 1) {
$adultQuintSharing2 = 1;
}
if ($adultHexaSharing2 == 5 || $adultHexaSharing2 == 4 || $adultHexaSharing2 == 3 || $adultHexaSharing2 == 2 || $adultHexaSharing2 == 1) {
$adultHexaSharing2 = 1;
}
$countRooms = $adultTwinSharing1 + $adultTwinSharing2 + $adultTripleSharing1 + $adultTripleSharing2 + $adultSingleSharing + $adultQuadSharing1 + $adultQuadSharing2 + $adultQuintSharing1 + $adultQuintSharing2 + $adultHexaSharing1 + $adultHexaSharing2;
$childSharing = $childWithBed + $childWithOutBed;
$roomCountMatchChild = (($adultTwinSharing1 * 2) + ($adultTripleSharing1 * 1) + ($adultSingleSharing * 2) + ($adultQuadSharing1 * 2) + ($adultQuadSharing2 * 2) + ($adultQuintSharing1 * 2) + ($adultQuintSharing2 * 2) + ($adultHexaSharing1 * 2) + ($adultHexaSharing2 * 2));
if ($roomCountMatchChild < ($childSharing)) {
$response = ['success' => false, 'msg' => 'Child count must be less than ' . $childSharing . '. Otherwise take extra Adult on twin/triple/single/quad sharing to accommodate the ' . $childSharing . ' child. '];
echo json_encode($response);
exit;
}
// echo "<pre>";print_r($param);exit;
$roomjson = array();
for ($i = 0, $k = 1; $k <= $countRooms; $k++, $i++) {
$totalAdultChild = (int) $param['adult'][$i] + (int) $param['child'][$i];
$roomjson[$k]['Adult'] = $param['adult'][$i];
$roomjson[$k]['adult_type'] = $param['adult_type'][$i];
$roomjson[$k]['Child'] = (int) $param['child'][$i];
$roomjson[$k]['Infant'] = (int) $param['infant'][$i];
$TotAdultCount = $TotAdultCount + $param['adult'][$i];
$TotChildCount = $TotChildCount + $param['child'][$i];
$noOfAdultsar[$k] = $param['adult'][$i];
if ($param['adult'][$i] == 3) {
$roomjson[$k]['AdultBedType'] = $param['adult_bed_type'][$i];
}
if ($param['child'][$i] > 0) {
for ($c = 1; $c <= (int) $param['child'][$i]; $c++) {
$roomjson[$k]['ChildBedType_' . $c] = $param['child_bed_type'][$i][$c - 1];
$roomjson[$k]['ChildAge_' . $c] = $param['child_age'][$i][$c - 1];
$selectnoOfChildar[$k] = $param['child'][$i];
}
}
$roomjson[$k]['departuredate'] = $getData['search_specific_date'];
$roomjson[$k]['returndate'] = '';
}
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityname = $search_going_to_dest[0];
$going_to_cityid = $search_going_to_dest[1];
}
$going_to_cityid = trim($getData['search_going_to_city']);
$search_going_from = $getData['search_going_from'];
if (!empty($search_going_from)) {
$search_going_to_source = explode('__', $search_going_from);
$going_from_cityid = $search_going_to_source[0];
$going_from_cityname = $search_going_to_source[1];
}
$customerID = $getData['customerID'];
if (empty($getData['search_going_to'])) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if (empty($getData['search_specific_date'])) {
$response = array('success' => false, 'msg' => 'Please select date range.');
echo json_encode($response);
exit;
}
$search_theme_list = $search_food_list = $search_inclusion_list = array();
if (!empty($getData['search_theme'])) {
$packageThemeList = $this->_objPkg->getPackageThemeList();
$search_theme = $getData['search_theme'];
for ($i = 0; $i < count($search_theme); $i++) {
$search_theme_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_theme[$i], $packageThemeList, 'PackType');
}
}
if (!empty($getData['search_food'])) {
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$search_food = $getData['search_food'];
for ($i = 0; $i < count($search_food); $i++) {
$search_food_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_food[$i], $packageFoodPreferenceList, 'CuisineSysId');
}
}
if (!empty($getData['search_inclusions'])) {
$packageInclList = $this->_objPkg->getPackageInclusionList();
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($search_theme_list)) {
$thememask = '1';
$char = '';
for ($k = 0; $k < count($packageThemeList); $k++) {
$char = in_array($packageThemeList[$k]['PackType'], $search_theme_list) ? '1' : '0';
$thememask .= $char;
}
}
$char = '';
if (!empty($search_food_list)) {
$foodmask = '1';
$char = '';
for ($k = 0; $k < count($packageFoodPreferenceList); $k++) {
$char = in_array($packageFoodPreferenceList[$k]['CuisineSysId'], $search_food_list) ? '1' : '0';
$foodmask .= $char;
}
}
$char = '';
if (!empty($search_inclusion_list)) {
$inclmask = '1';
for ($k = 0; $k < count($packageInclList); $k++) {
$char = in_array($packageInclList[$k]['InclId'], $search_inclusion_list) ? '1' : '0';
$inclmask .= $char;
}
}
if (isset($getData['search_theme'])) {
$PackTypeMask = $getData['search_theme'] ? $thememask : '';
} else {
$PackTypeMask = '';
}
if (isset($getData['search_food'])) {
$FoodTypeMask = $getData['search_food'] ? $foodmask : '';
} else {
$FoodTypeMask = '';
}
if (isset($getData['search_inclusions'])) {
$InclMask = $getData['search_inclusions'] ? $inclmask : '';
} else {
$InclMask = '';
}
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', @$getData['search_price_range']);
}
$min_price = $getData['search_price_range'] ? $search_price_range[0] : 0;
$max_price = $getData['search_price_range'] ? $search_price_range[1] : 0;
$PriceRange = isset($getData['PriceRange']) ? substr(trim($getData['PriceRange']), 0, 95) : '';
$planbookingID = 'Q/' . date('y');
$createDate = date('Y-m-d H:s:i');
$plan_start_date_Str = '';
if (!empty($getData['search_specific_date'])) {
$search_specific_date = explode('/', $getData['search_specific_date']);
$plan_start_date = $search_specific_date[2] . '-' . $search_specific_date[1] . '-' . $search_specific_date[0];
$plan_start_date_Str = date('d-M-y', strtotime($plan_start_date));
}
$status = (isset($getData['StatusType']) && !empty($getData['StatusType'])) ? (int) $getData['StatusType'] : 1;
$sessionPackageQueryData = new Zend_Session_Namespace('sessionPackageQueryData');
if (!empty($sessionPackageQueryData->searchData)) {
$packageSearchResult = $getData;
$packageSearchResult['RoomMemInfoJson'] = $getData;
$this->view->packageSearchResult = $packageSearchResult;
} else {
//$this->_redirect('/packagesearch');
}
$roominfojson = json_encode($roomjson);
$agentsysID = $this->intLoggedinUserId;
$sessionPackageSearchData = new Zend_Session_Namespace('sessionPackageSearchData');
$sessionPackageSearchData->searchData = $getData;
$sessionPackageSearchData->searchData['RoomMemInfoJson'] = json_encode($roomjson);
$sessionPackageSearchData->searchData['roominfojson'] = json_encode($roomjson);
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
############ StartDate ###############
if (isset($plan_start_date) && !empty($plan_start_date)) {
$plan_enddate_date = $createDate;
if (isset($noofdaysto) && !empty($noofdaysto)) {
$plan_enddate_date = date('Y-m-d H:i:s', strtotime($plan_start_date . " +" . $noofdaysto . " days"));
}
}
if ($customerID > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($customerID);
}
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$historyData = array(
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'CustomerSysId' => $customerID,
'PlanType' => $PlanType,
'SourcePlaces' => isset($going_from_cityname) ? trim($going_from_cityname) : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'DestinationPlaces' => $going_to_cityid,
'DestinationPlaceSysId' => (int) $going_to_cityname,
'PackTypeMask' => $PackTypeMask,
'InclusionMark' => $InclMask,
'Rooms' => $getData['roomlp'],
'TotAdultCount' => $TotAdultCount,
'TotChildCount' => $TotChildCount,
'TotInfantCount' => 0,
'PriceRangeFrom' => $min_price,
'PriceRangeTo' => $max_price,
'AdditionalSrvMark' => '',
'StartDate' => isset($plan_start_date) ? $plan_start_date : $createDate,
'ValidTill' => isset($plan_enddate_date) ? $plan_enddate_date : $createDate,
'Rating' => 0,
"SearchDate" => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
//echo "<pre>";print_r();exit;
$this->_crmcusttravelplanhistory = new Travel_Model_CRM_CustomerTravelPlanSearchHistory();
$this->_crmcusttravelplanhistory->addCustomerTravelPlanSearchHistory($historyData);
$ExpectedClosureDate = (isset($getData['ExpectedClosureDate']) && !empty($getData['ExpectedClosureDate'])) ? implode('-', array_reverse(explode('/', $getData['ExpectedClosureDate']))) : '';
$ExpectedValue = (isset($getData['ExpectedValue']) && !empty($getData['ExpectedValue'])) ? (float) trim($getData['ExpectedValue']) : 0;
$data = array(
'PlanBookingId' => $planbookingID,
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'CuisineMask' => $FoodTypeMask,
'InclMask' => $InclMask,
'SourcePlaces' => isset($going_from_cityname) ? trim($going_from_cityname) : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'DestinationPlaces' => $going_to_cityid,
'DestinationPlacesSysId' => (int) $going_to_cityname,
'Cities' => $citiesText . $going_to_cityid,
'CityIds' => isset($getcityvalue) ? $getcityvalue : ($going_from_cityid . "," . $going_to_cityname),
'PlanType' => $PlanType,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'MinPax' => $nooftraveler,
'PriceRange' => $PriceRange,
'DaysCountFrom' => $noofdaysfrom,
'DaysCountTo' => $noofdaysto,
'RoomInfoJson' => $roominfojson,
'StartDate' => isset($plan_start_date) ? $plan_start_date : '',
'InventoryType' => 5,
'PKqueryType' => $PKqueryType,
"CreatorSysId" => $agentsysID,
'HotelPreference' => $hotelpreference,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 1,
'IsB2Bproposal' => trim($IsB2BCustomer),
'LeadSourceSysId' => $getData['lead_source'],
'packageTypeCategory' => $packageTypeCategory,
'AdditionalReq' => $AdditionalReq,
'IsHotelOnlyPackage' => ($PlanType == 2) ? 1 : 0,
'Countries' => $ContSysId,
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
'ExpectedClosureDate' => $ExpectedClosureDate,
'ExpectedValue' => $ExpectedValue,
);
$preTpSysId = 0;
if ($isFromSearchResult == 0) {
if (empty($TPSysId)) {
$createNewQuery = isset($getData['createNewQuery']) ? $getData['createNewQuery'] : '';
$NewQueryLeadHiddenId = isset($getData['NewQueryLeadHiddenId']) ? trim($getData['NewQueryLeadHiddenId']) : '';
if (($NewQueryLeadHiddenId != "") && ($createNewQuery == 'false' || $createNewQuery == '')) {
$where = "TPSysId = " . $NewQueryLeadHiddenId;
if ($status == 1) {
unset($data['StatusType']);
}
unset($data['CreateDate']);
unset($data['IsB2Bproposal']);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($data, $where);
$lastID = $NewQueryLeadHiddenId;
} else {
$leadQueryDetails = array();
if ((int) $NewQueryLeadHiddenId > 0) {
$leadQueryDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($NewQueryLeadHiddenId, 'Query');
} else if ((int) $createNewQuery > 0) {
$leadQueryDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($createNewQuery, 'Query');
}
if (!empty($leadQueryDetails)) {
$data['IsB2Bproposal'] = $leadQueryDetails[0]['IsB2Bproposal'];
$data['B2BAgencySysId'] = $leadQueryDetails[0]['B2BAgencySysId'];
$data['CreatorSysId'] = $leadQueryDetails[0]['CreatorSysId'];
$data['LeadSysId'] = $leadQueryDetails[0]['LeadSysId'];
}
// echo "<pre>";print_r($data);exit;
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
}
$sessionPackageSearchData->searchData['TPSysId'] = $lastID;
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => @$lastID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = @$lastID;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
//if($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
);
//$ClosureData = $this->_crmcusttravelplan->expectedClosureData($lastID, $getData);
$secureCode = Catabatic_ValidateCustomer::secureCode($lastID, 1);
$lastupdaedID = $lastID;
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $lastID, 'code' => $secureCode);
// echo json_encode($response);
// exit;
// }
} else if ((int) $TPSysId > 0) {
$leadDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($TPSysId, 'Query');
//echo "<pre>";print_r($leadDetails);die;
$sessionPackageSearchData->searchData['IsB2bProposal'] = $leadDetails[0]['IsB2Bproposal'];
$StatusTypePre = $leadDetails[0]['StatusType'];
if ($StatusTypePre > 1 && $status == 1) {
$status = 26;
}
$agentsysID = $this->intLoggedinUserId;
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($TPSysId);
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $TPSysId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
if (empty($getlatestversion)) {
$versionnum = 0;
} else {
$versionnum = $getlatestversion[0]['VersionId'];
}
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
$ExpectedClosureDate = (isset($getData['ExpectedClosureDate']) && !empty($getData['ExpectedClosureDate'])) ? implode('-', array_reverse(explode('/', $getData['ExpectedClosureDate']))) : '';
$ExpectedValue = (isset($getData['ExpectedValue']) && !empty($getData['ExpectedValue'])) ? (float) trim($getData['ExpectedValue']) : 0;
$CreatorSysId = $agentsysID;
if ($leadDetails[0]['IsB2Bproposal'] == 3) {
$CreatorSysId = $leadDetails[0]['CreatorSysId'];
}
$updateddata = array(
'PlanBookingId' => $planbookingID,
//'VersionId' => $versionnum + 1,
//'MasterTPSysId' => $TPSysId,
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'CuisineMask' => $FoodTypeMask,
'InclMask' => $InclMask,
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'DestinationPlaces' => isset($going_to_cityid) ? $going_to_cityid : '',
'DestinationPlacesSysId' => isset($going_to_cityname) ? (int) $going_to_cityname : 0,
'Cities' => $citiesText . $going_to_cityid,
'CityIds' => isset($getcityvalue) ? $getcityvalue : ($going_from_cityid . "," . $going_to_cityname),
'PlanType' => $PlanType,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'PriceRange' => $PriceRange,
'MinPax' => $nooftraveler,
'DaysCountFrom' => $noofdaysfrom,
'DaysCountTo' => $noofdaysto,
'RoomInfoJson' => $roominfojson,
'StartDate' => isset($plan_start_date) ? $plan_start_date : '',
//'CreatorSysId' => $CreatorSysId,
'HotelPreference' => $hotelpreference,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 1,
'LeadSourceSysId' => $getData['lead_source'],
'packageTypeCategory' => $packageTypeCategory,
'Countries' => $ContSysId,
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
'ExpectedClosureDate' => $ExpectedClosureDate,
'ExpectedValue' => $ExpectedValue,
'PKqueryType' => $PKqueryType,
);
//added new code for update
$where = array('TPSysId = ? ' => $TPSysId);
$updateId = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updateddata, $where);
//
//commented for stop creation query again on search for customer search
//$lastupdaedID = $this->_crmcusttravelplan->addCustomerTravelPlan($updateddata);
$lastupdaedID = $TPSysId;
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $lastupdaedID;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
if ($lastupdaedID) {
$travelitenary = array(
'TPSysId' => $lastupdaedID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
);
}
//$ClosureData = $this->_crmcusttravelplan->expectedClosureData($lastupdaedID, $getData);
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($lastupdaedID), 1);
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $lastupdaedID, 'lastencodeID' => base64_encode($lastupdaedID), 'code' => $secureCode, 'plan_start_date' => $plan_start_date_Str);
}
$preTpSysId = isset($leadDetails[0]['AgentSysId']) ? (int) $leadDetails[0]['AgentSysId'] : 0;
if (!empty($currentOwnerSysId) && ($preTpSysId != (int) $currentOwnerSysId) && in_array('queryacknowledgement', $this->manageNotifications)) {
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $agencySysID,
"AgentSysId" => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$agentDetails = $this->_crmcustomerObj->getAgentDetailById($currentOwnerSysId);
$mAgentEmailId = $agentDetails[0]['EmailId'];
$agentAssineDetails[0]['FirstName'] = trim($_SESSION['AgencyUser']['user']->FirstName);
$agentAssineDetails[0]['LastName'] = trim($_SESSION['AgencyUser']['user']->LastName);
$agencyPrimaryEmail = trim($_SESSION['AgencyUser']['user']->EmailId);
$PrimaryContactName = trim($_SESSION['AgencyUser']['user']->FirstName) . ' ' . trim($_SESSION['AgencyUser']['user']->LastName);
$AgencyCRMLeadSysIdArr[] = $lastupdaedID;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'gtxCustomerAgentQueryEmailNotification');
$html->assign('agentDetails', $agentDetails);
$html->assign('agencyDetails', $_SESSION['sessionLogin_user']['agencyDetails']);
$html->assign('agentAssineDetails', $agentAssineDetails);
$html->assign('agencyCustomerDetails', $getcustomerDetail);
$html->assign('CustomerSysId', base64_encode(trim($getcustomerDetail['CustomerSysId'])));
$html->assign('AgencyCRMLeadSysIdArr', $AgencyCRMLeadSysIdArr);
$bodyTextAssign = $html->render('email-template.phtml');
$subject = 'New Query Assigned';
$emailMasterDataAssign = array('fromEmail' => trim($agencyPrimaryEmail), 'fromName' => trim($PrimaryContactName), 'subject' => $subject, 'to' => array($mAgentEmailId), 'bodyHtml' => $bodyTextAssign, 'bodyText' => '');
$checkStatusEmail = $this->mailSentByElastice($emailMasterDataAssign, $arrEmailStatistics);
}
echo json_encode($response);
exit;
//call function for supplier enquiry
Zend_Controller_Action_HelperBroker::getStaticHelper('PackageSearch')->enqsupupdatestatus($getData->searchData['EnqSupplierSysId'], 1); //2 for query
//#end of call function for supploer enquiry
} else {
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $TPSysId, 'lastencodeID' => '');
echo json_encode($response);
exit;
}
}
public function modifypackagequeryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclList = $this->_objPkg->getPackageInclusionList();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$getData = $this->getRequest()->getPost();
$TPSysId = $getData['TPSysId'];
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
$tpintsysID = $getData['itenaryID'];
$nooftraveler = $getData['travelers'];
$search_going_to = $getData['search_going_to'];
$search_going_from = $getData['search_going_from'];
$hotelpreference = @$getData['hotelpreference'];
if (isset($hotelpreference)) {
$hotelpreference = implode(",", $hotelpreference);
} else {
$hotelpreference = '';
}
$roomjson = array();
$TotAdultCount = 0;
$TotChildCount = 0;
for ($k = 1; $k <= $getData['roomlp']; $k++) {
$roomjson[$k]['Adult'] = $getData['adult_' . @$k];
$roomjson[$k]['Child'] = $getData['child_' . @$k];
$TotAdultCount += $roomjson[$k]['Adult'];
$TotChildCount += $roomjson[$k]['Child'];
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $getData['child_' . $k . '_' . $j];
}
$roomjson[$k]['bedtype'] = $getData['extrabed_' . @$k];
$roomjson[$k]['departuredate'] = $getData['search_specific_date'];
$roomjson[$k]['returndate'] = '';
}
//echo json_encode($roomjson);
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityid = $search_going_to_dest[0];
$going_to_cityname = $search_going_to_dest[1];
}
if (!empty($search_going_from)) {
$search_going_from_dest = explode('__', $search_going_from);
$going_from_cityid = $search_going_from_dest[0];
$going_from_cityname = $search_going_from_dest[1];
}
// echo $DestinationPlaces;
$customerID = $getData['customerID'];
if (empty($getData['search_going_to'])) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if (empty($getData['search_price_range'])) {
$response = array('success' => false, 'msg' => 'Please select price range.');
echo json_encode($response);
exit;
}
/*
if($getData['search_inclusions']) {
$response = array('success' => false, 'msg' => 'Please select Inclusion.');
echo json_encode($response);
exit;
}
if($getData['search_theme']) {
$response = array('success' => false, 'msg' => 'Please select Theme.');
echo json_encode($response);
exit;
}
*/
if (!empty($getData['search_theme'])) {
$search_theme = $getData['search_theme'];
for ($i = 0; $i < count($search_theme); $i++) {
$search_theme_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_theme[$i], $packageThemeList, 'PackType');
}
}
if (!empty($getData['search_inclusions'])) {
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($search_theme_list)) {
$thememask = '1';
$char = '';
for ($k = 0; $k < count($packageThemeList); $k++) {
$char = in_array(@$packageThemeList[$k]['PackType'], @$search_theme_list) ? '1' : '0';
$thememask .= $char;
}
}
$char = '';
if (!empty($search_inclusion_list)) {
$inclmask = '1';
for ($k = 0; $k < count($packageInclList); $k++) {
$char = in_array(@$packageInclList[$k]['InclId'], @$search_inclusion_list) ? '1' : '0';
$inclmask .= $char;
}
}
if (isset($getData['search_theme'])) {
$PackTypeMask = $getData['search_theme'] ? $thememask : '';
} else {
$PackTypeMask = '';
}
if (isset($getData['search_inclusions'])) {
$InclMask = $getData['search_inclusions'] ? $inclmask : '';
} else {
$InclMask = '';
}
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', @$getData['search_price_range']);
}
$min_price = $getData['search_price_range'] ? $search_price_range[0] : '';
$max_price = $getData['search_price_range'] ? $search_price_range[1] : '';
$planbookingID = 'Q/' . date('y');
$createDate = date('Y-m-d H:i:s');
if (!empty($getData['search_specific_date'])) {
$search_specific_date = explode('/', @$getData['search_specific_date']);
$plan_start_date = $search_specific_date[2] . '-' . $search_specific_date[1] . '-' . $search_specific_date[0];
}
$status = 1;
$sessionPackageQueryData = new Zend_Session_Namespace('sessionPackageQueryData');
if (!empty($sessionPackageQueryData->searchData)) {
$packageSearchResult = $getData;
$this->view->packageSearchResult = $packageSearchResult;
} else {
//$this->_redirect('/packagesearch');
}
$sessionPackageSearchData = new Zend_Session_Namespace('sessionPackageSearchData');
$sessionPackageSearchData->searchData = $getData;
//echo "<pre>";print_r($sessionPackageQueryData->searchData);
$roominfojson = json_encode($roomjson);
$agentsysID = $this->intLoggedinUserId;
############ StartDate ###############
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
$data = array(
'PlanBookingId' => $planbookingID,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'InclMask' => $InclMask,
'DestinationPlaces' => isset($going_to_cityname) ? $going_to_cityname : '',
'DestinationPlacesSysId' => isset($going_to_cityid) ? (int) $going_to_cityid : 0,
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'Cities' => $citiesText . $going_to_cityname,
'PlanType' => 5,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'MinPax' => $nooftraveler,
'RoomInfoJson' => $roominfojson,
'StartDate' => isset($plan_start_date) ? $plan_start_date : '',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 1
);
if (empty($TPSysId)) {
//add search history data for package modify
$historyData = array(
'TPSysId' => $TPSysId,
'AgencySysId' => $agencySysID,
'AgentSysId' => $agentsysID,
'CustomerSysId' => isset($customerID) ? $customerID : '',
'PlanType' => 5,
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'DestinationPlaces' => isset($going_to_cityname) ? $going_to_cityname : '',
'DestinationPlaceSysId' => isset($going_to_cityid) ? $going_to_cityid : '',
'PackTypeMask' => $PackTypeMask,
'InclusionMark' => $InclMask,
'Rooms' => $getData['roomlp'],
'TotAdultCount' => $TotAdultCount,
'TotChildCount' => $TotChildCount,
'TotInfantCount' => 0,
'PriceRangeFrom' => $min_price,
'PriceRangeTo' => $max_price,
'AdditionalSrvMark' => '',
'StartDate' => isset($plan_start_date) ? $plan_start_date : $createDate,
'ValidTill' => isset($plan_enddate_date) ? $plan_enddate_date : $createDate,
'Rating' => 5,
"SearchDate" => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 1,
);
$this->_crmcusttravelplanhistory = new Travel_Model_CRM_CustomerTravelPlanSearchHistory();
$this->_crmcusttravelplanhistory->addCustomerTravelPlanSearchHistory($historyData);
//end of add search history data for package modify
$TPSysId = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$sessionPackageSearchData->searchData['TPSysId'] = $TPSysId;
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $TPSysId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
}
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $TPSysId;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
$response = array('success' => true, 'msg' => 'Package Search.', 'TPSysId' => $TPSysId);
echo json_encode($response);
exit;
}
public function getStateDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$countryId = $this->getRequest()->getParam('countryId');
$this->view->countryId = $this->_HtmlPurifier->filter($countryId);
$this->view->type = 'state';
$this->render('ajaxDropdown');
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function getCityDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$countryId = $this->getRequest()->getParam('countryId');
$stateId = $this->getRequest()->getParam('stateId');
$this->view->countryId = $this->_HtmlPurifier->filter($countryId);
$this->view->stateId = $this->_HtmlPurifier->filter($stateId);
$this->view->type = 'city';
$this->render('ajaxDropdown');
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function savepkgproposalAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
$createDate = date('Y-m-d');
$newcost = $getData['newcost'];
$leadID = $getData['leadID'] ? $getData['leadID'] : '';
$travelplanID = $getData['travelplanID'];
$customerID = $getData['customerID'];
$custemail = $getData['custemail'];
$custphone = $getData['custphone'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (empty($customerID)) {
######### Register New Customer ###########
$date = date('Y-m-d');
$userArray = array(
'EmailId' => $custemail,
'PrimaryContactNumber' => $custphone,
'FullName' => '',
'FirstName' => '',
'ActiveDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
$customerID = $this->_crmcustomerObj->addCustomer($userArray);
$agencyuserArray = array(
'AgencySysId' => $agencySysId,
'CRMCustSysId' => $customerID,
'EmailId' => $custemail,
'Title' => '1',
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'IsEmployee' => '0',
'Contacts' => $custphone,
'JoinDate' => $date,
'UserName' => '',
'FirstName' => '',
'LastName' => '',
'RegisterDate' => $date,
'IsApproved' => '0',
);
### Insert Record in to Agency Table as well ########
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
}
$travelplandata = $this->_crmcusttravelplan->GetTravelPlan($travelplanID);
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($leadID, 'Query');
$roominfojson = $gettplandataforcustomer[0]['RoomInfoJson'] ? json_decode($gettplandataforcustomer[0]['RoomInfoJson']) : '';
$totaladult = 0;
$totalchild = 0;
foreach ($roominfojson as $roomarray) {
$adult = $roomarray->Adult;
$totaladult = $totaladult + $adult;
$child = $roomarray->Child;
$totalchild = $totalchild + $child;
}
$totaltraveller = $totaladult + $totalchild;
$planprice = $this->_crmcusttravelplan->GetTravelPlanCost($travelplanID, $gettplandataforcustomer[0]['RoomInfoJson']);
$finalprice = round($planprice['FinalCost']);
if (!empty($planprice[0]['ExcludedPercent'])) {
$seachincludestr = 'Exclude ' . $planprice[0]['ExcludedPercent'] . '%';
} else {
$seachincludestr = '';
}
$perpersonprice = $finalprice / $totaladult;
if ($totalchild > 0) {
$kidperpriice = $finalprice - $perpersonprice;
} else {
$kidperpriice = 0;
}
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
if (!empty($leadID)) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => 2
);
}
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
$planbookingID = 'Q/' . date('y');
$stratdate = $travelplandata[0]['StartDate'];
$ValidTill = $travelplandata[0]['ValidTill'];
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($leadID);
$versionnum = $getlatestversion[0]['VersionId'];
$agentsysID = $this->intLoggedinUserId;
$customertravelpaln = array(
'VersionId' => $versionnum + 1,
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $leadID,
'AgencySysId' => $agencySysId,
'AgentSysId' => $agentsysID,
'StatusType' => 4,
'CustomerSysId' => $customerID,
'PlanType' => 5,
'MinPax' => $travelplandata[0]['MinPax'],
'PackRangeType' => $travelplandata[0]['PackRangeType'],
'Title' => $travelplandata[0]['Title'],
'EconomyMask' => $travelplandata[0]['EconomyMask'],
'PackTypeMask' => $travelplandata[0]['PackTypeMask'],
'InclCatMask' => $travelplandata[0]['InclCatMask'],
'InclMask' => $travelplandata[0]['InclMask'],
'ExclusionMask' => $travelplandata[0]['ExclusionMask'],
'PackSpecType' => $travelplandata[0]['PackSpecType'],
'SeasonMask' => $travelplandata[0]['SeasonMask'],
'GeoType' => $travelplandata[0]['GeoType'],
'IsFixDatePlan' => $travelplandata[0]['IsFixDatePlan'],
'IsFixPlan' => $travelplandata[0]['IsFixPlan'],
'Details' => $travelplandata[0]['Details'],
'ImageTN' => $travelplandata[0]['ImageTN'],
'ImgForList' => $travelplandata[0]['ImgForList'],
'ImgeDetails' => $travelplandata[0]['ImgeDetails'],
'StartDate' => $stratdate->format('Y-m-d'),
'ValidTill' => $ValidTill->format('Y-m-d'),
'Price' => $travelplandata[0]['Price'] ? $travelplandata[0]['Price'] : 0,
'CurrencyType' => $travelplandata[0]['CurrencyType'],
'DiscountMsg' => $travelplandata[0]['DiscountMsg'],
'DiscountType' => $travelplandata[0]['DiscountType'],
'DiscountVal' => $travelplandata[0]['DiscountVal'],
'NetPrice' => $newcost,
'MinPrice' => $travelplandata[0]['MinPrice'],
'TotalMinDays' => $travelplandata[0]['TotalMinDays'],
'TotalMaxDays' => $travelplandata[0]['TotalMaxDays'],
'Hotels' => $travelplandata[0]['Hotels'],
'PopularPlaces' => $travelplandata[0]['PopularPlaces'],
'Cities' => $travelplandata[0]['Cities'],
'Countries' => $travelplandata[0]['Countries'],
'IsInsuranceExist' => $travelplandata[0]['TravelInsurance'],
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'],
'IsActive' => $travelplanIetnaryData[$i]['IsActive'],
);
$lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : 0,
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : '',
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'AdultPax' => 0,
'ChildPax' => 0,
'InfantPax' => 0,
'PetPax' => 0,
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCostGen'] ? $tplanitenaryaccomdata[$k]['TotalCostGen'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => 0,
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
$tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAir($tplanitenayvalues);
if (!empty($tpitenaryAirdata)) {
######### Add Air Data #######
for ($i = 0; $i < count($tpitenaryAirdata); $i++) {
$existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintairID, $travelpanitenary);
$travelitenaryaccomairArray = array(
'TPIntSysId' => $tpitenaryAirdata[$getkeyvalue] ? $tpitenaryAirdata[$getkeyvalue] : 0,
'SeqId' => $tpitenaryAirdata['SeqId'] ? $tpitenaryAirdata['SeqId'] : 0,
'AgencySysId' => $tpitenaryAirdata['AgencySysId'] ? $tpitenaryAirdata['AgencySysId'] : 0,
'Cost' => $tpitenaryAirdata['Cost'] ? $tpitenaryAirdata['Cost'] : 0,
'FlightNumber' => $tpitenaryAirdata['FlightNumber'] ? $tpitenaryAirdata['FlightNumber'] : 0,
'AirlineSysId' => $tpitenaryAirdata['AirlineSysId'] ? $tpitenaryAirdata['AirlineSysId'] : 0,
'ICSourceSysId' => $tpitenaryAirdata['ICSourceSysId'] ? $tpitenaryAirdata['ICSourceSysId'] : 0,
'IsFromAgency' => $tpitenaryAirdata['IsFromAgency'] ? $tpitenaryAirdata['IsFromAgency'] : 0,
'LocalFromTime' => $tpitenaryAirdata['LocalFromTime'] ? $tpitenaryAirdata['LocalFromTime'] : 0,
'LocalToTime' => $tpitenaryAirdata['LocalToTime'] ? $tpitenaryAirdata['LocalToTime'] : 0,
'FromUTCTime' => $tpitenaryAirdata['FromUTCTime'] ? $tpitenaryAirdata['FromUTCTime'] : 0,
'ToUTCTime' => $tpitenaryAirdata['ToUTCTime'] ? $tpitenaryAirdata['ToUTCTime'] : 0,
'FlightCabinClass' => $tpitenaryAirdata['FlightCabinClass'] ? $tpitenaryAirdata['FlightCabinClass'] : 0,
'AdultPax' => $tpitenaryAirdata['AdultPax'] ? $tpitenaryAirdata['AdultPax'] : 0,
'ChildPax' => $tpitenaryAirdata['ChildPax'] ? $tpitenaryAirdata['ChildPax'] : 0,
'InfentPax' => $tpitenaryAirdata['InfentPax'] ? $tpitenaryAirdata['InfentPax'] : 0,
'TotalPax' => $tpitenaryAirdata['TotalPax'] ? $tpitenaryAirdata['TotalPax'] : 0,
'IsDirect' => $tpitenaryAirdata['IsDirect'] ? $tpitenaryAirdata['IsDirect'] : 0,
'DayLightSavingDiff' => $tpitenaryAirdata['DayLightSavingDiff'] ? $tpitenaryAirdata['DayLightSavingDiff'] : 0,
'FlyingMinutes' => $tpitenaryAirdata['FlyingMinutes'] ? $tpitenaryAirdata['FlyingMinutes'] : 0,
'SourcePlaceSysId' => $tpitenaryAirdata['SourcePlaceSysId'] ? $tpitenaryAirdata['SourcePlaceSysId'] : 0,
'DestPlaceSysId' => $tpitenaryAirdata['DestPlaceSysId'] ? $tpitenaryAirdata['DestPlaceSysId'] : 0,
'SourceAirportCode' => $tpitenaryAirdata['SourceAirportCode'] ? $tpitenaryAirdata['SourceAirportCode'] : 0,
'DestAirportCode' => $tpitenaryAirdata['DestAirportCode'] ? $tpitenaryAirdata['DestAirportCode'] : 0,
'AirportHaultMinutes' => $tpitenaryAirdata['AirportHaultMinutes'] ? $tpitenaryAirdata['AirportHaultMinutes'] : 0,
'StopCount' => $tpitenaryAirdata['StopCount'] ? $tpitenaryAirdata['StopCount'] : 0,
'Stops' => $tpitenaryAirdata['Stops'] ? $tpitenaryAirdata['Stops'] : 0,
'Rating' => $tpitenaryAirdata['Rating'] ? $tpitenaryAirdata['Rating'] : 0,
'FllightFeatureMask' => $tpitenaryAirdata['FllightFeatureMask'] ? $tpitenaryAirdata['FllightFeatureMask'] : 0,
'UpdatedByISSysId' => $tpitenaryAirdata['UpdatedByISSysId'] ? $tpitenaryAirdata['UpdatedByISSysId'] : 0,
'CreatedByISSysId' => $tpitenaryAirdata['CreatedByISSysId'] ? $tpitenaryAirdata['CreatedByISSysId'] : 0,
'ImageTN' => $tpitenaryAirdata['ImageTN'] ? $tpitenaryAirdata['ImageTN'] : 0,
'ImgForList' => $tpitenaryAirdata['ImgForList'] ? $tpitenaryAirdata['ImgForList'] : 0,
'ImgeDetails' => $tpitenaryAirdata['ImgeDetails'] ? $tpitenaryAirdata['ImgeDetails'] : 0,
'UpdateDate' => $tpitenaryAirdata['UpdateDate'] ? $tpitenaryAirdata['UpdateDate'] : 0,
'CreateDate' => $tpitenaryAirdata['CreateDate'] ? $tpitenaryAirdata['CreateDate'] : 0,
'ApproveBy' => $tpitenaryAirdata['ApproveBy'] ? $tpitenaryAirdata['ApproveBy'] : 0,
'ApprovalDate' => $tpitenaryAirdata['ApprovalDate'] ? $tpitenaryAirdata['ApprovalDate'] : 0,
'IsApproved' => $tpitenaryAirdata['IsApproved'] ? $tpitenaryAirdata['IsApproved'] : 0,
'IsActive' => $tpitenaryAirdata['IsActive'] ? $tpitenaryAirdata['IsActive'] : 0,
'IsMarkForDel' => $tpitenaryAirdata['IsMarkForDel'] ? $tpitenaryAirdata['IsMarkForDel'] : 0,
'encodedata' => $tpitenaryAirdata['encodedata'] ? $tpitenaryAirdata['encodedata'] : 0,
);
#################### Insert Records in Air Table #######################
}
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenrayEvents[$k]['Sequence'] ? $tpitenrayEvents[$k]['Sequence'] : 0,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? $tpitenrayEvents[$k]['AgencySysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? $tpitenrayEvents[$k]['Title'] : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? $tpitenrayEvents[$k]['Type'] : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? $tpitenrayEvents[$k]['CityId'] : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? $tpitenrayEvents[$k]['Cost'] : 0,
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'] ? $tpitenrayEvents[$k]['IsActive'] : 1,
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
);
$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_crmcustomertravelItenaryPlaces->addCustomerTravelItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$travelitenraysightssing = $this->_crmcustomertravelSightSeeing->addCustomerTravelItenarySightSeeing($tpitenraysightseeingArray);
}
}
$travelplanmarketPrice = $this->_crmcusttravelplan->GetTravelMarketPrice($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelMarketPlaces->addCustomerTravelMarketRate($travelmarketpriceArray);
}
}
// $tpitenarytrans = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
// $tpitenaryrules = $this->_crmcusttravelplan->GetTravelPlanItenaryRules($tplanitenayvalues);
$tpitenarysightseeing = $this->_crmcusttravelplan->GetTravelPlanSightSeeing($tplanitenayvalues);
// $tpitenraytermscond = $this->_crmcusttravelplan->GetTravelPlanTerms($tplanitenayvalues);
// $tpitenarytrnasdaywise = $this->_crmcusttravelplan->GetTravelPlanTransDaywise($tplanitenayvalues);
################# Send Mail to Customer ##############
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName : '';
$primarycontact = $sessionLogin_user->PrimaryContactNumber ? $sessionLogin_user->PrimaryContactNumber : '';
$destination_places = $gettplandataforcustomer[0]['DestinationPlaces'];
$pkg_start_date = $gettplandataforcustomer[0]['StartDate'];
$pkgstartdate = $pkg_start_date->format('Y-m-d');
$QueryID = $gettplandataforcustomer[0]['PlanBookingId'] . '/' . $gettplandataforcustomer[0]['TPSysId'];
$path = $_SERVER['SERVER_NAME'] . '/public/assets/images/logotripsbank.jpg';
$secureCode = Catabatic_ValidateCustomer::secureCode($tpproposalID, 1);
$bodyText = '</table>
</body>
</html>';
$bodyText .= '<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #e5e5e5;">
<tr>
<td align="center" style="padding:10px 0px;">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" align="left" valign="top">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle" style="border:1px solid #e3dfd8; padding:15px 0px;">
<img src="http://st.tb.tripsbank.com/public/assets/images/logotripsbank.jpg" />
</td>
</tr>
</table>
</td>
<td width="67%" align="right" valign="top">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" style="border:1px solid #e3dfd8; padding:15px; background:#fafafa; color:#333333; font:normal 14px/20px Arial, Helvetica, sans-serif;">Name : ' . $firstname . '<br />
Contact Number : ' . $primarycontact . '</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="font:normal 14px/20px Arial, Helvetica, sans-serif; padding:15px 0px; color:#333333;">Dear ' . $sessionLogin_lead_customer->FirstName . '<br /><br />
As per your request, we are forwarding itineraries For ' . $destination_places . ' Package on ' . $pkgstartdate . '</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="background:#d9edf7; border-bottom:1px solid #bce8f1; border-top:1px solid #bce8f1; padding:15px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="68%" align="left" valign="top" style="color:#31708f; font:normal 14px/20px Arial, Helvetica, sans-serif;"><strong>Query Id: ' . $QueryID . '</strong><br />
<strong>Destination:' . $destination_places . '</strong></td>
<td width="32%" align="right" valign="top" style="color:#31708f; font:normal 14px/20px Arial, Helvetica, sans-serif;">Total Traveler | ' . $totaltraveller . '</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="padding:20px 0px;">
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="background:#428bca;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" height="40" align="left" valign="middle" style="color:#ffffff; font:normal 15px Arial, Helvetica, sans-serif;"><strong>Package : ' . $destination_places . ' 5 Nights 6 Days</strong></td>
<td width="50%" height="40" align="right" valign="middle" style="color:#ffffff; font:normal 15px Arial, Helvetica, sans-serif;">Fare : ' . $newcost . '</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" style="border:1px solid #428bca; padding:10px 0px;"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Trip Start Date:</strong> ' . $pkgstartdate . '</td>
<td width="50%" height="30">' . $seachincludestr . '</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Price Per Adult:</strong> ' . $perpersonprice . '</td>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><strong>Price Per Kid:</strong> ' . $kidperpriice . '</td>
</tr>
<tr>
<td height="30" align="left" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"> </td>
</tr>
<tr>
<td height="30" align="left" valign="middle"> </td>
<td height="30" align="right" valign="middle" style="color:#333333; font:normal 14px Arial, Helvetica, sans-serif;"><a href=' . $_SERVER['SERVER_NAME'] . '/publicpackage/view-customer-final-package/code/' . $secureCode . '/id/' . $tpproposalID . ' style="color:#31708f; font:normal 14px Arial, Helvetica, sans-serif;">Book Now</a> | <a href="#" style="color:#31708f; font:normal 14px Arial, Helvetica, sans-serif;">Enquire</a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>';
$bodyText .= '<tr>
<td style="padding:15px 25px 15px 25px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" style="color:#333333; font-size:12px; padding-top:5px;">*This Proposal is valid by till date ' . $ValidTill->format('Y-m-d h:i:s') . '</td>
</tr>
<tr>
<td align="left"><strong>Regards-</strong><br/>' . $firstname . '</td>
<td align="right"><strong>Technology By - globaltravelexchange.com</strong></td>
</tr>
</table>
</td>
</tr></table>
</body>
</html>';
$emailId = trim($custemail);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $tpproposalID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $customerID);
echo 'Email has sent to customer';
} catch (Exception $err) {
print_r($err, true);
}
}
function savepkgproposalwithleadAction() {
// Network packagerelated code check later
// die('ppp');
// error_reporting(E_ALL);
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ProposalExpiryDays = $sessionLogin_user->agencyDetails['ProposalExpiryDays'];
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$agentsysID = $this->intLoggedinUserId;
$objPackage = new Travel_Model_TblPackage();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo "<pre>";print_r($getData);die;
$createDate = date('Y-m-d H:i:s');
$package_flightdetails = isset($_SESSION['package_flightdetails']) ? $_SESSION['package_flightdetails'] : '';
$packid = isset($getData['packid']) ? $getData['packid'] : 0;
$going_from_cityid = isset($getData['dipartureCity']) ? $getData['dipartureCity'] : 0; // will come from popup
$displayTCS = isset($getData['displayTCS']) ? $getData['displayTCS'] : 0; // will come from popup
$TcsTaxSysId = isset($getData['TcsTaxSysId']) ? $getData['TcsTaxSysId'] : array();
$Isclipboard = isset($getData['Isclipboard']) ? $getData['Isclipboard'] : 0;
$IsSendMail = isset($getData['IsSendMail']) ? $getData['IsSendMail'] : 0;
$IsSendSms = isset($getData['IsSendSms']) ? $getData['IsSendSms'] : 0;
$isShareWithPrice = !empty($getData['isShareWithPrice']) ? $getData['isShareWithPrice'] : array();
$IsShareWithGST = isset($getData['GSTIncluded']) ? $getData['GSTIncluded'] : 0;
$isShareWithFlight = 0;
$ShareCurrencyArr = explode('_', $getData['ShareCurrency']);
$displayExchangeRate = (isset($getData['displayExchangeRate']) && !empty($getData['displayExchangeRate'])) ? (float) $getData['displayExchangeRate'] : 1;
$ExchangeRate = isset($getData['ExchangeRate']) ? $getData['ExchangeRate'] : array();
$ShareWithComponentFlightVisa = isset($getData['ShareWithComponent']) ? $getData['ShareWithComponent'] : 0;
$ShareBaseComponentWise = isset($getData['ShareBaseComponentWise']) ? $getData['ShareBaseComponentWise'] : array();
$EmailTemplateType = $getData['EmailTemplateType'];
$EmailTemplateColor = $getData['EmailTemplateColor'];
$IsFromGTXNetwork = isset($getData['IsFromGTXNetwork']) ? $getData['IsFromGTXNetwork'] : 0;
$GTXNetworkAgencySysId = isset($getData['GTXNetworkAgencySysId']) ? $getData['GTXNetworkAgencySysId'] : 0;
$travelplanID = isset($getData['travelplanID']) ? $getData['travelplanID'] : 0;
$leadID = $TPSysId = isset($getData['TPSysId']) ? $getData['TPSysId'] : 0;
$ccemail = isset($getData['ccemail']) ? $getData['ccemail'] : '';
$custemail = isset($getData['custemail']) ? $getData['custemail'] : '';
$custphone = isset($getData['custphone']) ? $getData['custphone'] : '';
$pricerange = isset($getData['pricerange']) ? $getData['pricerange'] : 0;
$aboutpackage = isset($getData['aboutpackage']) ? $getData['aboutpackage'] : '';
$SACCode = isset($getData['sac_code']) ? $getData['sac_code'] : 440063;
$gsttype = isset($getData['gsttype']) ? $getData['gsttype'] : 0;
$TourCatType = isset($getData['TourCatType']) ? $getData['TourCatType'] : '';
$emailsubject = isset($getData['emailsubject']) ? $getData['emailsubject'] : '';
$TourCatTypeId = isset($getData['TourCatTypeId']) ? $getData['TourCatTypeId'] : '';
$proposalEmailFrom = (isset($getData['senderEmailID']) && !empty($getData['senderEmailID'])) ? $getData['senderEmailID'] : trim($sessionLogin_user->EmailId);
$MarkupArray = isset($getData['MarkUp']) ? $getData['MarkUp'] : array();
$discountValue = isset($getData['discountValue']) ? $getData['discountValue'] : array();
$mainpricetype = isset($getData['pricetype']) ? $getData['pricetype'] : '';
$aId = isset($getData['aId']) ? (int) $getData['aId'] : 0;
$selectedCustomerId = isset($getData['selectedCustomerId']) ? (int) base64_decode($getData['selectedCustomerId']) : 0;
$destPlaceArr = isset($getData['DestinationPlaces']) ? json_decode(base64_decode($getData['DestinationPlaces']), true) : '';
$ShareWithTCSPackage = isset($TcsTaxSysId[5]) ? (int) $TcsTaxSysId[5] : 0;
$ShareWithTCSFlight = isset($TcsTaxSysId[1]) ? (int) $TcsTaxSysId[1] : 0;
$ShareWithTCSVisa = isset($TcsTaxSysId[6]) ? (int) $TcsTaxSysId[6] : 0;
$destinationIds = 0;
$destinationValues = $destinationValueswp = '';
if (isset($destPlaceArr) && !empty($destPlaceArr)) {
foreach ($destPlaceArr as $destIds => $destValues) {
$destIdsArr[] = $destIds;
$destValuesArr[] = $destValues;
}
$destinationIds = implode(',', $destIdsArr);
$destinationValues = implode(', ', $destValuesArr);
$destinationValueswp = strtoupper(implode(' + ', $destValuesArr));
}
$HotelVoucherStatus = $FlightVoucherStatus = $SightseeingVoucherStatus = $TransferVoucherStatus = $InsuranceVoucherStatus = $MealVoucherStatus = $OtherVoucherStatus = 0;
$TourTypeId = '';
if (isset($TourCatTypeId) && !empty($TourCatTypeId)) {
$TourTypeId = $TourCatTypeId[0];
}
$TourType = '';
$EconomyMask = '';
if (isset($TourCatType) && !empty($TourCatType)) {
$TourCatType = explode("_", $TourCatType);
$TourType = $TourCatType[0];
$EconomyMask = $TourCatType[1];
}
$MpType = isset($getData['MpType']) ? (int) $getData['MpType'] : 0;
$MarketPlaceId = isset($MpType) ? $MpType : 1;
$isPriceShared = ($mainpricetype == 'wp') ? 1 : 0;
if (strlen($aboutpackage) > 4000) {
echo json_encode(array('status' => 'failed', 'message' => 'Greeting Message Limit Exceed!!'));
exit;
}
$travelplandata = $this->_crmcusttravelplan->GetTravelPlan($travelplanID);
if (count($travelplandata) == 0) {
echo json_encode(array('status' => 'failed', 'message' => 'Package Unpublish'));
exit;
}
$ShareCurrency = !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'];
$SupplierSysId = isset($travelplandata[0]['SupplierSysId']) ? $travelplandata[0]['SupplierSysId'] : '0';
$MasterRefId = (isset($travelplandata[0]['MasterRefId']) && $travelplandata[0]['MasterRefId'] > 0) ? $travelplandata[0]['MasterRefId'] : $travelplanID;
$IsCommonFlightPackage = !empty($travelplandata[0]['IsCommonFlightPackage']) ? (int) $travelplandata[0]['IsCommonFlightPackage'] : 0;
$IsFixedDeparturePackage = ($travelplandata[0]['IsFixedDeparturePackage'] == 1 && $IsCommonFlightPackage == 0) ? 1 : 0;
$updateIsFixedDeparturePackage = !empty($travelplandata[0]['IsFixedDeparturePackage']) ? $travelplandata[0]['IsFixedDeparturePackage'] : 0;
$InternalRemarks = !empty($travelplandata[0]['InternalRemarks']) ? $travelplandata[0]['InternalRemarks'] : '';
$travelplanIetnaryData = $this->_crmcusttravelplan->GetTravelPlanItenary($travelplanID);
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($leadID, 'Query');
$customerID = (int) $gettplandataforcustomer[0]['CustomerSysId'];
$custemail = trim($gettplandataforcustomer[0]['EmailId']);
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerById($customerID);
$totalDaysNightsArr = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->getPackageTotalNoOfDays($travelplanIetnaryData);
$totalDays = $totalDaysNightsArr['totaldays'];
$totalNight = $totalDaysNightsArr['totalnights'];
$pkgCheckInDate = $getData['pkgCheckInDate'];
$pkgCheckOutDate = $getData['pkgCheckOutDate'];
if (!empty($pkgCheckInDate)) {
$explode_trip_start = explode('/', $pkgCheckInDate);
$main_trip_start_date = $explode_trip_start[2] . '-' . $explode_trip_start[1] . '-' . $explode_trip_start[0];
} else {
$main_trip_start_date = date('Y-m-d');
}
$tripdate = $main_trip_start_date;
;
$main_trip_end_date = date('Y-m-d', strtotime($main_trip_start_date . " +" . $totalNight . " days"));
$MarkUpOnGTXNetworkPackage = 0;
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$supplierArray = $this->_crmcustomerObj->getSupplierSysId($GTXNetworkAgencySysId);
$SupplierSysId = isset($supplierArray[0]['SupplierSysId']) ? $supplierArray[0]['SupplierSysId'] : '0';
$getAgencyDetail = $this->_agencyObj->getAgencyUserList($agencySysId); //to get network package agency detail
$MarkUpOnGTXNetworkPackage = $getAgencyDetail['MarkUpOnGTXNetworkPackage'];
}
if ((int) $IsB2BAgent == 1 && $selectedCustomerId > 0) {
$getB2bAgencySysId = $this->_crmcusttravelplan->getB2bAgencySysId($selectedCustomerId);
$GTXNetworkAgencySysId = isset($getB2bAgencySysId[0]['AgencySysId']) ? $getB2bAgencySysId[0]['AgencySysId'] : 0;
}
$tripaddress = $destinationValues ? $destinationValues : '';
if (isset($leadsource) && !is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$leadsource = 'Agency';
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$leadsource = 'GTX Network';
}
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($agencySysId, $leadsource); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$totaladult = 0;
$totalchild = 0;
$totalInfant = 0;
$Adultextrabed = $SingleOAdult = $Childextrabed = $Childwithoutbed = 0;
$roomjson = array();
if (isset($getData['PackageTypePS']) && $getData['PackageTypePS'] == 'PS') {
for ($k = 1; $k <= $sessionPackageSearchData->searchData['roomlp']; $k++) {
$roomjson[$k]['Adult'] = $sessionPackageSearchData->searchData['adult_' . $k];
$roomjson[$k]['adult_type'] = $sessionPackageSearchData->searchData['adult_type_' . $k];
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $sessionPackageSearchData->searchData['adultcl_extrabed_' . $k . '_3'];
}
$totaladult = $totaladult + $roomjson[$k]['Adult'];
$roomjson[$k]['Child'] = $sessionPackageSearchData->searchData['child_' . $k];
$totalchild = $totalchild + $roomjson[$k]['Child'];
$roomjson[$k]['Infant'] = $sessionPackageSearchData->searchData['infant_' . $k];
$totalInfant = $totalInfant + $roomjson[$k]['Infant'];
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $sessionPackageSearchData->searchData['child_age_' . $k . '_' . $j];
$roomjson[$k]['ChildBedType_' . $j] = $sessionPackageSearchData->searchData['child_extrabed_' . $k . '_' . $j];
if (trim($roomjson[$k]['ChildBedType_' . $j]) == 'extrabed') {
$Childextrabed++;
}
if (trim($roomjson[$k]['ChildBedType_' . $j]) == 'withoutbed') {
$Childwithoutbed++;
}
}
$roomjson[$k]['departuredate'] = $pkgCheckInDate;
$roomjson[$k]['returndate'] = $pkgCheckOutDate;
if ($roomjson[$k]['Adult'] == 1 && $roomjson[$k]['adult_type'] == 'single') {
$SingleOAdult++;
}
if (isset($roomjson[$k]['AdultBedType']) && trim($roomjson[$k]['AdultBedType']) == 'extrabed') {
$Adultextrabed++;
}
}
$totaltraveller = $sessionPackageSearchData->searchData['travelers'];
} else {
$roomlp = $getData['roomlp'];
for ($k = 1; $k <= $roomlp; $k++) {
$roomjson[$k]['Adult'] = $getData['adult_' . $k];
if (isset($getData['adult_type_' . $k]) && $getData['adult_type_' . $k] != '') {
$roomjson[$k]['adult_type'] = $getData['adult_type_' . $k];
} else {
if ($roomjson[$k]['Adult'] == 1) {
$roomjson[$k]['adult_type'] = 'single';
} else if ($roomjson[$k]['Adult'] == 2) {
$roomjson[$k]['adult_type'] = 'twin';
} else if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['adult_type'] = 'triple';
}
}
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $getData['adultcl_extrabed_' . $k . '_3'];
}
$totaladult = $totaladult + $roomjson[$k]['Adult'];
$roomjson[$k]['Child'] = $getData['child_' . $k];
$totalchild = $totalchild + $roomjson[$k]['Child'];
$roomjson[$k]['Infant'] = $getData['infant_' . $k];
$totalInfant = $totalInfant + $roomjson[$k]['Infant'];
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $getData['child_age_' . $k . '_' . $j];
$roomjson[$k]['ChildBedType_' . $j] = $getData['child_extrabed_' . $k . '_' . $j];
}
$roomjson[$k]['departuredate'] = $pkgCheckInDate;
$roomjson[$k]['returndate'] = $pkgCheckOutDate;
if ($roomjson[$k]['Adult'] == 1 && $roomjson[$k]['adult_type'] == 'single') {
$SingleOAdult++;
}
if (isset($roomjson[$k]['AdultBedType']) && trim($roomjson[$k]['AdultBedType']) == 'extrabed') {
$Adultextrabed++;
}
if (trim($roomjson[$k]['ChildBedType_1']) == 'extrabed') {
$Childextrabed++;
}
if (trim($roomjson[$k]['ChildBedType_2']) == 'extrabed') {
$Childextrabed++;
}
if (trim($roomjson[$k]['ChildBedType_1']) == 'withoutbed') {
$Childwithoutbed++;
}
if (trim($roomjson[$k]['ChildBedType_2']) == 'withoutbed') {
$Childwithoutbed++;
}
}
$totaltraveller = (int) $totaladult + (int) $totalchild + $totalInfant;
}
$RoomInfoJson = json_encode($roomjson);
if (empty($totaltraveller)) {
$totaltraveller = 2;
}
$paxCount = (int) $totaladult;
if ($IsB2BAgent == 1) {
$MarketPlaceId = 2;
}
$flightCost = 0;
/* Added by Mangal For Fix departure flight inventory Start 20/05/2022 */
$inventory = $objPackage->getFromDestinationFixedInventoryByDateAndDestination($MasterRefId, $main_trip_start_date, $going_from_cityid, $IsCommonFlightPackage);
$FlightExchangeRate = (isset($ExchangeRate[1]) && !empty($ExchangeRate[1])) ? (float) $ExchangeRate[1] : 1;
if (isset($inventory) && !empty($inventory)) {
$FlightMarkupType = isset($inventory[0]['MarkupType']) ? (float) $inventory[0]['MarkupType'] : 0;
$AdultCost = isset($inventory[0]['AdultCost']) ? (float) $inventory[0]['AdultCost'] : 0;
$InfantCost = isset($inventory[0]['InfantCost']) ? (float) $inventory[0]['InfantCost'] : 0;
$B2CAdultMarkup = isset($inventory[0]['B2CAdultMarkup']) ? (float) $inventory[0]['B2CAdultMarkup'] : 0;
$B2CInfantMarkup = isset($inventory[0]['B2CInfantMarkup']) ? (float) $inventory[0]['B2CInfantMarkup'] : 0;
$B2BAdultMarkup = isset($inventory[0]['B2BAdultMarkup']) ? (float) $inventory[0]['B2BAdultMarkup'] : 0;
$B2BInfantMarkup = isset($inventory[0]['B2BInfantMarkup']) ? (float) $inventory[0]['B2BInfantMarkup'] : 0;
$FlightCurrencySysId = isset($inventory[0]['CurrencySysId']) ? (float) $inventory[0]['CurrencySysId'] : 1;
$flightAdultCost = ((float) (($AdultCost) * ($totaladult + $totalchild)));
$flightInfantCost = ((float) (($InfantCost) * $totalInfant));
if ($MarketPlaceId == 2) {
if ($FlightMarkupType == 2) {
$B2BAdultMarkup = ((float) $AdultCost * (float) $B2BAdultMarkup / 100);
$B2BInfantMarkup = ((float) $InfantCost * (float) $B2BInfantMarkup / 100);
}
$flightAdultMarkup = ((float) (($B2BAdultMarkup) * ($totaladult + $totalchild)));
$flightInfantMarkup = ((float) (($B2BInfantMarkup) * $totalInfant));
} else {
if ($FlightMarkupType == 2) {
$B2CAdultMarkup = ((float) $AdultCost * (float) $B2CAdultMarkup / 100);
$B2CInfantMarkup = ((float) $InfantCost * (float) $B2CInfantMarkup / 100);
}
$flightAdultMarkup = ((float) (($B2CAdultMarkup) * ($totaladult + $totalchild)));
$flightInfantMarkup = ((float) (($B2CInfantMarkup) * $totalInfant));
}
$flightCost = ($flightAdultCost + $flightInfantCost) * $FlightExchangeRate * $displayExchangeRate;
$flightMarkup = ($flightAdultMarkup + $flightInfantMarkup) * $FlightExchangeRate * $displayExchangeRate;
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$flightCost = (float) $flightCost + (float) $flightMarkup;
if ($MarkUpOnGTXNetworkPackage > 0) {
$flightMarkup = $flightCost * $MarkUpOnGTXNetworkPackage / 100;
} else {
$flightMarkup = 0;
}
}
$isShareWithFlight = 1;
} else if (!empty($package_flightdetails)) {
$flightType = isset($package_flightdetails['flightType']) ? (int) $package_flightdetails['flightType'] : 1;
if ($flightType == 2) {
$flightCost = $totalcost_wom_flight = is_array($package_flightdetails['total_cost']) ? array_sum($package_flightdetails['total_cost']) * $FlightExchangeRate * $displayExchangeRate : 0;
$flightMarkup = $total_markup = is_array($package_flightdetails['total_markup']) ? array_sum($package_flightdetails['total_markup']) * $FlightExchangeRate * $displayExchangeRate : 0;
$total_flight_gst = is_array($package_flightdetails['total_gst']) ? array_sum($package_flightdetails['total_gst']) * $FlightExchangeRate * $displayExchangeRate : 0;
$totalflightcost = is_array($package_flightdetails['grand_total']) ? array_sum($package_flightdetails['grand_total']) * $FlightExchangeRate * $displayExchangeRate : 0;
} else {
$flightCost = $totalcost_wom_flight = (float) isset($package_flightdetails['totalcost_wom']) ? $package_flightdetails['totalcost_wom'] * $FlightExchangeRate * $displayExchangeRate : 0;
$flightMarkup = $total_markup = (float) isset($package_flightdetails['total_markup']) ? $package_flightdetails['total_markup'] * $FlightExchangeRate * $displayExchangeRate : 0;
$total_flight_gst = (float) isset($package_flightdetails['total_gst']) ? $package_flightdetails['total_gst'] * $FlightExchangeRate * $displayExchangeRate : 0;
$totalflightcost = (float) isset($package_flightdetails['totalflightcost']) ? $package_flightdetails['totalflightcost'] * $FlightExchangeRate * $displayExchangeRate : 0;
}
$isShareWithFlight = 1;
}
$ShareCombinedPricing = (isset($isShareWithPrice[1]) && $isShareWithPrice[1] == 1) ? 0 : 1;
if ($isShareWithFlight == 0) {
$ShareCombinedPricing = 0;
}
$ShareCombinedPricingVisa = (isset($isShareWithPrice[6]) && $isShareWithPrice[6] == 1) ? 0 : 1;
if($ShareWithComponentFlightVisa == 1 || $IsPackageShareBaseCurrency == 1){
$ShareCombinedPricingVisa = 0;
$ShareCombinedPricing = 0;
}
/* Added by Mangal For Fix departure flight inventory End 20/05/2022 */
$totalactcost = $totalactmarkup = 0;
$search_going_to = isset($getData['search_going_to']) ? $getData['search_going_to'] : '';
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityid = $search_going_to_dest[0];
$going_to_cityname = $search_going_to_dest[1];
}
$search_going_f = isset($getData['search_going_f']) ? $getData['search_going_f'] : '';
$search_going_from = isset($getData['search_going_from']) ? $getData['search_going_from'] : '';
if (!empty($search_going_from)) {
$search_going_to_from = explode('__', $search_going_from);
$going_from_cityid = (isset($search_going_to_from[0]) && !empty($search_going_to_from[0])) ? $search_going_to_from[0] : (isset($inventory[0]['CityTitle']) ? $inventory[0]['DestinationSysId'] : 0);
$going_from_cityname = (isset($search_going_to_from[1]) && !empty($search_going_to_from[1])) ? $search_going_to_from[1] : (isset($inventory[0]['CityTitle']) ? $inventory[0]['CityTitle'] : 0);
}
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', @$getData['search_price_range']);
$min_price = $getData['search_price_range'] ? $search_price_range[0] : '';
$max_price = $getData['search_price_range'] ? $search_price_range[1] : '';
} else {
$min_price = 0;
$max_price = 0;
}
$planbookingID = 'Q/' . date('y');
$currentDate = date('Y-m-d H:i:s');
$PkgSellValidTill = (!is_null($ProposalExpiryDays) && $ProposalExpiryDays !== '') ? date('Y-m-d', strtotime($currentDate . ' + ' . (int) $ProposalExpiryDays . ' days')) : $travelplandata[0]['PkgSellValidTill']->format('Y-m-d');
$LeadSourceSysId = !empty($gettplandataforcustomer[0]['LeadSourceSysId']) ? $gettplandataforcustomer[0]['LeadSourceSysId'] : 0;
if ($GTXNetworkAgencySysId) {
$LeadSourceSysId = isset($leadsource) ? $leadsource : 0;
}
if (!empty($leadID)) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => 2,
// 'B2BAgencySysId' => (int) $GTXNetworkAgencySysId, // comment for frenchisee update id issue
'LeadSourceSysId' => (int) $LeadSourceSysId,
'IsOperationalLead' => 0,
'ExpectedClosureDate' => $main_trip_start_date,
'ExpectedValue' => $totalCost ? round($totalCost, 2) : 0,
);
if ((int) $GTXNetworkAgencySysId > 0 && $gettplandataforcustomer[0]['IsB2BProposal'] != 3) {
$updatetravelplan['B2BAgencySysId'] = (int) $GTXNetworkAgencySysId;
}
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
}
$planbookingID = 'Q/' . date('y');
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($leadID);
$versionnum = $getlatestversion[0]['VersionId'] ? $getlatestversion[0]['VersionId'] : 0;
$packRate = $objPackage->getPackRateRowWise($packid, $tripdate, $MarketPlaceId, $paxCount, $RoomInfoJson);
$packMPRate = $objPackage->getPackMPRate($packid, $paxCount, $tripdate, $MarketPlaceId);
$CurrencyHelperObj = Zend_Controller_Action_HelperBroker::getStaticHelper('Currency');
$baseCurrencySymbol = $CurrencyHelperObj->getLoggedInAgencyBaseCurrency();
$baseCurrencyId = $CurrencyHelperObj->getLoggedInAgencyBaseCurrencyId(); // agency's currency
$arrPkg['ShareCurrency'] = $baseCurrencyId . '_' . $baseCurrencySymbol;
$customerAgencySysId = $getcustomerdetails['AgencySysId'];
if ($packMPRate[0]['MarkType'] != 'FixedAmount' && $aId > 0 && $customerAgencySysId > 0) {
$arrPkgCost = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->getMarkPercentageForAgent($aId, $customerAgencySysId);
if ($arrPkgCost > 0) {
$packMPRate[0]['MarkPercent'] = $arrPkgCost;
}
}
$arrPkg['MasterTPId'] = $MasterRefId;
$arrPkgCost = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->GetAgencyCustomerTravelPlanCost($packid, $RoomInfoJson, $arrPkg, $packMPRate[0], $packRate[0], 1);
$IsPackageShareBaseCurrency = (isset($ShareBaseComponentWise[5])) ? (int) $ShareBaseComponentWise[5] : 0;
$PackageExchangeRate = (isset($ExchangeRate[5]) && !empty($ExchangeRate[5])) ? (float) $ExchangeRate[5] : 1;
$NetCost = $arrPkgCost['SourcingNetCost'] * (float) $PackageExchangeRate * $displayExchangeRate;
$AgencyMarkUp = $arrPkgCost['SourcingMarkUp'] * (float) $PackageExchangeRate * $displayExchangeRate;
$GSTApplicableOn = isset($gsttype[5]) ? $gsttype[5] : 0;
$packageCost = $NetCost + $AgencyMarkUp;
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$packageCost = (float) $packageCost;
if ($MarkUpOnGTXNetworkPackage > 0) {
$AgencyMarkUp = $packageCost * $MarkUpOnGTXNetworkPackage / 100;
$packageCost = (float) $packageCost + (float) $AgencyMarkUp;
} else {
$AgencyMarkUp = 0;
}
}
$AgencyMarkUpPackage = $AgencyMarkUp;
$AgencyExtraMarkUp = (isset($MarkupArray[5]) && !empty($MarkupArray[5])) ? (float) $MarkupArray[5] * $displayExchangeRate : 0;
$AgencyDiscount = (isset($discountValue[5]) && !empty($discountValue[5])) ? (float) $discountValue[5] * $displayExchangeRate : 0;
$intProductType = 9;
$intProductGeoType = 1; // 1 For Domestic, 2 For International
$arrInputData = array(
"GSTApplicableOn" => $GSTApplicableOn,
"intProductType" => $intProductType,
"intProductGeoType" => $intProductGeoType,
"Cost" => $packageCost,
"AgencyMarkUp" => $AgencyMarkUp,
"AgencyExtraMarkUp" => $AgencyExtraMarkUp,
"AgencyDiscount" => $AgencyDiscount
);
$arrGSTCalculations = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->calculateGST($arrInputData);
//echo "<pre>";print_r($arrGSTCalculations); die;
$GSTApplicableOnFlight = isset($gsttype[1]) ? $gsttype[1] : 0;
$arrFlightGSTCalculations = array();
$AgencyExtraMarkUpFlight = (isset($MarkupArray[1]) && !empty($MarkupArray[1])) ? (float) $MarkupArray[1] * $displayExchangeRate : 0;
$AgencyDiscountFlight = (isset($discountValue[1]) && !empty($discountValue[1])) ? (float) $discountValue[1] * $displayExchangeRate : 0;
if ($flightCost > 0) {
$arrInputFlightData = array(
"GSTApplicableOn" => $GSTApplicableOnFlight,
"intProductType" => 9,
"intProductGeoType" => 1,
"Cost" => (float) $flightCost + (float) $flightMarkup,
"AgencyMarkUp" => (float) $flightMarkup,
"AgencyExtraMarkUp" => $AgencyExtraMarkUpFlight,
"AgencyDiscount" => $AgencyDiscountFlight
);
$arrFlightGSTCalculations = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->calculateGST($arrInputFlightData);
}
/* Visa Cost Start */
$GSTApplicableOnVisa = isset($gsttype[6]) ? $gsttype[6] : 0;
$arrVisaGSTCalculations = array();
$AgencyExtraMarkUpVisa = (isset($MarkupArray[6]) && !empty($MarkupArray[6])) ? (float) $MarkupArray[6] * $displayExchangeRate : 0;
$AgencyDiscountVisa = (isset($discountValue[6]) && !empty($discountValue[6])) ? (float) $discountValue[6] * $displayExchangeRate : 0;
$VisaCost = isset($arrPkgCost['VisaCost']) ? (float) $arrPkgCost['VisaCost'] * $displayExchangeRate : 0;
$VisaMarkup = isset($arrPkgCost['VisaMarkup']) ? (float) $arrPkgCost['VisaMarkup'] * $displayExchangeRate : 0;
$TotalVisaServiceFee = isset($arrPkgCost['TotalVisaServiceFee']) ? (float) $arrPkgCost['TotalVisaServiceFee'] * $displayExchangeRate : 0;
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$VisaCost = $VisaCost + $VisaMarkup;
if ($MarkUpOnGTXNetworkPackage > 0) {
$VisaMarkup = $VisaCost * $MarkUpOnGTXNetworkPackage / 100;
} else {
$VisaMarkup = 0;
}
}
if ($VisaCost > 0) {
$arrInputVisaData = array(
"GSTApplicableOn" => $GSTApplicableOnVisa,
"intProductType" => 9,
"intProductGeoType" => 1,
"Cost" => (float) $VisaCost + (float) $VisaMarkup,
"AgencyMarkUp" => (float) $VisaMarkup,
"AgencyExtraMarkUp" => $AgencyExtraMarkUpVisa,
"AgencyDiscount" => $AgencyDiscountVisa
);
$arrVisaGSTCalculations = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->calculateGST($arrInputVisaData);
}
// echo"<pre>";print_r($arrVisaGSTCalculations);
/* Visa Cost Start */
$flightGST = isset($arrFlightGSTCalculations['GSTAmount']) ? $arrFlightGSTCalculations['GSTAmount'] : 0;
$flightPriceWithGST = isset($arrFlightGSTCalculations['AmountWithGST']) ? $arrFlightGSTCalculations['AmountWithGST'] : 0;
$flightTaxRate = isset($arrFlightGSTCalculations['TaxRate']) ? (float) $arrFlightGSTCalculations['TaxRate'] : 0;
$flightTaxType = isset($arrFlightGSTCalculations['TaxType']) ? (int) $arrFlightGSTCalculations['TaxType'] : 0;
$priceDetails = Zend_Controller_Action_HelperBroker::getStaticHelper('PackageSearch')->getPackageRateById($travelplanID, $gettplandataforcustomer);
$DiscountArrayServiceTax = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrGSTCalculations['AgencyDiscount'], $arrGSTCalculations['TaxRate']);
$DiscountArrayServiceTaxFlight = 0;
if (!empty($arrFlightGSTCalculations) && $arrFlightGSTCalculations['AgencyDiscount'] > 0) {
$DiscountArrayServiceTaxFlight = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrFlightGSTCalculations['AgencyDiscount'], $arrFlightGSTCalculations['TaxRate']);
}
$DiscountArrayServiceTaxVisa = 0;
if (!empty($arrVisaGSTCalculations) && $arrVisaGSTCalculations['AgencyDiscount'] > 0) {
$DiscountArrayServiceTaxVisa = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrVisaGSTCalculations['AgencyDiscount'], $arrVisaGSTCalculations['TaxRate']);
}
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrGSTCalculations['AgencyExtraMarkUp'], $arrGSTCalculations['TaxRate']);
$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable) ? $arrServiceTaxOnNetPayable : 0;
$MarkupArrayServiceTaxFlight = 0;
if (!empty($arrFlightGSTCalculations) && $arrFlightGSTCalculations['AgencyExtraMarkUp'] > 0) {
$MarkupArrayServiceTaxFlight = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrFlightGSTCalculations['AgencyExtraMarkUp'], $arrFlightGSTCalculations['TaxRate']);
}
$MarkupArrayServiceTaxVisa = 0;
if (!empty($arrVisaGSTCalculations) && $arrVisaGSTCalculations['AgencyExtraMarkUp'] > 0) {
$MarkupArrayServiceTaxVisa = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrVisaGSTCalculations['AgencyExtraMarkUp'], $arrVisaGSTCalculations['TaxRate']);
}
$netPriceArrayServiceTax = 0;
if ($arrGSTCalculations['TaxType'] == 1) {
$netPriceArrayServiceTaxF = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrGSTCalculations['MyCost'], $arrGSTCalculations['TaxRate']);
$netPriceArrayServiceTax = $netPriceArrayServiceTaxF;
}
$GTXMarkupArrayServiceTax = 0;
$AgencyMarkupArrayServiceTax = 0;
if ($arrGSTCalculations['TaxType'] == 2) {
$AgencyMarkupArrayServiceTax = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrGSTCalculations['AgencyMarkUp'], $arrGSTCalculations['TaxRate']);
}
$netPriceArrayServiceTaxFlight = $AgencyMarkupArrayServiceTaxFlight = 0;
if ($arrFlightGSTCalculations['TaxType'] == 1) {
$netPriceArrayServiceTaxFlightF = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrFlightGSTCalculations['MyCost'], $arrFlightGSTCalculations['TaxRate']);
$netPriceArrayServiceTaxFlight = $netPriceArrayServiceTaxFlightF;
}
if ($arrFlightGSTCalculations['TaxType'] == 2) {
$AgencyMarkupArrayServiceTaxFlight = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrFlightGSTCalculations['AgencyMarkUp'], $arrFlightGSTCalculations['TaxRate']);
}
$netPriceArrayServiceTaxVisa = $AgencyMarkupArrayServiceTaxVisa = 0;
if ($arrVisaGSTCalculations['TaxType'] == 1) {
$netPriceArrayServiceTaxVisaF = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrVisaGSTCalculations['MyCost'], $arrVisaGSTCalculations['TaxRate']);
$netPriceArrayServiceTaxVisa = $netPriceArrayServiceTaxVisaF;
}
if ($arrVisaGSTCalculations['TaxType'] == 2) {
$AgencyMarkupArrayServiceTaxVisa = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->calculatePercentage($arrVisaGSTCalculations['AgencyMarkUp'], $arrVisaGSTCalculations['TaxRate']);
}
$NetCostPackageOnly = $NetCost = ($arrGSTCalculations['MyCost'] - $arrGSTCalculations['AgencyMarkUp']);
$Taxes = $GTXMarkUp = 0;
$totalCost = $totalCostPackageOnly = (($NetCost + $arrGSTCalculations['AgencyMarkUp'] + $AgencyMarkupArrayServiceTax + $netPriceArrayServiceTaxF + $arrGSTCalculations['AgencyExtraMarkUp'] + $MarkupArrayServiceTax + $GTXMarkUp) - ($arrGSTCalculations['AgencyDiscount'] + $DiscountArrayServiceTax));
$FullServiceTax = $netPriceArrayServiceTax + $AgencyMarkupArrayServiceTax + $MarkupArrayServiceTax - $DiscountArrayServiceTax;
$FullServiceTaxFlight = $netPriceArrayServiceTaxFlight + $AgencyMarkupArrayServiceTaxFlight + $MarkupArrayServiceTaxFlight - $DiscountArrayServiceTaxFlight;
$FullServiceTaxVisa = $netPriceArrayServiceTaxVisa + $AgencyMarkupArrayServiceTaxVisa + $MarkupArrayServiceTaxVisa - $DiscountArrayServiceTaxVisa;
if ((int) $flightPriceWithGST > 0) {
$NetCost = (float) ($NetCost + $flightCost);
$totalCost = (float) ($totalCost + $flightPriceWithGST);
$netPriceArrayServiceTax = $netPriceArrayServiceTax + (float) $netPriceArrayServiceTaxFlight;
$AgencyMarkupArrayServiceTax = $AgencyMarkupArrayServiceTax + (float) $AgencyMarkupArrayServiceTaxFlight;
$AgencyMarkUp = $AgencyMarkUp + (float) $flightMarkup;
}
$visaGST = isset($arrVisaGSTCalculations['GSTAmount']) ? $arrVisaGSTCalculations['GSTAmount'] : 0;
$visaPriceWithGST = isset($arrVisaGSTCalculations['AmountWithGST']) ? $arrVisaGSTCalculations['AmountWithGST'] : 0;
$visaTaxRate = isset($arrVisaGSTCalculations['TaxRate']) ? (float) $arrVisaGSTCalculations['TaxRate'] : 0;
$visaTaxType = isset($arrVisaGSTCalculations['TaxType']) ? (int) $arrVisaGSTCalculations['TaxType'] : 0;
$visaNetAdultCost = $visaNetChildCost = $visaNetInfantCost = 0;
if ((int) $visaPriceWithGST > 0) {
$NetCost = (float) ($NetCost + $VisaCost);
$totalCost = (float) ($totalCost + $visaPriceWithGST);
$netPriceArrayServiceTax = $netPriceArrayServiceTax + (float) $netPriceArrayServiceTaxVisa;
$AgencyMarkupArrayServiceTax = $AgencyMarkupArrayServiceTax + (float) $AgencyMarkupArrayServiceTaxVisa;
$AgencyMarkUp = $AgencyMarkUp + (float) $VisaMarkup;
$VisaPPCostMarkup = isset($arrPkgCost['VisaPPCostMarkup']) ? $arrPkgCost['VisaPPCostMarkup'] : array();
$visaGSTPP = $visaGST / $totaltraveller;
$visaNetAdultCost = $VisaPPCostMarkup['visaNetAdultCost'] * $displayExchangeRate;
$visaNetChildCost = $VisaPPCostMarkup['visaNetChildCost'];
$visaNetInfantCost = $VisaPPCostMarkup['visaNetInfantCost'];
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$PPVisaServiceFee = ($TotalVisaServiceFee > 0) ? $TotalVisaServiceFee / $totaltraveller : 0;
$visaNetAdultCost = $VisaPPCostMarkup['visaNetAdultCost'] * $displayExchangeRate + (float) $VisaPPCostMarkup['visaNetAdultMarkup'] + (float) $PPVisaServiceFee;
$visaNetChildCost = $VisaPPCostMarkup['visaNetChildCost'] + (float) $VisaPPCostMarkup['visaNetChildMarkup'] + (float) $PPVisaServiceFee;
$visaNetInfantCost = $VisaPPCostMarkup['visaNetInfantCost'] + (float) $VisaPPCostMarkup['visaNetInfantMarkup'] + (float) $PPVisaServiceFee;
}
}
$VisaDetails = isset($arrPkgCost['VisaDetails']) ? $arrPkgCost['VisaDetails'] : array();
$customertravelpaln = array(
'VersionId' => $versionnum + 1,
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $leadID,
'AgencySysId' => $agencySysId,
'AgentSysId' => $agentsysID,
'CreatorSysId' => $agentsysID,
'StatusType' => 4,
'CustomerSysId' => $customerID,
'PlanType' => 5,
'InventoryType' => 5,
'MinPax' => $travelplandata[0]['MinPax'] ? $travelplandata[0]['MinPax'] : 0,
'PackRangeType' => $travelplandata[0]['PackRangeType'] ? $travelplandata[0]['PackRangeType'] : 0,
'Title' => $travelplandata[0]['Title'] ? $travelplandata[0]['Title'] : '',
'TourType' => !empty($TourType) ? $TourType : 1,
'EconomyMask' => $travelplandata[0]['EconomyMask'] ? $travelplandata[0]['EconomyMask'] : 0,
'PackTypeMask' => $travelplandata[0]['PackTypeMask'] ? $travelplandata[0]['PackTypeMask'] : '',
'InclCatMask' => $travelplandata[0]['InclCatMask'] ? $travelplandata[0]['InclCatMask'] : 0,
'InclMask' => $travelplandata[0]['InclMask'] ? $travelplandata[0]['InclMask'] : '',
'ExclusionMask' => $travelplandata[0]['ExclusionMask'] ? $travelplandata[0]['ExclusionMask'] : '',
'PackSpecType' => $travelplandata[0]['PackSpecType'] ? $travelplandata[0]['PackSpecType'] : '',
'SupplierSysId' => (isset($SupplierSysId) && !empty($SupplierSysId)) ? $SupplierSysId : '0',
'PriceRange' => $pricerange,
'Readymade' => $travelplandata[0]['Readymade'] ? $travelplandata[0]['Readymade'] : 1,
'SeasonMask' => $travelplandata[0]['SeasonMask'] ? $travelplandata[0]['SeasonMask'] : 0,
'GeoType' => $travelplandata[0]['GeoType'] ? $travelplandata[0]['GeoType'] : 0,
'IsFixDatePlan' => $travelplandata[0]['IsFixDatePlan'] ? $travelplandata[0]['IsFixDatePlan'] : 0,
'IsFixPlan' => $travelplandata[0]['IsFixPlan'] ? $travelplandata[0]['IsFixPlan'] : 0,
'Details' => $travelplandata[0]['Details'] ? $travelplandata[0]['Details'] : '',
'ImageTN' => $travelplandata[0]['ImageTN'] ? $travelplandata[0]['ImageTN'] : '',
'ImgForList' => $travelplandata[0]['ImgForList'] ? $travelplandata[0]['ImgForList'] : '',
'ImgeDetails' => $travelplandata[0]['ImgeDetails'] ? $travelplandata[0]['ImgeDetails'] : '',
'StartDate' => $main_trip_start_date,
'ValidTill' => $main_trip_end_date ? $main_trip_end_date : '',
'PkgSellValidTill' => $PkgSellValidTill ? $PkgSellValidTill : '',
'CurrencyType' => $ShareCurrency, // insert shared currency
'ExchangeCurrencyRate' => $displayExchangeRate,
'DiscountMsg' => $travelplandata[0]['DiscountMsg'] ? $travelplandata[0]['DiscountMsg'] : '',
'DiscountType' => $travelplandata[0]['DiscountType'] ? $travelplandata[0]['DiscountType'] : 0,
'AdvBookingPercent' => $travelplandata[0]['AdvBookingPercent'] ? $travelplandata[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $travelplandata[0]['AdvBookingDays'] ? $travelplandata[0]['AdvBookingDays'] : 0,
'Price' => $NetCost ? $NetCost : 0,
'NetPrice' => $totalCost ? round($totalCost, 2) : 0,
'DiscountVal' => $priceDetails['arrPkgCost']['FinalDiscount'] ? $priceDetails['arrPkgCost']['FinalDiscount'] : 0,
'CustomDiscount' => $AgencyDiscount + $AgencyDiscountFlight + $AgencyDiscountVisa,
'ServiceTaxOnCustomDiscount' => $DiscountArrayServiceTax + $DiscountArrayServiceTaxFlight + $DiscountArrayServiceTaxVisa,
'XServiceTaxAmount' => $netPriceArrayServiceTax,
'GTXServiceTaxAmount' => $GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => $AgencyMarkupArrayServiceTax,
'MarkUp' => $AgencyExtraMarkUp + $AgencyExtraMarkUpFlight + $AgencyExtraMarkUpVisa,
'AgentsCustomServiceTaxAmount' => $MarkupArrayServiceTax + $MarkupArrayServiceTaxFlight + $MarkupArrayServiceTaxVisa,
'GTXMarkup' => $GTXMarkUp > 0 ? $GTXMarkUp : 0,
'AgencyMarkUp' => $AgencyMarkUp, //$priceDetails['arrPkgCost']['FinalMarkUp'] ? $priceDetails['arrPkgCost']['FinalMarkUp'] : 0,
'MinPrice' => $travelplandata[0]['MinPrice'] ? $travelplandata[0]['MinPrice'] : 0,
'IsCardChrgToCustomer' => $cardcharges ? $cardcharges : '',
'TotalMinDays' => $travelplandata[0]['TotalMinDays'] ? $travelplandata[0]['TotalMinDays'] : 0,
'TotalMaxDays' => $travelplandata[0]['TotalMaxDays'] ? $travelplandata[0]['TotalMaxDays'] : 0,
'Hotels' => $travelplandata[0]['Hotels'] ? $travelplandata[0]['Hotels'] : '',
'PopularPlaces' => $travelplandata[0]['PopularPlaces'] ? $travelplandata[0]['PopularPlaces'] : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : $travelplandata[0]['SourcePlaceSysId'],
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : $travelplandata[0]['SourcePlaces'],
'DestinationPlacesSysId' => isset($going_to_cityid) ? (int) $going_to_cityid : (int) $destinationIds,
'DestinationPlaces' => isset($going_to_cityname) ? $going_to_cityname : $destinationValues,
'CityIds' => $destinationIds ? $destinationIds : '',
'Cities' => $destinationValues ? $destinationValues : '',
'Countries' => $travelplandata[0]['Countries'] ? $travelplandata[0]['Countries'] : '',
'IsMarkForDel' => $travelplandata[0]['IsMarkForDel'] ? $travelplandata[0]['IsMarkForDel'] : '0',
'RoomInfoJson' => json_encode($roomjson),
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsFixedDeparturePackage' => $IsFixedDeparturePackage,
'IsActive' => 1,
'IsAprooved' => 1,
'IsMarkForDel' => $travelplandata[0]['IsMarkForDel'] ? $travelplandata[0]['IsMarkForDel'] : '0',
'TPId' => $travelplandata[0]['TPSysId'],
'IsPriceShared' => $isPriceShared, // to detect withprice or without price true = If price shared , false = price range shared
'GSTSharedMode' => $GSTApplicableOn, // (1 for 5% on total Cost, 2 for 18% on Service Fee) to detect what type and how much tax will apply to customer
'SACCode' => isset($SACCode[5]) ? $SACCode[5] : 0,
'EmailText' => '',
'GreetingMessage' => substr($aboutpackage, 0, 4000),
'EmailDestination' => $tripaddress,
'ProposalEmailTo' => trim($custemail),
'IsB2BProposal' => trim($getcustomerdetails['IsB2BAgent']) ? trim($getcustomerdetails['IsB2BAgent']) : '0',
'B2BAgencySysId' => trim($GTXNetworkAgencySysId),
'IsGTXNetwork' => $IsFromGTXNetwork,
'IsShared' => 1,
'DestinationCovered' => !empty($travelplandata[0]['DestinationCovered']) ? $travelplandata[0]['DestinationCovered'] : 0,
'IsBusRoutePackage' => !empty($travelplandata[0]['IsBusRoutePackage']) ? $travelplandata[0]['IsBusRoutePackage'] : null,
'IsSourceCurrency' => !empty($getData['showPriceBaseCurrency']) ? $getData['showPriceBaseCurrency'] : 0,
'SelectPricingType' => !empty($getData['SelectPricing']) ? $getData['SelectPricing'] : 'Overall',
'EmailTemplateType' => !empty($EmailTemplateType) ? $EmailTemplateType : '1',
'EmailTemplateColor' => !empty($EmailTemplateColor) ? $EmailTemplateColor : 'default',
'ShareCombinedFlightPricing' => $ShareCombinedPricing,
'isShareWithFlight' => $isShareWithFlight,
'IsShareWithGST' => $IsShareWithGST,
'LeadSourceSysId' => $LeadSourceSysId,
'ProposalEmailFrom' => $proposalEmailFrom,
'ExtraMarkupType' => 2,
'NetworkExtraMarkup' => (int) $MarkUpOnGTXNetworkPackage,
'InternalRemarks' => $InternalRemarks
);
if (isset($gettplandataforcustomer[0]['IsB2BProposal']) && $gettplandataforcustomer[0]['IsB2BProposal'] == 3) {
$customertravelpaln['IsB2BProposal'] = $gettplandataforcustomer[0]['IsB2BProposal'];
$customertravelpaln['B2BAgencySysId'] = $gettplandataforcustomer[0]['B2BAgencySysId'];
}
try {
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
if ($tpproposalID) {
$agencyuserArray = array(
'UpdateDate' => $createDate
);
$whereAgencyCustomer = " AgencySysId=" . $agencySysId . " AND CustomerSysId=" . $customerID . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$TPIntSysIdSequenceWiseItinerary = $TPIntSysIdWiseItinerary = array();
// echo "<pre>";print_r($travelplanIetnaryData);
$LastSequence = 0;
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
$seqItenDay[$travelplanIetnaryData[$i]['TPIntSysId']] = $travelplanIetnaryData[$i]['Sequence'];
// $TPIntSysIdWiseItinerary[$travelplanIetnaryData[$i]['TPIntSysId']] = $travelplanIetnaryData[$i];
if ($LastSequence == 0 || $LastSequence == $travelplanIetnaryData[$i]['Sequence']) {
$dayS = $travelplanIetnaryData[$i]['Sequence'];
}
$TPIntSysIdSequenceWiseItinerary['TPIntSysId'][$travelplanIetnaryData[$i]['TPIntSysId']] = $dayS;
$TPIntSysIdSequenceWiseItinerary['Sequence'][$dayS] = $travelplanIetnaryData[$i]['Sequence'];
$LastSequence = $travelplanIetnaryData[$i]['Sequence'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAccom($tplanitenayvalues);
$CheckItiAcoom = [];
foreach ($tplanitenaryaccomdata as $hckey => $hcVal) {
$CheckItiAcoom[$hcVal['TPIntSysId']] = $hcVal['AccoSysId'];
}
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$tpstart_date = $travelplanIetnaryData[$i]['StartDate'];
$tpend_date = $travelplanIetnaryData[$i]['EndDate'];
$TotalMinDaysM = $TPIntSysIdSequenceWiseItinerary['TPIntSysId'][$travelplanIetnaryData[$i]['TPIntSysId']];
$TotalMaxDaysM = $TPIntSysIdSequenceWiseItinerary['Sequence'][$TotalMinDaysM];
$TotalMinDays = $travelplanIetnaryData[$i]['TotalMinDays'] ? $travelplanIetnaryData[$i]['TotalMinDays'] : 0;
$TotalMaxDays = $travelplanIetnaryData[$i]['TotalMaxDays'] ? $travelplanIetnaryData[$i]['TotalMaxDays'] : 0;
$ItStartDate = $ItEndDate = '';
if ($TotalMinDays > 0 && $TotalMaxDays > 0) {
$ItStartDate = date('Y-m-d H:i:s', strtotime($main_trip_start_date . " +" . ($TotalMinDays - 1) . " days"));
$ItEndDate = date('Y-m-d H:i:s', strtotime($main_trip_start_date . " +" . ($TotalMaxDays - 1) . " days"));
}
$travelitenaryarray = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $agencySysId,
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => $travelplanIetnaryData[$i]['InclMask'] ? trim($travelplanIetnaryData[$i]['InclMask']) : '',
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'] ? $travelplanIetnaryData[$i]['ExclusionMask'] : '',
'InclCatMask' => $travelplanIetnaryData[$i]['InclCatMask'] ? trim($travelplanIetnaryData[$i]['InclCatMask']) : '',
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'] ? $travelplanIetnaryData[$i]['PackInclMask'] : '',
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'Rating' => $travelplanIetnaryData[$i]['Rating'] ? $travelplanIetnaryData[$i]['Rating'] : 0,
'TotalMinDays' => $TotalMinDays > 0 ? $TotalMinDays : $TotalMinDaysM,
'TotalMaxDays' => $TotalMaxDays > 0 ? $TotalMaxDays : $TotalMaxDaysM,
'Hotels' => isset($CheckItiAcoom[$travelplanIetnaryData[$i]['TPIntSysId']]) ? 0 : 1,
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'CitySysId' => $travelplanIetnaryData[$i]['CitySysId'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'StartDate' => $ItStartDate,
'EndDate' => $ItEndDate,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => 0,
'IsActive' => 1,
'MealPlanInclude' => (isset($travelplanIetnaryData[$i]['MealPlanInclude']) && $travelplanIetnaryData[$i]['MealPlanInclude'] != '') ? $travelplanIetnaryData[$i]['MealPlanInclude'] : '',
);
$destination_cities_arr[] = $travelplanIetnaryData[$i]['Cities'];
$DestinationNameById[$travelplanIetnaryData[$i]['CitySysId']] = $travelplanIetnaryData[$i]['Cities'];
$lasttravelitenaryID[] = $lastItenaryId = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenaryarray);
$TPIntSysIdWiseItinerary[$travelplanIetnaryData[$i]['TPIntSysId']]['TotalMinDays'] = $TotalMinDays > 0 ? $TotalMinDays : $TotalMinDaysM;
$TPIntSysIdWiseItinerary[$travelplanIetnaryData[$i]['TPIntSysId']]['TotalMaxDays'] = $TotalMaxDays > 0 ? $TotalMaxDays : $TotalMaxDaysM;
}
// echo "<pre>";print_r($TPIntSysIdSequenceWiseItinerary);
// echo "<pre>";print_r($TPIntSysIdWiseItinerary); die;
$tpitenarytransport = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
if (!empty($tpitenarytransport)) {
for ($k = 0; $k < count($tpitenarytransport); $k++) {
$existingtpintID = $tpitenarytransport[$k]['TPInvnSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarytransport[$k]['FromDate'];
$toDate = $tpitenarytransport[$k]['ToDate'];
$tpitenraytransportArray = array(
'TPSysId' => $tpproposalID,
'TPInvnSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenarytransport[$k]['Sequence'] ? $tpitenarytransport[$k]['Sequence'] : 0,
'XrefInvnItemSysId' => $tpitenarytransport[$k]['XrefInvnItemSysId'] ? $tpitenarytransport[$k]['XrefInvnItemSysId'] : 0,
'AgencySysId' => $tpitenarytransport[$k]['AgencySysId'] ? $tpitenarytransport[$k]['AgencySysId'] : 0,
'Qty' => $tpitenarytransport[$k]['Qty'] ? $tpitenarytransport[$k]['Qty'] : 0,
'Remark' => $tpitenarytransport[$k]['Remark'] ? $tpitenarytransport[$k]['Remark'] : 0,
'NetCost' => $tpitenarytransport[$k]['NetCost'] ? $tpitenarytransport[$k]['NetCost'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'ApproveBy' => 1,
'ApprovalDate' => $createDate,
'IsApproved' => $tpitenarytransport[$k]['IsApproved'] ? $tpitenarytransport[$k]['IsApproved'] : 0,
'IsActive' => $tpitenarytransport[$k]['IsActive'] ? $tpitenarytransport[$k]['IsActive'] : 0,
'IsMarkForDel' => $tpitenarytransport[$k]['IsMarkForDelete'] ? $tpitenarytransport[$k]['IsMarkForDelete'] : 0,
'AirportTransport' => $tpitenarytransport[$k]['AirportTransport'] ? $tpitenarytransport[$k]['AirportTransport'] : 0,
'HotelTransport' => $tpitenarytransport[$k]['HotelTransport'] ? $tpitenarytransport[$k]['HotelTransport'] : 0,
'RoadType' => $tpitenarytransport[$k]['RoadType'] ? $tpitenarytransport[$k]['RoadType'] : '',
);
try {
$travelitenraytransport = $this->_crmcustomertravelTransport->addCustomerTravelItenaryTransport($tpitenraytransportArray);
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
$TransferVoucherStatus = 0;
}
$flightexchangerate = (isset($ExchangeRate[1]) && !empty($ExchangeRate[1])) ? (float) $ExchangeRate[1] : 1;
if (isset($inventory) && !empty($inventory)) {
##################################################################
$totalFlightCost = $totalFlightMarkup = $totalFlightTax = 0;
if (!empty($inventory)) {
// echo "<pre>";print_r($inventory);die;
$inventoryAirline = $objPackage->getFromDestinationFixedInventoryAirlineDateAndDestination($MasterRefId, $inventory[0]['id']);
//echo "<pre>";print_r($inventoryAirline);die;
$inventoryAirlineArr = array();
foreach ($inventoryAirline as $key => $value) {
$inventoryAirlineArr[$value['FlightType']][] = $value;
}
$cuntFlight = 1;
if (empty($inventoryAirline) && $inventory[0]['id'] > 0) {
$inventoryAirlineArr[1] = array(
'AirlineCode' => '',
);
}
foreach ($inventoryAirlineArr as $inkey => $invalue) {
$AdultCost = (float) (($inventory[0]['AdultCost']) * $flightexchangerate * $displayExchangeRate);
$InfantCost = (float) (($inventory[0]['InfantCost']) * $flightexchangerate * $displayExchangeRate);
$FlightAdultMarkup = (float) $inventory[0]['B2CAdultMarkup'];
$FlightInfantMarkup = (float) $inventory[0]['B2CInfantMarkup'];
if ($MarketPlaceId == 2) {
$FlightAdultMarkup = (float) $inventory[0]['B2BAdultMarkup'];
$FlightInfantMarkup = (float) $inventory[0]['B2BInfantMarkup'];
}
// if (!empty($invalue[0]['AirlineCode'])) {
if ($inventory[0]['MarkupType'] == 2) {
$AdultMarkup = ($AdultCost * $FlightAdultMarkup / 100);
$InfantMarkup = ($InfantCost * $FlightInfantMarkup / 100);
} else {
$AdultMarkup = $FlightAdultMarkup * $flightexchangerate * $displayExchangeRate;
$InfantMarkup = $FlightInfantMarkup * $flightexchangerate * $displayExchangeRate;
}
$totalPax = $totaladult + $totalchild + $totalInfant;
if (isset($IsFromGTXNetwork) && ($IsFromGTXNetwork == 1) && !empty($GTXNetworkAgencySysId)) {
$AdultCost = $AdultCost + $AdultMarkup;
$InfantCost = $InfantCost + $InfantMarkup;
if ($MarkUpOnGTXNetworkPackage > 0) {
$AdultMarkup = $AdultCost * $MarkUpOnGTXNetworkPackage / 100;
$InfantMarkup = $InfantCost * $MarkUpOnGTXNetworkPackage / 100;
} else {
$AdultMarkup = 0;
$InfantMarkup = 0;
}
}
$AdultGst = $this->_crmcusttravelplan->calculateGSTPrice(($AdultCost + $AdultMarkup), $AdultMarkup, $flightTaxType, $flightTaxRate);
$InfantGst = $this->_crmcusttravelplan->calculateGSTPrice(($InfantCost + $InfantMarkup), $InfantMarkup, $flightTaxType, $flightTaxRate);
$totalAdultCost = $AdultCost * $totaladult;
$totalChildCost = $AdultCost * $totalchild;
$totalInfantCost = $InfantCost * $totalInfant;
$totalAdultMarkup = $AdultMarkup * $totaladult;
$totalChildMarkup = $AdultMarkup * $totalchild;
$totalInfantMarkup = $InfantMarkup * $totalInfant;
$totalAdultGst = $AdultGst * $totaladult;
$totalChildGst = $AdultGst * $totalchild;
$totalInfantGst = $InfantGst * $totalInfant;
$totalAdultCostFinal = $totalAdultCost + $totalAdultMarkup + $totalAdultGst;
$totalChildCostFinal = $totalChildCost + $totalChildMarkup + $totalChildGst;
$totalInfantFinal = $totalInfantCost + $totalInfantMarkup + $totalInfantGst;
$totalPaxCost = $totalAdultCost + $totalChildCost + $totalInfantCost;
$totalpaxMarkup = $totalAdultMarkup + $totalChildMarkup + $totalInfantMarkup;
$totalpaxGst = $totalAdultGst + $totalChildGst + $totalInfantGst;
$totalPaxCostFinal = $totalAdultCostFinal + $totalChildCostFinal + $totalInfantFinal;
$totalCostPerpersonF = (float) $totalPaxCost / $totalPax;
$totalMarkupPerpersonF = (float) $totalpaxMarkup / $totalPax;
$flightPriceWithGST1 = $totalPaxCostFinal;
$flightCost1 = $totalPaxCost;
$flightMarkup1 = $totalpaxMarkup;
//$flightPriceWithGST = $totalCostF = $this->_crmcusttravelplan->getPriceWithGST($totalCostF, $flightTaxType, $flightTaxRate);
if ($cuntFlight > 1) {
$totalAdultCostFinal = $totalChildCostFinal = $totalInfantFinal = $flightPriceWithGST1 = $flightCost1 = $flightMarkup1 = 0;
}
//echo "<pre>";print_r($FlightAdultMarkup);die;
$flightJson = array(
"inventory" => $invalue[0]['InvnAirlineSysId'],
"supplierName" => '',
"hidden_selected_supplier_sys_id" => '',
"FlightNo" => trim($invalue[0]['AirlineCode']),
"AirlineName" => trim($invalue[0]['AirlineName']),
"hidden_selected_airline_sys_id" => 0,
"departureCity" => (!empty(trim($invalue[0]['DepartureAirportName']))) ? trim($invalue[0]['DepartureAirportName']) : $invalue[0]['DepartureAirportCode'],
"depaartureDate" => ($inkey == 1) ? $pkgCheckInDate : $pkgCheckOutDate,
"depaartureTime" => (isset($invalue[0]['DepartureTime']) && !empty($invalue[0]['DepartureTime'])) ? $invalue[0]['DepartureTime']->format('H:i') : '',
"arrivalCity" => (!empty(trim($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalAirportName']))) ? trim($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalAirportName']) : $inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalAirportCode'],
"arrivalDate" => ($inkey == 1) ? $pkgCheckInDate : $pkgCheckOutDate,
"arrivalTime" => (isset($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']) && !empty($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime'])) ? $inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']->format('H:i') : '',
"stops" => count($invalue) - 1,
"duration" => $invalue[0]['EstimateHours'],
"refundableFlight" => 0,
"adultCabin" => "15",
"adultCheckIn" => "7",
"childCabin" => "15",
"childCheckIn" => "7",
"InfentCabin" => "",
"InfentCheckIn" => "",
"paxType" => array("2"),
"currencyType" => [$inventory[0]['CurrencySysId']],
"perpersoneprice" => [(int) $totalCostPerpersonF],
"perpersonemarkup" => [(int) $totalMarkupPerpersonF],
"taxpersentage" => ["1"],
"taxamount" => ["0"],
"totalAmount" => [$totalPaxCostFinal],
"QueryId" => $leadID,
"totalFightCost" => (float) $totalPaxCost,
"totalFightMarkup" => (float) $totalpaxMarkup,
"totalTax" => $totalpaxGst,
"totalFightCostWithMarkup" => (float) $totalPaxCostFinal,
"textbased" => "textbased",
"supplier_type" => "0",
"supplier_type_id" => "0",
"flighttext" => "",
"adult_pax" => $totaladult,
"adult_cost_pp" => $AdultCost,
"adult_markup" => $AdultMarkup,
"adult_gst" => $AdultGst,
"adult_total" => $totalAdultCostFinal,
"child_pax" => $totalchild,
"child_cost_pp" => $AdultCost,
"child_markup" => $AdultMarkup,
"child_gst" => $AdultGst,
"child_total" => $totalChildCostFinal,
"infant_pax" => $totalInfant,
"infant_cost_pp" => $InfantCost,
"infant_markup" => $InfantMarkup,
"infant_gst" => $InfantGst,
"infant_total" => $totalInfantFinal,
"totalcost_wom" => $totalPaxCost,
"total_markup" => $totalpaxMarkup,
"total_gst" => $totalpaxGst,
"totalflightcost" => (float) $totalPaxCost,
"GstTaxFlight" => "1"
);
if ($inkey == 1) {
$LocalFromTime = (isset($invalue[0]['DepartureTime']) && !empty($invalue[0]['DepartureTime'])) ? $main_trip_start_date . ' ' . $invalue[0]['DepartureTime']->format('H:i') : '';
$LocalToTime = (isset($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']) && !empty($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime'])) ? $main_trip_start_date . ' ' . $inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']->format('H:i') : '';
} else {
$LocalFromTime = (isset($invalue[0]['DepartureTime']) && !empty($invalue[0]['DepartureTime'])) ? $main_trip_end_date . ' ' . $invalue[0]['DepartureTime']->format('H:i') : '';
$LocalToTime = (isset($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']) && !empty($inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime'])) ? $main_trip_end_date . ' ' . $inventoryAirlineArr[$inkey][count($invalue) - 1]['ArrivalTime']->format('H:i') : '';
}
$travelitenaryaccomairArray = array(
'TPIntSysId' => $lasttravelitenaryID[1] ? $lasttravelitenaryID[1] : 0,
'SeqId' => 0,
'AgencySysId' => $agencySysId ? $agencySysId : 0,
'InvnItemSysId' => 0,
'IsFromAPI' => 0,
'SourceSysId' => 0,
'SupplierSysId' => $SupplierSysId,
'TripType' => (int) $inkey,
'CurrencyType' => $inventory[0]['CurrencySysId'],
'Cost' => (float) $flightCost1,
'TotalCost' => (float) $flightPriceWithGST1,
'FlightNumber' => (isset($invalue[0]['AirlineCode'])) ? trim($invalue[0]['AirlineCode']) : '',
'AirlineSysId' => (!empty($inventoryAirline)) ? 1 : 0,
'ICSourceSysId' => 0,
'IsFromAgency' => 0,
'LocalFromTime' => $LocalFromTime,
'LocalToTime' => $LocalToTime,
'FromUTCTime' => '',
'ToUTCTime' => '',
'FlightCabinClass' => '',
'AdultPax' => $totaladult,
'ChildPax' => $totalchild,
'InfentPax' => $totalInfant,
'TotalPax' => $totalPax,
'IsSelectedOnPkg' => 0,
'IsDirect' => 0,
'DayLightSavingDiff' => 0,
'FlyingMinutes' => 0,
'SourcePlaceSysId' => 0,
'DestPlaceSysId' => 0,
'SourceAirportCode' => '',
'DestAirportCode' => '',
'AirportHaultMinutes' => 0,
'StopCount' => 0,
'Stops' => count($invalue) - 1,
'Rating' => 0,
'FllightFeatureMask' => 0,
'UpdatedByISSysId' => 0,
'CreatedByISSysId' => 0,
'ImageTN' => 0,
'ImgForList' => 0,
'ImgeDetails' => 0,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'ApproveBy' => 0,
'ApprovalDate' => $createDate,
'IsApproved' => 1,
'IsActive' => 1,
'IsMarkForDel' => 0,
'encodedata' => json_encode($flightJson),
'XRefBookingId' => 0,
'XRefPNR' => 0,
'XRefCancellationlId' => 0,
'APIBookingRes' => 0,
'APICancellationRes' => 0,
'Discount' => 0,
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => 0,
'AgentsCustomServiceTaxAmount' => 0,
'MarkUp' => $flightMarkup1,
'AgencyMarkUp' => 0,
'GTXMarkup' => 0,
'GTXCommission' => 0,
'AgencyCommission' => 0,
'Taxes' => 0,
'TDS' => 0,
'DiscountMsg' => 0,
'IsFixedTransport' => 0,
'AirlineRefPNR' => 0
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_Air', $travelitenaryaccomairArray);
$cuntFlight++;
// }
}
}
##################################################################
} else {
if ($isShareWithFlight == 1) { // share with flight
$totalcost_wom = $total_flight_markup = $totalflightcost = 0;
$TPIntSysIdForFlight = $lasttravelitenaryID[0];
$tripType = (isset($package_flightdetails['tripType']) && !empty($package_flightdetails['tripType'])) ? (int) $package_flightdetails['tripType'] : 0;
$flightType = isset($package_flightdetails['flightType']) ? (int) $package_flightdetails['flightType'] : 1;
$refundable = (isset($package_flightdetails['refundable']) && $package_flightdetails['refundable'] === true) ? 1 : 0;
//echo "<pre>";print_r($package_flightdetails);die;
if ($flightType == 2) {
$airline_name = isset($package_flightdetails['airline_name']) ? $package_flightdetails['airline_name'] : array();
} else {
$airline_name = array(0 => '');
}
foreach ($airline_name as $key => $value) {
$sourceairportcode_name = $destairportcode_name = '';
$airportSourceCityId = $airportDestCityId = 0;
if ($flightType == 2) {
$departure_date_oneway = isset($package_flightdetails['departure_date_oneway'][$key]) ? explode(' ', trim($package_flightdetails['departure_date_oneway'][$key])) : '';
$arrival_date_oneway = isset($package_flightdetails['arrival_date_oneway'][$key]) ? explode(' ', trim($package_flightdetails['arrival_date_oneway'][$key])) : '';
$LocalFromTime = (isset($departure_date_oneway[0]) && !empty($departure_date_oneway[0])) ? explode('/', $departure_date_oneway[0]) : '';
$LocalFromTime1 = $LocalFromTime[2] . '-' . $LocalFromTime[1] . '-' . $LocalFromTime[0] . ' ' . (isset($departure_date_oneway[1]) ? trim($departure_date_oneway[1]) : '');
$LocalToTime = (isset($arrival_date_oneway[0]) && !empty($arrival_date_oneway[0])) ? explode('/', $arrival_date_oneway[0]) : '';
$LocalToTime1 = $LocalToTime[2] . '-' . $LocalToTime[1] . '-' . $LocalToTime[0] . ' ' . (isset($arrival_date_oneway[1]) ? trim($arrival_date_oneway[1]) : '');
$sourceairportcode_name = isset($package_flightdetails['source_place_id'][$key]) ? trim($package_flightdetails['source_place_id'][$key]) : '';
$airportSourceCityId = isset($package_flightdetails['sourceCityId'][$key]) ? trim($package_flightdetails['sourceCityId'][$key]) : 0;
$destairportcode_name = isset($package_flightdetails['destination_place_id'][$key]) ? trim($package_flightdetails['destination_place_id'][$key]) : '';
$airportDestCityId = isset($package_flightdetails['destinationCityId'][$key]) ? trim($package_flightdetails['destinationCityId'][$key]) : 0;
$totalFightCost = isset($package_flightdetails['total_cost'][$key]) ? (float) $package_flightdetails['total_cost'][$key] * $flightexchangerate * $displayExchangeRate : 0;
$totalFightMarkup = isset($package_flightdetails['total_markup'][$key]) ? (float) $package_flightdetails['total_markup'][$key] * $flightexchangerate * $displayExchangeRate : 0;
$totalTax = isset($package_flightdetails['total_gst'][$key]) ? (float) $package_flightdetails['total_gst'][$key] * $flightexchangerate * $displayExchangeRate : 0;
$totalFightCostWithMarkup = isset($package_flightdetails['grand_total'][$key]) ? (float) $package_flightdetails['grand_total'][$key] * $flightexchangerate * $displayExchangeRate : 0;
$adult_cost_pp = isset($package_flightdetails['costAd'][$key]) ? ((float) $package_flightdetails['costAd'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$adult_markup = isset($package_flightdetails['markupAd'][$key]) ? ((float) $package_flightdetails['markupAd'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$adult_gst = isset($package_flightdetails['gstAd'][$key]) ? ((float) $package_flightdetails['gstAd'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$adult_total = isset($package_flightdetails['totalAd'][$key]) ? ((float) $package_flightdetails['totalAd'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$child_cost_pp = isset($package_flightdetails['costCh'][$key]) ? ((float) $package_flightdetails['costCh'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$child_markup = isset($package_flightdetails['markupCh'][$key]) ? ((float) $package_flightdetails['markupCh'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$child_gst = isset($package_flightdetails['gstCh'][$key]) ? ((float) $package_flightdetails['gstCh'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$child_total = isset($package_flightdetails['totalCh'][$key]) ? ((float) $package_flightdetails['totalCh'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$infant_cost_pp = isset($package_flightdetails['costIn'][$key]) ? ((float) $package_flightdetails['costIn'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$infant_markup = isset($package_flightdetails['markupIn'][$key]) ? ((float) $package_flightdetails['markupIn'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$infant_gst = isset($package_flightdetails['gstIn'][$key]) ? ((float) $package_flightdetails['gstIn'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$infant_total = isset($package_flightdetails['totalIn'][$key]) ? ((float) $package_flightdetails['totalIn'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$totalcost_wom = isset($package_flightdetails['total_cost'][$key]) ? ((float) $package_flightdetails['total_cost'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$total_markup = isset($package_flightdetails['total_markup'][$key]) ? ((float) $package_flightdetails['total_markup'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$total_gst = isset($package_flightdetails['total_gst'][$key]) ? ((float) $package_flightdetails['total_gst'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$totalflightcost = isset($package_flightdetails['grand_total'][$key]) ? ((float) $package_flightdetails['grand_total'][$key] * $flightexchangerate * $displayExchangeRate) : 0;
$flightJson = [
'supplierName' => isset($package_flightdetails['supplier_type']) ? trim($package_flightdetails['supplier_type']) : '',
'hidden_selected_supplier_sys_id' => isset($package_flightdetails['supplier_type_id']) ? (int) $package_flightdetails['supplier_type_id'] : '',
'supplier_type_id' => isset($package_flightdetails['supplier_type_id']) ? (int) $package_flightdetails['supplier_type_id'] : '',
'FlightNo' => isset($package_flightdetails['airlineNo'][$key]) ? trim($package_flightdetails['airlineNo'][$key]) : '',
'AirlineName' => trim($value),
'hidden_selected_airline_sys_id' => isset($package_flightdetails['hidden_selected_airline_sys_id'][$key]) ? (int) $package_flightdetails['hidden_selected_airline_sys_id'][$key] : '',
'departureCity' => isset($package_flightdetails['source_place'][$key]) ? trim($package_flightdetails['source_place'][$key]) : '',
'depaartureDate' => isset($departure_date_oneway[0]) ? trim($departure_date_oneway[0]) : '',
'depaartureTime' => isset($departure_date_oneway[1]) ? trim($departure_date_oneway[1]) : '',
'arrivalCity' => isset($package_flightdetails['destination_place'][$key]) ? trim($package_flightdetails['destination_place'][$key]) : '',
'arrivalDate' => isset($arrival_date_oneway[0]) ? trim($arrival_date_oneway[0]) : '',
'arrivalTime' => isset($arrival_date_oneway[1]) ? trim($arrival_date_oneway[1]) : '',
'stops' => isset($package_flightdetails['stops'][$key]) ? trim($package_flightdetails['stops'][$key]) : '',
'stopOver' => isset($package_flightdetails['stopOver'][$key]) ? trim($package_flightdetails['stopOver'][$key]) : '',
'duration' => isset($package_flightdetails['duration'][$key]) ? trim($package_flightdetails['duration'][$key]) : '',
'refundableFlight' => $refundable,
'totalFightCost' => $totalFightCost,
'totalFightMarkup' => $totalFightMarkup,
'totalTax' => $totalTax,
'totalFightCostWithMarkup' => $totalFightCostWithMarkup,
'fareRules' => isset($package_flightdetails['fareRuleOneWay']) ? trim($package_flightdetails['fareRuleOneWay']) : '',
'adult_pax' => isset($package_flightdetails['adults_count_oneWay'][$key]) ? trim($package_flightdetails['adults_count_oneWay'][$key]) : '',
'adult_cost_pp' => $adult_cost_pp,
'adult_markup' => $adult_markup,
'adult_gst' => $adult_gst,
'adult_gst_id' => isset($package_flightdetails['gstAdType'][$key]) ? trim($package_flightdetails['gstAdType'][$key]) : '',
'adult_total' => $adult_total,
'child_pax' => isset($package_flightdetails['child_count_oneWay'][$key]) ? trim($package_flightdetails['child_count_oneWay'][$key]) : '',
'child_cost_pp' => $child_cost_pp,
'child_markup' => $child_markup,
'child_gst' => $child_gst,
'child_gst_id' => isset($package_flightdetails['gstChType'][$key]) ? trim($package_flightdetails['gstChType'][$key]) : '',
'child_total' => $child_total,
'infant_pax' => isset($package_flightdetails['infant_count_oneWay'][$key]) ? trim($package_flightdetails['infant_count_oneWay'][$key]) : '',
'infant_cost_pp' => $infant_cost_pp,
'infant_markup' => $infant_markup,
'infant_gst' => $infant_gst,
'infant_gst_id' => isset($package_flightdetails['gstInType'][$key]) ? trim($package_flightdetails['gstInType'][$key]) : '',
'infant_total' => $infant_total,
'totalcost_wom' => $totalcost_wom,
'total_markup' => $total_markup,
'total_gst' => $total_gst,
'totalflightcost' => $totalflightcost,
'GstTaxFlight' => isset($package_flightdetails['gstAdType'][$key]) ? trim($package_flightdetails['gstAdType'][$key]) : 0,
'flightType' => $flightType,
];
//$GSTApplicableOnFlight = isset($package_flightdetails['gstAdType'][$key]) ? trim($package_flightdetails['gstAdType'][$key]) : 0;
$package_flightdetailsFinal = $flightJson;
$tripType = $key + 1;
} else {
$package_flightdetails['totalcost_wom'] = isset($package_flightdetails['totalcost_wom']) ? (float) $package_flightdetails['totalcost_wom'] * $flightexchangerate * $displayExchangeRate : 0;
$package_flightdetails['total_markup'] = isset($package_flightdetails['total_markup']) ? (float) $package_flightdetails['total_markup'] * $flightexchangerate * $displayExchangeRate : 0;
$package_flightdetails['totalflightcost'] = isset($package_flightdetails['totalflightcost']) ? (float) $package_flightdetails['totalflightcost'] * $flightexchangerate * $displayExchangeRate : 0;
$package_flightdetails['adult_cost_pp'] = isset($package_flightdetails['adult_cost_pp']) ? ((float) $package_flightdetails['adult_cost_pp'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['adult_markup'] = isset($package_flightdetails['adult_markup']) ? ((float) $package_flightdetails['adult_markup'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['adult_total'] = isset($package_flightdetails['adult_total']) ? ((float) $package_flightdetails['adult_total'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['child_cost_pp'] = isset($package_flightdetails['child_cost_pp']) ? ((float) $package_flightdetails['child_cost_pp'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['child_markup'] = isset($package_flightdetails['child_markup']) ? ((float) $package_flightdetails['child_markup'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['child_total'] = isset($package_flightdetails['child_total']) ? ((float) $package_flightdetails['child_total'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['infantcost_pp'] = isset($package_flightdetails['infantcost_pp']) ? ((float) $package_flightdetails['infant_cost_pp'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['infant_markup'] = isset($package_flightdetails['infant_markup']) ? ((float) $package_flightdetails['infant_markup'] * $flightexchangerate * $displayExchangeRate) : 0;
$package_flightdetails['infant_total'] = isset($package_flightdetails['infant_total']) ? ((float) $package_flightdetails['infant_total'] * $flightexchangerate * $displayExchangeRate) : 0;
$tripType = 0;
$package_flightdetailsFinal = $package_flightdetails;
//$GSTApplicableOnFlight = (float) $package_flightdetails['adult_gst'];
}
if (!empty($package_flightdetailsFinal['totalcost_wom'])) {
$totalcost_wom = $totalcost_wom + (float) $package_flightdetailsFinal['totalcost_wom'];
}
if (!empty($package_flightdetailsFinal['total_markup'])) {
$total_flight_markup = $total_flight_markup + (float) $package_flightdetailsFinal['total_markup'];
}
$totalTaxAdult11 = $this->_crmcusttravelplan->calculateGSTPrice(((float) $package_flightdetailsFinal['adult_cost_pp'] + (float) $package_flightdetailsFinal['adult_markup']), (float) $package_flightdetailsFinal['adult_markup'], $flightTaxType, $flightTaxRate);
$totalTaxChild11 = $this->_crmcusttravelplan->calculateGSTPrice(((float) $package_flightdetailsFinal['child_cost_pp'] + (float) $package_flightdetailsFinal['child_markup']), (float) $package_flightdetailsFinal['child_markup'], $flightTaxType, $flightTaxRate);
$totalTaxInfant11 = $this->_crmcusttravelplan->calculateGSTPrice(((float) $package_flightdetailsFinal['infant_cost_pp'] + (float) $package_flightdetailsFinal['infant_markup']), (float) $package_flightdetailsFinal['infant_markup'], $flightTaxType, $flightTaxRate);
$totalTax11 = $this->_crmcusttravelplan->calculateGSTPrice(((float) $package_flightdetailsFinal['totalcost_wom'] + (float) $package_flightdetailsFinal['total_markup']), (float) $package_flightdetailsFinal['total_markup'], $flightTaxType, $flightTaxRate);
$package_flightdetailsFinal['adult_gst'] = $totalTaxAdult11;
$package_flightdetailsFinal['adult_total'] = ((float) $package_flightdetailsFinal['adult_cost_pp'] + (float) $package_flightdetailsFinal['adult_markup'] + $package_flightdetailsFinal['adult_gst']) * $package_flightdetailsFinal['adult_pax'];
$package_flightdetailsFinal['child_gst'] = $totalTaxChild11;
if ((int) $package_flightdetailsFinal['child_pax'] > 0) {
$package_flightdetailsFinal['child_total'] = ((float) $package_flightdetailsFinal['child_cost_pp'] + (float) $package_flightdetailsFinal['child_markup'] + $package_flightdetailsFinal['child_gst']) * $package_flightdetailsFinal['child_pax'];
}
$package_flightdetailsFinal['infant_gst'] = $totalTaxInfant11;
if ((int) $package_flightdetailsFinal['infant_pax'] > 0) {
$package_flightdetailsFinal['infant_total'] = ((float) $package_flightdetailsFinal['infant_cost_pp'] + (float) $package_flightdetailsFinal['infant_markup'] + $package_flightdetailsFinal['infant_gst']) * $package_flightdetailsFinal['infant_pax'];
}
$package_flightdetailsFinal['totalTax'] = $package_flightdetailsFinal['total_gst'] = $totalTax11;
if (!empty($package_flightdetailsFinal['totalflightcost'])) {
$package_flightdetailsFinal['totalflightcost'] = (float) $package_flightdetailsFinal['totalcost_wom'] + (float) $package_flightdetailsFinal['total_markup'] + $package_flightdetailsFinal['total_gst'];
$package_flightdetailsFinal['totalFightCostWithMarkup'] = (float) $package_flightdetailsFinal['totalcost_wom'] + (float) $package_flightdetailsFinal['total_markup'] + $package_flightdetailsFinal['total_gst'];
$totalflightcost = $totalflightcost + $package_flightdetailsFinal['totalflightcost'];
}
$package_flightdetailsFinal['adult_gst_id'] = $package_flightdetailsFinal['child_gst_id'] = $package_flightdetailsFinal['infant_gst_id'] = $package_flightdetailsFinal['GstTaxFlight'] = $GSTApplicableOnFlight;
if (!empty($package_flightdetailsFinal['total_gst'])) {
$totalcost_gst = $totalcost_gst + (float) $package_flightdetailsFinal['total_gst'];
}
//echo "<pre>";print_r($package_flightdetailsFinal);die;
$travelitenaryaccomairArray = array(
'TPIntSysId' => $TPIntSysIdForFlight,
'SeqId' => 0,
'InvnItemSysId' => 0,
'AgencySysId' => $agencySysId,
'IsFromAPI' => 0,
'SourceSysId' => 0,
'SupplierSysId' => !empty($package_flightdetailsFinal['supplier_type_id']) ? $package_flightdetailsFinal['supplier_type_id'] : $SupplierSysId,
'TripType' => $tripType,
'CurrencyType' => 0,
'Cost' => !empty($package_flightdetailsFinal['totalcost_wom']) ? $package_flightdetailsFinal['totalcost_wom'] : 0,
'TotalCost' => !empty($package_flightdetailsFinal['totalflightcost']) ? $package_flightdetailsFinal['totalflightcost'] : 0,
'FlightNumber' => !empty($package_flightdetailsFinal['FlightNo']) ? $package_flightdetailsFinal['FlightNo'] : 0,
'AirlineSysId' => isset($package_flightdetailsFinal['hidden_selected_airline_sys_id']) ? (int) $package_flightdetailsFinal['hidden_selected_airline_sys_id'] : 0,
'ICSourceSysId' => 0,
'IsFromAgency' => 0,
'LocalFromTime' => ($LocalFromTime1) ? $LocalFromTime1 : '',
'LocalToTime' => ($LocalToTime1) ? $LocalToTime1 : '',
'FromUTCTime' => '',
'ToUTCTime' => '',
'FlightCabinClass' => '',
'AdultPax' => !empty($package_flightdetailsFinal['adult_pax']) ? $package_flightdetailsFinal['adult_pax'] : 0,
'ChildPax' => !empty($package_flightdetailsFinal['child_pax']) ? $package_flightdetailsFinal['child_pax'] : 0,
'InfentPax' => !empty($package_flightdetailsFinal['infant_pax']) ? $package_flightdetailsFinal['infant_pax'] : 0,
'TotalPax' => (int) $package_flightdetailsFinal['adult_pax'] + (int) $package_flightdetailsFinal['child_pax'] + (int) $package_flightdetailsFinal['infant_pax'],
'IsSelectedOnPkg' => 0,
'IsDirect' => 0,
'DayLightSavingDiff' => 0,
'FlyingMinutes' => 0,
'SourcePlaceSysId' => $airportSourceCityId,
'DestPlaceSysId' => $airportDestCityId,
'SourceAirportCode' => $sourceairportcode_name,
'DestAirportCode' => $destairportcode_name,
'AirportHaultMinutes' => 0,
'StopCount' => 0,
'Stops' => !empty($package_flightdetailsFinal['stops']) ? $package_flightdetailsFinal['stops'] : 0,
'Rating' => 0,
'FllightFeatureMask' => 0,
'UpdatedByISSysId' => 0,
'CreatedByISSysId' => 0,
'ImageTN' => 0,
'ImgForList' => 0,
'ImgeDetails' => 0,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'ApproveBy' => 0,
'ApprovalDate' => $createDate,
'IsApproved' => 1,
'IsActive' => 1,
'IsMarkForDel' => 0,
'encodedata' => json_encode($package_flightdetailsFinal),
'XRefBookingId' => 0,
'XRefPNR' => 0,
'XRefCancellationlId' => 0,
'APIBookingRes' => 0,
'APICancellationRes' => 0,
'Discount' => 0,
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => 0,
'AgentsCustomServiceTaxAmount' => (float) $package_flightdetailsFinal['total_gst'],
'MarkUp' => (float) $package_flightdetailsFinal['total_markup'],
'AgencyMarkUp' => 0,
'GTXMarkup' => 0,
'GTXCommission' => 0,
'AgencyCommission' => 0,
'Taxes' => 0,
'TDS' => 0,
'DiscountMsg' => 0,
'IsFixedTransport' => 0,
'AirlineRefPNR' => 0
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_Air', $travelitenaryaccomairArray);
}
}
}
if ($tpproposalID > 0) {
$TotalCostPackageAddon = $NetCostPackageOnly + (float) ($AgencyMarkUpPackage + $AgencyExtraMarkUp) + $FullServiceTax - $AgencyDiscount;
$addonPackageData = [
'AgencySysId' => (int) $agencySysId,
'TPSysId' => (int) $tpproposalID,
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => (isset($SupplierSysId) && !empty($SupplierSysId)) ? $SupplierSysId : '0',
'PlanType' => 5,
'InvnSysId' => 0,
'ServiceTitle' => 'Package',
'CurrencyType' => !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'],
'GSTTYPE' => $GSTApplicableOn,
'Tax' => $FullServiceTax,
'Cost' => $NetCostPackageOnly,
'Markup' => (float) ($AgencyMarkUpPackage),
'TotalCost' => $TotalCostPackageAddon,
'Discount' => $AgencyDiscount,
'ExtraMarkUp' => $AgencyExtraMarkUp,
'ShareCombined' => 0,
'IsActive' => 1,
'IsApplyTax' => $ShareWithTCSPackage,
'ConversionRateBase' => ($IsPackageShareBaseCurrency == 1) ? $PackageExchangeRate : 0,
'SCurrencyType' => ($IsPackageShareBaseCurrency == 1) ? (int)$arrPkgCost['SourcingCurrencyId'] : 0,
'STotalCost' => ($IsPackageShareBaseCurrency == 1) ? (float)$arrPkgCost['SourcingNetCost'] : 0,
];
$saveAddonServicesData = $objPackage->saveAddonServicesData($addonPackageData);
}
$destination_cities_arr_unique = array_unique($destination_cities_arr);
$display_destination_city = implode("-", $destination_cities_arr_unique);
// $tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAccom($tplanitenayvalues);
$accomdataCheckSimilar = array();
foreach ($tplanitenaryaccomdata as $hckey => $hcVal) {
if ($hcVal['IsSelectedOnPkg'] == 0) {
$accomdataCheckSimilar[$hcVal['TPIntSysId']][] = $hcVal['AccoSysId'];
}
}
// echo "<pre>";print_r($tplanitenaryaccomdata);die;
$HotelDestinationWise = array();
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$startDay = $seqItenDay[$existingtpintID];
$endDay = $startDay + 1;
if ((int) $TPIntSysIdWiseItinerary[$existingtpintID]['TotalMinDays'] > 0) {
$TotalMinDays = (int) $TPIntSysIdWiseItinerary[$existingtpintID]['TotalMinDays'] - 1;
$TotalMaxDays = (int) $TPIntSysIdWiseItinerary[$existingtpintID]['TotalMaxDays'] - 1;
$TotalNights = (int) $TPIntSysIdWiseItinerary[$existingtpintID]['TotalMaxDays'] - (int) $TPIntSysIdWiseItinerary[$existingtpintID]['TotalMinDays'];
$accomStartDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $TotalMinDays days")); // strtotime(date("Y-m-d", strtotime($main_trip_start_date)) . " +".$startDay."days");;
$accomEndDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $TotalMaxDays days"));
} else {
if ($startDay == 1) {
$accomStartDate = $main_trip_start_date;
$accomEndDate = date('Y-m-d', strtotime($main_trip_start_date . "+ 1 days"));
} else {
$accomStartDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $startDay days")); // strtotime(date("Y-m-d", strtotime($main_trip_start_date)) . " +".$startDay."days");;
$accomEndDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $endDay days"));
}
$TotalNights = ((int) $tplanitenaryaccomdata[$k]['TotalNights'] > 0) ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0;
}
$AddOnServiceSysId = null;
if (isset($saveAddonServicesData['status']) && $saveAddonServicesData['status'] == 1) {
$AddOnServiceSysId = isset($saveAddonServicesData['id']) ? $saveAddonServicesData['id'] : null;
}
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $startDay,
'AgencySysId' => $agencySysId,
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'MealPlanType' => $tplanitenaryaccomdata[$k]['MealPlanType'] ? $tplanitenaryaccomdata[$k]['MealPlanType'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : '',
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : '',
//'FromDate' => $accomStartDate ? $accomStartDate : '',
'FromDate' => $accomStartDate ? $accomStartDate : '',
'ToDate' => $accomEndDate ? $accomEndDate : '',
'AdultPax' => $totaladult ? (int) $totaladult - $Adultextrabed : 0,
'ChildPax' => $Childextrabed ? $Childextrabed : 0,
'InfantPax' => $totalInfant,
'PetPax' => 0,
'TotalPax' => ($totaladult + $totalchild + $totalInfant),
'TotalNights' => (int) $TotalNights,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCostGen'] ? $tplanitenaryaccomdata[$k]['TotalCostGen'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => 0,
'AgentsCustomServiceTaxAmount' => 0,
'MarkUp' => 0,
'GTXMarkup' => 0,
'AgencyMarkUp' => 0,
'IsSelectedOnPkg' => $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] ? $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => 0,
'IsActive' => 1,
'AccoSimilarHotel' => (isset($accomdataCheckSimilar[$existingtpintID]) && !empty($accomdataCheckSimilar[$existingtpintID])) ? 1 : 0,
'SupplierSysId' => (isset($SupplierSysId) && !empty($SupplierSysId)) ? (int) $SupplierSysId : 0,
'SingleOAdult' => $SingleOAdult ? $SingleOAdult : 0,
'NoOfRoom' => is_array($roomjson) ? count($roomjson) : null,
'ChildNoBed' => $Childwithoutbed ? $Childwithoutbed : 0,
'ExtraAdult' => $Adultextrabed ? $Adultextrabed : 0,
'AddOnServiceSysId' => $AddOnServiceSysId,
);
if (($agencySysId == 2656 || $agencySysId == 21) || date('Y-m-d') >= '2025-06-25') {
$AccoSysId = $travelitenaryaccomArray['AccoSysId'];
$AgencySysId = $travelitenaryaccomArray['AgencySysId'];
$FromDate = $travelitenaryaccomArray['FromDate'];
$ToDate = $travelitenaryaccomArray['ToDate'];
$XRefCityId = $travelitenaryaccomArray['XRefCityId'];
$RoomType = $travelitenaryaccomArray['RoomType'];
$RoomTypeStr = $travelitenaryaccomArray['RoomTypeStr'];
$MealPlanType = $travelitenaryaccomArray['MealPlanType'];
$checkHotelData = $this->_crmcusttravelplanItenaryAccom->checkHotelDetailsInAccom($tpproposalID, $AccoSysId, $AgencySysId, $FromDate, $ToDate, $XRefCityId, $RoomType, $RoomTypeStr, $MealPlanType);
if (empty($checkHotelData)) {
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
// if ($travelitenaryaccomArray['IsSelectedOnPkg'] == 1) {
// $HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Count']++;
// $HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Title'] = str_replace('(Internal)', '', $travelitenaryaccomArray['Title']);
// $HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Destination'] = $DestinationNameById[$travelitenaryaccomArray['XRefCityId']];
// $HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['StarRating'] = $travelitenaryaccomArray['StarRating'];
// }
}
} else {
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
if ($travelitenaryaccomArray['IsSelectedOnPkg'] == 1) {
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Count']++;
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Title'] = str_replace('(Internal)', '', $travelitenaryaccomArray['Title']);
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['Destination'] = $DestinationNameById[$travelitenaryaccomArray['XRefCityId']];
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['StarRating'] = $travelitenaryaccomArray['StarRating'];
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['FromDate'] = $travelitenaryaccomArray['FromDate'];
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['ToDate'] = $travelitenaryaccomArray['ToDate'];
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['RoomName'] = $tplanitenaryaccomdata[$k]['RoomName'] ? $tplanitenaryaccomdata[$k]['RoomName'] : '';
$HotelDestinationWise[$travelitenaryaccomArray['AccoSysId']]['RoomMealType'] = $tplanitenaryaccomdata[$k]['RoomMealType'] ? $tplanitenaryaccomdata[$k]['RoomMealType'] : '';
}
$HotelVoucherStatus = 1;
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$startDay = $seqItenDay[$existingtpintID] - 1;
$accomStartDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $startDay days")); // strtotime(date("Y-m-d", strtotime($main_trip_start_date)) . " +".$startDay."days");;
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenrayEvents[$k]['Sequence'] ? $tpitenrayEvents[$k]['Sequence'] : 0,
'AgencySysId' => $agencySysId,
'SupplierSysId' => $tpitenrayEvents[$k]['SupplierSysId'] ? $tpitenrayEvents[$k]['SupplierSysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? $tpitenrayEvents[$k]['Title'] : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? $tpitenrayEvents[$k]['Type'] : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? $tpitenrayEvents[$k]['CityId'] : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? $tpitenrayEvents[$k]['Cost'] : 0,
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'] ? $tpitenrayEvents[$k]['IsActive'] : 1,
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
'FromDate' => $accomStartDate,
'ToDate' => $accomStartDate,
);
$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPSysId' => $tpproposalID,
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $agencySysId,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_crmcustomertravelItenaryPlaces->addCustomerTravelItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetTravelPlanSightSeeing($tplanitenayvalues);
if (!empty($tpitenarysightseeing)) {
$optionalSightIncludeArr = array();
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$startDay = $seqItenDay[$existingtpintID] - 1;
$accomStartDate = date('Y-m-d', strtotime($main_trip_start_date . "+ $startDay days")); // strtotime(date("Y-m-d", strtotime($main_trip_start_date)) . " +".$startDay."days");;
$type = in_array($tpitenarysightseeing[$k]['VersionId'], $optionalSightIncludeArr) ? 'Included' : $tpitenarysightseeing[$k]['Type'];
if ($tpitenarysightseeing[$k]['IsOptionalSightSeeing'] == 1) {
$CostNativeAdult = $newSsdaywiseArr[$tpitenarysightseeing[$k]['VersionId']]['CostNativeAdult'];
$CostNativeChild = $newSsdaywiseArr[$tpitenarysightseeing[$k]['VersionId']]['CostNativeChild'];
$CostAdultMarkup = $newSsdaywiseArr[$tpitenarysightseeing[$k]['VersionId']]['CostAdultMarkup'];
$CostKidsMarkup = $newSsdaywiseArr[$tpitenarysightseeing[$k]['VersionId']]['CostKidsMarkup'];
}
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'XrefInvnItemSysId' => $tpitenarysightseeing[$k]['XrefInvnItemSysId'] ? $tpitenarysightseeing[$k]['XrefInvnItemSysId'] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $agencySysId,
'SupplierSysId' => (isset($SupplierSysId) && !empty($SupplierSysId)) ? (int) $SupplierSysId : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => !empty($type) ? $type : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'FromDate' => $accomStartDate,
'ToDate' => $accomStartDate,
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
'CurrencyType' => $tpitenarysightseeing[$k]['CurrencyType'] ? $tpitenarysightseeing[$k]['CurrencyType'] : 1,
'IsOptionalSightSeeing' => $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] ? $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] : 0,
'Cost' => isset($CostNativeAdult) ? $CostNativeAdult : 0,
'KidsCost' => isset($CostNativeChild) ? $CostNativeChild : 0,
'Markup' => isset($CostAdultMarkup) ? $CostAdultMarkup : 0,
'ChildMarkup' => isset($CostKidsMarkup) ? $CostKidsMarkup : 0,
'AddOnServiceSysId' => $AddOnServiceSysId
);
$travelitenraysightssing = $this->_crmcustomertravelSightSeeing->addCustomerTravelItenarySightSeeing($tpitenraysightseeingArray);
}
$SightseeingVoucherStatus = 1;
}
if($IsPackageShareBaseCurrency == 1){
$PackageExchangeRate = 1;
}
//echo "<pre>";print_r($travelplanPriceArr);die;
$travelplanPriceArr = $this->_crmcusttravelplan->GetTravelRate($travelplanID, $MarketPlaceId, $main_trip_start_date);
$travelplanmarketPrice = $this->_crmcusttravelplan->GetTravelMarketPrice($travelplanID, $MarketPlaceId, $main_trip_start_date);
if (!empty($travelplanPriceArr)) {
foreach ($travelplanPriceArr as $travelplanPrice) {
unset($travelplanPrice['TPRateSheetSysId']);
$travelpriceArray = $travelplanPrice;
$CostDO = round(($travelplanPrice['CostDO'] * $PackageExchangeRate), 2);
$CostSO = round(($travelplanPrice['CostSO'] * $PackageExchangeRate), 2);
$CostExtraBed = round(($travelplanPrice['CostExtraBed'] * $PackageExchangeRate), 2);
$CostWithoutBed = round(($travelplanPrice['CostWithoutBed'] * $PackageExchangeRate), 2);
$CostInfent = round(($travelplanPrice['CostInfent'] * $PackageExchangeRate), 2);
$AdultCostExtraBed = round(($travelplanPrice['AdultCostExtraBed'] * $PackageExchangeRate), 2);
$CostQuad = round(($travelplanPrice['CostQuad'] * $PackageExchangeRate), 2);
$CostChildWOEBTwoToFour = round(($travelplanPrice['CostChildWOEBTwoToFour'] * $PackageExchangeRate), 2);
$CostChildEBTwoToFour = round(($travelplanPrice['CostChildEBTwoToFour'] * $PackageExchangeRate), 2);
$CostQuint = round(($travelplanPrice['CostQuint'] * $PackageExchangeRate), 2);
$CostHexa = round(($travelplanPrice['CostHexa'] * $PackageExchangeRate), 2);
$CurrencyType = ($PackageExchangeRate == 1) ? $travelplanPrice['CurrencyType'] : $baseCurrencyId;
$travelpriceArray['TPSysId'] = $tpproposalID;
$travelpriceArray['CurrencyType'] = $CurrencyType;
$travelpriceArray['TotalCost'] = round(($travelplanPrice['TotalCost'] * $PackageExchangeRate), 2);
$travelpriceArray['CostPerPerson'] = round(($travelplanPrice['CostPerPerson'] * $PackageExchangeRate), 2);
$travelpriceArray['CostDO'] = $CostDO;
$travelpriceArray['CostSO'] = $CostSO;
$travelpriceArray['CostExtraBed'] = $CostExtraBed;
$travelpriceArray['CostWithoutBed'] = $CostWithoutBed;
$travelpriceArray['CostInfent'] = $CostInfent;
$travelpriceArray['AdultCostExtraBed'] = $AdultCostExtraBed;
$travelpriceArray['CostQuad'] = $CostQuad;
$travelpriceArray['CostChildWOEBTwoToFour'] = $CostChildWOEBTwoToFour;
$travelpriceArray['CostChildEBTwoToFour'] = $CostChildEBTwoToFour;
$travelpriceArray['CostQuint'] = $CostQuint;
$travelpriceArray['CostHexa'] = $CostHexa;
$travelpriceArray['CreateDate'] = $createDate;
$travelpriceArray['UpdateDate'] = $createDate;
$this->_crmcustomertravelPlanRate->addCustomerTravelPlanRate($travelpriceArray);
$MarkType = $travelplanmarketPrice[0]['MarkType'];
$MarkPercent = $travelplanmarketPrice[0]['MarkPercent'];
if ($MarkType == 'FixedAmount') {
$CostSO = $CostSO + $MarkPercent;
$CostDO = $CostDO + $MarkPercent;
$CostExtraBed = $CostExtraBed + $MarkPercent;
$AdultCostExtraBed = $AdultCostExtraBed + $MarkPercent;
$CostWithoutBed = $CostWithoutBed + $MarkPercent;
$CostInfent = $CostInfent + $MarkPercent;
} else {
$CostSO = $CostSO + ($CostSO * $MarkPercent / 100);
$CostDO = $CostDO + ($CostDO * $MarkPercent / 100);
$CostExtraBed = $CostExtraBed + ($CostExtraBed * $MarkPercent / 100);
$AdultCostExtraBed = $AdultCostExtraBed + ($AdultCostExtraBed * $MarkPercent / 100);
$CostWithoutBed = $CostWithoutBed + ($CostWithoutBed * $MarkPercent / 100);
$CostInfent = $CostInfent + ($CostInfent * $MarkPercent / 100);
}
$fromDate = $travelplanPrice['StartDate'];
$toDate = $travelplanPrice['ValidTill'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $agencySysId,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $CurrencyType,
'MarkType' => $MarkType,
'MarketPlaceId' => $MarketPlaceId,
'MarketPlace' => ($MarketPlaceId == 2) ? 'MY B2B' : 'MY B2C',
'Permission' => $travelplanmarketPrice[0]['Permission'],
'MarkPercent' => $MarkPercent,
'CostPPSO' => round($CostSO, 1),
'CostPPDO' => round($CostDO, 1),
'CostExtraBed' => round($CostExtraBed, 1),
'AdultCostExtraBed' => round($AdultCostExtraBed, 1),
'CostChildWithoutBed' => round($CostWithoutBed, 1),
'Tax' => $travelplanmarketPrice[0]['Tax'] ? $travelplanmarketPrice[0]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[0]['ExcludedPercent'] ? $travelplanmarketPrice[0]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
'PackCategoryId' => $travelplandata[0]['EconomyMask'] ? $travelplandata[0]['EconomyMask'] : 0,
'TourType' => 1, // FOR private tour and readymade is always private
'CostInfent' => round($CostInfent, 1),
'Pax' => $travelplanPrice['Pax'],
);
$travelitenramarketwsierate = $this->_crmcustomertravelMarketPlaces->addCustomerTravelMarketRate($travelmarketpriceArray);
}
}
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTerms($travelplanID);
if (!empty($travelplanterms)) {
for ($k = 0; $k < count($travelplanterms); $k++) {
$IsInclusions = isset($travelplanterms[$k]['IsInclusions']) ? (int) $travelplanterms[$k]['IsInclusions'] : 0;
$IsExclusions = isset($travelplanterms[$k]['IsExclusions']) ? (int) $travelplanterms[$k]['IsExclusions'] : 0;
$IsCancellationPolicy = isset($travelplanterms[$k]['IsCancellationPolicy']) ? (int) $travelplanterms[$k]['IsCancellationPolicy'] : 0;
$IsTravelBasics = isset($travelplanterms[$k]['IsTravelBasics']) ? (int) $travelplanterms[$k]['IsTravelBasics'] : 0;
$IsTermsAndConditions = isset($travelplanterms[$k]['IsTermsAndConditions']) ? (int) $travelplanterms[$k]['IsTermsAndConditions'] : 0;
$IsBookingTerms = isset($travelplanterms[$k]['IsBookingTerms']) ? (int) $travelplanterms[$k]['IsBookingTerms'] : 0;
$IsWhyUseUs = isset($travelplanterms[$k]['IsWhyUseUs']) ? (int) $travelplanterms[$k]['IsWhyUseUs'] : 0;
$IsREFUNDPOLICY = isset($travelplanterms[$k]['IsREFUNDPOLICY']) ? (int) $travelplanterms[$k]['IsREFUNDPOLICY'] : 0;
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $agencySysId,
'Inclusions' => ($travelplanterms[$k]['Inclusions'] != '' && $IsInclusions == 1) ? $travelplanterms[$k]['Inclusions'] : '',
'Exclusions' => ($travelplanterms[$k]['Exclusions'] != '' && $IsExclusions == 1) ? $travelplanterms[$k]['Exclusions'] : '',
'CancellationPolicy' => ($travelplanterms[$k]['CancellationPolicy'] != '' && $IsCancellationPolicy == 1) ? $travelplanterms[$k]['CancellationPolicy'] : '',
'TravelBasics' => ($travelplanterms[$k]['TravelBasics'] != '' && $IsTravelBasics == 1) ? $travelplanterms[$k]['TravelBasics'] : '',
'TermsAndConditions' => ($travelplanterms[$k]['TermsAndConditions'] != '' && $IsTermsAndConditions == 1) ? $travelplanterms[$k]['TermsAndConditions'] : '',
'BookingTerms' => ($travelplanterms[$k]['BookingTerms'] != '' && $IsBookingTerms == 1) ? $travelplanterms[$k]['BookingTerms'] : '',
//'BookingTerms' => $travelplanterms[$k]['BookingTerms'] ? $travelplanterms[$k]['BookingTerms'] : 0,
//'WhyUseUs' => $travelplanterms[$k]['WhyUseUs'] ? $travelplanterms[$k]['WhyUseUs'] : 0,
'WhyUseUs' => ($travelplanterms[$k]['WhyUseUs'] != '' && $IsWhyUseUs == 1) ? $travelplanterms[$k]['WhyUseUs'] : '',
'REFUNDPOLICY' => ($travelplanterms[$k]['REFUNDPOLICY'] != '' && $IsREFUNDPOLICY == 1) ? $travelplanterms[$k]['REFUNDPOLICY'] : '',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
$OtherServices = $this->_crmcusttravelplan->GetTravelPlanOtherServices($MasterRefId);
if (!empty($OtherServices)) {
foreach ($OtherServices as $osKey => $osVal) {
$exchangerate = 1;
if (isset($ShareCurrencyArr[0]) && !empty($ShareCurrencyArr[0])) {
$exchangerate = $objPackage->currencyExchangeRate($osVal['CurrencyType'], $ShareCurrencyArr[0]);
}
$travelitenaryservices = array(
'TPIntSysId' => $tpproposalID,
'OtherSrvSysId' => $osVal['OtherSrvSysId'],
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => $osVal['SupplierSysId'],
'ServiceTitle' => $osVal['ServiceTitle'],
'ServiceType' => $osVal['ServiceType'],
'Comment' => $osVal['Comment'],
'CurrencyType' => (isset($ShareCurrencyArr[0])) ? $ShareCurrencyArr[0] : $osVal['CurrencyType'],
'RateType' => $osVal['RateType'],
'PaxCount' => $osVal['PaxCount'],
'Cost' => $osVal['Cost'] * $exchangerate,
'AdultCost' => $osVal['AdultCost'] * $exchangerate,
'ChildCost' => $osVal['ChildCost'] * $exchangerate,
'IsOptionalServices' => $osVal['IsOptionalServices'] ? $osVal['IsOptionalServices'] : 0,
'IsCostInclInTP' => $osVal['IsCostInclInTP'],
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => $osVal['IsMarkForDelete'],
'IsApproved' => $osVal['IsApproved'],
'IsActive' => $osVal['IsActive'],
'ItenarySysId' => isset($lasttravelitenaryID[0]) ? (int) $lasttravelitenaryID[0] : 0,
);
$lasttravelitenaryotherservices[] = $objPackage->insertData('TB_Agency_Customer_TravelPlan_OtherServices', $travelitenaryservices);
}
$OtherVoucherStatus = 1;
}
$lastvisaID = 0;
if (isset($VisaDetails['InvnVisaAllSysId']) && (int) $VisaDetails['InvnVisaAllSysId'] > 0) {
$visaData = array(
'TPIntSysId' => isset($lasttravelitenaryID[0]) ? (int) $lasttravelitenaryID[0] : 0,
'SeqId' => 1,
'VisaSysId' => $VisaDetails['InvnVisaAllSysId'],
'XrefInvnItemSysId' => 0,
'Title' => trim($VisaDetails['VisaName']),
'VisaValidity' => $VisaDetails['VisaValidity'],
'VisaDuration' => $VisaDetails['VisaDuration'],
'AgencySysId' => $agencySysId,
'AgentSysId' => $agentsysID,
'RoomInfoJson' => json_encode($roomjson),
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $main_trip_start_date,
'ToDate' => $main_trip_end_date ? $main_trip_end_date : $main_trip_start_date,
'NetCost' => $visaPriceWithGST,
'Cost' => $VisaCost,
'Markup' => $VisaMarkup,
'CurrencyType' => $ShareCurrency,
'SupplierSysId' => (int) $VisaDetails['SupplierSysId'],
'IsMarkForDelete' => 0,
'IsActive' => 1,
);
$lastvisaID = $objPackage->insertData("TB_Agency_Customer_TravelPlan_Visa", $visaData);
}
if ($isShareWithFlight == 1 && $flightPriceWithGST > 0) {
$flightDetailCost = $flightCost;
$flightDetailTotal = $flightPriceWithGST;
$flightDetailMarkup = $flightMarkup;
$flightDetailGST = $FullServiceTaxFlight;
if ((int) $flightDetailTotal > 0) {
$addonFlightData = [
'AgencySysId' => (int) $agencySysId,
'TPSysId' => (int) $tpproposalID,
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => (isset($package_flightdetails['supplier_type_id']) && !empty($package_flightdetails['supplier_type_id'])) ? $package_flightdetails['supplier_type_id'] : $SupplierSysId,
'PlanType' => 1,
'InvnSysId' => 0,
'ServiceTitle' => 'Flight',
'CurrencyType' => !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'], // Currency Id
'GSTTYPE' => $GSTApplicableOnFlight, // GST 18,15
'Tax' => (float) ($flightDetailGST), // GST Tax
'Cost' => $flightDetailCost,
'Markup' => (float) $flightDetailMarkup,
'TotalCost' => (float) $flightDetailTotal,
'Discount' => $AgencyDiscountFlight,
'ExtraMarkUp' => $AgencyExtraMarkUpFlight,
'ShareCombined' => $ShareCombinedPricing,
'IsActive' => 1,
'IsApplyTax' => $ShareWithTCSFlight,
'ShareWithComponent' => 0 ,
];
$saveAddonServicesData = $objPackage->saveAddonServicesData($addonFlightData);
$FlightVoucherStatus = 1;
}
}
if ((int) $visaPriceWithGST > 0) {
$addonFlightData = [
'AgencySysId' => (int) $agencySysId,
'TPSysId' => (int) $tpproposalID,
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => (isset($visaData['SupplierSysId']) && !empty($visaData['SupplierSysId'])) ? $visaData['SupplierSysId'] : 0,
'PlanType' => 6,
'InvnSysId' => 0,
'ServiceTitle' => 'Visa',
'CurrencyType' => !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'], // Currency Id
'GSTTYPE' => $GSTApplicableOnVisa, // GST 18,15
'Tax' => (float) $visaGST, // GST Tax
'Cost' => $VisaCost,
'Markup' => (float) $VisaMarkup,
'TotalCost' => (float) $visaPriceWithGST,
'Discount' => $AgencyDiscountVisa,
'ExtraMarkUp' => $AgencyExtraMarkUpVisa,
'ShareCombined' => $ShareCombinedPricingVisa,
'IsActive' => 1,
'IsApplyTax' => $ShareWithTCSVisa,
'AdultCount' => $totaladult,
'ChildCount' => $totalchild,
'InfentCount' => $totalInfant,
'AdultCost' => $visaNetAdultCost,
'ChildCost' => $visaNetChildCost,
'InfantCost' => $visaNetInfantCost,
'ShareWithComponent' => $ShareWithComponentFlightVisa,
];
// echo"<pre>";print_r($addonFlightData);die('d');
$saveAddonServicesData = $objPackage->saveAddonServicesData($addonFlightData);
$FlightVoucherStatus = 1;
}
if (!empty($TcsTaxSysId)) {
$tcscostPackage = $tcscostFlight = $tcscostVisa = $totalCostForTcs = 0;
if ($ShareWithTCSPackage == 1) {
$tcscostPackage = round(($totalCostPackageOnly * 5 / 100), 2);
$totalCostForTcs = $totalCostForTcs + $totalCostPackageOnly;
}
if ($ShareWithTCSFlight == 1) {
$totalCostForTcs = $totalCostForTcs + (float) $flightDetailTotal;
$tcscostFlight = round(((float) $flightDetailTotal * 5 / 100), 2);
}
if ($ShareWithTCSVisa == 1) {
$totalCostForTcs = $totalCostForTcs + (float) $visaPriceWithGST;
$tcscostVisa = round(((float) $visaPriceWithGST * 5 / 100), 2);
}
$tcscost = $tcscostPackage + $tcscostFlight + $tcscostVisa;
$costwithtcs = $totalCostForTcs + $tcscost;
$addonTcsData = [
'AgencySysId' => (int) $agencySysId,
'TPSysId' => (int) $tpproposalID,
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => 0,
'PlanType' => 25,
'InvnSysId' => 0,
'ServiceTitle' => 'TCS Approx',
'CurrencyType' => !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'],
'GSTTYPE' => (float) 5,
'Tax' => $tcscost,
'Cost' => $totalCostForTcs,
'TotalCost' => (float) $costwithtcs,
'IsActive' => 0,
'displayTCS' => (int) $displayTCS,
];
$saveAddonServicesData = $objPackage->saveAddonServicesData($addonTcsData);
$tcscost = 0;
$costwithtcs = $totalCostForTcs + $tcscost;
$addonTcsData = [
'AgencySysId' => (int) $agencySysId,
'TPSysId' => (int) $tpproposalID,
'CustomerSysId' => (int) $customerID,
'SupplierSysId' => 0,
'PlanType' => 21,
'InvnSysId' => 0,
'ServiceTitle' => 'TCS',
'CurrencyType' => !empty($ShareCurrencyArr) ? $ShareCurrencyArr[0] : $travelplandata[0]['CurrencyType'],
'GSTTYPE' => (float) 5,
'Tax' => $tcscost,
'Cost' => $totalCostForTcs,
'TotalCost' => (float) $costwithtcs,
'IsActive' => 0,
'displayTCS' => (int) $displayTCS,
];
$saveAddonServicesData = $objPackage->saveAddonServicesData($addonTcsData);
}
//echo "<pre>";print_r($saveAddonServicesData);die;
$cancelPolicyData = $objPackage->getPackageCancelPolictyList($travelplanID);
if (!empty($cancelPolicyData)) {
$cancelPolicyArray = array();
foreach ($cancelPolicyData as $cancelPolicy) {
unset($cancelPolicy['TPRulesSysId']);
$cancelPolicyArray = $cancelPolicy;
$cancelPolicyArray['TPSysId'] = $tpproposalID;
$cancelPolicyArray['CreateDate'] = $createDate;
$cancelPolicyArray['UpdateDate'] = $createDate;
$travelplancancelpolicyids[] = $objPackage->insertData('TB_Agency_Customer_TravelPlan_Rules', $cancelPolicyArray);
}
}
$expectedClosureData = [
'ExpectedClosureDate' => $pkgCheckInDate,
'ExpectedValue' => $totalCost ? round($totalCost, 2) : 0,
];
//$ClosureData = $this->_crmcusttravelplan->expectedClosureData($leadID, $expectedClosureData);
if ($HotelVoucherStatus > 0) {
$expectedClosureData['HotelVoucherStatus'] = 0;
}
if ($FlightVoucherStatus > 0) {
$expectedClosureData['FlightVoucherStatus'] = 0;
}
if ($SightseeingVoucherStatus > 0) {
$expectedClosureData['SightseeingVoucherStatus'] = 0;
}
if ($TransferVoucherStatus > 0) {
$expectedClosureData['TransferVoucherStatus'] = 0;
}
if ($OtherVoucherStatus > 0) {
$expectedClosureData['OtherVoucherStatus'] = 0;
}
$ClosureData = $this->_crmcusttravelplan->expectedClosureData($tpproposalID, $expectedClosureData);
Zend_Controller_Action_HelperBroker::getStaticHelper('PackageSearch')->enqsupupdatestatus($sessionPackageSearchData->searchData['EnqSupplierSysId'], 2); //2 for proposal
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$CountryCode = isset($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) . '-' : '+91-';
$primarycontact = $sessionLogin_user->ContactNo1 ? $sessionLogin_user->ContactNo1 : 'N/A';
$agencyDisplayName = trim($sessionLogin_user->agencyDetails['DisplayName']);
$PrimaryEmail = trim($sessionLogin_user->agencyDetails['PrimaryEmail']);
$sendersEmailId = trim($sessionLogin_user->EmailId);
$agencyDisplayName = (!empty($agencyDisplayName)) ? $agencyDisplayName : trim($sessionLogin_user->agencyDetails['Title']);
$Logo = $sessionLogin_user->Logo;
$pricetype = $this->_request->getParam('pricetype');
$enctpproposalID = base64_encode($tpproposalID);
$secureCode = Catabatic_ValidateCustomer::secureCode($enctpproposalID, 1);
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
$DynamicUrl = '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
//$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($custemail), $agencySysId);
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($agentsysID);
if ($agentDetails['IsB2CSite'] == 1) {
$DynamicUrl = "detail/index/view/id/" . base64_encode($booknowurl);
$booknowurl = $agentDetails['Url'] . $DynamicUrl;
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 1)) {
$DynamicUrl = "hellogtx/index.html?id=" . base64_encode($booknowurl);
$booknowurl = $agentDetails['Url'] . $DynamicUrl;
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 0)) {
$DynamicUrl = "hellogtx/gtx.php?id=" . base64_encode($booknowurl);
$booknowurl = $agentDetails['Url'] . $DynamicUrl;
}
$markupMdl = new Markup_Model_Markup();
$isDisplayTaxAgency = $markupMdl->getDetailsAgencyCurrencyDeatil("TB_Agency", $agencySysId);
$isDisplayTax = $isDisplayTaxAgency['TaxLabelId'];
$DefaultPDF = (isset($agentDetails['DefaultPDF']) && $agentDetails['DefaultPDF'] > 0) ? (int) $agentDetails['DefaultPDF'] - 1 : 0;
$isHold = $this->_request->getParam('isHold') ? $this->_request->getParam('isHold') : 0;
$HoldDay = $this->_request->getParam('HoldDay') ? $this->_request->getParam('HoldDay') : 1;
if ($isHold == 1 && $IsFixedDeparturePackage == 1) {
$modelPayment = new Payment_Model_Payment();
$modelPayment->lockInventory($tpproposalID, $HoldDay);
}
$sentpriceWP = 0;
if ($pricetype == 'wop') {
$sentprice = $pricerange;
$sentpriceWP = $pricerange;
$transactiontravelplandata = $this->_crmcusttravelplan->GetTravelPlanByCustomer($tpproposalID);
} else {
$CurrSymbol = trim($ShareCurrencyArr[1]);
if (isset($getData['PackageTypePS']) && $getData['PackageTypePS'] == 'PS') {
$fp = isset($getData['newcost']) ? (float) $getData['newcost'] : 0;
$totaltraveller = $totaladult + $totalchild;
$fp = round($totalCost / $totaltraveller);
} else {
$totaltraveller = $totaladult + $totalchild;
}
$transactiontravelplandata = $this->_crmcusttravelplan->GetTravelPlanByCustomer($tpproposalID); // get proposal data from customer travel plan
if ($IsShareWithGST == 1) {
$sentprice = $CurrSymbol . ' ' . round($totalCost, 2);
$sentpriceWP = $totalCost;
} else {
$PackageArray = $transactiontravelplandata[0];
$sentpriceWP = $totalCost;
$totalCost = $totalCost - ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
$sentprice = $CurrSymbol . ' ' . round($totalCost, 2);
}
}
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $agencySysId;
if (isset($Logo) && $Logo != '') {
$AgencyLogo = $pathAgency . '/' . $Logo;
} else {
$AgencyLogo = $path . '/gtx-logo-white.png';
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$custsalutation = $ARR_SALUTION[$gettplandataforcustomer[0]['Salutation']];
$custname = trim($gettplandataforcustomer[0]['FirstName']);
$lname = $gettplandataforcustomer[0]['LastName'];
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$params['IsFromGTXNetwork'] = $IsFromGTXNetwork;
$params['packageID'] = $packid;
$params['intLoggedinUserAgencySysId'] = $agencySysId;
$params['isDisplayTax'] = $isDisplayTax;
$params['agency_logo'] = $AgencyLogo;
$params['trip_address'] = $tripaddress;
$params['shared_url'] = $booknowurl;
$params['sent_price'] = $sentprice; //total price with currency
$params['price'] = $totalCost; // total price
$params['travelers'] = array('Adults' => $totaladult, 'Child' => $totalchild, 'Infants' => $totalInfant); // travelers to display
$params['cust_name'] = $custsalutation . ' ' . trim($custname) . ' ' . trim($lname);
$params['cust_first_name'] = $custsalutation . ' ' . trim($custname);
$params['about_package'] = '';
$params['GreetingMessage'] = isset($transactiontravelplandata[0]['GreetingMessage']) ? $transactiontravelplandata[0]['GreetingMessage'] : 0;
$params['agent_firstname'] = $firstname;
$params['agent_primarycontact'] = $primarycontact;
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $proposalEmailFrom;
$params['b2bagencyDisplayName'] = (isset($transactiontravelplandata[0]['CompanyName'])) ? trim($transactiontravelplandata[0]['CompanyName']) : '';
$params['agencyDisplayName'] = $agencyDisplayName;
$params['PrimaryEmail'] = $PrimaryEmail;
$params['TPSysId'] = $tpproposalID;
$params['AgentSysId'] = $agentsysID;
$params['AgencySysId'] = $agencySysId;
$params['PackageArray'] = isset($transactiontravelplandata[0]) ? $transactiontravelplandata[0] : array();
$params['agentDetails'] = $agentDetails;
$params['CustomerSysId'] = $customerID;
$params['IsSMSApi'] = $this->IsSMSApi;
$subject = $emailsubject ? $emailsubject : 'Proposal Details';
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$params['arrEmailStatisticsType'] = $arrEmailStatisticsType[0];
$params['TourTypeId'] = $TourTypeId;
$params['PackageArray']['NetworkExtraMarkup'] = $MarkUpOnGTXNetworkPackage;
$mailToCC = array();
if ($ccemail != '') {
$mailToCC = explode(',', $ccemail);
}
$params['customer_contact'] = trim($getcustomerdetails['Contacts']);
$params['customer_countrycode'] = trim($getcustomerdetails['countrycode']);
if ($Isclipboard == 1) {
$copyclipboardbody = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->CopyEmailBodyToClipboard($custemail, $subject, $params, $mailToCC);
}
if ($IsSendMail == 1) {
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->SendProposalToCustomer($custemail, $subject, $params, $mailToCC);
//echo "<pre>";print_r($emailStatus);die;
} else {
$emailStatus = 1;
}
$booknowurl = $booknowurl;
if ($params['customer_contact'] != '') {
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$params['arrSMSStatisticsType'] = $arrSMSStatisticsType[0];
if ($IsSendSms == 1) {
// $smsStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->SendSmsToCustomer($params);
}
$shorturl_response = Zend_Controller_Action_HelperBroker::getStaticHelper('ShortUrl')->url_get($params);
if (isset($shorturl_response['status_code']) && $shorturl_response['status_code'] == 200) {
$booknowurl = $shorturl_response['data']['short_url'];
}
}
if ($IsFromGTXNetwork) {
$arrData = array(
"packid" => $packid,
"isfromgtxnetwork" => $IsFromGTXNetwork,
"intLoggedinUserAgencySysId" => $agencySysId
);
$strUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataEncode($arrData);
//$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/data/' . $strUrlData . '/code/' . $secureCode;
$agentRegistrationApiData = array(
'AgencySysId' => (int) $GTXNetworkAgencySysId,
'B2CAgencySysId' => (int) $agencySysId,
'AgentSysId' => 0,
);
try {
$curl = curl_init($this->baseUrl . "/gtxwebservices/b2b-agency-create"); // b2c site url
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($agentRegistrationApiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$getresponseAgencyData = curl_exec($curl);
curl_close($curl);
$getresponseAgencyDataArray = Zend_Json::decode($getresponseAgencyData, true);
if (isset($getresponseAgencyDataArray) && !empty($getresponseAgencyDataArray)) {
$postFields = array(
'TravelPlanId' => $travelplanID,
'Salutation' => isset($getresponseAgencyDataArray['data']['Salutation']) ? trim($getresponseAgencyDataArray['data']['Salutation']) : 1,
'FirstName' => trim($getresponseAgencyDataArray['data']['FirstName']),
'LastName' => trim($getresponseAgencyDataArray['data']['LastName']),
'Email' => trim($getresponseAgencyDataArray['data']['EmailID']),
'MobileNumber' => trim($getresponseAgencyDataArray['data']['MobileNo']),
'CountryCode' => trim($getresponseAgencyDataArray['data']['CountryCode']),
'agencyName' => trim($getresponseAgencyDataArray['data']['agencyName']),
'IsB2BAgent' => 1,
'PriceRange' => $priceRange,
'PKGCheckInDate' => $pkgCheckInDate,
'PKGCheckOutDate' => $pkgCheckOutDate,
'MinPrice' => 0,
'DestinationID' => $destinationIds,
'Destination' => $destinationValues,
'IsFixedDeparturePackage' => !empty($travelplandata[0]['IsFixedDeparturePackage']) ? $travelplandata[0]['IsFixedDeparturePackage'] : 0,
'roomjson' => $RoomInfoJson,
'leadsource' => 'GTX Network',
'remark' => '',
'AgencyIdB2B' => $GTXNetworkAgencySysId,
'AgencyIdB2C' => $agencySysId,
'AgencySysId' => $GTXNetworkAgencySysId,
'aId' => $getresponseAgencyDataArray['data']['UserSysId'],
'selectedCustomerId' => base64_encode($getresponseAgencyDataArray['data']['CustomerSysId']),
'isPriceShared' => $isPriceShared,
'FromDestinationId' => isset($going_from_cityid) ? $going_from_cityid : $travelplandata[0]['SourcePlaceSysId'],
'FromDestination' => isset($going_from_cityname) ? $going_from_cityname : $travelplandata[0]['SourcePlaces'],
);
$curl = curl_init($this->baseUrl . "/gtxwebservices/b2b-readymade-query"); // b2c site url
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$getresponseData = curl_exec($curl);
curl_close($curl);
$getresponseDataArr = Zend_Json::decode($getresponseData, true);
}
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
$HotelHtml = $HotelListHtml = $HotelListHtmlwp = '';
$inch = 1;
foreach ($HotelDestinationWise as $hdwKey => $hdwValue) {
$hotelfromDate = new DateTime($hdwValue['FromDate']); // "2025-12-19"
$hoteltoDate = new DateTime($hdwValue['ToDate']); // "2025-12-21"
$hotelfromDay = $hotelfromDate->format("j");
$hoteltoDay = $hoteltoDate->format("j");
$hotelfrommonth = strtolower($hotelfromDate->format("M"));
$hoteltomonth = strtolower($hoteltoDate->format("M"));
$HotelFromToDate = $hotelfromDay . (($hotelfrommonth !== $hoteltomonth) ? " " . $hotelfrommonth : '') . " – " . $hoteltoDay . " " . $hoteltomonth;
$DestinationMM = explode('(', $hdwValue['Destination']);
$HotelHtml .= trim($DestinationMM[0]) . '(' . $hdwValue['Count'] . 'N): *' . trim($hdwValue['Title']) . '*\n\n';
$HotelListHtml .= ($inch == 1) ? '%0a%0a *🏨 HOTELS* %0a' : '';
$HotelListHtml .= ' • *' . trim($DestinationMM[0]) . ' - ' . $hdwValue['Count'] . (($hdwValue['Count'] > 1) ? ' Nights' : ' Night') . ' (' . $HotelFromToDate . ')' . '*%0a';
$HotelListHtml .= '' . trim($hdwValue['Title']) . ' - ' . $hdwValue['RoomName'] . ' (' . $hdwValue['RoomMealType'] .')'. '%0a%0a';
$HotelListHtmlwp .= ($inch == 1) ? '<p style="margin-bottom: 0px;"><strong>🏨 HOTELS</strong></p>' : '';
$HotelListHtmlwp .= '<p style="margin-bottom: 0;"><strong> • ' . trim($DestinationMM[0]) . ' - ' . $hdwValue['Count'] . (($hdwValue['Count'] > 1) ? ' Nights' : ' Night') . ' (' . $HotelFromToDate . ')' . '</strong></p>';
$HotelListHtmlwp .= '<p>' . trim($hdwValue['Title']) . ' - ' . $hdwValue['RoomName'] . ' (' . $hdwValue['RoomMealType'] .') '. '</p>';
$inch++;
}
$PackSpecType = $transactiontravelplandata[0]['PackSpecType'] ? $transactiontravelplandata[0]['PackSpecType'] : '';
$packageInclList = $this->_objPkg->getPackageInclusionList();
$paramArray = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->getPackageDetailsForEmailTemplate($transactiontravelplandata[0]['TPSysId'], $transactiontravelplandata[0], $transactiontravelplandata[0]['EconomyMask']);
$inclusionsArr = Zend_Controller_Action_HelperBroker::getStaticHelper('PackageSearch')->getInclusons($transactiontravelplandata[0]['InclMask'], $packageInclList);
$inclusionTitles = !empty($inclusionsArr) ? array_column($inclusionsArr, 'title') : [];
$WpInclusion = !empty($inclusionTitles) ? '<p><strong>Includes:</strong> ' . implode(', ', $inclusionTitles) . '</p>' : '';
$WpIncl = !empty($inclusionTitles) ? '%0a *Includes:* ' . implode(', ', $inclusionTitles) : '';
$getDaywiseSightseeingArr = isset($paramArray['getDaywiseMergedActSightseeingArr']) && !empty($paramArray['getDaywiseMergedActSightseeingArr']) ? $paramArray['getDaywiseMergedActSightseeingArr'] : [];
$itenDetailArr = isset($paramArray['itenDetailArr']) && !empty($paramArray['itenDetailArr']) ? $paramArray['itenDetailArr'] : [];
if ($PackSpecType == 2) {
foreach ($getDaywiseSightseeingArr as $key => $getDaywiseMergedActSightseeing) {
if ($key == 2) {
if (isset($getDaywiseMergedActSightseeing[2])) {
unset($getDaywiseMergedActSightseeing[2]);
}
if (isset($getDaywiseMergedActSightseeing[3])) {
unset($getDaywiseMergedActSightseeing[3]);
}
$dataArr = is_array($getDaywiseMergedActSightseeing) ? call_user_func_array('array_merge', $getDaywiseMergedActSightseeing) : [];
if (!empty($dataArr)) {
$DaywiseWp .= "<p style='margin-bottom:0px;'>🖼 <strong>Sightseeing Included:</strong> " . implode(', ', $dataArr) . "</p>";
}
$itenaryTransportDataArr = $paramArray['itenaryTransportDataArr'][0] ?? [];
if (isset($itenaryTransportDataArr) && (!empty($itenaryTransportDataArr['AirportTransport']) || !empty($itenaryTransportDataArr['HotelTransport']))) {
if ($itenaryTransportDataArr['AirportTransport'] != 0 || $itenaryTransportDataArr['HotelTransport'] != 0) {
$DaywiseWp .= "<p style='margin-bottom:0px;'>🚗 <strong>Transfers:</strong> ";
$transferTxt = [];
if ($itenaryTransportDataArr['AirportTransport'] != 0) {
$transferTxt[] = "Airport/Station to Hotel (" .
($itenaryTransportDataArr['AirportTransport'] == 2 ? "PVT" : "SIC") . ")";
}
if ($itenaryTransportDataArr['HotelTransport'] != 0) {
$transferTxt[] = "Hotel to Airport/Station (" .
($itenaryTransportDataArr['HotelTransport'] == 2 ? "PVT" : "SIC") . ")";
}
$DaywiseWp .= implode(" | ", $transferTxt) . "</p>";
}
}
}
}
$DaywiseWp .= "<br>";
} else {
if (!empty($getDaywiseSightseeingArr)) {
foreach ($getDaywiseSightseeingArr as $day => $sightseeingArr) {
$SSDate = date('d M', strtotime(($transactiontravelplandata[0]['StartDate']->format('d M y')) . ' + ' . ($day - 1) . ' days'));
$titleS = $itenDetailArr[$day]['Title'] ?? '';
$DaywiseWp .= "<p style='margin-bottom:0px;'>📅 <strong>DAY {$day} – {$SSDate}" . (!empty($titleS) ? " ({$titleS})" : "") . "</strong></p>";
/* ================= Transfers ================= */
$itenaryTransportDataArr = $paramArray['itenaryTransportDataArr'][$day] ?? [];
if (isset($itenaryTransportDataArr) && (!empty($itenaryTransportDataArr['AirportTransport']) || !empty($itenaryTransportDataArr['HotelTransport']))) {
if ($itenaryTransportDataArr['AirportTransport'] != 0 || $itenaryTransportDataArr['HotelTransport'] != 0) {
$DaywiseWp .= "<p style='margin-bottom:0px;'>🚗 <strong>Transfers:</strong> ";
$transferTxt = [];
if ($itenaryTransportDataArr['AirportTransport'] != 0) {
$transferTxt[] = "Airport/Station to Hotel (" .
($itenaryTransportDataArr['AirportTransport'] == 2 ? "PVT" : "SIC") . ")";
}
if ($itenaryTransportDataArr['HotelTransport'] != 0) {
$transferTxt[] = "Hotel to Airport/Station (" .
($itenaryTransportDataArr['HotelTransport'] == 2 ? "PVT" : "SIC") . ")";
}
$DaywiseWp .= implode(" | ", $transferTxt) . "</p>";
}
}
/* ================= Sightseeing ================= */
if (is_array($sightseeingArr)) {
$sightseeing = implode(', ', call_user_func_array('array_merge', $sightseeingArr));
if (!empty($sightseeing)) {
$DaywiseWp .= "<p style='margin-bottom:0px;'>🖼️ <strong>Sightseeing:</strong> {$sightseeing} </p>";
}
}
/* ================= Meal ================= */
if (!empty($paramArray['itenDetailArr'][$day]['MealPlanInclude'])) {
$meal = implode(', ', explode(',', $paramArray['itenDetailArr'][$day]['MealPlanInclude']));
$DaywiseWp .= "<p style='margin-bottom:0px;'>🍽️ <strong>Meal:</strong> {$meal}</p>";
}
$DaywiseWp .= "<br>";
}
} else {
foreach ($itenDetailArr as $day => $dayDetail) {
$SSDate = date('d M', strtotime(($transactiontravelplandata[0]['StartDate']->format('d M y')) . ' + ' . ($day - 1) . ' days'));
$titleS = $dayDetail['Title'] ?? '';
$DaywiseWp .= "<p>📅 <strong>DAY {$day} – {$SSDate} " .
(!empty($titleS) ? "({$titleS})" : "") .
"</strong></p>";
/* ================= Transfers ================= */
$itenaryTransportDataArr = $paramArray['itenaryTransportDataArr'][$day] ?? [];
if (isset($itenaryTransportDataArr) && (!empty($itenaryTransportDataArr['AirportTransport']) || !empty($itenaryTransportDataArr['HotelTransport']))) {
if ($itenaryTransportDataArr['AirportTransport'] != 0 || $itenaryTransportDataArr['HotelTransport'] != 0) {
$DaywiseWp .= "<p style='margin-bottom:0px;'>🚗 <strong>Transfers:</strong> ";
$transferTxt = [];
if ($itenaryTransportDataArr['AirportTransport'] != 0) {
$transferTxt[] = "Airport/Station to Hotel (" .
($itenaryTransportDataArr['AirportTransport'] == 2 ? "PVT" : "SIC") . ")";
}
if ($itenaryTransportDataArr['HotelTransport'] != 0) {
$transferTxt[] = "Hotel to Airport/Station (" .
($itenaryTransportDataArr['HotelTransport'] == 2 ? "PVT" : "SIC") . ")";
}
$DaywiseWp .= implode(" | ", $transferTxt) . "</p>";
}
}
/* ================= Meal ================= */
if (!empty($dayDetail['MealPlanInclude'])) {
$meal = implode(', ', explode(',', $dayDetail['MealPlanInclude']));
$DaywiseWp .= "<p>🍽️ <strong>Meal:</strong> {$meal}</p>";
}
$DaywiseWp .= "<br>";
}
}
}
$DaywiseWhatsapp = (isset($DaywiseWp) && !empty($DaywiseWp)) ? trim(strip_tags(str_replace(['<strong>', '</strong>'], ['*', '*'], preg_replace('/<p[^>]*>/i', '',
str_replace(['<br>', '<br/>', '<br />', '</p>'], '%0A', $DaywiseWp))))) : '';
// end code for daywise whatsapp
$TravelDate = (isset($transactiontravelplandata[0]['StartDate'])) ? '%0a%0a*Travel Date:* ' . ($transactiontravelplandata[0]['StartDate']->format('d M y')) : '';
$NoofDaysHtml = ((int) $getData['TotalNights']) . ' Night';
if ($getData['TotalNights'] > 1) {
$NoofDaysHtml .= 's';
}
$NoofDaysHtml .= '/ ' . ((int) $getData['TotalNights'] + 1) . ' Day';
if ($getData['TotalNights'] > 0) {
$NoofDaysHtml .= 's';
}
$dayCount = ((int) $getData['TotalNights']);
$startTrip = new DateTime($transactiontravelplandata[0]['StartDate']->format('d M y'));
$endTrip = (clone $startTrip)->modify("+{$dayCount} days");
$fromDay = $startTrip->format("j");
$toDay = $endTrip->format("j");
$fromMonth = strtolower($startTrip->format("M"));
$toMonth = strtolower($endTrip->format("M"));
$TravelDatewp = $fromDay .
(($fromMonth !== $toMonth) ? ' ' .ucfirst($fromMonth) : '') .
' - ' .
$toDay . ' ' .
ucfirst($toMonth);
if ($totalchild > 0) {
$totalchild = "$totalchild Child(s)";
} else {
$totalchild = '';
}
if ($totalInfant > 0) {
$totalInfant = "$totalInfant Infant(s)";
} else {
$totalInfant = '';
}
$AgenctEmailId = trim($agentDetails['EmailId']);
$custname = ucwords($custsalutation . ' ' . $custname);
if ($displayTCS == 1) {
$sentpriceWP = (int) $sentpriceWP + (int) $tcscost;
}
$priceWhatsapp = $CurrSymbol . ' ' . round($sentpriceWP, 2);
$sentpriceWhatsapp = '%0a%0a*💰 PRICING (PER PERSON)* %0a' . 'Price for ' . $totaltraveller . ' Pax ' . $priceWhatsapp . '/-%0a';
$sentpriceWhatsappClip = "<p style='margin-bottom:0;'><strong>💰 PRICING (PER PERSON)</strong></p><p><strong>Price for " . $totaltraveller . " Pax:</strong> " . $priceWhatsapp . "/-</p>";
if ($isShareWithFlight == 1 && $ShareCombinedPricing == 0) {
$CurrSymbol = isset($CurrSymbol) ? $CurrSymbol : '';
if ($displayTCS == 1) {
$flightDetailTotal = $flightDetailTotal + (int) $tcscostFlight;
}
$totalpackagecost = $CurrSymbol . ' ' . ((int) $sentpriceWP - $flightDetailTotal);
$sentpriceWhatsapp = '%0a%0a*Package Cost for ' . $totaltraveller . ':* ' . $totalpackagecost . '/-%0a%0a*Flight Cost for ' . $totaltraveller . ' Pax :* ' . $CurrSymbol . ' ' . $flightDetailTotal . '/-%0a';
$sentpriceWhatsappClip = '<p><strong>Package Cost for ' . $totaltraveller . ' Pax:</strong> ' . $totalpackagecost . '/</p><p><strong>Flight Cost for ' . $totaltraveller . ' Pax :</strong> ' . $CurrSymbol . ' ' . $flightDetailTotal . '/-</p>';
}
$whatsappmessage = "*Dear $custname*,%0a%0a" . "Greetings from $agencyDisplayName !%0a%0a" . "Pls find below details for your travel enquiry -%0a%0a" . "*📍 $destinationValueswp ITINERARY* %0a" . "*📅 ️$TravelDatewp* %0a" . "*👥 No of Pax:* $totaladult Adult(s) $totalchild $totalInfant $HotelListHtml " . " --- %0a" . "$DaywiseWhatsapp" . " $sentpriceWhatsapp " . "$WpIncl %0a" . "%0a%0aTo view hotels and program in details and *book online* click on the below link:%0a%0a$booknowurl %0a%0aRegards, %0a$firstname, %0a$agencyDisplayName, %0a $CountryCode $primarycontact";
$whatsappmessageClipBoard = "<p><strong>Dear $custname,</strong></p><p>Greetings from $agencyDisplayName !</p><p>Pls find below details for your travel enquiry -</p><p style='margin-bottom: 0;'><strong>📍 $destinationValueswp ITINERARY</strong></p><p style='margin-bottom: 0;'><strong>🗓️$TravelDatewp </strong></p><p ><strong >👥No of Pax:</strong> $totaladult Adult(s) $totalchild $totalInfant</p>" . $HotelListHtmlwp . "<p>---</p>" . $DaywiseWp . $sentpriceWhatsappClip . $WpInclusion . "<p style='margin-bottom: 0;'>To view hotels and program in details and <strong>book online</strong> click on the below link: </p><p> <a href='$booknowurl' target='_blank'>$booknowurl</a></p><p style='margin-bottom:0px;'>Regards,</p><p style='margin-bottom:0px;'>$firstname</p><p style='margin-bottom:0px;'>$agencyDisplayName</p><p style='margin-bottom:0px;'>$CountryCode $primarycontact</p>";
if ($emailStatus == 1) {
if ($_SESSION['sessionLogin_user']['IsWhatsApp'] == 1 && trim($getcustomerdetails['countrycode']) != '') {
$whatsappData = array(
'SecurityKey' => trim($agentDetails['SecurityKey']),
'CustomerName' => trim($custname),
'CustomerMobile' => trim($getcustomerdetails['countrycode']) . trim($getcustomerdetails['Contacts']),
'Destination' => trim($destinationValues),
'TravelDate' => $transactiontravelplandata[0]['StartDate']->format('d M y'),
'NoofDays' => (int) $getData['TotalNights'] + 1,
'Travellers' => trim($totaladult) . ' Adult(s)' . $totalchild . $totalInfant,
'DestinationWiseHotel' => ($HotelHtml != '') ? $HotelHtml : 'NA',
'TotalCost' => trim($priceWhatsapp),
'AgentName' => trim($firstname),
'AgencyDisplayName' => trim($agencyDisplayName),
'AgentContactNo' => trim($primarycontact),
'DynamicUrl' => $DynamicUrl,
);
$this->_crmcusttravelplan->sendWhatsAppMessage($whatsappData, $this->baseUrl);
}
$response = array('status' => 'success', 'whatsapp' => $whatsappmessage, 'contactno' => trim($getcustomerdetails['countrycode']) . trim($getcustomerdetails['Contacts']), 'message' => 'Proposal has been shared with customer', 'TPSysId' => @$leadID, 'enctpproposalID' => $enctpproposalID, 'code' => $secureCode, 'DefaultPDF' => $DefaultPDF, 'whatsappClipBoard' => $whatsappmessageClipBoard);
} else {
$response = array('status' => 'fail', 'message' => 'There is some error in sending email. Please try after sometime.', 'TPSysId' => @$leadID);
}
if ($Isclipboard == 1) {
$response = array('status' => 'success', 'Isclipboard' => 1, 'copyclipboardbody' => $copyclipboardbody, 'message' => 'Email body copied to clipboard', 'TPSysId' => @$leadID, 'enctpproposalID' => $enctpproposalID, 'code' => $secureCode, 'DefaultPDF' => $DefaultPDF);
}
} else {
$response = array('status' => 'fail', 'message' => 'There is some error in sending email. Please try after sometime.', 'TPSysId' => '');
}
echo json_encode($response);
exit;
}
public function editByoQueryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
$travelplanID = $getData['tpId'];
$agentsysID = $this->intLoggedinUserId;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($travelplanID, 'Query');
$netprice = $getData['netprice'];
$objPackage = new Travel_Model_TblPackage();
$getplanenddate = $objPackage->GetTravelEndDate($travelplanID);
$countgplandate = count($getplanenddate) - 1;
$planenddate = $getplanenddate[$countgplandate]['EndDate']->format('Y-m-d');
$planbookingID = 'QS/' . date('y');
$createDate = date('Y-m-d');
$customertravelpaln = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $travelplanID,
'AgencySysId' => $gettplandataforcustomer[0]['AgencySysId'],
'AgentSysId' => $agentsysID,
'StatusType' => 4,
'CustomerSysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PlanType' => 5,
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'DestinationPlaces' => $gettplandataforcustomer[0]['DestinationPlaces'],
'DestinationPlacesSysId' => (int) $gettplandataforcustomer[0]['DestinationPlacesSysId'],
'SourcePlaces' => $gettplandataforcustomer[0]['SourcePlaces'],
'SourcePlaceSysId' => $gettplandataforcustomer[0]['SourcePlaceSysId'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'],
'Details' => $gettplandataforcustomer[0]['Details'],
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'],
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'],
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'],
'StartDate' => $gettplandataforcustomer[0]['StartDate'],
'ValidTill' => $gettplandataforcustomer[0]['ValidTill'],
'PkgSellValidTill' => $planenddate,
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'],
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'],
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'],
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'],
'AdvBookingPercent' => $gettplandataforcustomer[0]['AdvBookingPercent'] ? $gettplandataforcustomer[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $gettplandataforcustomer[0]['AdvBookingDays'] ? $gettplandataforcustomer[0]['AdvBookingDays'] : 0,
'NetPrice' => $netprice,
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'] ? $gettplandataforcustomer[0]['MinPrice'] : 0,
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'],
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'],
'Hotels' => $gettplandataforcustomer[0]['Hotels'],
'InventoryType' => 5,
'CreatorSysId' => $agentsysID,
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'],
'Cities' => $gettplandataforcustomer[0]['Cities'],
'Countries' => $gettplandataforcustomer[0]['Countries'],
'IsInsuranceExist' => $gettplandataforcustomer[0]['IsInsuranceExist'],
'RoomInfoJson' => $gettplandataforcustomer[0]['RoomInfoJson'],
'ProposalEmailTo' => $gettplandataforcustomer[0]['ProposalEmailTo'],
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
$enctpproposalID = base64_encode($tpproposalID);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetCustomerTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'StartDate' => $travelplanIetnaryData[$i]['StartDate'],
'EndDate' => $travelplanIetnaryData[$i]['EndDate'],
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'],
'IsActive' => $travelplanIetnaryData[$i]['IsActive'],
);
$lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanCustomerItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
if ($tplanitenaryaccomdata[$k]['MasterIntSysId'] > 0) {
$masterintsysID = $tplanitenaryaccomdata[$k]['MasterIntSysId'];
$getkeyvalueintID = array_search($masterintsysID, $travelpanitenary);
$getmasterID = $lasttravelitenaryID[$getkeyvalueintID];
} else {
$getmasterID = 0;
}
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'IsFromAPI' => $tplanitenaryaccomdata[$k]['IsFromAPI'],
'SupplierSysId' => $tplanitenaryaccomdata[$k]['SupplierSysId'] ? $tplanitenaryaccomdata[$k]['SupplierSysId'] : 0,
'SourceSysId' => $tplanitenaryaccomdata[$k]['SourceSysId'] ? $tplanitenaryaccomdata[$k]['SourceSysId'] : 0,
'MasterIntSysId' => $getmasterID,
'AccoBookingId' => $tplanitenaryaccomdata[$k]['AccoBookingId'] ? $tplanitenaryaccomdata[$k]['AccoBookingId'] : '',
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'InvnItemSysId' => $tplanitenaryaccomdata[$k]['InvnItemSysId'] ? $tplanitenaryaccomdata[$k]['InvnItemSysId'] : '0',
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'XrefInvtSysId' => $tplanitenaryaccomdata[$k]['XrefInvtSysId'] ? $tplanitenaryaccomdata[$k]['XrefInvtSysId'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomTypeStr' => $tplanitenaryaccomdata[$k]['RoomTypeStr'] ? $tplanitenaryaccomdata[$k]['RoomTypeStr'] : '',
'RoomMemInfoJson' => $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] ? $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] : '',
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : '',
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : 0,
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'AdultPax' => $tplanitenaryaccomdata[$k]['AdultPax'] ? $tplanitenaryaccomdata[$k]['AdultPax'] : 0,
'ChildPax' => $tplanitenaryaccomdata[$k]['ChildPax'] ? $tplanitenaryaccomdata[$k]['ChildPax'] : 0,
'InfantPax' => $tplanitenaryaccomdata[$k]['InfantPax'] ? $tplanitenaryaccomdata[$k]['InfantPax'] : 0,
'PetPax' => $tplanitenaryaccomdata[$k]['PetPax'] ? $tplanitenaryaccomdata[$k]['PetPax'] : 0,
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCost'] ? $tplanitenaryaccomdata[$k]['TotalCost'] : 0,
'TotalCostSO' => $tplanitenaryaccomdata[$k]['TotalCostSO'] ? $tplanitenaryaccomdata[$k]['TotalCostSO'] : 0,
'TotalCostDO' => $tplanitenaryaccomdata[$k]['TotalCostDO'] ? $tplanitenaryaccomdata[$k]['TotalCostDO'] : 0,
'TotalCostTO' => $tplanitenaryaccomdata[$k]['TotalCostTO'] ? $tplanitenaryaccomdata[$k]['TotalCostTO'] : 0,
'TotalCostExtraBed' => $tplanitenaryaccomdata[$k]['TotalCostTO'] ? $tplanitenaryaccomdata[$k]['TotalCostExtraBed'] : 0,
'TotalCostWithoutBed' => $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] ? $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'IsSelectedOnPkg' => $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] ? $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => $tplanitenaryaccomdata[$k]['IsMarkForDel'] ? $tplanitenaryaccomdata[$k]['IsMarkForDel'] : '',
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
$tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanCustomterItenaryAir($tplanitenayvalues);
if (!empty($tpitenaryAirdata)) {
######### Add Air Data #######
for ($i = 0; $i < count($tpitenaryAirdata); $i++) {
$existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintairID, $travelpanitenary);
$travelitenaryaccomairArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
'SeqId' => $tpitenaryAirdata[$i]['SeqId'],
'InvnItemSysId' => $tpitenaryAirdata[$i]['InvnItemSysId'],
'AgencySysId' => $tpitenaryAirdata[$i]['AgencySysId'],
'IsFromAPI' => $tpitenaryAirdata[$i]['IsFromAPI'],
'SourceSysId' => $tpitenaryAirdata[$i]['SourceSysId'],
'SupplierSysId' => $tpitenaryAirdata[$i]['SupplierSysId'],
'Cost' => $tpitenaryAirdata[$i]['Cost'],
'FlightNumber' => $tpitenaryAirdata[$i]['FlightNumber'],
'AirlineSysId' => $tpitenaryAirdata[$i]['AirlineSysId'] ? $tpitenaryAirdata[$i]['AirlineSysId'] : 0,
'ICSourceSysId' => $tpitenaryAirdata[$i]['ICSourceSysId'] ? $tpitenaryAirdata[$i]['ICSourceSysId'] : 0,
'IsFromAgency' => $tpitenaryAirdata[$i]['IsFromAgency'] ? $tpitenaryAirdata[$i]['IsFromAgency'] : 0,
'LocalFromTime' => $tpitenaryAirdata[$i]['LocalFromTime'],
'LocalToTime' => $tpitenaryAirdata[$i]['LocalToTime'],
'FromUTCTime' => $tpitenaryAirdata[$i]['FromUTCTime'],
'ToUTCTime' => $tpitenaryAirdata[$i]['ToUTCTime'],
'FlightCabinClass' => $tpitenaryAirdata[$i]['FlightCabinClass'],
'AdultPax' => $tpitenaryAirdata[$i]['AdultPax'] ? $tpitenaryAirdata[$i]['AdultPax'] : 0,
'ChildPax' => $tpitenaryAirdata[$i]['ChildPax'] ? $tpitenaryAirdata[$i]['ChildPax'] : 0,
'InfentPax' => $tpitenaryAirdata[$i]['InfentPax'] ? $tpitenaryAirdata[$i]['InfentPax'] : 0,
'TotalPax' => $tpitenaryAirdata[$i]['TotalPax'] ? $tpitenaryAirdata[$i]['TotalPax'] : 0,
'IsSelectedOnPkg' => $tpitenaryAirdata[$i]['IsSelectedOnPkg'] ? $tpitenaryAirdata[$i]['IsSelectedOnPkg'] : 1,
'IsDirect' => $tpitenaryAirdata[$i]['IsDirect'] ? $tpitenaryAirdata[$i]['IsDirect'] : 0,
'DayLightSavingDiff' => $tpitenaryAirdata[$i]['DayLightSavingDiff'] ? $tpitenaryAirdata[$i]['DayLightSavingDiff'] : 0,
'FlyingMinutes' => $tpitenaryAirdata[$i]['FlyingMinutes'] ? $tpitenaryAirdata[$i]['FlyingMinutes'] : 0,
'SourcePlaceSysId' => $tpitenaryAirdata[$i]['SourcePlaceSysId'] ? $tpitenaryAirdata[$i]['SourcePlaceSysId'] : 0,
'DestPlaceSysId' => $tpitenaryAirdata[$i]['DestPlaceSysId'] ? $tpitenaryAirdata[$i]['DestPlaceSysId'] : 0,
'SourceAirportCode' => $tpitenaryAirdata[$i]['SourceAirportCode'] ? $tpitenaryAirdata[$i]['SourceAirportCode'] : '',
'DestAirportCode' => $tpitenaryAirdata[$i]['DestAirportCode'] ? $tpitenaryAirdata[$i]['DestAirportCode'] : '',
'AirportHaultMinutes' => $tpitenaryAirdata[$i]['AirportHaultMinutes'] ? $tpitenaryAirdata[$i]['AirportHaultMinutes'] : 0,
'StopCount' => $tpitenaryAirdata[$i]['StopCount'] ? $tpitenaryAirdata[$i]['StopCount'] : 0,
'Stops' => $tpitenaryAirdata[$i]['Stops'] ? $tpitenaryAirdata[$i]['Stops'] : 0,
'Rating' => $tpitenaryAirdata[$i]['Rating'] ? $tpitenaryAirdata[$i]['Rating'] : 0,
'FllightFeatureMask' => $tpitenaryAirdata[$i]['FllightFeatureMask'] ? $tpitenaryAirdata[$i]['FllightFeatureMask'] : 0,
'UpdatedByISSysId' => $tpitenaryAirdata[$i]['UpdatedByISSysId'] ? $tpitenaryAirdata[$i]['UpdatedByISSysId'] : 0,
'CreatedByISSysId' => $tpitenaryAirdata[$i]['CreatedByISSysId'] ? $tpitenaryAirdata[$i]['CreatedByISSysId'] : 0,
'ImageTN' => $tpitenaryAirdata[$i]['ImageTN'] ? $tpitenaryAirdata[$i]['ImageTN'] : 0,
'ImgForList' => $tpitenaryAirdata[$i]['ImgForList'] ? $tpitenaryAirdata[$i]['ImgForList'] : 0,
'ImgeDetails' => $tpitenaryAirdata[$i]['ImgeDetails'] ? $tpitenaryAirdata[$i]['ImgeDetails'] : 0,
'UpdateDate' => $tpitenaryAirdata[$i]['UpdateDate'] ? $tpitenaryAirdata[$i]['UpdateDate'] : 0,
'CreateDate' => $tpitenaryAirdata[$i]['CreateDate'] ? $tpitenaryAirdata[$i]['CreateDate'] : 0,
'ApproveBy' => $tpitenaryAirdata[$i]['ApproveBy'] ? $tpitenaryAirdata[$i]['ApproveBy'] : 0,
'ApprovalDate' => $tpitenaryAirdata[$i]['ApprovalDate'] ? $tpitenaryAirdata[$i]['ApprovalDate'] : 0,
'IsApproved' => $tpitenaryAirdata[$i]['IsApproved'] ? $tpitenaryAirdata[$i]['IsApproved'] : 0,
'IsActive' => $tpitenaryAirdata[$i]['IsActive'] ? $tpitenaryAirdata[$i]['IsActive'] : 0,
'IsMarkForDel' => $tpitenaryAirdata[$i]['IsMarkForDel'] ? $tpitenaryAirdata[$i]['IsMarkForDel'] : 0,
'encodedata' => $tpitenaryAirdata[$i]['encodedata'] ? $tpitenaryAirdata[$i]['encodedata'] : '',
);
#################### Insert Records in Air Table #######################
$this->_crmcusttravelplanAir->addCustomerTravelPlanAir($travelitenaryaccomairArray);
}
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
$seq = 1;
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $seq,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? trim($tpitenrayEvents[$k]['AgencySysId']) : 0,
'InvnItemSysId' => $tpitenrayEvents[$k]['InvnItemSysId'] ? $tpitenrayEvents[$k]['InvnItemSysId'] : 0,
'SupplierSysId' => $tpitenrayEvents[$k]['SupplierSysId'] ? $tpitenrayEvents[$k]['SupplierSysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? trim($tpitenrayEvents[$k]['Title']) : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? trim($tpitenrayEvents[$k]['Type']) : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? trim($tpitenrayEvents[$k]['CityId']) : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? trim($tpitenrayEvents[$k]['Cost']) : 0,
'KidsCost' => trim($tpitenrayEvents[$k]['KidsCost']),
'TotalCost' => $tpitenrayEvents[$k]['TotalCost'],
'Taxes' => trim($tpitenrayEvents[$k]['Taxes']),
'TDS' => trim($tpitenrayEvents[$k]['TDS']),
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsOptionalActivity' => $tpitenrayEvents[$k]['IsOptionalActivity'] ? $tpitenrayEvents[$k]['IsOptionalActivity'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'],
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
);
$seq = $seq + 1;
$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_crmcustomertravelItenaryPlaces->addCustomerTravelItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetCustomerTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'XrefInvnItemSysId' => $tpitenarysightseeing[$k]['XrefInvnItemSysId'] ? $tpitenarysightseeing[$k]['XrefInvnItemSysId'] : 0,
'SupplierSysId' => $tpitenarysightseeing[$k]['SupplierSysId'] ? $tpitenarysightseeing[$k]['SupplierSysId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'KidsCost' => $tpitenarysightseeing[$k]['KidsCost'] ? $tpitenarysightseeing[$k]['KidsCost'] : 0,
'TotalCost' => $tpitenarysightseeing[$k]['TotalCost'],
'IsOptionalSightSeeing' => $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] ? $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$travelitenraysightssing = $this->_crmcustomertravelSightSeeing->addCustomerTravelItenarySightSeeing($tpitenraysightseeingArray);
}
}
$travelplanmarketPrice = $this->_crmcusttravelplan->GetCustomerTravelMarketPrice($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'TotalCost' => $travelplanmarketPrice[$k]['TotalCost'] ? $travelplanmarketPrice[$k]['TotalCost'] : 0,
'CostPerPerson' => $travelplanmarketPrice[$k]['CostPerPerson'] ? $travelplanmarketPrice[$k]['CostPerPerson'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelMarketPlaces->addCustomerTravelMarketRate($travelmarketpriceArray);
}
}
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTermsCond($travelplanID);
if (!empty($travelplanterms)) {
for ($k = 0; $k < count($travelplanterms); $k++) {
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanterms[$k]['AgencySysId'] ? $travelplanterms[$k]['AgencySysId'] : 0,
'Inclusions' => $travelplanterms[$k]['Inclusions'] ? $travelplanterms[$k]['Inclusions'] : 0,
'Exclusions' => $travelplanterms[$k]['Exclusions'] ? $travelplanterms[$k]['Exclusions'] : 0,
'CancellationPolicy' => $travelplanterms[$k]['CancellationPolicy'] ? $travelplanterms[$k]['CancellationPolicy'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
$tpitenarytrans = $this->_crmcusttravelplan->GetAgencyCustomerTravelPlanItenaryTransport($travelplanID);
if (!empty($tpitenarytrans)) {
for ($k = 0; $k < count($tpitenarytrans); $k++) {
$existingtpintID = $tpitenarytrans[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpFixedArr = array(
'AgencySysId' => $tpitenarytrans[$k]['AgencySysId'] ? $tpitenarytrans[$k]['AgencySysId'] : 0,
'TPSysId' => $tpproposalID,
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Type' => $tpitenarytrans[$k]['Type'] ? $tpitenarytrans[$k]['Type'] : '',
'IsIncluded' => $tpitenarytrans[$k]['IsIncluded'] ? $tpitenarytrans[$k]['IsIncluded'] : 0,
'TransType' => $tpitenarytrans[$k]['TransType'] ? $tpitenarytrans[$k]['TransType'] : '',
'TransTypeCat' => $tpitenarytrans[$k]['TransTypeCat'] ? $tpitenarytrans[$k]['TransTypeCat'] : '',
'FromPlace' => $tpitenarytrans[$k]['FromPlace'] ? $tpitenarytrans[$k]['FromPlace'] : '',
'ToPlace' => $tpitenarytrans[$k]['ToPlace'] ? $tpitenarytrans[$k]['ToPlace'] : '',
'SourceCityId' => $tpitenarytrans[$k]['SourceCityId'] ? $tpitenarytrans[$k]['SourceCityId'] : 0,
'DestCityId' => $tpitenarytrans[$k]['DestCityId'] ? $tpitenarytrans[$k]['DestCityId'] : 0,
'CostPerson' => $tpitenarytrans[$k]['CostPerson'] ? $tpitenarytrans[$k]['CostPerson'] : 0,
'TotalPrice' => $tpitenarytrans[$k]['TotalPrice'] ? $tpitenarytrans[$k]['TotalPrice'] : 0,
'Capacity' => $tpitenarytrans[$k]['Capacity'] ? $tpitenarytrans[$k]['Capacity'] : 0,
'CreateDate' => $createDate,
'IsMarkForDel' => $tpitenarytrans[$k]['IsMarkForDel'] ? $tpitenarytrans[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenarytrans[$k]['IsActive'] ? $tpitenarytrans[$k]['IsActive'] : 0,
);
$travelplanfixed = $this->_crmcustomertravelFixed->addCustomerFixedItinerary($tpFixedArr);
}
}
########### Data For Inserting Insurace Table ##################################3
$getinsurance = $this->_crmcusttravelplan->GetAgencyCustomerInsurance($travelpanitenary[0]);
if (!empty($getinsurance)) {
$custpolicyID = $getinsurance[0]['CustPolicySysId'];
if (!empty($getinsurance)) {
for ($j = 0; $j < count($getinsurance); $j++) {
$tpinsurearr = array(
'TPIntSysId' => $lasttravelitenaryID[0],
'SuppPolicySysId' => $getinsurance[$j]['SuppPolicySysId'],
'CustomerSysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PolicyStartDate' => $getinsurance[$j]['PolicyStartDate'] ? $getinsurance[$j]['PolicyStartDate'] : '',
'MasterPolicySysId' => $getinsurance[$j]['MasterPolicySysId'] ? $getinsurance[$j]['MasterPolicySysId'] : 0,
'PolicyNo' => $getinsurance[$j]['PolicyNo'],
'MemberId' => $getinsurance[$j]['MemberId'],
'TrxGroupId' => $getinsurance[$j]['TrxGroupId'],
'TrxSysId' => $getinsurance[$j]['TrxSysId'],
'IssueDate' => $getinsurance[$j]['IssueDate'],
'EndDate' => $getinsurance[$j]['EndDate'],
'PolicyDocPath' => $getinsurance[$j]['PolicyDocPath'],
'OtherDoc' => $getinsurance[$j]['OtherDoc'],
'TandC' => $getinsurance[$j]['TandC'],
'CurrencyType' => $getinsurance[$j]['CurrencyType'],
'SumInsured' => $getinsurance[$j]['SumInsured'],
'Priminum' => $getinsurance[$j]['Priminum'],
'Commision' => $getinsurance[$j]['Commision'],
'PremiumWithTax' => $getinsurance[$j]['PremiumWithTax'],
'NetPaid' => $getinsurance[$j]['NetPaid'],
'Taxes' => $getinsurance[$j]['Taxes'],
'TDS' => $getinsurance[$j]['TDS'],
'CreateDate' => $getinsurance[$j]['CreateDate'],
'UpdateDate' => $getinsurance[$j]['UpdateDate'],
'ActivationDate' => $getinsurance[$j]['ActivationDate'],
'ApprovalDate' => $getinsurance[$j]['ApprovalDate'],
'IsOptionalInsurance' => $getinsurance[$j]['IsOptionalInsurance'],
'IsSelected' => $getinsurance[$j]['IsSelected'],
'IsVarified' => $getinsurance[$j]['IsVarified'],
'IsActive' => $getinsurance[$j]['IsActive'],
'IsMarkForDelete' => $getinsurance[$j]['IsMarkForDelete'],
'IsApproved' => $getinsurance[$j]['IsApproved'],
'GeoLocation' => $getinsurance[$j]['GeoLocation'],
'Insurer' => $getinsurance[$j]['Insurer'],
);
$this->_travelinsuranceobj->addCustomerTravelInsurance($tpinsurearr);
}
}
$getinsurancemember = $this->_crmcusttravelplan->GetAgencyCustomerInsuranceMember($custpolicyID);
$getactivecustpolicyID = $this->_crmcusttravelplan->GetActiveCustPolicyID($lasttravelitenaryID[0]);
//echo $getactivecustpolicyID['CustPolicySysId'].'ssssss';
if (!empty($getactivecustpolicyID)) {
for ($j = 0; $j < count($getinsurancemember); $j++) {
$tpinsurememberarr = array(
'CustPolicySysId' => $getactivecustpolicyID['CustPolicySysId'],
'Seq' => $getinsurancemember[$j]['Seq'],
'Salutation' => $getinsurancemember[$j]['Salutation'],
'FirstName' => $getinsurancemember[$j]['FirstName'],
'LastName' => $getinsurancemember[$j]['LastName'],
'FullAddress' => $getinsurancemember[$j]['FullAddress'],
'DOB' => $getinsurancemember[$j]['DOB'],
'Email' => $getinsurancemember[$j]['Email'],
'CitySysId' => $getinsurancemember[$j]['CitySysId'],
'PinCode' => $getinsurancemember[$j]['PinCode'],
'IDType' => $getinsurancemember[$j]['IDType'],
'IDNumber' => $getinsurancemember[$j]['IDNumber'],
'Nominee' => $getinsurancemember[$j]['Nominee'],
'CreateDate' => $getinsurancemember[$j]['CreateDate'],
'UpdateDate' => $getinsurancemember[$j]['UpdateDate'],
'ActivationDate' => $getinsurancemember[$j]['ActivationDate'],
'ApprovalDate' => $getinsurancemember[$j]['ApprovalDate'],
'IsVarified' => $getinsurancemember[$j]['IsVarified'],
'IsActive' => $getinsurancemember[$j]['IsActive'],
'IsMarkForDelete' => $getinsurancemember[$j]['IsMarkForDelete'],
'IsApproved' => $getinsurancemember[$j]['IsApproved'],
);
$this->_travelinsumemberobj->addCustomerTravelInsuranceMember($tpinsurememberarr);
}
}
}
}
public function savebyoreadymadeAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
if (!empty($getData)) {
$travelplanID = $getData['tpId'];
$secureCode = isset($getData['secure']) ? $getData['secure'] : $getData['securecode'];
$MealTypeId = !empty($getData['mID']) ? $getData['mID'] : 0;
$IsB2BAgent = !empty($getData['IsB2BAgent']) ? $getData['IsB2BAgent'] : 0;
$queryTPSysId = !empty($getData['queryTPSysId']) ? $getData['queryTPSysId'] : '';
$roominfojson = $getData['roominfojson'];
$roominfojsondata = base64_decode($roominfojson);
$pkgstartdate = $getData['tripstartdate'];
$explode_pkg_date = explode("/", $pkgstartdate);
$pkg_trip_start_date = $explode_pkg_date[2] . '-' . $explode_pkg_date[1] . '-' . $explode_pkg_date[0];
$agentsysID = $this->intLoggedinUserId;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$gettplandataforcustomer = $this->_crmcusttravelplan->GetAllTravelPlan($travelplanID);
$objPackage = new Travel_Model_TblPackage();
$planbookingID = 'Q/17';
$createDate = date('Y-m-d H:i:s');
$destPlaceArr = isset($getData['DestinationPlaces']) ? json_decode(base64_decode($getData['DestinationPlaces']), true) : '';
// echo '<pre>'; print_r($getData);
if (isset($destPlaceArr) && !empty($destPlaceArr)) {
foreach ($destPlaceArr as $destIds => $destValues) {
$destIdsArr[] = $destIds;
$destValuesArr[] = $destValues;
}
$destinationIds = implode(',', $destIdsArr);
$destinationValues = implode(', ', $destValuesArr);
}
if (empty($queryTPSysId)) {
$customertravelpalnquery = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => 0,
'TPId' => $travelplanID,
'AgencySysId' => $gettplandataforcustomer[0]['AgencySysId'],
'AgentSysId' => $agentsysID,
'SupplierSysId' => $gettplandataforcustomer[0]['SupplierSysId'],
'IsPriceShared' => 1,
'StatusType' => 1,
'DocumentStatus' => 0,
'CustomerSysId' => 0,
'TPCode' => '',
'IsShared' => 0,
'PlanType' => 5,
'TourType' => $gettplandataforcustomer[0]['TourType'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'RoomInfoJson' => $roominfojsondata,
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'GroupSize' => $gettplandataforcustomer[0]['GroupSize'],
'BYOPackTypeMask' => $gettplandataforcustomer[0]['BYOPackTypeMask'],
'MinPax' => 2,
'AdditionalReq' => '',
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'Readymade' => $gettplandataforcustomer[0]['Readymade'],
'SourcePlaces' => $gettplandataforcustomer[0]['SourcePlaces'],
'SourcePlaceSysId' => $gettplandataforcustomer[0]['SourcePlaceSysId'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'],
'Details' => $gettplandataforcustomer[0]['Details'],
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'],
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'],
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'],
'StartDate' => $pkg_trip_start_date,
'ValidTill' => $gettplandataforcustomer[0]['ValidTill'],
'PkgSellValidTill' => $gettplandataforcustomer[0]['ValidTill'],
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'],
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'] ? $gettplandataforcustomer[0]['DiscountMsg'] : '',
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'] ? $gettplandataforcustomer[0]['DiscountType'] : '',
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'] ? $gettplandataforcustomer[0]['DiscountVal'] : 0,
'AdvBookingPercent' => $gettplandataforcustomer[0]['AdvBookingPercent'] ? $gettplandataforcustomer[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $gettplandataforcustomer[0]['AdvBookingDays'] ? $gettplandataforcustomer[0]['AdvBookingDays'] : 0,
'NetPrice' => $gettplandataforcustomer[0]['NetPrice'] ? $gettplandataforcustomer[0]['NetPrice'] : '0',
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'] ? $gettplandataforcustomer[0]['MinPrice'] : 0,
'Countries' => 'IN',
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'],
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'],
'Hotels' => $gettplandataforcustomer[0]['Hotels'],
'InventoryType' => 5,
'CreatorSysId' => $agentsysID,
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'],
'Countries' => '',
'IsInsuranceExist' => $gettplandataforcustomer[0]['IsInsuranceExist'],
'RoomInfoJson' => !empty($roominfojsondata) ? $roominfojsondata : $gettplandataforcustomer[0]['RoomInfoJson'],
'ProposalEmailTo' => '',
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'] ? $gettplandataforcustomer[0]['TotalMaxDays'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'DestinationPlacesSysId' => isset($gettplandataforcustomer[0]['DestinationPlacesSysId']) ? (int) $gettplandataforcustomer[0]['DestinationPlacesSysId'] : (int) $destinationIds,
'DestinationPlaces' => isset($gettplandataforcustomer[0]['DestinationPlaces']) ? $gettplandataforcustomer[0]['DestinationPlaces'] : $destinationValues,
'CityIds' => isset($destinationIds) ? $destinationIds : '',
'Cities' => isset($destinationValues) ? $destinationValues : '',
'PackageCostCalType' => !empty($gettplandataforcustomer[0]['PackageCostCalType']) ? $gettplandataforcustomer[0]['PackageCostCalType'] : 0, // to detect package is by lowest cost or by meal plan
'SharedMealPlanType' => $MealTypeId, // shared meal plan id
'IsB2Bproposal' => $IsB2BAgent,
'DestinationCovered' => !empty($gettplandataforcustomer[0]['DestinationCovered']) ? $gettplandataforcustomer[0]['DestinationCovered'] : '0',
);
$tpqueryID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($customertravelpalnquery);
} else {
$tpqueryID = $queryTPSysId;
}
$customertravelpaln = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $tpqueryID,
'TPId' => $travelplanID,
'AgencySysId' => $gettplandataforcustomer[0]['AgencySysId'],
'AgentSysId' => $agentsysID,
'SupplierSysId' => $gettplandataforcustomer[0]['SupplierSysId'],
'IsPriceShared' => 0,
'StatusType' => 4,
'DocumentStatus' => 0,
'CustomerSysId' => 0,
'TPCode' => '',
'IsShared' => 0,
'PlanType' => 5,
'TourType' => $gettplandataforcustomer[0]['TourType'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'RoomInfoJson' => $gettplandataforcustomer[0]['RoomInfoJson'],
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'GroupSize' => $gettplandataforcustomer[0]['GroupSize'],
'BYOPackTypeMask' => $gettplandataforcustomer[0]['BYOPackTypeMask'],
'MinPax' => 2,
'AdditionalReq' => '',
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'Readymade' => $gettplandataforcustomer[0]['Readymade'],
'SourcePlaces' => $gettplandataforcustomer[0]['SourcePlaces'],
'SourcePlaceSysId' => $gettplandataforcustomer[0]['SourcePlaceSysId'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'],
'Details' => $gettplandataforcustomer[0]['Details'],
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'],
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'],
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'],
'StartDate' => $pkg_trip_start_date,
'ValidTill' => $gettplandataforcustomer[0]['ValidTill'],
'PkgSellValidTill' => $gettplandataforcustomer[0]['ValidTill'],
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'],
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'] ? $gettplandataforcustomer[0]['DiscountMsg'] : '',
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'] ? $gettplandataforcustomer[0]['DiscountType'] : '',
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'] ? $gettplandataforcustomer[0]['DiscountVal'] : 0,
'AdvBookingPercent' => $gettplandataforcustomer[0]['AdvBookingPercent'] ? $gettplandataforcustomer[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $gettplandataforcustomer[0]['AdvBookingDays'] ? $gettplandataforcustomer[0]['AdvBookingDays'] : 0,
'NetPrice' => $gettplandataforcustomer[0]['NetPrice'] ? $gettplandataforcustomer[0]['NetPrice'] : '0',
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'] ? $gettplandataforcustomer[0]['MinPrice'] : 0,
'Countries' => 'IN',
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'],
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'],
'Hotels' => $gettplandataforcustomer[0]['Hotels'],
'InventoryType' => 5,
'CreatorSysId' => $agentsysID,
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'],
'Countries' => '',
'IsInsuranceExist' => $gettplandataforcustomer[0]['IsInsuranceExist'],
'RoomInfoJson' => !empty($roominfojsondata) ? $roominfojsondata : $gettplandataforcustomer[0]['RoomInfoJson'],
'ProposalEmailTo' => '',
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'] ? $gettplandataforcustomer[0]['TotalMaxDays'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'VersionId' => 1,
'DestinationPlacesSysId' => isset($gettplandataforcustomer[0]['DestinationPlacesSysId']) ? (int) $gettplandataforcustomer[0]['DestinationPlacesSysId'] : (int) $destinationIds,
'DestinationPlaces' => isset($gettplandataforcustomer[0]['DestinationPlaces']) ? $gettplandataforcustomer[0]['DestinationPlaces'] : $destinationValues,
'CityIds' => isset($destinationIds) ? $destinationIds : '',
'Cities' => isset($destinationValues) ? $destinationValues : '',
'PackageCostCalType' => !empty($gettplandataforcustomer[0]['PackageCostCalType']) ? $gettplandataforcustomer[0]['PackageCostCalType'] : 0, // to detect package is by lowest cost or by meal plan
'SharedMealPlanType' => $MealTypeId, // shared meal plan id
'IsB2Bproposal' => $IsB2BAgent,
'DestinationCovered' => !empty($gettplandataforcustomer[0]['DestinationCovered']) ? $gettplandataforcustomer[0]['DestinationCovered'] : '0',
);
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
//echo '<br/>';
$enctpproposalID = base64_encode($tpproposalID);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
$newTPIDsArr = array();
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'CityCategoryMask' => trim($travelplanIetnaryData[$i]['CityCategoryMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'StartDate' => $travelplanIetnaryData[$i]['StartDate']->format('Y-m-d'),
'EndDate' => $travelplanIetnaryData[$i]['EndDate']->format('Y-m-d'),
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'CitySysId' => $travelplanIetnaryData[$i]['CitySysId'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'],
'IsActive' => $travelplanIetnaryData[$i]['IsActive'],
);
$lasttravelitenaryIDs = $objPackage->insertData('TB_Agency_Customer_TravelPlan_Itenary', $travelitenary);
$newTPIDsArr[$travelplanIetnaryData[$i]['Sequence']] = $lasttravelitenaryIDs;
$lasttravelitenaryID[] = $lasttravelitenaryIDs;
// $lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$travelplanotherservices = $this->_crmcusttravelplan->GetTravelPlanOtherServices($travelplanID);
for ($i = 0; $i < count($travelplanotherservices); $i++) {
$travelitenaryservices = array(
'TPIntSysId' => $tpproposalID,
'OtherSrvSysId' => $travelplanotherservices[$i]['OtherSrvSysId'],
'CustomerSysId' => 0,
'SupplierSysId' => $travelplanotherservices[$i]['SupplierSysId'],
'ServiceTitle' => $travelplanotherservices[$i]['ServiceTitle'],
'ServiceType' => $travelplanotherservices[$i]['ServiceType'],
'Comment' => $travelplanotherservices[$i]['Comment'],
'CurrencyType' => $travelplanotherservices[$i]['CurrencyType'],
'RateType' => $travelplanotherservices[$i]['RateType'],
'PaxCount' => $travelplanotherservices[$i]['PaxCount'],
'Cost' => $travelplanotherservices[$i]['Cost'],
'IsOptionalServices' => $travelplanotherservices[$i]['IsOptionalServices'] ? $travelplanotherservices[$i]['IsOptionalServices'] : 0,
'IsCostInclInTP' => $travelplanotherservices[$i]['IsCostInclInTP'],
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => $travelplanotherservices[$i]['IsMarkForDelete'],
'IsApproved' => $travelplanotherservices[$i]['IsApproved'],
'IsActive' => $travelplanotherservices[$i]['IsActive']
);
$lasttravelitenaryotherservices = $objPackage->insertData('TB_Agency_Customer_TravelPlan_OtherServices', $travelitenaryservices);
// $lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
if ($tplanitenaryaccomdata[$k]['MasterIntSysId'] > 0) {
$masterintsysID = $tplanitenaryaccomdata[$k]['MasterIntSysId'];
$getkeyvalueintID = array_search($masterintsysID, $travelpanitenary);
$getmasterID = $lasttravelitenaryID[$getkeyvalueintID];
} else {
$getmasterID = 0;
}
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'IsFromAPI' => $tplanitenaryaccomdata[$k]['IsFromAPI'],
'SupplierSysId' => $tplanitenaryaccomdata[$k]['SupplierSysId'] ? $tplanitenaryaccomdata[$k]['SupplierSysId'] : 0,
'SourceSysId' => $tplanitenaryaccomdata[$k]['SourceSysId'] ? $tplanitenaryaccomdata[$k]['SourceSysId'] : 0,
'MasterIntSysId' => $getmasterID,
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'InvnItemSysId' => $tplanitenaryaccomdata[$k]['InvnItemSysId'] ? $tplanitenaryaccomdata[$k]['InvnItemSysId'] : '0',
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'XrefInvtSysId' => $tplanitenaryaccomdata[$k]['XrefInvtSysId'] ? $tplanitenaryaccomdata[$k]['XrefInvtSysId'] : 0,
'BYOPackType' => $tplanitenaryaccomdata[$k]['BYOPackType'] ? $tplanitenaryaccomdata[$k]['BYOPackType'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'MealPlanType' => $tplanitenaryaccomdata[$k]['MealPlanType'] ? $tplanitenaryaccomdata[$k]['MealPlanType'] : 0,
'RoomTypeStr' => $tplanitenaryaccomdata[$k]['RoomTypeStr'] ? $tplanitenaryaccomdata[$k]['RoomTypeStr'] : '',
'RoomMemInfoJson' => $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] ? $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] : '',
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : '',
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : 0,
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'AdultPax' => $tplanitenaryaccomdata[$k]['AdultPax'] ? $tplanitenaryaccomdata[$k]['AdultPax'] : 0,
'ChildPax' => $tplanitenaryaccomdata[$k]['ChildPax'] ? $tplanitenaryaccomdata[$k]['ChildPax'] : 0,
'InfantPax' => $tplanitenaryaccomdata[$k]['InfantPax'] ? $tplanitenaryaccomdata[$k]['InfantPax'] : 0,
'PetPax' => $tplanitenaryaccomdata[$k]['PetPax'] ? $tplanitenaryaccomdata[$k]['PetPax'] : 0,
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCost'] ? $tplanitenaryaccomdata[$k]['TotalCost'] : 0,
'TotalCostSO' => $tplanitenaryaccomdata[$k]['TotalCostSO'] ? $tplanitenaryaccomdata[$k]['TotalCostSO'] : 0,
'TotalCostDO' => $tplanitenaryaccomdata[$k]['TotalCostDO'] ? $tplanitenaryaccomdata[$k]['TotalCostDO'] : 0,
'TotalCostTO' => $tplanitenaryaccomdata[$k]['TotalCostTO'] ? $tplanitenaryaccomdata[$k]['TotalCostTO'] : 0,
'TotalCostExtraBed' => $tplanitenaryaccomdata[$k]['TotalCostExtraBed'] ? $tplanitenaryaccomdata[$k]['TotalCostExtraBed'] : 0,
'TotalCostWithoutBed' => $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] ? $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'IsSelectedOnPkg' => $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] ? $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => $tplanitenaryaccomdata[$k]['IsMarkForDel'] ? $tplanitenaryaccomdata[$k]['IsMarkForDel'] : '',
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $objPackage->insertData('TB_Agency_Customer_TravelPlan_Accom', $travelitenaryaccomArray);
// $tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
// $tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanItenaryAir($tplanitenayvalues);
//
// if(!empty($tpitenaryAirdata) > 0){
// ######### Add Air Data #######
// for($i=0;$i<count($tpitenaryAirdata);$i++){
// $existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
// $getkeyvalue = array_search($existingtpintairID,$travelpanitenary);
// $travelitenaryaccomairArray = array(
// 'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
// 'SeqId' => $tpitenaryAirdata[$i]['SeqId'],
// 'InvnItemSysId' => $tpitenaryAirdata[$i]['InvnItemSysId'],
// 'AgencySysId' => $tpitenaryAirdata[$i]['AgencySysId'],
// 'IsFromAPI' => $tpitenaryAirdata[$i]['IsFromAPI'],
// 'SourceSysId' => $tpitenaryAirdata[$i]['SourceSysId'],
// 'SupplierSysId' => $tpitenaryAirdata[$i]['SupplierSysId'],
// 'Cost' => $tpitenaryAirdata[$i]['Cost'],
// 'FlightNumber' => $tpitenaryAirdata[$i]['FlightNumber'],
// 'AirlineSysId' => $tpitenaryAirdata[$i]['AirlineSysId'] ? $tpitenaryAirdata[$i]['AirlineSysId'] : 0,
// 'ICSourceSysId' => $tpitenaryAirdata[$i]['ICSourceSysId'] ? $tpitenaryAirdata[$i]['ICSourceSysId'] : 0,
// 'IsFromAgency' => $tpitenaryAirdata[$i]['IsFromAgency'] ? $tpitenaryAirdata[$i]['IsFromAgency'] : 0,
// 'LocalFromTime' => $tpitenaryAirdata[$i]['LocalFromTime'],
// 'LocalToTime' => $tpitenaryAirdata[$i]['LocalToTime'],
// 'FromUTCTime' => $tpitenaryAirdata[$i]['FromUTCTime'],
// 'ToUTCTime' => $tpitenaryAirdata[$i]['ToUTCTime'],
// 'FlightCabinClass' => $tpitenaryAirdata[$i]['FlightCabinClass'],
// 'AdultPax' => $tpitenaryAirdata[$i]['AdultPax'] ? $tpitenaryAirdata[$i]['AdultPax'] : 0,
// 'ChildPax' => $tpitenaryAirdata[$i]['ChildPax'] ? $tpitenaryAirdata[$i]['ChildPax'] : 0,
// 'InfentPax' => $tpitenaryAirdata[$i]['InfentPax'] ? $tpitenaryAirdata[$i]['InfentPax'] : 0,
// 'TotalPax' => $tpitenaryAirdata[$i]['TotalPax'] ? $tpitenaryAirdata[$i]['TotalPax'] : 0,
// 'IsSelectedOnPkg' => $tpitenaryAirdata[$i]['IsSelectedOnPkg'] ? $tpitenaryAirdata[$i]['IsSelectedOnPkg'] : 1,
// 'IsDirect' => $tpitenaryAirdata[$i]['IsDirect'] ? $tpitenaryAirdata[$i]['IsDirect'] : 0,
// 'DayLightSavingDiff' => $tpitenaryAirdata[$i]['DayLightSavingDiff'] ? $tpitenaryAirdata[$i]['DayLightSavingDiff'] : 0,
// 'FlyingMinutes' => $tpitenaryAirdata[$i]['FlyingMinutes'] ? $tpitenaryAirdata[$i]['FlyingMinutes'] : 0,
// 'SourcePlaceSysId' => $tpitenaryAirdata[$i]['SourcePlaceSysId'] ? $tpitenaryAirdata[$i]['SourcePlaceSysId'] : 0,
// 'DestPlaceSysId' => $tpitenaryAirdata[$i]['DestPlaceSysId'] ? $tpitenaryAirdata[$i]['DestPlaceSysId'] : 0,
// 'SourceAirportCode' => $tpitenaryAirdata[$i]['SourceAirportCode'] ? $tpitenaryAirdata[$i]['SourceAirportCode'] : '',
// 'DestAirportCode' => $tpitenaryAirdata[$i]['DestAirportCode'] ? $tpitenaryAirdata[$i]['DestAirportCode'] : '',
// 'AirportHaultMinutes' => $tpitenaryAirdata[$i]['AirportHaultMinutes'] ? $tpitenaryAirdata[$i]['AirportHaultMinutes'] : 0,
// 'StopCount' => $tpitenaryAirdata[$i]['StopCount'] ? $tpitenaryAirdata[$i]['StopCount'] : 0,
// 'Stops' => $tpitenaryAirdata[$i]['Stops'] ? $tpitenaryAirdata[$i]['Stops'] : 0,
// 'Rating' => $tpitenaryAirdata[$i]['Rating'] ? $tpitenaryAirdata[$i]['Rating'] : 0,
// 'FllightFeatureMask' => $tpitenaryAirdata[$i]['FllightFeatureMask'] ? $tpitenaryAirdata[$i]['FllightFeatureMask'] : 0,
// 'UpdatedByISSysId' => $tpitenaryAirdata[$i]['UpdatedByISSysId'] ? $tpitenaryAirdata[$i]['UpdatedByISSysId'] : 0,
// 'CreatedByISSysId' => $tpitenaryAirdata[$i]['CreatedByISSysId'] ? $tpitenaryAirdata[$i]['CreatedByISSysId'] : 0,
// 'ImageTN' => $tpitenaryAirdata[$i]['ImageTN'] ? $tpitenaryAirdata[$i]['ImageTN'] : 0,
// 'ImgForList' => $tpitenaryAirdata[$i]['ImgForList'] ? $tpitenaryAirdata[$i]['ImgForList'] : 0,
// 'ImgeDetails' => $tpitenaryAirdata[$i]['ImgeDetails'] ? $tpitenaryAirdata[$i]['ImgeDetails'] : 0,
// 'UpdateDate' => $tpitenaryAirdata[$i]['UpdateDate'] ? $tpitenaryAirdata[$i]['UpdateDate'] : 0,
// 'CreateDate' => $tpitenaryAirdata[$i]['CreateDate'] ? $tpitenaryAirdata[$i]['CreateDate'] : 0,
// 'ApproveBy' => $tpitenaryAirdata[$i]['ApproveBy'] ? $tpitenaryAirdata[$i]['ApproveBy'] : 0,
// 'ApprovalDate' => $tpitenaryAirdata[$i]['ApprovalDate'] ? $tpitenaryAirdata[$i]['ApprovalDate'] : 0,
// 'IsApproved' => $tpitenaryAirdata[$i]['IsApproved'] ? $tpitenaryAirdata[$i]['IsApproved'] : 0,
// 'IsActive' => $tpitenaryAirdata[$i]['IsActive'] ? $tpitenaryAirdata[$i]['IsActive'] : 0,
// 'IsMarkForDel' => $tpitenaryAirdata[$i]['IsMarkForDel'] ? $tpitenaryAirdata[$i]['IsMarkForDel'] : 0,
// 'encodedata' => $tpitenaryAirdata[$i]['encodedata'] ? $tpitenaryAirdata[$i]['encodedata'] : '',
// );
// #################### Insert Records in Air Table #######################
//
// $objPackage->insertData('TB_Agency_Customer_TravelPlan_Air', $travelitenaryaccomairArray);
// // $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($travelitenaryaccomairArray);
//
// }
// }
$tpitenrayEvents = $this->_crmcusttravelplan->GetTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
// $seq = 1;
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenrayEvents[$k]['Sequence'] ? $tpitenrayEvents[$k]['Sequence'] : 0,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? trim($tpitenrayEvents[$k]['AgencySysId']) : 0,
'InvnItemSysId' => $tpitenrayEvents[$k]['InvnItemSysId'] ? $tpitenrayEvents[$k]['InvnItemSysId'] : 0,
'SupplierSysId' => $tpitenrayEvents[$k]['SupplierSysId'] ? $tpitenrayEvents[$k]['SupplierSysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? trim($tpitenrayEvents[$k]['Title']) : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? trim($tpitenrayEvents[$k]['Type']) : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? trim($tpitenrayEvents[$k]['CityId']) : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? trim($tpitenrayEvents[$k]['Cost']) : 0,
'KidsCost' => trim($tpitenrayEvents[$k]['KidsCost']),
'TotalCost' => $tpitenrayEvents[$k]['TotalCost'],
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsOptionalActivity' => $tpitenrayEvents[$k]['IsOptionalActivity'] ? $tpitenrayEvents[$k]['IsOptionalActivity'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'],
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
);
// $seq = $seq + 1;
$objPackage->insertData('TB_Agency_Customer_TravelPlan_Itenary_Events', $tpitenrayevntsArray);
//$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'TPSysId' => $tpproposalID,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_Itenary_Places', $tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'XrefInvnItemSysId' => $tpitenarysightseeing[$k]['XrefInvnItemSysId'] ? $tpitenarysightseeing[$k]['XrefInvnItemSysId'] : 0,
'SupplierSysId' => $tpitenarysightseeing[$k]['SupplierSysId'] ? $tpitenarysightseeing[$k]['SupplierSysId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'KidsCost' => $tpitenarysightseeing[$k]['KidsCost'] ? $tpitenarysightseeing[$k]['KidsCost'] : 0,
'TotalCost' => $tpitenarysightseeing[$k]['TotalCost'],
'IsOptionalSightSeeing' => $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] ? $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'Markup' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['Markup'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_SightSeeing', $tpitenraysightseeingArray);
}
}
$travelplanmarketPrice = $this->_crmcusttravelplan->GetMarketWiseRate($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'TourType' => $travelplanmarketPrice[$k]['TourType'] ? $travelplanmarketPrice[$k]['TourType'] : 0,
'PackCategoryId' => $travelplanmarketPrice[$k]['PackCategoryId'] ? $travelplanmarketPrice[$k]['PackCategoryId'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
// 'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'CostPerPerson' => $travelplanmarketPrice[$k]['CostPerPerson'] ? $travelplanmarketPrice[$k]['CostPerPerson'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'TotalCost' => $travelplanmarketPrice[$k]['TotalCost'] ? $travelplanmarketPrice[$k]['TotalCost'] : 0,
'CostPerPerson' => $travelplanmarketPrice[$k]['CostPerPerson'] ? $travelplanmarketPrice[$k]['CostPerPerson'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'PricePerPerson' => $travelplanmarketPrice[$k]['PricePerPerson'] ? $travelplanmarketPrice[$k]['PricePerPerson'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
'MealPlanType' => !empty($travelplanmarketPrice[$k]['MealPlanType']) ? $travelplanmarketPrice[$k]['MealPlanType'] : 0, // meal plan
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_MarketWise_Rate', $travelmarketpriceArray);
}
}
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTerms($travelplanID);
if (!empty($travelplanterms)) {
for ($k = 0; $k < count($travelplanterms); $k++) {
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanterms[$k]['AgencySysId'] ? $travelplanterms[$k]['AgencySysId'] : 0,
'Inclusions' => $travelplanterms[$k]['Inclusions'] ? $travelplanterms[$k]['Inclusions'] : 0,
'Exclusions' => $travelplanterms[$k]['Exclusions'] ? $travelplanterms[$k]['Exclusions'] : 0,
'CancellationPolicy' => $travelplanterms[$k]['CancellationPolicy'] ? $travelplanterms[$k]['CancellationPolicy'] : 0,
'TravelBasics' => $travelplanterms[$k]['TravelBasics'] ? $travelplanterms[$k]['TravelBasics'] : '',
'TermsAndConditions' => $travelplanterms[$k]['TermsAndConditions'] ? $travelplanterms[$k]['TermsAndConditions'] : '',
'BookingTerms' => $travelplanterms[$k]['BookingTerms'] ? $travelplanterms[$k]['BookingTerms'] : '',
'WhyUseUs' => $travelplanterms[$k]['WhyUseUs'] ? $travelplanterms[$k]['WhyUseUs'] : '',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$objPackage->insertData('TB_Agency_Customer_TravelPlan_Terms_Conditions', $travelplantermsArray);
// $travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
$tpitenarytrans = $this->_crmcusttravelplan->GetTravelPlanItenaryTransFixed($travelplanID);
if (!empty($tpitenarytrans)) {
for ($k = 0; $k < count($tpitenarytrans); $k++) {
$existingtpintID = $tpitenarytrans[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpFixedArr = array(
'AgencySysId' => $tpitenarytrans[$k]['AgencySysId'] ? $tpitenarytrans[$k]['AgencySysId'] : 0,
'TPSysId' => $tpproposalID,
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Type' => $tpitenarytrans[$k]['Type'] ? $tpitenarytrans[$k]['Type'] : '',
'IsIncluded' => $tpitenarytrans[$k]['IsIncluded'] ? $tpitenarytrans[$k]['IsIncluded'] : 0,
'RouteVechSysId' => $tpitenarytrans[$k]['RouteVechSysId'] ? $tpitenarytrans[$k]['RouteVechSysId'] : 0,
'RouteSysId' => $tpitenarytrans[$k]['RouteVechSysId'] ? $tpitenarytrans[$k]['RouteSysId'] : 0,
'VehSysId' => $tpitenarytrans[$k]['VehSysId'] ? $tpitenarytrans[$k]['VehSysId'] : 0,
'VehicleTypeSysId' => $tpitenarytrans[$k]['VehicleTypeSysId'] ? $tpitenarytrans[$k]['VehicleTypeSysId'] : 0,
'TransType' => $tpitenarytrans[$k]['TransType'] ? $tpitenarytrans[$k]['TransType'] : '',
'TransTypeCat' => $tpitenarytrans[$k]['TransTypeCat'] ? $tpitenarytrans[$k]['TransTypeCat'] : '',
'FromPlace' => $tpitenarytrans[$k]['FromPlace'] ? $tpitenarytrans[$k]['FromPlace'] : '',
'ToPlace' => $tpitenarytrans[$k]['ToPlace'] ? $tpitenarytrans[$k]['ToPlace'] : '',
'SourceCityId' => $tpitenarytrans[$k]['SourceCityId'] ? $tpitenarytrans[$k]['SourceCityId'] : 0,
'DestCityId' => $tpitenarytrans[$k]['DestCityId'] ? $tpitenarytrans[$k]['DestCityId'] : 0,
'IsGroup' => $tpitenarytrans[$k]['IsGroup'] ? $tpitenarytrans[$k]['IsGroup'] : 0,
'CostPerson' => $tpitenarytrans[$k]['CostPerson'] ? $tpitenarytrans[$k]['CostPerson'] : 0,
'TotalPrice' => $tpitenarytrans[$k]['TotalPrice'] ? $tpitenarytrans[$k]['TotalPrice'] : 0,
'Sequence' => $tpitenarytrans[$k]['Sequence'] ? $tpitenarytrans[$k]['Sequence'] : 0,
'Capacity' => $tpitenarytrans[$k]['Capacity'] ? $tpitenarytrans[$k]['Capacity'] : 0,
'CreateDate' => $createDate,
'IsMarkForDel' => $tpitenarytrans[$k]['IsMarkForDel'] ? $tpitenarytrans[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenarytrans[$k]['IsActive'] ? $tpitenarytrans[$k]['IsActive'] : 0,
'Sequence' => $tpitenarytrans[$k]['Sequence'] ? $tpitenarytrans[$k]['Sequence'] : 0,
);
$objPackage->insertData('TB_Agency_Customer_Trans_Fixed', $tpFixedArr);
//$travelplanfixed = $this->_crmcustomertravelFixed->addCustomerFixedItinerary($tpFixedArr);
}
}
$encodetpID = base64_encode($tpproposalID);
$secureCodeFinal = Catabatic_ValidateCustomer::secureCode($enctpproposalID, 1);
$travelpanitenaryEncodedData = base64_encode(json_encode($lasttravelitenaryID));
$response = array('secureCode' => $secureCodeFinal, 'tpID' => $tpproposalID, 'encodetpID' => $encodetpID, 'itenArr' => $travelpanitenaryEncodedData);
echo json_encode($response);
}
}
public function savepkgproposalbyoAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
$aboutpackage = $getData['aboutpackage'];
$tripaddress = $getData['tripaddress'];
$pricerange = $getData['pricerange'];
$pricetype = $getData['pricetypeval'];
$createDate = date('Y-m-d H:i:s');
$travelplanID = $getData['tpID'];
if ($pricetype == "wop" && !empty($pricerange)) {
$where = "TPSysId = " . $travelplanID;
$updatetravelplan = array(
'PriceRange' => $pricerange,
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
}
$totprice = $getData['totalprice'];
$sentemail = trim($getData['customeremail']);
$FirstName = $getData['customername'];
$totalprice = $getData['totalprice'];
$priceperadult = $getData['costpp'];
// $travelplandata = $this->_crmcusttravelplan->GetTravelPlan($travelplanID);
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($travelplanID, 'Query');
$pkgtitle = $gettplandataforcustomer[0]['Title'];
#### For Fetching the Lead Detail which is sent to customer ####
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (!empty($travelplanID)) {
$where = "TPSysId = " . $travelplanID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'IsShared' => 1,
'StatusType' => 2
);
}
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
$planbookingID = 'Q/' . date('y');
$stratdate = $gettplandataforcustomer[0]['StartDate'];
$ValidTill = $gettplandataforcustomer[0]['ValidTill'];
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($travelplanID);
// $versionnum = $getlatestversion[0]['VersionId'];
$objPackage = new Travel_Model_TblPackage();
$getplanenddate = $objPackage->GetTravelEndDate($travelplanID);
$countgplandate = count($getplanenddate) - 1;
$planenddate = $getplanenddate[$countgplandate]['EndDate']->format('Y-m-d');
$agentsysID = $this->intLoggedinUserId;
$customertravelpaln = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => $travelplanID,
'AgencySysId' => $gettplandataforcustomer[0]['AgencySysId'],
'AgentSysId' => $agentsysID,
'StatusType' => 4,
'CustomerSysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PlanType' => 5,
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'DestinationPlaces' => $gettplandataforcustomer[0]['DestinationPlaces'],
'DestinationPlacesSysId' => (int) $gettplandataforcustomer[0]['DestinationPlacesSysId'],
'SourcePlaces' => $gettplandataforcustomer[0]['SourcePlaces'],
'SourcePlaceSysId' => $gettplandataforcustomer[0]['SourcePlaceSysId'],
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'],
'Details' => $gettplandataforcustomer[0]['Details'],
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'],
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'],
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'],
'StartDate' => $stratdate->format('Y-m-d'),
'ValidTill' => $ValidTill->format('Y-m-d'),
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'],
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'],
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'],
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'],
'AdvBookingPercent' => $gettplandataforcustomer[0]['AdvBookingPercent'] ? $gettplandataforcustomer[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $gettplandataforcustomer[0]['AdvBookingDays'] ? $gettplandataforcustomer[0]['AdvBookingDays'] : 0,
'NetPrice' => $totprice,
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'] ? $gettplandataforcustomer[0]['MinPrice'] : 0,
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'],
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'],
'Hotels' => $gettplandataforcustomer[0]['Hotels'],
'InventoryType' => 5,
'CreatorSysId' => $agentsysID,
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'],
'PkgSellValidTill' => $planenddate,
'Cities' => $gettplandataforcustomer[0]['Cities'],
'Countries' => $gettplandataforcustomer[0]['Countries'],
'IsInsuranceExist' => $gettplandataforcustomer[0]['IsInsuranceExist'],
'RoomInfoJson' => $gettplandataforcustomer[0]['RoomInfoJson'],
'ProposalEmailTo' => $gettplandataforcustomer[0]['ProposalEmailTo'],
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
$enctpproposalID = base64_encode($tpproposalID);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetCustomerTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'StartDate' => $travelplanIetnaryData[$i]['StartDate'],
'EndDate' => $travelplanIetnaryData[$i]['EndDate'],
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'],
'IsActive' => $travelplanIetnaryData[$i]['IsActive'],
);
$lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanCustomerItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
if ($tplanitenaryaccomdata[$k]['MasterIntSysId'] > 0) {
$masterintsysID = $tplanitenaryaccomdata[$k]['MasterIntSysId'];
$getkeyvalueintID = array_search($masterintsysID, $travelpanitenary);
$getmasterID = $lasttravelitenaryID[$getkeyvalueintID];
} else {
$getmasterID = 0;
}
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'IsFromAPI' => $tplanitenaryaccomdata[$k]['IsFromAPI'],
'SupplierSysId' => $tplanitenaryaccomdata[$k]['SupplierSysId'] ? $tplanitenaryaccomdata[$k]['SupplierSysId'] : 0,
'SourceSysId' => $tplanitenaryaccomdata[$k]['SourceSysId'] ? $tplanitenaryaccomdata[$k]['SourceSysId'] : 0,
'MasterIntSysId' => $getmasterID,
'AccoBookingId' => $tplanitenaryaccomdata[$k]['AccoBookingId'] ? $tplanitenaryaccomdata[$k]['AccoBookingId'] : '',
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'InvnItemSysId' => $tplanitenaryaccomdata[$k]['InvnItemSysId'] ? $tplanitenaryaccomdata[$k]['InvnItemSysId'] : '0',
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'XrefInvtSysId' => $tplanitenaryaccomdata[$k]['XrefInvtSysId'] ? $tplanitenaryaccomdata[$k]['XrefInvtSysId'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomTypeStr' => $tplanitenaryaccomdata[$k]['RoomTypeStr'] ? $tplanitenaryaccomdata[$k]['RoomTypeStr'] : '',
'RoomMemInfoJson' => $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] ? $tplanitenaryaccomdata[$k]['RoomMemInfoJson'] : '',
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : '',
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : 0,
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'AdultPax' => $tplanitenaryaccomdata[$k]['AdultPax'] ? $tplanitenaryaccomdata[$k]['AdultPax'] : 0,
'ChildPax' => $tplanitenaryaccomdata[$k]['ChildPax'] ? $tplanitenaryaccomdata[$k]['ChildPax'] : 0,
'InfantPax' => $tplanitenaryaccomdata[$k]['InfantPax'] ? $tplanitenaryaccomdata[$k]['InfantPax'] : 0,
'PetPax' => $tplanitenaryaccomdata[$k]['PetPax'] ? $tplanitenaryaccomdata[$k]['PetPax'] : 0,
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCost'] ? $tplanitenaryaccomdata[$k]['TotalCost'] : 0,
'TotalCostSO' => $tplanitenaryaccomdata[$k]['TotalCostSO'] ? $tplanitenaryaccomdata[$k]['TotalCostSO'] : 0,
'TotalCostDO' => $tplanitenaryaccomdata[$k]['TotalCostDO'] ? $tplanitenaryaccomdata[$k]['TotalCostDO'] : 0,
'TotalCostTO' => $tplanitenaryaccomdata[$k]['TotalCostTO'] ? $tplanitenaryaccomdata[$k]['TotalCostTO'] : 0,
'TotalCostExtraBed' => $tplanitenaryaccomdata[$k]['TotalCostTO'] ? $tplanitenaryaccomdata[$k]['TotalCostExtraBed'] : 0,
'TotalCostWithoutBed' => $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] ? $tplanitenaryaccomdata[$k]['TotalCostWithoutBed'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'IsSelectedOnPkg' => $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] ? $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => $tplanitenaryaccomdata[$k]['IsMarkForDel'] ? $tplanitenaryaccomdata[$k]['IsMarkForDel'] : '',
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
$tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanCustomterItenaryAir($tplanitenayvalues);
if (!empty($tpitenaryAirdata)) {
######### Add Air Data #######
for ($i = 0; $i < count($tpitenaryAirdata); $i++) {
$existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintairID, $travelpanitenary);
$travelitenaryaccomairArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue],
'SeqId' => $tpitenaryAirdata[$i]['SeqId'],
'InvnItemSysId' => $tpitenaryAirdata[$i]['InvnItemSysId'],
'AgencySysId' => $tpitenaryAirdata[$i]['AgencySysId'],
'IsFromAPI' => $tpitenaryAirdata[$i]['IsFromAPI'],
'SourceSysId' => $tpitenaryAirdata[$i]['SourceSysId'],
'SupplierSysId' => $tpitenaryAirdata[$i]['SupplierSysId'],
'Cost' => $tpitenaryAirdata[$i]['Cost'],
'FlightNumber' => $tpitenaryAirdata[$i]['FlightNumber'],
'AirlineSysId' => $tpitenaryAirdata[$i]['AirlineSysId'] ? $tpitenaryAirdata[$i]['AirlineSysId'] : 0,
'ICSourceSysId' => $tpitenaryAirdata[$i]['ICSourceSysId'] ? $tpitenaryAirdata[$i]['ICSourceSysId'] : 0,
'IsFromAgency' => $tpitenaryAirdata[$i]['IsFromAgency'] ? $tpitenaryAirdata[$i]['IsFromAgency'] : 0,
'LocalFromTime' => $tpitenaryAirdata[$i]['LocalFromTime'],
'LocalToTime' => $tpitenaryAirdata[$i]['LocalToTime'],
'FromUTCTime' => $tpitenaryAirdata[$i]['FromUTCTime'],
'ToUTCTime' => $tpitenaryAirdata[$i]['ToUTCTime'],
'FlightCabinClass' => $tpitenaryAirdata[$i]['FlightCabinClass'],
'AdultPax' => $tpitenaryAirdata[$i]['AdultPax'] ? $tpitenaryAirdata[$i]['AdultPax'] : 0,
'ChildPax' => $tpitenaryAirdata[$i]['ChildPax'] ? $tpitenaryAirdata[$i]['ChildPax'] : 0,
'InfentPax' => $tpitenaryAirdata[$i]['InfentPax'] ? $tpitenaryAirdata[$i]['InfentPax'] : 0,
'TotalPax' => $tpitenaryAirdata[$i]['TotalPax'] ? $tpitenaryAirdata[$i]['TotalPax'] : 0,
'IsSelectedOnPkg' => $tpitenaryAirdata[$i]['IsSelectedOnPkg'] ? $tpitenaryAirdata[$i]['IsSelectedOnPkg'] : 1,
'IsDirect' => $tpitenaryAirdata[$i]['IsDirect'] ? $tpitenaryAirdata[$i]['IsDirect'] : 0,
'DayLightSavingDiff' => $tpitenaryAirdata[$i]['DayLightSavingDiff'] ? $tpitenaryAirdata[$i]['DayLightSavingDiff'] : 0,
'FlyingMinutes' => $tpitenaryAirdata[$i]['FlyingMinutes'] ? $tpitenaryAirdata[$i]['FlyingMinutes'] : 0,
'SourcePlaceSysId' => $tpitenaryAirdata[$i]['SourcePlaceSysId'] ? $tpitenaryAirdata[$i]['SourcePlaceSysId'] : 0,
'DestPlaceSysId' => $tpitenaryAirdata[$i]['DestPlaceSysId'] ? $tpitenaryAirdata[$i]['DestPlaceSysId'] : 0,
'SourceAirportCode' => $tpitenaryAirdata[$i]['SourceAirportCode'] ? $tpitenaryAirdata[$i]['SourceAirportCode'] : '',
'DestAirportCode' => $tpitenaryAirdata[$i]['DestAirportCode'] ? $tpitenaryAirdata[$i]['DestAirportCode'] : '',
'AirportHaultMinutes' => $tpitenaryAirdata[$i]['AirportHaultMinutes'] ? $tpitenaryAirdata[$i]['AirportHaultMinutes'] : 0,
'StopCount' => $tpitenaryAirdata[$i]['StopCount'] ? $tpitenaryAirdata[$i]['StopCount'] : 0,
'Stops' => $tpitenaryAirdata[$i]['Stops'] ? $tpitenaryAirdata[$i]['Stops'] : 0,
'Rating' => $tpitenaryAirdata[$i]['Rating'] ? $tpitenaryAirdata[$i]['Rating'] : 0,
'FllightFeatureMask' => $tpitenaryAirdata[$i]['FllightFeatureMask'] ? $tpitenaryAirdata[$i]['FllightFeatureMask'] : 0,
'UpdatedByISSysId' => $tpitenaryAirdata[$i]['UpdatedByISSysId'] ? $tpitenaryAirdata[$i]['UpdatedByISSysId'] : 0,
'CreatedByISSysId' => $tpitenaryAirdata[$i]['CreatedByISSysId'] ? $tpitenaryAirdata[$i]['CreatedByISSysId'] : 0,
'ImageTN' => $tpitenaryAirdata[$i]['ImageTN'] ? $tpitenaryAirdata[$i]['ImageTN'] : 0,
'ImgForList' => $tpitenaryAirdata[$i]['ImgForList'] ? $tpitenaryAirdata[$i]['ImgForList'] : 0,
'ImgeDetails' => $tpitenaryAirdata[$i]['ImgeDetails'] ? $tpitenaryAirdata[$i]['ImgeDetails'] : 0,
'UpdateDate' => $tpitenaryAirdata[$i]['UpdateDate'] ? $tpitenaryAirdata[$i]['UpdateDate'] : 0,
'CreateDate' => $tpitenaryAirdata[$i]['CreateDate'] ? $tpitenaryAirdata[$i]['CreateDate'] : 0,
'ApproveBy' => $tpitenaryAirdata[$i]['ApproveBy'] ? $tpitenaryAirdata[$i]['ApproveBy'] : 0,
'ApprovalDate' => $tpitenaryAirdata[$i]['ApprovalDate'] ? $tpitenaryAirdata[$i]['ApprovalDate'] : 0,
'IsApproved' => $tpitenaryAirdata[$i]['IsApproved'] ? $tpitenaryAirdata[$i]['IsApproved'] : 0,
'IsActive' => $tpitenaryAirdata[$i]['IsActive'] ? $tpitenaryAirdata[$i]['IsActive'] : 0,
'IsMarkForDel' => $tpitenaryAirdata[$i]['IsMarkForDel'] ? $tpitenaryAirdata[$i]['IsMarkForDel'] : 0,
'encodedata' => $tpitenaryAirdata[$i]['encodedata'] ? $tpitenaryAirdata[$i]['encodedata'] : '',
);
#################### Insert Records in Air Table #######################
$this->_crmcusttravelplanAir->addCustomerTravelPlanAir($travelitenaryaccomairArray);
}
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
$seq = 1;
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $seq,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? trim($tpitenrayEvents[$k]['AgencySysId']) : 0,
'InvnItemSysId' => $tpitenrayEvents[$k]['InvnItemSysId'] ? $tpitenrayEvents[$k]['InvnItemSysId'] : 0,
'SupplierSysId' => $tpitenrayEvents[$k]['SupplierSysId'] ? $tpitenrayEvents[$k]['SupplierSysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? trim($tpitenrayEvents[$k]['Title']) : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? trim($tpitenrayEvents[$k]['Type']) : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? trim($tpitenrayEvents[$k]['CityId']) : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? trim($tpitenrayEvents[$k]['Cost']) : 0,
'KidsCost' => trim($tpitenrayEvents[$k]['KidsCost']),
'TotalCost' => $tpitenrayEvents[$k]['TotalCost'],
'Taxes' => trim($tpitenrayEvents[$k]['Taxes']),
'TDS' => trim($tpitenrayEvents[$k]['TDS']),
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsOptionalActivity' => $tpitenrayEvents[$k]['IsOptionalActivity'] ? $tpitenrayEvents[$k]['IsOptionalActivity'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'],
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
);
$seq = $seq + 1;
$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_crmcustomertravelItenaryPlaces->addCustomerTravelItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetCustomerTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'XrefInvnItemSysId' => $tpitenarysightseeing[$k]['XrefInvnItemSysId'] ? $tpitenarysightseeing[$k]['XrefInvnItemSysId'] : 0,
'SupplierSysId' => $tpitenarysightseeing[$k]['SupplierSysId'] ? $tpitenarysightseeing[$k]['SupplierSysId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'KidsCost' => $tpitenarysightseeing[$k]['KidsCost'] ? $tpitenarysightseeing[$k]['KidsCost'] : 0,
'TotalCost' => $tpitenarysightseeing[$k]['TotalCost'],
'IsOptionalSightSeeing' => $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] ? $tpitenarysightseeing[$k]['IsOptionalSightSeeing'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$travelitenraysightssing = $this->_crmcustomertravelSightSeeing->addCustomerTravelItenarySightSeeing($tpitenraysightseeingArray);
}
}
$travelplanmarketPrice = $this->_crmcusttravelplan->GetCustomerTravelMarketPrice($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'TotalCost' => $travelplanmarketPrice[$k]['TotalCost'] ? $travelplanmarketPrice[$k]['TotalCost'] : 0,
'CostPerPerson' => $travelplanmarketPrice[$k]['CostPerPerson'] ? $travelplanmarketPrice[$k]['CostPerPerson'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelMarketPlaces->addCustomerTravelMarketRate($travelmarketpriceArray);
}
}
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTermsCond($travelplanID);
if (!empty($travelplanterms)) {
for ($k = 0; $k < count($travelplanterms); $k++) {
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanterms[$k]['AgencySysId'] ? $travelplanterms[$k]['AgencySysId'] : 0,
'Inclusions' => $travelplanterms[$k]['Inclusions'] ? $travelplanterms[$k]['Inclusions'] : 0,
'Exclusions' => $travelplanterms[$k]['Exclusions'] ? $travelplanterms[$k]['Exclusions'] : 0,
'CancellationPolicy' => $travelplanterms[$k]['CancellationPolicy'] ? $travelplanterms[$k]['CancellationPolicy'] : 0,
'TravelBasics' => $travelplanterms[$k]['TravelBasics'] ? $travelplanterms[$k]['TravelBasics'] : '',
'BookingTerms' => $travelplanterms[$k]['BookingTerms'] ? $travelplanterms[$k]['BookingTerms'] : '',
'WhyUseUs' => $travelplanterms[$k]['WhyUseUs'] ? $travelplanterms[$k]['WhyUseUs'] : '',
'TermsAndConditions' => $travelplanterms[$k]['TermsAndConditions'] ? $travelplanterms[$k]['TermsAndConditions'] : '',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
$tpitenarytrans = $this->_crmcusttravelplan->GetAgencyCustomerTravelPlanItenaryTransport($travelplanID);
if (!empty($tpitenarytrans)) {
for ($k = 0; $k < count($tpitenarytrans); $k++) {
$existingtpintID = $tpitenarytrans[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpFixedArr = array(
'AgencySysId' => $tpitenarytrans[$k]['AgencySysId'] ? $tpitenarytrans[$k]['AgencySysId'] : 0,
'TPSysId' => $tpproposalID,
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Type' => $tpitenarytrans[$k]['Type'] ? $tpitenarytrans[$k]['Type'] : '',
'IsIncluded' => $tpitenarytrans[$k]['IsIncluded'] ? $tpitenarytrans[$k]['IsIncluded'] : 0,
'TransType' => $tpitenarytrans[$k]['TransType'] ? $tpitenarytrans[$k]['TransType'] : '',
'TransTypeCat' => $tpitenarytrans[$k]['TransTypeCat'] ? $tpitenarytrans[$k]['TransTypeCat'] : '',
'FromPlace' => $tpitenarytrans[$k]['FromPlace'] ? $tpitenarytrans[$k]['FromPlace'] : '',
'ToPlace' => $tpitenarytrans[$k]['ToPlace'] ? $tpitenarytrans[$k]['ToPlace'] : '',
'SourceCityId' => $tpitenarytrans[$k]['SourceCityId'] ? $tpitenarytrans[$k]['SourceCityId'] : 0,
'DestCityId' => $tpitenarytrans[$k]['DestCityId'] ? $tpitenarytrans[$k]['DestCityId'] : 0,
'CostPerson' => $tpitenarytrans[$k]['CostPerson'] ? $tpitenarytrans[$k]['CostPerson'] : 0,
'TotalPrice' => $tpitenarytrans[$k]['TotalPrice'] ? $tpitenarytrans[$k]['TotalPrice'] : 0,
'Capacity' => $tpitenarytrans[$k]['Capacity'] ? $tpitenarytrans[$k]['Capacity'] : 0,
'CreateDate' => $createDate,
'IsMarkForDel' => $tpitenarytrans[$k]['IsMarkForDel'] ? $tpitenarytrans[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenarytrans[$k]['IsActive'] ? $tpitenarytrans[$k]['IsActive'] : 0,
);
$travelplanfixed = $this->_crmcustomertravelFixed->addCustomerFixedItinerary($tpFixedArr);
}
}
########### Data For Inserting Insurace Table ##################################3
$getinsurance = $this->_crmcusttravelplan->GetAgencyCustomerInsurance($travelpanitenary[0]);
if (!empty($getinsurance)) {
$custpolicyID = $getinsurance[0]['CustPolicySysId'];
if (!empty($getinsurance)) {
for ($j = 0; $j < count($getinsurance); $j++) {
$tpinsurearr = array(
'TPIntSysId' => $lasttravelitenaryID[0],
'SuppPolicySysId' => $getinsurance[$j]['SuppPolicySysId'],
'CustomerSysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PolicyStartDate' => $getinsurance[$j]['PolicyStartDate'] ? $getinsurance[$j]['PolicyStartDate'] : '',
'MasterPolicySysId' => $getinsurance[$j]['MasterPolicySysId'] ? $getinsurance[$j]['MasterPolicySysId'] : 0,
'PolicyNo' => $getinsurance[$j]['PolicyNo'],
'MemberId' => $getinsurance[$j]['MemberId'],
'TrxGroupId' => $getinsurance[$j]['TrxGroupId'],
'TrxSysId' => $getinsurance[$j]['TrxSysId'],
'IssueDate' => $getinsurance[$j]['IssueDate'],
'EndDate' => $getinsurance[$j]['EndDate'],
'PolicyDocPath' => $getinsurance[$j]['PolicyDocPath'],
'OtherDoc' => $getinsurance[$j]['OtherDoc'],
'TandC' => $getinsurance[$j]['TandC'],
'CurrencyType' => $getinsurance[$j]['CurrencyType'],
'SumInsured' => $getinsurance[$j]['SumInsured'],
'Priminum' => $getinsurance[$j]['Priminum'],
'Commision' => $getinsurance[$j]['Commision'],
'PremiumWithTax' => $getinsurance[$j]['PremiumWithTax'],
'NetPaid' => $getinsurance[$j]['NetPaid'],
'Taxes' => $getinsurance[$j]['Taxes'],
'TDS' => $getinsurance[$j]['TDS'],
'CreateDate' => $getinsurance[$j]['CreateDate'],
'UpdateDate' => $getinsurance[$j]['UpdateDate'],
'ActivationDate' => $getinsurance[$j]['ActivationDate'],
'ApprovalDate' => $getinsurance[$j]['ApprovalDate'],
'IsOptionalInsurance' => $getinsurance[$j]['IsOptionalInsurance'],
'IsSelected' => $getinsurance[$j]['IsSelected'],
'IsVarified' => $getinsurance[$j]['IsVarified'],
'IsActive' => $getinsurance[$j]['IsActive'],
'IsMarkForDelete' => $getinsurance[$j]['IsMarkForDelete'],
'IsApproved' => $getinsurance[$j]['IsApproved'],
'GeoLocation' => $getinsurance[$j]['GeoLocation'],
'Insurer' => $getinsurance[$j]['Insurer'],
);
$this->_travelinsuranceobj->addCustomerTravelInsurance($tpinsurearr);
}
}
$getinsurancemember = $this->_crmcusttravelplan->GetAgencyCustomerInsuranceMember($custpolicyID);
$getactivecustpolicyID = $this->_crmcusttravelplan->GetActiveCustPolicyID($lasttravelitenaryID[0]);
//echo $getactivecustpolicyID['CustPolicySysId'].'ssssss';
if (!empty($getactivecustpolicyID)) {
for ($j = 0; $j < count($getinsurancemember); $j++) {
$tpinsurememberarr = array(
'CustPolicySysId' => $getactivecustpolicyID['CustPolicySysId'],
'Seq' => $getinsurancemember[$j]['Seq'],
'Salutation' => $getinsurancemember[$j]['Salutation'],
'FirstName' => $getinsurancemember[$j]['FirstName'],
'LastName' => $getinsurancemember[$j]['LastName'],
'FullAddress' => $getinsurancemember[$j]['FullAddress'],
'DOB' => $getinsurancemember[$j]['DOB'],
'Email' => $getinsurancemember[$j]['Email'],
'CitySysId' => $getinsurancemember[$j]['CitySysId'],
'PinCode' => $getinsurancemember[$j]['PinCode'],
'IDType' => $getinsurancemember[$j]['IDType'],
'IDNumber' => $getinsurancemember[$j]['IDNumber'],
'Nominee' => $getinsurancemember[$j]['Nominee'],
'CreateDate' => $getinsurancemember[$j]['CreateDate'],
'UpdateDate' => $getinsurancemember[$j]['UpdateDate'],
'ActivationDate' => $getinsurancemember[$j]['ActivationDate'],
'ApprovalDate' => $getinsurancemember[$j]['ApprovalDate'],
'IsVarified' => $getinsurancemember[$j]['IsVarified'],
'IsActive' => $getinsurancemember[$j]['IsActive'],
'IsMarkForDelete' => $getinsurancemember[$j]['IsMarkForDelete'],
'IsApproved' => $getinsurancemember[$j]['IsApproved'],
);
$this->_travelinsumemberobj->addCustomerTravelInsuranceMember($tpinsurememberarr);
}
}
}
// $tpitenarytrans = $this->_crmcusttravelplan->GetAgencyCustomerTravelPlanItenaryTransport($travelplanID);
// $tpitenarytrans = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
// $tpitenaryrules = $this->_crmcusttravelplan->GetTravelPlanItenaryRules($tplanitenayvalues);
// $tpitenarysightseeing = $this->_crmcusttravelplan->GetTravelPlanSightSeeing($tplanitenayvalues);
// $tpitenraytermscond = $this->_crmcusttravelplan->GetTravelPlanTerms($tplanitenayvalues);
// $tpitenarytrnasdaywise = $this->_crmcusttravelplan->GetTravelPlanTransDaywise($tplanitenayvalues);
################# Send Mail to Customer ##############
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$IsEmailIdForCustVarified = trim($sessionLogin_user->agencyDetails['IsEmailIdForCustVarified']);
$EmailIdForCustomer = trim($sessionLogin_user->agencyDetails['EmailIdForCustomer']);
$agencyDisplayName = trim($sessionLogin_user->agencyDetails['DisplayName']);
$PrimaryEmail = trim($sessionLogin_user->agencyDetails['PrimaryEmail']);
$sendersEmailId = ($IsEmailIdForCustVarified == 1) ? $EmailIdForCustomer : $PrimaryEmail;
$agencyDisplayName = (!empty($agencyDisplayName)) ? $agencyDisplayName : trim($sessionLogin_user->agencyDetails['Title']);
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName : '';
$primarycontact = $sessionLogin_user->PrimaryContactNumber ? $sessionLogin_user->PrimaryContactNumber : '';
$Logo = $sessionLogin_user->Logo;
if ($pricetype == 'wop') {
$sentprice = $pricerange;
} else {
// $sentprice = $travelplandata[0]['NetPrice'] - $travelplandata[0]['DiscountVal'];
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($travelplanmarketPrice[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($totalprice); //per person price without discount
}
$booknowurl = $this->baseUrl . '/publicpackage/customerview/id/' . $enctpproposalID;
$destination_places = $gettplandataforcustomer[0]['DestinationPlaces'];
$pkg_start_date = $gettplandataforcustomer[0]['StartDate'];
$pkgstartdate = $pkg_start_date->format('Y-m-d');
$QueryID = $gettplandataforcustomer[0]['PlanBookingId'] . '/' . $gettplandataforcustomer[0]['TPSysId'];
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $agencySysId;
if (isset($Logo) && $Logo != '') {
$AgencyLogo = $pathAgency . '/' . $Logo;
} else {
$AgencyLogo = $path . '/logo.png';
}
//$AgencyLogo = $path.'/email_logo.png';
$aboutpackage = $aboutpackage ? $aboutpackage : '';
$bodyText = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<table width="650" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#fff" style="font-family:Tahoma, Geneva, sans-serif; color:#434343;">
<tr>
<td style="padding:25px 25px 0 25px; background:#ff9900"><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="padding-bottom:10px;"><a href="' . SITE_FULL_URL . '"><img src="' . $AgencyLogo . '" alt="GTX" title="GTX" border="0" /></a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="background: #fff; border-radius:5px 5px 0 0; padding:20px 25px 0 25px; font-size:14px; line-height:24px; border-left:1px solid #CCC; border-right:1px solid #CCC; border-top:1px solid #CCC; font-family:Tahoma, Geneva, sans-serif;">Dear <strong>' . $FirstName . ',</strong><br />
This mail contains the itinerary for your trip to <strong>' . $tripaddress . '</strong>. We sincerely hope that
every detail has been tailored to your requirements and preferences.<br />
<br />
<strong>Total Price - ' . $sentprice . '.</strong> The exact price of the package will be
communicated only once you finalise the itinerary.</td><br/>
</tr>
</table></td>
</tr>
<tr>
<td style="padding:0 25px 10px 25px; background:#eee;"><table width="100%" border="0" cellpadding="0" cellspacing="0" align="left">
<tr>
<td colspan="3" style=" background: #fff; border-radius:0 0 5px 5px; padding:20px 25px ; font-size:14px; line-height:24px; border-left:1px solid #d9d9d9; border-right:1px solid #d9d9d9; border-bottom:1px solid #d9d9d9; font-family:Tahoma, Geneva, sans-serif;">
' . $aboutpackage . '<br /><br />
Feel free reach out to us in case you want any further iterations.<br />
<br />
Your personal trip manager,<br />
' . $firstname . '<br />
' . $primarycontact . '</td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="3" style=" background:#fff; border-radius:5px; padding:20px 25px ; font-size:22px; line-height:24px; text-align:center; border:1px solid #d9d9d9"><a href="' . $booknowurl . '" style="text-decoration:none; color:#ff9900; font-weight:500; font-family:Tahoma, Geneva, sans-serif;">Click here to view your trip itinerary</a></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="3" align="center"><img src="' . $path . '/heart.png" border="0" alt="" title=""/></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="3" style="font-family:Tahoma, Geneva, sans-serif; padding:0 25px ; font-size:14px; line-height:30px; text-align:center; color:#999;"><span style="font-size:18px; font-weight:700; color:#5b5b58;">Help us spread the word.</span><br />
If you like us, please help us grow by telling your friends<br />
and family about us. We\'ll truly appreciate the gesture.</td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="3" style="padding:10px 25px; font-size:9px; line-height:30px; font-weight:500; text-align:center; color:#484343; font-family:Verdana, Geneva, sans-serif">2016 © 2017 © Global Travel Exchange <span style="font-size:12px; ">|</span> Technology By Global Travel Exchange </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>';
$emailId = trim($sentemail);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $tpproposalID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $gettplandataforcustomer[0]['CustomerSysId']);
echo 'Email has sent to customer';
} catch (Exception $err) {
print_r($err, true);
}
}
public function mytestAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$arr = array('first' => 'a', 'second' => 'b',);
$key = array_search('a', $arr);
echo $key;
}
public function viewCustomerMemberAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CRMCustSysId = $this->_HtmlPurifier->filter($this->_request->getParam('id'));
$MMBRCustSysId = $this->_HtmlPurifier->filter($this->_request->getParam('mid'));
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
//echo $mobilenum;
$this->view->id = $CRMCustSysId;
$this->view->mid = $MMBRCustSysId;
$this->view->AgencySysId = base64_encode($AgencySysId);
$this->view->type = 'viewCustomerMember';
$objCustomer = new Travel_Model_CRM_Customer();
$memberDetails = $objCustomer->GetCustomerMembersById($AgencySysId, base64_decode($CRMCustSysId), base64_decode($MMBRCustSysId));
$this->view->memberDetails = $memberDetails;
$objCountry = new Travel_Model_TblCountry();
$countryList = $objCountry->getCountryList();
$this->view->countryList = $countryList;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->getCustomerMemberVisaDetail = $getCustomerMemberVisaDetail = $this->_crmagencyleadaccountObj->getCustomerMemberVisaDetail($AgencySysId, base64_decode($CRMCustSysId), base64_decode($MMBRCustSysId));
$this->render('ajax-html');
}
public function updateCustomerMemberAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$response = '';
if ($this->getRequest()->isPost()) {
$CRMCustSysId = $this->_HtmlPurifier->filter($this->_request->getParam('id'));
$MMBRCustSysId = $this->_HtmlPurifier->filter($this->_request->getParam('mid'));
$title = $this->_HtmlPurifier->filter($this->_request->getParam('title'));
$mmbrfname = $this->_HtmlPurifier->filter($this->_request->getParam('mmbrfname'));
$mmbrlname = $this->_HtmlPurifier->filter($this->_request->getParam('mmbrlname'));
$mmbremail = $this->_HtmlPurifier->filter($this->_request->getParam('mmbremail'));
$mmbrmobile = $this->_HtmlPurifier->filter($this->_request->getParam('mmbrmobile'));
$countrycode = $this->_HtmlPurifier->filter($this->_request->getParam('countrycode'));
$countryId = $this->_request->getParam('membercountry') ? $this->_HtmlPurifier->filter($this->_request->getParam('membercountry')) : '';
$stateId = $this->_request->getParam('hidden_selected_member_stateid') ? $this->_HtmlPurifier->filter($this->_request->getParam('hidden_selected_member_stateid')) : '';
$cityId = $this->_request->getParam('hidden_selected_member_cityid') ? $this->_HtmlPurifier->filter($this->_request->getParam('hidden_selected_member_cityid')) : '';
$address = $this->_request->getParam('memberaddress') ? $this->_HtmlPurifier->filter($this->_request->getParam('memberaddress')) : '';
$PinCode = $this->_request->getParam('PinCode') ? $this->_HtmlPurifier->filter($this->_request->getParam('PinCode')) : '';
$SecondaryEmail = $this->_request->getParam('SecondaryEmail') ? $this->_request->getParam('SecondaryEmail') : '';
$IsMarried = $this->_request->getParam('IsMarried') ? $this->_request->getParam('IsMarried') : '';
$Noofkids = $this->_request->getParam('Noofkids') ? $this->_request->getParam('Noofkids') : '';
$FoodPreference = $this->_request->getParam('FoodPreference') ? $this->_request->getParam('FoodPreference') : '';
$CompanyName = $this->_request->getParam('CustomerCompanyName') ? $this->_request->getParam('CustomerCompanyName') : '';
$Remarks = $this->_request->getParam('Remarks') ? $this->_request->getParam('Remarks') : '';
$CustomerCategory = $this->_request->getParam('CustomerCategory') ? $this->_request->getParam('CustomerCategory') : '';
$SeatPreference = $this->_request->getParam('SeatPreference') ? $this->_request->getParam('SeatPreference') : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiryedit = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiryedit'));
$passexpiry = '';
$explodeeditann = '';
if (!empty($passexpiryedit)) {
$explodpass = explode('/', $passexpiryedit);
$passexpiry = $explodpass[2] . '-' . $explodpass[1] . '-' . $explodpass[0];
}
$custdobedit = $this->_HtmlPurifier->filter($this->_request->getParam('custdobedit'));
if (!empty($custdobedit)) {
$explodpcustdobedit = explode('/', $custdobedit);
$custdob = $explodpcustdobedit[2] . '-' . $explodpcustdobedit[1] . '-' . $explodpcustdobedit[0];
}
$custanniversaryedit = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversaryedit'));
if (!empty($custanniversaryedit)) {
$explodanniversary = explode('/', $custanniversaryedit);
$explodeeditann = $explodanniversary[2] . '-' . $explodanniversary[1] . '-' . $explodanniversary[0];
}
if ($stateId != '') {
$stateDetail = explode("__", $stateId);
$stateId = $stateDetail[0] ? $stateDetail[0] : 0;
}
if ($cityId != '') {
$cityDetail = explode("__", $cityId);
$cityId = $cityDetail[0] ? $cityDetail[0] : 0;
}
$wheremembertableCond = "CustomerSysId = " . base64_decode($CRMCustSysId) . " AND AgencySysId = " . $AgencySysId . " AND MemberSysId = " . base64_decode($MMBRCustSysId);
$updateDate = date('Y-m-d H:i:s');
$updatecustomermember = array(
'EmailId' => $mmbremail,
'Title' => $title,
'Contacts' => $mmbrmobile,
'countrycode' => $countrycode,
'FirstName' => $mmbrfname,
'LastName' => $mmbrlname,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => isset($custdob) ? $custdob : '',
'MarriageAnniversary' => $explodeeditann,
'Address' => trim($address),
'PinCode' => trim($PinCode),
'CitySysId' => $cityId,
'StateOrZoneSysId' => $stateId,
'CountrySysId' => $countryId,
'UpdateDate' => $updateDate,
'SecondaryEmail' => !empty($SecondaryEmail) ? $SecondaryEmail : '',
'IsMarried' => $IsMarried,
'Noofkids' => $Noofkids,
'FoodPreference' => !empty($FoodPreference) ? implode(',', $FoodPreference) : '',
'CustomerCompanyName' => $CompanyName,
'Remarks' => $Remarks,
'CustomerCategory' => $CustomerCategory,
'SeatPreference' => $SeatPreference
);
//echo "<pre>";print_r($updatecustomermember);die;
$updatemember = $this->_crmcustomerObj->UpdateCustomerMember($updatecustomermember, $wheremembertableCond);
//die;
$VisaCountryId = $this->_request->getParam('VisaCountryId');
$VisaExpiryDate = $this->_request->getParam('VisaExpiryDate');
$this->_crmagencyleadaccountObj->deleteCustomerMemberVisaDetail(array('IsActive' => 0, 'IsMarkForDelete' => 1), array('AgencySysId =?' => $AgencySysId, 'CustomerSysId =?' => base64_decode($CRMCustSysId), 'CustomerMemberSysId =?' => base64_decode($MMBRCustSysId)));
if (!empty($VisaCountryId)) {
foreach ($VisaCountryId as $vKey => $vVal) {
$VisaExpiryDate1 = isset($VisaExpiryDate[$vKey]) ? DateTime::createFromFormat('d/m/Y', $VisaExpiryDate[$vKey]) : '';
$updateCustomerVisaData = [
'AgencySysId' => $AgencySysId,
'CustomerSysId' => base64_decode($CRMCustSysId),
'CustomerMemberSysId' => base64_decode($MMBRCustSysId),
'VisaCountry' => $vVal,
'VisaExpiryDate' => ($VisaExpiryDate1 != '') ? $VisaExpiryDate1->format('Y-m-d') : '',
'IsActive' => 1,
'IsMarkForDelete' => 0,
];
//echo "<pre>";print_r($updateCustomerVisaData);die;
$customerVisaData[] = $this->_crmagencyleadaccountObj->updateCustomerMemberVisaDetail($updateCustomerVisaData);
}
}
$response = array('status' => 'success', 'msg' => 'Record updated', 'res' => $updatemember);
} else {
$response = array('status' => 'failed', 'msg' => 'something went wrong..');
}
echo json_encode($response);
}
public function customerRemarksAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$getAllCustomerRemark = $this->_crmremarkObj->GetAllCustomerRemarkById($CustomerSysId, $AgencySysId);
//echo "<pre>";
//print_r($getAllCustomerRemark);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getAllCustomerRemark);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
//this function used for all customer tab beacuse functionlity added in flightsearch lead
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
//echo "<pre>"; print_r($airportlist);die;
//$cityListArray = $this->_objPkg->getCityList();
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
//end of flight search lead
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function customerFeedbackAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$EmailId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('emailId')));
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$feedbackModel = new CustomerReview_Model_Feedback();
$getAllCustomerRemark = $feedbackModel->getFeedbackDataFromEmailId($AgencySysId, $EmailId);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getAllCustomerRemark);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
}
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function deleteRemarkAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$remarksId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('id'));
$customerid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('customerId'));
$remarksId = base64_decode($remarksId);
$customerid = base64_decode($customerid);
// query for insert data in db created by amit kumar dubey on 17 september 2016 at 02:48 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$date = date('Y-m-d H:i:s');
$remarkArray = array(
'IsActive' => '0',
'CreatedDate' => $date,
'IsMarkForDelete' => '1'
);
$cond = ' RemarkSysId=' . $remarksId . '';
$customerRcord = $this->_crmremarkObj->updateRemark($remarkArray, $cond);
//return $customerRcord;
$result = array("status" => "success", 'id' => $remarksId);
echo json_encode($result);
}
}
public function customerChatHistoryAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('cid')) : '';
$leadId = $this->getRequest()->getParam('id') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('id')) : '';
$CRMCustSysId = base64_decode($CRMCustSysId);
$leadId = base64_decode($leadId);
if (isset($CRMCustSysId) && !empty($CRMCustSysId)) {
$getChatHostoryDetail = $this->_crmcusttravelplan->GetCustomerChatHistoryDetails($leadId);
$AgencySysId = $this->intLoggedinUserAgencySysId;
//echo "<pre>"; print_r($_SESSION); die;
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'viewCustomerChatHistory';
$this->view->id = $leadId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->cid = $CRMCustSysId;
$this->view->data = $getChatHostoryDetail;
$this->render('ajax-html');
}
}
public function savecustomercontactAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$status = 'failed';
if ($this->getRequest()->isPost()) {
$crmcustID = $this->_request->getParam('crmcustID') ? $this->_request->getParam('crmcustID') : 0;
$salutation = $this->_request->getParam('salutation') ? $this->_request->getParam('salutation') : 0;
$customerfname = $this->_request->getParam('customerfname') ? $this->_request->getParam('customerfname') : '';
$customerlname = $this->_request->getParam('customerlname') ? $this->_request->getParam('customerlname') : '';
$emailID = $this->_request->getParam('emailID') ? $this->_request->getParam('emailID') : '';
$mobilenum = $this->_request->getParam('mobilenum') ? $this->_request->getParam('mobilenum') : '';
$countrycode = $this->_request->getParam('countrycode') ? $this->_request->getParam('countrycode') : '';
$custrelation = $this->_request->getParam('custrelation') ? $this->_request->getParam('custrelation') : '';
$custdob = $this->_request->getParam('custdob') ? $this->_request->getParam('custdob') : '';
$passnumber = $this->_request->getParam('passnumber') ? $this->_request->getParam('passnumber') : '';
$passexpiry = $this->_request->getParam('passexpiry') ? $this->_request->getParam('passexpiry') : '';
$countryId = $this->_request->getParam('countryId') ? $this->_request->getParam('countryId') : '';
$stateId = $this->_request->getParam('stateId') ? $this->_request->getParam('stateId') : '';
$cityId = $this->_request->getParam('cityId') ? $this->_request->getParam('cityId') : '';
$address = $this->_request->getParam('address') ? $this->_request->getParam('address') : '';
$PinCode = $this->_request->getParam('PinCode') ? $this->_request->getParam('PinCode') : '';
$SecondaryEmail = $this->_request->getParam('SecondaryEmail') ? $this->_request->getParam('SecondaryEmail') : '';
$IsMarried = $this->_request->getParam('IsMarried') ? $this->_request->getParam('IsMarried') : '';
$Noofkids = $this->_request->getParam('Noofkids') ? $this->_request->getParam('Noofkids') : '';
$FoodPreference = $this->_request->getParam('FoodPreference') ? $this->_request->getParam('FoodPreference') : '';
$CompanyName = $this->_request->getParam('CustomerCompanyName') ? $this->_request->getParam('CustomerCompanyName') : '';
$Remarks = $this->_request->getParam('Remarks') ? $this->_request->getParam('Remarks') : '';
$CustomerCategory = $this->_request->getParam('CustomerCategory') ? $this->_request->getParam('CustomerCategory') : '';
$SeatPreference = $this->_request->getParam('SeatPreference') ? $this->_request->getParam('SeatPreference') : '';
if (!empty($custdob)) {
$explodedob = explode('/', $custdob);
$dob = $explodedob[2] . '-' . $explodedob[1] . '-' . $explodedob[0];
} else {
$dob = '';
}
if (!empty($passexpiry)) {
$explodpass = explode('/', $passexpiry);
$passexpiry = $explodpass[2] . '-' . $explodpass[1] . '-' . $explodpass[0];
} else {
$passexpiry = '';
}
$custanniversary = $this->_request->getParam('custanniversary') ? $this->_request->getParam('custanniversary') : '';
if (!empty($custanniversary)) {
$explodeanniversary = explode('/', $custanniversary);
$anniversary = $explodeanniversary[2] . '-' . $explodeanniversary[1] . '-' . $explodeanniversary[0];
} else {
$anniversary = '';
}
if ($stateId != '') {
$stateDetail = explode("__", $stateId);
$stateId = $stateDetail[0];
}
if ($cityId != '') {
$cityDetail = explode("__", $cityId);
$cityId = $cityDetail[0];
}
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$curr_date = date('Y-m-d H:i:s');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$ipadd = $_SERVER['REMOTE_ADDR'];
$customerMdl = new Travel_Model_CRM_Customer();
$customerArray = $customerMdl->getAgencyIdFromCustomerTable($crmcustID);
$data = array(
'AgencySysId' => isset($customerArray['AgencySysId']) ? $customerArray['AgencySysId'] : $agencySysId,
'CustomerSysId' => $crmcustID,
'EmailId' => $emailID,
'Contacts' => $mobilenum,
'UserName' => $customerfname . '' . $customerlname,
'FirstName' => $customerfname,
'LastName' => $customerlname,
'Relation' => $custrelation,
'DOB' => $dob,
'MarriageAnniversary' => $anniversary,
'IsMarkForDelete' => 0,
'Title' => $salutation,
'Logo' => '',
'IsfromSM' => 0,
'SMTypeId' => 0,
'SMId' => '',
'UserId' => '',
'IsEmployee' => 0,
'JoinDate' => $curr_date,
'ExitDate' => '1900-01-01',
'Designation' => '',
'Password' => '',
'RandStr' => '',
'PasswordExpiryDate' => $curr_date,
'IsPswExpire' => 0,
'OtherEmail' => '',
'SecondaryEmail' => $SecondaryEmail,
'LastLoginTime' => '1900-01-01',
'IsLogInNow' => 0,
'CreatedByUserSysId' => $agencySysId,
'RandomCode' => '',
'Gender' => '',
'UserNickName' => $customerfname,
'UserPicPath' => '',
'ContactNo1' => $mobilenum,
'countrycode' => $countrycode,
'ContactNo2' => '',
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'HomePhone' => '',
'SecondaryPhone' => '',
'UserDetails' => '',
'Address' => trim($address),
'PinCode' => trim($PinCode),
'CitySysId' => $cityId,
'StateOrZoneSysId' => $stateId,
'CountrySysId' => $countryId,
'SecondaryAddress' => '',
'Fax' => '',
'MacIp' => $ipadd,
'SpeakingLangSysId' => '',
'Signature' => '',
'UpdateDate' => $curr_date,
'RegisterDate' => $curr_date,
'IsApproved' => 1,
'IsActive' => 1,
'IsMarried' => $IsMarried,
'Noofkids' => $Noofkids,
'FoodPreference' => !empty($FoodPreference) ? implode(',', $FoodPreference) : '',
'CustomerCompanyName' => $CompanyName,
'Remarks' => $Remarks,
'CustomerCategory' => $CustomerCategory,
'SeatPreference' => $SeatPreference
);
$record = $this->_customermemberObj->addCustomerMember($data);
$VisaCountryId = $this->_request->getParam('VisaCountryId');
$VisaExpiryDate = $this->_request->getParam('VisaExpiryDate');
$this->_crmagencyleadaccountObj->deleteCustomerMemberVisaDetail(array('IsActive' => 0, 'IsMarkForDelete' => 1), array('AgencySysId =?' => $agencySysId, 'CustomerSysId =?' => $crmcustID, 'CustomerMemberSysId =?' => $record));
if (!empty($VisaCountryId)) {
foreach ($VisaCountryId as $vKey => $vVal) {
$VisaExpiryDate1 = isset($VisaExpiryDate[$vKey]) ? DateTime::createFromFormat('d/m/Y', $VisaExpiryDate[$vKey]) : '';
$updateCustomerVisaData = [
'AgencySysId' => $agencySysId,
'CustomerSysId' => $crmcustID,
'CustomerMemberSysId' => $record,
'VisaCountry' => $vVal,
'VisaExpiryDate' => ($VisaExpiryDate1 != '') ? $VisaExpiryDate1->format('Y-m-d') : '',
'IsActive' => 1,
'IsMarkForDelete' => 0,
];
$this->_crmagencyleadaccountObj->updateCustomerMemberVisaDetail($updateCustomerVisaData);
}
}
if ($record) {
$status = 'success';
}
}
echo json_encode(array('status' => $status));
}
public function getcustomerlistAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
try {
$arrResponse = array();
if (trim($this->getRequest()->getParam("query")) != '') {
$term = $this->_HtmlPurifier->filter(trim($this->getRequest()->getParam("query")));
$IsB2BAgent = (NULL != $this->getRequest()->getParam("IsB2BAgent")) ? $this->_HtmlPurifier->filter(trim($this->getRequest()->getParam("IsB2BAgent"))) : 0;
$arrResponse = $this->_crmcustomerObj->getAllCustomerList($term, $AgencySysId, $IsB2BAgent);
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function getcustomersearchAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
try {
$arrResponse = array();
if (trim($this->getRequest()->getParam("term")) != '') {
$term = $this->_HtmlPurifier->filter(trim($this->getRequest()->getParam("term")));
$arrResponse = $this->_crmcustomerObj->getAllCustomerSearch($term, $AgencySysId);
} elseif (trim($this->getRequest()->getParam("customerId")) != '' && trim($this->getRequest()->getParam("customerId")) > 0) {
$customerId = trim($this->getRequest()->getParam("customerId"));
$arrResponse = $this->_crmcustomerObj->getAllCustomerSearchByID($customerId, $AgencySysId);
}
//echo '<pre>';print_r($arrResponse);die;
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function savetododataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$post = $this->getRequest()->getPost();
$todosubject = $this->_request->getParam('todosubject') ? $this->_HtmlPurifier->filter($this->_request->getParam('todosubject')) : '';
$todostartdate = $this->_request->getParam('todostartdate') ? $this->_request->getParam('todostartdate') : '';
$todoenddate = $this->_request->getParam('todoenddate') ? $this->_request->getParam('todoenddate') : '';
$todostartdatetime = $this->_request->getParam('todostartdatetime') ? $this->_request->getParam('todostartdatetime') : '';
$contact = $this->_request->getParam('contact') ? $this->_HtmlPurifier->filter($this->_request->getParam('contact')) : '';
$AgencyCRMLeadSysId = $this->_request->getParam('AgencyCRMLeadSysId') ? $this->_HtmlPurifier->filter($this->_request->getParam('AgencyCRMLeadSysId')) : '';
$custsysID = $this->_request->getParam('custsysID') ? $this->_HtmlPurifier->filter($this->_request->getParam('custsysID')) : '';
$relatedto = $this->_request->getParam('relatedto') ? $this->_HtmlPurifier->filter($this->_request->getParam('relatedto')) : '';
$assignedto = $this->_request->getParam('assignedtoId') ? $this->_HtmlPurifier->filter($this->_request->getParam('assignedtoId')) : '';
if (empty($assignedto)) {
$assignedto = $this->_request->getParam('assignedto') ? $this->_HtmlPurifier->filter($this->_request->getParam('assignedto')) : '';
}
$calltype = $this->_request->getParam('calltype') ? $this->_HtmlPurifier->filter($this->_request->getParam('calltype')) : 0;
$callstatus = $this->_request->getParam('callstatus') ? $this->_HtmlPurifier->filter($this->_request->getParam('callstatus')) : 0;
$nextstepcall = $this->_request->getParam('nextstepcall') ? $this->_HtmlPurifier->filter($this->_request->getParam('nextstepcall')) : '';
$details = $this->_request->getParam('details') ? $this->_HtmlPurifier->filter($this->_request->getParam('details')) : '';
$markasdone = $this->_request->getParam('markasdone') ? $this->_HtmlPurifier->filter($this->_request->getParam('markasdone')) : '';
$checked = $this->_request->getParam('checked') ? $this->_HtmlPurifier->filter($this->_request->getParam('checked')) : '';
$todoreminder = $this->_request->getParam('todoreminder') ? $this->_HtmlPurifier->filter($this->_request->getParam('todoreminder')) : '';
$reminderinvalue = $this->_request->getParam('reminderinvalue') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderinvalue')) : '';
$reminderintype = $this->_request->getParam('reminderintype') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderintype')) : '';
$LeadStage = $this->_request->getParam('LeadStage') ? $this->_HtmlPurifier->filter($this->_request->getParam('LeadStage')) : '';
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$reminderday = $this->_request->getParam('reminderday');
if ($reminderintype == 'hour') {
$todoreminder = $reminderinvalue * 60;
} else if ($reminderintype == 'day') {
$todoreminder = $reminderinvalue * 60 * 24;
} else {
$todoreminder = $reminderinvalue;
}
$explodetodostartdateAll = explode(' ', $todostartdate);
$explodetodostartdate = explode('/', $explodetodostartdateAll[0]);
//echo date('Y-m-d H:i:s',strtotime($todostartdate));
//echo "<pre>";print_r($explodetodostartdate);die;
$startdate = $explodetodostartdate[2] . '-' . $explodetodostartdate[1] . '-' . $explodetodostartdate[0];
$explodetodoenddateAll = explode(' ', $todoenddate);
$explodetodoenddate = explode('/', $explodetodoenddateAll[0]);
$enddate = $explodetodoenddate[2] . '-' . $explodetodoenddate[1] . '-' . $explodetodoenddate[0];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$curr_date = date('Y-m-d H:i:s');
$agentID = $sessionLogin_user->intLoggedinUserId;
$currentdate = date('Y-m-d');
if ($todosubject == 'none' || $todosubject == '') {
$response = array('status' => 'failed', 'msg' => 'To Save Follow Up Please Select Call,Meeting or To do.');
echo json_encode($response);
exit;
}
if ($todosubject === 'Call') {
if ($calltype == 0) {
$response = array('status' => 'failed', 'msg' => 'Please select Outgoing or Incomming');
echo json_encode($response);
exit;
}
if ($callstatus == 0) {
$response = array('status' => 'failed', 'msg' => 'Please Select Answered,Unanswred or Not Reachable.');
echo json_encode($response);
exit;
}
}
if (empty($nextstepcall) && ($todosubject == 'Call')) {
$response = array('status' => 'failed', 'msg' => 'Please Select Callback,To Do,Meeting, or Lost');
echo json_encode($response);
exit;
}
if ($nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
if (!isset($reminderday)) {
$response = array('status' => 'failed', 'msg' => 'Please select Today,Tomorrow ,In 2 days ,In 3 days or Custom date');
echo json_encode($response);
exit;
}
}
// if ($nextstepcall == 5) {
if (empty(addslashes(trim($details)))) {
$response = array('status' => 'failed', 'msg' => 'Please enter details');
echo json_encode($response);
exit;
}
// }
$markasdone = 1;
$reminderday = isset($post['reminderday']) ? $post['reminderday'] : 0;
if ($reminderday != 4) {
$startdate = date('Y-m-d', strtotime($currentdate . " +" . $reminderday . " days"));
}
if (isset($reminderday)) {
$now = new DateTime();
date_default_timezone_set('Asia/Kolkata'); // or your preferred timezone
$nowt = date("H:i");
if ($reminderday == 0) {
$todayTarget = new DateTime('today ' . $todostartdatetime);
$target = $todayTarget;
} else if ($reminderday == 1) {
$now = new DateTime('today ' . $nowt);
$target = new DateTime('tomorrow ' . $todostartdatetime);
} else if ($reminderday == 2 || $reminderday == 3) {
$now = new DateTime('today ' . $nowt);
$target = new DateTime($reminderday . 'days ' . $todostartdatetime);
} else if ($reminderday == 4) {
$targetDate = DateTime::createFromFormat('d/m/Y', $todostartdate);
$currentDate = new DateTime();
$interval = $currentDate->diff($targetDate);
$DaysCount = (int) $interval->format('%r%a') + 1;
$now = new DateTime('today ' . $nowt);
$target = new DateTime($DaysCount . 'days ' . $todostartdatetime);
}
$secondsDiff = $target->getTimestamp() - $now->getTimestamp();
$minutesDiff = isset($secondsDiff) && ($secondsDiff > 0) ? floor($secondsDiff / 60) : 1;
$salutationArr = unserialize(ARR_SALUTION);
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
if (isset($custsysID) && !empty($custsysID)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($custsysID);
$CustomerContact = isset($getCustomerDetail['Contacts']) && !empty($getCustomerDetail['Contacts']) ? $getCustomerDetail['Contacts'] : '';
$salutation = $salutationArr[$getCustomerDetail['Salutation']] ? $salutationArr[$getCustomerDetail['Salutation']] : 'Mr.';
$CustomerName = isset($getCustomerDetail['FirstName']) ? $salutation . ' ' . trim($getCustomerDetail['FirstName']) . ' ' . trim($getCustomerDetail['LastName']) : '';
} else {
$customerDetails = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
$CustomerContact = isset($customerDetails['PrimaryContactNumber']) && !empty($customerDetails['PrimaryContactNumber']) ? $customerDetails['PrimaryContactNumber'] : '';
$salutation = $salutationArr[$customerDetails['Salutation']] ? $salutationArr[$customerDetails['Salutation']] : 'Mr.';
$CustomerName = isset($getCustomerDetail['FirstName']) ? $salutation . ' ' . trim($getCustomerDetail['FirstName']) . ' ' . trim($getCustomerDetail['LastName']) : '';
}
if (isset($minutesDiff) && !empty($minutesDiff)) {
$AgentSysId = $assignedto ? $assignedto : $agentID;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$AgentName = trim($agentDetails['FirstName']) . ' ' . trim($agentDetails['LastName']);
$payload = [
'recipient' => $CustomerContact,
'agent_name' => $AgentName,
'user_id' => $AgentSysId,
'title' => 'Follow-Up Reminder',
'text' => 'Don’t forget! You have a ' . $todosubject . ' scheduled at ' . $todostartdatetime . ' today with ' . $CustomerName . '. Kindly complete the follow-up and update in CRM.',
'label' => 'Click Here',
'url' => Catabatic_Helper::getSiteUrl() . 'dashboard/view-all-to-do/index',
'delay' => $minutesDiff,
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => Catabatic_Helper::getSiteUrl() . 'webservice/notification',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'SecurityKey:' . trim($agentDetails['SecurityKey']),
'Content-Type: application/json',
'Cookie: PHPSESSID=qb2ofl8h0g6hs66q3uhoenqasq'
),
));
$response = curl_exec($curl);
curl_close($curl);
}
}
if (trim($todosubject) == 'To Do' && empty($nextstepcall)) {
$checked = 0;
$markasdone = 0;
$data = array(
'Subject' => $todosubject,
'StartDateTime' => $curr_date,
'EndDateTime' => $curr_date,
'RelatedTo' => $relatedto,
'IsCompleted' => isset($checked) && ($checked == 1) ? $checked : $markasdone,
'Location' => 0,
'Type' => 2, // lead
'Description' => addslashes($details),
'CustSysId' => (int) $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
'AgencySysId' => $AgencySysId,
'CreateDate' => $curr_date,
'UpdateDate' => $curr_date,
'CallType' => $calltype,
'CallStatus' => $callstatus,
'ActionId' => $AgencyCRMLeadSysId
);
$data['StartDateTime'] = trim($startdate . ' ' . $todostartdatetime);
$data['EndDateTime'] = trim($startdate . ' ' . $todostartdatetime);
} else {
$data = array(
'Subject' => $todosubject,
'StartDateTime' => $curr_date,
'EndDateTime' => $curr_date,
'RelatedTo' => $relatedto,
'IsCompleted' => isset($checked) && ($checked == 1) ? $checked : $markasdone,
'Location' => 0,
'Type' => 2, // lead
'Description' => addslashes($details),
'CustSysId' => (int) $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
'AgencySysId' => $AgencySysId,
'CreateDate' => $curr_date,
'UpdateDate' => $curr_date,
'CallType' => $calltype,
'CallStatus' => $callstatus,
'ActionId' => $AgencyCRMLeadSysId
);
}
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
//update customer
$date = date('Y-m-d H:i:s');
$userQueryArray = array(
'UpdateDate' => $date,
);
if (!empty($custsysID)) {
$whereQuery = "CustomerSysId = " . $custsysID . "";
$updatecustomer = $this->_agencycustomerObj->UpdateAgencyCustomer($userQueryArray, $whereQuery);
}
if ($AgencyCRMLeadSysId > 0) {
$getLeadDetailById = $this->_crmagencyleadaccountObj->getAgentIdFromLeadId($AgencyCRMLeadSysId);
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
if ($getLeadDetailById['AssignUserSysId'] == 0) {
$userArray = array(
'AssignUserSysId' => $assignedto ? $assignedto : $agentID,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
}
}
if (!empty($nextstepcall) && $nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
if ($nextstepcall == 1) {
$todosubject = 'Call';
} else if ($nextstepcall == 2) {
$todosubject = 'To Do';
} else {
$todosubject = 'Meeting';
}
$data = array(
'Subject' => $todosubject,
'StartDateTime' => trim($startdate . ' ' . $todostartdatetime),
'EndDateTime' => trim($startdate . ' ' . $todostartdatetime),
'RelatedTo' => $relatedto,
'IsCompleted' => 0,
'Location' => 0,
'Type' => 2, // lead
'Description' => '',
'CustSysId' => $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
'AgencySysId' => $AgencySysId,
'CreateDate' => $curr_date,
'UpdateDate' => $curr_date,
'CallType' => 0,
'CallStatus' => 0,
'ActionId' => $AgencyCRMLeadSysId
);
$this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
} else if (!empty($nextstepcall) && $nextstepcall == 4) {
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($custsysID)), 1);
$redirect_Link = '/customer/customer-profile-desc/id/' . base64_encode($custsysID) . '/code/' . $secureCode . '/SearchData/' . $AgencyCRMLeadSysId;
$response = array('success' => true, 'msg' => 'Sucess', 'statge' => '50', 'link' => $redirect_Link);
echo json_encode($response);
exit;
} else if ((!empty($nextstepcall) && $nextstepcall == 5 && !empty($LeadStage))) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
$IsMarkForDelete = 0;
$IsApproved = 0;
// if ($LeadStage == 47) {
// $IsMarkForDelete = 1;
// }
$userArray = array(
'LeadStageSysId' => $LeadStage,
'IsMarkForDelete' => $IsMarkForDelete,
'IsApproved' => $IsApproved,
'AssignUserSysId' => $assignedto ? $assignedto : $agentID,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$response = array('success' => true, 'msg' => 'Sucess');
echo json_encode($response);
exit;
}
if ($lastID) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
if ($nextstepcall == 1) {
$userArray = array(
'LeadStageSysId' => 52,
'UpdatedDate' => $date,
'FollowUp' => 1
);
} else {
$userArray = array(
'UpdatedDate' => $date,
'FollowUp' => 1
);
}
$this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$response = array('success' => true, 'msg' => 'Sucess');
echo json_encode($response);
exit;
}
}
public function getTypeaheadCityDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$countryId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('countryId'));
$stateId = trim($this->_HtmlPurifier->filter($this->getRequest()->getParam('stateId')));
$cityId = trim($this->_HtmlPurifier->filter($this->getRequest()->getParam('cityId')));
$typevalue = $this->_HtmlPurifier->filter($this->getRequest()->getParam("query"));
$objCity = new Travel_Model_TblCity();
$objCity->strCondition = '';
if (isset($countryId) && $countryId != '' && $countryId > 0) {
$objCity->intContSysId = $countryId;
}
//if(isset($cityId) && $cityId!='' && $cityId > 0){
// $objCity->strCondition .= " AND TB_Master_Geo_City.CityId = '".$cityId."'";
//}
if (isset($stateId) && $stateId != '' && $stateId > 0) {
$objCity->strCondition .= " AND TB_Master_Geo_City.StateSysId = '" . $stateId . "'";
}
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('TBBCityId' => $row['TBBCityId'], 'CityId' => $row['CityId'], 'label' => $row['Title'], 'ContSysId' => trim($row['ContSysId']), 'Country' => trim($row['Country']));
}
}
echo json_encode($response);
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function getTypeaheadStatesListAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$countryId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('countryId'));
$typevalue = $this->_HtmlPurifier->filter($this->getRequest()->getParam("query"));
$objState = new Travel_Model_TblState();
$objState->strCondition = '';
if (isset($countryId) && $countryId != '' && $countryId > 0) {
$objState->intContSysId = $countryId;
}
//if(isset($cityId) && $cityId!='' && $cityId > 0){
// $objCity->strCondition .= " AND TB_Master_Geo_City.CityId = '".$cityId."'";
//}
if (isset($typevalue) && $typevalue != '') {
$objState->strCondition .= " AND (TB_Master_Geo_State.Title like '" . $typevalue . "%') ";
}
$cityList = $objState->getStateList();
$response = array();
if (!empty($cityList)) {
foreach ($cityList as $row) {
$response[] = array('StateId' => $row['StateId'], 'label' => $row['Title'], 'ContSysId' => trim($row['ContSysId']));
}
}
echo json_encode($response);
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function updateplanpriceAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$totprice = $this->_request->getParam('totprice') ? $this->_request->getParam('totprice') : '0';
$netprice = $this->_request->getParam('netprice') ? $this->_request->getParam('netprice') : '0';
$tpID = $this->_request->getParam('tpID') ? $this->_request->getParam('tpID') : '';
$where = "TPSysId = " . $tpID;
$updatetravelplan = array(
'NetPrice' => $totprice,
'Price' => $netprice
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplan, $where);
}
public function editproposalAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
$createDate = date('Y-m-d H:i:s');
$travelplanID = $getData['tpID'];
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($travelplanID);
$pkgtitle = $gettplandataforcustomer[0]['Title'];
#### For Fetching the Lead Detail which is sent to customer ####
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$planbookingID = 'Q/' . date('y');
$stratdate = $gettplandataforcustomer[0]['StartDate'];
$ValidTill = $gettplandataforcustomer[0]['ValidTill'];
//$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($travelplanID);
//$versionnum = $getlatestversion[0]['VersionId'];
$agentsysID = $this->intLoggedinUserId;
$customertravelpaln = array(
'PlanBookingId' => $planbookingID,
'VersionId' => $gettplandataforcustomer[0]['VersionId'] + 1,
'MasterTPSysId' => $gettplandataforcustomer[0]['MasterTPSysId'],
'AgencySysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'AgentSysId' => $agentsysID,
'StatusType' => 6,
'DocumentStatus' => 1,
'CustomerSysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PlanType' => 5,
'MinPax' => $gettplandataforcustomer[0]['MinPax'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'],
'Details' => $gettplandataforcustomer[0]['Details'],
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'],
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'],
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'],
'StartDate' => $stratdate->format('Y-m-d'),
'ValidTill' => $ValidTill->format('Y-m-d'),
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'],
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'],
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'],
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'],
'NetPrice' => $gettplandataforcustomer[0]['NetPrice'],
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'],
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'],
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'],
'Hotels' => $gettplandataforcustomer[0]['Hotels'],
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'],
'Cities' => $gettplandataforcustomer[0]['Cities'],
'Countries' => $gettplandataforcustomer[0]['Countries'],
'IsInsuranceExist' => $gettplandataforcustomer[0]['IsInsuranceExist'],
'RoomInfoJson' => $gettplandataforcustomer[0]['RoomInfoJson'],
'CreateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
$tpproposalID = $this->_crmcusttravelplan->addCustomerTravelPlan($customertravelpaln);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetCustomerTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'Cities' => $travelplanIetnaryData[$i]['Cities'],
'Countries' => $travelplanIetnaryData[$i]['Countries'],
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'],
'IsActive' => $travelplanIetnaryData[$i]['IsActive'],
);
$lasttravelitenaryID[] = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanCustomerItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : 0,
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'SpecialRequest' => '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : '',
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'AdultPax' => 0,
'ChildPax' => 0,
'InfantPax' => 0,
'PetPax' => 0,
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCost' => $tplanitenaryaccomdata[$k]['TotalCost'] ? $tplanitenaryaccomdata[$k]['TotalCost'] : 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => 0,
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $this->_crmcusttravelplanItenaryAccom->addCustomerTravelPlanAccom($travelitenaryaccomArray);
}
$tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanCustomterItenaryAir($travelplanID);
if (!empty($tpitenaryAirdata)) {
######### Add Air Data #######
for ($i = 0; $i < count($tpitenaryAirdata); $i++) {
$existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintairID, $travelpanitenary);
$travelitenaryaccomairArray = array(
'TPIntSysId' => $tpitenaryAirdata[$getkeyvalue] ? $tpitenaryAirdata[$getkeyvalue] : 0,
'SeqId' => $tpitenaryAirdata[$i]['SeqId'] ? $tpitenaryAirdata[$i]['SeqId'] : 0,
'AgencySysId' => $tpitenaryAirdata[$i]['AgencySysId'] ? $tpitenaryAirdata[$i]['AgencySysId'] : 0,
'Cost' => $tpitenaryAirdata[$i]['Cost'] ? $tpitenaryAirdata[$i]['Cost'] : 0,
'FlightNumber' => $tpitenaryAirdata[$i]['FlightNumber'] ? $tpitenaryAirdata[$i]['FlightNumber'] : 0,
'AirlineSysId' => $tpitenaryAirdata[$i]['AirlineSysId'] ? $tpitenaryAirdata[$i]['AirlineSysId'] : 0,
'ICSourceSysId' => $tpitenaryAirdata[$i]['ICSourceSysId'] ? $tpitenaryAirdata[$i]['ICSourceSysId'] : 0,
'IsFromAgency' => $tpitenaryAirdata[$i]['IsFromAgency'] ? $tpitenaryAirdata[$i]['IsFromAgency'] : 0,
'LocalFromTime' => $tpitenaryAirdata[$i]['LocalFromTime'] ? $tpitenaryAirdata[$i]['LocalFromTime'] : 0,
'LocalToTime' => $tpitenaryAirdata[$i]['LocalToTime'] ? $tpitenaryAirdata[$i]['LocalToTime'] : 0,
'FromUTCTime' => $tpitenaryAirdata[$i]['FromUTCTime'] ? $tpitenaryAirdata[$i]['FromUTCTime'] : 0,
'ToUTCTime' => $tpitenaryAirdata[$i]['ToUTCTime'] ? $tpitenaryAirdata[$i]['ToUTCTime'] : 0,
'FlightCabinClass' => $tpitenaryAirdata[$i]['FlightCabinClass'] ? $tpitenaryAirdata[$i]['FlightCabinClass'] : 0,
'AdultPax' => $tpitenaryAirdata[$i]['AdultPax'] ? $tpitenaryAirdata[$i]['AdultPax'] : 0,
'ChildPax' => $tpitenaryAirdata[$i]['ChildPax'] ? $tpitenaryAirdata[$i]['ChildPax'] : 0,
'InfentPax' => $tpitenaryAirdata[$i]['InfentPax'] ? $tpitenaryAirdata[$i]['InfentPax'] : 0,
'TotalPax' => $tpitenaryAirdata[$i]['TotalPax'] ? $tpitenaryAirdata[$i]['TotalPax'] : 0,
'IsDirect' => $tpitenaryAirdata[$i]['IsDirect'] ? $tpitenaryAirdata[$i]['IsDirect'] : 0,
'DayLightSavingDiff' => $tpitenaryAirdata[$i]['DayLightSavingDiff'] ? $tpitenaryAirdata[$i]['DayLightSavingDiff'] : 0,
'FlyingMinutes' => $tpitenaryAirdata[$i]['FlyingMinutes'] ? $tpitenaryAirdata[$i]['FlyingMinutes'] : 0,
'SourcePlaceSysId' => $tpitenaryAirdata[$i]['SourcePlaceSysId'] ? $tpitenaryAirdata[$i]['SourcePlaceSysId'] : 0,
'DestPlaceSysId' => $tpitenaryAirdata[$i]['DestPlaceSysId'] ? $tpitenaryAirdata[$i]['DestPlaceSysId'] : 0,
'SourceAirportCode' => $tpitenaryAirdata[$i]['SourceAirportCode'] ? $tpitenaryAirdata[$i]['SourceAirportCode'] : 0,
'DestAirportCode' => $tpitenaryAirdata[$i]['DestAirportCode'] ? $tpitenaryAirdata[$i]['DestAirportCode'] : 0,
'AirportHaultMinutes' => $tpitenaryAirdata[$i]['AirportHaultMinutes'] ? $tpitenaryAirdata[$i]['AirportHaultMinutes'] : 0,
'StopCount' => $tpitenaryAirdata[$i]['StopCount'] ? $tpitenaryAirdata[$i]['StopCount'] : 0,
'Stops' => $tpitenaryAirdata[$i]['Stops'] ? $tpitenaryAirdata[$i]['Stops'] : 0,
'Rating' => $tpitenaryAirdata[$i]['Rating'] ? $tpitenaryAirdata[$i]['Rating'] : 0,
'FllightFeatureMask' => $tpitenaryAirdata[$i]['FllightFeatureMask'] ? $tpitenaryAirdata[$i]['FllightFeatureMask'] : 0,
'UpdatedByISSysId' => $tpitenaryAirdata[$i]['UpdatedByISSysId'] ? $tpitenaryAirdata[$i]['UpdatedByISSysId'] : 0,
'CreatedByISSysId' => $tpitenaryAirdata[$i]['CreatedByISSysId'] ? $tpitenaryAirdata[$i]['CreatedByISSysId'] : 0,
'ImageTN' => $tpitenaryAirdata[$i]['ImageTN'] ? $tpitenaryAirdata[$i]['ImageTN'] : 0,
'ImgForList' => $tpitenaryAirdata[$i]['ImgForList'] ? $tpitenaryAirdata[$i]['ImgForList'] : 0,
'ImgeDetails' => $tpitenaryAirdata[$i]['ImgeDetails'] ? $tpitenaryAirdata[$i]['ImgeDetails'] : 0,
'UpdateDate' => $tpitenaryAirdata[$i]['UpdateDate'] ? $tpitenaryAirdata[$i]['UpdateDate'] : 0,
'CreateDate' => $tpitenaryAirdata[$i]['CreateDate'] ? $tpitenaryAirdata[$i]['CreateDate'] : 0,
'ApproveBy' => $tpitenaryAirdata[$i]['ApproveBy'] ? $tpitenaryAirdata[$i]['ApproveBy'] : 0,
'ApprovalDate' => $tpitenaryAirdata[$i]['ApprovalDate'] ? $tpitenaryAirdata[$i]['ApprovalDate'] : 0,
'IsApproved' => $tpitenaryAirdata[$i]['IsApproved'] ? $tpitenaryAirdata[$i]['IsApproved'] : 0,
'IsActive' => $tpitenaryAirdata[$i]['IsActive'] ? $tpitenaryAirdata[$i]['IsActive'] : 0,
'IsMarkForDel' => $tpitenaryAirdata[$i]['IsMarkForDel'] ? $tpitenaryAirdata[$i]['IsMarkForDel'] : 0,
'IsSelectedOnPkg' => $tpitenaryAirdata[$i]['IsSelectedOnPkg'] ? $tpitenaryAirdata[$i]['IsSelectedOnPkg'] : 1,
'encodedata' => $tpitenaryAirdata[$i]['encodedata'] ? $tpitenaryAirdata[$i]['encodedata'] : 0,
);
#################### Insert Records in Air Table #######################
// $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($travelitenaryaccomairArray);
}
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenrayEvents[$k]['Sequence'] ? $tpitenrayEvents[$k]['Sequence'] : 0,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? $tpitenrayEvents[$k]['AgencySysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? $tpitenrayEvents[$k]['Title'] : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? $tpitenrayEvents[$k]['Type'] : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? $tpitenrayEvents[$k]['CityId'] : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? $tpitenrayEvents[$k]['Cost'] : 0,
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'] ? $tpitenrayEvents[$k]['IsActive'] : 1,
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
);
$travelitenrayevents = $this->_crmcustomertravelItenaryEvents->addCustomerTravelItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_crmcustomertravelItenaryPlaces->addCustomerTravelItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetCustomerTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$travelitenraysightssing = $this->_crmcustomertravelSightSeeing->addCustomerTravelItenarySightSeeing($tpitenraysightseeingArray);
}
}
$travelplanmarketPrice = $this->_crmcusttravelplan->GetCustomerTravelMarketPrice($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelMarketPlaces->addCustomerTravelMarketRate($travelmarketpriceArray);
}
}
$tpitenarytransport = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarytransport)) {
for ($k = 0; $k < count($tpitenarytransport); $k++) {
$existingtpintID = $tpitenarytransport[$k]['TPInvnSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarytransport[$k]['FromDate'];
$toDate = $tpitenarytransport[$k]['ToDate'];
$tpitenraytransportArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenarytransport[$k]['Sequence'] ? $tpitenarytransport[$k]['Sequence'] : 0,
'VersionId' => $tpitenarytransport[$k]['VersionId'] ? $tpitenarytransport[$k]['VersionId'] : 0,
'XrefInvnItemSysId' => $tpitenarytransport[$k]['XrefInvnItemSysId'] ? $tpitenarytransport[$k]['XrefInvnItemSysId'] : 0,
'AgencySysId' => $tpitenarytransport[$k]['AgencySysId'] ? $tpitenarytransport[$k]['AgencySysId'] : 0,
'Qty' => $tpitenarytransport[$k]['Qty'] ? $tpitenarytransport[$k]['Qty'] : 0,
'Remark' => $tpitenarytransport[$k]['Remark'] ? $tpitenarytransport[$k]['Remark'] : 0,
'NetCost' => $tpitenarytransport[$k]['NetCost'] ? $tpitenarytransport[$k]['NetCost'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'ApproveBy' => 1,
'ApprovalDate' => $createDate,
'IsApproved' => $tpitenarytransport[$k]['IsApproved'] ? $tpitenarytransport[$k]['IsApproved'] : 0,
'IsActive' => $tpitenarytransport[$k]['IsActive'] ? $tpitenarytransport[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarytransport[$k]['IsMarkForDelete'] ? $tpitenarytransport[$k]['IsMarkForDelete'] : 0,
);
$travelitenraytransport = $this->_crmcustomertravelTransport->addCustomerTravelItenaryTransport($tpitenraytransportArray);
}
}
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $tpproposalID);
echo json_encode($response);
exit;
/*
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTerms($travelplanID);
if(!empty($travelplanterms) > 0){
for($k=0;$k<count($travelplanterms);$k++)
{
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanterms[$k]['AgencySysId'] ? $travelplanterms[$k]['AgencySysId'] : 0,
'Inclusions' => $travelplanterms[$k]['Inclusions'] ? $travelplanterms[$k]['Inclusions'] : 0,
'Exclusions' => $travelplanterms[$k]['Exclusions'] ? $travelplanterms[$k]['Exclusions'] : 0,
'CancellationPolicy' => $travelplanterms[$k]['CancellationPolicy'] ? $travelplanterms[$k]['CancellationPolicy'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
*/
// $tpitenarytrans = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
// $tpitenaryrules = $this->_crmcusttravelplan->GetTravelPlanItenaryRules($tplanitenayvalues);
// $tpitenraytermscond = $this->_crmcusttravelplan->GetTravelPlanTerms($tplanitenayvalues);
// $tpitenarytrnasdaywise = $this->_crmcusttravelplan->GetTravelPlanTransDaywise($tplanitenayvalues);
}
public function editreadymadeproposalAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$getData = $this->getRequest()->getPost();
$createDate = date('Y-m-d H:i:s');
$travelplanID = $getData['tpID'];
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($travelplanID);
$pkgtitle = $gettplandataforcustomer[0]['Title'] ? $gettplandataforcustomer[0]['Title'] : '';
#### For Fetching the Lead Detail which is sent to customer ####
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$planbookingID = 'Q/' . date('y');
$stratdate = $gettplandataforcustomer[0]['StartDate'];
$ValidTill = $gettplandataforcustomer[0]['ValidTill'];
//$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($travelplanID);
//$versionnum = $getlatestversion[0]['VersionId'];
$agentsysID = $this->intLoggedinUserId;
$customertravelpaln = array(
'VersionId' => 2,
'MasterRefId' => $travelplanID,
'AgencySysId' => $gettplandataforcustomer[0]['CustomerSysId'],
'PackRangeType' => $gettplandataforcustomer[0]['PackRangeType'],
'Title' => $gettplandataforcustomer[0]['Title'],
'EconomyMask' => $gettplandataforcustomer[0]['EconomyMask'],
'PackTypeMask' => $gettplandataforcustomer[0]['PackTypeMask'],
'InclCatMask' => $gettplandataforcustomer[0]['InclCatMask'],
'InclMask' => $gettplandataforcustomer[0]['InclMask'],
'ExclusionMask' => $gettplandataforcustomer[0]['ExclusionMask'],
'PackSpecType' => $gettplandataforcustomer[0]['PackSpecType'],
'SeasonMask' => $gettplandataforcustomer[0]['SeasonMask'],
'GeoType' => $gettplandataforcustomer[0]['GeoType'],
'IsFixDatePlan' => $gettplandataforcustomer[0]['IsFixDatePlan'],
'IsFixPlan' => $gettplandataforcustomer[0]['IsFixPlan'] ? $gettplandataforcustomer[0]['IsFixPlan'] : 0,
'Details' => $gettplandataforcustomer[0]['Details'] ? $gettplandataforcustomer[0]['Details'] : '',
'ImageTN' => $gettplandataforcustomer[0]['ImageTN'] ? $gettplandataforcustomer[0]['ImageTN'] : '',
'ImgForList' => $gettplandataforcustomer[0]['ImgForList'] ? $gettplandataforcustomer[0]['ImgForList'] : '',
'ImgeDetails' => $gettplandataforcustomer[0]['ImgeDetails'] ? $gettplandataforcustomer[0]['ImgeDetails'] : '',
'StartDate' => $stratdate->format('Y-m-d'),
'ValidTill' => $ValidTill->format('Y-m-d'),
'Price' => $gettplandataforcustomer[0]['Price'] ? $gettplandataforcustomer[0]['Price'] : 0,
'CurrencyType' => $gettplandataforcustomer[0]['CurrencyType'] ? $gettplandataforcustomer[0]['CurrencyType'] : 0,
'DiscountMsg' => $gettplandataforcustomer[0]['DiscountMsg'] ? $gettplandataforcustomer[0]['DiscountMsg'] : '',
'DiscountType' => $gettplandataforcustomer[0]['DiscountType'] ? $gettplandataforcustomer[0]['DiscountType'] : 0,
'Readymade' => 1,
'DiscountVal' => $gettplandataforcustomer[0]['DiscountVal'] ? $gettplandataforcustomer[0]['DiscountVal'] : 0,
'NetPrice' => $gettplandataforcustomer[0]['NetPrice'] ? $gettplandataforcustomer[0]['NetPrice'] : 0,
'MinPrice' => $gettplandataforcustomer[0]['MinPrice'] ? $gettplandataforcustomer[0]['MinPrice'] : 0,
'TotalMinDays' => $gettplandataforcustomer[0]['TotalMinDays'] ? $gettplandataforcustomer[0]['TotalMinDays'] : 0,
'TotalMaxDays' => $gettplandataforcustomer[0]['TotalMaxDays'] ? $gettplandataforcustomer[0]['TotalMaxDays'] : 0,
'Hotels' => $gettplandataforcustomer[0]['Hotels'] ? $gettplandataforcustomer[0]['Hotels'] : '',
'PopularPlaces' => $gettplandataforcustomer[0]['PopularPlaces'] ? $gettplandataforcustomer[0]['PopularPlaces'] : '',
'Cities' => $gettplandataforcustomer[0]['Cities'] ? $gettplandataforcustomer[0]['Cities'] : '',
'Countries' => $gettplandataforcustomer[0]['Countries'] ? $gettplandataforcustomer[0]['Countries'] : '',
'CreateDate' => $createDate,
'IsMarkForDel' => $gettplandataforcustomer[0]['IsMarkForDel'] ? $gettplandataforcustomer[0]['IsMarkForDel'] : 0,
'IsActive' => 1,
'IsAprooved' => 1,
);
$tpproposalID = $this->_travelplanObj->addTravelPlan($customertravelpaln);
$travelplanIetnaryData = $this->_crmcusttravelplan->GetCustomerTravelPlanItenary($travelplanID);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelpanitenary[] = $travelplanIetnaryData[$i]['TPIntSysId'];
}
$tplanitenayvalues = implode(",", $travelpanitenary);
for ($i = 0; $i < count($travelplanIetnaryData); $i++) {
$travelitenary = array(
'TPSysId' => $tpproposalID,
'Sequence' => $travelplanIetnaryData[$i]['Sequence'],
'AgencySysId' => $travelplanIetnaryData[$i]['AgencySysId'],
'Title' => $travelplanIetnaryData[$i]['Title'],
'Details' => $travelplanIetnaryData[$i]['Details'],
'InclMask' => trim($travelplanIetnaryData[$i]['InclMask']),
'ExclusionMask' => $travelplanIetnaryData[$i]['ExclusionMask'],
'InclCatMask' => trim($travelplanIetnaryData[$i]['InclCatMask']),
'PackInclMask' => $travelplanIetnaryData[$i]['PackInclMask'],
'PackTypeMask' => trim($travelplanIetnaryData[$i]['PackTypeMask']),
'ImageTN' => $travelplanIetnaryData[$i]['ImageTN'],
'ImgForList' => $travelplanIetnaryData[$i]['ImgForList'],
'ImgeDetails' => $travelplanIetnaryData[$i]['ImgeDetails'],
'Rating' => $travelplanIetnaryData[$i]['Rating'],
'TotalMinDays' => $travelplanIetnaryData[$i]['TotalMinDays'],
'TotalMaxDays' => $travelplanIetnaryData[$i]['TotalMaxDays'],
'Hotels' => $travelplanIetnaryData[$i]['Hotels'],
'PopularPlaces' => $travelplanIetnaryData[$i]['PopularPlaces'],
'CitySysId' => $travelplanIetnaryData[$i]['CitySysId'] ? $travelplanIetnaryData[$i]['CitySysId'] : 0,
'CreateDate' => $createDate,
'Cities' => $travelplanIetnaryData[$i]['Cities'] ? $travelplanIetnaryData[$i]['Cities'] : '',
'Countries' => $travelplanIetnaryData[$i]['Countries'] ? $travelplanIetnaryData[$i]['Countries'] : '',
'IsMarkForDel' => $travelplanIetnaryData[$i]['IsMarkForDel'] ? $travelplanIetnaryData[$i]['IsMarkForDel'] : 0,
'IsActive' => $travelplanIetnaryData[$i]['IsActive'] ? $travelplanIetnaryData[$i]['IsActive'] : 0,
);
$lasttravelitenaryID[] = $this->_travelplanitenaryObj->addTravelPlanItenary($travelitenary);
}
$tplanitenaryaccomdata = $this->_crmcusttravelplan->GetTravelPlanCustomerItenaryAccom($tplanitenayvalues);
for ($k = 0; $k < count($tplanitenaryaccomdata); $k++) {
$existingtpintID = $tplanitenaryaccomdata[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tplanitenaryaccomdata[$k]['SeqId'] ? $tplanitenaryaccomdata[$k]['SeqId'] : 0,
'AgencySysId' => $tplanitenaryaccomdata[$k]['AgencySysId'] ? $tplanitenaryaccomdata[$k]['AgencySysId'] : 0,
'InvnItemSysId' => $tplanitenaryaccomdata[$k]['InvnItemSysId'] ? $tplanitenaryaccomdata[$k]['InvnItemSysId'] : 0,
'AccoSysId' => $tplanitenaryaccomdata[$k]['AccoSysId'] ? $tplanitenaryaccomdata[$k]['AccoSysId'] : 0,
'XrefInvtSysId' => $tplanitenaryaccomdata[$k]['XrefInvtSysId'] ? $tplanitenaryaccomdata[$k]['XrefInvtSysId'] : 0,
'RoomType' => $tplanitenaryaccomdata[$k]['RoomType'] ? $tplanitenaryaccomdata[$k]['RoomType'] : 0,
'RoomNumber' => $tplanitenaryaccomdata[$k]['RoomNumber'] ? $tplanitenaryaccomdata[$k]['RoomNumber'] : 0,
'Title' => $tplanitenaryaccomdata[$k]['Title'] ? $tplanitenaryaccomdata[$k]['Title'] : '',
'CheckInTime' => $tplanitenaryaccomdata[$k]['CheckInTime'] ? $tplanitenaryaccomdata[$k]['CheckInTime'] : '',
'CheckOutTime' => $tplanitenaryaccomdata[$k]['CheckOutTime'] ? $tplanitenaryaccomdata[$k]['CheckOutTime'] : '',
'XRefCityId' => $tplanitenaryaccomdata[$k]['XRefCityId'] ? $tplanitenaryaccomdata[$k]['XRefCityId'] : '',
'FromDate' => $tplanitenaryaccomdata[$k]['FromDate'] ? $tplanitenaryaccomdata[$k]['FromDate'] : '',
'ToDate' => $tplanitenaryaccomdata[$k]['ToDate'] ? $tplanitenaryaccomdata[$k]['ToDate'] : '',
'TotalPax' => $tplanitenaryaccomdata[$k]['TotalPax'] ? $tplanitenaryaccomdata[$k]['TotalPax'] : 0,
'TotalNights' => $tplanitenaryaccomdata[$k]['TotalNights'] ? $tplanitenaryaccomdata[$k]['TotalNights'] : 0,
'StarRating' => $tplanitenaryaccomdata[$k]['StarRating'] ? $tplanitenaryaccomdata[$k]['StarRating'] : 0,
'CurrencyType' => $tplanitenaryaccomdata[$k]['CurrencyType'] ? $tplanitenaryaccomdata[$k]['CurrencyType'] : 0,
'TotalCostGen' => 0,
'TotalCostSO' => 0,
'TotalCostDO' => 0,
'TotalCostTO' => 0,
'Discounts' => $tplanitenaryaccomdata[$k]['Discounts'] ? $tplanitenaryaccomdata[$k]['Discounts'] : 0,
'Taxes' => $tplanitenaryaccomdata[$k]['Taxes'] ? $tplanitenaryaccomdata[$k]['Taxes'] : 0,
'IsSelectedOnPkg' => $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] ? $tplanitenaryaccomdata[$k]['IsSelectedOnPkg'] : 0,
'NetCost' => $tplanitenaryaccomdata[$k]['NetCost'] ? $tplanitenaryaccomdata[$k]['NetCost'] : 0,
'CreateDate' => $tplanitenaryaccomdata[$k]['CreateDate'] ? $tplanitenaryaccomdata[$k]['CreateDate'] : '',
'UpdateDate' => $tplanitenaryaccomdata[$k]['UpdateDate'] ? $tplanitenaryaccomdata[$k]['UpdateDate'] : '',
'IsMarkForDel' => $tplanitenaryaccomdata[$k]['IsMarkForDel'] ? $tplanitenaryaccomdata[$k]['IsMarkForDel'] : '',
'IsActive' => 1,
);
$tplanitenaryaccomdataID = $this->_travelitenaryaccom->addTravelPlanItenaryAccom($travelitenaryaccomArray);
}
$tpitenaryAirdata = $this->_crmcusttravelplan->GetTravelPlanCustomterItenaryAir($travelplanID);
if (!empty($tpitenaryAirdata)) {
######### Add Air Data #######
for ($i = 0; $i < count($tpitenaryAirdata); $i++) {
$existingtpintairID = $tpitenaryAirdata[$i]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintairID, $travelpanitenary);
$travelitenaryaccomairArray = array(
'TPIntSysId' => $tpitenaryAirdata[$getkeyvalue] ? $tpitenaryAirdata[$getkeyvalue] : 0,
'SeqId' => $tpitenaryAirdata[$i]['SeqId'] ? $tpitenaryAirdata[$i]['SeqId'] : 0,
'InvnItemSysId' => $tpitenaryAirdata[$i]['InvnItemSysId'] ? $tpitenaryAirdata[$i]['InvnItemSysId'] : 0,
'AgencySysId' => $tpitenaryAirdata[$i]['AgencySysId'] ? $tpitenaryAirdata[$i]['AgencySysId'] : 0,
'Cost' => $tpitenaryAirdata[$i]['Cost'] ? $tpitenaryAirdata[$i]['Cost'] : 0,
'FlightNumber' => $tpitenaryAirdata[$i]['FlightNumber'] ? $tpitenaryAirdata[$i]['FlightNumber'] : 0,
'AirlineSysId' => $tpitenaryAirdata[$i]['AirlineSysId'] ? $tpitenaryAirdata[$i]['AirlineSysId'] : 0,
'ICSourceSysId' => $tpitenaryAirdata[$i]['ICSourceSysId'] ? $tpitenaryAirdata[$i]['ICSourceSysId'] : 0,
'IsFromAgency' => $tpitenaryAirdata[$i]['IsFromAgency'] ? $tpitenaryAirdata[$i]['IsFromAgency'] : 0,
'LocalFromTime' => $tpitenaryAirdata[$i]['LocalFromTime'] ? $tpitenaryAirdata[$i]['LocalFromTime'] : 0,
'LocalToTime' => $tpitenaryAirdata[$i]['LocalToTime'] ? $tpitenaryAirdata[$i]['LocalToTime'] : 0,
'FromUTCTime' => $tpitenaryAirdata[$i]['FromUTCTime'] ? $tpitenaryAirdata[$i]['FromUTCTime'] : 0,
'ToUTCTime' => $tpitenaryAirdata[$i]['ToUTCTime'] ? $tpitenaryAirdata[$i]['ToUTCTime'] : 0,
'FlightCabinClass' => $tpitenaryAirdata[$i]['FlightCabinClass'] ? $tpitenaryAirdata[$i]['FlightCabinClass'] : 0,
'AdultPax' => $tpitenaryAirdata[$i]['AdultPax'] ? $tpitenaryAirdata[$i]['AdultPax'] : 0,
'ChildPax' => $tpitenaryAirdata[$i]['ChildPax'] ? $tpitenaryAirdata[$i]['ChildPax'] : 0,
'InfentPax' => $tpitenaryAirdata[$i]['InfentPax'] ? $tpitenaryAirdata[$i]['InfentPax'] : 0,
'TotalPax' => $tpitenaryAirdata[$i]['TotalPax'] ? $tpitenaryAirdata[$i]['TotalPax'] : 0,
'IsDirect' => $tpitenaryAirdata[$i]['IsDirect'] ? $tpitenaryAirdata[$i]['IsDirect'] : 0,
'DayLightSavingDiff' => $tpitenaryAirdata[$i]['DayLightSavingDiff'] ? $tpitenaryAirdata[$i]['DayLightSavingDiff'] : 0,
'FlyingMinutes' => $tpitenaryAirdata[$i]['FlyingMinutes'] ? $tpitenaryAirdata[$i]['FlyingMinutes'] : 0,
'SourcePlaceSysId' => $tpitenaryAirdata[$i]['SourcePlaceSysId'] ? $tpitenaryAirdata[$i]['SourcePlaceSysId'] : 0,
'DestPlaceSysId' => $tpitenaryAirdata[$i]['DestPlaceSysId'] ? $tpitenaryAirdata[$i]['DestPlaceSysId'] : 0,
'SourceAirportCode' => $tpitenaryAirdata[$i]['SourceAirportCode'] ? $tpitenaryAirdata[$i]['SourceAirportCode'] : 0,
'DestAirportCode' => $tpitenaryAirdata[$i]['DestAirportCode'] ? $tpitenaryAirdata[$i]['DestAirportCode'] : 0,
'AirportHaultMinutes' => $tpitenaryAirdata[$i]['AirportHaultMinutes'] ? $tpitenaryAirdata[$i]['AirportHaultMinutes'] : 0,
'StopCount' => $tpitenaryAirdata[$i]['StopCount'] ? $tpitenaryAirdata[$i]['StopCount'] : 0,
'Stops' => $tpitenaryAirdata[$i]['Stops'] ? $tpitenaryAirdata[$i]['Stops'] : 0,
'Rating' => $tpitenaryAirdata[$i]['Rating'] ? $tpitenaryAirdata[$i]['Rating'] : 0,
'FllightFeatureMask' => $tpitenaryAirdata[$i]['FllightFeatureMask'] ? $tpitenaryAirdata[$i]['FllightFeatureMask'] : 0,
'UpdatedByISSysId' => $tpitenaryAirdata[$i]['UpdatedByISSysId'] ? $tpitenaryAirdata[$i]['UpdatedByISSysId'] : 0,
'CreatedByISSysId' => $tpitenaryAirdata[$i]['CreatedByISSysId'] ? $tpitenaryAirdata[$i]['CreatedByISSysId'] : 0,
'ImageTN' => $tpitenaryAirdata[$i]['ImageTN'] ? $tpitenaryAirdata[$i]['ImageTN'] : 0,
'ImgForList' => $tpitenaryAirdata[$i]['ImgForList'] ? $tpitenaryAirdata[$i]['ImgForList'] : 0,
'ImgeDetails' => $tpitenaryAirdata[$i]['ImgeDetails'] ? $tpitenaryAirdata[$i]['ImgeDetails'] : 0,
'UpdateDate' => $tpitenaryAirdata[$i]['UpdateDate'] ? $tpitenaryAirdata[$i]['UpdateDate'] : 0,
'CreateDate' => $tpitenaryAirdata[$i]['CreateDate'] ? $tpitenaryAirdata[$i]['CreateDate'] : 0,
'ApproveBy' => $tpitenaryAirdata[$i]['ApproveBy'] ? $tpitenaryAirdata[$i]['ApproveBy'] : 0,
'ApprovalDate' => $tpitenaryAirdata[$i]['ApprovalDate'] ? $tpitenaryAirdata[$i]['ApprovalDate'] : 0,
'IsApproved' => $tpitenaryAirdata[$i]['IsApproved'] ? $tpitenaryAirdata[$i]['IsApproved'] : 0,
'IsActive' => $tpitenaryAirdata[$i]['IsActive'] ? $tpitenaryAirdata[$i]['IsActive'] : 0,
'IsMarkForDel' => $tpitenaryAirdata[$i]['IsMarkForDel'] ? $tpitenaryAirdata[$i]['IsMarkForDel'] : 0,
'encodedata' => $tpitenaryAirdata[$i]['encodedata'] ? $tpitenaryAirdata[$i]['encodedata'] : 0,
);
#################### Insert Records in Air Table #######################
$this->_travelitenaryair->addTravelPlanItenaryAir($travelitenaryaccomairArray);
}
}
$tpitenrayEvents = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryEvents($tplanitenayvalues);
if (!empty($tpitenrayEvents)) {
for ($k = 0; $k < count($tpitenrayEvents); $k++) {
$existingtpintID = $tpitenrayEvents[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayevntsArray = array(
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenrayEvents[$k]['Sequence'] ? $tpitenrayEvents[$k]['Sequence'] : 0,
'AgencySysId' => $tpitenrayEvents[$k]['AgencySysId'] ? $tpitenrayEvents[$k]['AgencySysId'] : 0,
'InvnItemSysId' => $tpitenrayEvents[$k]['InvnItemSysId'] ? $tpitenrayEvents[$k]['InvnItemSysId'] : 0,
'TPActivitySysId' => $tpitenrayEvents[$k]['TPActivitySysId'] ? $tpitenrayEvents[$k]['TPActivitySysId'] : 0,
'CurrencyType' => $tpitenrayEvents[$k]['CurrencyType'] ? $tpitenrayEvents[$k]['CurrencyType'] : 0,
'Title' => $tpitenrayEvents[$k]['Title'] ? $tpitenrayEvents[$k]['Title'] : '',
'Type' => $tpitenrayEvents[$k]['Type'] ? $tpitenrayEvents[$k]['Type'] : '',
'CityId' => $tpitenrayEvents[$k]['CityId'] ? $tpitenrayEvents[$k]['CityId'] : 0,
'Cost' => $tpitenrayEvents[$k]['Cost'] ? $tpitenrayEvents[$k]['Cost'] : 0,
'IsMarkForDel' => $tpitenrayEvents[$k]['IsMarkForDel'] ? $tpitenrayEvents[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenrayEvents[$k]['IsActive'] ? $tpitenrayEvents[$k]['IsActive'] : 1,
'Markup' => $tpitenrayEvents[$k]['Markup'] ? $tpitenrayEvents[$k]['Markup'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate
);
$travelitenrayevents = $this->_travelplanevents->addTravelPlanItenaryEvents($tpitenrayevntsArray);
}
}
$tpitenaryplaces = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryPaces($tplanitenayvalues);
if (!empty($tpitenaryplaces)) {
for ($k = 0; $k < count($tpitenaryplaces); $k++) {
$existingtpintID = $tpitenaryplaces[$k]['TPIntSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$tpitenrayplacesArray = array(
'TPSysId' => $tpproposalID,
'TPIntSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenaryplaces[$k]['Sequence'] ? $tpitenaryplaces[$k]['Sequence'] : 0,
'PlaceSysId' => $tpitenaryplaces[$k]['PlaceSysId'] ? $tpitenaryplaces[$k]['PlaceSysId'] : 0,
'AgencySysId' => $tpitenaryplaces[$k]['AgencySysId'] ? $tpitenaryplaces[$k]['AgencySysId'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $tpitenaryplaces[$k]['IsMarkForDel'] ? $tpitenaryplaces[$k]['IsMarkForDel'] : 0,
'IsActive' => $tpitenaryplaces[$k]['IsActive'] ? $tpitenaryplaces[$k]['IsActive'] : 0,
);
$travelitenrayplaces = $this->_travelplanplaces->addTravelPlanItenaryPlaces($tpitenrayplacesArray);
}
}
$tpitenarysightseeing = $this->_crmcusttravelplan->GetCustomerTravelPlanSightSeeing($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarysightseeing)) {
for ($k = 0; $k < count($tpitenarysightseeing); $k++) {
$existingtpintID = $tpitenarysightseeing[$k]['InvnItemSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarysightseeing[$k]['FromDate'];
$toDate = $tpitenarysightseeing[$k]['ToDate'];
$tpitenraysightseeingArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'SeqId' => $tpitenarysightseeing[$k]['SeqId'] ? $tpitenarysightseeing[$k]['SeqId'] : 0,
'SSSysId' => $tpitenarysightseeing[$k]['SSSysId'] ? $tpitenarysightseeing[$k]['SSSysId'] : 0,
'AgencySysId' => $tpitenarysightseeing[$k]['AgencySysId'] ? $tpitenarysightseeing[$k]['AgencySysId'] : 0,
'Title' => $tpitenarysightseeing[$k]['Title'] ? $tpitenarysightseeing[$k]['Title'] : 0,
'Type' => $tpitenarysightseeing[$k]['Type'] ? $tpitenarysightseeing[$k]['Type'] : 0,
'CityId' => $tpitenarysightseeing[$k]['CityId'] ? $tpitenarysightseeing[$k]['CityId'] : 0,
'Cost' => $tpitenarysightseeing[$k]['Cost'] ? $tpitenarysightseeing[$k]['Cost'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'BookingType' => $tpitenarysightseeing[$k]['BookingType'] ? $tpitenarysightseeing[$k]['BookingType'] : 0,
'Qty' => $tpitenarysightseeing[$k]['Qty'] ? $tpitenarysightseeing[$k]['Qty'] : 0,
'IfAnyOffer' => $tpitenarysightseeing[$k]['IfAnyOffer'] ? $tpitenarysightseeing[$k]['IfAnyOffer'] : 0,
'OfferMsg' => $tpitenarysightseeing[$k]['OfferMsg'] ? $tpitenarysightseeing[$k]['OfferMsg'] : 0,
'OfferImage' => $tpitenarysightseeing[$k]['OfferImage'] ? $tpitenarysightseeing[$k]['OfferImage'] : 0,
'IxFixedDateInven' => $tpitenarysightseeing[$k]['IxFixedDateInven'] ? $tpitenarysightseeing[$k]['IsMarkForDel'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $tpitenarysightseeing[$k]['IsActive'] ? $tpitenarysightseeing[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarysightseeing[$k]['IsMarkForDelete'] ? $tpitenarysightseeing[$k]['IsMarkForDelete'] : 0,
);
$travelitenraysightssing = $this->_travelplansight->addTravelPlanSightSeeing($tpitenraysightseeingArray);
}
}
####################### Market Price Rate ###############################
$travelplanmarketPrice = $this->_crmcusttravelplan->GetCustomerTravelMarketPrice($travelplanID);
if (!empty($travelplanmarketPrice)) {
for ($k = 0; $k < count($travelplanmarketPrice); $k++) {
$fromDate = $travelplanmarketPrice[$k]['FromDate'];
$toDate = $travelplanmarketPrice[$k]['ToDate'];
$travelmarketpriceArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanmarketPrice[$k]['AgencySysId'] ? $travelplanmarketPrice[$k]['AgencySysId'] : 0,
'FromDate' => $fromDate->format('Y-m-d'),
'ToDate' => $toDate->format('Y-m-d'),
'CurrencyType' => $travelplanmarketPrice[$k]['CurrencyType'] ? $travelplanmarketPrice[$k]['CurrencyType'] : 0,
'MarkType' => $travelplanmarketPrice[$k]['MarkType'] ? $travelplanmarketPrice[$k]['MarkType'] : 0,
'MarketPlaceId' => $travelplanmarketPrice[$k]['MarketPlaceId'] ? $travelplanmarketPrice[$k]['MarketPlaceId'] : 0,
'MarketPlace' => $travelplanmarketPrice[$k]['MarketPlace'] ? $travelplanmarketPrice[$k]['MarketPlace'] : 0,
'Permission' => $travelplanmarketPrice[$k]['Permission'] ? $travelplanmarketPrice[$k]['Permission'] : 0,
'MarkPercent' => $travelplanmarketPrice[$k]['MarkPercent'] ? $travelplanmarketPrice[$k]['MarkPercent'] : 0,
'CostPPSO' => $travelplanmarketPrice[$k]['CostPPSO'] ? $travelplanmarketPrice[$k]['CostPPSO'] : 0,
'CostPPDO' => $travelplanmarketPrice[$k]['CostPPDO'] ? $travelplanmarketPrice[$k]['CostPPDO'] : 0,
'CostPPTO' => $travelplanmarketPrice[$k]['CostPPTO'] ? $travelplanmarketPrice[$k]['CostPPTO'] : 0,
'CostExtraBed' => $travelplanmarketPrice[$k]['CostExtraBed'] ? $travelplanmarketPrice[$k]['CostExtraBed'] : 0,
'AdultCostExtraBed' => $travelplanmarketPrice[$k]['AdultCostExtraBed'] ? $travelplanmarketPrice[$k]['AdultCostExtraBed'] : 0,
'CostChildWithoutBed' => $travelplanmarketPrice[$k]['CostChildWithoutBed'] ? $travelplanmarketPrice[$k]['CostChildWithoutBed'] : 0,
'Tax' => $travelplanmarketPrice[$k]['Tax'] ? $travelplanmarketPrice[$k]['Tax'] : 0,
'ExcludedPercent' => $travelplanmarketPrice[$k]['ExcludedPercent'] ? $travelplanmarketPrice[$k]['ExcludedPercent'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => $travelplanmarketPrice[$k]['IsActive'] ? $travelplanmarketPrice[$k]['IsActive'] : 0,
'IsMarkForDel' => 0,
);
$travelitenramarketwsierate = $this->_travelplanmarketwiserate->addTravelPlanRate($travelmarketpriceArray);
}
}
$tpitenarytransport = $this->_crmcusttravelplan->GetCustomerTravelPlanItenaryTransport($tplanitenayvalues);
//echo '<pre>';
//print_r($tpitenarysightseeing);
if (!empty($tpitenarytransport)) {
for ($k = 0; $k < count($tpitenarytransport); $k++) {
$existingtpintID = $tpitenarytransport[$k]['TPInvnSysId'];
$getkeyvalue = array_search($existingtpintID, $travelpanitenary);
$fromDate = $tpitenarytransport[$k]['FromDate'];
$toDate = $tpitenarytransport[$k]['ToDate'];
$tpitenraytransportArray = array(
'InvnItemSysId' => $lasttravelitenaryID[$getkeyvalue] ? $lasttravelitenaryID[$getkeyvalue] : 0,
'Sequence' => $tpitenarytransport[$k]['Sequence'] ? $tpitenarytransport[$k]['Sequence'] : 0,
'VersionId' => $tpitenarytransport[$k]['VersionId'] ? $tpitenarytransport[$k]['VersionId'] : 0,
'XrefInvnItemSysId' => $tpitenarytransport[$k]['XrefInvnItemSysId'] ? $tpitenarytransport[$k]['XrefInvnItemSysId'] : 0,
'AgencySysId' => $tpitenarytransport[$k]['AgencySysId'] ? $tpitenarytransport[$k]['AgencySysId'] : 0,
'Qty' => $tpitenarytransport[$k]['Qty'] ? $tpitenarytransport[$k]['Qty'] : 0,
'Remark' => $tpitenarytransport[$k]['Remark'] ? $tpitenarytransport[$k]['Remark'] : 0,
'NetCost' => $tpitenarytransport[$k]['NetCost'] ? $tpitenarytransport[$k]['NetCost'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'ApproveBy' => 1,
'ApprovalDate' => $createDate,
'IsApproved' => $tpitenarytransport[$k]['IsApproved'] ? $tpitenarytransport[$k]['IsApproved'] : 0,
'IsActive' => $tpitenarytransport[$k]['IsActive'] ? $tpitenarytransport[$k]['IsActive'] : 0,
'IsMarkForDelete' => $tpitenarytransport[$k]['IsMarkForDelete'] ? $tpitenarytransport[$k]['IsMarkForDelete'] : 0,
);
$travelitenraytransport = $this->_travelplanitenarytransObj->addTravelPlanItenaryTrans($tpitenraytransportArray);
}
}
$response = array('success' => true, 'msg' => 'Package Search.', 'lastID' => $tpproposalID);
echo json_encode($response);
exit;
/*
$travelplanterms = $this->_crmcusttravelplan->GetCustomerTravelPlanTerms($travelplanID);
if(!empty($travelplanterms) > 0){
for($k=0;$k<count($travelplanterms);$k++)
{
$travelplantermsArray = array(
'TPIntSysId' => $tpproposalID,
'AgencySysId' => $travelplanterms[$k]['AgencySysId'] ? $travelplanterms[$k]['AgencySysId'] : 0,
'Inclusions' => $travelplanterms[$k]['Inclusions'] ? $travelplanterms[$k]['Inclusions'] : 0,
'Exclusions' => $travelplanterms[$k]['Exclusions'] ? $travelplanterms[$k]['Exclusions'] : 0,
'CancellationPolicy' => $travelplanterms[$k]['CancellationPolicy'] ? $travelplanterms[$k]['CancellationPolicy'] : 0,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDel' => $travelplanterms[$k]['IsMarkForDel'] ? $travelplanterms[$k]['IsMarkForDel'] : 0,
'IsActive' => $travelplanterms[$k]['IsActive'] ? $travelplanterms[$k]['IsActive'] : 0,
);
$travelitenramarketwsierate = $this->_crmcustomertravelTerm->addCustomerTerm($travelplantermsArray);
}
}
*/
// $tpitenarytrans = $this->_crmcusttravelplan->GetTravelPlanItenaryTransport($tplanitenayvalues);
// $tpitenaryrules = $this->_crmcusttravelplan->GetTravelPlanItenaryRules($tplanitenayvalues);
// $tpitenraytermscond = $this->_crmcusttravelplan->GetTravelPlanTerms($tplanitenayvalues);
// $tpitenarytrnasdaywise = $this->_crmcusttravelplan->GetTravelPlanTransDaywise($tplanitenayvalues);
}
public function addNewGoogleCityAction() {
$this->_helper->layout->disableLayout();
$intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
$objPackage = new Travel_Model_TblPackage();
$code = $this->_HtmlPurifier->filter($this->getRequest()->getParam('code'));
$cityname = $this->_HtmlPurifier->filter($this->getRequest()->getParam('cityname'));
$countryId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('countryId'));
$this->view->code = $this->_HtmlPurifier->filter($code);
$this->view->cityname = $this->_HtmlPurifier->filter($cityname);
$this->view->countryId = $this->_HtmlPurifier->filter($countryId);
//echo '<pre>';
//echo $this->getRequest()->getParam('code');
}
public function addNewCityAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$cityName = $this->_HtmlPurifier->filter($this->getRequest()->getParam('city_long_name'));
$place_lat = $this->_HtmlPurifier->filter($this->getRequest()->getParam('place_lat'));
$place_lng = $this->_HtmlPurifier->filter($this->getRequest()->getParam('place_lng'));
$intCity = $this->_HtmlPurifier->filter($this->getRequest()->getParam('intCity'));
$ContSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('contId'));
$formatted_address = $this->_HtmlPurifier->filter($this->getRequest()->getParam('formatted_address'));
$objCountry = new Travel_Model_TblCountry();
$objCountry->strCondition = " AND ContId=" . $ContSysId . "";
$detailCountry = $objCountry->getCountryList();
$countryName = $detailCountry[0]['Title'];
//add this city into database
$createDate = date('Y-m-d H:i:s');
$cityArray = array(
'Title' => $cityName ? $cityName : '',
'Alias' => $cityName ? $cityName : '',
'Country' => $countryName ? $countryName : '',
'StateSysId' => 0,
'ZoneSysId' => 0,
'PIN' => 0,
'GetLat' => $place_lat ? $place_lat : 0,
'GetLong' => $place_lng ? $place_lng : 0,
'ContSysId' => $ContSysId ? $ContSysId : 0,
'TBBCityId' => $intCity ? $intCity : 0,
'Synonyms' => $formatted_address ? $formatted_address : 0,
'UpdateDate' => $createDate,
'CreateDate' => $createDate,
'IsActive' => 1,
'IsApproved' => 0,
);
// print_r($cityArray);die;
$objcity = new Travel_Model_TblCity();
$addCity = $objcity->insertTable('TB_Master_Geo_City', $cityArray);
//print_r($addCity);die;
//end of add ciry
//$cityName='test';
$cityId = 2;
$res = array('cityName' => $cityName, 'cityId' => $addCity);
echo json_encode($res);
}
public function getlatlongAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$google_dr_address = $this->_request->getParam('showlocation');
$address = urlencode($google_dr_address);
$region = "";
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address");
//echo $json;
$decoded = json_decode($json);
//print_r($decoded->results[0]);die;
if ($decoded->status == 'ZERO_RESULTS') {
$response = array('status' => 'failed', 'errorCode' => $decoded->status);
} else {
$get_lat_long = $decoded->results[0]->geometry->location; //print "<pre>";print_r($get_lat_long);print "</pre>";die;
if (is_object($get_lat_long) && (!empty($get_lat_long))) {
$latitude = $get_lat_long->lat;
$longitude = $get_lat_long->lng;
$formatted_address = $decoded->results[0]->formatted_address;
$city_long_name = $decoded->results[0]->address_components[0]->long_name;
$city_short_name = $decoded->results[0]->address_components[0]->short_name;
$city_types = $decoded->results[0]->address_components[0]->types;
$response = array('status' => 'success', 'place_lat' => $latitude, 'place_lng' => $longitude, 'formatted_address' => $formatted_address, 'city_long_name' => $city_long_name);
}
}
echo json_encode($response);
}
public function customerTodoAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
//check customer status added by Er Amit Kumar Dubey on 20 april 2017 at 11:11 AM
if (count($getCustomerDetail) == 0) {
$this->_redirect('/customer/customer-message/type/status');
exit;
}
//end of check customer status
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$getAllCustomerTODO = $this->_crmcustomerObj->GetAllCustomerToDo($CustomerSysId, $ReportingToSysId);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
//print_r($foodPreferenceList);
//$cityListArray = $this->_objPkg->getCityList();
$cityListArray = array();
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->cityListArray = $cityListArray;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getAllCustomerTODO);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
//this function used for all customer tab beacuse functionlity added in flightsearch lead
$airportlist = $this->_objAirport->getAirportListWithCountryCode();
$this->view->sourceCity = $airportlist;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
//end of flight search lead
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
}
}
public function customerViewToDoAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$todoId = $this->getRequest()->getParam('tid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tid'))) : '';
if (isset($todoId) && !empty($todoId)) {
$getCustomerTODO = $this->_crmcustomerObj->GetCustomerToDoByID($CRMCustSysId, $todoId);
$AgencySysId = $this->intLoggedinUserAgencySysId;
// echo "<pre>"; print_r($_SESSION); die;
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'updateCustomerToDo';
$this->view->id = $todoId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->cid = $CRMCustSysId;
$this->view->data = $getCustomerTODO;
$this->view->leadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
$this->render('ajax-html');
}
}
public function customerToDoDescriptionAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$todoId = $this->getRequest()->getParam('tid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tid'))) : '';
if (isset($todoId) && !empty($todoId)) {
$getCustomerTODO = $this->_crmcustomerObj->GetCustomerToDoByID($CRMCustSysId, $todoId);
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'CustomerToDoDescription';
$this->view->id = $todoId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->cid = $CRMCustSysId;
$this->view->data = $getCustomerTODO;
$this->render('ajax-html');
}
}
public function updateTodoAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$post = $this->getRequest()->getPost();
// echo "<pre>";print_r($post);die;
$todosubject = $this->_request->getParam('todosubject') ? $this->_HtmlPurifier->filter($this->_request->getParam('todosubject')) : '';
$editId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('editId')));
$custsysID = $this->_HtmlPurifier->filter($this->getRequest()->getParam('custsysID_update'));
$title = $this->_HtmlPurifier->filter($this->getRequest()->getParam('subject'));
$todostartdate = $this->_HtmlPurifier->filter($this->getRequest()->getParam('todostartdate'));
$todoenddate = $this->_HtmlPurifier->filter($this->getRequest()->getParam('enddate'));
$todostartdatetime = $this->_request->getParam('todostartdatetime') ? $this->_request->getParam('todostartdatetime') : '';
$details = $this->_HtmlPurifier->filter($this->getRequest()->getParam('details'));
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$relatedto = $this->_request->getParam('RelatedTo') ? $this->_HtmlPurifier->filter($this->_request->getParam('RelatedTo')) : '';
$assignedto = $this->_request->getParam('assignedtoId') ? $this->_HtmlPurifier->filter($this->_request->getParam('assignedtoId')) : '';
$checked = $markasdone = $this->_request->getParam('markasdone') ? $this->_HtmlPurifier->filter($this->_request->getParam('markasdone')) : '';
$followupchecked = $this->_HtmlPurifier->filter($this->getRequest()->getParam('followupchecked'));
$todoreminder = $this->_HtmlPurifier->filter($this->getRequest()->getParam('todoreminder'));
$reminderinvalue = $this->_request->getParam('reminderinvalue') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderinvalue')) : '';
$reminderintype = $this->_request->getParam('reminderintype') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderintype')) : '';
$calltype = $this->_request->getParam('calltype') ? $this->_HtmlPurifier->filter($this->_request->getParam('calltype')) : 0;
$callstatus = $this->_request->getParam('callstatus') ? $this->_HtmlPurifier->filter($this->_request->getParam('callstatus')) : 0;
$nextstepcall = $this->_request->getParam('nextstepcall') ? $this->_HtmlPurifier->filter($this->_request->getParam('nextstepcall')) : '';
$LeadStage = $this->_request->getParam('LeadStage') ? $this->_HtmlPurifier->filter($this->_request->getParam('LeadStage')) : '';
$ActionId = $this->_request->getParam('ActionId') ? $this->_HtmlPurifier->filter($this->_request->getParam('ActionId')) : '';
$countrycode = $this->_request->getParam('countrycode') ? $this->_HtmlPurifier->filter($this->_request->getParam('countrycode')) : '+91';
$emailID = $this->_request->getParam('emailID') ? $this->_HtmlPurifier->filter($this->_request->getParam('emailID')) : '';
$mobile_number = $this->_request->getParam('mobilenum') ? $this->_HtmlPurifier->filter($this->_request->getParam('mobilenum')) : '';
$salution = $this->_request->getParam('salution') ? $this->_HtmlPurifier->filter($this->_request->getParam('salution')) : '';
$customername = $this->_request->getParam('customername') ? $this->_HtmlPurifier->filter($this->_request->getParam('customername')) : '';
$customerlastname = $this->_request->getParam('customerlastname') ? $this->_HtmlPurifier->filter($this->_request->getParam('customerlastname')) : '';
$leadsource = $this->_request->getParam('leadsource') ? $this->_HtmlPurifier->filter($this->_request->getParam('leadsource')) : '';
$reminderday = $this->_request->getParam('reminderday');
// query for insert data in db created by amit kumar dubey on 17 september 2016 at 02:48 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$agentID = $sessionLogin_user->intLoggedinUserId;
$explodetodostartdateAll = explode(' ', $todostartdate);
$explodetodostartdate = explode('/', $explodetodostartdateAll[0]);
$startdate = $explodetodostartdate[2] . '-' . $explodetodostartdate[1] . '-' . $explodetodostartdate[0];
$explodetodoenddateAll = explode(' ', $todoenddate);
$explodetodoenddate = explode('/', $explodetodoenddateAll[0]);
$enddate = $explodetodoenddate[2] . '-' . $explodetodoenddate[1] . '-' . $explodetodoenddate[0];
if ($reminderintype == 'hour') {
$todoreminder = $reminderinvalue * 60;
} else if ($reminderintype == 'day') {
$todoreminder = $reminderinvalue * 60 * 24;
} else {
$todoreminder = $reminderinvalue;
}
$date = date('Y-m-d H:i:s');
$curr_date = date('Y-m-d');
if ($editId) {
if ($todosubject === 'Call') {
if ($calltype == 0) {
$response = array('status' => 'failed', 'msg' => 'Please select outgoing or incomming');
echo json_encode($response);
exit;
}
if ($callstatus == 0) {
$response = array('status' => 'failed', 'msg' => 'Please select answered,unanswred or not reachable.');
echo json_encode($response);
exit;
}
}
if ((empty($nextstepcall)) && ($todosubject == 'Call')) {
$response = array('status' => 'failed', 'msg' => 'Please select callback,to do,meeting,lead or lost');
echo json_encode($response);
exit;
}
if ($nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
if (!isset($reminderday)) {
$response = array('status' => 'failed', 'msg' => 'Please select Today,Tomorrow ,In 2 days ,In 3 days or Custom date');
echo json_encode($response);
exit;
}
}
// if ($nextstepcall == 5) {
if (empty(addslashes(trim($details)))) {
$response = array('status' => 'failed', 'msg' => 'Please enter details');
echo json_encode($response);
exit;
}
// }
$todoArray = array('StartDateTime' => $date, 'EndDateTime' => $date, 'IsCompleted' => 1, 'Subject' => $todosubject, 'Description' => addslashes($details), 'CallType' => $calltype, 'CallStatus' => $callstatus);
$cond = ' ToDoSysId=' . $editId . '';
$customerRcord = $this->_crmcustomertodoObj->UpdateCustomerTodo($todoArray, $cond);
// next step action data
if ($nextstepcall == 1) {
$nexttodosubject = 'Call';
} else if ($nextstepcall == 2) {
$nexttodosubject = 'To Do';
} else {
$nexttodosubject = 'Meeting';
}
$reminderday = isset($reminderday) && ($reminderday != '') ? $reminderday : 0;
if ($reminderday != 4) {
$startdate = date('Y-m-d', strtotime($date . " +" . $reminderday . " days"));
}
$nextdata = array(
'Subject' => $nexttodosubject,
'StartDateTime' => trim($startdate . ' ' . $todostartdatetime),
'EndDateTime' => trim($startdate . ' ' . $todostartdatetime),
'RelatedTo' => $relatedto,
'IsCompleted' => isset($checked) && ($checked == 1) ? 1 : 0,
'Location' => 0,
'Type' => $type,
'Description' => '',
'CustSysId' => $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
'AgencySysId' => $AgencySysId,
'CreateDate' => $curr_date,
'UpdateDate' => $curr_date,
'CallType' => 0,
'CallStatus' => 0,
'ActionId' => $ActionId
);
if (isset($reminderday)) {
$now = new DateTime();
date_default_timezone_set('Asia/Kolkata'); // or your preferred timezone
$nowt = date("H:i");
if ($reminderday == 0) {
$todayTarget = new DateTime('today ' . $todostartdatetime);
$target = $todayTarget;
} else if ($reminderday == 1) {
$now = new DateTime('today ' . $nowt);
$target = new DateTime('tomorrow ' . $todostartdatetime);
} else if ($reminderday == 2 || $reminderday == 3) {
$now = new DateTime('today ' . $nowt);
$target = new DateTime($reminderday . 'days ' . $todostartdatetime);
} else if ($reminderday == 4) {
$targetDate = DateTime::createFromFormat('d/m/Y', $todostartdate);
$currentDate = new DateTime();
$interval = $currentDate->diff($targetDate);
$DaysCount = (int) $interval->format('%r%a') + 1;
$now = new DateTime('today ' . $nowt);
$target = new DateTime($DaysCount . 'days ' . $todostartdatetime);
}
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$salutationArr = unserialize(ARR_SALUTION);
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($custsysID);
$CustomerContact = isset($getCustomerDetail['Contacts']) && !empty($getCustomerDetail['Contacts']) ? $getCustomerDetail['Contacts'] : '';
$salutation = $salutationArr[$getCustomerDetail['Salutation']] ? $salutationArr[$getCustomerDetail['Salutation']] : 'Mr.';
$CustomerName = isset($getCustomerDetail['FirstName']) ? $salutation . ' ' . trim($getCustomerDetail['FirstName']) . ' ' . trim($getCustomerDetail['LastName']) : '';
$secondsDiff = $target->getTimestamp() - $now->getTimestamp();
$minutesDiff = isset($secondsDiff) && ($secondsDiff > 0) ? floor($secondsDiff / 60) : 1;
if (isset($minutesDiff) && !empty($minutesDiff)) {
$AgentSysId = $assignedto ? $assignedto : $agentID;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$AgentName = trim($agentDetails['FirstName']) . ' ' . trim($agentDetails['LastName']);
$payload = [
'recipient' => $CustomerContact,
'agent_name' => $AgentName,
'user_id' => $AgentSysId,
'title' => 'Follow-Up Reminder',
'text' => 'Don’t forget! You have a ' . $todosubject . ' scheduled at ' . $todostartdatetime . ' today with ' . $CustomerName . '. Kindly complete the follow-up and update in CRM.',
'label' => 'Click Here',
'url' => Catabatic_Helper::getSiteUrl() . 'dashboard/view-all-to-do/index',
'delay' => $minutesDiff,
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => Catabatic_Helper::getSiteUrl() . 'webservice/notification',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'SecurityKey:' . trim($agentDetails['SecurityKey']),
'Content-Type: application/json',
'Cookie: PHPSESSID=qb2ofl8h0g6hs66q3uhoenqasq'
),
));
$response = curl_exec($curl);
curl_close($curl);
}
}
if ($type == 1) {
if (!empty($nextstepcall) && $nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
$this->_crmcustomertodoObj->addAgencyCustomerTodo($nextdata);
} else if (!empty($nextstepcall) && $nextstepcall == 5) {
$response = $this->discardCallLogs($ActionId);
echo json_encode($response);
exit;
} else if (!empty($nextstepcall) && $nextstepcall == 4 && empty($custsysID)) {
if (empty($emailID)) {
$response = array('status' => 'failed', 'msg' => 'Please Enter email id');
echo json_encode($response);
exit;
}
if (empty($mobile_number)) {
$response = array('status' => 'failed', 'msg' => 'Please Enter mobile Number');
echo json_encode($response);
exit;
}
if (empty($customername)) {
$response = array('status' => 'failed', 'msg' => 'Please Enter First Name');
echo json_encode($response);
exit;
}
if (empty($customerlastname)) {
$response = array('status' => 'failed', 'msg' => 'Please Enter last Name');
echo json_encode($response);
exit;
}
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
$getDefaultCampaignByAgencyId = $this->_agencyObj->getDefaultCampaignByAgencyId($AgencySysId);
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $emailID,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobile_number,
'countrycode' => $countrycode,
'FullName' => $customername . ' ' . $customerlastname,
'FirstName' => trim($customername),
'LastName' => trim($customerlastname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $assignedto,
'ActiveDate' => $curr_date,
'UpdatedDate' => $curr_date,
'CreatedDate' => $curr_date,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => (int) $getDefaultCampaignByAgencyId
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
if ($AgencyCRMLeadSysId) {
$response = array('status' => 'success', 'msg' => 'Lead Created Successfully', 'type' => 'lead');
} else {
$response = array('status' => 'failed', 'msg' => 'Failed');
}
echo json_encode($response);
exit;
}
} else if ($type == 2) {
if (!empty($nextstepcall) && $nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
$this->_crmcustomertodoObj->addAgencyCustomerTodo($nextdata);
} else if (!empty($nextstepcall) && $nextstepcall == 4 && !empty($custsysID)) {
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($custsysID)), 1);
$redirect_Link = '/customer/customer-profile-desc/id/' . base64_encode($custsysID) . '/code/' . $secureCode;
$response = array('status' => 'success', 'msg' => 'Success', 'statge' => '50', 'link' => $redirect_Link);
echo json_encode($response);
exit;
} else if (!empty($nextstepcall) && $nextstepcall == 5) {
if (empty($LeadStage)) {
$response = array('status' => 'failed', 'msg' => 'Please Select Lead Stage');
echo json_encode($response);
exit;
}
$where = "AgencyCRMLeadSysId = " . $ActionId;
$date = date('Y-m-d H:i:s');
$IsMarkForDelete = 0;
$IsApproved = 0;
if ($LeadStage == 47) {
$IsMarkForDelete = 1;
}
$userArray = array(
'LeadStageSysId' => $LeadStage,
'IsMarkForDelete' => $IsMarkForDelete,
'IsApproved' => $IsApproved,
'AssignUserSysId' => $assignedto ? $assignedto : $agentID,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$response = array('status' => 'success', 'msg' => 'Success');
echo json_encode($response);
exit;
}
} else if ($type == 3) {
if (!empty($nextstepcall) && $nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
$nextdata['TPSysId'] = $ActionId;
$nextdata['TPIntSysId'] = $ActionId;
$this->_crmcustomertodoObj->addAgencyCustomerTodo($nextdata);
} else if (!empty($nextstepcall) && $nextstepcall == 4) {
$TotalProposal = $this->_request->getParam('totalproposal');
if (!empty($TotalProposal) && $TotalProposal > 0) {
$LeadsecureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($ActionId)), 1);
$redirectLink = "/leaddetail/proposal/id/" . base64_encode($ActionId) . "/cid/" . base64_encode($custsysID) . "/code/" . $LeadsecureCode;
$response = array('status' => 'success', 'msg' => 'Success', 'nextsteptype' => 4, 'redirectLink' => $redirectLink);
echo json_encode($response);
exit;
} else {
$LeadsecureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($ActionId)), 1);
$redirectLink = "/leaddetail/lead-detail/id/" . base64_encode($ActionId) . "/cid/" . base64_encode($custsysID) . "/code/" . $LeadsecureCode;
$response = array('status' => 'success', 'msg' => 'Success', 'nextsteptype' => 5, 'redirectLink' => $redirectLink);
echo json_encode($response);
exit;
}
} else if (!empty($nextstepcall) && $nextstepcall == 5) {
$QueryStage = $this->_request->getParam('QueryStage');
if (empty($QueryStage)) {
$response = array('status' => 'failed', 'msg' => 'Please Select Query Stage');
echo json_encode($response);
exit;
}
$where = "TPSysId = " . $ActionId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'StatusType' => $QueryStage,
'UpdateDate' => $date,
);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArray, $where);
$response = array('status' => 'success', 'msg' => 'Success');
echo json_encode($response);
exit;
}
}
$result = array("status" => "success", 'msg' => 'Upated Successfully', 'id' => $editId);
} else {
$result = array("status" => "failed", 'msg' => 'Failed');
}
echo json_encode($result);
}
}
public function discardCallLogs($callLogId) {
$data = array("is_mark_for_delete" => 1);
$url = "https://logs.hellogtx.com/api/v1/call-center/$callLogId/";
$data_stringh = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Accept-Encoding: gzip',
'Content-Length: ' . strlen($data_stringh)
));
$output = curl_exec($ch);
$data = json_decode($output, 1);
if ($data['is_mark_for_delete'] == true) {
$output = array('status' => 'success', 'msg' => 'Discard Successfully.');
}
return $output;
}
public function getExistingFollowupsAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$lid = $this->getRequest()->getParam('lid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('lid')) : '';
$AssignedUserId = $this->getRequest()->getParam('AssignedUserId') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('AssignedUserId')) : '';
$owner = $this->getRequest()->getParam('owner') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('owner')) : '';
$followup = $this->getRequest()->getParam('followup') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('followup')) : '';
$type = $this->getRequest()->getParam('type') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('type')) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$FollowupsArray = array();
if ($lid) {
$ToDoCount = $this->_crmcusttravelplan->getToDoCountBYActionId($lid, $AgencySysId, $type, 'To Do'); // To Do
$CallCount = $this->_crmcusttravelplan->getToDoCountBYActionId($lid, $AgencySysId, $type, 'Call'); // Call
$MeetingCount = $this->_crmcusttravelplan->getToDoCountBYActionId($lid, $AgencySysId, $type, 'Meeting'); // Meeting
$FollowupsArray = $this->_crmcusttravelplan->GetLeadFollowupsById($lid, $AgencySysId, $type);
$this->view->ToDoCount = $ToDoCount;
$this->view->CallCount = $CallCount;
$this->view->MeetingCount = $MeetingCount;
}
$this->view->id = $lid;
$this->view->AssignedUserId = $AssignedUserId;
$this->view->owner = $owner;
$this->view->followup = $followup;
$this->view->type = 'getExistingFollowup';
$this->view->FollowupsArray = $FollowupsArray;
$this->render('ajax-html');
}
public function getAgencyUserListAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
try {
$arrResponse = array();
if (trim($this->getRequest()->getParam("query")) != '') {
$term = $this->_HtmlPurifier->filter(trim($this->getRequest()->getParam("query")));
$AgencySysId = $this->intLoggedinUserAgencySysId;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($sessionLogin_user->UserRoleTitle == 'Owner') {
$arrResponse = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
} else {
$arrResponse = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId, $ReportingToSysId);
}
// $arrResponse = $this->_crmcustomerObj->getAllAgencyUserList($term, $AgencySysId,$ReportingToSysId);
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function updateAllTodoAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$Ids = $this->_HtmlPurifier->filter($this->getRequest()->getParam('ids'));
// query for Update data in todo db created by amit kumar dubey on 02 november 2016 at 01:23 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$date = date('Y-m-d H:i:s');
$Ids = explode(",", $Ids);
if (!empty($Ids)) {
foreach ($Ids as $key => $values) {
$todoArray = array(
'IsCompleted' => 1,
);
$cond = ' ToDoSysId=' . $values . '';
$customerRcord = $this->_crmcustomertodoObj->UpdateCustomerTodo($todoArray, $cond);
}
$result = array("status" => "success", 'id' => $values);
} else {
$result = array("status" => "failed");
}
//return $customerRcord;
echo json_encode($result);
}
}
public function savepackageleadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$param = $getData = $this->getRequest()->getPost();
$PKqueryType = (isset($getData['PKqueryType']) && !empty($getData['PKqueryType'])) ? (int) $getData['PKqueryType'] : 0; // Md sabir
$TPSysId = isset($getData['TPSysId']) ? $getData['TPSysId'] : 0;
$tpintsysID = $getData['itenaryID'];
$nooftraveler = $getData['travelers'];
$search_going_to = $getData['search_going_to'];
$noofdaysfrom = $getData['noofdaysfrom'];
$noofdaysto = $getData['noofdaysto'];
$LeadSysId = (int) $getData['LeadSysId'];
$leadRemark = $getData['leadRemark'];
$get_cityname = rtrim($getData['multicities'], ',');
$getcityvalue = $getData['search_going_to_id'];
$currentOwnerSysId = $getData['currentOwnerSysId'];
$hotelpreference = isset($getData['hotelpreference']) ? $getData['hotelpreference'] : '';
$additionalRequirement = $getData['additionalRequirement'] ? $getData['additionalRequirement'] : '';
$countrySysId = isset($getData['ContSysId']) ? $getData['ContSysId'] : '';
$IsOperationalLead = isset($getData['IsOperationalLead']) ? $getData['IsOperationalLead'] : 0;
$OpsAgentSysId = (isset($getData['OpsAgentSysId']) && $IsOperationalLead == 1) ? $getData['OpsAgentSysId'] : '';
$foodpreference = isset($getData['search_food']) ? $getData['search_food'] : '';
if (isset($hotelpreference) && !empty($hotelpreference)) {
$hotelpreference = implode(",", $hotelpreference);
} else {
$hotelpreference = '';
}
$TotAdultCount = $TotChildCount = $TotInfantCount = 0;
$childWithBed = $param['childWithBed'];
$childWithBedCalculate = $param['childWithBed'];
$childWithOutBed = $param['childWithOutBed'];
$childWithOutBedCalculate = $param['childWithOutBed'];
$infant1 = $TotInfantCount = (int) $param['infant1'];
$infant1Calculate = (int) $param['infant1'];
$adultTwinSharing = $param['adultTwinSharing'];
$adultTripleSharing = $param['adultTripleSharing'];
$adultSingleSharing = $param['adultSingleSharing'];
$adultQuadSharing = $param['adultQuadSharing'];
$adultQuintSharing = $param['adultQuintSharing'];
$adultHexaSharing = $param['adultHexaSharing'];
$adultTwinSharing1 = floor($adultTwinSharing / 2);
$adultTwinSharing2 = $adultTwinSharing % 2;
$adultTripleSharing1 = floor($adultTripleSharing / 3);
$adultTripleSharing2 = $adultTripleSharing % 3;
$adultQuadSharing1 = floor($adultQuadSharing / 4);
$adultQuadSharing2 = $adultQuadSharing % 4;
$adultQuintSharing1 = floor($adultQuintSharing / 5);
$adultQuintSharing2 = $adultQuintSharing % 5;
$adultHexaSharing1 = floor($adultHexaSharing / 6);
$adultHexaSharing2 = $adultHexaSharing % 6;
for ($m = 1; $m <= $adultTwinSharing1; $m++) {
$param['adult'][] = 2;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'twin';
}
if ($adultTwinSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'twin';
}
for ($m = 1; $m <= $adultTripleSharing1; $m++) {
$param['adult'][] = 3;
$param['adult_bed_type'][] = 'extrabed';
$param['adult_type'][] = 'triple';
}
if ($adultTripleSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'triple';
} else if ($adultTripleSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'triple';
}
for ($m = 1; $m <= $adultSingleSharing; $m++) {
$param['adult'][] = 1;
$param['adult_bed_type'][] = '';
$param['adult_type'][] = 'single';
}
for ($m = 1; $m <= $adultQuadSharing1; $m++) {
$param['adult'][] = 4;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
}
if ($adultQuadSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
} else if ($adultQuadSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
} else if ($adultQuadSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'quad';
$param['adult_bed_type'][] = '';
}
for ($m = 1; $m <= $adultQuintSharing1; $m++) {
$param['adult'][] = 5;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
}
if ($adultQuintSharing2 == 4) {
$param['adult'][] = 4;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
} else if ($adultQuintSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'quint';
$param['adult_bed_type'][] = '';
}
for ($m = 1; $m <= $adultHexaSharing1; $m++) {
$param['adult'][] = 6;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
}
if ($adultHexaSharing2 == 5) {
$param['adult'][] = 5;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 4) {
$param['adult'][] = 4;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 3) {
$param['adult'][] = 3;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 2) {
$param['adult'][] = 2;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
} else if ($adultHexaSharing2 == 1) {
$param['adult'][] = 1;
$param['adult_type'][] = 'hexa';
$param['adult_bed_type'][] = '';
}
$mn = $mncw = $mncwo = 0;
foreach ($param['adult'] as $adkey => $advalue) {
$adult_type = (isset($param['adult_type'][$adkey])) ? trim($param['adult_type'][$adkey]) : '';
if ($advalue == 3 && $adult_type != 'quad' && $adult_type != 'quint' && $adult_type != 'hexa') {
if ($childWithOutBedCalculate > 0) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
$mncwo++;
} else if ($childWithBedCalculate > 0) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$childWithBedCalculate = $childWithBedCalculate - 1;
$mncw++;
} else if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mn++;
}
if (($advalue != 3 || $adult_type == 'quad' || $adult_type == 'quint' || $adult_type == 'hexa') && $mn < ($childWithOutBed + $childWithBed + $infant1)) {
if ($childWithOutBedCalculate > 0 || $childWithBedCalculate > 0 || $infant1Calculate > 0) {
if ($childWithOutBedCalculate > 0 && $childWithBedCalculate > 0) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$mncw++;
$mn++;
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
$childWithBedCalculate = $childWithBedCalculate - 1;
} else if ($childWithOutBedCalculate > 0 && $childWithBedCalculate < 1) {
if ($childWithOutBedCalculate == 1) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$childWithOutBedCalculate = $childWithOutBedCalculate - 1;
if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mncwo++;
$mn++;
}
if ($childWithOutBedCalculate > 1) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_bed_type'][$mn][] = 'withoutbed';
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$param['child_age'][$mn][] = isset($param['childAgeWithOutBed'][$mncwo]) ? (int) $param['childAgeWithOutBed'][$mncwo] : '';
$mncwo++;
$mn++;
$childWithOutBedCalculate = $childWithOutBedCalculate - 2;
}
} else if ($childWithBedCalculate > 0 && $childWithOutBedCalculate < 1) {
if ($childWithBedCalculate == 1) {
$param['child'][$mn] = 1;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$childWithBedCalculate = $childWithBedCalculate - 1;
if ($infant1Calculate > 0) {
$param['infant'][$mn] = 1;
$infant1Calculate = $infant1Calculate - 1;
}
$mncw++;
$mn++;
}
if ($childWithBedCalculate > 1) {
$param['child'][$mn] = 2;
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_bed_type'][$mn][] = 'extrabed';
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$mncw++;
$param['child_age'][$mn][] = isset($param['childAgeWithBed'][$mncw]) ? (int) $param['childAgeWithBed'][$mncw] : '';
$mncw++;
$mn++;
$childWithBedCalculate = $childWithBedCalculate - 2;
}
} else if ($childWithBedCalculate == 0 && $childWithOutBedCalculate == 0 && $infant1Calculate > 0) {
if ($infant1Calculate == 1) {
$param['infant'][$mn] = 1;
$mn++;
$infant1Calculate = $infant1Calculate - 1;
}
if ($infant1Calculate > 1) {
$param['infant'][$mn] = 2;
$mn++;
$infant1Calculate = $infant1Calculate - 2;
}
}
}
}
}
if ($adultTripleSharing2 == 2) {
$adultTripleSharing2 = 1;
}
if ($adultQuadSharing2 == 3 || $adultQuadSharing2 == 2 || $adultQuadSharing2 == 1) {
$adultQuadSharing2 = 1;
}
if ($adultQuintSharing2 == 4 || $adultQuintSharing2 == 3 || $adultQuintSharing2 == 2 || $adultQuintSharing2 == 1) {
$adultQuintSharing2 = 1;
}
if ($adultHexaSharing2 == 5 || $adultHexaSharing2 == 4 || $adultHexaSharing2 == 3 || $adultHexaSharing2 == 2 || $adultHexaSharing2 == 1) {
$adultHexaSharing2 = 1;
}
$countRooms = $adultTwinSharing1 + $adultTwinSharing2 + $adultTripleSharing1 + $adultTripleSharing2 + $adultSingleSharing + $adultQuadSharing1 + $adultQuadSharing2 + $adultQuintSharing1 + $adultQuintSharing2 + $adultHexaSharing1 + $adultHexaSharing2;
$childSharing = $childWithBed + $childWithOutBed;
$roomCountMatchChild = (($adultTwinSharing1 * 2) + ($adultTripleSharing1 * 1) + ($adultSingleSharing * 2) + ($adultQuadSharing1 * 2) + ($adultQuadSharing2 * 2) + ($adultQuintSharing1 * 2) + ($adultQuintSharing2 * 2) + ($adultHexaSharing1 * 2) + ($adultHexaSharing2 * 2));
if ($roomCountMatchChild < ($childSharing)) {
$response = ['success' => false, 'msg' => 'Child count must be less than ' . $childSharing . '. Otherwise take extra Adult on twin/triple/single/quad sharing to accommodate the ' . $childSharing . ' child. '];
echo json_encode($response);
exit;
}
$roomjson = array();
for ($i = 0, $k = 1; $k <= $countRooms; $k++, $i++) {
$totalAdultChild = (int) $param['adult'][$i] + (int) $param['child'][$i];
$roomjson[$k]['Adult'] = $param['adult'][$i];
$roomjson[$k]['adult_type'] = $param['adult_type'][$i];
$roomjson[$k]['Child'] = (int) $param['child'][$i];
$roomjson[$k]['Infant'] = (int) $param['infant'][$i];
$TotAdultCount = $TotAdultCount + $param['adult'][$i];
$TotChildCount = $TotChildCount + $param['child'][$i];
$noOfAdultsar[$k] = $param['adult'][$i];
if ($param['adult'][$i] == 3) {
$roomjson[$k]['AdultBedType'] = $param['adult_bed_type'][$i];
}
if ($param['child'][$i] > 0) {
for ($c = 1; $c <= (int) $param['child'][$i]; $c++) {
$roomjson[$k]['ChildBedType_' . $c] = $param['child_bed_type'][$i][$c - 1];
$roomjson[$k]['ChildAge_' . $c] = $param['child_age'][$i][$c - 1];
$selectnoOfChildar[$k] = $param['child'][$i];
}
}
$roomjson[$k]['departuredate'] = $getData['search_specific_date'];
$roomjson[$k]['returndate'] = '';
}
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityid = $search_going_to_dest[0];
$going_to_cityname = $search_going_to_dest[1];
}
$going_to_cityname = trim($getData['search_going_to_city']);
$search_going_f = $getData['search_going_f'];
$search_going_from = $getData['search_going_from'];
if (!empty($search_going_from)) {
$search_going_to_from = explode('__', $search_going_from);
$going_from_cityid = $search_going_to_from[0];
$going_from_cityname = $search_going_to_from[1];
}
$customerID = $getData['customerID'] ? $getData['customerID'] : '';
if (empty($getData['search_going_to'])) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
$search_theme_list = $search_food_list = $search_inclusion_list = $packageFoodPreferenceList = $packageThemeList = array();
if (!empty($getData['search_theme'])) {
$packageThemeList = $this->_objPkg->getPackageThemeList();
$search_theme = $getData['search_theme'];
for ($i = 0; $i < count($search_theme); $i++) {
$search_theme_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_theme[$i], $packageThemeList, 'PackType');
}
}
if (!empty($getData['search_food'])) {
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$search_food = $getData['search_food'];
for ($i = 0; $i < count($search_food); $i++) {
$search_food_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_food[$i], $packageFoodPreferenceList, 'CuisineSysId');
}
}
if (!empty($getData['search_inclusions'])) {
$packageInclList = $this->_objPkg->getPackageInclusionList();
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($getData['search_inclusions'])) {
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($search_theme_list)) {
$thememask = '1';
$char = '';
for ($k = 0; $k < count($packageThemeList); $k++) {
$char = in_array($packageThemeList[$k]['PackType'], $search_theme_list) ? '1' : '0';
$thememask .= $char;
}
}
if (!empty($search_food_list)) {
$foodmask = '1';
$char = '';
for ($k = 0; $k < count($packageFoodPreferenceList); $k++) {
$char = in_array($packageFoodPreferenceList[$k]['CuisineSysId'], $search_food_list) ? '1' : '0';
$foodmask .= $char;
}
}
$char = '';
if (!empty($search_inclusion_list)) {
$inclmask = '1';
for ($k = 0; $k < count($packageInclList); $k++) {
$char = in_array($packageInclList[$k]['InclId'], $search_inclusion_list) ? '1' : '0';
$inclmask .= $char;
}
}
if (isset($getData['search_theme'])) {
$PackTypeMask = $getData['search_theme'] ? $thememask : '';
} else {
$PackTypeMask = '';
}
if (isset($getData['search_food'])) {
$FoodTypeMask = $getData['search_food'] ? $foodmask : '';
} else {
$FoodTypeMask = '';
}
if (isset($getData['search_inclusions'])) {
$InclMask = $getData['search_inclusions'] ? $inclmask : '';
} else {
$InclMask = '';
}
//echo "<pre>";print_r($InclMask);DIE;
$PriceRange = isset($getData['PriceRange']) ? substr(trim($getData['PriceRange']), 0, 95) : '';
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', $getData['search_price_range']);
$min_price = $getData['search_price_range'] ? $search_price_range[0] : '';
$max_price = $getData['search_price_range'] ? $search_price_range[1] : '';
} else {
$min_price = 0;
$max_price = 0;
}
$planbookingID = 'Q/' . date('y');
$createDate = date('Y-m-d H:i:s');
if (!empty($getData['search_specific_date'])) {
$search_specific_date = explode('/', $getData['search_specific_date']);
$plan_start_date = $search_specific_date[2] . '-' . $search_specific_date[1] . '-' . $search_specific_date[0];
} else {
$plan_start_date = '1900-01-01';
}
$status = 1;
$sessionPackageQueryData = new Zend_Session_Namespace('sessionPackageQueryData');
if (!empty($sessionPackageQueryData->searchData)) {
$packageSearchResult = $getData;
$this->view->packageSearchResult = $packageSearchResult;
} else {
//$this->_redirect('/packagesearch');
}
$roominfojson = json_encode($roomjson);
$agentsysID = $this->intLoggedinUserId;
if ($customerID > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($customerID);
}
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$getLeadDetailById = array();
if ($LeadSysId == 0) {
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
$getDefaultCampaignByAgencyId = $this->_agencyObj->getDefaultCampaignByAgencyId($agencySysID);
$userLeadArray = array(
'AgencySysId' => $agencySysID,
'EmailId' => $customerDetails['EmailId'],
'Salutation' => 1,
'PrimaryContactNumber' => $customerDetails['Contacts'],
'FullName' => trim($customerDetails['FirstName']) . ' ' . trim($customerDetails['LastName']),
'FirstName' => trim($customerDetails['FirstName']),
'LastName' => trim($customerDetails['LastName']),
'LeadSourceSysId' => (int) $getData['lead_source'],
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'Destination' => isset($going_to_cityname) ? $going_to_cityname : '',
'ToDestinationSysId' => isset($going_to_cityid) ? (int) $going_to_cityid : '',
'Remarks' => '',
'ActiveDate' => $createDate,
'UpdatedDate' => $createDate,
'CreatedDate' => $createDate,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => $getDefaultCampaignByAgencyId
);
$LeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
} else if ($LeadSysId > 0) {
$getLeadDetailById = $this->_crmagencyleadaccountObj->getAgentIdFromLeadId($LeadSysId);
}
$sessionPackageSearchData = new Zend_Session_Namespace('sessionPackageSearchData');
$sessionPackageSearchData->searchData = $getData;
$sessionPackageSearchData->searchData['RoomMemInfoJson'] = json_encode($roomjson);
$sessionPackageSearchData->searchData['customerID'] = $customerID;
$sessionPackageSearchData->searchData['is_source'] = 'CRM';
$sessionPackageSearchData->searchData['customerId'] = $customerID;
$sessionPackageSearchData->searchData['FirstName'] = $customerDetails['FirstName'];
$sessionPackageSearchData->searchData['EmailId'] = $customerDetails['EmailId'];
$sessionPackageSearchData->searchData['PrimaryContactNumber'] = $customerDetails['Contacts'];
$sessionPackageSearchData->searchData['customerDetails'] = $customerDetails;
//#end of record
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
$ExpectedClosureDate = (isset($getData['ExpectedClosureDate']) && !empty($getData['ExpectedClosureDate'])) ? implode('-', array_reverse(explode('/', $getData['ExpectedClosureDate']))) : '';
$ExpectedValue = (isset($getData['ExpectedValue']) && !empty($getData['ExpectedValue'])) ? (float) trim($getData['ExpectedValue']) : 0;
$data = array(
'PlanBookingId' => $planbookingID,
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'CreatorSysId' => $this->intLoggedinUserId,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'CuisineMask' => $FoodTypeMask,
'InclMask' => $InclMask,
'AdditionalReq' => $additionalRequirement,
'DestinationPlaces' => isset($going_to_cityname) ? $going_to_cityname : '',
'DestinationPlacesSysId' => isset($going_to_cityid) ? (int) $going_to_cityid : 0,
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : '',
'Cities' => $citiesText . $going_to_cityname,
'CityIds' => $getcityvalue,
'PlanType' => 5,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'PriceRange' => $PriceRange,
'DaysCountFrom' => $noofdaysfrom,
'DaysCountTo' => $noofdaysto,
'MinPax' => $nooftraveler,
'RoomInfoJson' => $roominfojson,
'HotelPreference' => $hotelpreference,
'StartDate' => $plan_start_date,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 1,
'IsB2Bproposal' => (isset($getLeadDetailById['B2BType']) && $getLeadDetailById['B2BType'] == 3) ? (int) $getLeadDetailById['B2BType'] : trim($IsB2BCustomer),
'B2BAgencySysId' => (isset($getLeadDetailById['B2BAgencySysId']) && $getLeadDetailById['B2BAgencySysId'] > 0) ? (int) $getLeadDetailById['B2BAgencySysId'] : 0,
'PKqueryType' => $PKqueryType,
'LeadSourceSysId' => $getData['lead_source'],
'LeadSysId' => (int) $LeadSysId,
'Countries' => $countrySysId,
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
'ExpectedClosureDate' => $ExpectedClosureDate,
'ExpectedValue' => $ExpectedValue,
);
if (empty($TPSysId)) {
$where = "AgencyCRMLeadSysId = " . $LeadSysId;
if ($getLeadDetailById['AssignUserSysId'] == 0) {
$userArray = array(
'IsApproved' => '1',
'UpdatedDate' => date('Y-m-d'),
'LeadStageSysId' => 50,
'AssignUserSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
);
} else {
$userArray = array(
'IsApproved' => '1',
'UpdatedDate' => date('Y-m-d'),
'LeadStageSysId' => 50,
);
}
$this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $lastID,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
Zend_Session::namespaceUnset('customerlead');
if ($IsB2BCustomer == 1) {
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B(trim($customerDetails['EmailId']), $agencySysID);
} else {
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerDetails['EmailId']), $agencySysID);
}
// echo "<pre>";print_r($getcustomerDetail);die;
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $lastID;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['Contacts'];
if (!empty($getcustomerDetail)) {
$agencyuserArray = array(
'UpdateDate' => $createDate
);
$whereAgencyCustomer = " AgencySysId=" . $agencySysID . " AND CustomerSysId=" . $customerID . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
if ($lastID) {
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$checkrecord = $custtravelhistoryObj->getCustomerTravelHistoryForCity($customerID, $agencySysID, $going_to_cityid);
if (empty($checkrecord)) {
$customerHistoryArray = array(
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'CustomerSysId' => $customerID,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => $plan_start_date,
'ContSysId' => $countrySysId ? (int) $countrySysId : 0,
'CitySysId' => isset($going_to_cityid) ? (int) $going_to_cityid : 0,
'PlanType' => '5',
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => '0'
);
//exitprint_r($customerHistoryArray);die;
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
}
//$ClosureData = $this->_crmcusttravelplan->expectedClosureData($lastID, $getData);
$sessionPackageSearchData->searchData['TPSysId'] = $lastID;
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($lastID), 1);
$response = array('success' => true, 'msg' => 'Query Has been Created For Customer .', 'lastID' => $lastID, 'lastencodeID' => base64_encode($lastID), 'code' => $secureCode);
/* Automation Emailer Master Template By Mangal 26-09-2018 Start */
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$getSenderEmailID = $this->_agencyObj->getSenderEmailIDBySenderSysId($agencySysID, $SenderEmailSysId);
$EmailIdForCustomer = (isset($_SESSION['sessionLogin_user']['agencyDetails']['EmailIdForCustomer'])) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['EmailIdForCustomer']) : '';
//echo "<pre>";print_r();die;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$Salutation = (isset($getcustomerDetail['Salutation']) && !empty($getcustomerDetail['Salutation'])) ? $ARR_SALUTION[trim($getcustomerDetail['Salutation'])] : '';
$mCustomerFirstName = trim($getcustomerDetail['FirstName']);
$mCustomerLastName = trim($getcustomerDetail['LastName']);
$mCustomerEmailId = trim($getcustomerDetail['EmailId']);
$companyLogo = trim($_SESSION['sessionLogin_user']['Logo']);
$agencyTitle = trim($_SESSION['sessionLogin_user']['agencyDetails']['DisplayName']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['DisplayName']) : trim($_SESSION['sessionLogin_user']['agencyDetails']['Title']);
$agencySenderEmailID = (isset($getSenderEmailID['SenderEmailID']) && !empty($getSenderEmailID['SenderEmailID'])) ? $getSenderEmailID['SenderEmailID'] : trim($_SESSION['AgencyUser']['user']->EmailId);
$agencyPrimaryEmail = (trim($_SESSION['AgencyUser']['user']->EmailId));
$agencyContactNo1 = trim($_SESSION['AgencyUser']['user']->ContactNo1);
$agencyContactNo2 = trim($_SESSION['sessionLogin_user']['contactnum']);
//$PrimaryContactName = trim($_SESSION['sessionLogin_user']['FirstName']) . ' ' . trim($_SESSION['sessionLogin_user']['LastName']);
$PrimaryContactName = trim($_SESSION['AgencyUser']['user']->FirstName) . ' ' . trim($_SESSION['AgencyUser']['user']->LastName);
$agencyUrl = trim($_SESSION['sessionLogin_user']['agencyDetails']['Url']);
$travelDate = trim($getData['search_specific_date']);
$CountryCode = isset($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) . '-' : '+91-';
$params = array('CountryCode' => $CountryCode, 'Salutation' => $Salutation, 'customerName' => ucfirst($mCustomerFirstName . ' ' . $mCustomerLastName), 'emailId' => $mCustomerEmailId, 'logo' => $companyLogo, 'agencyTitle' => $agencyTitle, 'destination' => $going_to_cityname, 'noofPax' => $nooftraveler, 'travelDate' => $travelDate, 'agencyPrimaryEmail' => $agencyPrimaryEmail, 'PrimaryContactName' => $PrimaryContactName, 'agencyContactNo1' => $agencyContactNo1, 'agencyContactNo2' => $agencyContactNo2, 'Url' => $agencyUrl, 'queryID' => $lastID, 'PKqueryType' => 'Package', 'agencySysID' => $agencySysID, 'noofdays' => $noofdaysfrom);
#Set subject
if ($IsB2BCustomer == 1) {
$NameAgencyCust = $getcustomerDetail['CompanyName'];
} else {
$NameAgencyCust = isset($_SESSION['sessionLogin_user']['agencyDetails']['DisplayName']) ? $_SESSION['sessionLogin_user']['agencyDetails']['DisplayName'] : $_SESSION['sessionLogin_user']['agencyDetails']['Title'];
}
if ($agencySysID == '4995') {
$subject = 'Thank You. Your ' . trim($going_to_cityname) . ' enquiry has been received by ' . trim($NameAgencyCust);
} else {
$subject = trim($lastID) . ' - ' . trim($NameAgencyCust) . ' / Pax: ' . $nooftraveler . ' / ' . implode('-', explode('/', $travelDate)) . ' / ' . trim($going_to_cityname) . ' / ' . trim($PrimaryContactName);
}
if (in_array('queryacknowledgement', $this->manageNotifications)) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('masterTemplateMailinfo.phtml');
$emailMasterData = array('fromEmail' => trim($agencySenderEmailID), 'fromName' => trim($agencyTitle), 'subject' => $subject, 'to' => array($mCustomerEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $agencySysID,
"AgentSysId" => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$checkStatusEmail = $this->mailSentByElastice($emailMasterData, $arrEmailStatistics);
}
//$currentOwnerSysId = (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID;
if (!empty($currentOwnerSysId) && in_array('queryacknowledgement', $this->manageNotifications)) {
$agentDetails = $this->_crmcustomerObj->getAgentDetailById($currentOwnerSysId);
$mAgentEmailId = $agentDetails[0]['EmailId'];
$agentAssineDetails[0]['FirstName'] = trim($_SESSION['AgencyUser']['user']->FirstName);
$agentAssineDetails[0]['LastName'] = trim($_SESSION['AgencyUser']['user']->LastName);
$AgencyCRMLeadSysIdArr[] = $lastID;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'gtxCustomerAgentQueryEmailNotification');
$html->assign('agentDetails', $agentDetails);
$html->assign('agencyDetails', $_SESSION['sessionLogin_user']['agencyDetails']);
$html->assign('agentAssineDetails', $agentAssineDetails);
$html->assign('agencyCustomerDetails', $getcustomerDetail);
$html->assign('CustomerSysId', base64_encode(trim($getcustomerDetail['CustomerSysId'])));
$html->assign('AgencyCRMLeadSysIdArr', $AgencyCRMLeadSysIdArr);
$bodyTextAssign = $html->render('email-template.phtml');
$subject = 'New Query Assigned';
$emailMasterDataAssign = array('fromEmail' => trim($agencySenderEmailID), 'fromName' => trim($agencyTitle), 'subject' => $subject, 'to' => array($mAgentEmailId), 'bodyHtml' => $bodyTextAssign, 'bodyText' => '');
$checkStatusEmail = $this->mailSentByElastice($emailMasterDataAssign, $arrEmailStatistics);
}
echo json_encode($response);
exit;
}
} else if ($TPSysId > 0) {
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $agencySysID,
'CustomerSysId' => $customerID,
'AgentSysId' => $agentsysID,
'Remarks' => $leadRemark,
'TPSysId' => $TPSysId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
$getlatestversion = $this->_crmcusttravelplan->CheckCustomerWithLeadId($TPSysId, 'Query');
$agentsysID = $this->intLoggedinUserId;
$versionnum = $getlatestversion[0]['VersionId'];
$updateddata = array(
'PlanBookingId' => $planbookingID,
'VersionId' => $versionnum + 1,
//'MasterTPSysId' => $TPSysId,
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'CreatorSysId' => $this->intLoggedinUserId,
'StatusType' => $status,
'CustomerSysId' => $customerID,
'PackTypeMask' => $PackTypeMask,
'CuisineMask' => $FoodTypeMask,
'AdditionalReq' => $additionalRequirement,
'InclMask' => $InclMask,
'DestinationPlaces' => $DestinationPlacesSysId,
'DestinationPlacesSysId' => isset($DestinationPlaces) ? (int) $DestinationPlaces : 0,
'PlanType' => 5,
'MinPrice' => $min_price,
'MaxPrice' => $max_price,
'DaysCountFrom' => $noofdaysfrom,
'DaysCountTo' => $noofdaysto,
'MinPax' => $nooftraveler,
'RoomInfoJson' => $roominfojson,
'HotelPreference' => $hotelpreference,
'StartDate' => $plan_start_date,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'Readymade' => 1,
'PKqueryType' => $PKqueryType,
'LeadSourceSysId' => $getData['lead_source'],
'OpsAgentSysId' => $OpsAgentSysId,
'IsOperationalLead' => $IsOperationalLead,
);
$whereQ = "TPSysId = " . $TPSysId;
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updateddata, $whereQ);
//$lastupdaedID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($updateddata);
Zend_Session::namespaceUnset('customerlead');
$getcustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($customerID);
$sessionLogin_lead_customer = new Zend_Session_Namespace('customerlead');
$sessionLogin_lead_customer->customerID = $customerID;
$sessionLogin_lead_customer->leadID = $TPSysId;
$sessionLogin_lead_customer->FirstName = $getcustomerDetail['FirstName'];
$sessionLogin_lead_customer->EmailId = $getcustomerDetail['EmailId'];
$sessionLogin_lead_customer->PrimaryContactNumber = $getcustomerDetail['PrimaryContactNumber'];
if (!empty($getcustomerDetail)) {
$agencyuserArray = array(
'UpdateDate' => $createDate
);
$whereAgencyCustomer = " AgencySysId=" . $agencySysID . " AND CustomerSysId=" . $customerID . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$sessionPackageSearchData->searchData['TPSysId'] = $TPSysId;
if ($TPSysId) {
$travelitenary = array(
'TPSysId' => $TPSysId,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'CreateDate' => $createDate,
);
$sessionPackageSearchData->searchData['TPSysId'] = $TPSysId;
}
$customerHistoryArray = array(
'AgencySysId' => $agencySysID,
'AgentSysId' => (isset($currentOwnerSysId) && !empty($currentOwnerSysId)) ? trim($currentOwnerSysId) : $agentsysID,
'CustomerSysId' => $customerID,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => $plan_start_date,
'ContSysId' => $countrySysId ? $countrySysId : '',
'CitySysId' => isset($going_to_cityid) ? $going_to_cityid : '',
'PlanType' => 5,
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsMarkForDelete' => '0'
);
//print_r($customerHistoryArray);die;
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
$secureCode = Catabatic_ValidateCustomer::secureCode($TPSysId, 1);
$response = array('success' => true, 'msg' => 'Query Created.', 'code' => $secureCode);
echo json_encode($response);
exit;
}
}
public function getCommonTypeaheadCityDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isPost()) {
$this->_helper->viewRenderer->setNoRender(true);
$countryId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('countryId'));
$stateId = trim($this->_HtmlPurifier->filter($this->getRequest()->getParam('stateId')));
$cityId = trim($this->_HtmlPurifier->filter($this->getRequest()->getParam('cityId')));
$typevalue = $this->_HtmlPurifier->filter($this->getRequest()->getParam("query"));
$objCity = new Travel_Model_TblCity();
$objCity->strCondition = '';
if (isset($countryId) && $countryId != '' && $countryId > 0) {
$objCity->intContSysId = $countryId;
}
if (isset($stateId) && $stateId != '' && $stateId > 0) {
$objCity->strCondition .= " AND TB_Master_Geo_City.StateSysId = '" . $stateId . "'";
}
if (isset($typevalue) && $typevalue != '') {
$objCity->strCondition .= " AND (TB_Master_Geo_City.Title like '%" . $typevalue . "%' or TB_Master_Geo_City.Alias like '%" . $typevalue . "%' or TB_Master_Geo_City.Synonyms like '%" . $typevalue . "%' ) ";
}
$cityList = $objCity->getCityList();
$response = array();
if (!empty($cityList)) {
foreach ($cityList as $row) {
$response[] = array('TBBCityId' => $row['TBBCityId'], 'CityId' => $row['CityId'], 'label' => $row['Title'], 'ContSysId' => trim($row['ContSysId']), 'Country' => trim($row['Country']));
}
}
echo json_encode($response);
}
//$this->render('ajaxDropdown',array('arg1' => 'value1'));
}
public function deletepkgitenaryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$postdata = $this->getRequest()->getPost();
$ItenaryID = $postdata['ItenaryID'];
$totitenary = $postdata['totitenary'];
$tpsysID = $postdata['tpsysID'];
$where = array('TPIntSysId = ? ' => $ItenaryID);
$updateData = array('IsMarkForDel' => '1');
$deleteitenary = $this->_travelplanObj->deleteItenary($where, $updateData);
$gettpitnsysID = $this->_travelplanObj->GetItenrayIDWithoutDelete($tpsysID);
//print_r($gettpitnsysID);
for ($i = 0; $i < count($gettpitnsysID); $i++) {
$j = $i + 1;
$where = array('TPIntSysId = ? ' => $gettpitnsysID[$i]);
$updateData = array('Sequence' => $j);
$deleteitenary = $this->_travelplanObj->deleteItenary($where, $updateData);
}
}
public function deletepkgitenarybyoAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$postdata = $this->getRequest()->getPost();
$ItenaryID = $postdata['ItenaryID'];
$totitenary = $postdata['totitenary'];
$tpsysID = $postdata['tpsysID'];
$where = array('TPIntSysId = ? ' => $ItenaryID);
$updateData = array('IsMarkForDel' => '1');
$deleteitenary = $this->_travelplanObj->deleteItenarybyo($where, $updateData);
$gettpitnsysID = $this->_travelplanObj->GetItenrayIDWithoutDeleteBYO($tpsysID);
for ($i = 0; $i < count($gettpitnsysID); $i++) {
$j = $i + 1;
$where = array('TPIntSysId = ? ' => $gettpitnsysID[$i]);
$updateData = array('Sequence' => $j);
$deleteitenary = $this->_travelplanObj->deleteItenarybyo($where, $updateData);
}
}
public function addflightinventoryAction() {
$this->_helper->layout->disableLayout();
$postdata = $this->getRequest()->getPost();
$invsysID = $postdata['invsysID'];
$sequenceID = $postdata['seqID'];
$price = $postdata['price'] ? ceil($postdata['price']) : 0;
$flightnum = str_replace(' ', '', $postdata['flightnum']);
$airlinesysID = $postdata['airlinesysID'];
$stopcount = $postdata['stopcount'];
$apiname = $postdata['apiname'];
if ($apiname == 'API') {
$is_api = 1;
} else {
$is_api = 0;
}
$flightduration = $postdata['flightduration'];
$sourceplaceID = $postdata['sourceplaceID'];
$DestplaceID = $postdata['DestplaceID'];
$sourceapcode = $postdata['sourceapcode'];
$destapcode = $postdata['destapcode'];
$onewayadults = $postdata['onewayadults'];
$onewaychild = $postdata['onewaychild'];
$onewayinfant = $postdata['onewayinfant'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$onewaydeparture = $postdata['onewaydeparture'];
$explodedepdate = explode("/", $onewaydeparture);
$depdate = date_create($postdata['depdate']);
$arrdate = date_create($postdata['arrivaltime']);
$departdate = date_format($depdate, 'Y-m-d H:i:s');
$arrivaldate = date_format($arrdate, 'Y-m-d H:i:s');
$createddate = date('Y-m-d H:i:s');
$itenaryID = $postdata['tpintsysID'];
$isfromapi = 1;
$airdata = array(
"TPIntSysId" => $itenaryID,
"SeqId" => $sequenceID,
"InvnItemSysId" => $invsysID,
"AgencySysId" => $AgencySysId,
"IsFromAPI" => $is_api,
"SourceSysId" => 0,
"SupplierSysId" => 0,
"Cost" => $price,
"FlightNumber" => $flightnum,
"AirlineSysId" => trim($airlinesysID),
"LocalFromTime" => $departdate,
"LocalToTime" => $arrivaldate,
"FromUTCTime" => $depdate,
"ToUTCTime" => "1900-01-01",
"AdultPax" => $onewayadults,
"ChildPax" => $onewaychild,
"InfentPax" => $onewayinfant,
"IsSelectedOnPkg" => 1,
"FlyingMinutes" => $flightduration,
"SourcePlaceSysId" => $sourceplaceID,
"DestPlaceSysId" => $DestplaceID,
"SourceAirportCode" => $sourceapcode,
"DestAirportCode" => $destapcode,
"StopCount" => $stopcount,
"UpdateDate" => $createddate,
"CreateDate" => $createddate,
"IsApproved" => 1,
"IsActive" => 1,
"IsMarkForDel" => 0
);
$this->view->itenaryID = $itenaryID;
$inssertdata = $this->_crmcusttravelplanAir->addCustomerTravelPlanAir($airdata);
$getselectedflightdata = $this->_crmcusttravelplanAir->GetSelectedFlightValues($invsysID);
$this->view->flightinfo = $getselectedflightdata;
$this->view->flightprice = $price;
}
public function addflightinventorypkgAction() {
$this->_helper->layout->disableLayout();
$postdata = $this->getRequest()->getPost();
$objPackage = new Travel_Model_TblPackage();
$invsysID = $postdata['invsysID'];
$sequenceID = $postdata['seqID'];
$price = $postdata['price'] ? ceil($postdata['price']) : 0;
$flightnum = str_replace(' ', '', $postdata['flightnum']);
$airlinesysID = $postdata['airlinesysID'];
$stopcount = $postdata['stopcount'];
$apiname = $postdata['apiname'];
if ($apiname == 'API') {
$is_api = 1;
} else {
$is_api = 0;
}
$flightduration = $postdata['flightduration'];
$sourceplaceID = $postdata['sourceplaceID'];
$DestplaceID = $postdata['DestplaceID'];
$sourceapcode = $postdata['sourceapcode'];
$destapcode = $postdata['destapcode'];
$onewayadults = $postdata['onewayadults'];
$onewaychild = $postdata['onewaychild'];
$onewayinfant = $postdata['onewayinfant'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$onewaydeparture = $postdata['onewaydeparture'];
$explodedepdate = explode("/", $onewaydeparture);
$depdate = date_create($postdata['depdate']);
$arrdate = date_create($postdata['arrivaltime']);
$departdate = date_format($depdate, 'Y-m-d H:i:s');
$arrivaldate = date_format($arrdate, 'Y-m-d H:i:s');
$createddate = date('Y-m-d H:i:s');
$itenaryID = $postdata['tpintsysID'];
$isfromapi = 1;
if ($stopcount > 0) {
$is_direct = 1;
} else {
$is_direct = 0;
}
$airdata = array(
"TPIntSysId" => $itenaryID,
"SeqId" => $sequenceID,
"InvnItemSysId" => $invsysID,
"AgencySysId" => $AgencySysId,
"IsFromAPI" => $is_api,
"ICSourceSysId" => 0,
"SupplierSysId" => 0,
"TripType" => 1,
"Cost" => $price,
"FlightNumber" => $flightnum,
"AirlineSysId" => trim($airlinesysID),
"IsFromAgency" => 0,
"LocalFromTime" => $departdate,
"LocalToTime" => $arrivaldate,
"FromUTCTime" => $depdate,
"ToUTCTime" => $arrdate,
"FlightCabinClass" => 1,
"AdultPax" => $onewayadults,
"ChildPax" => $onewaychild,
"InfentPax" => $onewayinfant,
"IsSelectedOnPkg" => 1,
"FlyingMinutes" => $flightduration,
"SourcePlaceSysId" => $sourceplaceID,
"DestPlaceSysId" => $DestplaceID,
"SourceAirportCode" => $sourceapcode,
"DestAirportCode" => $destapcode,
"StopCount" => $stopcount,
"Stops" => $stopcount,
"IsDirect" => $is_direct,
"DayLightSavingDiff" => 0,
"AirportHaultMinutes" => 0,
"Rating" => 0,
"FllightFeatureMask" => 0,
"UpdatedByISSysId" => $AgencySysId,
"CreatedByISSysId" => $AgencySysId,
"ImageTN" => '',
"ImgForList" => '',
"ImgeDetails" => '',
"ApproveBy" => $AgencySysId,
"ApprovalDate" => $createddate,
"UpdateDate" => $createddate,
"CreateDate" => $createddate,
"IsApproved" => 1,
"IsActive" => 1,
"IsMarkForDel" => 0
);
$this->view->itenaryID = $itenaryID;
$inssertdata = $objPackage->insertData('TB_TravelPlan_Itenary_Air', $airdata);
$getselectedflightdata = $this->_crmcusttravelplanAir->GetSelectedFlightValues($invsysID);
$this->view->flightinfo = $getselectedflightdata;
$this->view->flightprice = $price;
}
public function savepackagecostsheetAction() {
$objPackage = new Travel_Model_TblPackage();
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$postdata = $this->getRequest()->getPost();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$totalflight = $postdata['totalflight'];
$totalhotel = $postdata['totalhotel'];
$totalactitvity = $postdata['totalactitvity'];
$totalsightseeing = $postdata['totalsightseeing'];
$createdDate = date('Y-m-d H:i:s');
$travelplanID = $postdata['TPSysId'];
$gettpsysID = $this->_crmcusttravelplan->GetTravelPlanByID($travelplanID);
if (!empty($gettpsysID)) {
$where = "TPSysId = " . $travelplanID;
$this->_travelplancostsheet->DeleteCostSheet($where);
}
$tpitenaryID = $this->_crmcusttravelplan->GetCustomerTravelPlanOnlyItenary($travelplanID);
$is_flight = array();
######## Adding All the data in to customer costsheet ##########
for ($i = 0; $i < count($tpitenaryID); $i++) {
$intsysId = $tpitenaryID[$i]['TPIntSysId'];
$flightInvdata = $objPackage->GetFlightByItenary($intsysId);
if (!empty($flightInvdata['TPIntSysId'])) {
$flightdata = array(
"TPSysId" => $postdata['TPSysId'],
"TPIntSysId" => $flightInvdata['TPIntSysId'],
"SeqId" => $flightInvdata['SeqId'],
"IsSelected" => 1,
"AgencySysId" => $flightInvdata['AgencySysId'],
"InvXRefSysId" => $flightInvdata['InvnItemSysId'],
"XrefInvtSysId" => 0,
"DurationUOM" => 0,
"ItenaryDay" => $flightInvdata['SeqId'],
"Title" => $flightInvdata['Title'] . ',' . $flightInvdata['FlightNumber'],
"Details" => '',
"Duration" => $flightInvdata['FlyingMinutes'],
"SourceType" => 0,
"SupplierSysId" => $flightInvdata['SupplierSysId'] ? $flightInvdata['SupplierSysId'] : 0,
"IsFromAPI" => $flightInvdata['IsFromAPI'],
"SourceSysId" => $flightInvdata['SourceSysId'],
"SingleOcc" => (int) $flightInvdata['PublishedFare'],
"DoubleOcc" => 0,
"TrpOcc" => 0,
"ChildWithBed" => 0,
"PaxExtBed" => 0,
"AdultPax" => $flightInvdata['AdultPax'],
"ChildPax" => $flightInvdata['ChildPax'],
"InfantPax" => $flightInvdata['InfentPax'],
"PetPax" => 0,
"CurrencyType" => $flightInvdata['CurrencyType'],
"InventoryType" => 2,
"IsSelectedOnPkg" => 1,
"CreateDate" => $createdDate,
"UpdateDate" => $createdDate,
"IsMarkForDel" => 0,
"IsActive" => 1
);
$lastaddedflightID = $this->_travelplancostsheet->addAgencyCustomerCostSheet($flightdata);
}
}
for ($k = 0; $k < count($tpitenaryID); $k++) {
$intsysId = $tpitenaryID[$k]['TPIntSysId'];
$gethoteldetails = $objPackage->GetHotelByItenary($intsysId);
if (!empty($gethoteldetails)) {
$hoteldata = array(
"TPSysId" => $postdata['TPSysId'],
"TPIntSysId" => $gethoteldetails['TPIntSysId'],
"SeqId" => $gethoteldetails['SeqId'],
"IsSelected" => 1,
"AgencySysId" => $gethoteldetails['AgencySysId'],
"InvXRefSysId" => $gethoteldetails['AccoSysId'],
"RoomTypeStr" => $gethoteldetails['RoomTypeStr'],
"RoomNumber" => $gethoteldetails['RoomNumber'],
"XrefInvtSysId" => 0,
"DurationUOM" => 0,
"ItenaryDay" => $gethoteldetails['SeqId'],
"Title" => $gethoteldetails['Title'],
"Details" => '',
"Duration" => 0,
"SourceType" => 0,
"SupplierSysId" => $gethoteldetails['SupplierSysId'] ? $gethoteldetails['SupplierSysId'] : 0,
"IsFromAPI" => $gethoteldetails['IsFromAPI'],
"SourceSysId" => 0,
"SingleOcc" => $gethoteldetails['TotalCostSO'],
"DoubleOcc" => $gethoteldetails['TotalCostDO'],
"TrpOcc" => $gethoteldetails['TotalCostTO'],
"ChildWithBed" => $gethoteldetails['TotalCostExtraBed'],
"AdultPax" => $gethoteldetails['AdultPax'],
"PaxExtBed" => 0,
"ChildPax" => $gethoteldetails['ChildPax'],
"InfantPax" => $gethoteldetails['InfantPax'],
"PetPax" => $gethoteldetails['PetPax'],
"CurrencyType" => $gethoteldetails['CurrencyType'],
"InventoryType" => 1,
"IsSelectedOnPkg" => 1,
"CreateDate" => $createdDate,
"UpdateDate" => $createdDate,
"IsMarkForDel" => 0,
"IsActive" => 1
);
$this->_travelplancostsheet->addAgencyCustomerCostSheet($hoteldata);
}
}
$activitydetails = $objPackage->getCustPackageActivityList($postdata['TPSysId']);
for ($m = 0; $m < count($activitydetails); $m++) {
$activitydata = array(
"TPSysId" => $postdata['TPSysId'],
"TPIntSysId" => $activitydetails[$m]['TPIntSysId'],
"SeqId" => $activitydetails[$m]['Sequence'],
"IsSelected" => 1,
"AgencySysId" => $activitydetails[$m]['AgencySysId'],
"InvXRefSysId" => $activitydetails[$m]['InvnItemSysId'],
"XrefInvtSysId" => 0,
"DurationUOM" => 0,
"ItenaryDay" => $activitydetails[$m]['Sequence'],
"Title" => $activitydetails[$m]['Title'],
"Details" => '',
"Duration" => $activitydetails[$m]['duration'],
"SourceType" => $activitydetails[$m]['ICSourceSysId'],
"SupplierSysId" => 0,
"IsFromAPI" => 0,
"SourceSysId" => 0,
"SingleOcc" => 0,
"DoubleOcc" => 0,
"TrpOcc" => 0,
"ChildWithBed" => 0,
"PaxExtBed" => 0,
"ChildPax" => 0,
"InfantPax" => 0,
"PetPax" => 0,
"CurrencyType" => 0,
"InventoryType" => 3,
"IsSelectedOnPkg" => 1,
"CreateDate" => $createdDate,
"UpdateDate" => $createdDate,
"IsMarkForDel" => 0,
"IsActive" => 1
);
$this->_travelplancostsheet->addAgencyCustomerCostSheet($activitydata);
}
$sightseeigndetail = $objPackage->getCustPackageSightseenList($postdata['TPSysId']);
for ($l = 0; $l < count($sightseeigndetail); $l++) {
$sightseeingdata = array(
"TPSysId" => $postdata['TPSysId'] ? trim($postdata['TPSysId']) : 0,
"TPIntSysId" => $sightseeigndetail[$l]['InvnItemSysId'],
"SeqId" => $sightseeigndetail[$l]['SeqId'],
"IsSelected" => 1,
"AgencySysId" => $sightseeigndetail[$l]['AgencySysId'],
"InvXRefSysId" => $sightseeigndetail[$l]['XrefInvnItemSysId'],
"XrefInvtSysId" => 0,
"DurationUOM" => 0,
"ItenaryDay" => 0,
"Title" => $sightseeigndetail[$l]['Title'],
"Details" => '',
"Duration" => 0,
"SourceType" => 0,
"SupplierSysId" => 0,
"IsFromAPI" => 0,
"SourceSysId" => 0,
"SingleOcc" => $sightseeigndetail[$l]['Cost'],
"DoubleOcc" => 0,
"TrpOcc" => 0,
"ChildWithBed" => 0,
"PaxExtBed" => 0,
"ChildPax" => 0,
"InfantPax" => 0,
"PetPax" => 0,
"CurrencyType" => 0,
"InventoryType" => 4,
"IsSelectedOnPkg" => 1,
"CreateDate" => $createdDate,
"UpdateDate" => $createdDate,
"IsMarkForDel" => 0,
"IsActive" => 1
);
$lastsightssingID = $this->_travelplancostsheet->addAgencyCustomerCostSheet($sightseeingdata);
if ($lastsightssingID) {
$response = array('success' => true, 'msg' => 'Success.');
echo json_encode($response);
exit;
}
}
}
public function getCustomerDetailForPackageAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$email = $this->_request->getParam('emailID');
$mobilenum = $this->_request->getParam('mobilenum');
//echo $mobilenum;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->ChkEmailMobileWithResponse($email, $mobilenum, $AgencySysId);
if ($customerDetails) {
$status = 'success';
} else {
$status = 'failure';
}
// echo '<pre>';print_r($customerDetails);die;
$detail['status'] = $status;
//$detail['customerDetails']=$customerDetails;
$detail['FullName'] = (isset($customerDetails[0]['FullName']) && !empty($customerDetails[0]['FullName'])) ? trim(ucfirst($customerDetails[0]['FullName'])) : '';
$detail['ContactNumber'] = (isset($customerDetails[0]['Contacts']) && !empty($customerDetails[0]['Contacts'])) ? trim($customerDetails[0]['Contacts']) : '';
$cityName = (isset($customerDetails[0]['CityName']) && !empty($customerDetails[0]['CityName'])) ? trim($customerDetails[0]['CityName']) : '';
$countryName = (isset($customerDetails[0]['CountryName']) && !empty($customerDetails[0]['CountryName'])) ? ', ' . trim($customerDetails[0]['CountryName']) : '';
$detail['Address'] = $cityName . $countryName;
echo json_encode($detail);
}
public function listgtxcustomerAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$roleID = $sessionLogin_user->UserRole;
$getData = array();
//echo "<pre>";print_r($_SESSION);die;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
//print_r($getRoleDetail['IsAdmin']);die;
//code for if logedin user click on assign user notification
$type = $this->getRequest()->getParam('type');
$uid = $this->getRequest()->getParam('uid');
if (isset($type) && isset($uid) && !empty($type) && !empty($uid)) {
$type = $this->_HtmlPurifier->filter($type);
$uid = $this->_HtmlPurifier->filter(base64_decode($uid));
if ($uid == $sessionLogin_user->intLoggedinUserId) {
$where = "UserSysId = " . $uid . " AND MsgType = 3 AND ModuleType = 1";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => '1',
'Accepted' => '1',
'IsActive' => '0',
'UpdateDate' => $date,
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$updatedUserInbox = $this->_agencyuserObj->updateNotification($userArray, $where);
}
}
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($agencysysID);
//end of code for assign user notification
if ($getRoleDetail['IsAdmin'] == true) {
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getData['AgencySysId'] = $agencysysID;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData);
} else {
$getData['AgencySysId'] = $agencysysID;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData);
}
} else {
$getData['AgencySysId'] = $agencysysID;
$getData['UserSysId'] = $sessionLogin_user->intLoggedinUserId;
$leadSourcesIds = array();
$leadSourceExplodedRes = '';
$getCustomerList = array();
if (!empty($getleadSource)) {
foreach ($getleadSource as $k => $v) {
$leadSourcesIds[] = $v['LeadSourceSysId'];
}
$leadSourceExplodedRes = implode(",", $leadSourcesIds);
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $agencysysID);
} else {
$getData['AgencySysId'] = $agencysysID;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $agencysysID);
}
}
//print_r($leadSourceExplodedRes);die;
}
//print_r($getleadSource);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getCustomerList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
//$getStageList = $this->_leadstageObj->GetAllStage($agencysysID);
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
//echo "<pre>";print_r($getRoleDetail);die;
$this->view->leadStageList = $getStageList;
$this->view->leadSourceList = $getleadSource;
$this->view->agencyUser = $agencyUser;
$this->view->getRoleDetail = $getRoleDetail;
}
public function gtxcustomerUpdateAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$passData = array();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgencyCRMLeadSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$sid = (int) $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
if ($sid == 50) {
$userArray = array(
'IsApproved' => '1',
'UpdatedDate' => $date,
//'LeadStageSysId' => 50
);
} else {
$userArray = array(
'IsApproved' => '1',
'UpdatedDate' => $date
);
}
$getCustomerList = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
if (isset($getCustomerList) && count($getCustomerList) > 0) {
// $passData = array(
// "StartDate" => $getCustomerList['startDate'],
// "RoomInfoJson" => $getCustomerList['RoomInfoJson'],
// "PlanType" => $getCustomerList['PlanType'],
// "Destination" => $getCustomerList['Destination'],
// "Remarks" => $getCustomerList['Remarks']
// );
//echo "<pre>";print_r($getCustomerList);die;
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$getAgencyCustomerExist = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
//echo count($getAgencyCustomerExist);die;
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($getCustomerList['EmailId']), $agencysysID);
if (empty($getcustomerdetails)) {
//$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($getCustomerList['EmailId']),'');
}
if (isset($getCustomerList['PrimaryContactNumber']) && !empty(trim($getCustomerList['PrimaryContactNumber'])) && empty($getcustomerdetails)) {
$getcustomerdetails = $this->_crmcustomerObj->ChkMobileWithResponse(trim($getCustomerList['PrimaryContactNumber']), $agencysysID, '', '', '');
}
$customerRcord = $getcustomerdetails['CustomerSysId'];
$CRMCustSysId = $getcustomerdetails['CRMCustSysId'];
//code for customer check added by amit
if (empty($getcustomerdetails['CustomerSysId'])) {
$userArray = array(
'EmailId' => trim($getCustomerList['EmailId']),
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($getCustomerList['PrimaryContactNumber']),
'countrycode' => trim($getCustomerList['countrycode']),
'FullName' => trim($getCustomerList['FullName']),
'FirstName' => trim($getCustomerList['FirstName']),
'LastName' => trim($getCustomerList['LastName']),
'ActiveDate' => $date,
'UpdatedDate' => $date,
'CreatedDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
}
if (empty($getAgencyCustomerExist) && empty($getcustomerdetails) && empty($getAgencyCustomerExist) && empty($getcustomerdetails)) {
$agencyuserArray = array(
'AgencySysId' => $agencysysID,
'CRMCustSysId' => $CRMCustSysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'EmailId' => trim($getCustomerList['EmailId']),
'Title' => $getCustomerList['Salutation'],
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => 0,
'StateOrZoneSysId' => 0,
'CountrySysId' => 0,
'IsEmployee' => '0',
'Contacts' => trim($getCustomerList['PrimaryContactNumber']),
'countrycode' => trim($getCustomerList['countrycode']),
'JoinDate' => $date,
'UserName' => trim($getCustomerList['FirstName']) . '' . trim($getCustomerList['LastName']),
'FirstName' => trim($getCustomerList['FirstName']),
'LastName' => trim($getCustomerList['LastName']),
'Relation' => '',
'PassportNo' => '',
'PassportExpiry' => '',
'DOB' => '',
'MarriageAnniversary' => '',
'CreatedByUserSysId' => isset($getCustomerList['AssignUserSysId']) ? (int) $getCustomerList['AssignUserSysId'] : (int) $this->intLoggedinUserId,
'RegisterDate' => $date,
'UpdateDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well created by Er amit kumar dubey on 16 dec 2016 at 1:01PM ########
$CustomerSysId = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
} else {
$CustomerSysId = isset($getAgencyCustomerExist['CustomerSysId']) ? $getAgencyCustomerExist['CustomerSysId'] : $customerRcord;
}
}
// echo base64_encode($CustomerSysId);die;
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($CustomerSysId)), 1);
if ($sid == 50) {
$this->_redirect('/customer/customer-profile-desc/id/' . base64_encode($CustomerSysId) . '/code/' . $secureCode . '/SearchData/' . $AgencyCRMLeadSysId);
} else {
$this->_redirect('/customer/customer-profile-desc/id/' . base64_encode($CustomerSysId) . '/code/' . $secureCode);
}
exit;
} else {
echo "something went wrong.Please try after some time";
}
exit;
}
public function gtxcustomerStageUpdateAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$AgencyCRMLeadSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid')));
$title = '';
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
if ((int) $stageId > 0) {
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
$IsMarkForDelete = 0;
$IsApproved = 0;
if ($stageId == 47) {
$IsMarkForDelete = 1;
}
$userArray = array(
'LeadStageSysId' => $stageId,
'IsMarkForDelete' => $IsMarkForDelete,
'IsApproved' => $IsApproved,
'AssignUserSysId' => $AgentSysId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->GetLeadStageById($stageId);
$msg = "success";
$title = count($getStageList) > 0 ? $getStageList['Title'] : 'NA';
} else {
$msg = "failed";
}
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function assignAgencyUserAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$CustomerSysIds = $this->getRequest()->getParam('data');
$AgencyUserId = $this->getRequest()->getParam('aid');
$CustomerSysIds = $this->_HtmlPurifier->filterArray($CustomerSysIds);
$AgencyUserId = base64_decode($this->_HtmlPurifier->filter($AgencyUserId));
if (isset($AgencyUserId) && !empty($AgencyUserId) && is_numeric($AgencyUserId) > 0) {
if (!empty($CustomerSysIds)) {
for ($d = 0; $d < count($CustomerSysIds); $d++) {
$AgencyCRMLeadSysId = base64_decode($CustomerSysIds[$d]);
//print_r($agencyCustomerDetails);
//$where = "AgencyCRMLeadSysId = ". $agencyCustomerDetails['AgencyCRMLeadSysId']." AND AgencySysId=".$agencysysID." ";
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId . " AND AgencySysId=" . $agencysysID . " ";
$date = date('Y-m-d H:i:s');
$userArray = array(
'AssignUserSysId' => $AgencyUserId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
// only update in agency customer table
$agencyCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (!empty($agencyCustomerDetails)) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
//add notification for assign in table agency_user_inbox
// query for insert data in db created by amit kumar dubey on 4 april 2017 at 11:58 AM
$message = 'user ' . trim($agencyCustomerDetails['FirstName']) . ' assigned to ' . $AgencyUserId;
$messageArray = array(
'ModuleType' => 1,
'RefSysId' => 0,
'SenderSysId' => trim($agencyCustomerDetails['CustomerSysId']),
'UserSysId' => $AgencyUserId,
'AgencySysId' => $agencysysID,
'Message' => addslashes($message),
'MsgType' => 3,
'isAgent' => 0,
'Accepted' => 0,
'Rejected' => 0,
'RejectReason' => 0,
'OtherInfo' => 0,
'UpdateDate' => $date,
'CreatedDate' => $date,
'IsActive' => 1,
'IsMarkForDel' => '0'
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$notificationRcord = $this->_agencyuserObj->addNotification($messageArray);
//end of add notification
// send email to agency staff when assign completed
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
// render view
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$URL = 'cid:' . $agencyCustomerDetails['CustomerSysId'] . "@@" . "aid:" . $agencysysID;
$encryptData = $this->getEnc($URL);
//echo $this->getDec("9a68e8afc873c650966737e18378607d");
//die;
$agentDetails = $this->_crmcustomerObj->getAgentDetailById($AgencyUserId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencysysID);
$agentAssineDetails = $this->_crmcustomerObj->getAgentDetailById($sessionLogin_user->intLoggedinUserId);
$html->assign('type', 'gtxCustomerAgentEmailNotification');
$html->assign('URL', $encryptData);
$html->assign('agentDetails', $agentDetails);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('agentAssineDetails', $agentAssineDetails);
$bodyText = $html->render('email-template.phtml');
$emailId = trim($agentDetails[0]['EmailId']);
$emailSendId = trim($getAgencyDetail['PrimaryEmail']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailData = array('fromEmail' => $emailSendId, 'fromName' => $fromName, 'subject' => 'New Lead Assigned', 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
//echo "success";
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[2], // 7 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 0, 0);
$msg = "success";
} catch (Exception $err) {
//print_r($err, true);
$msg = "failed";
}
//end of send email to customer
}
}
$msg = "success";
$title = 'Success fully updated';
} else {
$msg = "failed";
$title = 'Something went wrong';
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function sendEmailGtxUserAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$CRMCustomerId = $this->getRequest()->getParam('cid');
$emailid = $this->getRequest()->getParam('emailid');
$CRMCustomerId = base64_decode($this->_HtmlPurifier->filter($CRMCustomerId));
$emailid = base64_decode($this->_HtmlPurifier->filter($emailid));
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
// render view
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$URL = 'cid:' . $CRMCustomerId . "@@" . "aid:" . $agencysysID;
$encryptData = $this->getEnc($URL);
//echo $this->getDec("9a68e8afc873c650966737e18378607d");
//die;
$html->assign('type', 'gtxCustomerEmailForm');
$html->assign('URL', $encryptData);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencysysID);
$html->assign('agencyDetails', $getAgencyDetail);
$bodyText = $html->render('email-template.phtml');
//$emailId = trim($getCustomerDetail['EmailId']);
$emailId = trim($emailid);
$emailSendId = trim($getAgencyDetail['PrimaryEmail']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailData = array('fromEmail' => $emailSendId, 'fromName' => $fromName, 'subject' => 'Proposal Details', 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
//echo "success";
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[2], // 7 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $CRMCustomerId);
$msg = "success";
} catch (Exception $err) {
print_r($err, true);
$msg = "failed";
}
//end of send email to customer
echo json_encode(array('status' => $msg));
}
public function addenquiryAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$formdata = $this->getRequest()->getPost();
$customerID = $formdata['customerID'];
$agencyID = $formdata['agencyID'];
$search_going_from = $formdata['search_going_from'];
$explode_search_going_from = explode('__', $search_going_from);
$going_from_id = $explode_search_going_from[0];
$going_from_name = $explode_search_going_from[1];
$search_going_to = $formdata['search_going_to'];
$explode_going_to = explode('__', $search_going_to);
$going_to_id = $explode_going_to['0'];
$going_to_name = $explode_going_to['1'];
if (!empty($formdata['search_price_range'])) {
$search_price_range = $formdata['search_price_range'];
$exp_search_price_range = explode("__", $search_price_range);
$minprice = $exp_search_price_range[0];
$maxprice = $exp_search_price_range[1];
} else {
$minprice = 0;
$maxprice = 0;
}
$selecttraveler = $formdata['selecttraveler'] ? $formdata['selecttraveler'] : 0;
if (!empty($formdata['travveldate'])) {
$traveldate = $formdata['travveldate'];
$explodetraveldate = explode("/", $formdata['travveldate']);
$traveldate = $explodetraveldate[2] . '-' . $explodetraveldate[0] . '-' . $explodetraveldate[1];
} else {
$traveldate = date('Y-m-d');
}
$requirement = $formdata['requirement'] ? $formdata['requirement'] : '';
$chkagencyuser = $this->_crmcustomerObj->ChkAgencyUser($customerID);
$createddate = date('Y-m-d H:i:s');
$agencyuserID = empty($chkagencyuser[0]['CustomerSysId']) ? 0 : $chkagencyuser[0]['CustomerSysId'];
###### Customer Exist in Agency_User Table ###############
if ($agencyuserID) {
$customerarray = array(
"VersionId" => 1,
"PlanBookingId" => "Q/16",
"AgencySysId" => $agencyID,
"AgentSysId" => 0,
"SupplierSysId" => 0,
"StatusType" => 1,
"CustomerSysId" => $customerID,
"PlanType" => 5,
"MinPax" => $selecttraveler,
"AdditionalReq" => $requirement,
"PackRangeType" => 0,
"Title" => '',
"LeadSourceSysId" => 0,
"EconomyMask" => 0,
"PackTypeMask" => 0,
"InclCatMask" => 0,
"InclMask" => '',
"ExclusionMask" => 0,
"PackSpecType" => 1,
"DestinationPlaces" => $going_to_name,
"DestinationPlacesSysId" => (int) $going_to_id,
"SourcePlaces" => $going_from_name,
"SourcePlaceSysId" => $going_from_id,
"StartDate" => $traveldate,
"ValidTill" => $createddate,
"MinPrice" => $minprice,
"MaxPrice" => $maxprice,
"CreateDate" => $createddate,
"UpdateDate" => $createddate,
"IsMarkForDel" => 0,
"IsActive" => 1,
"IsAprooved" => 1
);
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($customerarray);
if ($lastID) {
echo 'Enquiry Posted';
}
} else {
$getcrmuserdetail = $this->_crmcustomerObj->GetCRMCustDetails($customerID);
$createddate = date('Y-m-d H:i:s');
$agency = array(
"AgencySysId" => $agencyID,
"CRMCustSysId" => $customerID,
"EmailId" => $getcrmuserdetail[0]['EmailId'],
"Title" => 1,
"UserName" => $getcrmuserdetail[0]['FirstName'] . '' . $getcrmuserdetail[0]['LastName'],
"FirstName" => $getcrmuserdetail[0]['FirstName'],
"LastName" => $getcrmuserdetail[0]['LastName'],
"UpdateDate" => $createddate,
"RegisterDate" => $createddate,
"Logo" => '',
"IsfromSM" => 0,
"UserId" => 0,
"IsApproved" => 0,
"IsActive" => 1,
"IsMarkForDelete" => 0
);
$agencyinsertID = $this->_agencycustomerObj->addAgencyCustomer($agency);
if ($agencyinsertID) {
$customerarray = array(
"VersionId" => 1,
"PlanBookingId" => "Q/16",
"AgencySysId" => $agencyID,
"AgentSysId" => 0,
"SupplierSysId" => 0,
"StatusType" => 1,
"CustomerSysId" => $customerID,
"PlanType" => 5,
"MinPax" => $selecttraveler,
"AdditionalReq" => $requirement,
"PackRangeType" => 0,
"Title" => '',
"LeadSourceSysId" => 0,
"EconomyMask" => 0,
"PackTypeMask" => 0,
"InclCatMask" => 0,
"InclMask" => '',
"ExclusionMask" => 0,
"PackSpecType" => 1,
"DestinationPlaces" => $going_to_name,
"DestinationPlacesSysId" => (int) $going_to_id,
"SourcePlaces" => $going_from_name,
"SourcePlaceSysId" => $going_from_id,
"StartDate" => $traveldate,
"ValidTill" => $createddate,
"MinPrice" => $exp_search_price_range[0],
"MaxPrice" => $exp_search_price_range[1],
"CreateDate" => $createddate,
"UpdateDate" => $createddate,
"IsMarkForDel" => 0,
"IsActive" => 1,
"IsAprooved" => 1
);
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($customerarray);
if ($lastID) {
echo 'Enquiry Posted';
}
}
}
}
public function sendEmailSupplierUserAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$emailid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('emailId'));
$data = $this->getRequest()->getParam('data');
$callDetails = $this->getRequest()->getParam('suppCallDetails');
$data = base64_decode($this->_HtmlPurifier->filter($data));
$dataRes = json_decode($data, true);
$suppcustemailID = $this->_HtmlPurifier->filter($this->getRequest()->getParam('suppcustemailID'));
//echo "<pre>";print_r($dataRes);die;
$arrSupplierDetails = array();
$arrAgencyDetails = array();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
if (!empty($dataRes)) {
$supplierSysId = $dataRes['SupplierSysId'];
if ($supplierSysId > 0) {
$objSupplier = new Travel_Model_TblSupplier();
$arrSupplierDetails = $objSupplier->getSupplierById($supplierSysId);
}
if (!empty($dataRes)) {
$agencyId = $sessionLogin_user->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$arrAgencyDetails = $objAgency->getUserDataByAgency($agencyId);
}
//$inventSysId=$dataRes['InvnItemSysId'];
//$hotelid=$dataRes['hotelId'];
}
if (trim($suppcustemailID) == '') {
$createDate = date('Y-m-d H:i:s');
//send call details in db
$arrCall = json_decode(base64_decode($callDetails), true);
//print_r($arrCall);
if (!empty($arrCall)) {
$leadID = $dataRes['sessionhotelDirectSearchData']['TPSysId'];
$arrCallDb = array(
'TPSysId' => $leadID,
'SupplierSysId' => $supplierSysId,
'IsSupAvalOnCall' => $arrCall[0]['suppIsAvailable'],
'OnCallSupRate' => $arrCall[0]['suppRate'],
'OnCallSupRooms' => $arrCall[0]['suppRooms'],
'OnCallSupRateFrom' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $arrCall[0]['suppDate']))),
'OnCallSupRateTo' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $arrCall[0]['suppTo']))),
'OnCallSupRateValidTill' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $arrCall[0]['suppHeldTill']))),
'OnCallSupRemarks' => $arrCall[0]['suppRemark'],
'IsActive' => 1,
'IsMarkForDel' => 0,
'CreatedOn' => $createDate,
'UpdatedOn' => $createDate,
);
$this->_crmagencysupponcall = new Travel_Model_CRM_AgencyCustomerReqSupplierOnCall();
$lastcallID = $this->_crmagencysupponcall->addReqSupplierOnCall($arrCallDb);
}
//end of send call details
}
//echo "<pre>";print_r($dataRes);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
// render view
//echo $this->getDec("9a68e8afc873c650966737e18378607d");
//die;
$html->assign('type', 'supplierCustomerEmailForm');
$html->assign('arrSupplierDetails', $arrSupplierDetails);
$html->assign('data', $dataRes);
$html->assign('agentDetails', $sessionLogin_user);
$html->assign('agencyDetails', $arrAgencyDetails);
$html->assign('callDetails', $callDetails);
$bodyText = $html->render('email-template.phtml');
//$emailId = trim($getCustomerDetail['EmailId']);
$emailId = trim($emailid);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'New Query Received', 'to' => array(trim($emailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => $leadID,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[2], // 7 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics);
$msg = "success";
} catch (Exception $err) {
print_r($err, true);
$msg = "failed";
}
//end of send email to customer
echo json_encode(array('status' => $msg));
}
public function sendEmailSupplierEnquiryAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$emailid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('emailId'));
$sid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
$data = $this->getRequest()->getParam('data');
$data = base64_decode($this->_HtmlPurifier->filter($data));
$callDetails = $this->getRequest()->getParam('catDetails');
$dataRes = json_decode($data, true);
//echo "<pre>";print_r($callDetails);
$arrSupplierDetails = array();
$arrAgencyDetails = array();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
if (!empty($dataRes)) {
$supplierSysId = $sid;
if ($supplierSysId > 0) {
$objSupplier = new Travel_Model_TblSupplier();
$arrSupplierDetails = $objSupplier->getSupplierById($supplierSysId);
}
if (!empty($dataRes)) {
$agencyId = $sessionLogin_user->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$arrAgencyDetails = $objAgency->getUserDataByAgency($agencyId);
}
//$inventSysId=$dataRes['InvnItemSysId'];
//$hotelid=$dataRes['hotelId'];
}
//echo "<pre>";print_r($dataRes);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
// render view
//echo $this->getDec("9a68e8afc873c650966737e18378607d");
//die;
$html->assign('type', 'supplierCustomerEmailPreviewForm');
$html->assign('arrSupplierDetails', $arrSupplierDetails);
$html->assign('data', $dataRes);
$html->assign('agentDetails', $sessionLogin_user);
$html->assign('agencyDetails', $arrAgencyDetails);
$html->assign('callDetails', $callDetails);
$bodyText = $html->render('email-template.phtml');
//end of send email to customer
$msg = "success";
echo json_encode(array('status' => $msg, 'bodyText' => $bodyText));
}
public function getCustomerDetailByEmailidAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$email = $this->_request->getParam('emailID');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$customerDetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail($email);
if ($customerDetails) {
$status = 'success';
} else {
$status = 'failure';
}
$detail['status'] = $status;
//$detail['customerDetails']=$customerDetails;
$detail['Details'] = $customerDetails;
echo json_encode($detail);
}
public function customerViewToDoDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$todoId = $this->getRequest()->getParam('tid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tid'))) : '';
if (isset($todoId) && !empty($todoId)) {
$getCustomerTODO = $this->_crmcustomerObj->GetCustomerToDoByID($CRMCustSysId, $todoId);
$AgencySysId = $this->intLoggedinUserAgencySysId;
//echo "<pre>"; print_r($getCustomerTODO); die;
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'viewCustomerToDo';
$this->view->id = $todoId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->data = $getCustomerTODO;
$this->render('ajax-html');
}
}
public function listachievecustomerAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$roleID = $sessionLogin_user->UserRole;
$getData = array();
//echo "<pre>";print_r($_SESSION);die;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
//print_r($getRoleDetail['IsAdmin']);die;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($agencysysID);
if ($getRoleDetail['IsAdmin'] == true) {
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetArchieveGtxCustomer($getData);
} else {
$getData['AgencySysId'] = $agencysysID;
$getCustomerList = $this->_crmagencyleadaccountObj->GetArchieveGtxCustomer($getData);
}
} else {
$getData['AgencySysId'] = $agencysysID;
$leadSourcesIds = array();
$leadSourceExplodedRes = '';
$getCustomerList = array();
if (!empty($getleadSource)) {
foreach ($getleadSource as $k => $v) {
$leadSourcesIds[] = $v['LeadSourceSysId'];
}
$leadSourceExplodedRes = implode(",", $leadSourcesIds);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetArchieveGtxCustomer($getData);
} else {
$getCustomerList = $this->_crmagencyleadaccountObj->GetArchieveGtxCustomer($getData);
}
}
//print_r($leadSourceExplodedRes);die;
}
//print_r($getleadSource);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getCustomerList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
//echo "<pre>";print_r($agencyUser);die;
$this->view->leadStageList = $getStageList;
$this->view->leadSourceList = $getleadSource;
$this->view->agencyUser = $agencyUser;
$this->view->actionName = $this->getRequest()->getActionName();
}
public function gtxcustomerArchieveAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$agentID = $sessionLogin_user->intLoggedinUserId;
$AgencyCRMLeadSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid')));
$title = '';
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$getLeadDetailById = $this->_crmagencyleadaccountObj->getAgentIdFromLeadId($AgencyCRMLeadSysId);
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
if ($getLeadDetailById['AssignUserSysId'] == 0) {
$userArray = array(
'AssignUserSysId' => $agentID,
'IsMarkForDelete' => 1,
'UpdatedDate' => $date,
);
} else {
$userArray = array(
'IsMarkForDelete' => 1,
'UpdatedDate' => $date,
);
}
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$msg = "success";
$title = 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
//function used for update customer data created by Er Amit Kumar Dubey on 15 february 2017 at 11:59 AM
public function updateCustomerSenddataAction() {
// error_reporting(E_ALL);
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
if (isset($passexpiry) && !empty($passexpiry)) {
$passexpiry = explode('/', $passexpiry);
$passexpiry = $passexpiry[2] . "-" . $passexpiry[1] . "-" . $passexpiry[0];
}
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
if (isset($custanniversary) && !empty($custanniversary)) {
$custanniversary = explode('/', $custanniversary);
$custanniversary = $custanniversary[2] . "-" . $custanniversary[1] . "-" . $custanniversary[0];
}
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
if (isset($custdob) && !empty($custdob)) {
$custdob = explode('/', $custdob);
$custdob = $custdob[2] . "-" . $custdob[1] . "-" . $custdob[0];
}
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$changeEmailOrMobile = $this->_HtmlPurifier->filter($this->_request->getParam('changeEmailOrMobile'));
$updatedate = date('Y-m-d H:i:s');
$fname = $this->_HtmlPurifier->filter($this->_request->getParam('fname'));
$lname = $this->_HtmlPurifier->filter($this->_request->getParam('lname'));
$customerEmail = $this->_HtmlPurifier->filter($this->_request->getParam('customerEmail'));
$mobilenumber = $this->_HtmlPurifier->filter($this->_request->getParam('mobilenumber'));
$countrycode = $this->_HtmlPurifier->filter($this->_request->getParam('countrycode'));
$city = $this->_HtmlPurifier->filter($this->_request->getParam('city'));
$state = $this->_HtmlPurifier->filter($this->_request->getParam('state'));
$country = $this->_HtmlPurifier->filter($this->_request->getParam('country'));
$salution = $this->_HtmlPurifier->filter($this->_request->getParam('salution'));
$leadsource = $this->_HtmlPurifier->filter($this->_request->getParam('leadsource'));
$IsMarried = $this->_HtmlPurifier->filter($this->_request->getParam('IsMarried'));
$StateOrZoneSysId = $this->_HtmlPurifier->filter($this->_request->getParam('StateOrZoneSysId'));
$address = $this->_HtmlPurifier->filter($this->_request->getParam('address'));
$PinCode = $this->_HtmlPurifier->filter($this->_request->getParam('PinCode'));
$ContactNo1 = $this->_HtmlPurifier->filter($this->_request->getParam('ContactNo1'));
$SecondaryEmail = $this->_HtmlPurifier->filter($this->_request->getParam('SecondaryEmail'));
$IsB2BAgent = (NULL != $this->_request->getParam('IsB2BAgent')) ? $this->_HtmlPurifier->filter($this->_request->getParam('IsB2BAgent')) : 0;
$GstNumber = $this->_HtmlPurifier->filter($this->_request->getParam('GstNumber'));
$PanCard = $this->_HtmlPurifier->filter($this->_request->getParam('PanCard'));
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$ARR_SALUTION = unserialize(ARR_SALUTION);
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$TblLeadSourceModel = new Travel_Model_TblLeadSource();
if (!is_numeric($leadsource) && !empty($leadsource)) {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = $intLeadSourceSysId[0]['LeadSourceSysId'];
} else {
$leadSourceArr = $TblLeadSourceModel->GetLeadSourceById((int) $leadsource, $AgencySysId);
}
$detail = array();
$Noofkids = $this->_HtmlPurifier->filter($this->_request->getParam('Noofkids'));
$FoodPreference = $this->_request->getParam('FoodPreference');
$SpecialRequest = $this->_request->getParam('SpecialRequest');
$SpecialRequestArr = array();
if (isset($SpecialRequest) && !empty($SpecialRequest)) {
foreach ($SpecialRequest as $spKey => $spVal) {
if (isset($spVal) && !empty($spVal)) {
$checkCustomerTag = $this->_crmcustomerObj->checkExistCustomerTag(trim($spVal), $AgencySysId);
$SpecialRequestArr[] = $spVal;
}
}
}
// echo "<pre>";print_r($SpecialRequest);die;
$CompanyName = ($this->_request->getParam('CompanyName')) ? $this->_request->getParam('CompanyName') : '';
$VisaCountryId = $this->_request->getParam('VisaCountryId');
$VisaExpiryDate = $this->_request->getParam('VisaExpiryDate');
$this->_crmagencyleadaccountObj->deleteCustomerVisaDetail(array('IsActive' => 0, 'IsMarkForDelete' => 1), array('AgencySysId =?' => $AgencySysId, 'CustomerSysId =?' => $CustomerSysId));
if (!empty($VisaCountryId)) {
foreach ($VisaCountryId as $vKey => $vVal) {
$VisaExpiryDate1 = isset($VisaExpiryDate[$vKey]) ? DateTime::createFromFormat('d/m/Y', $VisaExpiryDate[$vKey]) : '';
$updateCustomerVisaData = [
'AgencySysId' => $AgencySysId,
'CustomerSysId' => $CustomerSysId,
'VisaCountry' => $vVal,
'VisaExpiryDate' => ($VisaExpiryDate1 != '') ? $VisaExpiryDate1->format('Y-m-d') : '',
'IsActive' => 1,
'IsMarkForDelete' => 0,
];
//echo "<pre>";print_r($updateCustomerVisaData);die;
$customerVisaData[] = $this->_crmagencyleadaccountObj->updateCustomerVisaDetail($updateCustomerVisaData);
}
}
if (isset($VisaExpiryDate[0]) && !empty($VisaExpiryDate[0])) {
$VisaExpiryDate = explode('/', $VisaExpiryDate[0]);
$VisaExpiryDate = $VisaExpiryDate[2] . "-" . $VisaExpiryDate[1] . "-" . $VisaExpiryDate[0];
}
$Remarks = ($this->_request->getParam('Remarks')) ? $this->_request->getParam('Remarks') : '';
$CustomerCategory = ($this->_request->getParam('CustomerCategory')) ? $this->_request->getParam('CustomerCategory') : '';
$SeatPreference = ($this->_request->getParam('SeatPreference')) ? $this->_request->getParam('SeatPreference') : '';
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$agencyCustomerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
//echo "<pre>";print_r($agencyCustomerDetails['IsB2BAgent']);die;
if ($agencyCustomerDetails['IsB2BAgent'] == 1) {
$AgencySysId = $agencyCustomerDetails['AgencySysId'];
}
if ($changeEmailOrMobile == 0) {
$agencyuserArray = array(
// 'AgencySysId' => $AgencySysId,
'Title' => $salution,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city,
'StateOrZoneSysId' => !empty($StateOrZoneSysId) ? $StateOrZoneSysId : 0,
'CountrySysId' => $country,
'Address' => !empty($address) ? $address : '',
'PinCode' => !empty($PinCode) ? $PinCode : '0',
'ContactNo1' => !empty($ContactNo1) ? $ContactNo1 : '',
'SecondaryEmail' => !empty($SecondaryEmail) ? $SecondaryEmail : '',
'IsEmployee' => '0',
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'countrycode' => $countrycode,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'IsMarried' => $IsMarried,
'UpdateDate' => $updatedate,
'Noofkids' => $Noofkids,
'FoodPreference' => !empty($FoodPreference) ? implode(',', $FoodPreference) : '',
'CustomerCompanyName' => $CompanyName,
'VisaCountry' => 0,
'VisaExpiryDate' => '',
'Remarks' => $Remarks,
// 'LeadSourceSysId' => $leadsource,
'CustomerCategory' => $CustomerCategory,
'SeatPreference' => $SeatPreference,
'SpecialRequest' => !empty($SpecialRequestArr) ? implode(',', $SpecialRequestArr) : '',
'GstNumber' => $GstNumber,
'PanCard' => $PanCard,
);
if (!empty($leadsource)) {
$agencyuserArray['LeadSourceSysId'] = $leadsource;
}
// echo "<pre>";print_r($leadSourceArr);die;
$where = "CRMCustSysId = " . $CRMCustSysId . " AND AgencySysId=" . $AgencySysId . " AND CustomerSysId=" . $CustomerSysId . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
$agencyCRMLeadArray = array(
// 'LeadSourceSysId' => $leadsource,
'UpdatedDate' => $updatedate
);
if (!empty($leadsource)) {
$agencyCRMLeadArray['LeadSourceSysId'] = $leadsource;
}
$whereCRMLead = "AgencyCRMLeadSysId = " . $agencyCustomerDetails['AgencyCRMLeadSysId'] . " AND AgencySysId=" . $AgencySysId . " ";
$agencyCRMLeadData = $this->_crmagencyleadaccountObj->UpdateCustomer($agencyCRMLeadArray, $whereCRMLead);
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($CustomerSysId) && !empty($CustomerSysId)) ? ($CustomerSysId) : '';
$detail['salutation'] = (isset($ARR_SALUTION[$salution]) && !empty($ARR_SALUTION[$salution])) ? $ARR_SALUTION[$salution] : '';
$detail['fname'] = (isset($fname) && !empty($fname)) ? ($fname) : '';
$detail['lname'] = (isset($lname) && !empty($lname)) ? ($lname) : '';
$detail['leadSourceTitle'] = (isset($leadSourceArr['Title']) && !empty($leadSourceArr['Title'])) ? ($leadSourceArr['Title']) : '';
$detail['UpdateDate'] = date('d-M-y');
} else {
$existMobileCustomer = array();
$existEmailCustomer = $this->_crmcustomerObj->ChkEmailAgencyCustomerUpdate($customerEmail, $AgencySysId, $CustomerSysId, 1, $IsB2BAgent);
if (isset($mobilenumber) && !empty($mobilenumber)) {
$existMobileCustomer = $this->_crmcustomerObj->ChkMobileAgencyCustomerUpdate($mobilenumber, $AgencySysId, $CustomerSysId, 1, $IsB2BAgent);
}
//echo count($existEmailCustomer)."/".count($existMobileCustomer);die;
if (empty($existEmailCustomer) && empty($existMobileCustomer)) {
$agencyuserArray = array(
// 'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Contacts' => $mobilenumber,
'countrycode' => $countrycode,
'Title' => $salution,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city,
// 'LeadSourceSysId' => $leadsource,
'StateOrZoneSysId' => !empty($StateOrZoneSysId) ? $StateOrZoneSysId : 0,
'CountrySysId' => $country,
'Address' => !empty($address) ? $address : '',
'PinCode' => !empty($PinCode) ? $PinCode : '0',
'ContactNo1' => !empty($ContactNo1) ? $ContactNo1 : '',
'SecondaryEmail' => !empty($SecondaryEmail) ? $SecondaryEmail : '',
'IsEmployee' => '0',
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'IsMarried' => $IsMarried,
'UpdateDate' => $updatedate,
'GstNumber' => $GstNumber,
'PanCard' => $PanCard,
);
if (!empty($leadsource)) {
$agencyuserArray['LeadSourceSysId'] = $leadsource;
}
//print_r($agencyuserArray);
$where = "CRMCustSysId = " . $CRMCustSysId . " AND AgencySysId=" . $AgencySysId . " AND CustomerSysId=" . $CustomerSysId . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
$agencyCRMLeadArray = array(
'UpdatedDate' => $updatedate
);
if (!empty($leadsource)) {
$agencyCRMLeadArray['LeadSourceSysId'] = $leadsource;
}
$whereCRMLead = "AgencyCRMLeadSysId = " . $agencyCustomerDetails['AgencyCRMLeadSysId'] . " AND AgencySysId=" . $AgencySysId . " ";
$agencyCRMLeadData = $this->_crmagencyleadaccountObj->UpdateCustomer($agencyCRMLeadArray, $whereCRMLead);
$AgencyUser = new Zend_Session_Namespace('AgencyUser');
$IsMaskingOnEmailAndMobile = $AgencyUser->user->IsMaskingOnEmailAndMobile;
$customHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$checkContact = ($IsMaskingOnEmailAndMobile == 1) ? trim($countrycode) . '-' . $customHelper->hidePhoneNumberDigit($mobilenumber, $IsMaskingOnEmailAndMobile) : trim($countrycode) . '-' . $mobilenumber;
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($CustomerSysId) && !empty($CustomerSysId)) ? $CustomerSysId : '';
$detail['salutation'] = (isset($ARR_SALUTION[$salution]) && !empty($ARR_SALUTION[$salution])) ? $ARR_SALUTION[$salution] : '';
$detail['fname'] = (isset($fname) && !empty($fname)) ? ($fname) : '';
$detail['lname'] = (isset($lname) && !empty($lname)) ? ($lname) : '';
$detail['Mobile'] = (isset($checkContact) && !empty($checkContact)) ? ($checkContact) : '';
$detail['leadSourceTitle'] = (isset($leadSourceArr['Title']) && !empty($leadSourceArr['Title'])) ? ($leadSourceArr['Title']) : '';
$detail['UpdateDate'] = date('d-M-y');
} else {
if (!empty($existEmailCustomer) && empty($existMobileCustomer)) {
$detail['msg'] = 'Email already exist';
} elseif (empty($existEmailCustomer) && !empty($existMobileCustomer)) {
$detail['msg'] = 'Mobile already exist';
} elseif (!empty($existEmailCustomer) && !empty($existMobileCustomer)) {
$detail['msg'] = 'Email or Mobile already exist';
}
// if (count($existEmailCustomer) != 0 && count($existMobileCustomer) == 0) {
// $detail['msg'] = 'Email already exist';
// }
// if (count($existEmailCustomer) == 0 && count($existMobileCustomer) != 0) {
// $detail['msg'] = 'Mobile already exist';
// }
// if (count($existEmailCustomer) != 0 && count($existMobileCustomer) != 0) {
// $detail['msg'] = 'Email or Mobile already exist';
// }
$detail['status'] = 'failed';
}
}
}
echo json_encode($detail);
}
public function getLeadCustomerDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$email = $this->_HtmlPurifier->filter($this->_request->getParam('emailID'));
$mobilenum = $this->_HtmlPurifier->filter($this->_request->getParam('mobilenum'));
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$IsB2BAgent = $this->_request->getParam('IsB2BAgent') ? $this->_HtmlPurifier->filter($this->_request->getParam('IsB2BAgent')) : '';
$aId = $this->_request->getParam('aId') ? $this->_HtmlPurifier->filter($this->_request->getParam('aId')) : '';
$post = $this->getRequest()->getPost();
//echo "<pre>";print_r($aId);die;
//echo $mobilenum;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (isset($email) && !empty($email)) {
if ($aId != '' || $IsB2BAgent == 1) {
//$aId=$aId?$aId:$AgencySysId;
if ($aId != '') {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponseUpdateB2B($email, $aId);
} else {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponseB2B($email, $AgencySysId);
}
} else {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponseUpdate($email, $AgencySysId, $IsB2BAgent);
}
}
if (isset($mobilenum) && !empty($mobilenum)) {
if ($aId != '' || $IsB2BAgent == 1) {
if ($aId != '') {
$customerDetails = $this->_crmcustomerObj->ChkMobileWithResponseB2B($mobilenum, $aId, '', $CRMCustSysId);
} else {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgencyB2B($mobilenum, $AgencySysId);
}
} else {
$customerDetails = $this->_crmcustomerObj->ChkMobileWithResponse($mobilenum, $AgencySysId, '', $CRMCustSysId, $IsB2BAgent);
}
}
if ($customerDetails) {
$status = 'success';
} else {
$status = 'failure';
}
// echo "<pre>";print_r($mobilenum);die;
$detail['status'] = $status;
//$detail['customerDetails']=$customerDetails;
$detail['CustomerSysId'] = (isset($customerDetails['CustomerSysId']) && !empty($customerDetails['CustomerSysId'])) ? base64_encode($customerDetails['CustomerSysId']) : '';
$detail['CRMCustSysId'] = (isset($customerDetails['CRMCustSysId']) && !empty($customerDetails['CRMCustSysId'])) ? base64_encode($customerDetails['CRMCustSysId']) : '';
echo json_encode($detail);
}
//for only add new customer with all validation
public function addNewAgencyCustomerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$updatedate = date('Y-m-d H:i:s');
$editID = $this->_request->getParam('editID');
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$countrycode = $this->_request->getParam('countrycode');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
$salution = $this->_request->getParam('salution');
$leadsource = $this->_request->getParam('leadsource');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (!is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
;
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
$detail = [];
if ($customerEmail != '') {
if (isset($customerEmail) && !empty($customerEmail)) {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponse($customerEmail, $AgencySysId);
}
if (isset($mobilenumber) && !empty($mobilenumber)) {
$customerDetails = $this->_crmcustomerObj->ChkMobileWithResponse($mobilenumber, $AgencySysId, '', '');
}
// echo"<pre>";print_r($customerDetails);die('data');
if (empty($customerDetails)) {
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => 1,
'PrimaryContactNumber' => '',
'FullName' => $fname . ' ' . @$lname,
'FirstName' => $fname,
'LastName' => $lname ? $lname : '',
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
} else {
$CRMCustSysId = $customerDetails['CRMCustSysId'];
}
//create new lead agency account
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => $salution ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber ? $mobilenumber : '',
'countrycode' => $countrycode ? $countrycode : '',
'FullName' => $fname . ' ' . $lname,
'FirstName' => $fname ? $fname : '',
'LastName' => $lname ? $lname : '',
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $this->intLoggedinUserId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => $customerEmail,
'Title' => $salution ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city ? $city : '',
'StateOrZoneSysId' => 0,
'CountrySysId' => $country ? $country : '',
'IsEmployee' => '0',
'Contacts' => $mobilenumber ? $mobilenumber : '',
'countrycode' => $countrycode ? $countrycode : '',
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname ? $fname : '',
'LastName' => $lname ? $lname : '',
'Relation' => $custrelation ? $custrelation : '',
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob ? $custdob : '',
'MarriageAnniversary' => $custanniversary ? $custanniversary : '',
'CreatedByUserSysId' => $this->intLoggedinUserId,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? base64_encode($agencyCustomerData) : '';
}
//$detail['customerDetails']=$customerDetails;
echo json_encode($detail);
}
public function savetododatadashboardAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$post = $this->getRequest()->getPost();
$todosubject = $this->_request->getParam('todosubject') ? $this->_HtmlPurifier->filter($this->_request->getParam('todosubject')) : '';
$todostartdate = $this->_request->getParam('todostartdate') ? $this->_request->getParam('todostartdate') : '';
$todoenddate = $this->_request->getParam('todoenddate') ? $this->_request->getParam('todoenddate') : '';
$todostartdatetime = $this->_request->getParam('todostartdatetime') ? $this->_request->getParam('todostartdatetime') : '';
$contact = $this->_request->getParam('contact') ? $this->_HtmlPurifier->filter($this->_request->getParam('contact')) : '';
$custsysID = $this->_request->getParam('custsysID') ? (int) $this->_request->getParam('custsysID') : 0;
$relatedto = $this->_request->getParam('relatedto') ? $this->_HtmlPurifier->filter($this->_request->getParam('relatedto')) : '';
$assignedto = $this->_request->getParam('assignedtoId') ? $this->_HtmlPurifier->filter($this->_request->getParam('assignedtoId')) : '';
$details = $this->_request->getParam('details') ? $this->_HtmlPurifier->filter($this->_request->getParam('details')) : '';
$markasdone = $this->_request->getParam('markasdone') ? $this->_HtmlPurifier->filter($this->_request->getParam('markasdone')) : '';
$followupchecked = $this->_request->getParam('followupchecked') ? $this->_HtmlPurifier->filter($this->_request->getParam('followupchecked')) : '';
$todoreminder = $this->_request->getParam('todoreminder') ? $this->_HtmlPurifier->filter($this->_request->getParam('todoreminder')) : '';
$reminderinvalue = $this->_request->getParam('reminderinvalue') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderinvalue')) : '';
$reminderintype = $this->_request->getParam('reminderintype') ? $this->_HtmlPurifier->filter($this->_request->getParam('reminderintype')) : '';
if ($reminderintype == 'hour') {
$todoreminder = $reminderinvalue * 60;
} else if ($reminderintype == 'day') {
$todoreminder = $reminderinvalue * 60 * 24;
} else {
$todoreminder = $reminderinvalue;
}
$explodetodostartdateAll = explode(' ', $todostartdate);
$explodetodostartdate = explode('/', $explodetodostartdateAll[0]);
//echo date('Y-m-d H:i:s',strtotime($todostartdate));
//echo "<pre>";print_r($explodetodostartdate);die;
$startdate = $explodetodostartdate[2] . '-' . $explodetodostartdate[1] . '-' . $explodetodostartdate[0];
$explodetodoenddateAll = explode(' ', $todoenddate);
$explodetodoenddate = explode('/', $explodetodoenddateAll[0]);
$enddate = $explodetodoenddate[2] . '-' . $explodetodoenddate[1] . '-' . $explodetodoenddate[0] . " " . $explodetodoenddateAll[1];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$curr_date = date('Y-m-d');
$agentID = $sessionLogin_user->intLoggedinUserId;
$currentdate = date('Y-m-d');
$reminderday = $post['reminderday'];
if ($reminderday != 4) {
$startdate = date('Y-m-d', strtotime($currentdate . " +" . $reminderday . " days"));
}
$data = array(
'Subject' => $todosubject,
'StartDateTime' => trim($startdate . ' ' . $todostartdatetime),
'EndDateTime' => trim($startdate . ' ' . $todostartdatetime),
'RelatedTo' => $relatedto,
'IsCompleted' => (int) $markasdone,
'Location' => 0,
'Type' => 0,
'Description' => addslashes($details),
'CustSysId' => (int) $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'CreateDate' => date('Y-m-d H:i:s'),
'UpdateDate' => date('Y-m-d H:i:s'),
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
//echo "<pre>";print_r($data);die;
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
//update customer
$date = date('Y-m-d H:i:s');
$userQueryArray = array(
'UpdateDate' => $date,
);
if (!empty($custsysID)) {
$whereQuery = "CustomerSysId = " . $custsysID . "";
$updatecustomer = $this->_agencycustomerObj->UpdateAgencyCustomer($userQueryArray, $whereQuery);
}
#end
if ($lastID) {
$response = array('success' => true, 'msg' => 'Sucess');
echo json_encode($response);
exit;
}
}
public function draftbyoAction() {
$objPackage = new Travel_Model_TblPackage();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$pkgtitle = $this->getRequest()->getParam('pkgtitle') ? $this->getRequest()->getParam('pkgtitle') : '';
$emailid = $this->getRequest()->getParam('emailid') ? $this->getRequest()->getParam('emailid') : '';
if (!empty($emailid)) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$crmcustID = $objPackage->GetCustomerIdByEmail($emailid, $AgencySysId);
} else {
$crmcustID = '';
}
$search_going_from = $this->getRequest()->getParam('search_going_from'); /* Delhi */
$search_going_to = $this->getRequest()->getParam('search_going_to'); /* Mumbai */
if (!empty($search_going_from)) {
$search_going_from_data = explode("__", $search_going_from);
$going_from_city_id = $search_going_from_data[0];
} else {
$going_from_city_id = '';
}
if (!empty($search_going_to)) {
$search_going_to_data = explode("__", $search_going_to);
$going_to_city_id = $search_going_to_data[0];
} else {
$going_to_city_id = '';
}
$getbyopckageist = $objPackage->GetDraftBYOPkgList($pkgtitle, $crmcustID, $going_from_city_id, $going_to_city_id, $agencySysId);
$this->view->byopkglist = $getbyopckageist;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getbyopckageist);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
}
public function byopackageAction() {
$objPackage = new Travel_Model_TblPackage();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$pkgtitle = $this->getRequest()->getParam('pkgtitle') ? $this->getRequest()->getParam('pkgtitle') : '';
$emailid = $this->getRequest()->getParam('emailid') ? $this->getRequest()->getParam('emailid') : '';
if (!empty($emailid)) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$crmcustID = $objPackage->GetCustomerIdByEmail($emailid, $AgencySysId);
} else {
$crmcustID = '';
}
$search_going_from = $this->getRequest()->getParam('search_going_from'); /* Delhi */
$search_going_to = $this->getRequest()->getParam('search_going_to'); /* Mumbai */
if (!empty($search_going_from)) {
$search_going_from_data = explode("__", $search_going_from);
$going_from_city_id = $search_going_from_data[0];
} else {
$going_from_city_id = '';
}
if (!empty($search_going_to)) {
$search_going_to_data = explode("__", $search_going_to);
$going_to_city_id = $search_going_to_data[0];
} else {
$going_to_city_id = '';
}
$getbyopckageist = $objPackage->GetBYOPkgList($pkgtitle, $crmcustID, $going_from_city_id, $going_to_city_id, $agencySysId);
$this->view->byopkglist = $getbyopckageist;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getbyopckageist);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
}
public function CustomerProposalCount($CustomerSysId) {
//function used for display no of proposal count in middle tab for customer partial
$getLeadlist = array();
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$AgentSysId = $this->intLoggedinUserId;
if ($this->checkIsAdmin() == true) {
$AgentSysId = '';
}
$AgentSysId = '';
$getdata = array('IsDraft' => 1);
$getLeadlist = $this->_crmcusttravelplan->GetAgencyLeadListCount($this->intLoggedinUserAgencySysId, $AgentSysId, $getdata, $CustomerSysId);
}
return isset($getLeadlist[0]['TPSysId']) ? $getLeadlist[0]['TPSysId'] : 0;
}
public function checkIsAdmin() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
if (isset($getRoleDetail['IsAdmin']) && !empty($getRoleDetail['IsAdmin'])) {
return $getRoleDetail['IsAdmin'];
} else {
return false;
}
}
//add gtx customer created by Er Amit Kumar Dubey on 3 april 2017 at 4:47 PM
public function addgtxcustomerdataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
$leadsource = $this->_HtmlPurifier->filter($this->_request->getParam('leadsource'));
$IsCreateNewGtxQuery = $this->_HtmlPurifier->filter($this->_request->getParam('IsCreateNewGtxQuery'));
if (isset($passexpiry) && !empty($passexpiry)) {
$passexpiry = explode('/', $passexpiry);
$passexpiry = $passexpiry[2] . "-" . $passexpiry[1] . "-" . $passexpiry[0];
}
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
if (isset($custanniversary) && !empty($custanniversary)) {
$custanniversary = explode('/', $custanniversary);
$custanniversary = $custanniversary[2] . "-" . $custanniversary[1] . "-" . $custanniversary[0];
}
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
if (isset($custdob) && !empty($custdob)) {
$custdob = explode('/', $custdob);
$custdob = $custdob[2] . "-" . $custdob[1] . "-" . $custdob[0];
}
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if (isset($leadsource) && is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$updatedate = date('Y-m-d H:i:s');
if ($source == "mainPage") {
echo $mobilenum = $this->_request->getParam('mobilenum');
echo $customername = $this->_request->getParam('customername');
echo $emailID = $this->_request->getParam('emailID');
exit;
} else {
$editID = base64_decode($this->_request->getParam('editID'));
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$countrycode = $this->_request->getParam('countrycode');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
$salution = $this->_request->getParam('salution');
$leadstage = trim($this->_request->getParam('leadStage', 53));
if (!empty($customerEmail)) {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerEmail), '');
}
if (!empty($CustomerSysId) && $CustomerSysId > 0) {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailByCustomerSysId(trim($CustomerSysId), $AgencySysId);
$leadstage = (isset($leadstage) && !empty($leadstage)) ? $leadstage : 53;
$CRMCustSysId = !empty($getcustomerdetails['CustomerSysId']) ? $getcustomerdetails['CustomerSysId'] : $CRMCustSysId;
$mobilenumber = !empty($getcustomerdetails['Contacts']) ? $getcustomerdetails['Contacts'] : $mobilenumber;
$countrycode = !empty($getcustomerdetails['countrycode']) ? trim($getcustomerdetails['countrycode']) : $countrycode;
$fname = !empty($getcustomerdetails['FirstName']) ? trim($getcustomerdetails['FirstName']) : $fname;
$lname = !empty($getcustomerdetails['FirstName']) ? trim($getcustomerdetails['LastName']) : $lname;
$salution = (isset($getcustomerdetails['Salutation']) && !empty($getcustomerdetails['Salutation'])) ? $getcustomerdetails['Salutation'] : $salution;
$customerEmail = (isset($getcustomerdetails['EmailId']) && !empty($getcustomerdetails['EmailId'])) ? $getcustomerdetails['EmailId'] : $customerEmail;
}
$customerRcord = $getcustomerdetails['CustomerSysId'];
$userUpdateArray = array(
//'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
//'PrimaryContactNumber' => $mobilenumber,
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
$detail = array();
// $this->_leadstageObj = new Travel_Model_TblLeadStage();
//$getStageList = $this->_leadstageObj->getLeadStage($AgencySysId,'NewLead');
// $getStageList = $this->_leadstageObj->getLeadStageSatus('New');
// $leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
//$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($customerEmail),$AgencySysId);
//code for customer check added by amit
/* if($CRMCustSysId=='' && empty($getcustomerdetails['CustomerSysId'])){
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution))?$salution:1,
'PrimaryContactNumber' => trim($mobilenumber),
'FullName' => $fname.' '.$lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
} else{
$CRMCustSysId=$getcustomerdetails['CRMCustSysId'];
} */
//if(empty($getcustomerdetails['CustomerSysId'])){
//create new lead agency account
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$AssignUserSysId = $this->intLoggedinUserId;
if ($getRoleDetail['IsAdmin'] == true) {
//$AssignUserSysId=0;
}
$getDefaultCampaignByAgencyId = $this->_agencyObj->getDefaultCampaignByAgencyId($AgencySysId);
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber,
'countrycode' => $countrycode,
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $AssignUserSysId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0',
'CampaignSysId' => (int) $getDefaultCampaignByAgencyId
);
// echo"<pre>";print_r($userLeadArray);die('dd');
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
//}
$detail['status'] = 'success';
$detail['mobilenumber'] = trim($mobilenumber);
$detail['countrycode'] = trim($countrycode);
$detail['fname'] = trim($fname);
$detail['lname'] = trim($lname);
$detail['customerEmail'] = trim($customerEmail);
$detail['CustomerSysId'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? base64_encode($agencyCustomerData) : '';
$detail['CustomerSysIdNew'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? $agencyCustomerData : '';
//$detail['customerDetails']=$customerDetails;
echo json_encode($detail);
}
}
//function used for change customer status
public function changeCustomerStatusAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$uniqueId = $this->getRequest()->getParam('uid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('uid'))) : '';
$loopId = $this->getRequest()->getParam('loopId') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('loopId')) : '';
$status = 'failed';
$checkCustomerDetails = [];
$AgencySysId = $this->intLoggedinUserAgencySysId;
if (isset($uniqueId) && !empty($uniqueId)) {
$getCustomerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($uniqueId);
$CustomerEmailId = !empty($getCustomerDetails['EmailId']) ? trim($getCustomerDetails['EmailId']) : '';
$CustomerContacts = !empty($getCustomerDetails['Contacts']) ? trim($getCustomerDetails['Contacts']) : '';
if (!empty($CustomerEmailId) || $CustomerContacts) {
$checkCustomerDetails = $this->_crmcustomerObj->GetAllAgencyCustomerDetails($AgencySysId, $uniqueId, $CustomerEmailId, $CustomerContacts);
}
if (!empty($checkCustomerDetails) && ($getCustomerDetails['IsActive'] == 0) && ($checkCustomerDetails['IsActive'] == 1)) {
$statustext = "Deactivate";
$data = '';
$mCustomerSysId = $getCustomerDetails['CustomerSysId'];
$data2 = "<a href=\"javascript:void(0);\" onclick=\"return alertCustomerStatus('status_','linkclass_','" . base64_encode($getCustomerDetails['CustomerSysId']) . "'," . $loopId . ",'statusLink1_','statusLink2_');\" title=\"View\" data-placement=\"top\" title=\"View\" index=\"0\" class=\"statusIsActive$mCustomerSysId\"><i class=\"fa fa-eye view_text tooltipLink\"></i></a>";
$data = "<a href=\"javascript:void(0);\" onclick=\"return changeActiveDeactive('status_','linkclass_','" . base64_encode($getCustomerDetails['CustomerSysId']) . "'," . $loopId . ",'Deactive');\" title=\"" . $statustext . "\" class=\"tooltipLink glyphicon fa fa-times gtxsendemail view_text\"></a>";
echo json_encode(array('status' => false, 'msg' => ($getCustomerDetails['IsActive'] == 1) ? 'Active' : 'Deactive', 'data2' => $data2, 'data' => $data, 'Message' => 'Duplicate customer records found. Please resolve duplicates before activating. Only one customer record can be active at a time.'));
exit;
} else {
if (!empty($getCustomerDetails)) {
$where = "CustomerSysId = " . $uniqueId . " AND AgencySysId = " . $getCustomerDetails['AgencySysId'];
$arrayData = array(
'IsActive' => ($getCustomerDetails['IsActive'] == 1) ? 0 : 1,
'UpdateDate' => date('Y-m-d H:i:s'),
'SMTypeId' => 0
);
$updateCustomerId = $this->_agencycustomerObj->UpdateAgencyCustomer($arrayData, $where);
// $getCustomerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($uniqueId);
$status = 'success';
}
}
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'changeCustomerStatus';
$this->view->id = $uniqueId;
$statustext = ($getCustomerDetails['IsActive'] == 0) ? "Activate" : "Deactivate";
// echo $getCustomerDetails['IsActive'];
$data = '';
$mCustomerSysId = $getCustomerDetails['CustomerSysId'];
if ($getCustomerDetails['IsActive'] == 0) {
$CustomerSysId = base64_encode($getCustomerDetails['CustomerSysId']);
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim($CustomerSysId), 1);
$data2 = '<a href="/customer/customer-profile-desc/id/' . $CustomerSysId . '/code/' . $secureCode . '" class="statusIsActive' . $mCustomerSysId . '" index="1"><i class="fa fa-eye view_text tooltipLink" data-placement="top" title="View"></i></a>';
$data = "<a href=\"javascript:void(0);\" onclick=\"return changeActiveDeactive('status_','linkclass_','" . base64_encode($getCustomerDetails['CustomerSysId']) . "'," . $loopId . ",'Active');\" title=\"" . $statustext . "\" class=\"tooltipLink glyphicon glyphicon-ok-circle view_text gtxsendemail\"></a>";
} else {
$data2 = "<a href=\"javascript:void(0);\" onclick=\"return alertCustomerStatus('status_','linkclass_','" . base64_encode($getCustomerDetails['CustomerSysId']) . "'," . $loopId . ",'statusLink1_','statusLink2_');\" title=\"View\" data-placement=\"top\" title=\"View\" index=\"0\" class=\"statusIsActive$mCustomerSysId\"><i class=\"fa fa-eye view_text tooltipLink\"></i></a>";
$data = "<a href=\"javascript:void(0);\" onclick=\"return changeActiveDeactive('status_','linkclass_','" . base64_encode($getCustomerDetails['CustomerSysId']) . "'," . $loopId . ",'Deactive');\" title=\"" . $statustext . "\" class=\"tooltipLink glyphicon fa fa-times gtxsendemail view_text\"></a>";
}
echo json_encode(array('status' => $status, 'msg' => ($getCustomerDetails['IsActive'] == 0) ? 'Active' : 'Deactive', 'data2' => $data2, 'data' => $data));
}
}
public function checkCustomerStatus($CustomerSysId) {
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
if (count($getCustomerDetail) == 0) {
return false;
} else {
return true;
}
exit;
//end of flight search lead
}
}
public function customerMessageAction() {
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
if (isset($type) && !empty($type)) {
if ($type == 'status') {
$this->view->Message = "Your account deactivated.Please contact to administrator.";
}
}
}
public function updateTraveldateTravelerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$tpID = $getData['tpID'] ? $getData['tpID'] : '';
$roomlp = $getData['roomlp'] ? $getData['roomlp'] : '';
$DestinationPlaces = isset($getData['DestinationPlaces']) ? json_decode(base64_decode($getData['DestinationPlaces']), 1) : '';
if (isset($DestinationPlaces) && !empty($DestinationPlaces)) {
$cityIds = implode(',', array_keys($DestinationPlaces));
$cities = implode(',', array_values($DestinationPlaces));
}
//echo "<pre>";print_r($DestinationPlaces);
$trip_start_date = $getData['tripdate'];
$checkInExplode = explode("/", $trip_start_date);
$trip_start_date = $checkInExplode[2] . "-" . $checkInExplode[1] . "-" . $checkInExplode[0];
$pkgCheckInDate = $getData['pkgCheckInDate'];
$pkgCheckOutDate = $getData['pkgCheckOutDate'];
// if(trim($trip_start_date)==''){
// $checkInDate=$trip_start_date;
// $checkInExplode=explode("/",$checkInDate);
// $newCheckInDate=$checkInExplode[2]."-".$checkInExplode[1]."-".$checkInExplode[0];
// $checkOutDate=strtotime("+".intval($totalDays)." day",strtotime($newCheckInDate));
// }else{
// $checkInDate=date('d/m/Y',time());
// $checkInExplode=explode("/",$checkInDate);
// $newCheckInDate=$checkInExplode[2]."-".$checkInExplode[1]."-".$checkInExplode[0];
// $checkOutDate=strtotime("+".intval($totalDays)." day",strtotime($newCheckInDate));
// }
$totaladult = 0;
$totalchild = 0;
$totalinfant = 0;
//print_r($sessionPackageSearchData->searchData);
$roomjson = array();
for ($k = 1; $k <= $roomlp; $k++) {// customise room info array acc to api
$roomjson[$k]['Adult'] = $getData['adult_' . $k];
unset($getData['adult_' . $k]);
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $getData['adultcl_extrabed_' . $k . '_3'];
unset($getData['adultcl_extrabed_' . $k . '_3']);
}
$roomjson[$k]['Child'] = $getData['child_' . $k];
unset($getData['child_' . $k]);
$roomjson[$k]['Infant'] = $getData['infant_' . $k];
unset($getData['infant_' . $k]);
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $getData['child_age_' . $k . '_' . $j];
unset($getData['child_age_' . $k . '_' . $j]);
$roomjson[$k]['ChildBedType_' . $j] = $getData['child_extrabed_' . $k . '_' . $j];
unset($getData['child_extrabed_' . $k . '_' . $j]);
}
$roomjson[$k]['departuredate'] = $pkgCheckInDate;
$roomjson[$k]['returndate'] = $pkgCheckOutDate;
}
$where = "TPSysId = " . $tpID;
$updatetravelplan = array(
'RoomInfoJson' => json_encode($roomjson),
'CityIds' => $cityIds ? $cityIds : '',
'Cities' => $cities ? $cities : '',
'StartDate' => $trip_start_date
);
//print_r($updatetravelplan);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplan, $where);
echo 1;
exit;
}
}
//this function is used for update only single lead stage 'call back' created by Er Amit Kumar Dubey on 28 april 2017 at 3:59 PM;
public function gtxcustomerStageUpdateCallbackAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$AgencyCRMLeadSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid')));
$callbackFrom = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackFrom'));
$callbackreminder = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackreminder'));
$callbackreminderremarks = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackreminderremarks'));
$title = '';
$CustomerSysId = '';
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'LeadStageSysId' => $stageId,
'AssignUserSysId' => $AgentSysId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$getAgencyCustomerExist = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (!empty($getAgencyCustomerExist)) {
$CustomerSysId = $getAgencyCustomerExist['CustomerSysId'];
} else {
//insert new record
$getCustomerList = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($getCustomerList['EmailId']), $agencysysID);
//code for customer check added by amit
if (empty($getcustomerdetails['CustomerSysId'])) {
$userArray = array(
'EmailId' => trim($getCustomerList['EmailId']),
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($getCustomerList['PrimaryContactNumber']),
'FullName' => trim($getCustomerList['FullName']),
'FirstName' => trim($getCustomerList['FirstName']),
'LastName' => trim($getCustomerList['LastName']),
'ActiveDate' => $date,
'UpdatedDate' => $date,
'CreatedDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
}
if ((is_array($getAgencyCustomerExist) && count($getAgencyCustomerExist) == 0) && (is_array($getcustomerdetails) && count($getcustomerdetails) == 0)) {
$agencyuserArray = array(
'AgencySysId' => $agencysysID,
'CRMCustSysId' => $CRMCustSysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'EmailId' => trim($getCustomerList['EmailId']),
'Title' => $getCustomerList['Salutation'],
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => 0,
'StateOrZoneSysId' => 0,
'CountrySysId' => 0,
'IsEmployee' => '0',
'Contacts' => trim($getCustomerList['PrimaryContactNumber']),
'JoinDate' => $date,
'UserName' => trim($getCustomerList['FirstName']) . '' . trim($getCustomerList['LastName']),
'FirstName' => trim($getCustomerList['FirstName']),
'LastName' => trim($getCustomerList['LastName']),
'Relation' => '',
'PassportNo' => '',
'PassportExpiry' => '',
'DOB' => '',
'MarriageAnniversary' => '',
'RegisterDate' => $date,
'UpdateDate' => $date,
'IsApproved' => '1',
'IsActive' => '1',
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well created by Er amit kumar dubey on 16 dec 2016 at 1:01PM ########
$CustomerSysId = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
} else {
$CustomerSysId = isset($getAgencyCustomerExist['CustomerSysId']) ? $getAgencyCustomerExist['CustomerSysId'] : $getcustomerdetails['CustomerSysId'];
;
}
//#end of insert
}
$callbackFromExplodeAll = explode(' ', $callbackFrom);
$callbackFromExplode = explode('/', $callbackFromExplodeAll[0]);
$callbackFrom = $callbackFromExplode[2] . '-' . $callbackFromExplode[1] . '-' . $callbackFromExplode[0] . " " . $callbackFromExplodeAll[1];
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId;
$date = date('Y-m-d H:i:s');
$agentID = $sessionLogin_user->intLoggedinUserId;
$data = array(
'Subject' => 'New To Do For call Back',
'StartDateTime' => $callbackFrom,
'EndDateTime' => $callbackFrom,
'AgencySysId' => $agencysysID,
'RelatedTo' => '',
'IsCompleted' => '',
'Location' => 0,
'Description' => addslashes($callbackreminderremarks),
'CustSysId' => $CustomerSysId,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $agentID,
'RemindDuration' => $callbackreminder,
'Createdate' => $date,
'Updatedate' => $date,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
// only update in agency customer table
/* $agencyuserArray = array(
'UpdateDate'=>$date
);
$whereAgencyCustomer = " AgencySysId=".$agencysysID." AND CustomerSysId=".$CustomerSysId."";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray,$whereAgencyCustomer); */
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3, $stageId);
//print_r($getStageList);
$msg = "success";
$title = count($getStageList) > 0 ? $getStageList[0]['Details'] : 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
//function used for only assigned leads created by Er Amit Kumar Dubey on 1 may 2017 at 1:05 PM
public function listgtxassignedcustomerAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$roleID = $sessionLogin_user->UserRole;
$getData = array();
//echo "<pre>";print_r($_SESSION);die;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
//print_r($getRoleDetail['IsAdmin']);die;
//code for if logedin user click on assign user notification
$type = $this->getRequest()->getParam('type');
$uid = $this->getRequest()->getParam('uid');
if (isset($type) && isset($uid) && !empty($type) && !empty($uid)) {
$type = $this->_HtmlPurifier->filter($type);
$uid = $this->_HtmlPurifier->filter(base64_decode($uid));
if ($uid == $sessionLogin_user->intLoggedinUserId) {
$where = "UserSysId = " . $uid . " AND MsgType = 3 AND ModuleType = 1";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => '1',
'Accepted' => '1',
'IsActive' => '0',
'UpdateDate' => $date,
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$updatedUserInbox = $this->_agencyuserObj->updateNotification($userArray, $where);
}
}
//end of code for assign user notification
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($agencysysID);
if ($getRoleDetail['IsAdmin'] == true) {
$getData['AgencySysId'] = $agencysysID;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxAssignedCustomer($getData);
} else {
$getData['AgencySysId'] = $agencysysID;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxAssignedCustomer($getData);
}
}
//print_r($getleadSource);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getCustomerList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
//$getStageList = $this->_leadstageObj->GetAllStage($agencysysID);
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
//echo "<pre>";print_r($getStageList);die;
$this->view->leadStageList = $getStageList;
$this->view->leadSourceList = $getleadSource;
$this->view->agencyUser = $agencyUser;
$this->view->getRoleDetail = $getRoleDetail;
}
// function used for change customer owner for any customer created by Er Amit Kumar Dubey on 11 may 2017 at 12:15 PM
public function updateCustomerOwnerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgencyCRMLeadSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('ACLid')));
$AgencyUserId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('UserSysId'));
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId . " AND AgencySysId=" . $agencysysID . " ";
$date = date('Y-m-d H:i:s');
$userArray = array(
'AssignUserSysId' => $AgencyUserId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
// only update in agency customer table
$agencyCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (!empty($agencyCustomerDetails)) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$response = array('status' => 'success', 'msg' => 'Record Updated');
} else {
$response = array('status' => 'failed', 'msg' => 'Some thing went wrong.');
}
echo json_encode($response);
exit;
}
public function customerResponseAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$chatDetails = $this->_crmcusttravelplan->GetAllProposalsCustomerChat($AgencySysId, $AgentSysId);
$page = $this->_getParam('page', 1);
//echo "<pre>";print_r($listArr);
$paginator = Zend_Paginator::factory($chatDetails);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$res = array();
$listArr = array();
foreach ($paginator as $key) {
if (!in_array($key['TPSysId'], $res)) {
$listArr[] = $key;
}
$res[] = $key['TPSysId'];
}
$this->view->paginator = $paginator;
$this->view->paginator1 = $listArr;
$this->view->totalres = $paginator->getTotalItemCount();
}
public function leadBulkUploadAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
if ($this->getRequest()->isPost()) {
# start : code for image uploading
$excelFileName = $_FILES['bulkuploadbtn']['name'];
$ext = @substr($excelFileName, strrpos($excelFileName, '.'));
$excelFileNameNew = $excelFileName;
$upload = new Zend_File_Transfer_Adapter_Http();
$this->upload_path = 'public/upload/excel/';
$upload->setDestination($this->upload_path);
// $file = $upload->getFileName();
if (($ext == ".csv") || ($ext == ".xls") || ($ext == ".xlsx")) {
try {
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
echo $this->view->error_msg = $e->getMessage();
die;
}
# end : code for image uploading
$file = $this->upload_path . $excelFileNameNew;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$phpexcel_obj = new PHPExcel_Classes_Readexcel;
$finalData = $phpexcel_obj->importFromExcel($file);
$leadListArray = array();
$error = array();
$i = 0;
//print_r($finalData);die;
foreach ($finalData as $listArray) {
if (trim($listArray[0]) == '') {
$error[$i]['EMAILID'] = 'EmailId cannot be empty.' . "</br>";
}
if (trim($listArray[0]) != '' && !filter_var(trim($listArray[0]), FILTER_VALIDATE_EMAIL) === true) {
$error[$i]['EMAILID'] = 'please enter a valid email address.' . "</br>";
}
if (trim($listArray[1]) == '') {
$error[$i]['MOBILE'] = 'Mobile cannot be empty.' . "</br>";
}
if (trim($listArray[1]) != '' && (is_numeric(trim($listArray[1])) == false || strlen(trim($listArray[1])) != 10)) {
$error[$i]['MOBILE'] = 'Mobile not in correct format.' . "</br>";
}
if (trim($listArray[2]) == '') {
$error[$i]['FIRSTNAME'] = 'First Name cannot be empty.' . "</br>";
}
/* if(trim($listArray[3])==''){
$error[$i]['LASTNAME']='Last Name cannot be empty.'."</br>";
} */
if (trim($listArray[4]) == '') {
$error[$i]['SOURCE'] = 'Source cannot be empty.' . "</br>";
}
$leadSource = $this->_leadstageObj->GetLeadSourceById(trim($listArray[4]), $AgencySysId);
if (isset($listArray[0]) && trim($listArray[0]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponse(trim($listArray[0]), $AgencySysId);
if (isset($customerDetails['CustomerSysId'])) {
$error[$i]['EMAILID'] = 'EmailId Already exist.please try another' . "</br>";
}
}
if (isset($listArray[1]) && trim($listArray[1]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgency(trim($listArray[1]), $AgencySysId, '');
if ($customerDetails) {
$error[$i]['MOBILE'] = 'Mobile Already exist.please try another' . "</br>";
}
}
if (count($leadSource) == 0) {
$error[$i]['SOURCE'] = 'Source not exist . Source Id not matched with source listing.' . "</br>";
}
$leadListArray[$i]['ERROR'] = $error;
$leadListArray[$i]['EMAILID'] = stripslashes(trim($listArray[0]));
$leadListArray[$i]['MOBILE'] = stripslashes(trim($listArray[1]));
$leadListArray[$i]['FIRSTNAME'] = stripslashes(trim($listArray[2]));
$leadListArray[$i]['LASTNAME'] = stripslashes(trim($listArray[3]));
$leadListArray[$i]['SOURCE'] = stripslashes(trim($leadSource['Title']));
$leadListArray[$i]['SOURCEID'] = stripslashes(trim($listArray[4]));
unset($error[$i]);
$i++;
}
//echo "<pre>";print_r($leadListArray);die;
$this->view->leadList = $leadListArray;
}
}
$leadSouceList = $this->_leadstageObj->GetAllSouce($AgencySysId);
$this->view->leadSouceList = $leadSouceList;
}
public function downloadTemplateAction() {
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
if ($type == 'lead' && $AgentSysId != '' && $AgencySysId != '') {
$file = 'public/xlstemplate/sample_lead.xls';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Description: File Transfer");
@readfile($file);
die;
} else if ($type == 'b2blead' && $AgentSysId != '' && $AgencySysId != '') {
$file = 'public/xlstemplate/sample_b2b_lead.xls';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Description: File Transfer");
@readfile($file);
die;
} else {
echo "some error . please try after some time.";
}
}
public function leadBulkUploadDataAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
if ($this->getRequest()->isPost()) {
$bulkuploaddata = $this->getRequest()->getParam('bulkuploaddata');
if (isset($bulkuploaddata) && !empty($bulkuploaddata)) {
$bulkuploaddata = json_decode(base64_decode($bulkuploaddata), true);
if (!empty($bulkuploaddata)) {
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$updatedate = date('Y-m-d H:i:s');
$this->_leadstageObj = new Travel_Model_TblLeadStage();
//$getStageList = $this->_leadstageObj->getLeadStage($AgencySysId,'NewLead');
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
//$leadstage = (isset($getStageList[0]['LeadStageSysId']) && !empty($getStageList[0]['LeadStageSysId']))?$getStageList[0]['LeadStageSysId']:0;
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$AssignUserSysId = $this->intLoggedinUserId;
if ($getRoleDetail['IsAdmin'] == true) {
$AssignUserSysId = 0;
}
foreach ($bulkuploaddata as $list) {
$emailid = stripslashes(trim($list['EMAILID']));
$mobile = stripslashes(trim($list['MOBILE']));
$firstname = stripslashes(trim($list['FIRSTNAME']));
$lastname = stripslashes(trim($list['LASTNAME']));
$leadsource = stripslashes(trim($list['SOURCEID']));
//insert value in lead table
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $emailid,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => $mobile,
'FullName' => $firstname . ' ' . $lastname,
'FirstName' => trim($firstname),
'LastName' => trim($lastname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $AssignUserSysId, // update by sibo on demand of anshul
//'AssignUserSysId' => 0, //for unassigned lead. changes made by amit dubey by gaurav sir on 25 april 2018
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
}
}
$this->_redirect('/customer/lead');
exit;
}
}
}
public function agencyProfileDescAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$this->view->SearchData = "";
$SearchData = $this->getRequest()->getParam('SearchData');
if (isset($SearchData) && $SearchData != "") {
$this->view->SearchData = $this->getRequest()->getParam('SearchData');
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getPendingPaymentLeadList = $this->_crmcusttravelplan->GetPendingPaymentLeadList($CustomerSysId, $AgencySysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
//$getAllCustomerTODO = $this->_crmcustomerObj->GetAllCustomerToDo($CustomerSysId);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
//$cityListArray = $this->_objPkg->getCityList();
//echo "<pre>";print_r($netRemarkRes);die;
//$getLeadlist = $this->_crmcusttravelplan->GetAgencyLeadList($AgencySysId,$AgentSysId,'',$CustomerSysId,10);
$getBookedLeadlist = $this->_crmcusttravelplan->getPriceDetailByCustId($AgencySysId, $CustomerSysId);
$getProfileLeadlist = $this->_crmcusttravelplan->getProfileDataForCustId($AgencySysId, $CustomerSysId);
$objCustomerTrx = new Travel_Model_TblAgencyCustomerTrx();
$getTrxDetails = $objCustomerTrx->getTrxDetailByCustomerIdInsteedOfInvoice($AgencySysId, $CustomerSysId);
$getMiscTrxDetails = $objCustomerTrx->getMiscellaneousDetailByCustId($CustomerSysId);
$getCustomerVisaDetail = $this->_crmagencyleadaccountObj->getCustomerVisaDetail($AgencySysId, $CustomerSysId); //added for multiple customer visa detail 06-05-2020
//food preference masking decode
$resmasking = array();
$RoomInfoJson['Adult'] = 0;
$RoomInfoJson['Child'] = 0;
$RoomInfoJson['ChildAge'] = array();
$resPackTypeMasking = array();
$selectedCuisineList = '';
$selectedPackTypeList = '';
$selectedCuisineListArray = array();
$selectedhotelStartList = '';
$selectedtotalChild = '';
$resHotelPreference = array();
$totalChild = array();
$cuisineMask = 00000;
for ($i = 0; $i < count($getProfileLeadlist); $i++) {
if (isset($getProfileLeadlist[$i]['CuisineMask']) && !empty($getProfileLeadlist[$i]['CuisineMask']) && trim($getProfileLeadlist[$i]['CuisineMask']) != '') {
for ($f = 0; $f < strlen($getProfileLeadlist[$i]['CuisineMask']); $f++) {
if ($getProfileLeadlist[$i]['CuisineMask'][$f] == 1) {
$resmasking[$f] = 1;
} else {
if (!in_array($f, $resmasking) && isset($resmasking[$f]) && $resmasking[$f] != 1) {
$resmasking[$f] = 0;
}
}
}
}
if (isset($getProfileLeadlist[$i]['HotelPreference']) && !empty($getProfileLeadlist[$i]['HotelPreference']) && trim($getProfileLeadlist[$i]['HotelPreference']) != '') {
//$maskArray[]=$getLeadlist[$i]['CuisineMask'];
$resHotelPreference[] = explode(',', $getProfileLeadlist[$i]['HotelPreference']);
}
if (isset($getProfileLeadlist[$i]['RoomInfoJson']) && !empty($getProfileLeadlist[$i]['RoomInfoJson']) && trim($getProfileLeadlist[$i]['RoomInfoJson']) != '') {
$RoomInfoJson = json_decode($getProfileLeadlist[$i]['RoomInfoJson'], true);
//echo "<pre>";print_r($RoomInfoJson);
if (!empty($RoomInfoJson)) {
foreach ($RoomInfoJson as $key => $val) {
if (isset($val['Child']) && $val['Child'] > 0)
$totalChild[$val['Child']] = $val['Child'];
}
}
}
/* if(isset($getLeadlist[$i]['PackTypeMask']) && !empty($getLeadlist[$i]['PackTypeMask']) && trim($getLeadlist[$i]['PackTypeMask'])!=''){
$PackTypeMaskArray[]=$getLeadlist[$i]['PackTypeMask'];
for($f=0;$f<strlen($getLeadlist[$i]['PackTypeMask']);$f++){
$resPackTypeMasking[$f]=(($getLeadlist[$i]['PackTypeMask'][$f]==1) || (isset($resPackTypeMasking[$f]) && $resPackTypeMasking[$f]==1))?1:0;
}
} */
}
//echo "<pre>";print_r($resmasking);die;
if (!empty($resPackTypeMasking)) {
$packagePackTypeList = $packageThemeList;
$g = 1;
foreach ($packagePackTypeList as $res => $value) {
if ($resPackTypeMasking[$g] == 1) {
$selectedPackTypeList[] = trim(stripslashes($value['Title']));
}
$g++;
}
}
//print_r($selectedPackTypeList);die;
if (!empty($resmasking)) {
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
//echo "<pre>";print_r($packageFoodPreferenceList);die;
$g = 1;
foreach ($packageFoodPreferenceList as $res => $value) {
if (@$resmasking[$g] == 1) {
$selectedCuisineListArray[] = trim(stripslashes($value['Title']));
}
$g++;
}
}
if (isset($selectedPackTypeList) && is_array($selectedPackTypeList) && count($selectedPackTypeList) > 0 && !empty($selectedPackTypeList)) {
$selectedPackTypeList = implode(',', $selectedPackTypeList);
//$selectedPackTypeList=asort($selectedPackTypeList);
}
if (!empty($selectedCuisineListArray)) {
$selectedCuisineList = implode(',', $selectedCuisineListArray);
}
if (!empty($totalChild)) {
sort($totalChild);
$selectedtotalChild = implode(',', $totalChild);
}
if (!empty($resHotelPreference)) {
$j = 0;
foreach ($resHotelPreference as $hotelList) {
foreach ($hotelList as $hotelKey => $hotelValue) {
$hotelListArray[$hotelValue] = $hotelValue;
}
$j++;
}
sort($hotelListArray);
array_walk($hotelListArray, function (&$value, $key) {
if ($value == 6) {
$value = "Any";
}
$value = "$value" . " Star";
});
$selectedhotelStartList = implode(', ', $hotelListArray);
}
$resHotelPreference = (isset($hotelListArray) && count($hotelListArray) > 0) ? implode(',', $hotelListArray) : '';
$memberArrayList = $this->_crmcustomerObj->GetCustomerMembersById($AgencySysId, $CustomerSysId, '');
$spouse = 0;
if (!empty($memberArrayList)) {
foreach ($memberArrayList as $memberList) {
if ($memberList['Relation'] == 1) {
$spouse = $memberList['Relation'];
}
}
}
/* if(!empty($RoomInfoJson['ChildAge']) > 0){
$RoomInfoJson['ChildAge']=implode('-',$RoomInfoJson['ChildAge']);
} */
//#end of food preference masking decode
/* for($i=0;$i<count($getBookedLeadlist);$i++){
} */
//echo "<pre>";print_r($getTrxDetails);die;
$preferneceData['FOODPREFERENCE'] = $selectedCuisineList ? $selectedCuisineList : 'NA';
$preferneceData['HOTELPREFERENCE'] = $selectedhotelStartList ? $selectedhotelStartList : 'NA';
$preferneceData['THEMEPREFERENCE'] = $selectedPackTypeList ? $selectedPackTypeList : 'NA';
$preferneceData['MARITALSTATUS'] = $spouse == 1 ? 'Married' : 'Unmarried';
$preferneceData['KIDS'] = $selectedtotalChild;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
//$preferneceData['RoomInfoJson']=$RoomInfoJson?$RoomInfoJson:'NA';
$objPlaceType = new Travel_Model_TblPlaceType();
$cityCategoryListing = $objPlaceType->getPlaceTypeList();
//$cityListArray = array();
$this->view->preferneceData = $preferneceData;
$this->view->getBookedLeadlist = $getBookedLeadlist;
$this->view->getTrxDetails = $getTrxDetails;
$this->view->getMiscTrxDetails = $getMiscTrxDetails;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
// $this->view->cityListArray = $cityListArray;
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
//$airportlist = $this->_objAirport->getAirportListWithCountryCode();
//$this->view->sourceCity = $airportlist;
$this->view->getPendingPaymentLeadList = $getPendingPaymentLeadList;
$this->view->cityCategoryListing = $cityCategoryListing;
// $this->view->getLatestLeadList = $getLatestLeadList;
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->getleadSource = $getleadSource;
$this->view->getCustomerVisaDetail = $getCustomerVisaDetail;
$SpecialRequest = $this->_crmcustomerObj->getCustomerTags($AgencySysId);
$this->view->SpecialRequest = $SpecialRequest;
}
}
public function customerProfileDescAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$this->view->urlsource = $urlsource = $this->getRequest()->getParam('urlsource');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
$this->view->SearchData = "";
$SearchData = $this->getRequest()->getParam('SearchData');
if (isset($SearchData) && $SearchData != "") {
$this->view->SearchData = $this->getRequest()->getParam('SearchData');
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getPendingPaymentLeadList = $this->_crmcusttravelplan->GetPendingPaymentLeadList($CustomerSysId, $AgencySysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = !empty($getCustomerRemarkDetail['Remarks']) ? stripslashes($getCustomerRemarkDetail['Remarks']) : '';
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
//$getAllCustomerTODO = $this->_crmcustomerObj->GetAllCustomerToDo($CustomerSysId);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
//$cityListArray = $this->_objPkg->getCityList();
//echo "<pre>";print_r($netRemarkRes);die;
//$getLeadlist = $this->_crmcusttravelplan->GetAgencyLeadList($AgencySysId,$AgentSysId,'',$CustomerSysId,10);
$getBookedLeadlist = $this->_crmcusttravelplan->getPriceDetailByCustId($AgencySysId, $CustomerSysId);
$getProfileLeadlist = $this->_crmcusttravelplan->getProfileDataForCustId($AgencySysId, $CustomerSysId);
$objCustomerTrx = new Travel_Model_TblAgencyCustomerTrx();
$getTrxDetails = $objCustomerTrx->getTrxDetailByCustomerIdInsteedOfInvoice($AgencySysId, $CustomerSysId);
$getMiscTrxDetails = $objCustomerTrx->getMiscellaneousDetailByCustId($CustomerSysId);
$getCustomerVisaDetail = $this->_crmagencyleadaccountObj->getCustomerVisaDetail($AgencySysId, $CustomerSysId); //added for multiple customer visa detail 06-05-2020
//food preference masking decode
$resmasking = array();
$RoomInfoJson['Adult'] = 0;
$RoomInfoJson['Child'] = 0;
$RoomInfoJson['ChildAge'] = array();
$resPackTypeMasking = array();
$selectedCuisineList = '';
$selectedPackTypeList = '';
$selectedCuisineListArray = array();
$selectedhotelStartList = '';
$selectedtotalChild = '';
$resHotelPreference = array();
$totalChild = array();
$cuisineMask = 00000;
for ($i = 0; $i < count($getProfileLeadlist); $i++) {
if (isset($getProfileLeadlist[$i]['CuisineMask']) && !empty($getProfileLeadlist[$i]['CuisineMask']) && trim($getProfileLeadlist[$i]['CuisineMask']) != '') {
for ($f = 0; $f < strlen($getProfileLeadlist[$i]['CuisineMask']); $f++) {
if ($getProfileLeadlist[$i]['CuisineMask'][$f] == 1) {
$resmasking[$f] = 1;
} else {
if (!in_array($f, $resmasking) && isset($resmasking[$f]) && $resmasking[$f] != 1) {
$resmasking[$f] = 0;
}
}
}
}
if (isset($getProfileLeadlist[$i]['HotelPreference']) && !empty($getProfileLeadlist[$i]['HotelPreference']) && trim($getProfileLeadlist[$i]['HotelPreference']) != '') {
//$maskArray[]=$getLeadlist[$i]['CuisineMask'];
$resHotelPreference[] = explode(',', $getProfileLeadlist[$i]['HotelPreference']);
}
if (isset($getProfileLeadlist[$i]['RoomInfoJson']) && !empty($getProfileLeadlist[$i]['RoomInfoJson']) && trim($getProfileLeadlist[$i]['RoomInfoJson']) != '') {
$RoomInfoJson = json_decode($getProfileLeadlist[$i]['RoomInfoJson'], true);
//echo "<pre>";print_r($RoomInfoJson);
if (!empty($RoomInfoJson)) {
foreach ($RoomInfoJson as $key => $val) {
if (isset($val['Child']) && $val['Child'] > 0)
$totalChild[$val['Child']] = $val['Child'];
}
}
}
/* if(isset($getLeadlist[$i]['PackTypeMask']) && !empty($getLeadlist[$i]['PackTypeMask']) && trim($getLeadlist[$i]['PackTypeMask'])!=''){
$PackTypeMaskArray[]=$getLeadlist[$i]['PackTypeMask'];
for($f=0;$f<strlen($getLeadlist[$i]['PackTypeMask']);$f++){
$resPackTypeMasking[$f]=(($getLeadlist[$i]['PackTypeMask'][$f]==1) || (isset($resPackTypeMasking[$f]) && $resPackTypeMasking[$f]==1))?1:0;
}
} */
}
//echo "<pre>";print_r($resmasking);die;
if (!empty($resPackTypeMasking)) {
$packagePackTypeList = $packageThemeList;
$g = 1;
foreach ($packagePackTypeList as $res => $value) {
if ($resPackTypeMasking[$g] == 1) {
$selectedPackTypeList[] = trim(stripslashes($value['Title']));
}
$g++;
}
}
//print_r($selectedPackTypeList);die;
if (!empty($resmasking)) {
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
//echo "<pre>";print_r($packageFoodPreferenceList);die;
$g = 1;
foreach ($packageFoodPreferenceList as $res => $value) {
if (@$resmasking[$g] == 1) {
$selectedCuisineListArray[] = trim(stripslashes($value['Title']));
}
$g++;
}
}
if (isset($selectedPackTypeList) && is_array($selectedPackTypeList) && count($selectedPackTypeList) > 0 && !empty($selectedPackTypeList)) {
$selectedPackTypeList = implode(',', $selectedPackTypeList);
//$selectedPackTypeList=asort($selectedPackTypeList);
}
if (!empty($selectedCuisineListArray)) {
$selectedCuisineList = implode(',', $selectedCuisineListArray);
}
if (!empty($totalChild)) {
sort($totalChild);
$selectedtotalChild = implode(',', $totalChild);
}
if (!empty($resHotelPreference)) {
$j = 0;
foreach ($resHotelPreference as $hotelList) {
foreach ($hotelList as $hotelKey => $hotelValue) {
$hotelListArray[$hotelValue] = $hotelValue;
}
$j++;
}
sort($hotelListArray);
array_walk($hotelListArray, function (&$value, $key) {
if ($value == 6) {
$value = "Any";
}
$value = "$value" . " Star";
});
$selectedhotelStartList = implode(', ', $hotelListArray);
}
$resHotelPreference = (isset($hotelListArray) && count($hotelListArray) > 0) ? implode(',', $hotelListArray) : '';
$memberArrayList = $this->_crmcustomerObj->GetCustomerMembersById($AgencySysId, $CustomerSysId, '');
$spouse = 0;
if (!empty($memberArrayList)) {
foreach ($memberArrayList as $memberList) {
if ($memberList['Relation'] == 1) {
$spouse = $memberList['Relation'];
}
}
}
/* if(!empty($RoomInfoJson['ChildAge']) > 0){
$RoomInfoJson['ChildAge']=implode('-',$RoomInfoJson['ChildAge']);
} */
//#end of food preference masking decode
/* for($i=0;$i<count($getBookedLeadlist);$i++){
} */
//echo "<pre>";print_r($getTrxDetails);die;
$preferneceData['FOODPREFERENCE'] = $selectedCuisineList ? $selectedCuisineList : 'NA';
$preferneceData['HOTELPREFERENCE'] = $selectedhotelStartList ? $selectedhotelStartList : 'NA';
$preferneceData['THEMEPREFERENCE'] = $selectedPackTypeList ? $selectedPackTypeList : 'NA';
$preferneceData['MARITALSTATUS'] = $spouse == 1 ? 'Married' : 'Unmarried';
$preferneceData['KIDS'] = $selectedtotalChild;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
//$preferneceData['RoomInfoJson']=$RoomInfoJson?$RoomInfoJson:'NA';
$objPlaceType = new Travel_Model_TblPlaceType();
$objservice = new Travel_Model_TblInsurance();
$cityCategoryListing = $objPlaceType->getPlaceTypeList();
//$cityListArray = array();
$this->view->preferneceData = $preferneceData;
$this->view->getBookedLeadlist = $getBookedLeadlist;
$this->view->getTrxDetails = $getTrxDetails;
$this->view->getMiscTrxDetails = $getMiscTrxDetails;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
// $this->view->cityListArray = $cityListArray;
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
//$airportlist = $this->_objAirport->getAirportListWithCountryCode();
//$this->view->sourceCity = $airportlist;
$this->view->getPendingPaymentLeadList = $getPendingPaymentLeadList;
$this->view->cityCategoryListing = $cityCategoryListing;
// $this->view->getLatestLeadList = $getLatestLeadList;
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->getleadSource = $getleadSource;
$this->view->getCustomerVisaDetail = $getCustomerVisaDetail;
$SpecialRequest = $this->_crmcustomerObj->getCustomerTags($AgencySysId);
$this->view->SpecialRequest = $SpecialRequest;
$this->view->getService = $objservice->getService($AgencySysId);
}
}
public function savedynamicpkgproposalwithleadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
unset($getData['roomJson']);
$departureCity = isset($getData['departureCity']) ? $getData['departureCity'] : 0;
$TcsTaxSysId = isset($getData['TcsTaxSysId']) ? $getData['TcsTaxSysId'] : 0;
$pkgCheckInDate = $getData['pkgCheckInDate'];
$pkgCheckOutDate = $getData['pkgCheckOutDate'];
$roomlp = $getData['roomlp'] ? $getData['roomlp'] : '';
$roomjson = array();
for ($k = 1; $k <= $roomlp; $k++) {// customise room info array acc to api
$roomjson[$k]['Adult'] = $getData['adult_' . $k];
unset($getData['adult_' . $k]);
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $getData['adultcl_extrabed_' . $k . '_3'];
unset($getData['adultcl_extrabed_' . $k . '_3']);
}
$roomjson[$k]['Child'] = $getData['child_' . $k];
unset($getData['child_' . $k]);
$roomjson[$k]['Infant'] = $getData['infant_' . $k];
unset($getData['infant_' . $k]);
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $getData['child_age_' . $k . '_' . $j];
unset($getData['child_age_' . $k . '_' . $j]);
$roomjson[$k]['ChildBedType_' . $j] = $getData['child_extrabed_' . $k . '_' . $j];
unset($getData['child_extrabed_' . $k . '_' . $j]);
}
$roomjson[$k]['departuredate'] = $pkgCheckInDate;
$roomjson[$k]['returndate'] = $pkgCheckOutDate;
}
$roomsArray = Zend_Json::encode($roomjson);
$getData['roomjson'] = $roomsArray;
$getData['AgencySysId'] = $this->intLoggedinUserAgencySysId;
$getData['AgentSysId'] = $this->intLoggedinUserId;
$getData['FirstName'] = $getData['custname'];
$getData['Email'] = $getData['custemail'];
$getData['MobileNumber'] = $getData['custphone'];
$getData['FromDestinationId'] = $departureCity;
$aboutpackage = $getData['aboutpackage'] ? $getData['aboutpackage'] : '';
if (strlen($aboutpackage) > 4000) {
echo json_encode(array('status' => false, 'message' => 'Greeting Message Limit Exceed!!', 'res' => array('status' => false)));
exit;
}
$anarray = http_build_query($getData); // true indicates for associative array rather than an object
/* write log for requested data @pooja on 10 aug 2017 */
$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog($anarray . "\n");
$ch = curl_init($this->baseUrl . '/gtxwebservices/dynamic-query');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $anarray);
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
// SSL connection
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
// execute!
$responseC = curl_exec($ch);
// echo '<Pre>'; print_r($responseC); die;
/* write log for response data @pooja on 10 aug 2017 */
//$writeLogObj = new Payment_Model_Payment();
$writeLogObj->writeLog('B2B===' . $responseC . "\n");
// echo "<pre>";print_r($responseC);exit;
// print_r($responseC); die;
$responseArr = Zend_Json::Decode($responseC);
// close the connection, release resources used
curl_close($ch);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$IsFromGTXNetwork = $getData['IsFromGTXNetwork'] ? $getData['IsFromGTXNetwork'] : 0;
$GTXNetworkAgencySysId = $getData['GTXNetworkAgencySysId'] ? $getData['GTXNetworkAgencySysId'] : 0;
if ($IsFromGTXNetwork == 1) {
$agentRegistrationApiData = array(
'AgencySysId' => (int) $GTXNetworkAgencySysId,
'B2CAgencySysId' => (int) $AgencySysId,
'AgentSysId' => 0,
);
try {
$curl = curl_init($this->baseUrl . "/gtxwebservices/b2b-agency-create"); // b2c site url
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($agentRegistrationApiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$getresponseAgencyData = curl_exec($curl);
curl_close($curl);
$getresponseAgencyDataArray = Zend_Json::decode($getresponseAgencyData, true);
if (isset($getresponseAgencyDataArray) && !empty($getresponseAgencyDataArray)) {
$travelplanID = !empty($getData['TravelPlanId']) ? $getData['TravelPlanId'] : 0;
$minpax = !empty($getData['minpax']) ? $getData['minpax'] : 0;
$catID = !empty($getData['catID']) ? $getData['catID'] : 1;
$mID = !empty($getData['mID']) ? $getData['mID'] : 0;
$FirstName = !empty($getData['FirstName']) ? $getData['FirstName'] : '';
$Email = !empty($getData['Email']) ? $getData['Email'] : '';
$TotalNights = !empty($getData['TotalNights']) ? $getData['TotalNights'] : 0;
$tripaddress = !empty($getData['tripaddress']) ? $getData['tripaddress'] : '';
$search_going_to = !empty($getData['search_going_to']) ? $getData['search_going_to'] : '';
$search_going_toA = explode('__', $search_going_to);
$pkgCheckInDate = !empty($getData['pkgCheckInDate']) ? $getData['pkgCheckInDate'] : '';
$pkgCheckOutDate = !empty($getData['pkgCheckOutDate']) ? $getData['pkgCheckOutDate'] : '';
$MobileNumber = !empty($getData['MobileNumber']) ? $getData['MobileNumber'] : '';
$countrycode = !empty($getData['countrycode']) ? $getData['countrycode'] : '';
$postFields = array(
'TravelPlanId' => $travelplanID,
'minpax' => $minpax,
'catID' => $catID,
'TotalNights' => $TotalNights,
'DestinationPlaces' => $search_going_toA[1],
'search_going_to' => $search_going_to,
'pkgCheckInDate' => $pkgCheckInDate,
'pkgCheckOutDate' => $pkgCheckOutDate,
'tripstartdate' => 0,
'custemail' => $Email,
'custname' => $FirstName,
'custphone' => $MobileNumber,
'tripaddress' => $tripaddress,
'aboutpackage' => '',
'pricetype' => 'wp',
'leadsource' => 'Agency',
'mealplantype' => $mID,
'roomjson' => Zend_Json::encode($roomjson),
'ItineraryArray' => array(),
'FristName' => trim($getresponseAgencyDataArray['data']['FristName']),
'LastName' => trim($getresponseAgencyDataArray['data']['LastName']),
'Email' => trim($getresponseAgencyDataArray['data']['EmailID']),
'MobileNumber' => trim($getresponseAgencyDataArray['data']['MobileNo']),
'CountryCode' => trim($getresponseAgencyDataArray['data']['CountryCode']),
'IsB2BAgent' => 1,
'AgencyIdB2B' => $GTXNetworkAgencySysId,
'AgencyIdB2C' => $AgencySysId,
'AgencySysId' => $GTXNetworkAgencySysId,
'aId' => $getresponseAgencyDataArray['data']['UserSysId'],
'selectedCustomerId' => base64_encode($getresponseAgencyDataArray['data']['CustomerSysId']),
);
$curl = curl_init($this->baseUrl . '/gtxwebservices/dynamic-query'); // b2c site url
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$getresponseData = curl_exec($curl);
curl_close($curl);
$getresponseDataArr = Zend_Json::decode($getresponseData, true);
}
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
if ($responseArr['status'] == 'success') {
$response = array('status' => 'success', 'message' => 'Proposal has been shared with customer', 'res' => $responseArr);
} else if ($responseArr['status'] == 'successemailfail') {
$response = array('status' => 'fail', 'message' => 'Proposal is created but there is some error in sending email.', 'res' => $responseArr);
} else {
$response = array('status' => 'fail', 'message' => 'There is some error. Please try after sometime.', 'res' => $responseArr);
}
echo Zend_Json::Encode($response);
exit;
}
}
// Added By Pardeep Panchal
public function customerProfilingAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
if ($this->getRequest()->isPost()) {
$STR_FILTER_DATA = new Zend_Session_Namespace('FILTER_DATA');
$getData = $this->getRequest()->getPost();
$this->view->searchData = $getData;
$phonenumber = trim($getData['phonenumber']);
$customername = trim($getData['customername']);
$emailid = trim($getData['emailid']);
$lead_source = trim($getData['lead_source']);
$search_going_from = trim($getData['search_going_from']);
$search_going_to = trim($getData['search_going_to']);
$destinationType = trim($getData['destination_type']);
$custCityId = trim($getData['cust_city_id']);
$travelPeriod = trim($getData['travel_month']);
$queryPeriod = trim($getData['query_month']);
$DOBMonth = trim($getData['dob']);
$anniversaryMonth = trim($getData['anniversary']);
$passportexpiryPeriod = trim($getData['passportexpiry']);
$lastStatus = trim($getData['last_status']);
$travelWithUs = isset($getData['travel_with']) ? trim($getData['travel_with']) : 0;
$travelWithUs = ($travelWithUs == '1') ? '17' : '0';
$search_price_range = trim($getData['search_price_range']);
if ($search_price_range != "") {
$arrSearchPriceRange = explode("__", $search_price_range);
$SearchPriceRangeFrom = trim($arrSearchPriceRange[0]);
$SearchPriceRangeTo = trim($arrSearchPriceRange[1]);
}
$age_group = trim($getData['age_group']);
if ($age_group != "") {
$arrAgeGroup = explode("_", $age_group);
$AgeGroupFrom = trim($arrAgeGroup[0]);
$timeFrom = strtotime("-" . $AgeGroupFrom . ' years');
$AgeGroupFrom = date('Y', $timeFrom);
$AgeGroupTo = trim($arrAgeGroup[1]);
$timeTo = strtotime("-" . $AgeGroupTo . ' years');
$AgeGroupTo = date('Y', $timeTo);
} else {
$AgeGroupFrom = "";
$AgeGroupTo = "";
}
if (!empty($travelPeriod)) {
$arrTravelPeriod = explode("to", $travelPeriod);
$TravelDateFrom = trim($arrTravelPeriod[0]);
$TravelDateTo = trim($arrTravelPeriod[1]);
}
if (!empty($queryPeriod)) {
$arrQueryPeriod = explode("to", $queryPeriod);
$QueryDateFrom = trim($arrQueryPeriod[0]);
$QueryDateTo = trim($arrQueryPeriod[1]);
}
// if(!empty($DOBMonth)){
// $arrDOBPeriod = explode("to",$DOBMonth);
// $DOBDateFrom = trim($arrDOBPeriod[0]);
// $DOBDateTo = trim($arrDOBPeriod[1]);
// }
if (!empty($passportexpiryPeriod)) {
$arrPassportExpiry = explode("to", $passportexpiryPeriod);
$PassportExpiryDateFrom = trim($arrPassportExpiry[0]);
$PassportExpiryDateTo = trim($arrPassportExpiry[1]);
}
$this->_crmcustomerObj->strCondition = " 1 = 1 ";
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($sessionLogin_user->UserRoleTitle != 'Owner') {
$this->_crmcustomerObj->strCondition .= " AND tb1.AssignUserSysId IN ( '" . $ReportingToSysId . "' ) ";
}
if (!empty($phonenumber)) {
$this->_crmcustomerObj->strCondition .= " AND tb2.Contacts LIKE '%" . $phonenumber . "%'";
}
if (!empty($customername)) {
$this->_crmcustomerObj->strCondition .= " AND (lower(tb1.FirstName) LIKE '%" . strtolower($customername) . "%' OR lower(tb1.LastName) LIKE '%" . strtolower($customername) . "%') ";
}
if (!empty($emailid)) {
$this->_crmcustomerObj->strCondition .= " AND tb2.EmailId LIKE '%" . $emailid . "%' ";
}
if ($AgeGroupFrom != "" && $AgeGroupTo != "") {
$this->_crmcustomerObj->strCondition .= " AND YEAR(tb2.DOB) <= '" . $AgeGroupFrom . "' AND YEAR(tb2.DOB) >= '" . $AgeGroupTo . "' ";
}
if (!empty($lead_source)) {
$this->_crmcustomerObj->strCondition .= " AND tb1.LeadSourceSysId = '" . $lead_source . "' ";
}
if (!empty($search_going_from)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.SourcePlaceSysId = '" . $search_going_from . "' ";
}
if (!empty($search_going_to)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.DestinationPlacesSysId = '" . $search_going_to . "' ";
}
if (!empty($TravelDateFrom) && !empty($TravelDateTo)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.StartDate >= '" . $TravelDateFrom . "' AND tb6.StartDate <= '" . $TravelDateTo . "' ";
}
if (!empty($SearchPriceRangeFrom) && !empty($SearchPriceRangeTo)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.NetPrice >= '" . $SearchPriceRangeFrom . "' AND tb6.NetPrice <= '" . $SearchPriceRangeTo . "' ";
}
if (!empty($QueryDateFrom) && !empty($QueryDateTo)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.CreateDate >= '" . $QueryDateFrom . "' AND tb6.CreateDate <= '" . $QueryDateTo . "' ";
}
if (!empty($destinationType)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.PackRangeType = '" . $destinationType . "' ";
}
if (!empty($custCityId)) {
$this->_crmcustomerObj->strCondition .= " AND tb2.CitySysId = '" . $custCityId . "' ";
}
if (!empty($DOBMonth)) {
$this->_crmcustomerObj->strCondition .= " AND MONTH(tb2.DOB) = '" . $DOBMonth . "'";
}
if (!empty($anniversaryMonth)) {
$this->_crmcustomerObj->strCondition .= " AND MONTH(tb2.MarriageAnniversary) = '" . $anniversaryMonth . "' ";
}
if (!empty($PassportExpiryDateFrom) && !empty($PassportExpiryDateTo)) {
$this->_crmcustomerObj->strCondition .= " AND tb2.PassportExpiry >= '" . $PassportExpiryDateFrom . "' AND tb2.PassportExpiry <= '" . $PassportExpiryDateTo . "' ";
}
if (!empty($lastStatus)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.StatusType = '" . $lastStatus . "' ";
}
if (!empty($travelWithUs)) {
$this->_crmcustomerObj->strCondition .= " AND tb6.StatusType = '" . $travelWithUs . "' ";
}
$STR_FILTER_DATA->params = $this->_crmcustomerObj->strCondition; // Putting Condition in to Session...
$this->_crmcustomerObj->strViewType = "list";
$getCustomerList = $this->_crmcustomerObj->getCustomerProfilingList($agencysysID);
} else {
$getData = array();
$this->_crmcustomerObj->strCondition = " 1 = 1 ";
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
if ($sessionLogin_user->UserRoleTitle != 'Owner') {
$this->_crmcustomerObj->strCondition .= " AND tb1.AssignUserSysId IN ( '" . $ReportingToSysId . "' ) ";
}
$this->_crmcustomerObj->strViewType = "list";
$getCustomerList = $this->_crmcustomerObj->getCustomerProfilingList($agencysysID);
//echo "<pre>";print_r($getCustomerList);echo "</pre>";
}
// $page = $this->_getParam('page', 1);
// $paginator = Zend_Paginator::factory($getCustomerList);
// $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
// $paginator->setCurrentPageNumber($page);
//echo "<pre>";print_r($paginator);die;
$listArr = array();
foreach ($getCustomerList as $key) {
$listArr[] = $key;
}
// Filtering Duplicate Data...
$newCustomerList = array_filter($listArr, function ($var) {
if (!in_array($var['CustomerSysId'], $this->arrCustomerSysId)) {
$this->arrCustomerSysId[] = $var['CustomerSysId'];
return true;
}
});
// Filtering Duplicate Data Ends...
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($newCustomerList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator1 = $paginator;
$this->view->paginator = $paginator;
//echo "<pre>";print_r($agencyUser);die;
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->agencyUser = $agencyUser;
$this->view->AgencySysId = $agencysysID;
$objPackage = new Travel_Model_TblPackage();
$packageThemeList = $objPackage->getPackageThemeList();
$this->view->packageThemeList = $packageThemeList;
$packageTypeList = $objPackage->getPackageTypeList();
$this->view->packageTypeList = $packageTypeList;
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
}
public function exportToExcelAction() {
$objPackage = new Travel_Model_TblPackage();
$packageTypeList = $objPackage->getPackageTypeList();
if (!empty($packageTypeList)) {
$arrpackType = array();
foreach ($packageTypeList as $packType) {
$arrpackType[$packType['PackRangeType']] = $packType['Title'];
}
}
$sheetTitle = "Customer Profiling Data";
$arrFieldLabel = array('Customer\'s Name', 'Email', 'Mobile', 'Date Of Birth', 'Marriage Anniversary', 'Passport Expiring On',
'Customer\'s City', 'Origin City', 'Destination City', 'Hotel Preference', 'Traveller Type',
'Destination Type', 'Meal Preference', 'Travelled With Us', 'Travel Date', 'Query Date', 'Lead Source', 'Agency User', 'Status'
);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$getData = array();
$STR_FILTER_DATA = new Zend_Session_Namespace('FILTER_DATA');
$this->_crmcustomerObj->strCondition = "";
$this->_crmcustomerObj->strCondition = $STR_FILTER_DATA->params;
$getCustomerList = $this->_crmcustomerObj->getCustomerProfilingList($agencysysID);
//echo "<pre>";print_r($getCustomerList);exit;
$intCounter = 0;
$arrFieldValue = array();
if (count($getCustomerList)) {
$arrCustomerSysId = array();
foreach ($getCustomerList as $value) {
if (!in_array($value['CustomerSysId'], $arrCustomerSysId)) {
$arrCustomerSysId[] = $value['CustomerSysId'];
$arrDob = (array) $value['DOB'];
$arrDob = explode(" ", $arrDob['date']);
$arrMarriageAnniversary = (array) $value['MarriageAnniversary'];
$arrMarriageAnniversary = explode(" ", $arrMarriageAnniversary['date']);
$arrPassportExpiry = (array) $value['PassportExpiry'];
$arrPassportExpiry = explode(" ", $arrPassportExpiry['date']);
$arrStartDate = (array) $value['StartDate'];
$StartDate = explode(" ", $arrStartDate['date']);
$arrCreateDate = (array) $value['CreateDate'];
$CreateDate = explode(" ", $arrCreateDate['date']);
$arrFieldValue[$intCounter]['FirstName'] = trim($value['FirstName']) . " " . trim($value['LastName']);
$arrFieldValue[$intCounter]['EmailId'] = trim($value['EmailId']);
$arrFieldValue[$intCounter]['Contacts'] = trim($value['Contacts']);
$arrFieldValue[$intCounter]['dob'] = ($arrDob[0] != "1900-01-01") ? $arrDob[0] : 'NA';
;
$arrFieldValue[$intCounter]['MarriageAnniversary'] = ($arrMarriageAnniversary[0] != "1900-01-01") ? $arrMarriageAnniversary[0] : 'NA';
$arrFieldValue[$intCounter]['PassportExpiring'] = ($arrPassportExpiry[0] != "1900-01-01") ? $arrPassportExpiry[0] : 'NA';
;
$arrFieldValue[$intCounter]['CustCity'] = trim($value['CustCity']);
$arrFieldValue[$intCounter]['OriginCity'] = trim($value['SourcePlaces']);
$arrFieldValue[$intCounter]['DestCity'] = trim($value['DestinationPlaces']);
$arrFieldValue[$intCounter]['HotelPreference'] = !empty($value['HotelPreference']) ? trim($value['HotelPreference']) : 'NA';
$arrFieldValue[$intCounter]['TravellerType'] = "NA";
$arrFieldValue[$intCounter]['DestinationType'] = !empty($arrpackType[$value['PackRangeType']]) ? trim($arrpackType[$value['PackRangeType']]) : 'NA';
$arrFieldValue[$intCounter]['MealPreference'] = "NA";
$arrFieldValue[$intCounter]['TravelledWithUs'] = (trim($value['StatusType']) == 17) ? "Yes" : "No";
$arrFieldValue[$intCounter]['StartDate'] = ($StartDate[0] != "1900-01-01") ? $StartDate[0] : 'NA';
$arrFieldValue[$intCounter]['CreateDate'] = ($CreateDate[0] != "1900-01-01") ? $CreateDate[0] : 'NA';
$arrFieldValue[$intCounter]['LeadSource'] = trim($value['LeadSource']);
$arrFieldValue[$intCounter]['AgencyUserFirstName'] = trim($value['AgencyUserFirstName']);
$arrFieldValue[$intCounter]['IsActive'] = trim($value['IsActive']) == '1' ? 'Active' : 'Inactive';
$intCounter++;
}
}
}
// echo '<pre>';print_r($sheetTitle);
// echo '<pre>';print_r($arrFieldLabel);
// echo '<pre>';print_r($arrFieldValue);die('ex');
Zend_Controller_Action_HelperBroker::getStaticHelper("CreateExcel")->exportToExcel($sheetTitle, $arrFieldLabel, $arrFieldValue);
exit;
}
public function exportExcelLeagQueryAction() {
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
$getData = array();
$getData['dateFrom'] = $this->getRequest()->getParam('dateFrom');
$getData['dateTo'] = $this->getRequest()->getParam('dateTo');
$getData['TravelFromDate'] = $this->getRequest()->getParam('TravelFromDate');
$getData['TravelToDate'] = $this->getRequest()->getParam('TravelToDate');
$getData['customername'] = $this->getRequest()->getParam('customername');
$getData['customermobile'] = $this->getRequest()->getParam('customermobile');
$getData['customeremail'] = $this->getRequest()->getParam('customeremail');
$getData['Destination'] = $this->getRequest()->getParam('Destination');
$getData['CityName'] = $this->getRequest()->getParam('CityName');
$getData['lead_stage'] = $this->getRequest()->getParam('lead_stage');
$getData['lead_source'] = $this->getRequest()->getParam('lead_source');
$getData['plan_type'] = $this->getRequest()->getParam('plan_type');
$getData['assigUnassignFilter'] = (NULL !== $this->getRequest()->getParam('assigUnassignFilter')) ? $this->getRequest()->getParam('assigUnassignFilter') : '';
$getData['agencyUserFilter'] = (NULL !== $this->getRequest()->getParam('agencyUserFilter')) ? $this->getRequest()->getParam('agencyUserFilter') : '';
$getData['filter_name'] = $this->getRequest()->getParam('filter_name', 'overall');
//$getData['UserSysId'] = $this->getRequest()->getParam('UserSysId',0);
$type = $this->getRequest()->getParam('type');
if (isset($type) && !empty($type)) {
$getData['leadType_' . $type] = $type;
}
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
//print_r($getData);die;
$getData['UserSysId'] = 0;
if ((isset($getData['leadType_LEAD']) && trim($getData['leadType_LEAD']) == 'LEAD')) {
$sheetTitle = "Lead Data";
} else {
$sheetTitle = "Query Data";
}
$arrFieldLabel = array('Query Date/Age', 'Name', 'Company Name', 'Mobile', 'Email', 'Type', 'Description', 'Travel Date', 'No. of Pax', 'From Destinations', 'Destinations', 'Proposal',
'Query Stage', 'Lead Quality', 'Lead Source', 'Lead Campaign', 'Lead Medium', 'Last Updated', 'Is Archived', 'Owner');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
$arrFieldValue = array();
if ((isset($getData['leadType_LEAD']) && trim($getData['leadType_LEAD']) == 'LEAD')) {
/*
if (isset($getData['lead_stage']) && $getData['lead_stage'] != '') {
// echo $getData['lead_stage'];exit;
$getData['lead_stage'] = explode(',', $getData['lead_stage']);
} else {
$getData['lead_stage'] = array(48, 49, 51, 52, 53);
}
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
$this->_crmagencyleadaccountObj->ReportingToSysId = $ReportingToSysId;
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$getData['AgencySysId'] = $AgencySysId;
if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 2)) { //condition for un assigned lead filter
$getData['UserSysId'] = 0;
}
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData);
} else {
$getData['UserSysId'] = $AgentSysId;
// if (isset($getData['agencyUserFilter']) && ($getData['agencyUserFilter'] != "")) { //condition for un assigned lead filter
// $getData['agencyUserFilter'] = $getData['agencyUserFilter'];
// }
if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 2)) { //condition for un assigned lead filter
$getData['UserSysId'] = 0;
}
$leadSourcesIds = array();
$leadSourceExplodedRes = '';
$getCustomerList = array();
if (!empty($getleadSource)) {
foreach ($getleadSource as $k => $v) {
$leadSourcesIds[] = $v['LeadSourceSysId'];
}
$leadSourceExplodedRes = implode(",", $leadSourcesIds);
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
} else {
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
}
}
}
$responseArray = array();
$UnAssignedLead = 0;
$AgencyCRMLeadSysIds = array();
$i = 0;
$paginator = Zend_Paginator::factory($getCustomerList);
// $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($getCustomerList));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(5000);
//echo "<pre>";print_r();die;
foreach ($paginator as $getCustomerListArr) {
$UnAssignedLead = (trim($getCustomerListArr['AgencyUserFirstName']) == '') ? $UnAssignedLead + 1 : $UnAssignedLead;
if (!in_array($getCustomerListArr['AgencyCRMLeadSysId'], $AgencyCRMLeadSysIds)) {
$selectedStatus = 53;
if (!empty($getStageList)) {
foreach ($getStageList as $key => $val) {
if (isset($getCustomerListArr['LeadStageSysId']) && !empty($getCustomerListArr['LeadStageSysId']) && trim($getCustomerListArr['LeadStageSysId']) != '') {
$selectedStatus = trim($getCustomerListArr['LeadStageSysId']);
if ($val['TPStatusSysId'] == $selectedStatus) {
$leadstageName = trim(stripslashes($val['TPStatus']));
}
}
}
}
$differenceIndays = '';
//if(isset($leadlist['TYPE']) && ($leadlist['TYPE']=='LEAD')){
$fromDate = $getCustomerListArr['ActiveDate']->format('Y-m-d');
//echo $leadlist['ActiveDate']->format('Y-m-d')
$fromDateTime = time() - strtotime($getCustomerListArr['ActiveDate']->format('Y-m-d H:i:s'));
$toDate = date('Y-m-d', time());
if ($fromDateTime / 3600 < 24) {
$fromDateTime = abs($fromDateTime / 60);
$differenceIndays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->convertToHoursMins($fromDateTime);
} else {
$differenceIndays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($fromDate, $toDate);
$differenceIndays = $differenceIndays . " Days";
}
if (!empty($getCustomerListArr['TPSysId'])) {
$proposalcount = $this->_crmcusttravelplan->GetProposalCount(@$getCustomerListArr['TPSysId']);
}
if ($getCustomerListArr['TPSysId'] != '') {
$totalproposal = $totalproposal;
} else {
$totalproposal = '0';
}
$totalproposal = !empty($proposalcount) ? count($proposalcount) : 0;
$arrFieldValue[$i]['QueryDateAge'] = !empty($getCustomerListArr['ActiveDate']) ? $getCustomerListArr['ActiveDate']->format('d-M-y') . ' - ' . ($differenceIndays ? $differenceIndays : '') : 'NA';
$arrFieldValue[$i]['name'] = !empty($getCustomerListArr['FullName']) ? ucfirst($getCustomerListArr['FullName']) : '';
$arrFieldValue[$i]['CompanyName'] = !empty($getCustomerListArr['CompanyName']) ? ucfirst($getCustomerListArr['CompanyName']) : '';
$arrFieldValue[$i]['Contacts'] = !empty($getCustomerListArr['PrimaryContactNumber']) ? ucfirst($getCustomerListArr['PrimaryContactNumber']) : '';
$arrFieldValue[$i]['EmailId'] = !empty($getCustomerListArr['EmailId']) ? ucfirst(trim($getCustomerListArr['EmailId'])) : '';
$arrFieldValue[$i]['type'] = ($getCustomerListArr['IsB2BAgent'] == 1) ? 'B2B' : 'B2C';
$arrFieldValue[$i]['Description'] = 'Lead (New Lead)';
$arrFieldValue[$i]['TravelDate'] = 'NA';
$arrFieldValue[$i]['noofpax'] = 'NA';
$arrFieldValue[$i]['Destinations'] = 'NA';
$arrFieldValue[$i]['Proposal'] = $totalproposal;
$arrFieldValue[$i]['leadstage'] = $leadstageName;
$arrFieldValue[$i]['lastupdate'] = (isset($getCustomerListArr['UpdatedDate']) && !empty($getCustomerListArr['UpdatedDate'])) ? $getCustomerListArr['UpdatedDate']->format('d-M-y') : 'NA';
$arrFieldValue[$i]['owner'] = trim(stripslashes($getCustomerListArr['AgencyUserFirstName'])) . " " . trim(stripslashes($getCustomerListArr['AgencyUserLastName']));
}
$i++;
} */
} else {
$crmProcedure = new Crm_Model_CrmProcedure();
$crmProcedure->updateCampaignMedium();
$objagencyCustomer = new Travel_Model_CRM_AgencyLeadAccount();
$objCustomer = new Travel_Model_CRM_Customer();
// query start
$this->_crmcusttravelplan->ReportingToSysId = $ReportingToSysId;
// echo "<pre>";print_r($getData);die;
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$LeadListArr = $this->_crmcusttravelplan->GetAgencyLeadListFilter($AgencySysId, '', $getData);
} else {
$LeadListArr = $this->_crmcusttravelplan->GetAgencyLeadListFilter($AgencySysId, $AgentSysId, $getData);
}
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($LeadListArr));
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(100000);
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$travelPlanStatusName = $customhelper->GetTravelPlanStatusArray(1, '');
$intCounter = 0;
if ($paginator) {
foreach ($paginator as $leadlist) {
$childinPAckage = 0;
$adultinPAckage = 0;
$infantinPAckage = 0;
$returndate = '';
$departuredate = '';
$totalmember = '';
$paxTOtalArray = json_decode($leadlist['RoomInfoJson'], 1);
$paxTOtalArr = json_decode($leadlist['RoomInfoJson']);
if (!empty($paxTOtalArr)) {
foreach ($paxTOtalArr as $PaxTotal) {
$adultinPAckage += (isset($PaxTotal->Adult) ? $PaxTotal->Adult : 0);
$childinPAckage += (isset($PaxTotal->Child) ? $PaxTotal->Child : 0);
$infantinPAckage += (isset($PaxTotal->Infant) ? $PaxTotal->Infant : 0);
$departuredate = isset($PaxTotal->departuredate) ? $PaxTotal->departuredate : '';
$returndate = isset($PaxTotal->returndate) ? $PaxTotal->returndate : '';
$totalmember = isset($PaxTotal->totalmember) ? $PaxTotal->totalmember : '';
}
}
$differenceIndays = '';
$fromDate = $leadlist['CreateDate']->format('Y-m-d');
$fromDateTime = time() - strtotime($leadlist['CreateDate']->format('Y-m-d H:i:s'));
$toDate = date('Y-m-d', time());
if ($fromDateTime / 3600 < 24) {
$fromDateTime = abs($fromDateTime / 60);
$differenceIndays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->convertToHoursMins($fromDateTime);
} else {
$differenceIndays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($fromDate, $toDate);
$differenceIndays = $differenceIndays . " Days";
}
if ($leadlist['PlanType'] != '') {
$Description = $customhelper->getPlanTypeName($leadlist['PlanType']);
} else {
$Description = 'Lead';
}
$Forex = '';
$Member = '';
$Adult = '';
$Kid = '';
$Infant = '';
$TravelDate = $departuredate;
if ($leadlist['PlanType'] == 7) {
$Forex = count($paxTOtalArray) . ' Forex Type';
} else if ($leadlist['PlanType'] == 4) {
$Member = !empty($totalmember) ? $totalmember . ' Member(s)' : '';
} else if ($adultinPAckage > 0 || $childinPAckage > 0 || $infantinPAckage > 0) {
$Adult = $adultinPAckage . ' Adult(s)';
$Kid = !empty($childinPAckage) ? ', ' . $childinPAckage . ' Kid ' : '';
$Infant = !empty($infantinPAckage) ? ', ' . $infantinPAckage . ' Infant ' : '';
} else {
echo "NA";
}
if (!empty($leadlist['TPSysId'])) {
$proposalcount = $this->_crmcusttravelplan->GetProposalCount(@$leadlist['TPSysId']);
}
if ($leadlist['TPSysId'] != '') {
$totalproposal = $totalproposal;
} else {
$totalproposal = '0';
}
$LeadQuality = (int) $leadlist['LeadQuality'];
$LeadQualityStatus = 'No Status';
if ($LeadQuality == 1) {
$LeadQualityStatus = "Hot";
} else if ($LeadQuality == 2) {
$LeadQualityStatus = "Warm";
} else if ($LeadQuality == 3) {
$LeadQualityStatus = "Cold";
}
$CompanyName = !empty($leadlist['CompanyName']) ? ucfirst($leadlist['CompanyName']) : '';
if ($leadlist['IsB2BProposal'] == 3) {
$CompanyName = !empty($leadlist['FranchiseCompanyName']) ? ucfirst($leadlist['FranchiseCompanyName']) : '';
}
$totalproposal = !empty($proposalcount) ? count($proposalcount) : 0;
$destination = (!empty($leadlist['Cities']) && trim($leadlist['Cities']) != '') ? stripslashes($leadlist['Cities']) : '';
$SourcePlaces = (!empty($leadlist['SourcePlaces']) && trim($leadlist['SourcePlaces']) != '') ? stripslashes($leadlist['SourcePlaces']) : '';
$arrFieldValue[$intCounter]['QueryDateAge'] = !empty($leadlist['CreateDate']) ? $leadlist['CreateDate']->format('d-M-y') . ' - ' . ($differenceIndays ? $differenceIndays : '') : 'NA';
$arrFieldValue[$intCounter]['name'] = !empty($leadlist['FullName']) ? ucfirst($leadlist['FullName']) : '';
$arrFieldValue[$intCounter]['CompanyName'] = $CompanyName;
$arrFieldValue[$intCounter]['Contacts'] = !empty($leadlist['Contacts']) ? ucfirst($leadlist['Contacts']) : '';
$arrFieldValue[$intCounter]['EmailId'] = !empty($leadlist['EmailId']) ? ucfirst(trim($leadlist['EmailId'])) : '';
$arrFieldValue[$intCounter]['type'] = ($leadlist['IsB2BAgent'] == 1) ? 'B2B' : 'B2C';
$arrFieldValue[$intCounter]['Description'] = $Description;
$arrFieldValue[$intCounter]['TravelDate'] = $TravelDate;
$arrFieldValue[$intCounter]['noofpax'] = $Forex . ' ' . $Member . ' ' . $Adult . $Kid . $Infant;
$arrFieldValue[$intCounter]['SourcePlaces'] = str_replace(',', ', ', $SourcePlaces);
$arrFieldValue[$intCounter]['Destinations'] = str_replace(',', ', ', $destination);
$arrFieldValue[$intCounter]['Proposal'] = $totalproposal;
$arrFieldValue[$intCounter]['QueryStage'] = (isset($leadlist['StatusType']) && !empty($leadlist['StatusType']) && isset($travelPlanStatusName[$leadlist['StatusType']]['TPStatus'])) ? $travelPlanStatusName[$leadlist['StatusType']]['TPStatus'] : 'NA';
$arrFieldValue[$intCounter]['leadquality'] = $LeadQualityStatus;
$arrFieldValue[$intCounter]['leadSource'] = isset($leadlist['LeadSource']) ? trim($leadlist['LeadSource']) : '';
$arrFieldValue[$intCounter]['LeadCampaign'] = isset($leadlist['LeadCampaign']) ? trim($leadlist['LeadCampaign']) : '';
$arrFieldValue[$intCounter]['LeadMedium'] = isset($leadlist['LeadMedium']) ? trim($leadlist['LeadMedium']) : '';
$arrFieldValue[$intCounter]['lastupdate'] = (isset($leadlist['UpdateDate']) && !empty($leadlist['UpdateDate'])) ? $leadlist['UpdateDate']->format('d-M-y') : 'NA';
$arrFieldValue[$intCounter]['IsMarkForDelete'] = ($leadlist['IsMarkForDelete'] == 1) ? 'Archived' : '';
$arrFieldValue[$intCounter]['owner'] = trim(stripslashes($leadlist['OwnerAgentFirstName'])) . " " . trim(stripslashes($leadlist['OwnerAgentLastName']));
$intCounter++;
}
}
}
// echo "<pre>";print_r($arrFieldLabel);
// echo "<pre>";print_r($arrFieldValue);exit;
Zend_Controller_Action_HelperBroker::getStaticHelper("CreateExcel")->exportToExcel($sheetTitle, $arrFieldLabel, $arrFieldValue);
exit;
}
public function oddAction($var) {
// returns whether the input integer is odd
return($var & 1);
}
//function for assign user/lead
public function updateAssignAgencyUserAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$CustomerSysIds = $this->getRequest()->getParam('data');
$AgencyUserId = $this->getRequest()->getParam('aid');
$usertype = $this->getRequest()->getParam('usertype', 's');
$CustomerSysIds = $this->_HtmlPurifier->filterArray($CustomerSysIds);
$AgencyUserId = base64_decode($this->_HtmlPurifier->filter($AgencyUserId));
$FullName = '';
if (isset($AgencyUserId) && !empty($AgencyUserId) && (int) $AgencyUserId > 0) {
$agentDetails = $this->_crmcustomerObj->getAgentDetailById($AgencyUserId);
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgencyUserId);
$ContactNumber = isset($getAgentDetails['ContactNo1']) ? $getAgentDetails['countrycode'] . '' . trim($getAgentDetails['ContactNo1']) : '';
$agentAssineDetails = $this->_crmcustomerObj->getAgentDetailById($sessionLogin_user->intLoggedinUserId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencysysID);
$responsefirst = explode("_", base64_decode($CustomerSysIds[0]));
$typefirst = $responsefirst[1];
$encryptData = '';
$FullName = (isset($agentDetails[0]['FirstName'])) ? trim($agentDetails[0]['FirstName']) . ' ' . trim($agentDetails[0]['LastName']) : '';
if (!empty($CustomerSysIds)) {
for ($d = 0; $d < count($CustomerSysIds); $d++) {
$response = explode("_", base64_decode($CustomerSysIds[$d]));
$type = $response[1];
$AgencyCRMLeadSysId = $response[0];
$AgencyCRMLeadSysIdArr[] = $AgencyCRMLeadSysId;
if ($type == 'LEAD') {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId . " AND (AgencySysId = $agencysysID OR AgencySysId IN (SELECT AgencySysId From TB_Agency Where MasterAgencySysId = $agencysysID)) ";
$date = date('Y-m-d H:i:s');
$userArray = array(
'AssignUserSysId' => $AgencyUserId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$agencyCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (!empty($agencyCustomerDetails)) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$message = 'user ' . trim($agencyCustomerDetails['FirstName']) . ' assigned to ' . $AgencyUserId;
$messageArray = array(
'ModuleType' => 1,
'RefSysId' => 0,
'SenderSysId' => trim($agencyCustomerDetails['CustomerSysId']),
'UserSysId' => $AgencyUserId,
'AgencySysId' => $agencysysID,
'Message' => addslashes($message),
'MsgType' => 3,
'isAgent' => 0,
'Accepted' => 0,
'Rejected' => 0,
'RejectReason' => 0,
'OtherInfo' => 0,
'UpdateDate' => $date,
'CreatedDate' => $date,
'IsActive' => 1,
'IsMarkForDel' => '0'
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$notificationRcord = $this->_agencyuserObj->addNotification($messageArray);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$URL = 'cid:' . $agencyCustomerDetails['CustomerSysId'] . "@@" . "aid:" . $agencysysID;
$encryptData = $this->getEnc($URL);
}
if ($type == 'QUERY') {
$TPSysId = $response[2];
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId) && is_numeric($AgencyCRMLeadSysId) > 0) {
$date = date('Y-m-d H:i:s');
if ($usertype == 'o') {
$userQueryAgent = array(
'IsOperationalLead' => 1,
'OpsAgentSysId' => $AgencyUserId,
'UpdateDate' => $date,
);
$whereQuery = "TPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userQueryAgent, $whereQuery);
$whereProposal = "MasterTPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($userQueryAgent, $whereProposal);
} else {
$userQueryAgent = array(
'AgentSysId' => $AgencyUserId,
'UpdateDate' => $date,
);
$whereQuery = "TPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userQueryAgent, $whereQuery);
$whereProposal = "MasterTPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($userQueryAgent, $whereProposal);
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId . " AND AgencySysId=" . $agencysysID . " ";
$userArray = array(
'AssignUserSysId' => $AgencyUserId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
$agencyCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (is_array($agencyCustomerDetails) && count($agencyCustomerDetails) > 0) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
}
$response = array('status' => 'success', 'msg' => 'Record Updated');
} else {
$response = array('status' => 'failed', 'msg' => 'Some thing went wrong.');
}
}
}
if ($typefirst == 'LEAD') {
$html->assign('type', 'gtxCustomerAgentEmailNotification');
$html->assign('URL', $encryptData);
$html->assign('agentDetails', $agentDetails);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('agentAssineDetails', $agentAssineDetails);
$html->assign('CustomerSysIds', $CustomerSysIds);
$html->assign('AgencyCRMLeadSysIdArr', $AgencyCRMLeadSysIdArr);
$bodyText = $html->render('email-template.phtml');
$emailId = trim($agentDetails[0]['EmailId']);
$emailSendId = trim($agentAssineDetails[0]['EmailId']) ? trim($agentAssineDetails[0]['EmailId']) : trim($getAgencyDetail['PrimaryEmail']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : stripslashes(trim($getAgencyDetail['Title']));
$fromName = (isset($agentAssineDetails[0]['FirstName']) && !empty($agentAssineDetails[0]['FirstName'])) ? stripslashes(trim($agentAssineDetails[0]['FirstName'])) : trim($fromName);
$subject = 'New Lead Assigned';
$LeadCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerContactByLeadId($AgencyCRMLeadSysId);
$CustomerRecipient = isset($LeadCustomerDetails['PrimaryContactNumber']) ? $LeadCustomerDetails['PrimaryContactNumber'] : '';
$CustomerName = isset($LeadCustomerDetails['FullName']) ? $LeadCustomerDetails['FullName'] : '';
$AgentName = (isset($agentDetails[0]['FirstName']) && !empty($agentDetails[0]['FirstName'])) ? stripslashes(trim($agentDetails[0]['FirstName'])) . ' ' . stripslashes(trim($agentDetails[0]['LastName'])) : '';
$AgentSysId = isset($agentDetails[0]['UserSysId']) ? (int) $agentDetails[0]['UserSysId'] : $sessionLogin_user->intLoggedinUserId;
$payload = [
'recipient' => $CustomerRecipient,
'agent_name' => $AgentName,
'user_id' => $AgentSysId,
'title' => 'Lead Assigned',
'text' => 'Good news! A new lead of ' . $CustomerName . ' has been assigned to you in CRM.',
'label' => 'Click Here',
'url' => Catabatic_Helper::getSiteUrl() . 'crm/lead/index',
'delay' => 0,
];
} else if ($typefirst == 'QUERY') {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'gtxCustomerAgentQueryEmailNotification');
$html->assign('agentDetails', $agentDetails);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('agentAssineDetails', $agentAssineDetails);
$html->assign('agencyCustomerDetails', $agencyCustomerDetails);
$html->assign('CustomerSysId', base64_encode(trim($agencyCustomerDetails['CustomerSysId'])));
$html->assign('AgencyCRMLeadSysIdArr', $AgencyCRMLeadSysIdArr);
$bodyText = $html->render('email-template.phtml');
$emailId = trim($agentDetails[0]['EmailId']);
$emailSendId = trim($agentAssineDetails[0]['EmailId']) ? trim($agentAssineDetails[0]['EmailId']) : trim($getAgencyDetail['PrimaryEmail']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : stripslashes(trim($getAgencyDetail['Title']));
$fromName = (isset($agentAssineDetails[0]['FirstName']) && !empty($agentAssineDetails[0]['FirstName'])) ? stripslashes(trim($agentAssineDetails[0]['FirstName'])) : trim($fromName);
$subject = 'New Query Assigned';
$QueryCustomerDetails = $this->_crmagencyleadaccountObj->GetCustomerByQueryId($AgencyCRMLeadSysId);
$CustomerRecipient = isset($QueryCustomerDetails['Contacts']) ? $QueryCustomerDetails['Contacts'] : '';
$CustomerName = isset($QueryCustomerDetails['FirstName']) ? stripslashes(trim($QueryCustomerDetails['FirstName'])) . ' ' . stripslashes(trim($QueryCustomerDetails['LastName'])) : '';
$AgentName = (isset($agentDetails[0]['FirstName']) && !empty($agentDetails[0]['FirstName'])) ? stripslashes(trim($agentDetails[0]['FirstName'])) . ' ' . stripslashes(trim($agentDetails[0]['LastName'])) : '';
$AgentSysId = isset($agentDetails[0]['UserSysId']) ? (int) $agentDetails[0]['UserSysId'] : $sessionLogin_user->intLoggedinUserId;
$payload = [
'recipient' => $CustomerRecipient,
'agent_name' => $AgentName,
'user_id' => $AgentSysId,
'title' => 'Query Assigned',
'text' => 'Great news! A new query of ' . $CustomerName . ' has been assigned to you.',
'label' => 'Click Here',
'url' => Catabatic_Helper::getSiteUrl() . 'crm/query',
'delay' => 0,
];
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => Catabatic_Helper::getSiteUrl() . 'webservice/notification',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'SecurityKey:' . trim($getAgentDetails['SecurityKey']),
'Content-Type: application/json',
'Cookie: PHPSESSID=qb2ofl8h0g6hs66q3uhoenqasq'
),
));
$response = curl_exec($curl);
curl_close($curl);
try {
$emailId = trim($agentDetails[0]['EmailId']);
$emailData = array('fromEmail' => $emailSendId, 'fromName' => $fromName, 'subject' => $subject, 'to' => array($emailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[2], // 7 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$this->mailSentByElastice($emailData, $arrEmailStatistics, 0, 0);
$msg = "success";
} catch (Exception $err) {
$msg = "failed";
}
if ($agencysysID == $AgencyUserId) {
$CustomerContactNumber = (strpos($ContactNumber, '+') == true) ? $ContactNumber : "+" . $ContactNumber;
$postData = array(
"UserSysId" => $AgencyUserId,
// "IsSchedule" => False,
"schedule_time" => "",
"title" => "Fresh Fish Alert!",
"body" => "Hi User, You have been assigned new lead(s)/ Query(ies) in CRM.",
//"IsButton" => True,
"URL" => "crm/lead/index/filter/fresh",
"IsCall" => false,
"mobileNo" => trim($CustomerContactNumber)
);
if (isset($getAgentDetails['SecurityKey'])) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://globaltravelexchange.com/gtxwebservices/agency/create-fire-base-message',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $postData,
CURLOPT_HTTPHEADER => array(
'securitykey:' . trim($getAgentDetails['SecurityKey']),
//'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
}
}
}
$msg = "success";
$title = 'Success fully updated';
} else {
if (!empty($CustomerSysIds)) {
for ($d = 0; $d < count($CustomerSysIds); $d++) {
$response = explode("_", base64_decode($CustomerSysIds[$d]));
$type = $response[1];
$TPSysId = $response[2];
if ($TPSysId > 0) {
if ($usertype == 'o') {
$date = date('Y-m-d H:i:s');
$userQueryAgent = array(
'OpsAgentSysId' => 0,
'UpdateDate' => $date,
);
//$whereQuery = "TPSysId = " . $TPSysId . " OR MasterTPSysId = " . $TPSysId;
try {
$whereQuery = "TPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userQueryAgent, $whereQuery);
$whereProposal = "MasterTPSysId = " . $TPSysId;
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($userQueryAgent, $whereProposal);
$title = 'Record Updated';
$msg = 'success';
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
}
}
}
$msg = ($msg) ? $msg : "failed";
$title = ($title) ? $title : 'Something went wrong';
}
echo json_encode(array('status' => $msg, 'title' => $title, 'FullName' => $FullName));
exit;
}
public function saveCustomerProfileDescAction() {
$this->_helper->layout->disableLayout();
$result = '';
if ($this->getRequest()->isPost()) {
$historyTravelDate = $this->_HtmlPurifier->filter($this->getRequest()->getParam('historyTravelDate'));
$historyCountrySysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('historyCountrySysId'));
$historyCitySysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('historyCitySysId'));
$historyCityContSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('hidden_wanttogo_going_to_contid'));
$historyStarType = $this->_HtmlPurifier->filter($this->getRequest()->getParam('historyStarType'));
$historyPlanType = (NULL != $this->getRequest()->getParam('historyPlanType')) ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('historyPlanType')) : '';
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('historyCustomerSysId')));
$isManualAdded = (NULL != $this->getRequest()->getParam('isManualAdded')) ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('isManualAdded')) : '';
$Type = (NULL != $this->getRequest()->getParam('Type')) ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('Type')) : '';
//$data = json_decode($this->_HtmlPurifier->filterArray($data));
//print_r($data);die;
// query for insert data in db created by Er Amit kumar dubey on 25 july 2017 at 04:39 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$date = date('Y-m-d H:i:s');
if (isset($historyTravelDate) && !empty($historyTravelDate)) {
// $historyTravelDate=explode('/',$historyTravelDate);
$historyTravelDate = $historyTravelDate . "-" . date('m') . "-" . date('d');
}
$CitySysId = '';
if ($historyCitySysId != '') {
$historyCitySysIdExp = explode('__', $historyCitySysId);
$CitySysId = $historyCitySysIdExp[0];
}
$customerHistoryArray = array(
'AgencySysId' => $AgencySysId,
'AgentSysId' => $AgentSysId,
'CustomerSysId' => $CustomerSysId,
'IsManualAdded' => $isManualAdded,
'Type' => $Type,
'TravelDate' => $historyTravelDate,
'ContSysId' => $historyCountrySysId ? $historyCountrySysId : $historyCityContSysId,
'CitySysId' => $CitySysId,
'PlanType' => $historyPlanType,
'Star' => $historyStarType,
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $date,
'UpdateDate' => $date,
'IsMarkForDelete' => '0'
);
//print_r($customerHistoryArray);die;
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
//return $customerRcord;
$result = "success";
}
$status = array('response' => $result);
return $this->_helper->json($status);
}
public function getCustomerTravelHistoryAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
//echo $mobilenum;
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$type = 3; //Type 3 used for fetch only have been to do
$customerHistoryRcord = $custtravelhistoryObj->getCustomerTravelHistory($CustomerSysId, $AgencySysId, $type);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'getCustomerTravelHistoryHaveBeelTo');
$html->assign('data', $customerHistoryRcord);
echo $bodyText = $html->render('ajax-html.phtml');
}
public function getCustomerRemarksDataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getAllCustomerRemark = $this->_crmremarkObj->GetAllCustomerRemarkById($CustomerSysId, $AgencySysId);
$getAllLeadCustomerRemark = $this->_crmremarkObj->GetAllLeadRemarksWithTravelPlan($AgencySysId, $CustomerSysId, 10);
$netRemarkRes = array_merge($getAllCustomerRemark, $getAllLeadCustomerRemark);
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'getCustomerAllRemarks');
$html->assign('data', $netRemarkRes);
echo $bodyText = $html->render('ajax-html.phtml');
}
public function getCustomerRecentQueryDataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getLeadlist = $this->_crmcusttravelplan->GetAgencyLeadList($AgencySysId, $AgentSysId, '', $CustomerSysId, 10);
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getLeadlist);
$paginator->setItemCountPerPage(10); // number of items to show per page
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'getCustomerRecentQuery');
$html->assign('data', $paginator);
echo $bodyText = $html->render('ajax-html.phtml');
}
public function getCustomerAllToDoDataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getAllCustomerTODO = $this->_crmcustomertodoObj->GetAllAgentNotCompletedToDo(10, '', $AgencySysId, $CustomerSysId);
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getAllCustomerTODO);
$paginator->setItemCountPerPage(10); // number of items to show per page
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'getCustomerAllToDo');
$html->assign('data', $paginator);
echo $bodyText = $html->render('ajax-html.phtml');
}
public function senddynamicpkgproposalwithleadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
// echo "<pre>"; print_r($getData);die;
$pkgCheckInDate = $getData['pkgCheckInDate'];
$IsShareWithGST = isset($getData['GSTIncluded']) ? $getData['GSTIncluded'] : 0;
$tripdate = date("Y-m-d", strtotime(str_replace('/', '-', $pkgCheckInDate)));
$pkgCheckOutDate = $getData['pkgCheckOutDate'];
$roomlp = $getData['roomlp'] ? $getData['roomlp'] : '';
$IsB2BAgent = $getData['IsB2BAgent'];
$queryTPSysId = $getData['queryTPSysId'];
$MarketPlaceId = ($IsB2BAgent == 1) ? 2 : 1;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$tpproposalID = $getData["TravelPlanId"];
$custname = $fname = $getData["custname"];
$custemail = $email = $getData["custemail"];
$CustomerSysId = base64_decode($getData['selectedCustomerId']);
$catID = !empty($getData['catID']) ? $getData['catID'] : 1;
$tourID = !empty($getData['tourID']) ? $getData['tourID'] : 1;
$MealTypeId = !empty($getData['mID']) ? $getData['mID'] : 0;
$aboutpackage = !empty($getData['aboutpackage']) ? $getData['aboutpackage'] : '';
$tripaddress = !empty($getData['tripaddress']) ? $getData['tripaddress'] : '';
$cardcharges = !empty($getData['cardcharges']) ? $getData['cardcharges'] : 1;
$MarkupArray = !empty($getData['MarkUp']) ? $getData['MarkUp'] : 0;
$discountValue = !empty($getData['discountValue']) ? $getData['discountValue'] : 0;
$gsttype = !empty($getData['gsttype']) ? $getData['gsttype'] : '';
$SACCode = !empty($getData['sac_code']) ? $getData['sac_code'] : 440063; // default value 440063 for Tour Oprators..
$AgencyMarkUp = !empty($getData['AgencyMarkUp1']) ? $getData['AgencyMarkUp1'] : 0;
$EmailTemplateType = isset($getData['EmailTemplateType']) ? $getData['EmailTemplateType'] : 1;
$EmailTemplateColor = isset($getData['EmailTemplateColor']) ? $getData['EmailTemplateColor'] : 'default';
$objPackage = new Travel_Model_TblPackage();
// $getversionid = $this->_crmcusttravelplan->CheckCustomerWithLeadId($tpproposalID);
// $travelplandata = $this->_crmcusttravelplan->GetTravelPlan($getversionid[0]['TPId']);
// $marketwiseratebyo = $objPackage->GetDynamicMarketwiserateDate($getversionid[0]['TPId'],$tripdate,$catID, $tourID);
// $travelplandata[0]['MarkUp']=$MarkupArray[0]; // this added by amit for extra markup type in share popoup
// $travelplandata[0]['CustomDiscount']=$discountValue[0];// this added by amit for extra markup type in share popoup
//# code added by amit
$roomjson = array();
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= $getData['roomlp']; $k++) {// customise room info array acc to api
$roomjson[$k]['Adult'] = $getData['adult_' . $k];
unset($getData['adult_' . $k]);
if ($roomjson[$k]['Adult'] == 3) {
$roomjson[$k]['AdultBedType'] = $getData['adultcl_extrabed_' . $k . '_3'];
unset($getData['adultcl_extrabed_' . $k . '_3']);
}
$totaladult = $totaladult + $roomjson[$k]['Adult'];
$roomjson[$k]['Child'] = $getData['child_' . $k];
unset($getData['child_' . $k]);
$totalchild = $totalchild + $roomjson[$k]['Child'];
$roomjson[$k]['Infant'] = $getData['infant_' . $k];
unset($getData['infant_' . $k]);
$totalInfant = $totalInfant + $roomjson[$k]['Infant'];
for ($j = 1; $j <= $roomjson[$k]['Child']; $j++) {
$roomjson[$k]['ChildAge_' . $j] = $getData['child_age_' . $k . '_' . $j];
unset($getData['child_age_' . $k . '_' . $j]);
$roomjson[$k]['ChildBedType_' . $j] = $getData['child_extrabed_' . $k . '_' . $j];
unset($getData['child_extrabed_' . $k . '_' . $j]);
}
$roomjson[$k]['departuredate'] = $pkgCheckInDate;
$roomjson[$k]['returndate'] = $pkgCheckOutDate;
}
// for ($k = 1; $k <= $roomlp; $k++) { // customise room info array acc to api
// $roomjson[$k]['Adult'] = $getData['adult_' . $k]; unset($getData['adult_' . $k]);
// $roomjson[$k]['Child'] = $getData['child_' . $k]; unset($getData['child_' . $k]);
// $roomjson[$k]['bedtype'] = $getData['extrabed_' . $k];unset($getData['extrabed_' . $k]);
// $roomjson[$k]['Infant'] = @$getData['infant_' . $k];unset($getData['infant_' . $k]);
//
// $totaladult = $totaladult + @$roomjson[$k]['Adult'];
// $totalchild = $totalchild + @$roomjson[$k]['Child'];
// $totalInfant = $totalInfant + @$roomjson[$k]['Infant'];
// for($j=1;$j<=$roomjson[$k]['Child'];$j++){
// $roomjson[$k]['ChildAge_'.$j] = @$getData['child_'.$k.'_'.$j];unset($getData['child_'.$k.'_'.$j]);
// }
// $roomjson[$k]['departuredate'] = $pkgCheckInDate;
// $roomjson[$k]['returndate'] = $pkgCheckOutDate;
// }
$roomsInfoJson = Zend_Json::encode($roomjson);
$totaltraveller = $totalchild + $totaladult;
//$roomsArray = Zend_Json::decode($roomsArray);
// echo "<pre>"; print_r($roomsArray);die;
$countRooms = count($roomjson);
/* -------------Customised parameters for rate calculation-------------------- */
$getData['travelers'] = $totaltraveller;
$getData['roomlp'] = $countRooms; // count of room info array
$StaxDiscount = !empty($getData['StaxDiscount1']) ? $getData['StaxDiscount1'] : 0;
$StaxMarkUp = !empty($getData['StaxMarkUp1']) ? $getData['StaxMarkUp1'] : 0;
$destPlaceArr = isset($getData['DestinationPlaces']) ? json_decode(base64_decode($getData['DestinationPlaces']), true) : '';
//print_r($destPlaceArr);
if (isset($destPlaceArr) && !empty($destPlaceArr)) {
foreach ($destPlaceArr as $destIds => $destValues) {
$destIdsArr[] = $destIds;
$destValuesArr[] = $destValues;
}
$destinationIds = implode(',', $destIdsArr);
$destinationValues = implode(', ', $destValuesArr);
}
if (!empty($pkgCheckInDate)) {
$explode_trip_start = explode('/', $pkgCheckInDate);
$main_trip_start_date = $explode_trip_start[2] . '-' . $explode_trip_start[1] . '-' . $explode_trip_start[0];
} else {
$main_trip_start_date = date('Y-m-d');
$pkgCheckInDate = date("d/m/Y");
}
if (!empty($pkgCheckOutDate)) {
$explode_trip_start = explode('/', $pkgCheckOutDate);
$main_trip_end_date = $explode_trip_start[2] . '-' . $explode_trip_start[1] . '-' . $explode_trip_start[0];
} else {
$main_trip_end_date = date('Y-m-d');
$pkgCheckOutDate = date("d/m/Y");
}
$travelplandata = $this->_crmcusttravelplan->GetTravelPlanByCustomer($tpproposalID);
if (count($travelplandata) == 0) {
$status = array("status" => 'fail', "url" => '', "availability" => 'false', "addtional" => 0);
echo Zend_Json::Encode($status);
exit;
}
$priceData = Zend_Controller_Action_HelperBroker::getStaticHelper('DynamicPackageSeasonCost')->GetDynamicPackagePrice($roomsInfoJson, $tpproposalID, $catID, $tourID, $MealTypeId, $main_trip_start_date, 'Customer', 'Calculate', NULL, $MarketPlaceId);
// $marketwiseratebyoCust = $this->_crmcusttravelplan->GetDynamicCustomerMarketwiserateDate($tpproposalID,$tripdate,$catID,$tourID);
$travelplandata[0]['MarkUp'] = ($MarkupArray[0] > 0) ? $MarkupArray[0] : 0;
$travelplandata[0]['CustomDiscount'] = ($discountValue[0] > 0) ? $discountValue[0] : 0;
// echo '<pre>'; print_r($priceRate);die;
// $priceRate = Zend_Controller_Action_HelperBroker::getStaticHelper('DynamicPackage')->getDynamicPackageRate($totaltraveller, $travelplandata[0],$marketwiseratebyoCust,$gsttype);
//$priceRateMaster = Zend_Controller_Action_HelperBroker::getStaticHelper('DynamicPackage')->getDynamicPackageRate($totaltraveller, $travelplandata[0],$marketwiseratebyo,$gsttype);
$getData['AdvBookingPercent'] = $travelplandata[0]['AdvBookingPercent'];
// $priceRate = $this->_crmcusttravelplan->getPackageRate($totaltraveller, $tpproposalID, $pkgCheckInDate, $travelplandata[0],$catID);
// $priceData = Zend_Json::decode($priceRate, true);
$Price = $priceData['cwom'];
$NetPrice = $getData['displayFinalValue1'];
$GSTApplicableOn = $gsttype;
$packageCost = (float) $Price + (float) $AgencyMarkUp;
$AgencyExtraMarkUp = $MarkupArray[0];
$AgencyDiscount = $discountValue[0];
$intProductType = 9;
$intProductGeoType = 1; // 1 For Domestic, 2 For International
$arrInputData = array(
"GSTApplicableOn" => $GSTApplicableOn,
"intProductType" => $intProductType,
"intProductGeoType" => $intProductGeoType,
"Cost" => $packageCost,
"AgencyMarkUp" => $AgencyMarkUp,
"AgencyExtraMarkUp" => $AgencyExtraMarkUp,
"AgencyDiscount" => $AgencyDiscount
);
$arrGSTCalculations = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->calculateGST($arrInputData);
$XServiceTaxAmount = ceil($arrGSTCalculations['GSTAmount']);
$createDate = date('Y-m-d H:i:s');
$AgentSysId = $travelplandata[0]['AgentSysId'];
$availability = ($NetPrice > 0) ? 1 : 0;
$data = array(
'CustomerSysId' => $CustomerSysId,
'SharedMealPlanType' => $MealTypeId,
'EmailText' => $aboutpackage,
'EmailDestination' => $tripaddress,
'ProposalEmailTo' => trim($custemail),
'IsShared' => 1,
'IsPriceShared' => 1,
'IsCardChrgToCustomer' => $cardcharges,
'Price' => $Price ? $Price : 0,
'NetPrice' => $NetPrice ? $NetPrice : 0,
'DiscountVal' => $getData['DiscountVal'] ? $getData['DiscountVal'] : 0,
'DiscountType' => $getData['DiscountType'] ? $getData['DiscountType'] : 0,
'CustomDiscount' => ($discountValue[0] > 0) ? $discountValue[0] : 0,
'AgentsCustomServiceTaxAmount' => $StaxMarkUp ? $StaxMarkUp : 0,
'ServiceTaxOnCustomDiscount' => $StaxDiscount ? $StaxDiscount : 0,
'MarkUp' => ($MarkupArray[0] > 0) ? $MarkupArray[0] : 0,
'AgencyMarkUp' => $AgencyMarkUp ? $AgencyMarkUp : 0,
'XServiceTaxAmount' => $XServiceTaxAmount,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => 0,
'GTXMarkup' => 0,
'MinPrice' => $travelplandata[0]['MinPrice'] ? $travelplandata[0]['MinPrice'] : 0,
'IsCardChrgToCustomer' => $cardcharges,
'EmailText' => $aboutpackage,
'EmailDestination' => $destinationValues,
'StartDate' => $main_trip_start_date,
'ValidTill' => $main_trip_end_date ? $main_trip_end_date : '',
'EconomyMask' => !empty($catID) ? $catID : 1,
'TourType' => !empty($tourID) ? $tourID : 1,
'GSTSharedMode' => $gsttype, // (1 for 5% on total Cost, 2 for 18% on Service Fee) to detect what type and how much tax will apply to customer
'SACCode' => $SACCode,
'RoomInfoJson' => $roomsInfoJson ? $roomsInfoJson : '',
'UpdateDate' => $createDate,
'EmailTemplateType' => !empty($EmailTemplateType) ? $EmailTemplateType : '1',
'EmailTemplateColor' => !empty($EmailTemplateColor) ? $EmailTemplateColor : '1',
'IsShareWithGST' => $IsShareWithGST,
'SelectPricingType' => $SelectPricingType
);
$where = array('TPSysId = ? ' => $tpproposalID);
$updateId = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($data, $where);
$dataQuery = array(
'CustomerSysId' => $CustomerSysId,
'SharedMealPlanType' => $MealTypeId,
'EmailText' => $aboutpackage,
'EmailDestination' => $tripaddress,
'ProposalEmailTo' => trim($custemail),
'IsShared' => 1,
'IsPriceShared' => 1,
'IsCardChrgToCustomer' => $cardcharges,
'Price' => $Price ? $Price : 0,
'NetPrice' => $NetPrice ? $NetPrice : 0,
'CustomDiscount' => ($discountValue[0] > 0) ? $discountValue[0] : 0,
'AgentsCustomServiceTaxAmount' => $StaxMarkUp ? $StaxMarkUp : 0,
'ServiceTaxOnCustomDiscount' => $StaxDiscount ? $StaxDiscount : 0,
'MarkUp' => ($MarkupArray[0] > 0) ? $MarkupArray[0] : 0,
'AgencyMarkUp' => $AgencyMarkUp ? $AgencyMarkUp : 0,
'StartDate' => $main_trip_start_date,
'ValidTill' => $main_trip_end_date ? $main_trip_end_date : '',
'EconomyMask' => !empty($catID) ? $catID : 1,
'TourType' => !empty($tourID) ? $tourID : 1,
'StatusType' => 2,
'UpdateDate' => $createDate,
'SACCode' => $SACCode,
'RoomInfoJson' => $roomsInfoJson ? $roomsInfoJson : '',
'EmailTemplateType' => !empty($EmailTemplateType) ? $EmailTemplateType : '1',
'EmailTemplateColor' => !empty($EmailTemplateColor) ? $EmailTemplateColor : 'default',
'IsShareWithGST' => $IsShareWithGST,
'SelectPricingType' => $SelectPricingType
);
$whereQuery = array('TPSysId = ? ' => $travelplandata[0]['MasterTPSysId']);
$updateId = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($dataQuery, $whereQuery);
//call function for supplier enquiry
Zend_Controller_Action_HelperBroker::getStaticHelper('PackageSearch')->enqsupupdatestatus($getData['EnqSupplierSysId'], 2); //2 for proposal
//#end of call function for supploer enquiry
// die;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$currencyType = $travelplandata[0]['CurrencyType'];
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($currencyType);
$CurrSymbol = trim($currencyTypeArr['Symbol']);
// $GrandTotal = isset($priceData['GrandTotal']) ? $priceData['GrandTotal'] : 0;
$GrandTotal = isset($getData['displayFinalValue1']) ? round($getData['displayFinalValue1']) : round($priceData['GrandTotal']);
// $sentprice = $CurrSymbol . ' ' . $GrandTotal;
$travelplandataUpdated = $this->_crmcusttravelplan->GetTravelPlanByCustomer($tpproposalID);
if ($IsShareWithGST == 1) {
$sentprice = $CurrSymbol . ' ' . round($GrandTotal, 2);
} else {
$PackageArray = $travelplandataUpdated[0];
$GrandTotal = $GrandTotal - ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
$sentprice = $CurrSymbol . ' ' . round($GrandTotal, 2);
}
$enctpproposalID = base64_encode($tpproposalID);
$secureCode = Catabatic_ValidateCustomer::secureCode($enctpproposalID, 1);
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
//added by pooja on 5 sept 2017
if ($agentDetails['IsB2CSite'] == 1) {
$booknowurl = $agentDetails['Url'] . "detail/index/view/id/" . base64_encode($booknowurl);
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 1)) {
$booknowurl = $agentDetails['Url'] . "hellogtx/index.html?id=" . base64_encode($booknowurl);
} else if (($agentDetails['IsB2CSite'] == 2) && ($agentDetails['IsSiteType'] == 0)) {
$booknowurl = $agentDetails['Url'] . "hellogtx/gtx.php?id=" . base64_encode($booknowurl);
}
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $AgencySysId;
if (isset($agentDetails['Logo']) && $agentDetails['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $agentDetails['Logo'];
} else {
$AgencyLogo = $path . '/gtx-logo-white.png';
}
$params['agency_logo'] = $AgencyLogo;
$params['TourTypeId'] = $catID;
$params['trip_address'] = $tripaddress;
$params['shared_url'] = $booknowurl;
$params['sent_price'] = $sentprice; //total price with currency
$params['price'] = $GrandTotal; // total price
$params['travelers'] = array('Adults' => $totaladult, 'Child' => $totalchild, 'Infants' => $totalInfant); // travelers to display
$params['cust_name'] = $custname;
$params['about_package'] = $aboutpackage;
$params['agent_firstname'] = $agentDetails['FirstName'] . ' ' . $agentDetails['LastName'];
$params['agent_primarycontact'] = $agentDetails['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $agentDetails['EmailId'];
$params['agencyDisplayName'] = $agentDetails['DisplayName'] ? $agentDetails['DisplayName'] : $agentDetails['Title'];
$params['PrimaryEmail'] = $agentDetails['PrimaryEmail'];
$params['PackageArray'] = $travelplandataUpdated[0];
$params['agentDetails'] = $agentDetails;
$params['TPSysId'] = $tpproposalID;
$params['AgentSysId'] = $AgentSysId;
$params['AgencySysId'] = $AgencySysId;
$params['IsSMSApi'] = $this->IsSMSApi;
// $subject = 'Proposal Details';
$subject = 'Your ' . $tripaddress . ' trip details from ' . $params['agencyDisplayName'];
// $custemail = $getData['custemail'];
$ccemail = $getData['ccemail'] ? $getData['ccemail'] : '';
$mailToCC = array();
if ($ccemail != '') {
$mailToCC = explode(',', $ccemail);
}
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->SendProposalToCustomer($custemail, $subject, $params, $mailToCC);
//send sms to when proposal sent
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($custemail), $AgencySysId);
$mobile = trim($getcustomerdetails['Contacts']);
$params['customer_contact'] = trim($mobile);
if (trim($params['customer_contact']) != '') {
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$params['arrSMSStatisticsType'] = $arrSMSStatisticsType[0];
// $smsStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->SendSmsToCustomer($params);
}
//#end of send sms
if ($emailStatus == 1) {
$whatsappmessage = "Dear $custname, Thanks for your query for *$destinationValues*, Destination Covered: *$destinationValues*, No. of Pax: *$totaladult Adult(s) $totalchild Child(s) $totalInfant Infant(s)*, Total Cost: *$sentprice* You can call $firstname at $primarycontact or email at $AgenctEmailId or whatsapp me here. To know more and see proposal in detail with hotel details $booknowurl regards, $firstname ";
$status = "success";
$contactno = trim($getcustomerdetails['countrycode']) . trim($getcustomerdetails['Contacts']);
} else {
$whatsappmessage = "";
$status = "successemailfail";
$contactno = "";
}
if ($status == 'success') {
$res = array("status" => $status, 'whatsapp' => $whatsappmessage, 'contactno' => $contactno, "url" => $booknowurl, "availability" => $availability, "addtional" => $arrGSTCalculations, "proposalId" => $tpproposalID);
$response = array('status' => 'success', 'message' => 'Proposal has been shared with customer.', 'res' => $res);
} else if ($status == 'successemailfail') {
$response = array('status' => 'fail', 'message' => 'Proposal is created but there is some error in sending email.');
} else {
$response = array('status' => 'fail', 'message' => 'There is some error. Please try after sometime.');
}
echo Zend_Json::Encode($response);
exit;
}
}
public function proposalFollowUpHistoryAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$CustomerSysId = $this->getRequest()->getParam('CustomerSysId');
$MasterTPSysId = $this->getRequest()->getParam('MasterTPSysId');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrCustomerTODOHistory = $crmcustomerObj->GetAllCustomerToDoByLeadId($CustomerSysId, $MasterTPSysId);
$this->view->arrCustomerTODOHistory = $arrCustomerTODOHistory;
}
}
public function viewVisaApplicantDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$rowsCount = $this->_HtmlPurifier->filter($this->_request->getParam('rowsCount'));
$getData = $this->getRequest()->getPost();
$this->view->rowsCount = $rowsCount;
$this->view->getData = $getData;
$this->view->type = 'getVisaApplicantDetail';
echo $bodyData = $this->render('ajax-html');
}
public function sendBulkEmailToCustomerAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$TPSysIds = $this->getRequest()->getParam('TPSysIds');
$templateId = $this->getRequest()->getParam('templateId');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$agentId = $this->intLoggedinUserId;
// Agency Details...
$arrAgencyDetails = $this->_crmcusttravelplan->getAgentDetails($agentId);
//$arrAgencyDetails = $this->_agencyObj->getAgencyDataById($AgencySysId); //get agent details
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $AgencySysId;
if (isset($arrAgencyDetails['Logo']) && $arrAgencyDetails['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $arrAgencyDetails['Logo'];
} else {
$AgencyLogo = $path . '/default_company_logo.jpg';
}
// Mail Template Details...
$arrTempDetails = $this->_agencyObj->getAgencyEmailTemplateByTemplateId($templateId);
$Subject = trim($arrTempDetails['Subject']);
$MessageBody = trim($arrTempDetails['MessageBody']);
$params = array();
$params['agency_logo'] = $AgencyLogo;
$params['company_name'] = $arrAgencyDetails['DisplayName'];
$params['MessageBody'] = $MessageBody;
$params['agent_firstname'] = $arrAgencyDetails['FirstName'] . ' ' . $arrAgencyDetails['LastName'];
$params['agent_primarycontact'] = $arrAgencyDetails['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $arrAgencyDetails['EmailId'];
$params['agencyDisplayName'] = $arrAgencyDetails['DisplayName'] ? $arrAgencyDetails['DisplayName'] : $arrAgencyDetails['Title'];
$params['PrimaryEmail'] = $arrAgencyDetails['PrimaryEmail'];
$params['agentDetails'] = $arrAgencyDetails;
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => '',
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $agentId,
"Title" => $Subject,
"Source" => $arrEmailStatisticsType[2], // 4 For Promotional Emails
"Status" => "",
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
if (!empty($TPSysIds)) {
foreach ($TPSysIds as $TPSysId) {
if ($TPSysId > 0) {
$arrEmailStatistics['TPSysId'] = $TPSysId;
$arrTravelPlanDetails = $this->_crmcusttravelplan->getTravelPlanDetailsByTPSysId(trim($TPSysId), 'Query');
$EmailId = trim($arrTravelPlanDetails[0]['EmailId']);
$FirstName = trim($arrTravelPlanDetails[0]['FirstName']);
$LastName = trim($arrTravelPlanDetails[0]['LastName']);
$params['cust_name'] = @$FirstName . " " . @$LastName;
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->sendBulkEmailToCustomer($EmailId, $Subject, $params, $arrEmailStatistics);
}
}
$response = array('success' => true, 'msg' => 'Email sent to customer(s) successfully.');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! there might be some technical error.');
echo json_encode($response);
exit;
}
}
}
public function sendBulkEmailToCustomerForQueryAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$TPSysIds = $this->getRequest()->getParam('TPSysIds');
$templateId = $this->getRequest()->getParam('templateId');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$agentId = $this->intLoggedinUserId;
// echo "<pre>";print_r($TPSysIds);exit;
// Agency Details...
$arrAgencyDetails = $this->_crmcusttravelplan->getAgentDetails($agentId);
//$arrAgencyDetails = $this->_agencyObj->getAgencyDataById($AgencySysId); //get agent details
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $AgencySysId;
if (isset($arrAgencyDetails['Logo']) && $arrAgencyDetails['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $arrAgencyDetails['Logo'];
} else {
$AgencyLogo = $path . '/default_company_logo.jpg';
}
// Mail Template Details...
$arrTempDetails = $this->_agencyObj->getAgencyEmailTemplateByTemplateId($templateId);
$Subject = trim($arrTempDetails['Subject']);
$MessageBody = trim($arrTempDetails['MessageBody']);
$params = array();
$params['agency_logo'] = $AgencyLogo;
$params['company_name'] = $arrAgencyDetails['DisplayName'];
$params['MessageBody'] = $MessageBody;
$params['agent_firstname'] = $arrAgencyDetails['FirstName'] . ' ' . $arrAgencyDetails['LastName'];
$params['agent_primarycontact'] = $arrAgencyDetails['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $arrAgencyDetails['EmailId'];
$params['agencyDisplayName'] = $arrAgencyDetails['DisplayName'] ? $arrAgencyDetails['DisplayName'] : $arrAgencyDetails['Title'];
$params['PrimaryEmail'] = $arrAgencyDetails['PrimaryEmail'];
$params['agentDetails'] = $arrAgencyDetails;
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => '',
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $agentId,
"Title" => $Subject,
"Source" => $arrEmailStatisticsType[2], // 4 For Promotional Emails
"Status" => "",
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
if (!empty($TPSysIds)) {
foreach ($TPSysIds as $TPSysIdt) {
$TPSysIdEx = base64_decode($TPSysIdt);
$TPSysIdExt = explode("_", $TPSysIdEx);
$TPSysId = $TPSysIdExt[0];
$Type = $TPSysIdExt[1];
$arrEmailStatistics['TPSysId'] = $TPSysId;
if ($Type == 'LEAD') {
$arrTravelPlanDetails[0] = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($TPSysId);
} else {
$arrTravelPlanDetails = $this->_crmcusttravelplan->getTravelPlanDetailsByTPSysId((int) $TPSysId, 'Query');
}
//echo "<pre>";print_r($arrTravelPlanDetails);die;
$EmailId = trim($arrTravelPlanDetails[0]['EmailId']);
$FirstName = trim($arrTravelPlanDetails[0]['FirstName']);
$LastName = trim($arrTravelPlanDetails[0]['LastName']);
$params['cust_name'] = trim($FirstName . " " . $LastName);
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->sendBulkEmailToCustomer($EmailId, $Subject, $params, $arrEmailStatistics);
}
$response = array('success' => true, 'msg' => 'Email sent to customer(s) successfully.');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! there might be some technical error.');
echo json_encode($response);
exit;
}
}
}
public function bulkSmsTemplatesAction() {
$this->view->layout()->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getSmsTemplate = $this->_crmcustomertemplateObj->GetAllSmsTemplates(1); //1 for sms 2 for email
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$this->view->type = 'ViewSmsTemplate';
$this->view->agentDetails = $getAgentDetails;
$this->view->agencyDetails = $getAgencyDetail;
$this->view->AgencySysId = $AgencySysId;
$this->view->data = $getSmsTemplate;
$this->render('ajax-bulk-sms-html');
}
}
public function sendBulkSmsToCustomerAction() {
$this->view->layout()->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$this->SMSURL = Catabatic_Helper::getSMSURL();
$this->SMSMETHOD = Catabatic_Helper::getSMSMETHOD();
$this->SMSAPIKEY = Catabatic_Helper::getSMSAPIKEY();
$this->SMSSENDER = Catabatic_Helper::getSMSSENDER();
$this->SMSFORMAT = Catabatic_Helper::getSMSFORMAT();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$TPSysIds = $this->getRequest()->getParam('TPSysIds') ? $this->getRequest()->getParam('TPSysIds') : '';
$CustomerSysIds = $this->getRequest()->getParam('CustomerSysIds') ? $this->getRequest()->getParam('CustomerSysIds') : '';
$smsTemplateId = $this->getRequest()->getParam('smsTemplateId') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('smsTemplateId'))) : '';
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, $smsTemplateId); //1 for sms 2 for email
if (!empty($TPSysIds)) {
$intI = 0;
foreach ($TPSysIds as $TPSysId) {
//Customer Details...
$CustomerSysId = isset($CustomerSysIds[$intI]) ? $CustomerSysIds[$intI] : 0;
$getcustomerdetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$customerName = trim(stripslashes($getcustomerdetails['FirstName'])) . ' ' . trim(stripslashes($getcustomerdetails['LastName']));
$agentname = $getAgentDetails['FirstName'] ? $getAgentDetails['FirstName'] : $getAgentDetails['Title'];
$agencyname = (isset($getAgentDetails['DisplayName']) && !empty($getAgentDetails['DisplayName'])) ? trim($getAgentDetails['DisplayName']) : trim(trim($getAgentDetails['Title']));
$agentcontact = trim($getAgentDetails['ContactNo1']);
$mobile_no = trim($getcustomerdetails['Contacts']);
//Customer Details Ends...
//TravelPlan Details...
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId);
$tripaddress = addslashes(trim($travelPlanDetail[0]['DestinationPlaces']));
$price = round($travelPlanDetail[0]['NetPrice']);
$refnumber = 'NA';
$tripdate = $travelPlanDetail[0]['StartDate']->format('d-M-y');
$triptitle = addslashes(trim($travelPlanDetail[0]['Title']));
$updateData = new Payment_Model_Checkotp();
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($TPSysId), 1);
$link = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . base64_encode($TPSysId) . '/code/' . $secureCode;
$params['TPSysId'] = $TPSysId;
$params['shared_url'] = $link;
$params['AgencySysId'] = $AgencySysId;
$params['AgentSysId'] = $AgentSysId;
$shorturl_response = Zend_Controller_Action_HelperBroker::getStaticHelper('ShortUrl')->url_get($params);
if (isset($shorturl_response['status_code']) && $shorturl_response['status_code'] == 200) {
$link = $shorturl_response['data']['short_url'];
}
$NetPrice = round($travelPlanDetail[0]['NetPrice']);
$objPkgBooking = new Travel_Model_TblPackageBooking();
$amountPaid = $objPkgBooking->getAmountPaidForProposalByTPSysId($travelPlanDetail[0]['TPSysId']);
$TotalAmountPaid = !empty($amountPaid['TotalAmountPaid']) ? $amountPaid['TotalAmountPaid'] : 0;
$balanceamount = round($NetPrice - $TotalAmountPaid);
if ($balanceamount == 0) {
$balanceamount = "Nil";
}
//TravelPlan Details Ends...
$message = trim(stripslashes($getSmsTemplate[0]['Body']));
$message = str_replace('##customername', $customerName, $message);
$message = str_replace('##agencyname', $agencyname, $message);
$message = str_replace('##link', $link, $message);
$message = str_replace('##agentname', $agentname, $message);
$message = str_replace('##agentcontact', $agentcontact, $message);
$message = str_replace('##tripaddress', $tripaddress, $message);
$message = str_replace('##price', $price, $message);
$message = str_replace('##balanceamount', $balanceamount, $message);
$message = str_replace('##refnumber', $refnumber, $message);
$message = str_replace('##tripdate', $tripdate, $message);
$message = str_replace('##triptitle', $triptitle, $message);
$this->postFields = "";
$this->postFields .= "&method=$this->SMSMETHOD";
$this->postFields .= "&api_key=$this->SMSAPIKEY";
$this->postFields .= "&to=$mobile_no";
$this->postFields .= "&sender=$this->SMSSENDER";
$this->postFields .= "&message=$message";
$this->postFields .= "&format=$this->SMSFORMAT";
$postURL = $this->SMSURL;
// Added By Pardeep Panchal For SMS Count...
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$arrSMSStatistics = array(
"TPSysId" => $TPSysId,
"TypeSysId" => 2, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $message,
"Source" => $arrSMSStatisticsType[0], // 2 Resend Proposals (Bulk)
"Status" => '',
"RefSysId" => '',
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For SMS Count Ends...
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$IsSMSApi = $sessionLogin_user->agencyDetails['IsSMSApi'];
// $resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics, $IsSMSApi);
$intI++;
}
$response = array('success' => true, 'msg' => 'SMS sent to customer(s) successfully.');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! there might be some technical error.');
echo json_encode($response);
exit;
}
}
}
public function changeStatusProposalBulkAction() {
$this->view->layout()->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$TPSysIds = $this->getRequest()->getParam('TPSysIds') ? $this->getRequest()->getParam('TPSysIds') : '';
$date = date('Y-m-d H:i:s');
if (count($TPSysIds)) {
foreach ($TPSysIds as $id) {
$insuranceMdl = new Insurance_Model_Insurance();
//$editData = ['StatusType' => 11,'UpdateDate' => $date,'IsMarlForDel' => 1]; // 11 for proposal expired
$editData = ['UpdateDate' => $date, 'IsMarkForDel' => 1]; // 11 for proposal expired
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($editData, ['TPSysId =?' => $id]);
}
}
$response = array('success' => true, 'msg' => 'Proposal status changed successfully, And record(s) Moved to Archived Proposals List.');
echo Zend_Json::encode($response);
exit;
}
}
public function listarchiveproposalAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$roleID = $sessionLogin_user->UserRole;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$getData = [];
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($agencysysID);
if ($getRoleDetail['IsAdmin'] == true) {
if ($this->checkIsAdmin() == true) {
$getData['AgentSysId'] = '';
}
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
// $getData=$this->sanitizeData($getData);
$customerProposalId = trim($getData['customerProposalId']);
$getData['customerProposalId'] = $customerProposalId;
$customerProposalIdchk = '';
if ($customerProposalId != "") {
$explodeProposal = explode("/", $customerProposalId);
if (count($explodeProposal) == 4) {
$customerProposalId = $explodeProposal[2];
} else if (count($explodeProposal) == 1) {
$customerProposalId = $explodeProposal[0];
} else {
$customerProposalId = intval($customerProposalIdchk);
}
}
$getData['customerProposalId'] = trim($getData['customerProposalId']);
$getData['TPSysId'] = $customerProposalId;
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getRecordList = $this->_crmcusttravelplan->getArchiveProposalList($getData);
} else {
$getData['AgencySysId'] = $agencysysID;
$getRecordList = $this->_crmcusttravelplan->getArchiveProposalList($getData);
}
} else {
$getData['AgencySysId'] = $agencysysID;
$leadSourcesIds = $getCustomerList = [];
$getData['AgentSysId'] = $AgentSysId;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['AgencySysId'] = $agencysysID;
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getRecordList = $this->_crmcusttravelplan->getArchiveProposalList($getData);
} else {
$getRecordList = $this->_crmcusttravelplan->getArchiveProposalList($getData);
}
}
// echo '<pre>'; print_r($getRecordList);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getRecordList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$this->view->leadSourceList = $getleadSource;
$this->view->isAdmin = $getRoleDetail['IsAdmin'];
$this->view->actionName = $this->getRequest()->getActionName();
}
// Added By Ranvir Singh on 28 Sep 2017
public function proposalItineraryRequiredAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$CustomerSysId = $this->getRequest()->getParam('CustomerSysId');
$MasterTPSysId = $this->getRequest()->getParam('MasterTPSysId');
$TPIntSysId = $this->getRequest()->getParam('TPIntSysId');
$crmcustomerObj = new Travel_Model_CRM_Customer();
$type = 2;
$arrCustomerTODOHistory = $crmcustomerObj->GetAllCustomerToDoITIByLeadId($CustomerSysId, $MasterTPSysId, $TPIntSysId, $type);
// Zend_Debug::dump($arrCustomerTODOHistory);
$this->view->arrCustomerTODOHistory = $arrCustomerTODOHistory;
}
}
public function getCustomerTravelHistoryWantToGoAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
//echo $mobilenum;
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$type = 4; // type 4 is used for manualy added want to go
$customerHistoryRcord = $custtravelhistoryObj->getCustomerTravelHistory($CustomerSysId, $AgencySysId, $type);
$customerHistoryRcordPKG = $custtravelhistoryObj->getCustomerTravelHistoryOnlyForPackage($CustomerSysId, $AgencySysId, $type);
$finalData = array();
$i = 0;
$j = 0;
if (!empty($customerHistoryRcord)) {
foreach ($customerHistoryRcord as $key => $val) {
$finalData[$i]['HaveBeenToSysId'] = $val['HaveBeenToSysId'];
$finalData[$i]['CountryName'] = $val['CountryName'];
$finalData[$i]['CityName'] = $val['CityName'];
$i++;
$j = $i++;
}
}
$k = $j;
if (!empty($customerHistoryRcordPKG)) {
foreach ($customerHistoryRcordPKG as $key => $val) {
$finalData[$k]['HaveBeenToSysId'] = $val['HaveBeenToSysId'];
$finalData[$k]['CountryName'] = $val['CountryName'];
$finalData[$k]['CityName'] = $val['CityName'];
$k++;
}
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
$html->assign('type', 'getCustomerTravelHistoryWantToGo');
$html->assign('data', $finalData);
echo $bodyText = $html->render('ajax-html.phtml');
}
public function deleteRecordAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$Id = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('Id')));
$Type = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('Type')));
// query for delete data in db created by amit kumar dubey on 12 october 2017 at 01:28 PM
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$date = date('Y-m-d H:i:s');
if ($Type == 'PROFILEHISTORY') {
$updateArray = array(
'IsActive' => '0',
'UpdateDate' => $date,
'IsMarkForDelete' => '1'
);
$cond = ' HaveBeenToSysId=' . $Id . ' AND AgencySysId=' . $AgencySysId . '';
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$updateRcord = $custtravelhistoryObj->UpdateAgencyCustomerTravelHistory($updateArray, $cond);
$status = "success";
} else {
$status = "failed";
}
}
$result = array("status" => $status, 'id' => $Id);
echo json_encode($result);
}
//code for display b2b customers
public function listb2bcustomerAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$IsB2bSite = $sessionLogin_user->agencyDetails['IsB2bSite'];
// $type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
// $orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
$IsB2BCustomer = 1;
$orderDetails = '';
$columnNameOrder = 'tb2.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$this->view->order = $orderBy;
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 1) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 0) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'companyname' && $order_type[1] == 1) {
$columnNameOrder = 'tb6.AgencyName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'companyname' && $order_type[1] == 0) {
$columnNameOrder = 'tb6.AgencyName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'DESC';
} else {
$orderQueryDate = 'DESC';
}
$orderDetails = $columnNameOrder . " " . $orderQueryDate . "";
}
//echo $orderDetails;
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$orderBy = $getData['order'];
$IsB2BCustomer = 1;
$orderDetails = '';
$columnNameOrder = 'tb2.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$this->view->order = $orderBy;
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'tb4.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'customername' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.FirstName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 1) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'leadsource' && $order_type[1] == 0) {
$columnNameOrder = 'tb3.Title';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'companyname' && $order_type[1] == 1) {
$columnNameOrder = 'tb6.AgencyName';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'companyname' && $order_type[1] == 0) {
$columnNameOrder = 'tb6.AgencyName';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'tb2.UpdateDate';
$orderQueryDate = 'DESC';
} else {
$orderQueryDate = 'DESC';
}
$orderDetails = $columnNameOrder . " " . $orderQueryDate . "";
}
// $getData=$this->sanitizeData($getData);
$getData = $this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmcustomerObj->getCustomerListAll($agencysysID, $getData, $orderDetails, $IsB2BCustomer);
} else {
//for superadmin
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
//end for superadmin
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$getData = array();
if ($getRoleDetail['IsAdmin'] == true) {
$getData['AgentSysId'] = '';
} else {
$getData['AgentSysId'] = $ReportingToSysId;
}
$getCustomerList = $this->_crmcustomerObj->getCustomerListAll($agencysysID, $getData, $orderDetails, $IsB2BCustomer);
}
// $agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
if ($sessionLogin_user->UserRoleTitle == 'Owner') {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $agencysysID, $ReportingToSysId);
}
$page = $this->getRequest()->getParam('page') != '' ? $this->getRequest()->getParam('page') : 1;
if (!empty($getData)) {
$page = isset($getData['page']) ? $getData['page'] : $page;
} else {
$page = $this->_getParam('page', $page);
}
$paginator = Zend_Paginator::factory($getCustomerList);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT_TWENTY);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//echo "<pre>";print_r($getCustomerList);die;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->agencyUser = $agencyUser;
$this->view->AgencySysId = $agencysysID;
$this->view->IsB2bSite = $IsB2bSite;
}
public function createGtxNetworkAgentLeadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$packageInclList = $this->_objPkg->getPackageInclusionList();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencySysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$getData = $this->getRequest()->getPost();
$TPSysId = $getData['TPSysId'];
$isFromSearchResult = $getData['isFromSearchResult'];
$leadRemark = $this->_HtmlPurifier->filter($this->getRequest()->getPost('leadRemark'));
$tpintsysID = $getData['itenaryID'];
$nooftraveler = $getData['travelers'];
$search_going_to = $getData['search_going_to'];
$get_cityname = rtrim($getData['multicities'], ',');
$getcityvalue = @$getData['search_multi_from'];
$noofdaysto = @$getData['noofdaysto'];
$currentOwnerSysId = isset($getData['currentOwnerSysId']) ? $getData['currentOwnerSysId'] : '';
$hotelpreference = @$getData['hotelpreference'];
if (isset($hotelpreference)) {
$hotelpreference = implode(",", $hotelpreference);
} else {
$hotelpreference = '';
}
$roomjson = array();
//$childcount = 1;
$childsage = '';
$TotAdultCount = 0;
$TotChildCount = 0;
$TotInfantCount = 0;
for ($k = 1; $k <= $getData['roomlp']; $k++) {
$childcount = $getData['child_' . @$k];
$roomjson[$k]['Adult'] = $getData['adult_' . @$k];
$roomjson[$k]['Child'] = $getData['child_' . @$k];
$roomjson[$k]['Infant'] = $getData['infant_' . @$k];
$TotAdultCount += $roomjson[$k]['Adult'];
$TotChildCount += $childcount;
$TotInfantCount += $roomjson[$k]['Infant'];
for ($c = 1; $c <= $childcount; $c++) {
$childsage = $getData['child_' . @$childcount . '_' . @$c];
$roomjson[$k]['ChildAge_' . $c] = $childsage;
}
$roomjson[$k]['bedtype'] = $getData['extrabed_' . @$k];
$roomjson[$k]['departuredate'] = $getData['search_specific_date'];
$roomjson[$k]['returndate'] = '';
}
if (!empty($search_going_to)) {
$search_going_to_dest = explode('__', $search_going_to);
$going_to_cityname = $search_going_to_dest[0];
$going_to_cityid = $search_going_to_dest[1];
}
$search_going_from = $getData['search_going_from'];
if (!empty($search_going_from)) {
$search_going_to_source = explode('__', $search_going_from);
$going_from_cityid = $search_going_to_source[0];
$going_from_cityname = $search_going_to_source[1];
}
// echo $DestinationPlaces;
$customerID = $getData['customerID'];
if (empty($getData['search_going_to'])) {
$response = array('success' => false, 'msg' => 'Please select destination city.');
echo json_encode($response);
exit;
}
if (empty($getData['search_specific_date'])) {
$response = array('success' => false, 'msg' => 'Please select date range.');
echo json_encode($response);
exit;
}
if (!empty($getData['search_theme'])) {
$search_theme = $getData['search_theme'];
for ($i = 0; $i < count($search_theme); $i++) {
$search_theme_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_theme[$i], $packageThemeList, 'PackType');
}
}
if (!empty($getData['search_food'])) {
$search_food = $getData['search_food'];
for ($i = 0; $i < count($search_food); $i++) {
$search_food_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_food[$i], $packageFoodPreferenceList, 'CuisineSysId');
}
}
if (!empty($getData['search_inclusions'])) {
$search_inclusion_array = $getData['search_inclusions'];
for ($i = 0; $i < count($search_inclusion_array); $i++) {
$search_inclusion_list[] = $this->_crmcusttravelplan->searchForInclusionId($search_inclusion_array[$i], $packageInclList, 'InclId');
}
}
if (!empty($search_theme_list)) {
$thememask = '1';
$char = '';
for ($k = 0; $k < count($packageThemeList); $k++) {
$char = in_array(@$packageThemeList[$k]['PackType'], @$search_theme_list) ? '1' : '0';
$thememask .= $char;
}
}
$char = '';
if (!empty($search_food_list)) {
$foodmask = '1';
$char = '';
for ($k = 0; $k < count($packageFoodPreferenceList); $k++) {
$char = in_array(@$packageFoodPreferenceList[$k]['CuisineSysId'], @$search_food_list) ? '1' : '0';
$foodmask .= $char;
}
}
$char = '';
if (!empty($search_inclusion_list)) {
$inclmask = '1';
for ($k = 0; $k < count($packageInclList); $k++) {
$char = in_array(@$packageInclList[$k]['InclId'], @$search_inclusion_list) ? '1' : '0';
$inclmask .= $char;
}
}
if (isset($getData['search_theme'])) {
$PackTypeMask = $getData['search_theme'] ? $thememask : '';
} else {
$PackTypeMask = '';
}
if (isset($getData['search_food'])) {
$FoodTypeMask = $getData['search_food'] ? $foodmask : '';
} else {
$FoodTypeMask = '';
}
if (isset($getData['search_inclusions'])) {
$InclMask = $getData['search_inclusions'] ? $inclmask : '';
} else {
$InclMask = '';
}
if (!empty($getData['search_price_range'])) {
$search_price_range = explode('__', @$getData['search_price_range']);
}
$min_price = $getData['search_price_range'] ? $search_price_range[0] : 0;
$max_price = $getData['search_price_range'] ? $search_price_range[1] : 0;
$planbookingID = 'Q/' . date('y');
$createDate = date('Y-m-d H:s:i');
if (!empty($getData['search_specific_date'])) {
$search_specific_date = explode('/', @$getData['search_specific_date']);
$plan_start_date = $search_specific_date[2] . '-' . $search_specific_date[1] . '-' . $search_specific_date[0];
}
$status = 1;
//$getData['RoomInfoJson']=json_encode($roomjson);
$sessionPackageQueryData = new Zend_Session_Namespace('sessionPackageQueryData');
if (!empty($sessionPackageQueryData->searchData)) {
$packageSearchResult = $getData;
$this->view->packageSearchResult = $packageSearchResult;
} else {
//$this->_redirect('/packagesearch');
}
$roominfojson = json_encode($roomjson);
$agentsysID = $this->intLoggedinUserId;
$citiesText = (isset($going_from_cityname) && !empty($going_from_cityname)) ? $going_from_cityname . '-' : '';
############ StartDate ###############
if (isset($plan_start_date) && !empty($plan_start_date)) {
$plan_enddate_date = $createDate;
if (isset($noofdaysto) && !empty($noofdaysto)) {
$plan_enddate_date = date('Y-m-d H:i:s', strtotime($plan_start_date . " +" . $noofdaysto . " days"));
}
}
$travelplandata = $this->_crmcusttravelplan->GetTravelPlan(1345);
//echo "<pre>";print_r($travelplandata);exit;
$AgencyNetworkQuery = array(
'PlanBookingId' => $planbookingID,
'MasterTPSysId' => '',
'AgencySysId' => $agencySysId,
'AgentSysId' => $agentsysID,
'CreatorSysId' => $agentsysID,
'StatusType' => 2,
'CustomerSysId' => $customerID,
'PlanType' => 5,
'InventoryType' => 5,
'MinPax' => $travelplandata[0]['MinPax'] ? $travelplandata[0]['MinPax'] : 0,
'PackRangeType' => $travelplandata[0]['PackRangeType'] ? $travelplandata[0]['PackRangeType'] : 0,
'Title' => $travelplandata[0]['Title'] ? $travelplandata[0]['Title'] : '',
'EconomyMask' => $travelplandata[0]['EconomyMask'] ? $travelplandata[0]['EconomyMask'] : 0,
'PackTypeMask' => $PackTypeMask ? $PackTypeMask : '',
'InclCatMask' => $travelplandata[0]['InclCatMask'] ? $travelplandata[0]['InclCatMask'] : 0,
'InclMask' => $InclMask ? $InclMask : '',
'ExclusionMask' => $travelplandata[0]['ExclusionMask'] ? $travelplandata[0]['ExclusionMask'] : '',
'PackSpecType' => $travelplandata[0]['PackSpecType'] ? $travelplandata[0]['PackSpecType'] : '',
'SupplierSysId' => isset($travelplandata[0]['SupplierSysId']) ? $travelplandata[0]['SupplierSysId'] : '0',
'PriceRange' => $pricerange,
'SeasonMask' => $travelplandata[0]['SeasonMask'] ? $travelplandata[0]['SeasonMask'] : 0,
'GeoType' => $travelplandata[0]['GeoType'] ? $travelplandata[0]['GeoType'] : 0,
'IsFixDatePlan' => $travelplandata[0]['IsFixDatePlan'] ? $travelplandata[0]['IsFixDatePlan'] : 0,
'IsFixPlan' => $travelplandata[0]['IsFixPlan'] ? $travelplandata[0]['IsFixPlan'] : 0,
'Details' => $travelplandata[0]['Details'] ? $travelplandata[0]['Details'] : '',
'ImageTN' => $travelplandata[0]['ImageTN'] ? $travelplandata[0]['ImageTN'] : '',
'ImgForList' => $travelplandata[0]['ImgForList'] ? $travelplandata[0]['ImgForList'] : '',
'ImgeDetails' => $travelplandata[0]['ImgeDetails'] ? $travelplandata[0]['ImgeDetails'] : '',
'StartDate' => $main_trip_start_date,
'ValidTill' => $main_trip_end_date ? $main_trip_end_date : '',
'PkgSellValidTill' => $PkgSellValidTill ? $PkgSellValidTill->format('Y-m-d') : '',
'Price' => $travelplandata[0]['Price'] ? $travelplandata[0]['Price'] : 0,
'CurrencyType' => $travelplandata[0]['CurrencyType'] ? $travelplandata[0]['CurrencyType'] : 0,
'DiscountMsg' => $travelplandata[0]['DiscountMsg'] ? $travelplandata[0]['DiscountMsg'] : '',
'DiscountType' => $travelplandata[0]['DiscountType'] ? $travelplandata[0]['DiscountType'] : 0,
'DiscountVal' => $travelplandata[0]['DiscountVal'] ? $travelplandata[0]['DiscountVal'] : 0,
'AdvBookingPercent' => $travelplandata[0]['AdvBookingPercent'] ? $travelplandata[0]['AdvBookingPercent'] : 0,
'AdvBookingDays' => $travelplandata[0]['AdvBookingDays'] ? $travelplandata[0]['AdvBookingDays'] : 0,
'NetPrice' => $travelplandata[0]['NetPrice'] ? $travelplandata[0]['NetPrice'] : 0,
'MinPrice' => $min_price ? $min_price : 0,
'MaxPrice' => $max_price ? $max_price : 0,
'TotalMinDays' => $travelplandata[0]['TotalMinDays'] ? $travelplandata[0]['TotalMinDays'] : 0,
'TotalMaxDays' => $travelplandata[0]['TotalMaxDays'] ? $travelplandata[0]['TotalMaxDays'] : 0,
'Hotels' => $travelplandata[0]['Hotels'] ? $travelplandata[0]['Hotels'] : '',
'PopularPlaces' => $travelplandata[0]['PopularPlaces'] ? $travelplandata[0]['PopularPlaces'] : '',
'SourcePlaceSysId' => isset($going_from_cityid) ? $going_from_cityid : '',
'SourcePlaces' => isset($going_from_cityname) ? $going_from_cityname : '',
// 'DestinationPlacesSysId' => $destinationIds ? $destinationIds : '',
// 'DestinationPlaces' => $destinationValues ? $destinationValues : '',
'DestinationPlacesSysId' => isset($going_to_cityid) ? (int) $going_to_cityid : (int) $destinationIds,
'DestinationPlaces' => isset($going_to_cityname) ? $going_to_cityname : $destinationValues,
'CityIds' => $destinationIds ? $destinationIds : '',
'Cities' => $destinationValues ? $destinationValues : '',
'Countries' => $travelplandata[0]['Countries'] ? $travelplandata[0]['Countries'] : '',
'IsMarkForDel' => $travelplandata[0]['IsMarkForDel'] ? $travelplandata[0]['IsMarkForDel'] : '0',
'RoomInfoJson' => $roomjson ? json_encode($roomjson) : '',
'EmailText' => $aboutpackage,
'EmailDestination' => $tripaddress,
'ProposalEmailTo' => trim($custemail),
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'Readymade' => 1,
'IsMarkForDel' => $travelplandata[0]['IsMarkForDel'] ? $travelplandata[0]['IsMarkForDel'] : '0',
'IsAprooved' => 1,
'TPId' => $travelplandata[0]['TPSysId'],
'IsPriceShared' => $isPriceShared, // to detect withprice or without price true = If price shared , false = price range shared
'GSTSharedMode' => $gsttype, // (1 for 5% on total Cost, 2 for 18% on Service Fee) to detect what type and how much tax will apply to customer
'SACCode' => $SACCode,
'IsB2Bproposal' => 1
);
//echo '<pre>'; print_r($customertravelpaln);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($AgencyNetworkQuery);
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$response = array('success' => true, 'msg' => 'Supplier Lead Created successfully.', 'lastID' => '');
echo json_encode($response);
exit;
}
public function customerAllTodoReminderListAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$this->view->type = 'customerAllTodoReminderListAction';
$session = new Zend_Session_Namespace('sessionLogin_user');
$todoreminderDetail = $session->todoreminderDetail;
$this->view->todoreminderDetail = $todoreminderDetail;
$this->render('ajax-html');
}
//addB2bAACAction ==> add b2b Agency,Agent,Customer created by Er Amit Kumar Dubey on 13 nov 2017 at 1:50 PM
//Aac ==> Agency Agent Customer
public function addB2bAacAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$source = $this->_request->getParam('source');
$custrelation = $this->_HtmlPurifier->filter($this->_request->getParam('custrelation'));
$passnumber = $this->_HtmlPurifier->filter($this->_request->getParam('passnumber'));
$passexpiry = $this->_HtmlPurifier->filter($this->_request->getParam('passexpiry'));
$leadsource = $this->_HtmlPurifier->filter($this->_request->getParam('leadsource'));
$b2bagencyname = $this->_HtmlPurifier->filter($this->_request->getParam('b2bagencyname'));
$b2btype = $this->_HtmlPurifier->filter($this->_request->getParam('b2btype', 1));
$b2bagent_remarks = $this->_HtmlPurifier->filter($this->_request->getParam('b2bagent_remarks'));
$hidden_b2bagency_agentId = $this->_HtmlPurifier->filter($this->_request->getParam('SelectedAgentId'));
$hidden_b2bagency_agencysysid = $this->_HtmlPurifier->filter($this->_request->getParam('SelectedAgencySysId'));
$reportsTo = $this->_HtmlPurifier->filter($this->_request->getParam('reportsTo'));
$AgencyCRMLeadSysId = 0;
if (isset($passexpiry) && !empty($passexpiry)) {
$passexpiry = explode('/', $passexpiry);
$passexpiry = $passexpiry[2] . "-" . $passexpiry[1] . "-" . $passexpiry[0];
}
$custanniversary = $this->_HtmlPurifier->filter($this->_request->getParam('custanniversary'));
if (isset($custanniversary) && !empty($custanniversary)) {
$custanniversary = explode('/', $custanniversary);
$custanniversary = $custanniversary[2] . "-" . $custanniversary[1] . "-" . $custanniversary[0];
}
$custdob = $this->_HtmlPurifier->filter($this->_request->getParam('custdob'));
if (isset($custdob) && !empty($custdob)) {
$custdob = explode('/', $custdob);
$custdob = $custdob[2] . "-" . $custdob[1] . "-" . $custdob[0];
}
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CustomerSysId')));
$B2BAgencySysId = (NULL != $this->_request->getParam('SelectedAgencySysId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('SelectedAgencySysId')) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
if (isset($leadsource) && is_numeric($leadsource) && !empty($leadsource)) {
$leadsource = $leadsource;
} else {
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = (isset($intLeadSourceSysId[0]['LeadSourceSysId']) && !empty($intLeadSourceSysId[0]['LeadSourceSysId'])) ? $intLeadSourceSysId[0]['LeadSourceSysId'] : 0;
}
$updatedate = date('Y-m-d H:i:s');
$currentDate = date('Y-m-d H:i:s');
if ($source == "mainPage") {
$mobilenum = $this->_request->getParam('mobilenumber');
$customername = $this->_request->getParam('customername');
$emailID = $this->_request->getParam('customerEmail');
$b2bagencyname = $this->_request->getParam('b2bagencyname');
$customerfname = $this->_request->getParam('fname');
$customerlname = $this->_request->getParam('lname');
$detail = array(
'b2bagencyname' => $b2bagencyname,
'mobilenum' => $mobilenum,
'customerfname' => $customerfname,
'customerlname' => $customerlname,
'emailID' => $emailID,
);
} else {
$editID = base64_decode($this->_request->getParam('editID'));
$fname = $this->_request->getParam('fname');
$lname = $this->_request->getParam('lname');
$customerEmail = $this->_request->getParam('customerEmail');
$mobilenumber = $this->_request->getParam('mobilenumber');
$countrycode = $this->_request->getParam('countrycode');
$city = $this->_request->getParam('city');
$state = $this->_request->getParam('state');
$country = $this->_request->getParam('country');
$salution = $this->_request->getParam('salution');
$customeraddress = $this->_request->getParam('customeraddress');
$customerpincode = $this->_request->getParam('customerpincode');
$IsB2BAgent = 1;
$CreatedByUserSysId = $this->intLoggedinUserId;
$detail = array();
if ($editID) {
$agencyuserArray = array(
'EmailId' => $customerEmail,
'Title' => (isset($salution) && !empty($salution)) ? $salution : 1,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => $city,
'StateOrZoneSysId' => 0,
'CountrySysId' => $country,
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => $fname,
'LastName' => $lname,
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'IsApproved' => '0',
'IsActive' => '1',
'IsB2BAgent' => $IsB2BAgent,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
);
$where = "CustomerSysId = " . $editID;
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $where);
$detail['status'] = 'success';
$detail['CustomerSysId'] = (isset($editID) && !empty($editID)) ? base64_encode($editID) : '';
$detail['CustomerSysIdNew'] = (isset($editID) && !empty($editID)) ? $editID : '';
} else {
$oRandStrPass = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->generateRandomString(5);
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B(trim($customerEmail), $AgencySysId);
if (empty($getcustomerdetails)) {
$getcustomerdetails = $this->_crmcustomerObj->ChkMobileExistInAgencyB2B(trim($mobilenumber), $AgencySysId);
}
$customerRcord = $getcustomerdetails['CustomerSysId'];
if ($CRMCustSysId == '' && empty($getcustomerdetails['CustomerSysId'])) {
$userArray = array(
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 1,
'PrimaryContactNumber' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
}
if (empty($getcustomerdetails['CustomerSysId'])) {
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $customerEmail,
'Salutation' => (isset($salution) && !empty($salution)) ? $salution : 0,
'PrimaryContactNumber' => $mobilenumber,
'countrycode' => trim($countrycode),
'FullName' => $fname . ' ' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'LeadSourceSysId' => $leadsource,
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $this->intLoggedinUserId,
'ActiveDate' => $updatedate,
'UpdatedDate' => $updatedate,
'CreatedDate' => $updatedate,
'IsApproved' => '1',
'IsActive' => '1',
'B2BType' => $b2btype,
'Remarks' => $b2bagent_remarks,
'IsMarkForDelete' => '0'
);
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => trim($customerEmail),
'Title' => (isset($salution) && !empty($salution)) ? $salution : 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => isset($city) ? $city : '',
'StateOrZoneSysId' => isset($state) ? $state : 0,
'CountrySysId' => isset($country) ? $country : '',
'IsEmployee' => '0',
'Contacts' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'JoinDate' => $updatedate,
'UserName' => $fname . '' . $lname,
'FirstName' => trim($fname),
'LastName' => trim($lname),
'Relation' => $custrelation,
'PassportNo' => $passnumber,
'Password' => md5($oRandStrPass),
'RandStr' => $oRandStrPass,
'PassportExpiry' => $passexpiry,
'DOB' => $custdob,
'MarriageAnniversary' => $custanniversary,
'RegisterDate' => $updatedate,
'UpdateDate' => $updatedate,
'JoinDate' => $updatedate,
'IsApproved' => '0',
'CreatedByUserSysId' => $CreatedByUserSysId,
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : '0'),
'IsActive' => '1',
'IsMarkForDelete' => '0',
'IsB2BAgent' => $IsB2BAgent,
'LeadSourceSysId' => $leadsource,
'CustomerType' => 2
);
$agencyCustomerData = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
//add remarks for customer
if ($b2bagent_remarks != '') {
$customerid = $agencyCustomerData;
// query for insert data in db created by amit kumar dubey on 16 august 2016 at 12:40 PM
$remarkArray = array(
'AgencySysId' => $AgencySysId,
'CustomerSysId' => $customerid,
'AgentSysId' => $this->intLoggedinUserId,
'Remarks' => $b2bagent_remarks,
'IsActive' => '1',
'CreatedDate' => $updatedate,
'IsMarkForDelete' => '0'
);
//echo "<pre>";print_r($remarkArray);die;
$customerRemarksRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
//#end of add remarks
//code for add b2b agency and agent
$objStaff = new Travel_Model_TblAgencyStaff();
$chkAgentExist = array();
if ($hidden_b2bagency_agentId != '' && $hidden_b2bagency_agencysysid != '') {
$chkAgentExist = $objStaff->chkB2BUserExist($hidden_b2bagency_agentId, $hidden_b2bagency_agencysysid, '');
}
//code for add b2b agency
//get verify response data
$agencyDetails = $objAgency->isB2BAgencyExists('', $hidden_b2bagency_agentId, $this->intLoggedinUserAgencySysId);
//echo count($agencyDetails)."/".count($chkAgentExist);
//echo $objStaff->isUserEmailExists(trim($customerEmail),0,$AgencySysId,1);die;
$IsB2BAgent = 1;
if (empty($agencyDetails) && empty($chkAgentExist)) {
$BusinessType = 0;
if ($b2btype == 2) {
$BusinessType = 1;
}
$agencyData = array(
'MasterAgencySysId' => $this->intLoggedinUserAgencySysId,
'agencyName' => $b2bagencyname,
'selectCountry' => isset($country) ? $country : '',
'selectState' => '',
'selectCity' => isset($city) ? $city : '',
'contactName' => $fname . '' . $lname,
'emailId' => $customerEmail,
'mobileNo' => trim($mobilenumber),
'countrycode' => trim($countrycode),
'shortDetail' => '',
'PanCardNo' => '',
'AgencyMarketPlaceSysId' => '',
'IsActive' => 1,
'CreateDate' => $currentDate,
'BusinessType' => $BusinessType,
'RMUserSysId' => $reportsTo,
);
$NewAgencySysId = $objAgency->registerAgency($agencyData, 1);
} else {
$NewAgencySysId = $agencyDetails['AgencySysId'];
}
//#end of code for b2b agency
//code for add b2b agent
//echo "ssss".$NewAgencySysId;die;
if (!$objStaff->isUserEmailExists(trim($customerEmail), 0, $NewAgencySysId, 1)) {
//insert user details
// $date = new Zend_Date();
// $currentDate = $date->toString('yyyy-MM-dd HH:mm:ss');
$currentDate = date('Y-m-d H:i:s');
if (isset($b2bagencyname) && !empty($b2bagencyname)) {
$getagencyname = trim($this->sanitize_data($b2bagencyname));
$getAgencyCode = $objStaff->checkExistAgencyCode($getagencyname);
if ($getAgencyCode['AgencyCode'] != '') {
$AgencyCode = (trim($getAgencyCode['AgencyCode']) != '') ? $getAgencyCode['AgencyCode'] : 1;
$remainingNumber = 5 - strlen($AgencySysId . $getAgencyCode['AgencyCode']);
$AgencyCode = str_pad($AgencyCode, $remainingNumber, '0', STR_PAD_LEFT);
$AgencyCode = (strlen($AgencyCode) == 5) ? $AgencyCode : $AgencySysId . $AgencyCode;
} else {
$getAgencyCode = $objStaff->getLastAgencyCode();
$AgencyCode = (trim($getAgencyCode['AgencyCode']) != '') ? $getAgencyCode['AgencyCode'] + 1 : 1;
$remainingNumber = 5 - strlen($AgencySysId);
$AgencyCode = str_pad($AgencyCode, $remainingNumber, '0', STR_PAD_LEFT);
$AgencyCode = (strlen($AgencyCode) == 5) ? $AgencyCode : $AgencySysId . $AgencyCode;
}
}
$agencyUserDataForDb = array(
'AgencySysId' => $NewAgencySysId,
'Designation' => '',
'IsfromSM' => 0,
'SMTypeId' => 0,
'SMId' => 0,
'UserId' => 0,
'EmpId' => 0,
'JoinDate' => $currentDate ? $currentDate : 0,
'ExitDate' => 0,
'UserName' => 0,
'Salutation' => !empty($salution) ? (int) $salution : 1,
'FirstName' => !empty($fname) ? $this->_HtmlPurifier->filter($fname) : '',
'LastName' => !empty($lname) ? $this->_HtmlPurifier->filter($lname) : '',
'UserRole' => (empty($agencyDetails)) ? 0 : 1,
'IsInsurance' => 0,
'IsB2BAgent' => $IsB2BAgent,
'AgencyName' => !empty($b2bagencyname) ? $this->_HtmlPurifier->filter($b2bagencyname) : 0,
'GSTIN' => '',
'PanNumber' => '',
'AgencyCode' => !empty($AgencyCode) ? $this->_HtmlPurifier->filter($AgencyCode) : 0,
'UserAccessLevelType' => 0,
'Password' => md5($oRandStrPass),
'RandStr' => $oRandStrPass,
'PasswordExpiryDate' => 0,
'IsPswExpire' => 0,
'EmailId' => !empty($customerEmail) ? $this->_HtmlPurifier->filter($customerEmail) : 0,
'LastLoginTime' => 0,
'IsLogInNow' => 0,
'CreatedByUserSysId' => $this->intLoggedinUserAgencySysId,
'RandomCode' => 0,
'Gender' => 0,
'UserNickName' => 0,
'UserPicPath' => 0,
'ContactNo1' => !empty($mobilenumber) ? $this->_HtmlPurifier->filter($mobilenumber) : '',
'countrycode' => !empty($countrycode) ? $this->_HtmlPurifier->filter($countrycode) : '',
'ContactNo2' => '',
'UserDetails' => '',
'MacIp' => 0,
'UpdateDate' => $currentDate ? $currentDate : 0,
'RegisterDate' => $currentDate ? $currentDate : 0,
'IsMarkForDel' => 0,
'IsActive' => 1,
'IsApproved' => 1,
'PinCode' => (isset($customerpincode) && !empty($customerpincode) ? $customerpincode : ''),
'Address' => (isset($customeraddress) && !empty($customeraddress) ? $customeraddress : ''),
'CitySysId' => isset($city) ? $city : 0,
'StateOrZoneSysId' => isset($state) ? $state : 0,
'CountrySysId' => isset($country) ? $country : 0,
);
$userSysId = $objStaff->addUserDetails($agencyUserDataForDb);
if (@$userSysId) {
$agencyCustomerUpdateArray = array(
'CreatedByUserSysId' => $userSysId,
'AgencySysId' => $NewAgencySysId
);
$whereCustomerCond = " CustomerSysId=" . $agencyCustomerData;
$agencyCustomerDataUpdate = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyCustomerUpdateArray, $whereCustomerCond);
if ((int) $AgencyCRMLeadSysId > 0) {
$LeadAccountUpdate = array(
'AgencySysId' => $NewAgencySysId,
);
$objAgency->updateLeadAgencyData($LeadAccountUpdate, $AgencyCRMLeadSysId);
}
$arrayData = array(
'PrimaryUserSysId' => $userSysId,
);
$updateAgencyId = $objAgency->updateAgencyData($arrayData, $NewAgencySysId);
$objAgency->checkAgencyWallet($NewAgencySysId, $userSysId);
}
} else {
if ((int) $AgencyCRMLeadSysId > 0) {
$LeadAccountUpdate = array(
'AgencySysId' => $NewAgencySysId,
);
$objAgency->updateLeadAgencyData($LeadAccountUpdate, $AgencyCRMLeadSysId);
}
$agencyCustomerUpdateArray = array(
'CreatedByUserSysId' => (isset($chkAgentExist['UserSysId'])) ? $chkAgentExist['UserSysId'] : 0,
'AgencySysId' => $NewAgencySysId
);
$whereCustomerCond = " CustomerSysId=" . $agencyCustomerData;
$agencyCustomerDataUpdate = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyCustomerUpdateArray, $whereCustomerCond);
}
$modelAgency = new Travel_Model_TblAgency();
$masterAgencyData = $modelAgency->getUserDataByAgency($AgencySysId);
// echo "<pre>";print_r($masterAgencyData);exit;
if ($masterAgencyData['IsB2bSite'] == 1) {
$PrimaryEmail = (isset($masterAgencyData['PrimaryEmail'])) ? $masterAgencyData['PrimaryEmail'] : '';
$PrimaryContactNo = (isset($masterAgencyData['PrimaryContactNo'])) ? $masterAgencyData['PrimaryContactNo'] : '';
$checkSupportContact = $objAgency->checkSupportContact($AgencySysId, 99, 2, 1, 1);
if (isset($checkSupportContact) && !empty($checkSupportContact) && isset($checkSupportContact[0]['UserSysId'])) {
$SupportUserSysId = $checkSupportContact[0]['UserSysId'];
$crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$getAgentDetails = $crmcusttravelplan->getAgentDetails($SupportUserSysId);
if (!empty($getAgentDetails)) {
$masterAgencyData = $getAgentDetails;
}
$PrimaryEmail = (isset($masterAgencyData['EmailId'])) ? $masterAgencyData['EmailId'] : '';
$PrimaryContactNo = (isset($masterAgencyData['ContactNo1'])) ? $masterAgencyData['ContactNo1'] : '';
}
$params = array('agentName' => ucfirst($fname . ' ' . $lname), 'emailId' => $customerEmail, 'password' => $oRandStrPass, 'Url' => $masterAgencyData['Url'], 'Title' => $masterAgencyData['Title'], 'PrimaryEmail' => $PrimaryEmail, 'PrimaryContactNo' => $PrimaryContactNo, 'IsB2bSite' => $masterAgencyData['IsB2bSite'], 'IsB2bSiteURL' => $masterAgencyData['IsB2bSiteURL']);
#Set subject
$subject = 'Your Account Details';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('b2bcustomerinfo.phtml');
$emailData = array('fromEmail' => trim($PrimaryEmail), 'fromName' => trim($masterAgencyData['PrimaryContactName']), 'subject' => $subject, 'to' => array($customerEmail), 'bodyHtml' => $bodyText, 'bodyText' => '');
try {
//echo "success";
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $masterAgencyData['AgencySysId'],
"AgentSysId" => $agencyDetails['AgencySysId'],
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
if (in_array('b2bautologin', $this->manageNotifications)) {
$checkStatus = $this->mailSentByElastice($emailData, $arrEmailStatistics);
}
} catch (Exception $err) {
echo 4;
exit;
}
}
$detail['status'] = 'success';
$detail['mobilenumber'] = trim($mobilenumber);
$detail['LeadID'] = (int) $AgencyCRMLeadSysId;
$detail['countrycode'] = trim($countrycode);
$detail['fname'] = trim($fname);
$detail['lname'] = trim($lname);
$detail['b2bagencyname'] = trim($b2bagencyname);
$detail['customerEmail'] = trim($customerEmail);
$detail['CustomerSysId'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? base64_encode($agencyCustomerData) : '';
$detail['CustomerSysIdNew'] = (isset($agencyCustomerData) && !empty($agencyCustomerData)) ? $agencyCustomerData : '';
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($detail['CustomerSysId']), 1);
$detail['SecureCode'] = $secureCode;
} else {
$detail['status'] = 'failed';
if (isset($getcustomerdetails['IsActive']) && $getcustomerdetails['IsActive'] == 0) {
$detail['message'] = 'Email-id or mobile all ready exist in deactivate mode.';
} else {
$detail['message'] = 'Email-id or mobile all ready exist';
}
}
}
//$detail['customerDetails']=$customerDetails;
}
echo json_encode($detail);
}
public function getB2bCustomerDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$email = $this->_HtmlPurifier->filter($this->_request->getParam('emailID'));
$aId = (NULL != $this->_request->getParam('aId')) ? $this->_HtmlPurifier->filter($this->_request->getParam('aId')) : ''; // for get b2b agency
$mobilenum = $this->_HtmlPurifier->filter($this->_request->getParam('mobilenum'));
$CRMCustSysId = $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('CRMCustSysId')));
//echo $mobilenum;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgencyType = $sessionLogin_user->agencyDetails['AgencyType'];
$customerDetails = array();
if (isset($email) && !empty($email)) {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponseB2B($email, $AgencySysId, '', '', $AgencyType, $aId);
}
//echo "<pre>";print_r($customerDetails);die;
if (isset($mobilenum) && !empty($mobilenum)) {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgencyB2B($mobilenum, $AgencySysId, '', $AgencyType, $aId);
}
if ($customerDetails) {
$status = 'success';
} else {
$status = 'failure';
}
$detail['status'] = $status;
//$detail['customerDetails']=$customerDetails;
$detail['CustomerSysId'] = (isset($customerDetails['CustomerSysId']) && !empty($customerDetails['CustomerSysId'])) ? base64_encode($customerDetails['CustomerSysId']) : '';
$detail['CRMCustSysId'] = (isset($customerDetails['CRMCustSysId']) && !empty($customerDetails['CRMCustSysId'])) ? base64_encode($customerDetails['CRMCustSysId']) : '';
$detail['IsActive'] = (isset($customerDetails['IsActive'])) ? $customerDetails['IsActive'] : 1;
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($detail['CustomerSysId']), 1);
$detail['SecureCode'] = $secureCode;
echo json_encode($detail);
}
public function customerBulkUploadAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
if ($this->getRequest()->isPost()) {
# start : code for image uploading
$excelFileName = $_FILES['bulkuploadbtn']['name'];
$ext = @substr($excelFileName, strrpos($excelFileName, '.'));
$excelFileNameNew = $excelFileName;
$upload = new Zend_File_Transfer_Adapter_Http();
$this->upload_path = 'public/upload/excel/';
$upload->setDestination($this->upload_path);
// $file = $upload->getFileName();
if (($ext == ".csv") || ($ext == ".xls") || ($ext == ".xlsx")) {
try {
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
echo $this->view->error_msg = $e->getMessage();
die;
}
# end : code for image uploading
$file = $this->upload_path . $excelFileNameNew;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$phpexcel_obj = new PHPExcel_Classes_Readexcel;
$finalData = $phpexcel_obj->importFromExcel($file);
$leadListArray = array();
$error = array();
$i = 0;
//print_r($finalData);die;
foreach ($finalData as $listArray) {
if (trim($listArray[0]) == '') {
$error[$i]['EMAILID'] = 'EmailId cannot be empty.' . "</br>";
}
if (trim($listArray[0]) != '' && !filter_var(trim($listArray[0]), FILTER_VALIDATE_EMAIL) === true) {
$error[$i]['EMAILID'] = 'please enter a valid email address.' . "</br>";
}
if (trim($listArray[1]) == '') {
$error[$i]['MOBILE'] = 'Mobile cannot be empty.' . "</br>";
}
if (trim($listArray[1]) != '' && (is_numeric(trim($listArray[1])) == false || strlen(trim($listArray[1])) > 15)) {
$error[$i]['MOBILE'] = 'Mobile not in correct format.' . "</br>";
}
if (trim($listArray[2]) == '') {
$error[$i]['FIRSTNAME'] = 'First Name cannot be empty.' . "</br>";
}
/* if(trim($listArray[3])==''){
$error[$i]['LASTNAME']='Last Name cannot be empty.'."</br>";
} */
if (isset($listArray[0]) && trim($listArray[0]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponse(trim($listArray[0]), $AgencySysId);
if ($customerDetails) {
$error[$i]['EMAILID'] = 'EmailId Already exist.' . "</br>";
}
}
if (isset($listArray[1]) && trim($listArray[1]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgency(trim($listArray[1]), $AgencySysId, '');
if ($customerDetails) {
$error[$i]['MOBILE'] = 'Mobile Already exist.' . "</br>";
}
}
$leadListArray[$i]['ERROR'] = $error;
$leadListArray[$i]['EMAILID'] = stripslashes(trim($listArray[0]));
$leadListArray[$i]['MOBILE'] = stripslashes(trim($listArray[1]));
$leadListArray[$i]['FIRSTNAME'] = stripslashes(trim($listArray[2]));
$leadListArray[$i]['LASTNAME'] = stripslashes(trim($listArray[3]));
unset($error[$i]);
$i++;
}
//echo "<pre>";print_r($leadListArray);die;
$this->view->leadList = $leadListArray;
}
}
$leadSouceList = $this->_leadstageObj->GetAllSouce($AgencySysId);
$this->view->leadSouceList = $leadSouceList;
}
public function downloadCustomerTemplateAction() {
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
if ($type == 'lead' && $AgentSysId != '' && $AgencySysId != '') {
$excelFileNameNew = 'sample_customer.xls';
$file = "public/xlstemplate/" . $excelFileNameNew;
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream;");
readfile($file);
exit;
} else {
echo "some error . please try after some time.";
}
}
public function customerBulkUploadDataAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
if ($this->getRequest()->isPost()) {
$bulkuploaddata = $this->getRequest()->getParam('bulkuploaddata');
if (isset($bulkuploaddata) && !empty($bulkuploaddata)) {
$bulkuploaddata = json_decode(base64_decode($bulkuploaddata), true);
if (!empty($bulkuploaddata)) {
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$updatedate = date('Y-m-d H:i:s');
$this->_leadstageObj = new Travel_Model_TblLeadStage();
//$getStageList = $this->_leadstageObj->getLeadStage($AgencySysId,'NewLead');
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
//$leadstage = (isset($getStageList[0]['LeadStageSysId']) && !empty($getStageList[0]['LeadStageSysId']))?$getStageList[0]['LeadStageSysId']:0;
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$leadsource = $intLeadSourceSysId[0]['LeadSourceSysId'];
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$AssignUserSysId = $this->intLoggedinUserId;
/* if($getRoleDetail['IsAdmin']==true){
$AssignUserSysId=0;
} */
$IsB2BAgent = 0;
$createDate = date('Y-m-d H:i:s');
$passnumber = '';
$passexpiry = '';
$custdob = '';
$custanniversary = '';
foreach ($bulkuploaddata as $list) {
$emailid = stripslashes(trim($list['EMAILID']));
$mobile = stripslashes(trim($list['MOBILE']));
$firstname = stripslashes(trim($list['FIRSTNAME']));
$lastname = stripslashes(trim($list['LASTNAME']));
if ($IsB2BAgent == 1) {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B($emailid, $AgencySysId);
} else {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail($emailid, $AgencySysId);
}
//add data
if (empty($getcustomerdetails['CustomerSysId'])) {
if (isset($emailid) && !empty($emailid)) {
if ($IsB2BAgent == 1) {
$customerEmailDetails = $this->_crmcustomerObj->ChkEmailWithResponseB2B($emailid, $AgencySysId);
} else {
$customerEmailDetails = $this->_crmcustomerObj->ChkEmailWithResponse($emailid, $AgencySysId);
}
}
if (isset($mobile) && !empty($mobile)) {
if ($IsB2BAgent == 1) {
$customerMobileDetails = $this->_crmcustomerObj->ChkMobileWithResponseB2B($mobile, $AgencySysId, '', '');
} else {
$customerMobileDetails = $this->_crmcustomerObj->ChkMobileWithResponse($mobile, $AgencySysId, '', '');
}
}
if (count($customerEmailDetails) == 0 && count($customerMobileDetails) == 0) {
$userArray = array(
'EmailId' => $emailid,
'Salutation' => 1,
'AgencySysId' => $AgencySysId,
'PrimaryContactNumber' => $mobile,
'FullName' => $firstname . " " . $lastname,
'FirstName' => $firstname,
'LastName' => (isset($lastname) && !empty($lastname)) ? $lastname : '',
'LeadSourceSysId' => trim($leadsource),
'ActiveDate' => date('Y-m-d H:i:s'),
'UpdatedDate' => $createDate,
'CreatedDate' => $createDate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$CRMCustSysId = $this->_crmcustomerObj->addCustomer($userArray);
} else {
$CRMCustSysId = $customerEmailDetails['CRMCustSysId'] ? $customerEmailDetails['CRMCustSysId'] : $customerMobileDetails['CRMCustSysId'];
}
//create new lead agency account
$userLeadArray = array(
'AgencySysId' => $AgencySysId,
'EmailId' => $emailid,
'Salutation' => 1,
'PrimaryContactNumber' => $mobile ? $mobile : '',
'FullName' => $firstname . " " . $lastname,
'FirstName' => $firstname ? $firstname : '',
'LastName' => (isset($lastname) && !empty($lastname)) ? $lastname : '',
'LeadSourceSysId' => trim($leadsource),
'LeadStageSysId' => $leadstage,
'AssignUserSysId' => $AssignUserSysId,
'ActiveDate' => $createDate,
'UpdatedDate' => $createDate,
'CreatedDate' => $createDate,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => $emailid,
'Title' => 0,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => 0,
'StateOrZoneSysId' => 0,
'CountrySysId' => '',
'IsEmployee' => '0',
'Contacts' => $mobile ? $mobile : '',
'JoinDate' => $createDate,
'UserName' => $firstname . $lastname,
'FirstName' => (isset($firstname) && !empty($firstname)) ? $firstname : '',
'LastName' => (isset($lastname) && !empty($lastname)) ? $lastname : '',
'Relation' => 0,
'PassportNo' => (isset($passnumber) && !empty($passnumber)) ? $passnumber : '',
'PassportExpiry' => (isset($passexpiry) && !empty($passexpiry)) ? $passexpiry : '',
'DOB' => (isset($custdob) && !empty($custdob)) ? $custdob : '',
'MarriageAnniversary' => (isset($custanniversary) && !empty($custanniversary)) ? $custanniversary : '',
'RegisterDate' => $createDate,
'CreatedByUserSysId' => $this->intLoggedinUserId,
'IsApproved' => '0',
'UpdateDate' => $createDate,
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$CustomerSysId = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
}
}
}
$this->_redirect('/customer/listcustomer');
exit;
}
}
}
public function historicalDataAction() {
}
public function addNewB2bAgencyCustomerAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$detail = '';
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$requestPerameter = array();
$requestPerameter['fname'] = $this->_HtmlPurifier->filter(trim($getData['fname']));
$requestPerameter['b2bagencyname'] = $this->_HtmlPurifier->filter(trim($getData['agencyname']));
$requestPerameter['customerEmail'] = $this->_HtmlPurifier->filter(trim($getData['customerEmail']));
$requestPerameter['lname'] = isset($getData['custlastname']) ? $this->_HtmlPurifier->filter(trim($getData['custlastname'])) : '';
$requestPerameter['mobilenumber'] = $this->_HtmlPurifier->filter(trim($getData['mobilenumber']));
$requestPerameter['countrycode'] = $this->_HtmlPurifier->filter(trim($getData['countrycode']));
$requestPerameter['city'] = '';
$requestPerameter['state'] = '';
$requestPerameter['country'] = '';
$requestPerameter['custrelation'] = 0;
$requestPerameter['salutation'] = 1;
$requestPerameter['CRMCustSysId'] = '';
$requestPerameter['passnumber'] = '';
$requestPerameter['passexpiry'] = '';
$requestPerameter['custdob'] = '';
$requestPerameter['custanniversary'] = '';
$requestPerameter['leadsource'] = '';
$requestPerameter['IsB2BAgent'] = $this->_HtmlPurifier->filter(trim($getData['IsB2BAgent']));
$requestPerameter['AgencySysId'] = $this->intLoggedinUserAgencySysId;
$requestPerameter['AgentSysId'] = $this->intLoggedinUserId;
$requestPerameter['B2BAgencySysId'] = $this->_HtmlPurifier->filter(trim($getData['hidden_b2bagency_agencysysid']));
$requestPerameter['B2BAgentSysId'] = $this->_HtmlPurifier->filter(trim($getData['hidden_b2bagency_agentId']));
//print_r($requestPerameter);die;
$saveAgencyWithCustomer = $this->_crmcustomerObj->saveB2BCustomer($requestPerameter);
echo $saveAgencyWithCustomer;
}
}
public function getqueystatusajaxAction() {
$this->view->layout()->disableLayout();
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$AllLeadStatus = $customhelper->GetTravelPlanStatus($type, '');
echo json_encode(['AllLeadStatus' => $AllLeadStatus, 'status' => 'success']);
exit;
}
public function getleadqualitystatusajaxAction() {
$this->view->layout()->disableLayout();
$AllLeadQualityStatus = array(array('Id' => 1, 'Title' => 'Hot'), array('Id' => 2, 'Title' => 'Warm'), array('Id' => 3, 'Title' => 'Cold'));
echo json_encode(['LeadQualityStatus' => $AllLeadQualityStatus, 'status' => 'success']);
exit;
}
public function updateCustomerRecordAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$IsMarried = (isset($getData['IsMarried'])) ? $this->_HtmlPurifier->filter(trim($getData['IsMarried'])) : '';
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($getData['CustomerSysId']));
$customerDesDOB = $this->_HtmlPurifier->filter(trim($getData['customerDesDOB']));
$customerDesAnniversary = $this->_HtmlPurifier->filter(trim($getData['customerDesAnniversary']));
$customerDesAnniversary2 = $customerDesDOB2 = '';
if (trim($customerDesDOB) != '') {
$customerDesDOB1 = explode('/', $customerDesDOB);
$customerDesDOB2 = trim($customerDesDOB1[2] . '-' . $customerDesDOB1[1] . '-' . $customerDesDOB1[0]);
}
if (trim($customerDesAnniversary) != '') {
$customerDesAnniversary1 = explode('/', $customerDesAnniversary);
$customerDesAnniversary2 = trim($customerDesAnniversary1[2] . '-' . $customerDesAnniversary1[1] . '-' . $customerDesAnniversary1[0]);
}
$userArray = array(
'UpdateDate' => date('Y-m-d H:i:s'),
);
if ($IsMarried != '') {
$userArray['IsMarried'] = $IsMarried;
}
if ($customerDesDOB2 != '') {
$userArray['DOB'] = $customerDesDOB2;
}
if ($customerDesAnniversary2 != '') {
$userArray['MarriageAnniversary'] = $customerDesAnniversary2;
}
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if ($AgencySysId != '' && $CustomerSysId != '') {
$where = "CustomerSysId = " . $CustomerSysId . " AND AgencySysId = " . $AgencySysId;
$customerRcord = $this->_agencycustomerObj->UpdateAgencyCustomer($userArray, $where);
}
if ($customerRcord) {
echo json_encode(array('status' => true));
exit;
} else {
echo json_encode(array('status' => false));
exit;
}
}
}
public function proposalFollowUpHistoryCustAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$CustomerSysId = $this->getRequest()->getParam('CustomerSysId');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$crmcustomerObj = new Travel_Model_CRM_Customer();
$arrCustomerTODOHistory = $crmcustomerObj->GetAllCustomerToDoByCustId($CustomerSysId, $AgencySysId);
$this->view->arrCustomerTODOHistory = $arrCustomerTODOHistory;
}
}
public function stateAutoSuggestAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
// print_r($this->getRequest()->getParam("term"));
// exit;
try {
$arrResponse = array();
if ($this->getRequest()->getParam("term") or $this->getRequest()->getParam("query")) {
$term = $this->getRequest()->getParam("term") ? $this->getRequest()->getParam("term") : $this->getRequest()->getParam("query");
$countryId = $this->getRequest()->getParam("countryId") ? $this->getRequest()->getParam("countryId") : '';
$objState = new Travel_Model_TblState();
$condState = "tb1.Title like '" . $term . "%'";
if (isset($countryId) && !empty($countryId)) {
$condState .= " AND tb1.ContSysId = " . $countryId . "";
}
//echo $condCity;
$arrResponse = $objState->getStateAutoSuggest($condState);
//print_r($arrResponse);die;
}
echo json_encode($arrResponse);
exit;
} catch (Exception $e) {
$response = array('success' => false, 'msg' => $e->getMessage());
echo json_encode($response);
exit;
}
}
public function leadB2bBulkUploadAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
if ($this->getRequest()->isPost()) {
# start : code for image uploading
$excelFileName = $_FILES['bulkuploadbtn']['name'];
$ext = @substr($excelFileName, strrpos($excelFileName, '.'));
$excelFileNameNew = $excelFileName;
$upload = new Zend_File_Transfer_Adapter_Http();
$this->upload_path = 'public/upload/excel/';
$upload->setDestination($this->upload_path);
// $file = $upload->getFileName();
if (($ext == ".csv") || ($ext == ".xls") || ($ext == ".xlsx")) {
try {
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
echo $this->view->error_msg = $e->getMessage();
die;
}
# end : code for image uploading
$file = $this->upload_path . $excelFileNameNew;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$phpexcel_obj = new PHPExcel_Classes_Readexcel;
$finalData = $phpexcel_obj->importFromExcel($file);
$leadListArray = array();
$error = array();
$i = 0;
//print_r($finalData);die;
foreach ($finalData as $listArray) {
if (trim($listArray[0]) == '') {
$error[$i]['EMAILID'] = 'EmailId cannot be empty.' . "</br>";
}
if (trim($listArray[0]) != '' && !filter_var(trim($listArray[0]), FILTER_VALIDATE_EMAIL) === true) {
$error[$i]['EMAILID'] = 'please enter a valid email address.' . "</br>";
}
if (trim($listArray[1]) == '') {
$error[$i]['MOBILE'] = 'Mobile cannot be empty.' . "</br>";
}
if (trim($listArray[1]) != '' && (is_numeric(trim($listArray[1])) == false || strlen(trim($listArray[1])) != 10)) {
$error[$i]['MOBILE'] = 'Mobile not in correct format.' . "</br>";
}
if (trim($listArray[2]) == '') {
$error[$i]['FIRSTNAME'] = 'First Name cannot be empty.' . "</br>";
}
/* if(trim($listArray[3])==''){
$error[$i]['LASTNAME']='Last Name cannot be empty.'."</br>";
} */
if (trim($listArray[4]) == '') {
$error[$i]['SOURCE'] = 'Source cannot be empty.' . "</br>";
}
if (trim($listArray[5]) == '') {
$error[$i]['SOURCE'] = 'Company Name cannot be empty.' . "</br>";
}
if (trim($listArray[6]) == '') {
$error[$i]['SOURCE'] = 'B2B Type cannot be empty.' . "</br>";
}
$leadSource = $this->_leadstageObj->GetLeadSourceById(trim($listArray[4]), $AgencySysId);
if (isset($listArray[0]) && trim($listArray[0]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkEmailWithResponseB2B(trim($listArray[0]), $AgencySysId);
if (isset($customerDetails['CustomerSysId'])) {
$error[$i]['EMAILID'] = 'EmailId Already exist.please try another' . "</br>";
}
}
if (isset($listArray[1]) && trim($listArray[1]) != '') {
$customerDetails = $this->_crmcustomerObj->ChkMobileExistInAgencyB2B(trim($listArray[1]), $AgencySysId, '');
if ($customerDetails) {
$error[$i]['MOBILE'] = 'Mobile Already exist.please try another' . "</br>";
}
}
if (count($leadSource) == 0) {
$error[$i]['SOURCE'] = 'Source not exist . Source Id not matched with source listing.' . "</br>";
}
/* if(isset($listArray[5]) && trim($listArray[5])!=''){
$agencyname=trim($listArray[5]);
$objAgency = new Travel_Model_TblAgency();
$checkb2bAgencyExist=$objAgency->isB2BAgencyNameExists($agencyname,$AgencySysId);
if(count($checkb2bAgencyExist)==0){
$error[$i]['AGENCYNAME']='Company Name Not exist.please try another'."</br>";
}
} */
if (isset($listArray[6]) && trim($listArray[6]) != '') {
if ($listArray[6] != 1 && $listArray[6] != 2) {
$error[$i]['B2BTYPE'] = 'B2B Type Not exist. 1 For Agency, 2 For Corporate' . "</br>";
}
}
$leadListArray[$i]['ERROR'] = $error;
$leadListArray[$i]['EMAILID'] = stripslashes(trim($listArray[0]));
$leadListArray[$i]['MOBILE'] = stripslashes(trim($listArray[1]));
$leadListArray[$i]['FIRSTNAME'] = stripslashes(trim($listArray[2]));
$leadListArray[$i]['LASTNAME'] = stripslashes(trim($listArray[3]));
$leadListArray[$i]['SOURCE'] = stripslashes(trim($leadSource['Title']));
$leadListArray[$i]['SOURCEID'] = stripslashes(trim($listArray[4]));
$leadListArray[$i]['AGENCYNAME'] = stripslashes(trim($listArray[5]));
$leadListArray[$i]['B2BTYPE'] = stripslashes(trim($listArray[6]));
unset($error[$i]);
$i++;
}
//echo "<pre>";print_r($leadListArray);die;
$this->view->leadList = $leadListArray;
}
}
$leadSouceList = $this->_leadstageObj->GetAllSouce($AgencySysId);
$this->view->leadSouceList = $leadSouceList;
}
public function leadB2bBulkUploadDataAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$this->_leadstageObj = new Travel_Model_TblLeadSource();
if ($this->getRequest()->isPost()) {
$bulkuploaddata = $this->getRequest()->getParam('bulkuploaddata');
if (isset($bulkuploaddata) && !empty($bulkuploaddata)) {
$bulkuploaddata = json_decode(base64_decode($bulkuploaddata), true);
if (!empty($bulkuploaddata)) {
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$updatedate = date('Y-m-d H:i:s');
$this->_leadstageObj = new Travel_Model_TblLeadStage();
//$getStageList = $this->_leadstageObj->getLeadStage($AgencySysId,'NewLead');
$getStageList = $this->_leadstageObj->getLeadStageSatus('New');
$leadstage = (isset($getStageList[0]['TPStatusSysId']) && !empty($getStageList[0]['TPStatusSysId'])) ? $getStageList[0]['TPStatusSysId'] : 0;
//$leadstage = (isset($getStageList[0]['LeadStageSysId']) && !empty($getStageList[0]['LeadStageSysId']))?$getStageList[0]['LeadStageSysId']:0;
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$AssignUserSysId = $this->intLoggedinUserId;
if ($getRoleDetail['IsAdmin'] == true) {
$AssignUserSysId = 0;
}
$AgencySysId = $this->intLoggedinUserAgencySysId;
foreach ($bulkuploaddata as $list) {
$emailid = stripslashes(trim($list['EMAILID']));
$mobile = stripslashes(trim($list['MOBILE']));
$firstname = stripslashes(trim($list['FIRSTNAME']));
$lastname = stripslashes(trim($list['LASTNAME']));
$leadsourceid = stripslashes(trim($list['SOURCEID']));
$leadsource = stripslashes(trim($list['SOURCE']));
$agencyname = stripslashes(trim($list['AGENCYNAME']));
$b2btype = stripslashes(trim($list['B2BTYPE']));
//insert value in lead table
$requestPerameter = array();
$requestPerameter['fname'] = $firstname;
$requestPerameter['b2bagencyname'] = $agencyname;
$requestPerameter['customerEmail'] = $emailid;
$requestPerameter['lname'] = $lastname;
$requestPerameter['mobilenumber'] = $mobile;
$requestPerameter['countrycode'] = '';
$requestPerameter['city'] = '';
$requestPerameter['state'] = '';
$requestPerameter['country'] = '';
$requestPerameter['custrelation'] = 0;
$requestPerameter['salutation'] = 1;
$requestPerameter['CRMCustSysId'] = '';
$requestPerameter['passnumber'] = '';
$requestPerameter['passexpiry'] = '';
$requestPerameter['custdob'] = '';
$requestPerameter['custanniversary'] = '';
$requestPerameter['leadsource'] = $leadsource;
$requestPerameter['IsB2BAgent'] = 1;
$requestPerameter['B2BType'] = $b2btype;
$requestPerameter['AgencySysId'] = $AgencySysId;
$requestPerameter['AgentSysId'] = $this->intLoggedinUserId;
$requestPerameter['Unassigned'] = 1;
$objAgency = new Travel_Model_TblAgency();
$checkb2bAgencyExist = $objAgency->isB2BAgencyNameExists($agencyname, $AgencySysId);
$b2bAgencySysId = '';
$b2bAgentSysId = '';
if (!empty($checkb2bAgencyExist)) {
$b2bAgencySysId = $checkb2bAgencyExist['AgencySysId'];
$b2bAgentSysId = $checkb2bAgencyExist['MasterAgencySysId'];
}
$requestPerameter['B2BAgencySysId'] = $b2bAgencySysId;
$requestPerameter['B2BAgentSysId'] = $b2bAgentSysId;
//for create new customer
//echo "<pre>";print_r($requestPerameter);die;
$AgencyCRMLeadSysId = $this->_crmcustomerObj->saveB2BCustomer($requestPerameter);
}
}
$this->_redirect('/customer/lead');
exit;
}
}
}
public function deleteDiscardedProposalAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$proposalId = $this->getRequest()->getParam('data', null);
$msg = "failed";
$title = '';
$date = date('Y-m-d H:i:s');
if ($proposalId) {
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$TPSysId = $customhelper->getDec($proposalId);
if ((int) $TPSysId > 0) {
$userQueryAgent = array(
'IsMarkForDel' => 1,
'IsActive' => 0,
'UpdateDate' => $date,
);
$whereQuery = "TPSysId = " . $TPSysId . "";
try {
$this->_crmcusttravelplan->UpdateCustomerTravelPlan($userQueryAgent, $whereQuery);
$msg = "success";
$title = "Proposal discarded successfully";
} catch (Zend_Exception $e) {
$msg = "failed";
}
}
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function updateArchieveAgencyLeadAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$objAgency = new Travel_Model_TblAgency();
$CustomerSysIds = $this->getRequest()->getParam('data');
$CustomerSysIds = $this->_HtmlPurifier->filterArray($CustomerSysIds);
if (isset($agencysysID) && !empty($agencysysID) && is_numeric($agencysysID) > 0) {
$agentAssineDetails = $this->_crmcustomerObj->getAgentDetailById($sessionLogin_user->intLoggedinUserId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencysysID);
if (!empty($CustomerSysIds)) {
for ($d = 0; $d < count($CustomerSysIds); $d++) {
$response = explode("_", base64_decode($CustomerSysIds[$d]));
$type = $response[1];
$AgencyCRMLeadSysId = $response[0];
//print_r($agencyCustomerDetails);
//$where = "AgencyCRMLeadSysId = ". $agencyCustomerDetails['AgencyCRMLeadSysId']." AND AgencySysId=".$agencysysID." ";
if ($type == 'LEAD') {
$where = "AgencyCRMLeadSysId = " . $AgencyCRMLeadSysId . " AND (AgencySysId = " . $agencysysID . " OR AgencySysId IN (select AgencySysId from TB_Agency where MasterAgencySysId = $agencysysID AND IsActive = '1' AND IsMarkForDelete = '0') ) ";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDelete' => 1,
'IsActive' => 0,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray, $where);
// only update in agency customer table
$agencyCustomerDetails = $this->_crmagencyleadaccountObj->GetAgencyCustomerByLeadId($AgencyCRMLeadSysId);
if (!empty($agencyCustomerDetails)) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$msg = "success";
} else if ($type == 'QUERY') {
$TPSysId = $response[2];
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$date = date('Y-m-d H:i:s');
$AgencyUserId = $sessionLogin_user->intLoggedinUserId;
$userQueryAgent = array(
'IsMarkForDel' => 1,
'IsActive' => 0,
'UpdateDate' => $date,
);
$whereQuery = "TPSysId = " . $TPSysId . "";
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userQueryAgent, $whereQuery);
/* $where = "AgencyCRMLeadSysId = ". $AgencyCRMLeadSysId." AND AgencySysId=".$agencysysID." ";
$userArray = array(
'AssignUserSysId' => $AgencyUserId,
'UpdatedDate' => $date,
);
$customerRcord = $this->_crmagencyleadaccountObj->UpdateGtxCrmCustomer($userArray,$where); */
// only update in agency customer table
$agencyCustomerDetails = $this->_crmcusttravelplan->getTravelPlanDetailsByTPSysId($TPSysId, 'Query');
if (!empty($agencyCustomerDetails)) {
$agencyuserArray = array(
'UpdateDate' => $date
);
$whereAgencyCustomer = " AgencySysId=" . $agencysysID . " AND CustomerSysId=" . $agencyCustomerDetails[0]['CustomerSysId'] . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
$msg = "success";
} else {
$msg = "failed";
}
// send email to agency staff when assign completed
/* $html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/customer/');
// render view
$html->assign('type', 'gtxCustomerAgentQueryEmailNotification');
$html->assign('agentDetails', $agentAssineDetails);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('agentAssineDetails', $agentAssineDetails);
$html->assign('agencyCustomerDetails',$agencyCustomerDetails);
$html->assign('CustomerSysId', base64_encode(trim($agencyCustomerDetails['CustomerSysId'])));
$bodyText = $html->render('email-template.phtml');
$emailId = trim($agentDetails[0]['EmailId']);
//$emailId = 'amit.k@catpl.co.in';
//$emailSendId=trim($getAgencyDetail['PrimaryEmail']);
$emailSendId=trim($agentAssineDetails[0]['EmailId'])?trim($agentAssineDetails[0]['EmailId']):trim($getAgencyDetail['PrimaryEmail']);
$fromName=(isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName']))?trim($getAgencyDetail['DisplayName']):stripslashes(trim($getAgencyDetail['Title']));
$fromName=(isset($agentAssineDetails[0]['FirstName']) && !empty($agentAssineDetails[0]['FirstName']))?stripslashes(trim($agentAssineDetails[0]['FirstName'])):trim($fromName);
$emailData = array('fromEmail'=>$emailSendId,'fromName'=>$fromName,'subject'=>'New Query Assigned-'.trim($agencyCustomerDetails['CustomerSysId']),'to'=>array($emailId),'bodyHtml'=>$bodyText,'bodyText'=>'');
try {
//echo "success";
// Added By Pardeep Panchal For Email Count...
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[2], // 7 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData,$arrEmailStatistics);
$msg="success";
} catch (Exception $err) {
//print_r($err, true);
$msg="failed";
} */
$response = array('status' => 'success', 'msg' => 'Record Updated');
} else {
$response = array('status' => 'failed', 'msg' => 'Some thing went wrong.');
}
}
}
}
$msg = "success";
$title = 'Success fully updated';
} else {
$msg = "failed";
$title = 'Something went wrong';
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function queryAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$leadFilter = $this->getRequest()->getParam('filter');
$lead_stage = "";
if ($leadFilter == 'inprogress') {
$lead_stage = "1, 2, 58, 36, 20";
}
if ($leadFilter == 'confirmed') {
$lead_stage = "29, 21, 22, 23, 3, 24, 38, 37, 34, 35";
}
if ($leadFilter == 'rejected') {
$lead_stage = "25, 28, 30, 31, 32, 33";
}
if ($leadFilter == 'unassigned') {
$lead_stage = 'UnAssigned';
}
if ($leadFilter == 'callback') {
$lead_stage = "69";
}
$getData = array();
if ($this->getRequest()->getPost()) {
$getData = $this->getRequest()->getPost();
$getData = $this->_HtmlPurifier->filterArray($getData);
}
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
$orderQueryDate = 'DESC';
$columnNameOrder = 'UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$this->view->order = $orderBy;
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'queryDate' && $order_type[1] == 0) {
$columnNameOrder = 'UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'queryDate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'travelDate' && $order_type[1] == trim(1)) {
$columnNameOrder = 'StartDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'travelDate' && $order_type[1] == 0) {
$columnNameOrder = 'StartDate';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'UpdateDate';
$orderQueryDate = 'DESC';
} else if ($order_type[0] == 'destination' && $order_type[1] == 1) {
$columnNameOrder = 'DestinationPlaces';
$orderQueryDate = 'ASC';
} else if ($order_type[0] == 'destination' && $order_type[1] == 0) {
$columnNameOrder = 'DestinationPlaces';
$orderQueryDate = 'DESC';
}
}
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$model = new Gtxwebservices_Model_Procedures();
$pageNumber = $this->_getParam('page', 1);
$setItem = GRID_PER_PAGE_RECORD_COUNT;
$LeadListArr = $model->customerQuery($AgencySysId, $pageNumber, $setItem, $lead_stage, $getData, $orderQueryDate, $columnNameOrder, $getRoleDetail, $AgentSysId, $ReportingToSysId);
$totalCountResult = 0;
if (!empty($LeadListArr['Result1'])) {
$totalCountResult = $LeadListArr['Result1'][0]['TotalCount'];
}
$data = range(1, $totalCountResult);
$paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($setItem);
$lead_stageUn = 'UnAssigned';
$LeadListArrUn = $model->customerQuery($AgencySysId, $pageNumber, $setItem, $lead_stageUn, $getData, $orderQueryDate, $columnNameOrder, $getRoleDetail, $AgentSysId, $ReportingToSysId);
$totalCountResultUA = 0;
if (!empty($LeadListArrUn['Result1'])) {
$totalCountResultUA = $LeadListArrUn['Result1'][0]['TotalCount'];
}
// $order['order'] = $orderBy;
//echo "<pre>";print_r($totalCountResultUA);die('dd');
if ($sessionLogin_user->UserRoleTitle == 'Owner') {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId, $ReportingToSysId);
}
$order['order'] = $orderBy;
$order['lead_stage_name'] = $leadFilter;
$this->view->getData = $order;
$this->view->searchData = $getData;
$this->view->filterFormDisplay = $this->getRequest()->getPost();
$this->view->agencyUser = $agencyUser;
$this->view->paginator = $paginator;
$this->view->paginator1 = $LeadListArr['Result1'];
$this->view->getRoleDetail = $getRoleDetail;
//for todo assigned value default loggedin user
$agencyUserDetails['intLoggedinUserId'] = $sessionLogin_user->intLoggedinUserId;
$agencyUserDetails['FirstName'] = $sessionLogin_user->FirstName;
$agencyUserDetails['LastName'] = $sessionLogin_user->LastName;
$agencyUserDetails['EmailId'] = $sessionLogin_user->EmailId;
$this->view->agencyUserDetails = $agencyUserDetails;
$this->view->CountResultUnAssigned = $totalCountResultUA;
//print_r($LeadListArr['Result1']);die;
}
public function leadPrashantAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$leadFilter = $this->getRequest()->getParam('filter');
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
$type = $this->getRequest()->getParam('type');
$uid = $this->getRequest()->getParam('uid');
if (isset($type) && isset($uid) && !empty($type) && !empty($uid)) {
$type = $this->_HtmlPurifier->filter($type);
$uid = $this->_HtmlPurifier->filter(base64_decode($uid));
if ($uid == $sessionLogin_user->intLoggedinUserId) {
$where = "UserSysId = " . $uid . " AND MsgType = 3 AND ModuleType = 1";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => '1',
'Accepted' => '1',
'IsActive' => '0',
'UpdateDate' => $date,
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$updatedUserInbox = $this->_agencyuserObj->updateNotification($userArray, $where);
}
}
$getData = array();
if ($this->getRequest()->getPost()) {
$getData = $this->getRequest()->getPost();
$getData['POST'] = 1;
$getData = $this->_HtmlPurifier->filterArray($getData);
}
if (isset($type) && !empty($type)) {
$getData['leadType_' . $type] = $type;
}
//echo "<pre>";print_r($getData);die;
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 1)) {
$getData['UserSysId'] = $getData['agencyUserFilter'];
} else if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 2)) {
$getData['UserSysId'] = 0;
} else {
$getData['UserSysId'] = 0;
}
$this->view->searchData = $getData;
$this->view->filterFormDisplay = $this->getRequest()->getPost();
$getCustomerList = array();
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
if (isset($getData['lead_stage']) && $getData['lead_stage'] != '') {
$getData['lead_stage'] = $getData['lead_stage'];
} else {
$getData['lead_stage'] = "48, 49, 51, 52, 53";
}
$this->_crmagencyleadaccountObj->ReportingToSysId = $ReportingToSysId;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
if ($leadFilter == 'callback') {
$getData['lead_stage'] = 52;
$this->view->searchData = $getData;
}
if ($leadFilter == 'fresh') {
$getData['lead_stage'] = 53;
$this->view->searchData = $getData;
}
if ($leadFilter == 'overall') {
$getData['lead_stage'] = "48, 49, 51, 52, 53";
}
$model = new Gtxwebservices_Model_Procedures();
$pageNumber = $this->_getParam('page', 1);
$setItem = GRID_PER_PAGE_RECORD_COUNT;
if ($getRoleDetail['IsAdmin'] == true) {
$getData['AgencySysId'] = $AgencySysId;
$LeadListArr = $model->customerLead($AgencySysId, $pageNumber, $setItem, $getData, $AgentSysId, $ReportingToSysId, $getRoleDetail);
//$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData);
} else {
$getData['UserSysId'] = $AgentSysId;
$leadSourcesIds = array();
$leadSourceExplodedRes = '';
$getCustomerList = array();
if (!empty($getleadSource)) {
foreach ($getleadSource as $k => $v) {
$leadSourcesIds[] = $v['LeadSourceSysId'];
}
$leadSourceExplodedRes = implode(",", $leadSourcesIds);
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
if ($this->getRequest()->isPost()) {
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$this->view->searchData = $getData;
$LeadListArr = $model->customerLead($AgencySysId, $pageNumber, $setItem, $getData, $AgentSysId, $ReportingToSysId, $getRoleDetail);
//$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
} else {
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$LeadListArr = $model->customerLead($AgencySysId, $pageNumber, $setItem, $getData, $AgentSysId, $ReportingToSysId, $getRoleDetail);
// $getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
}
}
}
$totalCountResult = 0;
if (!empty($LeadListArr['Result1'])) {
$totalCountResult = $LeadListArr['Result1'][0]['TotalCount'];
}
$data = range(1, $totalCountResult);
$paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($setItem);
$responseArray = array();
$UnAssignedLead = 0;
$i = 0;
$this->view->leadSourceList = $getleadSource;
$this->view->UnAssignedLead = $UnAssignedLead;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
if ($getRoleDetail['IsAdmin'] == true) {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId, $ReportingToSysId);
}
$getData['orderQueryDate'] = SORT_DESC;
$columnNameOrder = 'UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'queryDate' && $order_type[1] == 1) {
$columnNameOrder = 'ActiveDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'TravelDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'destination' && $order_type[1] == 1) {
$columnNameOrder = 'DestinationPlaces';
$getData['orderQueryDate'] = SORT_ASC;
} else {
$getData['orderQueryDate'] = SORT_DESC;
}
}
if (!empty(@$responseArray)) {
foreach ($responseArray as $key => $part) {
$sort[$key] = ($part[$columnNameOrder] == 'UpdateDate' || $part[$columnNameOrder] == 'ActiveDate' || $part[$columnNameOrder] == 'TravelDate') ? strtotime($part[$columnNameOrder]->format('Y-m-d H:i:s')) : $part[$columnNameOrder];
}
array_multisort($sort, $getData['orderQueryDate'], $responseArray);
}
$this->view->paginator = $paginator;
$this->view->paginator1 = $LeadListArr['Result1'];
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->leadStageList = $getStageList;
$this->view->agencyUser = $agencyUser;
$this->view->getRoleDetail = $getRoleDetail;
$this->view->getData = $getData;
$this->view->countLead = count($getCustomerList);
$this->view->countQuery = $paginator->getTotalItemCount();
$this->view->ReportingToSysId = $ReportingToSysId;
}
public function leadAction() {
//echo "<pre>";print_r($_SESSION);die;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$type = $this->getRequest()->getParam('type');
$leadFilter = $this->getRequest()->getParam('filter');
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
//update assigned lead header notification
$type = $this->getRequest()->getParam('type');
$uid = $this->getRequest()->getParam('uid');
if (isset($type) && isset($uid) && !empty($type) && !empty($uid)) {
$type = $this->_HtmlPurifier->filter($type);
$uid = $this->_HtmlPurifier->filter(base64_decode($uid));
if ($uid == $sessionLogin_user->intLoggedinUserId) {
$where = "UserSysId = " . $uid . " AND MsgType = 3 AND ModuleType = 1";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => '1',
'Accepted' => '1',
'IsActive' => '0',
'UpdateDate' => $date,
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$updatedUserInbox = $this->_agencyuserObj->updateNotification($userArray, $where);
}
}
//# end of update assigned lead header notification
$getData = array();
if ($this->getRequest()->getPost()) {
$getData = $this->getRequest()->getPost();
$getData['POST'] = 1;
$getData = $this->_HtmlPurifier->filterArray($getData);
}
if (isset($type) && !empty($type)) {
$getData['leadType_' . $type] = $type;
}
//echo "<pre>";print_r($getData);die;
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 1)) {
$getData['UserSysId'] = $getData['agencyUserFilter'];
} else if (isset($getData['assigUnassignFilter']) && ($getData['assigUnassignFilter'] == 2)) {
$getData['UserSysId'] = 0;
} else {
$getData['UserSysId'] = 0;
}
$this->view->searchData = $getData;
$this->view->filterFormDisplay = $this->getRequest()->getPost();
$LeadListArr = array();
$getCustomerList = array();
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
$uid = $this->getRequest()->getParam('uid');
if (isset($type) && isset($uid) && !empty($type) && !empty($uid)) {
$type = $this->_HtmlPurifier->filter($type);
$uid = $this->_HtmlPurifier->filter(base64_decode($uid));
if ($uid == $sessionLogin_user->intLoggedinUserId) {
$where = "UserSysId = " . $uid . " AND MsgType = 3 AND ModuleType = 1";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => '1',
'Accepted' => '1',
'IsActive' => '0',
'UpdateDate' => $date,
);
$this->_agencyuserObj = new Travel_Model_CRM_AgencyUserInbox();
$updatedUserInbox = $this->_agencyuserObj->updateNotification($userArray, $where);
}
}
//print_r($getData);die;
if (isset($getData['lead_stage']) && $getData['lead_stage'] != '') {
$getData['lead_stage'] = $getData['lead_stage'];
} else {
$getData['lead_stage'] = array(48, 49, 51, 52, 53);
}
$this->_crmagencyleadaccountObj->ReportingToSysId = $ReportingToSysId;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($AgencySysId);
if ($leadFilter == 'callback') {
$getData['lead_stage'] = 52;
$this->view->searchData = $getData;
}
if ($leadFilter == 'fresh') {
$getData['lead_stage'] = 53;
$this->view->searchData = $getData;
}
if ($leadFilter == 'overall') {
$getData['lead_stage'] = array(48, 49, 51, 52, 53);
}
if ($getRoleDetail['IsAdmin'] == true) {
$getData['AgencySysId'] = $AgencySysId;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData);
} else {
$getData['UserSysId'] = $AgentSysId;
$leadSourcesIds = array();
$leadSourceExplodedRes = '';
$getCustomerList = array();
if (!empty($getleadSource)) {
foreach ($getleadSource as $k => $v) {
$leadSourcesIds[] = $v['LeadSourceSysId'];
}
$leadSourceExplodedRes = implode(",", $leadSourcesIds);
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
if ($this->getRequest()->isPost()) {
// $getData = $this->getRequest()->getPost();
//print_r($getData['lead_stage']);die;
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
//print_r($getData['lead_stage']);die;
//$getData = @$this->_HtmlPurifier->filterArray($getData);
$this->view->searchData = $getData;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
} else {
$getData['AgencySysId'] = $AgencySysId;
$getData['AgentSourceIds'] = $leadSourceExplodedRes;
$getCustomerList = $this->_crmagencyleadaccountObj->GetGtxCustomerApproved($getData, $AgencySysId);
}
}
}
$responseArray = array();
$UnAssignedLead = 0;
$AgencyCRMLeadSysIds = array();
$i = 0;
//echo "<pre>";print_r($getCustomerList);die;
foreach ($getCustomerList as $key => $getCustomerListArr) {
$UnAssignedLead = (trim($getCustomerListArr['AgencyUserFirstName']) == '') ? $UnAssignedLead + 1 : $UnAssignedLead;
if (!in_array($getCustomerListArr['AgencyCRMLeadSysId'], $AgencyCRMLeadSysIds)) {
$responseArray[$i]['Title'] = $getCustomerListArr['CompanyName'];
$responseArray[$i]['ActiveDate'] = $getCustomerListArr['ActiveDate'];
$responseArray[$i]['B2BType'] = $getCustomerListArr['B2BType'];
$responseArray[$i]['AgencyUserFirstName'] = $getCustomerListArr['AgencyUserFirstName'];
$responseArray[$i]['AgencyUserLastName'] = $getCustomerListArr['AgencyUserLastName'];
$responseArray[$i]['FullName'] = $getCustomerListArr['FullName'];
$responseArray[$i]['EmailId'] = $getCustomerListArr['EmailId'];
$responseArray[$i]['Remarks'] = $getCustomerListArr['Remarks'];
$responseArray[$i]['PrimaryContactNumber'] = $getCustomerListArr['PrimaryContactNumber'];
$responseArray[$i]['ActiveDate'] = $getCustomerListArr['ActiveDate'];
$responseArray[$i]['LeadSource'] = $getCustomerListArr['LeadSource'];
$responseArray[$i]['LeadStageSysId'] = $getCustomerListArr['LeadStageSysId'];
$responseArray[$i]['AgencyCRMLeadSysId'] = $getCustomerListArr['AgencyCRMLeadSysId'];
$responseArray[$i]['AgentSysId'] = $getCustomerListArr['AssignUserSysId'];
$responseArray[$i]['TPSysId'] = '';
$responseArray[$i]['IsB2BAgent'] = $getCustomerListArr['IsB2BAgent'];
$responseArray[$i]['hasFollowUp'] = $getCustomerListArr['Subject'];
$responseArray[$i]['hasIteration'] = '';
$responseArray[$i]['MasterTPSysId'] = '';
$responseArray[$i]['VersionId'] = '';
$responseArray[$i]['RoomInfoJson'] = $getCustomerListArr['RoomInfoJson'];
$responseArray[$i]['CreateDate'] = '';
$responseArray[$i]['CustomerSysId'] = $getCustomerListArr['CustomerSysId'];
$responseArray[$i]['PlanBookingId'] = '';
$responseArray[$i]['PlanType'] = '';
$responseArray[$i]['TravelDate'] = $getCustomerListArr['startDate'];
$responseArray[$i]['IsPriceShared'] = '';
$responseArray[$i]['DestinationPlaces'] = '';
$responseArray[$i]['Cities'] = $getCustomerListArr['Destination'];
$responseArray[$i]['NetPrice'] = '';
$responseArray[$i]['ChkEmailId'] = $getCustomerListArr['ChkEmailId'];
$responseArray[$i]['StatusType'] = '';
$responseArray[$i]['UpdateDate'] = $getCustomerListArr['UpdatedDate'];
$responseArray[$i]['OwnerAgentFirstName'] = trim($getCustomerListArr['AgencyUserFirstName']);
$responseArray[$i]['OwnerAgentLastName'] = trim($getCustomerListArr['AgencyUserLastName']);
$responseArray[$i]['Owner'] = (isset($getCustomerListArr['AgencyUserFirstName']) && !empty($getCustomerListArr['AgencyUserFirstName'])) ? stripslashes(trim($getCustomerListArr['AgencyUserFirstName'])) . " " . stripslashes(trim($getCustomerListArr['AgencyUserLastName'])) : 'Admin';
$responseArray[$i]['TYPE'] = 'LEAD';
$AgencyCRMLeadSysIds[] = $getCustomerListArr['AgencyCRMLeadSysId'];
}
$i++;
}
$this->view->leadSourceList = $getleadSource;
$this->view->UnAssignedLead = $UnAssignedLead;
//echo '<pre>';print_r($responseArray);die;
$this->_leadstageObj = new Travel_Model_TblLeadStage();
$crmtravelplanstatusObj = new Travel_Model_CRM_TravelPlanStatus();
$getStageList = $crmtravelplanstatusObj->GetTravelPlanStatusByType(3);
if ($getRoleDetail['IsAdmin'] == true) {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId, $ReportingToSysId);
}
$getData['orderQueryDate'] = SORT_DESC;
$columnNameOrder = 'UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'queryDate' && $order_type[1] == 1) {
$columnNameOrder = 'ActiveDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'TravelDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$getData['orderQueryDate'] = SORT_ASC;
} else if ($order_type[0] == 'destination' && $order_type[1] == 1) {
$columnNameOrder = 'DestinationPlaces';
$getData['orderQueryDate'] = SORT_ASC;
} else {
$getData['orderQueryDate'] = SORT_DESC;
}
}
if (!empty(@$responseArray)) {
foreach ($responseArray as $key => $part) {
$sort[$key] = ($part[$columnNameOrder] == 'UpdateDate' || $part[$columnNameOrder] == 'ActiveDate' || $part[$columnNameOrder] == 'TravelDate') ? strtotime($part[$columnNameOrder]->format('Y-m-d H:i:s')) : $part[$columnNameOrder];
}
array_multisort($sort, $getData['orderQueryDate'], $responseArray);
}
//echo count($responseArray);
//$paginator->getTotalItemCount()=count($responseArray);
$paginator = Zend_Paginator::factory($responseArray);
$pageNumber = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$this->view->paginator = $paginator;
$this->view->paginator1 = @$paginator;
$this->view->messages = $this->_helper->flashMessenger->getMessages();
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
$this->view->leadStageList = $getStageList;
$this->view->agencyUser = $agencyUser;
$this->view->getRoleDetail = $getRoleDetail;
$this->view->getData = $getData;
$this->view->countLead = count($getCustomerList);
$this->view->countQuery = $paginator->getTotalItemCount();
$this->view->ReportingToSysId = $ReportingToSysId;
}
public function queryStageUpdateAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$tpid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid')));
$sid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
$stageType = $this->_HtmlPurifier->filter($this->getRequest()->getParam('stageType', null));
$title = '';
$customHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$travelPlanStatusName = $customHelper->GetTravelPlanStatusArray(1, $sid);
if (isset($tpid) && !empty($tpid) && is_numeric($tpid) > 0 && $sid != '') {
$where = "TPSysId = " . $tpid;
$date = date('Y-m-d H:i:s');
if ($stageType == 1) {
$userArray = array(
'StatusType' => $sid,
'UpdateDate' => $date,
);
} else if ($stageType == 2) {
$userArray = array(
'PaymentStatus' => $sid,
'UpdateDate' => $date,
);
} else if ($stageType == 3) {
$userArray = array(
'BookingStatus' => $sid,
'UpdateDate' => $date,
);
} else {
}
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArray, $where);
$msg = "success";
$title = 'NA';
if (isset($travelPlanStatusName) && is_array($travelPlanStatusName)) {
$title = isset($travelPlanStatusName[0]['TPStatus']) ? $travelPlanStatusName[0]['TPStatus'] : 'NA';
}
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function queryStageUpdateCallbackAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$tpid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid')));
$callbackFrom = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackFrom'));
$callbackreminder = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackreminder'));
$callbackreminderremarks = $this->_HtmlPurifier->filter($this->getRequest()->getParam('callbackreminderremarks'));
$title = '';
$CustomerSysId = '';
$sid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
if (isset($tpid) && !empty($tpid) && is_numeric($tpid) > 0) {
$where = "TPSysId = " . $tpid;
$date = date('Y-m-d H:i:s');
$userArray = array(
'StatusType' => $sid,
'hasFollowUp' => 1,
'UpdateDate' => $date,
);
$travelPlanRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArray, $where);
$callbackFromExplodeAll = explode(' ', $callbackFrom);
$callbackFromExplode = explode('/', $callbackFromExplodeAll[0]);
$callbackFrom = $callbackFromExplode[2] . '-' . $callbackFromExplode[1] . '-' . $callbackFromExplode[0] . " " . $callbackFromExplodeAll[1];
$date = date('Y-m-d H:i:s');
$leadDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($tpid, 'Query');
$CustomerSysId = $leadDetails[0]['CustomerSysId'];
$data = array(
'Subject' => 'New To Do For call Back',
'StartDateTime' => $callbackFrom,
'EndDateTime' => $callbackFrom,
'RelatedTo' => '',
'IsCompleted' => '',
'TPSysId' => $tpid,
'Type' => 1,
'AgencySysId' => $AgencySysId,
'Location' => 0,
'Description' => addslashes($callbackreminderremarks),
'CustSysId' => $CustomerSysId,
'CreatedBySysId' => $AgentSysId,
'AssignToSysId' => $AgentSysId,
'RemindDuration' => $callbackreminder,
'CreateDate' => $date,
'UpdateDate' => $date,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
//print_r($getStageList);
$msg = "success";
$customHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$travelPlanStatusName = $customHelper->GetTravelPlanStatusArray(1, $sid);
//print_r($travelPlanStatusName);die;
$title = count($travelPlanStatusName) > 0 ? $travelPlanStatusName[0]['TPStatus'] : 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function customerProposalAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->view->arrEmailTemplates = $this->_agencyObj->getAgencyEmailTemplates($AgencySysId);
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
$this->view->getData = $getData;
$this->_crmcusttravelplan->strCondition = "";
if ($this->getRequest()->isPost()) {
//$this->_crmcusttravelplan->strCondition = "1=1";
$getData = $this->getRequest()->getPost();
$this->view->searchData = $getData;
$customerName = trim($getData['customerName']);
if ($customerName != "") {
$this->_crmcusttravelplan->strCondition .= " AND (tb3.FirstName LIKE '%" . $customerName . "%' OR tb3.LastName LIKE '%" . $customerName . "%')";
}
$customerEmail = trim($getData['customerEmail']);
if ($customerEmail != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb3.EmailId = '" . $customerEmail . "'";
}
if (!empty($getData['dateFrom']) && !empty($getData['dateTo'] && $getData['dateTo'] != '__-__-____' && $getData['dateFrom'] != '__-__-____')) {
$dateFromEx = explode('-', $getData['dateFrom']);
$dateToEx = explode('-', $getData['dateTo']);
$dateFrom = $dateFromEx[2] . '-' . $dateFromEx[1] . '-' . $dateFromEx[0];
$dateTo = $dateToEx[2] . '-' . $dateToEx[1] . '-' . $dateToEx[0];
$dateTos = date('Y-m-d', strtotime($dateTo . ' +1 days'));
$this->_crmcusttravelplan->strCondition .= " AND tb1.CreateDate >= '" . $dateFrom . "' AND tb1.CreateDate <= '" . $dateTos . "'";
}
$customerMobile = trim($getData['customerMobile']);
if ($customerMobile != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb3.Contacts = '" . $customerMobile . "'";
}
$customerProposalId = trim($getData['customerProposalId']);
if ($customerProposalId != "") {
$explodeProposal = explode("/", $customerProposalId);
if (count($explodeProposal) == 4) {
$customerProposalId = $explodeProposal[2];
} else if (count($explodeProposal) == 1) {
$customerProposalId = $explodeProposal[0];
} else {
$customerProposalId = intval($customerProposalId);
}
$this->_crmcusttravelplan->strCondition .= " AND tb1.TPSysId = '" . $customerProposalId . "'";
}
$OwnerName = isset($getData['owner']) ? trim($getData['owner']) : '';
if ($OwnerName != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb1.AgentSysId = '" . $OwnerName . "'";
}
$Destination = trim($getData['Destination']);
if ($Destination != "") {
if (!$this->checkIsAdmin()) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.AgentSysId = '" . $AgentSysId . "'";
}
$this->_crmcusttravelplan->strCondition .= " AND (tb1.DestinationPlacesSysId = '" . $Destination . "' OR tb1.SourcePlaceSysId = '" . $Destination . "')";
}
$StatusType = trim($getData['StatusType']);
if ($StatusType != "") {
if (!$this->checkIsAdmin()) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.AgentSysId = '" . $AgentSysId . "'";
}
if ($StatusType == 101) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.hasFollowUp = '1'";
} else if ($StatusType == 102) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.hasIteration = '1'";
} else {
$this->_crmcusttravelplan->strCondition .= " AND tb1.StatusType = '" . $StatusType . "'";
}
}
$curdateDB = (date('Y-m-d'));
$isexpired = (isset($getData['isexpired'])) ? trim($getData['isexpired']) : '';
if ($isexpired != "") {
$strCondition = "";
$ids = implode(',', $this->statustypeIDForExpiredArr);
$strCondition .= "AND ( tb1.StatusType NOT IN($ids) ) ";
$this->_crmcusttravelplan->strCondition .= " AND ( CONVERT(VARCHAR(40), tb1.StartDate, 101) < CONVERT(VARCHAR(40), CAST('$curdateDB 0:00:00:000' AS DATETIME), 101) $strCondition ) ";
}
// echo $this->_crmcusttravelplan->strCondition; die;
// echo '<pre>';
// print_r($getData);
// die;
}
$columnNameOrder = 'tb1.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.StartDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.UpdateDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'tb1.UpdateDate';
$orderBy = "DESC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.TpSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 0) {
$columnNameOrder = 'tb1.TpSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.AgentSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'tb1.AgentSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.StatusType';
$orderBy = "ASC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 0) {
$columnNameOrder = 'tb1.StatusType';
$orderBy = "DESC";
} else {
$orderBy = "DESC";
}
} else {
$orderBy = "DESC";
}
// echo $orderDetails = $columnNameOrder . " " . $orderBy;die;
//echo $columnNameOrder." ".$orderBy;
$this->_crmcusttravelplan->strOrder = $columnNameOrder . " " . $orderBy;
if ($this->checkIsAdmin()) {
$this->view->isAdmin = true;
$this->_crmcusttravelplan->isAdmin = true;
}
$this->_crmcusttravelplan->ReportingToSysId = $ReportingToSysId;
$chatDetails = $this->_crmcusttravelplan->GetAllProposalListDetails('', $AgencySysId, $AgentSysId);
$page = $this->_getParam('page', 1);
//echo "<pre>";print_r($listArr);
// $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($chatDetails));
$paginator = Zend_Paginator::factory($chatDetails);
if (isset($getData['page'])) {
$paginator->setCurrentPageNumber($getData['page']); // page number
} else {
$paginator->setCurrentPageNumber($page); // page number
}
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$res = array();
$listArr = array();
foreach ($paginator as $key) {
if (!in_array($key['TPSysId'], $res)) {
$listArr[] = $key;
}
$res[] = $key['TPSysId'];
}
$this->view->paginator1 = $listArr;
$this->view->paginator = $paginator;
$this->view->totalres = $paginator->getTotalItemCount();
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
$this->view->agencyUser = $agencyUser;
//echo "<pre>";print_r($agencyUser);die;
$this->view->statustypenameForExpiredArr = $this->statustypenameForExpiredArr;
}
public function customerProposalPrashantAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->view->arrEmailTemplates = $this->_agencyObj->getAgencyEmailTemplates($AgencySysId);
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
$this->view->getData = $getData;
$this->_crmcusttravelplan->strCondition = "";
$checkAdmin = $this->checkIsAdmin();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['statustypeIDForExpiredArr'] = $this->statustypeIDForExpiredArr;
$this->view->searchData = $getData;
}
$columnNameOrder = 'UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'StartDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'UpdateDate';
$orderBy = "DESC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 1) {
$columnNameOrder = 'TpSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 0) {
$columnNameOrder = 'TpSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'AgentSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'AgentSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 1) {
$columnNameOrder = 'StatusType';
$orderBy = "ASC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 0) {
$columnNameOrder = 'StatusType';
$orderBy = "DESC";
} else {
$orderBy = "DESC";
}
} else {
$orderBy = "DESC";
}
// echo $orderDetails = $columnNameOrder . " " . $orderBy;die;
$this->_crmcusttravelplan->strOrder = $columnNameOrder . " " . $orderBy;
if ($checkAdmin) {
$this->view->isAdmin = true;
$this->_crmcusttravelplan->isAdmin = true;
}
$this->_crmcusttravelplan->ReportingToSysId = $ReportingToSysId;
$model = new Gtxwebservices_Model_Procedures();
$pageNumber = $this->_getParam('page', 1);
$setItem = GRID_PER_PAGE_RECORD_COUNT;
$LeadListArr = $model->customerB2CPropopsal($AgencySysId, $pageNumber, $setItem, $getData, $AgentSysId, $ReportingToSysId, $checkAdmin, $orderBy, $columnNameOrder);
$totalCountResult = 0;
if (!empty($LeadListArr['Result1'])) {
$totalCountResult = $LeadListArr['Result1'][0]['TotalCount'];
}
$data = range(1, $totalCountResult);
$paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($setItem);
$this->view->paginator1 = $LeadListArr['Result1'];
$this->view->paginator = $paginator;
$this->view->totalres = $totalCountResult;
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
$this->view->agencyUser = $agencyUser;
//echo "<pre>";print_r($agencyUser);die;
$this->view->statustypenameForExpiredArr = $this->statustypenameForExpiredArr;
}
public function b2bProposalAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->view->arrEmailTemplates = $this->_agencyObj->getAgencyEmailTemplates($AgencySysId);
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
$this->view->getData = $getData;
$this->_crmcusttravelplan->strCondition = "";
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchData = $getData;
$customerName = trim($getData['customerName']);
if ($customerName != "") {
$this->_crmcusttravelplan->strCondition .= " AND (tb3.FirstName LIKE '%" . $customerName . "%' OR tb3.LastName LIKE '%" . $customerName . "%')";
}
$agencyName = trim($getData['agencyName']);
if ($agencyName != "") {
$this->_crmcusttravelplan->strCondition .= " AND (tb5.AgencyName LIKE '%" . $agencyName . "%')";
}
$customerEmail = trim($getData['customerEmail']);
if ($customerEmail != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb3.EmailId = '" . $customerEmail . "'";
}
if (!empty($getData['dateFrom']) && !empty($getData['dateTo'] && $getData['dateTo'] != '__-__-____' && $getData['dateFrom'] != '__-__-____')) {
$dateFromEx = explode('-', $getData['dateFrom']);
$dateToEx = explode('-', $getData['dateTo']);
$dateFrom = $dateFromEx[2] . '-' . $dateFromEx[1] . '-' . $dateFromEx[0];
$dateTo = $dateToEx[2] . '-' . $dateToEx[1] . '-' . $dateToEx[0];
$dateTos = date('Y-m-d', strtotime($dateTo . ' +1 days'));
$this->_crmcusttravelplan->strCondition .= " AND tb1.CreateDate >= '" . $dateFrom . "' AND tb1.CreateDate <= '" . $dateTos . "'";
}
$customerMobile = trim($getData['customerMobile']);
if ($customerMobile != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb3.Contacts = '" . $customerMobile . "'";
}
$customerProposalId = trim($getData['customerProposalId']);
if ($customerProposalId != "") {
$explodeProposal = explode("/", $customerProposalId);
if (count($explodeProposal) == 4) {
$customerProposalId = $explodeProposal[2];
} else if (count($explodeProposal) == 1) {
$customerProposalId = $explodeProposal[0];
} else {
$customerProposalId = intval($customerProposalId);
}
$this->_crmcusttravelplan->strCondition .= " AND tb1.TPSysId = '" . $customerProposalId . "'";
}
$OwnerName = isset($getData['owner']) ? trim($getData['owner']) : '';
if ($OwnerName != "") {
$this->_crmcusttravelplan->strCondition .= " AND tb1.AgentSysId = '" . $OwnerName . "'";
}
$Destination = trim($getData['Destination']);
if ($Destination != "") {
$this->_crmcusttravelplan->strCondition .= " AND (tb1.DestinationPlacesSysId = '" . $Destination . "' OR tb1.SourcePlaceSysId = '" . $Destination . "')";
}
$StatusType = trim($getData['StatusType']);
if ($StatusType != "") {
if ($StatusType == 101) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.hasFollowUp = '1'";
} else if ($StatusType == 102) {
$this->_crmcusttravelplan->strCondition .= " AND tb1.hasIteration = '1'";
} else {
$this->_crmcusttravelplan->strCondition .= " AND tb1.StatusType = '" . $StatusType . "'";
}
}
$curdateDB = (date('Y-m-d'));
$isexpired = (isset($getData['isexpired'])) ? trim($getData['isexpired']) : '';
if ($isexpired != "") {
$strCondition = "";
$ids = implode(',', $this->statustypeIDForExpiredArr);
$strCondition .= "AND ( tb1.StatusType NOT IN($ids) ) ";
$this->_crmcusttravelplan->strCondition .= " AND ( CONVERT(VARCHAR(40), tb1.StartDate, 101) < CONVERT(VARCHAR(40), CAST('$curdateDB 0:00:00:000' AS DATETIME), 101) $strCondition ) ";
}
// echo $this->_crmcusttravelplan->strCondition; die;
// echo '<pre>';
// print_r($getData);
// die;
}
$columnNameOrder = 'tb1.UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.StartDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.UpdateDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.TpSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.AgentSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 1) {
$columnNameOrder = 'tb1.StatusType';
$orderBy = "ASC";
} else {
$orderBy = "DESC";
}
} else {
$orderBy = "DESC";
}
//echo $columnNameOrder." ".$orderBy;
$this->_crmcusttravelplan->strOrder = $columnNameOrder . " " . $orderBy;
if ($this->checkIsAdmin()) {
$this->view->isAdmin = true;
$this->_crmcusttravelplan->isAdmin = true;
}
$this->_crmcusttravelplan->ReportingToSysId = $ReportingToSysId;
$chatDetails = $this->_crmcusttravelplan->GetAllB2BProposalListDetails('', $AgencySysId, $AgentSysId);
$page = $this->_getParam('page', 1);
//echo "<pre>";print_r($listArr);
$paginator = Zend_Paginator::factory($chatDetails);
if (isset($getData['page'])) {
$paginator->setCurrentPageNumber($getData['page']); // page number
} else {
$paginator->setCurrentPageNumber($page); // page number
}
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
$res = array();
$listArr = array();
foreach ($paginator as $key) {
if (!in_array($key['TPSysId'], $res)) {
$listArr[] = $key;
}
$res[] = $key['TPSysId'];
}
$this->view->paginator = $paginator;
$this->view->paginator1 = $listArr;
$this->view->totalres = $paginator->getTotalItemCount();
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
$this->view->agencyUser = $agencyUser;
$this->view->statustypenameForExpiredArr = $this->statustypenameForExpiredArr;
}
public function b2bProposalPrashantAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $sessionLogin_user->intLoggedinUserId;
$ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->view->arrEmailTemplates = $this->_agencyObj->getAgencyEmailTemplates($AgencySysId);
$orderBy = $this->_HtmlPurifier->filter($this->getRequest()->getParam('order'));
isset($orderBy) ? ($getData['order'] = $orderBy) : '';
$this->view->getData = $getData;
$this->_crmcusttravelplan->strCondition = "";
$checkAdmin = $this->checkIsAdmin();
if ($this->getRequest()->isPost()) {
$getData = $this->getRequest()->getPost();
$getData['statustypeIDForExpiredArr'] = $this->statustypeIDForExpiredArr;
$this->view->searchData = $getData;
}
$columnNameOrder = 'UpdateDate';
if (isset($orderBy) && !empty($orderBy)) {
$order_type = explode('_', $orderBy);
if ($order_type[0] == 'travelDate' && $order_type[1] == 1) {
$columnNameOrder = 'StartDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 1) {
$columnNameOrder = 'UpdateDate';
$orderBy = "ASC";
} else if ($order_type[0] == 'lastUpdate' && $order_type[1] == 0) {
$columnNameOrder = 'UpdateDate';
$orderBy = "DESC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 1) {
$columnNameOrder = 'TpSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'proposalId' && $order_type[1] == 0) {
$columnNameOrder = 'TpSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 1) {
$columnNameOrder = 'AgentSysId';
$orderBy = "ASC";
} else if ($order_type[0] == 'owner' && $order_type[1] == 0) {
$columnNameOrder = 'AgentSysId';
$orderBy = "DESC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 1) {
$columnNameOrder = 'StatusType';
$orderBy = "ASC";
} else if ($order_type[0] == 'stage' && $order_type[1] == 0) {
$columnNameOrder = 'StatusType';
$orderBy = "DESC";
} else {
$orderBy = "DESC";
}
} else {
$orderBy = "DESC";
}
$this->_crmcusttravelplan->strOrder = $columnNameOrder . " " . $orderBy;
if ($checkAdmin) {
$this->view->isAdmin = true;
$this->_crmcusttravelplan->isAdmin = true;
}
$this->_crmcusttravelplan->ReportingToSysId = $ReportingToSysId;
$model = new Gtxwebservices_Model_Procedures();
$pageNumber = $this->_getParam('page', 1);
$setItem = GRID_PER_PAGE_RECORD_COUNT;
$LeadListArr = $model->customerB2BPropopsal($AgencySysId, $pageNumber, $setItem, $getData, $AgentSysId, $ReportingToSysId, $checkAdmin, $orderBy, $columnNameOrder);
// $chatDetails = $this->_crmcusttravel
// $chatDetails = $this->_crmcusttravelplan->GetAllB2BProposalListDetails('', $AgencySysId, $AgentSysId);
// $page = $this->_getParam('page', 1);
// //echo "<pre>";print_r($listArr);
// $paginator = Zend_Paginator::factory($chatDetails);
// if (isset($getData['page'])) {
// $paginator->setCurrentPageNumber($getData['page']); // page number
// } else {
// $paginator->setCurrentPageNumber($page); // page number
// }
// $paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT); // number of items to show per page
// $res = array();
// $listArr = array();
// foreach ($paginator as $key) {
// if (!in_array($key['TPSysId'], $res)) {
// $listArr[] = $key;
// }
// $res[] = $key['TPSysId'];
// }
// $this->view->paginator = $paginator;
// $this->view->paginator1 = $listArr;
// $this->view->totalres = $paginator->getTotalItemCount();
$totalCountResult = 0;
if (!empty($LeadListArr['Result1'])) {
$totalCountResult = $LeadListArr['Result1'][0]['TotalCount'];
}
$data = range(1, $totalCountResult);
$paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($setItem);
$this->view->paginator1 = $LeadListArr['Result1'];
$this->view->paginator = $paginator;
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $AgencySysId);
$this->view->agencyUser = $agencyUser;
$this->view->statustypenameForExpiredArr = $this->statustypenameForExpiredArr;
}
public function checkDummyQueryAction() {
$GSTApplicableOn = 1;
$packageCost = 28468;
$AgencyExtraMarkUp = $MarkupArray[0];
$AgencyDiscount = $discountValue[0];
$intProductType = 9;
$intProductGeoType = 1; // 1 For Domestic, 2 For International
$arrInputData = array(
"GSTApplicableOn" => $GSTApplicableOn,
"intProductType" => $intProductType,
"intProductGeoType" => $intProductGeoType,
"Cost" => $packageCost,
"AgencyMarkUp" => $AgencyMarkUp,
"AgencyExtraMarkUp" => $AgencyExtraMarkUp,
"AgencyDiscount" => $AgencyDiscount
);
$arrGSTCalculations = Zend_Controller_Action_HelperBroker::getStaticHelper("General")->calculateGST($arrInputData);
}
/* Added By Mangal For B2B Agent Forget Password 13-11-2018 Start */
public function sendB2bAgentForgetPasswordMailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$data = $this->getRequest()->getParams();
$tblAgencyStaff = new Travel_Model_TblAgencyStaff();
$userSysId = $data['userSysId'];
$getUserDetailsById = $tblAgencyStaff->getUserDetailsById($userSysId);
$modelAgency = new Travel_Model_TblAgency();
$masterAgencyData = $modelAgency->getUserDataByAgency($agencysysID);
$fname = $data['FirstName'];
$lname = $data['LastName'];
$customerEmail = $data['EmailId'];
$AgentAuth = new Travel_Model_AgencyAgentAuth();
$result = $AgentAuth->updatePasswordFormB2bPassword($customerEmail, $agencysysID);
// echo "<pre>";print_r($result);die;
if (isset($result['password'])) {
$params = array('agentName' => ucfirst($fname . ' ' . $lname), 'emailId' => $customerEmail, 'password' => $result['password'], 'Url' => $masterAgencyData['Url'], 'Title' => $masterAgencyData['Title'], 'PrimaryEmail' => $masterAgencyData['PrimaryEmail'], 'PrimaryContactNo' => $masterAgencyData['PrimaryContactNo'], 'IsB2bSite' => $masterAgencyData['IsB2bSite'], 'IsB2bSiteURL' => $masterAgencyData['IsB2bSiteURL']);
#Set subject
$subject = 'Your Account Details';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('b2bcustomerinfo.phtml');
$emailData = array('fromEmail' => trim($masterAgencyData['PrimaryEmail']), 'fromName' => trim($masterAgencyData['PrimaryContactName']), 'subject' => $subject, 'to' => array($customerEmail), 'bodyHtml' => $bodyText, 'bodyText' => '');
//echo "success";
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $masterAgencyData['AgencySysId'],
"AgentSysId" => $getUserDetailsById['UserSysId'],
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
//print_r($arrEmailStatistics);
$checkStatus = $this->mailSentByElastice($emailData, $arrEmailStatistics);
}
if (isset($checkStatus)) {
echo json_encode(array('status' => true));
exit;
} else {
echo json_encode(array('status' => false));
exit;
}
}
/* Added By Mangal For B2B Agent Forget Password 13-11-2018 End */
/* Added By Mangal For Miscellaneous Query 12-05-2020 Start */
public function saveQueryDetailAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
//echo "<pre>";print_r($_POST);exit;
$miscellaneoussearch_going_f = trim($this->getRequest()->getParam('miscellaneoussearch_going_f'));
$miscellaneoussearch_going_from = trim($this->getRequest()->getParam('miscellaneoussearch_going_from'));
$arrMiscellaneoussearchGoingFrom = explode("__", $miscellaneoussearch_going_from);
if (!empty($arrMiscellaneoussearchGoingFrom) && (isset($arrMiscellaneoussearchGoingFrom[0]) && (int) $arrMiscellaneoussearchGoingFrom[0] > 0)) {
$MiscellaneousGoingFrom = $arrMiscellaneoussearchGoingFrom[0];
$nooftraveler = $this->getRequest()->getParam('count_miscellaneous');
$CustomerSysId = !empty($this->getRequest()->getParam('CustomerSysId')) ? trim($this->getRequest()->getParam('CustomerSysId')) : 0;
$serviceName = !empty($this->getRequest()->getParam('serviceName')) ? trim($this->getRequest()->getParam('serviceName')) : '';
$travelDate = $miscellaneoussearch_specific_date = $this->getRequest()->getParam('miscellaneoussearch_specific_date');
$arrMiscellaneoussearch_specific_date = explode("/", $miscellaneoussearch_specific_date);
$miscellaneoussearch_specific_date = $arrMiscellaneoussearch_specific_date[2] . "-" . $arrMiscellaneoussearch_specific_date[1] . "-" . $arrMiscellaneoussearch_specific_date[0];
$editLeadId = (trim($this->getRequest()->getParam('editLeadId')) != '') ? base64_decode(trim($this->getRequest()->getParam('editLeadId'))) : '';
$SaveQuery = trim($this->getRequest()->getParam('saveQuery'));
$saveSearchQuery = trim($this->getRequest()->getParam('saveSearchQuery'));
$countrySysId = trim($this->getRequest()->getParam('ContSysId')) ? trim($this->getRequest()->getParam('ContSysId')) : '';
$leadRemark = trim($this->getRequest()->getParam('leadRemark')) ? trim($this->getRequest()->getParam('leadRemark')) : '';
$currentOwnerSysId = trim($this->getRequest()->getParam('currentOwnerSysId')) ? trim($this->getRequest()->getParam('currentOwnerSysId')) : '';
$leadsource = (NULL !== $this->getRequest()->getParam('lead_source')) ? $this->getRequest()->getParam('lead_source') : '';
$IsOperationalLead = $this->getRequest()->getParam('IsOperationalLead') ? $this->getRequest()->getParam('IsOperationalLead') : 0;
$OpsAgentSysId = ($this->getRequest()->getParam('OpsAgentSysId') && $IsOperationalLead == 1) ? $this->getRequest()->getParam('OpsAgentSysId') : '';
$ExpectedClosureDate = $this->getRequest()->getParam('ExpectedClosureDate');
$ExpectedValue = $this->getRequest()->getParam('ExpectedValue');
$roomjson = array();
$roomjson[1]['TotalPax'] = $this->getRequest()->getParam('count_miscellaneous');
$roomjson[1]['Adult'] = $this->getRequest()->getParam('count_miscellaneous');
$roomjson[1]['Child'] = 0;
$roomjson[1]['Infant'] = 0;
$roomjson[1]['bedtype'] = 'none';
$roomjson[1]['departuredate'] = $this->getRequest()->getParam('miscellaneoussearch_specific_date');
$roomjson[1]['returndate'] = '';
$roominfojson = json_encode($roomjson);
$tottravelers = $this->getRequest()->getParam('count_miscellaneous') + $this->getRequest()->getParam('totadlt_miscellaneous') + $this->getRequest()->getParam('totadlt_miscellaneous');
// $currentDate = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
$currentDate = date('Y-m-d H:i:s');
$PlanBookingId = "Q/" . date('y');
if ($CustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
}
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$ExpectedClosureDateN = (isset($ExpectedClosureDate) && !empty($ExpectedClosureDate)) ? implode('-', array_reverse(explode('/', $ExpectedClosureDate))) : '';
$ExpectedValueN = (isset($ExpectedValue) && !empty($ExpectedValue)) ? (float) trim($ExpectedValue) : 0;
$arrMiscellaneousQuery = array();
$arrMiscellaneousQuery['PlanBookingId'] = $PlanBookingId;
$arrMiscellaneousQuery['AgencySysId'] = $this->intLoggedinUserAgencySysId;
$arrMiscellaneousQuery['AgentSysId'] = (isset($currentOwnerSysId) && $currentOwnerSysId != '') ? $currentOwnerSysId : $this->intLoggedinUserId;
$arrMiscellaneousQuery['CreatorSysId'] = $this->intLoggedinUserId;
$arrMiscellaneousQuery['PlanType'] = 10; // For Miscellaneous
$arrMiscellaneousQuery['SupplierSysId'] = 0;
$arrMiscellaneousQuery['StatusType'] = 1;
$arrMiscellaneousQuery['InventoryType'] = 1;
$arrMiscellaneousQuery['CurrencyType'] = 0;
$arrMiscellaneousQuery['SourcePlaceSysId'] = '';
$arrMiscellaneousQuery['SourcePlaces'] = '';
$arrMiscellaneousQuery['DestinationPlacesSysId'] = (int) $MiscellaneousGoingFrom;
$arrMiscellaneousQuery['DestinationPlaces'] = $miscellaneoussearch_going_f;
$arrMiscellaneousQuery['Cities'] = $miscellaneoussearch_going_f;
$arrMiscellaneousQuery['CityIds'] = $MiscellaneousGoingFrom;
$arrMiscellaneousQuery['StartDate'] = $miscellaneoussearch_specific_date;
$arrMiscellaneousQuery['RoomInfoJson'] = $roominfojson;
$arrMiscellaneousQuery['MinPax'] = $tottravelers;
$arrMiscellaneousQuery['CustomerSysId'] = $CustomerSysId;
$arrMiscellaneousQuery['Countries'] = $countrySysId;
$arrMiscellaneousQuery['CreateDate'] = $currentDate;
$arrMiscellaneousQuery['UpdateDate'] = $currentDate;
$arrMiscellaneousQuery['ApproveDate'] = $currentDate;
$arrMiscellaneousQuery['IsMarkForDel'] = 0;
$arrMiscellaneousQuery['IsActive'] = 1;
$arrMiscellaneousQuery['IsAprooved'] = 1;
$arrMiscellaneousQuery['IsB2Bproposal'] = trim($IsB2BCustomer);
$arrMiscellaneousQuery['CustomerRemark'] = trim($leadRemark);
$arrMiscellaneousQuery['EconomyMask'] = $serviceName;
$arrMiscellaneousQuery['LeadSourceSysId'] = $leadsource;
$arrMiscellaneousQuery['OpsAgentSysId'] = $OpsAgentSysId;
$arrMiscellaneousQuery['IsOperationalLead'] = $IsOperationalLead;
$arrMiscellaneousQuery['ExpectedClosureDate'] = $ExpectedClosureDateN;
$arrMiscellaneousQuery['ExpectedValue'] = $ExpectedValueN;
if (isset($editLeadId) && !empty($editLeadId)) {
$arrMiscellaneousQuery['TemplatePckSysId'] = $editLeadId;
$crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$existLeadDetail = $crmcusttravelplan->CheckCustomerWithLeadId($editLeadId, 'Query');
$nextVersionId = $existLeadDetail[0]['VersionId'] + 1;
$arrMiscellaneousQuery['VersionId'] = $nextVersionId;
}
$objCurd = new Sightseeing_Model_Sightseeing();
//update crm lead account record when created new query
if ($customerDetails['AgencyCRMLeadSysId']) {
$userleadAccountArray = array(
'LeadStageSysId' => 50, //50 id for change status in create query for crm lead account table
'UpdatedDate' => $currentDate,
);
$whereleadAccount = "AgencyCRMLeadSysId = " . $customerDetails['AgencyCRMLeadSysId'];
$objCurd->updateTable("TB_Agency_CRM_Leadaccount", $userleadAccountArray, $whereleadAccount);
}
if (empty($editLeadId)) {
$createNewQuery = (NULL != $this->getRequest()->getParam('createNewQuery')) ? $this->getRequest()->getParam('createNewQuery') : '';
$NewQueryLeadHiddenId = (NULL != $this->getRequest()->getParam('NewQueryLeadHiddenId')) ? trim($this->getRequest()->getParam('NewQueryLeadHiddenId')) : '';
// echo $NewQueryLeadHiddenId."/".$createNewQuery;die;
if (($NewQueryLeadHiddenId != "") && ($createNewQuery == 'false' || $createNewQuery == '')) {
$where = "TPSysId = " . $NewQueryLeadHiddenId;
$updateQuery = array(
"IsMarkForDel" => true,
'IsActive' => False
);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updateQuery, $where);
}
$MiscellaneousQueryTravelPlanId = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($arrMiscellaneousQuery);
//echo "<pre>";print_r($MiscellaneousQueryTravelPlanId);die;
if ($MiscellaneousQueryTravelPlanId) {
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'CustomerSysId' => $CustomerSysId,
'AgentSysId' => $this->intLoggedinUserId,
'Remarks' => $leadRemark,
'TPSysId' => $MiscellaneousQueryTravelPlanId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $currentDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
// $arrMiscellaneousQuery = [
// 'ExpectedClosureDate' => $ExpectedClosureDate,
// 'ExpectedValue' => $ExpectedValue,
// ];
// $ClosureData = $this->_crmcusttravelplan->expectedClosureData($MiscellaneousQueryTravelPlanId, $arrMiscellaneousQuery);
}
$redirection = false;
if (isset($saveSearchQuery) && !empty($saveSearchQuery)) {
$redirection = true;
}
} else {
$where = "TPSysId = " . ($editLeadId);
unset($arrMiscellaneousQuery['CreateDate']);
$MiscellaneousQueryPrposalTravelPlanId = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($arrMiscellaneousQuery, $where);
$redirection = true;
$MiscellaneousQueryTravelPlanId = $editLeadId;
// $arrMiscellaneousQuery = [
// 'ExpectedClosureDate' => $ExpectedClosureDate,
// 'ExpectedValue' => $ExpectedValue,
// ];
// $ClosureData = $this->_crmcusttravelplan->expectedClosureData($MiscellaneousQueryTravelPlanId, $arrMiscellaneousQuery);
}
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$checkrecord = $custtravelhistoryObj->getCustomerTravelHistoryForCity($CustomerSysId, $this->intLoggedinUserAgencySysId, $MiscellaneousGoingFrom);
if (count($checkrecord) == 0) {
$customerHistoryArray = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $CustomerSysId,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => isset($miscellaneoussearch_specific_date) ? $miscellaneoussearch_specific_date : $currentDate,
'ContSysId' => $countrySysId ? $countrySysId : '',
'CitySysId' => $MiscellaneousGoingFrom ? $MiscellaneousGoingFrom : '',
'PlanType' => 10,
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
'IsMarkForDelete' => '0'
);
//print_r($customerHistoryArray);die;
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
}
//#end of customer profile data
if (!empty($MiscellaneousQueryTravelPlanId)) {
/* Automation Emailer Master Template By Mangal 26-09-2018 Start */
// echo "<pre>";print_r($_SESSION);die;
$objAgency = new Travel_Model_TblAgency();
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$getSenderEmailID = $objAgency->getSenderEmailIDBySenderSysId($this->intLoggedinUserAgencySysId, $SenderEmailSysId);
$mCustomerFirstName = trim($customerDetails['FirstName']);
$mCustomerLastName = trim($customerDetails['LastName']);
$mCustomerEmailId = trim($customerDetails['EmailId']);
$companyLogo = trim($_SESSION['sessionLogin_user']['Logo']);
$agencyTitle = trim($_SESSION['sessionLogin_user']['agencyDetails']['Title']);
$agencyPrimaryEmail = (isset($getSenderEmailID['SenderEmailID']) && !empty($getSenderEmailID['SenderEmailID'])) ? $getSenderEmailID['SenderEmailID'] : trim($_SESSION['AgencyUser']['user']->EmailId);
$agencyContactNo1 = trim($_SESSION['AgencyUser']['user']->ContactNo1);
$agencyContactNo2 = trim($_SESSION['sessionLogin_user']['agencyDetails']['ContactNo2']);
$PrimaryContactName = trim($_SESSION['sessionLogin_user']['agencyDetails']['PrimaryContactName']);
$agencyUrl = trim($_SESSION['sessionLogin_user']['agencyDetails']['Url']);
$travelDate = trim($travelDate);
$nooftraveler = $nooftraveler;
$CountryCode = isset($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) . '-' : '+91-';
$params = array('CountryCode' => $CountryCode, 'customerName' => ucfirst($mCustomerFirstName . ' ' . $mCustomerLastName), 'emailId' => $mCustomerEmailId, 'logo' => $companyLogo, 'agencyTitle' => $agencyTitle, 'destination' => $arrMiscellaneoussearchGoingFrom[1], 'noofPax' => $nooftraveler, 'travelDate' => $travelDate, 'agencyPrimaryEmail' => $agencyPrimaryEmail, 'agencyContactNo1' => $agencyContactNo1, 'agencyContactNo2' => $agencyContactNo2, 'Url' => $agencyUrl, 'queryID' => $MiscellaneousQueryTravelPlanId, 'PKqueryType' => 'Miscellaneous');
#Set subject
$subject = $mCustomerFirstName . ' ' . $mCustomerLastName . ' Thanks for your Query for ' . $arrMiscellaneoussearchGoingFrom[1] . '[' . $arrMiscellaneoussearchGoingFrom[0] . ']';
if (empty($editLeadId) && in_array('queryacknowledgement', $this->manageNotifications)) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('masterTemplateMailinfo.phtml');
$emailMasterData = array('fromEmail' => trim($agencyPrimaryEmail), 'fromName' => trim($PrimaryContactName), 'subject' => $subject, 'to' => array($mCustomerEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$checkStatusEmail = $this->mailSentByElastice($emailMasterData, $arrEmailStatistics);
}
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($MiscellaneousQueryTravelPlanId), 1);
/* Automation Emailer Master Template By Mangal 26-09-2018 End */
$response = array('success' => true, 'msg' => 'Query for Miscellaneous created successfully', 'TPSysId' => base64_encode($MiscellaneousQueryTravelPlanId), 'redirection' => $redirection, 'lastID' => $MiscellaneousQueryTravelPlanId, 'code' => $secureCode);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! Some Error accured.', 'TPSysId' => '', 'redirection' => $redirection);
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'msg' => 'Oops! Some Error accured.', 'TPSysId' => '', 'redirection' => false);
echo json_encode($response);
exit;
}
}
}
/* Added By Mangal For Miscellaneous Query 12-05-2020 End */
public function editCustomerInformationAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$CustomerSysId = trim($this->getRequest()->getParam('CustomerSysId'));
$objCountry = new Travel_Model_TblCountry();
$this->_objPkg = new Travel_Model_PackageSearch();
$countryList = $objCountry->getCountryList();
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$SpecialRequest = $this->_crmcustomerObj->getCustomerTags($AgencySysId);
$getCustomerVisaDetail = $this->_crmagencyleadaccountObj->getCustomerVisaDetail($AgencySysId, $CustomerSysId);
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['cityName'] = $customerCityName;
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
// echo "<pre>";print_r($getCustomerDetail);die;
$customerDetail = ['IsB2BAgent' => 0];
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/');
$html->assign('customerDetail', $getCustomerDetail);
$html->assign('mpageType', 'list');
$html->assign('countryList', $countryList);
$html->assign('packageInclusionList', $packageInclusionList);
$html->assign('packageThemeList', $packageThemeList);
$html->assign('foodPreferenceList', $foodPreferenceList);
$html->assign('SpecialRequest', $SpecialRequest);
$html->assign('getCustomerVisaDetail', $getCustomerVisaDetail);
echo $bodyText = $html->render('customer/edit-customer-info.phtml');
}
}
public function sendCustomEmailToCustomerForQueryAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$TPSysId = $this->getRequest()->getParam('TPSysId');
$type = $this->getRequest()->getParam('type');
$mCustomSubject = $this->getRequest()->getParam('mCustomSubject');
$mCustomMessage = $this->getRequest()->getParam('mCustomMessage');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$agentId = $this->intLoggedinUserId;
$arrAgencyDetails = $this->_crmcusttravelplan->getAgentDetails($agentId);
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $AgencySysId;
if (isset($arrAgencyDetails['Logo']) && $arrAgencyDetails['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $arrAgencyDetails['Logo'];
} else {
$AgencyLogo = $path . '/default_company_logo.jpg';
}
$subject = $mCustomSubject;
$bodyText = $mCustomMessage;
// echo "<pre>";print_r($arrAgencyDetails['EmailId']);die;
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => '',
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $agentId,
"Title" => $subject,
"Source" => $arrEmailStatisticsType[2], // 4 For Promotional Emails
"Status" => "",
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
if ($TPSysId) {
if ($type == 'lead') {
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$arrTravelPlanDetails[0] = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($TPSysId);
} else {
$arrTravelPlanDetails = $this->_crmcusttravelplan->getTravelPlanDetailsByTPSysId(trim($TPSysId), 'Query');
}
$EmailId = trim($arrTravelPlanDetails[0]['EmailId']);
$FirstName = trim($arrTravelPlanDetails[0]['FirstName']);
$LastName = trim($arrTravelPlanDetails[0]['LastName']);
$AgentEmailId = $arrAgencyDetails['EmailId'];
$fromName = $arrAgencyDetails['Title'];
$emailData = array('fromEmail' => $AgentEmailId, 'fromName' => $fromName, 'subject' => $subject, 'to' => array(trim($EmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_sender = array('fromEmail' => $AgentEmailId, 'fromName' => $fromName, 'subject' => $subject, 'to' => array($AgentEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$CustomerEmailId = array(trim($EmailId));
try {
Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($AgentEmailId));
Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($AgentEmailId), $CustomerEmailId);
} catch (Exception $err) { //print_r($mail);
print_r($err, true);
}
$response = array('success' => true, 'msg' => 'Email sent to customer(s) successfully.');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! there might be some technical error.');
echo json_encode($response);
exit;
}
}
}
public function getProposalWhatsappMessageAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
if ($this->getRequest()->isXmlHttpRequest()) {
$AgentSysId = $this->intLoggedinUserId;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencyDisplayName = (isset($sessionLogin_user->agencyDetails['DisplayName']) && !empty($sessionLogin_user->agencyDetails['DisplayName'])) ? trim($sessionLogin_user->agencyDetails['DisplayName']) : trim($sessionLogin_user->agencyDetails['Title']);
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$tpproposalID = $this->getRequest()->getParam('TPSysId');
$enctpproposalID = base64_encode($tpproposalID);
if ($tpproposalID) {
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($tpproposalID), 1);
$transactiontravelplandata = $this->_crmcusttravelplan->GetTravelPlanByCustomer($tpproposalID);
$getCustomerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($transactiontravelplandata[0]['CustomerSysId']);
// echo "<pre>";print_r($transactiontravelplandata);die("");
$FirstName = isset($transactiontravelplandata[0]['FirstName']) ? $transactiontravelplandata[0]['FirstName'] : '';
$LastName = isset($transactiontravelplandata[0]['LastName']) ? $transactiontravelplandata[0]['LastName'] : '';
$custname = ucwords(trim(trim($FirstName) . ' ' . trim($LastName)));
$destinationValues = isset($transactiontravelplandata[0]['DestinationPlaces']) ? trim($transactiontravelplandata[0]['DestinationPlaces']) : '';
$TravelDate = (isset($transactiontravelplandata[0]['StartDate'])) ? '%0a%0a*Travel Date:* ' . ($transactiontravelplandata[0]['StartDate']->format('d M y')) : '';
$MasterTPSysId = (isset($transactiontravelplandata[0]['MasterTPSysId'])) ? (int) $transactiontravelplandata[0]['MasterTPSysId'] : 0;
$roominfojson = $transactiontravelplandata[0]['RoomInfoJson'] ? json_decode($transactiontravelplandata[0]['RoomInfoJson'], 1) : '';
$noofRooms = (isset($roominfojson) && !empty($roominfojson)) ? '%0a%0a*No of Rooms:* ' . count($roominfojson) : '';
// echo "<pre>";print_r($transactiontravelplandata);die;
$totaladult = 0;
$totalchild = 0;
$totalInfant = 0;
foreach ($roominfojson as $roomarray) {
$adult = $roomarray['Adult'];
$totaladult = $totaladult + $adult;
$child = $roomarray['Child'];
$totalchild = $totalchild + $child;
$Infant = $roomarray['Infant'];
$totalInfant = $totalInfant + $Infant;
}
$totalchild = ($totalchild > 0) ? $totalchild . ' Child(s)' : '';
$totalInfant = ($totalInfant > 0) ? $totalInfant . ' Infant(s)' : '';
// echo $totaladult ; die;
// echo $totalInfant; die;
$StartDate = (isset($transactiontravelplandata[0]['StartDate']) && $transactiontravelplandata[0]['StartDate'] != '') ? $transactiontravelplandata[0]['StartDate']->format('Y-m-d') : '';
$ValidTill = (isset($transactiontravelplandata[0]['ValidTill']) && $transactiontravelplandata[0]['ValidTill'] != '') ? $transactiontravelplandata[0]['ValidTill']->format('Y-m-d') : '';
$differenceIndays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($StartDate, $ValidTill);
// echo $differenceIndays ; die();
// echo $transactiontravelplandata[0]['EconomyMask'] ; die('jh');
if ($transactiontravelplandata[0]['EconomyMask'] == 8) {
$NoofDays = (isset($differenceIndays)) ? '%0a%0a*No Of Days:* ' . ((int) $differenceIndays) : '';
} else {
$NoofDays = (isset($differenceIndays)) ? '%0a%0a*No Of Days:* ' . ((int) $differenceIndays + 1) : '';
}
// echo $NoofDays; die("no-o-days");
$AgenctEmailId = isset($getAgentDetails['EmailId']) ? trim($getAgentDetails['EmailId']) : '';
$SenderEmaiId = !empty($transactiontravelplandata[0]['ProposalEmailFrom']) ? trim($transactiontravelplandata[0]['ProposalEmailFrom']) : $AgenctEmailId;
$firstname = isset($getAgentDetails['FirstName']) ? trim($getAgentDetails['FirstName']) : '';
$primarycontact = isset($getAgentDetails['ContactNo1']) ? trim($getAgentDetails['ContactNo1']) : '';
$CurrencySymbol = trim($transactiontravelplandata[0]['Symbol']);
$sentprice = (isset($transactiontravelplandata[0]['NetPrice'])) ? $CurrencySymbol . ' ' . round($transactiontravelplandata[0]['NetPrice'] + $transactiontravelplandata[0]['TotalCostGen']) : '';
if ($transactiontravelplandata[0]['PlanType'] == 6) {
$booknowurl = $this->baseUrl . '/proposal/booking-visa-review-customer/mid/' . (base64_encode($MasterTPSysId)) . '/tpid/' . $enctpproposalID;
} else {
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
}
if ($getAgentDetails['IsB2CSite'] == 1) {
$booknowurl = $getAgentDetails['Url'] . "detail/index/view/id/" . base64_encode($booknowurl);
} else if (($getAgentDetails['IsB2CSite'] == 2) && ($getAgentDetails['IsSiteType'] == 1)) {
$booknowurl = $getAgentDetails['Url'] . "hellogtx/index.html?id=" . base64_encode($booknowurl);
} else if (($getAgentDetails['IsB2CSite'] == 2) && ($getAgentDetails['IsSiteType'] == 0)) {
$booknowurl = $getAgentDetails['Url'] . "hellogtx/gtx.php?id=" . base64_encode($booknowurl);
}
$paramsm['TPSysId'] = $tpproposalID;
$paramsm['shared_url'] = $booknowurl;
$paramsm['AgencySysId'] = $AgencySysId;
$paramsm['AgentSysId'] = $AgentSysId;
$shorturl_response = Zend_Controller_Action_HelperBroker::getStaticHelper('ShortUrl')->url_get($paramsm);
if (isset($shorturl_response['status_code']) && $shorturl_response['status_code'] == 200) {
$booknowurl = $shorturl_response['data']['short_url'];
}
if ($transactiontravelplandata[0]['PlanType'] == 6) { //for visa
$objVisa = new Visa_Model_Visa();
$objVisa->strCondition = "1=1";
$objVisa->strCondition .= " AND tb1.InvnVisaAllSysId = " . $transactiontravelplandata[0]['TPId'];
$getVisaPrice = $objVisa->getVisaPrice();
$arrVisaCategory = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getVisaCategory();
$VisaCategory = (isset($arrVisaCategory[$getVisaPrice[0]['VisaCategory']])) ? $arrVisaCategory[$getVisaPrice[0]['VisaCategory']] . ' Visa' : '';
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your visa for $destinationValues.%0a%0a*Destination:* $destinationValues %0a%0a*Visa Category:* $VisaCategory %0a%0a*No Of Pax:* $totaladult Adult(s) $totalchild $totalInfant $TravelDate %0a%0a*Total Cost:* $sentprice/- %0a%0aTo view visa details and *book online* click on the below link:%0a%0a$booknowurl %0a%0aYou can also call $firstname at $primarycontact or email at %0a$SenderEmaiId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
} else if ($transactiontravelplandata[0]['PlanType'] == 5) {
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your package query for $destinationValues.%0a%0a*Destination:* $destinationValues $TravelDate $NoofDays %0a%0a*No Of Pax:* $totaladult Adult(s) $totalchild $totalInfant %0a%0a*Total Cost:* $sentprice/- %0a%0aTo view hotels and program in details and to *book online* click on the below link:%0a%0a$booknowurl %0a%0aYou can also call $firstname at $primarycontact or email at %0a$SenderEmaiId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
} else if ($transactiontravelplandata[0]['PlanType'] == 24) {
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your query for company formation. $TravelDate %0a%0a*Total Cost:* $sentprice/- %0a%0aTo view hotels and program in details and to *book online* click on the below link:%0a%0a$booknowurl %0a%0aYou can also call $firstname at $primarycontact or email at %0a$SenderEmaiId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
} else if ($transactiontravelplandata[0]['PlanType'] == 2 && $transactiontravelplandata[0]['IsHotelOnlyPackage'] == 1) {
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your hotel query for $destinationValues.%0a%0a*Destination:* $destinationValues $TravelDate $NoofDays %0a%0a*No Of Pax:* $totaladult Adult(s) $totalchild $totalInfant %0a%0a*Total Cost:* $sentprice/- %0a%0aTo view hotels and program in details and to *book online* click on the below link:%0a%0a$booknowurl %0a%0aYou can also call $firstname at $primarycontact or email at %0a$SenderEmaiId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
} else {
$whatsappmessage = '';
}
// echo $whatsappmessage; die("msg");
if ($whatsappmessage != '') {
$response = array('status' => true, 'whatsapp' => $whatsappmessage, 'contactno' => trim($getCustomerDetails['countrycode']) . trim($getCustomerDetails['Contacts']), 'message' => 'Proposal has been shared with customer', 'TPSysId' => $tpproposalID);
} else {
$response = array('status' => false, 'message' => 'There is some error in sending email. Please try after sometime.', 'TPSysId' => $tpproposalID);
}
} else {
$response = array('status' => false, 'message' => 'There is some error in sending email. Please try after sometime.', 'TPSysId' => $tpproposalID);
}
echo json_encode($response);
exit;
}
}
public function deleteCustomerMemberAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$response = '';
if ($this->getRequest()->isPost()) {
$params = $this->getRequest()->getParams();
//echo "<pre>";print_r($params);die;
$AgencySysId = $this->intLoggedinUserAgencySysId;
$CustomerSysId = $params['CustomerSysId'];
$CustomerMemberSysId = $params['MemberSysId'];
if (isset($CustomerSysId) && $CustomerSysId != '' && isset($CustomerMemberSysId) && $CustomerMemberSysId != '') {
$wheremembertableCond = "CustomerSysId = " . $CustomerSysId . " AND AgencySysId = " . $AgencySysId . " AND MemberSysId = " . $CustomerMemberSysId;
$updatecustomermember = array(
'IsActive' => 0,
'isMarkForDelete' => 1
);
//echo "<pre>";print_r($updatecustomermember);die;
$updatemember = $this->_crmcustomerObj->UpdateCustomerMember($updatecustomermember, $wheremembertableCond);
$this->_crmagencyleadaccountObj->deleteCustomerMemberVisaDetail(array('IsActive' => 0, 'IsMarkForDelete' => 1), array('AgencySysId =?' => $AgencySysId, 'CustomerSysId =?' => $CustomerSysId, 'CustomerMemberSysId =?' => $CustomerMemberSysId));
$response = array('status' => true);
echo json_encode($response);
exit;
} else {
$response = array('status' => false);
echo json_encode($response);
exit;
}
}
}
public function customerAccountAction() {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$code = $this->getRequest()->getParam('code');
$secureCode = Catabatic_ValidateCustomer::secureCode(trim($this->getRequest()->getParam('id')), 1);
if ($secureCode != $code) {
echo "Please check your request parameters";
exit;
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerWithDetails($CustomerSysId);
$customerCityName = '';
if (isset($getCustomerDetail['CitySysId']) && !empty($getCustomerDetail['CitySysId']) && $getCustomerDetail['CitySysId'] > 0) {
$objcity = new Travel_Model_TblCity();
$customerCityName = $objcity->getCityNameById($getCustomerDetail['CitySysId']);
}
$getCustomerDetail['cityName'] = $customerCityName;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = stripslashes($getCustomerRemarkDetail['Remarks']);
$getCustomerDetail['CustomerProposalCount'] = $this->CustomerProposalCount($CustomerSysId);
$this->view->customerId = $CustomerSysId;
$this->view->customerDetail = $getCustomerDetail;
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageInclusionList = $this->_objPkg->getPackageInclusionList();
$foodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$this->view->foodPreferenceList = $foodPreferenceList;
$this->view->packageInclusionList = $packageInclusionList;
$this->view->packageThemeList = $packageThemeList;
}
$this->view->controller = $this;
$objPackageViewList = new Travel_Model_TblAgencyCustomerTrx();
$getData = array();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$customerBookingRecord = $objPackageViewList->getAccountDetailByCust($AgencySysId, $CustomerSysId);
//$miscBookingRecord = $objPackageViewList->getMiscellaneousListByCust($CustomerSysId);
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($customerBookingRecord);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//$this->view->miscBookingRecord = $miscBookingRecord;
$ARR_SALUTION = unserialize(ARR_SALUTION);
$ARR_CUSTOMER_RELATION = unserialize(ARR_CUSTOMER_RELATION);
$this->view->ARR_CUSTOMER_RELATION = $ARR_CUSTOMER_RELATION;
$this->view->ARR_SALUTION = $ARR_SALUTION;
}
public function customerAccountPaymentEmailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$postData = $this->getRequest()->getParams();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$TPSysId = isset($postData['tpid']) ? base64_decode($postData['tpid']) : '';
$emailType = (isset($postData['emailType']) && !empty($postData['emailType'])) ? $postData['emailType'] : 0;
if ($TPSysId != '') {
$objPkgBooking = new Travel_Model_TblPackageBooking();
$objPkgBooking->TPSysId = $TPSysId;
$objAgency = new Travel_Model_TblAgency();
$arrAgencyDetails = $objAgency->getAgencyDataById($AgencySysId);
$arrAgentDetails = $objAgency->getAgencyUserDataById($AgentSysId);
$paramArray = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId);
$getCurrencyType = isset($paramArray[0]['CurrencyType']) ? $paramArray[0]['CurrencyType'] : 1;
$getCurrencySymbolArray = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($getCurrencyType);
$currencySymbol = isset($getCurrencySymbolArray['Symbol']) ? $getCurrencySymbolArray['Symbol'] : 'INR';
$GSTSharedModeVal = isset($paramArray[0]['GSTSharedMode']) ? $paramArray[0]['GSTSharedMode'] : 1;
$objGstRates = new Travel_Model_TblGstRates();
$arrGSTRatesInfo = $objGstRates->getGSTTypeAndRates(9, $GSTSharedModeVal, 0, 0);
$paymentList = $objPkgBooking->getOfflinePaymentByTPSysIdList($TPSysId);
// echo "<pre>";print_r($paymentList);die;
$path = $this->baseUrl . '/public/assets/images';
$pathAgency = $this->baseUrl . '/public/upload/media/agency/' . $AgencySysId;
if (isset($arrAgencyDetails['Logo']) && $arrAgencyDetails['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $arrAgencyDetails['Logo'];
} else {
$AgencyLogo = $path . '/default_company_logo.jpg';
}
$amountPaid = $objPkgBooking->getAmountPaidForProposalOfflinePaymentByTPSysId($TPSysId, 19);
$TotalAmountPaid = !empty($amountPaid['TotalAmountPaid']) ? round($amountPaid['TotalAmountPaid']) : 0;
$FirstName = (isset($paramArray[0]['FirstName']) && $paramArray[0]['FirstName'] != '') ? $paramArray[0]['FirstName'] : '';
$LastName = (isset($paramArray[0]['LastName']) && $paramArray[0]['LastName'] != '') ? $paramArray[0]['LastName'] : '';
$leadCustFirstName = $FirstName;
$leadCustLastName = $LastName;
$leadCustEmailId = $paramArray[0]['ProposalEmailTo'];
$paramArrayPackage = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->getPackageDetailsForEmailTemplate($paramArray[0]['TPSysId'], $paramArray[0], $paramArray[0]['EconomyMask'], 1);
}
$paramArray[0]['NetPrice'] = $paramArray[0]['NetPrice'] + $paramArray[0]['TotalCostGen'];
$paramArray[0]['XServiceTaxAmount'] = $paramArray[0]['XServiceTaxAmount'] + $paramArray[0]['ServiceProiderFee'];
$modelPayment = new Payment_Model_Payment();
$params['TcsAddonServicesData'] = $modelPayment->getTcsAddonServicesData($AgencySysId, $TPSysId, 21);
$params['GSTSharedModeVal'] = isset($arrGSTRatesInfo['TaxType']) ? $arrGSTRatesInfo['TaxType'] : 0;
$params['currencySymbol'] = $currencySymbol;
$params['PickUpLocation'] = '';
$params['PickUpTime'] = $paymentList[0]['TrxDate']->format('Y-m-d');
$params['AgencySysId'] = $arrAgencyDetails['AgencySysId'];
$params['AgentSysId'] = $AgentSysId;
$params['agency_logo'] = $AgencyLogo;
$params['company_name'] = $arrAgencyDetails['DisplayName'];
$params['booking_date'] = date("d/m/Y");
$params['package_cost'] = $paramArray[0]['NetPrice'];
$params['paid_amount'] = $amountPaid['TotalAmountPaid'];
$params['balance_amount'] = $paramArray[0]['NetPrice'] - $amountPaid['TotalAmountPaid'];
$params['current_paid_amount'] = $paymentList[0]['NetAmount'];
$params['GST'] = $paramArray[0]['XServiceTaxAmount'] + $paramArray[0]['AgentServiceTaxAmount'];
$params['shared_url'] = "";
$params['cust_name'] = trim(@$leadCustFirstName) . " " . trim(@$leadCustLastName);
$params['cust_email'] = $leadCustEmailId;
$params['about_package'] = "";
$params['destination_city'] = $paramArray[0]['Cities'];
$params['agent_firstname'] = '';
$params['agent_primarycontact'] = $arrAgentDetails['Signature'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $arrAgentDetails['EmailId'];
$params['ContactNo1'] = $arrAgentDetails['ContactNo1'];
$params['agencyDisplayName'] = $arrAgencyDetails['DisplayName'] ? $arrAgencyDetails['DisplayName'] : $arrAgencyDetails['Title'];
$params['PrimaryEmail'] = $arrAgencyDetails['PrimaryEmail'];
$params['arrPackage'] = $paramArrayPackage;
$params['ProposalId'] = $TPSysId;
$params['strTxnId'] = $paymentList[0]['TrxId'];
$params['AgentContactForSMS'] = array_unique(array($arrAgentDetails['ContactNo1'], $arrAgencyDetails['PrimaryContactNo']));
$params['GUID'] = $paymentList[0]['GUID'];
$params['TpSysId'] = $TPSysId;
$params['last_payment'] = 0;
$params['payment_type'] = "Full Payment";
$params['paymentStatus'] = "full";
$params['txn_status'] = "Successful";
$params['customerName'] = $FirstName . ' ' . $LastName;
$params['customer_contact'] = $paramArray[0]['Contacts'];
$params['IsCancellationProtection'] = $paramArray[0]['IsCancellationProtection'];
$params['CancellationProtectionPrice'] = $paramArray[0]['CancellationProtectionPrice'];
$params['isOfflinePayment'] = 1;
array_shift($paymentList);
$paymentListArr = array();
$refundGUID = '';
foreach ($paymentList as $kkey => $kval) {
if ($kval['TrxOrdDocId'] != 19) {
$strtime = strtotime($kval['TrxDate']->format('Y-m-d H:s'));
$paymentListArr[$strtime . $kkey] = $kval;
} else {
$refundGUID = $kval['GUID'];
}
}
asort($paymentListArr);
$params['paymentList'] = ($paymentListArr);
$params['refundGUID'] = ($refundGUID);
$params['TaxTypeTitle'] = isset($arrGSTRatesInfo['TaxTypeTitle']) ? $arrGSTRatesInfo['TaxTypeTitle'] : 'Tax';
$bookNowLink = '';
$secureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(base64_encode($paramArray[0]['TPSysId']), 1);
if ($paramArray[0]['PlanType'] == 5) { //5 for package
$typename = 'package';
$isPkgReadymade = $paramArray[0]['Readymade'];
$pkgId = $paramArray[0]['TPSysId'];
$modifyPackageLink = '';
if ($paramArray[0]['PackSpecType'] == 4) {
$modifyLink = '#';
$viewLink = $this->baseUrl . '/publicpackage/view-customer-final-package/code/' . $secureCode . '/id/' . base64_encode($paramArray[0]['TPSysId']);
} else if ($isPkgReadymade == 0) {
$viewLink = $this->baseUrl . '/package/view-byo-pkg/id/' . base64_encode($paramArray[0]['TPSysId']);
} else {
$modifyLink = '#';
$viewLink = $this->baseUrl . '/publicpackage/view-customer-final-package/code/' . $secureCode . '/id/' . base64_encode($paramArray[0]['TPSysId']);
}
$bookNowLink = $viewLink;
$paybalance = $this->baseUrl . '/package-booking/package-booking-view/pid/' . base64_encode($paramArray[0]['TPSysId']) . '/cid/' . base64_encode($paramArray[0]['CustomerSysId']) . '/code/' . $secureCode;
} else if ($paramArray[0]['PlanType'] == 6) { //6 for visa
$bookNowLink = $this->baseUrl . '/proposal/booking-visa-review-customer/mid/' . base64_encode($paramArray[0]['MasterTPSysId']) . '/tpid/' . base64_encode($paramArray[0]['TPSysId']);
$paybalance = $this->baseUrl . '/package-booking/package-booking-view/pid/' . base64_encode($paramArray[0]['TPSysId']) . '/cid/' . base64_encode($paramArray[0]['CustomerSysId']) . '/code/' . $secureCode;
}
$params['bookNowLink'] = ($bookNowLink != '') ? '<a href="' . $bookNowLink . '" style="text-decoration: none;"> View Detail</a>' : '';
$params['paybalance'] = ($bookNowLink != '') ? '(<a href="' . $paybalance . '" style="text-decoration: none;">Click here to pay balance</a>)' : '';
// echo "<pre>";print_r($params);die;
$subject = 'Payment Confirmation from ' . $params['agencyDisplayName'] . ' for ' . trim($paramArray[0]['Title']) . ' trip';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('send_payment_transaction_status_email.phtml');
if ($emailType == 1) {
$AgentEmailId = trim($params['sendersEmailId']);
$emailData = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array(trim($leadCustEmailId)), 'bodyHtml' => $bodyText, 'bodyText' => '');
$emailData_sender = array('fromEmail' => $params['sendersEmailId'], 'fromName' => $params['agencyDisplayName'], 'subject' => $subject, 'to' => array($AgentEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$CustomerEmailId = array(trim($leadCustEmailId));
try {
$arrEmailStatistics = array(
"TPSysId" => $params['TpSysId'],
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $params['AgencySysId'],
"AgentSysId" => $params['AgentSysId'],
"Title" => $bodyText,
"Source" => 1, // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
if (!empty($CustomerEmailId)) {
$emailstatus = Catabatic_ValidateCustomer::mailSentByElastice($emailData, $arrEmailStatistics, 0, 0, array($AgentEmailId));
$emailstatus1 = Catabatic_ValidateCustomer::mailSentByElastice($emailData_sender, $arrEmailStatistics, 0, 0, array($AgentEmailId), $CustomerEmailId);
}
if ($emailstatus) {
echo json_encode(array('status' => true, 'msg' => 'Mail Sent Successfully.'));
exit;
} else {
echo json_encode(array('status' => false, 'msg' => 'Error, Please try after some time!!!.'));
exit;
}
} catch (Exception $err) { //print_r($mail);
echo json_encode(array('status' => false, 'msg' => 'Error, Please try after some time!!!.'));
exit;
}
} else {
echo $bodyText;
}
}
/*
Action : memberDocumentUpload
Created date : 01-10-2023
Created By : Neeraj Prajapati
*/
public function memberDocumentUploadAction() {
$this->view->layout()->disableLayout();
$objAgency = new Travel_Model_TblAgency();
$AgencySysId = $this->intLoggedinUserAgencySysId;
$CustomerSysId = $this->_HtmlPurifier->filter($this->_request->getParam('id'));
$MMBRCustSysId = $this->_HtmlPurifier->filter($this->_request->getParam('mid'));
$MemberSysId = ($MMBRCustSysId !== null) ? base64_decode($MMBRCustSysId) : Null;
$this->view->CustomerSysId = $CustomerSysId;
$this->view->mid = $MMBRCustSysId;
$this->view->AgencySysId = $AgencySysId;
$custmenberdocument = $objAgency->getcustmenberdocument(base64_decode($CustomerSysId), $AgencySysId, $MemberSysId);
$this->view->memberdocumentdata = $custmenberdocument;
}
/*
Action : saveMemberDocumentData
Created date : 01-10-2023
Created By : Neeraj Prajapati
*/
public function saveMemberDocumentDataAction() {
$this->view->layout()->disableLayout();
if ($this->getRequest()->isPost()) {
$objAgency = new Travel_Model_TblAgency();
$postData = $this->getRequest()->getParams();
$MMBRCustSysId = (!empty($postData['memberCustSysId'])) ? base64_decode($postData['memberCustSysId']) : 0;
$CustomerSysId = base64_decode($postData['CustomerSysId']);
$MemberSysId = $MMBRCustSysId;
$doctype = $postData['documenttype'];
$docname = $postData['docname'];
$titletype = $postData['titletype'];
$data = array();
$fileName = null;
$i = 0;
for ($i = 0; $i < count($doctype); $i++) {
$docid = isset($postData['MembersDocumentSysId'][$i]) ? $postData['MembersDocumentSysId'][$i] : null;
$orignalFileName = isset($_FILES['docfile']['name'][$i]) ? $_FILES['docfile']['name'][$i] : null;
if ($docid) {
$memberdocdata = $objAgency->getmenberdocumentById($docid, $this->intLoggedinUserAgencySysId);
if ($orignalFileName) {
$fileExt = strtolower(pathinfo($orignalFileName, PATHINFO_EXTENSION));
$uniqueIdentifier = time() . '_' . uniqid();
$fileName = $uniqueIdentifier . '.' . $fileExt;
if ($MemberSysId) {
$image_path = 'doc/' . $this->intLoggedinUserAgencySysId . '/customer/' . $CustomerSysId . '/member/' . $MMBRCustSysId . '/document';
} else {
$image_path = 'doc/' . $this->intLoggedinUserAgencySysId . '/customer/' . $CustomerSysId . '/document';
}
$imageDetail = IMAGE_PATH_URL_AWS . $image_path . '/' . $fileName;
$file1 = array(
'name' => $_FILES['docfile']["name"][$i],
'type' => $_FILES['docfile']["type"][$i],
'tmp_name' => $_FILES['docfile']["tmp_name"][$i],
'error' => $_FILES['docfile']["error"][$i],
'size' => $_FILES['docfile']["size"][$i],
);
$data = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'image_path' => $image_path,
'tags' => 'Member',
'title' => $fileName,
'FILES' => $file1,
'fileName' => $fileName,
);
$toupload = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->uploadToAWS($data);
$updatedata = [
'FileName' => $fileName,
];
$where = array('MembersDocumentSysId = ? ' => @$docid, 'CustomerSysId =?' => $CustomerSysId);
$objAgency->updateData('Tb_Agency_Customer_Members_Document', $updatedata, $where);
}
} else {
if ($orignalFileName) {
$fileExt = strtolower(pathinfo($orignalFileName, PATHINFO_EXTENSION));
$uniqueIdentifier = time() . '_' . uniqid();
$fileName = $uniqueIdentifier . '.' . $fileExt;
if ($MemberSysId) {
$image_path = 'doc/' . $this->intLoggedinUserAgencySysId . '/customer/' . $CustomerSysId . '/member/' . $MMBRCustSysId . '/document';
} else {
$image_path = 'doc/' . $this->intLoggedinUserAgencySysId . '/customer/' . $CustomerSysId . '/document';
}
$imageDetail = IMAGE_PATH_URL_AWS . $image_path . '/' . $fileName;
$file1 = array(
'name' => $_FILES['docfile']["name"][$i],
'type' => $_FILES['docfile']["type"][$i],
'tmp_name' => $_FILES['docfile']["tmp_name"][$i],
'error' => $_FILES['docfile']["error"][$i],
'size' => $_FILES['docfile']["size"][$i],
);
$data = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'image_path' => $image_path,
'tags' => 'Member',
'title' => $fileName,
'FILES' => $file1,
'fileName' => $fileName,
);
$toupload = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->uploadToAWS($data);
}
$data = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'MemberSysId' => !empty($MemberSysId) ? (int) $MemberSysId : NULL,
'CustomerSysId' => (int) $CustomerSysId,
'Title' => $docname[$i],
'TitleType' => $titletype[$i],
'FileName' => $fileName,
'IsActive' => 1,
'IsMarkfordelete' => 0,
'CreateDate' => date('Y-m-d H:i:s'),
);
$objAgency->insertData('Tb_Agency_Customer_Members_Document', $data);
}
}
$response = array('status' => true, 'msg' => "Data Added Succesfully");
echo json_encode($response);
exit;
}
}
public function deleteMemberDocumentAction() {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$documentId = $_POST['documentId'];
$objAgency = new Travel_Model_TblAgency();
$data = ['IsMarkfordelete' => 1];
$where = array('MembersDocumentSysId = ?' => @$documentId);
$result = $objAgency->updateMemberDocument('Tb_Agency_Customer_Members_Document', $data, $where);
if ($result) {
$response = ['status' => true, 'msg' => 'Document deleted successfully'];
} else {
$response = ['status' => false, 'msg' => 'Failed to delete document'];
}
echo json_encode($response);
exit();
}
}
/*
Action : shareDocByEmail
Created date : 06-10-2023
Created By : Neeraj Prajapati
*/
public function shareDocByEmailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
if ($this->getRequest()->isPost()) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$objAgency = new Travel_Model_TblAgency();
$arrAgencyDetails = $objAgency->getAgencyDataById($AgencySysId);
$arrAgentDetails = $objAgency->getAgencyUserDataById($AgentSysId);
$PrimaryEmail = $arrAgencyDetails['PrimaryEmail'];
$PrimaryContactName = $arrAgencyDetails['DisplayName'];
$postData = $this->getRequest()->getParams();
$recipientEmail = $postData['recipientEmail'];
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$params['agent_firstname'] = $firstname;
$params['agent_signature'] = $arrAgentDetails['Signature'];
$params['recipientName'] = isset($postData['recipientName']) ? $postData['recipientName'] : '';
$memberCustSysId = isset($postData['memberCustSysId']) ? base64_decode($postData['memberCustSysId']) : '';
$CustomerSysId = isset($postData['CustomerSysId']) ? base64_decode($postData['CustomerSysId']) : '';
$memberDetails = $objAgency->getMemberById($memberCustSysId, $this->intLoggedinUserAgencySysId);
$CustomerDetails = $objAgency->getCustomerById($CustomerSysId, $this->intLoggedinUserAgencySysId);
$documentIds = array();
$documentIds = explode(",", $postData['selectedDocumentIds']);
$documentdata = $objAgency->getdocumentByIds($documentIds, $this->intLoggedinUserAgencySysId);
foreach ($documentdata as $docVal) {
$filename = (isset($docVal['FileName'])) ? trim($docVal['FileName']) : '';
$folderNamePath = 'doc/' . $AgencySysId . '/customer/' . $CustomerSysId . '/';
$folderNamePath .= empty($memberCustSysId) ? 'document/' : 'member/' . $memberCustSysId . '/document/';
$folderNamePath .= $filename;
$data = array(
'AgencySysId' => $AgencySysId,
'folderName' => $folderNamePath,
);
$responseArr = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->getFileFromAWS($data);
$params['documentList'] .= '<li> ' . $docVal['Title'] . ' (<a href="' . $responseArr[0]['document'] . '" >Download</a>)</li>';
}
$salutation = (isset($memberDetails['Title']) && $memberDetails['Title'] != '') ? $memberDetails['Title'] : $CustomerDetails['Title'];
$salutationTitle = Zend_Controller_Action_HelperBroker::getStaticHelper('General')->getSalutation(trim($salutation));
$FirstName = (isset($memberDetails['FirstName']) && $memberDetails['FirstName'] != '') ? trim($memberDetails['FirstName']) : trim($CustomerDetails['FirstName']);
$LastName = (isset($memberDetails['LastName']) && $memberDetails['LastName'] != '') ? trim($memberDetails['LastName']) : trim($CustomerDetails['LastName']);
$params['travellerName'] = $salutationTitle . ' ' . $FirstName . ' ' . $LastName;
$params['PrimaryContactName'] = $PrimaryContactName;
$subject = 'Travel Document For <' . $params['travellerName'] . '>';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('share_docs_by_email.phtml');
$customerEmails = array();
$customerEmails[] = $recipientEmail;
$customerEmails[] = (isset($memberDetails['EmailId']) && $memberDetails['EmailId'] != '') ? $memberDetails['EmailId'] : $CustomerDetails['EmailId'];
$emailData = array('fromEmail' => trim($PrimaryEmail), 'fromName' => trim($PrimaryContactName), 'subject' => $subject, 'to' => $customerEmails, 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => 'Share Document',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:s:i')
);
$emailstatus = $this->mailSentByElastice($emailData, $arrEmailStatistics);
if ($emailstatus) {
echo json_encode(array('status' => true, 'msg' => 'Mail Sent Successfully.'));
exit;
} else {
echo json_encode(array('status' => false, 'msg' => 'Error, Please try after some time!!!.'));
exit;
}
}
}
/*
Action : shareDocByWhatsapp
Created date : 06-10-2023
Created By : Neeraj Prajapati
*/
public function shareDocByWhatsappAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
if ($this->getRequest()->isPost()) {
$objAgency = new Travel_Model_TblAgency();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$postData = $this->getRequest()->getParams();
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$PrimaryContactName = $firstname;
$Name = ucwords($postData['recipientName']);
$countrycode = $postData['countrycode'];
$Mobile = $postData['recipientMobile'];
$memberCustSysId = isset($postData['memberCustSysId']) ? base64_decode($postData['memberCustSysId']) : '';
$CustomerSysId = isset($postData['CustomerSysId']) ? base64_decode($postData['CustomerSysId']) : '';
$memberDetails = $objAgency->getMemberById($memberCustSysId, $this->intLoggedinUserAgencySysId);
$CustomerDetails = $objAgency->getCustomerById($CustomerSysId, $this->intLoggedinUserAgencySysId);
$documentIds = array();
$documentIds = explode(",", $postData['selectedDocumentIds']);
$documentdata = $objAgency->getdocumentByIds($documentIds, $this->intLoggedinUserAgencySysId);
$i = 1;
foreach ($documentdata as $docVal) {
$filename = (isset($docVal['FileName'])) ? trim($docVal['FileName']) : '';
$folderNamePath = 'doc/' . $AgencySysId . '/customer/' . $CustomerSysId . '/';
$folderNamePath .= empty($memberCustSysId) ? 'document/' : 'member/' . $memberCustSysId . '/document/';
$folderNamePath .= $filename;
$data = array(
'AgencySysId' => $AgencySysId,
'folderName' => $folderNamePath,
);
$responseArr = Zend_Controller_Action_HelperBroker::getStaticHelper('FileUpload')->getFileFromAWS($data);
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($responseArr[0]['document'], $this->BITLYLOGIN, $this->BITLYAPIKEY);
if ($bitly_response['errorCode'] == 0) {
$docUrl = $bitly_response['results'][trim($responseArr[0]['document'])]['shortUrl'];
}
$params['documentList'][] = $i . '. ' . $docVal['Title'] . ' (Download - ' . $docUrl . ')';
$i++;
}
$params['travellerName'] = $Name;
// start whatsapp msg
$whatsappmessage = "Hi,\n";
$whatsappmessage .= "Do find the documents of " . $params['travellerName'] . " for travel purpose. Kindly click on the link below to download:\n";
foreach ($params['documentList'] as $documentInfo) {
$whatsappmessage .= $documentInfo . "\n";
}
$whatsappmessage .= "Thanks,\n" . $PrimaryContactName;
// end whatsapp msg
if ($whatsappmessage != '') {
$response = array('status' => true, 'whatsapp' => $whatsappmessage, 'contactno' => trim($countrycode) . trim($Mobile), 'msg' => 'Document has been shared with customer Whatsapp');
} else {
$response = array('status' => false, 'msg' => 'There is some error in sending email. Please try after sometime.');
}
echo json_encode($response);
exit();
}
}
public function saveCompanyFormationAction() {
$this->_helper->layout->disableLayout();
if ($this->getRequest()->isXmlHttpRequest()) {
$going_f = trim($this->getRequest()->getParam('going_f'));
$going_from = trim($this->getRequest()->getParam('going_from'));
$arrFormationGoingFrom = explode("__", $going_from);
if (!empty($arrFormationGoingFrom) && (isset($arrFormationGoingFrom[0]) && (int) $arrFormationGoingFrom[0] > 0)) {
$GoingFrom = $arrFormationGoingFrom[0];
$nooftraveler = $this->getRequest()->getParam('modify_totaltravelers');
$CustomerSysId = !empty($this->getRequest()->getParam('CustomerSysId')) ? trim($this->getRequest()->getParam('CustomerSysId')) : 0;
$travelDate = $specific_date = $this->getRequest()->getParam('specific_date');
$arr_specific_date = explode("/", $specific_date);
$formation_specific_date = $arr_specific_date[2] . "-" . $arr_specific_date[1] . "-" . $arr_specific_date[0];
$editLeadId = (trim($this->getRequest()->getParam('editLeadId')) != '') ? base64_decode(trim($this->getRequest()->getParam('editLeadId'))) : '';
$SaveQuery = trim($this->getRequest()->getParam('saveQuery'));
$saveSearchQuery = trim($this->getRequest()->getParam('saveSearchQuery'));
$countrySysId = trim($this->getRequest()->getParam('search_multi_country')) ? trim($this->getRequest()->getParam('search_multi_country')) : '';
$leadRemark = trim($this->getRequest()->getParam('leadRemark')) ? trim($this->getRequest()->getParam('leadRemark')) : '';
$currentOwnerSysId = trim($this->getRequest()->getParam('currentOwnerSysId')) ? trim($this->getRequest()->getParam('currentOwnerSysId')) : '';
$leadsource = (NULL !== $this->getRequest()->getParam('lead_source')) ? $this->getRequest()->getParam('lead_source') : '';
$IsOperationalLead = $this->getRequest()->getParam('IsOperationalLead') ? $this->getRequest()->getParam('IsOperationalLead') : 0;
$OpsAgentSysId = ($this->getRequest()->getParam('OpsAgentSysId') && $IsOperationalLead == 1) ? $this->getRequest()->getParam('OpsAgentSysId') : '';
$ExpectedClosureDate = $this->getRequest()->getParam('ExpectedClosureDate');
$ExpectedValue = $this->getRequest()->getParam('ExpectedValue');
$roomjson = array();
$roomjson[1]['TotalPax'] = $this->getRequest()->getParam('modify_totaltravelers');
$roomjson[1]['Adult'] = $this->getRequest()->getParam('modify_totaltravelers');
$roomjson[1]['Child'] = 0;
$roomjson[1]['Infant'] = 0;
$roomjson[1]['bedtype'] = 'none';
$roomjson[1]['departuredate'] = $this->getRequest()->getParam('specific_date');
$roomjson[1]['returndate'] = '';
$roominfojson = json_encode($roomjson);
$tottravelers = $this->getRequest()->getParam('modify_totaltravelers') + $this->getRequest()->getParam('modify_totaltravelers') + $this->getRequest()->getParam('modify_totaltravelers');
$currentDate = date('Y-m-d H:i:s');
$PlanBookingId = "Q/" . date('y');
if ($CustomerSysId > 0) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$customerDetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
}
$IsB2BCustomer = isset($customerDetails['IsB2BAgent']) ? $customerDetails['IsB2BAgent'] : 0;
$ExpectedClosureDateN = (isset($ExpectedClosureDate) && !empty($ExpectedClosureDate)) ? implode('-', array_reverse(explode('/', $ExpectedClosureDate))) : '';
$ExpectedValueN = (isset($ExpectedValue) && !empty($ExpectedValue)) ? (float) trim($ExpectedValue) : 0;
$arrFormationQuery = array();
$arrFormationQuery['PlanBookingId'] = $PlanBookingId;
$arrFormationQuery['AgencySysId'] = $this->intLoggedinUserAgencySysId;
$arrFormationQuery['AgentSysId'] = (isset($currentOwnerSysId) && $currentOwnerSysId != '') ? $currentOwnerSysId : $this->intLoggedinUserId;
$arrFormationQuery['CreatorSysId'] = $this->intLoggedinUserId;
$arrFormationQuery['PlanType'] = 24; // For CompanyFormation
$arrFormationQuery['SupplierSysId'] = 0;
$arrFormationQuery['StatusType'] = 1;
$arrFormationQuery['InventoryType'] = 1;
$arrFormationQuery['SourcePlaceSysId'] = '';
$arrFormationQuery['SourcePlaces'] = '';
$arrFormationQuery['DestinationPlacesSysId'] = (int) $GoingFrom;
$arrFormationQuery['DestinationPlaces'] = $going_f;
$arrFormationQuery['Cities'] = $going_f;
$arrFormationQuery['CityIds'] = $GoingFrom;
$arrFormationQuery['StartDate'] = $formation_specific_date;
$arrFormationQuery['RoomInfoJson'] = $roominfojson;
$arrFormationQuery['MinPax'] = $tottravelers;
$arrFormationQuery['CustomerSysId'] = $CustomerSysId;
$arrFormationQuery['Countries'] = $countrySysId;
$arrFormationQuery['CreateDate'] = $currentDate;
$arrFormationQuery['UpdateDate'] = $currentDate;
$arrFormationQuery['ApproveDate'] = $currentDate;
$arrFormationQuery['IsMarkForDel'] = 0;
$arrFormationQuery['IsActive'] = 1;
$arrFormationQuery['IsAprooved'] = 1;
$arrFormationQuery['IsB2Bproposal'] = trim($IsB2BCustomer);
$arrFormationQuery['CustomerRemark'] = trim($leadRemark);
$arrFormationQuery['LeadSourceSysId'] = $leadsource;
$arrFormationQuery['OpsAgentSysId'] = $OpsAgentSysId;
$arrFormationQuery['IsOperationalLead'] = $IsOperationalLead;
$arrFormationQuery['ExpectedClosureDate'] = $ExpectedClosureDateN;
$arrFormationQuery['ExpectedValue'] = $ExpectedValueN;
if (isset($editLeadId) && !empty($editLeadId)) {
$arrFormationQuery['TemplatePckSysId'] = $editLeadId;
$crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$existLeadDetail = $crmcusttravelplan->CheckCustomerWithLeadId($editLeadId, 'Query');
$nextVersionId = $existLeadDetail[0]['VersionId'] + 1;
$arrFormationQuery['VersionId'] = $nextVersionId;
}
$objCurd = new Sightseeing_Model_Sightseeing();
//update crm lead account record when created new query
if ($customerDetails['AgencyCRMLeadSysId']) {
$userleadAccountArray = array(
'LeadStageSysId' => 50, //50 id for change status in create query for crm lead account table
'UpdatedDate' => $currentDate,
);
$whereleadAccount = "AgencyCRMLeadSysId = " . $customerDetails['AgencyCRMLeadSysId'];
$objCurd->updateTable("TB_Agency_CRM_Leadaccount", $userleadAccountArray, $whereleadAccount);
}
if (empty($editLeadId)) {
$createNewQuery = (NULL != $this->getRequest()->getParam('createNewQuery')) ? $this->getRequest()->getParam('createNewQuery') : '';
$NewQueryLeadHiddenId = (NULL != $this->getRequest()->getParam('NewQueryLeadHiddenId')) ? trim($this->getRequest()->getParam('NewQueryLeadHiddenId')) : '';
// echo $NewQueryLeadHiddenId."/".$createNewQuery;die;
if (($NewQueryLeadHiddenId != "") && ($createNewQuery == 'false' || $createNewQuery == '')) {
$where = "TPSysId = " . $NewQueryLeadHiddenId;
$updateQuery = array(
"IsMarkForDel" => true,
'IsActive' => False
);
$this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updateQuery, $where);
}
// print_r($arrFormationQuery); die();
$CompanyFormationQueryTravelPlanId = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($arrFormationQuery);
// echo "<pre>";print_r($CompanyFormationQueryTravelPlanId);die;
if ($CompanyFormationQueryTravelPlanId) {
if (isset($leadRemark) && !empty($leadRemark)) {
$remarkArray = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'CustomerSysId' => $CustomerSysId,
'AgentSysId' => $this->intLoggedinUserId,
'Remarks' => $leadRemark,
'TPSysId' => $CompanyFormationQueryTravelPlanId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $currentDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
// $arrFormationQuery = [
// 'ExpectedClosureDate' => $ExpectedClosureDate,
// 'ExpectedValue' => $ExpectedValue,
// ];
// $ClosureData = $this->_crmcusttravelplan->expectedClosureData($CompanyFormationQueryTravelPlanId, $arrFormationQuery);
}
$redirection = false;
if (isset($saveSearchQuery) && !empty($saveSearchQuery)) {
$redirection = true;
}
} else {
$where = "TPSysId = " . ($editLeadId);
unset($arrFormationQuery['CreateDate']);
$CompanyFormationQueryTravelPlanId = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($arrFormationQuery, $where);
$redirection = true;
$CompanyFormationQueryTravelPlanId = $editLeadId;
// $arrFormationQuery = [
// 'ExpectedClosureDate' => $ExpectedClosureDate,
// 'ExpectedValue' => $ExpectedValue,
// ];
// $ClosureData = $this->_crmcusttravelplan->expectedClosureData($CompanyFormationQueryTravelPlanId, $arrFormationQuery);
}
$custtravelhistoryObj = new Travel_Model_CRM_CustomerTravelHistory();
$checkrecord = $custtravelhistoryObj->getCustomerTravelHistoryForCity($CustomerSysId, $this->intLoggedinUserAgencySysId, $GoingFrom);
if (count($checkrecord) == 0) {
$customerHistoryArray = array(
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'AgentSysId' => $this->intLoggedinUserId,
'CustomerSysId' => $CustomerSysId,
'IsManualAdded' => 0,
'Type' => 4,
'TravelDate' => isset($formation_specific_date) ? $formation_specific_date : $currentDate,
'ContSysId' => $countrySysId ? $countrySysId : '',
'CitySysId' => $GoingFrom ? $GoingFrom : '',
'PlanType' => 24,
'Star' => '',
'IsActive' => '1',
'IsApproved' => '1',
'CreateDate' => $currentDate,
'UpdateDate' => $currentDate,
'IsMarkForDelete' => '0'
);
//print_r($customerHistoryArray);die;
$customerRcord = $custtravelhistoryObj->addAgencyCustomerTravelHistory($customerHistoryArray);
}
//#end of customer profile data
if (!empty($CompanyFormationQueryTravelPlanId)) {
/* Automation Emailer Master Template By Mangal 26-09-2018 Start */
$objAgency = new Travel_Model_TblAgency();
$SenderEmailSysId = isset($_SESSION['AgencyUser']['user']->SenderEmailSysId) ? $_SESSION['AgencyUser']['user']->SenderEmailSysId : 0;
$getSenderEmailID = $objAgency->getSenderEmailIDBySenderSysId($this->intLoggedinUserAgencySysId, $SenderEmailSysId);
$mCustomerFirstName = trim($customerDetails['FirstName']);
$mCustomerLastName = trim($customerDetails['LastName']);
$mCustomerEmailId = trim($customerDetails['EmailId']);
$companyLogo = trim($_SESSION['sessionLogin_user']['Logo']);
$agencyTitle = trim($_SESSION['sessionLogin_user']['agencyDetails']['Title']);
$agencyPrimaryEmail = (isset($getSenderEmailID['SenderEmailID']) && !empty($getSenderEmailID['SenderEmailID'])) ? $getSenderEmailID['SenderEmailID'] : trim($_SESSION['AgencyUser']['user']->EmailId);
$agencyContactNo1 = trim($_SESSION['AgencyUser']['user']->ContactNo1);
$agencyContactNo2 = trim($_SESSION['sessionLogin_user']['agencyDetails']['ContactNo2']);
$PrimaryContactName = trim($_SESSION['sessionLogin_user']['agencyDetails']['PrimaryContactName']);
$agencyUrl = trim($_SESSION['sessionLogin_user']['agencyDetails']['Url']);
$travelDate = trim($travelDate);
$nooftraveler = $nooftraveler;
$CountryCode = isset($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) ? trim($_SESSION['sessionLogin_user']['agencyDetails']['countrycode']) . '-' : '+91-';
$params = array('CountryCode' => $CountryCode, 'customerName' => ucfirst($mCustomerFirstName . ' ' . $mCustomerLastName), 'emailId' => $mCustomerEmailId, 'logo' => $companyLogo, 'agencyTitle' => $agencyTitle, 'destination' => $arrFormationGoingFrom[1], 'noofPax' => $nooftraveler, 'travelDate' => $travelDate, 'agencyPrimaryEmail' => $agencyPrimaryEmail, 'agencyContactNo1' => $agencyContactNo1, 'agencyContactNo2' => $agencyContactNo2, 'Url' => $agencyUrl, 'queryID' => $CompanyFormationQueryTravelPlanId);
#Set subject
$subject = $mCustomerFirstName . ' ' . $mCustomerLastName . ' Thanks for your Query for ' . $arrFormationGoingFrom[1] . '[' . $arrFormationGoingFrom[0] . ']';
if (empty($editLeadId) && in_array('queryacknowledgement', $this->manageNotifications)) {
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/emails/');
$html->assign($params);
$bodyText = $html->render('masterTemplateMailinfo.phtml');
$emailMasterData = array('fromEmail' => trim($agencyPrimaryEmail), 'fromName' => trim($PrimaryContactName), 'subject' => $subject, 'to' => array($mCustomerEmailId), 'bodyHtml' => $bodyText, 'bodyText' => '');
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$arrEmailStatistics = array(
"TPSysId" => 0,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $this->intLoggedinUserAgencySysId,
"AgentSysId" => $this->intLoggedinUserId,
"Title" => '',
"Source" => $arrEmailStatisticsType[2], // 6 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
$checkStatusEmail = $this->mailSentByElastice($emailMasterData, $arrEmailStatistics);
}
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($CompanyFormationQueryTravelPlanId), 1);
/* Automation Emailer Master Template By Mangal 26-09-2018 End */
$response = array('success' => true, 'msg' => 'Query for Company Formation created successfully', 'TPSysId' => base64_encode($CompanyFormationQueryTravelPlanId), 'redirection' => $redirection, 'lastID' => $CompanyFormationQueryTravelPlanId, 'code' => $secureCode);
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'Oops! Some Error accured.', 'TPSysId' => '', 'redirection' => $redirection);
echo json_encode($response);
exit;
}
} else {
$response = array('success' => false, 'msg' => 'Oops! Some Error accured.', 'TPSysId' => '', 'redirection' => false);
echo json_encode($response);
exit;
}
}
}
public function sharepopupreadymadenewAction() {
$this->_helper->layout->disableLayout();
$objPackage = new Travel_Model_TblPackage();
$markupMdl = new Markup_Model_Markup();
$getData = $this->getRequest()->getPost();
$tpsysID = $getData['tpsysID'];
$flexiPackageList = $getData['flexiPackageList'];
$totalDays = $getData['totalDays'];
$totalNight = $getData['totalNight'];
$flexiPackagePlaces = $getData['flexiPackagePlaces'];
$customerDetails = $getData['customerDetails'];
$currencyarr = $getData['currencyarr'];
$queryTPSysId = $getData['queryTPSysId'];
$MpType = $getData['MpType'];
$GTXNetwork = $getData['GTXNetwork'];
$getTaxSettingDetail = $getData['getTaxSettingDetail'];
$departureCity = $getData['departureCity'];
$getgsttcsSettingDetail = $getData['getgsttcsSettingDetail'];
$getTaxSettingFlight = $getData['getTaxSettingFlight'];
$package_flightdetails = $_SESSION['package_flightdetails'];
$pricebrakup = array();
// echo"<pre>";
// print_r($pricebrakup);
// print_r($package_flightdetails);
// die('ddd');
if (isset($_SESSION['package_flightdetails']) && is_array($pricebrakup) && count($pricebrakup) > 1) {
// echo"<pre>";
// print_r($pricebrakup);
// echo"<pre>";
// print_r($package_flightdetails);
// die('ddd');
foreach ($pricebrakup as $key => $upValue) {
if ($upValue['PlanType'] == 1) {
if ($package_flightdetails['flightType'] == 2) {
$pricebrakup[$key] = [
'Service' => 'Flight',
'PlanType' => 1,
'SourcingCurrency' => $pricebrakup[0]['SourcingCurrency'],
'SourceMarkup' => (float) array_sum($package_flightdetails['total_markup']),
'Rate' => (float) array_sum($package_flightdetails['total_cost']),
'ConversionRate' => 1,
'TotalCost' => (float) array_sum($package_flightdetails['total_cost']) + (float) array_sum($package_flightdetails['total_markup']),
'Markup' => (float) array_sum($package_flightdetails['total_markup']),
'Currency' => 1,
'Discount' => 0,
'Tax' => (float) array_sum($package_flightdetails['gstInType']),
'Tcs' => 0,
'TaxPercentage' => '',
'GSTAmount' => array_sum($package_flightdetails['total_gst']),
'TCSPercentage' => '',
'TCSAmount' => '',
'TotalPrice' => (float) array_sum($package_flightdetails['total_cost']) + (float) array_sum($package_flightdetails['total_markup']) + (float) array_sum($package_flightdetails['total_gst']),
];
} else {
$pricebrakup[$key] = [
'Service' => 'Flight',
'PlanType' => 1,
'SourcingCurrency' => $pricebrakup[0]['SourcingCurrency'],
'SourceMarkup' => (float) $package_flightdetails['total_markup'],
'Rate' => (float) $package_flightdetails['totalcost_wom'],
'ConversionRate' => 1,
'TotalCost' => (float) $package_flightdetails['totalcost_wom'] + (float) $package_flightdetails['total_markup'],
'Markup' => (float) $package_flightdetails['total_markup'],
'Currency' => $pricebrakup[0]['Currency'],
'Discount' => 0,
'Tax' => (float) $package_flightdetails['adult_gst'],
'Tcs' => 0,
'TaxPercentage' => '',
'GSTAmount' => $package_flightdetails['total_gst'],
'TCSPercentage' => '',
'TCSAmount' => 0,
'TotalPrice' => $package_flightdetails['totalflightcost']
];
}
} else {
}
}
} else if (isset($package_flightdetails) && is_array($pricebrakup) && count($pricebrakup) == 1) {
if ($package_flightdetails['flightType'] == 2) {
$pricebrakup[1] = [
'Service' => 'Flight',
'PlanType' => 1,
'SourcingCurrency' => $pricebrakup[0]['SourcingCurrency'],
'SourceMarkup' => (float) array_sum($package_flightdetails['total_markup']),
'Rate' => (float) array_sum($package_flightdetails['total_cost']),
'ConversionRate' => 1,
'TotalCost' => (float) array_sum($package_flightdetails['total_cost']) + (float) array_sum($package_flightdetails['total_markup']),
'Markup' => (float) array_sum($package_flightdetails['total_markup']),
'Currency' => 1,
'Discount' => 0,
'Tax' => (float) array_sum($package_flightdetails['gstInType']),
'Tcs' => 0,
'TaxPercentage' => '',
'GSTAmount' => array_sum($package_flightdetails['total_gst']),
'TCSPercentage' => '',
'TCSAmount' => '',
'TotalPrice' => (float) array_sum($package_flightdetails['total_cost']) + (float) array_sum($package_flightdetails['total_markup']) + (float) array_sum($package_flightdetails['total_gst']),
];
} else {
$pricebrakup[1] = [
'Service' => 'Flight',
'PlanType' => 1,
'SourcingCurrency' => $pricebrakup[0]['SourcingCurrency'],
'SourceMarkup' => (float) $package_flightdetails['total_markup'],
'Rate' => (float) $package_flightdetails['totalcost_wom'],
'ConversionRate' => 1,
'TotalCost' => (float) $package_flightdetails['totalcost_wom'] + (float) $package_flightdetails['total_markup'],
'Markup' => (float) $package_flightdetails['total_markup'],
'Currency' => 1,
'Discount' => 0,
'Tax' => (float) $package_flightdetails['adult_gst'],
'Tcs' => 0,
'TaxPercentage' => '',
'GSTAmount' => $package_flightdetails['total_gst'],
'TCSPercentage' => '',
'TCSAmount' => '',
'TotalPrice' => $package_flightdetails['totalflightcost']
];
}
} else {
$pricebrakup = $getData['pricebrakup'];
}
// echo"<pre>";
// print_r($pricebrakup);
// die('shalvii');
$this->view->tpsysID = $tpsysID = $getData['tpsysID'];
$this->view->flexiPackageList = $flexiPackageList = $getData['flexiPackageList'];
$this->view->totalDays = $totalDays = $getData['totalDays'];
$this->view->totalNight = $totalNight = $getData['totalNight'];
$this->view->flexiPackagePlaces = $flexiPackagePlaces = $getData['flexiPackagePlaces'];
$this->view->customerDetails = $customerDetails = $getData['customerDetails'];
$this->view->currencyarr = $currencyarr = $getData['currencyarr'];
$this->view->queryTPSysId = $queryTPSysId = $getData['queryTPSysId'];
$this->view->checkOutDate = $checkOutDate = $getData['checkOutDate'];
$this->view->checkInDate = $checkInDate = $getData['checkInDate'];
$this->view->MpType = $MpType = $getData['MpType'];
$this->view->GTXNetwork = $GTXNetwork = $getData['GTXNetwork'];
$this->view->getTaxSettingDetail = $getTaxSettingDetail = $getData['getTaxSettingDetail'];
$this->view->getTcsSettingDetail = $getTcsSettingDetail = $getData['getTcsSettingDetail'];
$this->view->departureCity = $departureCity = $getData['departureCity'];
$this->view->popuppackageType = $popuppackageType = $getData['popuppackageType'];
$this->view->getgsttcsSettingDetail = $getgsttcsSettingDetail = $getData['getgsttcsSettingDetail'];
$this->view->pricebrakup = $pricebrakup;
$this->view->package_flightdetails = $_SESSION['package_flightdetails'];
$this->view->getTaxSettingFlight = $getTaxSettingFlight;
}
}