public static function generateDashboard()
    {
        $res = '<div class="row">
                    <div class="col-sm-12 page-title">
                        <h2><span class="glyphicon glyphicon-dashboard"></span> Tableau de bord</h2>
                    </div>
                </div> 
                <div class="row">
                    <div class="col-sm-12 page-content">

                        <div class=" col-sm-6">
                            <h3>Paiements en retard</h3>
                            <hr>
                            <table class="table table-striped">
                                <!-- header du tableau -->
                                <thead>
                                <th class="col-sm-4">Adresse</th>
                                <th class="col-sm-2">Montant du</th>
                                <th class="col-sm-3">Prochaine écheance du loyer</th> 
                                <th class="col-sm-1">Rappel</th>
                                </thead>
                                <!-- contenu du tableau -->
                                <tbody>';
        $res2 = "";
        $res3 = "";
        $impayes = Impaye::findAll();
        foreach ($impayes as $impaye) {
            $location = Location::findById($impaye->id_location);
            $utilisateur = Utilisateur::findById($impaye->id_utilisateur);
            $typeutilisateur = TypeUtilisateur::findById($utilisateur->id_type_utilisateur);
            if ($typeutilisateur->id_type_utilisateur != 14) {
                $appart = Appartement::findById($location->id_appartement);
                $adresse = Adresse::findById($appart->id_adresse);
                $res .= '               <tr id="appart_01">
                                            <td>' . $adresse->numRue . ' ' . $adresse->rue . '<br>' . $adresse->codePostal . ' ' . $adresse->ville . '</td>
                                            <td>' . $impaye->montant . ' €</td>
                                            <td>' . $impaye->dateLimite . '</td>
                                            <td>
                                                <a class="btn btn-sm btn-default">
                                                    Envoyer rappel
                                                </a>
                                            </td>
                                        </tr>';
            }
            $res2 .= '               <tr id="proprio01">
                                            <td>' . $utilisateur->prenom . ' ' . $utilisateur->nom . '</td>
                                            <td>' . $impaye->montant . ' €</td>
                                            <td>
                                                <a class="btn btn-sm btn-primary">
                                                    Payer
                                                </a>
                                            </td>
                                        </tr>';
        }
        $res .= '</tbody>
                            </table>

                        </div>
                        <div class="col-sm-5 col-sm-offset-1">
                            <h3>Propriétaires à payer</h3>
                            <hr>
                            <table class="table table-striped">
                                <!-- header du tableau -->
                                <thead>
                                <th class="col-sm-6">Nom</th>
                                <th>Montant à régler</th>
                                <th class="col-sm-2">Régler</th>
                                </thead>
                                <!-- contenu du tableau -->
                                <tbody>';
        $res .= $res2;
        $res .= '               </tbody>
                            </table>

                        </div>
                    
                ';
        $options = Option::findAll();
        $idappart = "";
        $old_idappart = "";
        foreach ($options as $option) {
            $id_appart = $option->id_appartement;
            if ($id_appart != $old_idappart) {
                $res3 .= '               <tr id="proprio01">
                                            <td>Appartement n°' . $option->id_appartement . '</td>
                                            <td></td>
                                            <td>
                                                <center><a class="btn btn-sm btn-primary">
                                                    Détails
                                                </a></center>
                                            </td>
                                        </tr>';
            }
            $utilisateur = Utilisateur::findById($option->id_utilisateur);
            $appart = Appartement::findById($option->id_appartement);
            $res3 .= '               <tr id="proprio01">
                                        <td>' . $utilisateur->prenom . ' ' . $utilisateur->nom . '</td>
                                        <td>' . $option->date . '</td>
                                        <td>
                                            <center><a class="btn btn-sm btn-success">
                                                Attribuer
                                            </a></center>
                                        </td>
                                    </tr>';
            $old_idappart = $id_appart;
        }
        $res .= '<br>
                        <div class="col-sm-5 col-sm-offset-1">
                            <h3>Options</h3>
                            <hr>
                            <table class="table table-striped">
                                <!-- header du tableau -->
                                <thead>
                                <th class="col-sm-4">Posée par</th>
                                <th class="col-sm-5">Le</th>
                                <th class="col-sm-3">Attribuer l\'appartement</th>
                                </thead>
                                <!-- contenu du tableau -->
                                <tbody>';
        $res .= $res3;
        $res .= '               </tbody>
                            </table>

                        </div>
                    </div>
                </div>';
        return $res;
    }
    public static function generateUniquePossession($possession)
    {
        $appart = Appartement::findById($possession->id_appartement);
        $adresse = Adresse::findById($appart->id_adresse);
        $rep = '<div class="col-sm-3">
                    <div class="thumbnail">
                        <div style="background-image: url(http://www.yooko.fr/wp-content/uploads/2013/07/appartement-W-par-Regis-Botta-7.jpg)">

                        </div>
                    <img src="http://www.yooko.fr/wp-content/uploads/2013/07/appartement-W-par-Regis-Botta-7.jpg" />
                                    <div class="caption">
                                        <h3>Appartement<br><small>Quartier ' . $adresse->quartier . ' ' . $adresse->ville . ' (' . $adresse->codePostal . ')</small></h3>

                                        <h4>Caractéristiques</h4>
                                        <table class="table table-hover">
                                            <tr>
                                                <td>
                                                    Surface
                                                </td>
                                                <td>
                                                    ' . $appart->surface . ' m²
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Loyer
                                                </td>
                                                <td>
                                                    ' . $appart->loyer . ' €
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Type
                                                </td>
                                                <td>
                                                    ' . TypeAppartement::findById($appart->id_type_appart)->nom . '
                                                </td>
                                            </tr>
                                        </table>
                                        <p>
                                            <span class="pull-right"></span>
                                            <a href="./?a=displayApp&id_app=' . $appart->id_appart . '" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-list-alt"></span> Détails</a>';
        if (isset($_SESSION['email'])) {
            //$location = location::findByIdUtilisateurAndIdAppartement($_SESSION['id_utilisateur'], $appart->id_appart);
            if ($possession->id_possession != "") {
                $rep .= '                   <a class="btn btn-success pull-right" role="button"><span class="glyphicon glyphicon-check"></span> Appartement loué</a>';
            }
        }
        $rep .= '                       </p>
                                    </div>
                                </div>
                            </div> ';
        return $rep;
    }
$appart->etat = "Bon etat";
$appart->id_type_appart = 19;
$appart->id_adresse = 4;
// Ajout dans la base
echo "OK<br/>Ajout de l'appartement dans la base ... ";
$appart->insert();
echo "OK<br/>";
// Liste de tous les appartements
listerTout();
// Apport d'une modification
$appart->loyer = 650;
echo "Augmentation du loyer ! Mise a jour dans la base ... ";
$appart->update();
echo "OK<br/>";
// Sélection de l'appartement
$selectionAppart = Appartement::findById($appart->id_appart);
$selectionAppart->afficher();
// Suppression de l'appartement
echo "Suppression de l'appartement de la base ... ";
$selectionAppart->delete();
echo "OK<br/>";
// Liste de tous les appartements
listerTout();
function listerTout()
{
    // Liste de tous les appartements
    echo "Liste des appartements disponibles dans la base : <br/>";
    $ListeAppartements = Appartement::findAll();
    foreach ($ListeAppartements as $value) {
        $value->afficher();
    }
 public function displayAppAction()
 {
     // Création de la vue principale
     $this->begin();
     if (isset($_GET["id_app"])) {
         // Création de la vue détaillée de l'appartement
         $id_app = $_GET["id_app"];
         $AppartementView = new AppartementView();
         $this->content = $AppartementView->generateDetailDisplay(Appartement::findById($id_app));
     }
     // Création et affichage de la vue globale
     $this->end();
 }