<?php
/*
  $Id: new.php $
  TomatoCart Open Source Shopping Cart Solutions
  http://www.tomatocart.com

  Copyright (c) 2009 Wuxi Elootec Technology Co., Ltd;  Copyright (c) 2007 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/
?>
<div class="moduleBox">
  <div style="position: relative;">
	  <h6><?php echo $osC_Template->getPageTitle(); ?></h6>
	  <?php
	    $product_view_style = '<div class="newProductViewStyle">' .
	                            '<span>' . $osC_Language->get('products_views_label') . '</span>';
	      
	    if ( (!isset($_GET['view']) && !isset($_SESSION['view'])) || (isset($_GET['view']) && $_GET['view'] == 'list') ) {
	      $product_view_style .= '<span>'. osc_image('images/list_view_color.png', 'list_view', 18, 18) . '</span>' . 
	                             '<span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'new&view=grid'), osc_image('images/grid_view.png', 'grid_view', 18, 18)) . '</span>';
	    }else if ( isset($_GET['view']) && $_GET['view'] == 'grid') {
	      $product_view_style .= '<span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'new&view=list'), osc_image('images/list_view.png', 'list_view', 18, 18)) . '</span>' .
	                             '<span>' . osc_image('images/grid_view_color.png', 'grid_view', 18, 18) . '</span>';
	    }else if( !isset($_GET['view']) && isset($_SESSION['view']) ){
	      $view_style = $_SESSION['view'];
	      if($view_style == 'list') {
	        $product_view_style .= '<span>'. osc_image('images/list_view_color.png', 'list_view', 18, 18) . '</span>' . 
	                               '<span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'new&view=grid'), osc_image('images/grid_view.png', 'grid_view', 18, 18)) . '</span>';
	      }else {
	        $product_view_style .= '<span>' . osc_link_object(osc_href_link(basename($_SERVER['SCRIPT_FILENAME']), 'new&view=list'), osc_image('images/list_view.png', 'list_view', 18, 18)) . '</span>' .
	                               '<span>' . osc_image('images/grid_view_color.png', 'grid_view', 18, 18) . '</span>';
	      }
	    }
	
	    $product_view_style .= '</div>';
	      
	    echo $product_view_style;
  ?>      
	</div>  
  <div class="content">
  <?php
    $Qproducts = osC_Product::getListingNew();
    
    if ($Qproducts->numberOfRows() > 0) {
      if ((!isset($_GET['view']) && !isset($_SESSION['view'])) || (isset($_GET['view']) && $_GET['view'] == 'list')) {
        require('new_products_list.php');
      }else if (isset($_GET['view']) && $_GET['view'] == 'grid') {
        require('new_products_grid.php');
      }else if( !isset($_GET['view']) && isset($_SESSION['view']) ){
        $view_type = $_SESSION['view'];
        require('new_products_'. $view_type. '.php');
      }
    }else{
  ?>
      <table border="0" width="100%" cellspacing="20" cellpadding="2">
        <tr>
          <td><?php echo $osC_Language->get('no_new_products'); ?></td>
        </tr>
        <tr>
          <td colspan="3">&nbsp;</td>
        </tr>
      </table>
  <?php
    }
  ?>  
    
    <div class="listingPageLinks">
      <div style="float: right;"><?php echo $Qproducts->getBatchPageLinks('page', 'new'); ?></div>
    
      <?php echo $Qproducts->getBatchTotalPages($osC_Language->get('result_set_number_of_products')); ?>
    </div>
  </div>
</div>