<?php

include ("config.php");

_post("id_consult", "id_pat", "id_user", "consu_type", "consu_date", "consu_comment", "consu_eval", "consu_ferme");

class consu
{
	var $id_consult;
	var $id_pat;
	var $id_user;
	var $consu_type;
	var $consu_date;
	var $consu_comment;
	var $consu_eval;
	var $consu_ferme;

	function set_consu($id_consult, $id_pat, $id_user, $consu_type, $consu_date, $consu_comment, $consu_eval, $consu_ferme)
	{
		$this->id_consult = $id_consult;
		$this->id_pat = $id_pat;
		$this->id_user = $id_user;
		$this->consu_type = $consu_type;
		$this->consu_date = $consu_date;
		$this->consu_comment = $consu_comment;
		$this->consu_eval = $consu_eval;
		$this->consu_ferme = $consu_ferme;
	}

	function get_consu($id_consult)
	{
		$q = "SELECT * FROM consultation WHERE id_consult = '" . $id_consult . "'";
		$r = mysql_query($q);

		if ($r)
		{
			if ($t = mysql_num_rows($r))
			{
				$row = mysql_fetch_array($r);

				foreach ($row as $key => $value)
					$this->{$key} = $value;	
			}
		}
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	}

	function form_consu($id_consult = 0)
	{
		if ($id_consult)
			$this->get_consu($id_consult);

		echo "<form action=\"\" method=\"post\">\n";
		echo "<table>\n";

		echo "<tr>\n";
		echo "<td>ID</td>\n";
		echo "<td><input type=\"text\" name=\"id_consult\" value=\"" . $this->id_consult . "\" /></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>PAT</td>\n";
		echo "<td><input type=\"text\" name=\"id_pat\" value=\"" . $this->id_pat . "\" /></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>USER</td>\n";
		echo "<td><input type=\"text\" name=\"id_user\" value=\"" . $this->id_user . "\" /></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>Type de consultation</td>\n";
		echo "<td><input type=\"text\" name=\"consu_type\" value=\"" . $this->consu_type . "\" /></td>\n";
		echo "</tr>\n";

		echo "</table>\n";

		echo "<input type=\"submit\" name=\"edit\" value=\"Go go go !!\">\n";
		echo "</form>\n";
	}
}

$test = new consu();
$test->set_consu($id_consult, $id_pat, $id_user, $consu_type, $consu_date, $consu_comment, $consu_eval, $consu_ferme);
$test->form_consu();
?>