<?php
/*
  $Id: new_events.php,v 1.1.1.1 2003/09/18 19:04:53 wilt Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

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


?>
<!-- new_products //-->
<?php
	if ( (!isset($new_events_events_category_id)) || ($new_events_events_category_id == '0') ) {
		$new_events_query = tep_db_query("select events_id, events_image from " . TABLE_EVENTS . " where (e.events_status=1 or ( e.events_status=2 and e.sessions_start_date>=curdate()) or (e.events_status>=3 and e.sessions_end_date>=curdate())) and date_format(e.events_date_available,'%Y-%m-%d')<=curdate() order by events_date_added desc limit 4");
	} else {
		$new_events_query = tep_db_query("select distinct e.events_id, e.events_image from " . TABLE_EVENTS . " e, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " e2c, " . TABLE_EVENTS_CATEGORIES . " ec where e.events_id = e2c.events_id and e2c.events_categories_id = ec.events_categories_id and ec.parent_id = '" . $new_events_events_category_id . "' " . EVENTS_CONDITION_STATUS . " order by e.events_date_added desc limit 4");
	}
	$cnt=tep_db_num_rows($new_events_query);
	$display_flag=false;
	if ($cnt>0){
		/*$status=array();
		while ($new_events = tep_db_fetch_array($new_events_query)) {
			$event_select=tep_get_event_display_status($new_events["events_id"]);
			if ($event_select) $display_flag=true;
			$status[$new_events["events_id"]]=$event_select;
		}*/
		$display_flag=true;
	}

	if ($display_flag){
		$info_box_contents = array();
		$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_EVENTS, strftime('%B')));
		
		new contentBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_EVENTS_NEW));
	  
		$row = 0;
		$col = 0;
		$info_box_contents = array();
		tep_mysql_data_seek ( $new_events_query, 0)
	
		while ($new_events = tep_db_fetch_array($new_events_query)) {
			if ($status[$new_events["events_id"]]){
				$new_events['events_name'] = tep_get_events_name($new_events['events_id']);
				$info_box_contents[$row][$col] = array('align' => 'center',
													   'params' => 'class="smallText" width="33%" valign="top"',
													   'text' => '<a href="' . tep_href_link(FILENAME_SESSION_DETAILS, tep_get_all_get_params() . '&events_id=' . $new_events['events_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_events['events_image'], $new_events['events_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_SESSION_DETAILS, tep_get_all_get_params() . '&events_id=' . $new_events['events_id']) . '">' . $new_events['events_name'] . '</a>');
		
				$col ++;
				if ($col > 2) {
					$col = 0;
					$row ++;
				}
			}
		}
		new contentBox($info_box_contents);
		if (MAIN_TABLE_BORDER == 'yes'){
			$info_box_contents = array();
			$info_box_contents[] = array('align' => 'left',
								'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
							  );
			new infoboxFooter($info_box_contents, true, true);
		}
	}
?>
<!-- new_products_eof //-->
