<?php

	define('IN_HUGLO', true);
	require_once('./common.php');

	$id = isset($_GET['id']) ? (is_numeric($_GET['id']) ? $_GET['id'] : 0) : 0;

	$navct = $aide = array();

	$sql = 'SELECT * FROM ' . CATEGORY_TABLE . ' WHERE category_id = 3';
	$result = mysql_query($sql);
	$category = mysql_fetch_assoc($result);
	mysql_free_result($result);

	$sql = 'SELECT * FROM ' . METIERS_TABLE . ' ORDER BY metiers_sort ASC';
	$result = mysql_query($sql);
	while($row = mysql_fetch_assoc($result)) {
		$navct[$row['metiers_id']] = array(
			'metiers_name_fr'	=>	$row['metiers_name_fr'],
			'metiers_name_en'	=>	$row['metiers_name_en']
		);
	}
	mysql_free_result($result);

	$sql = 'SELECT * FROM ' . METIERS_DETAILS_TABLE . ' ORDER BY metiers_details_sort ASC';
	$result = mysql_query($sql);
	while($row = mysql_fetch_assoc($result)) {
		$aide[$row['metiers_details_id']] = array(
			'metiers_id'				=>	$row['metiers_id'],
			'metiers_details_type'		=>	$row['metiers_details_type'],
			'metiers_details_title_fr'	=>	$row['metiers_details_title_fr'],
			'metiers_details_text_fr'	=>	$row['metiers_details_text_fr'],
			'metiers_details_title_en'	=>	$row['metiers_details_title_en'],
			'metiers_details_text_en'	=>	$row['metiers_details_text_en']
		);
	}
	mysql_free_result($result);

	foreach($navct as $key => $value) {
		$template->assign_block_vars('metiersrow', array(
			'U_LINK'	=>	BASE_PATH . '/' . $category['category_page'] . '.php?id=' . $key,
			'T_TITLE'	=>	ucfirst($value['metiers_name_' . $l])
		));
	}

	for($i = 1; $i <= 4; $i++) {
		$template->assign_block_vars('metiersdetailsrow', array(
			'V_N'	=>	$i,
			'V_IN'	=>	($id) ? $i : false
		));
		
		foreach($aide as $key => $value) {
			if($i == $value['metiers_details_type'] and $id == $value['metiers_id']) {
				$template->assign_block_vars('metiersdetailsrow.metiersdetailsitemsrow', array(
					'U_LINK'	=>	BASE_PATH . '/' . $category['category_page'] . '.php?id=' . $key . '&amp;type=' . $i,
					'T_TITLE'	=>	$value['metiers_details_title_' . $l]
				));
			}
		}
	}

	$template->assign_vars(array(
		'T_NAME_PAGE'		=>	$category['category_name_' . $l],
		'V_C_NAME'			=>	$category['category_name_' . $l],
		'V_BG'				=>	true,
		'V_BG_IMG'			=>	$category['category_bg_img'],
		'V_BG_COLOR'		=>	$category['category_bg_color']
	));

	$template->set_filenames(array('body' => 'view_metiers.html'));
	$template->display('body');

	unset($navct, $aide);
	$db->sql_close();

?>
