<?php

include ("config.php");

$highlight_menu = 5;

_post("id_pat", "edit_submit");

if (empty($edit_submit) && !empty($_SESSION["Sid_pat"]))
	$id_pat = $_SESSION["Sid_pat"];

if ($edit_submit)
{
	$_SESSION["Sid_pat"] = $id_pat;
	header ("Location: rdv.php");
}

include ("header.php");

if (isset($_SESSION["Sadmin"]))
	$ls = $suivi->list_suivi_admin();
else
	$ls = $suivi->list_suivi_util($_SESSION["Sid_user"]);

if (!empty($ls))
{
	$i = 0;
	echo "<div id=\"list-suivi\">\n";
	echo "<table>\n";
	echo "<tr>\n";
	echo "<th colspan=\"2\">Choix du patient</th>\n";
	echo "</tr>\n";
	echo "<tr class=\"titre\">\n";
	echo "<td>Patient</td>\n";
	echo "<td>Action</td>\n";
	echo "</tr>\n";
	foreach ($ls AS $s)
	{
		if (isset($_SESSION["Sadmin"]))
		{
			$patNom = substr($s["pat_nom"], 0, 3);
			$patPrenom = substr($s["pat_prenom"], 0, 1);
		}
		else
		{
			$patNom = $s["pat_nom"];
			$patPrenom = $s["pat_prenom"];
		}
		$class = ($i % 2 == 0 ? "" : "inter");
		echo "<tr class=\"" . $class . "\">\n";
		echo "<td>" . $patNom . " " . $patPrenom . "</td>\n";
		echo "<td class=\"action\"><form action=\"suivi.php\" method=\"post\"><input type=\"hidden\" name=\"id_pat\" value=\"" . $s["id_pat"] . "\" /><input type=\"submit\" name=\"edit_submit\" class=\"inb\" value=\"Afficher le suivi\" /></form></td>\n";
		echo "</tr>\n";
		$i++;
	}
	echo "</table>\n";
	echo "</div>\n";
}
else
{
	echo "<p class=\"error center\">Vous n'avez aucun patient en cours de suivi.</p>\n";
}

include ("footer.php");

?>