$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']);
            $montant = htmlentities($_POST['montant']);
            $observation = htmlentities($_POST['observation']);
            $updatedBy = $_SESSION['userMerlaTrav']->login();
            $updated = date('Y-m-d h:i:s');
            $contratCasLibre = new ContratCasLibre(array('id' => $idContratCasLibre, 'date' => $date, 'montant' => $montant, 'observation' => $observation, 'updated' => $updated, 'updatedBy' => $updatedBy));
            $contratCasLibreManager->update($contratCasLibre);
            //add history data to db
            $createdBy = $_SESSION['userMerlaTrav']->login();
            $created = date('Y-m-d h:i:s');
            $history = new History(array('action' => "Ajout", 'target' => "Table des cas libres (contratcaslibre)", 'description' => "Modifier un cas libre contrat", 'created' => $created, 'createdBy' => $createdBy));
            //add it to db
            $historyManager->add($history);
            $actionMessage = "Opération Valide : ContratCasLibre Modifié(e) avec succès.";
            $typeMessage = "success";
        } else {
            $actionMessage = "Erreur Modification ContratCasLibre : Vous devez remplir le champ 'date'.";
            $typeMessage = "error";
        }
        $codeContrat = htmlentities($_POST['codeContrat']);
        $idProjet = htmlentities($_POST['idProjet']);
        $redirectLink = "Location:../contrat.php?codeContrat=" . $codeContrat . '&idProjet=' . $idProjet . '#contratCasLibre';