<?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");


include_once("../inc/config.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_rel.inc.php");
include_once("../inc/lst.inc.php");
include_once("../classes/ezSQL/shared/ez_sql_core.php");
include_once("../classes/ezSQL/mysqli/ez_sql_mysqli.php");
include_once("../inc/func_sql.inc.php");
Archivelog(@$_SESSION["code_log"]);
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$td = '';
$tr = '';
$cr = '';
$crl = '';
$crp = '';
$id = 0;
$cap = -1;

$td = $_GET['td']; // Récupération type demande
$tr = intval($_GET['tr']); // Récupération type relevé (1 = Licence, 2 = matériel)
if (isset($_GET['cr']))
    $cr = $_GET['cr']; // Récupération code relevé
if (isset($_GET['crl']))
    $crl = $_GET['crl']; // Récupération code relevé licence
if (isset($_GET['crp']))
    $crp = $_GET['crp']; // Récupération code relevé produit
if (isset($_GET['id']))
    $id = intval($_GET['id']); // Récupération code ID
if (isset($_GET['cap']))
    $cap = intval($_GET['cap']); // Code Appelant (0 = Dossier relevé, 1 = Fiche relevé)

$pbm_rpbm = FALSE;

if (($cap <> 0) AND ($cap <> 1))
    $pbm_rpbm = TRUE;
else {
    if ($cr <> "") {
        switch ($tr) {
            case 1 :
                // Récupération des informations relevé licence
                $row = lit_enr_rlic($crl);
                if (is_array($row)) {
                    $row = encode_str($row);
                    extract($row);

                    $datecfich = datetolocal($rlic_daterel);
                    $coderel = $rlic_coderel;
                    $code = $rlic_code;
                    $codecli = $rlic_codecli;
                    $idsite = $rlic_idsite;

                    // Récupération de la marque marque et du type de licence
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                    $rech = "SELECT * FROM `" . TBMQUE . "` WHERE `mque_code` = '" . $rlic_codema . "'";
                    $row = $db->get_row($rech, ARRAY_A);
                    if ($row) {
                        $row = encode_str($row);
                        extract($row);
                    }
                    $rech = "SELECT * FROM `" . TBRLTL . "` WHERE `rltl_code` = '" . $rlic_codetl . "'";
                    $row = $db->get_row($rech, ARRAY_A);
                    if ($row) {
                        $row = encode_str($row);
                        extract($row);
                    }
                    $db->disconnect();

                    $descr = "<b>" . $mque_ste . "</b> : " . $rlic_modele . " ver." . $rlic_version . " <span class=\"annot_std_it\">(type : " . $rltl_desc . ")</span>";
                } else
                    $pbm_rpbm = TRUE;
                break;

            case 2 :
                // Récupération des informations relevé produit
                $row = lit_enr_rpdt($crp);
                if (is_array($row)) {
                    $row = encode_str($row);
                    extract($row);

                    $datecfich = datetolocal($rpdt_daterel);
                    $coderel = $rpdt_coderel;
                    $code = $rpdt_code;
                    $codecli = $rpdt_codecli;
                    $idsite = $rpdt_idsite;

                    // Récupération de la catégorie et de la marque
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                    $rech = "SELECT * FROM `" . TBRPCAT . "` WHERE `rpcat_code` = '" . $rpdt_codecat . "'";
                    $row = $db->get_row($rech, ARRAY_A);
                    if ($row) {
                        $row = encode_str($row);
                        extract($row);
                    }
                    $rech = "SELECT * FROM `" . TBMQUE . "` WHERE `mque_code` = '" . $rpdt_codema . "'";
                    $row = $db->get_row($rech, ARRAY_A);
                    if ($row) {
                        $row = encode_str($row);
                        extract($row);
                    }
                    $db->disconnect();

                    $descr = "<b>" . $rpcat_desc . "</b> : " . $mque_ste . " / " . $rpdt_modele . " <span class=\"annot_std_it\">(ns : " . $rpdt_ns . ")<br />code : " . $rpdt_codep . " / lieu : " . $rpdt_empl . "</span>";
                } else
                    $pbm_rpbm = TRUE;
                break;

            default :
                $pbm_rpbm = TRUE;
                break;
        }

        if ($pbm_rpbm == FALSE) {
            $row = lit_enr_rel($coderel);
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);
                $datedrel = datetolocal($rel_datecrea);

                // vérification des tentatives de hack
                switch (@$_SESSION["niv_log"]) {
                    // Contrôle qu'un client n'essaye pas de "hacker" un relevé
                    case 1 :
                        $tab_cli = give_tab_rcli($_SESSION["code_log"], TRUE);
                        if (exist_in_array($rel_codecli, $tab_cli) == FALSE)
                            $pbm_rpbm = TRUE;
                        break;
                    // Contrôle qu'une agence n'essaye pas de "hacker" un relevé
                    case 3 :
                    case 4 :
                        if ($rel_codeage <> @$_SESSION["code_age"])
                            $pbm_rpbm = TRUE;
                        break;
                }
            } else
                $pbm_rpbm = TRUE;

            if ($pbm_rpbm == FALSE) {
                $row = lit_enr_cli($codecli, TRUE);
                if (is_array($row)) {
                    $row = encode_str($row);
                    extract($row);
                    $rpbm_codecli = $codecli;

                    // vérification des tentatives de hack
                    switch (@$_SESSION["niv_log"]) {
                        // Contrôle qu'un client n'essaye pas de "hacker" un relevé
                        case 1 :
                            $tab_cli = give_tab_rcli($_SESSION["code_log"], TRUE);
                            if (exist_in_array($rpbm_codecli, $tab_cli) == FALSE)
                                $pbm_rpbm = TRUE;
                            break;
                        // Contrôle qu'une agence n'essaye pas de "hacker" un relevé
                        case 3 :
                        case 4 :
                            if ($cli_prop <> @$_SESSION["code_age"])
                                $pbm_rpbm = TRUE;
                            break;
                    }
                } else
                    $pbm_rpbm = TRUE;

                if ($pbm_rpbm == FALSE) {
                    if ($id > 0) {
                        $row = lit_enr_rpbm($id);
                        if (is_array($row)) {
                            $row = encode_str($row);
                            extract($row);
                            if ($rpbm_codeint <> "")
                                $td = "view";

                            if ($rpbm_codecli <> $codecli)
                                $pbm_rpbm = TRUE;

                            if ($rpbm_code <> $cr)
                                $pbm_rpbm = TRUE;
                        } else
                            $pbm_rpbm = FALSE;

                        $datecreaf = datetolocal($rpbm_datecrea);
                        $datettf = datetolocal($rpbm_datett);
                    } else
                        if ($td <> "add")
                            $pbm_rpbm = TRUE;
                }
            }
        }
    } else
        $pbm_rpbm = TRUE;
}

switch ($td) {
    case "view" :
        $titre = _("VOIR DECLARATION DE PROBLEME");
        break;
    case "edit" :
        $titre = _("MISE A JOUR DECLARATION DE PROBLEME");
        break;
    case "del" :
        $titre = _("SUPPRESSION DECLARATION DE PROBLEME");
        break;
    case "add" :
        $rpbm_idsite = -2;
        $titre = _("DECLARATION DE PROBLEME");
        break;
    default :
        $pbm_rpbm = TRUE;
        break;
}
?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title>SMI - <?PHP echo _("ESPACE PRIVE"); ?> : <?PHP echo _("Déclaration de Problème"); ?></title>

        <?PHP include_once("../inc/header.inc.php"); ?>

        <script language="javascript">
            <!--
            var tab1_champ = ["nom:pbm ; format:txt ; req:Y ; txt:<?PHP echo _("Problème détaillé"); ?> ; stok:frmok ; stbad:frmbad",
                "nom:datecreaf ; format:date ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; req:Y ; txt:<?PHP echo _("Détecté le"); ?> ; stok:frmok ; stbad:frmbad",
                "nom:signale; format:txt ; req:Y ; txt:<?PHP echo _("Signalé par"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad"];
            //-->
        </script>

        <script type="text/javascript">
            <!--
            function init_datepicker() {
                $.datepicker.setDefaults({
                    closeText: "<?PHP echo _("Fermer"); ?>",
                    prevText: "<?PHP echo _("Précédent"); ?>",
                    nextText: "<?PHP echo _("Suivant"); ?>",
                    currentText: "<?PHP echo _("Aujourd'hui"); ?>",
                    monthNames: ["<?PHP echo implode('","',$lng_tmoisf); ?>"],
                    monthNamesShort: ["<?PHP echo implode('","',$lng_tmoism); ?>"],
                    dayNames: ["<?PHP echo implode('","',$lng_tjourf); ?>"],
                    dayNamesShort: ["<?PHP echo implode('","',$lng_tjourm); ?>"],
                    dayNamesMin: ["<?PHP echo implode('","',$lng_tjours); ?>"],
                    weekHeader: "<?PHP echo _("Sem."); ?>",
                    dateFormat: "<?PHP echo $_SESSION['date_fmtshort']; ?>",
                    firstDay: 1,
                    isRTL: !1,
                    changeMonth: true,
                    changeYear: true,
                    showMonthAfterYear: !1,
                    yearSuffix: "",
                    showButtonPanel: true,
                    showOn: "both",
                    buttonImageOnly: true,
                    buttonImage: "../img/calendar.png",
                    buttonText: "<?PHP echo _("Calendrier"); ?>"
                });
            }

            function init_all() {
                init_Body();
                init_datepicker();
                <?php
                switch ($td)
                {
                    case "add" :
                        echo '$("#datecreaf").datepicker({';
                        echo '    onSelect: function (datesel) {';
                        echo '        $("#datecreaf").blur();';
                        echo '    },';
                        echo '});';
                        echo "init_autoraz('razdatecreaf','datecreaf','click');";
                        echo "init_valid_form('enr','rpbm_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        break;
                    case "edit" :
                        if (@$_SESSION["niv_log"] >= 3)
                            echo 'warn_cpta('.$cli_cpta.',"rel");';
                        echo "init_valid_form('enr','rpbm_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        break;
                    case "del" :
                        echo "init_valid_form('del','rpbm_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        echo "readonly_all();";
                        echo "warn_del('');";
                        break;
                    case "view" :
                        if (@$_SESSION["niv_log"] >= 3)
                            echo 'warn_cpta('.$cli_cpta.',"rel");';
                        echo "readonly_all();";
                        break;
                }
                if (@$_SESSION["niv_log"] >= 3)
                    echo "init_fensaisie('aff_notesc',930,380);";
                ?>
                Focus_first();
            }

            $(document).ready(function () {
                init_all();
            });
            //-->
        </script>
    </head>

<body>
<?PHP include_once("../inc/entete.inc.php"); ?>
    <p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
    <table width="100%" border="0">
        <tr>
            <td width="33%">
                <?PHP
                /*
                if (@$_SESSION["niv_log"] <> 1)
                {
                */
                $lnk_rel_maj = 'rel_maj.php?td=edit&cr=' . $coderel;
                if ($tr == 1) {
                    $txt_ret_fiche = _("Retour fiche licence");
                    $lnk_ret_fiche = 'rlic_maj.php?td=';
                } else {
                    $txt_ret_fiche = _("Retour fiche matériel");
                    $lnk_ret_fiche = 'rpdt_maj.php?td=';
                }
                if (@$_SESSION["niv_log"] <> 1)
                    $lnk_ret_fiche .= 'edit';
                else
                    $lnk_ret_fiche .= 'view';
                if ($tr == 1)
                    $lnk_ret_fiche .= '&crl=' . $code;
                else
                    $lnk_ret_fiche .= '&crp=' . $code;
                aff_lnk_lst_rech($lnk_rel_maj, _("Retour au dossier de relevé"), $lnk_ret_fiche, $txt_ret_fiche);
                ?>
            </td>
            <td width="33%" align="center" class="annot_petit_it">
                <div id="oblig">(<img src="../img/oblig.png" align="absmiddle"
                                      alt="<?PHP echo _("Champ obligatoire"); ?>">
                    : <?PHP echo _("Saisie obligatoire"); ?>)
                </div>
            </td>
            <td width="33%">&nbsp;</td>
        </tr>
    </table>
    <br />
    <form name="rpbm_maj" id="rpbm_maj" method="post" action="rpbm_enr.php">
    <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
    <input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
    <input name="typrel" type="hidden" id="typrel" value="<?PHP echo $tr ?>">
    <input name="coderel" type="hidden" id="coderel" value="<?PHP echo $coderel ?>">
    <input name="id" type="hidden" id="id" value="<?PHP echo $id ?>">
    <input name="code" type="hidden" id="code" value="<?PHP echo $code ?>">
    <input name="codecli" type="hidden" id="codecli" value="<?PHP echo $rpbm_codecli ?>">
    <input name="cap" type="hidden" id="cap" value="<?PHP echo $cap ?>">
    <input name="nbutton" type="hidden" id="nbutton" value="">

    <!-- Code du relevé client (affiché uniquement si édition ou suppression) -->
    <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_coderlic" align="right"><?PHP echo _("Code fiche relevé"); ?></td>
            <td>
                <span class="annot_std_gras"><?PHP echo $code; ?></span>
                <span class="annot_petit_it">(<?PHP Echo _("Fiche de relevé créée le"); ?> <?PHP echo $datecfich ?>
                    )</span>
            </td>
        </tr>
    </table>

    <!-- N° Dossier & Date de création -->
    <table width="100%" border="0">
        <tr>
            <td class="annot_petit_it">
                <?PHP echo _("Appartient au dossier de relevé"); ?> <?PHP echo $coderel; ?>
                , <?PHP echo _("créé le"); ?> <?PHP echo $datedrel; ?>
            </td>
        </tr>
    </table>

    <!-- Affichage du client -->
    <table width="100%" border="0">
        <tr>
            <td class="rubfrm" id="f_codecli" align="center"><?PHP echo _("Client"); ?>
                <?PHP
                if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
                    echo " <img src=\"../img/" . $ico_cpta[$cli_cpta] . "\" title =\"" . $mess_cpta[$cli_cpta] . "\" border=\"0\" align=\"absmiddle\">";
                ?>
            </td>
        </tr>
    </table>

    <!-- détails client -->
    <table width="100%" border="0">
        <tr>
            <td valign="top" bgcolor="#C5CED7">
                <?PHP
                echo "<span class=\"annot_std_gras\">";
                if ($cli_ste <> "")
                    echo $cli_ste . "<br />";
                else
                    echo $cli_civilite . " " . $cli_prenom . " " . $cli_nom . "<br />";
                echo "</span>";
                echo $cli_adr1 . "<br />";
                if ($cli_adr2 <> "")
                    echo $cli_adr2 . "<br />";
                echo Retournecp_Id($cli_ville, TRUE) . " " . Retourneville_Id($cli_ville, TRUE) . "<br />";
                $chemin_imagesco = $chemin_images . "/telc.png";
                echo "<img src=\"" . $chemin_imagesco . "\" align=\"bottom\">";
                echo " " . $cli_telf . "<br />";
                ?>
            </td>
            <td width="60" valign="top">
                <?PHP
                if (@$_SESSION["niv_log"] >= 3) {
                    $url_affnotesc = "aff_notesc.php?cc=" . $codecli;
                    if (url_ok($url_affnotesc, TRUE) == TRUE)
                        cre_falselnk('', 'aff_notesc', 'span', '', _("Notes"), $url_affnotesc, '../img/eye.png', _("Notes"));
                } else
                    echo "&nbsp;";
                ?>
            </td>
        </tr>
    </table>

    <!-- Site de déclaration du problème -->
    <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_site" align="right"><?PHP echo _("Site"); ?></td>
            <td>
                <?PHP
                // On doit choisir un site précis si la fiche est notée "affectée à tous les sites"
                if (($idsite == -1) and ($td <> "view") and ($td <> "del")) // zone modifiable si pas sorti du parc et si pas en visualisation
                {
                    echo '<select name="site" id="site">';
                    echo '<option selected>' . _("-- Choisissez le site touché par ce problème --") . '</option>';
                    if ($td == "add") // On ne peut déclarer "Tous les sites" que lors de la 1ère déclaration du problème
                        echo '<option value="-1">' . _("Tous les sites") . '</option>';
                    echo '<option value="0"';
                    if ($rpbm_idsite == 0)
                        echo ' selected';
                    echo '>' . _("Site principal") . '</option>';

                    // création de la liste des sites actifs
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                    $rech = "SELECT * FROM `" . TBSCLI . "` WHERE `scli_actif` = '1' AND `scli_codecli` = '" . $codecli . "' ORDER BY scli_ste";
                    $rows = $db->get_results($rech, ARRAY_A);

                    if ($rows) {
                        foreach ($rows as $row) {
                            $row = encode_str($row);
                            extract($row);

                            if ($scli_adr2 <> "")
                                $nom_site = $scli_ste . " (" . $scli_adr1 . ", " . $scli_adr2 . ", " . Retournecp_Id($scli_ville, FALSE) . " " . Retourneville_Id($scli_ville, FALSE) . ")";
                            else
                                $nom_site = $scli_ste . " (" . $scli_adr1 . ", " . Retournecp_Id($scli_ville, FALSE) . " " . Retourneville_Id($scli_ville, FALSE) . ")";
                            echo '<option value="' . $scli_id . '"';
                            if ($rpbm_idsite == $scli_id)
                                echo ' selected';
                            echo '>' . $nom_site . '</option>';
                        }
                    }
                    $db->disconnect();
                    echo '</select>';
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="' . _("Champ obligatoire") . '">';
                } else {
                    echo '<input name="site" type="hidden" id="site" value="' . $idsite . '">';
                    if ($td == "add")
                        $site = $idsite;
                    else
                        $site = $rpbm_idsite;
                    switch ($site) {
                        case 0 :
                            echo '<input name="nsite" type="text" id="nsite" value="' . _("Site principal") . '" readonly>';
                            break;
                        default :
                            $nom_site = "";
                            $row = lit_enr_scli_id($site, TRUE);
                            if (is_array($row)) {
                                $row = encode_str($row);
                                extract($row);
                                if ($scli_adr2 <> "")
                                    $nom_site = $scli_ste . " (" . $scli_adr1 . ", " . $scli_adr2 . ", " . Retournecp_Id($scli_ville, TRUE) . " " . Retourneville_Id($scli_ville, TRUE) . ")";
                                else
                                    $nom_site = $scli_ste . " (" . $scli_adr1 . ", " . Retournecp_Id($scli_ville, TRUE) . " " . Retourneville_Id($scli_ville, TRUE) . ")";
                            }
                            echo '<input name="nsite" type="text" id="nsite" value="' . $nom_site . '" size="100" readonly>';
                            break;
                    }
                }
                ?>
            </td>
        </tr>
    </table>

    <!-- Descriptif rapide de la licence ou du produit concerné -->
    <table width="100%" border="0">
        <tr>
            <td class="rubfrm" colspan="2" id="f_codecli" align="center">
                <?PHP
                if ($tr == 1)
                    echo _("Licence Concernée");
                else
                    echo _("Matériel Concerné");
                ?>
            </td>
        </tr>
    </table>

    <table width="100%" border="0">
        <tr>
            <td width="160" valign="top" class="rubfrm" align="right">
                <?PHP
                if ($tr == 1)
                    echo _("Licence");
                else {
                    echo _("Matériel (ns)");
                    echo '<br />';
                    echo _("Code - empl.");
                }
                ?>
            </td>
            <td>
                <?PHP echo $descr ?>
            </td>
        </tr>
    </table>

    <!-- Délai du problème rencontré -->
    <table width="100%" border="0">
        <tr>
            <td class="rubfrm" colspan="2" align="center">
                <?PHP echo _("Détail du problème rencontré"); ?>
            </td>
        </tr>
    </table>

    <!-- Descriptif du problème -->
    <table width="100%" border="0">
        <tr>
            <td width="160" valign="top" class="rubfrm" id="f_pbm"
                align="right"><?PHP echo _("Problème détaillé"); ?></td>
            <td>
                <textarea name="pbm" rows="5" id="pbm"><?PHP echo $rpbm_pbm ?></textarea>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"><br />
            </td>
        </tr>
    </table>

    <!-- Date détection -->
    <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_datecreaf" align="right"><?PHP echo _("Détecté le"); ?></td>
            <td>
                <input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $datecreaf ?>" size="10"
                       maxlength="10" readonly>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                <img src="../img/raz.png" id="razdatecreaf" border="0" align="absmiddle">
            </td>
        </tr>
    </table>

    <!-- Qui a détecté le problème ?-->
    <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_signale" align="right">
                <?PHP echo _("Détécté par"); ?>
            </td>
            <td>
                <input name="signale" type="text" id="signale" value="<?PHP echo $rpbm_signale ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"><br />

                <div class="annot_petit_it"><?PHP echo _("Entrer le prénom et le nom de personne ayant détecté le problème"); ?></div>
            </td>
        </tr>
    </table>

    <?PHP
    if ($td <> "add") {
        ?>
        <!-- détail du traitement -->
        <table width="100%" border="0">
            <tr>
                <td class="rubfrm" colspan="2" id="f_operation" align="center">
                    <?PHP echo _("Pour info : Opération en cours ou effectuée"); ?>
                </td>
            </tr>
        </table>

        <?PHP
        if ($rpbm_codeint <> "") {
            ?>
            <!-- N° Intervention-->
            <table width="100%" border="0">
                <tr>
                    <td width="160" class="rubfrm" id="f_codeint" align="right"><?PHP echo _("N° Intervention"); ?></td>
                    <td>
                        <input name="codeint" type="text" id="codeint" value="<?PHP echo $rpbm_codeint ?>" size="20"
                               maxlength="20" readonly>
                    </td>
                </tr>
                <!-- Date traitement-->
                <tr>
                    <td width="160" class="rubfrm" id="f_datettf" align="right"><?PHP echo _("Traité le"); ?></td>
                    <td>
                        <?PHP
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        $rech2 = "SELECT * FROM `" . TBINT . "` WHERE `int_code`='" . $rpbm_codeint . "'";
                        $row = $db->get_row($rech2, ARRAY_A);
                        if ($row) {
                            if (datetolocal($row["int_datefin"]) <> "") {
                                echo "<span class=\"annot_std_gras\">";
                                echo _("Terminée");
                                echo "</span>";
                                echo " (" . _("close le") . " " . datetolocal($row["int_datefin"]) . ")";
                            } else {
                                if (datetolocal($row["int_dateprev"]) <> "") {
                                    echo "<span class=\"annot_std_gras\">";
                                    echo _("Terminée");
                                    echo "</span>";
                                    echo " (" . _("client appelé le") . " " . datetolocal($row["int_dateprev"]) . ")";
                                } else {
                                    echo "<span class=\"annot_std_it\">";
                                    echo _("En cours");
                                    echo "</span>";
                                    echo " (" . _("dernière modif.") . " : " . datetolocal($row["int_datemod"]) . ")";
                                }
                            }
                        } else
                            echo "&nbsp;";
                        $db->disconnect();
                        ?>
                    </td>
                </tr>
                <!-- Travail effectué-->
                <tr>
                    <td width="160" class="rubfrm" id="f_fait" align="right"><?PHP echo _("Travail effectué"); ?></td>
                    <td>
                        <textarea name="fait" rows="5" id="fait" readonly><?PHP echo $rpbm_fait ?></textarea>
                    </td>
                </tr>
            </table>
        <?PHP
        } else {
            ?>
            <table width="100%" border="0">
                <tr>
                    <td colspan="2" id="f_codeint" align="center">
				<span class="annot_std_it">
					<?PHP echo _("Aucune intervention effectuée"); ?>
				</span>
                    </td>
                </tr>
            </table>
        <?PHP
        }
    }
    ?>
    <p align="center">
        <?PHP
        switch ($td)
        {
            case "add" :
            case "edit" :
                echo '<input name="enr" type="button" class="bton_std" id="enr" value="'._("Valider").'">';
                break;
            case "del" :
                echo '<input name="del" type="button" class="bton_std" id="del" value="'._("Supprimer").'">';
                break;
        }
        echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
        ?>
    </p>
    </form>
<?PHP
include_once("pied.php");
?>