<?php
/*********************************************************************************
 * Gest'Ecole is a school management software developped by
 * DOX Conception Copyright (C) 2012-2013 DOX Conception
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the license published by DOX Conception.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY.  See the Software License for more details.
 * 
 * You should have received a copy of the software license along with
 * this program; if not, see:
 * http://www.doxconception.com/index.php/licence-de-gestecole.html
 ********************************************************************************/

  $id=$_POST['id'];
  $id_livre_emprunt=$_POST['id_livre_emprunt'];
  $id_util_emprunt=$_POST['id_util_emprunt'];
  $decoupe=explode("|",$id_util_emprunt);
  $date_emprunt=Date_Convertir($_POST['date_emprunt'],$Format_Date_PHP,"Y-m-d");
  $date_retour=$_POST['date_retour'];
  if ($date_retour!="")
  {
    $date_retour=Date_Convertir($date_retour,$Format_Date_PHP,"Y-m-d");
  }
  else
  {
    $date_retour="0000-00-00";
  }
  
  if ($id=="")
  {
    $id=Construit_Id("bibliotheque_emprunt",20);
		$req=mysql_query("INSERT INTO `bibliotheque_emprunt` (id,id_livre,id_util,type_util,date_emprunt,date_retour) VALUES ('$id','$id_livre_emprunt','".$decoupe[1]."','".$decoupe[0]."','$date_emprunt','$date_retour')");
  }
  else
  {
		$req=mysql_query("UPDATE `bibliotheque_emprunt` SET id_util='".$decoupe[1]."', type_util='".$decoupe[0]."', date_emprunt='$date_emprunt', id_livre='$id_livre_emprunt', date_retour='$date_retour' WHERE id='$id'");
  }
  
  echo $id.'|'.$id_livre_emprunt;
?>