<?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();
        
if ( (!isset($featured_categories_category_id)) || ($featured_categories_category_id == '0') ) 
	{		
	$unix = $_SERVER['REQUEST_TIME'];
	
	//$serverDate = date(EVENTS_DATE_FORMAT,getServerDate(false));
	//$expires=" and cd.concert_date_unix >'" . $unix . "' ";
	$expires="";
	
	//$page=" and c.parent_id = '" . (int)$current_category_id . "'";
	$page=" and c.parent_id = 0";
	$featured_categories_query = tep_db_query("select * from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status > '0'  ".$expires." ".$page." and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$FSESSION->languages_id . "' order by c.categories_id,cd.concert_date_unix");
	}

  $num_featured_categories = tep_db_num_rows($featured_categories_query);

  if ($num_featured_categories > 0) 
  {
    $counter = 0;
    $col = 0;
//<br>'.$serverDate.'
    while ($featured_categories = tep_db_fetch_array($featured_categories_query)) 
	{
		$categories_description = $featured_categories['categories_description'];
		
		$cdate = strtotime($featured_categories['concert_date']);
		// $concert_date=date(EVENTS_DATE_FORMAT, $date);
		
		if(EVENTS_DATE_FORMAT=='d-m-Y')
				{
				$concert_date = date('d M, Y', $cdate);
				}
				
				//this one:
				if(EVENTS_DATE_FORMAT=='m-d-Y')
				{
				$concert_date = date('M d', $cdate);
				}
				if(EVENTS_DATE_FORMAT=='Y-m-d')
				{
				$concert_date = date('Y, d M,', $cdate);
				}
			if (strtotime($concert_date)>strtotime(0)) 
			{ 
			}
			else
			{
			$concert_date = $result['concert_date'];
			}
		
		
		$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="rounded-rectangle.png";
		}else{
			$cat_image=$featured_categories['categories_image'];
		}
		$button="btn btn-primary";
		$featured_categories_content .= '
		
		  <div class="col-lg-1 col-md-3 col-sm-4">
			<div class="featured-item wow fadeInUp" rel="show_hide_'.$featured_categories['manufacturers_id'].'">
			  <a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $featured_categories['categories_id']) . '">' . 
						tep_image(DIR_WS_IMAGES . $cat_image, $featured_categories['categories_name'], '', '') . 
					'<div class="featured-overlay">
				  <div class="featured-info"><h2 class="wow fadeInUp">' . $concert_date . '</h2></div>
				</div></a>
			</div>
		  </div>
			';
		$col ++;
	}

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