<?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 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/


if (isset($pw_mispell)){ 
?>
<tr><td><?php echo $pw_string; ?></td></tr>
<?php
 } 
$listing_split = new splitPageResults($listing_sql, MAX_SHOW_SEARCH_RESULTS, 'p.items_id');
  if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2"> 
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_SHOW_NUMBER_OF_ITEMS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_SHOW_PAGE_LINKS, go_get_all_get_parameter(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
  $list_frame_contents = array();

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
      case 'ITEM_LIST_MODEL':
        $lc_text = DB_TBL_ABOVE_MODEL;
        $lc_align = '';
        break;
      case 'ITEM_LIST_NAME':
        $lc_text = DB_TBL_ABOVE_ITEMS;
        $lc_align = '';
        break;
      case 'ITEM_LIST_PRODUCER':
        $lc_text = DB_TBL_ABOVE_PRODUCER;
        $lc_align = '';
        break;
      case 'ITEM_LIST_PRICE':
        $lc_text = DB_TBL_ABOVE_PRICE;
        $lc_align = 'right';
        break;
      case 'ITEM_LIST_QUANTITY':
        $lc_text = '';
        $lc_align = 'center';
        break;
      case 'ITEM_LIST_WEIGHT':
        $lc_text = DB_TBL_ABOVE_WEIGHT;
        $lc_align = 'right';
        break;
      case 'ITEM_LIST_PICTURE':
        $lc_text = DB_TBL_ABOVE_PICTURE;
        $lc_align = 'center';
        $cell_pos = $col+1;
        break;
      case 'ITEM_LIST_BUY_NOW':
        $lc_text = DB_TBL_ABOVE_BUY_NOW;
        $lc_align = 'center';
        break;
      case 'ITEM_LIST_INFO':
        $lc_text = DB_TBL_ABOVE_INFO;
        $lc_align = 'center';
        break;
    }
    if ( ($column_list[$col] != 'ITEM_LIST_BUY_NOW') && ($column_list[$col] != 'ITEM_LIST_PICTURE') ) {
      $lc_text = go_create_sort_heading($_GET['sort'], $col+1, $lc_text);
    }
		if (STYLE_CSS == '1'){
      $params = 'class="header_items_listing_css"';
		}else{
			$params = 'class="itemListing-heading"';
		}
    
    $list_frame_contents[0][] = array('align' => $lc_align,
                                    'params' => $params,
                                    'text' => '&nbsp;' . $lc_text . '&nbsp;');
  }
  if ($listing_split->number_of_rows > 0) {
    $rows = 0;
    $listing_query = go_db_query($listing_split->sql_query);
    while ($listing = go_db_fetch_array($listing_query)) {
      $rows++;
      $items_description_in_cat_list = go_get_items_description_in_cat_list($listing['items_id']);
      if (($rows/2) == floor($rows/2)) {
        $list_frame_contents[] = array('params' => 'class="itemListing-even"');
        if (go_not_null($items_description_in_cat_list)){
        	$list_frame_contents[$rows]['ad_cell_params_tr'] = 'class="itemListing-even"';
      	}
      } else {
        $list_frame_contents[] = array('params' => 'class="itemListing-odd"');
        if (go_not_null($items_description_in_cat_list)){ 
        	$list_frame_contents[$rows]['ad_cell_params_tr'] = 'class="itemListing-odd"';
      	}
      }
			if (go_not_null($items_description_in_cat_list)){
      	$list_frame_contents[$rows]['ad_cell'] = '1';
      	$list_frame_contents[$rows]['ad_cell_text'] = $items_description_in_cat_list;
      	$list_frame_contents[$rows]['ad_cell_params_td'] = 'class="itemListing-data"';
      	$list_frame_contents[$rows]['cell_pos'] = $cell_pos;
      	$list_frame_contents[$rows]['activ_col'] = $col;
      }
      
      
      $cur_row = sizeof($list_frame_contents) - 1;
      for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
        $lc_align = '';
        $rap = '';
                     
        switch ($column_list[$col]) {
          case 'ITEM_LIST_MODEL':
            $lc_align = '';
            $lc_text = '&nbsp;' . $listing['items_model'] . '&nbsp;';
            break;
          case 'ITEM_LIST_NAME': 
            $lc_align = '';
            if (isset($_GET['producers_id'])) {	
              $lc_text = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'producers_id=' . $_GET['producers_id'] . '&items_id=' . $listing['items_id']) . '">' . $listing['items_name'] . '</a>&nbsp;<br><br>' . $listing['items_name2'];
            } else {
              $lc_text = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], ($bigPfad ? 'bigPfad=' . $bigPfad . '&' : '') . 'items_id=' . $listing['items_id']) . '">' . $listing['items_name'] . '</a>&nbsp;<br><br>' . $listing['items_name2'];
            } 
            break;
          case 'ITEM_LIST_INFO':
            $lc_align = 'center';
            if (isset($_GET['producers_id'])) {	
              $lc_text = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'producers_id=' . $_GET['producers_id'] . '&items_id=' . $listing['items_id']) . '">' . go_picture_button('button_info.gif', 'Info') . '</a>&nbsp;';
            } else {
              $lc_text = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], ($bigPfad ? 'bigPfad=' . $bigPfad . '&' : '') . 'items_id=' . $listing['items_id']) . '">' . go_picture_button('button_info.gif', 'Info') . '</a>&nbsp;';
            } 
            break;
          case 'ITEM_LIST_PRODUCER':
            $lc_align = '';
            $lc_text = '&nbsp;<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_29], 'producers_id=' . $listing['producers_id']) . '">' . $listing['producers_name'] . '</a>&nbsp;';
            break;
          case 'ITEM_LIST_PRICE':

                    if ($listing['items_price']=="123456.7890"){
              		$lc_text = '&nbsp;' . PRICE_ON_DEMAND_TEXT2 . '&nbsp;';	            		
            	}else{ 
				$item_service_status_query = go_db_query("select * from " . DB_TBL_ITEMS . " where items_id = '" . (int)$listing['items_id'] . "'");
				$item_service_status = go_db_fetch_array($item_service_status_query);
				$after_price = '';
				$before_price = '';	
          	// Loopthrough8b	
				if ($item_service_status['iss_masseinheit'] == '1'){						
					$before_price = BEFORE_PRICE_MASSEINHEIT;
				}
				if ($item_service_status['domainservice_status'] != '0'){					
					$after_price = $item_service_status['domainservice_zahlungsintervall'];
					$after_price = str_replace("0", " (" . DOMAIN_PAYMENT_ONCE . ")", $after_price);
					$after_price = str_replace("12", " (" . DOMAIN_PAYMENT_ANNUAL . ")", $after_price);
					$after_price = str_replace("1", " (" . DOMAIN_PAYMENT_MONTHLY . ")", $after_price);
				}
	    			$rap = ' nowrap';
            			$lc_align = 'right';
				$items_price_s = '&nbsp;'.$currencies->display_special_pricing( $item_service_status , $attendee_id).'&nbsp;';
				if (PRICES_LOGGED_IN == 'false') {
					$item_price_d = $items_price_s;
				}
				if ((PRICES_LOGGED_IN == 'true') && (!go_session_is_registered('attendee_id'))) {
					$item_price_d = ('<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_40], '','SSL') . '">'  . PRICES_LOGGED_IN_TEXT . '</a>&nbsp;' );
				} else {
					$item_price_d = $items_price_s;
				}
				$lc_text =  $before_price . $item_price_d . $after_price . $currencies->shipping_tag($item_service_status);
            	}
            break;

// Erweiterung Bert Bestandsanzeige ;
          case 'ITEM_LIST_QUANTITY':
            $lc_align = 'center';
				
						$prod_quantity = go_get_items_stock($listing['items_id']);

// ist die Bestandsanzeige per Ampel eingeschaltet ? 
            if (STOCK_LIMIT_LEVEL == 'true' ) {

// wenn ja 

// die Einstellungen für die gelbe und orange Ampel aus der DB holen 
$orange_light_query = go_db_query("SELECT * FROM " . DB_TBL_LIMIT_LEVEL_CONFIG . " WHERE set_it_up_key = 'SHOW_ORANGE_TRAFFIC_LIGHT' ");
$orange_light_sql = go_db_fetch_array($orange_light_query);
$orange_light = $orange_light_sql["set_it_up_value"];

$yellow_light_query = go_db_query("SELECT * FROM " . DB_TBL_LIMIT_LEVEL_CONFIG . " WHERE set_it_up_key = 'SHOW_YELLOW_TRAFFIC_LIGHT' ");
$yellow_light_sql = go_db_fetch_array($yellow_light_query);
$yellow_light = $yellow_light_sql["set_it_up_value"];

// wenn Artikelbestand weniger "1" ist die Ampel "ROT" 
                if ($prod_quantity < 1){
		  				  $lc_text = '&nbsp; &nbsp; <img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'ampel_rot_list.gif" border="0" title="Artikel zur Zeit nicht verfügbar">&nbsp; &nbsp; ';
                }
// wenn Artikelbestand weniger oder gleich "ORANGE" 
                elseif ($prod_quantity <= $orange_light){
		  				  $lc_text = '&nbsp; &nbsp; <img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'ampel_orange_list.gif" border="0" title="Artikel nur noch sehr begrenzt verfügbar">&nbsp; &nbsp; ';
                }
// wenn Artikelbestand weniger oder gleich "GELB" 
                elseif ($prod_quantity <= $yellow_light){
		  				  $lc_text = '&nbsp; &nbsp; <img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'ampel_gelb_list.gif" border="0" title="Artikel begrenzt verfügbar">&nbsp; &nbsp; ';
                }
// wenn Artikelbestand mehr als "GELB" ist die Ampel grün 
                elseif ($prod_quantity > $yellow_light){
		  				  $lc_text = '&nbsp; &nbsp; <img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'ampel_gruen_list.gif" border="0" title="Artikel ausreichend verfügbar">&nbsp; &nbsp; ';
                }
            }
            else {

// Ampelanzeige ist ausgeschaltet 
		  				  if ($prod_quantity < 1){
		  				  $lc_text = '<img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'nicht_am_lager.gif" border="0">'; 	
		  				  }
		  				  else{
		  				  $lc_text = '<img src="' . FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES . 'am_lager.gif" border="0">';
		  				  }	 
            }
            break;            
// Ende ;
          case 'ITEM_LIST_WEIGHT':
            $lc_align = 'right';
            $lc_text = '&nbsp;' . $listing['items_weight'] . '&nbsp;';
            break;
          case 'ITEM_LIST_PICTURE':
            $lc_align = 'center';

            if (isset($_GET['producers_id'])) {
              $lc_text = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'producers_id=' . $_GET['producers_id'] . '&items_id=' . $listing['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . $listing['items_picture'], $listing['items_name'], SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '</a>';
            } else {
            	$picture_frame = picture_frame();
              $lc_text = $picture_frame['begin_frame'] . '<a href="'. go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], ($bigPfad ? 'bigPfad=' . $bigPfad . '&' : '') . 'items_id=' . $listing['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . $listing['items_picture'], $listing['items_name'], SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '</a>' . $picture_frame['end_frame'] . '';
            }			
            if (go_not_null($items_description_in_cat_list)){		
            	
						}
            break;
          case 'ITEM_LIST_BUY_NOW':
            $lc_align = 'right';
            if ((STOCK_ALLOW_CHECKOUT == 'false')&&(go_get_items_stock($listing['items_id']) < 1)) {
	          	$lc_text = '&nbsp;';
            } else {
            	if ($listing['items_price']=="123456.7890"){
			       		$preistext = QUERYTEXT1 . $listing['items_name'] . QUERYTEXT2 . $listing['items_model'] . QUERYTEXT3 ;
			    			$preistext = urlencode($preistext);
			      		$preistext = "<a href=\"" . $GLOBALS[CONFIG_NAME_FILE][main_bigware_8] . "?enquiry=$preistext\">" . go_picture_button('button_fragen_now.gif', PICTURE_BUTTON_BUY_NOW) . "</a>";
              	$lc_text = $preistext;
            	}
							else{		
								
								// Hat Artikel Produktmerkmale?			
								$count_merkmal_query = go_db_query("select count(*) as merkmal_total from " . DB_TBL_ITEMS_CHARACTERISTICS . " where items_id='" . $listing['items_id'] . "'");
					    	$count_merkmal_result = go_db_fetch_array($count_merkmal_query);	
					    	// Ist Artikel ein Masseinheitenartikel?
								$item_service_status_query = go_db_query("select * from " . DB_TBL_ITEMS . " where items_id = '" . (int)$listing['items_id'] . "'");
								$item_service_status = go_db_fetch_array($item_service_status_query);
								// Loopthrough8a
								
								// wenn ja (Masseinheit oder Produktmerkmal), dann geht der Kaufen Button doch direkt in den Artikel und nicht in den Warenkorb
								if (($item_service_status['iss_masseinheit'] == '1') OR ($count_merkmal_result['merkmal_total'] > 0)){
					    		$form = '';
					    		$buy_now_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], ($bigPfad ? 'bigPfad=' . $bigPfad . '&' : '') . 'items_id=' . $listing['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';
					    		$submit_item_quant = '';
					    		$hidden = '';
					    		$endform = '';
								}else{     // ansonsten in den Warenkorb	
								
									if ($item_service_status['domainservice_status'] != '0'){
											
										$zahlungsintervall = $item_service_status['domainservice_zahlungsintervall'];
										$zahlungsintervall = str_replace("0", " (" . DOMAIN_PAYMENT_ONCE . ")", $zahlungsintervall);
										$zahlungsintervall = str_replace("12", " (" . DOMAIN_PAYMENT_ANNUAL . ")", $zahlungsintervall);
										$zahlungsintervall = str_replace("1", " (" . DOMAIN_PAYMENT_MONTHLY . ")", $zahlungsintervall);
													
										$item_price_d = $item_price_d . $zahlungsintervall;
										$items_price_domainservice = strip_tags($item_price_d);	
										
										$buy_now_button = go_picture_submit('button_buy_now_domain.gif', PICTURE_BUTTON_IN_CART);
										$submit_item_quant = '<input type="hidden" name="cart_quantity" value="1">';
										
										$form = go_fetch_form ('cart_quantity', go_href_link($GLOBALS[CONFIG_NAME_FILE][bestell_domaincheck], go_get_all_get_parameter(array('action')), 'NONSSL'),'post','');											
										$hidden .= go_fetch_hidden_field ('items_price_domainservice', $items_price_domainservice,'');
										$hidden .= go_fetch_hidden_field ('gewuenschtes_paket', $listing['items_name'],'');
										
									}
									else{								
										$form = go_fetch_form ('cart_quantity', go_href_link(basename($PHP_SELF), go_get_all_get_parameter(array('action')) . 'action=add_item', 'NONSSL'),'post','');
										$buy_now_button = go_picture_submit('button_buy_now.gif', PICTURE_BUTTON_IN_CART);
										$submit_item_quant = '<input type="text" name="cart_quantity" value="1" maxlength="2" size="2"><br>';
									}
									// Loopthrough8
									
									if (file_exists(FOLDER_ABSOLUT_CATALOG . 'modules/download')) {
						         $download_items_id = $listing['items_id'];
						         require(FOLDER_ABSOLUT_CATALOG . 'modules/download/load_this/mods/mods_bigware_7_10_11.php');
						      }
							
									$hidden .= go_fetch_hidden_field ('items_id', $listing['items_id'],'');
									$endform = '</form>';

								}									    	
						
								if (PRICES_LOGGED_IN == 'false')
									$buy_now_button_d = $buy_now_button;
								if ((PRICES_LOGGED_IN == 'true') && (!go_session_is_registered('attendee_id'))) {
									$buy_now_button_d = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_40], '','SSL') . '"></a>&nbsp;';
								} else {
									$buy_now_button_d =  $hidden . $submit_item_quant . '&nbsp;'. $buy_now_button;
								}
								$lc_text = $form .  $buy_now_button_d . $endform; 
            	}            	
            	
            }
            break;
        }
        $list_frame_contents[$cur_row][] = array('align' => $lc_align,
                                               'params' => 'class="itemListing-data"' . $rap,
                                               'text'  => $lc_text);
       
      }
    }
    new itemListingBox($list_frame_contents);
  } else {
    $list_frame_contents = array();
    $list_frame_contents[0] = array('params' => 'class="itemListing-odd"');
    $list_frame_contents[0][] = array('params' => 'class="itemListing-data"',
                                   'text' => TEXT_NO_ITEMS);
    new itemListingBox($list_frame_contents);
  }
  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" style="width: 100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_SHOW_NUMBER_OF_ITEMS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_SHOW_PAGE_LINKS, go_get_all_get_parameter(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
?>
