<?php
  switch($Etape)
  {
    case 0:
	  echo $_SERVER["REQUEST_URI"];
      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='1'>\n";
      echo "<TABLE border=1>\n";
	  $resultat = ChassisModel::getAll();
      echo "   <TR><TH>Model</TH><TD><select name='Id'>";
	  foreach($resultat as $ligne)
	  {
		echo "<option value='".$ligne["Id"]."'>".$ligne["Chassis"]." ".$ligne["Model"]." ".$ligne["Cylindree"]." ".$ligne["Homologation"]."</option>";
	  }
	  echo "</TD></TR>\n";
      echo "</TABLE>\n";
      echo "   <button type='submit'>Supprimer</button>\n";
      echo "  </form>\n";  
    break;
    case 1:
      $resultat = ServiceVHC::getServiceVHCByID($Id);
      if($ligne = $resultat)
      {
        $requette = "DELETE FROM service_action WHERE Id_Service = ".$ligne['Id'];
        Connection::executeRawQuery($requette);
      }
      $requette = "DELETE FROM service_vhc WHERE Id_vhc = $Id";
      Connection::executeRawQuery($requette);
      $requette = "DELETE FROM vhc_action WHERE Id_vhc = $Id";
      Connection::executeRawQuery($requette);
      $requette = "DELETE FROM service_article WHERE Id_Vhc = $Id";
      Connection::executeRawQuery($requette);
      $requette = "DELETE FROM chassis_model WHERE Id = $Id";
      Connection::executeRawQuery($requette);
	  $requette = "DELETE FROM vhc_option WHERE Id_vhc = $Id";
	  Connection::executeRawQuery($requette);
	  $requette = "DELETE FROM vhc_option_action WHERE Id_vhc = $Id";
	  Connection::executeRawQuery($requette);
	  $requette = "DELETE FROM service_option_article WHERE Id_Vhc = $Id";
	  Connection::executeRawQuery($requette);
	  $requette = "DELETE FROM vhc_option_action_remplacement WHERE Id_vhc = $Id";
	  Connection::executeRawQuery($requette);
    break;
  }
?>
