<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_MANUFACTURERS);
  $current_page = FILENAME_MANUFACTURERS;
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_MANUFACTURERS));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<?php echo tep_draw_content_top();?>

<?php echo tep_draw_heading_top();?>
<h2><?php echo HEADING_TITLE; ?></h2>
<?php echo tep_draw_heading_bottom();?>

<div class="contentContainer page_manufacturers">
<?php
	$manufacturers_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name, md.manufacturers_description, m.manufacturers_image, COUNT(*) as total from " . TABLE_MANUFACTURERS . " m,  " . TABLE_MANUFACTURERS_INFO . " md, " . TABLE_PRODUCTS . " p where m.manufacturers_id = p.manufacturers_id and m.manufacturers_id = md.manufacturers_id  and md.languages_id = '" . (int)$languages_id . "' GROUP BY manufacturers_id order by manufacturers_name");	
	
	if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {
		$image_width = MANUFACTURERS_PAGE_IMAGE_WIDTH;
		$image_height = MANUFACTURERS_PAGE_IMAGE_HEIGHT;		
		$manufacturers_list = '<ul id="view_row">';
		while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
		//	$manufacturers_query = tep_db_query("select manufacturers_description, manufacturers_id from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturers['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
	//		$manufacturers = tep_db_fetch_array($manufacturers_query);
			$manufacturers_name = ((MANUFACTURERS_PAGE_SHOW_NAME == 'Show') ? '<h3><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">'.$manufacturers['manufacturers_name'].'</a></h3>' : '');
			if (tep_not_null($manufacturers['manufacturers_image'])) {
			$manufacturers_image = ((MANUFACTURERS_PAGE_SHOW_THUMBS == 'Show') ? tep_image(DIR_WS_IMAGES . $manufacturers['manufacturers_image'], $manufacturers['manufacturers_name'], $image_width, $image_height, ' class="fl_left"') : '');
			}else{
			$manufacturers_image = '';
			}
			if (MAX_DISPLAY_MANUFACTURERS_PAGE_DESCRIPTION_LEN_PAGE != 0) {
			$manufacturers_description = ((strlen($manufacturers['manufacturers_description']) > MAX_DISPLAY_MANUFACTURERS_PAGE_DESCRIPTION_LEN_PAGE) ? '<div class="desc">'.substr($manufacturers['manufacturers_description'], 0, MAX_DISPLAY_MANUFACTURERS_PAGE_DESCRIPTION_LEN_PAGE) . '...</div>' : '<div class="desc">'.$manufacturers['manufacturers_description'].'</div>');
			}
			if	($manufacturers['total'] > 1)	{
				$text_info	= TEXT_INFO_S;	
			}else{
				$text_info	= TEXT_INFO;
			}
			$p_desc = ((MAX_DISPLAY_MANUFACTURERS_PAGE_DESCRIPTION_LEN_PAGE !=0) ? ''.mb_substr(strip_tags($manufacturers['manufacturers_description']), 0, MAX_DISPLAY_MANUFACTURERS_PAGE_DESCRIPTION_LEN_PAGE, 'UTF-8').'...' : '');
			
			$manufacturers_total = ((MANUFACTURERS_PAGE_SHOW_TOTAL == 'Show') ? '<a class="fl_right" href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">'.$manufacturers['total'].' '.$text_info.'</a>' : '');
				if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) 
				$manufacturers_name .= '<strong>' . $manufacturers_name .'</strong>';
				$manufacturers_list .= '<li class="manufacturers_block"><div>'.$manufacturers_image.$manufacturers_total.$manufacturers_name.$p_desc.'</div></li>';
				}		  
				$manufacturers_list .= '</ul>'; 
				$content = $manufacturers_list;				
	  }
//}
?>
  <div class="contentBlock">
      <div class="content"><?php echo $content; ?></div>
      <div class="buttonSet">
        <span class="fl_right"><?php echo tep_draw_button2_top();?><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?><?php echo tep_draw_button2_bottom();?></span>
      </div>
	</div>
</div>

<?php echo tep_draw_content_bottom();?>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
