<?php
/*
	osCommerce, Open Source E-Commerce Solutions 
	http://www.oscommerce.com 
	
	Copyright (c) 2003 osCommerce 
	
	osCommRes, Services Oline 
	http://www.oscommres.com 
	Copyright (c) 2005 osCommRes 
	
	Freeway eCommerce 
	http://www.zac-ware.com/freeway 
	Copyright (c) 2007 ZacWare
	
	Released under the GNU General Public License
*/



// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	
	require('includes/application_top.php');
	
	if (!tep_session_is_registered('customer_id')) {
		$navigation->set_snapshot();
		tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
	}
	if (isset($HTTP_POST_VARS['events_id']) && is_numeric($HTTP_POST_VARS['events_id']))
		$events_id=tep_db_prepare_input($HTTP_POST_VARS['events_id']);
	else
		tep_redirect(tep_href_link(FILENAME_ACCOUNT,'','SSL'));
     
	if (isset($HTTP_POST_VARS['orders_products_id']) && is_array($HTTP_POST_VARS['orders_products_id']))
		$orders_products_id=tep_db_prepare_input($HTTP_POST_VARS['orders_products_id']);
	else
		tep_redirect(tep_href_link(FILENAME_ACCOUNT,'','SSL'));

	$events_query=tep_db_query("SELECT events_forward_period,events_forward_length from " . TABLE_EVENTS . " where events_id='" . tep_db_input($events_id) . "'");
	$events_result=tep_db_fetch_array($events_query);
	if ($events_result['events_forward_period']=='Y'){
		$check_date=date('Y-m-d',tep_dateadd(time(),'day',(int)$events_result['events_forward_length']));
		$check_data=" and s.start_date<='" . $check_date . "' ";
	}
  
	$dates_query=tep_db_query("SELECT s.sessions_id,s.start_date from " . TABLE_EVENTS_SESSIONS . " s where s.events_id='" . tep_db_input($events_id) . "' and s.start_date>curdate() and s.sessions_type!=''" . tep_db_input($check_data) . " order by start_date");
	while ($dates_result=tep_db_fetch_array($dates_query)){
		$dates_array[]=array('id'=>$dates_result['sessions_id'],'text'=>$dates_result['start_date']);}
  
	if (isset($HTTP_POST_VARS['error']) && is_array($HTTP_POST_VARS['error']))
		$error=tep_db_prepare_input($HTTP_POST_VARS['error']);

	if (isset($HTTP_POST_VARS['new_ids']) && is_array($HTTP_POST_VARS['new_ids']))
		$new_ids=tep_db_prepare_input($HTTP_POST_VARS['new_ids']);
  

	for ($icnt=0;$icnt<sizeof($orders_products_id);$icnt++){
		if ($select_ids!="") $select_ids.=", ";
			$select_ids.=$orders_products_id[$icnt];
	}

	$reservations_query=tep_db_query("SELECT op.orders_products_id,s.sessions_id,s.start_date from " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_EVENTS_SESSIONS . " s "
								   . " where op.orders_products_id in (" . tep_db_input($select_ids) . ") and op.products_id=s.sessions_id and op.products_type='E' and (op.events_type='R' or op.events_type='W')");


	$content = CONTENT_MOVE_RESERVATIONS;
	
	require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_MOVE_RESERVATIONS);
	
	require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);
	
	require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
