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

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

while ($default_specials = tep_db_fetch_array($default_specials_query)) {
    $default_specials['products_name'] = tep_get_products_name($default_specials['products_id']);
    $default_specials['products_name'] = osc_trunc_string($default_specials['products_name'], 50, 1);

	if ($default_specials['products_quantity']  > 0) {
		if ($default_specials['products_price'] > 0) {
			$form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $default_specials['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="' . $default_specials['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $default_specials['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_' . $default_specials['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="' . $default_specials['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $default_specials['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($default_specials['products_id']) ) {
        $default_specials_org['products_price'] = tep_xppp_getproductprice($default_specials['products_id']);
        $default_specials['products_price'] = $new_price;

        if ($default_specials['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($default_specials['products_id'], $default_specials_org['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s></span><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($default_specials['products_id'], $default_specials['products_price'],tep_get_tax_rate($default_specials['products_tax_class_id']),1,$display_nb) .'</span>';
               } else {
                  $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="smallText"><b>' . PRICES_LOGGED_IN_TEXT . '</b></span>';
               }
           } else {
                $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($default_specials['products_id'], $default_specials_org['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id']),1,$display_nb) .'</span>';
            }
        } else {
             $cena_produktu = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
        }
    } else {
        $default_specials['products_price'] = tep_xppp_getproductprice($default_specials['products_id']);
        if ($default_specials['products_price'] > 0) {
            $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($default_specials['products_id'],$default_specials['products_price'],tep_get_tax_rate($default_specials['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=' . $default_specials['products_id']).'\'">'.$form_start.'
	<div class="title_prod"> 
		<a class="ProductTile" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a>
	</div>
    <div class="modul_cont">
    	<div class="foto_frame">'.
    	  (($default_specials['products_image'] != '') ? tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$default_specials['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=' . $default_specials["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>';
    }
}

?>