<?php
  switch($Etape)
  {
    case 0:
      Create_Recherche_Form(2,$NoVisu);
    break;
    case 1:
      Create_Recherche_Form(2,$NoVisu);
      Affiche_Resultat_Recherche_Form(2,$NoVisu);
    break;
    case 2:
	  echo "<button type='button' onClick='dialog_historique(\"".${GetNomClef(2)}."\");'>Historique</button><br/>";
      if(isset($Modif))
	  {
        $clef = Valide_Modif(2,MODIFICATION,1,${GetNomClef(2)},$NoVisu,",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'" , '');
		if ($clef != ${GetNomClef(2)})
		{
		  echo "la cle a changé<br/>";
		  header("Location: default.php?Type=$Type&Sous_Type=$Sous_Type&Etape=$Etape&NoVisu=$NoVisu&Mode=$Mode&NoChasis=$clef");
		}
      }
	  CheckAlertVhc(${GetNomClef(2)});
      Affiche_formulaire(2,MODIFICATION,$no_division=1,$clef=${GetNomClef(2)},$no_visu=$NoVisu);
    break;
    case 3:
      Valide_Modif(2,MODIFICATION,1,${GetNomClef(2)},$NoVisu,",DateModif='" . date("Y-m-d") . "',PersonneModif='" . addslashes($lg_user) . "'" , '');
    break;
  }
?>
<div id="dialog" title="Recherche client">Dialog</div>
 <script>
  $(function() {
    $( "#dialog" ).dialog({
      autoOpen: false
    });
  });
function dialog_historique(nochasis)
{
  if (nochasis.length > 0)
  {
    $.get( "historique_atelier.php?nochasis="+nochasis, function( data ) {
      var dialog = $('#dialog');
      dialog.html( data );
      dialog.dialog({
        //resizable: false,
        //height:140,
		width:800,
	    title:"Historique",
        buttons: {
          "Fermer": function() {
            $( this ).dialog( "close" );
          }
        }
      });
      dialog.dialog( "open" );
      //alert( "Load was performed." );
    });
    //window.open("historique_atelier.php?nochasis="+nochasis);
  }
}
</script>
