<?php
	error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
	Include('../database.params.inc.php');
	$link = pg_connect("host=$machine user=$user password=$pwd dbname=$db")or die("Erreur de Connection !<br />".pg_last_error()) ;

	switch ($_POST['action']) {
		case 'etat':
			$id = $_POST['id'];
			$query1 = "UPDATE COMMANDE SET etat='fait' WHERE conso = '$id'";
			$result1 = pg_query($link, $query1) or die("Erreur SQL !<br />$query<br />".pg_last_error()) ;
			break;

		case 'etat_tot':
			$cmd = $_POST['cmd'];
			$query2 = "UPDATE COMMANDE SET etat='fait' WHERE num_cmd = '$cmd'";
			$result2 = pg_query($link, $query2) or die("Erreur SQL !<br />$query<br />".pg_last_error()) ;
			break;

		case 'paiement':
			$cmd = $_POST['cmd'];
			$query2 = "UPDATE COMMANDE SET paiement='TRUE' WHERE num_cmd = '$cmd'";
			$result2 = pg_query($link, $query2) or die("Erreur SQL !<br />$query<br />".pg_last_error()) ;
			break;

		case 'livraison':
			$cmd = $_POST['cmd'];
			$query2 = "UPDATE COMMANDE SET etat='LIVREE' WHERE num_cmd = '$cmd'";
			$result2 = pg_query($link, $query2) or die("Erreur SQL !<br />$query<br />".pg_last_error()) ;
			break;
		
		default:
			header('Location: index.php');
			exit();
			break;
	}


	header('Location: index.php');
	exit();
?>


				