$createdBy = $_SESSION['userMerlaTrav']->login(); $numeroCheque = '0'; if (isset($_POST['numeroCheque'])) { $numeroCheque = htmlentities($_POST['numeroCheque']); } $contratManager = new ContratManager($pdo); $contrat = new Contrat(array('numero' => $numero, 'dateCreation' => $dateCreation, 'prixVente' => $prixNegocie, 'avance' => $avance, 'modePaiement' => $modePaiement, 'dureePaiement' => $dureePaiement, 'nombreMois' => $nombreMois, 'echeance' => $echeance, 'note' => $note, 'idClient' => $idClient, 'idProjet' => $idProjet, 'idBien' => $idBien, 'typeBien' => $typeBien, 'code' => $codeContrat, 'numeroCheque' => $numeroCheque, 'created' => $created, 'createdBy' => $createdBy)); $contratManager->add($contrat); if ($typeBien == "appartement") { $appartementManager = new AppartementManager($pdo); $appartementManager->changeStatus($idBien, "Vendu"); } else { if ($typeBien == "localCommercial") { $locauxManager = new LocauxManager($pdo); $locauxManager->changeStatus($idBien, "Vendu"); } } //add note client into db and show it in the dashboard $notesClientManager = new NotesClientManager($pdo); $notesClient = new NotesClient(array('note' => $note, 'created' => date('Y-m-d'), 'idProjet' => $idProjet, 'codeContrat' => $codeContrat)); $notesClientManager->add($notesClient); header('Location:../contrat.php?codeContrat=' . $codeContrat); } else { $_SESSION['contrat-add-error'] = "<strong>Erreur Création Contrat : </strong>Vous devez choisir un 'Type de bien'."; header('Location:../contrats-add.php?idProjet=' . $idProjet . '&codeClient=' . $codeClient); exit; } } else { $_SESSION['contrat-add-error'] = "<strong>Erreur Création Contrat : </strong>Vous devez remplir le champ <strong>Nom</strong>."; header('Location:../contrats-add.php?idProjet=' . $idProjet . '&codeClient=' . $codeClient); }