<?php

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

	$date = isset($_GET['date']) ? $_GET['date'] : '0-0';
	list($years, $months) = explode('-', $date);
	$years = is_numeric($years) ? $years : 0;
	$months = is_numeric($months) ? $months : 0;

	$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_page, 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 = 12';
	$result = mysql_query($sql);
	$category = mysql_fetch_assoc($result);
	mysql_free_result($result);

	if($years and $months) {
		$sql = 'SELECT inter_day, inter_text_fr, inter_text_en FROM ' . INTER_TABLE . ' WHERE inter_year = ' . $years .' AND inter_month = ' . $months .' ORDER BY inter_day + 0 ASC';
		$result = mysql_query($sql);
		while($row = mysql_fetch_assoc($result)) {
			$template->assign_block_vars('itemrow', array(
				'T_DAY'		=>	$row['inter_day'],
				'T_TEXT'	=>	$row['inter_text_' . $l]
			));
		}
		mysql_free_result($result);
	}

	$sql = 'SELECT DISTINCT inter_year FROM ' . INTER_TABLE . ' ORDER BY inter_year DESC';
	$result = mysql_query($sql);
	while($row = mysql_fetch_assoc($result)) {
		$template->assign_block_vars('yearrow', array(
			'U_LINK'		=>	BASE_PATH . '/' . $category['category_page'] . '.php?date=' . $row['inter_year'] . '-' . 1,
			'T_YEAR'		=>	$row['inter_year'],
			'V_SELECTED'	=>	($row['inter_year'] == $years) ? true : false
		));
	}
	mysql_free_result($result);

	for($month = 1; $month <= 12; $month++) {
		$template->assign_block_vars('monthrow', array(
			'U_LINK'		=>	BASE_PATH . '/' . $category['category_page'] . '.php?date=' . $years . '-' . $month,
			'T_MONTH'		=>	$lang['MONTH'][$month],
			'V_SELECTED'	=>	($month == $months) ? true : false
		));
	}

	$template->assign_vars(array(
		'T_INTER_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_YEARS'			=>	$lang['YEARS']
	));

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

	$db->sql_close();

?>
