<?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/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_geol.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/lst.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);
$_POST = clean_str($_POST);

$codecli = @$_GET['cc'];
$id = intval(@$_GET['id']);
$td = @$_GET['td'];
$scli_dep = $_GET['dep'];

$pbm_scli = FALSE;
$totalscli = 0;
$chx_code = TRUE;
$chx_prop = TRUE;
if ($codecli <> "") {
    // Contrôle qu'un client n'essaye pas de "hacker" un autre compte
    if (@$_SESSION["niv_log"] == 1) {
        $tab_cli = give_tab_rcli($_SESSION["code_log"], TRUE);
        if (exist_in_array($codecli, $tab_cli) == FALSE)
            $pbm_scli = TRUE;
    }

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

            $totalscli = nb_scli($codecli, "", TRUE);
            if ($totalscli == 0)
                $td = "add";
            $retourliste = FALSE;

            if (($td <> "add") AND ($td <> "edit") AND ($td <> "del"))
                $td = "lst";

            // Contrôle qu'une agence n'essaye pas de "hacker" un client
            if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($cli_prop <> @$_SESSION["code_age"])) {
                if ($cli_prop <> NULL)
                    $pbm_scli = TRUE;
            }

            // Contrôle qu'un donneur d'ordres n'essaye pas de "hacker" un client
            if ((@$_SESSION["niv_log"] == 7) OR (@$_SESSION["niv_log"] == 6)) {
                if ($cli_codedo <> @$_SESSION["code_do"])
                    $pbm_scli = TRUE;
            }

            if ($td == "add")
                $scli_codepays = pays_connect_code($_SERVER['REMOTE_ADDR']);

            if (($td == "edit") OR ($td == "del")) {
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                $rech = "SELECT * FROM `" . TBSCLI . "` WHERE scli_id = '$id' AND scli_codecli='" . $db->escape($codecli) . "'";
                $row = $db->get_row($rech, ARRAY_A);
                if ($row) {
                    $row = encode_str($row);
                    extract($row);
                    if ($scli_prop == "")
                        $scli_prop = $cli_prop;
                } else
                    $pbm_scli = TRUE;
                $db->disconnect();
            }
        } else
            $pbm_scli = TRUE;
    }
} else
    $pbm_scli = TRUE;

switch ($td) {
    case "add" :
        $titre = _("CREATION SITE CLIENT");
        $scli_prop = "0";
        $scli_actif = 1;
        break;
    case "edit" :
        $titre = _("EDITER SITE CLIENT");
        break;
    case "del" :
        $titre = _("SUPPRIMER SITE CLIENT");
        break;
    case "lst" :
        $titre = _("LISTE SITES CLIENT");
        break;
    default :
        $pbm_scli = TRUE;
        break;
}

switch ($_SESSION["niv_log"])
{
    case 3 :
        $chx_code = FALSE;
        $chx_prop = FALSE;
        break;
    case 4 :
        $chx_code = FALSE;
        if ($cli_prop <> $_SESSION["code_age"])
            $chx_prop = FALSE;
        break;
    case 5 :
    case 9 :
        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("Sites Client"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = [
            <?PHP
            if (((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) OR ((@$_SESSION["niv_log"] == 4) AND ($cli_prop==$_SESSION["code_age"])))
                echo '"nom:ccpta; format:txt ; req:N ; txt:'._("Code compta").'; stok:frmok ; stbad:frmbad",';
            ?>
            "nom:prop ; format:liste ; req:Y ; txt:<?PHP echo _("Agence gestionnaire"); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:ste ; format:txt ; req:Y ; txt:<?PHP echo _("Société"); ?> ; 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:adr1 ; format:txt ; req:Y ; txt:<?PHP echo _("Adresse"); ?> ; 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:telf ; format:tel ; req:Y ; txt:<?PHP echo _("Téléphone Fixe"); ?>; stok:frmok ; stbad:frmbad",
            "nom:fax ; format:tel ; req:N ; txt:<?PHP echo _("Télécopieur"); ?>; stok:frmok ; stbad:frmbad",
            "nom:email ; format:mail ; req:Y ; txt:<?PHP echo _("Email"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rcivil ; format:liste ; req:Y ; txt:<?PHP echo _("Civilité (Contact)"); ?>  ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:rprenom ; format:txt ; req:Y ; txt:<?PHP echo _("Prénom (Contact)"); ?>  ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rnom ; format:txt ; req:Y ; txt:<?PHP echo _("Nom (Contact)"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rtelf ; format:tel ; req:Y ; txt:<?PHP echo _("Téléphone Fixe (Contact)"); ?>  ; lmx:20 ; stok:frmok ; stbad:frmbad",
            "nom:rfax ; format:tel ; req:N ; txt:<?PHP echo _("Télécopieur (Contact)"); ?>  ; lmx:20 ; stok:frmok ; stbad:frmbad",
            "nom:rtelp ; format:telp ; req:N ; txt:<?PHP echo _("Téléphone Portable (Contact)"); ?> ; lmx:20 ; stok:frmok ; stbad:frmbad",
            "nom:remail ; format:mail ; req:Y ; txt:<?PHP echo _("Email (Contact)"); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:rfunc ; format:liste ; req:Y ; txt:<?PHP echo _("Fonction (Contact)"); ?>  ; vmn:1; stok:frmok ; stbad:frmbad",
            "nom:nota; format:txt ; req:N ; txt:<?PHP echo _("Notes"); ?>; stok:frmok ; stbad:frmbad"];
        //-->
    </script>


    <?PHP if ($pbm_scli == FALSE) { ?>
        <script type="text/javascript">
            <!--
            $(function () {
                $("#ste").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#rcs").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#ape").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#tvai").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});
                $("#remail").Setcase({caseValue: 'lower', changeonFocusout: true});
                $("#rprenom").Setcase({caseValue: 'pascal', changeonFocusout: true});
            });

            function init_all() {
                init_Body();
                init_autohref_classe('falselnkimg','');
                <?PHP
                switch ($td)
                {
                    case "view" :
                    case "del" :
                        echo "readonly_all();";
                        if ($td=="del") echo "warn_del('');";
                        break;
                    case "add" :
                    case "edit" :
                        echo 'init_ajax_ville();';
                        if (((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) OR ((@$_SESSION["niv_log"] == 4) AND ($cli_prop==$_SESSION["code_age"])))
                            echo 'init_ajax_age_dep_pays2();';
                        echo 'init_ajax_dep();';
                        if ($chx_code == FALSE)
                            echo "readonly_id('code',false);";
                        if ($chx_prop == FALSE)
                            echo "readonly_id('prop',false);";
            			echo "init_valid_form('enr','scli_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'pays','');";
                        break;
                    default :
                        break;
                }
                ?>
                init_autohref('lst', 'click', 'scli_maj.php?cc=<?PHP echo $codecli; ?>&td=lst',false);
                init_autohref('add', 'click', 'scli_maj.php?cc=<?PHP echo $codecli; ?>&td=add',false);
                add_func_click('quit', 'sclose', '');
                Focus_first();
            }

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

</head>
<body>
<?PHP
if ($pbm_scli == FALSE) {
    ?>
    <p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
    <p align="center"><span class="titre_gras"><?PHP echo _("Pour le client"); ?> : <?php echo $cli_ste; ?> </span></p>
    <table width="890" border="0">
        <tr>
            <td width="33%">&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">
                <input name="quit" type="button" class="bton_fgris_petit" id="quit" value="<?PHP echo _("Quitter"); ?>">
                <?PHP if (($totalscli > 0) AND ($td <> "lst")) { ?>
                    <input name="lst" type="button" class="bton_fgris_petit" id="lst"
                           value="<?PHP echo _("Revenir à la liste"); ?>">
                <?PHP } ?>
            </td>
        </tr>
    </table>
    <?PHP if ($td == "lst") // Mode listing
    {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
        $rech = "SELECT * FROM `" . TBSCLI . "` WHERE `scli_codecli`= '" . $codecli . "' ORDER BY scli_ste";
        $rows = $db->get_results($rech, ARRAY_A);

        if ($rows) {

            echo "<table class=\"MtableD\" border=\"0\" width=\"890\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";

            // création de l'entête de la table "sites secondaires"
            echo "<th>";
            echo _("Coordonnées");
            echo "</th>\n";
            echo "<th>";
            echo _("Tel/Fax");
            echo "</th>\n";
            echo "<th>";
            echo _("Contact");
            echo "</th>\n";
            echo "<th>";
            echo _("créé le");
            echo "</th>\n";
            echo "<th>";
            echo _("Cliquer");
            echo "</th>\n";

            $j = 0;

            foreach ($rows as $row) {
                $row = encode_str($row);
                // création de l'entête de ligne (TR)
                creetrlstdet($j);

                echo "<td>\n";
                echo $row["scli_ste"];
                if (intval($row["scli_actif"]) == 0)
                    echo ' <a href="#" class="popw"><img src="../img/locked.png" alt="' . _("Site désactivé") . '" border="0" align="absmiddle"><span>' . _("Site désactivé") . '</span></a>';
                echo "<br />";

                echo $row["scli_adr1"];
                echo "<br />";
                if ($row["scli_adr2"] <> "") {
                    echo $row["scli_adr2"];
                    echo "<br />";
                }
                echo Retournecp_Id($row["scli_ville"], FALSE) . " " . Retourneville_Id($row["scli_ville"], FALSE);

                // détail propriétaire
                if (((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) OR (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)))) {
                    if ((trim($cli_prop) == "") OR ($cli_prop == @$_SESSION["code_age"])) {
                        echo "<div class=\"annot_petit_it\" align=\"right\">";
                        $txt = _("Géré par") . " ";
                        switch ($row["scli_prop"]) {
                            case "-1" :
                                $txt .= _("agences couvrant le département");
                                break;
                            case "0" :
                                if (trim($cli_prop) <> "")
                                    $txt .= $cli_prop;
                                else
                                    $txt = _("Non affecté");
                                break;
                            default :
                                if (trim($row["scli_prop"]) <> "")
                                    $txt .= $row["scli_prop"];
                                else {
                                    if (trim($cli_prop) <> "")
                                        $txt .= $cli_prop;
                                    else
                                        $txt = _("Non affecté");
                                }
                                break;
                        }
                        echo $txt;
                        echo "</div>";
                    }
                }

                echo "</td>\n";
                echo "<td align=\"center\">\n";
                echo _("T.") . $row["scli_telf"];
                if ($row["scli_fax"] <> "") {
                    echo "<br />";
                    echo _("F.") . $row["scli_fax"];
                }
                echo "<td align=\"center\">\n";
                echo $row["scli_rcivil"] . " " . $row["scli_rprenom"] . " " . $row["scli_rnom"];
                echo "<br />";
                echo _("T.") . $row["scli_rtelf"];
                if ($row["scli_rfax"] <> "") {
                    echo "<br />";
                    echo _("F.") . $row["scli_rfax"];
                }
                if ($row["scli_rtelp"] <> "") {
                    echo "<br />";
                    echo _("P.") . $row["scli_rtelp"];
                }
                echo "</td>\n";
                echo "<td align=\"center\">\n";
                echo datetolocal($row["scli_datecrea"]);
                echo "</td>\n";
                echo "<td align=\"center\">\n";
                $lst_maj = TRUE;
                cre_falselnk_img('', 'scli_edit_'.$row["scli_id"], 'span', 'center', _("Edition"), 'lnk', 'scli_maj.php?td=edit&cc=' . $codecli . '&id=' . $row["scli_id"] . '&dep=' . $row["scli_dep"], '../img/edit.png');
                $lst_del = TRUE;
                cre_falselnk_img('', 'scli_del_'.$row["scli_id"], 'span', 'center', _("Suppression"), 'lnk', 'scli_maj.php?td=del&cc=' . $codecli . '&id=' . $row["scli_id"] . '&dep=' . $row["scli_dep"], '../img/del.png');
                echo "</td>\n";

                echo "</tr>\n";

                $j++;
            }

            echo "</table>\n";
            // Fin affichage table liste sites

        } else
            echo '<p class="annot_petit_it">' . _("Aucun site client enregistré") . '</p>';

        $db->disconnect();

        $taille_piedla = "";
        include_once("piedla.inc.php");

        echo '<p align="center">';
        echo '<input name="add" type="button" class="bton_std" id="add" value="' . _("Saisir un nouveau site") . '">';
        echo '</p>';
    } else // Formulaire de saisie
    {
        ?>
        <form name="scli_maj" id="scli_maj" method="post" action="scli_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="id" type="hidden" id="idccli" value="<?PHP echo $id ?>">
        <input name="cc" type="hidden" id="cc" value="<?PHP echo $codecli ?>">
        <input name="ca" type="hidden" id="ca" value="<?PHP echo $cli_prop ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <table width="100%" border="0" align="center">
        <tr>
            <td width="160" class="rubfrm" id="f_prop" align="right"><?PHP echo _("Agence gestion."); ?></td>
            <td>
                <?PHP
                $tab_first_options = [];
                $tab_first_options['-1'] = _("-- Aucune agence en particulier --");
                if (($cli_prop <> "") AND ($cli_prop <> NULL))
                    $tab_first_options['0'] = $cli_prop . ' ' . _("uniquement (gestionnaire compte client)");

                // création de la liste des agences ouvertes et couvrant ce site
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

                $rech = "";
                // On établi la liste des agences couvrant le Département du site
                // autre que l'agence gestionnaire du site principal
                $rech2 = "SELECT zcc_code FROM `" . TBZCC . "` WHERE zcc_codedep = '$scli_dep' AND zcc_codepays = '$scli_codepays'";
                if (($cli_prop <> "") AND ($cli_prop <> NULL))
                    $rech2 .= " AND zcc_code <> '$cli_prop'";
                $rows2 = $db->get_results($rech2, ARRAY_A);
                if ($rows2) {
                    $idx = 0;
                    $rech = "SELECT * FROM `" . TBAGE . "` WHERE `age_ouvert` = '1'";
                    if (count($rows2) == 1)
                        $rech .= " AND";
                    else
                        $rech .= " AND (";
                    foreach ($rows2 as $row2) {
                        $row2 = encode_str($row2);
                        extract($row2);
                        if ($idx == 0)
                            $rech .= " age_code='" . $zcc_code . "'";
                        else
                            $rech .= " OR age_code='" . $zcc_code . "'";
                        $idx++;
                    }
                    if (count($rows2) > 1)
                        $rech .= ")";
                    $rech .= " ORDER BY age_nom";
                }

                if (trim($rech) <> "")
                    $rows = $db->get_results($rech, ARRAY_A);
                $db->disconnect();
                cre_select_tab('prop', 'prop', $rows, 'age_code', 'age_nom', 'age_code', $scli_prop, '', _("-- Faites votre choix --"), 1, $multiple = FALSE, '', '', TRUE, TRUE, FALSE, $tab_first_options);
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
            <td>
                <?PHP
                echo '<input name="code" type="text" id="code" value="' . $scli_code . '">';
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_ste" align="right"><?PHP echo _("Société"); ?></td>
            <td>
                <input name="ste" type="text" id="ste" value="<?PHP echo $scli_ste ?>" 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 $scli_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 $scli_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 $scli_tvai ?>" size="50">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_adr1" align="right"><?PHP echo _("Adresse"); ?></td>
            <td>
                <input name="adr1" type="text" id="adr1" value="<?PHP echo $scli_adr1 ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_adr2" align="right"><?PHP echo _("Adresse (2)"); ?></td>
            <td>
                <input name="adr2" type="text" id="adr2" value="<?PHP echo $scli_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', '', $scli_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($scli_codepays);
                cre_select_tab('dep', 'dep', $rows, 'dep_code', 'dep_code', 'dep_nom', $scli_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($scli_dep,$scli_codepays);
                cre_select_tab('ville', 'ville', $rows, 'villes_id', 'villes_nom', 'villes_cp', $scli_ville, '', _("-- Faites votre choix --"), 1, FALSE, '-1', _("-- Inconnu --"));
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_telf" align="right"><?PHP echo _("Téléphone Fixe"); ?> </td>
            <td>
                <input name="telf" type="text" id="telf" value="<?PHP echo $scli_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_fax" align="right"><?PHP echo _("Télécopieur"); ?></td>
            <td>
                <input name="fax" type="text" id="fax" value="<?PHP echo $scli_fax ?>" size="20" maxlength="20">
            </td>
        </tr>
        <tr>
            <td class="rubfrm" id="f_email" align="right"><?PHP echo _("Email"); ?></td>
            <td>
                <input name="email" type="text" id="email" value="<?PHP echo $scli_email ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $scli_email ?>"><img src="../img/mail.png"
                                                                    title="<?PHP echo _("Envoyer e-mail"); ?>"
                                                                    border="0" align="absmiddle"></a>
                <?PHP } ?>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="rubfrm" id="f_resp" align="center"><?PHP echo _("Responsable du site"); ?></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rcivil" align="right"><?PHP echo _("Civilité"); ?></td>
            <td width="84%">
                <?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', '', $scli_rcivil, '', _("-- Faites votre choix --"));
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rprenom" align="right"><?PHP echo _("Prénom"); ?></td>
            <td><input name="rprenom" type="text" id="rprenom" value="<?PHP echo $scli_rprenom ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rnom" align="right"><?PHP echo _("Nom"); ?></td>
            <td><input name="rnom" type="text" id="rnom" value="<?PHP echo $scli_rnom ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rtelf" align="right"><?PHP echo _("Tél. Fixe"); ?></td>
            <td><input name="rtelf" type="text" id="rtelf" value="<?PHP echo $scli_rtelf ?>" size="20" maxlength="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rfax" align="right"><?PHP echo _("Télécopieur"); ?></td>
            <td><input name="rfax" type="text" id="rfax" value="<?PHP echo $scli_rfax ?>" size="20" maxlength="20"></td>
        </tr>
        <tr>
            <td width="160" 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 $scli_rtelp ?>" size="20" maxlength="20">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_remail" align="right"><?PHP echo _("Email"); ?></td>
            <td>
                <input name="remail" type="text" id="remail" value="<?PHP echo $scli_remail ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                <?PHP if ($td == "edit") { ?>
                <a href="mailto:<?PHP echo $scli_remail ?>"><img src="../img/mail.png"
                                                                 title="<?PHP echo _("Envoyer e-mail"); ?>" border="0"
                                                                 align="absmiddle"></a></td>
            <?PHP } ?>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_rfunc" align="right"><?PHP echo _("Fonction"); ?></td>
            <td>
                <?PHP
                // création de la liste des fonctions
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                $rech = "SELECT * FROM `" . TBFONC . "` ORDER BY fonc_desc";
                $rows = $db->get_results($rech, ARRAY_A);
                $db->disconnect();
                cre_select_tab('rfunc', 'func', $rows, 'fonc_code', 'fonc_desc', '', $scli_rcodefonc, '', _("-- Faites votre choix --"));
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_nota" align="right"><?PHP echo _("Notes"); ?></td>
            <td><textarea name="nota" id="nota"><?PHP echo $scli_nota ?></textarea></td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_ouvert" align="right"><?PHP echo("Ouvert ?"); ?></td>
            <td>
                <?PHP
                cre_select('actif', 'actif', $non_oui, intval($scli_actif));
                ?>
            </td>
        </tr>
        <?PHP
        if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) {
            ?>
            <tr>
                <td class="rubfrm" id="f_ccpta" align="right"><?PHP echo _("Code compta"); ?></td>
                <td>
                    <input name="ccpta" type="text" id="ccpta" value="<?PHP echo $scli_ccpta ?>">
                </td>
            </tr>
        <?PHP
        }
        ?>
        </table>
        <p align="center">
            <?PHP
            switch ($td)
            {
                case "add" :
                case "edit" :
                    echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
                    echo '<input name="enr" type="button" class="bton_std" id="enr" value="'._("Enregistrer").'">';
                    break;
                case "del" :
                    echo '<input name="del" type="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                    break;
            }
            ?>
        </p>
        </form>
    <?PHP
    }
} else
    close_fen_auto('', '');
?>
</body>
</html>