Your IP : 216.73.216.84


Current Path : /home/h/e/l/helpink/www/modules/mod_jbusiness_offers/
Upload File :
Current File : /home/h/e/l/helpink/www/modules/mod_jbusiness_offers/mod_jbusiness_offers.php

<?php
/**
 * @package    J-BusinessDirectory
 *
 * @author     CMSJunkie http://www.cmsjunkie.com/
 * @copyright  Copyright (C) 2007 - 2022 CMSJunkie. All rights reserved.
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html
 */
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;

require_once JPATH_SITE.'/components/com_jbusinessdirectory/helpers/defines.php';
require_once HELPERS_PATH.'/utils.php';

JBusinessUtil::enqueueStyle('css/common.css');
JBusinessUtil::enqueueStyle('css/line-awesome.css');

$appSettings = JBusinessUtil::getApplicationSettings();

JHtml::_('stylesheet', 'modules/mod_jbusiness_offers/assets/style.css');
JHtml::_('script', 'modules/mod_jbusiness_offers/assets/js/script.js');

JHtml::_('jquery.framework', true, true);

if ($params->get('viewtype') == 'slider') {
	JBusinessUtil::enqueueStyle('libraries/slick/slick.css');
	JBusinessUtil::enqueueScript('libraries/slick/slick.js');
}

JBusinessUtil::enqueueStyle('libraries/modal/jquery.modal.css');
JBusinessUtil::enqueueScript('libraries/modal/jquery.modal.js');

if ($appSettings->enable_ratings) {
	JBusinessUtil::enqueueStyle('libraries/star-rating/star-rating.css');
	JBusinessUtil::enqueueScript('libraries/star-rating/star-rating.js');
}

JBusinessUtil::loadBaseScripts();

require_once HELPERS_PATH.'/translations.php';

// Include the syndicate functions only once
require_once __DIR__ . '/helper.php';

JBusinessUtil::loadSiteLanguage();
JBusinessUtil::includeCSSLibraries();
JBusinessUtil::loadClasses();

//load items through cache mechanism
$cache = Factory::getCache('mod_jbusiness_offers', '');
if ($cache->contains($module->id) && $params->get("cache")) {
	$items = $cache->get($module->id);
} else {
	$items = modJBusinessOffersHelper::getList($params);
	$cache->store($items, $module->id, 'mod_jbusiness_offers');
}

$showLocation = $params->get('showLocation');
$showListingName = $params->get('showlistingName');
$showFreeText = $params->get('showOfferFree');

$appSettings = JBusinessUtil::getApplicationSettings();
if ($appSettings->enable_multilingual) {
	JBusinessDirectoryTranslations::updateOffersTranslation($items);
}

$moduleclass_sfx = htmlspecialchars((string)$params->get('moduleclass_sfx'));

$backgroundCss="";
if ($params->get('backgroundColor')) {
	$backgroundCss = "background-color:".$params->get('backgroundColor').";";
}

$borderCss="";
if ($params->get('borderColor')) {
	$borderCss="border-color:".$params->get('borderColor').";";
}

$categoryParam = "";
$categoriesIds = $params->get('categoryIds');
if (isset($categoriesIds) && count($categoriesIds)>0 && $categoriesIds[0]!= 0 && $categoriesIds[0]!= "") {
	$categoryParam="&categorySearch=".$categoriesIds[0];
}

$itemType ="";
if ($params->get('itemType')) {
	$itemType="&itemType=".$params->get('itemType');
}

$menuItemId ="";
if ($params->get('mItemId')) {
	$menuItemId="&Itemid=".$params->get('mItemId');
}
$viewAllLink = JRoute::_('index.php?option=com_jbusinessdirectory&view=offers&resetSearch=1'.$menuItemId.$categoryParam.$itemType);

$newTab = ($appSettings->open_listing_on_new_tab)?" target='_blank'":"";
$span = $params->get('layout-type')=="vertical"?"col-12":$params->get('phoneGridOption', 'col-12').' '.$params->get('tabletGridOption', 'col-md-6').' '.$params->get('desktopGridOption', "col-lg-4");

// echo OfferSellingService::getCartModal();

$jsSettings = JBusinessUtil::addJSSettings();
$jsSettings->isProfile = 1;

$token = rand(10, 1000);

if (!defined('JBD_UTILS_LOADED')) {
	$document  = JFactory::getDocument();
	$document->addScriptDeclaration('
		window.addEventListener("load",function() {
		    jbdUtils.setProperties(' . json_encode($jsSettings) . ');
		});
	');
	define('JBD_UTILS_LOADED', 1);
}

$document  = JFactory::getDocument();
$campaignCall = "";
$campaignCallClass = "";
if (!empty($params->get('plan')) && !empty($params->get('only_campaign'))) {
	$campaignCallClass = 'campaignCallOffers';
	$campaignCall =
		"
            var campaignUrl = jbdUtils.getAjaxUrl('decreaseCampaignBudget', 'campaign', 'managecampaign');
            var offerPlanId = '" . $params->get('plan') . "';

            jQuery.ajax({
                type:'GET',
                url: campaignUrl,
                data: { planId: offerPlanId, item_id: itemId },
                dataType: 'json',
                cache: false,
                success: function(data) {
                    console.log(data);
                }
            });
        ";

	$document->addScriptDeclaration("  
		window.addEventListener('load',function() {
			jQuery('.' + '$campaignCallClass').on('click', function(event) {
				//event.preventDefault();
				var itemId = jQuery(this).attr('data-item-id');
				if (itemId) {
					" . $campaignCall . "
				} else {
					console.error('data-item-id not found on clicked element');
				}
			});
		});
	");
}


require JModuleHelper::getLayoutPath('mod_jbusiness_offers', "default_".$params->get('viewtype'));