<?php
/*
  osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

	Freeway eCommerce
	http://www.openfreeway.org
	Copyright (c) 2007 ZacWare
	
Featured Categories for osConcert by cartZone UK 
Copyright (c) 2009-2014 osConcert
	
Released under the GNU General Public License 
*/

// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();

define ('TEXT_NO_FEATURED_CATEGORIES','');
        
if ( (!isset($featured_categories_category_id)) || ($featured_categories_category_id == '0') ) 
	{		
	// $featured_categories_query = tep_db_query("select c.categories_status, c.manufacturers_id, c.categories_id, cd.categories_name,cd.categories_heading_title, c.categories_image, c.parent_id, cd.categories_description, cd.concert_venue,cd.concert_date,cd.concert_time,c.date_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status > '0' and c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$FSESSION->languages_id . "' order by sort_order, cd.categories_id");
	// }
	
	$page=" and c.parent_id = '" . (int)$current_category_id . "'";
	//$page="";
	$featured_categories_query = tep_db_query("select * from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status > '0' ".$page." and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$FSESSION->languages_id . "' order by sort_order, cd.categories_id");
	}

  $num_featured_categories = tep_db_num_rows($featured_categories_query);

  if ($num_featured_categories > 0) 
  {
    $counter = 0;
    $col = 0;

    while ($featured_categories = tep_db_fetch_array($featured_categories_query)) 
	{
		$plan_id=$featured_categories['plan_id'];
		$categories_description = $featured_categories['categories_description'];	
		$categories_description = ltrim(substr($categories_description, 0, 75) . '...'); //Trims and Limits the desc
		$counter++;

		if (($featured_categories['categories_image'] == 'NULL') or ($featured_categories['categories_image'] == '')) {
			$cat_image="theatre.png";
		}else{
			$cat_image=$featured_categories['categories_image'];
		}
		$concert_name=$featured_categories['categories_name'];
		if($plan_id==9)
		{
		$concert_date='';
		$concert_time='';
		$select=IMAGE_BUTTON_BUY_NOW;
		}else
		{
		$concert_date='<h6>Date: '.$featured_categories['concert_date'].'</h6>';
		$concert_time='<h6>Time: '.$featured_categories['concert_time'].'</h6>';
		$select=TEXT_SELECT_TICKETS;
		}
		$concert_venue=$featured_categories['concert_venue'];
		
		
		
		$featured_subcategories_content .= '
		  	 <div id="sub_listing" class="col-lg-12 col-md-12">
			 <div class="row p-3 effects">
					
				<div class="col-md-4">

				'.$concert_date.'
				'.$concert_time.'

				</div>
				<div class="col-md-4">
				<h5>'.$concert_venue.'</h5>

				</div>
				<div class="col-md-4">

				<a class="pull-right" href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $featured_categories['categories_id']) . '">' . tep_template_image_button('', $select) . '</a>

				</div>
				  </div>
				  </div>
			';
		$col ++;
	}

	if(SHOW_MAIN_FEATURED_CATEGORIES == true)
	{
	?>
	<?php if(DISABLE_OVERLAY=='yes')
	{
	?>
	<style>
	#featured_subs .featured_subs-overlay {
	display:none;
	}
	</style>
	<?php
	}
	?>
	<section id="featured_subs" class="wow fadeInUp">
	<div class="container">
	<div class="container-fluid">
	<div class="row no-gutters">
    <?php 
	echo $featured_subcategories_content; 
	?>
	</div>
	</div>
	</div>
	</section>
	<?php
	}
	?>
 
  <?php
  }
  else
  {
	echo "<p style=\"text-align:center\">";
	echo TEXT_NO_FEATURED_CATEGORIES;
	echo "</p>";
  }
?>