<?php
CheckAlertCommande($NoCommande);
?>
<div class="div_facture">
<?php
  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;
    }
  }
  if(isset($NewType))
  {
    $TypeCommande=$NewType;
  }
  else
  {
    $ligne=Commande::getCommandeByNoCommande($NoCommande);
    $TypeCommande=$ligne['Type'];
  }
  switch($TypeCommande)
  {
    case "FD":
      Update_Coordonnees_Facture('FD','F');
      entete_commande("FD","Facture detaillée");
      Affiche_Facture('FD','F',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_MODELE, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "BP":
      Update_Coordonnees_Facture('BP','B');
      entete_commande("BP","Bulletin de livraison");
      Affiche_Facture('BP','B',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI);
    break;
    case "FB":
      Update_Coordonnees_Facture('FB','F');
      entete_commande("FB","Facture bulletin de livraison");
      Affiche_Facture('FB','F',F_EDIT+F_TOT+F_ART+F_TEXT+F_BL, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "FV":
      $Devis=0;
      Update_Coordonnees_Facture('FV','F');
      entete_commande("FV","Facture véhicule neuf");
      Affiche_Facture('FV','F',F_EDIT+F_TOT+F_ART+F_TEXT+F_VHC+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "FO":
      $Devis=0;
      Update_Coordonnees_Facture('FO','F');
      entete_commande("FO","Facture véhicule occasion");
      Affiche_Facture('FO','F',F_EDIT+F_TOT+F_ART+F_TEXT+F_VHC_OCC+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "FL":
      Update_Coordonnees_Facture('FL','F');
      entete_commande("FL","Facture location véhicule");
      Affiche_Facture('FL','F',F_EDIT+F_ART+F_TEXT, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "FI":
      Update_Coordonnees_Facture('FI','F');
      entete_commande("FI","Facture interne");
      Affiche_Facture('FI','F',F_EDIT+F_TOT+F_ART+F_TEXT, M_CLI+M_FAC+M_PRI);
    break;
    case "DP":
      Update_Coordonnees_Facture('DP','D');
      entete_commande("DP","Devis");
      Affiche_Facture('DP','D',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_DUPLIQUER, M_CLI+M_FAC+M_PRI);
    break;
    case "OP":
      Update_Coordonnees_Facture('OP','O');
      entete_commande("OP","Offre pièces");
      Affiche_Facture('OP','O',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_DUPLIQUER, M_CLI+M_FAC+M_PRI);
    break;
    case "OV":
      $Devis=1;
      Update_Coordonnees_Facture('OV','O');
      entete_commande("OV","Offre véhicule");
      Affiche_Facture('OV','O',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_VHC+F_VHC_OCC+F_DUPLIQUER+F_MODELE, M_CLI+M_FAC+M_PRI);
    break;
    case "CP":
      Update_Coordonnees_Facture('CP','C');
      entete_commande("CP","Commande",1);
      Affiche_Facture('CP','C', F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_COMMANDE+F_TITRE, M_CLI+M_FAC+M_PRI);
    break;
    case "RC":
      Update_Coordonnees_Facture('RC','C');
      entete_commande("RC","Retour commande");
      Affiche_Facture('RC','C', F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI);
    break;
    case "AM":
      Update_Coordonnees_Facture('AM','A');
      entete_commande("AM","Achat");
      Affiche_Facture('AM','A',F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER+F_ACHAT_MARCHANDISE, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "GF":
      Update_Coordonnees_Facture('GF','G');
      entete_commande("GF","Garantie fourniseur");
      Affiche_Facture('GF','G', F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "GG":
      Update_Coordonnees_Facture('GG','G');
      entete_commande("GG","Garantie garage");
      Affiche_Facture('GG','G', F_EDIT+F_TOT+F_ART+F_TEXT+F_PRESSEPAPIER, M_CLI+M_FAC+M_PRI);
    break;
    case "RV":
      Update_Coordonnees_Facture('RV','R');
      entete_commande("RV","Reprise véhicule");
      Affiche_Facture('RV','R', F_EDIT+F_TEXT+F_VHC_REP, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "ND":
      Update_Coordonnees_Facture('ND','N');
      entete_commande("ND","Note de crédit facture détaillée");
      Affiche_Facture('ND','N', F_EDIT+F_TEXT+F_ART, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NB":
      Update_Coordonnees_Facture('NB','N');
      entete_commande("NB","Note de credit facture bulletins");
      Affiche_Facture('NB','N', F_EDIT+F_TEXT+F_VHC_REP, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NV":
      Update_Coordonnees_Facture('NV','N');
      entete_commande("NV","Note de crédit facture véhicule neuf");
      Affiche_Facture('NV','N', F_EDIT+F_TEXT+F_VHC_REP, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NO":
      Update_Coordonnees_Facture('NO','N');
      entete_commande("NO","Note de crédit facture occasion");
      Affiche_Facture('NO','N', F_EDIT+F_TEXT+F_VHC_REP, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "NL":
      Update_Coordonnees_Facture('NL','N');
      entete_commande("NL","Note de crédit facture location");
      Affiche_Facture('NL','N', F_EDIT+F_TEXT+F_VHC_REP, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "TR":
      Update_Coordonnees_Facture('TR','T');
      entete_commande("TR","Transfert");
      Affiche_Facture('TR','T',0, M_CLI+M_FAC+M_PRI+M_ENC);
    break;
    case "MO":
      Update_Coordonnees_Facture('MO','M');
      entete_commande("MO","Modele");
      Affiche_Facture('MO','M', F_EDIT+F_TOT+F_ART+F_TEXT+F_TITRE, M_CLI+M_FAC);
    break;
    default:
      echo $ligne['Type']."<BR>\n";
    break;
  }
?>
</div>