<?php
/*
  
	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 the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_EVENT_PAYMENT));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($event_cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_DEFAULT));
  }

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($event_cart->event_cartID) && tep_session_is_registered('event_cartID')) {
    if ($event_cart->event_cartID != $event_cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

  if (!tep_session_is_registered('event_payment')) tep_session_register('event_payment');
  if (isset($HTTP_POST_VARS['event_payment'])) $event_payment = $HTTP_POST_VARS['event_payment'];

  if (!tep_session_is_registered('event_comments')) tep_session_register('event_comments');
  if (tep_not_null($HTTP_POST_VARS['event_comments'])) {
    $event_comments = tep_db_prepare_input($HTTP_POST_VARS['event_comments']);
  }

// load the selected payment module
  require(DIR_WS_CLASSES . 'payment.php');
//  if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS
  $event_payment_modules = new payment($event_payment);
//ICW ADDED FOR CREDIT CLASS SYSTEM
//  require(DIR_WS_CLASSES . 'order_total.php');

  require(DIR_WS_CLASSES . 'reservation.php');
  $reservation = new reservation;

  $event_payment_modules->update_status();
//ICW ADDED FOR CREDIT CLASS SYSTEM
//  $order_total_modules = new order_total;
//ICW ADDED FOR CREDIT CLASS SYSTEM
//  $order_total_modules->collect_posts();
//ICW ADDED FOR CREDIT CLASS SYSTEM
//  $order_total_modules->pre_confirmation_check();

// ICW CREDIT CLASS Amended Line
  if ( ( is_array($event_payment_modules->modules) && (sizeof($event_payment_modules->modules) > 1) && !is_object($$event_payment) ) || (is_object($$event_payment) && ($$event_payment->enabled == false)) ) {
  if ( (is_array($event_payment_modules->modules)) && (sizeof($event_payment_modules->modules) > 1) && (!is_object($$event_payment)) && (!$credit_covers) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_EVENT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
  }

  if (is_array($event_payment_modules->modules)) {
    $event_payment_modules->pre_confirmation_check();
  }
  }
  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_EVENT_CONFIRMATION);

  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2);

  $content = CONTENT_CHECKOUT_EVENT_CONFIRMATION;

  require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);

  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
