<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.2
 *
 * Copyright (C) 2006-2015  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/fic_do.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_fici.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_geol.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../classes/geoplugin/geoplugin.class.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 = @$_GET['td'];
$coderech = @$_GET['code'];
$do_dep = @$_GET['dep'];

if (@$_SESSION["niv_log"] == 6) {
    $coderech = @$_SESSION["code_log"];
    $td = "edit";
}

$nbordres = 0;
$pbm_do = FALSE;

$do_codeadev = give_dev_codea_defaut($_SESSION["lng"], TRUE);

if ($coderech <> "") {
    // Vérification qu'il existe bien des interventions et nombre de celles-ci
    $nbinterventions = nb_int_do($coderech);

    // Récupération des informations donneur d'ordres
    $row = lit_enr_do($coderech);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
        $do_codeadev = give_dev_codea_defaut_do($do_code, $_SESSION["lng"]);

        // Vérification qu'il existe bien des contacts et nombre de ceux-ci
        $nbcontacts = nb_cdo_in_do($coderech);

        if (($td <> "del") AND ($do_ouvert == FALSE))
            $td = "view";

        if (@$_SESSION["niv_log"] >= 5) {
            if (@$_SESSION["niv_log"] == 6) {
                if ($coderech <> $_SESSION["code_do"])
                    $pbm_do = TRUE;
            }
        } else
            $pbm_do = TRUE;
    } else
        $pbm_do = TRUE;
} else {
    if ($td == "add") {
        $do_ouvert = TRUE;
        $do_codepays = pays_connect_code($_SERVER['REMOTE_ADDR']);
    } else
        $pbm_do = TRUE;
}

switch ($td) {
    case "add" :
        $titre = _("CREATION DONNEUR D'ORDRES");
        break;
    case "edit" :
        $titre = _("MISE A JOUR DONNEUR D'ORDRES");
        break;
    case "del" :
        $titre = _("SUPPRESSION DONNEUR D'ORDRES");
        break;
    case "view" :
        $titre = _("VISUALISATION DONNEUR D'ORDRES");
        break;
    default :
        $pbm_do = TRUE;
        break;
}

$lst_chp_readonly = '';
if ((@$_SESSION["niv_log"] <> 5) AND (@$_SESSION["niv_log"] <> 9))
    $lst_chp_readonly = 'nom-rcs-ape-tvai-tcom-adr1-adr2';
if ($do_ouvert == FALSE)
    $lst_chp_readonly .= '-pays-dep-ville';
?>

<!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 _("Fiche Donneur d'Ordres"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo _("Code"); ?> ; lmn:1 ; lmx:9; stok:frmok ; stbad:frmbad",
            "nom:nom ; format:txt ; req:Y ; txt:<?PHP echo _("Nom"); ?>; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rcs ; format:siret ; req:N ; txt:<?PHP echo _("Siret"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:ape ; format:naf ; req:N ; txt:<?PHP echo _("APE"); ?> ; lmx:10; stok:frmok ; stbad:frmbad",
            "nom:tvai ; format:tva ; req:N ; txt:<?PHP echo _("TVA intra."); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:tcom ; format:txt ; req:N ; txt:<?PHP echo _("Tribunal de commerce"); ?>; lmn:1 ; lmx:70; stok:frmok ; stbad:frmbad",
            "nom:adr1 ; format:txt ; req:Y ; txt:<?PHP echo _("Adresse"); ?> ; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:adr2 ; format:txt ; req:N ; txt:<?PHP echo _("Adresse (2)"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:ville ; format:liste ; req:Y ; txt:<?PHP echo _("Ville"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:dep ; format:liste ; req:Y ; txt:<?PHP echo _("Département"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:pays ; format:liste ; req:Y ; txt:<?PHP echo _("Pays"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:codeadev ; format:liste ; req:Y ; txt:<?PHP echo _("Devise"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:telf ; format:tel ; req:Y ; txt:<?PHP echo _("Téléphone Fixe"); ?>; stok:frmok ; stbad:frmbad",
            "nom:txttelf ; format:txt ; req:N ; txt:<?PHP echo _("Commentaire téléphone fixe"); ?>; lmx:100 ; stok:frmok ; stbad:frmbad",
            "nom:fax ; format:tel ; req:Y ; txt:<?PHP echo _("Télécopieur"); ?>; stok:frmok ; stbad:frmbad",
            "nom:txtfax ; format:txt ; req:N ; txt:<?PHP echo _("Commentaire télécopieur"); ?>; lmx:100 ; stok:frmok ; stbad:frmbad",
            "nom:web ; format:url_npref ; req:N ; txt:<?PHP echo _("Adresse site web"); ?>; lmx:200; stok:frmok ; stbad:frmbad",
            "nom:heures ; format:txt ; req:Y ; txt:<?PHP echo _("Horaires"); ?>; lmx:200; stok:frmok ; stbad:frmbad",
            "nom:txtent ; format:txt ; req:N ; txt:<?PHP echo _("Texte d'entête"); ?>; stok:frmok ; stbad:frmbad",
            "nom:rcivil ; format:liste ; req:Y ; txt:<?PHP echo _("Civilité responsable d'agence"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:rprenom ; format:txt ; req:Y ; txt:<?PHP echo _("Prénom responsable d'agence"); ?> ; lmn:1; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rnom ; format:txt ; req:Y ; txt:<?PHP echo _("Nom responsable d'agence"); ?>; lmn:1; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rtelf ; format:tel ; req:Y ; txt:<?PHP echo _("N° tel fixe contact principal"); ?>; stok:frmok ; stbad:frmbad",
            "nom:rtelp ; format:telp ; req:N ; txt:<?PHP echo _("N° tel portable contact principal"); ?>; stok:frmok ; stbad:frmbad",
            "nom:email ; format:mail ; req:Y ; txt:<?PHP echo _("Email")." "._("Général"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:emaild ; format:mail ; req:Y ; txt:<?PHP echo _("Email")." "._("Direction"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:emailc ; format:mail ; req:Y ; txt:<?PHP echo _("Email")." "._("Comptabilité"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            <?PHP
            if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
            {
            ?>
            "nom:nota ; format:txt ; req:N ; txt:<?PHP echo _("Notes"); ?>; stok:frmok ; stbad:frmbad",
            <?PHP
            }
            ?>
            "nom:emailt ; format:mail ; req:Y ; txt:<?PHP echo _("Email")." "._("Technique"); ?> ; lmx:50; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <?PHP if (($pbm_do == FALSE)  AND ($do_ouvert == 1)) { ?>
        <script type="text/javascript">
            <!--
            $(function () {
                $('.nyroModal').nyroModal();
            });
            //-->
        </script>

        <script type="text/javascript">
            <!--
            $(function () {
                $("#code").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#nom").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#rcs").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#ape").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#tvai").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#tcom").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#adr1").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#adr2").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#rnom").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#email").Setcase({caseValue: 'lower', changeonFocusout: true});
                $("#emaild").Setcase({caseValue: 'lower', changeonFocusout: true});
                $("#emailc").Setcase({caseValue: 'lower', changeonFocusout: true});
                $("#emailt").Setcase({caseValue: 'lower', changeonFocusout: true});
                $("#rprenom").Setcase({caseValue: 'pascal', changeonFocusout: true});
            });

            function init_all() {
                init_Body();
                $( "#onglets_do" ).tabs();
                <?php
                switch ($td)
                {
                    case "add" :
                        echo "$('#ouverture').hide();";
                        echo "init_valid_form('enr','do_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'pays','');";
                        break;
                    case "edit" :
                        echo "$('#ouverture').show();";
                        echo "init_valid_form('enr','do_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'pays','');";
                        echo "readonly_id('code',false);";
                        echo "init_fensaisie('add_ctact',950,560);";
                        echo "init_fensaisie('edit_ctact',950,560);";
                        if ((@$_SESSION["niv_log"]==5) OR (@$_SESSION["niv_log"]==9))
                            echo "init_fensaisie('tra_do',800,500);";
                        echo "init_new_fen('imprim','impression','click');";
                        break;
                    case "del" :
                        echo "$('#ouverture').show();";
                        echo "readonly_all();";
                        echo "warn_del();";
                        break;
                    case "view" :
                        echo "$('#ouverture').show();";
                        echo "init_new_fen('imprim','impression','click');";
                        echo "readonly_all();";
                        break;
                }
                ?>
                readonly_id('<?PHP echo $lst_chp_readonly; ?>',false);
                init_autohref('int_view', 'click', '', true);
                init_ajax_ville();
                init_ajax_dep();
                init_back('annul', 'click');
                Focus_first();
            }

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

    <?PHP } ?>
</head>

<body>
<?PHP
include_once("../inc/entete.inc.php");
?>
<p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- affiché uniquement s'il y a au moins une civilité -->
<?PHP
if ($pbm_do == FALSE) {
    if (nb_civ() <> 0) {
        ?>
        <table width="100%" border="0">
            <tr>
                <td width="33%" class="annot_gras_it">
                    <?PHP    if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
                        aff_lnk_lst_rech('do_lst.php', _("Retour à la liste"), $_SERVER['HTTP_REFERER'], _("Retour à la page précédente"));
                    else
                        echo "&nbsp;";
                    ?>
                </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%" align="right">
                    <?PHP
                    if (($td == "edit") OR ($td == "view")) {
                        $urlimp = "do_maji.php?cd=" . $coderech;
                        if (url_ok($urlimp) == TRUE) {
                            echo '<div id="imprim" align="right" title="' . $urlimp . '" class="falselnk">';
                            echo '<img src="../img/print.png" title="' . _("Imprimer") . '" border="0" align="absmiddle"> ' . _("Imprimer");
                            echo '</div>';
                        } else
                            echo '&nbsp;';
                    } else
                        echo '&nbsp;';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="33%">
                    <?PHP if ($td == "edit") {
                        $url_cdo = "cdo_maj.php?td=add&cd=" . $do_code . "&tx=do";
                        if (url_ok($url_cdo) == TRUE)
                            cre_falselnk('', 'add_ctact', 'span', '', _("Ajouter un contact"), $url_cdo, '', _("Ajouter un contact"));
                        else
                            echo "&nbsp;";

                        $url_cdo = "cdo_maj.php?td=lst&cd=" . $do_code . "&tx=do";
                        if ($nbcontacts == 0)
                            echo '<span id="ctact" style="display:none">';
                        else
                            echo '<span id="ctact" style="display:inline">';
                        if (url_ok($url_cdo) == TRUE) {
                            cre_falselnk('', 'edit_ctact', 'span', '', _("Editioncontacts"), $url_cdo, '', _("Edition contacts"),true);
                        } else
                            echo "&nbsp;";
                        echo '</span>';
                    } else
                        echo "&nbsp;";
                    ?>
                </td>
                <td width="33%">&nbsp;</td>
                <td width="33%" align="right">
                    <?PHP
                    if (($td == "edit") AND ($nbinterventions <> 0) AND (@$_SESSION["niv_log"] <> 6)) {
                        if (url_ok($url_inter) == TRUE) {
                            $url_inter = "int_lst.php?ord=DES&tri=Code&search=" . $do_code . "&rech=Rechercher";
                            cre_falselnk('', 'int_view', 'span', '', '', $url_inter, '', _("Voir ses interventions") . ' (' . sprintf("%'03s", $nbinterventions) . ')');
                        } else
                            echo "&nbsp;";
                    } else
                        echo "&nbsp;";
                    ?>
                </td>
            </tr>
            <tr>
                <td width="33%">
                    <?PHP if ($td == "edit") {
                        if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) {
                            $url_trado = "tra_lst.php?tx=r&tl=d&cr=" . $do_code;
                            if (url_ok($url_trado) == TRUE)
                                cre_falselnk('', 'tra_do', 'span', '', _("Traçabilité"), $url_trado, '../img/trace.gif', _("Traçabilité"));
                            else
                                echo "&nbsp;";
                        } else
                            echo "&nbsp;";
                    } else
                        echo "&nbsp;";
                    ?>
                </td>
                <td width="33%">&nbsp;</td>
                <td width="33%" align="right">&nbsp;</td>
            </tr>
        </table>

        <!-- Formulaire de saisie de la fiche -->
        <form id="do_maj" name="do_maj" id="do_maj" method="post" action="do_enr.php">
        <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
        <input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
        <?PHP if ($td == "add") { ?>
            <input name="actif" type="hidden" id="actif" value="Oui">
        <?PHP } ?>
        <input name="nbutton" type="hidden" id="nbutton" value="">

        <div id="onglets_do">
        <ul>
            <li><a href="#do_coord"><?PHP echo _("Coordonnées"); ?></a></li>
            <li><a href="#do_contact"><?PHP echo _("Contacts"); ?></a></li>
            <li><a href="#do_divers"><?PHP echo _("Divers"); ?></a></li>
        </ul>
        <div id="do_coord">

        <!-- activité (avec dates) du donneur d'ordre -->
        <?PHP if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) {
            if (($td == "edit") OR ($td == "del")) {
            ?>
            <div id="ouverture" style="display: none;">
            <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_ouvert" align="right"><?PHP echo _("Actif"); ?></td>
                <td>
                    <?PHP
                    cre_select('actif', 'actif', $non_oui, (int)$do_ouvert);
                    echo '<span class="annot_std_it">';
                    if ($do_ouvert == 1)
                        echo ' (' . _("Depuis le") . ' : ' . datetolocal($do_datecrea) . ')';
                    else
                        echo ' (' . _("Ouverte le") . ' : ' . datetolocal($do_datecrea) . ', ' . _("fermée le") . ' : ' . datetolocal($do_datec) . ')';
                    echo '</span>';
                    ?>
                </td>
                <?PHP
                echo '<td align="right" valign="top">';
                $url_img_logo = $chemin_logos . "/log" . strtolower($do_code) . ".png";
                if (exist_logo($do_code)) {
                    echo '<a href="' . $url_img_logo . '" class="nyroModal" title="'._("Logo donneur d'ordres").' (' . $do_code . ')">';
                    echo '<img src="../img/vlogo.png" border="0" align="absmiddle"> ' . _("Voir le logo");
                    echo '</a>';
                } else {
                    echo '<div class="annot_petit_it">';
                    echo _("Pas de logo pour ce donneur d'ordres");
                    echo '<br />(<a href="logo_maj.php?td=do">' . _("Configurer") . '</a>)';
                    echo '</div>';
                }
                echo '</td>';
                ?>
            </tr>
            </table>
            </div>
            <?PHP
            }
        }
        ?>

        <!-- Fiche principale -->
        <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
            <td>
                <?PHP
                if ($td == "add") {
                    echo '<strong>D</strong>';
                    echo '<input name="code" type="text" id="code" value="' . $do_code . '" size="9" maxlength="9">';
                    echo '<img src="../img/oblig.png" align="absmiddle" alt="' . _("Champ obligatoire") . '">';
                } else
                    echo '<input name="code" type="text" id="code" value="' . $do_code . '" size="10" maxlength="10" readonly>';
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_nom" align="right"><?PHP echo _("Nom"); ?></td>
            <td>
                <input name="nom" type="text" id="nom" value="<?PHP echo $do_nom; ?>" size="50">
                 <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_rcs" align="right"><?PHP echo _("Siret"); ?></td>
            <td>
                <input name="rcs" type="text" id="rcs" value="<?PHP echo $do_rcs ?>" size="50">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_ape" align="right"><?PHP echo _("APE"); ?></td>
            <td>
                <input name="ape" type="text" id="ape" value="<?PHP echo $do_ape ?>" size="10">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_tvai" align="right"><?PHP echo _("TVA intra."); ?></td>
            <td>
                <input name="tvai" type="text" id="tvai" value="<?PHP echo $do_tvai ?>" size="50">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_tcom" align="right"><?PHP echo _("Tribunal com."); ?></td>
            <td>
                <input name="tcom" type="text" id="tcom" value="<?PHP echo $do_tcom ?>" size="70">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_adr1" align="right"><?PHP echo _("Adresse"); ?></td>
            <td>
                <input name="adr1" type="text" id="adr1" value="<?PHP echo $do_adr1 ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_adr2" align="right"><?PHP echo _("Adresse (2)"); ?></td>
            <td>
                <input name="adr2" type="text" id="adr2" value="<?PHP echo $do_adr2 ?>" size="50">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_pays" align="right"><?PHP echo _("Pays"); ?></td>
            <td>
                <?PHP
                // Création de la liste des pays
                $rows = give_rows_pays();
                cre_select_tab('pays', 'pays', $rows, 'pays_code', 'pays_nom', '', $do_codepays, '', _("-- Faites votre choix --"), 1, FALSE, '-1', _("-- Inconnu --"));
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_dep" align="right"><?PHP echo _("Département"); ?></td>
            <td>
                <?PHP
                // Création de la liste des départements
                $rows = give_rows_dep($do_codepays);
                cre_select_tab('dep', 'dep', $rows, 'dep_code', 'dep_code', 'dep_nom', $do_dep, '', _("-- Faites votre choix --"), 1, FALSE, '-1', _("-- Inconnu --"));
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_ville" align="right"><?PHP echo _("Ville"); ?></td>
            <td>
                <?PHP
                // Création de la liste des villes
                $rows = give_rows_villes($do_dep,$do_codepays);
                cre_select_tab('ville', 'ville', $rows, 'villes_id', 'villes_nom', 'villes_cp', $do_ville, '', _("-- Faites votre choix --"), 1, FALSE, '-1', _("-- Inconnu --"));
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_codeadev" align="right"><?PHP echo _("Devise"); ?></td>
            <td>
                <?PHP
                // Création de la liste des devises
                $rows = give_rows_devises();
                cre_select_tab('codeadev', 'codeadev', $rows, 'dev_codea', 'dev_nom', 'dev_codea', $do_codeadev, '', _("-- Faites votre choix --"));
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_telf" align="right">
                <?PHP echo _("Téléphone Fixe"); ?><br />
                (<?PHP echo _("Commentaire"); ?>)
            </td>
            <td>
                <input name="telf" type="text" id="telf" value="<?PHP echo $do_telf ?>" size="20" maxlength="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"><br />
                <input name="txttelf" type="text" id="txttelf" value="<?PHP echo $do_txttelf ?>" size="100">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_fax" align="right">
                <?PHP echo _("Télécopieur"); ?><br />
                (<?PHP echo _("Commentaire"); ?>)
            </td>
            <td>
                <input name="fax" type="text" id="fax" value="<?PHP echo $do_fax ?>" size="20" maxlength="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"><br />
                <input name="txtfax" type="text" id="txtfax" value="<?PHP echo $do_txtfax ?>" size="100">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_web" align="right"><?PHP echo _("Site Web"); ?><span
                    class="annot_petit_it">(<?PHP echo _("Sans préfixe"); ?>)</span></td>
            <td>
                <input name="web" type="text" id="web" value="<?PHP echo $do_web ?>" size="80" maxlength="200">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_heures" align="right"><?PHP echo _("Horaires"); ?></td>
            <td>
                <input name="heures" type="text" id="heures" value="<?PHP echo $do_heures ?>" size="80">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_com" align="right"><?PHP echo _("Texte d'entête"); ?></td>
            <td><textarea name="txtent" id="txtent"><?PHP echo $do_txtent ?></textarea></td>
        </tr>
        </table>
        </div>

        <div id="do_contact">
        <table width="100%" border="0">
        <tr>
            <td class="rubfrm" id="f_rcivil" align="right"><?PHP echo _("Civilité"); ?></td>
            <td>
                <?PHP
                // Création de la liste des civilités
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                $rech = "SELECT * FROM `" . TBCIV . "` ORDER BY civ_desc";
                $rows = $db->get_results($rech, ARRAY_A);
                $db->disconnect();
                cre_select_tab('rcivil', 'rcivil', $rows, 'civ_code', 'civ_desc', '', $do_resp_civilite, '', _("-- Faites votre choix --"));
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_rprenom" align="right"><?PHP echo _("Prénom"); ?></td>
            <td>
                <input name="rprenom" type="text" id="rprenom" value="<?PHP echo $do_resp_prenom ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_rnom" align="right"><?PHP echo _("Nom"); ?></td>
            <td>
                <input name="rnom" type="text" id="rnom" value="<?PHP echo $do_resp_nom ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_rtelf" align="right"><?PHP echo _("Téléphone Fixe"); ?></td>
            <td>
                <input name="rtelf" type="text" id="rtelf" value="<?PHP echo $do_resp_telf ?>" size="20" maxlength="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_rtelp" align="right"><?PHP echo _("Téléphone portable"); ?></td>
            <td>
                <input name="rtelp" type="text" id="rtelp" value="<?PHP echo $do_resp_telp ?>" size="20" maxlength="20">
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" class="rubfrm" align="center"><?PHP echo _("Emails"); ?></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_email" align="right"><?PHP echo _("Général"); ?></td>
            <td>
                <input name="email" type="text" id="email" value="<?PHP echo $do_email ?>" size="50" maxlength="50">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $do_email ?>"><img src="../img/mail.png"
                                                                  title="<?PHP echo _("Envoyer e-mail"); ?>" border="0"
                                                                  align="absmiddle"></a>
                <?PHP } ?>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"> <span
                    class="annot_std_it">(<?PHP echo _("Pour contacts clients"); ?>)</span>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_emaild" align="right"><?PHP echo _("Direction"); ?></td>
            <td>
                <input name="emaild" type="text" id="emaild" value="<?PHP echo $do_emaild ?>" size="50" maxlength="50">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $do_emaild ?>"><img src="../img/mail.png"
                                                                   title="<?PHP echo _("Envoyer e-mail"); ?>" border="0"
                                                                   align="absmiddle"></a>
                <?PHP } ?>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_emailc" align="right"><?PHP echo _("Comptabilité"); ?></td>
            <td>
                <input name="emailc" type="text" id="emailc" value="<?PHP echo $do_emailc ?>" size="50" maxlength="50">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $do_emailc ?>"><img src="../img/mail.png"
                                                                   title="<?PHP echo _("Envoyer e-mail"); ?>" border="0"
                                                                   align="absmiddle"></a>
                <?PHP } ?>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_emailt" align="right"><?PHP echo _("Technique"); ?></td>
            <td>
                <input name="emailt" type="text" id="emailt" value="<?PHP echo $do_emailt ?>" size="50" maxlength="50">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $do_emailt ?>"><img src="../img/mail.png"
                                                                   title="<?PHP echo _("Envoyer e-mail"); ?>" border="0"
                                                                   align="absmiddle"></a>
                <?PHP } ?>
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        </table>
        </div>

        <div id="do_divers">
        <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_nota" align="right"><?PHP echo _("Notes"); ?></td>
            <td><textarea name="nota" id="nota"><?PHP echo $do_nota ?></textarea></td>
        </tr>
        <tr>
            <td width="160">&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <?PHP
        if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) {
            ?>
            <tr>
                <td width="160" class="rubfrm" id="f_factures" align="right"><?PHP echo _("Emet ses factures"); ?></td>
                <td>
                    <?PHP
                    switch ($td) {
                        case "add" :
                            cre_select('factures', 'factures', $non_oui, 0);
                            break;
                        default :
                            cre_select('factures', 'factures', $non_oui, (int)$do_fact);
                    }
                    ?>
            </tr>
        <?PHP
        }
        ?>
        </table>
        </div>
        </div>

        <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="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                break;
        }
        echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
        ?>
        </p>
        </form>
        <!-- Fin affiché uniquement s'il y a au moins une catégorie agence et au moins une civilité -->
    <?PHP
    } else
        pop_ret_auto(_("Aucune civilité"), 'warn', "civ_lst.php");
} else
    pop_ret_auto(_("Problème de paramètres"), 'warn', "index.php");
include_once("pied.php");
?>
</body>
</html>