<?php
require 'database.inc.php';
if (Test_User($lg_user, $lg_password) == TRUE) {
  $ligne = Commande::getCommandeByNoCommande($NoCommande);;
  if ($ligne['Paye'] != 'O') {
    if ($resultat = CommandeArticle::getCommandeArticleByNoCommande($NoCommande)) {
      echo "document.info.Texte_libre.value='Bultin de livraison no $NoCommande';\n";
      echo "add_new_text_newfact();\n";
      foreach ($resultat as $ligne) {
        echo "document.info.NoArticle.value='" . addslashes($ligne['NoArticle']) . "';\n";
        echo "document.info.Description.value='" . addslashes($ligne['Description']) . "';\n";
        echo "document.info.Prix.value ='" . $ligne['PrixBase']  . "';\n";
        echo "document.info.TVA.value = '" . $ligne['TVA']  . "';\n";
        echo "document.info.GM.value = '" . $ligne['GM'] . "';\n";
        echo "document.info.Rabais.value = '" . $ligne['Rabais'] . "';\n";
        echo "document.info.Quantite.value = '" . $ligne['Quantite'] . "';\n";
        echo "add_new_newfact(false);\n";
      }
      echo "tot_inter_newfact();\n";
      $requette = "UPDATE commande" . ID_GARAGE . " SET Paye='O', DatePayement='" . date("Y-m-d") . "' WHERE NoCommande=$NoCommande";
      Connection::executeRawQuery($requette);
    }
  }
}
