<?php

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

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

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

	$sql = 'SELECT * FROM ' . COMMITS_TABLE . ' ORDER BY commits_sort ASC';
	$result = mysql_query($sql);
	while($row = mysql_fetch_assoc($result)) {
		$commits[$row['commits_id']] = array(
			'commits_name_fr'	=>	$row['commits_name_fr'],
			'commits_text_fr'	=>	$row['commits_text_fr'],
			'commits_name_en'	=>	$row['commits_name_en'],
			'commits_text_en'	=>	$row['commits_text_en']
		);
	}
	mysql_free_result($result);
	
	
	
	foreach($commits as $value) {
		$template->assign_block_vars('commitsrow', array(
			'T_TEXT'	=>	addslashes(htmlspecialchars(preg_replace('/(\r\n|\n|\r)/', ' ', $value['commits_text_' . $l]))),
			'T_NAME'	=>	preg_replace('/(\r\n|\n|\r)/', ' ', $value['commits_name_' . $l])
		));
	}

	$template->assign_vars(array(
		'T_ETHICS'			=>	$ethics['content_text_' . $l],
		'T_ETHICS_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_COMMITS'			=>	sprintf($lang['COMMITS'], count($commits))
	));

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

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

?>
