$created = date('Y-m-d h:i:s'); $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);
$createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Modification", 'target' => "Table des locaux commerciaux", 'description' => "Modifier un local commercial", 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Local Commercial Modifié avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Modification Local Commercial : Vous devez remplir le champ <strong>Code</strong>."; $typeMessage = "error"; } } else { if ($action == "updateStatus") { $idLocaux = $_POST['idLocaux']; $status = htmlentities($_POST['status']); $locauxManager->changeStatus($idLocaux, $status); //add History data $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); $history = new History(array('action' => "Modification Status", 'target' => "Table des locaux commerciaux", 'description' => "Modifier le status d'un local commercial", 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : Local Commercial Status Modifié avec succès."; $typeMessage = "success"; } else { if ($action == "updateClient") { $idLocaux = $_POST['idLocaux']; $par = htmlentities($_POST['par']); $locauxManager->updatePar($par, $idLocaux); //add History data $createdBy = $_SESSION['userMerlaTrav']->login();
if (file_exists('../model/' . $myClass . '.php')) { include '../model/' . $myClass . '.php'; } elseif (file_exists('../controller/' . $myClass . '.php')) { include '../controller/' . $myClass . '.php'; } } spl_autoload_register("classLoad"); include '../config.php'; //classes loading end session_start(); //post input processing $idProjet = $_POST['idProjet']; $idContrat = $_POST['idContrat']; $contratManager = new ContratManager($pdo); $contrat = $contratManager->getContratById($idContrat); $contratManager->delete($idContrat); if ($contrat->typeBien() == "appartement") { $appartementManager = new AppartementManager($pdo); $appartementManager->changeStatus($contrat->idBien(), "Non"); } else { if ($contrat->typeBien() == "localCommercial") { $locauxManager = new LocauxManager($pdo); $locauxManager->changeStatus($contrat->idBien(), "Non"); } } $_SESSION['contrat-delete-success'] = "<strong>Opération valide : </strong>Contrat supprimé avec succès."; $redirectLink = 'Location:../contrats-list.php?idProjet=' . $idProjet; if (isset($_GET['p']) and $_GET['p'] == 99) { $redirectLink = 'Location:../clients-search.php'; } header($redirectLink);
include '../controller/' . $myClass . '.php'; } } spl_autoload_register("classLoad"); include '../config.php'; //classes loading end session_start(); //post input processing $idProjet = $_POST['idProjet']; $idContrat = $_POST['idContrat']; //create classes managers $locauxManager = new LocauxManager($pdo); $contratManager = new ContratManager($pdo); $appartementManager = new AppartementManager($pdo); //create classes $contrat = $contratManager->getContratById($idContrat); //change status of the old contrat Bien from reservé to non reservé if ($contrat->typeBien() == "appartement") { $appartementManager->changeStatus($contrat->idBien(), "Disponible"); } else { if ($contrat->typeBien() == "localCommercial") { $locauxManager->changeStatus($contrat->idBien(), "Disponible"); } } $contratManager->desisterContrat($idContrat); $_SESSION['contrat-desister-success'] = "<strong>Opération valide : </strong>Le contrat est désisté avec succès."; $redirectLink = 'Location:../contrats-list.php?idProjet=' . $idProjet; if (isset($_GET['p']) and $_GET['p'] == 99) { $redirectLink = 'Location:../clients-search.php'; } header($redirectLink);