<?php

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

	$dates = array();
	
	$sql = 'SELECT c2.category_id, c2.category_parent_id, c1.category_name_fr , c2.category_name_fr AS category_s_name_fr, c1.category_name_en , c2.category_name_en AS category_s_name_en, c2.category_bg_img, c2.category_bg_color FROM ' . CATEGORY_TABLE . ' c1 LEFT JOIN ' . CATEGORY_TABLE . ' c2 ON c2.category_parent_id = c1.category_id WHERE c2.category_id = 8';
	$result = mysql_query($sql);
	$category = mysql_fetch_assoc($result);
	mysql_free_result($result);

	$sql = 'SELECT * FROM ' . CONTENT_TABLE . ' WHERE content_id = 1';
	$result = mysql_query($sql);
	$history = mysql_fetch_assoc($result);
	mysql_free_result($result);

	$sql = 'SELECT * FROM ' . HISTORY_DATES_TABLE . ' ORDER BY history_dates_date ASC';
	$result = mysql_query($sql);
	while($row = mysql_fetch_assoc($result)) {
		$dates[$row['history_dates_id']] = array(
			'history_dates_date'	=>	$row['history_dates_date'],
			'history_dates_text_fr'	=>	$row['history_dates_text_fr'],
			'history_dates_text_en'	=>	$row['history_dates_text_en']
		);
	}
	mysql_free_result($result);
	
	foreach($dates as $value) {
		$template->assign_block_vars('keydatesrow', array(
			'V_KEYDATES'	=>	$value['history_dates_date'],
			'V_TEXT'		=>	addslashes(htmlspecialchars(preg_replace('/(\r\n|\n|\r)/', '<br />', $value['history_dates_text_' . $l])))
		));
	}

	$template->assign_vars(array(
		'T_HISTORY'			=>	preg_replace('/(\r\n|\n|\r)/', '<br />', $history['content_text_' . $l]),
		'T_HISTORY_NAME'	=>	$category['category_s_name_' . $l],

		'T_NAME_PAGE'		=>	$category['category_s_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'],
		
		'L_KEYDATES'		=>	$lang['KEYDATES']
	));

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

	unset($dates);
	$db->sql_close();

?>
