function search_availability() { bfi_get_locale(); if (!isset($_REQUEST['task'])) { unset($_SESSION['search.filterparams']); setSessionFromSubmittedData(); $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $num_per_page = 20; $start = ($page - 1) * $num_per_page; $searchmodel = new BookingForConnectorModelSearch(); $items = $searchmodel->getItems(false, false, $start); $items = is_array($items) ? $items : array(); $total = 0; if (!empty($_SESSION['search.results']) && !empty($_SESSION['search.results']['totalresultcount'])) { $total = $_SESSION['search.results']['totalresultcount']; } $pages = ceil($total / $num_per_page); $output = ''; $output = $output . '<div id="bfcmerchantlist"><div id="searchitems" rel="' . htmlspecialchars(json_encode($items)) . '"></div> <div class="resourcetabmenu"> <a class="resources" rel="resources"><i class="fa fa-list-ul"></i> ' . __('List', 'bfi') . '</a><a id="maptab" class="mappa" rel="mappa"> ' . __('Map', 'bfi') . '</a> </div> <div class="resourcetabcontainer"> <div id="resources" class="tabcontent"> <div class="com_bookingforconnector-merchantlist">'; echo $output; $merchant_ids = ''; if ($_SESSION['search.params']['merchantResults']) { $resource_ids = array(); if (is_array($items)) { $merchant_ids = array(); foreach ($items as $merchant) { $merchant_ids[] = $merchant->MerchantId; } $merchant_ids = implode(',', $merchant_ids); } echo '<div id="idsforajax" rel="' . $merchant_ids . '"></div>'; include 'templates/search-listing.php'; } else { $resource_ids = array(); foreach ($items as $resource) { $resource_ids[] = $resource->ResourceId; } $resource_ids = implode(',', $resource_ids); echo '<div id="idsforajax" rel="' . $resource_ids . '"></div>'; include 'templates/search-listing-resources.php'; } $output = ''; $output = $output . '</div> </div> <div id="mappa" class="tabcontent"> <div id="map_canvassearch" class="searchmap" style="width:100%; min-height:400px"></div> </div>'; $url = $_SERVER['REQUEST_URI']; $pagination_args = array('base' => $url . '%_%', 'format' => '&page=%#%', 'total' => $pages, 'current' => $page, 'show_all' => false, 'end_size' => 5, 'mid_size' => 2, 'prev_next' => true, 'prev_text' => __('«'), 'next_text' => __('»'), 'type' => 'plain', 'add_args' => false, 'add_fragment' => ''); $paginate_links = paginate_links($pagination_args); if ($paginate_links) { echo "<nav class='custom-pagination'>"; // echo "<span class='page-numbers page-num'>Page " . $page . " of " . $numpages . "</span> "; echo "<span class='page-numbers page-num'>" . __('Page', 'bfi') . " </span> "; print $paginate_links; echo "</nav>"; } $output = $output . "</div></div>"; echo $output; } else { $task = $_REQUEST['task']; if ($task == 'GetMerchantsByIds') { $lists = $_REQUEST['merchantsId']; $merchants = BFCHelper::getMerchantsByIds($lists, $GLOBALS['bfi_lang']); die($merchants); } else { if ($task == 'getMerchantGroups') { $merchantgroups = BFCHelper::getMerchantGroups(); wp_send_json($merchantgroups); } else { if ($task == 'GetPhoneByMerchantId') { $merchantId = $_REQUEST['merchantid']; $language = $GLOBALS['bfi_lang']; $phno = BFCHelper::GetPhoneByMerchantId($merchantId, $language); wp_send_json($phno); } else { if ($task == 'GetResourcesByIds') { $lists = $_REQUEST['resourcesId']; $language = $GLOBALS['bfi_lang']; $resources = BFCHelper::GetResourcesByIds($lists, $language); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $resources; die; } else { if ($task == 'getmarketinfo') { $base_url = get_site_url(); $merchant_id = $_REQUEST['merchantId']; $model = new BookingForConnectorModelMerchantDetails(); $merchant = $model->getItem($merchant_id); $output = '<div class="com_bookingforconnector_map_merchantdetails" style="display:block;height:150px;overflow:auto; width: 300px;"> <div class="com_bookingforconnector_merchantdetails com_bookingforconnector_merchantdetails-t257"> <h3 style="margin:0;" class="com_bookingforconnector_merchantdetails-name"><a class="com_bookingforconnector_merchantdetails-nameAnchor" href="' . $base_url . '/merchant-details/merchantdetails/' . $merchant->MerchantId . '-' . seoUrl($merchant->Name) . '">' . $merchant->Name . '</a> <br/><span class="com_bookingforconnector_merchantdetails-rating com_bookingforconnector_merchantdetails-rating' . $merchant->Rating . '"> <span class="com_bookingforconnector_merchantdetails-ratingText">Rating ' . $merchant->Rating . '</span> </span> </h3> <div class="com_bookingforconnector_merchantdetails-contacts" style="display:none;"> <h3>' . __('Facility contacts data', 'bfi') . '</h3> <div>' . __('Phone', 'bfi') . ': <br/> <!-- Fax: --> </div> </div> </div> </div>'; die($output); } else { if ($task == 'getmarketinforesource') { $base_url = get_site_url(); $resource_id = $_REQUEST['resourceId']; $model = new BookingForConnectorModelResource(); $resource = $model->getItem($resource_id); $merchant = $resource->Merchant; $output = '<div class="com_bookingforconnector_map_merchantdetails" style="display:block;height:150px;overflow:auto; width: 300px;"> <div class="com_bookingforconnector_merchantdetails com_bookingforconnector_merchantdetails-t257"> <h3 style="margin:0;" class="com_bookingforconnector_merchantdetails-name"><a class="com_bookingforconnector_merchantdetails-nameAnchor" href="' . $base_url . '/accommodation-details/resource/' . $resource->ResourceId . '-' . seoUrl($resource->Name) . '">' . $resource->Name . '</a> <br/><span class="com_bookingforconnector_merchantdetails-rating com_bookingforconnector_merchantdetails-rating' . $merchant->Rating . '"> <span class="com_bookingforconnector_merchantdetails-ratingText">Rating ' . $merchant->Rating . '</span> </span> </h3> <div class="com_bookingforconnector_merchantdetails-contacts" style="display:none;"> <h3>' . __('Facility contacts data', 'bfi') . '</h3> <div>' . __('Phone', 'bfi') . ': <br/> Fax: </div> </div> </div> </div>'; die($output); } else { if ($task == 'getmarketinforesourceonsell') { $base_url = get_site_url(); $resource_id = $_REQUEST['resourceId']; $model = new BookingForConnectorModelOnSellUnit(); $resource = $model->getItem($resource_id); $merchant = $resource->Merchant; $resource->Price = $resource->MinPrice; $resourceName = BFCHelper::getLanguage($resource->Name, $language, null, array('ln2br' => 'ln2br', 'striptags' => 'striptags')); $resourceDescription = BFCHelper::getLanguage($resource->Description, $language, null, array('ln2br' => 'ln2br', 'striptags' => 'striptags')); $zone = $resource->LocationZone; $location = $resource->LocationName; $contractType = $resource->ContractType ? 'contacttype1' : 'contacttype'; // $img = "/images/default.png"; // $imgError = "/images/default.png"; $img = plugins_url("images/default.png", dirname(__FILE__)); $imgError = plugins_url("images/default.png", dirname(__FILE__)); $route = '/merchant-details/sale/' . $resource_id . '-' . seoUrl($resource->Name); if ($resource->ImageUrl != '') { $img = BFCHelper::getImageUrlResized('onsellunits', $resource->ImageUrl, 'onsellunit_map_default'); $imgError = BFCHelper::getImageUrl('onsellunits', $resource->ImageUrl, 'onsellunit_map_default'); } elseif ($merchant->LogoUrl != '') { $img = BFCHelper::getImageUrlResized('merchant', $merchant->LogoUrl, 'onsellunit_map_default'); $imgError = BFCHelper::getImageUrl('merchant', $merchant->LogoUrl, 'onsellunit_map_default'); } ob_start(); include 'templates/onsellmapmarker.php'; $output = ob_get_contents(); ob_end_clean(); die($output); } } } } } } } } }
function GetResourcesByIds() { $listsId = JRequest::getVar('resourcesId'); $language = JRequest::getVar('language'); $return = BFCHelper::GetResourcesByIds($listsId, $language); echo $return; $app = JFactory::getApplication(); $app->close(); }