<?php
  //require_once 'class.FirePHP.php';
  function Trouve_No_Client_Libre()
  {
      if($ligne = Config::getNoClient())
      {
        $last=$ligne;
        if($last>0)
        {
          $last++;
          Config::updateNoClient($last);
          return $last;
        }
      }
	  return 0;
  }

  function Compare_Sans_Accents($Var1,$Var2)
  {
    $Debut="(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LCASE(";
    $Fin="),'ö','o'),'é','e'),'è','e'),'à','a'),'ä','a'),'á','a'),'â','a'),'ç','c'),'ê','e'),'ï','i'),'î','i'),'ô','o'),'û','u'),'ü','u'))";
    return $Debut . $Var1 . $Fin . " LIKE '" . addslashes(enleveaccents($Var2)) . "%'";
  }

  function Compare_Sans_Accents_Multiple($Var1,$Var2)
  {
    $arr = explode(" ", $Var2);
	$out = "";
	$first = true;
    $Debut="(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LCASE(";
    $Fin="),'ö','o'),'é','e'),'è','e'),'à','a'),'ä','a'),'á','a'),'â','a'),'ç','c'),'ê','e'),'ï','i'),'î','i'),'ô','o'),'û','u'),'ü','u'))";
	foreach ($arr as $item)
	{
	  if ($first)
	  {
	      $out.="((";
	  }
	  else
	  {
	      $out.=" AND (";
	  }
	  $out .= $Debut . $Var1 . $Fin . " LIKE '%" . addslashes(enleveaccents($item)) . "%'";
	  $out .= ")";
      $first = false;	  
	}
	$out .= ")";
	return $out;
    return $Debut . $Var1 . $Fin . " LIKE '" . addslashes(enleveaccents($Var2)) . "%'";
  }
  
  function Diff_Sans_Accents($Var1,$Var2)
  {
    $Debut="(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LCASE(";
    $Fin="),'ö','o'),'é','e'),'è','e'),'à','a'),'ä','a'),'á','a'),'â','a'),'ç','c'),'ê','e'),'ï','i'),'î','i'),'ô','o'),'û','u'),'ü','u'))";
    return $Debut . $Var1 . $Fin . " NOT LIKE '" . addslashes(enleveaccents($Var2)) . "%'";
  }
  
  function enleveaccents($chaine)
  {
    $chaine = strtr($chaine,  "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",  "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
    return $chaine;
  }

  function Create_Table_Formulaire($no_formulaire,$no_division,$no_visu,&$nb_champs)
  {
    if ($resultat = Formulaire::getFormulaireByNoFormulaireNoDivisionNoVisu($no_formulaire,$no_division,$no_visu))
    {
      $nb_champs=0;
      foreach($resultat as $ligne)
      {
        $nb_champs++;
        $tab_description[$nb_champs][0]=$ligne['NoChamp'];
        $tab_description[$nb_champs][1]=$ligne['ValeurDefault'];
      }
    }
    return $tab_description;
  }

  function Create_Table_Champs($no_table,&$nb_champs)
  {
    if ($resultat = Champ::getChampsByNoTable($no_table))
    {
      $nb_champs=0;
      $tab_description[255][0]="Vide";
      $tab_description[255][1]="";
      $tab_description[255][2]="";
      $tab_description[255][3]="";
      $tab_description[255][3]="255";
      $tab_description[0][0]="-";
      $tab_description[0][1]="";
      $tab_description[0][2]="";
      $tab_description[0][3]="";
      $tab_description[0][4]="0";
      foreach($resultat as $ligne)
      {
        $nb_champs++;
        $tab_description[$nb_champs][0]=$ligne['Description'];
        $tab_description[$nb_champs][1]=$ligne['NomChamp'];
        $tab_description[$nb_champs][2]=$ligne['TypeChamp'];
        $tab_description[$nb_champs][3]=$ligne['SousTypeChamp'];
        $tab_description[$nb_champs][4]=$ligne['NoChamp'];
      }
    }
    return $tab_description;
  }

  function Cree_Entree_Type($champ,$type,$sous_type,$default,$mode,$comp='')
  {
    global $lg_admin,$NoVisu;
    $type_interne=$type;
    if ($type_interne>=200 and $type_interne<300)
    {
      if (Is_Admin())
      {
        $type_interne=$type-200;
      }
	  else if ($type == 239 && As_Right_Fonction(1, 92)) // modifier stock admin si permission "Inventaire - Ajouter"
	  {
		$type_interne=39;  
	  }
      else
      {
        $type_interne=$type-100;
      }
    }
    if ($mode==AFFICHAGE and $type_interne<100)
    {
      $type_interne=$type_interne+100;
    }
    if ($mode==RECHERCHE)
    {
      $type_interne=($type_interne%100)+300;
    }
    if ($mode==RESULTAT)
    {
      $type_interne=($type_interne%100)+200;
    }
    switch($type_interne)
    {
      case 0: /* texte */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
          if($sous_type==20)
          {
        	$out.=" size=22 MAXLENGTH=$sous_type";
          }
          else
          {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
          }
        }
        $out .=" onChange='AsChange=1;'>";
      break;
      case 1: /* chiffre */
	    if ($sous_type == 1)
		{
          $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_nombre_obligatoire(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:";
		  if (strlen($default)==0)
		  {
		    $out .= "visible";
		  }
		  else
		  {
		    $out .= "hidden";
		  }
		  $out .= ";'>*</span>";
		  if (strlen($default)==0)
		  {
		    $out .= "<script>ajoute_err(\"err$champ\");</script>";
		  }
		}
		else
		{
          $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_nombre(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		}
      break;
      case 2: /* date */
	    if(true)
		{
          if($sous_type!=100)
          {
            if($default!="0000-00-00" && $default!=".." && $default!="")
            {
	          $out = "<input type='text' size='10' name='$champ' value='".substr($default,8,2).".".substr($default,5,2).".".substr($default,0,4)."'>";
		      $out .= "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		      $out .= "\n<script>\njQuery(document).ready(function($) { jQuery('input[name=\"".$champ."\"]').datepicker($.datepicker.regional[ \"fr-CH\" ]).change(function(){test_date_new(this.value, \"err$champ\");}); });\n</script>\n";
            }
            else
            {
	          $out = "<input type='text' size='10' name='$champ' value=''>";
		      $out .= "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		      $out .= "\n<script>\njQuery(document).ready(function($) { jQuery('input[name=\"".$champ."\"]').datepicker($.datepicker.regional[ \"fr-CH\" ]).change(function(){test_date_new(this.value, \"err$champ\");}); });\n</script>\n";
            }
          }
          else
          {
	        $out = "<input type='text' size='10' name='$champ' value='".substr($default,8,2).".".substr($default,5,2).".".substr($default,0,4)."'>";
		    $out .= "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		    $out .= "\n<script>\njQuery(document).ready(function($) { jQuery('input[name=\"".$champ."\"]').datepicker($.datepicker.regional[ \"fr-CH\" ]).change(function(){test_date_new(this.value, \"err$champ\");}); });\n</script>\n";
          }
		}
	    else
		{
          if($sous_type!=100)
          {
            if($default!="0000-00-00")
            {
              $out = "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,8,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,5,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,0,4) . '"' ." size=4 MAXLENGTH=4 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
            }
            else
            {
              $out = "<input type='texte' name='" . $champ . "[0]' value=" . '""' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<input type='texte' name='" . $champ . "[1]' value=" . '""' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<input type='texte' name='" . $champ . "[2]' value=" . '""' ." size=4 MAXLENGTH=4 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                     "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
            }
          }
          else
          {
            $out = "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,8,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");valider_delais_payement(this.form);'>".
                   "<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,5,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");valider_delais_payement(this.form);'>".
                   "<input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,0,4) . '"' ." size=4 MAXLENGTH=4 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");valider_delais_payement(this.form);'>".
                   "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
          }
		}
      break;
      case 3: /* type allocution */
      break;
      case 4: /* NPA */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='npa_to_localite(this.value);'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 5: /* Localite */
        $out = "<input ID='Localite' type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
        }
        $out .=" onChange='AsChange=1;'>";
      break;
      case 6: /* Pays */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
        }
        $out .=" onChange='AsChange=1;'>";
      break;
      case 7: /* Telephone */
  	    if (substr($default, 0, 2) == "00")
		{
		  if (substr($default, 2, 2) == "33")
		  {
		    $tel = substr($default, 0, 4) . " " . substr($default, 4, 3) . " " . substr($default, 7, 2) . " " . substr($default, 9, 2) . " " . substr($default, 11);
		  }
		  else if (substr($default, 2, 2) == "41")
		  {
		    $tel = "0" . substr($default, 4, 2) . " " . substr($default, 6, 3) . " " . substr($default, 9, 2) . " " . substr($default, 11);
		  }
		  else
		  {
		    $tel = substr($default, 0, 4) . " " . substr($default, 4, 2) . " " . substr($default, 6, 3) . " " . substr($default, 9, 2) . " " . substr($default, 11);
		  }
		}
		else if (substr($default, 0, 1) == "0")
		{
		  $tel = substr($default, 0, 3) . " " . substr($default, 3, 3) . " " . substr($default, 6, 2) . " " . substr($default, 8);
		}
		else
		{
          $tel = htmlspecialchars($default);
		}
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($tel) . '"' ." onChange='test_telephone(this.value, ".'"'."err$champ".'"'.");'";
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
        }
        $out .="><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		if (strlen($default) != 0)
		{
          if($ligne=Poste::getPostesByIP())
  	      {
  	        $interne=$ligne['NoInterne'];
            if ($interne != 0)
            {
                $out .= " <a href=\"javascript:appel_avec_formatage('$champ', $interne);\"><img src=\"images/phone.gif\"/></a>";
            }
	      }
		}
      break;
      case 8: /* Email */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_email(this.value, ".'"'."err$champ".'"'.");'";
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=\"$sous_type\" size=\"$sous_type\"";
        }
        $out .="><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 9: /* Langue */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
        }
        $out .=" onChange='AsChange=1;'>";
      break;
      case 10: /* Type client */
      break;
      case 11: /* Code rabais */
      break;
      case 12: /* Moyen de payement */
        $out = "";
        if ($resultat = ModePayement::getModePayment())
        {
          $out .= "   <select name='$champ' onChange='AsChange=1;'>\n";
          foreach($resultat as $ligne)
          {
            $out .= "    <option value='" . $ligne['NoMode'] . " " . $ligne['NoCaisse'] . "'";
            if (($ligne['NoMode']." ".$ligne['NoCaisse']) == $default)
            {
              $out .= " selected";
            }
            $out .= ">" . htmlspecialchars($ligne['Description']) . "</option>\n";
          }
          $out .= "   </select>\n";
        }
      break;
      case 13: /* Long texte */
        //$out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' .">";
        $out = "<textarea name='$champ' rows=\"5\" cols=\"50\" onfocus=\"memory_force_submit=force_submit;force_submit=false;\" onblur=\"force_submit=memory_force_submit;\">" . htmlspecialchars($default) . "</textarea>";
      break;
      case 14: /* Client */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='go_trouve_nom(".'"'.$champ.'"'.");'><BR>\n";
        if(empty($default))
        {
          $default=0;
        }

          if($ligne = Client::getClientByNoClient($default))
          {
          	$out .= "<input type='texte' name='" . $champ . "Nom' value=" . '"' . $ligne['Nom'] . '"' ." readonly><BR>\n";
          	$out .= "<input type='texte' name='" . $champ . "Prenom' value=" . '"' . $ligne['Prenom'] . '"' ." readonly><BR>\n";
          }
          else
          {
          	$out .= "<input type='texte' name='" . $champ . "Nom' value='' readonly><BR>\n";
          	$out .= "<input type='texte' name='" . $champ . "Prenom' value='' readonly><BR>\n";
          }
        $out .= "<A HREF='find.php?Type=13&Detail=0&Cible=" . $champ . "' target='recherche'>Recherche</A>";
      break;
      case 15: /* Type Rabais */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          $out .= "   <select name='$champ' onChange='AsChange=1;'>\n";
          foreach($resultat as $ligne)
          {
            $out .= "    <option value='" . $ligne['NoRabais'] . "'";
            if ($ligne['NoRabais'] == $default)
            {
              $out .= " selected";
            }
            $out .= ">" . htmlspecialchars($ligne['Description']) . "</option>\n";
          }
          $out .= "   </select>\n";
        }
      break;
      case 16: /* Type Rabais base articles */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais'] == $sous_type)
            {
              $out .= htmlspecialchars($ligne['Description']);
            }
          }
        }
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_decimal(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 17: /* No Matricule */
        $out = "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,3) . '"' ." size=3 MAXLENGTH=3 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,3);' onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'><input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,3,3) . '"' ." size=3 MAXLENGTH=3 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,3);' onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'><input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,6,3) . '"' ." size=3 MAXLENGTH=3 onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 18: /* Date et heure */
	    if (true)
		{
          if(As_Right_Groupe(6))
		  {
	        $out = "<input type='text' size='10' name='" . $champ . "[0]' value='".substr($default,8,2).".".substr($default,5,2).".".substr($default,0,4)."'>";
		    $out .= "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
		    $out .= "\n<script>\njQuery(document).ready(function($) { jQuery('input[name=\"".$champ."[0]\"]').datepicker($.datepicker.regional[ \"fr-CH\" ]).change(function(){test_date_new(this.value, \"err$champ\");}); });\n</script>\n";
          }
		  else
		  {
	        $out = "<input type='hidden' size='10' name='" . $champ . "[0]' value='".substr($default,8,2).".".substr($default,5,2).".".substr($default,0,4)."'>";
		  }
		  $out .= "<input type='hidden' name='" . $champ . "[1]' value=" . '"' . substr($default,11,2) . '"' ." size=2 MAXLENGTH=2>";
          $out .= "<input type='hidden' name='" . $champ . "[2]' value=" . '"' . substr($default,14,2) . '"' ." size=2 MAXLENGTH=2>";
		}
		else
		{
        $out = "<input type='";
        if(As_Right_Groupe(6))
          $out .= "texte";
        else
          $out .= "hidden";
        $out .= "' name='" . $champ . "[0]' value=" . '"' . substr($default,8,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>";
        if(As_Right_Groupe(6))
          $out .= ".";
        $out .= "<input type='";
        if(As_Right_Groupe(6))
          $out .= "texte";
        else
          $out .= "hidden";
        $out .= "' name='" . $champ . "[1]' value=" . '"' . substr($default,5,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>";
        if(As_Right_Groupe(6))
          $out .= ".";
        $out .= "<input type='";
        if(As_Right_Groupe(6))
          $out .= "texte";
        else
          $out .= "hidden";
        $out .= "' name='" . $champ . "[2]' value=" . '"' . substr($default,0,4) . '"' ." size=4 MAXLENGTH=4 onKeyUp='auto_tab(".'"'.$champ.'"'.",2,4);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");'>".
                "<input type='hidden' name='" . $champ . "[3]' value=" . '"' . substr($default,11,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",3,2);' onChange='test_heure(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value, ".'"'."err$champ".'"'.");'>".
                "<input type='hidden' name='" . $champ . "[4]' value=" . '"' . substr($default,14,2) . '"' ." size=2 MAXLENGTH=2 onChange='test_heure(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value, ".'"'."err$champ".'"'.");'>".
                "<span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
	    }
      break;
      case 19: /* Decimal */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_decimal(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 20: /* Texte avec recherche sans espace */
        
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
        }
        $out .= " onChange='test_obligatoire(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:";
		if (strlen($default)==0)
		{
		  $out .= "visible";
		}
		else
		{
		  $out .= "hidden";
		}
		$out .= ";'>*</span>";
		if (strlen($default)==0)
		{
		  $out .= "<script>ajoute_err(\"err$champ\");</script>";
		}
      break;
      case 21: /* Type facture */
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
          $out .= " selected";
        $out .= "></option>\n";
        $out .= "   <option value='FD'";
        if($default=="FD")
          $out .= " selected";
        $out .= ">Facture détaillée</option>\n";
        $out .= "   <option value='BP'";
        if($default=="BP")
          $out .= " selected";
        $out .= ">Bulletin de livraison</option>\n";
        $out .= "   <option value='FB'";
        if($default=="FB")
          $out .= " selected";
        $out .= ">Facture bulletin de livraison</option>\n";
        $out .= "   <option value='FV'";
        if($default=="FV")
          $out .= " selected";
        $out .= ">Facture véhicule neuf</option>\n";
        $out .= "   <option value='FO'";
        if($default=="FO")
          $out .= " selected";
        $out .= ">Facture véhicule occasion</option>\n";
        $out .= "   <option value='FL'";
        if($default=="FL")
          $out .= " selected";
        $out .= ">Facture location</option>\n";
        $out .= "   <option value='FI'";
        if($default=="FI")
          $out .= " selected";
        $out .= ">Facture interne</option>\n";
        $out .= "   <option value='CP'";
        if($default=="CP")
          $out .= " selected";
        $out .= ">Commande pièces</option>\n";
        $out .= "   <option value='RC'";
        if($default=="RC")
          $out .= " selected";
        $out .= ">Retour commande pièces</option>\n";
        $out .= "   <option value='OP'";
        if($default=="OP")
          $out .= " selected";
        $out .= ">Offre pièces</option>\n";
        $out .= "   <option value='OV'";
        if($default=="OV")
          $out .= " selected";
        $out .= ">Offre véhicule</option>\n";
        $out .= "   <option value='DP'";
        if($default=="DP")
          $out .= " selected";
        $out .= ">Devis</option>\n";
        $out .= "   <option value='GF'";
        if($default=="GF")
          $out .= " selected";
        $out .= ">Garantie fourniseur</option>\n";
        $out .= "   <option value='GG'";
        if($default=="GG")
          $out .= " selected";
        $out .= ">Garantie garage</option>\n";
        $out .= "   <option value='RV'";
        if($default=="RV")
          $out .= " selected";
        $out .= ">Reprise véhicule</option>\n";
        $out .= "   <option value='ND'";
        if($default=="ND")
          $out .= " selected";
        $out .= ">Note de crédit facture détaillée</option>\n";
        $out .= "   <option value='NB'";
        if($default=="NB")
          $out .= " selected";
        $out .= ">Note de crédit facture bulletin liv</option>\n";
        $out .= "   <option value='NV'";
        if($default=="NV")
          $out .= " selected";
        $out .= ">Note de crédit véhicule neuf</option>\n";
        $out .= "   <option value='NO'";
        if($default=="NO")
          $out .= " selected";
        $out .= ">Note de crédit véhicule occasion</option>\n";
        $out .= "   <option value='NL'";
        if($default=="NL")
          $out .= " selected";
        $out .= ">Note de crédit location</option>\n";
        $out .= "   <option value='AM'";
        if($default=="AM")
          $out .= " selected";
        $out .= ">Achat marchandise</option>\n";
        $out .= "   <option value='VV'";
        if($default=="VV")
          $out .= " selected";
        $out .= ">Achat véhicule neuf</option>\n";
        $out .= "   <option value='MO'";
        if($default=="MO")
          $out .= " selected";
        $out .= ">Modèle</option>\n";
        $out .= "</select>";
      break;
      case 22: /* Genre facture */
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
          $out .= " selected";
        $out .= "></option>\n";
        $out .= "   <option value='F'";
        if($default=="F")
          $out .= " selected";
        $out .= ">Facture</option>\n";
        $out .= "   <option value='B'";
        if($default=="B")
          $out .= " selected";
        $out .= ">Bulletin de livraison</option>\n";
        $out .= "   <option value='C'";
        if($default=="C")
          $out .= " selected";
        $out .= ">Commande</option>\n";
        $out .= "   <option value='O'";
        if($default=="O")
          $out .= " selected";
        $out .= ">Offre</option>\n";
        $out .= "   <option value='D'";
        if($default=="D")
          $out .= " selected";
        $out .= ">Devis</option>\n";
        $out .= "   <option value='G'";
        if($default=="G")
          $out .= " selected";
        $out .= ">Garantie</option>\n";
        $out .= "   <option value='R'";
        if($default=="R")
          $out .= " selected";
        $out .= ">Reprise</option>\n";
        $out .= "   <option value='N'";
        if($default=="N")
          $out .= " selected";
        $out .= ">Note de crédit</option>\n";
        $out .= "   <option value='A'";
        if($default=="A")
          $out .= " selected";
        $out .= ">Achat</option>\n";
        $out .= "   <option value='V'";
        if($default=="V")
    		  $out .= " selected";
    		$out .= ">Achat véhicule</option>\n";
    		$out .= "</select>";
      break;
      case 23: /* Type vehicule */
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='M'";
        if($default=="M")
    		  $out .= " selected";
    		$out .= ">Moto</option>\n";
        $out .= "   <option value='S'";
        if($default=="S")
    		  $out .= " selected";
    		$out .= ">Scooter</option>\n";
    		$out .= "</select>";
      break;
      case 24: /* Status vehicule */
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='N'";
        if($default=="N")
    		  $out .= " selected";
    		$out .= ">Neuf</option>\n";
        $out .= "   <option value='O'";
        if($default=="O")
    		  $out .= " selected";
    		$out .= ">Occasion</option>\n";
        $out .= "   <option value='C'";
        if($default=="C")
    		  $out .= " selected";
    		$out .= ">Client</option>\n";
        $out .= "   <option value='L'";
        if($default=="L")
    		  $out .= " selected";
    		$out .= ">Location</option>\n";
        $out .= "   <option value='P'";
        if($default=="P")
    		  $out .= " selected";
    		$out .= ">Prêt</option>\n";
        $out .= "   <option value='DO'";
        if($default=="DO")
    		  $out .= " selected";
    		$out .= ">Dépot vente occasion</option>\n";
        $out .= "   <option value='DN'";
        if($default=="DN")
    		  $out .= " selected";
    		$out .= ">Dépot vente neuf</option>\n";
        $out .= "   <option value='S'";
        if($default=="S")
    		  $out .= " selected";
    		$out .= ">Supprimé</option>\n";
    		$out .= "</select>";
      break;
      case 25: /* NoChasis */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
    		}
    		$out .=" onChange='AsChange=1;'>";
      break;
      case 26: /* Vendu */
      break;
      case 27: /* Description */
        if($ligne= Article::getArticleByNoArticleRR(addslashes($default)))
        {
          $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
          if($sous_type!=0)
          {
          	$out.=" size=$sous_type MAXLENGTH=$sous_type";
      		}
      		$out .=" onChange='AsChange=1;'>";
          $out .= "<A HREF='".$path_parts["basename"]."?Type=1&Sous_Type=2&Etape=2&NoVisu=$NoVisu&NoArticle=".$ligne['NoArticle']."'>suivre</A>";
    		}
        else
        {
          $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
          if($sous_type!=0)
          {
          	$out.=" size=$sous_type MAXLENGTH=$sous_type";
      		}
      		$out .=" onChange='AsChange=1;'>";
        }
      break;
      case 28: /* Vehicule */
      break;
      case 29: /* No plaques */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
    		}
    		$out .=" onChange='test_no_plaque(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 30: /* Status atelier */
      break;
      case 31: /* Vendeur */
  	    $resultat=Employee::getVendeur();
  	    $out = "<SELECT name='$champ'>\n";
  	    $out .= "<option value=''";
  	    if($default==0)
  	    {
  	      $out .= " selected";
    		}
    		$out .= ">-</option>\n";
  	    foreach($resultat as $ligne)
  	    {
  	      $out .= "<option value='".$ligne[0]."'";
  	      if($ligne[0]==$default)
  	       	$out .= " selected";
    		  $out .= ">".$ligne[2]." ".$ligne[1]."</option>\n";
    		}
    		$out .= "</SELECT>";
      break;
      case 32: /* NoCommande */
    		$path_parts = pathinfo($_SERVER['PHP_SELF']);
    		$ligne=Commande::getCommandeByNoCommande($default);
    		$out= "<A HREF='".$path_parts["basename"]."?Type=4&Sous_Type=1&Etape=3&NoCommande=$default&NoClient=".$ligne['NoClient']."&NoClient2=".$ligne['NoClient2']."'>$default</A>";
      break;
      case 33: /* Commande ouverte, envoyée, reçue */
      break;
      case 34: /* texte majuscules */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
    		}
    		$out .=" onChange='AsChange=1;'>";
      break;
      case 35: /* Texte Sans Espaces */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
    		}
    		$out .=" onChange='AsChange=1;'>";
  	  break;
      case 36: /* Categories Articles */
        $out = "";
        if ($resultat = Category::getTopCategories())
        {
          $out .= "   <select name='$champ' onChange='AsChange=1;'>\n";
          foreach($resultat as $ligne)
          {
            $out .= "    <option value='" . $ligne['ID'] . "'";
            if (($ligne['ID']) == $default)
            {
      			  $out .= " selected";
      			}
      			$out .= ">" . htmlspecialchars($ligne['Description']) . "</option>\n";
      			$out .= Affiche_input_sub_cat($ligne['ID'], 1, $default);
          }
          $out .= "   </select>\n";
        }
      break;
      case 37: /* Vendu  export excel*/
      break;
      case 38: /* No chassis cle primaire */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
	$spelength = $sous_type + 5;
        if($sous_type!=0)
        {
        	$out.=" size=$spelength MAXLENGTH=$sous_type";
    		}
    		$out .=" onChange='AsChange=1;'>";
  	  break;
	  case 39: /* NbStock ou NbTransfert Dans un autre table par garage */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_decimal(this.value, ".'"'."err$champ".'"'.");'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
  	  break;
	  case 40: /* LieuxStoquage Dans un autre table par garage */
        $out = "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" size=$sous_type MAXLENGTH=$sous_type";
        }
        $out .=" onChange='AsChange=1;'>";
  	  break;
      case 41: /* Allocution */
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
          $out .= " selected";
    	$out .= "></option>\n";
        $out .= "   <option value='Monsieur'";
        if(strtolower($default)=="monsieur")
    	  $out .= " selected";
    	$out .= ">Monsieur</option>\n";
        $out .= "   <option value='Madame'";
        if(strtolower($default)=="madame")
          $out .= " selected";
    	$out .= ">Madame</option>\n";
        $out .= "   <option value='Société'";
        if(strtolower($default)=="société")
          $out .= " selected";
    	$out .= ">Société</option>\n";
        $out .= "   <option value='Entreprise'";
        if(strtolower($default)=="entreprise")
          $out .= " selected";
    	$out .= ">Entreprise</option>\n";
        $out .= "   <option value='Garage'";
        if(strtolower($default)=="garage")
          $out .= " selected";
    	$out .= ">Garage</option>\n";
    	$out .= "</select>";
      break;
      case 42: /* Boolean */
        $out = "<input type='checkbox' name='$champ' value='1'";
        if($default == "1")
        {
		  $out .= " checked=\"checked\"";
        }
        $out .=" onChange='AsChange=1;'>";
	  break;
      case 43: /* Types client */
	    $types_client = get_config("TYPES_CLIENT");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
          $out .= " selected";
    	$out .= "></option>\n";
		$arr_types_client = explode(";", $types_client);
		foreach ($arr_types_client as $type_client)
		{
          $out .= "   <option value='$type_client'";
          if(strtolower($default)==strtolower($type_client))
    	    $out .= " selected";
    	  $out .= ">$type_client</option>\n";
		}
    	$out .= "</select>";
	  break;
      case 44: /* Impression entete */
	    $out = "<button type=\"button\" onclick=\"imprimer_entete_client('".$_GET["NoClient"]."')\">Imprimer</button>";
	  break;
      case 45: /* Type garantie */
		$value_found = false;
	    $types_garantie = get_config("TYPES_GARANTIE");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
		{	
          $out .= " selected";
		  $value_found = true;
		}
    	$out .= "></option>\n";
		$arr_types_garantie = explode(";", $types_garantie);
		foreach ($arr_types_garantie as $type_garantie)
		{
          $out .= "   <option value=\"$type_garantie\"";
          if(strtolower($default)==strtolower($type_garantie))
		  {
    	    $out .= " selected";
			$value_found = true;
		  }
    	  $out .= ">$type_garantie</option>\n";
		}
		if (!$value_found)
		{
          $out .= "   <option value=\"$default\"";
    	  $out .= " selected";
    	  $out .= ">? $default</option>\n";
		}
    	$out .= "</select>";
  	  break;
      case 46: /* Type vehicule */
		$value_found = false;
	    $types_vehicule = get_config("TYPES_VEHICULE");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
		{	
          $out .= " selected";
		  $value_found = true;
		}
    	$out .= "></option>\n";
		$arr_types_vehicule = explode(";", $types_vehicule);
		foreach ($arr_types_vehicule as $type_vehicule)
		{
          $out .= "   <option value=\"$type_vehicule\"";
          if(strtolower($default)==strtolower($type_vehicule))
		  {
    	    $out .= " selected";
			$value_found = true;
		  }
    	  $out .= ">$type_vehicule</option>\n";
		}
		if (!$value_found)
		{
          $out .= "   <option value=\"$default\"";
    	  $out .= " selected";
    	  $out .= ">? $default</option>\n";
		}
    	$out .= "</select>";
  	  break;
      case 100: /* texte */
        $out = htmlspecialchars($default);
      break;
      case 101: /* chiffre */
        $out = htmlspecialchars($default);
      break;
      case 102: /* date */
        if($default!="0000-00-00" && $default!=".." && $default!="")
        {
          $out = substr($default,8,2) . "." . substr($default,5,2) . "." . substr($default,0,4);
        }
        else
        {
          $out = "";
        }
      break;
      case 103: /* type allocution */
      break;
      case 104: /* NPA */
        $out = htmlspecialchars($default);
      break;
      case 105: /* Localite */
        $out = htmlspecialchars($default);
      break;
      case 106: /* Pays */
        $out = htmlspecialchars($default);
      break;
      case 107: /* Telephone */
	    $out = Format_Telephone($default);
      if (strlen($default) != 0)
      {
            if($ligne=$ligne=Poste::getPostesByIP())
  	        {
  	          $interne=$ligne['NoInterne'];
              if ($interne != 0)
              {
                  $out .= " <a href=\"javascript:appel('$default', $interne);\"><img src=\"images/phone.gif\"/></a>";
              }
	        }
		  //$out .= $champ;
            if($ligne2=Config::getSMSClient())
  	        {
  	          $valeur=$ligne2['valeur'];
              if (strlen($valeur) != 0)
              {
              $out .= " <select id='sel".$champ."'>".$valeur."</select>";
                  $out .= " <a href=\"javascript:send_sms_client('".$default."', '#sel".$champ."');\">SMS</a>";
              }
	        }
		}
      break;
      case 108: /* Email */
        $out = htmlspecialchars($default);
      break;
      case 109: /* Langue */
        $out = htmlspecialchars($default);
      break;
      case 110: /* Type client */
      break;
      case 111: /* Code rabais */
      break;
      case 112: /* Moyen de payement */
        $out = "";
        if ($resultat = ModePayement::getModePayment())
        {
          foreach($resultat as $ligne)
          {
            if (($ligne['NoMode']." ".$ligne['NoCaisse'])==$default)
            {
      			  $out = htmlspecialchars($ligne['Description']);
      			}
          }
        }
      break;
      case 113: /* Long texte */
        $out = str_replace("\n","<br/>\n",htmlspecialchars($default));
      break;
      case 114: /* Client */
        $out="";
        if($default!=0)
        {
          $path_parts = pathinfo($_SERVER['PHP_SELF']);
          $out = "<A HREF='".$path_parts["basename"]."?Type=3&Sous_Type=1&Etape=2&NoVisu=0&NoClient=$default'>";
    		}
        $out .= htmlspecialchars($default);
        if($ligne = Client::getClientByNoClient($default)) {
          	$out .= " " . $ligne['Nom'] . " " . $ligne['Prenom'];
          }
        if($default!=0)
        {
          $out .= "</A>";
        }
      break;
      case 115: /* Type Rabais */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais']==$default)
            {
      			  $out = htmlspecialchars($ligne['Description']);
      			}
          }
        }
      break;
      case 116: /* Type Rabais base articles */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais'] == $sous_type)
            {
      			  $out .= htmlspecialchars($ligne['Description']);
      			}
          }
        }
        $out .= " " . htmlspecialchars($default);
      break;
      case 117: /* No Matricule */
        $out = substr($default,0,3) . "." . substr($default,3,3) . "." . substr($default,6,3);
      break;
      case 118: /* Date et heure */
    		$out = substr($default,8,2) . "." . substr($default,5,2) . "." . substr($default,0,4) . " à " . substr($default,11,2) . "h" . substr($default,14,2);
      break;
      case 119: /* Decimal */
        $out = htmlspecialchars($default);
      break;
      case 120: /* Texte avec recherche sans espace */
        $out = htmlspecialchars($default);
      break;
      case 121: /* Type facture */
        switch ($default)
        {
          case "FD":
            $out = "Facture détaillée";
          break;
          case "BP":
            $out = "Bulletin de livraison";
          break;
          case "FB":
            $out = "Facture bulletin de livraison";
          break;
          case "FV":
            $out = "Facture véhicule neuf";
          break;
          case "FO":
            $out = "Facture véhicule occasion";
          break;
          case "FL":
            $out = "Facture location";
          break;
          case "FI":
            $out = "Facture interne";
          break;
          case "CP":
            $out = "Commande pièces";
          break;
          case "RC":
            $out = "Retour commande pièces";
          break;
          case "OP":
            $out = "Offre pièces";
          break;
          case "OV":
            $out = "Offre véhicule";
          break;
          case "DP":
            $out = "Devis";
          break;
          case "GF":
            $out = "Garantie fourniseur";
          break;
          case "GG":
            $out = "Garantie garage";
          break;
          case "RV":
            $out = "Reprise véhicule";
          break;
          case "ND":
            $out = "Note de crédit facture détaillée";
          break;
          case "NB":
            $out = "Note de crédit facture bulletin liv";
          break;
          case "NV":
            $out = "Note de crédit véhicule neuf";
          break;
          case "NO":
            $out = "Note de crédit véhicule occasion";
          break;
          case "NL":
            $out = "Note de crédit location";
          break;
          case "AM":
            $out = "Achat marchandise";
          break;
          case "VV":
            $out = "Achat véhicule neuf";
          break;
        }
      break;
      case 122: /* Genre facture */
        switch ($default)
        {
          case "F":
            $out = "Facture";
          break;
          case "B":
            $out = "Bulletin de livraison";
          break;
          case "C":
            $out = "Commande";
          break;
          case "O":
            $out = "Offre";
          break;
          case "D":
            $out = "Devis";
          break;
          case "G":
            $out = "Garantie";
          break;
          case "R":
            $out = "Reprise";
          break;
          case "N":
            $out = "Note de crédit";
          break;
          case "A":
            $out = "Achat";
          break;
          case "V":
            $out = "Achat véhicule";
          break;
        }
      break;
      case 123: /* Type vehicule */
        switch ($default)
        {
          case "M":
            $out = "Moto";
          break;
          case "S":
            $out = "Scooter";
          break;
          default:
            $out = "";
          break;
        }
      break;
      case 124: /* Status vehicule */
        switch ($default)
        {
          case "N":
            $out = "Neuf";
          break;
          case "O":
            $out = "Occasion";
          break;
          case "C":
            $out = "Client";
          break;
          case "L":
            $out = "Location";
          break;
          case "P":
            $out = "Prêt";
          break;
          case "DO":
            $out = "Dépot vente occasion";
          break;
          case "DN":
            $out = "Dépot vente neuf";
          break;
          case "Supprimé":
            $out = "Dépot vente neuf";
          break;
          default:
            $out = "";
          break;
        }
      break;
      case 125: /* NoChasis */
        $out = htmlspecialchars($default);
      break;
      case 126: /* Vendu */
        $out="";
        $out .= "<table border='1'>\n";
        $out .= "<tr><th>Annee</th><th>Quantite</th><th>Prix</th></tr>\n";
        for($cpt_annee=date("Y");$cpt_annee>(date("Y")-4);$cpt_annee--)
        {
          $requette = "SELECT SUM(commandearticles".ID_GARAGE.".Quantite) AS Quantite, SUM(commandearticles".ID_GARAGE.".PrixMulti) AS Prix FROM commandearticles".ID_GARAGE.", commande".ID_GARAGE." WHERE commandearticles".ID_GARAGE.".NoArticle = :noarticle AND commandearticles".ID_GARAGE.".NoCommande = commande".ID_GARAGE.".NoCommande AND commande".ID_GARAGE.".DateCommande LIKE '$cpt_annee%' AND (commande".ID_GARAGE.".Genre = 'F' OR commande".ID_GARAGE.".Genre = 'G')";
          $statement = Connection::getStatement($requette);
          $statement->bindParam(":noarticle", $default);
          $statement->execute();
          if ($ligne = $statement->fetch())
          {
            $requette2 = "SELECT SUM(commandearticles".ID_GARAGE.".Quantite) AS Quantite, SUM(commandearticles".ID_GARAGE.".PrixMulti) AS Prix FROM commandearticles".ID_GARAGE.", commande".ID_GARAGE." WHERE commandearticles".ID_GARAGE.".NoArticle = :noarticle AND commandearticles".ID_GARAGE.".NoCommande = commande".ID_GARAGE.".NoCommande AND commande".ID_GARAGE.".DateCommande LIKE '$cpt_annee%' AND commande".ID_GARAGE.".Genre = 'N'";
            $statement2 = Connection::getStatement($requette2);
            $statement2->bindParam(":noarticle", $default);
            $statement2->execute();
            if ($ligne2 = $statement2->fetch())
            {
              $Prix = 0;
              $Quantite = 0;
              $Prix = $Prix + $ligne["Prix"];
              $Prix = $Prix - $ligne2["Prix"];
              $Quantite = $Quantite + $ligne["Quantite"];
              $Quantite = $Quantite - $ligne2["Quantite"];
              $out .= "<tr><td>$cpt_annee</td><td>$Quantite</td><td>".number_format($Prix,2,".","'")."</td></tr>\n";
            }
          }
        }
        $out .= "</table>\n";
      break;
      case 127: /* Description */
        if($ligne=Article::getArticleByNoArticleRR(addslashes($default)))
        {
    		  $path_parts = pathinfo($_SERVER['PHP_SELF']);
          $out = "<A HREF='".$path_parts["basename"]."?Type=1&Sous_Type=1&Etape=2&NoVisu=$NoVisu&NoArticle=".$ligne[0]['NoArticle']."'>".htmlspecialchars($default)."</A>";
    		}
    		else
    		{
          $out = htmlspecialchars($default);
        }
      break;
      case 128: /* Vehicule */
        $out="";
        if($resultat=Vehicule::getVehiculeByClient($default))
    		{
          $vide=true;
    		  foreach ($resultat as $ligne)
    		  {
    		    if($vide)
    		    {
    		  	  $vide=false;
    		    }
    		    else
    		    {
    		  	  $out.= "<BR>";
    		    }
    		    $path_parts = pathinfo($_SERVER['PHP_SELF']);
    		    $out.= "<A HREF='".$path_parts["basename"]."?Type=2&Sous_Type=1&Etape=2&NoVisu=0&NoChasis=".$ligne['NoChasis']."'>".$ligne['NoChasis']." ".$ligne['Model']." ".$ligne['NoPlaque']."</A>";
    		  }
    		}
      break;
      case 129: /* No plaques */
        $out = htmlspecialchars($default);
      break;
      case 130: /* Status atelier */
      break;
      case 131: /* Vendeur */
  	    if($ligne=Client::getClientByNoClient($default))
  	    {
  		  $out = htmlspecialchars($ligne["Prenom"])." ".htmlspecialchars($ligne["Nom"]);
    		}
    		else
    		{
    		  $out = "inconnu";
    		}
      break;
      case 132: /* NoCommande */
    		$path_parts = pathinfo($_SERVER['PHP_SELF']);
    		$ligne=Commande::getCommandeByNoCommande($default);
    		$out= "<A HREF='".$path_parts["basename"]."?Type=4&Sous_Type=1&Etape=3&NoCommande=$default&NoClient=".$ligne['NoClient']."&NoClient2=".$ligne['NoClient2']."'>$default</A>";
      break;
      case 133: /* Commande ouverte, envoyée, reçue */
      break;
      case 134: /* texte majuscules */
        $out = htmlspecialchars($default);
      break;
      case 135: /* Texte Sans Espaces */
        $out = htmlspecialchars($default);
  	  break;
      case 136: /* Categories Articles */
        $out = "";
        if ($ligne = Category::getCategoryByID($default))
        {
          if($ligne['ParentID']!=0)
          {
            $out = Parent_cat($ligne['ParentID'])."-";
          }
			  $out .= htmlspecialchars($ligne['Nom']);
        }
      break;
      case 137: /* Vendu  export excel*/
        $out="";
        $out .= "<table border='1'><tr>\n";
        //$out .= "<tr><th>Annee</th><th>Quantite</th><th>Prix</th></tr>\n";
        for($cpt_annee=date("Y");$cpt_annee>(date("Y")-4);$cpt_annee--)
        {
          if ($ligne = CommandeArticle::getSumByNoArticleGenreFOrG($default, $cpt_annee))
          {
            if ($ligne2 = CommandeArticle::getSumByNoArticleGenreN($default, $cpt_annee))
            {
              $Prix = 0;
              $Quantite = 0;
              $Prix = $Prix + $ligne["Prix"];
              $Prix = $Prix - $ligne2["Prix"];
              $Quantite = $Quantite + $ligne["Quantite"];
              $Quantite = $Quantite - $ligne2["Quantite"];
              $out .= "<td>$cpt_annee</td><td>$Quantite</td><td>".number_format($Prix,2,".","'")."</td>\n";
            }
          }
        }
        $out .= "</tr></table>\n";
      break;
      case 138: /* No chassis cle primaire */
        $out = htmlspecialchars($default);
  	  break;
	  case 139: /* NbStock ou NbTransfert Dans un autre table par garage */
        $out = htmlspecialchars($default);
  	  break;
	  case 140: /* LieuxStoquage Dans un autre table par garage */
        $out = htmlspecialchars($default);
  	  break;
      case 141: /* Allocution */
        $out = htmlspecialchars($default);
      break;
      case 142: /* Boolean */
        if($default == "1")
        {
		  $out = "oui";
        }
		else
		{
		  $out = "non";
		}
	  break;
      case 143: /* Types client */
        $out = htmlspecialchars($default);
	  break;
      case 144: /* Impression entete */
	    $out = "<button type=\"button\" onclick=\"imprimer_entete_client('".$_GET["NoClient"]."')\">Imprimer</button>";
	  break;
      case 145: /* Type garantie */
        $out = htmlspecialchars($default);
	  break;
      case 146: /* Type vehicule */
        $out = htmlspecialchars($default);
	  break;
      case 200: /* texte */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 201: /* chiffre */
        $taille=strlen($default);
        if($sous_type==0)
        {
          $max=6;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out=" ".$out;
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 202: /* date */
        if($default!="0000-00-00")
        {
          $out = substr($default,8,2) . "." . substr($default,5,2) . "." . substr($default,0,4);
        }
        else
        {
          $out = "";
        }
      break;
      case 203: /* type allocution */
      break;
      case 204: /* NPA */
        $out = htmlspecialchars($default);
      break;
      case 205: /* Localite */
        $out = htmlspecialchars($default);
      break;
      case 206: /* Pays */
        $out = htmlspecialchars($default);
      break;
      case 207: /* Telephone */
	    $tel=str_replace("/", "", $default);
		$tel=str_replace(".", "", $tel);
		$tel=str_replace(" ", "", $tel);
	    if (substr($tel, 0, 2) == "00")
		{
		  if (substr($tel, 2, 2) == "33")
		  {
		    $out = "+" . substr($tel, 2, 2) . " " . substr($tel, 4, 3) . " " . substr($tel, 7, 2) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		  else if (substr($tel, 2, 2) == "41")
		  {
		    $out = "0" . substr($tel, 4, 2) . " " . substr($tel, 6, 3) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		  else
		  {
		    $out = "+" . substr($tel, 2, 2) . " " . substr($tel, 4, 2) . " " . substr($tel, 6, 3) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		}
		else if (substr($tel, 0, 1) == "0")
		{
		  $out = substr($tel, 0, 3) . " " . substr($tel, 3, 3) . " " . substr($tel, 6, 2) . " " . substr($tel, 8);
		}
		else
		{
          $out = htmlspecialchars($tel);
		}
      break;
      case 208: /* Email */
        $out = htmlspecialchars($default);
      break;
      case 209: /* Langue */
        $out = htmlspecialchars($default);
      break;
      case 210: /* Type client */
      break;
      case 211: /* Code rabais */
      break;
      case 212: /* Moyen de payement */
        $out = "";
        if ($resultat = ModePayement::getModePayment())
        {
          foreach($resultat as $ligne)
          {
            if (($ligne['NoMode']." ".$ligne['NoCaisse'])==$default)
            {
      			  $out = htmlspecialchars($ligne['Description']);
      			}
          }
        }
      break;
      case 213: /* Long texte */
        $out = htmlspecialchars($default);
      break;
      case 214: /* Client */
        $out = $default . "";
          if($ligne = Client::getClientByNoClient($default))
          {
          	$out = $out . " " . htmlspecialchars($ligne['Nom']) . " " . htmlspecialchars($ligne['Prenom']);
          }
        $max=25;
        $taille=strlen($out);
    		if($taille>$max)
    		{
    		  $out=mb_substr($out,0,$max,'UTF-8');
    		}
    		else
    		{
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 215: /* Type Rabais */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais']==$default)
            {
      			  $out = htmlspecialchars($ligne['Description']);
      			}
          }
        }
      break;
      case 216: /* Type Rabais base articles */
        $out = "";
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais'] == $sous_type)
            {
      			  $out .= htmlspecialchars($ligne['Description']);
      			}
          }
        }
        $out .= " " . htmlspecialchars($default);
      break;
      case 217: /* No Matricule */
        $out = substr($default,0,3) . "." . substr($default,3,3) . "." . substr($default,6,3);
      break;
      case 218: /* Date et heure */
		$out = substr($default,8,2) . "." . substr($default,5,2) . "." . substr($default,0,4) . " à " . substr($default,11,2) . "h" . substr($default,14,2);
      break;
      case 219: /* Decimal */
        $taille=strlen($default);
        if($sous_type==0)
        {
          $max=9;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out=" ".$out;
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 220: /* Texte avec recherche sans espace */
        $out = htmlspecialchars($default);
      break;
      case 221: /* Type facture */
        switch ($default)
        {
          case "FD":
            $out = "Facture détaillée";
          break;
          case "BP":
            $out = "Bulletin de livraison";
          break;
          case "FB":
            $out = "Facture bulletin de livraison";
          break;
          case "FV":
            $out = "Facture véhicule neuf";
          break;
          case "FO":
            $out = "Facture véhicule occasion";
          break;
          case "FL":
            $out = "Facture location";
          break;
          case "FI":
            $out = "Facture interne";
          break;
          case "CP":
            $out = "Commande pièces";
          break;
          case "RC":
            $out = "Retour commande pièces";
          break;
          case "OP":
            $out = "Offre pièces";
          break;
          case "OV":
            $out = "Offre véhicule";
          break;
          case "DP":
            $out = "Devis";
          break;
          case "GF":
            $out = "Garantie fourniseur";
          break;
          case "GG":
            $out = "Garantie garage";
          break;
          case "RV":
            $out = "Reprise véhicule";
          break;
          case "ND":
            $out = "Note de crédit facture détaillée";
          break;
          case "NB":
            $out = "Note de crédit facture bulletin liv";
          break;
          case "NV":
            $out = "Note de crédit véhicule neuf";
          break;
          case "NO":
            $out = "Note de crédit véhicule occasion";
          break;
          case "NL":
            $out = "Note de crédit location";
          break;
          case "AM":
            $out = "Achat marchandise";
          break;
          case "VV":
            $out = "Achat véhicule neuf";
          break;
        }
      break;
      case 222: /* Genre facture */
        switch ($default)
        {
          case "F":
            $out = "Facture";
          break;
          case "B":
            $out = "Bulletin de livraison";
          break;
          case "C":
            $out = "Commande";
          break;
          case "O":
            $out = "Offre";
          break;
          case "D":
            $out = "Devis";
          break;
          case "G":
            $out = "Garantie";
          break;
          case "R":
            $out = "Reprise";
          break;
          case "N":
            $out = "Note de crédit";
          break;
          case "A":
            $out = "Achat";
          break;
          case "V":
            $out = "Achat véhicule";
          break;
        }
      break;
      case 223: /* Type vehicule */
        switch ($default)
        {
          case "M":
            $out = "Moto";
          break;
          case "S":
            $out = "Scooter";
          break;
          default:
            $out = "";
          break;
        }
      break;
      case 224: /* Status vehicule */
        switch ($default)
        {
          case "N":
            $out = "Neuf";
          break;
          case "O":
            $out = "Occasion";
          break;
          case "C":
            $out = "Client";
          break;
          case "L":
            $out = "Location";
          break;
          case "P":
            $out = "Prêt";
          break;
          case "DO":
            $out = "Dépot vente occasion";
          break;
          case "DN":
            $out = "Dépot vente neuf";
          break;
          case "Supprimé":
            $out = "Dépot vente neuf";
          break;
    		  default:
    		    $out = "";
    		  break;
        }
      break;
      case 225: /* NoChasis */
        $out = htmlspecialchars($default);
      break;
      case 226: /* Vendu */
        $out="";
        $out .= "<table border='1'>\n";
        $out .= "<tr><th>Annee</th><th>Quantite</th><th>Prix</th></tr>\n";
        for($cpt_annee=date("Y");$cpt_annee>(date("Y")-4);$cpt_annee--)
        {
          if ($ligne = CommandeArticle::getSumByNoArticleGenreFOrG($default, $cpt_annee))
          {
            if ($ligne2 = CommandeArticle::getSumByNoArticleGenreN($default, $cpt_annee))
            {
              $Prix = 0;
              $Quantite = 0;
              $Prix = $Prix + $ligne["Prix"];
              $Prix = $Prix - $ligne2["Prix"];
              $Quantite = $Quantite + $ligne["Quantite"];
              $Quantite = $Quantite - $ligne2["Quantite"];
              $out .= "<tr><td>$cpt_annee</td><td>$Quantite</td><td>$Prix</td></tr>\n";
            }
          }
        }
        $out .= "</table>\n";
      break;
      case 227: /* Description */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 228: /* Vehicule */
      break;
      case 229: /* No plaques */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 230: /* Status atelier */
      break;
      case 231: /* Vendeur */
      break;
      case 232: /* NoCommande */
      break;
      case 233: /* Commande ouverte, envoyée, reçue */
      break;
      case 234: /* texte majuscules */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
      break;
      case 235: /* Texte Sans Espaces */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
  	  break;
      case 236: /* Categories Articles */
        $out = "";
        if ($resultat = Category::getCategoryByID($default))
        {
          foreach($resultat as $ligne)
          {
            $out = htmlspecialchars($ligne['Nom']);
          }
        }
      break;
      case 237: /* Vendu  export excel*/
      break;
      case 238: /* No chassis cle primaire */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
  	  break;
	  case 239: /* NbStock ou NbTransfert Dans un autre table par garage */
        $taille=strlen($default);
        if($sous_type==0)
        {
          $max=9;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out=" ".$out;
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
  	  break;
	  case 240: /* LieuxStoquage Dans un autre table par garage */
        $taille=strlen($default);
        if($sous_type>20 || $sous_type==0)
        {
          $max=20;
    		}
    		else
    		{
    		  $max=$sous_type;
    		}
    		if($taille>$max)
    		{
    		  $out=htmlspecialchars(substr($default,0,$max));
    		}
    		else
    		{
    		  $out=htmlspecialchars($default);
    		  for($cpt=$taille;$cpt<$max;$cpt++)
    		  {
    		  	$out.=" ";
    		  }
    		}
    		$out=str_replace(" ","&nbsp;",$out);
  	  break;
      case 241: /* Allocution */
        $out = htmlspecialchars($default);
      break;
      case 242: /* Boolean */
        if($default == "1")
        {
		  $out = "oui";
        }
		else
		{
		  $out = "non";
		}
	  break;
      case 243: /* Types client */
        $out = htmlspecialchars($default);
	  break;
      case 244: /* Impression entete */
	    $out = "<button type=\"button\" onclick=\"imprimer_entete_client('".$_GET["NoClient"]."')\">Imprimer</button>";
	  break;
      case 245: /* Type garantie */
        $out = htmlspecialchars($default);
	  break;
      case 246: /* Type vehicule */
        $out = htmlspecialchars($default);
	  break;
      case 300: /* texte */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 301: /* chiffre */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onChange='test_nombre(this.value, ".'"'."erra$champ".'"'.");'><span class='span_err' id='erra$champ' style='visibility:hidden;'>*</span>à<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,strpos($default,">")+1) . '"' ." onChange='test_nombre(this.value, ".'"'."errb$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='errb$champ' style='visibility:hidden;'>*</span>";
      break;
      case 302: /* date */
        $out="";
        if($comp!='')
        {
          $out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
        }
        //$out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,8,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,5,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,0,4) . '"' ." size=4 MAXLENGTH=4 onKeyUp='auto_tab(".'"'.$champ.'"'.",2,4);' onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err0$champ' style='visibility:hidden;'>*</span>au" .
        //        "<input type='texte' name='" . $champ . "[3]' value=" . '"' . substr($default,19,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",3,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value,this.form.elements[".'"'.$champ.'[5]"'."].value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[4]' value=" . '"' . substr($default,16,2) . '"' ." size=2 MAXLENGTH=2 onKeyUp='auto_tab(".'"'.$champ.'"'.",4,2);' onChange='test_date(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value,this.form.elements[".'"'.$champ.'[5]"'."].value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[5]' value=" . '"' . substr($default,11,4) . '"' ." size=4 MAXLENGTH=4 onChange='test_date(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value,this.form.elements[".'"'.$champ.'[5]"'."].value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err1$champ' style='visibility:hidden;'>*</span>";
	    $out .= "<input type='text' size='10' name='".$champ."[0]' class='$champ' value=''> au <input type='text' size='10' name='".$champ."[1]' class='$champ' value=''>";
		$out .= "\n<script>\njQuery(document).ready(function($) { jQuery('input.$champ').datepicker($.datepicker.regional[ \"fr-CH\" ]); });\n</script>\n";
				
      break;
      case 303: /* type allocution */
      break;
      case 304: /* NPA */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onChange='test_nombre(this.value, ".'"'."erra$champ".'"'.");'><span class='span_err' id='erra$champ' style='visibility:hidden;'>*</span>à<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,strpos($default,">")+1) . '"' ." onChange='test_nombre(this.value, ".'"'."errb$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='errb$champ' style='visibility:hidden;'>*</span>";
      break;
      case 305: /* Localite */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 306: /* Pays */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 307: /* Telephone */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_telephone_recherche(this.value, ".'"'."err$champ".'"'.");'";
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .=" onKeyDown='actif=".'"info";'."'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 308: /* Email */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onChange='test_email(this.value, ".'"'."err$champ".'"'.");'";
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .=" onKeyDown='actif=".'"info";'."'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 309: /* Langue */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onKeyDown='actif=".'"info";'."'>";
      break;
      case 310: /* Type client */
      break;
      case 311: /* Code rabais */
      break;
      case 312: /* Moyen de payement */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        if ($resultat = ModePayement::getModePayment())
        {
          $out .= "   <select name='$champ' onChange='AsChange=1;'>\n";
          $out .= "    <option value=''";
    		  $out .= "></option>\n";
          foreach ($resultat as $ligne)
          {
            $out .= "    <option value='" . $ligne['NoMode'] . " " . $ligne['NoCaisse'] . "'";
            if (($ligne['NoMode']." ".$ligne['NoCaisse']) == $default)
            {
      			  $out .= " selected";
      			}
      			$out .= ">" . htmlspecialchars($ligne['Description']) . "</option>\n";
          }
          $out .= "   </select>\n";
        }
      break;
      case 313: /* Long texte */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onKeyDown='actif=".'"info";'."'>";
      break;
      case 314: /* Client */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onKeyDown='actif=".'"info";'."' />à<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,strpos($default,">")+1) . '"' ." onKeyDown='actif=".'"info";'."' /><A HREF='find.php?Type=13&Detail=0&Cible=". $champ . htmlspecialchars("[0]") ."' target='recherche'>Rechercher</A>\n";
      break;
      case 315: /* Type Rabais */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          $out .= "   <select name='$champ'>\n";
          foreach($resultat as $ligne)
          {
            $out .= "    <option value='" . $ligne['NoRabais'] . "'";
            if ($ligne['NoRabais']==$default)
            {
      			  $out .= " selected";
      			}
      			$out .= ">" . htmlspecialchars($ligne['Description']) . "</option>\n";
          }
          $out .= "   </select>\n";
        }
      break;
      case 316: /* Type Rabais base articles */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        if ($resultat = TypeRabais::getActiveTypeRabais())
        {
          foreach($resultat as $ligne)
          {
            if ($ligne['NoRabais'] == $sous_type)
            {
      			  $out .= htmlspecialchars($ligne['Description']);
      			}
          }
        }
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"' ." onKeyDown='actif=".'"info";'."'>";
      break;
      case 317: /* No Matricule */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,3) . '"' ." size=3 MAXLENGTH=3 onKeyUp='auto_tab(".'"'.$champ.'"'.",0,3);' onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,3,3) . '"' ." size=3 MAXLENGTH=3 onKeyUp='auto_tab(".'"'.$champ.'"'.",1,3);' onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,6,3) . '"' ." size=3 MAXLENGTH=3 onChange='test_matricule(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err$champ' style='visibility:hidden;'>*</span>";
      break;
      case 318: /* Date et heure */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,8,2) . '"' ." size=2 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,5,2) . '"' ." size=2 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[2]' value=" . '"' . substr($default,0,4) . '"' ." size=4 onChange='test_date(this.form.elements[".'"'.$champ.'[0]"'."].value,this.form.elements[".'"'.$champ.'[1]"'."].value,this.form.elements[".'"'.$champ.'[2]"'."].value, ".'"'."err0$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err0$champ' style='visibility:hidden;'>*</span>au" .
                "<input type='texte' name='" . $champ . "[3]' value=" . '"' . substr($default,19,2) . '"' ." size=2 onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[4]' value=" . '"' . substr($default,16,2) . '"' ." size=2 onKeyDown='actif=".'"info";'."'><input type='texte' name='" . $champ . "[5]' value=" . '"' . substr($default,11,4) . '"' ." size=4 onChange='test_date(this.form.elements[".'"'.$champ.'[3]"'."].value,this.form.elements[".'"'.$champ.'[4]"'."].value,this.form.elements[".'"'.$champ.'[5]"'."].value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err1$champ' style='visibility:hidden;'>*</span>";
      break;
      case 319: /* Decimal */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
        }
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onChange='test_decimal(this.value, ".'"'."err0$champ".'"'.");'><span class='span_err' id='err0$champ' style='visibility:hidden;'>*</span>à<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,strpos($default,">")+1) . '"' ." onChange='test_decimal(this.value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err1$champ' style='visibility:hidden;'>*</span>";
      break;
      case 320: /* Texte avec recherche sans espace */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
        }
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 321: /* Type facture */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        if(isset($GLOBALS['Type_default']))
        {
        	$default=$GLOBALS['Type_default'];
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='FD'";
        if($default=="FD")
    		  $out .= " selected";
    		$out .= ">Facture détaillée</option>\n";
        $out .= "   <option value='BP'";
        if($default=="BP")
    		  $out .= " selected";
    		$out .= ">Bulletin de livraison</option>\n";
        $out .= "   <option value='FB'";
        if($default=="FB")
    		  $out .= " selected";
    		$out .= ">Facture bulletin de livraison</option>\n";
        $out .= "   <option value='FV'";
        if($default=="FV")
    		  $out .= " selected";
    		$out .= ">Facture véhicule neuf</option>\n";
        $out .= "   <option value='FO'";
        if($default=="FO")
    		  $out .= " selected";
    		$out .= ">Facture véhicule occasion</option>\n";
        $out .= "   <option value='FL'";
        if($default=="FL")
    		  $out .= " selected";
    		$out .= ">Facture location</option>\n";
        $out .= "   <option value='FI'";
        if($default=="FI")
    		  $out .= " selected";
    		$out .= ">Facture interne</option>\n";
        $out .= "   <option value='CP'";
        if($default=="CP")
    		  $out .= " selected";
    		$out .= ">Commande pièces</option>\n";
        $out .= "   <option value='RC'";
        if($default=="RC")
    		  $out .= " selected";
    		$out .= ">Retour commande pièces</option>\n";
        $out .= "   <option value='OP'";
        if($default=="OP")
    		  $out .= " selected";
    		$out .= ">Offre pièces</option>\n";
        $out .= "   <option value='OV'";
        if($default=="OV")
    		  $out .= " selected";
    		$out .= ">Offre véhicule</option>\n";
        $out .= "   <option value='DP'";
        if($default=="DP")
    		  $out .= " selected";
    		$out .= ">Devis</option>\n";
        $out .= "   <option value='GF'";
        if($default=="GF")
    		  $out .= " selected";
    		$out .= ">Garantie fourniseur</option>\n";
        $out .= "   <option value='GG'";
        if($default=="GG")
    		  $out .= " selected";
    		$out .= ">Garantie garage</option>\n";
        $out .= "   <option value='RV'";
        if($default=="RV")
    		  $out .= " selected";
    		$out .= ">Reprise véhicule</option>\n";
        $out .= "   <option value='ND'";
        if($default=="ND")
    		  $out .= " selected";
    		$out .= ">Note de crédit facture détaillée</option>\n";
        $out .= "   <option value='NB'";
        if($default=="NB")
    		  $out .= " selected";
    		$out .= ">Note de crédit facture bulletin liv</option>\n";
        $out .= "   <option value='NV'";
        if($default=="NV")
    		  $out .= " selected";
    		$out .= ">Note de crédit véhicule neuf</option>\n";
        $out .= "   <option value='NO'";
        if($default=="NO")
    		  $out .= " selected";
    		$out .= ">Note de crédit véhicule occasion</option>\n";
        $out .= "   <option value='NL'";
        if($default=="NL")
    		  $out .= " selected";
    		$out .= ">Note de crédit location</option>\n";
        $out .= "   <option value='AM'";
        if($default=="AM")
    		  $out .= " selected";
    		$out .= ">Achat marchandise</option>\n";
        $out .= "   <option value='VV'";
        if($default=="VV")
    		  $out .= " selected";
    		$out .= ">Achat véhicule neuf</option>\n";
        $out .= "   <option value='MO'";
        if($default=="MO")
    		  $out .= " selected";
    		$out .= ">Modèle</option>\n";
    		$out .= "</select>";
      break;
      case 322: /* Genre facture */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='F'";
        if($default=="F")
    		  $out .= " selected";
    		$out .= ">Facture</option>\n";
        $out .= "   <option value='B'";
        if($default=="B")
    		  $out .= " selected";
    		$out .= ">Bulletin de livraison</option>\n";
        $out .= "   <option value='C'";
        if($default=="C")
    		  $out .= " selected";
    		$out .= ">Commande</option>\n";
        $out .= "   <option value='O'";
        if($default=="O")
    		  $out .= " selected";
    		$out .= ">Offre</option>\n";
        $out .= "   <option value='D'";
        if($default=="D")
    		  $out .= " selected";
    		$out .= ">Devis</option>\n";
        $out .= "   <option value='G'";
        if($default=="G")
    		  $out .= " selected";
    		$out .= ">Garantie</option>\n";
        $out .= "   <option value='R'";
        if($default=="R")
    		  $out .= " selected";
    		$out .= ">Reprise</option>\n";
        $out .= "   <option value='N'";
        if($default=="N")
    		  $out .= " selected";
    		$out .= ">Note de crédit</option>\n";
        $out .= "   <option value='A'";
        if($default=="A")
    		  $out .= " selected";
    		$out .= ">Achat</option>\n";
        $out .= "   <option value='V'";
        if($default=="V")
    		  $out .= " selected";
    		$out .= ">Achat véhicule</option>\n";
    		$out .= "</select>";
      break;
      case 323: /* Type vehicule */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='M'";
        if($default=="M")
    		  $out .= " selected";
    		$out .= ">Moto</option>\n";
        $out .= "   <option value='S'";
        if($default=="S")
    		  $out .= " selected";
    		$out .= ">Scooter</option>\n";
    		$out .= "</select>";
      break;
      case 324: /* Status vehicule */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='N'";
        if($default=="N")
    		  $out .= " selected";
    		$out .= ">Neuf</option>\n";
        $out .= "   <option value='O'";
        if($default=="O")
    		  $out .= " selected";
    		$out .= ">Occasion</option>\n";
        $out .= "   <option value='C'";
        if($default=="C")
    		  $out .= " selected";
    		$out .= ">Client</option>\n";
        $out .= "   <option value='L'";
        if($default=="L")
    		  $out .= " selected";
    		$out .= ">Location</option>\n";
        $out .= "   <option value='P'";
        if($default=="P")
    		  $out .= " selected";
    		$out .= ">Prêt</option>\n";
        $out .= "   <option value='DO'";
        if($default=="DO")
    		  $out .= " selected";
    		$out .= ">Dépot vente occasion</option>\n";
        $out .= "   <option value='DN'";
        if($default=="DN")
    		  $out .= " selected";
    		$out .= ">Dépot vente neuf</option>\n";
        $out .= "   <option value='S'";
        if($default=="S")
    		  $out .= " selected";
    		$out .= ">Supprimé</option>\n";
    		$out .= "</select>";
      break;
      case 325: /* NoChasis */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='" . $champ . "' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onKeyDown='actif=".'"info";'."'><A HREF='find.php?Type=12&Detail=0&Cible=". $champ ."' target='recherche'>Rechercher</A>\n";
      break;
      case 326: /* Vendu */
      break;
      case 327: /* Description */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 328: /* Vehicule */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "Model <input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
      break;
      case 329: /* No plaques */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 330: /* Status atelier */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=='')
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='0'";
        if($default=='0')
    		  $out .= " selected";
    		$out .= ">Rendez-vous</option>\n";
        $out .= "   <option value='1'";
        if($default=='1')
    		  $out .= " selected";
    		$out .= ">En cours</option>\n";
        $out .= "   <option value='2'";
        if($default=='2')
    		  $out .= " selected";
    		$out .= ">Facturé</option>\n";
        $out .= "   <option value='3'";
        if($default=='3')
    		  $out .= " selected";
    		$out .= ">Sans facture</option>\n";
    		$out .= "</select>";
      break;
      case 331: /* Vendeur */
  	    $resultat=Employee::getVendeur();
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
  	    $out .= "<SELECT name='$champ'>\n";
  	    $out .= "<option value=''";
  	    if($default==0)
  	    {
  	      $out .= " selected";
    		}
    		$out .= ">-</option>\n";
  	    foreach($resultat as $ligne)
  	    {
  	      $out .= "<option value='".$ligne["NoClient"]."'";
  	      if($ligne["NoClient"]==$default)
  	       	$out .= " selected";
    		  $out .= ">".$ligne["Prenom"]." ".$ligne["Nom"]."</option>\n";
    		}
    		$out .= "</SELECT>";
      break;
      case 332: /* NoCommande */
      break;
      case 333: /* Commande ouverte, envoyée, reçue */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    		  $out .= " selected";
    		$out .= "></option>\n";
        $out .= "   <option value='O'";
        if($default=="O")
    		  $out .= " selected";
    		$out .= ">Ouverte</option>\n";
        $out .= "   <option value='E'";
        if($default=="E")
    		  $out .= " selected";
    		$out .= ">Envoyée</option>\n";
        $out .= "   <option value='R'";
        if($default=="R")
    		  $out .= " selected";
    		$out .= ">Reçue</option>\n";
    		$out .= "</select>";
      break;
      case 334: /* texte majuscules */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
      break;
      case 335: /* Texte Sans Espaces */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
  	  break;
      case 336: /* Categories Articles */
        $out = htmlspecialchars($default);
      break;
      case 337: /* Vendu  export excel*/
      break;
      case 338: /* No chassis cle primaire */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
  	  break;
	  case 339: /* NbStock ou NbTransfert Dans un autre table par garage */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
        }
        $out .= "<input type='texte' name='" . $champ . "[0]' value=" . '"' . substr($default,0,strpos($default,">")) . '"' ." onChange='test_decimal(this.value, ".'"'."err0$champ".'"'.");'><span class='span_err' id='err0$champ' style='visibility:hidden;'>*</span>à<input type='texte' name='" . $champ . "[1]' value=" . '"' . substr($default,strpos($default,">")+1) . '"' ." onChange='test_decimal(this.value, ".'"'."err1$champ".'"'.");' onKeyDown='actif=".'"info";'."'><span class='span_err' id='err1$champ' style='visibility:hidden;'>*</span>";
  	  break;
	  case 340: /* LieuxStoquage Dans un autre table par garage */
        $out="";
        if($comp!='')
        {
        	$out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    		}
        $out .= "<input type='texte' name='$champ' value=" . '"' . htmlspecialchars($default) . '"';
        if($sous_type!=0)
        {
        	$out.=" MAXLENGTH=$sous_type";
    		}
    		$out .= " onKeyDown='actif=".'"info";'."'>";
  	  break;
      case 341: /* Allocution */
        $out="";
        if($comp!='')
        {
          $out .= "<select name='$comp'><option value='0'>égal</option><option value='1'>diff</option></select>";
    	}
        $out .= "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
    	  $out .= " selected";
    	$out .= "></option>\n";
        $out .= "   <option value='Monsieur'";
        if($default=="Monsieur")
    	  $out .= " selected";
    	$out .= ">Monsieur</option>\n";
        $out .= "   <option value='Madame'";
        if($default=="Madame")
    	  $out .= " selected";
    	$out .= ">Madame</option>\n";
        $out .= "   <option value='Société'";
        if($default=="Société")
    	  $out .= " selected";
    	$out .= ">Société</option>\n";
        $out .= "   <option value='Entreprise'";
        if($default=="Entreprise")
    	  $out .= " selected";
    	$out .= ">Entreprise</option>\n";
        $out .= "   <option value='Garage'";
        if($default=="Garage")
    	  $out .= " selected";
    	$out .= ">Garage</option>\n";
    	$out .= "</select>";
      break;
      case 342: /* Boolean */
        $out = "oui <input type='radio' name='$champ' value='1'> non <input type='radio' name='$champ' value='0'>";
	  break;
      case 343: /* Types client */
	    $types_client = get_config("TYPES_CLIENT");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
          $out .= " selected";
    	$out .= "></option>\n";
		$arr_types_client = explode(";", $types_client);
		foreach ($arr_types_client as $type_client)
		{
          $out .= "   <option value='$type_client'";
          if(strtolower($default)==strtolower($type_client))
    	    $out .= " selected";
    	  $out .= ">$type_client</option>\n";
		}
    	$out .= "</select>";
	  break;
      case 344: /* Impression entete */
	    $out = "<button type=\"button\" onclick=\"imprimer_entete_client('".$_GET["NoClient"]."')\">Imprimer</button>";
	  break;
      case 345: /* Type garantie */
		$value_found = false;
	    $types_garantie = get_config("TYPES_GARANTIE");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
		{	
          $out .= " selected";
		  $value_found = true;
		}
    	$out .= "></option>\n";
		$arr_types_garantie = explode(";", $types_garantie);
		foreach ($arr_types_garantie as $type_garantie)
		{
          $out .= "   <option value='$type_garantie'";
          if(strtolower($default)==strtolower($type_garantie))
		  {
    	    $out .= " selected";
			$value_found = true;
		  }
    	  $out .= ">$type_garantie</option>\n";
		}
		if (!$value_found)
		{
          $out .= "   <option value='$default'";
    	  $out .= " selected";
    	  $out .= ">? $default</option>\n";
		}
    	$out .= "</select>";
  	  break;
      case 346: /* Type vehicule */
		$value_found = false;
	    $types_vehicule = get_config("TYPES_VEHICULE");
        $out  = "   <select name='$champ'>\n";
        $out .= "   <option value=''";
        if($default=="")
		{	
          $out .= " selected";
		  $value_found = true;
		}
    	$out .= "></option>\n";
		$arr_types_vehicule = explode(";", $types_vehicule);
		foreach ($arr_types_vehicule as $type_vehicule)
		{
          $out .= "   <option value='$type_vehicule'";
          if(strtolower($default)==strtolower($type_vehicule))
		  {
    	    $out .= " selected";
			$value_found = true;
		  }
    	  $out .= ">$type_vehicule</option>\n";
		}
		if (!$value_found)
		{
          $out .= "   <option value='$default'";
    	  $out .= " selected";
    	  $out .= ">? $default</option>\n";
		}
    	$out .= "</select>";
  	  break;
    }
 	return $out;
  }
  
  function Format_Telephone($valeur)
  {
	    $tel=str_replace("/", "", $valeur);
		$tel=str_replace(".", "", $tel);
		$tel=str_replace(" ", "", $tel);
	    if (substr($tel, 0, 2) == "00")
		{
		  if (substr($tel, 2, 2) == "33")
		  {
		    $out = "+" . substr($tel, 2, 2) . " " . substr($tel, 4, 3) . " " . substr($tel, 7, 2) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		  else if (substr($tel, 2, 2) == "41")
		  {
		    $out = "0" . substr($tel, 4, 2) . " " . substr($tel, 6, 3) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		  else
		  {
		    $out = "+" . substr($tel, 2, 2) . " " . substr($tel, 4, 2) . " " . substr($tel, 6, 3) . " " . substr($tel, 9, 2) . " " . substr($tel, 11);
		  }
		}
		else if (substr($tel, 0, 1) == "0")
		{
		  $out = substr($tel, 0, 3) . " " . substr($tel, 3, 3) . " " . substr($tel, 6, 2) . " " . substr($tel, 8);
		}
		else
		{
          $out = htmlspecialchars($tel);
		}
		return $out;
  }
 
  function Decode_Entree_Type($data,$type)
  {
    //echo "$data $type<br>";
    $type_interne = $type % 100;
    switch($type_interne)
    {
      case 0: /* texte */
        $out=addslashes($data);
      break;
      case 1: /* chiffre */
        $out=addslashes($data);
      break;
      case 2: /* date */
	    if (true)
		{
		  $out = "";
		  if ($data == "")
		  {
		  }
		  else
		  {
		    $out = substr($data,6,4)."-".substr($data,3,2)."-".substr($data,0,2);
		  }
		}
		else
		{
        $erreur=0;
        $out="";
        if($data[0]!="")
        {
          $tmp1=$data[2];
          $tmp2=$data[1];
          $tmp3=$data[0];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
          else if (strlen($tmp1)>4)
          {
            $erreur=1;
          }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3 . " 12:00:00";
    		}
    		if ($erreur==1)
    		{
    		  $out="";
    		}
	    }
      break;
      case 3: /* type allocution */
      break;
      case 4: /* NPA */
        $out=addslashes($data);
      break;
      case 5: /* Localite */
        $out=addslashes($data);
      break;
      case 6: /* Pays */
        $out=addslashes($data);
      break;
      case 7: /* Telephone */
	    $tel=str_replace("/", "", $data);
		$tel=str_replace(".", "", $tel);
		$tel=str_replace(" ", "", $tel);
		if (strlen($tel) == 0)
		{
		}
  	    else if (substr($tel, 0, 2) == "00")
		{
		}
		else if (substr($tel, 0, 1) == "0")
		{
		  $tel = "0041" . substr($tel, 1);
		}
		else
		{
          $tel = "004122" . htmlspecialchars($tel);
		}
        $out=addslashes($tel);
      break;
      case 8: /* Email */
        $out=addslashes($data);
      break;
      case 9: /* Langue */
        $out=$data;
      break;
      case 10: /* Type client */
      break;
      case 11: /* Code rabais */
      break;
      case 12: /* Moyen de payement */
      break;
      case 13: /* Long texte */
        $out=addslashes($data);
      break;
      case 14: /* Client */
        $out=addslashes($data);
      break;
      case 15: /* Type Rabais */
        $out=addslashes($data);
      break;
      case 16: /* Type Rabais base articles */
        $out=addslashes($data);
      break;
      case 17: /* No Matricule */
        $erreur=0;
        $out="";
        if($data[0]!="")
        {
          $tmp1=$data[0];
          $tmp2=$data[1];
          $tmp3=$data[2];
          if (strlen($tmp1)<3)
          {
            $tmp1 = substr("000",0,3-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>3)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<3)
          {
            $tmp2 = substr("000",0,3-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>3)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<3)
          {
            $tmp3 = substr("000",0,3-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>3)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . $tmp2 . $tmp3;
    		}
    		if ($erreur==1)
    		{
    		  $out="";
    		}
      break;
      case 18: /* Date et heure */
        $erreur=0;
        $out="";
        if($data[0]!="")
        {
		  if (true)
		  {
            $tmp1=$data[0];
            $out=substr($tmp1,6,4)."-".substr($tmp1,3,2)."-".substr($tmp1,0,2)." ".$data[1].":".$data[2].":00";
		  }
		  else
		  {
          $tmp1=$data[2];
          $tmp2=$data[1];
          $tmp3=$data[0];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>4)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3;
    		}
		}
    		if ($erreur==1)
    		{
    		  $out="";
    		}
      break;
      case 19: /* Decimal */
        $out=addslashes($data);
      break;
      case 20: /* Texte avec recherche sans espace */
        $out=addslashes($data);
      break;
      case 21: /* Type facture */
        $out=addslashes($data);
      break;
      case 22: /* Genre facture */
        $out=addslashes($data);
      break;
      case 23: /* Type vehicule */
        $out=addslashes($data);
      break;
      case 24: /* Status vehicule */
        $out=addslashes($data);
      break;
      case 25: /* NoChasis */
        $out=addslashes($data);
      break;
      case 26: /* Vendu */
      break;
      case 27: /* Description */
        $out=addslashes($data);
      break;
      case 28: /* Vehicule */
      break;
      case 29: /* No plaques */
        $out=strtoupper($data);
        $out=str_replace(" ","",$out);
        $out=addslashes($out);
      break;
      case 30: /* Status atelier */
      break;
      case 31: /* Vendeur */
        $out=addslashes($data);
      break;
      case 32: /* NoCommande */
      break;
      case 33: /* Commande ouverte, envoyée, reçue */
      break;
      case 34: /* texte majuscules */
        $out=strtoupper($data);
        $out=addslashes($out);
      break;
      case 35: /* Texte Sans Espaces */
        $out=strtoupper($data);
        $out=str_replace(" ","",$out);
        $out=addslashes($out);
  	  break;
      case 36: /* Categories Articles */
        $out=addslashes($data);
      break;
      case 38: /* No chassis cle primaire */
        $out=strtoupper($data);
        $out=str_replace(" ","",$out);
        $out=addslashes($out);
  	  break;
	  case 39: /* NbStock ou NbTransfert Dans un autre table par garage */
        $out=addslashes($data);
  	  break;
	  case 40: /* LieuxStoquage Dans un autre table par garage */
        $out=addslashes($data);
  	  break;
	  case 41: /* Allocution */
        $out=addslashes($data);
  	  break;
      case 42: /* Boolean */
        if(!empty($data) && $data == "1")
        {
    		  $out="1";
        }
		else
		{
    		  $out="0";
		}
        //$out=addslashes($data);
	  break;
      case 43: /* Types client */
        $out=addslashes($data);
  	  break;
      case 44: /* Impression entete */
        $out=addslashes($data);
  	  break;
      case 45: /* Type garantie */
        $out=addslashes($data);
  	  break;
      case 46: /* Type vehicule */
        $out=addslashes($data);
  	  break;
  	}
    return $out;
  }
  
  function Decode_Recherche_Type($data,$type)
  {
    $type_interne = $type % 100;
    switch($type_interne)
    {
      case 0: /* texte */
        $out=addslashes($data);
      break;
      case 1: /* chiffre */
        $out=$data[0] . ">" .$data[1];
      break;
      case 2: /* date */
	    //echo "Toto";
        $erreur=0;
        $out="";
        if((!empty($data[0]))and(!empty($data[1]))and(!empty($data[2])))
        {
          $tmp1=$data[2];
          $tmp2=$data[1];
          $tmp3=$data[0];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>4)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3;
    		}
        if(((!empty($data[0]))and(!empty($data[1]))and(!empty($data[2])))or((!empty($data[3]))and(!empty($data[4]))and(!empty($data[5]))))
        {
          $out .= ">";
    		}
        if((!empty($data[3]))and(!empty($data[4]))and(!empty($data[5])))
        {
          $tmp1=$data[5];
          $tmp2=$data[4];
          $tmp3=$data[3];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>4)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3;
    		}
    		if ($erreur==1)
    		{
    		  $out="";
    		}
      break;
      case 3: /* type allocution */
      break;
      case 4: /* NPA */
        $out=$data[0] . ">" .$data[1];
      break;
      case 5: /* Localite */
        $out=addslashes($data);
      break;
      case 6: /* Pays */
        $out=addslashes($data);
      break;
      case 7: /* Telephone */
	    $tel=$data;
		
		$tel=str_replace(" ", "", $tel);
		$tel=str_replace("/", "", $tel);
		$tel=str_replace(".", "", $tel);
		$tel=str_replace("+", "00", $tel);
		if (strpos($tel, '%') !== false)
		{
		$out=addslashes($tel);
		}
		else
		{
		if (strlen($tel) >= 2)
		{
		  if (substr($tel, 0, 2) == "00")
		  {
		  }
		  else if (substr($tel, 0, 1) == "0")
		  {
		    $tel = "0041" . substr($tel, 1);
		  }
		}
		echo $tel;
        $out=addslashes($tel);
		}
      break;
      case 8: /* Email */
        $out=addslashes($data);
      break;
      case 9: /* Langue */
        $out=$data;
      break;
      case 10: /* Type client */
      break;
      case 11: /* Code rabais */
      break;
      case 12: /* Moyen de payement */
      break;
      case 13: /* Long texte */
        $out=addslashes($data);
      break;
      case 14: /* Client */
        $out=$data[0] . ">" .$data[1];
      break;
      case 15: /* Type Rabais */
        $out=addslashes($data);
      break;
      case 16: /* Type Rabais base articles */
        $out=addslashes($data);
      break;
      case 17: /* No Matricule */
      break;
      case 18: /* Date et heure */
        $erreur=0;
        $out="";
        if((!empty($data[0]))and(!empty($data[1]))and(!empty($data[2])))
        {
          $tmp1=$data[2];
          $tmp2=$data[1];
          $tmp3=$data[0];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>4)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3;
    		}
        if(((!empty($data[0]))and(!empty($data[1]))and(!empty($data[2])))or((!empty($data[3]))and(!empty($data[4]))and(!empty($data[5]))))
        {
          $out .= ">";
    		}
        if((!empty($data[3]))and(!empty($data[4]))and(!empty($data[5])))
        {
          $tmp1=$data[5];
          $tmp2=$data[4];
          $tmp3=$data[3];
          if (strlen($tmp1)<4)
          {
            $tmp1 = substr("2000",0,4-strlen($tmp1)). $tmp1;
          }
    		  else if (strlen($tmp1)>4)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp2)<2)
          {
            $tmp2 = substr("01",0,2-strlen($tmp2)). $tmp2;
          }
    		  else if (strlen($tmp2)>2)
    		  {
    		  	$erreur=1;
    		  }
          if (strlen($tmp3)<2)
          {
            $tmp3 = substr("01",0,2-strlen($tmp3)). $tmp3;
          }
    		  else if (strlen($tmp3)>2)
    		  {
    		  	$erreur=1;
    		  }
    		  $out .= $tmp1 . "-" . $tmp2 . "-" . $tmp3;
    		}
    		if ($erreur==1)
    		{
    		  $out="";
    		}
      break;
      case 19: /* Decimal */
        $out=$data[0] . ">" .$data[1];
      break;
      case 20: /* Texte avec recherche sans espace */
        $out=addslashes($data);
      break;
      case 21: /* Type facture */
        $out=addslashes($data);
      break;
      case 22: /* Genre facture */
        $out=addslashes($data);
      break;
      case 23: /* Type vehicule */
        $out=addslashes($data);
      break;
      case 24: /* Status vehicule */
        $out=addslashes($data);
      break;
      case 25: /* NoChasis */
        $out=addslashes($data);
      break;
      case 26: /* Vendu */
      break;
      case 27: /* Description */
        $out=addslashes($data);
      break;
      case 28: /* Vehicule */
      break;
      case 29: /* No plaques */
        $out=addslashes($data);
      break;
      case 30: /* Status atelier */
      break;
      case 31: /* Vendeur */
        $out=addslashes($data);
      break;
      case 32: /* NoCommande */
      break;
      case 33: /* Commande ouverte, envoyée, reçue */
        $out=addslashes($data);
      break;
      case 34: /* texte majuscules */
        $out=addslashes($data);
      break;
      case 35: /* Texte Sans Espaces */
        $out=addslashes($data);
  	  break;
      case 36: /* Categories Articles */
        $out=addslashes($data);
      break;
      case 38: /* No chassis cle primaire */
        $out=addslashes($data);
  	  break;
	  case 39: /* NbStock ou NbTransfert Dans un autre table par garage */
        $out=$data[0] . ">" .$data[1];
  	  break;
	  case 40: /* LieuxStoquage Dans un autre table par garage */
        $out=addslashes($data);
  	  break;
	  case 41: /* Allocution */
        $out=addslashes($data);
  	  break;
      case 42: /* Boolean */
        $out=addslashes($data);
	  break;
      case 43: /* Types client */
        $out=addslashes($data);
  	  break;
      case 44: /* Impression entete */
        $out=addslashes($data);
  	  break;
      case 45: /* Type garantie */
        $out=addslashes($data);
  	  break;
      case 46: /* Type vehicule */
        $out=addslashes($data);
  	  break;
  	}
   	return $out;
  }
  
  function Create_Recherche($no_recherche,$NoVisu=0)
  {
    $tab_description=Create_Table_Champs($no_recherche,$nb_description);
    if ($resultat = Recherche::getRechercheByNoRechercheAndNoVisu($no_recherche, $NoVisu))
    {
      echo "   <table cellspacing='0' class='tab_recherche'>\n";
      foreach($resultat as $ligne)
      {
        $no_champ = $ligne['NoChamp'];
        echo "    <tr><th class='th_nom_champ'>" . $tab_description[$no_champ][0] . "</th><td class='td_saisie_champ'>";
        echo Cree_Entree_Type("recherche" . $ligne['Position'],$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['ValeurDefault'],RECHERCHE);
        echo "&nbsp</td></tr>\n";
      }
      echo "   </table>\n";
    }
  }
  
  function Create_Recherche_Form($no_recherche,$NoVisu=0)
  {
    global $Type, $Sous_Type;
    echo "<SCRIPT language=JavaScript src='valideformulaire.js' type=text/javascript></SCRIPT>\n";
    Affiche_No_Visu_recherche($no_recherche,VISU_DATA);
    echo "  <form class='formulaire_recherche' name='info'>\n";
    Create_Recherche($no_recherche,$NoVisu);
    echo "<script language=JavaScript>\n";
    echo "  force_submit=true;\n";
    echo "  this.document.forms['info'].elements[0].focus();\n";
    echo "</script>\n";
    echo "   <input type='hidden' name='Type' value=$Type>\n";
    echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
    echo "   <input type='hidden' name='Etape' value='1'>\n";
    echo "   <input type='hidden' name='NoVisu' value='$NoVisu'>\n";
    echo "   <input class='button' type='button' onClick='submit_ok(this.form);' value='Rechercher' />\n";
    echo "  </form>\n";
  }
  
  function Affiche_Resultat_Recherche($no_recherche,$mode=0,$NoVisu=0, $RequetteManuelle="")
  {
    $nb_result = 0;
    if ($ligne_nom = TableData::getTableDataByNoRechercheAndNoVisu($no_recherche, $NoVisu))
      {
        if($RequetteManuelle!="")
        {
          $requette = $RequetteManuelle;
        }
        else
        {
		  switch ($no_recherche)
		  {
		    case 4:
		    case 5:
		    case 6:
		    case 7:
              $requette = "SELECT * FROM " . $ligne_nom['NomTable'] . ID_GARAGE . " WHERE ";
			break;
			case 1:
              $requette = "SELECT * FROM articles LEFT JOIN stock".ID_GARAGE." ON articles.NoArticleRR = stock".ID_GARAGE.".NoArticleRR WHERE ";
			break;
			default:
              $requette = "SELECT * FROM " . $ligne_nom['NomTable'] . " WHERE ";
			break;
		  }
          $vide=1;
          $tab_description=Create_Table_Champs($no_recherche,$nb_description);
          if ($resultat2 = Recherche::getRechercheByNoRechercheAndNoVisu($no_recherche, $NoVisu))
          {
            foreach($resultat2 as $ligne2)
            {
              $no_champ = $ligne2['NoChamp'];
              if($mode==8 && $tab_description[$no_champ][1]=="NoClient")
              {
                $tmp_requette = Requette_Recherche($tab_description[$no_champ][1],$tab_description[$no_champ][2],$GLOBALS["recherche" . $ligne2['Position']], 2);
              }
              else
              {
                $tmp_requette = Requette_Recherche($tab_description[$no_champ][1],$tab_description[$no_champ][2],$GLOBALS["recherche" . $ligne2['Position']]);
              }
              if (!empty($tmp_requette))
              {
                if($vide==1)
                {
                  $vide=0;
                }
                else
                {
                  $requette .= " AND ";
                }
                $requette .= $tmp_requette;
              }
            }
          }
          if($vide==1)
          {
            $requette .= "1=0";
              echo "aucun parametre de recherche<BR>\n";
          }
          $requette .= " ORDER BY " . $ligne_nom['ChampsTri'];
        }
		//echo $requette."<br />";
        if ($resultat = Connection::executeRawQueryWithfetchAll($requette))
        {
          switch($no_recherche)
          {
            case 1:
              $_SESSION["memres1"]=$requette;
            break;
            case 2:
              $_SESSION["memres2"]=$requette;
            break;
            case 3:
              $_SESSION["memres3"]=$requette;
            break;
            case 4:
              $_SESSION["memres4"]=$requette;
            break;
          }
          switch($mode)
          {
            case 0:
              $vide=1;
              $tmp_affichage = "   <select class='select_resultat' name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='auto_submit(".'document.forms["recherche"]'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= " selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              $tmp_affichage .= "   <input class='button' type='submit' value='Afficher' />\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 1: // facture
              $nb_result = count($resultat);
              $no_type_rabais=0;
                if ($ligne = Client::getClientByNoClient($GLOBALS['NoClient']))
                {
                  $no_type_rabais=$ligne2['TypeRabais'];
                }
              $tmp_txt = "";
              switch ($nb_result)
              {
                case 0:
                  echo "<big>aucun resultat</big>\n";
                break;
                case 1:
                  $ligne = $resultat[0];
                  echo "<script language=javascript>\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = " . '"' . $ligne['NoArticle'] . '"' . ";" ;
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"' . $ligne['RabaisType'.$no_type_rabais] . '"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = " . '"'.round($ligne['EnStock']).'"' . ";";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
                  $ligneb=$ligne;
                  $resultata=Article::getArticleByNoArticleRR(addslashes($ligne['Description']));
                  $niv=0;
                  foreach($resultata as $lignea)
                  {
                    echo "window.opener.document.info.Description.value='" . addslashes($lignea['NoArticle']) . "';\n";
                    $niv++;
                    echo "if(confirm('".$ligneb['NoArticle']."->".$lignea['NoArticle']."'))\n";
                    echo "{\n";
                    echo "window.opener.document.info.NoArticle.value='" . addslashes($lignea['NoArticle']) . "';\n";
                    echo "window.opener.document.info.Description.value='" . addslashes($lignea['Description']) . "';\n";
                    echo "window.opener.document.info.Prix.value ='" . $lignea['PrixImportateur']  . "';\n";
                    echo "window.opener.document.info.TVA.value = '" . $lignea['TVA']  . "';\n";
                    echo "window.opener.document.info.GM.value = '" . $lignea['GroupeMarchandise'] . "';\n";
                    echo "window.opener.document.info.Rabais.value = '" . $lignea['RabaisType'.$no_type_rabais] . "';\n";
                    echo "window.opener.document.info.Stock.value = '" . round($lignea['EnStock']) . "';\n";
                    echo "window.opener.document.info.Quantite.value = '1.00';\n";
                    $resultata=Article::getArticleByNoArticleRR(addslashes($lignea['Description']));
                    $ligneb=$lignea;
                  }
                  for($cpt=0;$cpt<$niv;$cpt++)
                  {
                    echo "}\n";
                  }
                  echo "window.opener.document.info.Quantite.select();\n";
                  if($niv!=0)
                  {
                    echo "window.opener.document.info.Description.value='" . addslashes($ligneb['Description']) . "';\n";
                  }
                  echo "  window.close();";
                  echo "</script>\n";
                break;
                default:
                  $vide=1;
                  $tmp_txt2 = "<script language=javascript>\n";
                  $tmp_txt2 .= "  NoArticles=new Array();\n" .
                               "  Descriptions=new Array();\n" .
                               "  Prix=new Array();\n" .
                               "  TVA=new Array();\n" .
                               "  GM=new Array();\n" .
                               "  Rabais=new Array();\n" .
                               "  Stock=new Array();\n" .
                               "  Liste=new Array();\n" .
                               "  actif='recherche';\n";
                  $tmp_txt = "<form name='recherche'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Type' value='" . $GLOBALS['Type'] . "'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Etape' value='2'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Detail' value='" . $GLOBALS['Detail'] . "'>\n";
                  $tmp_txt .= "   <select  name='" . $ligne_nom['ChampCle'] . "' size='10' onDblClick='transfert(this.form.NoArticle,this.form);'>\n";
                  $cpt=0;
                  foreach($resultat as $ligne)
                  {
                    $tmp_txt3  = "  NoArticles[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Descriptions[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Prix[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  TVA[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  GM[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Rabais[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Stock[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  NoArticles[$cpt][0] = " . '"' . $ligne['NoArticle'] . '"' . ";\n";
                    $tmp_txt3 .= "  Descriptions[$cpt][0] = " . '"' . $ligne['Description'] . '"' . ";\n";
                    $tmp_txt3 .= "  Prix[$cpt][0] = " . '"' . $ligne['PrixImportateur'] . '"' . ";\n";
                    $tmp_txt3 .= "  TVA[$cpt][0] = " . '"' . $ligne['TVA'] . '"' . ";\n";
                    $tmp_txt3 .= "  GM[$cpt][0] = " . '"' . $ligne['GroupeMarchandise'] . '"' . ";\n";
                    $tmp_txt3 .= "  Rabais[$cpt][0] = " . '"' . $ligne['RabaisType'.$no_type_rabais] . '"' . ";\n";
                    $tmp_txt3 .= "  Stock[$cpt][0] = " . '"' . round($ligne['EnStock']) . '"' . ";\n";
                    //$requette2 = "SELECT * FROM articles WHERE NoArticleRR='" . Texte_Sans_Espace($ligne['Description']) . "'";
                    $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne['Description']));
                    if($ligne2 = $resultat2[0])
                    {
                      $nb_renv=1;
                      $tmp_txt3 .= "  NoArticles[$cpt][1] = " . '"' . $ligne2['NoArticle'] . '"' . ";\n";
                      $tmp_txt3 .= "  Descriptions[$cpt][1] = " . '"' . $ligne2['Description'] . '"' . ";\n";
                      $tmp_txt3 .= "  Prix[$cpt][1] = " . '"' . $ligne2['PrixImportateur'] . '"' . ";\n";
                      $tmp_txt3 .= "  TVA[$cpt][1] = " . '"' . $ligne2['TVA'] . '"' . ";\n";
                      $tmp_txt3 .= "  GM[$cpt][1] = " . '"' . $ligne2['GroupeMarchandise'] . '"' . ";\n";
                      $tmp_txt3 .= "  Rabais[$cpt][1] = " . '"' . $ligne2['RabaisType'.$no_type_rabais] . '"' . ";\n";
                      $tmp_txt3 .= "  Stock[$cpt][1] = " . '"' . round($ligne2['EnStock']) . '"' . ";\n";
                      //$requette2 = "SELECT * FROM articles WHERE NoArticleRR='" . Texte_Sans_Espace($ligne2['Description']) . "'";
                      $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne2['Description']));
                      foreach($resultat2 as $ligne2)
                      {
                        $nb_renv++;
                        $tmp_txt3 .= "  NoArticles[$cpt][$nb_renv] = " . '"' . $ligne2['NoArticle'] . '"' . ";\n";
                        $tmp_txt3 .= "  Descriptions[$cpt][$nb_renv] = " . '"' . $ligne2['Description'] . '"' . ";\n";
                        $tmp_txt3 .= "  Prix[$cpt][$nb_renv] = " . '"' . $ligne2['PrixImportateur'] . '"' . ";\n";
                        $tmp_txt3 .= "  TVA[$cpt][$nb_renv] = " . '"' . $ligne2['TVA'] . '"' . ";\n";
                        $tmp_txt3 .= "  GM[$cpt][$nb_renv] = " . '"' . $ligne2['GroupeMarchandise'] . '"' . ";\n";
                        $tmp_txt3 .= "  Rabais[$cpt][$nb_renv] = " . '"' . $ligne2['RabaisType'.$no_type_rabais] . '"' . ";\n";
                        $tmp_txt3 .= "  Stock[$cpt][$nb_renv] = " . '"' . round($ligne2['EnStock']) . '"' . ";\n";
                        //$requette2 = "SELECT * FROM articles WHERE NoArticleRR='" . Texte_Sans_Espace($ligne2['Description']) . "'";
                        $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne2['Description']));
                      }
                      $tmp_txt2 .= "  Liste[$cpt] = $nb_renv;\n";
                    }
                    else
                    {
                      $tmp_txt2 .= "  Liste[$cpt] = 0;\n";
                    }
                    $tmp_txt2 .= $tmp_txt3;
                    $tmp_txt .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]). "'";
                    if($vide==1)
                    {
                      $tmp_txt .= " selected";
                    }
                    $tmp_txt .= ">";
                    $vide=0;
                    if (!empty($ligne_nom['Affichage1']))
                    {
                      $tmp_txt .= htmlspecialchars($ligne[$ligne_nom['Affichage1']]);
                      if (!empty($ligne_nom['Affichage2']))
                      {
                        $tmp_txt .= "\t" . htmlspecialchars($ligne[$ligne_nom['Affichage2']]);
                        if (!empty($ligne_nom['Affichage3']))
                        {
                          $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage3']]);
                          if (!empty($ligne_nom['Affichage4']))
                          {
                            $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage4']]);
                            if (!empty($ligne_nom['Affichage5']))
                            {
                              $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage5']]);
                              if (!empty($ligne_nom['Affichage6']))
                              {
                                $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage6']]);
                              }
                            }
                          }
                        }
                      }
                    }
                    $tmp_txt .= "</option>\n";
                    $cpt++;
                  }
                  $tmp_txt .= "   </select><br>\n";
                  $tmp_txt .= "   <button type='button' onClick='transfert(this.form.NoArticle,this.form);'>Transférer</button>\n";
                  $tmp_txt .= "   </form>\n";
                  $tmp_txt2 .= "  function transfert(ici,ici2)\n" .
                               "  {\n" .
                               "    pos=1;\n" .
                               "    no=ici.options.selectedIndex;\n" .
                               "    val=ici.options[no].value;\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = NoArticles[no][0];\n" .
                               "    if(Liste[no]>0)\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = NoArticles[no][1];\n" .
                               "    else\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = Prix[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = TVA[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = GM[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = Rabais[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = Stock[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";\n" .
                               "    while ((Liste[no]>=pos)&&confirm(NoArticles[no][pos-1]+'->'+NoArticles[no][pos]))\n" .
                               "    {\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = NoArticles[no][pos];\n" .
                               "      if(Liste[no]>pos)\n" .
                               "        window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = NoArticles[no][pos+1];\n" .
                               "      else\n" .
                               "        window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = Prix[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = TVA[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = GM[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = Rabais[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = Stock[no][pos];\n" .
                               "      pos++\n" .
                               "    }\n" .
                               "    if(Liste[no]!=0)\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][Liste[no]];\n" .
                               "    window.opener.document.info.Quantite.select();\n" .
                               "    window.close();\n" .
                               "  }\n";
                  $tmp_txt2 .= "</script>\n";
                  echo $tmp_txt;
                  echo $tmp_txt2;
                break;
              }
            break;
            case 2: // commande
              $nb_result = count($resultat);
              $no_type_rabais=0;
                if ($ligne = Client::getClientByNoClient($GLOBALS['NoClient']))
                {
                  $no_type_rabais=$ligne2['TypeRabais'];
                }
              $tmp_txt = "";
              switch ($nb_result)
              {
                case 0:
                  echo "<big>aucun resultat</big>\n";
                break;
                case 1:
                  $ligne = $resultat[0];
                  echo "<script language=javascript>\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = " . '"' . $ligne['NoArticle'] . '"' . ";" ;
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = " . '"' . $ligne['Description']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = " . '"' . $ligne['PrixImportateur']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = " . '"' . $ligne['TVA']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = " . '"' . $ligne['GroupeMarchandise']  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = " . '"-' . $ligne['Rabais'] . '"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = " . '"' . round($ligne['EnStock'])  .'"' . ";\n";
                  echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";";
                  $ligneb=$ligne;
                  //$requettea="SELECT * FROM articles WHERE NoArticleRR='".addslashes($ligne['Description'])."'";
                  $resultata=Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne['Description']));
                  $niv=0;
                  foreach ( $resultata as $lignea)
                  {
                    echo "window.opener.document.info.Description.value='" . addslashes($lignea['NoArticle']) . "';\n";
                    $niv++;
                    echo "if(confirm('".$ligneb['NoArticle']."->".$lignea['NoArticle']."'))\n";
                    echo "{\n";
                    echo "window.opener.document.info.NoArticle.value='" . addslashes($lignea['NoArticle']) . "';\n";
                    echo "window.opener.document.info.Description.value='" . addslashes($lignea['Description']) . "';\n";
                    echo "window.opener.document.info.Prix.value ='" . $lignea['PrixImportateur']  . "';\n";
                    echo "window.opener.document.info.TVA.value = '" . $lignea['TVA']  . "';\n";
                    echo "window.opener.document.info.GM.value = '" . $lignea['GroupeMarchandise'] . "';\n";
                    echo "window.opener.document.info.Rabais.value = '-" . $lignea['Rabais'] . "';\n";
                    echo "window.opener.document.info.Stock.value = '" . round($lignea['EnStock']) . "';\n";
                    echo "window.opener.document.info.Quantite.value = '1.00';\n";
                    $resultata=Article::getArticleByNoArticleRR(addslashes($lignea['Description']));
                    $ligneb=$lignea;
                  }
                  for($cpt=0;$cpt<$niv;$cpt++)
                  {
                    echo "}\n";
                  }
                  echo "window.opener.document.info.Quantite.select();\n";
                  if($niv!=0)
                  {
                    echo "window.opener.document.info.Description.value='" . addslashes($ligneb['Description']) . "';\n";
                  }
                  echo "  window.close();";
                  echo "</script>\n";
                break;
                default:
                  $tmp_txt2 = "<script language=javascript>\n";
                  $tmp_txt2 .= "  NoArticles=new Array();\n" .
                               "  Descriptions=new Array();\n" .
                               "  Prix=new Array();\n" .
                               "  TVA=new Array();\n" .
                               "  GM=new Array();\n" .
                               "  Rabais=new Array();\n" .
                               "  Stock=new Array();\n" .
                               "  Liste=new Array();\n" .
                               "  actif='recherche';\n";
                  $tmp_txt = "<form name='recherche'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Type' value='" . $GLOBALS['Type'] . "'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Etape' value='2'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Detail' value='" . $GLOBALS['Detail'] . "'>\n";
                  $tmp_txt .= "   <select  name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='transfert(this.form.NoArticle,this.form);'>\n";
                  $cpt=0;
                  foreach($resultat as $ligne)
                  {
                    $tmp_txt3  = "  NoArticles[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Descriptions[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Prix[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  TVA[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  GM[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Rabais[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  Stock[$cpt] = new Array();\n";
                    $tmp_txt3 .= "  NoArticles[$cpt][0] = " . '"' . $ligne['NoArticle'] . '"' . ";\n";
                    $tmp_txt3 .= "  Descriptions[$cpt][0] = " . '"' . $ligne['Description'] . '"' . ";\n";
                    $tmp_txt3 .= "  Prix[$cpt][0] = " . '"' . $ligne['PrixImportateur'] . '"' . ";\n";
                    $tmp_txt3 .= "  TVA[$cpt][0] = " . '"' . $ligne['TVA'] . '"' . ";\n";
                    $tmp_txt3 .= "  GM[$cpt][0] = " . '"' . $ligne['GroupeMarchandise'] . '"' . ";\n";
                    $tmp_txt3 .= "  Rabais[$cpt][0] = " . '"-' . $ligne['Rabais'] . '"' . ";\n";
                    $tmp_txt3 .= "  Stock[$cpt][0] = " . '"' . round($ligne['EnStock']) . '"' . ";\n";
                    $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne['Description']));
                    if($ligne2 = $resultat2[0])
                    {
                      $nb_renv=1;
                      $tmp_txt3 .= "  NoArticles[$cpt][1] = " . '"' . $ligne2['NoArticle'] . '"' . ";\n";
                      $tmp_txt3 .= "  Descriptions[$cpt][1] = " . '"' . $ligne2['Description'] . '"' . ";\n";
                      $tmp_txt3 .= "  Prix[$cpt][1] = " . '"' . $ligne2['PrixImportateur'] . '"' . ";\n";
                      $tmp_txt3 .= "  TVA[$cpt][1] = " . '"' . $ligne2['TVA'] . '"' . ";\n";
                      $tmp_txt3 .= "  GM[$cpt][1] = " . '"' . $ligne2['GroupeMarchandise'] . '"' . ";\n";
                      $tmp_txt3 .= "  Rabais[$cpt][1] = " . '"-' . $ligne2['Rabais'] . '"' . ";\n";
                      $tmp_txt3 .= "  Stock[$cpt][1] = " . '"' . round($ligne2['EnStock']) . '"' . ";\n";
                      $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne2['Description']));
                      foreach($resultat2 as $ligne2)
                      {
                        $nb_renv++;
                        $tmp_txt3 .= "  NoArticles[$cpt][$nb_renv] = " . '"' . $ligne2['NoArticle'] . '"' . ";\n";
                        $tmp_txt3 .= "  Descriptions[$cpt][$nb_renv] = " . '"' . $ligne2['Description'] . '"' . ";\n";
                        $tmp_txt3 .= "  Prix[$cpt][$nb_renv] = " . '"' . $ligne2['PrixImportateur'] . '"' . ";\n";
                        $tmp_txt3 .= "  TVA[$cpt][$nb_renv] = " . '"' . $ligne2['TVA'] . '"' . ";\n";
                        $tmp_txt3 .= "  GM[$cpt][$nb_renv] = " . '"' . $ligne2['GroupeMarchandise'] . '"' . ";\n";
                        $tmp_txt3 .= "  Rabais[$cpt][$nb_renv] = " . '"-' . $ligne2['Rabais'] . '"' . ";\n";
                        $tmp_txt3 .= "  Stock[$cpt][$nb_renv] = " . '"' . round($ligne2['EnStock']) . '"' . ";\n";
                        $resultat2 = Article::getArticleStockByNoArticleRR(Texte_Sans_Espace($ligne2['Description']));
                      }
                      $tmp_txt2 .= "  Liste[$cpt] = $nb_renv;\n";
                    }
                    else
                    {
                      $tmp_txt2 .= "  Liste[$cpt] = 0;\n";
                    }
                    $tmp_txt2 .= $tmp_txt3;
                    $tmp_txt .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]). "'";
                    if($vide==1)
                    {
                      $tmp_txt .= " selected";
                    }
                    $tmp_txt .= ">";
                    $vide=0;
                    if (!empty($ligne_nom['Affichage1']))
                    {
                      $tmp_txt .= htmlspecialchars($ligne[$ligne_nom['Affichage1']]);
                      if (!empty($ligne_nom['Affichage2']))
                      {
                        $tmp_txt .= "\t" . htmlspecialchars($ligne[$ligne_nom['Affichage2']]);
                        if (!empty($ligne_nom['Affichage3']))
                        {
                          $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage3']]);
                          if (!empty($ligne_nom['Affichage4']))
                          {
                            $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage4']]);
                            if (!empty($ligne_nom['Affichage5']))
                            {
                              $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage5']]);
                              if (!empty($ligne_nom['Affichage6']))
                              {
                                $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage6']]);
                              }
                            }
                          }
                        }
                      }
                    }
                    $tmp_txt .= "</option>\n";
                    $cpt++;
                  }
                  $tmp_txt .= "   </select><br>\n";
                  $tmp_txt .= "   <button type='button' onClick='transfert(this.form.NoArticle,this.form);'>Transférer</button>\n";
                  $tmp_txt .= "   </form>\n";
                  $tmp_txt2 .= "  function transfert(ici,ici2)\n" .
                               "  {\n" .
                               "    pos=1;\n" .
                               "    no=ici.options.selectedIndex;\n" .
                               "    val=ici.options[no].value;\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = NoArticles[no][0];\n" .
                               "    if(Liste[no]>0)\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = NoArticles[no][1];\n" .
                               "    else\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = Prix[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = TVA[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = GM[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = Rabais[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = Stock[no][0];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Quantite" . '"' . "].value = " . '"1.00"' . ";\n" .
                               "    while ((Liste[no]>=pos)&&confirm(NoArticles[no][pos-1]+'->'+NoArticles[no][pos]))\n" .
                               "    {\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoArticle" . '"' . "].value = NoArticles[no][pos];\n" .
                               "      if(Liste[no]>pos)\n" .
                               "        window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = NoArticles[no][pos+1];\n" .
                               "      else\n" .
                               "        window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prix" . '"' . "].value = Prix[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "TVA" . '"' . "].value = TVA[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "GM" . '"' . "].value = GM[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Rabais" . '"' . "].value = Rabais[no][pos];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Stock" . '"' . "].value = Stock[no][pos];\n" .
                               "      pos++\n" .
                               "    }\n" .
                               "    if(Liste[no]!=0)\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Description" . '"' . "].value = Descriptions[no][Liste[no]];\n" .
                               "    window.opener.document.info.Quantite.select();\n" .
                               "    window.close();\n" .
                               "  }\n";
                  $tmp_txt2 .= "</script>\n";
                  echo $tmp_txt;
                  echo $tmp_txt2;
                break;
              }
            break;
            case 3:
              $nb_result = count($resultat);
              $tmp_txt = "";
              switch ($nb_result)
              {
                case 0:
                  echo "<big>aucun resultat</big>\n";
                break;
                case 1:
                  $ligne = $resultat[0];
                  $resultat2 = Vehicule::getVehiculeByClient($ligne['NoClient']);
                  $nb_result2 = count($resultat2);
                  echo "<script language=javascript>\n" .
                       "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoClient" . '"' . "].value = " . '"' . $ligne['NoClient'] . '"' . ";\n" .
                       "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Nom" . '"' . "].value = " . '"' . $ligne['Nom'] . '"' . ";\n" .
                       "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prenom" . '"' . "].value = " . '"' . $ligne['Prenom'] . '"' . ";\n";
                  switch ($nb_result2)
                  {
                    case 0:
                      echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '""' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '""' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '""' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '""' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '""' . ";\n";
                    break;
                    case 1:
                      $ligne2 = $resultat2[0];
                      echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . $ligne2['NoChasis'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne2['MarqueModel'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne2['Model'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne2['Km'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne2['NoPlaque'] . '"' . ";\n";
                    break;
                    default:
                      $ligne2 = $resultat2[0];
                      echo "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . $ligne2['NoChasis'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne2['MarqueModel'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne2['Model'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne2['Km'] . '"' . ";\n" .
                           "  window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne2['NoPlaque'] . '"' . ";\n";
                      $tmp_txt = "<BIG><BIG>Vehicules</BIG></BIG><BR>\n";
                      $tmp_txt .= "<TABLE border=1>\n";
                      $tmp_txt .= "<TR><TH>Numéro chasis</TH><TD>" . $ligne2['NoChasis'] . "</TD></TR>\n";
                      $tmp_txt .= "<TR><TH>Marque</TH><TD>" . $ligne2['MarqueModel'] . "</TD></TR>\n";
                      $tmp_txt .= "<TR><TH>Model</TH><TD>" . $ligne2['Model'] . "</TD></TR>\n";
                      $tmp_txt .= "<TR><TH>Km</TH><TD>" . $ligne2['Km'] . "</TD></TR>\n";
                      $tmp_txt .= "<TR><TH>Numéro de plaques</TH><TD>" . $ligne2['NoPlaque'] . "</TD></TR>\n";
                      $tmp_txt .= "</TABLE>\n";
                      $tmp_txt .= "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . $ligne2['NoChasis'] . '"' . ";" .
			                            " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne2['MarqueModel']  .'"' . ";" .
			                            " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne2['Model']  .'"' . ";" .
			                            " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne2['Km']  .'"' . ";" .
			                            " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne2['NoPlaque']  .'"' . ";" .
													        " '>transfert</button><BR><BR>\n";
                      foreach ($resultat2 as $ligne2)
                      {
                        $tmp_txt .= "<TABLE border=1>\n";
                        $tmp_txt .= "<TR><TH>Numéro chasis</TH><TD>" . $ligne2['NoChasis'] . "</TD></TR>\n";
                        $tmp_txt .= "<TR><TH>Marque</TH><TD>" . $ligne2['MarqueModel'] . "</TD></TR>\n";
                        $tmp_txt .= "<TR><TH>Model</TH><TD>" . $ligne2['Model'] . "</TD></TR>\n";
                        $tmp_txt .= "<TR><TH>Km</TH><TD>" . $ligne2['Km'] . "</TD></TR>\n";
                        $tmp_txt .= "<TR><TH>Numéro de plaques</TH><TD>" . $ligne2['NoPlaque'] . "</TD></TR>\n";
                        $tmp_txt .= "</TABLE>\n";
                        $tmp_txt .= "  <button type='button' onClick='window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = " . '"' . $ligne2['NoChasis'] . '"' . ";" .
                                    " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = " . '"' . $ligne2['MarqueModel']  .'"' . ";" .
			                              " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = " . '"' . $ligne2['Model']  .'"' . ";" .
			                              " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = " . '"' . $ligne2['Km']  .'"' . ";" .
			                              " window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = " . '"' . $ligne2['NoPlaque']  .'"' . ";" .
                                    " '>transfert</button><BR><BR>\n";
                      }
                    break;
                  }
                  echo "window.close();\n";
                  echo "</script>\n";
                  echo $tmp_txt;
                break;
                default:
                  $tmp_txt2 = "<script language=javascript>\n";
                  $tmp_txt2 .= "  Noms=new Array();\n" .
                               "  Prenoms=new Array();\n" .
                               "  NbVhc=new Array();\n" .
                               "  NoChassis=new Array();\n" .
                               "  Marques=new Array();\n" .
                               "  Models=new Array();\n" .
                               "  Kms=new Array();\n" .
                               "  NoPlaques=new Array();\n";
                  $tmp_txt = "<form>\n";
                  $tmp_txt .= "   <input type='hidden' name='Type' value='" . $GLOBALS['Type'] . "'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Etape' value='2'>\n";
                  $tmp_txt .= "   <input type='hidden' name='Detail' value='" . $GLOBALS['Detail'] . "'>\n";
                  $tmp_txt .= "   <select  name='" . $ligne_nom['ChampCle'] . "' size='10'>\n";
                  foreach($resultat as $ligne)
                  {
                    $tmp_txt2 .= "  Noms[" . $ligne['NoClient'] . "] = " . '"' . $ligne['Nom'] . '"' . ";\n";
                    $tmp_txt2 .= "  Prenoms[" . $ligne['NoClient'] . "] = " . '"' . $ligne['Prenom'] . '"' . ";\n";
                    $resultat2 = Vehicule::getVehiculeByClient($ligne['NoClient']);
                    $nb_result2 = count($resultat2);
                    $tmp_txt2 .= "  NbVhc[" . $ligne['NoClient'] . "] = " . $nb_result2 . ";\n";
                    if ($nb_result2>0)
                    {
                      $ligne2 = $resultat2[0];
                      $tmp_txt2 .= "  NoChassis[" . $ligne['NoClient'] . "] = " . '"' . $ligne2['NoChasis'] . '"' . ";\n";
                      $tmp_txt2 .= "  Marques[" . $ligne['NoClient'] . "] = " . '"' . $ligne2['MarqueModel'] . '"' . ";\n";
                      $tmp_txt2 .= "  Models[" . $ligne['NoClient'] . "] = " . '"' . $ligne2['Model'] . '"' . ";\n";
                      $tmp_txt2 .= "  Kms[" . $ligne['NoClient'] . "] = " . '"' . $ligne2['Km'] . '"' . ";\n";
                      $tmp_txt2 .= "  NoPlaques[" . $ligne['NoClient'] . "] = " . '"' . $ligne2['NoPlaque'] . '"' . ";\n";
                    }
                    else
                    {
                      $tmp_txt2 .= "  NoChassis[" . $ligne['NoClient'] . "] = " . '""' . ";\n";
                      $tmp_txt2 .= "  Marques[" . $ligne['NoClient'] . "] = " . '""' . ";\n";
                      $tmp_txt2 .= "  Models[" . $ligne['NoClient'] . "] = " . '""' . ";\n";
                      $tmp_txt2 .= "  Kms[" . $ligne['NoClient'] . "] = " . '""' . ";\n";
                      $tmp_txt2 .= "  NoPlaques[" . $ligne['NoClient'] . "] = " . '""' . ";\n";
                    }
                    $tmp_txt .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]). "'";
                    if($vide==1)
                    {
                      $tmp_txt .= " selected";
                    }
                    $tmp_txt .= ">";
                    $vide=0;
                    if(!empty($ligne_nom['Affichage1']))
                    {
                      $tmp_txt .= htmlspecialchars($ligne[$ligne_nom['Affichage1']]);
                      if (!empty($ligne_nom['Affichage2']))
                      {
                        $tmp_txt .= "\t" . htmlspecialchars($ligne[$ligne_nom['Affichage2']]);
                        if (!empty($ligne_nom['Affichage3']))
                        {
                          $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage3']]);
                          if (!empty($ligne_nom['Affichage4']))
                          {
                            $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage4']]);
                            if (!empty($ligne_nom['Affichage5']))
                            {
                              $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage5']]);
                              if (!empty($ligne_nom['Affichage6']))
                              {
                                $tmp_txt .= " - " . htmlspecialchars($ligne[$ligne_nom['Affichage6']]);
                              }
                            }
                          }
                        }
                      }
                    }
                    $tmp_txt .= "</option>\n";
                  }
                  $tmp_txt .= "   </select><br>\n";
                  $tmp_txt .= "   <button type='button' onClick='transfert(this.form.NoClient,this.form);'>Afficher</button>\n";
                  $tmp_txt .= "   </form>\n";
                  $tmp_txt2 .= "  function transfert(ici,ici2)\n" .
                               "  {\n" .
                               "    no=ici.options.selectedIndex;\n" .
                               "    val=ici.options[no].value;\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoClient" . '"' . "].value = val;\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Nom" . '"' . "].value = Noms[val];\n" .
                               "    window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Prenom" . '"' . "].value = Prenoms[val];\n" .
                               "    if (NbVhc[val]>0)\n" .
                               "    {\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = NoChassis[val];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = Marques[val];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = Models[val];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = Kms[val];\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = NoPlaques[val];\n" .
                               "      if (NbVhc[val]>1)\n" .
                               "      {\n" .
                               "        ici2.submit();\n" .
                               "      }\n" .
                               "    }\n" .
                               "    else\n" .
                               "    {\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoChasis" . '"' . "].value = '';\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Marque" . '"' . "].value = '';\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Model" . '"' . "].value = '';\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "Km" . '"' . "].value = '';\n" .
                               "      window.opener.document.forms[" . '"' . "info" . '"' . "].elements[" . '"' . "NoPlaque" . '"' . "].value = '';\n" .
                               "    }\n" .
                               "    if (NbVhc[val]<2)\n" .
                               "    {\n" .
                               "      window.close();\n" .
                               "    }\n" .
                               "  }\n";
                  $tmp_txt2 .= "</script>\n";
                  echo $tmp_txt;
                  echo $tmp_txt2;
                break;
              }
            break;
            case 4:
              $vide=1;
              if($no_recherche==3)
              {
                echo "<script language=JavaScript>\n";
                echo "Noms = new Array;\n";
                echo "Prenoms = new Array;\n";
                echo "</script>\n";
              }
              $tmp_affichage = "   <select  name='" . $ligne_nom['ChampCle'] . "' size='10'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                if($no_recherche==3)
                {
                  echo "<script language=JavaScript>\n";
                  echo "Noms[".$ligne[$ligne_nom['ChampCle']]."]=".'"'.$ligne['Nom'].'"'."\n";
                  echo "Prenoms[".$ligne[$ligne_nom['ChampCle']]."]=".'"'.$ligne['Prenom'].'"'."\n";
                  echo "</script>\n";
                }
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= " selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],AFFICHAGE);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],AFFICHAGE);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],AFFICHAGE);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],AFFICHAGE);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],AFFICHAGE);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],AFFICHAGE);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 5:
              $vide=1;
              $tmp_affichage = "   <select name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='auto_submit(".'document.forms["recherche"]'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= "selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if(empty($ligne['NoFourniseur']))
                {
                  $tmp_affichage .= "Ouverte ";
                }
                else
                {
                  if($ligne['Recu']=='O')
                  {
                    $tmp_affichage .= "Recue ";
                  }
                  else
                  {
                    $tmp_affichage .= "Envoyée ";
                  }
                }
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              $tmp_affichage .= "   <button type='submit'>Afficher</button>\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 6:
              $vide=1;
              $tmp_affichage = "   <select name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='auto_submit(".'document.forms["recherche"]'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= "selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                if($ligne['Type']=='CP')
                {
                  if(empty($ligne['NoFourniseur']))
                  {
                    $tmp_affichage .= " Ouverte";
                  }
                  else
                  {
                    if($ligne['Recu']=='O')
                    {
                      $tmp_affichage .= " Recue";
                    }
                    else
                    {
                      $tmp_affichage .= " Envoyée";
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              //$tmp_affichage .= "   <button type='submit'>Afficher</button>\n";
              $tmp_affichage .= "   <input class='button' type='submit' value='Afficher' />\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 7:
              $vide=1;
              $tmp_affichage = "   <select name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='auto_submit(".'document.forms["recherche"]'.");'>\n";
              echo "<script language=JavaScript>\n";
              echo "TabNoChasis=new Array;\n";
              echo "TabMarque=new Array;\n";
              echo "TabModel=new Array;\n";
              echo "TabKm=new Array;\n";
              echo "TabNoPlaque=new Array;\n";
              echo "TabNoClient=new Array;\n";
              echo "TabNom=new Array;\n";
              echo "TabPrenom=new Array;\n";
              echo "</script>\n";
              $cpt=0;
              foreach($resultat as $ligne)
              {
                $nb_result++;
                echo "<script language=JavaScript>\n";
                echo "TabNoChasis[$cpt]=".'"'.$ligne['NoChasis'].'"'.";\n";
                echo "TabMarque[$cpt]=".'"'.$ligne['MarqueModel'].'"'.";\n";
                echo "TabModel[$cpt]=".'"'.$ligne['Model'].'"'.";\n";
                echo "TabKm[$cpt]=".'"'.$ligne['Km'].'"'.";\n";
                echo "TabNoPlaque[$cpt]=".'"'.$ligne['NoPlaque'].'"'.";\n";
                if($ligne['Client']!=0)
                {
                  $ligne1=$ligne = Client::getClientByNoClient($ligne['Client']);
                  echo "TabNoClient[$cpt]=".'"'.$ligne['Client'].'"'.";\n";
                  echo "TabNom[$cpt]=".'"'.$ligne1['Nom'].'"'.";\n";
                  echo "TabPrenom[$cpt]=".'"'.$ligne1['Prenom'].'"'.";\n";
                }
                else
                {
                  echo "TabNoClient[$cpt]=".'""'.";\n";
                  echo "TabNom[$cpt]=".'""'.";\n";
                  echo "TabPrenom[$cpt]=".'""'.";\n";
                }
                echo "</script>\n";
                $cpt++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= "selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              $tmp_affichage .= "   <button class='button' type='submit' value='Modifier'>Modifier</button><button type='button' onClick='transfert_vhc(".$GLOBALS["Mode"].");'>Transférer</button>\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 8:
              $vide=1;
              $tmp_affichage = "   <select name='jourmoisannee' size='10' OnDblClick='auto_submit(".'document.forms["recherche"]'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . $ligne['Date'] . "'";
                if($vide==1)
                {
                  $tmp_affichage .= "selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              $tmp_affichage .= "   <button type='submit'>Afficher</button>\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 9:
              $vide=1;
              $tmp_affichage = "   <select  name='" . $ligne_nom['ChampCle'] . "' size='10' onDblClick='transfert_no_client(".'"'.$GLOBALS['Cible'].'"'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= " selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],AFFICHAGE);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],AFFICHAGE);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],AFFICHAGE);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],AFFICHAGE);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],AFFICHAGE);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " - " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],AFFICHAGE);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
            case 10:
              $vide=1;
              $tmp_affichage = "   <select class='select_resultat' name='" . $ligne_nom['ChampCle'] . "' size='10' OnDblClick='auto_submit(".'document.forms["info"]'.");'>\n";
              foreach($resultat as $ligne)
              {
                $nb_result++;
                $tmp_affichage .= "    <option value='" . htmlspecialchars($ligne[$ligne_nom['ChampCle']]) . "'";
                if($vide==1)
                {
                  $tmp_affichage .= " selected";
                }
                $tmp_affichage .= ">";
                $vide=0;
                if (!empty($ligne_nom['Affichage1']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
                  $tmp_affichage .= Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],RESULTAT);
                  if (!empty($ligne_nom['Affichage2']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                    $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],RESULTAT);
                    if (!empty($ligne_nom['Affichage3']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                      $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],RESULTAT);
                      if (!empty($ligne_nom['Affichage4']))
                      {
                        $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                        $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],RESULTAT);
                        if (!empty($ligne_nom['Affichage5']))
                        {
                          $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                          $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],RESULTAT);
                          if (!empty($ligne_nom['Affichage6']))
                          {
                            $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage6']);
                            $tmp_affichage .= " " . Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage6']],RESULTAT);
                          }
                        }
                      }
                    }
                  }
                }
                $tmp_affichage .= "</option>\n";
              }
              $tmp_affichage .= "   </select><br>\n";
              $tmp_affichage .= "   \n";
              if ($vide==0)
              {
                echo $tmp_affichage;
              }
              else
              {
                echo "<big>aucun resultat</big>\n";
              }
            break;
          }
        }
    }
    return $nb_result;
  }
  
  function Affiche_Resultat_Recherche_Form($no_recherche,$NoVisu,$mode=0,$RequetteManuelle="")
  {
    global $Type, $Sous_Type;
    echo "  <form name='recherche'>\n";
    $nb_result=Affiche_Resultat_Recherche($no_recherche,$mode,$NoVisu,$RequetteManuelle);
    if($mode==8)
    {
      echo "   <input type='hidden' name='Type' value=5>\n";
      echo "   <input type='hidden' name='Sous_Type' value=2>\n";
    }
    else
    {
      echo "   <input type='hidden' name='Type' value=$Type>\n";
      echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
      if($mode==5 || $mode==6)
        echo "   <input type='hidden' name='Etape' value='3'>\n";
      else
        echo "   <input type='hidden' name='Etape' value='2'>\n";
      echo "   <input type='hidden' name='NoVisu' value=0>\n";
    }
    echo "  </form>\n";
    if ($nb_result > 0)
    {
      echo "<script language=JavaScript>\n";
      echo "actif='recherche';\n";
      echo "this.document.forms['recherche'].elements[0].focus();\n";
      echo "</script>\n";
    }
  }
  
  function Affiche_Resultat_Recherche_Table($no_recherche,$NoVisu)
  {
      if ($ligne_nom = TableData::getTableDataByNoRechercheAndNoVisu($no_recherche, $NoVisu))
      {
        $requette = "SELECT * FROM " . $ligne_nom['NomTable'] . " WHERE ";
        $vide=1;
        $tab_description=Create_Table_Champs($no_recherche,$nb_description);
        if ($resultat2 = Recherche::getRechercheByNoRechercheAndNoVisu($no_recherche, $NoVisu))
        {
          foreach($resultat2 as $ligne2)
          {
            $no_champ = $ligne2['NoChamp'];
            $tmp_requette = Requette_Recherche($tab_description[$no_champ][1],$tab_description[$no_champ][2],$GLOBALS["recherche" . $ligne2['Position']]);
            if (!empty($tmp_requette))
            {
              if($vide==1)
              {
                $vide=0;
              }
              else
              {
                $requette .= " AND ";
              }
              $requette .= $tmp_requette;
            }
          }
        }
        if($vide==1)
        {
          $requette .= "1=1";
        }
        $requette .= " ORDER BY " . $ligne_nom['ChampsTri'];
        if ($resultat = Connection::executeRawQueryWithfetchAll($requette))
        {
          echo "<TABLE border=1>";
          foreach($resultat as $ligne)
          {
            echo "<TR>";
            if (!empty($ligne_nom['Affichage1']))
            {
              $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage1']);
              echo "<TD>" .Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage1']],AFFICHAGE) . "</TD>";
              if (!empty($ligne_nom['Affichage2']))
              {
                $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage2']);
                echo "<TD>" .Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage2']],AFFICHAGE) . "</TD>";
                if (!empty($ligne_nom['Affichage3']))
                {
                  $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage3']);
                  echo "<TD>" .Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage3']],AFFICHAGE) . "</TD>";
                  if (!empty($ligne_nom['Affichage4']))
                  {
                    $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage4']);
                    echo "<TD>" .Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage4']],AFFICHAGE) . "</TD>";
                    if (!empty($ligne_nom['Affichage5']))
                    {
                      $ligne2=Champ::getChampsByNoTableAndNoChamp($no_recherche, $ligne_nom['Affichage5']);
                      echo "<TD>" .Cree_Entree_Type("",$ligne2['TypeChamp'],$ligne2['SousTypeChamp'],$ligne[$ligne_nom['Affichage5']],AFFICHAGE) . "</TD>";
                    }
                  }
                }
              }
            }
            echo "</TR>\n";
          }
          echo "   </TABLE><br>\n";
        }
      }
  }
  
  function Affiche_No_Visu($no_table,$mode,$clef='',$param1='',$param2='',$Mode=0)
  {
    global $Type, $Sous_Type, $Etape;
    $resultat = Division::getDivisionByNoFormulaireAndNoDivision($no_table);
    echo "<table><tr>\n";
    foreach($resultat as $ligne)
    {
      if ($mode==VISU_SETUP)
        echo "<td><form><input type='hidden' name='Type' value=$Type><input type='hidden' name='Sous_Type' value=$Sous_Type><input type='hidden' name='NoVisu' value=" . $ligne['NoVisu'] . "><button type='submit'>" . $ligne['NomVisu'] . "</button></form></td>\n";
      if ($mode==VISU_DATA)
      {
          if ($ligne_nom = TableData::getTableDataByNoTable($no_table))
          {
            echo "<td><form><input type='hidden' name='Type' value=$Type><input type='hidden' name='Sous_Type' value=$Sous_Type><input type='hidden' name='Etape' value=$Etape><input type='hidden' name='NoVisu' value=" . $ligne['NoVisu'] . "><input type='hidden' name='Mode' value=$Mode>";
            if (!empty($param1))
            {
              echo "<input type='hidden' name='param1' value='$param1'>";
            }
            if (!empty($param2))
            {
              echo "<input type='hidden' name='param2' value='$param2'>";
            }
            echo "<input type='hidden' name='" . $ligne_nom['ChampCle'] . "' value='" . htmlspecialchars($clef) . "'><button type='button' onClick='test_change(this.form);'>" . $ligne['NomVisu'] . "</button></form></td>\n";
          }
      }
    }
    echo "</tr></table>\n";
  }
  
  function Affiche_No_Visu_recherche($no_table,$mode,$clef='',$param1='',$param2='')
  {
    global $Type, $Sous_Type, $Etape;
    $resultat = DivisionRecherche::getDivisionRechercheByNoFormulaireAndNoDivision($no_table);
    echo "<table><tr>\n";
    foreach ($resultat as $ligne)
    {
      if ($mode==VISU_SETUP)
        echo "<td><form><input type='hidden' name='Type' value=$Type><input type='hidden' name='Sous_Type' value=$Sous_Type><input type='hidden' name='NoVisu' value=" . $ligne['NoVisu'] . "><button type='submit'>" . $ligne['NomVisu'] . "</button></form></td>\n";
      if ($mode==VISU_DATA)
      {
          if ($ligne_nom = TableData::getTableDataByNoTable($no_table))
          {
            echo "<td><form><input type='hidden' name='Type' value=$Type><input type='hidden' name='Sous_Type' value=$Sous_Type><input type='hidden' name='Etape' value=$Etape><input type='hidden' name='NoVisu' value=" . $ligne['NoVisu'] . ">";
            if (!empty($param1))
            {
              echo "<input type='hidden' name='param1' value='$param1'>";
            }
            if (!empty($param2))
            {
              echo "<input type='hidden' name='param2' value='$param2'>";
            }
            echo "<input type='hidden' name='" . $ligne_nom['ChampCle'] . "' value='" . htmlspecialchars($clef) . "'><button type='submit'>" . $ligne['NomVisu'] . "</button></form></td>\n";
          }
      }
    }
    echo "</tr></table>\n";
  }

  function GetNomClef($no_formulaire)
  {
    $out='';
      if ($ligne_nom = TableData::getTableDataByNoTable($no_formulaire))
      {
        $out=$ligne_nom['ChampCle'];
      }
    return $out;
  }
  
  function GetNomTable($no_formulaire)
  {
    $out='';
      if ($ligne_nom = TableData::getTableDataByNoTable($no_formulaire))
      {
        $out=$ligne_nom['NomTable'];
      }
    return $out;
  }

  function Affiche_formulaire($no_formulaire,$mode,$no_division=1,$clef='',$no_visu=0,$param1='',$param2='',$Mode=0)
  {
    global $Type, $Sous_Type, $Etape;
    if(isset($GLOBALS['Move']))
    {
      switch($GLOBALS['Move'])
      {
        case "UP":
          switch($no_formulaire)
          {
            case 1:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres1"]);
              $up=$clef;
              foreach($resultat as $ligne)
              {
                if($clef==$ligne['NoArticle'])
                {
                  break;
                }
                else
                {
                  $up=$ligne['NoArticle'];
                }
              }
              $clef=$up;
            break;
            case 2:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres2"]);
              $up=$clef;
              foreach($resultat as $ligne)
              {
                if($clef==$ligne['NoChasis'])
                {
                  break;
                }
                else
                {
                  $up=$ligne['NoChasis'];
                }
              }
              $clef=$up;
            break;
            case 3:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres3"]);
              $up=$clef;
              foreach($resultat as $ligne)
              {
                if($clef==$ligne['NoClient'])
                {
                  break;
                }
                else
                {
                  $up=$ligne['NoClient'];
                }
              }
              $clef=$up;
            break;
          }
     	  break;
     	  case "DOWN":
          switch($no_formulaire)
          {
            case 1:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres1"]);
              $down=$clef;
              for ($i = 0; $i <= count($resultat); $i++)
              {
                $ligne=$resultat[$i];
                $down=$ligne['NoArticle'];
                if($clef==$ligne['NoArticle'])
                {
                  $ligne=$resultat[$i+1];
                  $down=$ligne['NoArticle'];
                  break;
                }
              }
              $clef=$down;
            break;
            case 2:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres2"]);
              $down=$clef;
              for ($i = 0; $i <= count($resultat); $i++) {
                $ligne=$resultat[$i];
                $down=$ligne['NoChasis'];
                if($clef==$ligne['NoChasis'])
                {
                  $ligne=$resultat[$i+1];
                  $down=$ligne['NoChasis'];
                  break;
                }
              }
              $clef=$down;
            break;
            case 3:
              $resultat=Connection::executeRawQueryWithfetchAll($_SESSION["memres3"]);
              $down=$clef;
              for ($i = 0; $i <= count($resultat); $i++) {
                $ligne=$resultat[$i];
                $down=$ligne['NoClient'];
                if($clef==$ligne['NoClient'])
                {
                  $ligne=$resultat[$i+1];
                    $down=$ligne['NoClient'];
                  break;
                }
              }
              $clef=$down;
            break;
            case 4:
            break;
          }
     	  break;
      }
    }
    Affiche_No_Visu($no_formulaire,VISU_DATA,$clef,$param1,$param2,$Mode);
    $tab_description=Create_Table_Champs($no_formulaire,$nb_description);
    $tab_formulaire=Create_Table_Formulaire($no_formulaire,$no_division,$no_visu,$nb_champs);
    echo "<SCRIPT language=JavaScript>\nmemnoform=$no_formulaire;\n";
    echo "force_submit=true;\n";
    echo "</SCRIPT>\n";
    if ($mode==NOUVEAU)
    {
      $mode2=MODIFICATION;
      echo "  <form name='info' method='POST'>\n";
      echo "<table class='tab_formulaire' border='1'>\n";
      //$tab_debug = array();
      for ($cpt=0;$cpt<$nb_champs;$cpt++)
      {
      	//$tab_debug[$cpt] = array();
        if($cpt%2)
        {
        }
        else
        {
          echo "<tr class='tr_formulaire'>\n";
        }
        $no_champ = $tab_formulaire[$cpt+1][0];
        if($tab_description[$no_champ][0]=="Nom" && !empty($param1))
        {
          $tab_formulaire[$cpt+1][1]=$param1;
        }
        if($tab_description[$no_champ][0]=="Client" && !empty($param1))
        {
          $tab_formulaire[$cpt+1][1]=$param1;
        }
        if($tab_description[$no_champ][0]=="Prénom" && !empty($param2))
        {
          $tab_formulaire[$cpt+1][1]=$param2;
        }
        if ($tab_description[$no_champ][0]=="Vide")
        {
          echo "<td colspan=2>&nbsp;</td>";
        }
        else if ($tab_description[$no_champ][2]==126)
        {
          echo "<td colspan=2>&nbsp;</td>";
        }
        else
        {
          //$tab_debug[$cpt][0]=$tab_description[$no_champ][0];
          //$tab_debug[$cpt][1]=$tab_description[$no_champ][1];
          //$tab_debug[$cpt][2]=$tab_description[$no_champ][2];
          //$tab_debug[$cpt][3]=$tab_description[$no_champ][3];
          //$tab_debug[$cpt]["mode2"]=$mode2;
          echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$tab_formulaire[$cpt+1][1],$mode2) . "&nbsp;</td>\n";
        }
        if($cpt%2)
        {
          echo "</tr>\n";
        }
        else
        {
        }
      }
      //$firephp = new FirePHP();
      //$firephp->log($tab_debug, "array");
      if($cpt%2)
      {
      }
      else
      {
        echo "</tr>\n";
      }
      echo "</table>\n";
      echo "<script language=JavaScript>\n";
      echo "this.document.forms['info'].elements[0].focus();\n";
      echo "</script>\n";
      echo "   <input type='hidden' name='Type' value=$Type>\n";
      echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
      echo "   <input type='hidden' name='Etape' value='" . ($Etape + 1) . "'>\n";
      echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
      if(!empty($param1))
      {
        echo "   <input type='hidden' name='param1' value='$param1'>\n";
      }
      if(!empty($param2))
      {
        echo "   <input type='hidden' name='param2' value='$param2'>\n";
      }
      if($Mode!=0)
      {
        echo "   <input type='hidden' name='Mode' value='$Mode'>\n";
      }
      echo "   <button type='button' onClick='submit_ok(this.form);'>Ajouter</button>\n";
      echo "  </form>\n";
    }
    else
    {
	  if ($no_formulaire==1)
	  {
		  $resultatExiste = Stock::getStockByNoArticleRR(addslashes(Texte_Sans_Espace($clef)));
      if ($resultatExiste)
      {
          $requette = "SELECT * FROM articles, stock".ID_GARAGE." WHERE articles." . GetNomClef($no_formulaire) . "='$clef' AND articles.NoArticleRR = stock".ID_GARAGE.".NoArticleRR";
      }
      else
      {
          $requette = "SELECT *, 0.00 as EnStock, 0.00 as EnTransfert, '' as LieuxStock FROM articles WHERE articles." . GetNomClef($no_formulaire) . "='$clef'";
      }
	  }
	  else
	  {
        $requette = "SELECT * FROM " . GetNomTable($no_formulaire) . " WHERE " . GetNomClef($no_formulaire) . "='$clef'";
	  }
      if ($resultat = Connection::executeRawQueryWithfetchAll($requette))
      {
        if($ligne = $resultat[0])
        {
          $mode2=$mode;
          //echo "<big>Clef : $clef</big><br>\n";
          if ($mode==MODIFICATION)
          {
            echo "  <form name='info'>\n";
            $mode2=$mode;
          }
          if ($mode==COPIE)
          {
            echo "  <form name='info'>\n";
            $mode2=MODIFICATION;
          }
          if ($mode==SUPPRIMER)
          {
            echo "  <form name='info'>\n";
            $mode2=AFFICHAGE;
          }
          if(!empty($param1))
          {
            echo "   <input type='hidden' name='param1' value='$param1'>\n";
          }
          if(!empty($param2))
          {
            echo "   <input type='hidden' name='param2' value='$param2'>\n";
          }
          echo "<table class='tab_formulaire' border='1'>\n";
          for ($cpt=0;$cpt<$nb_champs;$cpt+=2)
          {
		    $colls_special = ""; 
            $no_champ = $tab_formulaire[$cpt+1][0];
            $special=0;
            if($tab_description[$no_champ][0]=="Nom" && !empty($param1))
            {
              $special=1;
            }
            if($tab_description[$no_champ][0]=="Client" && !empty($param1))
            {
              $special=1;
            }
            if($tab_description[$no_champ][0]=="Prénom" && !empty($param2))
            {
              $special=2;
            }
            if(is_numeric($tab_description[$no_champ][2]) && (intval($tab_description[$no_champ][2])%100)==26)
            {
              $special=3;
            }
            if(is_numeric($tab_description[$no_champ][2]) && (intval($tab_description[$no_champ][2])%100)==28)
            {
              $special=4;
            }
            if ($tab_description[$no_champ][0]=="Vide")
            {
              echo "<tr><td colspan=2>&nbsp;</td>";
            }
            else
            {
			  if (($cpt+1)<$nb_champs)
			  {
			    if ($tab_description[$tab_formulaire[$cpt+2][0]][0]=="Vide")
                {
				  $colls_special = " colspan='3'";
				}
			  }
              switch($special)
              {
                case 0:
                  echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'$colls_special>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne[$tab_description[$no_champ][1]],$mode2) . "&nbsp;</td>";
                break;
                case 1:
                  echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'$colls_special>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$param1,$mode2) . "&nbsp;</td>";
                break;
                case 2:
                  echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'$colls_special>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$param2,$mode2) . "&nbsp;</td>";
                break;
                case 3: //fonction spéciale pour le champ vendu
                  //echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['Annee1'].";".$ligne['NombreVendu1'].";".$ligne['SommeVendu1'].";".$ligne['Annee2'].";".$ligne['NombreVendu2'].";".$ligne['SommeVendu2'].";".$ligne['Annee3'].";".$ligne['NombreVendu3'].";".$ligne['SommeVendu3'],$mode2) . "&nbsp;</td>";
                  echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'$colls_special>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['NoArticle'],$mode2) . "&nbsp;</td>";
                break;
                case 4:
                  echo " <tr class='tr_formulaire'><th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'$colls_special>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['NoClient'],$mode2) . "&nbsp;</td>";
                break;
              }
            }
            if (($cpt+1)<$nb_champs && $colls_special == "")
            {
              $no_champ = $tab_formulaire[$cpt+2][0];
              $special=0;
              if($tab_description[$no_champ][0]=="Nom" && !empty($param1))
              {
                $special=1;
              }
              if($tab_description[$no_champ][0]=="Client" && !empty($param1))
              {
                $special=1;
              }
              if($tab_description[$no_champ][0]=="Prénom" && !empty($param2))
              {
                $special=2;
              }
              if(($tab_description[$no_champ][2]%100)==26)
              {
                $special=3;
              }
              if(($tab_description[$no_champ][2]%100)==28)
              {
                $special=4;
              }
              if ($tab_description[$no_champ][0]=="Vide")
              {
                echo "<td colspan=2>&nbsp;</td></tr>";
              }
              else
              {
                switch($special)
                {
                  case 0:
                    echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+2),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne[$tab_description[$no_champ][1]],$mode2) . "&nbsp;</td>";
                  break;
                  case 1:
                    echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+2),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$param1,$mode2) . "&nbsp;</td>";
                  break;
                  case 2:
                    echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+2),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$param2,$mode2) . "&nbsp;</td>";
                  break;
                  case 3:
                    //echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['Annee1'].";".$ligne['NombreVendu1'].";".$ligne['SommeVendu1'].";".$ligne['Annee2'].";".$ligne['NombreVendu2'].";".$ligne['SommeVendu2'].";".$ligne['Annee3'].";".$ligne['NombreVendu3'].";".$ligne['SommeVendu3'],$mode2) . "&nbsp;</td>";
                    echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['NoArticle'],$mode2) . "&nbsp;</td>";
                  break;
                  case 4:
                    echo "<th class='th_formulaire_nom'>" . $tab_description[$no_champ][0] . "</th><td class='td_formulaire_valeur'>" . Cree_Entree_Type("data".($cpt+1),$tab_description[$no_champ][2],$tab_description[$no_champ][3],$ligne['NoClient'],$mode2) . "&nbsp;</td>";
                  break;
                }
              }
            }
            else if ($colls_special == "")
            {
              echo "<th>&nbsp;</th><td>&nbsp;</td>";
            }
            echo "</tr>\n";
          }
          echo "</table>\n";
          if($mode!=AFFICHAGE && $mode!=SUPPRIMER)
          {
            echo "<script language=JavaScript>\n";
            echo "this.document.forms['info'].elements[0].focus();\n";
            echo "</script>\n";
          }
          if ($mode==MODIFICATION)
          {
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
            echo "   <input type='hidden' name='Etape' value='" . ($Etape) . "'>\n";
            echo "   <input type='hidden' name='Modif' value='1'>\n";
            echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
            echo "   <input type='hidden' name='" . GetNomClef($no_formulaire) . "' value='$clef'>\n";
            if($Mode!=0)
            {
              echo "   <input type='hidden' name='Mode' value='$Mode'>\n";
            }
            echo "   <input class='button' type='button' onClick='submit_ok(this.form);' value='Modifier' />\n";
            echo "  </form>\n";
          }
          if ($mode==COPIE)
          {
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
            echo "   <input type='hidden' name='Etape' value='" . ($Etape + 1) . "'>\n";
            echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
            echo "   <input class='button' type='button' onClick='submit_ok(this.form);' value='Copier' />\n";
            echo "  </form>\n";
          }
          if ($mode==SUPPRIMER)
          {
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
            echo "   <input type='hidden' name='Etape' value='" . ($Etape + 1) . "'>\n";
            echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
            echo "   <input type='hidden' name='" . GetNomClef($no_formulaire) . "' value='$clef'>\n";
            echo "   <input class='button' type='submit' value='Supprimer' />\n";
            echo "  </form>\n";
          }
          if ($mode==AFFICHAGE)
          {
            echo "  <form name='info'>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Sous_Type' value=$Sous_Type>\n";
            echo "   <input type='hidden' name='Etape' value='" . ($Etape+1) . "'>\n";
            echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
            if($Type==1)
            {
              echo "   <input type='hidden' name='NoArticle' value='$clef'>\n";
              echo "  </form>\n";
              if(!As_Right_Fonction(1, 2))
                return;
            }
            if($Type==2)
            {
              echo "   <input type='hidden' name='NoChasis' value='$clef'>\n";
              echo "  </form>\n";
              if(!As_Right_Fonction(2, 2))
                return;
            }
            if($Type==3)
            {
              echo "   <input type='hidden' name='NoClient' value='$clef'>\n";
              echo "  </form>\n";
              if(!As_Right_Fonction(3, 2))
                return;
            }
            echo "  <form>\n";
            echo "   <input type='hidden' name='Type' value=$Type>\n";
            echo "   <input type='hidden' name='Sous_Type' value=2>\n";
            echo "   <input type='hidden' name='Etape' value='" . $Etape . "'>\n";
            echo "   <input type='hidden' name='NoVisu' value='$no_visu'>\n";
            echo "   <input type='hidden' name='" . GetNomClef($no_formulaire) . "' value='$clef'>\n";
            echo "   <input class='button' type='submit' value='Modifier' />\n";
            echo "  </form>\n";
          }
        }
      }
    }
  }
  
  function Valide_Modif($no_formulaire,$mode,$no_division=1,$clef='',$no_visu=0,$arguments1='',$arguments2='')
  {
    $tab_description=Create_Table_Champs($no_formulaire,$nb_description);
    $tab_formulaire=Create_Table_Formulaire($no_formulaire,$no_division,$no_visu,$nb_champs);
    $cle = "";
    switch($mode)
    {
      case MODIFICATION:
        $requette = "UPDATE " . GetNomTable($no_formulaire) . " SET ";
        $free=0;
		    $must_update_key = false;
        for ($cpt=0;$cpt<$nb_champs;$cpt++)
        {
          $nom_var = "data".($cpt+1);
          if(isset($GLOBALS[$nom_var]))
            ${$nom_var}=$GLOBALS[$nom_var];
          if(isset(${$nom_var})==TRUE || $tab_description[$tab_formulaire[$cpt+1][0]][2] == 42)
          {
            $no_champ = $tab_formulaire[$cpt+1][0];
            $valeur = Decode_Entree_Type(${$nom_var},$tab_description[$no_champ][2]);
          //echo $tab_description[$no_champ][2]."<br />";
          if (((($tab_description[$no_champ][2])%100)==39)||((($tab_description[$no_champ][2])%100)==40))
          {
            $key = addslashes(Texte_Sans_Espace($clef));
            $resultatExiste=Stock::getStockByNoArticleRR($key);
            if ($resultatExiste)
            {
              Stock::updateFieldByNoArticleRR($tab_description[$no_champ][1], $valeur, $key);
            }
            else
            {
              Stock::insertField($tab_description[$no_champ][1], $valeur, $key);
            }
          }
          else
          {
              if($free==0)
              {
                $free=1;
              }
              else
              {
                $requette .= ", ";
              }
              if(strlen($valeur) > 0) {
                $requette .= $tab_description[$no_champ][1] . "='$valeur'";
              } else {
                $requette .= $tab_description[$no_champ][1] . "=NULL";
              }
          }
                if (($tab_description[$no_champ][2])==20)
                {
                  if(!empty($valeur)) {
                    $requette .= ", ";
                    $requette .= $tab_description[$no_champ][1] . "RR='".Texte_Sans_Espace($valeur)."'";
                  }
                }
          if (($tab_description[$no_champ][2])==38) // No chassis cle primaire
          {
            if ($valeur != $clef)
            {
            // on teste si le no de chassis existe deja en bdd
            if ($ligne_ctrl = Vehicule::getVehiculeByNoChassis($valeur))
            {
              echo("Nouveau numero de chassis existe déjà !");
              return $cle;
            }
            else if (trim($valeur)=="")
            {
              echo("Numéro de chassis ne peut pas être vide !");
              return $cle;
            }
            else
            {
                // on met à jour toutes les factures, RDV atelier et vehicules de location
              $requette_update = "UPDATE commande".ID_GARAGE." SET Vehicule = '$valeur' WHERE Vehicule = '$clef'";
              if (!Connection::executeRawQuery($requette_update))
              {
                echo "erreur commande";
              }
              $requette_update = "UPDATE atelier".ID_GARAGE." SET NoChasis = '$valeur' WHERE NoChasis = '$clef'";
              if (!Connection::executeRawQuery($requette_update))
              {
                echo "erreur atelier";
              }
              $requette_update = "UPDATE vehiculeslocation".ID_GARAGE." SET NoChasis = '$valeur' WHERE NoChasis = '$clef'";
              if (!Connection::executeRawQuery($requette_update))
              {
                echo "erreur vehiculeslocation";
              }
              $must_update_key = true;
              $valeur_key = $valeur;
            }
            }
          }
          }
        }
        $requette .= $arguments1;
        $requette .= " WHERE " . GetNomClef($no_formulaire) . "='" . addslashes($clef) . "'";
		if ($must_update_key)
		{
		  $cle = $valeur_key; 
		}
		else
		{
		  $cle = $clef;
		}
      break;
      case NOUVEAU:
      case COPIE:
        $requette = "INSERT INTO " . GetNomTable($no_formulaire) . " (";
        $requette2 = '';
        $free=0;
        if ($no_formulaire==3)
        {
          $requette .= "NoClient";
          $requette2 .= Trouve_No_Client_Libre();
          $free=1;
        }
        $nom_cle = GetNomClef($no_formulaire);
        for ($cpt=0;$cpt<$nb_champs;$cpt++)
        {
          $nom_var = "data".($cpt+1);
          if(isset($GLOBALS[$nom_var]))
            ${$nom_var}=$GLOBALS[$nom_var];
          if(isset(${$nom_var})==TRUE)
          {
            $no_champ = $tab_formulaire[$cpt+1][0];
            $valeur = Decode_Entree_Type(${$nom_var},$tab_description[$no_champ][2]);
          if (((($tab_description[$no_champ][2])%100)==39)||((($tab_description[$no_champ][2])%100)==40))
          {
            $resultatExiste=Stock::getStockByNoArticleRR(addslashes(Texte_Sans_Espace($cle)));
            if ($resultatExiste)
            {
                Stock::updateFieldByNoArticleRR($tab_description[$no_champ][1], $valeur, addslashes(Texte_Sans_Espace($cle)));
            }
            else
            {
                Stock::insertField($tab_description[$no_champ][1], $valeur, addslashes(Texte_Sans_Espace($cle)));
            }
          }
          else
          {
                  if ($nom_cle == $tab_description[$no_champ][1])
                  {
                    $cle = $valeur;
                  }
                  if($free==0)
                  {
                    $free=1;
                  }
                  else
                  {
                    $requette .= ", ";
                    $requette2 .= ", ";
                  }
                  $requette .= $tab_description[$no_champ][1];
                  if(empty($valeur)) {
                    $requette2 .= "NULL";
                  } else {
                    $requette2 .= "'$valeur'";
                  }
                  
                  if (($tab_description[$no_champ][2])==20)
                  {
                    $requette .= ", ";
                    $requette2 .= ", ";
                    $requette .= $tab_description[$no_champ][1] . "RR";
                    $requette2 .= "'".Texte_Sans_Espace($valeur)."'";
                  }
          }
          }
	      if (($tab_description[$no_champ][2])==38) // No chassis cle primaire
        {
          if (trim($valeur)=="")
          {
            echo("Numéro de chassis ne peut pas être vide !");
            return;
          }		    
        }
        }
        $requette .= $arguments1 . ") VALUES (" . $requette2 . $arguments2 . ")";
      break;
      case SUPPRIMER:
        $requette = "DELETE FROM " . GetNomTable($no_formulaire) . " WHERE " . GetNomClef($no_formulaire) . " = '" . addslashes($clef) . "'";
        if ($no_formulaire==1)
        {
          for ($cpt_garage=1;$cpt_garage<=NB_GARAGES;$cpt_garage++)
          {
            $requetteDel = "DELETE FROM stock".$cpt_garage." WHERE NoArticleRR='".addslashes(Texte_Sans_Espace($clef))."'";
            echo $requetteDel."<br />";
            try {
              Connection::executeRawQuery($requetteDel);
            } catch (\Throwable $th) {
              echo "Table stock".$cpt_garage." non existant";
            }
          }
        }
      break;
    }
    if ($resultat = Connection::executeRawQuery($requette))
    {
      //echo "$requette<BR>\n";
      return $cle;
    }
    else
    {
      echo "KO $requette<BR>\n";
	  return $clef;
    }
  }

  function Input_Date_Heure($nom,$annee,$mois,$jour,$heure,$minute)
  {
    $out="<select name='".$nom."_jour'>\n";
    for($cpt=1;$cpt<=31;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$jour)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>-\n";
    $out.="<select name='".$nom."_mois'>\n";
    for($cpt=1;$cpt<=12;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$mois)
        $out.=" selected";
      $out.=">$cpt ".nom_mois($cpt)."</option>\n";
    }
    $out.="</select>-\n";
    $out.="<select name='".$nom."_annee'>\n";
    for($cpt=date("Y")-2;$cpt<=date("Y")+2;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$annee)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>\n";
    $out.="<select name='".$nom."_heure'>\n";
    for($cpt=0;$cpt<=23;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$heure)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>:\n";
    $out.="<select name='".$nom."_minute'>\n";
    for($cpt=0;$cpt<=59;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$minute)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>\n";
    return $out;
  }
  
  function Input_Date($nom,$annee,$mois,$jour)
  {
    $out="<select name='".$nom."_jour'>\n";
    for($cpt=1;$cpt<=31;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$jour)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>-\n";
    $out.="<select name='".$nom."_mois'>\n";
    for($cpt=1;$cpt<=12;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$mois)
        $out.=" selected";
      $out.=">$cpt ".nom_mois($cpt)."</option>\n";
    }
    $out.="</select>-\n";
    $out.="<select name='".$nom."_annee'>\n";
    for($cpt=date("Y")-2;$cpt<=date("Y")+2;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$annee)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>\n";
	//$out.="<img src=\"images/calendar.gif\" onclick=\"new calendar(this, '$nom');\" />";
    return $out;
  }
  
  function Input_Heure_15($nom,$heure,$minute)
  {
    $out="<select name='".$nom."_heure'>\n";
    for($cpt=0;$cpt<=23;$cpt++)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$heure)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>:\n";
    $out.="<select name='".$nom."_minute'>\n";
    for($cpt=0;$cpt<=59;$cpt+=15)
    {
      $out.="<option value='$cpt'";
      if ($cpt==$minute)
        $out.=" selected";
      $out.=">$cpt</option>\n";
    }
    $out.="</select>\n";
    return $out;
  }

  function CheckAlertClient($NoClient)
  {
    $alertemail = false;
    if (get_config("ALERT_EMAIL") == "1")
    {
      $ligne_email = Client::getClientByNoClient($NoClient);
      if (strlen($ligne_email["Email"]) == 0 && $ligne_email["IgnoreAlerteEmail"] == 0)
      {
        $alertemail = true;
      }
    }
	$resultat_client = AlertesClients::getAlerteClientActifByNoClient($NoClient);
	$nb_resultat_client = count($resultat_client);
	//$requette_vhc = "SELECT a.*, v.MarqueModel, v.Model FROM vehicules as v, alertes_vehicules as a WHERE v.Client = $NoClient AND v.NoChasis = a.NoChasis AND a.Etat = 'actif'";
	//$resultat_vhc = mysql_query($requette_vhc);
	//$nb_resultat_vhc = mysql_num_rows($resultat_vhc);
	if ($nb_resultat_client > 0 || $alertemail == true)
	{
      echo "<div id=\"div_alert\" style=\"display: block; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\">";
	  echo "<h2 style=\"padding: 10px 10px; margin: 0;\">Alerte client</h2>";
      foreach ($resultat_client as $ligne_client)
	  {
        echo "<p style=\"padding: 0px 20px 10px; margin: 0;\">".$ligne_client["Message"]."</p>";
	  }
	  if ($alertemail == true)
	  {
        echo "<p style=\"padding: 0px 20px 10px; margin: 0;\" class=\"alertemail\">Manque adresse email <button onclick=\"ignore_alerte_email_ajax($NoClient);\" type=\"button\">Ignorer</button></p>";
	  }
	  echo "</div>";
	}
	else
    {
	  echo "<div id=\"div_alert\" style=\"display: none; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\"></div>";
    }
  }  
  
  function CheckAlertVhc($NoChasis)
  {
	$requette_vhc = "SELECT * FROM alertes_vehicules WHERE NoChasis = '$NoChasis' AND Etat = 'actif'";
	$resultat_vhc = AlertesVehicules::getAlerteVehiculeActifByNoChassis($NoChasis);
	$nb_resultat_vhc = count($resultat_vhc);
	if ($nb_resultat_vhc > 0)
	{
	  echo "<div id=\"div_alert\" style=\"display: block; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\">";
	  echo "<h2 style=\"padding: 10px 10px; margin: 0;\">Alerte véhicule</h2>";
      foreach ($resultat_vhc as $ligne_vhc)
	  {
        echo "<p style=\"padding: 0px 20px 10px; margin: 0;\">".$ligne_vhc["Message"]."</p>";
	  }
	  echo "</div>";
	}
	else
    {
	  echo "<div id=\"div_alert\" style=\"display: none; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\"></div>";
    }
  }  

  function CheckAlertClientVhc($NoClient,$NoChasis)
  {
    $alertemail = false;
    if (get_config("ALERT_EMAIL") == "1")
	{
	  $ligne_email = Client::getClientByNoClient($NoClient);
	  if (strlen($ligne_email["Email"]) == 0 && $ligne_email["IgnoreAlerteEmail"] == 0)
	  {
	    $alertemail = true;
	  }
	}
	$resultat_client = AlertesClients::getAlerteClientActifByNoClient($NoClient);
	$nb_resultat_client = count($resultat_client);
	$resultat_vhc = AlertesVehicules::getAlerteVehiculeActifByNoChassis($NoChasis);
	$nb_resultat_vhc = count($resultat_vhc);

	//$requette_vhc = "SELECT a.*, v.MarqueModel, v.Model FROM vehicules as v, alertes_vehicules as a WHERE v.Client = $NoClient AND v.NoChasis = a.NoChasis AND a.Etat = 'actif'";
	//$resultat_vhc = mysql_query($requette_vhc);
	//$nb_resultat_vhc = mysql_num_rows($resultat_vhc);
	if ($nb_resultat_client > 0 || $nb_resultat_vhc > 0)
	{
      echo "<div id=\"div_alert\" style=\"display: block; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\">";
	  if ($nb_resultat_client > 0)
	  {
	    echo "<h2 style=\"padding: 10px 10px; margin: 0;\">Alerte client</h2>";
        foreach ($resultat_client as $ligne_client)
	    {
          echo "<p style=\"padding: 0px 20px 10px; margin: 0;\">".$ligne_client["Message"]."</p>";
	    }
      }
	  if ($nb_resultat_vhc > 0)
	  {
	    echo "<h2 style=\"padding: 10px 10px; margin: 0;\">Alerte véhicule</h2>";
        foreach ($resultat_vhc as $ligne_vhc)
	    {
          echo "<p style=\"padding: 0px 20px 10px; margin: 0;\">".$ligne_vhc["Message"]."</p>";
	    }
	  }
	  if ($alertemail == true)
	  {
        echo "<p style=\"padding: 0px 20px 10px; margin: 0;\" class=\"alertemail\">Manque adresse email <button onclick=\"ignore_alerte_email_ajax($NoClient);\" type=\"button\">Ignorer</button></p>";
	  }
	  echo "</div>";
	}
	else
    {
	  echo "<div id=\"div_alert\" style=\"display: none; color: red; width: 100%; background-color: rgba(255,255,255,0.5);\"></div>";
    }
  }  

  function CheckAlertCommande($NoCommande)
  {
    if ($ligne = Commande::getCommandeByNoCommande($NoCommande))
    {
        CheckAlertClientVhc($ligne["NoClient"],$ligne["NoChasis"]);
    }
  }  

  function CheckAlertAtelier($NoAtelier)
  {
    if ($ligne = Atelier::getAtelierByNoAtelier($NoAtelier))
    {
        CheckAlertClientVhc($ligne["NoClient"],$ligne["NoChasis"]);
    }
  }  

?>