<?php
function tep_star_product_with_attributes($products_id) {
$attributes_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "'");
$attributes = tep_db_fetch_array($attributes_query);

if ($attributes['count'] > 0) {
return true;
} else {
return false;
}
}

$star_products['products_name'] = tep_get_products_name($star_products['products_id']);

$evita_cortar_palabras = explode( ' ',  $star_products["products_description"] );
array_pop( $evita_cortar_palabras );
$star_products["products_description"]  = implode( ' ', $evita_cortar_palabras ); 

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

if ($star_products['products_quantity']  > 0) {
	if ($star_products['products_price'] > 0) {
		$form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $star_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="' . $star_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 . ' ' . $star_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_' . $star_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="' . $star_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 . ' ' . $star_products['products_name']);
		$ilosc = ENTRY_CANTIDAD.'&nbsp;&nbsp;<input type="text" name="quantity" value="1" maxlength="4" size="2">';
	}
}   


//TotalB2B start
$special_hide = SPECIAL_PRICES_HIDE;
if ($new_price = tep_get_products_special_price($star_products['products_id']) ) {
	$star_products_org['products_price'] = tep_xppp_getproductprice($star_products['products_id']);
	$star_products['products_price'] = $new_price;

	if ($star_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')))) {
			  $star_price = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span>&nbsp;<span class="smallText"><s>' . $currencies->display_price($star_products['products_id'], $star_products_org['products_price'], tep_get_tax_rate($star_products['products_tax_class_id'])) . '</s></span><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($star_products['products_id'], $star_products['products_price'],tep_get_tax_rate($star_products['products_tax_class_id']),1,$display_nb) .'</span>';
		   } else {
			  $star_price = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . PRICES_LOGGED_IN_TEXT . '</span>';
		   }
	   } else {
			$star_price = '<span class="Cena">' . $currencies->display_price($star_products['products_id'], $star_products_org['products_price'], tep_get_tax_rate($star_products['products_tax_class_id']),1,$display_nb) .'</span>';
		}
	} else {
		 $star_price = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
	}
} else {
	$star_products['products_price'] = tep_xppp_getproductprice($star_products['products_id']);
	if ($star_products['products_price'] > 0) {
		$star_price = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($star_products['products_id'],$star_products['products_price'],tep_get_tax_rate($star_products['products_tax_class_id']),1,$display_nb).'</span>';
	} else {
		$star_price = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
	}
}
//TotalB2B end & TotalB2B end   

$szerokosc = SMALL_IMAGE_WIDTH*1.2 + 10;
$wysokosc = SMALL_IMAGE_HEIGHT*1.2 + 10;

echo '<td class="TableFrame">'.$form_start.'
		<div align="center" style="padding:5px"> 
			<a class="star-product-title" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $star_products["products_id"]) . '">' . $star_products['products_name'] . '</a>
		</div>   
		<div>
			<table><tr><td>
				<div style="padding:5px;" class="star-product"> 
					'. strip_tags($star_products["products_description"]) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $star_products["products_id"]). '">' . STAR_READ_MORE . '</a>
				</div>
				<div style="padding:5px;" align="center">'.$star_price . '</div>';
				if (CZY_ZAMAWIANA_ILOSC == 1 && USE_SHOP_AS_CATALOG != 'true') { echo '
				  <div align="center" class="smallText"'.(($ilosc != '') ? ' style="padding:6px;"' : '').'>'.$ilosc.'</div>';
				}
				echo '<div align="center">
				<a class="ProductDescripion" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $star_products["products_id"]) . '">'.tep_image_button('small_view.gif').'</a>&nbsp;&nbsp;' . ((USE_SHOP_AS_CATALOG == 'true') ? '' : $przcisk_kup) . '
				</div>						
			</td><td valign="middle" width="'.$szerokosc.'px">'.
				(($star_products['products_image'] != '') ? tep_image(DIR_WS_IMAGES . $star_products['products_image'], $star_products['products_name'], SMALL_IMAGE_WIDTH*1.2, SMALL_IMAGE_HEIGHT*1.2,'',$wysokosc,$szerokosc,$star_products['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $star_products['products_id']),true) : '').'
			</td></tr></table>
		</div>
	'.$form_koniec.'</td>';
?>