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();
    }
}
 /**
  * Affiche la liste des appartements, sans filtres
  * @param type $tab
  * @return type
  */
 public function displayList()
 {
     $list = array();
     foreach (Appartement::findAll() as $flat) {
         $appart = new Appartement();
         //ajouter attributs
         $list[] = $appart;
     }
     $rep = AppartementVue::generateListDisplay($list);
     return $rep;
 }
    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 function update(Appartement $appartement)
    {
        $query = $this->_db->prepare('
		UPDATE t_appartement SET nom=:nom, superficie=:superficie, prix=:prix, niveau=:niveau, facade=:facade, 
		nombrePiece=:nombrePiece, status=:status, cave=:cave, par=:par, updated=:updated,
		updatedBy=:updatedBy WHERE id=:idAppartement') or die(print_r($this->_db->errorInfo()));
        $query->bindValue(':idAppartement', $appartement->id());
        $query->bindValue(':nom', $appartement->nom());
        $query->bindValue(':superficie', $appartement->superficie());
        $query->bindValue(':facade', $appartement->facade());
        $query->bindValue(':prix', $appartement->prix());
        $query->bindValue(':niveau', $appartement->niveau());
        $query->bindValue(':nombrePiece', $appartement->nombrePiece());
        $query->bindValue(':cave', $appartement->cave());
        $query->bindValue(':status', $appartement->status());
        $query->bindValue(':par', $appartement->par());
        $query->bindValue(':updated', $appartement->updated());
        $query->bindValue(':updatedBy', $appartement->updatedBy());
        $query->execute();
        $query->closeCursor();
    }
    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;
    }
 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();
 }
Example #7
0
    public function update(Appartement $appartement)
    {
        $query = $this->_db->prepare(' UPDATE t_appartement SET 
		numeroTitre=:numeroTitre,nom=:nom,superficie=:superficie,surplan=:surplan,prix=:prix,
		niveau=:niveau,facade=:facade,nombrePiece=:nombrePiece,cave=:cave WHERE id=:id') or die(print_r($this->_db->errorInfo()));
        $query->bindValue(':id', $appartement->id());
        $query->bindValue(':numeroTitre', $appartement->numeroTitre());
        $query->bindValue(':nom', $appartement->nom());
        $query->bindValue(':superficie', $appartement->superficie());
        $query->bindValue(':surplan', $appartement->surplan());
        $query->bindValue(':prix', $appartement->prix());
        $query->bindValue(':niveau', $appartement->niveau());
        $query->bindValue(':facade', $appartement->facade());
        $query->bindValue(':nombrePiece', $appartement->nombrePiece());
        $query->bindValue(':cave', $appartement->cave());
        $query->execute();
        $query->closeCursor();
    }