<?php
  CheckAlertCommande($NoCommande);
  if(isset($Move))
  {
    switch($Move)
    {
      case "UP":
        $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres4"]);
        $up=$NoCommande;
        foreach($resultat as $ligne)
        {
          if($NoCommande==$ligne['NoCommande'])
          {
            break;
          }
          else
          {
             $up=$ligne['NoCommande'];
          }
        }
        $NoCommande=$up;
      break;
      case "DOWN":
        $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres4"]);
        $down=$NoCommande;
        for ($i=0; $i < count($resultat); $i++)
        {
          $ligne =$resultat[$i];
          $down=$ligne['NoCommande'];
          if($NoCommande==$ligne['NoCommande'])
          {
            if($ligne=$resultat[$i+1])
            {
                $down=$ligne['NoCommande'];
            }
            break;
          }
        }
        $NoCommande=$down;
      break;
    }
  }
  $ligne=Commande::getCommandeByNoCommande($NoCommande);
  switch($ligne['Type'])
  {
    case "FD":
      Maj_Facture(1, True);
      entete_commande("FD","Facture detaillée");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI+M_ENC);
      Affiche_Delais_Payement();
      Affiche_Convert_FD($NoCommande);
    break;
    case "BP":
      Maj_Facture(1, True);
      entete_commande("BP","Bulletin de livraison");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI);
    break;
    case "FB":
      Maj_Facture(0, True);
      entete_commande("FB","Facture bulletin de livraison");
      Affiche_Impression(0,M_CLI+M_FAC+M_PRI+M_ENC);
      Affiche_Delais_Payement();
    break;
    case "FV":
      Maj_Facture(1, True);
      entete_commande("FV","Facture vehicule neuf");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI+M_ENC,O_VENTEVHC);
      Affiche_Delais_Payement();
    break;
    case "FO":
      Maj_Facture(1, True);
      entete_commande("FO","Facture vehicule occasion");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI+M_ENC,O_VENTEVHC);
      Affiche_Delais_Payement();
    break;
    case "FL":
      Maj_Facture(1, True);
      entete_commande("FL","Facture location vehicule");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI+M_ENC);
      Affiche_Delais_Payement();
    break;
    case "FI":
      Maj_Facture(1, False);
      entete_commande("FI","Facture interne");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI);
      Affiche_Convert_FI($NoCommande);
    break;
    case "DP":
      Maj_Facture(0, False);
      entete_commande("DP","Devis");
      Affiche_Impression(0,M_CLI+M_FAC+M_PRI);
    break;
    case "OP":
      Maj_Facture(0, False);
      entete_commande("OP","Offre pièces");
      Affiche_Impression(0,M_CLI+M_FAC+M_PRI);
    break;
    case "OV":
      $Devis=1;
      Maj_Facture(0, False);
      entete_commande("OV","Offre vehicule");
      Affiche_Impression(0,M_CLI+M_FAC+M_PRI,O_VENTEVHC);
    break;
    case "CP":
      Maj_Facture(3, True);
      entete_commande("CP","Commande",1);
      Affiche_Impression(3,M_CLI+M_FAC+M_PRI);
    break;
    case "RC":
      Maj_Facture(1, False);
      entete_commande("RC","Retour commande");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI);
    break;
    case "AM":
      Maj_Facture(2, True);
      entete_commande("AM","Achat");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "GF":
      Maj_Facture(1, True);
      entete_commande("GF","Garantie fourniseur");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI+M_ENC);
      Affiche_Delais_Payement();
      Affiche_Convert_GF($NoCommande);
    break;
    case "GG":
      Maj_Facture(1, False);
      entete_commande("GG","Garantie garage");
      Affiche_Impression(1,M_CLI+M_FAC+M_PRI);
      Affiche_Convert_GG($NoCommande);
    break;
    case "RV":
      Maj_Facture(2, True);
      entete_commande("RV","Reprise véhicule");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "ND":
      Maj_Facture(2, True);
      entete_commande("ND","Note de credit facture détaillée");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NB":
      Maj_Facture(2, True);
      entete_commande("NB","Note de credit facture bulletins");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NV":
      Maj_Facture(2, True);
      entete_commande("NV","Note de credit facture vehicule neuf");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NO":
      Maj_Facture(2, True);
      entete_commande("NO","Note de credit facture occasion");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NL":
      Maj_Facture(2, True);
      entete_commande("NL","Note de credit facture location");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "MO":
      Maj_Facture(0, False);
      entete_commande("MO","Modèle");
      Affiche_Impression(2,M_CLI+M_FAC+M_PRI);
    break;
    case "TR":
      entete_commande("TR","Transfert");
    break;
    default:
      echo $ligne['Type']."<BR>\n";
    break;
  }
?>
