<?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_bigware_11.php');
$order_total_class['ot_cod_fee']['prefix'] = '+';
$order_total_class['ot_cod_fee']['tax'] = '16';
$order_total_class['ot_attendee_discount']['prefix'] = '-';
$order_total_class['ot_attendee_discount']['tax'] = '16';
$order_total_class['ot_gv']['prefix'] = '-';
$order_total_class['ot_gv']['tax'] = '0';
$order_total_class['ot_loworderfee']['prefix'] = '+';
$order_total_class['ot_loworderfee']['tax'] = '16';
$order_total_class['ot_shipping']['prefix'] = '+';
$order_total_class['ot_shipping']['tax'] = '16';
 $version_nr    = '0.30';
$version_datum = '2004.01.31';
  
  header ("Last-Modified: ". gmdate ("D, d M Y H:i:s"). " GMT"); 
  header ("Cache-Control: no-cache, must-revalidate"); 
  header ("Pragma: no-cache"); 
  header ("Content-type: text/xml");
  if ($_GET['action']) 
  {
    switch ($_GET['action']) 
    {
      
      case 'categories_export':
      
        if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); echo "aaa"; }
        
        $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
                  '<CATEGORIES>' . "\n";
                  
        echo $schema;
                  
        $cat_query = go_db_query("select categories_id, categories_picture, parent_id, sort_order, date_added, last_modified ".
        	                         " from " . DB_TBL_CATEGORIES . " order by parent_id, categories_id");
        while ($cat = go_db_fetch_array($cat_query)) 
        {
          $schema  = '<CATEGORIES_DATA>' . "\n" .
                     '<ID>' . $cat['categories_id'] . '</ID>' . "\n" .
                     '<PARENT_ID>' . $cat['parent_id'] . '</PARENT_ID>' . "\n" .
                     '<PICTURE_URL>' . isohtmlspecialchars($cat['categories_picture']) . '</PICTURE_URL>' . "\n" .
                     '<SORT_ORDER>' . $cat['sort_order'] . '</SORT_ORDER>' . "\n" .
                     '<DATE_ADDED>' . $cat['date_added'] . '</DATE_ADDED>' . "\n" .
                     '<LAST_MODIFIED>' . $cat['last_modified'] . '</LAST_MODIFIED>' . "\n";
                     
          
          $detail_query = go_db_query("select categories_id, language_id, categories_name, " . DB_TBL_LANGUAGES . ".code as lang_code, " . DB_TBL_LANGUAGES . ".name as lang_name from " . DB_TBL_CATEGORIES_DESCRIPTION . "," . DB_TBL_LANGUAGES .
												   " where " . DB_TBL_CATEGORIES_DESCRIPTION . ".categories_id=" . $cat['categories_id'] . " and " . DB_TBL_LANGUAGES . ".languages_id=" . DB_TBL_CATEGORIES_DESCRIPTION . ".language_id");
			
	       while ($details = go_db_fetch_array($detail_query)) 
          {
               $schema .= "<CATEGORIES_DESCRIPTION ID='" . $details["language_id"] ."' CODE='" . $details["lang_code"] . "' NAME='" . $details["lang_name"] . "'>\n";
         		$schema .= "<NAME>" . isohtmlspecialchars($details["categories_name"]) . "</NAME>" . "\n";
         		$schema .= "</CATEGORIES_DESCRIPTION>\n";
          } 
          
          
          $prod2cat_query = go_db_query("select categories_id, items_id from " . DB_TBL_ITEMS_TO_CATEGORIES . 
                                         " where categories_id='" . $cat['categories_id'] . "'");
                                       
          while ($prod2cat = go_db_fetch_array($prod2cat_query)) 
          {
            $schema .="<ITEMS ID='" . $prod2cat["items_id"] ."'></ITEMS>" . "\n";
          }
          
          $schema .= '</CATEGORIES_DATA>' . "\n";
          
          echo $schema;
        }
        $schema = '</CATEGORIES>' . "\n";
        
        echo $schema;
        exit;
        
      case 'producers_export':
      
        if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); }
        $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
                  '<PRODUCERS>' . "\n";
                  
        echo $schema;
                  
        $cat_query = go_db_query("select producers_id, producers_name, producers_picture, date_added, last_modified ".
        	                         " from " . DB_TBL_PRODUCERS . " order by producers_id");
        while ($cat = go_db_fetch_array($cat_query)) 
        {
          $schema  = '<PRODUCERS_DATA>' . "\n" .
                     '<ID>' . $cat['producers_id'] . '</ID>' . "\n" .
                     '<NAME>' . isohtmlspecialchars($cat['producers_name']) . '</NAME>' . "\n" .
                     '<PICTURE>' . isohtmlspecialchars($cat['producers_picture']) . '</PICTURE>' . "\n" .
                     '<DATE_ADDED>' . $cat['date_added'] . '</DATE_ADDED>' . "\n" .
                     '<LAST_MODIFIED>' . $cat['last_modified'] . '</LAST_MODIFIED>' . "\n";
                     
          
          $detail_query = go_db_query("select producers_id, " . DB_TBL_PRODUCERS_INFO . ".languages_id, producers_url, url_clicked, date_last_click, " . DB_TBL_LANGUAGES . ".code as lang_code, " . DB_TBL_LANGUAGES . ".name as lang_name from " . DB_TBL_PRODUCERS_INFO . "," . DB_TBL_LANGUAGES .
												   " where " . DB_TBL_PRODUCERS_INFO . ".producers_id=" . $cat['producers_id'] . " and " . DB_TBL_LANGUAGES . ".languages_id=" . DB_TBL_PRODUCERS_INFO . ".languages_id");
			
	       while ($details = go_db_fetch_array($detail_query)) 
          {
               $schema .= "<PRODUCERS_DESCRIPTION ID='" . $details["languages_id"] ."' CODE='" . $details["lang_code"] . "' NAME='" . $details["lang_name"] . "'>\n";
         		$schema .= "<URL>" . isohtmlspecialchars($details["producers_url"]) . "</URL>" . "\n" ;
         		$schema .= "<URL_CLICK>" . $details["url_clicked"] . "</URL_CLICK>" . "\n" ;
         		$schema .= "<DATE_LAST_CLICK>" . $details["date_last_click"] . "</DATE_LAST_CLICK>" . "\n" ;
         		$schema .= "</PRODUCERS_DESCRIPTION>\n";
          }
          
          $schema .= '</PRODUCERS_DATA>' . "\n";
          echo $schema;
        }
        $schema = '</PRODUCERS>' . "\n";
        
        echo $schema;
        exit;
      
      case 'orders_export':
        $order_from = go_db_producing_input($_GET['order_from']);
        $order_to = go_db_producing_input($_GET['order_to']);
        $order_status = go_db_producing_input($_GET['order_status']);
        
        if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); }
        $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
                  '<ORDER>' . "\n";
        
        echo $schema;
        
        $sql ="select * from " . DB_TBL_ORDERS . " where orders_id >= '" . go_db_input($order_from) . "'";
        if (!isset($order_status) && !isset($order_from)) 
        {
        	 $order_status = 1;
        	 $sql .= "and orders_status = " . $order_status;
        }
        
        $orders_query = go_db_query($sql);
        
        while ($orders = go_db_fetch_array($orders_query)) 
        { 
          $cust_sql = "select * from " . DB_TBL_ATTENDEES . " where attendees_id=" . $orders['attendees_id'];
          $cust_query = go_db_query ($cust_sql);
          if (($cust_query) && ($cust_data = go_db_fetch_array($cust_query)))
          {
            $cust_dob = $cust_data['attendees_dob'];
          }
          
          $schema  = '<ORDER_INFO>' . "\n" .
                     '<ORDER_HEADER>' . "\n" .
                     '<ORDER_ID>' . $orders['orders_id'] . '</ORDER_ID>' . "\n" .
                     '<ATTENDEE_ID>' . $orders['attendees_id'] . '</ATTENDEE_ID>' . "\n" .
                     '<ORDER_DATE>' . $orders['date_purchased'] . '</ORDER_DATE>' . "\n" .
                     '<ORDER_STATUS>' . $orders['orders_status'] . '</ORDER_STATUS>' . "\n" .
                     '<ORDER_CURRENCY>' . isohtmlspecialchars($orders['currency']) . '</ORDER_CURRENCY>' . "\n" .
                     '<ORDER_CURRENCY_VALUE>' . $orders['currency_value'] . '</ORDER_CURRENCY_VALUE>' . "\n" .
                     '</ORDER_HEADER>' . "\n" .
                     '<BILLING_ADDRESS>' . "\n" .
                     '<COMPANY>' . isohtmlspecialchars($orders['billing_company']) . '</COMPANY>' . "\n" .
                     '<NAME>' . isohtmlspecialchars($orders['billing_name']) . '</NAME>' . "\n" .
                     '<STREET>' . isohtmlspecialchars($orders['billing_street_address']) . '</STREET>' . "\n" .
                     '<ZIP>' . isohtmlspecialchars($orders['billing_postcode']) . '</ZIP>' . "\n" .
                     '<CITY>' . isohtmlspecialchars($orders['billing_city']) . '</CITY>' . "\n" .
                     '<SUBURB>' . isohtmlspecialchars($orders['billing_suburb']) . '</SUBURB>' . "\n" .
                     '<STATE>' . isohtmlspecialchars($orders['billing_state']) . '</STATE>' . "\n" .
                     '<LAND>' . isohtmlspecialchars($orders['billing_land']) . '</LAND>' . "\n" .
                     '<TELEPHONE>' . isohtmlspecialchars($orders['attendees_telephone']) . '</TELEPHONE>' . "\n" . 
                     '<EMAIL>' . isohtmlspecialchars($orders['attendees_email_address']) . '</EMAIL>' . "\n" . 
                     '<BIRTHDAY>' . isohtmlspecialchars($cust_dob) . '</BIRTHDAY>' . "\n" .
                     '</BILLING_ADDRESS>' . "\n" .
                     '<DELIVERY_ADDRESS>' . "\n" .
                     '<COMPANY>' . isohtmlspecialchars($orders['delivery_company']) . '</COMPANY>' . "\n" .
                     '<NAME>' . isohtmlspecialchars($orders['delivery_name']) . '</NAME>' . "\n" .
                     '<STREET>' . isohtmlspecialchars($orders['delivery_street_address']) . '</STREET>' . "\n" .
                     '<ZIP>' . isohtmlspecialchars($orders['delivery_postcode']) . '</ZIP>' . "\n" .
                     '<CITY>' . isohtmlspecialchars($orders['delivery_city']) . '</CITY>' . "\n" .
                     '<SUBURB>' . isohtmlspecialchars($orders['delivery_suburb']) . '</SUBURB>' . "\n" .
                     '<STATE>' . isohtmlspecialchars($orders['delivery_state']) . '</STATE>' . "\n" .
                     '<LAND>' . isohtmlspecialchars($orders['delivery_land']) . '</LAND>' . "\n" .
                     '</DELIVERY_ADDRESS>' . "\n" .
                     '<PAYMENT>' . "\n" . 
                     '<PAYMENT_METHOD>' . isohtmlspecialchars($orders['payment_method']) . '</PAYMENT_METHOD>'  . "\n" .
                     '<PAYMENT_CLASS>' . isohtmlspecialchars($orders['payment_class']) . '</PAYMENT_CLASS>'  . "\n";
          switch ($orders['payment_class']) {
            case 'banktransfer': 
              $bank_name = '';
              $bank_blz  = '';
              $bank_kto  = '';
              $bank_inh  = '';
              $bank_stat = -1;
  	          $bank_sql = "select * from banktransfer where orders_id = " . $orders['orders_id'];
              $bank_query = go_db_query($bank_sql);
	            if (($bank_query) && ($bankdata = go_db_fetch_array($bank_query))) {
	              $bank_name = $bankdata['banktransfer_bankname'];
	              $bank_blz  = $bankdata['banktransfer_blz'];
	              $bank_kto  = $bankdata['banktransfer_number'];
	              $bank_inh  = $bankdata['banktransfer_owner'];
	              $bank_stat = $bankdata['banktransfer_status'];
	            }
              $schema .= '<PAYMENT_BANKTRANS_BNAME>' . isohtmlspecialchars($bank_name) . '</PAYMENT_BANKTRANS_BNAME>' . "\n" .
                         '<PAYMENT_BANKTRANS_BLZ>' . isohtmlspecialchars($bank_blz) . '</PAYMENT_BANKTRANS_BLZ>' . "\n" .
                         '<PAYMENT_BANKTRANS_NUMBER>' . isohtmlspecialchars($bank_kto) . '</PAYMENT_BANKTRANS_NUMBER>' . "\n" .
                         '<PAYMENT_BANKTRANS_OWNER>' . isohtmlspecialchars($bank_inh) . '</PAYMENT_BANKTRANS_OWNER>' . "\n" .
                         '<PAYMENT_BANKTRANS_STATUS>' . isohtmlspecialchars($bank_stat) . '</PAYMENT_BANKTRANS_STATUS>' . "\n";
              break;
            case 'banktransfer_sepa': 
              $bank_name = '';
              $bank_iban = '';
              $bank_bic  = '';
              $bank_inh  = '';
              $bank_stat = -1;
  	          $bank_sql = "select * from banktransfer_sepa where orders_id = " . $orders['orders_id'];
              $bank_query = go_db_query($bank_sql);
	            if (($bank_query) && ($bankdata = go_db_fetch_array($bank_query))) {
	              $bank_name = $bankdata['banktransfer_sepa_bankname'];
	              $bank_iban = $bankdata['banktransfer_sepa_iban'];
	              $bank_bic  = $bankdata['banktransfer_sepa_bic'];
	              $bank_inh  = $bankdata['banktransfer_sepa_owner'];
	              $bank_stat = $bankdata['banktransfer_sepa_status'];
	            }
              $schema .= '<PAYMENT_BANKTRANS_BNAME>' . isohtmlspecialchars($bank_name) . '</PAYMENT_BANKTRANS_BNAME>' . "\n" .
                         '<PAYMENT_BANKTRANS_IBAN>' . isohtmlspecialchars($bank_iban) . '</PAYMENT_BANKTRANS_IBAN>' . "\n" .
                         '<PAYMENT_BANKTRANS_BIC>' . isohtmlspecialchars($bank_bic) . '</PAYMENT_BANKTRANS_BIC>' . "\n" .
                         '<PAYMENT_BANKTRANS_OWNER>' . isohtmlspecialchars($bank_inh) . '</PAYMENT_BANKTRANS_OWNER>' . "\n" .
                         '<PAYMENT_BANKTRANS_STATUS>' . isohtmlspecialchars($bank_stat) . '</PAYMENT_BANKTRANS_STATUS>' . "\n";
              break;
          }           
          $schema .= '</PAYMENT>' . "\n" . 
                     '<SHIPPING>' . "\n" . 
                     '<SHIPPING_METHOD>' . isohtmlspecialchars($orders['shipping_method']) . '</SHIPPING_METHOD>'  . "\n" .
                     '<SHIPPING_CLASS>' . isohtmlspecialchars($orders['shipping_class']) . '</SHIPPING_CLASS>'  . "\n" .
                     '</SHIPPING>' . "\n" .                      
                     '<ORDER_ITEMS>' . "\n";
          $items_query = go_db_query("select orders_items_id, items_id, items_model, items_name, final_price, items_tax, items_quantity from " . DB_TBL_ORDERS_ITEMS . " where orders_id = '" . $orders['orders_id'] . "'");
          while ($items = go_db_fetch_array($items_query)) 
          {
            $schema .= '<ITEM>' . "\n" .
                       '<ITEMS_ID>' . $items['items_id'] . '</ITEMS_ID>' . "\n" .
                       '<ITEMS_QUANTITY>' . $items['items_quantity'] . '</ITEMS_QUANTITY>' . "\n" .
                       '<ITEMS_MODEL>' . isohtmlspecialchars($items['items_model']) . '</ITEMS_MODEL>' . "\n" .
                       '<ITEMS_NAME>' . isohtmlspecialchars($items['items_name']) . '</ITEMS_NAME>' . "\n" .
                       '<ITEMS_PRICE>' . $items['final_price'] . '</ITEMS_PRICE>' . "\n" .
                       '<ITEMS_TAX>' . $items['items_tax'] . '</ITEMS_TAX>' . "\n";
                       
            
            $characteristics_query = go_db_query("select items_options, items_options_values, options_values_price, price_prefix from " . DB_TBL_ORDERS_ITEMS_CHARACTERISTICS . " where orders_id = '" .$orders['orders_id'] . "' and orders_items_id = '" . $items['orders_items_id'] . "'");
            if (go_db_num_rows($characteristics_query)) 
            {
              while ($characteristics = go_db_fetch_array($characteristics_query)) 
              {
                $schema .= '<OPTION>' . "\n" .
                           '<ITEMS_OPTIONS>' .  isohtmlspecialchars($characteristics['items_options']) . '</ITEMS_OPTIONS>' . "\n" . 
                           '<ITEMS_OPTIONS_VALUES>' .  isohtmlspecialchars($characteristics['items_options_values']) . '</ITEMS_OPTIONS_VALUES>' . "\n" .
                           '<ITEMS_OPTIONS_PRICE>' .  $characteristics['price_prefix'] . ' ' . $characteristics['options_values_price'] . '</ITEMS_OPTIONS_PRICE>' . "\n" .
                           '</OPTION>' . "\n";
              }
            }            
            $schema .=  '</ITEM>' . "\n";
          }
		    $schema .= '</ORDER_ITEMS>' . "\n";                     
          $schema .= '<ORDER_TOTAL>' . "\n";
          
          $totals_query = go_db_query("select title, value, class, sort_order from " . DB_TBL_ORDERS_TOTAL . " where orders_id = '" . $orders['orders_id'] . "' order by sort_order");
          while ($totals = go_db_fetch_array($totals_query)) 
          {
            $total_prefix = "";
            $total_tax  = "";
            $total_prefix = $order_total_class[$totals['class']]['prefix'];
            $total_tax = $order_total_class[$totals['class']]['tax'];
            $schema .= '<TOTAL>' . "\n" .
                       '<TOTAL_TITLE>' . isohtmlspecialchars($totals['title']) . '</TOTAL_TITLE>' . "\n" .
                       '<TOTAL_VALUE>' . isohtmlspecialchars($totals['value']) . '</TOTAL_VALUE>' . "\n" .
                       '<TOTAL_CLASS>' . isohtmlspecialchars($totals['class']) . '</TOTAL_CLASS>' . "\n" .
                       '<TOTAL_SORT_ORDER>' . isohtmlspecialchars($totals['sort_order']) . '</TOTAL_SORT_ORDER>' . "\n" .
                       '<TOTAL_PREFIX>' . isohtmlspecialchars($total_prefix) . '</TOTAL_PREFIX>' . "\n" .
                       '<TOTAL_TAX>' . isohtmlspecialchars($total_tax) . '</TOTAL_TAX>' . "\n" . 
                       '</TOTAL>' . "\n";
          }
          $schema .= '</ORDER_TOTAL>' . "\n";
          $comments_query = go_db_query("select comments from " . DB_TBL_ORDERS_STATUS_HISTORY . " where orders_id = '" . $orders['orders_id'] . "' and orders_status_id = '" . $orders['orders_status'] . "' ");
          if ($comments =  go_db_fetch_array($comments_query)) {
            $schema .=  '<ORDER_COMMENTS>' . isohtmlspecialchars($comments['comments']) . '</ORDER_COMMENTS>' . "\n";
          }
          $schema .= '</ORDER_INFO>' . "\n\n";
          echo $schema;
        }
        $schema = '</ORDER>' . "\n\n";
        
        echo $schema;
        exit;
      
      case 'items_export':
        if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); }
        $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
                  '<ITEMS>' . "\n";
        echo $schema;
                  
        $sql = "select items_id, items_quantity, items_model, items_picture, items_price, " .
               "items_date_added, items_last_modified, items_date_available, items_date_available_end, items_weight, " .
               "items_status, items_tax_class_id, producers_id, items_ordered from " . DB_TBL_ITEMS;
               
        $from = go_db_producing_input($_GET['items_from']);
        $anz  = go_db_producing_input($_GET['items_count']);
        if (isset($from))
        {
          if (!isset($anz)) $anz=1000;
          
          $sql .= " limit " . $from . "," . $anz;
        }
                  
        $orders_query = go_db_query($sql);
        while ($items = go_db_fetch_array($orders_query)) 
        {
          $schema  = '<ITEM_INFO>' . "\n" .
                     '<ITEM_DATA>' . "\n" .
                     '<ITEM_ID>' . $items['items_id'] . '</ITEM_ID>' . "\n" .
                     '<ITEM_QUANTITY>' . $items['items_quantity'] . '</ITEM_QUANTITY>' . "\n" .
                     '<ITEM_MODEL>' . isohtmlspecialchars($items['items_model']) . '</ITEM_MODEL>' . "\n" .
                     '<ITEM_PICTURE>' . isohtmlspecialchars($items['items_picture']) . '</ITEM_PICTURE>' . "\n" .
                     '<ITEM_PRICE>' . $items['items_price'] . '</ITEM_PRICE>' . "\n" .
                     '<ITEM_WEIGHT>' . $items['items_weight'] . '</ITEM_WEIGHT>' . "\n" .
                     '<ITEM_STATUS>' . $items['items_status'] . '</ITEM_STATUS>' . "\n" .
                     '<ITEM_TAX_CLASS_ID>' . $items['items_tax_class_id'] . '</ITEM_TAX_CLASS_ID>' . "\n"  .
                     '<PRODUCERS_ID>' . $items['producers_id'] . '</PRODUCERS_ID>' . "\n" .
                     
                     '<ITEM_DATE_ADDED>' . $items['items_date_added'] . '</ITEM_DATE_ADDED>' . "\n" .
                     '<ITEM_LAST_MODIFIED>' . $items['items_last_modified'] . '</ITEM_LAST_MODIFIED>' . "\n" .
                     '<ITEM_DATE_AVAILABLE>' . $items['items_date_available'] . '</ITEM_DATE_AVAILABLE>' . "\n" .
                     '<ITEM_DATE_AVAILABLE_END>' . $items['items_date_available_end'] . '</ITEM_DATE_AVAILABLE_END>' . "\n" .
                     
                     '<ITEMS_ORDERED>' . $items['items_ordered'] . '</ITEMS_ORDERED>' . "\n" ;
                     
          $detail_query = go_db_query("select items_id, language_id, items_name, " . DB_TBL_ITEMS_DESCRIPTION . 
          										".items_description, items_url, name as language_name, code as language_code " .
 												   "from " . DB_TBL_ITEMS_DESCRIPTION . ", " . DB_TBL_LANGUAGES .
												   " where " . DB_TBL_ITEMS_DESCRIPTION . ".language_id=" . DB_TBL_LANGUAGES . ".languages_id " .
												   "and " . DB_TBL_ITEMS_DESCRIPTION . ".items_id=" . $items['items_id']);
												  
			 
												  
	       while ($details = go_db_fetch_array($detail_query)) 
          {
         		$schema .= "<ITEM_DESCRIPTION ID='" . $details["language_id"] ."' CODE='" . $details["language_code"] . "' NAME='" . $details["language_name"] . "'>\n";
         		           
         		if ($details["items_name"] !='Array')
         		{
         			$schema .= "<NAME>" . isohtmlspecialchars($details["items_name"]) . "</NAME>" . "\n" ;
         		}
         		$schema .=  "<URL>" . isohtmlspecialchars($details["items_url"]) . "</URL>" . "\n" ;
         		
         		$prod_details = $details["items_description"];
         		if ($prod_details != 'Array')
         		{
         			$schema .=  "<DESCRIPTION>" . isohtmlspecialchars($prod_details) . "</DESCRIPTION>" . "\n";
         		}
         		$schema .= "</ITEM_DESCRIPTION>\n";
          }
          $schema .= '</ITEM_DATA>' . "\n" .
                     '</ITEM_INFO>' . "\n";
          echo $schema;
        }
        $schema = '</ITEMS>' . "\n\n";
        echo $schema;
        exit;   
  case 'attendees_export':
		if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); }
		$schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
			'<ATTENDEES>' . "\n";
			
		echo $schema;
			
		$from = go_db_producing_input($_GET['attendees_from']);
		$anz  = go_db_producing_input($_GET['attendees_count']);
		
		$address_query = "select c.attendees_gender, c.attendees_id, c.attendees_firstname, c.attendees_lastname,c.attendees_dob, c.attendees_email_address, c.attendees_telephone, c.attendees_fax, 
                             ci.attendees_info_date_member_created  as attendees_date_member_created, 
                             a.entry_firstname as firstname, a.entry_lastname as lastname, a.entry_company as company, a.entry_street_address as street_address, a.entry_city as city, a.entry_postcode as postcode, 
                             co.lands_iso_code_2 as land 
                      from " . DB_TBL_ATTENDEES. " c, ". DB_TBL_ATTENDEES_INFO. " ci, ". DB_TBL_DIRECTORY_TO_ADDRESS . " a , ".DB_TBL_LANDS." co 
                      where c.attendees_id = ci.attendees_info_id
                        AND c.attendees_id = a.attendees_id 
                        AND c.attendees_default_address_id = a.directory_to_address_id 
                        AND a.entry_land_id  = co.lands_id";
		if (isset($from)) 
		{
			if (!isset($anz)) $anz = 1000;
			$address_query.= " limit " . $from . "," . $anz;
		}
		$address_result = go_db_query($address_query);
		
		while ($address = go_db_fetch_array($address_result)) 
		{
			$schema = '<ATTENDEES_DATA>' . "\n";		
				foreach($address as $key => $value) 
				{
					$schema.= '<'.strtoupper($key).'>'.isohtmlspecialchars($value).'</'.strtoupper($key).'>'."\n";
				}
			$schema .= '</ATTENDEES_DATA>' . "\n";		
			echo $schema;
		}
		
		$schema = '</ATTENDEES>' . "\n\n";
		echo $schema;
		exit;  
  case 'attendees_newsletter_export':
		if (defined('SET_TIME_LIMIT')) { go_set_time_limit(0); }
		$schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
			'<ATTENDEES>' . "\n".
			
		$from = go_db_producing_input($_GET['attendees_from']);
		$anz  = go_db_producing_input($_GET['attendees_count']);
		
		$address_query = "select *
                      from " . DB_TBL_ATTENDEES. " 
                      where attendees_newsletter = 1
                     ";
		if (isset($from)) {
			if (!isset($anz)) $anz = 1000;
			$address_query.= " limit " . $from . "," . $anz;
		}
		$address_result = go_db_query($address_query);
		
		while ($address = go_db_fetch_array($address_result)) 
		{
			$schema .= '<ATTENDEES_DATA>' . "\n";		
      	$schema .= '<ATTENDEES_ID>' . $address['attendees_id'] . '</ATTENDEES_ID>' . "\n";	
      	$schema .= '<ATTENDEES_GENDER>' . $address['attendees_gender'] . '</ATTENDEES_GENDER>' . "\n";	
      	$schema .= '<ATTENDEES_FIRSTNAME>' . $address['attendees_firstname'] . '</ATTENDEES_FIRSTNAME>' . "\n";	
      	$schema .= '<ATTENDEES_LASTNAME>' . $address['attendees_lastname'] . '</ATTENDEES_LASTNAME>' . "\n";	
      	$schema .= '<ATTENDEES_EMAIL_ADDRESS>' . $address['attendees_email_address'] . '</ATTENDEES_EMAIL_ADDRESS>' . "\n";	
			$schema .= '</ATTENDEES_DATA>' . "\n";		
		}
		
		$schema .= '</ATTENDEES>' . "\n\n";
		echo $schema;
		exit; 
  
	
   case 'version': 
        $schema = '<?xml version="1.0" encoding="' . CHARSET . '"?>' . "\n" .
                  '<STATUS>' . "\n" .
                  '<STATUS_DATA>' . "\n" .
                  '<ACTION>' . $_GET['action'] . '</ACTION>' . "\n" .
                  '<CODE>' . '111' . '</CODE>' . "\n" .              
                  '<SCRIPT_VER>' . $version_nr . '</SCRIPT_VER>' . "\n" . 
                  '<SCRIPT_DATE>' . $version_datum . '</SCRIPT_DATE>' . "\n" . 
                  '</STATUS_DATA>' . "\n" .
                  '</STATUS>' . "\n\n";
       echo $schema; 
       exit;
     }
  }
?>
