<?php

include ("config.php");

$highlight_menu = 3;

_request("id_pat", "confirm");

if ($info_pat = $pat->get_patient($id_pat))
{
	$id_zone = $info_pat["id_zone"];
	$pat_sexe = $info_pat["pat_sexe"];
	if ($_SESSION["Sid_user"] == ADMIN_USER)
	{
		$pat_nom = substr($info_pat["pat_nom"], 0, 3);
		$pat_prenom = substr($info_pat["pat_prenom"], 0, 1);
	}
	else
	{
		$pat_nom = $info_pat["pat_nom"];
		$pat_prenom = $info_pat["pat_prenom"];
	}

	$pat_datenaiss = $info_pat["pat_datenaiss"];
	ereg("^([0-9]{4})-([0-9]{2})-([0-9]{2})$", $pat_datenaiss, $regs);
	$pat_jour = $regs[3];
	$pat_mois = $regs[2];
	$pat_annee = $regs[1];
	$pat_nom_ep = $info_pat["pat_nom_ep"];
	$pat_adresse = $info_pat["pat_adresse"];
	$pat_code = $info_pat["pat_code"];
	$pat_ville = $info_pat["pat_ville"];
	$pat_tel = $info_pat["pat_tel"];
	$pat_mail = $info_pat["pat_mail"];
	$pat_envoi = $info_pat["pat_envoi"];
	$pat_qui = $info_pat["pat_qui"];
	$pat_hab = $info_pat["pat_hab"];
	$pat_contrat = $info_pat["pat_contrat"];
}
else
{
	header ("Location: patient.php");
	exit();
}

if ($confirm == 1)
{
	if ($pat->purge_patient($id_pat))
	{
		header ("Location: patient.php?action=suppression");
		exit();
	}
}

include ("header.php");

if (!empty($error))
{
	if (is_int($error))
		echo "<p class=\"center error\">" . $error_list[$error] . "</p>\n";
	else
		echo "<p class=\"center error\">" . $error . "</p>\n";
}

echo "<div id=\"form-patient\">\n";
echo "<table class=\"center\">\n";

echo "<tr>\n";
echo "<th class=\"center\" colspan=\"2\">Informations concernant ce patient</th>\n";
echo "</tr>\n";

echo "<tr>\n";
echo "<td class=\"r\"><label for=\"pat_nom\">Nom</label></td>\n";
echo "<td><input type=\"text\" class=\"int\" name=\"pat_nom\" id=\"pat_nom\" value=\"" . $pat_nom . "\" readonly=\"readonly\" /></td>\n";
echo "</tr>\n";

echo "<tr>\n";
echo "<td class=\"r\"><label for=\"pat_prenom\">Pr&eacute;nom</label></td>\n";
echo "<td><input type=\"text\" class=\"int\" name=\"pat_prenom\" id=\"pat_prenom\" value=\"" . $pat_prenom . "\" readonly=\"readonly\" /></td>\n";
echo "</tr>\n";

echo "<tr>\n";
echo "<td class=\"r\">Date de naissance</td>\n";
echo "<td><input type=\"text\" class=\"int\" name=\"pat_jour\" id=\"pat_jour\" value=\"" . $pat_jour . "\" maxlength=\"2\" size=\"2\" readonly=\"readonly\" />&nbsp;<input type=\"text\" class=\"int\" name=\"pat_mois\" id=\"pat_mois\" value=\"" . $pat_mois . "\" maxlength=\"2\"  size=\"2\" readonly=\"readonly\" />&nbsp;<input type=\"text\" class=\"int\" name=\"pat_annee\" id=\"pat_annee\" value=\"" . $pat_annee . "\" maxlength=\"4\"  size=\"4\" readonly=\"readonly\" /></td>\n";
echo "</tr>\n";

if ($_SESSION["Sid_user"] != ADMIN_USER)
{
	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_sexe\">Sexe</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_sexe\" id=\"pat_sexe\" value=\"" . (isset($sexe_tab[$pat_sexe]) ? $sexe_tab[$pat_sexe] : "") . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_nom_ep\">Nom d'&eacute;pouse</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_nom_ep\" id=\"pat_nom_ep\" value=\"" . $pat_nom_ep . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_adresse\">Adresse</label></td>\n";
	echo "<td><textarea name=\"pat_adresse\" id=\"pat_adresse\" readonly=\"readonly\">" . nobr($pat_adresse) . "</textarea></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_code\">Code Postal</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_code\" id=\"pat_code\" value=\"" . $pat_code . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_ville\">Ville</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_ville\" id=\"pat_ville\" value=\"" . $pat_ville . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_tel\">T&eacute;l&eacute;phone</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_tel\" id=\"pat_tel\" value=\"" . $pat_tel . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"pat_mail\">E-mail</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_mail\" id=\"pat_mail\" value=\"" . $pat_mail . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	$info_zone = $menu->get_zone_geo($id_zone);

	echo "<tr>\n";
	echo "<td class=\"r\"><label for=\"id_zone\">Zone g&eacute;ographique</label></td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"id_zone\" id=\"id_zone\" value=\"" . $info_zone["zone_nom"] . "\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";

	echo "<tr>\n";
	echo "<td class=\"r\">Date du contrat N°1</td>\n";
	echo "<td><input type=\"text\" class=\"int\" name=\"pat_contrat\" id=\"pat_contrat\" value=\"" . format_date($pat_contrat) . "\" size=\"10\" maxlength=\"10\" readonly=\"readonly\" /></td>\n";
	echo "</tr>\n";
}

echo "<tr>\n";
echo "<td class=\"center\" colspan=\"2\"><a class=\"sdel\" href=\"patient_suppression.php?id_pat=" . $id_pat . "&amp;confirm=1\">Confirmer la suppression de ce patient</a></td>\n";
echo "</tr>\n";

echo "</table>\n";
echo "</div>\n";

echo "<p><a class=\"slink\" href=\"patient.php\">Retour &agrave; la liste des patients</a></p>\n";

include ("footer.php");

?>