$terrainManager = new TerrainManager($pdo); $maisonManager = new MaisonManager($pdo); $locauxManager = new LocauxManager($pdo); $biens = ""; $idContrat = 0; if (isset($_GET['idContrat']) and ($_GET['idContrat'] > 0 and $_GET['idContrat'] <= $contratManager->getLastId())) { $idContrat = $_GET['idContrat']; } else { header('Location:../dashboard.php'); exit; } $contrat = $contratManager->getContratById($idContrat); $projet = $projetManager->getProjetById($contrat->idProjet()); $typeBien = ""; if ($contrat->typeBien() == "appartement") { $biens = $appartementManager->getAppartementById($contrat->idBien()); $typeBien = "Appartement"; } else { if ($contrat->typeBien() == "localCommercial") { $biens = $locauxManager->getLocauxById($contrat->idBien()); $typeBien = "Local Commercial"; } else { if ($contrat->typeBien() == "maison") { $biens = $maisonManager->getMaisonById($contrat->idBien()); $typeBien = "Maison"; } else { if ($contrat->typeBien() == "terrain") { $biens = $terrainManager->getTerrainById($contrat->idBien()); $typeBien = "Terrain"; } }
$createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Modification", 'target' => "Table des appartements", 'description' => "Modification de l'appartement : " . $code . " - Projet : " . $nomProjet, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Appartement Modifié avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Modification Appartement : Vous devez remplir le champ <strong>Code</strong>."; $typeMessage = "error"; } } else { if ($action == "updateStatus") { $idAppartement = $_POST['idAppartement']; $status = htmlentities($_POST['status']); $nomAppartement = $appartementManager->getAppartementById($idAppartement)->nom(); $appartementManager->changeStatus($idAppartement, $status); //add history data to db $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Modification Status", 'target' => "Table des appartements", 'description' => "Changement de status de l'appartement " . $nomAppartement . " vers le status : " . $status . " - Projet : " . $nomProjet, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Appartement Status Modifié avec succès."; $typeMessage = "success"; } else { if ($action == "updateClient") { $idAppartement = $_POST['idAppartement']; $par = htmlentities($_POST['par']); $nomAppartement = $appartementManager->getAppartementById($idAppartement)->nom(); $appartementManager->updatePar($par, $idAppartement);
$idContrat = $_POST['idContrat']; $status = $_POST['status']; //create classes managers $contratManager = new ContratManager($pdo); $locauxManager = new LocauxManager($pdo); $appartementManager = new AppartementManager($pdo); $maisonManager = new MaisonManager($pdo); $terrainManager = new TerrainManager($pdo); //create classes $contrat = $contratManager->getContratById($idContrat); $redirectLink = 'Location:../contrats-list.php?idProjet=' . $idProjet . '&idSociete=' . $idSociete; if (isset($_GET['p']) and $_GET['p'] == 99) { $redirectLink = 'Location:../clients-search.php'; } if ($contrat->typeBien() == "appartement") { if ($appartementManager->getAppartementById($contrat->idBien())->status() == "Disponible") { $appartementManager->updateStatus($status, $contrat->idBien()); $contratManager->activerContrat($idContrat); $_SESSION['contrat-activation-success'] = "<strong>Opération valide : </strong>Le contrat est activé avec succès."; header($redirectLink); exit; } else { $_SESSION['contrat-activation-error'] = "<strong>Erreur Activation Contrat : </strong>Le bien est déjà réservé par un autre client."; header($redirectLink); exit; } } else { if ($contrat->typeBien() == "localCommercial") { if ($locauxManager->getLocauxById($contrat->idBien())->status() == "Disponible") { $locauxManager->updateStatus($status, $contrat->idBien()); $contratManager->activerContrat($idContrat);
spl_autoload_register("classLoad"); include 'config.php'; include 'lib/pagination.php'; //classes loading end session_start(); if (isset($_SESSION['userMerlaTrav'])) { //les sources $projetManager = new ProjetManager($pdo); $appartementManager = new AppartementManager($pdo); $appartement = ""; $idAppartement = 0; $idProjet = $_GET['idProjet']; $projet = $projetManager->getProjetById($idProjet); if (isset($_GET['idAppartement']) and ($_GET['idAppartement'] > 0 and $_GET['idAppartement'] <= $appartementManager->getLastId())) { $idAppartement = htmlentities($_GET['idAppartement']); $appartement = $appartementManager->getAppartementById($idAppartement); $piecesManager = new AppartementPiecesManager($pdo); $piecesNumber = $piecesManager->getPiecesAppartementNumberByIdAppartement($idAppartement); if ($piecesNumber != 0) { $piecesAppartement = $piecesManager->getPiecesAppartementByIdAppartement($idAppartement); } } ?> <!DOCTYPE html> <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> <!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> <!-- BEGIN HEAD --> <head> <meta charset="utf-8" /> <title>ImmoERP - Management Application</title>
session_start(); //post input processing $idProjet = $_POST['idProjet']; $idContrat = $_POST['idContrat']; //create classes managers $contratManager = new ContratManager($pdo); $locauxManager = new LocauxManager($pdo); $appartementManager = new AppartementManager($pdo); //create classes $contrat = $contratManager->getContratById($idContrat); $redirectLink = 'Location:../contrats-list.php?idProjet=' . $idProjet; if (isset($_GET['p']) and $_GET['p'] == 99) { $redirectLink = 'Location:../clients-search.php'; } if ($contrat->typeBien() == "appartement") { if ($appartementManager->getAppartementById($contrat->idBien())->status() == "Non") { $appartementManager->changeStatus($contrat->idBien(), "Vendu"); $contratManager->activerContrat($idContrat); $_SESSION['contrat-activation-success'] = "<strong>Opération valide : </strong>Le contrat est activé avec succès."; header($redirectLink); exit; } else { $_SESSION['contrat-activation-error'] = "<strong>Erreur Activation Contrat : </strong>Le bien est déjà réservé par un autre client."; header($redirectLink); exit; } } else { if ($contrat->typeBien() == "localCommercial") { if ($locauxManager->getLocauxById($contrat->idBien())->status() == "Non") { $locauxManager->changeStatus($contrat->idBien(), "Vendu"); $contratManager->activerContrat($idContrat);
$nomBien = ""; $typeBien = ""; if ($contrat->typeBien() == "maison") { $maisonManager = new MaisonManager($pdo); $typeBien = "Maison"; $nomBien = $maisonManager->getMaisonById($contrat->idBien())->nom(); } else { if ($contrat->typeBien() == "localCommercial") { $locauxManager = new LocauxManager($pdo); $typeBien = "Local Commercial"; $nomBien = $locauxManager->getLocauxById($contrat->idBien())->nom(); } else { if ($contrat->typeBien() == "appartement") { $appartementManager = new AppartementManager($pdo); $typeBien = "Appartement"; $nomBien = $appartementManager->getAppartementById($contrat->idBien())->nom(); } else { if ($contrat->typeBien() == "terrain") { $terrainManager = new TerrainManager($pdo); $typeBien = "Terrain"; $nomBien = $terrainManager->getTerrainById($contrat->idBien())->nom(); } } } } ?> <li> <div class="col1"> <div class="cont"> <div class="cont-col1"> <div class="label label-success">
<th style="width: 10%">Date Création</th> <th style="width: 10%">Date Retour</th> <th style="width: 10%">Status</th> </tr> </thead> <tbody> <?php foreach ($contratsEnCours as $element) { $projet = $projetManager->getProjetById($element->idProjet()); $bien = ""; $typeBien = ""; //if the property is a "Local commercial" we don't need to mention niveau attribute $niveau = ""; if ($element->typeBien() == "appartement") { $appartementManager = new AppartementManager($pdo); $bien = $appartementManager->getAppartementById($element->idBien()); $niveau = $bien->niveau(); $typeBien = "Appartement"; } else { if ($element->typeBien() == "localCommercial") { $locauxManager = new LocauxManager($pdo); $bien = $locauxManager->getLocauxById($element->idBien()); $typeBien = "Local Commercial"; } else { if ($element->typeBien() == "maison") { $maisonManager = new MaisonManager($pdo); $bien = $maisonManager->getMaisonById($element->idBien()); $typeBien = "Maison"; } else { if ($element->typeBien() == "terrain") { $terrainManager = new TerrainManager($pdo);
//try{ //$bdd = new PDO('mysql:host=localhost;dbname=maroccar', 'root', ''); //} //catch(Exception $e){ //exit('Impossible de se connecter à la base de données.'); //} // exécution de la requête $resultat = $pdo->query($requete) or die(print_r($bdd->errorInfo())); // résultats $res = '<option value="">Vous pouvez séléctionnez un contrat</option>'; echo $res; while ( $contrat = $resultat->fetch(PDO::FETCH_ASSOC)) { $client = $clientManager->getClientById($contrat['idClient']); $typeBien = ""; $bien = ""; $etage = ""; if ( $contrat['typeBien'] == "appartement" ) { $typeBien = "Appartement"; $bien = $appartementManager->getAppartementById($contrat['idBien']); $etage = "Etage : ".$bien->niveau(); } else { $typeBien = "Local.Com"; $bien = $locauxManager->getLocauxById($contrat['idBien']); } $res = '<option value="'.$contrat['id'].'">'.$client->nom().' - '.$projet->nom().' - '.$typeBien.' : '.$bien->nom().' - '.$etage.'</option>'; echo $res; } } ?>