<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.0
 *
 * Copyright (C) 2006-2014  Sylvain FATOME
 * This program is free software; you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation;
 * either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program
 * (in the directory docs);
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 * Contact : galawa@free.fr
 *
 * Web : http://smi.no-ip.org
 ****************************************************************************************/


// Vérification des tentatives de hack
$pos = strpos($_SERVER['PHP_SELF'], "inc.php");
if ($pos === FALSE)
    $ok_inc = TRUE;
else
    $ok_inc = FALSE;
if ($ok_inc == FALSE) header("Location: ../index.php");

$pdf->Ln(1);
$pdf->SetFont('', '', 10);
$pdf->SetFillColor(0);
$pdf->SetTextColor(255);
$pdf->Cell(80, 5, _("Relevé") . ' : ' . $rlic_code, 1, 0, 'C', 1);
$pdf->SetFillColor(255);
$pdf->SetTextColor(0);
$PosX = $pdf->GetX();
$PosY = $pdf->GetY();
$pdf->Ln();
// Code-barre
$pdf->write1DBarcode($rlic_code, 'C39', $PosX + 10, $PosY, 55, 5, 0.4, $style, 'N');

// Relevé effectué "par"
$pdf->SetFont('', 'I', 8);

$row2 = lit_enr_tec($rlic_codetec);
if ($row2) {
    $row2 = encode_str($row2);
    extract($row2);
}

$pdf->Cell(140, 4, _("Fiche créée le") . ' ' . datetolocal($rlic_datecrea) . '. ' . _("Relevé effectué par") . ' ' . $tec_nom . ' ' . $tec_prenom . '.', 0, 0, 'L');
$pdf->SetFont('', '', 8);

if (datetolocal($rlic_dateout) == "")
    $pdf->Ln(5);
else {
    $pdf->SetFont('', 'BI', 8);
    $pdf->Cell(137, 5, _("Sortie du parc le") . ' ' . datetolocal($rlic_dateout), 0, 1, 'R');
    $pdf->SetFont('', '', 8);
}

// Site d'utilisation
$nom_site = str_majuscules(nom_scli($rlic_idsite, FALSE, FALSE, FALSE));

$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, 'Site : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $nom_site, 0, 1, 'L');

// Marque
$row2 = lit_enr_mque($rlic_codema);
if ($row2) {
    $row2 = encode_str($row2);
    extract($row2);
}
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Marque") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $mque_ste, 0, 1, 'L');

// Type
$row2 = lit_enr_rltl($rlic_codetl);
if ($row2) {
    $row2 = encode_str($row2);
    extract($row2);
}
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Type") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rltl_desc, 0, 1, 'L');

// Modèle
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Modèle") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_modele, 0, 1, 'L');

// Version
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Version") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_version, 0, 1, 'L');

// Maximum de postes
$nbutilise = 0;

$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
$rexist = "SELECT * FROM `" . TBRPDT . "` WHERE `rpdt_codecli` = '" . $rlic_codecli . "'";
$rows2 = $db->get_results($rech2, ARRAY_A);
$db->disconnect();

if ($rows2) {
    foreach ($rows2 as $row2) {
        $row2 = encode_str($row2);
        if (strpos($row2["rpdt_coderlic"], $rlic_code) !== false)
            $nbutilise++;
    }
}
$db->disconnect();
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Maximum de postes") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_maxcli . ' (' . _("Utilisé") . ' : ' . $nbutilise . ')', 0, 1, 'L');

// Média
$row2 = lit_enr_med($rlic_codemed);
if ($row2) {
    $row2 = encode_str($row2);
    extract($row2);
}
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Média") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlmed_desc, 0, 1, 'L');

// Numéro
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Numéro") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_numlic, 0, 1, 'L');

// Clef
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Clef d'activation") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_cleflic, 0, 1, 'L');

// A jour / Légale ?
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("A jour / Légale") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
if ($rlic_ajour == TRUE) {
    $pdf->Cell(7, 4, _("OUI") . ' / ', 0, 0, 'L');
} else {
    $pdf->SetFont('', 'BI', 8);
    $pdf->Cell(6, 4, _("NON"), 0, 0, 'L');
    $pdf->SetFont('', '', 8);
    $pdf->Cell(2, 4, ' / ', 0, 0, 'L');
}

if ($rlic_legal == TRUE) {
    $pdf->Cell(197, 4, _("OUI"), 0, 1, 'L');
} else {
    $pdf->SetFont('', 'BI', 8);
    $pdf->Cell(197, 4, _("NON"), 0, 1, 'L');
    $pdf->SetFont('', '', 8);
}

// Date Validité
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Date de validité") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
if (datetolocal($rlic_dateval) <> "") {
    if (echeance_depassee_date($datea, $rlic_dateval) == TRUE)
        $pdf->SetFont('', 'BI', 8);
}
$pdf->Cell(247, 4, datetolocal($rlic_dateval), 0, 1, 'L');

// Validation
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Validé par") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->Cell(247, 4, $rlic_signataire, 0, 1, 'L');

/********************************/
/* Informations complémentaires */
/********************************/
$pdf->Ln(2);
$pdf->SetFont('', 'BU', 10);
$pdf->Cell(277, 5, _("INFORMATIONS COMPLEMENTAIRES"), '', 1, 'L');
$pdf->Ln(2);

/*********/
/* Notes */
/*********/
$pdf->SetFont('', 'B', 8);
$pdf->Cell(30, 4, _("Notes") . ' : ', 0, 0, 'R');
$pdf->SetFont('', '', 8);
$pdf->MultiCell(247, 4, $rlic_nota, 0, 'L');
$pdf->Ln(2);

/*************/
/* Matériels */
/*************/
if ($nbutilise <> 0) {
    $warn = FALSE;
    $pdf->SetFont('', 'IB', 8);
    $pdf->Cell(7);
    $pdf->Cell(30, 4, _("Détail matériels") . ' : ', 'LT', 0, 'R');
    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
    $rech2 = "SELECT * FROM `" . TBRPDT . "` WHERE rpdt_codecli = '" . $rel_codecli . "' AND rpdt_dateout = '0000-00-00'";
    $rech2 .= " AND rpdt_coderlic LIKE '%" . $rlic_code . "%'";
    $rech2 .= " ORDER BY rpdt_code";
    $rows2 = $db->get_results($rech2, ARRAY_A);
    $db->disconnect();
    if ($rows2) {
        $pdf->SetFont('', 'IU', 7); // Titres
        $pdf->Cell(30, 4, _("Code Fiche Mat."), 1, 0, 'C');
        $pdf->Cell(14, 4, _("Dte Relevé"), 1, 0, 'C');
        $pdf->Cell(58, 4, _("Catégorie"), 1, 0, 'C');
        $pdf->Cell(58, 4, _("Marque / Modèle / NS / Emplacement"), 1, 0, 'C');
        $pdf->Cell(14, 4, _("Fin Gar."), 1, 1, 'C');
        $pdf->SetFont('', 'I', 8);

        foreach ($rows2 as $row2) {
            $row2 = encode_str($row2);
            extract($row2);
            $pdf->Cell(7);
            $pdf->Cell(30, 4, '', 'LR', 0, 'R');
            $pdf->SetFont('', 'I', 7);
            $pdf->Cell(30, 4, $rpdt_code, 'LR', 0, 'L');
            $pdf->Cell(14, 4, datetolocal($rpdt_daterel), 'LR', 0, 'C');
            $row3 = lit_enr_rpcat($rpdt_codecat);
            if ($row3) {
                $row3 = encode_str($row3);
                extract($row3);
            }
            $pdf->Cell(58, 4, $rpcat_desc, 'LR', 0, 'L');
            $row3 = lit_enr_mque($rpdt_codema);
            if ($row3) {
                $row3 = encode_str($row3);
                extract($row3);
            }
            $pdf->Cell(58, 4, $mque_ste, 'LR', 0, 'L');

            // Alertes complémentaires
            $txt_warn = "";
            if (datetolocal($rpdt_fingar) <> "") {
                if ((echeance_depassee_date($datea, $rpdt_fingar) == TRUE)  AND (datetolocal($rpdt_dateout) == ""))
                    $warn = TRUE;
                $txt_warn .= "G";
            }

            if ($txt_warn <> "") {
                $pdf->Cell(14, 4, datetolocal($rpdt_fingar), 'LR', 0, 'L');
                $pdf->Cell(5, 4, $txt_warn, 0, 1, 'L');
            } else {
                $pdf->Cell(14, 4, datetolocal($rpdt_fingar), 'LR', 1, 'L');
            }

            if ($rpdt_modele <> "") {
                $pdf->Cell(7);
                $pdf->Cell(30, 4, '', 'LR', 0, 'R');
                $pdf->Cell(30, 4, '', 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 0, 'C');
                $pdf->Cell(58, 4, '', 'LR', 0, 'L');
                $pdf->Cell(58, 4, $rpdt_modele, 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 1, 'C');
            }

            if ($rpdt_ns <> "") {
                $pdf->Cell(7);
                $pdf->Cell(30, 4, '', 'LR', 0, 'R');
                $pdf->Cell(30, 4, '', 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 0, 'C');
                $pdf->Cell(58, 4, '', 'LR', 0, 'L');
                $pdf->Cell(58, 4, _("NS") . ' : ' . $rpdt_ns, 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 1, 'C');
            }

            if ($rpdt_empl <> "") {
                $pdf->Cell(7);
                $pdf->Cell(30, 4, '', 'LR', 0, 'R');
                $pdf->Cell(30, 4, '', 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 0, 'C');
                $pdf->Cell(58, 4, '', 'LR', 0, 'L');
                $pdf->Cell(58, 4, _("Empl.") . ' : ' . $rpdt_empl, 'LR', 0, 'L');
                $pdf->Cell(14, 4, '', 'LR', 1, 'C');
            }
        }
    }
    $PosY = $pdf->GetY();
    $pdf->Line(17, $PosY, 221, $PosY); // On "ferme" le tableau

    // Légende si alertes affichées
    if ($warn == TRUE) {
        $pdf->SetFont('', 'I', 8);
        $pdf->Cell(7);
        $pdf->Cell(204, 4, _("Légende") . ' : \'G\'= ' . _("Garantie dépassée"), 0, 1, 'R');
    }
}
$pdf->SetFont('', '', 8);
$pdf->Ln(2);

/*******************/
/* Télémaintenance */
/*******************/
$pdf->SetFont('', 'IB', 8);
$pdf->Cell(7);
$pdf->Cell(30, 4, _("Télémaintenance") . ' : ', 'LTR', 0, 'R');

$pdf->SetFont('', 'I', 8);

// Type d'accès
$pdf->Cell(30, 4, _("Type d'accès") . ' : ', 'LTR', 0, 'R');
$row2 = lit_enr_tmta($rlic_codeta);
if ($row2) {
    $row2 = encode_str($row2);
    extract($row2);
}
$pdf->Cell(144, 4, $rlptmta_desc, 'LTR', 1, 'L');

// Mode d'accès
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Mode d'accès") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $maj_typesma[$rlic_tma], 'R', 1, 'L');

// Logiciel télémaintenance
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Logiciel télém.") . ' : ', 'R', 0, 'R');
if ($rlic_codel <> '')
{
    $row2 = lit_enr_rlptml($rlic_codel);
    if ($row2) {
        $row2 = encode_str($row2);
        extract($row2);
    }
}
else
    $rlptml_desc ='';
$pdf->Cell(144, 4, $rlptml_desc, 'R', 1, 'L');

// Mode Service
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Mode service ?") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $non_oui[$rlic_tser], 'R', 1, 'L');

// Lien d'accès
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Lien d'accès") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $rlic_tlien, 'R', 1, 'L');

// Login/MDP
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Login / MDP") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $rlic_tlogin . " / " . $rlic_tmdp, 'R', 1, 'L');

// Arrêt exploitation
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Arrêt exploitation ?") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $non_oui[$rlic_tae], 'R', 1, 'L');

// Redémarrage
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Redémarrage ?") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $non_oui[$rlic_tred], 'R', 1, 'L');

$PosY = $pdf->GetY();
$pdf->Line(17, $PosY, 221, $PosY); // On "ferme" le tableau

$pdf->Ln(2);

/****************/
/* Mises à jour */
/****************/
$pdf->SetFont('', 'IB', 8);
$pdf->Cell(7);
$pdf->Cell(30, 4, _("Mises à jour") . ' : ', 'LTR', 0, 'R');

$pdf->SetFont('', 'I', 8);

// Mode
$pdf->Cell(30, 4, _("Mode") . ' : ', 'LTR', 0, 'R');
if ($rlic_codel <> '')
{
    $row2 = lit_enr_rlpmm($rlic_codem);
    if ($row2) {
        $row2 = encode_str($row2);
        extract($row2);
    }
    $db->disconnect();
}
else
    $rlpmm_desc = '';
$pdf->Cell(144, 4, $rlpmm_desc, 'LTR', 1, 'L');

// Fréquence/type
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Fréquence") . ' : ', 'R', 0, 'R');
$txt_per = "";
if ($rlic_mper <> '')
{
    $row2 = lit_enr_per($rlic_mper);
    if ($row2) {
        $row2 = encode_str($row2);
        extract($row2);
        if ($per_nbj <> 0)
            $txt_per = $per_desc . ' (' . _("tous les") . ' ' . $per_nbj . ' ' . _("jours") . ')';
        else
            $txt_per = $per_desc . ' (' . _("à la demande") . ')';
    }
}
$pdf->Cell(144, 4, $txt_per . " -> " . _("type") . " " . $maj_types[$rlic_mmode], 'R', 1, 'L');

// Date échéance
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Echéance") . ' : ', 'R', 0, 'R');
$txt_edep = "";
if (datetolocal($rlic_mdval) <> "") {
    if (echeance_depassee_date($datea, $rlic_mdval) == TRUE)
        $txt_edep = " (" . _("Echéance dépassée") . ")";
}
$pdf->Cell(144, 4, datetolocal($rlic_mdval) . $txt_edep, 'R', 1, 'L');

// Date mise à jour
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Dernière MAJ") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, datetolocal($rlic_mdlmaj), 'R', 1, 'L');

// Arrêt exploitation
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Arrêt exploitation ?") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $non_oui[$rlic_mae], 'R', 1, 'L');

// Redémarrage
$pdf->Cell(7);
$pdf->Cell(30, 4, '', 'LR', 0, 'R');
$pdf->Cell(30, 4, _("Redémarrage ?") . ' : ', 'R', 0, 'R');
$pdf->Cell(144, 4, $non_oui[$rlic_mred], 'R', 1, 'L');

$PosY = $pdf->GetY();
$pdf->Line(17, $PosY, 221, $PosY); // On "ferme" le tableau

$pdf->Ln(2);

/************/
/* Contrats */
/************/
$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
$rech2 = "SELECT * FROM `" . TBCOCL . "` WHERE `cocl_coderlp` LIKE '%" . $rlic_code . "%'";
$rech2 .= " ORDER BY `cocl_code` ASC";
$rows2 = $db->get_results($rech2, ARRAY_A);
$db->disconnect();
if ($rows2) {
    $warn = FALSE;

    $pdf->SetFont('', 'IB', 8);
    $pdf->Cell(7);
    $pdf->Cell(30, 4, _("Contrats") . ' : ', 'LTR', 0, 'R');

    $pdf->SetFont('', 'IU', 7); // Titres
    $pdf->Cell(45, 4, _("Code"), 1, 0, 'C');
    $pdf->Cell(43, 4, _("Créé le"), 1, 0, 'C');
    $pdf->Cell(43, 4, _("Début le"), 1, 0, 'C');
    $pdf->Cell(43, 4, _("Fin le"), 1, 1, 'C');
    $pdf->SetFont('', 'I', 8);

    foreach ($rows2 as $row2) {
        $row2 = encode_str($row2);
        $echeance_ok = TRUE;
        if (datetolocal($row2["cocl_datef"]) <> "") {
            if (echeance_depassee_date($datea, $row2["cocl_datef"]) == TRUE)
                $echeance_ok = FALSE;
        }

        $pdf->Cell(7);
        $pdf->Cell(30, 4, '', 'LR', 0, 'C');
        $pdf->Cell(45, 4, $row2["cocl_code"], 'LR', 0, 'L');
        $pdf->Cell(43, 4, datetolocal($row2["cocl_datecrea"]), 'LR', 0, 'C');
        $pdf->Cell(43, 4, datetolocal($row2["cocl_dated"]), 'LR', 0, 'C');

        // Alertes complémentaires
        $txt_warn = "";
        if (datetolocal($row2["cocl_datesig"]) == "") {
            $warn = TRUE;
            $txt_warn .= "S";
        }
        if ((datetolocal($row2["cocl_datefin"]) <> "") OR ($echeance_ok == FALSE)) {
            $warn = TRUE;
            $txt_warn .= "T";
        }

        if ($txt_warn <> "") {
            $pdf->Cell(43, 4, datetolocal($row2["cocl_datef"]), 'LR', 0, 'C');
            $pdf->Cell(5, 4, $txt_warn, 0, 1, 'L');
        } else {
            $pdf->Cell(43, 4, datetolocal($row2["cocl_datef"]), 'LR', 1, 'C');
        }
    }

    $PosY = $pdf->GetY();
    $pdf->Line(17, $PosY, 221, $PosY); // On "ferme" le tableau

    // Légende si alertes affichées
    if ($warn == TRUE) {
        $pdf->SetFont('', 'I', 8);
        $pdf->Cell(7);
        $pdf->Cell(204, 4, _("Légende") . ' : \'S\'=' . _("Non signé") . ' / \'T\'=' . _("Terminé"), 0, 1, 'R');
    }
} else {
    $pdf->SetFont('', 'IB', 8);
    $pdf->Cell(7);
    $pdf->Cell(30, 4, _("Contrats") . ' : ', 0, 0, 'R');
    $pdf->SetFont('', 'I', 8);
    $pdf->Cell(277, 4, _("Aucun contrat couvrant cette licence"), 0, 1, 'L');
}

/*************/
/* Problèmes */
/*************/

if ($pbm == 1) {
    $pdf->Ln(2);
    $pdf->SetFont('', 'BU', 10);
    $pdf->Cell(277, 5, _("PROBLEMES"), 0, 1, 'C');
    $pdf->Ln(2);

    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
    $rech2 = "SELECT * FROM `" . TBRPBM . "` WHERE `rpbm_coderlp` = '" . $rlic_code . "' ORDER BY `rpbm_datecrea`";
    $rows2 = $db->get_results($rech2, ARRAY_A);
    $db->disconnect();
    if ($rows2) {
        $pdf->SetFont('', 'IU', 7); // Titres
        $pdf->Cell(30, 4, _("Déclaré le"), 1, 0, 'C');
        $pdf->Cell(73, 4, _("Déclaré par"), 1, 0, 'C');
        $pdf->Cell(144, 4, _("Site / Problème"), 1, 0, 'C');
        $pdf->Cell(30, 4, _("Traité le"), 1, 1, 'C');
        $pdf->SetFont('', 'I', 8);

        foreach ($rows2 as $row2) {
            $row2 = encode_str($row2);
            extract($row2);

            $pdf->SetFont('', 'IB', 7);
            $pdf->Cell(30, 4, datetolocal($rpbm_datecrea), 'LR', 0, 'L');
            $pdf->Cell(73, 4, $rpbm_signale, 'LR', 0, 'L');

            $nom_site = "";
            switch ($rpbm_idsite) {
                case 0 :
                    $nom_site = _("Site principal");
                    break;
                default :
                    $row3 = lit_enr_scli_id($rpbm_idsite);
                    if ($row3) {
                        extract($row3);
                        $nom_site .= $scli_ste;
                        $nom_site .= " (" . Retournecp_Id($scli_ville, TRUE) . " " . Retourneville_Id($scli_ville, TRUE) . ")";
                    }
            }
            $pdf->Cell(144, 4, $nom_site, 'LR', 0, 'L');
            if (($rpbm_datett <> "0000-00-00") AND ($rpbm_datett <> NULL))
                $pdf->Cell(30, 4, datetolocal($rpbm_datett) . ' (' . $rpbm_codeint . ')', 'LR', 1, 'L');
            else {
                if ($rpbm_codeint <> NULL)
                    $pdf->Cell(30, 4, _("En cours") . ' (' . $rpbm_codeint . ')', 'LR', 1, 'L');
                else
                    $pdf->Cell(30, 4, _("Non traité"), 'LR', 1, 'L');
            }
            $pdf->SetFont('', 'I', 7);

            // Lignes supplémentaires si long descriptif problème
            $ligne_cesure = cesuretxt_tab($rpbm_pbm, 100);

            foreach ($ligne_cesure as $key => $value) {
                $pdf->SetFillColor(255);
                $pdf->Cell(30, 4, "", 'LR', 0, 'L', 1);
                $pdf->Cell(73, 4, "", 'LR', 0, 'L', 1);
                $pdf->Cell(144, 4, $value, 'LR', 0, 'L', 1);
                $pdf->Cell(30, 4, "", 'LR', 1, 'L', 1);
            }
        }
        $PosY = $pdf->GetY();
        $pdf->Line(10, $PosY, 287, $PosY); // On "ferme" le tableau
    } else {
        $pdf->SetFont('', 'I', 8);
        $pdf->Cell(277, 4, _("Aucun problème déclaré"), 0, 1, 'C');
    }
}

$pdf->Ln(1);
$pdf->SetDrawColor(120);
$pdf->SetLineWidth(0.4);
$PosY = $pdf->GetY();
$pdf->Line(10, $PosY, 287, $PosY);
$pdf->SetDrawColor(0);
$pdf->SetLineWidth(0.2);
?>