<?php
require 'database.inc.php';
if ((!empty($User)) && (!empty($Passwd))) {
  $lg_user = $User;
  $lg_password = $Passwd;
}
if (Test_User($lg_user, $lg_password) == TRUE) {
  //$annee=date("Y");
  if ($new == 1) {
    if ($text != "") {
      $requette = "INSERT INTO note" . ID_GARAGE . " (Date, Personne, Texte) VALUES ('$annee-$mois-$jour', '" . Connection::getConnection()->quote($personne) . "', '" . Connection::getConnection()->quote($text) . "')";
      Connection::executeRawQuery($requette);
    }
  } else {
    if ($text != "") {
      $requette = "UPDATE note" . ID_GARAGE . " SET Texte = '" . Connection::getConnection()->quote($text) . "' WHERE Date = '$annee-$mois-$jour' AND Personne = '" . Connection::getConnection()->quote($personne) . "'";
      Connection::executeRawQuery($requette);
    } else {
      $requette = "DELETE FROM note" . ID_GARAGE . " WHERE Date = '$annee-$mois-$jour' AND Personne = '" . Connection::getConnection()->quote($personne) . "'";
      Connection::executeRawQuery($requette);
    }
  }
  echo "<script language=JavaScript>\n";
  echo "this.opener.location.reload();\n";
  echo "window.close();\n";
  echo "</script>\n";
}
