Exemple #1
0
}
spl_autoload_register("classLoad");
include 'config.php';
include 'lib/pagination.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav']) and $_SESSION['userMerlaTrav']->profil() == "admin") {
    //class managers
    $projetManager = new ProjetManager($pdo);
    $caisseDetailsManager = new CaisseDetailsManager($pdo);
    $caisseManager = new CaisseManager($pdo);
    //objects
    $projets = $projetManager->getProjets();
    $idCaisse = $_GET['idCaisse'];
    $entrees = $caisseDetailsManager->getCaisseDetailsByIdCaisse($idCaisse);
    $caisse = $caisseManager->getCaisseById($idCaisse);
    ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8" />
    <title>GELM - Management Application</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/metro.css" rel="stylesheet" />
    <link href="assets/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" />
        $typeOperation = htmlentities($_POST['typeOperation']);
        $montant = htmlentities($_POST['montant']);
        $commentaire = htmlentities($_POST['commentaire']);
        $createdBy = $_SESSION['userMerlaTrav']->login();
        $created = date('Y-m-d');
        //create object
        $caisseDetails = new CaisseDetails(array('dateOperation' => $dateOperation, 'personne' => $personne, 'designation' => $designation, 'projet' => $projet, 'type' => $typeOperation, 'montant' => $montant, 'commentaire' => $commentaire, 'idCaisse' => $idCaisse, 'createdBy' => $createdBy, 'created' => $created));
        //add it to db
        $caisseDetailsManager->add($caisseDetails);
        $actionMessage = "Opération Valide : Caisse Détails Ajoutée avec succès.";
        $typeMessage = "success";
        //add history data to db
        $historyManager = new HistoryManager($pdo);
        $createdBy = $_SESSION['userMerlaTrav']->login();
        $created = date('Y-m-d h:i:s');
        $history = new History(array('action' => "Ajout", 'target' => "Table des détails de caisse", 'description' => "Ajout d'une opération - Caisse : " . $caisseManager->getCaisseById($idCaisse)->nom() . " - Type : " . $typeOperation . " - Montant : " . $montant . " - Projet : " . $projet, 'created' => $created, 'createdBy' => $createdBy));
        //add it to db
        $historyManager->add($history);
    } else {
        $actionMessage = "Erreur Ajout Caisse Détails: Vous devez remplir le champ 'Montant'.";
        $typeMessage = "error";
    }
} else {
    if ($action == "update") {
        $idCaisseDetails = htmlentities($_POST['idCaisseDetails']);
        $caisseDetails = $caisseDetailsManager->getCaisseDetailsById($idCaisseDetails);
        $caisse = $caisseManager->getCaisseById($caisseDetails->idCaisse());
        if (!empty($_POST['montant'])) {
            $dateOperation = htmlentities($_POST['dateOperation']);
            $personne = htmlentities($_POST['personne']);
            $designation = htmlentities($_POST['designation']);