<?php

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
echo "<html lang=\"fr\">\n";
echo "<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";
echo "<meta name=\"author\" content=\"Chantal Bernard-Putz, Franck Denis, Philippe Plane et Octopuce\" />\n";
echo "<meta name=\"description\" lang=\"fr\" content=\"Application de gestion en ligne de reseau Alcool.Ce logiciel libre écrit en PHP permet de gerer facilement l'activite d'un reseau medico-social et d'assurer le suivi des patients \" />\n";

echo "<title>" . (isset($page_title) ? $page_title : "GRAL") . "</title>\n";
echo "<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n";
echo "<link rel=\"stylesheet\" href=\"jscalendar/calendar-blue.css\" type=\"text/css\" media=\"all\" />\n";
echo "<script type=\"text/javascript\" src=\"jscalendar/calendar.js\"></script>\n";
echo "<script type=\"text/javascript\" src=\"jscalendar/lang/calendar-fr.js\"></script>\n";
echo "<script type=\"text/javascript\" src=\"calendar.js\"></script>\n";
echo "<script type=\"text/javascript\" src=\"app.js\"></script>\n";
echo "<script type=\"text/javascript\" src=\"wz_jsgraphics.js\"></script>\n";
echo "<script type=\"text/javascript\" src=\"rosace.js\"></script>\n";
echo "</head>\n";
echo "<body>\n";

echo "<div id=\"global\">\n";

echo "<div id=\"menu\">\n";

echo "<p>\n";
echo "<a" . (isset($highlight_menu) && $highlight_menu === 1 ? " class=\"highlight\"" : "") . " href=\"index.php\">" . (empty($_SESSION) ? "Connexion" : "Se d&eacute;connecter") . "</a>\n";

if (!empty($_SESSION["Sid_user"]))
{
	echo "<a" . (isset($highlight_menu) && $highlight_menu === 7 ? " class=\"highlight\"" : "") . " href=\"password.php\">Changer de mot de passe</a>\n";

	if ($_SESSION["Sid_user"] == ADMIN_USER)
		echo "<a" . (isset($highlight_menu) && $highlight_menu === 2 ? " class=\"highlight\"" : "") . " href=\"utilisateur.php\">Utilisateurs</a>\n";

	echo "<a" . (isset($highlight_menu) && $highlight_menu === 3 ? " class=\"highlight\"" : "") . " href=\"patient.php\">Patients</a>\n";

	if ($_SESSION["Sid_user"] == ADMIN_USER)
	{
		echo "<a" . (isset($highlight_menu) && $highlight_menu === 4 ? " class=\"highlight\"" : "") . " href=\"menu.php\">Menus d&eacute;roulants</a>\n";
		echo "<a" . (isset($highlight_menu) && $highlight_menu === 6 ? " class=\"highlight\"" : "") . " href=\"bilan.php\">Bilans</a>\n";
		echo "<a" . (isset($highlight_menu) && $highlight_menu === 8 ? " class=\"highlight\"" : "") . " href=\"compta.php\">Compta</a>\n";
	}

	echo "<a" . (isset($highlight_menu) && $highlight_menu === 5 ? " class=\"highlight\"" : "") . " href=\"suivi.php\">Suivi des patients</a>\n";
}

echo "</p>\n";

echo "</div>\n";

if (isset($display_menu) && $display_menu === true)
{
	echo "<div id=\"sous-menu\">\n";

	echo "<p>\n";
	echo "<a" . (isset($highlight_sous_menu) && $highlight_sous_menu === 1 ? " class=\"highlight\"" : "") . " href=\"module.php\">Modules</a>\n";
	echo "<a" . (isset($highlight_sous_menu) && $highlight_sous_menu === 2 ? " class=\"highlight\"" : "") . " href=\"zone.php\">Zones g&eacute;ographiques</a>\n";
	echo "<a" . (isset($highlight_sous_menu) && $highlight_sous_menu === 3 ? " class=\"highlight\"" : "") . " href=\"specialite.php\">Sp&eacute;cialit&eacute;s</a>\n";
//	echo "<a" . (isset($highlight_sous_menu) && $highlight_sous_menu === 4 ? " class=\"highlight\"" : "") . " href=\"couverture.php\">Couvertures sociales</a>\n";
	echo "</p>\n";

	echo "</div>\n";
}

if (isset($display_consu) && $display_consu === true)
{
	echo "<div id=\"consultation-menu\">\n";

	echo "<p>\n";
	echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 1 ? " class=\"highlight\"" : "") . " href=\"rdv.php\">Rendez-vous</a>\n";
	echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 6 ? " class=\"highlight\"" : "") . " href=\"consultation.php\">Historique des consultations</a>\n";

	$last_consu = $consu->get_last_consultation($_SESSION["Sid_user"], $_SESSION["Sid_pat"]);

	if (empty($last_consu) && !isset($_SESSION["Sadmin"]))
	{
		echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 2 ? " class=\"highlight\"" : "") . " href=\"fiche.php\">Fiche de contact</a>\n";
		if ($_SESSION["Suser_cat"] == 1)
			echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 3 ? " class=\"highlight\"" : "") . " href=\"dossier_init.php\">Dossier initial</a>\n";
	}
	else
	{
		if ($_SESSION["Suser_cat"] == 1 && !isset($_SESSION["Sadmin"]))
		{
			echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 8 ? " class=\"highlight\"" : "") . " href=\"filtre.php\">Filtre</a>\n";

			$last_prop = $prop->get_last_proposition($_SESSION["Sid_pat"]);

			if (!empty($last_prop) && $last_prop["prop_fini"] == 0 && ($last_consu["consu_type"] == 2 || $last_consu["consu_type"] == 4))
				echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 7 ? " class=\"highlight\"" : "") . " href=\"proposition.php\">Proposition</a>\n";

// 			if ($consu->isLastAndEditable($last_consu["id_consult"], $_SESSION["Sid_user"], $_SESSION["Sid_pat"]) === false)
// 			{
				if ($last_consu["consu_type"] == 1)
					echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 3 ? " class=\"highlight\"" : "") . " href=\"dossier_init.php\">Dossier initial</a>\n";

				if (($last_consu["consu_type"] != 1 && !empty($last_prop) && $last_prop["prop_contrat"] != "0000-00-00" && $last_prop["id_mod"] != "0") || $last_consu["consu_type"] == 3)
					echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 4 ? " class=\"highlight\"" : "") . " href=\"dossier_suite.php\">Consultation de suite</a>\n";

				if ($last_consu["consu_type"] == 3)
					echo "<a" . (isset($highlight_cousu) && $highlight_cousu === 5 ? " class=\"highlight\"" : "") . " href=\"dossier_final.php\">Dossier final</a>\n";
// 			}
		}
	}

	echo "</p>\n";

	echo "</div>\n";
}

// Fiche de contact
if (isset($display_fiche) && $display_fiche === true)
{
	echo "<div id=\"dossier-menu\">\n";

	echo "<p>\n";

	echo "<a class=\"highlight\" id=\"tab-info\" href=\"javascript:displayTab('info')\">Informations g&eacute;n&eacute;rales</a>\n";

// 	if ($_SESSION["Suser_cat"] == 1)
// 	{
		echo "<a id=\"tab-alcool\" href=\"javascript:displayTab('alcool')\">Alcool / Tabac</a>\n";
//		echo "<a id=\"tab-drogue\" href=\"javascript:displayTab('drogue')\">Drogue</a>\n";
//		echo "<a id=\"tab-medic\" href=\"javascript:displayTab('medic')\">M&eacute;dicaments</a>\n";
// 	}
	echo "<a id=\"tab-rosace\" href=\"javascript:displayTab('rosace')\">Evaluation</a>\n";
	echo "<a id=\"tab-consultation\" href=\"javascript:displayTab('consultation')\">Enregistrer</a>\n";

	echo "</p>\n";

	echo "</div>\n";
}

// Dossier initial
if (isset($display_dossier_init) && $display_dossier_init === true)
{
	echo "<div id=\"dossier-menu\">\n";

	echo "<p>\n";

	echo "<a class=\"highlight\" id=\"tab-info\" href=\"javascript:displayTab('info')\">Informations g&eacute;n&eacute;rales</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
	{
		echo "<a id=\"tab-alcool\" href=\"javascript:displayTab('alcool')\">Alcool / Tabac</a>\n";
		echo "<a id=\"tab-drogue\" href=\"javascript:displayTab('drogue')\">Drogue</a>\n";
		echo "<a id=\"tab-medic\" href=\"javascript:displayTab('medic')\">M&eacute;dicaments</a>\n";
	}
	echo "<a id=\"tab-rosace\" href=\"javascript:displayTab('rosace')\">Evaluation</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
		echo "<a id=\"tab-proposition\" href=\"javascript:displayTab('proposition')\">Proposition</a>\n";
	echo "<a id=\"tab-consultation\" href=\"javascript:displayTab('consultation')\">Enregistrer</a>\n";

	echo "</p>\n";

	echo "</div>\n";
}

// Consultation de suite
if (isset($display_dossier_suite) && $display_dossier_suite === true)
{
	echo "<div id=\"dossier-menu\">\n";

	echo "<p>\n";

	echo "<a class=\"highlight\" id=\"tab-info\" href=\"javascript:displayTab('info')\">Informations g&eacute;n&eacute;rales</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
	{
		echo "<a id=\"tab-alcool\" href=\"javascript:displayTab('alcool')\">Alcool / Tabac</a>\n";
		echo "<a id=\"tab-drogue\" href=\"javascript:displayTab('drogue')\">Drogue</a>\n";
		echo "<a id=\"tab-medic\" href=\"javascript:displayTab('medic')\">M&eacute;dicaments</a>\n";
		echo "<a id=\"tab-bio\" href=\"javascript:displayTab('bio')\">Biologie</a>\n";
	}
	echo "<a id=\"tab-rosace\" href=\"javascript:displayTab('rosace')\">Evaluation</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
		echo "<a id=\"tab-prescription\" href=\"javascript:displayTab('prescription')\">Prescription</a>\n";
	echo "<a id=\"tab-consultation\" href=\"javascript:displayTab('consultation')\">Enregistrer</a>\n";

	echo "</p>\n";

	echo "</div>\n";
}

// Dossier final
if (isset($display_dossier_final) && $display_dossier_final === true)
{
	echo "<div id=\"dossier-menu\">\n";

	echo "<p>\n";

	echo "<a class=\"highlight\" id=\"tab-info\" href=\"javascript:displayTab('info')\">Informations g&eacute;n&eacute;rales</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
	{
		echo "<a id=\"tab-alcool\" href=\"javascript:displayTab('alcool')\">Alcool / Tabac</a>\n";
		echo "<a id=\"tab-drogue\" href=\"javascript:displayTab('drogue')\">Drogue</a>\n";
		echo "<a id=\"tab-medic\" href=\"javascript:displayTab('medic')\">M&eacute;dicaments</a>\n";
	}
	echo "<a id=\"tab-rosace\" href=\"javascript:displayTab('rosace')\">Evaluation</a>\n";
	if ($_SESSION["Suser_cat"] == 1)
	{
		echo "<a id=\"tab-proposition\" href=\"javascript:displayTab('proposition')\">Proposition</a>\n";
		echo "<a id=\"tab-satisfaction\" href=\"javascript:displayTab('satisfaction')\">Satisfaction</a>\n";
	}
	echo "<a id=\"tab-consultation\" href=\"javascript:displayTab('consultation')\">Enregistrer</a>\n";

	echo "</p>\n";

	echo "</div>\n";
}

echo "<div id=\"contenu\">\n";

?>