<?php

include ("config.php");

$highlight_menu = 5;
$highlight_cousu = 7;
$display_consu = true;

_post("id_prop", "id_mod", "prop_date", "prop_contrat", "prop_objectif", "prop_orientation", "prop_interv", "prop_sortie", "prop_motif", "edit_submit", "prop_tera");
_post("propPresc");

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

if (empty($edit_submit))
{
	$last_situpat = $situpat->get_situpat($last_id_consult);
	_array($last_situpat, "prop_tera");

	$last_proposition = $prop->get_last_proposition($_SESSION["Sid_pat"]);
	_array($last_proposition, "id_prop", "id_mod", "prop_date", "prop_contrat", "prop_objectif", "prop_orientation", "prop_interv", "prop_sortie", "prop_motif");
	$propPresc = $last_proposition["id_user"];
}

if ($edit_submit)
{
	if ($prop->edit_proposition($id_prop, $_SESSION["Sid_pat"], $id_mod, sql_date($prop_date), sql_date($prop_contrat), $prop_objectif, $prop_orientation, $prop_interv, $prop_sortie, $prop_motif) && $consu->editPropTera($last_id_consult, $prop_tera))
	{
		header ("Location: consultation.php");
		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 "<form action=\"proposition.php\" method=\"post\">\n";

$form->proposition($id_prop, $id_mod, $prop_date, $prop_contrat, $prop_objectif, $prop_orientation, $prop_interv, $prop_sortie, $prop_motif);

echo "<input class=\"inb\" type=\"submit\" name=\"edit_submit\" value=\"Enregistrer\" />\n";

echo "</form>\n";

include ("footer.php");

?>