<?php
$szerokosc = SMALL_IMAGE_WIDTH+10;
$wysokosc = SMALL_IMAGE_HEIGHT+10;

$row = 0;
$col = 1;
$info_box_contents = array();

while ($new_products = tep_db_fetch_array($new_products_query)) {
  $new_products['products_name'] = osc_trunc_string($new_products['products_name'], 50, 1);

  if ($new_products['products_quantity']  > 0) {
    if ($new_products['products_price'] > 0) {
      $form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $new_products['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '">');
      $form_koniec = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '</form>');
      $przcisk_kup = '<input type="hidden" name="products_id" value="' . $new_products['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $new_products['products_name']);
      $ilosc = ENTRY_CANTIDAD.'&nbsp;&nbsp;<input type="text" name="quantity" value="1" maxlength="4" size="2">';
    } else {
      $form_start = '';
      $form_koniec = '';
      $przcisk_kup = '';
      $ilosc = '';
    }
  } else {
    if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
      $form_start = '';
      $form_koniec = '';
      $przcisk_kup = ' '.tep_image_button('button_sold.gif').'';
      $ilosc = '';
    } else {
      $form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $new_products['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '">');
      $form_koniec = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '</form>');
      $przcisk_kup = '<input type="hidden" name="products_id" value="' . $new_products['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $new_products['products_name']);
      $ilosc = ENTRY_CANTIDAD.'&nbsp;&nbsp;<input type="text" name="quantity" value="1" maxlength="4" size="2">';
    }
  }

  if (DISPLAY_PRICE_BRUTTO_NETTO == 'true') {
    $display_nb = 1;
  } else {
    $display_nb = 0;
  }

  //TotalB2B start
  if ($new_price = tep_get_products_special_price($new_products['products_id']) ) {
    $new_products_org['products_price'] = tep_xppp_getproductprice($new_products['products_id']);
    $new_products['products_price'] = $new_price;

    if ($new_products['products_price'] > 0) {
      if ($special_hide == 'false') {
        $query_price_to_guest_result = ALLOW_GUEST_TO_SEE_PRICES;
        if ((($query_price_to_guest_result=='true') && !(tep_session_is_registered('customer_id'))) || ((tep_session_is_registered('customer_id')))) {
          $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span>&nbsp;<span class="smallText"><s>' . $currencies->display_price($new_products['products_id'], $new_products_org['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</s></span><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($new_products['products_id'], $new_products['products_price'],tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb) .'</span>';
        } else {
          $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="smallText">' . PRICES_LOGGED_IN_TEXT . '</span>';
        }
      } else {
        $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($new_products['products_id'], $new_products_org['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb) .'</span>';
      }
    } else {
      $cena_produktu = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
    }
  } else {
    $new_products['products_price'] = tep_xppp_getproductprice($new_products['products_id']);
    if ($new_products['products_price'] > 0) {
      $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($new_products['products_id'],$new_products['products_price'],tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb).'</span>';
    } else {
      $cena_produktu = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
    }
  }
  //TotalB2B end & TotalB2B end

  echo optimize_html('
  <td width="'.$szer_tab.'%" align="center" valign="top" height="100%" class="TableModule" onmouseout="module(this,\'1\')" onmouseover="module(this,\'0\')" onclick="document.location=\''.tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']).'\'">'.$form_start.'
	<div class="title_prod"> 
		<a class="ProductTile" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a>
	</div>
    <div class="modul_cont">
    	<div class="foto_frame">'.
    	  (($new_products['products_image'] != '') ? tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$new_products['products_id'],'',true) : '').'
    	</div>
        <div class="text_frame">
        	<div class="cena_frame">'.$cena_produktu .'</div>');
        	if (CZY_ZAMAWIANA_ILOSC == 1 && USE_SHOP_AS_CATALOG != 'true') { echo '
        	  <div class="smallText"'.(($ilosc != '') ? ' style="padding:3px;"' : '').'>'.$ilosc.'</div>';
        	}
            echo optimize_html('<div class="button_frame">
        	<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products["products_id"]) . '">'.tep_image_button('small_view.gif').'</a></div>
            <div class="button_frame">' . ((USE_SHOP_AS_CATALOG == 'true') ? '' : $przcisk_kup) . '</div>
        </div>
    </div>
  '.$form_koniec.'</td>');

  $col ++;
  if ($col > $ilosc_col) {
    $span= 0;
    $col = 1;
    $row ++;
    $span = ($ilosc_col * 2) - 1;
    if ($row < $max_wiersz) {
      echo optimize_html('
      </tr>
      <tr>
        <td colspan="'.$span.'" width="100%" height="5"></td>
      </tr>
      <tr>');
    } else {
      echo '
       '
       ;
    }
  } else {
    echo '
    <td width="3" height="100%">'.tep_draw_separator('pixel_trans.gif', '3', '1').'</td>';
  }
}

?>