<?php
/*
  $Id: whats_new.php,v 1.3 2006/07/16 05:09:34 ryu Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
  
  modified for Koshoten.net2
  http://www.koshoten.net/
*/

  if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {
?>
<!-- whatsNewBox -->
<?php
    $random_product['products_name'] = tep_get_products_name($random_product['products_id']);
    $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);

    $cssid = 'whatsNewBox';
    $infobox_header = BOX_HEADING_WHATS_NEW;
    $infobox_footer = '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . BOX_MORE_WHATS_NEW . '</a>';

    $box_whats_new_contents = '';
    if (defined("KN_CFG_ALLOW_CHECKOUT") && (KN_CFG_ALLOW_CHECKOUT == "false")) {
      $whats_new_price = '';
    } else {
      if (tep_not_null($random_product['specials_new_products_price'])) {
        $whats_new_price = '<del>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</del><br />';
        $whats_new_price .= '<span class="specialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';
      } else {
        $whats_new_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));
      }
    }
    
    if ($random_product['products_image']) {
      $box_whats_new_contents = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "</a></p>\n" .
                                            '<h4><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . "</a></h4>\n" .
                                            '<p class="pPrice">' . $whats_new_price . "</p>\n";
    } else {
      $box_whats_new_contents = '<h4><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . "</a></h4>\n" .
                                            '<p class="pPrice">' . $whats_new_price . "</p>\n";
    }
    $infobox_contents = array();
    $infobox_contents[] = array('text' => $box_whats_new_contents);

    new infoBox($cssid, $infobox_contents, $infobox_header, $infobox_footer);
?>
<!-- /whatsNewBox -->
<?php
  }
?>
