//Action Add Processing Begin //begin process: test the action //Action Add Processing Begin if ($action == "add") { if (!empty($_POST['type'])) { $type = htmlentities($_POST['type']); $dateOperation = htmlentities($_POST['dateOperation']); $montant = htmlentities($_POST['montant']); $societe = htmlentities($_POST['societe']); $designation = htmlentities($_POST['designation']); $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); //create object $charge = new ChargeCommun(array('type' => $type, 'dateOperation' => $dateOperation, 'montant' => $montant, 'societe' => $societe, 'designation' => $designation, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $chargeManager->add($charge); //add history data to db $history = new History(array('action' => "Ajout", 'target' => "Table des charges communs", 'description' => "Ajout d'une charge de type : " . $type . ", le : " . $dateOperation . ", d'un montant de : " . $montant . ", dont la designation est : " . $designation . " - Projet : " . $nomProjet, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $historyManager->add($history); $actionMessage = "<strong>Opération Valide</strong> : Charge Ajouté(e) avec succès."; $typeMessage = "success"; } else { $actionMessage = "<strong>Erreur Ajout Charge</strong> : Vous devez remplir le champ 'type'."; $typeMessage = "error"; } } else { if ($action == "update") { $idCharge = htmlentities($_POST['idCharge']); if (!empty($_POST['type'])) { $type = htmlentities($_POST['type']);
$societe = ""; $montant = htmlentities($_POST['montant']); $dateOperation = htmlentities($_POST['dateOperation']); $dateOperation = DateTime::createFromFormat('d/m/Y', trim($dateOperation)); $dateOperation = $dateOperation->format('Y-m-d'); $designation = htmlentities($_POST['designation']); if ($destinations == "ChargesCommuns") { $chargeCommunManager = new ChargeCommunManager($pdo); $societe = htmlentities($_POST['societe']); $type = htmlentities($_POST['typeChargesCommuns']); $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); //create object $charge = new ChargeCommun(array('type' => $type, 'dateOperation' => $dateOperation, 'montant' => $montant, 'societe' => $societe, 'designation' => $designation, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $chargeCommunManager->add($charge); $releveBancaireManager->hide($idReleveBancaire); } else { if ($destinations == "ChargesProjets") { $chargeManager = new ChargeManager($pdo); $societe = htmlentities($_POST['societe2']); $type = htmlentities($_POST['typeChargesProjet']); $projet = htmlentities($_POST['projet']); $createdBy = $_SESSION['userMerlaTrav']->login(); $created = date('Y-m-d h:i:s'); //create object $charge = new Charge(array('type' => $type, 'dateOperation' => $dateOperation, 'montant' => $montant, 'societe' => $societe, 'designation' => $designation, 'idProjet' => $projet, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $chargeManager->add($charge); $releveBancaireManager->hide($idReleveBancaire); } else {