$contratCasLibreManager = new ContratCasLibreManager($pdo); //The History Component is used in all ActionControllers to mention a historical version of each action $historyManager = new HistoryManager($pdo); //Action Add Processing Begin if ($action == "add") { if (!empty($_POST['date'])) { $date = htmlentities($_POST['date']); $montant = htmlentities($_POST['montant']); $observation = htmlentities($_POST['observation']); $codeContrat = htmlentities($_POST['codeContrat']); $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); //create object $contratCasLibre = new ContratCasLibre(array('date' => $date, 'montant' => $montant, 'observation' => $observation, 'codeContrat' => $codeContrat, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $contratCasLibreManager->add($contratCasLibre); //add history data to db $history = new History(array('action' => "Ajout", 'target' => "Table des cas libres (contratcaslibre)", 'description' => "Ajouter la liste des cas libres au contrat", 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "Opération Valide : ContratCasLibre Ajouté(e) avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Ajout contratCasLibre : Vous devez remplir le champ 'date'."; $typeMessage = "error"; } } else { if ($action == "update") { $idContratCasLibre = htmlentities($_POST['idContratCasLibre']); if (!empty($_POST['date'])) { $date = htmlentities($_POST['date']);
//CAS LIBRE PROCESSING BEGIN if (isset($_POST['show-cas-libre'])) { $dates = array(); $montants = array(); $observations = array(); for ($i = 1; $i < 7; $i++) { if (isset($_POST['cas-libre-date' . $i])) { $dates[$i] = htmlentities($_POST['cas-libre-date' . $i]); } if (isset($_POST['cas-libre-montant' . $i])) { $montants[$i] = htmlentities($_POST['cas-libre-montant' . $i]); } if (isset($_POST['cas-libre-observation' . $i])) { $observations[$i] = htmlentities($_POST['cas-libre-observation' . $i]); } $contratCasLibreManager->add(new ContratCasLibre(array('date' => $dates[$i], 'montant' => $montants[$i], 'observation' => $observations[$i], 'status' => 0, 'codeContrat' => $codeContrat, 'created' => $created, 'createdBy' => $createdBy))); } } //else we have to put here our datePrevu processing //CAS LIBRE PROCESSING END //create the contract object $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)); //adding the contract object to our database $contratManager->add($contrat); //add history data to db $history = new History(array('action' => "Ajout", 'target' => "Table des contrats", 'description' => "Ajouter un contrat", 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); //in the next if elseif statement, we test the type of the property to change its status //and its price if ($typeBien == "appartement") {