$idEmploye = htmlentities($_POST['idEmploye']);
$idProjet = htmlentities($_POST['idProjet']);
if (!empty($_POST['nom'])) {
    $nom = htmlentities($_POST['nom']);
    $cin = htmlentities($_POST['cin']);
    $email = htmlentities($_POST['email']);
    $telephone = htmlentities($_POST['telephone']);
    $etatCivile = htmlentities($_POST['etatCivile']);
    $dateDebut = htmlentities($_POST['dateDebut']);
    $dateSortie = htmlentities($_POST['dateSortie']);
    $photo = htmlentities($_POST['photo']);
    if (!empty($_FILES['newPhoto']) and $_FILES['newPhoto']['error'] == 0) {
        $photo = imageProcessing($_FILES['newPhoto'], '/photo_employes_societe/');
    }
    $employe = new EmployeProjet(array('id' => $idEmploye, 'nom' => $nom, 'cin' => $cin, 'etatCivile' => $etatCivile, 'telephone' => $telephone, 'photo' => $photo, 'email' => $email, 'dateDebut' => $dateDebut, 'dateSortie' => $dateSortie));
    $employeManager = new EmployeProjetManager($pdo);
    $employeManager->update($employe);
    $_SESSION['employe-update-success'] = "<strong>Opération valide : </strong>Les informations de l'employé '" . $nom . "' sont modifiées avec succès.";
    $location = "employes-projet.php?idProjet=" . $idProjet;
    if ($param == 2) {
        $location = "employe-projet-profile.php?idEmploye=" . $idEmploye;
    }
    header('Location:../' . $location);
} else {
    $_SESSION['employe-update-error'] = "<strong>Erreur Modification Employé : </strong>Vous devez remplir au moins le champ 'Nom'.";
    $location = "employes-projet.php?idProjet=" . $idProjet;
    if ($param == 2) {
        $location = "employe-societe-profile.php?idEmploye=" . $idEmploye;
    }
    header('Location:../' . $location);
    exit;
{
    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
$idProjet = htmlentities($_POST['idProjet']);
if (!empty($_POST['nom'])) {
    $employeManager = new EmployeProjetManager($pdo);
    $nom = htmlentities($_POST['nom']);
    if ($employeManager->exists($nom)) {
        $_SESSION['employe-add-error'] = "<strong>Erreur Ajout Employé : </strong>Un employé existe déjà avec ce nom : " . $nom . ".";
        header('Location:../employes-projet.php?idProjet=' . $idProjet);
        exit;
    } else {
        $cin = htmlentities($_POST['cin']);
        $email = htmlentities($_POST['email']);
        $telephone = htmlentities($_POST['telephone']);
        $etatCivile = htmlentities($_POST['etatCivile']);
        $email = htmlentities($_POST['email']);
        $dateDebut = htmlentities($_POST['dateDebut']);
        $dateSortie = htmlentities($_POST['dateSortie']);
        $photo = imageProcessing($_FILES['photo'], '/photo_employes_societe/');
        $employe = new EmployeProjet(array('nom' => $nom, 'cin' => $cin, 'etatCivile' => $etatCivile, 'telephone' => $telephone, 'photo' => $photo, 'email' => $email, 'dateDebut' => $dateDebut, 'dateSortie' => $dateSortie, 'idProjet' => $idProjet));
        include 'controller/' . $myClass . '.php';
    }
}
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
    $idProjet = 0;
    $projetManager = new ProjetManager($pdo);
    if (isset($_GET['idProjet']) and $_GET['idProjet'] > 0 and $_GET['idProjet'] <= $projetManager->getLastId()) {
        $idProjet = $_GET['idProjet'];
    }
    $employeManager = new EmployeProjetManager($pdo);
    $employes = "";
    //test the employeSociete object number: if exists get terrain else do nothing
    $employeNumber = $employeManager->getEmployeProjetNumberByIdProjet($idProjet);
    if ($employeNumber != 0) {
        $employeProjetPerPage = 10;
        $pageNumber = ceil($employeNumber / $employeProjetPerPage);
        $p = 1;
        if (isset($_GET['p']) and ($_GET['p'] > 0 and $_GET['p'] <= $pageNumber)) {
            $p = $_GET['p'];
        } else {
            $p = 1;
        }
        $begin = ($p - 1) * $employeProjetPerPage;
        $pagination = paginate('employes-projet.php', '?p=', $pageNumber, $p);
        $employesProjet = $employeManager->getEmployesProjetByIdProjetByLimits($idProjet, $begin, $employeProjetPerPage);
{
    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
if (!empty($_POST['searchOption']) and !empty($_POST['search'])) {
    $testRadio = 0;
    if (isset($_POST['searchOption'])) {
        if ($_POST['searchOption'] == "searchByName") {
            $testRadio = 1;
        } else {
            if ($_POST['searchOption'] == "searchByCIN") {
                $testRadio = 2;
            }
        }
    }
    $recherche = htmlentities($_POST['search']);
    $employeManager = new EmployeProjetManager($pdo);
    $_SESSION['searchEmployeProjetResult'] = $employeManager->getEmployeProjetBySearch($recherche, $testRadio);
    header('Location:../employes-projet-search.php');
} else {
    $_SESSION['employe-search-error'] = "<strong>Erreur Recherche Employé</strong> : Vous devez séléctionner un choix 'Nom' ou 'CIN' \n        et 'Tapez votre recherche'";
    header('Location:../employes-projet-search.php');
}
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/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]-->
<?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'];
$idProjet = $_POST['idProjet'];
$employeManager = new EmployeProjetManager($pdo);
$employeManager->delete($idEmploye);
$_SESSION['employe-delete-success'] = "<strong>Opération valide : </strong>Employé supprimé avec succès.";
header('Location:../employes-projet.php?idProjet=' . $idProjet);