<?php

class final
{
	function get_final($id_consult)
	{
		$q = "SELECT * FROM final WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			$n = mysql_fetch_assoc($r);
			return $n;
		}
		else
			die("Erreur m�canique " . mysql_errno() . " : " . mysql_error());

		return false;
	}

	function edit_final($id_consult, $fin_add, $fin_motiv, $fin_courrier, $fin_conseil, $fin_objectif, $fin_modfini, $fin_satisf, $fin_satisf_fait)
	{
		if ($id_consult)
			$q = "UPDATE final SET fin_add = '" . $fin_add . "', fin_motiv = '" . $fin_motiv . "', fin_courrier = '" . $fin_courrier . "', fin_conseil = '" . $fin_conseil . "', fin_objectif = '" . $fin_objectif . "', fin_modfini = '" . $fin_modfini . "', fin_satisf = '" . $fin_satisf . "', fin_satisf_fait = '" . $fin_satisf_fait . "' WHERE id_consult = '" . $id_consult . "'";
		else
			$q = "INSERT INTO final (id_consult, fin_add, fin_motiv, fin_courrier, fin_conseil, fin_objectif, fin_modfini, fin_satisf, fin_satisf_fait) VALUES ('" . $id_consult . "', '" . $fin_add . "', '" . $fin_motiv . "', '" . $fin_courrier . "', '" . $fin_conseil . "', '" . $fin_objectif . "', '" . $fin_modfini . "', '" . $fin_satisf . "', '" . $fin_satisf_fait . "')";

		$r = mysql_query($q);

		if ($r)
			return true;
		else
			die("Erreur m�canique " . mysql_errno() . " : " . mysql_error());

		return false;
	}

	function del_final($id_consult)
	{
		$q = "DELETE FROM final WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			$q = "OPTIMIZE TABLE final";
			$r = mysql_query($q);

			return true;
		}
		else
			die("Erreur m�canique " . mysql_errno() . " : " . mysql_error());

		return false;
	}
}

?>