Code:
$title = sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'));
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
// display limits
$display_limit = zen_get_products_new_timelimit();
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
$new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_date_added
from " . TABLE_PRODUCTS . " p
where p.products_status = '1' " . $display_limit;
} else {
$new_products_query = "select distinct p.products_id, p.products_image, p.products_description, p.products_tax_class_id, p.products_date_added,
p.products_price
from " . TABLE_PRODUCTS . " p
left join " . TABLE_SPECIALS . " s
on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_CATEGORIES . " c
where p.products_id = p2c.products_id
and p2c.categories_id = c.categories_id
and c.parent_id = '" . (int)$new_products_category_id . "'
and p.products_status = '1' " . $display_limit;
}
$new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS);
$row = 0;
$col = 0;
$list_box_contents = '';
$num_products_count = $new_products->RecordCount();
// show only when 1 or more
if ($num_products_count > 0) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS) {
$col_width = 100/$num_products_count;
} else {
$col_width = 100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS;
}
while (!$new_products->EOF) {
$product_query = "select products_name, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products->fields['products_id'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'";
$product_info = $db->Execute($product_query);
$products_price = zen_get_products_display_price($new_products->fields['products_id']);
$products_price = str_replace('$', '<small>$</small>', $products_price);
$new_products->fields['products_name'] = zen_get_products_name($new_products->fields['products_id']);
#PR Build product information box
$product_info_str = '<table class="productBoxHeading_tb" width="241" cellspacing="0" cellpadding="0"><tr>';
$product_info_str .= '<td class="productBoxHeadingLcorner"></td>';
$product_info_str .= '<td class="productBoxHeading">' . '<span class="productBoxPrice floatRight">' . $products_price . '</span>' . '<a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a>' . '</td>';
$product_info_str .= '<td class="productBoxHeadingRcorner"></td>';
$product_info_str .= '</tr></table>';
$product_info_str .= '<table class="productBoxOuter" width="241" cellspacing="0" cellpadding="0"><tr>';
$product_info_str .= '<td class="productBoxLSide"> </td>';
$product_info_str .= '<td class="productBoxMSide" valign="top">';
$product_info_str .= '<table class="productBox" width="100%" cellspacing="0" cellpadding="0"><tr>';
$product_info_str .= '<td class="productBoxImage" width="118">';
$product_info_str .= '<a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
$product_info_str .= '</td><td class="productBoxContent" valign="top">';
$product_info_str .= '<table width="100%" cellspacing="0" cellpadding="0"><tr>';
$product_info_str .= '<td class="productBoxDescription" valign="top">';
$product_info_str .= (strlen($product->fields['products_description']) > 50) ? substr(strip_tags($product->fields['products_description']), 0, 50) . '…' : strip_tags($product->fields['products_description']);
$product_info_str .= '</td></tr><tr><td>';
$product_info_str .= '<a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products->fields['products_id']) . '">' . '<img src="'. DIR_WS_TEMPLATE_IMAGES .'az_more_info.gif" class="noborder" alt="" />' . '</a>';
$product_info_str .= '</td></tr><tr><td height="4"></td></tr><tr><td>';
$product_info_str .= '<a href="' . zen_href_link(basename($PHP_SELF), zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products->fields['products_id']) . '">' . '<img src="'. DIR_WS_TEMPLATE_IMAGES .'az_buy_now.gif" class="noborder" alt="" />' . '</a>';
$product_info_str .= '</td></tr></table>';
$product_info_str .= '</td';
$product_info_str .= '</tr></table>'; // productBoxContent
$product_info_str .= '</td>';
$product_info_str .= '<td class="productBoxRSide"> </td>';
$product_info_str .= '</tr></table>';
$product_info_str .= '<table class="productBoxBottom_tb" width="241" cellspacing="0" cellpadding="0"><tr>';
$product_info_str .= '<td class="productBoxLBottom"></td>';
$product_info_str .= '<td class="productBoxMBottom"></td>';
$product_info_str .= '<td class="productBoxRBottom"></td>';
$product_info_str .= '</tr></table>';
if ($col > 0) {
$list_box_contents[$row][$col] = array('align' => 'center',
'params' => 'width="1" class="productBoxVSep"',
'text' => zen_draw_separator('pixel_trans.gif', '1', '1'));
}
if ($row > 0) {
$list_box_contents[$row - 1][$col] = array('align' => 'center',
'params' => 'height="1"',
'text' => zen_draw_separator('pixel_trans.gif', '1', '1'));
}
if ($col > 0) $col ++;
if ($row > 0) {
$list_box_contents[$row - 1][$col] = array('align' => 'center',
'params' => 'height="1" class="productBoxHSep"',
'text' => zen_draw_separator('pixel_trans.gif', '1', '1'));
}
$list_box_contents[$row][$col] = array('align' => 'center',
'params' => 'class="smallText" width="49%" valign="top"',
'text' => $product_info_str);
$col ++;
if ($col > 2) {
$col = 0;
$row += 2;
}
$new_products->MoveNextRandom();
}
if ($new_products->RecordCount() > 0) {
if (isset($new_products_category_id)) {
$category_title = zen_get_categories_name((int)$new_products_category_id);
$title = sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' );
} else {
$title = sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'));
}
$zc_show_new_products = true;
}
}
?>
Thanks once again in advance!
Bookmarks