if (!empty($_POST['code'])) { $code = htmlentities($_POST['code']); $niveau = htmlentities($_POST['niveau']); $prix = htmlentities($_POST['prix']); $superficie = htmlentities($_POST['superficie']); $facade = htmlentities($_POST['facade']); $nombrePiece = htmlentities($_POST['nombrePiece']); $cave = htmlentities($_POST['cave']); $status = htmlentities($_POST['status']); $par = htmlentities($_POST['par']); $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); //create object $appartement = new Appartement(array('nom' => $code, 'niveau' => $niveau, 'prix' => $prix, 'superficie' => $superficie, 'facade' => $facade, 'nombrePiece' => $nombrePiece, 'cave' => $cave, 'idProjet' => $idProjet, 'status' => $status, 'par' => $par, 'createdBy' => $createdBy, 'created' => $created)); //add it to db $appartementManager->add($appartement); //add history data to db $history = new History(array('action' => "Ajout", 'target' => "Table des appartements", 'description' => "Ajouter un appartement", 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Appartement Ajouté avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Ajout Appartement : Vous devez remplir le champ <strong>Nom</strong>."; $typeMessage = "error"; } } else { if ($action == "update") { if (!empty($_POST['code'])) { $id = htmlentities($_POST['idAppartement']); $code = htmlentities($_POST['code']);