<html>

<head>
  <meta http-equiv='content-type' content='text/html;charset=utf-8'>
  <title>WebBike V1.0</title>
  <link href='style.css' rel='stylesheet' media='screen'>
</head>

<body>
  <?php
  set_time_limit(300);
  require 'database.inc.php';
  if (Test_User($lg_user, $lg_password) == TRUE) {
    $requette = "SELECT * FROM `commande" . ID_GARAGE . "` WHERE `Type` = 'GF' AND `Paye` != 'O' AND `APayer` != 0 AND `DateCommande` < '2008-01-01'";
    $resultat = Connection::executeRawQueryWithfetchAll($requette);
    foreach ($resultat as $ligne) {
      echo $ligne["NoCommande"] . "<br />\n";
      $requette = "INSERT INTO `dbcash" . ID_GARAGE . "` (`NoFacture`, `Date`, `Somme`, `TVA`, `ModePayement`, `NoCaisse`, `PersonneEncaissement`) VALUES (" . $ligne["NoCommande"] . ", '2000-01-01 00:00:00', " . $ligne["APayer"] . ", -" . get_config('TVA') . ", 12, 0, 'system')";
      Connection::executeRawQuery($requette);
      //echo $requette . "<br />\n";
      $requette = "UPDATE `commande" . ID_GARAGE . "` SET `APayer` = 0, `Paye` = 'O', `DatePayement` = '2000-01-01' WHERE `NoCommande` = " . $ligne["NoCommande"];
      Connection::executeRawQuery($requette);
      //echo $requette . "<br />\n";
    }
  }
  ?>
</body>

</html>