<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php

  require('load_this/load_this_bigware_10.php'); 
  if (!go_session_is_registered('attendee_id')) {
    $navigation->set_snapshot(); 
      go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_40], 'origin=' . $GLOBALS[CONFIG_NAME_FILE][main_bigware_51], 'SSL'));  
  } 
  if ($cart->count_contents() < 1) {
    go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_69]));
  } 
  if (!go_session_is_registered('shipping')) {
    go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_66], '', 'SSL'));
  } 
  if (isset($cart->cartID) && go_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_66], '', 'SSL'));
    }
  }   	

	if(go_session_is_registered('crchange_covers')) go_session_unregister('crchange_covers'); 
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
  	
 		if (OPTIMIZE_ORDER == 'true'){ 	
  	
			  $check_query = go_db_query("select count(*) as count from temp_serialize where user = '" . $attendee_id . "' AND was = 'get_items'");
			  $check = go_db_fetch_array($check_query);
			  if ($check['count'] > 0) {
					$my_items_query = go_db_query("SELECT serialize_code FROM temp_serialize WHERE user = '" . $attendee_id . "' AND was = 'get_items'");
					$my_items_result=go_db_fetch_array($my_items_query);    
				  $items = array_in_one_hidden_decode($my_items_result['serialize_code']);
			
				 }else{
			    $items = $cart->get_items();
			   }
			}
			else{
			    $items = $cart->get_items();
				
			}   
			   
    for ($i=0, $n=sizeof($items); $i<$n; $i++) {
      if (go_check_stock($items[$i]['id'], $items[$i]['quantity'])) {
        go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_69]));
        break;
      }
    }
  } 
  if (MAX_ITEMS_PER_ORDER > 0 && ($cart->count_contents() > MAX_ITEMS_PER_ORDER)) {
     go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_69]));
  }

  if (!go_session_is_registered('billto')) {
    go_session_register('billto');
    $billto = $attendee_default_address_id;
  } else { 
    $check_address_query = go_db_query("select count(*) as total from " . DB_TBL_DIRECTORY_TO_ADDRESS . " where attendees_id = '" . (int)$attendee_id . "' and directory_to_address_id = '" . (int)$billto . "'");
    $check_address = go_db_fetch_array($check_address_query);
    if ($check_address['total'] != '1') {
      $billto = $attendee_default_address_id;
      if (go_session_is_registered('payment')) go_session_unregister('payment');
    }
  }  
 	include('load_this/preloader_header.php');  
	require(FOLDER_RELATIV_CLASSES . $GLOBALS[CONFIG_NAME_FILE_CLASSES][classes_bigware_14]);  
  require(FOLDER_RELATIV_CLASSES . $GLOBALS[CONFIG_NAME_FILE_CLASSES][classes_bigware_15]);	
  
	if (OPTIMIZE_ORDER == 'true'){ 	
			$check_order_query = go_db_query("select count(*) as count from temp_serialize where user = '" . $attendee_id . "' AND was = 'order'");
			$check_order= go_db_fetch_array($check_order_query);
				if ($check_order['count'] > 0) {	
					
				$my_order_query = go_db_query("SELECT serialize_code FROM temp_serialize WHERE user = '" . $attendee_id . "' AND was = 'order'");
				$my_order_result=go_db_fetch_array($my_order_query);    
				$order = array_in_one_hidden_decode($my_order_result['serialize_code']);	
				}	 
				else{ 
					  $order = new order;
				}


	$check_order_total_query = go_db_query("select count(*) as count from temp_serialize where user = '" . $attendee_id . "' AND was = 'order_total'");
	$check_order_total= go_db_fetch_array($check_order_total_query);
		if ($check_order_total['count'] < 1) {	  
  			$order_total_modules = new order_total;
  			$hidden_order_total = objekt_encode($order_total_modules);	
	    	go_db_query("insert into temp_serialize (user, serialize_code, was) values ('" . $attendee_id . "', '" . $hidden_order_total . "', 'order_total')"); 
	    
		}
		else{
				$my_order_total_query = go_db_query("SELECT serialize_code FROM temp_serialize WHERE user = '" . $attendee_id . "' AND was = 'order_total'");
				$my_order_total_result=go_db_fetch_array($my_order_total_query);    
				$order_total_modules = array_in_one_hidden_decode($my_order_total_result['serialize_code']);	
		}
	}
	else{
		  $order = new order;	
		  $order_total_modules = new order_total;
	}		
		
  if (!go_session_is_registered('comments')) go_session_register('comments');
  $total_weight = $cart->show_weight();
  $total_count = $cart->count_contents();
  $total_count = $cart->count_contents_virtual(); 
  require(FOLDER_RELATIV_CLASSES . $GLOBALS[CONFIG_NAME_FILE_CLASSES][classes_bigware_16]);
  $payment_modules = new payment;
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . $GLOBALS[CONFIG_NAME_FILE][main_bigware_51]);
  $breadcrumb->add(NAVBAR_TITLE_1, go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_66], '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2, go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_51], '', 'SSL'));
  $content = $GLOBALS[CONFIG_SHOW_FILE][main_bigware_51];
  $javascript = $content . '.js.php';
  require(FOLDER_RELATIV_TEMPLATES . TEMPLATENAME_MAIN_PAGE); 
  require(FOLDER_RELATIV_INCLUDES . 'load_this_bigware_3.php');   
?>
