<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
$query_price_to_guest_result = ALLOW_GUEST_TO_SEE_PRICES;
$boxHeading = BOX_HEADING_WHATS_NEW;
$corner_left = 'rounded';
$corner_right = 'rounded';
$boxContent_attributes = ' align="center"';
$szerokosc = SMALL_IMAGE_WIDTH+10;
$wysokosc = SMALL_IMAGE_HEIGHT+10;

$boxLink = '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' .tep_image(DIR_WS_TEMPLATES . 'images/infobox/arrow_right.gif') .'</a>';
$box_base_name = 'whats_new_scroll';

$box_id = $box_base_name . 'Box';

if (!isset($customer_id)) $customer_id = 0;

$rp_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_quantity, p.products_price, p.products_retail_price, p.products_tax_class_id, p.products_date_added, pd.products_name, pd.products_description, m.manufacturers_name from (" . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.categories_status='1' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) < ".MAX_DISPLAY_TIME_NEW_PRODUCTS." and p.products_id = p2c.products_id and c.categories_id = p2c.categories_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name limit " . MAX_RANDOM_SELECT_NEW);

if (tep_db_num_rows($rp_query)) {

  $i = 0;
  if (DISPLAY_PRICE_BRUTTO_NETTO == 'true') {
    $display_nb = 1;
    } else {
    $display_nb = 0;
  }
  $pausecontentn = Array();
  while ($random_product = tep_db_fetch_array($rp_query)) {

      $random_product['products_price'] = tep_xppp_getproductprice($random_product['products_id']);
      $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);
      $query_special_prices_hide_result = SPECIAL_PRICES_HIDE;
      
	  $random_product['products_name'] = str_replace('"','`',$random_product['products_name']);
	  $random_product['products_name'] = str_replace("'","`",$random_product['products_name']);      

      $pausecontentn[$i] = '<div class="spec_kont">';

      if ($random_product['products_image'] != ''){
        $pausecontentn[$i] .= '<div class="spec_img" align="center">';  
        $pausecontentn[$i] .= str_replace('/','%2F',tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$random_product['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']),true));
        $pausecontentn[$i] .= '<%2Fdiv>';
      }

      $pausecontentn[$i] .= '<div class="spec_text">';
      if ($random_product['products_price'] > 0) {
          if ($query_special_prices_hide_result == 'true') {
            $pausecontentn[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50, 1) . '<%2Fa><br><br><span class="Cena">' . $currencies->display_price($random_product['products_id'], $random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,$display_nb) . '<%2Fspan>';
          } else {
            if ((($query_price_to_guest_result=='true') && !(tep_session_is_registered('customer_id'))) || ((tep_session_is_registered('customer_id')))) {
              if ($random_product['specials_new_products_price'] > 0) {
                 $pausecontentn[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50, 1) . '<%2Fa><br><br><span class="boxText"><s>' . $currencies->display_price($random_product['products_id'], $random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '<%2Fs><%2Fspan><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($random_product['products_id'], $random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,$display_nb) . '<%2Fspan>';
                 } else {
                 $pausecontentn[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50, 1) . '<%2Fa><br><br><span class="Cena">' . $currencies->display_price($random_product['products_id'], $random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,$display_nb) . '<%2Fspan>';
              }
            } else {
              $pausecontentn[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50 ,1) . '<%2Fa><br><br><span class="boxText"><b>' .PRICES_LOGGED_IN_TEXT. '<%2Fb><%2Fspan>';
            }
         }
      } else {
        $pausecontentn[$i] .= '<span class="boxText"><b>' .TEMPORARY_NO_PRICE. '<%2Fb><%2Fspan>';
      }         
     $pausecontentn[$i] .= '<%2Fdiv><%2Fdiv>';
     $pausecontentn[$i] = str_replace('</span>','<%2Fspan>',$pausecontentn[$i]);
     $i++;
  }

  $i = 0;
  $tablica_new = '';
  while ($pausecontentn[$i]) { $tablica_new .= "pausecontentn[".$i."] = '".$pausecontentn[$i]."';"."\n"; $i++; }
  if ($i == 1) { $tablica_new .= "pausecontentn[".$i."] = '".$pausecontentn[0]."';"."\n"; }

  $boxContent = '<script type="text/javascript">var pausecontentn=new Array();'."\n".$tablica_new.'new pausescrollern(pausecontentn, "pscroller3", "someclass", 2000);</script>';
  $boxContent .= '<noscript><span class="smallText">Brak obslugi JavaScript</span><br><br></noscript>';   
  $boxContent .= '<a class="boxLink" href="'.tep_href_link(FILENAME_PRODUCTS_NEW).'"><b>'.WHATS_NEW_ALL.'</b></a>';  

  include (bts_select('boxes', $box_base_name)); // BTS 1.5

}

$boxLink = '';
$boxContent_attributes = '';
?>