<?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 gro�e 
  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
  
  -----------------------------------------------------------------------
  
 ##################################################################################


*/
///$items_name = wordwrap( $items_name, 20, "<br />\n" )

	$picture_frame = picture_frame(); 

  $sql=go_db_query('SELECT * FROM erw_einstellungen');
  $row=go_db_fetch_array($sql);  
  $linie = $row['linie'];
  
  
  $info_frame_contents = array();
  $info_frame_contents[] = array('text' => sprintf('<a class="headerNavigation" href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_38]) . '">' . DB_TBL_ABOVE_NEW_ITEMS . '</a>', pagadors_strftime('%B')));
  new contentBoxGeneralsign($info_frame_contents);
  global $attendee_id;
  $attendee_group_query = go_db_query("select attendees_group_id from " . DB_TBL_ATTENDEES . " where attendees_id =  '" . $attendee_id . "'");
  $attendee_group = go_db_fetch_array($attendee_group_query);
        
  if ( (!isset($new_items_category_id)) || ($new_items_category_id == '0') ) {  
    // angepasst
    if (SHOW_ONLY_ITEMS_WITH_PICTURE == 'true'){
    $new_items_query = go_db_query("select distinct max(p.items_id), p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and items_status = '1' AND (p.items_picture != 'alle/nopic.gif' AND p.items_picture != '') GROUP BY p.items_id order by p.items_date_added desc limit " . MAX_SHOW_NEW_ITEMS);    	
  	}
  	else{
    $new_items_query = go_db_query("select distinct max(p.items_id), p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and items_status = '1' GROUP BY p.items_id order by p.items_date_added desc limit " . MAX_SHOW_NEW_ITEMS);
  	}
  } else { 
    // angepasst
    if (SHOW_ONLY_ITEMS_WITH_PICTURE == 'true'){
    $new_items_query = go_db_query("select distinct p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, if(s.status, s.specials_new_items_price, p.items_price) as items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_items_category_id . "' and p.items_status = '1' AND (p.items_picture != 'alle/nopic.gif') AND (p.items_picture != '') order by rand() desc limit " . MAX_SHOW_NEW_ITEMS);    
  	}
	
  	else{
    $new_items_query = go_db_query("select distinct p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, if(s.status, s.specials_new_items_price, p.items_price) as items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_items_category_id . "' and p.items_status = '1' order by rand() desc limit " . MAX_SHOW_NEW_ITEMS);
  	}

  if ( (!isset($new_items_category_id)) || ($new_items_category_id == '0') ) {  
    // angepasst
    if (SHOW_ONLY_ITEMS_WITH_PICTURE == 'true'){
    $new_items_query = go_db_query("select distinct max(p.items_id), p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and items_status = '1' AND (p.items_picture != 'alle/nopic.gif' AND p.items_picture != '') GROUP BY p.items_id order by p.items_date_added desc limit " . MAX_SHOW_NEW_ITEMS);    	
  	}
  	else{
    $new_items_query = go_db_query("select distinct max(p.items_id), p.items_id, p.items_picture, p.items_tax_class_id, p.items_model, items_price from ((" . DB_TBL_ITEMS . " p) left join " . DB_TBL_SPECIALS . " s on p.items_id = s.items_id, " . DB_TBL_ITEMS_TO_CATEGORIES . " p2c, " . DB_TBL_CATEGORIES . " c) where c.categories_status='1' and p.items_id = p2c.items_id and p2c.categories_id = c.categories_id and items_status = '1' GROUP BY p.items_id order by p.items_date_added desc limit " . MAX_SHOW_NEW_ITEMS);
  	}
  } 
  
  } 
  $row = 0;
  $col = 0;
  $info_frame_contents = array();
while ($new_items = go_db_fetch_array($new_items_query)) {
  	
		$new_items['items_name'] = go_get_items_name($new_items['items_id'] ) ; $go_get_items_name = wordwrap($items_name, 2,"\n", "<br />\n" );
		
    $new_items['items_name2'] = go_get_items_name2($new_items['items_id']);
    if ($new_items['items_name2'] != ""){$new_items['items_name2'] = $new_items['items_name2'] . '';}
	

	
	if ($col == "0"){
    	$zellenstyle = 'style="border-right-style: ' . $linie . '; border-right-width: 0px; border-bottom-style: ' . $linie . '; border-bottom-width: 0px; vertical-align:bottom"';	
    }
    else{
    	$zellenstyle = 'style="border-bottom-style:' . $linie . '; border-bottom-width: 0px; vertical-align:bottom"';
		
} 
		

				
				
    if ($new_items['items_price']=="123456.7890"){
			$preistext = QUERYTEXT1 . $new_items['items_name'] . QUERYTEXT2 . $new_items['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>";
			$info_frame_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'class="smallText" valign="top"' . $zellenstyle,
                                           'text' => $picture_frame['begin_frame'] . '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . $new_items['items_picture'], $new_items['items_name'], SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '</a>' . $picture_frame['end_frame'] . '<a class="txt" href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . $new_items['items_name'] .  $new_items['items_name2'] . '</a><br><table border="0" cellpadding="5" cellspacing="0"><tr><td style="width: 50%">' . PRICE_ON_DEMAND_TEXT2 . '</td><td style="width: 50%">' . $preistext . '</td></tr></table>');
		}
    else{ 
 				$item_service_status_query = go_db_query("select * from " . DB_TBL_ITEMS . " where items_id = '" . (int)$new_items['items_id'] . "'");
				$item_service_status = go_db_fetch_array($item_service_status_query);
				$after_price = '';
				$before_price = '';	
				$no_normal_form = '';  // individuelle weiterleitung
 
 
 
      	// Loopthrough7b	
      	
				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);
				}
        $new_items['items_price'] = $currencies->display_special_pricing($item_service_status,  $attendee_id);
        if (PRICES_LOGGED_IN == 'false') {                                                     
        	$item_price_d = $before_price . $new_items['items_price'] . $after_price .$currencies->shipping_tag($item_service_status);
          if ((STOCK_ALLOW_CHECKOUT == 'false')&&(go_get_items_stock($new_items['items_id']) < 1)) {
             		$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';            	
          }
          else{ 
						$count_merkmal_query = go_db_query("select count(*) as merkmal_total from " . DB_TBL_ITEMS_CHARACTERISTICS . " where items_id='" . $new_items['items_id'] . "'");
		    		$count_merkmal_result = go_db_fetch_array($count_merkmal_query);
		    		if ($count_merkmal_result['merkmal_total'] > 0) {    
		    			$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';             
            }
            else{
            	
            	// Loopthrough7a
            	
            	            	
            	if ($item_service_status['iss_masseinheit'] == '1'){
            		$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';
            		$no_normal_form = '1';  // individuelle weiterleitung
            	}
            	
            	if ($item_service_status['domainservice_status'] != '0'){
            		$kaufen_button = '<form action="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][bestell_domaincheck], go_get_all_get_parameter(array('action'))) . '" method="post">' . go_fetch_hidden_field('cart_quantity', '1') . go_fetch_hidden_field('items_id', $new_items['items_id']) . go_fetch_hidden_field('zahlungsintervall', $after_price) . go_fetch_hidden_field('items_price_domainservice', $item_price_d) . go_fetch_hidden_field('gewuenschtes_paket', $new_items['items_name']) . go_picture_submit('button_buy_now_domain.gif', PICTURE_BUTTON_IN_CART) . '</form>';
								$no_normal_form = '1';  // individuelle weiterleitung
            	}
				
            	if ($no_normal_form != '1'){
            		$kaufen_button = '' .  go_fetch_form('cart_quantity', go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], go_get_all_get_parameter(array('action')) . 'action=add_item')) . go_fetch_hidden_field('cart_quantity', '1') . go_fetch_hidden_field('items_id', $new_items['items_id']) . go_picture_submit('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</form>';   
            	}
            } 
          }
          $td_breite = ' style="width: 50%"';
        }
        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;' );
          $kaufen_button = '';
          $td_breite = ' width="100%"';
        }
        else{
        	$item_price_d = $before_price . $new_items['items_price'] . $after_price .$currencies->shipping_tag($item_service_status);
		    	if ((STOCK_ALLOW_CHECKOUT == 'false')&&(go_get_items_stock($new_items['items_id']) < 1)) {
		      	$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';   
		      }
		      else{  
						$count_merkmal_query = go_db_query("select count(*) as merkmal_total from " . DB_TBL_ITEMS_CHARACTERISTICS . " where items_id='" . $new_items['items_id'] . "'");
						$count_merkmal_result = go_db_fetch_array($count_merkmal_query);
						if ($count_merkmal_result['merkmal_total'] > 0) {    
				    	$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';             
		        }
		        else{	
		        	$hidden = '';

		        	// Loopthrough7a2		        	
		        	
            	if ($item_service_status['iss_masseinheit'] == '1'){
            		$kaufen_button = '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture_button('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</a>';
								$no_normal_form = '1';  // individuelle weiterleitung
            	}
            			        	
		        	// Loopthrough7
		        	
		        	// hier rein
									if (file_exists(FOLDER_ABSOLUT_CATALOG . 'modules/download')) {
						         $download_items_id = $new_items['items_id'];
						         require(FOLDER_ABSOLUT_CATALOG . 'modules/download/load_this/mods/mods_bigware_7_10_11.php');
						      }


		        	
		        	if ($item_service_status['domainservice_status'] != '0'){		                    
            		$kaufen_button = '<form action="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][bestell_domaincheck], go_get_all_get_parameter(array('action'))) . '" method="post">' . go_fetch_hidden_field('cart_quantity', '1') . go_fetch_hidden_field('items_id', $new_items['items_id']) . go_fetch_hidden_field('items_price_domainservice', $item_price_d) . go_fetch_hidden_field('gewuenschtes_paket', $new_items['items_name']) . $hidden . go_picture_submit('button_buy_now_domain.gif', PICTURE_BUTTON_IN_CART) . '</form>';
								$no_normal_form = '1';  // individuelle weiterleitung
			      	}
			      	if ($no_normal_form != '1'){
			      		$kaufen_button = '' .  go_fetch_form('cart_quantity', go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], go_get_all_get_parameter(array('action')) . 'action=add_item')) . go_fetch_hidden_field('cart_quantity', '1') . go_fetch_hidden_field('items_id', $new_items['items_id']) . $hidden . go_picture_submit('button_in_cart.gif', PICTURE_BUTTON_IN_CART) . '</form>';   
            	}
            }
          }
          $td_breite = ' style="width: 50%"';
        } 
// wordwrapper f�r Artikel auf der Startseite siehe "exact_wordwrap($new_items['items_name'], 2, 25)" die zahl "2" sind die Zeilen, die Zahl "25" die max. Zeichen. Zu lange Artikelnamen, k�nnen so auf der Startseite abgek�rzt werden. der Wrapper trennt immer nach kompletten Wortern, nie mitten in einem Wort.
	    	$info_frame_contents[$row][$col] = array('align' => 'center',
	                                           'params' => 'class="smallText" valign="top"' . $zellenstyle,
	                                           'text' => $picture_frame['begin_frame'] . '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . $new_items['items_picture'], $new_items['items_name'], SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '</a>' . $picture_frame['end_frame'] . '<br><a class="txt" href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . exact_wordwrap($new_items['items_name'], 2, 25) . '<br>' . $new_items['items_name2'] . '</a><br><br> <div id="items_home_wrapper">
																							<div id="items_home_wrapper">
																							<div id="items_home_column">
																							<div class="items_home_innertube">' . $item_price_d . '</div>
																							</div>
																							</div>
																							<div id="items_home_rightcolumn">
																							<div class="items_home_innertube">' . $kaufen_button . '</div>
																							</div>
																							</div>
																							');
	                                           //'text' => $picture_frame['begin_frame'] . '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . $new_items['items_picture'], $new_items['items_name'], SMALL_PICTURE_WIDTH, SMALL_PICTURE_HEIGHT) . '</a>' . $picture_frame['end_frame'] . '<br><a class="txt" href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_34], 'items_id=' . $new_items['items_id']) . '">' . $new_items['items_name'] . '<br>' . $new_items['items_name2'] . '</a><br><table style="width: 100%" border="0" cellpadding="1" cellspacing="0"><tr><td' . $td_breite . '>' . $item_price_d . '</td>' . $kaufen_button . '</tr></table>');
	 	} 
	    $col ++; 
    if ($col > 1) {
      $col = 0;
      $row ++;
    }
}  

  new contentBox($info_frame_contents);
  


  
?>

<!-- new_items_eof //-->
