include 'config.php';
include 'lib/pagination.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav']) and ($_SESSION['userMerlaTrav']->profil() == "admin" or $_SESSION['userMerlaTrav']->profil() == "consultant")) {
    //les sources
    $idProjet = 0;
    $projetManager = new ProjetManager($pdo);
    $contratEmployeManager = new ContratEmployeManager($pdo);
    $contratDetaislManager = new ContratDetailsManager($pdo);
    $employesManager = new EmployeManager($pdo);
    if (isset($_GET['idContratEmploye']) and $_GET['idContratEmploye'] > 0 and $_GET['idContratEmploye'] <= $contratEmployeManager->getLastId()) {
        $idProjet = $_GET['idProjet'];
        $idContratEmploye = $_GET['idContratEmploye'];
        $projet = $projetManager->getProjetById($idProjet);
        $contratEmploye = $contratEmployeManager->getContratEmployeById($idContratEmploye);
        $contratDetails = $contratDetaislManager->getContratDetailsByIdContratEmploye($idContratEmploye);
        $totalPaye = $contratDetaislManager->getContratDetailsTotalByIdContratEmploye($idContratEmploye);
        ?>
<!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" />
    <meta content="" name="author" />
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
}
spl_autoload_register("classLoad");
include '../config.php';
include '../lib/image-processing.php';
require_once '../lib/tcpdf/tcpdf.php';
//classes loading end
session_start();
//classes managers
$contratEmployeManager = new ContratEmployeManager($pdo);
$companyManager = new CompanyManager($pdo);
$clientManager = new ClientManager($pdo);
$projetManager = new ProjetManager($pdo);
$employeManager = new EmployeManager($pdo);
//classes
$idContrat = $_GET['idContratEmploye'];
$contrat = $contratEmployeManager->getContratEmployeById($idContrat);
$projet = $projetManager->getProjetById($contrat->idProjet());
$employe = $employeManager->getEmployeById($contrat->employe());
//choix unité en arabe selon la valeur de l'unité
$unite = "";
if ($contrat->unite() == "m²") {
    $unite = "المتر المربع";
} else {
    if ($contrat->unite() == "m lineaire") {
        $unite = "المتر الخطي";
    } else {
        if ($contrat->unite() == "appartement") {
            $unite = "الشقة";
        } else {
            if ($contrat->unite() == "unite") {
                $unite = $contrat->nomUniteArabe();
if (isset($_SESSION['userMerlaTrav'])) {
    //classes managers
    $idProjet = 0;
    $projetManager = new ProjetManager($pdo);
    $contratEmployeManager = new ContratEmployeManager($pdo);
    $contratDetaislManager = new ContratDetailsManager($pdo);
    $employesManager = new EmployeManager($pdo);
    $contratDetails = "";
    if (isset($_GET['idContratDetail']) and $_GET['idContratDetail'] > 0 and $_GET['idContratDetail'] <= $contratDetaislManager->getLastId()) {
        $idProjet = $_GET['idProjet'];
        $idContratDetail = $_GET['idContratDetail'];
        $projet = $projetManager->getProjetById($idProjet);
        //$contratEmploye = $contratEmployeManager->getContratEmployeById($idContratEmploye);
        //$contratDetails = $contratDetaislManager->getContratDetailsByIdContratEmploye($idContratEmploye);
        $contratDetails = $contratDetaislManager->getContratDetailsById($idContratDetail);
        $contrat = $contratEmployeManager->getContratEmployeById($contratDetails->idContratEmploye());
        $employe = $employesManager->getEmployeById($contrat->employe());
        //$totalPaye = $contratDetaislManager->getContratDetailsTotalByIdContratEmploye($idContratEmploye);
    }
    ob_start();
    ?>
<style type="text/css">
    p, h1, h3{
        text-align: center;
        text-decoration: underline;
    }
    table {
            border-collapse: collapse;
            width:100%;
        }