<?php

define("LIBERATIONSWEB", 20091223);

session_start();

//Librairie de fonctions
require (__DIR__ . '/vendor/autoload.php');
require_once("lib/libconfig.inc.php");
require_once("lib/libsession.inc.php");
require_once("lib/libfonctions.inc.php");
require_once("lib/libmysql.inc.php");
require_once("lib/libencode.inc.php");
require_once("lib/libcourriel.inc.php");
require_once("lib/libcentrale.inc.php");
require_once("fpdf/fpdf.php");

//Validation du numéro de la libération
$nolib2 = filter_input(INPUT_GET, "lib");
if ($nolib2 == -1 || !is_numeric($nolib2)) {
    die("Erreur A");
}
$nolib = antiInjection($nolib2);

//Validation de la sortie (écran,courriel ou impression) de la libération)
$verssortie = filter_input(INPUT_GET, "sortie");
if ($verssortie != "ecran" && $verssortie != "courriel" && $verssortie != "impression" && $verssortie != "web") {
    die("Erreur B");
}

class PDF extends FPDF {

    var $NomContact;
    var $Dept;
    var $NomEmployeur;
    var $EmployeursAdresse1;
    var $EmployeursVille;
    var $EmployeursCodePostal;
    var $DateDemande;
    var $NumEmploye;
    var $NomEmploye;
    var $EmployeAdresse1;
    var $EmployeAdresse2;
    var $Ville;
    var $Operation;
    var $Dateliberation;
    var $javascript;
    var $Presentation;
    var $n_js;
    var $syndicatnom;
    var $configCentrale;

    function WordWrap(&$text, $maxwidth) {
        $text = trim($text);
        if ($text === '')
            return 0;
        $space = $this->GetStringWidth(' ');
        $lines = explode("\n", $text);
        $text = '';
        $count = 0;

        foreach ($lines as $line) {
            $words = preg_split('/ +/', $line);
            $width = 0;

            foreach ($words as $word) {
                $wordwidth = $this->GetStringWidth($word);
                if ($wordwidth > $maxwidth) {
                    // Word is too long, we cut it
                    for ($i = 0; $i < strlen($word); $i++) {
                        $wordwidth = $this->GetStringWidth(substr($word, $i, 1));
                        if ($width + $wordwidth <= $maxwidth) {
                            $width += $wordwidth;
                            $text .= substr($word, $i, 1);
                        } else {
                            $width = $wordwidth;
                            $text = rtrim($text) . "\n" . substr($word, $i, 1);
                            $count++;
                        }
                    }
                } elseif ($width + $wordwidth <= $maxwidth) {
                    $width += $wordwidth + $space;
                    $text .= $word . ' ';
                } else {
                    $width = $wordwidth + $space;
                    $text = rtrim($text) . "\n" . $word . ' ';
                    $count++;
                }
            }
            $text = rtrim($text) . "\n";
            $count++;
        }
        $text = rtrim($text);
        return $count;
    }

    //Entête de page
    function Header() {
        $Image41 = 'logo/' . $_SESSION["syndicat"] . "." . $_SESSION['logo'];
        $this->Image($Image41, 139, 25, 47, 22);

        //Employeur
        $x1 = 119;
        $x2 = 159;
        $x3 = 160;

        //Employeur
        $this->SetXY($x1, 54);
        $this->SetFont('Times', 'BU', 11);
        $etiquette64 = "Employeur";
        $this->Cell(52, 6, $etiquette64, 0, 0, 'L');

        $this->SetXY($x1, 60);
        $this->SetFont('Times', '', 11);
        $this->Cell(70, 5, mb_convert_encoding($this->NomContact, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY($x1, 65);
        $this->SetFont('Times', '', 11);
        $this->Cell(91, 5, mb_convert_encoding($this->Dept, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY($x1, 70);
        $this->SetFont('Times', '', 11);
        $this->Cell(91, 5, mb_convert_encoding($this->NomEmployeur, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY($x1, 75);
        $this->SetFont('Times', '', 11);
        $this->Cell(91, 5, mb_convert_encoding($this->EmployeursAdresse1, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY($x1, 80);
        $this->SetFont('Times', '', 11);
        $this->Cell(37, 5, mb_convert_encoding($this->EmployeursVille, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY($x2, 80);
        $this->SetFont('Times', '', 11);
        $this->Cell(30, 5, $this->EmployeursCodePostal, 0, 0, 'L');

        $this->SetXY($x3, 90);
        $this->SetFont('Times', '', 11);
        $this->Cell(28, 5, $this->DateDemande, 0, 0, 'L');

        //étiquette de détail
        $this->SetXY(119, 90);
        $this->SetFont('Times', 'B', 11);
        $DateDemande_etiquette = "Date de la demande :";
        $this->Cell(28, 5, $DateDemande_etiquette, 0, 0, 'L');

        $this->SetXY(25, 90);
        $this->SetFont('Times', 'B', 11);
        $etiquette46 = mb_convert_encoding("LA(LES) LIBÉRATION(S) SYNDICALE(S)", 'ISO-8859-1', 'UTF-8');
        $this->Cell(67, 6, $etiquette46, 0, 0, 'L');

        $this->SetXY(25, 95);
        $this->SetFont('Times', 'BU', 11);
        $etiquette56 = "DATE(S)";
        $this->Cell(16, 6, $etiquette56, 0, 0, 'L');

        $this->SetXY(64, 95);
        $this->SetFont('Times', 'BU', 11);
        $etiquette57 = "ARTICLE";
        $this->Cell(20, 6, $etiquette57, 0, 0, 'L');

        $this->SetXY(46, 95);
        $this->SetFont('Times', 'BU', 11);
        $etiquette59 = mb_convert_encoding("DURÉE", 'ISO-8859-1', 'UTF-8');
        $this->Cell(16, 6, $etiquette59, 0, 0, 'L');

        $this->SetXY(86, 95);
        $this->SetFont('Times', 'BU', 11);
        $etiquette71 = "LIEU";
        $this->Cell(20, 6, $etiquette71, 0, 0, 'L');

        $this->SetXY(119, 95);
        $this->SetFont('Times', 'BU', 11);
        $etiquette58 = "COMMENTAIRES";
        $this->Cell(29, 6, $etiquette58, 0, 0, 'L');

        //Employé
        $this->SetXY(25, 54);
        $this->SetFont('Times', 'BU', 11);
        $etiquette65 = mb_convert_encoding("Employé", 'ISO-8859-1', 'UTF-8');
        if ($this->Presentation == "Madame") {
            $etiquette65 .= "e";
        }
        $this->Cell(52, 6, $etiquette65, 0, 0, 'L');

        //Employé
        $this->SetXY(25, 60);
        $this->SetFont('Times', '', 11);
        $this->Cell(60, 5, mb_convert_encoding($this->NomEmploye, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY(25, 65);
        $this->SetFont('Times', '', 11);
        $this->Cell(60, 5, mb_convert_encoding($this->EmployeAdresse1, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        unset($y);
        $y = 0;

        $this->SetXY(25, 70 + $y);
        $this->SetFont('Times', '', 11);
        $this->Cell(59, 5, mb_convert_encoding($this->Ville, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY(25, 75 + $y);
        $this->SetFont('Times', '', 11);
        $etiquette66 = "Matricule :";
        $this->Cell(19, 5, $etiquette66, 0, 0, 'L');

        $this->SetXY(46, 75 + $y);
        $this->SetFont('Times', '', 11);
        $this->Cell(19, 5, mb_convert_encoding($this->NumEmploye, 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

        $this->SetXY(25, 30);
        $this->SetFont('Times', 'B', 20);
        $this->Cell(113, 9, $this->Operation, 0, 0, 'C');

        $this->SetLineWidth(1);
        $this->Rect(25, 25, 113, 22);

        $this->SetY(105);
    }

    //Pied de page
    function Footer() {
        //Numéro de page
        //Positionnement à 1,5 cm du bas
        //Police Arial italique 8
        $this->SetY(-12);
        $this->SetFont('Arial', 'I', 8);
        $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');

        $etiquette52 = $this->configCentrale["presidence_nom"] . ", " . $this->configCentrale["presidence_poste"];
        $etiquette43 = $this->configCentrale["syndicat_nom"];
        $etiquette45 = $this->configCentrale["adresse"] . ", " . $this->configCentrale["ville"] .
                " (" . $this->configCentrale["province"] . ") " . $this->configCentrale["codepostal"] .
                " Téléphone : " . str_replace(array("(", ")"), "", $this->configCentrale["telephone"]) .
                " Télécopieur : " . str_replace(array("(", ")"), "", $this->configCentrale["telecopieur"]);
        $etiquette71 = "À compléter par l'employeur et retourner par courriel à " . $this->configCentrale["courriel"];

        // Ligne de signature
        $this->SetLineWidth(0);
        $this->Line(125, 218, 184, 218);

        // Nom de la personne à la présidence
        $this->SetXY(125, 220);
        $this->SetFont('Times', 'B', 9);
        $this->WordWrap($etiquette52, 57);
        $this->MultiCell(60, 4, mb_convert_encoding($etiquette52, 'ISO-8859-1', 'UTF-8'));

        //Nom du syndicat
        $this->SetXY(25, 259);
        $this->SetFont('Times', 'B', 9);
        $this->Cell(160, 4, mb_convert_encoding($etiquette43, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');

        // Adresse
        $this->SetXY(25, 264);
        $this->SetFont('Times', 'B', 9);
        $this->Cell(160, 4, mb_convert_encoding($etiquette45, 'ISO-8859-1', 'UTF-8'), 0, 0, 'C');

        // Mention
        $this->SetXY(130, 232);
        $this->SetFont('Times', '', 9);
        $this->WordWrap($etiquette71, 38);
        $this->MultiCell(38, 3, mb_convert_encoding($etiquette71, 'ISO-8859-1', 'UTF-8'));

        $this->SetLineWidth(1);
        $this->Line(25, 264, 184, 264);

        // Rectangle employeur
        $this->SetLineWidth(0);
        $this->Rect(29, 229, 145, 23);

        // Section employeur
        $this->SetXY(32, 227);
        $this->SetFont('Times', 'B', 9);
        $etiquette69 = "Section Employeur";
        $this->SetFillColor(255, 255, 255);
        $this->Cell(37, 4, $etiquette69, 0, 0, 'L', true);
        $this->SetXY(32, 227);
        $this->SetFillColor(0, 0, 0);
        $this->Cell(37, 4, $etiquette69, 0, 0, 'L', false);

        $this->SetLineWidth(0);
        $this->Rect(33, 234, 4, 4);

        // Case à cocher Acceptée
        $this->SetXY(41, 236);
        $this->SetFont('Times', 'B', 9);
        $etiquette73 = mb_convert_encoding("Acceptée", 'ISO-8859-1', 'UTF-8');
        $this->Cell(21, 4, $etiquette73, 0, 0, 'L');

        $this->SetLineWidth(0);
        $this->Rect(83, 234, 4, 4);

        // Case à cocher Refusée
        $this->SetXY(92, 235);
        $this->SetFont('Times', 'B', 9);
        $etiquette76 = mb_convert_encoding("Refusée", 'ISO-8859-1', 'UTF-8');
        $this->Cell(21, 4, $etiquette76, 0, 0, 'L');

        $this->SetLineWidth(0);
        $this->Line(34, 246, 66, 246);

        // Signature employeur
        $this->SetXY(38, 247);
        $this->SetFont('Times', 'B', 9);
        $etiquette78 = "Signature";
        $this->Cell(24, 4, $etiquette78, 0, 0, 'L');

        $this->SetLineWidth(0);
        $this->Line(75, 246, 107, 246);

        $this->SetXY(77, 247);
        $this->SetFont('Times', 'B', 9);
        $etiquette80 = "Date";
        $this->Cell(24, 4, $etiquette80, 0, 0, 'L');
    }
}

unset($sqlparam);
$sqlparam["table"][] = "liberations";
$sqlparam["table"][] = "ligneliberations";
$sqlparam["table"][] = "employes";
$sqlparam["table"][] = "articles";
$sqlparam["table"][] = "employeurs";
$sqlparam["table"][] = "duree";
$sqlparam["join"][] = "ligneliberations.refliberation = liberations.refliberation";
$sqlparam["join"][] = "employes.refemploye = liberations.refemploye";
$sqlparam["join"][] = "articles.refarticle=ligneliberations.refarticle";
$sqlparam["join"][] = "employeurs.refemployeur=employes.refemployeur";
$sqlparam["join"][] = "duree.refduree=ligneliberations.duree";
$sqlparam["champs"][] = "employes.numemploye";
$sqlparam["champs"][] = "IF(employes.presentation=-1,'Madame','Monsieur') as presentation";
$sqlparam["champs"][] = "employes.prenom";
$sqlparam["champs"][] = "employes.nomfamille";
$sqlparam["champs"][] = "employes.adresse1";
$sqlparam["champs"][] = "employes.adresse2";
$sqlparam["champs"][] = "CONCAT_WS(' ',employes.ville,LEFT(employes.codepostal,3),"
        . "RIGHT(employes.codepostal,3)) as ville";
$sqlparam["champs"][] = "employeurs.nomcontact";
$sqlparam["champs"][] = "employeurs.dept";
$sqlparam["champs"][] = "employeurs.nomemployeur";
$sqlparam["champs"][] = "employeurs.adresse1 as adresseemployeur";
$sqlparam["champs"][] = "employeurs.ville as villeemployeur";
$sqlparam["champs"][] = "CONCAT(LEFT(employeurs.codepostal,3),\" \",RIGHT(employeurs.codepostal,3)) as codepemployeur";
$sqlparam["champs"][] = "If(liberations.typeoperation=2,'Annulation','Demande') AS toperation";
$sqlparam["champs"][] = " UNIX_TIMESTAMP(liberations.datedemande) as datedemande";
$sqlparam["champs"][] = "unix_timestamp(ligneliberations.dateliberation) as dateliberation";
$sqlparam["champs"][] = "duree.duree";
$sqlparam["champs"][] = "articles.noarticle";
$sqlparam["champs"][] = "ligneliberations.commentaire";
$sqlparam["champs"][] = "ligneliberations.lieu";
$sqlparam["champs"][] = "employes.email";
$sqlparam["champs"][] = "employeurs.email as emailemployeur";
$sqlparam["where"][] = sprintf("liberations.refliberation=%d", $nolib);
$result = executerRequeteSql($sqlparam);

//Si aucune libération, alors erreur
if (!($result && is_array($result) && count($result) > 0)) {
    die("Erreur C - Libération introuvable");
}
//Instanciation de la classe dérivée
$pdf = new PDF('P', 'mm', 'Letter');

$pdf->SetMargins(25, 25);
$pdf->SetAutoPageBreak(true, 70);
$pdf->AliasNbPages();
$pdf->SetFont('Times', '', 11);
$pdf->syndicatnom = $_SESSION["syndicatnom"];
$pdf->configCentrale = buildConfigCentrale();

$lignesujetmail = "\n";
$i = 1;

foreach ($result as $clef => $champs) {
    if ($i == 1) {
        //Info de l'employé
        $pdf->Presentation = htmlspecialchars($champs["presentation"], ENT_SUBSTITUTE, "ISO8859-15");
        $pdf->NumEmploye = htmlspecialchars(stripslashes($champs["numemploye"]), ENT_SUBSTITUTE, "ISO8859-15"); //0
        $pdf->NomEmploye = htmlspecialchars(stripslashes($champs["prenom"] . " " . $champs["nomfamille"]), ENT_SUBSTITUTE, "ISO8859-15"); //1
        $pdf->EmployeAdresse1 = htmlspecialchars(stripslashes($champs["adresse1"]), ENT_SUBSTITUTE, "ISO8859-15"); //2
        $pdf->EmployeAdresse2 = htmlspecialchars(stripslashes($champs["adresse2"]), ENT_SUBSTITUTE, "ISO8859-15"); //2
        $pdf->Ville = htmlspecialchars(stripslashes($champs["ville"]), ENT_SUBSTITUTE, "ISO8859-15"); //3
        $pdf->Operation = mb_convert_encoding($champs["toperation"] . " de libération", 'ISO-8859-1', 'UTF-8');
        $pdf->DateDemande = date("Y-m-d", $champs["datedemande"]); //5
        //
        //Info de l'employeur
        $pdf->NomContact = htmlspecialchars(stripslashes($champs["nomcontact"]), ENT_SUBSTITUTE, "ISO8859-15"); //6
        $pdf->Dept = htmlspecialchars(stripslashes($champs["dept"]), ENT_SUBSTITUTE, "ISO8859-15"); //7
        $pdf->NomEmployeur = htmlspecialchars(stripslashes($champs["nomemployeur"]), ENT_SUBSTITUTE, "ISO8859-15"); //8
        $pdf->EmployeursAdresse1 = htmlspecialchars(stripslashes($champs["adresseemployeur"]), ENT_SUBSTITUTE, "ISO8859-15"); //9
        $pdf->EmployeursVille = htmlspecialchars(stripslashes($champs["villeemployeur"]), ENT_SUBSTITUTE, "ISO8859-15"); //10
        $pdf->EmployeursCodePostal = htmlspecialchars(stripslashes($champs["codepemployeur"]), ENT_SUBSTITUTE, "ISO8859-15");
        $pdf->AddPage();
    }

    $pdf->Dateliberation = date("Y-m-d", $champs["dateliberation"]); //12
    $pdf->SetX(25);
    $pdf->Cell(16, 4, $pdf->Dateliberation, 0, 0, 'L');

    // Utiliser un format plus facilement lisible
    $lignesujetmail .= str_replace(" ", "&nbsp;", sprintf("%-18s", $pdf->Dateliberation));

    $pdf->SetX(46);
    $pdf->Cell(16, 4, $champs["duree"], 0, 0, 'L');

    $pdf->SetX(64);
    $pdf->Cell(15, 4, mb_convert_encoding($champs["noarticle"], 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');
    $lignesujetmail .= " / " . str_replace(" ", "&nbsp;", sprintf("%-11s",
                            mb_convert_encoding($champs["noarticle"], 'ISO-8859-1', 'UTF-8')));

    $pdf->SetX(86);
    $pdf->Cell(20, 4, mb_convert_encoding($champs["lieu"], 'ISO-8859-1', 'UTF-8'), 0, 0, 'L');

    $pdf->SetX(119);
    $pdf->MultiCell(84, 4, mb_convert_encoding($champs["commentaire"], 'ISO-8859-1', 'UTF-8'));
    $lignesujetmail .= " / " . substr(mb_convert_encoding($champs["commentaire"], 'ISO-8859-1', 'UTF-8'), 0, 40);
    $lignesujetmail .= (strlen($champs["commentaire"]) > 40 ? "..." : "");

    // Fermeture de la ligne de détail
    $lignesujetmail .= "\n";

    $pdf->ln();

    $i++;
}

// Assignation de la signature
unset($signature, $car_sig);
$car_sig = "";
if ($verssortie == "courriel") {
    $car_sig = "<br>";
}
if ($_SESSION['gestion_site'] >= "Oui") {
    $signature = "$car_sig$car_sig\n\n";
    $signature .= $pdf->configCentrale["contact"] . "$car_sig\n";
    $signature .= $pdf->configCentrale["contact_poste"] . "$car_sig\n";
    $signature .= "Téléphone : " . str_replace(array("(", ")"), "", $pdf->configCentrale["telephone"])
            . "$car_sig\n";
    $signature .= " Télécopieur : " . str_replace(array("(", ")"), "", $pdf->configCentrale["telecopieur"])
            . "$car_sig\n";
    $signature .= "Courriel : " . $pdf->configCentrale["courriel"];
} else {
    $signature = "\n\n";
    $signature .= "" . $_SESSION['nomreel'] . "\n";
    $signature .= "Représentant local\n";
    $signature .= $_SESSION['adressecourriel'];
}

// Affichage
if ($verssortie == "ecran") {
    $pdf->Output();
} elseif ($verssortie == "web") {

    $message = "Résumé du document de libération\n";
    $message .= "\n";
    $message .= "Info de l'employé\n";
    $message .= "Matricule : " . $pdf->NumEmploye . "\n";
    $message .= $pdf->Presentation . " " . $pdf->NomEmploye . "\n";
    $message .= $pdf->EmployeAdresse1 . "\n";
    if (!empty($pdf->EmployeAdresse2)) {
        $message .= $pdf->EmployeAdresse2 . "\n";
    }
    $message .= $pdf->Ville . "\n";
    $message .= "\n";
    $message .= "Info de l'employeur\n";
    $message .= $pdf->NomContact . "\n";
    $message .= $pdf->Dept . "\n";
    $message .= $pdf->NomEmployeur . "\n";
    $message .= $pdf->EmployeursAdresse1 . "\n";
    $message .= $pdf->EmployeursVille . ", ";
    $message .= $pdf->EmployeursCodePostal . "\n";
    $message .= "\n";
    $message .= "Type : " . $pdf->Operation . "\n";
    $message .= "Date de la demande : " . $pdf->DateDemande . "\n";
    $message .= "\n";
    $message .= "Date de libération / Article     / Commentaires (40 premiers caractères)";
    $message .= $lignesujetmail;
    $message .= "\n";
    $message .= "\n";
    $message .= "Ce document sera vérifié dans une période de 3 jours.\n";
    $message .= "Ce message a été généré automatiquement par une application. $APPLICATION";

    $message .= $signature;
    $sujetcourriel = $pdf->Operation . " par courriel pour " . $pdf->NomEmploye;
    print "<html>";
    print "<style> body { height:100%; margin:0; padding:0; font-family:arial, helvetica, sans-serif; background-color:#e8e8e8; }</style>\n";
    print "</body>\n";
    print "<div style='width:650px; margin:auto; padding:10;'>";
    print "<form action='creation_liberation.php?lib=" . $nolib . "&sortie=courriel' method='post' enctype='text/plain'>\n";
    print "<div style='float:left; width:75px; padding-top:2px; height:23px;'>De : </div>" . $_SESSION['nomreel'] . " (" . $_SESSION['adressecourriel'] . ")\n";
    print "<div style='clear:both;'both;'></div>\n";
    print "<div style='float:left; width:75px; padding-top:2px; height:23px;'>Pour : </div><input style='width:450px;' type='text' name='employeur' value=\"" . $champs["emailemployeur"] . "\" /> (employeur)\n";
    print "<div style='clear:both;'both;'></div>\n";
    print "<div style='float:left; width:75px; padding-top:2px; height:23px;'>Cc : </div><input style='width:450px;' type='text' name='employe' value=\"" . $champs["email"] . "\" /> (employ�)\n";
    print "<div style='clear:both;'both;'></div>\n";
    print "<div style='float:left; width:75px; padding-top:2px; height:23px;'>Sujet : </div><input style='width:450px;' type='text' name='sujet' value=\"$sujetcourriel\" />\n";
    print "<div style='clear:both;'both;'></div>\n";
    print "<div style='float:left; width:75px; padding-top:2px; height:23px;'>Message : </div>\n";
    print "<div style='clear:both;'both;'></div>\n";
    print "<textarea name='message' rows='10' cols='80' style='width:650px; height:575px;' >$message</textarea>\n";
    print "<br>\n";
    print "<input type='submit' name='envoyer' style='margin-top:10px;' value='Envoyer le courriel' />\n";
    print "</form>\n";
    print "</div>\n";
    print "</body></html>";
}

/*elseif ($verssortie == "courriel") {
    $doc = $pdf->Output('', 'S');

    if (empty($_REQUEST["message"])) {

        $message = "<u>Résumé du document de libération</u><br>\n";
        $message .= "<br>\n";
        $message .= "<u>Info de l'employé</u><br>\n";
        $message .= "Matricule : " . $pdf->NumEmploye . "<br>\n";
        $message .= $pdf->Presentation . " " . $pdf->NomEmploye . "<br>\n";
        $message .= $pdf->EmployeAdresse1 . "<br>\n";
        $message .= $pdf->EmployeAdresse2 . "<br>\n";
        $message .= $pdf->Ville . "<br>\n";
        $message .= "<br>\n";
        $message .= "<u>Info de l'employeur</u><br>";
        $message .= $pdf->NomContact . "<br>\n";
        $message .= $pdf->Dept . "<br>\n";
        $message .= $pdf->NomEmployeur . "<br>\n";
        $message .= $pdf->EmployeursAdresse1 . "<br>\n";
        $message .= $pdf->EmployeursVille . "<br>\n";
        $message .= $pdf->EmployeursCodePostal . "<br>\n";
        $message .= "<br>\n";
        $message .= "Type : " . $pdf->Operation . "<br>\n";
        $message .= "Date de la demande : " . $pdf->DateDemande . "<br>\n";
        $message .= "<br>\n<pre>";
        $message .= "<u>Date de libération</u> / <u>Article</u>     / <u>Commentaires (40 premiers caractères)</u><br>";
        $message .= $lignesujetmail;
        $message .= "</pre><br>\n";
        $message .= "<br>\n";
        $message .= "Ce document sera vérifié dans une période de 3 jours.<br><br>\n";
        $message .= "Ce message a été généré automatiquement par une application. $APPLICATION";

        $message .= $signature;
    } else {
        $message = $_REQUEST["message"];
    }

    if (empty($_REQUEST["sujet"])) {
        $sujetcourriel = $pdf->Operation . " par courriel pour " . $pdf->NomEmploye;
    } else {
        $sujetcourriel = $_REQUEST["sujet"];
    }

    if (empty($_REQUEST["employeur"])) {
        $adresseemployeur = $champs["emailemployeur"];
    } else {
        $adresseemployeur = $_REQUEST["employeur"];
    }
    if (empty($_REQUEST["employe"])) {
        $adresseemploye = $champs["email"];
    } else {
        $adresseemploye = $_REQUEST["employe"];
    }
}
 */