<?php

class alctab
{
	function get_alctab($id_consult)
	{
		$q = "SELECT * FROM alctab 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_alctab($id_consult, $alc_verre_jour, $alc_jour_sem, $alc_jour_mois, $alc_an, $alc_4_5_jour, $alc_4_5_occ, $alc_8_12_jour, $alc_8_12_occ, $alc_16_20_jour, $alc_16_20_occ, $alc_40_jour, $alc_40_occ, $alc_conso_sem, $alc_conso_jour, $alc_conso_occ, $alc_audit, $tab_conso, $alc_objectif)
	{
		if ($id_consult)
			$this->del_alctab($id_consult);

		$q = "INSERT INTO alctab (id_consult, alc_verre_jour, alc_jour_sem, alc_jour_mois, alc_an, alc_4_5_jour, alc_4_5_occ, alc_8_12_jour, alc_8_12_occ, alc_16_20_jour, alc_16_20_occ, alc_40_jour, alc_40_occ, alc_conso_sem, alc_conso_jour, alc_conso_occ, alc_audit, tab_conso, alc_objectif) VALUES ('" . $id_consult . "', '" . $alc_verre_jour . "', '" . $alc_jour_sem . "', '" . $alc_jour_mois . "', '" . $alc_an . "', '" . $alc_4_5_jour . "', '" . $alc_4_5_occ . "', '" . $alc_8_12_jour . "', '" . $alc_8_12_occ . "', '" . $alc_16_20_jour . "', '" . $alc_16_20_occ . "', '" . $alc_40_jour . "', '" . $alc_40_occ . "', '" . $alc_conso_sem . "', '" . $alc_conso_jour . "', '" . $alc_conso_occ . "', '" . $alc_audit . "', '" . $tab_conso . "', '" . $alc_objectif . "')";
		$r = mysql_query($q);
	
		if ($r) 
			return true;
		else
			die("Erreur mécanique " . mysql_errno() . " : " . mysql_error());
	
		return false;
	}

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

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

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

		return false;
}
}

?>