<?php
  switch($Etape)
  {
    case 0:
      $ligne =   Config::getLastRappel();
      echo "Dernière mise à jour le " . $ligne["valeur"] . "<BR>\n";
      echo "<form>";
      echo "<input type='hidden' name='Type' value=$Type>";
      echo "<input type='hidden' name='Sous_Type' value=$Sous_Type>";
      echo "<input type='hidden' name='Etape' value='1'>";
      echo "Voulez-vous faire une nouvelle génération de rappels ?<BR>\n";
      echo "<input type='submit' value='oui'>";
      echo "</form>";
    break;
    case 1:
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='FD'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='FB'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='FV'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='FO'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='FL'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE commande".ID_GARAGE." SET DegreSommation=DegreSommation+1 WHERE DegreSommation<3 AND APayer!=0 AND Paye!='O' AND DateDelaisPayement<'".date("Y-m-d")."' AND ModeDelaisPayement=0 AND Type='GF'";
      Connection::executeRawQuery($requette);
      $requette="UPDATE config".ID_GARAGE." SET valeur='".date("d.m.Y")."' WHERE champ='last_rappel'";
      Connection::executeRawQuery($requette);
    break;
  }
?>
