$terrain = new Terrain(array('id' => $id, 'vendeur' => $vendeur, 'prix' => $prix, 'superficie' => $superficie, 'fraisAchat' => $fraisAchat, 'emplacement' => $emplacement, 'idProjet' => $idProjet, 'updated' => $updated, 'updatedBy' => $updatedBy)); $terrainManager->update($terrain); //Add To History Table $history = new History(array('action' => "Modification", 'target' => "Table des terrains", 'description' => "Modification du terrain: " . $emplacement . " - Projet : " . $nomProjet, 'created' => $updated, 'createdBy' => $updatedBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Terrain Modifié avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Modification Terrain : Vous devez remplir le champ <strong>Prix</strong>."; $typeMessage = "error"; } } else { if ($action == "delete") { $idTerrain = $_POST['idTerrain']; $emplacementTerrain = $terrainManager->getTerrainById($idTerrain)->emplacement(); $terrainManager->delete($idTerrain); //add history data to db $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Suppression", 'target' => "Table des terrain", 'description' => "Suppression du terrain " . $emplacementTerrain . " - Projet : " . $nomProjet, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Terrain Supprimé avec succès."; $typeMessage = "success"; } } } $_SESSION['terrain-action-message'] = $actionMessage; $_SESSION['terrain-type-message'] = $typeMessage; header('Location:../terrain.php?idProjet=' . $idProjet);
$id = htmlentities($_POST['id']); if (htmlentities($_POST['typeImmobiliere']) == "appartement") { $appartementManager = new AppartementManager($pdo); $appartementManager->delete($id); } else { if (htmlentities($_POST['typeImmobiliere']) == "local") { $locauxManager = new LocauxManager($pdo); $locauxManager->delete($id); } else { if (htmlentities($_POST['typeImmobiliere']) == "maison") { $maisonManager = new MaisonManager($pdo); $maisonManager->delete($id); } else { if (htmlentities($_POST['typeImmobiliere']) == "terrain") { $terrainManager = new TerrainManager($pdo); $terrainManager->delete($id); } } } } //add history data to db $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Suppression", 'target' => "Table des " . htmlentities($_POST['typeImmobiliere']), 'description' => "Suppression de " . htmlentities($_POST['typeImmobiliere']) . " - ID : " . $id . " - Projet : " . $projetManager->getProjetById($idProjet)->nom(), 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $_SESSION['bien-delete-success'] = '<strong>Opération valide</strong> : Le Bien Immobilière est supprimé avec succès !'; $redirectLink = 'Location:../projet-biens.php?idProjet=' . $idProjet . '&type=' . $type . '&idSociete=' . $idSociete; header($redirectLink); } else { header('Location:../projet-biens.php?idProjet=' . $idProjet . '&type=' . $type . '&idSociete=' . $idSociete);