<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/

$szerokosc = ALLPROD_IMAGE_WIDTH+10;
$wysokosc = ALLPROD_IMAGE_HEIGHT+10;

// ****************************************************************************

$list_box_contents = array();

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

$rows = 0;
$listing_query = tep_db_query($listing_sql);
while ($listing = tep_db_fetch_array($listing_query)) {

 if (($rows/2) == floor($rows/2)) {
  $list_box_contents[] = array('params' => 'class="productListing-even"');
 } else {
  $list_box_contents[] = array('params' => 'class="productListing-odd"');
 }

 $cur_row = sizeof($list_box_contents) - 1;

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  $lc_align = '';
  $lc_params = '';

  switch ($column_list[$col]) {
          case 'PRODUCT_LIST_NAME':
            $lc_align = 'left';
            if (isset($HTTP_GET_VARS['manufacturers_id'])) {
              $lc_text = '<a class="ProductTile" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . osc_trunc_string($listing['products_name'],50, 1) . '</a>';
            } else {
              $lc_text = '<a class="ProductTile" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . osc_trunc_string($listing['products_name'],50, 1) . '</a>';
            }
            $lc_params = ' width="80%"';
            break;
          // Products Description Hack begins
          case 'PRODUCT_LIST_DESCRIPTION':
            $lc_text = '' . osc_trunc_string(strip_tags($listing['products_description'], ''), PRODUCT_LIST_DESCRIPTION_LENGTH) . '&nbsp;';
            $col_to_span = sizeof($column_list)-1;
            if (PRODUCT_LIST_IMAGE > 0) {
              $col_to_span -= 1;
            }
            $lc_params = 'colspan="' . $col_to_span . '" valign="top"';
            break;
          // Products Description Hack ends
          case 'PRODUCT_LIST_PRICE':
            $lc_align = 'left';
            if ($listing['products_price'] < 0.01 ) {
             $lc_text = ''.TEMPORARY_NO_PRICE.'';
            } else {
             //TotalB2B start
                 $listing['products_price'] = tep_xppp_getproductprice($listing['products_id']);
                   //TotalB2B start
                 if ($new_price = tep_get_products_special_price($listing['products_id'])) {
              $listing['specials_new_products_price'] = $new_price;
              $query_special_prices_hide_result = SPECIAL_PRICES_HIDE;
              if ($query_special_prices_hide_result == 'true') {
                     $lc_text = '<span class="Cena">' . $currencies->display_price($listing['products_id'], $listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']),1,$display_nb) . '</span>';
                } else {
                     $lc_text = '<s>' .  $currencies->display_price($listing['products_id'], $listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing['products_id'], $listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id']),1,$display_nb) . '</span>';
                }
                    //TotalB2B end
                   } else {
                    if (tep_not_null($listing['specials_new_products_price'])) {
               				$lc_text = '<s>' .  $currencies->display_price($listing['products_id'], $listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($listing['products_id'], $listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id']),1,$display_nb) . '</span>';
              			} else {
                     	$lc_text = '<span class="Cena">' . (($listing['products_price'] > 0) ? $currencies->display_price($listing['products_id'], $listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']),1,$display_nb) : '') . '</span>';
              			}
             }
            }
            $lc_params = ' width="20%"';
            break;
      case 'PRODUCT_LIST_IMAGE':
            $lc_align = 'center';
            $lc_text = '&nbsp;';
            if (isset($HTTP_GET_VARS['manufacturers_id'])) {
              if (tep_not_null($listing['products_image'])){
			          $lc_text .= tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], ALLPROD_IMAGE_WIDTH, ALLPROD_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$listing['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']),true);
			        }
            } else {
              if (tep_not_null($listing['products_image'])){
                $lc_text .= tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], ALLPROD_IMAGE_WIDTH, ALLPROD_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$listing['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']),true);
			  }
            }
            // Products Description Hack begins
            if (PRODUCT_LIST_DESCRIPTION > 0) {
             $lc_params = 'rowspan="2" ';
            }
            // Products Description Hack ends
            break;
  }

  // Products Description Hack begins
  $lc_params .= 'class="productListing-data"';
  if ($column_list[$col] == 'PRODUCT_LIST_DESCRIPTION') {
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                                 'params' => $lc_params,
                                                 'text' => $lc_text,
                                                 'desc_flag' => 'true');
  } else {
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                                 'params' => $lc_params,
                                                 'text'  => $lc_text);
  }
      // Products Description Hack ends
 }

 $rows++;
}

new productListingBox($list_box_contents);

?>