| 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
/* * ***************
* 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 Shobhit Srivastav(shobhit833@gmail.com).
* Create Date 27-07-2016
* Update Date 27-07-2016
* CustomerControoler (It will allow users to add different masters)
* *** */
class LeadDetailController extends Catabatic_ValidateGtx {
private $intLoggedinUserId;
private $intLoggedinUserGroupSysId;
private $intLoggedinUserAgencySysId;
private $intLoggedinUserTrxCurrency;
public $baseUrl;
private $SMSURL;
private $SMSMETHOD;
private $SMSAPIKEY;
private $SMSSENDER;
private $SMSFORMAT;
public $shorturl_link;
public $IsSMSApi;
public $_crmcustomerObj;
public $_crmcusttravelplan;
public $_crmcusttravelplanAir;
public $_crmcusttravelplanHotel;
public $_crmcustomertravelItenary;
public $_crmremarkObj;
public $_searchhotelObj;
public $_objAirport;
public $hotelApiEndpointURLSearchResult;
public $_HtmlPurifier;
public $_leadSourceObj;
public $_objPkg;
public $_flightlObj;
public $_proposal;
public $getLeadlist;
private $smtpUserName;
private $smtpPassword;
private $smtpPort;
private $smtpHost;
private $fromEmail;
private $fromName;
private $BITLYLOGIN;
private $BITLYAPIKEY;
public function init() {
parent::init();
$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();
$this->shorturl_link = Catabatic_Helper::getShortUrl();
$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');
#get session variable
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserGroupSysId = $sessionLogin_user->intLoggedinUserGroupSysId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->IsSMSApi = $sessionLogin_user->agencyDetails['IsSMSApi'];
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$this->_crmcusttravelplanAir = new Travel_Model_CRM_CustomerTravelPlanAir();
$this->_crmcusttravelplanHotel = new Travel_Model_CRM_CustomerTravelPlanHotel();
$this->_crmcustomertravelItenary = new Travel_Model_CRM_CustomerTravelItenary();
$this->_crmremarkObj = new Travel_Model_CRM_Remark();
$this->_searchhotelObj = new Travel_Model_TblHotel();
$this->_objAirport = new Travel_Model_TblAirport();
############## For HTML Purifer ####################
$this->_HtmlPurifier = new Zend_Filter_HtmlPurifier();
$this->hotelApiEndpointURLSearchResult = $this->baseUrl . API_RES_HOTEL; // from constant file
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->getRequest()->getParam('cid') : '';
$leadId = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '';
$MasterTPSysId = $this->getRequest()->getParam('mid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('mid'))) : '';
if (!empty($CustomerSysId) && !empty($leadId)) {
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($CustomerSysId));
$leadId = base64_decode($leadId);
$leadId = (isset($MasterTPSysId) && ($MasterTPSysId > 0)) ? $MasterTPSysId : $this->_HtmlPurifier->filter($leadId);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
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 (empty($getCustomerDetail)) {
$this->_redirect('/customer/customer-message/type/status');
exit;
}
if ($getCustomerDetail['IsB2BAgent'] == 0 && $getCustomerDetail['AgencySysId'] != $this->intLoggedinUserAgencySysId) {
echo "Please check request parameter..";
die;
}
//end of check customer status
//echo "<pre>";print_r($getCustomerDetail);die;
$getCustomerRemarkDetail = $this->_crmremarkObj->GetCustomerRemarkById($CustomerSysId, $AgencySysId);
$getCustomerDetail['Remarks'] = !empty($getCustomerRemarkDetail['Remarks']) ? stripslashes($getCustomerRemarkDetail['Remarks']) : null;
$agencyUserDetails['intLoggedinUserId'] = $sessionLogin_user->intLoggedinUserId;
$agencyUserDetails['FirstName'] = $sessionLogin_user->FirstName;
$agencyUserDetails['LastName'] = $sessionLogin_user->LastName;
$agencyUserDetails['EmailId'] = $sessionLogin_user->EmailId;
$getCustomerDetail['agencyUserDetails'] = $agencyUserDetails;
$this->view->customerDetail = $getCustomerDetail;
}
$airportlist = $this->_objAirport->getAirportList();
$this->view->sourceCity = $airportlist;
$this->view->leadId = $leadId;
$getLeadlist = $this->_crmcusttravelplan->GetLeadList($CustomerSysId, $AgencySysId, $leadId);
$this->_leadSourceObj = new Travel_Model_TblLeadSource();
$leadSource = $this->_leadSourceObj->GetAllSouce($AgencySysId);
$getLeadlist[0]['LeadSourceArray'] = $leadSource;
if (count($getLeadlist) == 0) {
$this->_redirect('/dashboard/agency/');
exit;
}
$planType = $this->_crmcusttravelplan->GetTravelPlanType($leadId, 'Query');
$this->_objPkg = new Travel_Model_PackageSearch();
$packageThemeList = $this->_objPkg->getPackageThemeList();
$packageFoodPreferenceList = $this->_objPkg->getFoodPreferenceList();
$packageInclList = $this->_objPkg->getPackageInclusionList();
//$cityListArray = $this->_objPkg->getCityList(); hidden_selected_hotel_id
$cityListArray = array();
$this->view->packageThemeList = $packageThemeList;
$this->view->packageFoodPreferenceList = $packageFoodPreferenceList;
$this->view->packageInclList = $packageInclList;
$this->view->cityListArray = $cityListArray;
//print_r($packageThemeList);die;
//echo count($getflightproposal);
$getFlightQueryDetail = array();
$totalDays = 0;
// for flight query list
if ($planType['PlanType'] == 1) {
if (isset($getLeadlist[0]['SourcePlaceSysId']) && ($getLeadlist[0]['SourcePlaceSysId'] > 0)) {
$this->_flightlObj = new Travel_Model_TblFlight();
$getAirportSourcePlaceName = $this->_flightlObj->getAirPortAutoSuggest("tb2.AirportCode = '" . trim($getLeadlist[0]['SourceAirportCode']) . "' AND tb2.CityId = " . $getLeadlist[0]['SourcePlaceSysId'] . "");
$getLeadlist[0]['sourceCityText'] = $getAirportSourcePlaceName[0]['label'];
}
if (isset($getLeadlist[0]['DestinationPlacesSysId']) && ($getLeadlist[0]['DestinationPlacesSysId'] > 0)) {
$this->_flightlObj = new Travel_Model_TblFlight();
$getAirportDestinationPlaceName = $this->_flightlObj->getAirPortAutoSuggest("tb2.AirportCode = '" . trim($getLeadlist[0]['DestAirportCode']) . "' AND tb2.CityId = " . $getLeadlist[0]['DestinationPlacesSysId'] . "");
$getLeadlist[0]['destinationCityText'] = @$getAirportDestinationPlaceName[0]['label'];
}
$getflightproposal = $this->_crmcusttravelplan->GetFlightProposal($leadId);
$this->_proposal = $getflightproposal;
$this->view->proposalCount = count($getflightproposal);
if (isset($getLeadlist[0]['StartDate']) && !empty($getLeadlist[0]['ValidTill'])) {
$fromDate = $getLeadlist[0]['StartDate']->format('Y-m-d');
$toDate = $getLeadlist[0]['ValidTill']->format('Y-m-d');
if ($getLeadlist[0]['ValidTill']->format('Y') != '1900') {
// input format should be 206-03-25
$totalDays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($fromDate, $toDate);
}
}
}
if ($planType['PlanType'] == 2) {
//query to fetch all hotel proposals created by Er Amit Kumar Dubey On 7 August 2016 at 10:37:AM//
$gethotelproposalArr = $this->_crmcusttravelplan->GetAllProposalList($leadId);
// echo "<pre>";print_r($gethotelproposalArr);die;
foreach ($gethotelproposalArr as $hpkey => $hpVal) {
if ($hpVal['IsHotelOnlyPackage'] == 1) {
$gethotelproposal[$hpVal['TPSysId']] = $hpVal;
} else {
$gethotelproposal[] = $hpVal;
}
}
$this->_proposal = (isset($gethotelproposal)) ? $gethotelproposal : array();
$this->view->proposalCount = (isset($gethotelproposal)) ? count($gethotelproposal) : 0;
if (isset($getLeadlist[0]['hotelFromDate']) && !empty($getLeadlist[0]['hotelToDate'])) {
$fromDate = $getLeadlist[0]['hotelFromDate']->format('Y-m-d');
$toDate = $getLeadlist[0]['hotelToDate']->format('Y-m-d');
// input format should be 206-03-25
$totalDays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($fromDate, $toDate);
}
}
if ($planType['PlanType'] == 4 || $planType['PlanType'] == 5 || $planType['PlanType'] == 6 || $planType['PlanType'] == 7 || $planType['PlanType'] == 8 || $planType['PlanType'] == 9 || $planType['PlanType'] == 11 || $planType['PlanType'] == 10) {
//if($planType['PlanType']==5){
//query to fetch all package proposals created by Er Amit Kumar Dubey On 8 March 2016 at 03:38:AM//
$gethotelproposal = $this->_crmcusttravelplan->GetPackageProposal($leadId);
//echo "<pre>";print_r($gethotelproposal);die;
$this->_proposal = $gethotelproposal;
$this->view->proposalCount = count($gethotelproposal);
if (isset($getLeadlist[0]['hotelFromDate']) && !empty($getLeadlist[0]['hotelToDate'])) {
$fromDate = $getLeadlist[0]['hotelFromDate']->format('Y-m-d');
$toDate = $getLeadlist[0]['hotelToDate']->format('Y-m-d');
// input format should be 206-03-25
$totalDays = Zend_Controller_Action_HelperBroker::getStaticHelper('DateFormat')->calculateNoOfDays($fromDate, $toDate);
}
}
// end of query to fetch hotel proposals
//echo $getLeadlist[0]['TPIntSysId'];die;
//$hotelAccomDetails=$this->_crmcusttravelplanHotel->GetAccomDetailsById($getLeadlist[0]['TPIntSysId']);
//echo count($getLeadlist);
$roominfojson = isset($getLeadlist[0]['RoomMemInfoJson']) ? json_decode($getLeadlist[0]['RoomMemInfoJson'], 1) : array();
if (!empty($roominfojson)) {
for ($d = 1; $d <= count($roominfojson); $d++) {
$getLeadlist[0]['hotelTotalRooms'] = count($roominfojson);
$getLeadlist[0]['memberDetails'][] = array('AdultPax' => $roominfojson[$d]['adult'], 'ChildPax' => $roominfojson[$d]['child']['childcount'], 'ChildsAge' => @$roominfojson[$d]['child']['childage']);
}
} else {
for ($d = 0; $d < count($getLeadlist); $d++) {
$getLeadlist[0]['hotelTotalRooms'] = count($getLeadlist);
$getLeadlist[0]['memberDetails'][] = array('AdultPax' => @$getLeadlist[$d]['adultsinHotel'], 'ChildPax' => @$getLeadlist[$d]['childsinHotel'], 'ChildsAge' => @$getLeadlist[$d]['hotelChildsAge']);
}
}
$getLeadlist[0]['searchType'] = 'CRMHOTELSEARCH';
$getLeadlist[0]['TPSysId'] = $leadId;
$getLeadRemarkDetail = $this->_crmremarkObj->GetLeadRemarkById($leadId);
//print_r($getLeadRemarkDetail);die;
$CustomerRemark = isset($getLeadlist[0]['CustomerRemark']) ? $getLeadlist[0]['CustomerRemark'] : '';
$SourcePlaceSysId = isset($getLeadlist[0]['SourcePlaceSysId']) ? $getLeadlist[0]['SourcePlaceSysId'] : '';
$getLeadlist[0]['leadRemark'] = is_array($getLeadRemarkDetail) && count($getLeadRemarkDetail) > 0 ? $getLeadRemarkDetail['Remarks'] : $CustomerRemark;
$getLeadlist[0]['TPIntSysId'] = isset($getLeadlist[0]['TPIntSysId']) ? $getLeadlist[0]['TPIntSysId'] : '';
$objCity = new Travel_Model_TblCity();
$cityList = isset($getLeadlist[0]['hotelXrefCityId']) ? $objCity->getCityDetailsById($getLeadlist[0]['hotelXrefCityId']) : array();
$hoteltbbcityid = '';
if (!empty($cityList)) {
$hoteltbbcityid = $cityList[0]['TBBCityId'];
}
// echo '<pre>';
// print_r($cityList);
// echo '<pre>';
// print_r($getLeadlist);
// die;
$getLeadlist[0]['hidden_selected_hotel_id'] = !empty($hoteltbbcityid) ? $hoteltbbcityid : $SourcePlaceSysId;
$getLeadlist[0]['hotelFromDateSession'] = isset($getLeadlist[0]['hotelFromDate']) ? $getLeadlist[0]['hotelFromDate']->format('d-M-y') : '';
$getLeadlist[0]['customername'] = isset($getCustomerDetail['FullName']) ? $getCustomerDetail['FullName'] : '';
$getLeadlist[0]['emailID'] = isset($getCustomerDetail['EmailId']) ? $getCustomerDetail['EmailId'] : '';
$getLeadlist[0]['customerId'] = $CustomerSysId;
$getLeadlist[0]['hotelToDateSession'] = isset($getLeadlist[0]['hotelToDate']) ? $getLeadlist[0]['hotelToDate']->format('d-M-y') : '';
$getLeadlist[0]['totalDays'] = isset($totalDays) ? $totalDays : 0;
//echo "<pre>";print_r($getLeadlist);die;
$this->getLeadlist = $getLeadlist;
$this->view->leadDetail = $getLeadlist;
$this->view->getFlightQueryDetail = $getFlightQueryDetail;
}
// add for send email to customer
$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'];
// end of add email to sending to customer
$this->BITLYLOGIN = 'gpurwar';
$this->BITLYAPIKEY = 'R_c1c94b5c789249d5a59d585bc0e7ef80';
}
public function indexAction() {
}
public function leadDetailAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$leadId = $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;
}
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid')));
$SupplierSysId = (NULL !== $this->getRequest()->getParam('sid')) ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('sid'))) : '';
if (isset($leadId) && !empty($leadId)) {
$getAllCustomerTODO = $this->_crmcustomerObj->GetAllCustomerToDoByLeadIdNotComplete($CustomerSysId, $leadId);
$lastUpdatedQueryStatus = $this->_crmcusttravelplan->GetProposalLastUpdateInfo($leadId);
$this->view->alltodo = $getAllCustomerTODO;
$this->view->lastUpdatedQueryStatus = $lastUpdatedQueryStatus;
$this->view->EnqSupplierSysId = $SupplierSysId ? base64_encode($SupplierSysId) : '';
//$this->view->totalrec = $paginator->getTotalItemCount();
$objAgency = new Travel_Model_TblAgency();
$this->view->getActiveStaff = $getActiveStaff = $objAgency->getActiveStaff($AgencySysId);
$this->view->agencyOpsUser = $agencyOpsUser = $this->_crmcustomerObj->getAllAgencyOpsUserList($AgencySysId);
//echo "<pre>";print_r($getAllLeadRemark);die;
$objCountry = new Travel_Model_TblCountry();
$countryList = $objCountry->getCountryList();
$this->view->countryList = $countryList;
}
}
public function proposalAction() {
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('cid')) : '';
$leadId = $this->getRequest()->getParam('id') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('id')) : '';
$decode_leadId = base64_decode($leadId);
//$flightproposal = $this->_flightproposal;
//print_r($this->_flightproposal);
$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;
$this->view->intLoggedinUserId = $AgentSysId = $sessionLogin_user->intLoggedinUserId;
$roleID = $sessionLogin_user->UserRole;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($roleID);
if (($getRoleDetail['IsAdmin'] == True) || $getRoleDetail['IsSuperAdmin'] == True) {
$IsAdmin = true;
} else {
$IsAdmin = false;
}
$this->view->IsAdmin = $IsAdmin;
//echo "<pre>";print_r($this->_proposal);exit;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($this->_proposal);
$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;
//echo '<pre>';print_r($paginator);die;
$this->view->totalrec = $paginator->getTotalItemCount();
// update notification in travel plan is viewd
$where = "TPSysId = " . $decode_leadId;
$this->_crmcusttravelplan = new Travel_Model_CRM_CustomerTravelPlan();
$data = array(
'UpdateDate' => date('Y-m-d H:i:s'),
'isPlanViewed' => 1
);
$updateViewdInCustomerTravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($data, $where);
//end of notification
//$this->view->hotelproposal = $this->_hotelproposal ? $this->_hotelproposal : '';
// $this->view->flightproposal = count($this->_flightproposal)>0 ? $this->_flightproposal : '';
$this->view->controller = $this;
if (@$this->getLeadlist[0]['PlanType'] == '') {
$this->_redirect('/dashboard/agency');
}
if ($this->getLeadlist[0]['PlanType'] == 2) {
$proposalModuleComp = $this->_crmcusttravelplan->GetProposalStatusModuleComp(2, 18);
$this->view->proposalModuleComp = $proposalModuleComp;
}
$TblCurrency = new Travel_Model_TblCurrency();
$this->view->CurrencySymbol = $CurrencySymbol = $TblCurrency->getCurrencySymbolByIdsList();
}
public function confirmationAction() {
}
public function performaIinvoiceAction() {
}
public function invoiceAction() {
}
public function accountsAction() {
}
public function chatHistoryAction() {
}
public function leadContactAction() {
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$leadId = $this->getRequest()->getParam('id') ? $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;
$fetchLeadDetails = $this->_crmcusttravelplan->GetProposalCount($leadId);
if (count($fetchLeadDetails) == 0) {
$this->_redirect('/dashboard/agency');
exit;
}
$TPSysIds = array();
if (!empty($fetchLeadDetails)) {
foreach ($fetchLeadDetails as $key => $value) {
$TPSysIds[] = $value['TPSysId'];
}
}
//print_r($fetchLeadDetails);die;
$getLeadMemberDetail = (!empty($TPSysIds)) ? $this->_crmcusttravelplan->GetLeadMembersByIdArray($AgencySysId, $CustomerSysId, $TPSysIds) : '';
//print_r($getLeadMemberDetail);die;
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getLeadMemberDetail);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
$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;
}
public function supplierProposalAction() {
}
public function updateHotelProposalLeadAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$createDate = date('Y-m-d');
$leadID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('leadID')));
$cardcharges = $this->_HtmlPurifier->filter($this->getRequest()->getPost('cardcharges'));
/* Custom Rates & Data For Quick Hotel Added By Pardeep Panchal */
$arrRateType = json_decode($this->getRequest()->getPost('rateType'));
$arrSupplier = json_decode($this->getRequest()->getPost('SuppLiers'));
$arrCustomizeBasePrice = json_decode($this->getRequest()->getPost('customizeBaseRate'));
$arrGSTOnCustomizeBasePrice = json_decode($this->getRequest()->getPost('GstOncustomizeBaseRate'));
$arrcustomizeMarkUp = json_decode($this->getRequest()->getPost('customizeMarkUp'));
$arrGSTOncustomMarkup = json_decode($this->getRequest()->getPost('GSTOncustomizeMarkUp'));
$arrCustomExtraMarkup = json_decode($this->getRequest()->getPost('customExtraMarkup'));
$arrGSTOnCustomExtraMarkup = json_decode($this->getRequest()->getPost('customExtraMarkupGST'));
$arrCustomFinalPrice = json_decode($this->getRequest()->getPost('customFinalPrice'));
$arrRoomtype = json_decode($this->getRequest()->getPost('roomtype'));
$arrMPType = json_decode($this->getRequest()->getPost('mptype'));
$arrAllowBooking = json_decode($this->getRequest()->getPost('allowbooking'));
$remarks = $this->getRequest()->getPost('remarks');
$ccemail = !empty($this->getRequest()->getPost('ccemail')) ? $this->getRequest()->getPost('ccemail') : '';
$sendersEmailId = !empty($this->getRequest()->getPost('senderEmailID')) ? $this->getRequest()->getPost('senderEmailID') : trim($sessionLogin_user->EmailId);
/* Custom Rates & Data For Quick Hotel Ends */
// echo "<pre>";print_r($this->getRequest()->getPost());echo "</pre>";exit;
$hotelValues = $this->getRequest()->getPost('hotelValues');
$hotelValues = json_decode($hotelValues);
// print_r(base64_decode($hotelValues[0]));die;
$finalPriceArray = json_decode($this->getRequest()->getPost('finalPriceArray'));
$MarkupArray = json_decode($this->getRequest()->getPost('MarkupArray'));
$AgencyMarkupArray = json_decode($this->getRequest()->getPost('AgencyMarkupArray'));
$GTXMarkupArray = json_decode($this->getRequest()->getPost('GTXMarkupArray'));
$netPriceArray = json_decode($this->getRequest()->getPost('netPriceArray'));
$TotalTaxes = json_decode($this->getRequest()->getPost('TotalTaxes'));
$planbookingID = 'QS/' . date('y');
$agencySysID = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$newcustomersysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('newcustomerId')));
if (isset($newcustomersysID) && !empty($newcustomersysID)) {
$customersysID = $newcustomersysID;
} else {
$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_cityid = $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_cityid'));
$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'));
// $selectRoom = $this->_HtmlPurifier->filter($this->getRequest()->getPost('selectRoom'));
$selectRoom = $this->_HtmlPurifier->filter($this->getRequest()->getPost('roomlp'));
$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;
$s = 1;
// for ($i = 0; $i < $selectRoom; $i++) {
// $noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $s));
// $selectnoOfChild = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild' . $s));
// $totalNoOfAdult = $noOfAdults + $totalNoOfAdult;
// $totalNoOfChild = $selectnoOfChild + $totalNoOfChild;
// $s++;
// }
$roomaaray = array();
$roomArrayProposal = array();
// for ($i = 1; $i <= $selectRoom; $i++) {
// $roomaaray[$i]['adult'] = $this->_request->getParam('noOfAdults' . $i);
// $roomaaray[$i]['child']['childcount'] = $this->_request->getParam('select-noOfChild' . $i);
//
// $childcount = $this->_request->getParam('select-noOfChild' . $i);
// $childnum = '';
// for ($j = 1; $j <= $childcount; $j++) {
// $childnum = $childnum . ',' . $this->_request->getParam('select-childAge_' . $i . '_' . $j);
// $roomaaray[$i]['child']['childage'] = trim($childnum, ",");
// }
//
// //create array for proposal
// $roomArrayProposal[$i]['Adult'] = $this->_request->getParam('noOfAdults' . $i);
// $roomArrayProposal[$i]['Child'] = $this->_request->getParam('select-noOfChild' . $i);
// $roomArrayProposal[$i]['bedtype'] = 'none';
// $roomArrayProposal[$i]['departuredate'] = $chekInDate;
// $roomArrayProposal[$i]['returndate'] = $chekOutDate;
//
// //$roomaaray[$i]['child'] = $this->_request->getParam('select-noOfChild'.$i);
// }
// $roomaarayinfo = json_encode($roomaaray);
// $roomArrayProposalRes = json_encode($roomArrayProposal);
for ($k = 1; $k <= $selectRoom; $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']
);
}
$roomArrayProposalRes = json_encode($roomjson);
$roomaarayinfo = json_encode($roomaarayinfo);
$selectStarRating = intval($selectStarRating);
$chekInDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekInDate)));
$validTillDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekOutDate)));
$status = '1';
$createDate = date('Y-m-d H:i:s');
//$taxdetailforagency=$this->_crmcusttravelplan->getAgencyStandardTax($agencySysID);
$taxdetailforagency = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax('', "H", 8);
$agenttaxPercentage = (trim($taxdetailforagency['ServiceTaxPercentage']) > 0) ? trim(floatval($taxdetailforagency['ServiceTaxPercentage'])) : 0;
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($customersysID);
############ Update Status Of Queries ##########
if (isset($leadID) && !empty($leadID)) {
$leadID = $leadID;
} else {
if (empty($editLeadId) or $editLeadId == '') {
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'AgentSysId' => $AgentSysId,
'StatusType' => $this->_HtmlPurifier->filter($status),
'CustomerSysId' => $this->_HtmlPurifier->filter($customersysID),
'IsCardChrgToCustomer' => $cardcharges,
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'PlanType' => 2,
'Cities' => $Hotel_name_city,
'SourcePlaces' => $Hotel_name_city,
'SourcePlaceSysId' => $hidden_selected_hotel_cityid,
'RoomInfoJson' => $roomArrayProposalRes,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'StatusType' => 1,
'IsActive' => 1,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'Price' => isset($finalPriceArray[$i]) ? $finalPriceArray[$i] : $finalPriceArray[0],
'NetPrice' => isset($netPriceArray[$i]) ? $netPriceArray[$i] : $netPriceArray[0],
/* 'MarkUp' => isset($MarkupArray[$i])?$MarkupArray[$i]:$MarkupArray[0],
'GTXMarkup' => isset($AgencyMarkupArray[$i])?$AgencyMarkupArray[$i]:$AgencyMarkupArray[0],
'AgencyMarkUp' => isset($AgencyMarkupArray[$i])?$AgencyMarkupArray[$i]:$AgencyMarkupArray[0],
'MarkUp' => isset($MarkupArray[$i])?$MarkupArray[$i]:$MarkupArray[0],
*/
'IsAprooved' => 1,
'IsMarkForDel' => 0,
'selectNationality' => $selectNationality,
'IsB2Bproposal' => trim($getCustomerDetail['IsB2BAgent']),
'ProposalEmailFrom' => trim($sendersEmailId),
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$sessionhotelDirectSearchData->params['TPSysId'] = $leadID;
//this query used when user direct search hotel
for ($i = 0; $i < count($hotelValues); $i++) {
$rateType = $arrRateType[$i];
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
//$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 ($leadID) {
// $travelitenary = array(
// 'TPSysId' => $leadID,
// 'AgencySysId' => $agencySysID,
// 'StartDate' => $createDate,
// 'IsActive' => 1,
// 'Sequence' => 1,
// 'CreateDate' => $createDate,
// 'UpdateDate' => $createDate,
// 'IsActive' => 1,
// 'IsMarkForDel' => 0,
// );
//
// $lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
// }
########### End Add Data in Travel Hotel Table ###################
// for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
//add service tax amount
if ($selectedHotelDetail['intICSourceSysId'] == 3) {
$serviceTaxApiType = 8;
}
if ($selectedHotelDetail['intICSourceSysId'] == 4) {
$serviceTaxApiType = 9;
}
if ($selectedHotelDetail['intICSourceSysId'] == "Inv") {
$serviceTaxApiType = 10;
}
//service tax for base fare
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($netPriceArray[$i], "H", $serviceTaxApiType);
$netPriceArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for GTX MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($GTXMarkupArray[$i], "H", $serviceTaxApiType);
$GTXMarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for Agency MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($AgencyMarkupArray[$i], "H", $serviceTaxApiType);
$AgencyMarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for Agent MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($MarkupArray[$i], "H", $serviceTaxApiType);
$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//end of service tax
//echo $netPriceArrayServiceTax."/".$GTXMarkupArrayServiceTax."/".$AgencyMarkupArrayServiceTax."/".$MarkupArrayServiceTax;
$Taxes = 0;
$totalCost = $netPriceArray[$i] + $MarkupArray[$i] + $GTXMarkupArray[$i] + $AgencyMarkupArray[$i] + $Taxes + $netPriceArrayServiceTax + $GTXMarkupArrayServiceTax + $AgencyMarkupArrayServiceTax + $MarkupArrayServiceTax;
if ($rateType == 'custom') {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => isset($arrSupplier[$i]) ? $arrSupplier[$i] : $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $arrCustomFinalPrice[$i],
'Discounts' => 0,
'Taxes' => $arrGSTOnCustomizeBasePrice[$i],
'NetCost' => $arrCustomizeBasePrice[$i],
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => $arrGSTOncustomMarkup[$i],
'AgentsCustomServiceTaxAmount' => $arrGSTOnCustomExtraMarkup[$i],
'MarkUp' => $arrCustomExtraMarkup[$i],
'GTXMarkup' => 0,
'AgencyMarkUp' => $arrcustomizeMarkUp[$i],
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RoomTypeStr' => isset($arrRoomtype[$i]) ? $arrRoomtype[$i] : '',
'MealPlanType' => isset($arrMPType[$i]) ? $arrMPType[$i] : '',
'SpecialRequest' => isset($remarks) ? $remarks : '',
'RateType' => 2,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
} else {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $totalCost,
'Discounts' => 0,
'Taxes' => $Taxes,
'NetCost' => $netPriceArray[$i],
'XServiceTaxAmount' => $netPriceArrayServiceTax,
'GTXServiceTaxAmount' => $GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => $AgencyMarkupArrayServiceTax,
'AgentsCustomServiceTaxAmount' => $MarkupArrayServiceTax,
'MarkUp' => $MarkupArray[$i],
'GTXMarkup' => $GTXMarkupArray[$i],
'AgencyMarkUp' => $AgencyMarkupArray[$i],
'SpecialRequest' => isset($remarks) ? $remarks : '',
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RateType' => 1,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
}
// $lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
########### Start Add Data in Travel Hotel Table ###################
//echo $leadID;
//echo $lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
########### End Add Data in Travel Air Table ###################
}
//end of direct search hotel
} else {
$leadID = $editLeadId;
}
}
//check if cuurent customer is not new
$chkCustomerWithLeadId = $this->_crmcusttravelplan->CheckCustomerWithLeadId($leadID, 'Query');
if ($chkCustomerWithLeadId[0]['CustomerSysId'] == $customersysID) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
} else {
for ($i = 0; $i < count($hotelValues); $i++) {
$rateType = $arrRateType[$i];
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'MasterTPSysId' => 0,
'SupplierSysId' => ($selectedHotelDetail['SupplierSysId'] == "Inv") ? 1 : $selectedHotelDetail['SupplierSysId'],
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'IsHotelFromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'IsCardChrgToCustomer' => $cardcharges,
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'StatusType' => 2,
'PlanType' => 2,
'CustomerSysId' => $customersysID,
'AdditionalReq' => $additionalRequirement,
'RoomInfoJson' => $roomArrayProposalRes,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'Cities' => $Hotel_name_city,
'SourcePlaces' => $Hotel_name_city,
'SourcePlaceSysId' => $hidden_selected_hotel_cityid,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'Price' => $finalPriceArray[$i],
'NetPrice' => $netPriceArray[$i],
//'MarkUp' => $MarkupArray[$i],
'IsActive' => 1,
'IsAprooved' => 1,
'selectNationality' => $selectNationality,
'IsB2Bproposal' => trim($getCustomerDetail['IsB2BAgent'])
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
if ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Hotel Plan Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
$agentMarkup = 0;
$agentServiceTax = 0;
if ($agenttaxPercentage > 0) {
$agentServiceTax = ($MarkupArray[$i] * $agenttaxPercentage) / 100;
$agentMarkup = $MarkupArray[$i];
} else {
$agentMarkup = $MarkupArray[$i];
}
$Taxes = $agentServiceTax + $TotalTaxes[$i];
if ($rateType == 'custom') {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => (int) $selectedHotelDetail['intICSourceSysId'],
//'SupplierSysId' => ($selectedHotelDetail['SupplierSysId'] == "Inv")?1:$selectedHotelDetail['SupplierSysId'],
'SupplierSysId' => isset($arrSupplier[$i]) ? $arrSupplier[$i] : $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $arrCustomFinalPrice[$i],
'Discounts' => 0,
'Taxes' => $arrGSTOnCustomizeBasePrice[$i],
'NetCost' => $arrCustomizeBasePrice[$i],
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => $arrGSTOncustomMarkup[$i],
'AgentsCustomServiceTaxAmount' => $arrGSTOnCustomExtraMarkup[$i],
'MarkUp' => $arrCustomExtraMarkup[$i],
'GTXMarkup' => 0,
'AgencyMarkUp' => $arrcustomizeMarkUp[$i],
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RoomTypeStr' => isset($arrRoomtype[$i]) ? $arrRoomtype[$i] : '',
'MealPlanType' => isset($arrMPType[$i]) ? $arrMPType[$i] : '0',
'SpecialRequest' => isset($remarks) ? $remarks : '',
'RateType' => 2,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
} else {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => (int) $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => ($selectedHotelDetail['SupplierSysId'] == "Inv") ? 1 : $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $netPriceArray[$i] + $agentMarkup + $GTXMarkupArray[$i] + $AgencyMarkupArray[$i] + $Taxes,
'Discounts' => 0,
'Taxes' => $Taxes,
'NetCost' => $netPriceArray[$i],
'XServiceTaxAmount' => $selectedHotelDetail['netTaxOnBasePrice'],
'MarkUp' => $agentMarkup,
'GTXMarkup' => $GTXMarkupArray[$i],
'AgencyMarkUp' => $AgencyMarkupArray[$i],
'SpecialRequest' => isset($remarks) ? $remarks : '',
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RateType' => 1,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
}
// echo "<pre>";print_r($hotelData);die;
try {
//$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
} catch (Exception $err) {
print_r($err);
echo "failed";
die;
}
//}
########### End Add Data in Hotel Plan Table ###################
}
}
for ($i = 0; $i < count($hotelValues); $i++) {
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($leadID);
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
//print_r($selectedHotelDetail);
//add service tax amount
if ($selectedHotelDetail['intICSourceSysId'] == 3) {
$serviceTaxApiType = 8;
}
if ($selectedHotelDetail['intICSourceSysId'] == 4) {
$serviceTaxApiType = 9;
}
if ($selectedHotelDetail['intICSourceSysId'] == "Inv") {
$serviceTaxApiType = 10;
}
//service tax for base fare
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($netPriceArray[$i], "H", $serviceTaxApiType);
$netPriceArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for GTX MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($GTXMarkupArray[$i], "H", $serviceTaxApiType);
$GTXMarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for Agency MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($AgencyMarkupArray[$i], "H", $serviceTaxApiType);
$AgencyMarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//service tax for Agent MarkUp
$arrServiceTaxOnNetPayable = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiServiceTax($MarkupArray[$i], "H", $serviceTaxApiType);
$MarkupArrayServiceTax = !empty($arrServiceTaxOnNetPayable['serviceTaxAmount']) ? $arrServiceTaxOnNetPayable['serviceTaxAmount'] : 0;
//end of service tax
//echo $netPriceArrayServiceTax."/".$GTXMarkupArrayServiceTax."/".$AgencyMarkupArrayServiceTax."/".$MarkupArrayServiceTax;
$Taxes = 0;
$totalCost = $netPriceArray[$i] + $MarkupArray[$i] + $GTXMarkupArray[$i] + $AgencyMarkupArray[$i] + $Taxes + $netPriceArrayServiceTax + $GTXMarkupArrayServiceTax + $AgencyMarkupArrayServiceTax + $MarkupArrayServiceTax;
$nextVersionId = (isset($getlatestversion[0]['VersionId']) && $getlatestversion[0]['VersionId'] > 0) ? $getlatestversion[0]['VersionId'] + 1 : 1;
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'MasterTPSysId' => $leadID,
'VersionId' => $nextVersionId,
'SupplierSysId' => ($selectedHotelDetail['SupplierSysId'] == "Inv") ? 1 : $selectedHotelDetail['SupplierSysId'],
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'IsHotelFromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4 || $selectedHotelDetail['intICSourceSysId'] == "Inv") ? 1 : 0,
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'IsCardChrgToCustomer' => $cardcharges,
'StatusType' => 4,
'ProposalEmailTo' => $getCustomerDetail['EmailId'],
'PlanType' => 2,
'CustomerSysId' => $customersysID,
'RoomInfoJson' => $roomArrayProposalRes,
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'Cities' => $Hotel_name_city,
'SourcePlaces' => $Hotel_name_city,
'SourcePlaceSysId' => $hidden_selected_hotel_cityid,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'Price' => $finalPriceArray[$i],
'NetPrice' => $totalCost,
//'MarkUp' => $MarkupArray[$i],
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
'selectNationality' => $selectNationality,
'IsB2Bproposal' => trim($getCustomerDetail['IsB2BAgent'])
);
//echo "<pre>";print_r($data);exit;
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
$sessionhotelDirectSearchData->params['TPSysId'] = $lastID;
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Hotel Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
/* $agentMarkup=0;
$agentServiceTax=0;
if($agenttaxPercentage > 0){
$agentServiceTax=($MarkupArray[$i]*$agenttaxPercentage)/100;
$agentMarkup=$MarkupArray[$i];
}else{
$agentMarkup=$MarkupArray[$i];
} */
//$Taxes=$agentServiceTax+$TotalTaxes[$i];
//$totalCost=$netPriceArray[$i]+$agentMarkup+$GTXMarkupArray[$i]+$AgencyMarkupArray[$i]+$Taxes;
$rateType = $arrRateType[$i];
if ($rateType == 'custom') {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => ($selectedHotelDetail['intICSourceSysId'] == "Inv") ? 1 : $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => isset($arrSupplier[$i]) ? $arrSupplier[$i] : $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4 || $selectedHotelDetail['intICSourceSysId'] == "Inv") ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $arrCustomFinalPrice[$i],
'Discounts' => 0,
'Taxes' => $arrGSTOnCustomizeBasePrice[$i],
'NetCost' => $arrCustomizeBasePrice[$i],
'XServiceTaxAmount' => 0,
'GTXServiceTaxAmount' => 0,
'AgentServiceTaxAmount' => $arrGSTOncustomMarkup[$i],
'AgentsCustomServiceTaxAmount' => $arrGSTOnCustomExtraMarkup[$i],
'MarkUp' => $arrCustomExtraMarkup[$i],
'GTXMarkup' => 0,
'AgencyMarkUp' => $arrcustomizeMarkUp[$i],
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RoomTypeStr' => isset($arrRoomtype[$i]) ? $arrRoomtype[$i] : '',
'MealPlanType' => isset($arrMPType[$i]) ? $arrMPType[$i] : '',
'SpecialRequest' => isset($remarks) ? $remarks : '',
'RateType' => 2,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
} else {
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'InvnItemSysId' => isset($selectedHotelDetail['InvnItemSysId']) ? $selectedHotelDetail['InvnItemSysId'] : 0,
'SourceSysId' => ($selectedHotelDetail['intICSourceSysId'] == "Inv") ? 1 : $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => ($selectedHotelDetail['SupplierSysId'] == "Inv") ? 1 : $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4 || $selectedHotelDetail['intICSourceSysId'] == "Inv") ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $totalCost,
'Discounts' => 0,
'Taxes' => $Taxes,
'NetCost' => $netPriceArray[$i],
'XServiceTaxAmount' => $netPriceArrayServiceTax,
'GTXServiceTaxAmount' => $GTXMarkupArrayServiceTax,
'AgentServiceTaxAmount' => $AgencyMarkupArrayServiceTax,
'AgentsCustomServiceTaxAmount' => $MarkupArrayServiceTax,
'MarkUp' => $MarkupArray[$i],
'GTXMarkup' => $GTXMarkupArray[$i],
'AgencyMarkUp' => $AgencyMarkupArray[$i],
'SpecialRequest' => isset($remarks) ? $remarks : '',
'AllowBooking' => isset($arrAllowBooking[$i]) ? $arrAllowBooking[$i] : 0,
'RateType' => 1,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
}
//echo "<pre>";print_r($hotelData);exit;
$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
########### Start Add Data in Travel Hotel Table ###################
//echo $leadID;
//echo $lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
########### End Add Data in Travel Air Table ###################
}
$emailData = array(
'data' => $hotelValues ? $hotelValues : '',
'customerId' => base64_encode($customersysID),
'noOfAdults' => $totalNoOfAdult,
'noOfChilds' => $totalNoOfChild,
'leadId' => $lastID,
'type' => 'hotelPreviewForm',
'netPrice[]' => $netPriceArray,
'markUp[]' => $MarkupArray,
'finalPrice' => $finalPriceArray,
);
//print_r($emailData);die;
$this->_request->setPost($emailData);
//return $this->_forward("hotel-preview-form", "buyhotel", "module");
// echo $this->_forward('hotel-preview-form', 'buyhotel', null, array('baz' => 'bogus'));
//$this->_request->setPost(array('param_name' => 'paramValue'));
// $this->_helper->redirector('hotel-preview-form','buyhotel',$this->_request->setPost(array('param_name' => 'paramValue')));
//echo $result;
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/buyhotel/');
// render view
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($agencySysID);
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$uid = trim($customersysID) . ':' . trim($lastID) . ':' . trim($leadID);
$uid = $this->getEnc($uid);
//echo $desc=base64_encode($this->getDec($uid));die;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
// $getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']). " " .trim($getAgentDetail['LastName']),'AgentContact'=>trim($getAgentDetail['ContactNo1']),'AgentEmailId'=>trim($getAgentDetail['EmailId']));
// print_r($getAgentDetail);die;
$html->assign('type', 'hotelPreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('netPrice', $netPriceArray);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', $agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('arrRateType', $arrRateType);
$html->assign('arrCustomFinalPrice', $arrCustomFinalPrice);
$html->assign('arrRoomtype', $arrRoomtype);
$html->assign('arrMPType', $arrMPType);
$html->assign('arrAllowBooking', $arrAllowBooking);
$html->assign('remarks', $remarks);
$html->assign('noOfAdults', $totalNoOfAdult);
$html->assign('leadId', $lastID);
$html->assign('uid', trim($uid));
$html->assign('MasterTPSysId', $leadID);
$html->assign('noOfChilds', $totalNoOfChild);
$html->assign('data', $hotelValues);
$bodyText = $html->render('email-template.phtml');
$mailToCC = array();
if ($ccemail != '') {
$mailToCC = explode(',', $ccemail);
}
$emailId = trim($getCustomerDetail['EmailId']);
$mailCustmail = array(trim($emailId));
$toArray = array_merge($mailToCC, $mailCustmail);
//$emailSendId=(isset($getAgencyDetail['EmailIdForCustomer']) && !empty($getAgencyDetail['EmailIdForCustomer']) && ($getAgencyDetail['IsEmailIdForCustVarified']==1))?trim($getAgencyDetail['EmailIdForCustomer']):trim($getAgentDetail['AgentEmailId']);
$emailSendId = (isset($sendersEmailId) && $sendersEmailId != '') ? $sendersEmailId : trim($getAgentDetail['EmailId']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$subject = trim($getCustomerDetail['FirstName']) . " your " . $Hotel_name_city . " Hotel details from " . $fromName;
$emailData = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => trim($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 {
//echo "success";
// 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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$arrEmailStatisticsAgent = $arrEmailStatistics;
$arrEmailStatisticsAgent["Source"] = $arrEmailStatisticsType[2];
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $customersysID, $mailToCC);
$this->mailSentByElastice($emailData_cc, $arrEmailStatisticsAgent, 0, 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:i:s')
);
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$whereAgencyCustomer = " AgencySysId=" . $this->intLoggedinUserAgencySysId . " AND CustomerSysId=" . $customersysID . "";
$agencyCustomerData = $this->_agencycustomerObj->UpdateAgencyCustomer($agencyuserArray, $whereAgencyCustomer);
}
$booknowurlUrls = '';
$finalHtml = '';
foreach ($hotelValues as $hhKey => $hhVal) {
$recordFirst = json_decode(base64_decode($hhVal), 1);
//echo "<pre>";print_r($recordFirst);die;
$memberDetails = $recordFirst['sessionhotelDirectSearchData']['memberDetails'];
$totalMemberCount = $recordFirst['sessionhotelDirectSearchData']['totalMemberCount'];
$ChildCount = $totalMemberCount['ChildPax'];
if ($ChildCount > 0) {
$ChildCount = "$ChildCount Child(s)";
} else {
$ChildCount = '';
}
$NoofPax = '%0a%0a*No of Pax:* ' . $totalMemberCount['AdultPax'] . ' Adult(s) ' . $ChildCount;
$NoofRooms = '%0a%0a*No of Rooms:* ' . count($memberDetails);
$finalPrice = trim(round($netPriceArray[$hhKey] + $MarkupArray[$hhKey] + $GTXMarkupArray[$hhKey] + $AgencyMarkupArray[$hhKey]));
$travelPlanObj = new Travel_Model_CRM_CustomerTravelPlan();
$currencyTypeArr = $travelPlanObj->GetCurrencyByCurrencyType($recordFirst['CurrencyType']);
$CurrSymbol = ($currencyTypeArr['Symbol'] != '') ? trim($currencyTypeArr['Symbol']) : 'INR';
$booknowurl = $this->baseUrl . '/proposal/preview-hotel-result/mid/' . base64_encode($leadID) . '/pid/' . base64_encode($lastID) . '/uid/' . base64_encode(trim($uid));
if ($getAgentDetail['IsB2CSite'] == 1) {
$booknowurl = $getAgentDetail['Url'] . "detail/index/view/id/" . base64_encode($booknowurl);
}
if (count($hotelValues) > 1) {
$finalHtml .= '%0a%0a*======* %0a*Option* *' . ($hhKey + 1) . '.*';
}
$TravelDate = '%0a%0a*Travel Date:* ' . date('d M y', strtotime(str_replace("/", "-", $recordFirst['checkInDate'])));
$NoofNights = '%0a%0a*No of Nights:* ' . $recordFirst['nights'];
$finalHtml .= '%0a%0a*Hotel Name:* ' . stripslashes($recordFirst['hotelName']) . ' %0a%0a*Total Cost:* ' . $CurrSymbol . ' ' . $finalPrice . '/-';
}
$bitly_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->getSmallLinkFromBitlyAPI($booknowurl, $this->BITLYLOGIN, $this->BITLYAPIKEY);
if ($bitly_response['errorCode'] == 0) {
$booknowurl = $bitly_response['results'][trim($booknowurl)]['shortUrl'];
}
$primarycontact = $sessionLogin_user->ContactNo1 ? $sessionLogin_user->ContactNo1 : 'N/A';
$agencyDisplayName = $fromName;
$destinationValues = $Hotel_name_city;
$firstname = $sessionLogin_user->FirstName ? $sessionLogin_user->FirstName . ' ' . $sessionLogin_user->LastName : 'Agent';
$custname = $getCustomerDetail['FirstName'] ? trim(trim($getCustomerDetail['FirstName']) . ' ' . trim($getCustomerDetail['LastName'])) : 'Customer';
$whatsappmessage = "*Dear $custname*,%0a%0aThanks for your Hotel query for $destinationValues.%0a%0a*Destination:* $destinationValues $TravelDate $NoofNights $NoofPax $NoofRooms $finalHtml %0a%0aTo view hotel details and *book online* click on the below link:%0a%0a$booknowurl %0a%0aYou can also call $firstname at $primarycontact or email at %0a$emailSendId or whatsapp me here.%0a%0aRegards %0a%0a$firstname, %0a$agencyDisplayName";
$response = array('status' => 'success', 'whatsapp' => $whatsappmessage, 'contactno' => trim($getCustomerDetail['countrycode']) . trim($getCustomerDetail['Contacts']), 'message' => 'Proposal has been shared with customer');
//#end of update customer
echo json_encode($response);
exit;
echo "success";
} catch (Exception $err) {
print_r($err, true);
echo "failed";
}
//end of send email to customer
}
public function bookingPartialDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$leadId = $this->getRequest()->getParam('id') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('id')) : '';
$leadId = base64_decode($leadId);
if (isset($leadId) && !empty($leadId)) {
$this->view->type = 'viewBookingPartialDetail';
$this->view->id = $leadId;
$this->render('ajax-html');
}
}
public function leadListingAction() {
}
public function leadRemarksAction() {
$leadId = $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($leadId) && !empty($leadId)) {
$getAllLeadRemark = $this->_crmremarkObj->GetAllLeadRemarkById($leadId);
//echo "<pre>";print_r($getAllLeadRemark);
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($getAllLeadRemark);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$perPage = $paginator->setItemCountPerPage(10); // number of items to show per page
$this->view->paginator = $paginator;
$this->view->totalrec = $paginator->getTotalItemCount();
}
}
public function leadSupplierDetailAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$leadId = $this->getRequest()->getParam('id') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('id')) : '';
$supplierIds = $this->getRequest()->getParam('sid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid')) : '';
$leadId = base64_decode($leadId);
$supplierIds = $supplierIds ? base64_decode($supplierIds) : '';
// if (isset($leadId) && !empty($leadId) && !empty($supplierIds)) { removed sipplierids condition . when send default 0 value its not working
if (isset($leadId) && !empty($leadId)) {
$this->view->type = 'viewSupplierDetail';
$leadDetail = $this->_crmcusttravelplan->GetTravelPlanByCustomer($leadId);
//print_r($leadDetail);die;
$supplierObj = new Travel_Model_CRM_Supplier();
$supplierDetails = $supplierObj->GetSupplierDetailsByIds($supplierIds);
$this->view->id = $leadId;
$this->view->leadDetail = $leadDetail;
$this->view->supplierDetails = $supplierDetails;
$this->render('ajax-html');
}
}
//this function used when hotel search result and send email to supplier created by Er Amit Kumar dubey on 28 dec 2016 at 5:18 PM
public function updateHotelQueryLeadAction() {
$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(base64_decode($this->getRequest()->getPost('leadID')));
$callDetails = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('suppCallDetails')));
$hotelValues = $this->getRequest()->getPost('hotelValues');
$hotelValues = json_decode(base64_decode($hotelValues), true);
$callDetails = json_decode($callDetails, true);
//echo "<pre>";print_r($callDetails);die;
$finalPriceArray = trim($hotelValues['finalPrice']);
$MarkupArray = trim($hotelValues['addMarkup']);
$netPriceArray = trim($hotelValues['netPrice']);
$planbookingID = 'Q/' . date('y');
$agencySysID = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$newcustomersysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('newcustomerId')));
if (isset($newcustomersysID) && !empty($newcustomersysID)) {
$customersysID = $newcustomersysID;
} else {
$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_cityid = $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_cityid'));
$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'));
$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;
$s = 1;
$roomjson = array();
for ($i = 0; $i < $selectRoom; $i++) {
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $s));
$selectnoOfChild = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild' . $s));
$totalNoOfAdult = $noOfAdults + $totalNoOfAdult;
$totalNoOfChild = $selectnoOfChild + $totalNoOfChild;
$roomjson[$s]['Adult'] = $noOfAdults;
$roomjson[$s]['Child'] = $selectnoOfChild;
$roomjson[$s]['bedtype'] = 0;
$s++;
}
$roominfojson = json_encode($roomjson);
$roomaaray = array();
$roomArrayProposal = array();
for ($i = 1; $i <= $selectRoom; $i++) {
$roomaaray[$i]['adult'] = $this->_request->getParam('noOfAdults' . $i);
$roomaaray[$i]['child']['childcount'] = $this->_request->getParam('select-noOfChild' . $i);
$childcount = $this->_request->getParam('select-noOfChild' . $i);
$childnum = '';
for ($j = 1; $j <= $childcount; $j++) {
$childnum = $childnum . ',' . $this->_request->getParam('select-childAge_' . $i . '_' . $j);
$roomaaray[$i]['child']['childage'] = trim($childnum, ",");
}
//create array for proposal
$roomArrayProposal[$i]['Adult'] = $this->_request->getParam('noOfAdults' . $i);
$roomArrayProposal[$i]['Child'] = $this->_request->getParam('select-noOfChild' . $i);
$roomArrayProposal[$i]['bedtype'] = 'none';
//$roomaaray[$i]['child'] = $this->_request->getParam('select-noOfChild'.$i);
}
$roomaarayinfo = json_encode($roomaaray);
$roomArrayProposalRes = json_encode($roomArrayProposal);
$selectStarRating = intval($selectStarRating);
$chekInDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekInDate)));
$validTillDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekOutDate)));
$status = '1';
$createDate = date('Y-m-d H:i:s');
############ Update Status Of Queries ##########
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'StatusType' => $this->_HtmlPurifier->filter($status),
'CustomerSysId' => $this->_HtmlPurifier->filter($customersysID),
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'PlanType' => 2,
'Cities' => $Hotel_name_city,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'StatusType' => 1,
'IsActive' => 1,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'RoomInfoJson' => $roominfojson,
'Price' => isset($finalPriceArray) ? $finalPriceArray : $finalPriceArray[0],
'NetPrice' => isset($netPriceArray) ? $netPriceArray : $netPriceArray[0],
'MarkUp' => isset($MarkupArray[$i]) ? $MarkupArray[$i] : $MarkupArray[0],
'IsAprooved' => 1,
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$sessionhotelDirectSearchData->params['TPSysId'] = $leadID;
//this query used when user direct search hotel
$selectedHotelDetail = $hotelValues;
//$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 ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
);
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Hotel Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $finalPriceArray,
'Discounts' => 0,
'Taxes' => 0,
'NetCost' => $netPriceArray,
'MarkUp' => $MarkupArray,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_cityid,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
//$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
$msg = 'failed';
$lastcallID = '';
if (isset($leadID) && $leadID > 0) {
$msg = 'success';
if (!empty($callDetails)) {
$arrCall = array(
'TPSysId' => $leadID,
'IsSupAvalOnCall' => $callDetails[0]['suppIsAvailable'],
'OnCallSupRate' => $callDetails[0]['suppRate'],
'OnCallSupRooms' => $callDetails[0]['suppRooms'],
'OnCallSupRateFrom' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $callDetails[0]['suppDate']))),
'OnCallSupRateTo' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $callDetails[0]['suppTo']))),
'OnCallSupRateValidTill' => date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $callDetails[0]['suppHeldTill']))),
'OnCallSupRemarks' => $callDetails[0]['suppRemark'],
'IsActive' => 1,
'IsMarkForDel' => 0,
'CreatedOn' => $createDate,
'UpdatedOn' => $createDate,
);
$this->_crmagencysupponcall = new Travel_Model_CRM_AgencyCustomerReqSupplierOnCall();
$lastcallID = $this->_crmagencysupponcall->addReqSupplierOnCall($arrCall);
}
//echo "<pre>";print_r($callDetails);die;
}
echo json_encode(array('status' => $msg, 'data' => $lastcallID));
}
public function updateHotelQueryLeadSupplierAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
$createDate = date('Y-m-d');
$leadID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('leadID')));
$hotelValues[0] = $this->getRequest()->getPost('hotelValues');
$param = $this->getRequest()->getParams();
//echo '<pre>';print_r($param);die('ggggg');
//print_r(base64_decode($hotelValues[0]));die;
$hotelValuesArr = json_decode(base64_decode($hotelValues[0]), true);
//echo "<pre>";print_r($hotelValuesArr);die;
$finalPriceArray = trim($hotelValuesArr['finalPrice']);
$MarkupArray = trim($hotelValuesArr['addMarkup']);
$netPriceArray = trim($hotelValuesArr['netPrice']);
$planbookingID = 'QS/' . date('y');
$agencySysID = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$newcustomersysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getPost('newcustomerId')));
if (isset($newcustomersysID) && !empty($newcustomersysID)) {
$customersysID = $newcustomersysID;
} else {
$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_cityid = $this->_HtmlPurifier->filter($this->getRequest()->getPost('hidden_selected_hotel_cityid'));
$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'));
$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;
$s = 1;
$roomjson = array();
for ($i = 0; $i < $selectRoom; $i++) {
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $s));
$selectnoOfChild = $this->_HtmlPurifier->filter($this->getRequest()->getPost('select-noOfChild' . $s));
$totalNoOfAdult = $noOfAdults + $totalNoOfAdult;
$totalNoOfChild = $selectnoOfChild + $totalNoOfChild;
$roomjson[$s]['Adult'] = $noOfAdults;
$roomjson[$s]['Child'] = $selectnoOfChild;
$roomjson[$s]['bedtype'] = 0;
$s++;
}
$roominfojson = json_encode($roomjson);
$roomaaray = array();
$roomArrayProposal = array();
for ($i = 1; $i <= $selectRoom; $i++) {
$roomaaray[$i]['adult'] = $this->_request->getParam('noOfAdults' . $i);
$roomaaray[$i]['child']['childcount'] = $this->_request->getParam('select-noOfChild' . $i);
$childcount = $this->_request->getParam('select-noOfChild' . $i);
$childnum = '';
for ($j = 1; $j <= $childcount; $j++) {
$childnum = $childnum . ',' . $this->_request->getParam('select-childAge_' . $i . '_' . $j);
$roomaaray[$i]['child']['childage'] = trim($childnum, ",");
}
//create array for proposal
$roomArrayProposal[$i]['Adult'] = $this->_request->getParam('noOfAdults' . $i);
$roomArrayProposal[$i]['Child'] = $this->_request->getParam('select-noOfChild' . $i);
$roomArrayProposal[$i]['bedtype'] = 'none';
//$roomaaray[$i]['child'] = $this->_request->getParam('select-noOfChild'.$i);
}
$roomaarayinfo = json_encode($roomaaray);
$roomArrayProposalRes = json_encode($roomArrayProposal);
$selectStarRating = intval($selectStarRating);
$chekInDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekInDate)));
$validTillDate = date('Y-m-d', strtotime(str_replace("/", "-", $chekOutDate)));
$status = '1';
$createDate = date('Y-m-d H:i:s');
############ Update Status Of Queries ##########
if (isset($leadID) && !empty($leadID)) {
$leadID = $leadID;
} else {
if (empty($editLeadId) or $editLeadId == '') {
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'StatusType' => $this->_HtmlPurifier->filter($status),
'CustomerSysId' => $this->_HtmlPurifier->filter($customersysID),
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'PlanType' => 2,
'Cities' => $Hotel_name_city,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'StatusType' => 1,
'IsActive' => 1,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'RoomInfoJson' => $roominfojson,
'Price' => isset($finalPriceArray) ? $finalPriceArray : $finalPriceArray[0],
'NetPrice' => isset($netPriceArray) ? $netPriceArray : $netPriceArray[0],
//'MarkUp' => isset($MarkupArray[$i])?$MarkupArray[$i]:$MarkupArray[0],
'IsAprooved' => 1,
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
$sessionhotelDirectSearchData->params['TPSysId'] = $leadID;
//this query used when user direct search hotel
for ($i = 0; $i < count($hotelValues); $i++) {
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
//$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 ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
);
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Hotel Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $finalPriceArray,
'Discounts' => 0,
'Taxes' => 0,
'NetCost' => $netPriceArray,
'MarkUp' => $MarkupArray,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
########### Start Add Data in Travel Hotel Table ###################
//echo $leadID;
//echo $lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
########### End Add Data in Travel Air Table ###################
}
//end of direct search hotel
} else {
$leadID = $editLeadId;
}
}
//check if cuurent customer is not new
$chkCustomerWithLeadId = $this->_crmcusttravelplan->CheckCustomerWithLeadId($leadID, 'Query');
if ($chkCustomerWithLeadId[0]['CustomerSysId'] == $customersysID) {
$where = "TPSysId = " . $leadID;
$updatetravelplan = array(
'UpdateDate' => $createDate,
'StatusType' => '2'
);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
} else {
for ($i = 0; $i < count($hotelValues); $i++) {
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'MasterTPSysId' => 0,
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'IsHotelFromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'StatusType' => 2,
'PlanType' => 2,
'CustomerSysId' => $customersysID,
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'Cities' => $Hotel_name_city,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'RoomInfoJson' => $roominfojson,
'Price' => $finalPriceArray,
'NetPrice' => $netPriceArray,
//'MarkUp' => $MarkupArray[$i],
'IsActive' => 1,
'IsAprooved' => 1,
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
if ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
);
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Hotel Plan Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => 0,
'TotalCost' => $finalPriceArray,
'Discounts' => 0,
'Taxes' => 0,
'NetCost' => $netPriceArray,
'MarkUp' => $MarkupArray,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_id,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
########### End Add Data in Hotel Plan Table ###################
}
}
for ($i = 0; $i < count($hotelValues); $i++) {
$getlatestversion = $this->_crmcusttravelplan->GetLatestVersionID($leadID);
$nextVersionId = (isset($getlatestversion[0]['VersionId']) && $getlatestversion[0]['VersionId'] > 0) ? $getlatestversion[0]['VersionId'] + 1 : 1;
$selectedHotelDetail = json_decode(base64_decode($hotelValues[$i]), true);
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'MasterTPSysId' => $leadID,
'VersionId' => $nextVersionId,
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'IsHotelFromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'AgencySysId' => $this->_HtmlPurifier->filter($agencySysID),
'AgentSysId' => $AgentSysId,
'StatusType' => 4,
'PlanType' => 2,
'CustomerSysId' => $customersysID,
'RoomInfoJson' => $roomArrayProposalRes,
'AdditionalReq' => $additionalRequirement,
'StartDate' => $chekInDate,
'validTill' => $validTillDate,
'Cities' => $Hotel_name_city,
'Countries' => $selectNationality,
'CreateDate' => $createDate,
'Price' => $finalPriceArray,
'NetPrice' => $netPriceArray,
//'MarkUp' => $MarkupArray[$i],
'UpdateDate' => $createDate,
'IsActive' => 1,
'IsAprooved' => 1,
);
$lastID = $this->_crmcusttravelplan->addCustomerTravelPlan($data);
$sessionhotelDirectSearchData->params['TPSysId'] = $lastID;
if ($lastID) {
$travelitenary = array(
'TPSysId' => $lastID,
'AgencySysId' => $agencySysID,
'StartDate' => $createDate,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $createDate,
);
$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
}
########### End Add Data in Travel Hotel Table ###################
//for ($f = 1; $f <= $selectRoom; $f++) {
$f = 1;
$noOfAdults = $this->_HtmlPurifier->filter($this->getRequest()->getPost('noOfAdults' . $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;
}
$hotelData = array(
'TPIntSysId' => $lasttravelitenaryID,
'SeqId' => $f,
'AccoBookingId' => 0,
'XRefBookingId' => 0,
'AccoSysId' => $selectedHotelDetail['hotelId'],
'SourceSysId' => $selectedHotelDetail['intICSourceSysId'],
'SupplierSysId' => $selectedHotelDetail['SupplierSysId'],
'IsfromAPI' => ($selectedHotelDetail['intICSourceSysId'] == 3 || $selectedHotelDetail['intICSourceSysId'] == 4) ? 1 : 0,
'Title' => $Hotel_name_city,
'AgencySysId' => $agencySysID,
'RoomMemInfoJson' => $roomaarayinfo,
'CreateDate' => $createDate,
'UpdateDate' => $createDate,
'FromDate' => $chekInDate,
'ToDate' => $validTillDate,
'TotalNights' => $nights,
'StarRating' => $selectStarRating,
'AdultPax' => $noOfAdults,
'ChildPax' => $selectnoOfChild,
'ChildsAge' => $commaSeperatedChildAge,
'InfantPax' => 0,
'CurrencyType' => trim($selectedHotelDetail['CurrencyType']),
'TotalCost' => $finalPriceArray[$i],
'Discounts' => 0,
'Taxes' => 0,
'NetCost' => $netPriceArray,
'MarkUp' => $MarkupArray,
'PetPax' => 0,
'TotalPax' => $totalNoOfChild + $totalNoOfAdult,
'XrefCityId' => $hidden_selected_hotel_cityid,
'IsMarkForDel' => 0,
'IsSelectedOnPkg' => 1,
'IsActive' => 1,
//'InfentPax' => $infant,
);
$lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
//}
########### Start Add Data in Travel Hotel Table ###################
//echo $leadID;
//echo $lastairID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($hotelData);
########### End Add Data in Travel Air Table ###################
}
$emailData = array(
'data' => $hotelValues ? $hotelValues : '',
'customerId' => base64_encode($customersysID),
'noOfAdults' => $totalNoOfAdult,
'noOfChilds' => $totalNoOfChild,
'leadId' => $lastID,
'type' => 'hotelPreviewForm',
'netPrice[]' => $netPriceArray,
'markUp[]' => $MarkupArray,
'finalPrice' => $finalPriceArray,
);
//print_r($emailData);die;
$this->_request->setPost($emailData);
//return $this->_forward("hotel-preview-form", "buyhotel", "module");
// echo $this->_forward('hotel-preview-form', 'buyhotel', null, array('baz' => 'bogus'));
//$this->_request->setPost(array('param_name' => 'paramValue'));
// $this->_helper->redirector('hotel-preview-form','buyhotel',$this->_request->setPost(array('param_name' => 'paramValue')));
//echo $result;
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/buyhotel/');
// render view
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($customersysID);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgentSysId);
//print_r($getCustomerDetail);die;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$getAgentDetail = array('AgentName' => $sessionLogin_user->FirstName . " " . $sessionLogin_user->LastName, 'AgentContact' => $sessionLogin_user->contactnum);
$html->assign('type', 'hotelPreviewEmailFormOnRequest');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('noOfAdults', $totalNoOfAdult);
$html->assign('leadId', $lastID);
$html->assign('MasterTPSysId', $leadID);
$html->assign('noOfChilds', $totalNoOfChild);
$html->assign('data', $hotelValues);
$bodyText = $html->render('email-template.phtml');
$emailId = trim($getCustomerDetail['EmailId']);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($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" => $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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $customersysID);
$msg = "success";
} catch (Exception $err) {
print_r($err, true);
$msg = "failed";
}
echo json_encode(array('status' => $msg));
//end of send email to customer
}
public function leadTodoAction() {
$leadId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$CustomerSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid')));
$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($leadId) && !empty($leadId)) {
$getAllCustomerTODO = $this->_crmcustomerObj->GetAllCustomerToDoByLeadId($CustomerSysId, $leadId);
//echo "<pre>";print_r($getAllLeadRemark);
$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;
$todoTypeArray = array(1 => 'Sales', 2 => 'Payment');
$this->view->todoTypeArray = $todoTypeArray;
$this->view->totalrec = $paginator->getTotalItemCount();
}
}
public function savetododataAction() {
$this->view->layout()->disableLayout();
$post = $this->getRequest()->getPost();
// echo "<pre>";print_r($post);die;
$this->_helper->viewRenderer->setNoRender(true);
$post = $this->getRequest()->getPost();
$TPSysId = $this->_request->getParam('lid') ? $this->_HtmlPurifier->filter($this->_request->getParam('lid')) : '';
$TPIntSysId = $this->_request->getParam('TPIntSysId') ? $this->_HtmlPurifier->filter($this->_request->getParam('TPIntSysId')) : 0;
$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') ? $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')) : '';
$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('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')) : '';
$selectedLeadType = $this->_request->getParam('selectedLeadType') ? $this->_HtmlPurifier->filter($this->_request->getParam('selectedLeadType')) : '';
$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')) : '';
$QueryStage = $this->_request->getParam('QueryStage') ? $this->_HtmlPurifier->filter($this->_request->getParam('QueryStage')) : '';
$reminderday = $this->_request->getParam('reminderday');
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;
}
//}
if ($reminderintype == 'hour') {
$todoreminder = $reminderinvalue * 60;
} else if ($reminderintype == 'day') {
$todoreminder = $reminderinvalue * 60 * 24;
} else {
$todoreminder = $reminderinvalue;
}
$followupchecked = isset($followupchecked) ? (int) $followupchecked : 0;
//$changeQueryStatus = $this->_request->getParam('sid') ? $this->_HtmlPurifier->filter($this->_request->getParam('sid')) : '';
//die('sss');
$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];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$curr_date = date('Y-m-d H:i:s');
$agentID = $sessionLogin_user->intLoggedinUserId;
$TPSysId = base64_decode($TPSysId);
$currentdate = date('Y-m-d');
$reminderday = isset($reminderday) && ($reminderday != '') ? $reminderday : 0;
if ($reminderday != 4) {
$startdate = date('Y-m-d', strtotime($currentdate . " +" . $reminderday . " days"));
}
$data = array(
'TPIntSysId' => $TPIntSysId,
'Subject' => $todosubject,
'StartDateTime' => $curr_date,
'EndDateTime' => $curr_date,
'RelatedTo' => $relatedto,
'IsCompleted' => 1,
'Location' => 0,
'Type' => 3,
'Description' => addslashes($details),
'CustSysId' => $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'TPSysId' => $TPSysId,
'IsActive' => 1,
'IsMarkForDel' => 0,
'AgencySysId' => $AgencySysId,
'CreateDate' => $curr_date,
'UpdateDate' => $curr_date
);
/* end : code added by Ranvir Singh on 6 Oct 2017
* description : if type is 2 (iteration required ) then save : TPSysId
* else save MasterTPSysId
*/
$data['TPSysId'] = !empty($TPSysId) ? $TPSysId : $TPIntSysId;
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$this->_crmcustomertodoObj = new Travel_Model_CRM_AgencyCustomerTodo();
if ($selectedLeadType == 'LEAD' || $selectedLeadType == 'CUSTOMER') {
$data2 = array(
'Subject' => $todosubject,
'StartDateTime' => ($selectedLeadType == 'CUSTOMER') ? trim($startdate . ' ' . $todostartdatetime) : $startdate,
'EndDateTime' => ($selectedLeadType == 'CUSTOMER') ? trim($startdate . ' ' . $todostartdatetime) : $enddate,
'RelatedTo' => $relatedto,
'IsCompleted' => $checked,
'Location' => 0,
'Type' => isset($followupchecked) ? $followupchecked : 0,
'Description' => addslashes($details),
'CustSysId' => $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $assignedto ? $assignedto : $agentID,
'RemindDuration' => $todoreminder,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
// echo "<pre>";print_r($data2);die;
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data2);
//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 ($lastID) {
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($custsysID);
$schedule_time = trim($startdate . ' ' . $todostartdatetime);
$AgentSysId = $assignedto ? $assignedto : $agentID;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$countryCode = (strpos($getCustomerDetail['countrycode'], '+') !== false) ? $getCustomerDetail['countrycode'] : "+" . $getCustomerDetail['countrycode'];
$MobileNumber = trim($countryCode) . '' . trim($getCustomerDetail['Contacts']);
$CustomerfullName = trim($getCustomerDetail['FullName']);
$postData = array(
"UserSysId" => $AgentSysId,
// "IsSchedule" => False,
"schedule_time" => $schedule_time,
"title" => $todosubject,
"body" => "You have a $todosubject with $CustomerfullName at $schedule_time.",
//"IsButton" => True,
"URL" => "dashboard/view-all-to-do",
"IsCall" => True,
"mobileNo" => trim($MobileNumber)
);
if (isset($agentDetails['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($agentDetails['SecurityKey']),
//'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
//echo "<pre>";print_r($response);exit;
}
$response = array('status' => 'success', 'msg' => 'Success');
} else {
$response = array('status' => 'failed', 'msg' => 'Failed');
}
echo json_encode($response);
exit;
} else {
if ($data['TPSysId']) {
$data['IsCompleted'] = 1;
$data['CallType'] = $calltype;
$data['CallStatus'] = $callstatus;
$data['ActionId'] = $TPSysId;
if (trim($todosubject) == 'To Do' && empty($nextstepcall)) {
$data['IsCompleted'] = 0;
$data['StartDateTime'] = trim($startdate . ' ' . $todostartdatetime);
$data['EndDateTime'] = trim($startdate . ' ' . $todostartdatetime);
}
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
//update customer
$date = date('Y-m-d H:i:s');
$userQueryArray = array(
'UpdateDate' => $date,
);
if ($custsysID) {
$whereQuery = "CustomerSysId = " . $custsysID . "";
$updatecustomer = $this->_agencycustomerObj->UpdateAgencyCustomer($userQueryArray, $whereQuery);
}
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($custsysID);
$schedule_time = trim($startdate . ' ' . $todostartdatetime);
$AgentSysId = $assignedto ? $assignedto : $agentID;
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$countryCode = (strpos($getCustomerDetail['countrycode'], '+') !== false) ? $getCustomerDetail['countrycode'] : "+" . $getCustomerDetail['countrycode'];
$MobileNumber = trim($countryCode) . '' . trim($getCustomerDetail['Contacts']);
$CustomerfullName = trim($getCustomerDetail['FullName']);
$postData = array(
"UserSysId" => $AgentSysId,
// "IsSchedule" => False,
"schedule_time" => $schedule_time,
"title" => $todosubject,
"body" => "You have a $todosubject with $CustomerfullName at $schedule_time.",
//"IsButton" => True,
"URL" => "dashboard/view-all-to-do",
"IsCall" => true,
"mobileNo" => trim($MobileNumber)
);
if (isset($agentDetails['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($agentDetails['SecurityKey']),
//'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
//echo "<pre>";print_r($response);exit;
}
#end
// if inserted successfully then do flag true in TB_Agency_Customer_TravelPlan
if ($lastID) {
if ($followupchecked == 2) {
$updateColum = 'hasIteration';
$where = ['TPSysId =?' => $TPSysId];
if ($TPSysId) {
$objCrud = new Insurance_Model_Insurance(); // create object for crud
$objCrud->updateTable('TB_Agency_Customer_TravelPlan', [$updateColum => 1, 'UpdateDate' => $date], $where);
}
} else {
$updateColum = 'hasFollowUp';
//$where = " (MasterTPSysId = {$data['TPSysId']}) or (TPSysId = {$data['TPSysId']}) " ; // pick masterTPSysId to update in all proposal related to this query tp id
$where = ['TPSysId =?' => $TPSysId]; // pick masterTPSysId to update in all proposal related to this query tp id
if ($TPSysId) {
$objCrud = new Insurance_Model_Insurance(); // create object for crud
$objCrud->updateTable('TB_Agency_Customer_TravelPlan_Query', [$updateColum => 1, 'UpdateDate' => $date], $where);
}
}
//$objCrud->updateTable('TB_Agency_Customer_TravelPlan', [ $updateColum => 1,'UpdateDate' => $date ], $where2 );
}
//$this->updateQueryStageAction();
if (!empty($nextstepcall) && $nextstepcall == 1 || $nextstepcall == 2 || $nextstepcall == 3) {
if ($nextstepcall == 1) {
$nexttodosubject = 'Call';
} else if ($nextstepcall == 2) {
$nexttodosubject = 'To Do';
} else {
$nexttodosubject = 'Meeting';
}
$data2 = array(
'TPIntSysId' => $TPIntSysId,
'TPSysId' => !empty($TPSysId) ? $TPSysId : $TPIntSysId,
'Subject' => $nexttodosubject,
'StartDateTime' => trim($startdate . ' ' . $todostartdatetime),
'EndDateTime' => trim($startdate . ' ' . $todostartdatetime),
'RelatedTo' => $relatedto,
'IsCompleted' => isset($checked) && ($checked == 1) ? $checked : 0,
'Location' => 0,
'Type' => 3, // for query
'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' => $TPSysId
);
$this->_crmcustomertodoObj->addAgencyCustomerTodo($data2);
} else if (!empty($nextstepcall) && $nextstepcall == 4) {
$TotalProposal = $this->_request->getParam('Totalproposal');
$pageName = $this->_request->getParam('page_name');
if (!empty($TotalProposal) && $TotalProposal > 0) {
if (!empty($pageName) && $pageName === 'lead_detail') {
$LeadsecureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($TPSysId)), 1);
$redirectLink = "/leaddetail/proposal/id/" . base64_encode($TPSysId) . "/cid/" . base64_encode($custsysID) . "/code/" . $LeadsecureCode;
} else {
$redirectLink = '';
}
$response = array('status' => 'success', 'msg' => 'Success', 'Totalproposal' => $TotalProposal, 'TPSysId' => $TPSysId, 'nextsteptype' => 4, 'redirectLink' => $redirectLink);
echo json_encode($response);
exit;
} else {
$LeadsecureCode = Zend_Controller_Action_HelperBroker::getStaticHelper('SecureCode')->secureCode(trim(base64_encode($TPSysId)), 1);
$redirectLink = "/leaddetail/lead-detail/id/" . base64_encode($TPSysId) . "/cid/" . base64_encode($custsysID) . "/code/" . $LeadsecureCode;
$response = array('status' => 'success', 'msg' => 'Success', 'redirectLink' => $redirectLink, 'Totalproposal' => 0, 'nextsteptype' => 5);
echo json_encode($response);
exit;
}
} else if (!empty($nextstepcall) && $nextstepcall == 5 && !empty($QueryStage)) {
$where = "TPSysId = " . $TPSysId;
$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;
}
if ($lastID) {
$response = array('status' => 'success', 'msg' => 'Success');
} else {
$response = array('status' => 'failed', 'msg' => 'Failed');
}
echo json_encode($response);
exit;
}
}
}
public function saveupdatequerystatusqualityAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysIdType = $this->_request->getParam('TPSysIdType') ? $this->_HtmlPurifier->filter($this->_request->getParam('TPSysIdType')) : '';
$TPSysId = $this->_request->getParam('TPSysId') ? $this->_HtmlPurifier->filter(base64_decode($this->_request->getParam('TPSysId'))) : '';
$LeadQuality = $this->_request->getParam('LeadQuality') ? $this->_HtmlPurifier->filter($this->_request->getParam('LeadQuality')) : '0';
$leadRemarkData = $this->_request->getParam('leadRemarkData') ? $this->_HtmlPurifier->filter($this->_request->getParam('leadRemarkData')) : '';
$stageId = $this->getRequest()->getParam('sid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid')) : '';
$stageId = $this->getRequest()->getParam('sid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid')) : '';
$checkForChangeStatus = '';
if ($stageId) {
$checkForChangeStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->GetTravelPlanStatusName('', $stageId);
}
//print_r($checkForChangeStatus);die;
if ($TPSysId > 0) {
if ($TPSysIdType == 'Query') {
//$update = $this->updateQueryStageAction($TPSysId);
$updateq = $this->updateLeadQualityAction($LeadQuality);
if (isset($leadRemarkData) && !empty($leadRemarkData)) {
$createDate = date('Y-m-d H:i:s');
//$ChangeTPSysId=base64_decode($TPSysId);
$leadDetails = $this->_crmcusttravelplan->CheckCustomerWithLeadId($TPSysId, 'Query');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$remarkArray = array(
'AgencySysId' => $AgencySysId,
'CustomerSysId' => $leadDetails[0]['CustomerSysId'],
'AgentSysId' => $AgentSysId,
'Remarks' => $leadRemarkData,
'TPSysId' => $TPSysId,
'RemarkType' => 1,
'IsActive' => '1',
'CreatedDate' => $createDate,
'IsMarkForDelete' => '0'
);
$saveRemarkRcord = $this->_crmremarkObj->addRemark($remarkArray);
}
} else if ($TPSysIdType == 'Proposal') {
$update = $this->updateProposalStageAction($TPSysId);
$updateq = true;
}
}
//add remark in lead
//#end
$AllLeadQualityStatusName = array(1 => 'hot', 2 => 'warm', 3 => 'cold');
$leadQualityDetails = '';
if (isset($LeadQuality) && $LeadQuality == 1) {
$leadQualityDetails = '<div class="vertical_redline"></div>';
} elseif (isset($LeadQuality) && $LeadQuality == 2) {
$leadQualityDetails = '<div class="vertical_yellowline"></div>';
} elseif (isset($LeadQuality) && $LeadQuality == 3) {
$leadQualityDetails = '<div class="vertical_blueline"></div>';
} else {
$leadQualityDetails = '<div class="vertical_blackline"></div>';
}
//echo $TPSysId;
if ($updateq) {
$response = array('success' => true, 'msg' => 'Status Updated Successfully', 'status' => $checkForChangeStatus, 'ResId' => ($TPSysId), 'leadQualityDetails' => $leadQualityDetails, 'LeadQuality' => $LeadQuality, 'stageId' => $stageId);
} else {
$response = array('success' => false, 'msg' => 'Failed', 'status' => $checkForChangeStatus, 'ResId' => ($TPSysId), 'leadQualityDetails' => $leadQualityDetails, 'LeadQuality' => $LeadQuality, 'stageId' => $stageId);
}
echo json_encode($response);
exit;
}
public function leadViewToDoAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('lid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('lid'))) : '';
$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 = 'updateLeadToDo';
$this->view->id = $todoId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->cid = $CRMCustSysId;
$this->view->lid = $TPSysId;
$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()) {
$editId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$custsysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('customerId')));
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('lid')));
$details = $this->_HtmlPurifier->filter($this->getRequest()->getParam('details'));
$checked = $this->_HtmlPurifier->filter($this->getRequest()->getParam('checked'));
$followupchecked = $this->_HtmlPurifier->filter($this->getRequest()->getParam('followupchecked'));
$todoreminder = $this->_request->getParam('todoreminder') ? $this->_HtmlPurifier->filter($this->_request->getParam('todoreminder')) : '';
// 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');
$todoArray = array(
'Description' => addslashes($details),
'RemindDuration' => $todoreminder,
'IsCompleted' => $checked,
'Type' => isset($followupchecked) ? $followupchecked : 0,
);
if ($editId) {
$cond = ' ToDoSysId=' . $editId . ' and TPSysId=' . $TPSysId . '';
$this->_crmcustomertodoObj = new Travel_Model_CRM_AgencyCustomerTodo();
$customerRcord = $this->_crmcustomertodoObj->UpdateCustomerTodo($todoArray, $cond);
$result = array("status" => "success", 'id' => $editId);
} else {
$result = array("status" => "failed");
}
//return $customerRcord;
echo json_encode($result);
}
}
//this function is used for create encryption key on 6 february 2017 at 3:45 PM
/* public static function getEnc($input){
$filter = new Zend_Filter_Encrypt(array('adapter' => 'mcrypt', 'key' => self::ENC_KEY));
$filter->setVector(self::VECTOR);
$encrypted = $filter->filter($input);
return bin2hex($encrypted); //hints: rawurlencode(..) works
return $encrypted;
}
*/
public function updateProposalQueryAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$leadType = $this->_HtmlPurifier->filter($this->getRequest()->getParam('leadType'));
$MasterTPSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('MasterTPSysId'));
$CustomerSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('CustomerSysId'));
$loopid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('h'));
$ProposalStatusId = base64_decode($this->_HtmlPurifier->filter($this->getRequest()->getParam('ProposalStatusId')));
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
if ($proposalId) {
//update accom table with bookingid
$statusArray = $customhelper->changeQueryStatusByProposal();
$status = $statusArray[$ProposalStatusId];
$wheremaster = "TPSysId = " . $proposalId;
$updatetravelplanMaster = array(
'StatusType' => $ProposalStatusId,
'UpdateDate' => date('Y-m-d H:i:s.0')
);
if ($MasterTPSysId > 0) {
$updateMastertravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($updatetravelplanMaster, $wheremaster);
}
if (isset($status) && !empty($status)) {
$where = "TPSysId = " . $MasterTPSysId;
$updatetravelplan = array(
'StatusType' => $status,
'UpdateDate' => date('Y-m-d H:i:s')
);
//print_r($updatetravelplan);
$updatetravelPlan = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($updatetravelplan, $where);
}
$leadTypeExplode = explode("_", $leadType);
$planType = $leadTypeExplode[0];
if ($planType == 'flight') {
$travelPlanDetail = $this->_crmcusttravelplan->GetFlightproposalDetails($AgencySysId, $proposalId);
$hotelFromDate = $travelPlanDetail[0]['returnDate'];
}
if ($planType == 'hotel') {
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanCustomerDetails($proposalId);
$hotelFromDate = $travelPlanDetail[0]['hotelFromDate'];
}
if ($planType == 'package') {
$travelPlanDetail = $this->_crmcusttravelplan->GetPackageProposalById($proposalId);
$hotelFromDate = $travelPlanDetail[0]['PkgSellValidTill'];
}
if ($planType == 'activity') {
$travelPlanDetail = $this->_crmcusttravelplan->GetCustomerActivityProposal($MasterTPSysId, '', $AgencySysId, $proposalId);
$hotelFromDate = $travelPlanDetail[0]['StartDate'];
}
if ($planType == 'visa') {
$travelPlanDetail = $this->_crmcusttravelplan->GetCustomerVisaProposal($MasterTPSysId, '', $AgencySysId, $proposalId);
$hotelFromDate = $travelPlanDetail[0]['StartDate'];
} else {
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanCustomerDetails($proposalId);
$hotelFromDate = $travelPlanDetail[0]['hotelFromDate'];
}
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/leaddetail/');
$html->assign('type', 'viewHotelProposalStatusDetail');
$html->assign('leadType', $leadType);
$html->assign('TPSysId', $proposalId);
$html->assign('planType', $planType);
$html->assign('MasterTPSysId', $MasterTPSysId);
$html->assign('hotelFromDate', $hotelFromDate);
$html->assign('CustomerSysId', $CustomerSysId);
$html->assign('loopid', $loopid);
$uid = $CustomerSysId . ':' . $proposalId . ':' . $MasterTPSysId;
$display = 'unique:yes';
$uid = $this->getEnc($uid);
$display = $this->getEnc($display);
$html->assign('uid', $uid);
$html->assign('display', $display);
if ($planType == 'package') {
$getPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
if ($ProposalStatusId == 15) {
$paymentMdl = new Payment_Model_Payment();
$paymentMdl->updatelockInventorystatusManual($proposalId, 2);
}
$html->assign('Readymade', $getPlanDetails[0]['Readymade']);
$html->assign('PackSpecType', $getPlanDetails[0]['PackSpecType']);
}
$html->assign('status', $ProposalStatusId);
$bodyText = $html->render('ajax-html.phtml');
$result = array("status" => "success", 'id' => $proposalId, 'msg' => $customhelper->GetTravelPlanStatusName(2, $ProposalStatusId), 'statusArray' => $bodyText, 'newQueryStatus' => $status);
} else {
$result = array("status" => "failed");
}
//return $customerRcord;
echo json_encode($result);
}
}
//resend hotel proposal email to customer created By Er Amit Kumar Dubey on 9 feb 2017 at 1:37 PM
public function sendSingleProposalToCustomerAction() {
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanCustomerDetails($proposalId);
//echo "<pre>";print_r($travelPlanDetail);die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/buyhotel/');
// render view
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($travelPlanDetail[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($travelPlanDetail[0]['AgencySysId']);
//print_r($getCustomerDetail);die;
$uid = $travelPlanDetail[0]['CustomerSysId'] . ':' . $proposalId . ':' . $travelPlanDetail[0]['MasterTPSysId'];
$uid = $this->getEnc($uid);
$display = 'unique:yes';
$display = $this->getEnc($display);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$getAgentDetail = array('AgentName' => $sessionLogin_user->FirstName . " " . $sessionLogin_user->LastName, 'AgentContact' => $sessionLogin_user->contactnum);
$html->assign('type', 'hotelPreviewEmailFormForSingleProposal');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('uid', $uid);
$html->assign('display', $display);
$html->assign('data', $travelPlanDetail);
$bodyText = $html->render('email-template.phtml');
$emailId = trim($getCustomerDetail['EmailId']);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($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" => $proposalId,
"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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $travelPlanDetail[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
//echo "success";
} catch (Exception $err) {
//print_r($err, true);
$result = array("status" => "failed");
//echo "failed";
}
echo json_encode($result);
}
}
//resend flight proposal email to customer created By Er Amit Kumar Dubey on 18 april 2017 at 12:26 PM
public function sendSingleFlightProposalToCustomerAction() {
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$travelPlanDetail = $this->_crmcusttravelplan->GetFlightproposalDetails($AgencySysId, $proposalId);
//echo "<pre>";print_r($travelPlanDetail);die;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
// render view
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($travelPlanDetail[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($travelPlanDetail[0]['AgencySysId']);
$objFlight = new Travel_Model_TblFlight();
$objFlight->strCondition = " TBQAirInvenSysId IN (" . $travelPlanDetail[0]['InvnItemSysId'] . ") ";
$getflightData = $objFlight->getSelectedFlightDetails();
//print_r($getCustomerDetail);die;
$uid = $travelPlanDetail[0]['CustomerSysId'] . ':' . $proposalId . ':' . $travelPlanDetail[0]['MasterTPSysId'];
$uid = $this->getEnc($uid);
$display = 'unique:yes';
$display = $this->getEnc($display);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$getAgentDetail = array('AgentName' => $sessionLogin_user->FirstName . " " . $sessionLogin_user->LastName, 'AgentContact' => $sessionLogin_user->contactnum);
$html->assign('type', 'flightEmailFormForSingleProposal');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('uid', $uid);
$html->assign('display', $display);
$html->assign('data', $getflightData);
$html->assign('travelPlanDetail', $travelPlanDetail);
$bodyText = $html->render('ajax-html.phtml');
$sessionLogin_agnet_details = new Zend_Session_Namespace('sessionLogin_user');
$agentemail = trim($sessionLogin_agnet_details->EmailId);
//$emailSendId=(isset($getAgencyDetail['EmailIdForCustomer']) && !empty($getAgencyDetail['EmailIdForCustomer']) && ($getAgencyDetail['IsEmailIdForCustVarified']==1))?trim($getAgencyDetail['EmailIdForCustomer']):trim($agentemail);
$emailSendId = trim($agentemail);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailId = trim($getCustomerDetail['EmailId']);
$emailData = array('fromEmail' => $this->fromEmail, 'fromName' => $this->fromName, 'subject' => 'Proposal Details', 'to' => array(trim($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" => $proposalId,
"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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $travelPlanDetail[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
//echo "success";
} catch (Exception $err) {
//print_r($err, true);
$result = array("status" => "failed");
//echo "failed";
}
echo json_encode($result);
}
}
//resend BYO package proposal email to customer created By Er Amit Kumar Dubey on 10 feb 2017 at 4:37 PM
public function sendByoPkgProposalToCustomerAction() {
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$pkgtitle = $gettplandataforcustomer[0]['Title'];
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
//$AgentSysId = $this->intLoggedinUserId;
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
//echo "<pre>";print_r($gettplandataforcustomer);die;
$FirstName = $getCustomerDetail['FirstName'];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
if ($gettplandataforcustomer[0]['NetPrice'] == 0 || $gettplandataforcustomer[0]['NetPrice'] == '') {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']); //per person price without discount
}
$booknowurl = $this->baseUrl . '/publicpackage/customerview/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']);
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $gettplandataforcustomer[0]['AgencySysId'];
$aboutpackage = $gettplandataforcustomer[0]['Title'];
$tripaddress = 'NA';
$sentEmail = $gettplandataforcustomer[0]['ProposalEmailTo'];
$AgencyLogo = '';
if (!empty($getAgencyDetail)) {
$AgencyLogo = $getAgencyDetail['Logo'] ? SITE_FULL_URL . 'public/upload/media/agency/' . $getAgencyDetail['AgencySysId'] . '/' . $getAgencyDetail['Logo'] . '' : SITE_FULL_URL . 'public/images/tripsbanklogo.png';
}
$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="http://www.tripsbank.com/"><img src="' . $AgencyLogo . '" alt="Tripsbank" title="Tripsbank" 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>Package price per person - ' . $sentprice . '.</strong> The exact price of the package will be
communicated only once you finalise the itinerary.</td>
</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 />
' . $getAgencyDetail['Title'] . '<br />
' . $getAgencyDetail['ContactInfo'] . '</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 Tripsbank, 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" align="center"><a href="' . FACEBOOK_PAGE . '"><img src="' . $path . '/fb.png" alt="Tripsbank" title="Tripsbank" border="0" /></a> <a href="' . INSTAGRAM . '" ><img src="' . $path . '/instagram.png" alt="Tripsbank" title="Tripsbank" border="0" /></a> <a href="' . TWITTER_PAGE . '"><img src="' . $path . '/twitter.png" alt="Tripsbank" title="Tripsbank" border="0" /></a> <a href="' . LINKEDIN_PAGE . '" ><img src="' . $path . '/in.png" alt="Tripsbank" title="Tripsbank" border="0" /></a></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 © Show Me Trips Private Limited <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" => $proposalId,
"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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $gettplandataforcustomer[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Sent');
} catch (Exception $err) {
$result = array("status" => "failed");
}
echo json_encode($result);
}
}
//resend readymade package proposal email to customer created By Er Amit Kumar Dubey on 10 feb 2017 at 4:37 PM
public function sendReadymadePkgProposalToCustomerAction() {
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$agentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
// echo "<pre>";print_r($gettplandataforcustomer);die;
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$travellers = $totalchild + $totaladult;
// for($i=1;$i<=count($RoomInfoJson);$i++){
// $travellers += $RoomInfoJson[$i]['Adult'];
// $travellers += $RoomInfoJson[$i]['Child'];
// }
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
// $booknowurl = $_SERVER['SERVER_NAME'] . '/publicpackage/view-customer-proposal/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']);
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
// $sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']/$travellers); //per person price without discount
// $sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice'],2);
if ($gettplandataforcustomer[0]['IsShareWithGST'] == 1) {
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice'], 2);
$sentprice1 = round($gettplandataforcustomer[0]['NetPrice'], 2);
} else {
$PackageArray = $gettplandataforcustomer[0];
$totalCost = (float) $PackageArray['NetPrice'] - ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
$sentprice = $CurrSymbol . ' ' . round($totalCost, 2);
$sentprice1 = round($totalCost, 2);
}
}
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($gettplandataforcustomer[0]['TPSysId']), 1);
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']) . '/code/' . $secureCode; // now only 1 url for view package
//added by pooja on 5 sept 2017
$AgentSysId = $gettplandataforcustomer[0]['AgentSysId'];
$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;
}
/* -------------------Added by pooja @20april2017---------------------- */
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $gettplandataforcustomer[0]['AgencySysId'];
if (isset($getAgencyDetail['Logo']) && $getAgencyDetail['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $getAgencyDetail['Logo'];
} else {
$AgencyLogo = $path . '/gtx-logo-white.png';
}
$aboutpackage = $gettplandataforcustomer[0]['EmailText'] ? $gettplandataforcustomer[0]['EmailText'] : '';
//$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? $gettplandataforcustomer[0]['EmailDestination'] :'NA';
$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? trim($gettplandataforcustomer[0]['EmailDestination']) : trim($gettplandataforcustomer[0]['DestinationPlaces']);
$sentEmail = trim($getCustomerDetail['EmailId']);
$custname = $getCustomerDetail['FirstName'] ? $getCustomerDetail['FirstName'] : 'Customer';
$ARR_SALUTION = unserialize(ARR_SALUTION);
$Salutation = isset($ARR_SALUTION[trim($getCustomerDetail['Salutation'])]) ? $ARR_SALUTION[trim($getCustomerDetail['Salutation'])] : '';
$IsEmailIdForCustVarified = trim($getAgencyDetail['IsEmailIdForCustVarified']);
$EmailIdForCustomer = trim($getAgencyDetail['EmailIdForCustomer']);
$PrimaryEmail = trim($getAgencyDetail['PrimaryEmail']);
$AgentEmailId = trim($sessionLogin_user->EmailId);
//$sendersEmailId = ($IsEmailIdForCustVarified == 1) ? $EmailIdForCustomer : $AgentEmailId;
$sendersEmailId = trim($AgentEmailId) ? trim($AgentEmailId) : trim($EmailIdForCustomer);
$agencyDisplayName = (!empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim($getAgencyDetail['Title']);
// echo "<pre>";print_r($gettplandataforcustomer);exit;
if ($gettplandataforcustomer[0]['EconomyMask'] == 8) {
$booknowurlArray[1] = $booknowurl;
$sentpriceArray[1] = $sentprice1;
$params['shared_url'] = $booknowurlArray;
$params['sent_price'] = $sentpriceArray;
} else {
$params['shared_url'] = $booknowurl;
$params['sent_price'] = $sentprice;
}
$params['agency_logo'] = $AgencyLogo;
$params['trip_address'] = $tripaddress;
//total price with currency
$params['price'] = $gettplandataforcustomer[0]['NetPrice']; // 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'] = trim($agentDetail['FirstName']) ? trim(stripslashes($agentDetail['FirstName'])) . " " . stripslashes(trim($agentDetail['LastName'])) : $getAgencyDetail['PrimaryContactName'];
$params['agent_primarycontact'] = $agentDetails['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = !empty($gettplandataforcustomer[0]['ProposalEmailFrom']) ? trim($gettplandataforcustomer[0]['ProposalEmailFrom']) : $sendersEmailId;
$params['agencyDisplayName'] = $agencyDisplayName;
$params['PrimaryEmail'] = $PrimaryEmail;
$params['PackageArray'] = @$gettplandataforcustomer[0];
$params['agentDetails'] = $agentDetails;
$params['TPSysId'] = $gettplandataforcustomer[0]['TPSysId'];
$params['AgentSysId'] = $gettplandataforcustomer[0]['AgentSysId'];
$params['AgencySysId'] = $gettplandataforcustomer[0]['AgencySysId'];
$arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
$params['arrEmailStatisticsType'] = $arrEmailStatisticsType[2];
$params['TourTypeId'] = $gettplandataforcustomer[0]['EconomyMask'];
$params['CurrencySymbol'] = $CurrSymbol;
$params['IsSMSApi'] = $this->IsSMSApi;
// echo "<pre>";print_r($params);die;
$params['GreetingMessage'] = isset($gettplandataforcustomer[0]['GreetingMessage']) ? $gettplandataforcustomer[0]['GreetingMessage'] : 0;
$subject = $Salutation . ' ' . trim($custname) . ' your ' . trim($gettplandataforcustomer[0]['DestinationPlaces']) . ' trip details from ' . $agencyDisplayName;
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->SendProposalToCustomer($sentEmail, $subject, $params);
//send sms to when proposal sent
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
//$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail(trim($sentEmail), $gettplandataforcustomer[0]['AgencySysId']);
$mobile = trim($getCustomerDetail['Contacts']);
$params['customer_contact'] = trim($mobile);
$params['customer_countrycode'] = isset($getcustomerdetails['countrycode']) ? trim($getcustomerdetails['countrycode']) : '';
if (trim($params['customer_contact']) != '') {
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$params['arrSMSStatisticsType'] = $arrSMSStatisticsType[0];
$params['shared_url'] = (isset($params['shared_url']) && is_array($params['shared_url'])) ? $params['shared_url'][1] : $params['shared_url'];
$params['sent_price'] = (isset($params['sent_price']) && is_array($params['sent_price'])) ? $params['sent_price'][1] : $params['sent_price'];
//$smsStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->SendSmsToCustomer($params);
}
//#end of send sms
if ($emailStatus == 1) {
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
} else {
$result = array("status" => "failed");
}
/* ------------------------------------------------- */
echo json_encode($result);
}
}
//cancel API booking
public function cancelHotelBookingAction() {
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
if ($this->_request->isXmlHttpRequest()) {
$API_SOURCE_ID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('API_SOURCE_ID')));
$BOOKING_REFERENCE = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('BOOKING_REFERENCE')));
$REQUEST_TYPE = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('REQUEST_TYPE')));
$CANCELLATION_REMARKS = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('CANCELLATION_REMARKS')));
// $sessionPreBookingHotelDetails = new Zend_Session_Namespace('sessionPreBookingHotelDetails');
$data = array(
"API_SOURCE_ID" => $API_SOURCE_ID,
"BOOKING_REFERENCE_ID" => $BOOKING_REFERENCE,
"REQUEST_TYPE" => $BOOKING_REFERENCE,
"CANCELLATION_REMARKS" => $BOOKING_REFERENCE
);
$arrResponseData = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->cancelHotelBooking($data);
print_r($arrResponseData);
if (!empty($arrResponseData) && empty($arrResponseData['ERROR']['CODE'])) {
$sessionPreBookingHotelDetails->params = $arrResponseData;
$response = array('success' => true, 'msg' => '');
echo json_encode($response);
exit;
} else {
$response = array('success' => false, 'msg' => 'there might be some technical error');
echo json_encode($response);
exit;
}
exit;
}
}
public function bookProposalQueryAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$type = $this->_HtmlPurifier->filter($this->getRequest()->getParam('type'));
$leadType = $this->_HtmlPurifier->filter($this->getRequest()->getParam('leadType'));
$MasterTPSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('MasterTPSysId'));
$CustomerSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('CustomerSysId'));
$loopid = $this->_HtmlPurifier->filter($this->getRequest()->getParam('h'));
$customhelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom');
if ($proposalId) {
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanCustomerDetails($proposalId);
//hit hotel rest api though curl
$getCurrencyObj = new Travel_Model_TblCurrency();
$CurrencyTypeStr = $getCurrencyObj->getCurrencySymbol($travelPlanDetail[0]['CurrencyType']);
$roominfojson = json_decode($travelPlanDetail[0]['RoomMemInfoJson'], 1);
$arrMemberDetails = array();
$arrGRNMemberDetails = array();
if (!empty($roominfojson)) {
$g = 0;
foreach ($roominfojson as $res) {
$adultPax += $res['adult'];
$childPax += $res['child']['childcount'];
$arrMemberDetails[$g]['NoOfAdults'] = $res['adult'];
$arrMemberDetails[$g]['NoOfChild'] = $res['child']['childcount'];
$arrGRNMemberDetails[$g]['AdultPax'] = $res['adult'];
$arrGRNMemberDetails[$g]['ChildPax'] = $res['child']['childcount'];
//$arrMemberDetails[$i]['NoOfChild'] = $memberDetails[$i]['ChildPax'];
if ($res['child']['childcount'] > 0) {
$arrChildAge = explode(",", $res['child']['childage']);
$arrMemberDetails[$g]['ChildAge'] = $arrChildAge;
$arrGRNMemberDetails[$g]['ChildAge'] = $arrChildAge;
} else {
$arrMemberDetails[$g]['ChildAge'] = NULL;
$arrGRNMemberDetails[$g]['ChildAge'] = NULL;
}
$g++;
}
}
if ($travelPlanDetail[0]['hotelStarRating'] > 5) {
$intMaxRating = 5;
$intMinRating = 1;
} else {
$intMaxRating = $travelPlanDetail[0]['hotelStarRating'];
$intMinRating = $travelPlanDetail[0]['hotelStarRating'];
}
if ($travelPlanDetail[0]['ICSourceSysId'] == 3) {
$apiData = array(
'CheckInDate' => $travelPlanDetail[0]['hotelFromDate']->format('d-M-y'),
'NoOfNights' => $travelPlanDetail[0]['hotelTotalNights'],
'CountryCode' => $travelPlanDetail[0]['Countries'],
'CityId' => $travelPlanDetail[0]['hotelXrefCityId'],
'PreferredCurrency' => $travelPlanDetail[0]['CurrencyType'],
'GuestNationality' => $travelPlanDetail[0]['Countries'],
'NoOfRooms' => count($roominfojson),
'PreferredCurrency' => $CurrencyTypeStr,
'PreferredHotel' => $travelPlanDetail[0]['hotelName'],
'RoomGuests' => $arrMemberDetails,
'intMaxRating' => $intMaxRating,
'intMinRating' => $intMinRating,
'IsNearBySearchAllowed' => false,
'ICSourceSysId' => $travelPlanDetail[0]['ICSourceSysId'],
'AgencySysId' => $this->intLoggedinUserAgencySysId,
'UserSysId' => $this->intLoggedinUserId,
);
$apiRes1 = array();
$urlHotel = TBO_HOTEL_API_SEARCH_URL;
$data_stringh = json_encode($datah);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlHotel);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_stringh);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_stringh)
));
$outputH = curl_exec($ch);
$hotelsearch_response = json_decode($outputH, true);
//$intResponseStatus = $response['HotelSearchResult']['ResponseStatus'];
//$intErrorCode = $response['HotelSearchResult']['Error']['ErrorCode'];
//echo "<pre>";print_r($travelPlanDetail);die;
}
if ($travelPlanDetail[0]['ICSourceSysId'] == 4) {
$getApiRooms['hotelTotalRooms'] = count($roominfojson);
$getApiRooms['hotelTotalNights'] = $travelPlanDetail[0]['hotelTotalNights'];
$getApiRooms['hotelFromDateSession'] = $travelPlanDetail[0]['hotelFromDate']->format('d-M-y');
$getApiRooms['hotelToDateSession'] = $travelPlanDetail[0]['hotelToDate']->format('d-M-y');
$getApiRooms['selectNationality'] = $travelPlanDetail[0]['Countries'];
$getApiRooms['countryCode'] = $travelPlanDetail[0]['Countries'];
$getApiRooms['hotelXrefCityId'] = $travelPlanDetail[0]['hotelXrefCityId'];
$getApiRooms['hidden_selected_hotel_id'] = $travelPlanDetail[0]['hotelXrefCityId'];
$getApiRooms['totalMemberCount']['AdultPax'] = $adultPax;
$getApiRooms['totalMemberCount']['ChildPax'] = $childPax;
$getApiRooms['totalMemberCount']['ChildsAge'] = '';
$getApiRooms['memberDetails'] = $arrGRNMemberDetails;
$getApiRooms['hotelStarRating'] = $travelPlanDetail[0]['hotelStarRating'];
$getApiRooms['apiSourceSysId'] = $travelPlanDetail[0]['ICSourceSysId'];
$getApiRooms['strTraceId'] = $strTraceId = $travelPlanDetail[0]['TraceId'];
$getApiRooms['strHotelCode'] = $strHotelCode = $travelPlanDetail[0]['ShortName'];
$hotelsearch_response = Zend_Controller_Action_HelperBroker::getStaticHelper('Hotel')->getApiHotelRoomInfo($getApiRooms);
}
//print_r($hotelsearch_response);die;
//update accom table with bookingid
$leadTypeExplode = explode("_", $leadType);
$planType = $leadTypeExplode[0];
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/leaddetail/');
$html->assign('type', 'viewHotelSearchDetailFromApiTBO');
$uid = $CustomerSysId . ':' . $proposalId . ':' . $MasterTPSysId;
$display = 'unique:yes';
$uid = $this->getEnc($uid);
$display = $this->getEnc($display);
$html->assign('uid', $uid);
$html->assign('apiResponse', $hotelsearch_response);
$html->assign('travelPlanDetail', $travelPlanDetail);
$bodyText = $html->render('ajax-html.phtml');
$result = array("status" => "success", 'id' => $proposalId, 'data' => $bodyText);
} else {
$result = array("status" => "failed");
}
//return $customerRcord;
echo json_encode($result);
}
}
//for save followup data created by Er Amit Kumar Dubey on 27 april 2017 at 3:30 PM
public function savefollowupdataAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->_request->getParam('lid') ? $this->_HtmlPurifier->filter($this->_request->getParam('lid')) : '';
$purpose = $this->_request->getParam('purpose') ? $this->_HtmlPurifier->filter($this->_request->getParam('purpose')) : '';
$followupstartdate = $this->_request->getParam('followupstartdate') ? $this->_request->getParam('followupstartdate') : '';
$followupenddate = $this->_request->getParam('followupenddate') ? $this->_request->getParam('followupenddate') : '';
$custsysID = $this->_request->getParam('custsysID') ? $this->_HtmlPurifier->filter($this->_request->getParam('custsysID')) : '';
$followupdetails = $this->_request->getParam('followupdetails') ? $this->_HtmlPurifier->filter($this->_request->getParam('followupdetails')) : '';
$checked = $this->_request->getParam('checked') ? $this->_HtmlPurifier->filter($this->_request->getParam('checked')) : '';
$followupreminder = $this->_request->getParam('followupreminder') ? $this->_HtmlPurifier->filter($this->_request->getParam('followupreminder')) : '';
$explodefollowupstartdate = explode(' ', $followupstartdate);
$explodetodostartdate = explode('/', $explodefollowupstartdate[0]);
$startdate = $explodetodostartdate[2] . '-' . $explodetodostartdate[1] . '-' . $explodetodostartdate[0] . " " . $explodefollowupstartdate[1];
$explodefollowupenddate = explode(' ', $followupenddate);
$explodetodoenddate = explode('/', $explodefollowupenddate[0]);
$enddate = $explodetodoenddate[2] . '-' . $explodetodoenddate[1] . '-' . $explodetodoenddate[0] . " " . $explodefollowupenddate[1];
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$curr_date = date('Y-m-d');
$agentID = $sessionLogin_user->intLoggedinUserId;
$TPSysId = base64_decode($TPSysId);
$data = array(
'Subject' => $purpose,
'StartDateTime' => $startdate,
'EndDateTime' => $enddate,
'RelatedTo' => '',
'IsCompleted' => $checked,
'Type' => 1,
'Location' => 0,
'Description' => addslashes($followupdetails),
'CustSysId' => $custsysID,
'CreatedBySysId' => $agentID,
'AssignToSysId' => $agentID,
'RemindDuration' => $followupreminder,
'TPSysId' => $TPSysId,
'IsActive' => 1,
'IsMarkForDel' => 0,
);
$this->_crmcustomertodoObj = new Travel_Model_CRM_AgencyCustomerTodo();
$lastID = $this->_crmcustomertodoObj->addAgencyCustomerTodo($data);
if ($lastID) {
$response = array('status' => 'success', 'msg' => 'Success');
} else {
$response = array('status' => 'failed', 'msg' => 'Failed');
}
echo json_encode($response);
exit;
}
public function leadViewFollowUpAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('lid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('lid'))) : '';
$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 = 'updateLeadFollowUp';
$this->view->id = $todoId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->cid = $CRMCustSysId;
$this->view->lid = $TPSysId;
$this->view->data = $getCustomerTODO;
$this->render('ajax-html');
}
}
public function updateFollowupAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isPost()) {
$editId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('id')));
$custsysID = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('customerId')));
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('lid')));
$details = $this->_HtmlPurifier->filter($this->getRequest()->getParam('details'));
$checked = $this->_HtmlPurifier->filter($this->getRequest()->getParam('checked'));
$purpose = $this->_request->getParam('purpose') ? $this->_HtmlPurifier->filter($this->_request->getParam('purpose')) : '';
$followupreminder = $this->_request->getParam('followupreminder') ? $this->_HtmlPurifier->filter($this->_request->getParam('followupreminder')) : '';
$followupstartdate = $this->_request->getParam('followupstartdate') ? $this->_request->getParam('followupstartdate') : '';
$followupenddate = $this->_request->getParam('followupenddate') ? $this->_request->getParam('followupenddate') : '';
$explodefollowupstartdate = explode(' ', $followupstartdate);
$explodetodostartdate = explode('/', $explodefollowupstartdate[0]);
$startdate = $explodetodostartdate[2] . '-' . $explodetodostartdate[1] . '-' . $explodetodostartdate[0] . " " . $explodefollowupstartdate[1];
$explodefollowupenddate = explode(' ', $followupenddate);
$explodetodoenddate = explode('/', $explodefollowupenddate[0]);
$enddate = $explodetodoenddate[2] . '-' . $explodetodoenddate[1] . '-' . $explodetodoenddate[0] . " " . $explodefollowupenddate[1];
// 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');
$todoArray = array(
'Subject' => addslashes($purpose),
'Description' => addslashes($details),
'StartDateTime' => $startdate,
'EndDateTime' => $enddate,
'RemindDuration' => $followupreminder,
'IsCompleted' => $checked,
);
if ($editId) {
$cond = ' ToDoSysId=' . $editId . ' and TPSysId=' . $TPSysId . '';
$this->_crmcustomertodoObj = new Travel_Model_CRM_AgencyCustomerTodo();
$customerRcord = $this->_crmcustomertodoObj->UpdateCustomerTodo($todoArray, $cond);
$result = array("status" => "success", 'id' => $editId);
} else {
$result = array("status" => "failed");
}
//return $customerRcord;
echo json_encode($result);
}
}
public function updateQueryStageAction($TPSysIdCUstom = null) {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$sid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('sid')));
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
$isDisplayProposalStatus = false;
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0 && !empty($stageId)) {
$where = "TPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'StatusType' => $stageId,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArray, $where);
$checkForChangeStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->changeProposalStatusByQuery();
$masterStatusTypeId = isset($checkForChangeStatus[$stageId]) ? $checkForChangeStatus[$stageId] : '';
if (isset($masterStatusTypeId) && !empty($masterStatusTypeId)) {
$where = "MasterTPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'StatusType' => $masterStatusTypeId,
'UpdateDate' => $date,
);
$MasterleadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
//$title=Zend_Controller_Action_HelperBroker::getStaticHelper('Custom')->GetTravelPlanStatusName($type,$stageId);
$isDisplayProposalStatus = true;
}
$msg = "success";
} else {
$msg = "failed";
}
if (!isset($TPSysIdCUstom) && empty($TPSysIdCUstom)) {
echo json_encode(array('status' => $msg, 'title' => '', 'isDisplayProposalStatus' => $isDisplayProposalStatus));
exit;
}
}
public function updateProposalStageAction($TPSysIdCUstom = null) {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$sid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('sid')));
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
$isDisplayProposalStatus = false;
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0 && !empty($stageId)) {
$where = "TPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'StatusType' => $stageId,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
$isDisplayProposalStatus = true;
$msg = "success";
} else {
$msg = "failed";
}
if (!isset($TPSysIdCUstom) && empty($TPSysIdCUstom)) {
echo json_encode(array('status' => $msg, 'title' => '', 'isDisplayProposalStatus' => $isDisplayProposalStatus));
exit;
}
}
public function updateLeadQualityAction($LeadQuality = null) {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$sid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('sid')));
if (isset($LeadQuality) && $LeadQuality >= 0) {
$stageId = $LeadQuality;
} else {
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
}
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
//$MasterTPSysIds = $this->_crmcusttravelplan->GetMasterPlanId($TPSysId, $agencysysID);
$getmasterId = $this->_crmcusttravelplan->CheckCustomerWithLeadId($TPSysId, 'Query');
if (!empty($getmasterId)) {
if ($TPSysId > 0) {
$whereMaster = "TPSysId = $TPSysId";
$date = date('Y-m-d H:i:s');
$userArrayMaster = array(
'LeadQuality' => $stageId,
'UpdateDate' => $date,
);
$leadRcordMatster = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArrayMaster, $whereMaster);
$where = "MasterTPSysId = $TPSysId";
$date = date('Y-m-d H:i:s');
$userArray = array(
'LeadQuality' => $stageId,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
}
}
//print_r($getmasterId);
//print_r($MasterTPSysIds);die;
$msg = "success";
} else {
$msg = "failed";
}
if (!isset($LeadQuality) && empty($LeadQuality)) {
echo json_encode(array('status' => $msg, 'title' => ''));
exit;
} else {
return true;
}
}
// function used for change lead owner or agent for any lead/query created by Er Amit Kumar Dubey on 11 may 2017 at 11:58 AM
public function updateQueryOwnerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('TPSysId'));
$UserSysId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('UserSysId'));
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$where = "TPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'AgentSysId' => $UserSysId,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
$response = array('status' => 'success', 'msg' => 'Record Updated');
} else {
$response = array('status' => 'failed', 'msg' => 'Some thing went wrong.');
}
echo json_encode($response);
exit;
}
//view sent email preview sent to to customer created By Er Amit Kumar Dubey on 26 may 2017 at 01:04 PM
public function viewSentPackageEmailAction() {
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$type = $this->getRequest()->getParam('type');
$result = '';
$booknowurlArr = array();
if ($this->getRequest()->isGet()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
// echo "<pre>";print_r($gettplandataforcustomer);exit;
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$totalHotelOptions = (isset($gettplandataforcustomer[0]['MultiOptions']) && $gettplandataforcustomer[0]['MultiOptions'] != '') ? json_decode($gettplandataforcustomer[0]['MultiOptions'], true) : 1;
$totalHotelOptionCount = is_array($totalHotelOptions) ? count($totalHotelOptions) : 0;
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
//$agentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$agentDetails = $this->_crmcusttravelplan->getAgentDetails($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$objAgency = new Travel_Model_TblAgency();
$getBankDetails = $objAgency->getBankDetailsByAgency($gettplandataforcustomer[0]['AgencySysId']);
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$IsShareWithGST = $gettplandataforcustomer[0]['IsShareWithGST'];
//echo "<pre>";print_r($RoomInfoJson);
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
// $booknowurl = $_SERVER['SERVER_NAME'] . '/publicpackage/view-customer-proposal/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']);
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
// $sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']/$travellers); //per person price without discount
if ($gettplandataforcustomer[0]['EconomyMask'] == 8) {
for ($muy2 = 1; $muy2 <= $totalHotelOptionCount; $muy2++) {
$gettplandataforcustomerMultiOption = $this->_crmcusttravelplan->GetTravelPlanByCustomer($totalHotelOptions[$muy2]);
if ($IsShareWithGST == 1) {
$sentprice[$muy2] = round($gettplandataforcustomerMultiOption[0]['NetPrice'], 2);
} else {
$PackageArray = $gettplandataforcustomerMultiOption[0];
$totalCost = $PackageArray['NetPrice'];
$sentprice[$muy2] = round($totalCost, 2);
$sentpriceTax[$muy2] = (float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount'];
}
}
} else {
if ($IsShareWithGST == 1) {
$sentprice = round($gettplandataforcustomer[0]['NetPrice'], 2);
} else {
$PackageArray = $gettplandataforcustomer[0];
$totalCost = $gettplandataforcustomer[0]['NetPrice'] - ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
$sentprice = round($totalCost, 2);
$sentpriceTax = (float) ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
}
}
}
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($gettplandataforcustomer[0]['TPSysId']), 1);
$booknowurl = Catabatic_Helper::getSiteUrl() . 'publicpackage/view-customer-final-package/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']) . '/code/' . $secureCode; // now only 1 url for view package
// echo $totalHotelOptionCount;exit;
$muy2 = 1;
if (is_array($totalHotelOptions)) {
if ($gettplandataforcustomer[0]['EconomyMask'] == 8) {
foreach ($totalHotelOptions as $totalHotelOptionCountVal) {
$enctpproposalID = base64_encode($totalHotelOptionCountVal);
$secureCode = Catabatic_ValidateCustomer::secureCode($enctpproposalID, 1);
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
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);
}
$booknowurlArr[$muy2] = $booknowurl;
$muy2++;
}
} else {
$MultiOptionsVal = array_values($totalHotelOptions);
$MultiOptionsVal = array_keys($MultiOptionsVal[0]);
$TPArray = $this->_crmcusttravelplan->GetTravelPlanByVersion($gettplandataforcustomer[0]['MasterTPSysId'], $MultiOptionsVal);
foreach ($TPArray as $totalHotelOptionCountKey => $totalHotelOptionCountVal) {
$enctpproposalID = base64_encode($totalHotelOptionCountVal['TPSysId']);
$secureCode = Catabatic_ValidateCustomer::secureCode($enctpproposalID, 1);
$booknowurl = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . $enctpproposalID . '/code/' . $secureCode;
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);
}
$booknowurlArr[$muy2] = $booknowurl;
$muy2++;
}
}
}
// echo "<pre>";print_r($booknowurlArr);exit;
/* -------------------Added by pooja @20april2017---------------------- */
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $gettplandataforcustomer[0]['AgencySysId'];
if (isset($getAgencyDetail['Logo']) && $getAgencyDetail['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $getAgencyDetail['Logo'];
} else {
$AgencyLogo = $path . '/gtx-logo-white.png';
}
$aboutpackage = $gettplandataforcustomer[0]['EmailText'] ? $gettplandataforcustomer[0]['EmailText'] : '';
$GreetingMessage = $gettplandataforcustomer[0]['GreetingMessage'] ? $gettplandataforcustomer[0]['GreetingMessage'] : '';
//$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? $gettplandataforcustomer[0]['EmailDestination'] :'NA';
$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? trim($gettplandataforcustomer[0]['EmailDestination']) : trim($gettplandataforcustomer[0]['DestinationPlaces']);
$sentEmail = $getCustomerDetail['EmailId'];
$ARR_SALUTION = unserialize(ARR_SALUTION);
$custsalutation = (isset($getCustomerDetail['Salutation']) && !empty($getCustomerDetail['Salutation'])) ? $ARR_SALUTION[trim($getCustomerDetail['Salutation'])] : '';
$custname = $getCustomerDetail['FirstName'] ? $custsalutation . ' ' . trim($getCustomerDetail['FirstName']) . ' ' . trim($getCustomerDetail['LastName']) : 'Customer';
$IsEmailIdForCustVarified = trim($getAgencyDetail['IsEmailIdForCustVarified']);
$EmailIdForCustomer = trim($getAgencyDetail['EmailIdForCustomer']);
$PrimaryEmail = trim($getAgencyDetail['PrimaryEmail']);
$AgentEmailId = trim($sessionLogin_user->EmailId);
$sendersEmailId = ($IsEmailIdForCustVarified == 1) ? $EmailIdForCustomer : $AgentEmailId;
$agencyDisplayName = (!empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim($getAgencyDetail['Title']);
$params['agency_logo'] = $AgencyLogo;
$params['AgencySysId'] = $gettplandataforcustomer[0]['AgencySysId'];
$params['trip_address'] = $tripaddress;
$params['shared_url'] = !empty($booknowurlArr) && is_array($booknowurlArr) ? $booknowurlArr : $booknowurl;
//$params['shared_url'] = !empty($booknowurlOne) ? $booknowurlOne:$booknowurl;
if ($gettplandataforcustomer[0]['EconomyMask'] == 8) {
$shared_url = array();
$params['sent_price'] = $sentprice; //total price with currency
$params['sent_price_tax'] = $sentpriceTax; //total price with currency
if (!empty($booknowurlArr)) {
foreach ($booknowurlArr as $eKey => $eval) {
$shared_url[$eKey] = !empty($eval) ? $eval : $booknowurl;
}
$params['shared_url'] = $shared_url;
}
} else {
$params['sent_price'] = $CurrSymbol . ' ' . $sentprice; //total price with currency
}
if ($gettplandataforcustomer[0]['IsB2BProposal'] == 1) {
$gettplandataforcustomer[0]['ExtraMarkUp'] = 0;
}
//echo"<pre>";print_r($getAgencyDetail);die('here');
$params['price'] = $gettplandataforcustomer[0]['NetPrice']; // total price
$params['travelers'] = array('Adults' => $totaladult, 'Child' => $totalchild, 'Infants' => $totalInfant); // travelers to display
$params['cust_name'] = trim($custname);
$params['customer_countrycode'] = ($getCustomerDetail['countrycode']) ? trim($getCustomerDetail['countrycode']) : '';
$params['customer_contact'] = trim($getCustomerDetail['Contacts']);
$params['about_package'] = $aboutpackage;
$params['GreetingMessage'] = $GreetingMessage;
$params['agent_firstname'] = trim($agentDetails['FirstName']) ? stripslashes(trim($agentDetails['FirstName'])) . " " . stripslashes(trim($agentDetails['LastName'])) : $getAgencyDetail['PrimaryContactName'];
$params['agent_primarycontact'] = $agentDetails['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $sendersEmailId;
$params['agencyDisplayName'] = $agencyDisplayName;
$params['b2bagencyDisplayName'] = (isset($gettplandataforcustomer[0]['CompanyName'])) ? $gettplandataforcustomer[0]['CompanyName'] : '';
$params['PrimaryEmail'] = $PrimaryEmail;
$params['PackageArray'] = @$gettplandataforcustomer[0];
$params['IsDayWiseItinerary'] = isset($gettplandataforcustomer[0]['IsDayWiseItinerary']) ? (int) $gettplandataforcustomer[0]['IsDayWiseItinerary'] : 0;
$params['agentDetails'] = $agentDetails;
$params['TourTypeId'] = $gettplandataforcustomer[0]['EconomyMask'];
$params['CurrencySymbol'] = $CurrSymbol;
$params['BankDetails'] = $getBankDetails;
$params['CompanyAddress'] = $getAgencyDetail['CompanyAddress'];
if ($type == 'pdf') {
$params['allowimage'] = 0;
$params['isPdf'] = 1;
}
// echo "<pre>"; print_r($params); die;
$subject = 'Resend Proposal Details';
$emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->ViewEmailProposalForCustomer($sentEmail, $subject, $params);
if ($type == 'pdf') {
$filename = isset($custname) ? str_replace(' ', '-', trim($custname)) : 'package';
$filename = $filename . '-' . ($gettplandataforcustomer[0]['MasterTPSysId']) . '-Proposal';
$image_file = '/images/logo.png';
$html = <<<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
$emailStatus
EOF;
$header = '';
if ($gettplandataforcustomer[0]['PlanType'] == 24) {
$header = '<table border="0" cellspacing="0" cellpadding="0" align="left" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:18px;">
<tbody>
<tr>
<td>
<img src="' . $AgencyLogo . '" alt="" title="" border="0" style="max-height: 68px;"> </td>
</td>
</tr>
</tbody>
</table>';
}
Zend_Controller_Action_HelperBroker::getStaticHelper("DownloadPdf")->byodownloadpdfwithheader($html, $filename, $header);
exit();
} else {
echo $emailStatus;
}
}
}
public function updateLeadSourceAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$sid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('sid')));
$stageId = $this->_HtmlPurifier->filter($this->getRequest()->getParam('sid'));
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$where = "TPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'LeadSourceSysId' => $stageId,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
$msg = "success";
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => ''));
exit;
}
public function updateQueryOtherInfoAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$agencysysID = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$details = $this->_HtmlPurifier->filter($this->getRequest()->getParam('details'));
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$where = "TPSysId = " . $TPSysId;
$date = date('Y-m-d H:i:s');
$userArray = array(
'FullFillmentInfo' => $details,
'UpdateDate' => $date,
);
$leadRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
$msg = "success";
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => ''));
exit;
}
public function viewSmsTemplateToCustomerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$btnType = $this->getRequest()->getParam('btnType') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('btnType')) : '';
if (isset($TPSysId) && !empty($TPSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
if ($btnType == 'QUERY') {
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, 4); //1 for sms 2 for email
} else {
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, array(2, 4, 5, 6, 7, 8, 9)); //1 for sms 2 for email
}
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$getcustomerdetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$GetTravelPlanUploadedDocuments = $getOperationDeptPlanMapData = array();
if ($btnType == 'VISADOC') {
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$GetTravelPlanVisaLeadpaxDeail = $this->_crmcusttravelplan->GetTravelPlanVisaLeadpaxDeail($TPSysId);
$travelPlanDetails[] = $GetTravelPlanVisaLeadpaxDeail;
$GetTravelPlanUploadedDocuments = $this->_crmcusttravelplan->GetTravelPlanUploadedDocuments($TPSysId, 0, 'file', 3);
$OpsAgentSysId = $GetTravelPlanVisaLeadpaxDeail['OpsAgentSysId'];
if ($OpsAgentSysId > 0) {
$getOperationDeptPlanMapData = $agencyStaffObj->getOperationDeptPlanMapData($AgencySysId, 0, $OpsAgentSysId);
} else {
$getOperationDeptPlanMapData = $agencyStaffObj->getOperationDeptPlanMapData($AgencySysId, 6);
}
// echo "<pre>"; print_r($getOperationDeptPlanMapData); die;
} else {
if ($btnType == 'QUERY') {
$travelPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId, 'Query');
} else {
$travelPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId);
}
}
$hostname = $this->getRequest()->getServer('HTTP_HOST');
$isProduction = 0;
if ($hostname == 'demo.tripsbank.com') {
$isProduction = 1;
}
if ($hostname == 'globaltravelexchange.com') {
$isProduction = 2;
}
$link = $this->shorturl_link . base64_encode($TPSysId . '_' . $isProduction . '_1');
$this->view->type = 'ViewSmsTemplate';
$this->view->customerDetails = $getcustomerdetails;
$this->view->agentDetails = $getAgentDetails;
$this->view->agencyDetails = $getAgencyDetail;
$this->view->linkUrl = $link;
$this->view->id = base64_encode($TPSysId);
$this->view->AgencySysId = $AgencySysId;
$this->view->cid = base64_encode($CustomerSysId);
$this->view->data = $getSmsTemplate;
$this->view->travelPlanDetails = $travelPlanDetails;
$this->view->GetTravelPlanUploadedDocuments = $GetTravelPlanUploadedDocuments;
$this->view->getOperationDeptPlanMapData = $getOperationDeptPlanMapData;
$this->view->btnType = $btnType;
$this->render('ajax-html');
}
}
public function sendSmsToCustomerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$tempId = $this->getRequest()->getParam('tempid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tempid'))) : '';
$status = 'failed';
$msg = '';
if (isset($TPSysId) && !empty($TPSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
// $getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($CustomerSysId);
$getcustomerdetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
// print_r($getcustomerdetails);die;
if (!empty($getcustomerdetails)) {
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
//echo "<pre>"; print_r($_SESSION); die;
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$customerName = trim(stripslashes($getcustomerdetails['FirstName']));
$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']);
// $mobile_no = '7727052691';
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, $tempId); //1 for sms 2 for email
//print_r($getSmsTemplate);die;
$link = '';
if (!empty($getSmsTemplate)) {
$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);
if ($travelPlanDetail[0]['PlanType'] == 5) {
$link = $this->baseUrl . '/publicpackage/view-customer-final-package/id/' . base64_encode($TPSysId) . '/code/' . $secureCode;
}
if ($travelPlanDetail[0]['PlanType'] == 6) {
$link = $this->baseUrl . '/proposal/booking-visa-review-customer/mid/' . base64_encode($travelPlanDetail[0]['MasterTPSysId']) . '/tpid/' . base64_encode($travelPlanDetail[0]['TPSysId']);
}
if ($travelPlanDetail[0]['PlanType'] == 7) {
$link = $this->baseUrl . '/proposal/booking-forex-review-customer/mid/' . base64_encode($travelPlanDetail[0]['MasterTPSysId']) . '/tpid/' . base64_encode($travelPlanDetail[0]['TPSysId']);
}
if ($travelPlanDetail[0]['PlanType'] == 8) {
$link = $this->baseUrl . '/proposal/booking-activity-review-customer/mid/' . base64_encode($travelPlanDetail[0]['MasterTPSysId']) . '/tpid/' . base64_encode($travelPlanDetail[0]['TPSysId']);
}
if ($travelPlanDetail[0]['PlanType'] == 9) {
$link = $this->baseUrl . '/proposal/booking-sightseeing-review-customer/mid/' . base64_encode($travelPlanDetail[0]['MasterTPSysId']) . '/tpid/' . base64_encode($travelPlanDetail[0]['TPSysId']);
}
$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";
}
//echo $link;
//$massage = "Your Customer(" . trim($getCustomerDetail['FirstName']) . " " . trim($getCustomerDetail['LastName']) . "-" . trim($getCustomerDetail['Contacts']) . ") has just opened the proposal for ,Click: to view and assist for finalizing.";
$message = trim($getSmsTemplate[0]['Body']);
$message = str_replace('##customername', trim($customerName), $message);
$message = str_replace('##agencyname', $agencyname, $message);
$message = str_replace('##link', $link, $message);
$message = str_replace('##agentname', trim($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);
//echo $message;die;
//$message = "Hi mangal katiyar,\nThanks for shimla trip confirmation. \nPls pay 544 to confirm the trip. You can pay using below link: http://g07.in/MTI5N18w \nFor any query pls feel free to call Prashant at 9015562063.\nThanks\nAgency Private Limited\nTRVCRM";
$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;
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$arrSMSStatistics = array(
"TPSysId" => $TPSysId,
"TypeSysId" => 2, // 1 For Email 2 For SMS
"AgencySysId" => $travelPlanDetail[0]['AgencySysId'],
"AgentSysId" => $travelPlanDetail[0]['AgentSysId'],
"Title" => $message,
"Source" => $arrSMSStatisticsType[0], // 3 For Misc
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
'TemplateSysId' => $tempId,
"CreateDate" => date('Y-m-d H:i:s')
);
// $resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics, $this->IsSMSApi);
// print_r($resultVal);die;
$resultVal['status'] = 'OK';
if (isset($resultVal['status']) && $resultVal['status'] == 'OK') {
$status = 'success';
$msg = "success";
} else {
$msg = "Oops! Please try again";
$status = 'failed';
}
}
$AgencySysId = $this->intLoggedinUserAgencySysId;
}
} else {
$status = 'failed';
}
echo json_encode(array('status' => $status, 'msg' => $msg));
}
public function viewEmailTemplateToCustomerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CRMCustSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
if (isset($TPSysId) && !empty($TPSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getSmsTemplate = $this->_crmcustomertemplateObj->GetAllSmsTemplates(2); //1 for sms 2 for email
$AgencySysId = $this->intLoggedinUserAgencySysId;
//echo "<pre>"; print_r($_SESSION); die;
$AgentSysId = $this->intLoggedinUserId;
$this->view->type = 'ViewEmailTemplate';
$this->view->id = base64_encode($TPSysId);
$this->view->AgencySysId = $AgencySysId;
$this->view->cid = base64_encode($CRMCustSysId);
$this->view->data = $getSmsTemplate;
$this->render('ajax-html');
}
}
public function sendEmailTemplateToCustomerAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$tempId = $this->getRequest()->getParam('tempid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tempid'))) : '';
$status = 'failed';
$msg = '';
$AgentSysId = $this->intLoggedinUserId;
$AgencySysId = $this->intLoggedinUserAgencySysId;
if (isset($TPSysId) && !empty($TPSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($CustomerSysId);
//print_r($getCustomerDetail);
if (!empty($getCustomerDetail) && isset($getCustomerDetail['EmailId']) && trim($getCustomerDetail['EmailId']) != '') {
$emailid = trim($getCustomerDetail['EmailId']);
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(2, $tempId); //1 for sms 2 for email
//print_r($getSmsTemplate);die;
if (!empty($getSmsTemplate)) {
$massage = trim(stripslashes($getSmsTemplate[0]['Body']));
$objAgency = new Travel_Model_TblAgency();
$agencyData = $objAgency->getAgencyDataById($AgencySysId);
$emailSendId = trim($agencyData['PrimaryEmail']);
$fromName = (isset($agencyData['DisplayName']) && !empty($agencyData['DisplayName'])) ? trim($agencyData['DisplayName']) : trim(trim($agencyData['Title']));
$emailId = trim($emailid);
$bodyText = $massage;
$emailData = array('fromEmail' => trim($emailSendId), 'fromName' => trim($fromName), 'subject' => trim(stripslashes($getSmsTemplate[0]['Subject'])), '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" => $proposalId,
"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:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $CustomerSysId);
$status = 'success';
$msg = "Mail Sent";
} catch (Exception $err) {
$status = 'failed';
$msg = "Oops! Please try again";
}
}
}
} else {
$status = 'failed';
}
echo json_encode(array('status' => $status, 'msg' => $msg));
}
//this function used for to get app supplier list for dynamic shared package
public function leadSupplierDetailDynamicAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$leadId = $this->getRequest()->getParam('id') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('id')) : '';
$leadId = base64_decode($leadId);
if (isset($leadId) && !empty($leadId)) {
$this->view->type = 'viewSupplierDynamicDetail';
$leadDetail = $this->_crmcusttravelplan->GetTravelPlanByCustomer($leadId);
$supplierDetails = $this->_crmcusttravelplan->getAllSupplierForDynamicPackageByTpId($leadId);
//print_r($supplierIds);die;
$supplierIds = array();
if (!empty($supplierDetails)) {
for ($i = 0; $i < count($supplierDetails); $i++) {
if ($supplierDetails[$i]['SupplierSysId'] > 0) {
$supplierIds[] = $supplierDetails[$i]['SupplierSysId'];
}
}
$supplierObj = new Travel_Model_CRM_Supplier();
$supplierDetails = $supplierObj->GetSupplierDetailsByIds($supplierIds);
}
$this->view->id = $leadId;
$this->view->leadDetail = $leadDetail;
$this->view->supplierDetails = $supplierDetails;
$this->render('ajax-html');
}
}
public function addBulkQueryAction() {
}
public function saveBulkQueryAction() {
$this->_helper->layout->disableLayout();
$front = Zend_Controller_Front::getInstance();
$front->setParam('noViewRenderer', true);
//echo "<pre>";print_r($_REQUEST);die;
if ($this->getRequest()->isPost()) {
$first_name = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('first_name'));
$last_name = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('last_name'));
$email_id = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('email_id'));
$mobile = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('mobile'));
$queryType = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('queryType'));
$destination = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('destination'));
$hidden_destination = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('hidden_destination'));
$hidden_destination_country = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('hidden_destination_country'));
$query_date = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('query_date'));
$travel_date = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('travel_date'));
$counter = $this->_HtmlPurifier->filterArray($this->getRequest()->getPost('counter'));
$createDate = date('Y-m-d H:i:s');
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$IsB2BAgent = 0;
$passnumber = '';
$custdob = '';
$custanniversary = '';
$intLeadSourceSysId = $this->_crmcustomerObj->getLeadSource($AgencySysId, 'Agency'); // for Master LeadSouce Creation
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$this->_agencycustomerObj = new Travel_Model_CRM_AgencyCustomer();
$leadsource = $intLeadSourceSysId[0]['LeadSourceSysId'];
$roomArrayProposal = array();
$planbookingID = 'Q/' . date('y');
// echo count($first_name);
for ($i = 0; $i < count($first_name); $i++) {
$first_name = trim(stripslashes($first_name[$i]));
$last_name = trim(stripslashes($last_name[$i]));
$email_id = trim(stripslashes($email_id[$i]));
$mobile = trim(stripslashes($mobile[$i]));
$queryType = trim(stripslashes($queryType[$i]));
$destination = trim(stripslashes($destination[$i]));
$country = trim(stripslashes($hidden_destination_country[$i]));
$hidden_destination = explode("__", $hidden_destination[$i]);
$hidden_destination_cityId = trim(stripslashes($hidden_destination[0]));
$hidden_destination_cityName = trim(stripslashes($hidden_destination[1]));
$query_date_exp = explode("/", trim(stripslashes($query_date[$i])));
$query_date_format = $query_date_exp[2] . "-" . $query_date_exp[1] . "-" . $query_date_exp[0];
$travel_date_exp = explode("/", trim(stripslashes($travel_date[$i])));
$travel_date_format = $travel_date_exp[2] . "-" . $travel_date_exp[1] . "-" . $travel_date_exp[0];
$travel_date_format_one_day = date('Y-m-d', strtotime($travel_date_format . ' +1 day'));
$roomArrayProposal[1]['TotalPax'] = 2;
$roomArrayProposal[1]['Adult'] = 2;
$roomArrayProposal[1]['Child'] = 0;
$roomArrayProposal[1]['bedtype'] = 'none';
$roomArrayProposal[1]['departuredate'] = $travel_date[$i];
$roomArrayProposal[1]['returndate'] = '';
$roomArrayProposalRes = json_encode($roomArrayProposal);
$roomaaray[1]['adult'] = 2;
$roomaaray[1]['child']['childcount'] = 0;
$roomaarayinfo = json_encode($roomaaray);
if ($IsB2BAgent != '') {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmailB2B($email_id, $AgencySysId);
} else {
$getcustomerdetails = $this->_crmcustomerObj->GetCustomerDetailsByEmail($email_id, $AgencySysId);
}
//add data
if (empty($getcustomerdetails['CustomerSysId'])) {
if (isset($email_id) && !empty($email_id)) {
if ($IsB2BAgent == 1) {
$customerEmailDetails = $this->_crmcustomerObj->ChkEmailWithResponseB2B($email_id, $AgencySysId);
} else {
$customerEmailDetails = $this->_crmcustomerObj->ChkEmailWithResponse($email_id, $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' => $email_id,
'Salutation' => 1,
'AgencySysId' => $AgencySysId,
'PrimaryContactNumber' => $mobile,
'FullName' => $first_name . " " . $last_name,
'FirstName' => $first_name,
'LastName' => (isset($last_name) && !empty($last_name)) ? $last_name : '',
'LeadSourceSysId' => trim($leadsource),
'ActiveDate' => date('Y-m-d H:i:s'),
'UpdatedDate' => $query_date_format,
'CreatedDate' => $query_date_format,
'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' => $email_id,
'Salutation' => 1,
'PrimaryContactNumber' => $mobile ? $mobile : '',
'FullName' => $first_name . " " . $last_name,
'FirstName' => $first_name ? $first_name : '',
'LastName' => (isset($last_name) && !empty($last_name)) ? $last_name : '',
'LeadSourceSysId' => trim($leadsource),
'ActiveDate' => date('Y-m-d H:i:s'),
'UpdatedDate' => $query_date_format,
'CreatedDate' => $query_date_format,
'IsApproved' => '1',
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//for create new customer
$AgencyCRMLeadSysId = $this->_crmagencyleadaccountObj->addCustomer($userLeadArray);
$agencyuserArray = array(
'AgencySysId' => $AgencySysId,
'AgencyCRMLeadSysId' => $AgencyCRMLeadSysId,
'CRMCustSysId' => $CRMCustSysId,
'EmailId' => $email_id,
'Title' => 1,
'Logo' => '',
'IsfromSM' => '0',
'UserId' => '0',
'CitySysId' => (isset($hidden_destination_cityId) && !empty($hidden_destination_cityId)) ? $hidden_destination_cityId : '',
'StateOrZoneSysId' => 0,
'CountrySysId' => (isset($country) && !empty($country)) ? $country : '',
'IsEmployee' => '0',
'Contacts' => $mobile ? $mobile : '',
'JoinDate' => date('Y-m-d H:i:s'),
'UserName' => $first_name . $last_name,
'FirstName' => (isset($first_name) && !empty($first_name)) ? $first_name : '',
'LastName' => (isset($last_name) && !empty($last_name)) ? $last_name : '',
'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 H:i:s'),
'IsApproved' => '0',
'UpdateDate' => $query_date_format,
'IsActive' => '1',
'IsMarkForDelete' => '0'
);
//print_r($agencyuserArray);die;
### Insert Record in to Agency Table as well ########
$CustomerSysId = $this->_agencycustomerObj->addAgencyCustomer($agencyuserArray);
} else {
$CustomerSysId = $getcustomerdetails['CustomerSysId'];
}
$data = array(
'PlanBookingId' => $this->_HtmlPurifier->filter($planbookingID),
'AgencySysId' => $AgencySysId,
'InventoryType' => 2,
'CreatorSysId' => $AgentSysId,
'AgentSysId' => $AgentSysId,
'StatusType' => 1,
'CustomerSysId' => $CustomerSysId,
'IsCardChrgToCustomer' => 0,
'AdditionalReq' => '000',
'StartDate' => $travel_date_format,
'validTill' => '',
'PlanType' => $queryType,
'Cities' => $destination,
'DestinationPlaces' => $destination,
'DestinationPlacesSysId' => $hidden_destination_cityId,
'RoomInfoJson' => $roomArrayProposalRes,
'Countries' => $country,
'CreateDate' => $createDate,
'StatusType' => 1,
'IsActive' => 1,
'CreateDate' => $query_date_format,
'UpdateDate' => $query_date_format,
'Price' => 0,
'NetPrice' => 0,
'IsAprooved' => 1,
'IsMarkForDel' => 0,
'IsB2Bproposal' => 0
);
$leadID = $this->_crmcusttravelplan->addCustomerTravelPlanQuery($data);
if ($leadID) {
$travelitenary = array(
'TPSysId' => $leadID,
'AgencySysId' => $AgencySysId,
'StartDate' => $travel_date_format,
'IsActive' => 1,
'Sequence' => 1,
'CreateDate' => $query_date_format,
'UpdateDate' => $query_date_format,
'IsMarkForDel' => 0,
);
//$lasttravelitenaryID = $this->_crmcustomertravelItenary->addCustomerTravelItenary($travelitenary);
if ($queryType == 2) { //2 for hotel need to insert data in accom table
$travelitenaryaccomArray = array(
'TPIntSysId' => $lasttravelitenaryID ? $lasttravelitenaryID : 0,
'SeqId' => 0,
'AgencySysId' => $AgencySysId ? $AgencySysId : 0,
'InvnItemSysId' => 2,
'AccoSysId' => 0,
'XrefInvtSysId' => 0,
'RoomType' => 0,
'RoomNumber' => 0,
'Title' => trim($destination),
'CheckInTime' => '',
'CheckOutTime' => '',
'XRefCityId' => $hidden_destination_cityId ? $hidden_destination_cityId : '',
'SourceSysId' => $hidden_destination_cityId ? $hidden_destination_cityId : '',
'FromDate' => $travel_date_format ? $travel_date_format : '',
'ToDate' => $travel_date_format_one_day ? $travel_date_format_one_day : '',
'TotalPax' => $roomArrayProposal[1]['Adult'],
'TotalNights' => 1,
'StarRating' => 0,
'CurrencyType' => 0,
'TotalCostGen' => 0,
'TotalCostSO' => 0,
'TotalCostDO' => 0,
'TotalCostTO' => 0,
'Discounts' => 0,
'Taxes' => 0,
'IsSelectedOnPkg' => 0,
'NetCost' => 0,
'TotalCost' => 0,
'CreateDate' => $query_date_format ? $query_date_format : '',
'UpdateDate' => $query_date_format ? $query_date_format : '',
'RoomMemInfoJson' => $roomaarayinfo,
'AdultPax' => $roomArrayProposal[1]['Adult'],
'ChildPax' => $roomArrayProposal[1]['Child'],
'ChildsAge' => '',
'InfantPax' => 0,
'IsMarkForDel' => 0,
'IsActive' => 1,
);
// echo "<pre>";print_r($travelitenaryaccomArray);
//$tplanitenaryaccomdataID = $this->_crmcusttravelplanHotel->addCustomerTravelPlanHotel($travelitenaryaccomArray);
}
}
}
$response = array('status' => 'success', 'msg' => 'Record added successfully', 'counter' => $counter);
} else {
$response = array('status' => 'failed', 'msg' => 'Something went wrong', 'counter' => $counter);
}
echo json_encode($response);
}
//view booking email to customer . added by Er Amit Kumar Dubey on 10 january 2018 at 04:36 PM
public function viewSentProposalEmailAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$result = '';
if ($this->getRequest()->isGet()) {
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$AgencySysId = $gettplandataforcustomer[0]['AgencySysId'];
$AgentSysId = $gettplandataforcustomer[0]['AgentSysId'];
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$getAgentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$getAgentDetail['IsPaymentGateway'] = $getAgencyDetail['IsPaymentGateway'];
$getAgentDetail['IsB2CSite'] = $getAgencyDetail['IsB2CSite'];
$getAgentDetail['IsB2CSite'] = $getAgencyDetail['Url'];
$sessionFlightSearchParamsDetails = new Zend_Session_Namespace('sessionFlightSearchParamsDetails');
//echo "<pre>";print_r($getAgencyDetail);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$RoomInfoJsonHotel = json_decode($gettplandataforcustomer[0]['RoomInfoJson']);
$RoomInfoJsonNew = $RoomInfoJsonNewm = array();
$g = 0;
foreach ($RoomInfoJsonHotel as $mmbr => $val) {
$RoomInfoJsonNew['AdultPax'] = $val->Adult;
$RoomInfoJsonNew['ChildPax'] = $val->Child;
$RoomInfoJsonNewm[$g] = (object) $RoomInfoJsonNew;
$g++;
}
$RoomInfoJsonNew = (object) $RoomInfoJsonNew;
//$RoomInfoJsonNew=base64_encode(json_encode($RoomInfoJsonNew));
//echo "<pre>";print_r($RoomInfoJsonNewm);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']);
}
//send email
// render view
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
if ($gettplandataforcustomer[0]['PlanType'] == 1) { // for flight
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/flight/');
$subject = 'Hotel Proposal Details';
$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'Signature' => trim($getAgentDetail['Signature']), 'ContactNo1' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$objFlightProposal = new Travel_Model_TblFlightProposal();
$proposalList = $objFlightProposal->getFlightProposalDetails(trim($gettplandataforcustomer[0]['MasterTPSysId']), trim($gettplandataforcustomer[0]['TPSysId']));
$flightValues = $proposalList[0]['AirInvenSysId'];
$objFlight = new Travel_Model_TblFlight();
if (!empty($flightValues)) {
$objFlight->strCondition = " TBQAirInvenSysId IN ($flightValues) ";
$getflightData = $objFlight->getSelectedFlightDetails();
}
$sessionFlightSearchParamsDetails->params['child'] = $totalchild;
$sessionFlightSearchParamsDetails->params['infant'] = $totalInfant;
$sessionFlightSearchParamsDetails->params['adults'] = $totaladult; //IsQuickProposal
if ($getflightData[0]['IsQuickProposal'] == 1) {
$bookingUrl = $this->view->baseUrl('flight-proposal/view-flight-proposal-quick/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']));
} else {
$bookingUrl = $this->view->baseUrl('flight-proposal/view-flight-proposal/id/' . base64_encode($gettplandataforcustomer[0]['MasterTPSysId']));
}
$childDetails = ($sessionFlightSearchParamsDetails->params['child'] > 0) ? ', ' . $sessionFlightSearchParamsDetails->params['child'] . ' Child(ren) ' : '';
$InfantDetails = ($sessionFlightSearchParamsDetails->params['infant'] > 0) ? ', ' . $sessionFlightSearchParamsDetails->params['infant'] . ' Infant' : '';
$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'];
//$proposalList=$this->_crmcusttravelplan->GetPublicPageLeadListForView($gettplandataforcustomer[0]['CustomerSysId'],$AgencySysId,trim($gettplandataforcustomer[0]['TPSysId']),trim($gettplandataforcustomer[0]['MasterTPSysId']));
//echo "Work In Progress...";die;
//echo "<pre>";print_r($proposalList);die;
$html->assign('type', 'flightPreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('getAgencyDetail', $getAgencyDetail);
$html->assign('Origincity', $Origincity);
$html->assign('DestinationCity', $DestinationCity);
$html->assign('departure_date', $proposalList[0]['DepartureTime']);
$html->assign('getflightData', $getflightData);
$html->assign('childDetails', $childDetails);
$html->assign('InfantDetails', $InfantDetails);
$html->assign('sessionFlightSearchParams', $sessionFlightSearchParamsDetails);
$html->assign('isInternational', $proposalList[0]['IsInternational']);
$html->assign('flightValues', $flightValues);
$html->assign('tripType', $proposalList[0]['JourneyType']);
$html->assign('totalCost', $proposalList[0]['TotalCost']);
$html->assign('totalCostArray', $proposalList[0]['TotalCost']);
$html->assign('bookingUrl', $bookingUrl);
echo $bodyText = $html->render('ajax-html.phtml');
}
if ($gettplandataforcustomer[0]['PlanType'] == 2) { // for hotel
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/buyhotel/');
$subject = 'Hotel Proposal Details';
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetPublicProposalWithHotelListByPlanId(trim($gettplandataforcustomer[0]['MasterTPSysId']), trim($gettplandataforcustomer[0]['TPSysId']));
if (empty($proposalList)) {
$proposalList = $this->_crmcusttravelplan->GetTravelPlanCustomerInvHotelDetails(trim($gettplandataforcustomer[0]['TPSysId']));
}
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$MarkUp = 0;
$activityPreviewDetails = array(
'intICSourceSysId' => @$proposalList[$j]['ICSourceSysId'],
'hotelName' => $proposalList[$j]['hotelName'],
'address' => $proposalList[$j]['hotelAddress'],
'cityName' => $proposalList[$j]['hotelCityTitle'],
'title' => $proposalList[$j]['hotelCityTitle'],
'EconomyTypeTitle' => @$proposalList[$j]['EconomyTypeTitle'],
'MealPlanTypeTitle' => @$proposalList[$j]['MealPlanTypeTitle'],
'checkInDate' => $proposalList[$j]['hotelFromDate']->format('d-M-y'),
'checkOutdate' => $proposalList[$j]['hotelToDate']->format('d-M-y'),
'nights' => $proposalList[$j]['hotelTotalNights'],
'CurrencyType' => ($proposalList[$j]['CurrencyType'] != '') ? $proposalList[$j]['CurrencyType'] : 1,
'sessionhotelDirectSearchData' => array('memberDetails' => $RoomInfoJsonNewm)
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$netPriceArray[] = $proposalList[$j]['TotalCost'];
}
$uid = trim($gettplandataforcustomer[0]['CustomerSysId']) . ':' . trim($proposalList[0]['TPSysId']) . ':' . trim($proposalList[0]['MasterTPSysId']);
$uid = $this->getEnc($uid);
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$TotalTaxes[] = 0;
$html->assign('type', 'hotelPreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('netPrice', $netPriceArray);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('noOfAdults', $totaladult);
$html->assign('leadId', $proposalList[0]['TPSysId']);
$html->assign('uid', trim($uid));
$html->assign('MasterTPSysId', $proposalList[0]['MasterTPSysId']);
$html->assign('noOfChilds', $totalchild);
$html->assign('remarks', '');
$html->assign('data', $data);
echo $bodyText = $html->render('email-template.phtml');
}
if ($gettplandataforcustomer[0]['PlanType'] == 6) { // for visa
$subject = 'Visa Proposal Details';
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$proposalList = $this->_crmcusttravelplan->GetCustomerVisaProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
// echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
$objPackage = new Travel_Model_TblPackage();
$getTravelPlanAddonServices = $objPackage->getTravelPlanAddonServicesMultipleIds($gettplandataforcustomer[0]['AgencySysId'], $gettplandataforcustomer[0]['TPSysId'], array(6, 22));
for ($j = 0; $j < count($proposalList); $j++) {
$MarkUp = 0;
$activityPreviewDetails = array(
'VisaType' => @$proposalList[$j]['TourType'],
'VisaCategory' => @$proposalList[$j]['VisaCategory'],
'VisaDuration' => @$proposalList[$j]['VisaDuration'],
'VisaValidity' => @$proposalList[$j]['VisaValidity'],
'VisaName' => $proposalList[$j]['VisaName'],
'PrecessingTime' => $proposalList[$j]['PrecessingTime'],
'BasicRequirementsText' => $proposalList[$j]['BasicRequirementsText'],
'EmbassyAddressText' => $proposalList[$j]['EmbassyAddressText'],
'DocsRequiredText' => $proposalList[$j]['DocsRequiredText'],
'InvnVisaAllSysId' => $proposalList[$j]['InvnVisaAllSysId'],
'DocName1' => $proposalList[$j]['DocName1'],
'DocName2' => $proposalList[$j]['DocName2'],
'DocName3' => $proposalList[$j]['DocName3'],
'DocName4' => $proposalList[$j]['DocName4'],
'DocName5' => $proposalList[$j]['DocName5'],
'DocName6' => $proposalList[$j]['DocName6'],
'DocFileName1' => $proposalList[$j]['DocFileName1'],
'DocFileName2' => $proposalList[$j]['DocFileName2'],
'DocFileName3' => $proposalList[$j]['DocFileName3'],
'DocFileName4' => $proposalList[$j]['DocFileName4'],
'DocFileName5' => $proposalList[$j]['DocFileName5'],
'DocFileName6' => $proposalList[$j]['DocFileName6'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
'markUp' => $proposalList[$j]['MarkUp'],
'XServiceTaxAmount' => $proposalList[$j]['XServiceTaxAmount'],
'VisaRequired' => $proposalList[$j]['VisaRequired'],
'TravelPlanAddonData' => $getTravelPlanAddonServices,
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray = 0;
$TotalTaxes = 0;
$serviceType = 'Visa';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/visa/views/scripts/index/');
$html->assign('type', 'visaPreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('MasterTPSysId', trim($gettplandataforcustomer[0]['MasterTPSysId']));
$html->assign('leadId', trim($proposalId));
$html->assign('data', $data);
$html->assign('visaTravelStartDate', $gettplandataforcustomer[0]['StartDate']->format('d-M-y'));
$html->assign('country', $proposalList[0]['Cities']);
$html->assign('roominfojson', $proposalList[0]['RoomInfoJson']);
echo $bodyText = $html->render('ajax-html.phtml');
}
if ($gettplandataforcustomer[0]['PlanType'] == 8) { //for activity
$subject = 'Activity Proposal Details';
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetCustomerActivityProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($proposalList[0]['AgentSysId']);
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$title = stripslashes(trim($proposalList[$j]['Title']));
$MarkUp = 0;
$activityPreviewDetails = array(
'InvnSysId' => @$proposalList[$j]['TPId'],
'Title' => $proposalList[$j]['Title'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
$arrActivityDetails = array();
if (count($data) == 1) {
$objActivity = new Activity_Model_Activity();
$InvnSysId = @$proposalList[0]['TPId'];
$arrActivityDetails = $objActivity->activityDetailById($InvnSysId);
$subject = $title . " " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
} else {
$subject = "Activity " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
}
// echo "<pre>";print_r($arrActivityDetails);die;
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$TotalTaxes[] = 0;
$serviceType = 'Activity';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/activity/views/scripts/index/');
$html->assign('type', 'PreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('noOfAdults', $RoomInfoJson[1]['TotalPax']);
$html->assign('leadId', $gettplandataforcustomer[0]['TPSysId']);
$html->assign('MasterTPSysId', $gettplandataforcustomer[0]['MasterTPSysId']);
$html->assign('data', $data);
$html->assign('serviceType', $serviceType);
$html->assign('TravelStartDate', $RoomInfoJson[1]['departuredate']);
$html->assign('roominfojson', $gettplandataforcustomer[0]['RoomInfoJson']);
$html->assign('arrActivityDetails', $arrActivityDetails);
echo $bodyText = $html->render('ajax-html.phtml');
}
if ($gettplandataforcustomer[0]['PlanType'] == 9) { // for sightseeing
$subject = 'SightSeeing Proposal Details';
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetCustomerSightSeeingProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($proposalList[0]['AgentSysId']);
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$MarkUp = 0;
$activityPreviewDetails = array(
'InvnSysId' => @$proposalList[$j]['TPId'],
'Title' => $proposalList[$j]['Title'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/sight-seeing/views/scripts/index/');
$TotalTaxes[] = 0;
$serviceType = 'SightSeeing';
$html->assign('type', 'PreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('noOfAdults', $RoomInfoJson[1]['TotalPax']);
$html->assign('leadId', '');
$html->assign('MasterTPSysId', $gettplandataforcustomer[0]['MasterTPSysId']);
$html->assign('data', $data);
$html->assign('serviceType', $serviceType);
$html->assign('TravelStartDate', $RoomInfoJson[1]['departuredate']);
echo $bodyText = $html->render('ajax-html.phtml');
}
if ($gettplandataforcustomer[0]['PlanType'] == 11) { // for sightseeing
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$gettplandataDetail = $this->_crmcusttravelplan->GetCustomerTravelTransportDetail($proposalId);
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$agentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
//echo "<pre>";print_r($gettplandataforcustomer);
$SightSeeings = $this->_crmcusttravelplan->GetCustomerTravelPlanSightSeeingForTransport($proposalId);
$TermConditions = $this->_crmcusttravelplan->GetCustomerTravelPlanTermsCond($proposalId);
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
// echo "<pre>";print_r($RoomInfoJson);die;
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 0; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$IsShareWithGST = $gettplandataforcustomer[0]['IsShareWithGST'];
//echo "<pre>";print_r($RoomInfoJson);
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
// $booknowurl = $_SERVER['SERVER_NAME'] . '/publicpackage/view-customer-proposal/id/' . base64_encode($gettplandataforcustomer[0]['TPSysId']);
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
// $sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']/$travellers); //per person price without discount
if ($IsShareWithGST == 1) {
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice'], 2);
} else {
$PackageArray = $gettplandataforcustomer[0];
$totalCost = $gettplandataforcustomer[0]['NetPrice'] - ((float) $PackageArray['XServiceTaxAmount'] + (float) $PackageArray['AgentServiceTaxAmount'] + (float) $PackageArray['AgentsCustomServiceTaxAmount'] - (float) $PackageArray['ServiceTaxOnCustomDiscount']);
$sentprice = $CurrSymbol . ' ' . round($totalCost, 2);
}
}
$secureCode = Catabatic_ValidateCustomer::secureCode(base64_encode($gettplandataforcustomer[0]['TPSysId']), 1);
$booknowurl = Catabatic_Helper::getSiteUrl() . 'proposal/booking-transport-review-customer/tpid/' . base64_encode($gettplandataforcustomer[0]['TPSysId']) . '/code/' . $secureCode;
/* -------------------Added by pooja @20april2017---------------------- */
$path = SITE_FULL_URL . 'public/assets/images';
$pathAgency = SITE_FULL_URL . 'public/upload/media/agency/' . $gettplandataforcustomer[0]['AgencySysId'];
if (isset($getAgencyDetail['Logo']) && $getAgencyDetail['Logo'] != '') {
$AgencyLogo = $pathAgency . '/' . $getAgencyDetail['Logo'];
} else {
$AgencyLogo = $path . '/gtx-logo-white.png';
}
$aboutpackage = $gettplandataforcustomer[0]['EmailText'] ? $gettplandataforcustomer[0]['EmailText'] : '';
//$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? $gettplandataforcustomer[0]['EmailDestination'] :'NA';
$tripaddress = $gettplandataforcustomer[0]['EmailDestination'] ? trim($gettplandataforcustomer[0]['EmailDestination']) : trim($gettplandataforcustomer[0]['DestinationPlaces']);
$sentEmail = $getCustomerDetail['EmailId'];
$custname = $getCustomerDetail['FirstName'] ? $getCustomerDetail['FirstName'] : 'Customer';
$IsEmailIdForCustVarified = trim($getAgencyDetail['IsEmailIdForCustVarified']);
$EmailIdForCustomer = trim($getAgencyDetail['EmailIdForCustomer']);
$PrimaryEmail = trim($getAgencyDetail['PrimaryEmail']);
$AgentEmailId = trim($sessionLogin_user->EmailId);
$sendersEmailId = ($IsEmailIdForCustVarified == 1) ? $EmailIdForCustomer : $AgentEmailId;
$agencyDisplayName = (!empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim($getAgencyDetail['Title']);
$params['QueryID'] = $gettplandataforcustomer[0]['PlanBookingId'] . '/' . $gettplandataforcustomer[0]['TPSysId'] . '/' . $gettplandataforcustomer[0]['VersionId'];
$params['NoofNights'] = $gettplandataforcustomer[0]['NoofNight'];
$params['SourceCity'] = $gettplandataforcustomer[0]['SourcePlaces'];
$params['DestinationCity'] = $gettplandataforcustomer[0]['DestinationPlaces'];
$params['EmailDestination'] = $gettplandataforcustomer[0]['EmailDestination'];
$params['TravellingOn'] = $gettplandataforcustomer[0]['StartDate']->format('Y-m-d');
$params['TravellingTo'] = $gettplandataforcustomer[0]['ValidTill']->format('Y-m-d');
$params['IsShareWithGST'] = $gettplandataforcustomer[0]['IsShareWithGST'];
$params['Details'] = json_decode($gettplandataforcustomer[0]['Details'], 1);
$params['getCityWiseSS'] = $SightSeeings;
$params['Inclusions'] = $TermConditions[0]['Inclusions'];
$params['Exclusions'] = $TermConditions[0]['Exclusions'];
$params['BookingTerms'] = $TermConditions[0]['BookingTerms'];
$params['TransType'] = $gettplandataDetail[0]['TransType'];
$params['VehicleQty'] = $gettplandataDetail[0]['VehicleQty'];
$params['NetPrice'] = $gettplandataDetail[0]['NetPrice'];
$params['MarkUp'] = $gettplandataDetail[0]['MarkUp'];
$params['agency_logo'] = $AgencyLogo;
$params['trip_address'] = $tripaddress;
$params['shared_url'] = $booknowurl;
$params['sent_price'] = $sentprice; //total price with currency
$params['Price'] = $gettplandataDetail[0]['Price']; // 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'] = trim($agentDetail['FirstName']) ? stripslashes(trim($agentDetail['FirstName'])) . " " . stripslashes(trim($agentDetail['LastName'])) : $getAgencyDetail['PrimaryContactName'];
$params['agent_primarycontact'] = $agentDetail['ContactNo1'];
$params['file_path_location'] = $path;
$params['sendersEmailId'] = $sendersEmailId;
$params['agencyDisplayName'] = $agencyDisplayName;
$params['PrimaryEmail'] = $PrimaryEmail;
$params['PackageArray'] = @$gettplandataforcustomer[0];
$params['agentDetails'] = $agentDetail;
$params['TourTypeId'] = $gettplandataforcustomer[0]['EconomyMask'];
// echo "<pre>"; print_r($params); die;
$subject = 'Resend Proposal Details';
echo $emailStatus = Zend_Controller_Action_HelperBroker::getStaticHelper('EmailTemplate')->ViewEmailTransportProposalForCustomer($sentEmail, $subject, $params);
}
}
}
public function queryArchieveAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$title = '';
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$where = "TPSysId = " . $TPSysId . " AND AgencySysId=" . $AgencySysId . "";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => 1,
'IsActive' => 0,
'UpdateDate' => date('Y-m-d H:i:s'),
);
$customerRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
$msg = "success";
$title = 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
//resend activity proposal email to customer created By Er Amit Kumar Dubey on 18 feb 2018 at 1:40 PM
public function sendActivityProposalToCustomerAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$AgencySysId = $gettplandataforcustomer[0]['AgencySysId'];
$AgentSysId = $gettplandataforcustomer[0]['AgentSysId'];
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$getAgentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$RoomInfoJsonHotel = json_decode($gettplandataforcustomer[0]['RoomInfoJson']);
$RoomInfoJsonNew = array();
foreach ($RoomInfoJsonHotel as $mmbr => $val) {
$RoomInfoJsonNew['AdultPax'] = $val->Adult;
$RoomInfoJsonNew['ChildPax'] = $val->Child;
}
$RoomInfoJsonNew = (object) $RoomInfoJsonNew;
//$RoomInfoJsonNew=base64_encode(json_encode($RoomInfoJsonNew));
//echo "<pre>";print_r((object)$RoomInfoJsonNew);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']);
}
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
//echo "<pre>";print_r($gettplandataforcustomer);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetCustomerActivityProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($proposalList[0]['AgentSysId']);
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$title = stripslashes(trim($proposalList[$j]['Title']));
$MarkUp = 0;
$activityPreviewDetails = array(
'InvnSysId' => @$proposalList[$j]['TPId'],
'Title' => $proposalList[$j]['Title'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
$arrActivityDetails = array();
if (count($data) == 1) {
$objActivity = new Activity_Model_Activity();
$InvnSysId = @$proposalList[0]['TPId'];
$arrActivityDetails = $objActivity->activityDetailById($InvnSysId);
$subject = $title . " " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
} else {
$subject = "Activity " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
}
//echo "<pre>";print_r($arrActivityDetails);die;
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$TotalTaxes[] = 0;
$serviceType = 'Activity';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/activity/views/scripts/index/');
$html->assign('type', 'PreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('noOfAdults', $RoomInfoJson[1]['TotalPax']);
$html->assign('leadId', $gettplandataforcustomer[0]['TPSysId']);
$html->assign('MasterTPSysId', $gettplandataforcustomer[0]['MasterTPSysId']);
$html->assign('data', $data);
$html->assign('serviceType', $serviceType);
$html->assign('TravelStartDate', $RoomInfoJson[1]['departuredate']);
$html->assign('roominfojson', $gettplandataforcustomer[0]['RoomInfoJson']);
$html->assign('arrActivityDetails', $arrActivityDetails);
$bodyText = $html->render('ajax-html.phtml');
$emailId = trim($getCustomerDetail['EmailId']);
$fromEmail = trim($getAgentDetail['EmailId']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailData = array('fromEmail' => $fromEmail, 'fromName' => $fromName, 'subject' => $subject, '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" => $proposalId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $gettplandataforcustomer[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
//echo "success";
} catch (Exception $err) {
//print_r($err, true);
$result = array("status" => "failed");
//echo "failed";
}
echo json_encode($result);
}
//resend visa proposal email to customer created By Er Amit Kumar Dubey on 22 feb 2018 at 05:59 PM
public function sendVisaProposalToCustomerAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$AgencySysId = $gettplandataforcustomer[0]['AgencySysId'];
$AgentSysId = $gettplandataforcustomer[0]['AgentSysId'];
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$getAgentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$RoomInfoJsonHotel = json_decode($gettplandataforcustomer[0]['RoomInfoJson']);
$RoomInfoJsonNew = array();
foreach ($RoomInfoJsonHotel as $mmbr => $val) {
$RoomInfoJsonNew['AdultPax'] = $val->Adult;
$RoomInfoJsonNew['ChildPax'] = $val->Child;
}
$RoomInfoJsonNew = (object) $RoomInfoJsonNew;
//$RoomInfoJsonNew=base64_encode(json_encode($RoomInfoJsonNew));
//echo "<pre>";print_r((object)$RoomInfoJsonNew);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']);
}
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetCustomerVisaProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($proposalList[0]['AgentSysId']);
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$MarkUp = 0;
$activityPreviewDetails = array(
'VisaType' => @$proposalList[$j]['TourType'],
'VisaCategory' => @$proposalList[$j]['VisaCategory'],
'VisaDuration' => @$proposalList[$j]['VisaDuration'],
'VisaValidity' => @$proposalList[$j]['VisaValidity'],
'VisaName' => $proposalList[$j]['VisaName'],
'DocsRequiredText' => $proposalList[$j]['DocsRequiredText'],
'InvnVisaAllSysId' => $proposalList[$j]['InvnVisaAllSysId'],
'PrecessingTime' => $proposalList[$j]['PrecessingTime'],
'BasicRequirementsText' => $proposalList[$j]['BasicRequirementsText'],
'EmbassyAddressText' => $proposalList[$j]['EmbassyAddressText'],
'DocName1' => $proposalList[$j]['DocName1'],
'DocName2' => $proposalList[$j]['DocName2'],
'DocName3' => $proposalList[$j]['DocName3'],
'DocName4' => $proposalList[$j]['DocName4'],
'DocName5' => $proposalList[$j]['DocName5'],
'DocName6' => $proposalList[$j]['DocName6'],
'DocFileName1' => $proposalList[$j]['DocFileName1'],
'DocFileName2' => $proposalList[$j]['DocFileName2'],
'DocFileName3' => $proposalList[$j]['DocFileName3'],
'DocFileName4' => $proposalList[$j]['DocFileName4'],
'DocFileName5' => $proposalList[$j]['DocFileName5'],
'DocFileName6' => $proposalList[$j]['DocFileName6'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
//echo "<pre>";print_r($arrActivityDetails);die;
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$TotalTaxes[] = 0;
$serviceType = 'Visa';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/visa/views/scripts/index/');
$html->assign('type', 'visaPreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('leadId', $gettplandataforcustomer[0]['TPSysId']);
$html->assign('MasterTPSysId', $gettplandataforcustomer[0]['MasterTPSysId']);
$html->assign('data', $data);
$html->assign('serviceType', $serviceType);
$html->assign('visaTravelStartDate', $gettplandataforcustomer[0]['StartDate']->format('d-M-y'));
$html->assign('country', $proposalList[0]['Cities']);
$html->assign('roominfojson', $gettplandataforcustomer[0]['RoomInfoJson']);
$bodyText = $html->render('ajax-html.phtml');
$emailId = trim($getCustomerDetail['EmailId']);
$fromEmail = trim($getAgentDetail['EmailId']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$subject = trim($getCustomerDetail['FirstName']) . " your " . stripslashes(trim($proposalList[0]['Cities'])) . " Visa details from " . $fromName;
$emailData = array('fromEmail' => $fromEmail, 'fromName' => $fromName, 'subject' => $subject, '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" => $proposalId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $gettplandataforcustomer[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
//echo "success";
} catch (Exception $err) {
//print_r($err, true);
$result = array("status" => "failed");
//echo "failed";
}
echo json_encode($result);
}
//resend sightseeing proposal email to customer created By Er Amit Kumar Dubey on 02 feb 2018 at 1:02 PM
public function sendSightseeingProposalToCustomerAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$proposalId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('proposalId')));
$gettplandataforcustomer = $this->_crmcusttravelplan->GetTravelPlanByCustomer($proposalId);
$AgencySysId = $gettplandataforcustomer[0]['AgencySysId'];
$AgentSysId = $gettplandataforcustomer[0]['AgentSysId'];
$getCustomerDetail = $this->_crmcustomerObj->GetCustomerById($gettplandataforcustomer[0]['CustomerSysId']);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($gettplandataforcustomer[0]['AgencySysId']);
$agencyStaffObj = new Travel_Model_TblAgencyStaff();
$getAgentDetail = $agencyStaffObj->getUserDetailsById($gettplandataforcustomer[0]['AgentSysId']);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$RoomInfoJson = json_decode($gettplandataforcustomer[0]['RoomInfoJson'], 1);
$RoomInfoJsonHotel = json_decode($gettplandataforcustomer[0]['RoomInfoJson']);
$RoomInfoJsonNew = array();
foreach ($RoomInfoJsonHotel as $mmbr => $val) {
$RoomInfoJsonNew['AdultPax'] = $val->Adult;
$RoomInfoJsonNew['ChildPax'] = $val->Child;
}
$RoomInfoJsonNew = (object) $RoomInfoJsonNew;
//$RoomInfoJsonNew=base64_encode(json_encode($RoomInfoJsonNew));
//echo "<pre>";print_r((object)$RoomInfoJsonNew);
$totalchild = 0;
$totaladult = 0;
$totalInfant = 0;
for ($k = 1; $k <= count($RoomInfoJson); $k++) {
$totaladult = $totaladult + @$RoomInfoJson[$k]['Adult'];
$totalchild = $totalchild + @$RoomInfoJson[$k]['Child'];
$totalInfant = $totalInfant + @$RoomInfoJson[$k]['Infant'];
}
$travellers = $totalchild + $totaladult;
if ($gettplandataforcustomer[0]['IsPriceShared'] == 0) {
$sentprice = $gettplandataforcustomer[0]['PriceRange'];
} else {
$currencyTypeArr = $this->_crmcusttravelplan->GetCurrencyByCurrencyType($gettplandataforcustomer[0]['CurrencyType']);
$CurrSymbol = $currencyTypeArr['Symbol'];
$sentprice = $CurrSymbol . ' ' . round($gettplandataforcustomer[0]['NetPrice']);
}
//send booking email to customer . added by Er Amit Kumar Dubey on 7 august 2016 at 1:44 PM
$subject = 'SightSeeing Proposal Details';
//echo "<pre>";print_r($agentDetail);die;
//$getAgentDetail = array('AgentName' => trim($getAgentDetail['FirstName']) . " " . trim($getAgentDetail['LastName']), 'AgentContact' => trim($getAgentDetail['ContactNo1']), 'AgentEmailId' => trim($getAgentDetail['EmailId']));
//echo "<pre>";print_r(json_decode($data));die;
$proposalList = $this->_crmcusttravelplan->GetCustomerSightSeeingProposal(trim($gettplandataforcustomer[0]['MasterTPSysId']), '', '', trim($gettplandataforcustomer[0]['TPSysId']));
$getAgentDetail = $this->_crmcusttravelplan->getAgentDetails($proposalList[0]['AgentSysId']);
//echo "<pre>";print_r($proposalList);die;
$mailPrice = array();
for ($j = 0; $j < count($proposalList); $j++) {
$title = stripslashes(trim($proposalList[$j]['Title']));
$MarkUp = 0;
$activityPreviewDetails = array(
'InvnSysId' => @$proposalList[$j]['TPId'],
'Title' => $proposalList[$j]['Title'],
'TravelDate' => $proposalList[$j]['StartDate']->format('d-M-y'),
'totalCost' => $proposalList[$j]['NetPrice'],
);
$data[] = base64_encode(json_encode($activityPreviewDetails));
$mailPrice[] = $proposalList[$j]['NetPrice'];
}
$arrActivityDetails = array();
if (count($data) == 1) {
$objActivity = new Sightseeing_Model_Sightseeing();
$InvnSysId = @$proposalList[0]['TPId'];
$arrActivityDetails = $objActivity->sightSeeingDetailById($InvnSysId);
$subject = $title . " " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
} else {
$subject = "SightSeeing " . $proposalList[0]['DestinationPlaces'] . ' Proposal Details';
}
//echo "<pre>";print_r($arrActivityDetails);die;
$finalPriceArray[] = 0;
$AgencyMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$GTXMarkupArray[] = 0;
$MarkupArray[] = 0;
$TotalTaxes[] = 0;
$serviceType = 'SightSeeing';
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/sight-seeing/views/scripts/index/');
$html->assign('type', 'PreviewEmailForm');
$html->assign('customerDetails', $getCustomerDetail);
$html->assign('agentDetails', $getAgentDetail);
$html->assign('agencyDetails', $getAgencyDetail);
$html->assign('finalPrice', $finalPriceArray);
$html->assign('mailPrice', $mailPrice);
$html->assign('AgencyMarkUp', $AgencyMarkupArray);
$html->assign('GTXmarkUp', $GTXMarkupArray);
$html->assign('markUp', $MarkupArray);
$html->assign('Tax', @$agenttaxPercentage);
$html->assign('TotalTaxes', $TotalTaxes);
$html->assign('noOfAdults', $RoomInfoJson[1]['TotalPax']);
$html->assign('leadId', $gettplandataforcustomer[0]['TPSysId']);
$html->assign('MasterTPSysId', $gettplandataforcustomer[0]['MasterTPSysId']);
$html->assign('data', $data);
$html->assign('serviceType', $serviceType);
$html->assign('TravelStartDate', $RoomInfoJson[1]['departuredate']);
$html->assign('roominfojson', $gettplandataforcustomer[0]['RoomInfoJson']);
//$html->assign('arrSightSeeingDetails',$arrActivityDetails);
$bodyText = $html->render('ajax-html.phtml');
$fromEmail = trim($getAgentDetail['EmailId']);
$fromName = (isset($getAgencyDetail['DisplayName']) && !empty($getAgencyDetail['DisplayName'])) ? trim($getAgencyDetail['DisplayName']) : trim(trim($getAgencyDetail['Title']));
$emailId = trim($getCustomerDetail['EmailId']);
$emailData = array('fromEmail' => $fromEmail, 'fromName' => $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" => $proposalId,
"TypeSysId" => 1, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $bodyText,
"Source" => $arrEmailStatisticsType[0], // 1 For Fresh Proposals
"Status" => 0,
"RefSysId" => "",
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// Added By Pardeep Panchal For Email Count Ends...
$this->mailSentByElastice($emailData, $arrEmailStatistics, 1, $gettplandataforcustomer[0]['CustomerSysId']);
$result = array("status" => "success", 'id' => $proposalId, 'msg' => 'Resent');
//echo "success";
} catch (Exception $err) {
//print_r($err, true);
$result = array("status" => "failed");
//echo "failed";
}
echo json_encode($result);
}
public function viewSmsTemplateToLeadAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$AgencyCRMLeadSysId = $this->getRequest()->getParam('crmid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('crmid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$travelPlanDetails = array();
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, 4); //1 for sms 2 for email
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$getcustomerdetails = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$this->view->type = 'ViewSmsTemplateLead';
$this->view->customerDetails = $getcustomerdetails;
$this->view->agentDetails = $getAgentDetails;
$this->view->agencyDetails = $getAgencyDetail;
$this->view->id = base64_encode($AgencyCRMLeadSysId);
$this->view->TPSysId = $TPSysId;
$this->view->travelPlanDetails = $travelPlanDetails;
$this->view->AgencySysId = $AgencySysId;
$this->view->data = $getSmsTemplate;
$this->view->LeadType = 'LEAD';
$this->render('ajax-html');
}
if (isset($CustomerSysId) && !empty($CustomerSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, array(4, 9, 10)); //1 for sms 2 for email
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$getcustomerdetails = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
if ($TPSysId) {
$travelPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId, 'Query');
}
//echo "<pre>"; print_r($getcustomerdetails); die;
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$this->view->type = 'ViewSmsTemplateLead';
$this->view->LeadType = 'QUERY';
$this->view->customerDetails = $getcustomerdetails;
$this->view->agentDetails = $getAgentDetails;
$this->view->agencyDetails = $getAgencyDetail;
$this->view->id = base64_encode($CustomerSysId);
$this->view->AgencySysId = $AgencySysId;
$this->view->TPSysId = $TPSysId;
$this->view->travelPlanDetails = $travelPlanDetails;
$this->view->data = $getSmsTemplate;
$this->render('ajax-html');
}
}
public function sendSmsToCustomerCrmLeadAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$AgencyCRMLeadSysId = $this->getRequest()->getParam('crmid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('crmid'))) : '';
$tempId = $this->getRequest()->getParam('tempid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tempid'))) : '';
$LeadType = $this->getRequest()->getParam('LeadType') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('LeadType'))) : '';
$TPSysId = (NULL !== $this->getRequest()->getParam('tpid')) ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$status = 'failed';
$msg = '';
$triptitle = '';
$tripdate = '';
$price = '';
$tripaddress = '';
if (isset($AgencyCRMLeadSysId) && !empty($AgencyCRMLeadSysId)) {
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
if ($LeadType == "QUERY") {
$CustomerSysId = $AgencyCRMLeadSysId;
$getCustomerDetail = $this->_crmcustomerObj->GetAgencyCustomerById($CustomerSysId);
$contacts = trim($getCustomerDetail['Contacts']);
if ($TPSysId) {
$travelPlanDetail = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId, 'Query');
if (!empty($travelPlanDetail)) {
$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']));
$NetPrice = round($travelPlanDetail[0]['NetPrice']);
}
}
} else {
$getCustomerDetail = $this->_crmagencyleadaccountObj->GetAgencyLeadCustomerById($AgencyCRMLeadSysId);
$contacts = $getCustomerDetail['PrimaryContactNumber'];
}
//echo "<pre>";print_r($getCustomerDetail);die;
if (!empty($getCustomerDetail) > 0 && isset($contacts) && trim($contacts) != '') {
$AgencySysId = $this->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
//echo "<pre>"; print_r($_SESSION); die;
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$customerName = trim(stripslashes($getCustomerDetail['FirstName']));
$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($contacts);
$link = '';
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, $tempId); //1 for sms 2 for email
//print_r($getSmsTemplate);die;
if (!empty($getSmsTemplate)) {
$updateData = new Payment_Model_Checkotp();
$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'];
}
$objPkgBooking = new Travel_Model_TblPackageBooking();
$message = trim(stripslashes($getSmsTemplate[0]['Body']));
$message = str_replace('##customername', $customerName, $message);
$message = str_replace('##agencyname', $agencyname, $message);
$message = str_replace('##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', '', $message);
$message = str_replace('##refnumber', '', $message);
$message = str_replace('##tripdate', $tripdate, $message);
$message = str_replace('##triptitle', $triptitle, $message);
$message = str_replace('View Trip ', '', $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;
$arrSMSStatisticsType = array_keys(unserialize(ARR_SMS_STATISTICS_TYPE));
$arrSMSStatistics = array(
"TPSysId" => $TPSysId,
"TypeSysId" => 2, // 1 For Email 2 For SMS
"AgencySysId" => $AgencySysId,
"AgentSysId" => $AgentSysId,
"Title" => $message,
"Source" => $arrSMSStatisticsType[0], // 3 For Misc
"Status" => 0,
"RefSysId" => "",
"TemplateSysId" => $tempId,
"RefSysStatus" => "",
"CreateDate" => date('Y-m-d H:i:s')
);
// $resultVal = $updateData->sendSmsDetails($postURL, $this->postFields, $arrSMSStatistics, $this->IsSMSApi);
$resultVal['status'] = 'OK';
//print_r($resultVal);
if (isset($resultVal['status']) && $resultVal['status'] == 'OK') {
$status = 'success';
$msg = "";
} else {
$msg = isset($resultVal['Message']) ? $resultVal['Message'] : '';
$status = 'failed';
}
}
$AgencySysId = $AgencySysId;
}
} else {
$status = 'failed';
}
echo json_encode(array('status' => $status, 'msg' => $msg));
}
public function leadArchieveActiveAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$crmid = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('crmid')));
$title = '';
if (isset($crmid) && !empty($crmid) && is_numeric($crmid) > 0) {
$where = "AgencyCRMLeadSysId = " . $crmid . " AND AgencySysId=" . $AgencySysId . "";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDelete' => 0,
'IsActive' => 1,
'UpdatedDate' => date('Y-m-d H:i:s'),
'LeadStageSysId' => 53
);
$this->_crmagencyleadaccountObj = new Travel_Model_CRM_AgencyLeadAccount();
$customerRcord = $this->_crmagencyleadaccountObj->UpdateCustomer($userArray, $where);
$msg = "success";
$title = 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function queryArchieveActiveAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$TPSysId = $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('TPSysId')));
$title = '';
if (isset($TPSysId) && !empty($TPSysId) && is_numeric($TPSysId) > 0) {
$where = "TPSysId = " . $TPSysId . " AND AgencySysId=" . $AgencySysId . "";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsMarkForDel' => 0,
'IsActive' => 1,
'UpdateDate' => date('Y-m-d H:i:s'),
);
$customerRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlanQuery($userArray, $where);
$msg = "success";
$title = 'NA';
} else {
$msg = "failed";
}
echo json_encode(array('status' => $msg, 'title' => $title));
exit;
}
public function viewTouchPointsAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$travelPlanDetails = array();
$totalplanStatus = array();
$touchPoints = array();
if ($TPSysId) {
$travelPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId, 'Query');
$getAgentDetails = $this->_crmcusttravelplan->getAgentDetails($AgentSysId);
$getAgencyDetail = $this->_crmcustomerObj->GetAgencyDetailById($AgencySysId);
$masterPlanIds = $this->_crmcusttravelplan->GetMasterPlanId($TPSysId, $AgencySysId);
$this->_crmcustomertemplateObj = new Travel_Model_CRM_CustomerTemplate();
array_push($masterPlanIds, $TPSysId);
//echo "<pre>";print_r($masterPlanIds);
$smsCount = $this->_crmcusttravelplan->getSmsCount($masterPlanIds, $AgencySysId, 2); // 2 for SMS
$ToDoCount = $this->_crmcusttravelplan->getToDoCount($masterPlanIds, $AgencySysId, 'To Do'); // To Do
$CallCount = $this->_crmcusttravelplan->getToDoCount($masterPlanIds, $AgencySysId, 'Call'); // Call
$MeetingCount = $this->_crmcusttravelplan->getToDoCount($masterPlanIds, $AgencySysId, 'Meeting'); // Meeting
$planStatusArray = $this->_crmcusttravelplan->GetTravelPlanStatusById($masterPlanIds, $AgencySysId);
$remarksArray = $this->_crmcusttravelplan->GetLeadRemarkById($masterPlanIds, $AgencySysId);
$emailData = $this->_crmcusttravelplan->getSentEmailByPlanId($masterPlanIds, $AgencySysId, 1); // 1 for Email
$smsData = $this->_crmcusttravelplan->getSentEmailByPlanId($masterPlanIds, $AgencySysId, 2); // 2 for SMS
$todoFollowupData = $this->_crmcusttravelplan->getToDoFollowUpByPlanId($masterPlanIds, $AgencySysId, ''); // 1 for Email
// echo "<pre>";print_r($todoFollowupData); die();
foreach ($planStatusArray as $key => $value) {
$touchPoints[] = array(
'Type' => 'StatusType',
'Date' => $value['CreateDate']->format('d-M-y H:i'),
'UpdateDate' => $value['UpdateDate']->format('d-M-y H:i:s'),
'originalDate' => $value['CreateDate']->format('Y-m-d H:i:s'),
'StatusType' => $value['StatusType'],
'MasterTPSysId' => $value['MasterTPSysId'],
'Title' => '',
'Subject' => '',
'Description' => '',
'Remarks' => '',
);
}
foreach ($remarksArray as $key => $value) {
$touchPoints[] = array(
'Type' => 'Remarks',
'Date' => $value['CreatedDate']->format('d-M-y H:i'),
'originalDate' => $value['CreatedDate']->format('Y-m-d H:i:s'),
'StatusType' => '',
'Title' => '',
'Subject' => '',
'Description' => '',
'Remarks' => $value['Remarks'],
'UpdatedBy' => trim($value['UpdatedBy'])
);
}
foreach ($emailData as $key => $value) {
if (($value['Source'] == 1 && $value['CustomerSysId'] == 0) || ($value['Title'] == 'Proposal Details')) {
} else {
$touchPoints[] = array(
'Type' => 'Email',
'Date' => $value['CreateDate']->format('d-M-y H:i'),
'originalDate' => $value['CreateDate']->format('Y-m-d H:i:s'),
'StatusType' => '',
'Title' => $value['Title'],
'Subject' => '',
'Description' => '',
'Remarks' => ''
);
}
}
foreach ($smsData as $key => $value) {
$subject = '';
if ($value['TemplateSysId']) {
$getSmsTemplate = $this->_crmcustomertemplateObj->GetSmsTemplateById(1, $value['TemplateSysId']); //1 for sms 2 for email
$subject = trim(stripslashes($getSmsTemplate[0]['Subject']));
}
$touchPoints[] = array(
'Type' => 'SMS',
'Date' => $value['CreateDate']->format('d-M-y H:i'),
'originalDate' => $value['CreateDate']->format('Y-m-d H:i:s'),
'StatusType' => '',
'Title' => $value['Title'],
'Subject' => $subject,
'Description' => '',
'Remarks' => ''
);
}
foreach ($todoFollowupData as $key => $value) {
if ($value['Type'] == 0) {
$subject = "To-Do";
} else {
$subject = "Follow-Up";
}
$touchPoints[] = array(
'Type' => 'ToDoFollowUp',
'Date' => $value['CreateDate']->format('d-M-y H:i'),
'originalDate' => $value['EndDateTime']->format('Y-m-d H:i:s'),
'EndDateTime' => $value['EndDateTime']->format('d-M-y H:i'),
'StatusType' => '',
'Title' => @$value['Subject'],
'Subject' => $subject,
'Description' => $value['Description'],
'UpdatedBy' => $value['UpdatedBy'],
'Remarks' => '',
'IsCompleted' => $value['IsCompleted'],
'CallType' => $value['CallType'],
'CallStatus' => $value['CallStatus'],
);
}
//sort by date
foreach ($touchPoints as $key => $part) {
$sort[$key] = strtotime($part['originalDate']);
//$sort[$key] = strtotime($part[$columnNameOrder]->format('Y-m-d H:i:s'));
}
if (!empty($touchPoints)) {
array_multisort($sort, SORT_DESC, $touchPoints);
}
$this->view->touchPoints = $touchPoints;
//echo "<pre>";print_r($touchPoints);
//$this->view->todoFollowupData=$todoFollowupData;
//$this->view->remarksArray=$remarksArray;
//$this->view->planStatusArray=$planStatusArray;
$this->view->agentDetails = $getAgentDetails;
$this->view->smsCount = $smsCount;
$this->view->ToDoCount = $ToDoCount;
$this->view->CallCount = $CallCount;
$this->view->MeetingCount = $MeetingCount;
//$this->view->emailData=$emailData;
$this->view->agencyDetails = $getAgencyDetail;
}
//echo "<pre>"; print_r($getcustomerdetails); die;
$this->view->type = 'ViewTouchPoints';
$this->view->id = base64_encode($TPSysId);
$this->view->travelPlanDetails = $travelPlanDetails;
$this->render('ajax-html');
}
public function getExistingRemarksAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$remarksArray = array();
if ($TPSysId) {
$remarksArray = $this->_crmcusttravelplan->GetLeadRemarkById($TPSysId, $AgencySysId);
}
$this->view->id = $TPSysId;
$this->view->type = 'getExistingRemarks';
$this->view->remarksArray = $remarksArray;
$this->render('ajax-html');
}
public function getqueryLastFollowupAction() {
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$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;
$remarksArray = array();
if ($TPSysId) {
$remarksArray = $this->_crmcusttravelplan->GetLeadLastFollowupsByTPSysId($TPSysId, $AgencySysId, $type);
}
$this->view->id = $TPSysId;
$this->view->type = 'getqueryLastFollow';
$this->view->remarksArray = $remarksArray;
$this->render('ajax-html');
}
public function viewCreateEmiAction() {
$this->view->layout()->disableLayout();
// $this->_helper->viewRenderer->setNoRender(true);
$TPSysId = $this->getRequest()->getParam('tpid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('tpid'))) : '';
$CustomerSysId = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter(base64_decode($this->getRequest()->getParam('cid'))) : '';
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$AgentSysId = $this->intLoggedinUserId;
$travelPlanDetails = array();
$totalplanStatus = array();
$travelPlanEMIData = array();
$touchPoints = array();
if ($TPSysId) {
$travelPlanDetails = $this->_crmcusttravelplan->GetTravelPlanByCustomer($TPSysId);
$travelPlanEMIData = $this->_crmcusttravelplan->GetCustomerTravelPlanEMIData($TPSysId);
}
$this->view->id = $TPSysId;
$this->view->CustomerSysId = $CustomerSysId;
$this->view->AgencySysId = $AgencySysId;
$this->view->AgentSysId = $AgentSysId;
$this->view->travelPlanDetails = $travelPlanDetails;
$this->view->travelPlanEMIData = $travelPlanEMIData;
$this->view->baseUrl = $this->baseUrl;
$objPkgBooking = new Travel_Model_TblPackageBooking();
$amountPaid = $objPkgBooking->getAmountPaidForProposalByTPSysId($TPSysId);
$objPkg = new Travel_Model_TblPackage();
$flexiPackageList = $objPkg->getCustPackageList($TPSysId);
$flexiPackageList['NetPrice'] = $flexiPackageList['NetPrice'] + $flexiPackageList['TotalCostGen'];
// echo "<pre>";print_r($amountPaid);die;
$exchangerate = $objPkg->currencyExchangeRate(1, 1);
$PlanTypeArr = array(21);
$TblPackage = new Travel_Model_TblPackage();
$addonsData = $TblPackage->getTravelPlanAddonServicesMultipleIds($AgencySysId, $TPSysId, $PlanTypeArr);
$addonDataPrice = isset($addonsData[0]['Tax']) ? $addonsData[0]['Tax'] : 0;
$totalPrice = $flexiPackageList['NetPrice'] + $addonDataPrice;
$finalPackageCostWith_extramarkupNdiscount = $packageBaseCurrencyNetPrice = Zend_Controller_Action_HelperBroker::getStaticHelper('Package')->convertRatetoBaseCurrency($totalPrice, $exchangerate);
// echo "<pre>";print_r($finalPackageCostWith_extramarkupNdiscount);die;
$this->view->amountPaid = (isset($amountPaid['TotalAmountPaid']) && trim($amountPaid['TotalAmountPaid']) != '') ? (int) $amountPaid['TotalAmountPaid'] : 0;
$this->view->amountPaidSymbol = (isset($amountPaid['Symbol']) && trim($amountPaid['Symbol']) != '') ? trim($amountPaid['Symbol']) : '';
$this->view->packageBaseCurrencyNetPrice = (isset($packageBaseCurrencyNetPrice)) ? $packageBaseCurrencyNetPrice : 0;
}
public function saveEmiDataAction() {
$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;
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
// echo "<pre>";print_r($param);die;
$objCrud = new Insurance_Model_Insurance();
$TPSysId = $param['TPSysId'];
$CustomerSysId = $param['CustomerSysId'];
$travelPlanEMIData = $this->_crmcusttravelplan->GetCustomerTravelPlanEMIData($TPSysId);
if (!empty($travelPlanEMIData)) {
$objCrud->deleteRow('TB_Agency_Customer_Trx_Emi', array('TPSysId =?' => $TPSysId, 'TrxStatus =?' => 0));
}
if (!empty($param['emiDate'])) {
foreach ($param['emiDate'] as $eKey => $eVal) {
$emiDate = explode('/', $eVal);
$emiDateFinal = $emiDate[2] . '-' . $emiDate[1] . '-' . $emiDate[0];
$RemindersSMS = (isset($param['RemindersSMS']) && $param['RemindersSMS'] != '') ? $param['RemindersSMS'] : 0;
$RemindersEmail = (isset($param['RemindersEmail']) && $param['RemindersEmail'] != '') ? $param['RemindersEmail'] : 0;
$sendReminders = array('RemindersSMS' => $RemindersSMS, 'RemindersEmail' => $RemindersEmail);
$RemindersBefore = isset($param['RemindersBefore']) ? implode(',', $param['RemindersBefore']) : '';
$RemindersJson = json_encode(array('RemindersSMS' => $RemindersSMS, 'RemindersEmail' => $RemindersEmail, 'RemindersBefore' => $RemindersBefore));
$saveDataArray = [
'AgencySysId' => $param['AgencySysId'],
'UserSysId' => $param['AgentSysId'],
'TPSysId' => $TPSysId,
'CustomerSysId' => $param['CustomerSysId'],
'XRefTrxNo' => '',
'MPSysId' => (int) $param['MPSysId'],
'InvoiceId' => '',
'RecieptNo' => '',
'TrxDate' => date('Y-m-d H:i:s'),
'EmiDate' => $emiDateFinal,
'TrxType' => 0,
'PaymentModeType' => 0,
'TrxPayMediaType' => 0,
'CurrencyType' => (int) $param['CurrencyType'],
'Amount' => $param['emiAmount'][$eKey],
'PaidAmount' => 0,
'TrxStatus' => 0,
'IsActive' => 1,
'RemindersJson' => $RemindersJson,
'RemindersSMS' => $RemindersSMS,
'RemindersEmail' => $RemindersEmail,
];
// echo "<pre>";print_r($saveDataArray);die;
try {
$objCrud->insertTable('TB_Agency_Customer_Trx_Emi', $saveDataArray);
$where = "TPSysId = " . $TPSysId . " AND AgencySysId=" . $AgencySysId . "";
$date = date('Y-m-d H:i:s');
$userArray = array(
'IsSetEmi' => 1,
'UpdateDate' => date('Y-m-d H:i:s'),
);
$customerRcord = $this->_crmcusttravelplan->UpdateCustomerTravelPlan($userArray, $where);
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
echo json_encode(array('status' => true, 'TPSysId' => $TPSysId, 'CustomerSysId' => $CustomerSysId));
exit;
}
}
}
public function callsAction() {
$this->_helper->layout->disableLayout();
$contactNumber = $this->getRequest()->getParam('cid') ? $this->_HtmlPurifier->filter($this->getRequest()->getParam('cid')) : '';
if ($contactNumber != '') {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$AgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$SecurityKey = $sessionLogin_user->agencyDetails['SecurityKey'];
$contact_number = base64_decode($contactNumber);
$url = "https://logs.hellogtx.com/api/v1/call-center/?security_key=$SecurityKey&contact_number=$contact_number";
$webservicesModel = new Gtxwebservices_Model_Webservices();
$getData = $webservicesModel->sendInfo($url);
//echo "<pre>";print_r($getData);exit;
$this->view->agencySysId = $AgencySysId;
$this->view->getData = $getData;
}
}
}