include '../config.php'; //classes loading end session_start(); if (isset($_SESSION['userMerlaTrav']) and $_SESSION['userMerlaTrav']->profil() == "admin") { //classes managers $clientManager = new ClientManager($pdo); $contratManager = new ContratManager($pdo); $projetManager = new ProjetManager($pdo); $operationManager = new OperationManager($pdo); $appartementManager = new AppartementManager($pdo); $locauxManager = new LocauxManager($pdo); //classes and attributes $bien = ""; $idOperation = $_GET['idOperation']; $operation = $operationManager->getOperationById($idOperation); $contrat = $contratManager->getContratById($operation->idContrat()); $client = $clientManager->getClientById($contrat->idClient()); $projet = $projetManager->getProjetById($contrat->idProjet()); $typeBien = ""; $etage = ""; $expressionOrthographe = ""; if ($contrat->typeBien() == "appartement") { $bien = $appartementManager->getAppartementById($contrat->idBien()); $typeBien = "Appartement"; $etage = "en " . $bien->niveau(); $expressionOrthographe = "de l'"; } else { if ($contrat->typeBien() == "localCommercial") { $bien = $locauxManager->getLocauxById($contrat->idBien()); $typeBien = "Local commercial"; $expressionOrthographe = "du";
if (isset($_SESSION['userMerlaTrav']) and $_SESSION['userMerlaTrav']->profil() == "admin") { $contratManager = new ContratManager($pdo); $projetManager = new ProjetManager($pdo); $appartementManager = new AppartementManager($pdo); $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") {
$projet = $projetManager->getProjetById($idProjet); //Container 1 : Statistiques $chiffreAffaireTheorique = ceil( $appartementManager->getTotalPrixAppartementsByIdProjet($idProjet) + $locauxManager->getTotalPrixLocauxByIdProjet($idProjet) ); //get contacts ids and get sum of client operations $idsContrats = $contratManager->getContratActifIdsByIdProjet($idProjet); $sommeOperationsClients = 0; $sommePrixVente = 0; foreach($idsContrats as $id){ $sommeOperationsClients += $operationsManager->sommeOperations($id); $sommePrixVente += $contratManager->getContratById($id)->prixVente(); } $sommeApportsClients = ($sommeOperationsClients); $reliquat = $sommePrixVente - $sommeOperationsClients; $sommeCharges = $chargeCommunManager->getTotal() + $chargeManager->getTotalByIdProjet($idProjet); $sommeCharges = ceil($sommeCharges); //Container 2 : Statistiques $sommeLivraisons = 0; $idsLivraisons = $livraisonsManager->getLivraisonIdsByIdProjet($idProjet); foreach ( $idsLivraisons as $id ) { $sommeLivraisons += $livraisonDetailManager->getTotalLivraisonByIdLivraison($id); } $sommeReglements = ceil($reglementsFournisseurManager->sommeReglementFournisseurByIdProjet($_GET['idProjet'])); $sommeLivraison = ceil($livraisonsManager->getTotalLivraisonsIdProjet($_GET['idProjet']));