| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/modules/marketing/controllers/ |
Upload File : |
<?php
class Marketing_CouponController extends Catabatic_ValidateGtx {
private $baseUrl = '';
private $reportMdl = '';
private $roleID = 0;
private $ReportingToSysId = 0;
private $intLoggedinUserId = 0;
private $intLoggedinUserAgencySysId = 0;
private $intLoggedinUserTrxCurrency = 0;
private $DIR_WRITE_MODE = 0;
private $COUPON_CODE_API = '';
public $CurrencySymbol = '';
private $paymentMdl = '';
private $_crmcustomerObj = '';
private $_agencyuserroleObj = '';
public $COUPON_HISTORY_CODE_API = '';
public function init() {
parent::init();
$aConfig = $this->getInvokeArg('bootstrap')->getOptions();
$BootStrap = $aConfig['bootstrap'];
$this->baseUrl = $BootStrap['siteUrl'];
$this->reportMdl = new Marketing_Model_Marketing();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$this->roleID = $sessionLogin_user->UserRole;
$this->ReportingToSysId = $sessionLogin_user->ReportingToSysId;
$this->intLoggedinUserId = $sessionLogin_user->intLoggedinUserId;
$this->intLoggedinUserAgencySysId = $sessionLogin_user->intLoggedinUserAgencySysId;
$this->intLoggedinUserTrxCurrency = $sessionLogin_user->intLoggedinUserTrxCurrency;
$this->CurrencySymbol = isset($sessionLogin_user->agencyDetails['Symbol'])?$sessionLogin_user->agencyDetails['Symbol']:'INR';
$this->DIR_WRITE_MODE = 0777;
$this->COUPON_CODE_API = COUPON_CODE_API;
$this->paymentMdl = new Payment_Model_Payment();
$this->_crmcustomerObj = new Travel_Model_CRM_Customer();
// error_reporting(E_ALL);
}
public function indexAction() {
$this->view->baseUrl = $this->baseUrl;
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$SecurityKey = $sessionLogin_user->agencyDetails['SecurityKey'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->COUPON_CODE_API . '?SecurityKey=' . $SecurityKey);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
$response = curl_exec($ch);
$resultset = json_decode($response, 1);
// echo "<pre>";print_r($resultset);die;
$this->view->page = $page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($resultset['results']);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
}
public function addCouponAction() {
// $this->_helper->layout->disableLayout();
$this->view->baseUrl = $this->baseUrl;
$TblCurrency = new Travel_Model_TblCurrency();
$this->view->Currency = $Currency = $TblCurrency->getCurrencyTypes();
$this->view->intLoggedinUserTrxCurrency = $this->intLoggedinUserTrxCurrency;
$this->view->CurrencySymbol = $this->CurrencySymbol;
$this->view->id = $id = ($this->getRequest()->getParam('id')) ? base64_decode($this->getRequest()->getParam('id')) : '';
$resultset = array();
if (isset($id) && !empty($id)) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->COUPON_CODE_API . $id . "/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$resultset = json_decode($response, 1);
}
// echo "<pre>";print_r($resultset);die;
$this->view->resultset = $resultset;
$objPackage = new Travel_Model_TblPackage();
$objPackage->searchArr = array('IsMaster' => 1);
$packageList = $objPackage->getPackageList($this->intLoggedinUserAgencySysId);
$this->view->packageList = $packageList;
//echo "<pre>";print_r($packageList);die;
}
public function saveCouponDataAction() {
$this->_helper->layout->disableLayout();
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$SecurityKey = $sessionLogin_user->agencyDetails['SecurityKey'];
$intLoggedinUserAgencySysId = $this->intLoggedinUserAgencySysId;
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
// echo "<pre>";
// print_r($param);
// die;
$id = (isset($param['id']) && !empty($param['id'])) ? $param['id'] : '';
$DiscountName = (isset($param['DiscountName']) && !empty($param['DiscountName'])) ? $param['DiscountName'] : '';
$DiscountType = (isset($param['DiscountType']) && !empty($param['DiscountType'])) ? $param['DiscountType'] : '';
$DiscountValue = (isset($param['DiscountValue'][$DiscountType]) && !empty($param['DiscountValue'][$DiscountType])) ? $param['DiscountValue'][$DiscountType] : '';
$DiscountValue1 = (isset($param['DiscountValue1'][$DiscountType]) && !empty($param['DiscountValue1'][$DiscountType]) && $DiscountType == 4) ? $param['DiscountValue1'][$DiscountType] : 0;
$ProductType = (isset($param['ProductType']) && !empty($param['ProductType'])) ? $param['ProductType'] : '';
$CustomerEligibilityType = (isset($param['CustomerEligibilityType']) && !empty($param['CustomerEligibilityType'])) ? $param['CustomerEligibilityType'] : '';
$CriteriaValue = (isset($param['CriteriaValue']) && !empty($param['CriteriaValue'])) ? $param['CriteriaValue'] : '';
$NoofUsage = (isset($param['CriteriaValue']) && !empty($param['NoofUsage'])) ? $param['NoofUsage'] : '';
$LimitPerCustomer = (isset($param['LimitPerCustomer']) && !empty($param['LimitPerCustomer'])) ? $param['LimitPerCustomer'] : 0;
$FromActiveDuring = (isset($param['FromActiveDuring']) && !empty($param['FromActiveDuring'])) ? explode(' ', $param['FromActiveDuring']) : '';
$FromActiveDuringDate = (isset($FromActiveDuring[0]) && !empty($FromActiveDuring[0])) ? explode('/', $FromActiveDuring[0]) : '';
$FromActiveDuringTime = (isset($FromActiveDuring[1]) && !empty($FromActiveDuring[1])) ? trim($FromActiveDuring[1]) : '';
$FromActiveDuring = ($FromActiveDuringDate != '') ? $FromActiveDuringDate[2] . '-' . $FromActiveDuringDate[1] . '-' . $FromActiveDuringDate[0] . ' ' . $FromActiveDuringTime : '';
$ToActiveDuring = (isset($param['ToActiveDuring']) && !empty($param['ToActiveDuring'])) ? explode(' ', $param['ToActiveDuring']) : '';
$ToActiveDuringDate = (isset($ToActiveDuring[0]) && !empty($ToActiveDuring[0])) ? explode('/', $ToActiveDuring[0]) : '';
$ToActiveDuringTime = (isset($ToActiveDuring[1]) && !empty($ToActiveDuring[1])) ? trim($ToActiveDuring[1]) : '';
$ToActiveDuring = ($ToActiveDuringDate != '') ? $ToActiveDuringDate[2] . '-' . $ToActiveDuringDate[1] . '-' . $ToActiveDuringDate[0] . ' ' . $ToActiveDuringTime : '';
$FromBookingDate = (isset($param['FromBookingDate']) && !empty($param['FromBookingDate'])) ? explode('/', $param['FromBookingDate']) : '';
$FromBookingDate = ($FromBookingDate != '') ? $FromBookingDate[2] . '-' . $FromBookingDate[1] . '-' . $FromBookingDate[0] . ' ' . date('H:i:s') : '';
$ToBookingDate = (isset($param['ToBookingDate']) && !empty($param['ToBookingDate'])) ? explode('/', $param['ToBookingDate']) : '';
$ToBookingDate = ($ToBookingDate != '') ? $ToBookingDate[2] . '-' . $ToBookingDate[1] . '-' . $ToBookingDate[0] . ' ' . date('H:i:s') : '';
$DiscountCodePre = (isset($param['DiscountCodePre']) && !empty($param['DiscountCodePre'])) ? $param['DiscountCodePre'] : '';
$DiscountCode = (isset($param['DiscountCode']) && !empty($param['DiscountCode'])) ? $param['DiscountCode'] : 0;
$Domestic = (isset($param['Domestic']) && !empty($param['Domestic'])) ? $param['Domestic'] : 0;
$International = (isset($param['International']) && !empty($param['International'])) ? $param['International'] : 0;
$OneWay = (isset($param['OneWay']) && !empty($param['OneWay'])) ? $param['OneWay'] : 0;
$Return = (isset($param['Return']) && !empty($param['Return'])) ? $param['Return'] : 0;
$SeriesFare = (isset($param['SeriesFare']) && !empty($param['SeriesFare'])) ? $param['SeriesFare'] : 0;
$Currency = (isset($param['Currency']) && !empty($param['Currency'])) ? $param['Currency'] : 'INR';
$IsAllowOnBookingDate = (isset($param['IsAllowOnBookingDate']) && !empty($param['IsAllowOnBookingDate'])) ? $param['IsAllowOnBookingDate'] : 0;
$IsActive = (isset($param['IsActive']) && !empty($param['IsActive'])) ? $param['IsActive'] : 0;
$CouponApplicableType = (isset($param['CouponApplicableType']) && !empty($param['CouponApplicableType'])) ? (int) $param['CouponApplicableType'] : 1;
$RefundApplicableType = (isset($param['RefundApplicableType']) && !empty($param['RefundApplicableType'])) ? (int) $param['RefundApplicableType'] : 1;
$IsApplicableMaxBudget = (isset($param['IsApplicableMaxBudget']) && !empty($param['IsApplicableMaxBudget'])) ? (int) $param['IsApplicableMaxBudget'] : 0;
$MaxBudget = (isset($param['MaxBudget']) && !empty($param['MaxBudget']) && $IsApplicableMaxBudget == 1) ? (int) $param['MaxBudget'] : 0;
$IsDefaultDisplay = (isset($param['IsDefaultDisplay']) && !empty($param['IsDefaultDisplay'])) ? (int) $param['IsDefaultDisplay'] : 0;
$description = (isset($param['description']) && !empty($param['description'])) ? trim($param['description']) : '';
$Packages = (isset($param['Packages']) && !empty($param['Packages'])) ? ($param['Packages']) : '';
$PackagesArr = $TPSysIdsArray = array();
if (is_array($Packages)) {
foreach ($Packages as $pKey => $pVal) {
$datavalue = explode('~~', $pVal);
$TPSysID = (isset($datavalue[0])) ? (int) $datavalue[0] : 0;
$TPSysIDMapId = (isset($datavalue[1])) ? trim($datavalue[1]) : '';
if (!empty($TPSysIDMapId)) {
$PackagesArr[] = array('TPSysID' => (int) $TPSysID, 'id' => $TPSysIDMapId);
} else {
$PackagesArr[] = array('TPSysID' => (int) $TPSysID);
}
$TPSysIdsArray[] = (int) $TPSysID;
}
}
$postData = [
'id' => 1,
'SecurityKey' => $SecurityKey,
'DiscountName' => $DiscountName,
'DiscountType' => $DiscountType,
'Currency' => trim($Currency),
'DiscountValue' => $DiscountValue,
'DiscountValue1' => $DiscountValue1,
'ProductType' => $ProductType,
'CustomerEligibilityType' => $CustomerEligibilityType,
'CriteriaValue' => $CriteriaValue,
'NoofUsage' => $NoofUsage,
'LimitPerCustomer' => $LimitPerCustomer,
'FromActiveDuring' => $FromActiveDuring,
'ToActiveDuring' => $ToActiveDuring,
'FromBookingDate' => ($IsAllowOnBookingDate == 1) ? $FromBookingDate : NULL,
'ToBookingDate' => ($IsAllowOnBookingDate == 1) ? $ToBookingDate : NULL,
'DiscountCode' => $DiscountCode,
'Domestic' => $Domestic,
'International' => $International,
'OneWay' => $OneWay,
'Return' => $Return,
'SeriesFare' => $SeriesFare,
'CreatedBy' => $this->intLoggedinUserId,
'IsActive' => $IsActive,
'IsAllowOnBookingDate' => $IsAllowOnBookingDate,
'CouponApplicableType' => $CouponApplicableType,
'RefundApplicableType' => $RefundApplicableType,
'IsApplicableMaxBudget' => $IsApplicableMaxBudget,
'MaxBudget' => $MaxBudget,
'IsDefaultDisplay' => $IsDefaultDisplay,
'Description' => $description,
'packages' => $PackagesArr,
];
$response = array();
try {
if (isset($param['id']) && !empty($param['id'])) {
$url = $this->COUPON_CODE_API . trim($param['id']) . '/';
$CURLOPT_CUSTOMREQUEST = "PATCH";
} else {
$url = $this->COUPON_CODE_API;
$CURLOPT_CUSTOMREQUEST = "POST";
}
$curl = curl_init();
// echo $url;
// echo "-------";
// echo json_encode($postData);exit;
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $CURLOPT_CUSTOMREQUEST,
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
//echo "<pre>";print_r($response);die;
$err = curl_error($curl);
curl_close($curl);
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
$getresponseDataArray = Zend_Json::decode($response, true);
if (isset($getresponseDataArray['id']) && $getresponseDataArray['id'] != '') {
if ($ProductType == 5) {
$this->checkAndUpdateTravelPlanCoupons($intLoggedinUserAgencySysId, $DiscountCode, $TPSysIdsArray, $description, $DiscountCodePre);
}
echo json_encode(array('status' => true, 'msg' => 'Data saved successfully.'));
exit;
} else {
$msg = '';
foreach ($getresponseDataArray as $key => $val) {
if ($msg == '') {
if (is_array($val[0])) {
foreach ($val[0] as $key1 => $val1) {
if ($msg == '') {
$msg = $key1 . ', ' . str_replace('This field', $key1, $val1[0]);
}
}
} else {
$msg = $key . ', ' . str_replace('This field', $key, $val[0]);
}
}
}
echo json_encode(array('status' => false, 'msg' => ($msg != '') ? $msg : 'Fail Please try after some time.'));
exit;
}
}
}
public function changeCouponStatusAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$SecurityKey = $sessionLogin_user->agencyDetails['SecurityKey'];
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$id = (isset($param['id'])) ? $param['id'] : 0;
$status = (isset($param['status'])) ? $param['status'] : 0;
if ($status == 1) {
$postData = [
'IsActive' => 0,
];
} else {
$postData = [
'IsActive' => 1,
];
}
$curl = curl_init();
$url = $this->COUPON_CODE_API . $param['id'] . '/';
$CURLOPT_CUSTOMREQUEST = "PATCH";
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $CURLOPT_CUSTOMREQUEST,
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
// echo "<pre>";print_r($resultset);die;
$err = curl_error($curl);
curl_close($curl);
$resultset = json_decode($response, 1);
if (!empty($resultset) && is_array($resultset)) {
$id = $resultset['id'];
$IsActive = (int) $resultset['IsActive'];
if ($resultset['IsActive'] == 1) {
$html = "<a onclick=\"changeCouponStatus('" . $id . "'," . $IsActive . ")\" href=\"javascript:void(0);\" title=\"Deactive\" class=\"tooltipLink glyphicon glyphicon-ok-circle view_text\"></a>";
} else {
$html = "<a onclick=\"changeCouponStatus('" . $id . "'," . $IsActive . ")\" href=\"javascript:void(0);\" title=\"Active\" class=\"tooltipLink glyphicon fa fa-times view_text\"></a>";
}
$result = array('status' => true, '' => 'Status updated successfully.', 'html' => $html);
} else {
$result = array('status' => false, '' => 'Unable to update.', 'html' => '');
}
echo json_encode($result);
exit;
}
}
public function deleteCouponAction() {
$sessionLogin_user = new Zend_Session_Namespace('sessionLogin_user');
$SecurityKey = $sessionLogin_user->agencyDetails['SecurityKey'];
if ($this->getRequest()->isPost()) {
$param = $this->getRequest()->getParams();
$id = (isset($param['id'])) ? $param['id'] : '';
if (!empty($id)) {
$postData = [
'IsMarkForDelete' => true,
];
$curl = curl_init();
$url = $this->COUPON_CODE_API . $id . '/';
$CURLOPT_CUSTOMREQUEST = "PATCH";
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $CURLOPT_CUSTOMREQUEST,
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json",
),
));
$responseRes = curl_exec($curl);
// echo "<pre>";print_r($responseRes);exit;
$err = curl_error($curl);
curl_close($curl);
$resultset = json_decode($responseRes, 1);
if (!empty($resultset)) {
$response = array('status' => true);
} else {
$response = array('status' => false);
}
} else {
$response = array('status' => false);
}
echo json_encode($response);
exit;
}
}
public function bookingListAction() {
$strUrlData = $this->view->strUrlData = $this->getRequest()->getParam('data');
$arrUrlData = Zend_Controller_Action_HelperBroker::getStaticHelper("Flight")->dataDecode($strUrlData);
$this->view->msg = !empty($arrUrlData['msg']) ? $arrUrlData['msg'] : '';
$this->view->status = !empty($arrUrlData['status']) ? $arrUrlData['status'] : '';
$this->view->TPSysIdReq = !empty($arrUrlData['TPSysId']) ? $arrUrlData['TPSysId'] : 0;
$this->_agencyuserroleObj = new Travel_Model_TblAgencyUserRole();
$getRoleDetail = $this->_agencyuserroleObj->getDataByRole($this->roleID);
//echo print_r($getRoleDetail);die;
$objPackageViewList = new Travel_Model_TblAgencyCustomerTrx();
$objPackageViewList->ReportingToSysId = $this->ReportingToSysId;
$getData = array();
if ($this->getRequest()->getPost()) {
$getData = $this->getRequest()->getPost();
$this->view->searchData = $getData;
}
$coupon_id = $this->_getParam('id', '');
$filter = $this->_getParam('filter', 'today');
$currentDate = date("Y-m-d");
$fromDate = '2016-10-26';
$update_from_date = $this->_request->getPost('from_date', NULL);
$update_to_date = $this->_request->getPost('to_date', NULL);
$from_date = $this->_request->getParam('from_date', NULL);
$to_date = $this->_request->getParam('to_date', NULL);
// echo "<pre>";print_r($update_from_date);die;
if ($update_from_date != NULL && $update_to_date != NULL) {
$getData = array(
'updatecurrentDate' => $update_to_date,
'updatefromDate' => $update_from_date
);
} else if ($from_date != NULL && $to_date != NULL) {
$getData = array(
'currentDate' => $to_date,
'fromDate' => $from_date
);
} else {
$getData = array(
'updatecurrentDate' => $currentDate,
'updatefromDate' => $fromDate
);
}
$checkOutFromDate = $this->_request->getParam('from_checkout_date', NULL);
$checkOutToDate = $this->_request->getParam('to_checkout_date', NULL);
if ($checkOutFromDate != NULL && $checkOutToDate != NULL) {
$getData = array(
'ValidTillcurrentDate' => $checkOutToDate,
'ValidTillfromDate' => $checkOutFromDate
);
}
if ($filter == 'coupon' && $coupon_id != '') {
$couponurl = $this->COUPON_CODE_API . $coupon_id . "/";
$CouponArray = $this->paymentMdl->getgtxapiinfo($couponurl);
$this->COUPON_HISTORY_CODE_API = COUPON_HISTORY_CODE_API;
$url = $this->COUPON_HISTORY_CODE_API . 'get-tpsysid/?MasterCouponId=' . $coupon_id;
$CouponHistoryArray = $this->paymentMdl->getgtxapiinfo($url);
$TPSysIdArray = array();
if (isset($CouponHistoryArray['results']) && !empty($CouponHistoryArray['results'])) {
foreach ($CouponHistoryArray['results'] as $key => $value) {
if ($value['TPSysID'] > 0) {
$TPSysIdArray[] = $value['TPSysID'];
}
}
}
if (!empty($TPSysIdArray)) {
$getData['TPSysIdArr'] = $TPSysIdArray;
}
}
$this->view->CouponArray = $CouponArray;
$getData['PlanType'] = [1, 2, 4, 3, 5, 6];
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$getData['UserSysId'] = '0';
$customerBookingRecord = $objPackageViewList->getBookedPackageDetail($this->intLoggedinUserAgencySysId, $getData);
} else {
$getData['UserSysId'] = $this->intLoggedinUserId;
$customerBookingRecord = $objPackageViewList->getBookedPackageDetail($this->intLoggedinUserAgencySysId, $getData);
}
$page = $this->_getParam('page', 1);
$paginator = Zend_Paginator::factory($customerBookingRecord);
$paginator->setItemCountPerPage(GRID_PER_PAGE_RECORD_COUNT);
$paginator->setCurrentPageNumber($page);
// echo '<pre>';print_r($paginator); die;
$this->view->paginator = $paginator;
$TblCurrency = new Travel_Model_TblCurrency();
$this->view->CurrencySymbol = $CurrencySymbol = $TblCurrency->getCurrencySymbolByIdsList();
$this->_crmcustomerObj->ReportingToSysId = $this->ReportingToSysId;
$getleadSource = $this->_crmcustomerObj->getLeadSourceByAgency($this->intLoggedinUserAgencySysId);
$this->view->leadSourceList = $getleadSource;
if ($getRoleDetail['IsAdmin'] == true || $getRoleDetail['IsAbleToManageTask'] == true || $getRoleDetail['IsSuperAdmin'] == true) {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId);
} else {
$agencyUser = $this->_crmcustomerObj->getAllAgencyUserList('', $this->intLoggedinUserAgencySysId, $this->ReportingToSysId);
}
$this->view->agencyUser = $agencyUser;
}
public function checkAndUpdateTravelPlanCoupons($intLoggedinUserAgencySysId, $DiscountCode, $TPSysIdsArray, $description, $DiscountCodePre) {
$objPackage = new Travel_Model_TblPackage();
$this->marketingMdl = new Marketing_Model_Marketing();
if(!empty($TPSysIdsArray)){
$checkPackageCouponCodes = $objPackage->checkPackageCouponCodes($intLoggedinUserAgencySysId, $DiscountCodePre, $TPSysIdsArray);
}
$checkPackageCouponCodeArr = array_column($checkPackageCouponCodes, 'TPSysId');
$UpdateTravelplanCoupon = ['IsMarkForDelete' => 1];
$WhereTravelplanCoupon = ['AgencySysId =?' => $intLoggedinUserAgencySysId, 'CouponCode =?' => $DiscountCodePre];
$this->marketingMdl->updateTable("TB_TravelPlan_Coupons", $UpdateTravelplanCoupon, $WhereTravelplanCoupon);
foreach ($TPSysIdsArray as $tpKey => $tpValue) {
$SaveTPCoupon = array(
'AgencySysId' => $intLoggedinUserAgencySysId,
'TPSysId' => $tpValue,
'CouponCode' => $DiscountCode,
'Description' => $description,
'IsActive' => 1,
'IsMarkForDelete' => 0,
'UpdatedDate' => date('Y-m-d H:i'),
);
try {
if (in_array($tpValue, $checkPackageCouponCodeArr)) {
$WhereTravelplanCoupon = ['AgencySysId =?' => $intLoggedinUserAgencySysId, 'CouponCode =?' => $DiscountCodePre, 'TPSysId =?' => $tpValue];
$this->marketingMdl->updateTable("TB_TravelPlan_Coupons", $SaveTPCoupon, $WhereTravelplanCoupon);
} else {
$SaveTPCoupon['CreatedDate'] = date('Y-m-d H:i');
$this->marketingMdl->insertTable("TB_TravelPlan_Coupons", $SaveTPCoupon);
}
} catch (Zend_Exception $e) {
echo $e->getMessage();
exit;
}
}
return 1;
}
}