<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 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_product_listing.php 3241 2006-03-22 04:27:27Z ajeh $
 */
 include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));
?>
<div id="productListing">

<?php
  $check_for_alpha = $listing_sql;
  $check_for_alpha = $db->Execute($check_for_alpha);

  if ($do_filter_list || ($check_for_alpha->RecordCount() > 0 && PRODUCT_LIST_ALPHA_SORTER == 'true' && $current_page_base != 'advanced_search_result')) {
  $form = zen_draw_form('filter', zen_href_link(FILENAME_DEFAULT), 'get', 'class="clearfix"') . '<label class="inputLabel">' . $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS) . '</label>';

  echo $form;
  echo zen_draw_hidden_field('main_page', FILENAME_DEFAULT);
  echo zen_hide_session_id();

  if (!$getoption_set) {
    echo zen_draw_hidden_field('cPath', $cPath);
  } else {
    echo zen_draw_hidden_field($get_option_variable, $_GET[$get_option_variable]);
  }

  if (isset($_GET['music_genre_id']) && $_GET['music_genre_id'] != '') echo zen_draw_hidden_field('music_genre_id', $_GET['music_genre_id']);

  if (isset($_GET['record_company_id']) && $_GET['record_company_id'] != '') echo zen_draw_hidden_field('record_company_id', $_GET['record_company_id']);

  if (isset($_GET['typefilter']) && $_GET['typefilter'] != '') echo zen_draw_hidden_field('typefilter', $_GET['typefilter']);

  if ($get_option_variable != 'manufacturers_id' && isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] > 0) {
    echo zen_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']);
  }

  echo zen_draw_hidden_field('sort', $_GET['sort']);

  require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING_ALPHA_SORTER));

  if ($do_filter_list) {
    echo zen_draw_pull_down_menu('filter_id', $options, (isset($_GET['filter_id']) ? $_GET['filter_id'] : ''), 'onchange="this.form.submit()"');
  }
?>
</form>
<?php } ?>

<?php if( $current_page_base == 'advanced_search_result' && ($do_filter_list || PRODUCT_LIST_ALPHA_SORTER == 'true')){

  $form = zen_draw_form('filter', zen_href_link(FILENAME_ADVANCED_SEARCH_RESULT), 'get', 'class="clearfix"') . '<label class="inputLabel">' . $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS) . '</label>';
  echo $form;
  echo zen_hide_session_id();

  $hidden_get_variables = '';
  reset($_GET);
  while (list($key, $value) = each($_GET)) {
    if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) {
      $hidden_get_variables .= zen_draw_hidden_field($key, $value);
    }
  }
  echo $hidden_get_variables;

  require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING_ALPHA_SORTER));
?>
</form>
<?php } ?>

<?php 
if ($how_many > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0) {
// bof: multiple products
  echo zen_draw_form('multiple_products_cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product', $request_type), 'post', 'enctype="multipart/form-data"');
}
?>

<div class="before-product-listing clearfix">
  <?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) : ?>
  <div id="productsListingListingTopLinks" class="navSplitPagesLinks pull-left"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
  <?php endif; ?>

  <?php if ($show_top_submit_button == true) : ?>
  <div class="buttonRow pull-right"><input id="submit1" type="submit" name="submit1" value="<?php echo BUTTON_ADD_PRODUCTS_TO_CART_ALT; ?>"></div>
  <?php endif; ?>
</div>

<?php
/**
 * load the list_box_content template to display the products
 */
  require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
?>

<div class="after-product-listing clearfix">
  <?php if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) : ?>
  <div  id="productsListingListingBottomLinks" class="navSplitPagesLinks pull-left"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></div>
  <?php endif; ?>

  <?php if ($show_bottom_submit_button == true) : ?>
  <div class="buttonRow pull-right"><input id="submit2" type="submit" name="submit1" value="<?php echo BUTTON_ADD_PRODUCTS_TO_CART_ALT; ?>"></div>
  <?php endif; ?>
</div>


<?php if ($show_top_submit_button == true or $show_bottom_submit_button == true) : ?>
</form>
<?php endif; ?>

</div><!-- #productListing -->
