<?php

//classes loading begin
function classLoad($myClass)
{
    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
$idEmploye = $_POST['idEmploye'];
$idConge = $_POST['idConge'];
$congeManager = new EmployeProjetCongeManager($pdo);
$congeManager->delete($idConge);
$_SESSION['conge-delete-success'] = "<strong>Opération valide : </strong>Congé supprimé avec succès.";
header('Location:../employe-projet-profile.php?idEmploye=' . $idEmploye);
//classes loading begin
function classLoad($myClass)
{
    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';
include '../lib/image-processing.php';
//classes loading end
session_start();
//post input processing
$idEmploye = htmlentities($_POST['idEmploye']);
if (!empty($_POST['dateDebut']) and !empty($_POST['dateFin'])) {
    $dateDebut = htmlentities($_POST['dateDebut']);
    $dateFin = htmlentities($_POST['dateFin']);
    //create class
    $conge = new EmployeProjetConge(array('dateDebut' => $dateDebut, 'dateFin' => $dateFin, 'idEmploye' => $idEmploye));
    //create class manager
    $congeManager = new EmployeProjetCongeManager($pdo);
    $congeManager->add($conge);
    $_SESSION['conge-add-success'] = "<strong>Opération valide : </strong>Le congé est ajouté avec succès.";
    header('Location:../employe-projet-profile.php?idEmploye=' . $idEmploye);
} else {
    $_SESSION['conge-add-error'] = "<strong>Erreur Ajout Congé : </strong>Vous devez remplir tous les champs.";
    header('Location:../employe-projet-profile.php?idEmploye=' . $idEmploye);
    exit;
}
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") {
    //les sources
    $employeManager = new EmployeProjetManager($pdo);
    $employe = "";
    $idEmploye = 0;
    if (isset($_GET['idEmploye']) and ($_GET['idEmploye'] > 0 and $_GET['idEmploye'] <= $employeManager->getLastId())) {
        $idEmploye = htmlentities($_GET['idEmploye']);
        $employe = $employeManager->getEmployeProjetById($idEmploye);
        $salairesManager = new EmployeProjetSalaireManager($pdo);
        $salaires = $salairesManager->getSalairesByIdEmploye($idEmploye);
        $congesManager = new EmployeProjetCongeManager($pdo);
        $conges = $congesManager->getCongesByIdEmploye($idEmploye);
        $projetManager = new ProjetManager($pdo);
        $projet = $projetManager->getProjetById($employe->idProjet());
    }
    ?>
<!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>ImmoERP - Management Application</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
function classLoad($myClass)
{
    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';
include '../lib/image-processing.php';
//classes loading end
session_start();
//post input processing
$idEmploye = htmlentities($_POST['idEmploye']);
if (!empty($_POST['dateDebut']) and !empty($_POST['dateFin'])) {
    $idConge = htmlentities($_POST['idConge']);
    $dateDebut = htmlentities($_POST['dateDebut']);
    $dateFin = htmlentities($_POST['dateFin']);
    //create class
    $conge = new EmployeProjetConge(array('id' => $idConge, 'dateDebut' => $dateDebut, 'dateFin' => $dateFin));
    //create class manager
    $congeManager = new EmployeProjetCongeManager($pdo);
    $congeManager->update($conge);
    $_SESSION['conge-update-success'] = "<strong>Opération valide : </strong>Les infos du congé sont modifiées avec succès.";
    header('Location:../employe-projet-profile.php?idEmploye=' . $idEmploye);
} else {
    $_SESSION['conge-update-error'] = "<strong>Erreur Modification Congé : </strong>Vous devez remplir tous les champs";
    header('Location:../employe-projet-profile.php?idEmploye=' . $idEmploye);
    exit;
}