<?php
/**
 * Module Template
 *
 * Loaded automatically by index.php?main_page=featured_products.<br />
 * Displays listing of Featured Products
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_products_new_listing.php 6096 2007-04-01 00:43:21Z ajeh $
 */
?>
<div class="products grid clearfix" data-items="3">

<?php
$group_id = zen_get_configuration_key_value('PRODUCT_NEW_LIST_GROUP_ID');

if ($products_new_split->number_of_rows > 0) {
  $products_new = $db->Execute($products_new_split->sql_query);
  
  while (!$products_new->EOF) {
    
    $products_price = zen_get_products_display_price($products_new->fields['products_id']);
    if (!isset($productsInCategory[$products_new->fields['products_id']])) $productsInCategory[$products_new->fields['products_id']] = zen_get_generated_category_path_rev($products_new->fields['master_categories_id']);

    $additional_images = genesis_get_additional_images( $products_new->fields['products_id'] );

    $product_image = '<div class="product-images ' . ( $additional_images ? 'has_additional' : '') . '"><a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . $productsInCategory[$products_new->fields['products_id']] . '&products_id=' . $products_new->fields['products_id']) . '">';
    if( $products_new->fields['products_image'] != '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS != 0 ){
      $product_image .= sprintf( '<div class="product-main-images">%s</div>', zen_image(DIR_WS_IMAGES . $products_new->fields['products_image'], $products_new->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT, 'class="img-responsive"') );
    }
    
    if( $additional_images ){
      $product_image .= sprintf( '<div class="product-additional-images">%s</div>', zen_image($additional_images[0], $products_new->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT, 'class="img-responsive"') );
    }
    $product_image .= '</a>';

    $button = genesis_get_product_action( $products_new->fields, $how_many );
    $how_many += $button['how_many'];

    $product_image .= '<div class="product-action">' . $button['button'] . '</div>';
    $product_image .= '</div>';

    $product_cat = sprintf( '<div class="product-category">%s</div>', zen_get_categories_name( $products_new->fields['master_categories_id'] ) );

    $product_name = sprintf( '<h2 class="product-name"><a href="%s">%s</a></h2>', zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . $productsInCategory[$products_new->fields['products_id']] . '&products_id=' . $products_new->fields['products_id']), $products_new->fields['products_name'] );

    $product_price = sprintf( '<div class="product-price">%s</div>', zen_get_products_display_price($products_new->fields['products_id']) );

    $content = array( 
      'params'  => 'product column',
      'text'    => $product_image  . $product_cat . $product_name . $product_price
    );
        
    echo '<div class="' . $content['params'] . '">';
      echo $content['text']; 
    echo '</div>';

    $products_new->MoveNext();
  
  }
} else {
  echo '<h3 clsas="important">' . TEXT_NO_NEW_PRODUCTS . '</h3>';
}
?>
</div>
