<?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/fic_age.inc.php");
include_once("../inc/fic_do.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_pw.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_tec.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("../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"]);
check_modules();
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$td = $_GET['td'];
$tl = $_GET['tl'];
$coderech = $_GET['code'];
$tec_dep = $_GET['dep'];

$nbinterventions = 0;
$nbcoloc = 0;
$pbm_tec = FALSE;
$sais_dteout = TRUE;
$sais_dconges = TRUE;
$sais_fconges = TRUE;

if (($tl < 1) OR ($tl > 3))
    $pbm_tec = TRUE;

if (@$_SESSION["niv_log"] == 4)
    $tl = 1;

if (@$_SESSION["niv_log"] == 6)
    $tl = 2;

if (@$_SESSION["niv_log"] == 10)
    $tl = 3;

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

    // Récupération des informations technicien
    $row = lit_enr_tec($coderech, TRUE);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
        if ($tl == 1)
            $nbcoloc = nb_coloc_tec($coderech, 2);
        if ($tl == 3)
            $nbcoloc = nb_coloc_tec($coderech, 4);

        switch ($_SESSION["niv_log"]) {
            case 4 :
                if ($tec_codeage <> $_SESSION["code_age"])
                    $pbm_tec = TRUE;
                break;
            case 6 :
                if ($tec_codedo <> $_SESSION["code_do"])
                    $pbm_tec = TRUE;
                break;
            case 10 :
                if ($tec_codest <> $_SESSION["code_st"])
                    $pbm_tec = TRUE;
                break;
        }

        if ($pbm_tec == FALSE) {
            $tec_datecreaf = datetolocal($tec_datecrea);
            $tec_congdf = datetolocal($tec_congd);
            $tec_congff = datetolocal($tec_congf);
            $tec_dateoutf = datetolocal($tec_dateout);

            if (($tec_out == TRUE) AND ($td <> "del"))
                $td = "view";
        }
    } else
        $pbm_tec = TRUE;
} else {
    if ($td == "add") {
        if (@$_SESSION["niv_log"] == 4)
            $tec_codeage = (@$_SESSION["code_log"]);
        if (@$_SESSION["niv_log"] == 6)
            $tec_codedo = (@$_SESSION["code_do"]);
        if (@$_SESSION["niv_log"] == 10)
            $tec_codest = (@$_SESSION["code_st"]);
        $tec_codepays = pays_connect_code($_SERVER['REMOTE_ADDR']);
        $tec_out = FALSE;
    } else
        $pbm_tec = TRUE;
}

if (trim($tec_couleur) == '')
    $tec_couleur = "#C5CED7";

switch ($td) {
    case "add" :
        $titre = _("CREATION COMPTE TECHNICIEN");
        $sais_dteout = FALSE;
        $sais_dconges = FALSE;
        $sais_fconges = FALSE;
        break;
    case "edit" :
        $titre = _("MISE A JOUR COMPTE TECHNICIEN");
        break;
    case "del" :
        $titre = _("SUPPRESSION COMPTE TECHNICIEN");
        $sais_dteout = FALSE;
        $sais_dconges = FALSE;
        $sais_fconges = FALSE;
        break;
    case "view" :
        $titre = _("VISUALISATION COMPTE TECHNICIEN");
        $sais_dteout = FALSE;
        $sais_dconges = FALSE;
        $sais_fconges = FALSE;
        break;
    default :
        $pbm_tec = 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 _("Fiche Technicien"); ?></title>

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

<script language="javascript">
    <!--
    var tab1_champ = [
        <?PHP
        if ($td=="add") {
            echo '"nom:datecreaf ; format:date ; masque:'.$_SESSION['date_fmtfull'].' ; req:Y ; txt:'._("Date embauche").' ; stok:frmok ; stbad:frmbad",';
            echo '"nom:emploi ; format:txt ; req:N ; txt:'._("Emploi").' ; lmx:50 ; stok:frmok ; stbad:frmbad",';
            echo '"nom:qualif ; format:txt ; req:N ; txt:'._("Qualification").' ; lmx:50 ; stok:frmok ; stbad:frmbad",';
            echo '"nom:niveau ; format:txt ; req:N ; txt:'._("Niveau / Ech. / Coeff.").' ; lmx:5 ; stok:frmok ; stbad:frmbad",';
            echo '"nom:echelon ; format:txt ; req:N ; txt:'._("Niveau / Ech. / Coeff.").' ; lmx:5 ; stok:frmok ; stbad:frmbad",';
            echo '"nom:coeff ; format:txt ; req:N ; txt:'._("Niveau / Ech. / Coeff.").' ; lmx:5 ; stok:frmok ; stbad:frmbad",';
            echo '"nom:couleur ; format:hexacol ; req:Y ; txt:'._("Couleur").'; lmn:7 ; lmx:7; stok:frmok ; stbad:frmbad",';
        }
        if (@$_SESSION["niv_log"] <> 4)
        {
            if ($tec_out == FALSE)
                echo '"nom:empl ; format:liste ; req:Y ; txt:'._("Employeur").' ; vmn:1 ; stok:frmok ; stbad:frmbad",';
            else
                echo '"nom:empl ; format:txt ; req:Y ; txt:'._("Employeur").' ; stok:frmok ; stbad:frmbad",';
        }
        else
            echo '"nom:empl ; format:txt ; req:Y ; txt:'._("Employeur").' ; stok:frmok ; stbad:frmbad",';
        ?>
        "nom:civil ; format:liste ; req:Y ; txt:<?PHP echo _("Civilité"); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
        "nom:prenom ; format:txt ; req:Y ; txt:<?PHP echo _("Prénom"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
        "nom:nom ; format:txt ; req:Y ; txt:<?PHP echo _("Nom"); ?> ; 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:telp ; format:telp ; req:Y ; txt:<?PHP echo _("Téléphone portable"); ?> ; stok:frmok ; stbad:frmbad",
        "nom:email ; format:mail ; req:Y ; txt:<?PHP echo _("Email"); ?> ; stok:frmok ; stbad:frmbad",
        "nom:mess ; format:mail ; req:N ; txt:<?PHP echo _("Messagerie"); ?>  ; stok:frmok ; stbad:frmbad",
        "nom:nota ; format:txt ; req:N ; txt:<?PHP echo _("Notes"); ?> ; stok:frmok ; stbad:frmbad"];
    //-->
</script>

    <?PHP if ($pbm_tec == FALSE) { ?>
    <script type="text/javascript">
        <!--
        $(function () {
            $("#nom").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#adr1").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#adr2").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#email").Setcase({caseValue: 'lower', changeonFocusout: true});
            $("#mess").Setcase({caseValue: 'lower', changeonFocusout: true});
            $("#prenom").Setcase({caseValue: 'allfirst', changeonFocusout: true});
        });

        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"); ?>"
            });
            <?PHP if ($td == "add") { ?>
            $("#datecreaf").datepicker({
                onSelect: function (datesel) {
                    $("#datecreaf").blur();
                    return chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, '', '', 'today',false)
                }
            });
            <?PHP }

            if ($sais_dteout == TRUE) { ?>
            $("#dateoutf").datepicker({
                onSelect: function (datesel) {
                    $("#dateoutf").blur();
                    return chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, 'datecreaf,dconges,fconges', '', 'today',false);
                }
            });
            <?PHP }

            if ($sais_dconges == TRUE) { ?>
            $("#dconges").datepicker({
                onSelect: function (datesel) {
                    $("#dconges").blur();
                    return chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, 'datecreaf', '', 'dateoutf,fconges',false);
                }
            });
            <?PHP }

           if ($sais_fconges == TRUE) { ?>
            $("#fconges").datepicker({
                onSelect: function (datesel) {
                    $("#fconges").blur();
                    return chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, 'dconges,today,datecreaf', '', 'dateoutf',false);
                }
            });
            <?PHP } ?>
        }

        function init_all() {
            init_Body();
            init_datepicker();
            <?php
            switch ($td)
            {
                case "add" :
                    if (($_SESSION["niv_log"] == 4) OR ($_SESSION["niv_log"] == 5) OR ($_SESSION["niv_log"] == 9))
                        echo "init_warn('".nb_age_actives()."age','','back','','');";
                    echo "init_valid_tec('enr','tec_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'pays','');";
                    break;
                case "edit" :
                    if (($_SESSION["niv_log"] == 4) OR ($_SESSION["niv_log"] == 5) OR ($_SESSION["niv_log"] == 9))
                        echo "init_warn('".last_id_tecpr($tec_code)."tecpr','','','','');";
                    echo "init_fensaisie('edit_tecpr',850,700);";
                    echo "init_fensaisie('edit_pla',1020,760);";
                    echo "init_new_fen('imprim','impression','click');";
                    echo "init_valid_tec('enr','tec_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'pays','');";
                    break;
                case "view" :
                    echo "readonly_all();";
                    echo "init_new_fen('imprim','impression','click');";
                    break;
                case "del" :
                    echo "readonly_all();";
                    echo "warn_del('scli');";
                    break;
            }
            ?>
            $('#boxpicker').hide();
            init_colorpicker();
            display_colorpicker();
            close_colorpicker();
            valid_colorpicker();
            init_ajax_ville();
            init_ajax_dep();
            init_back('annul', 'click');
            init_autohref('coloc_add', 'click', '', true);
            init_autohref('coloc_view', 'click', '', true);
            init_autohref('int_view', 'click', '', true);
            init_autoraz('razdatecreaf', 'datecreaf', 'click');
            init_autoraz('razdateoutf', 'dateoutf', 'click');
            init_autoraz('razconges', 'dconges', 'click');
            init_autoraz('razconges', 'fconges', '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>

<p align="center"><span class="annot_std_it">
<?PHP
switch ($tl) {
    case 1 :
        echo "(" . _("Agence") . ")";
        break;
    case 2 :
        echo "(" . _("Donneur d'ordres") . ")";
        break;
    case 3 :
        echo "(" . _("Sous-traitant") . ")";
        break;
    default :
        break;
}
?>
</span></p>
<?PHP
if ($pbm_tec == FALSE) {
    if (nb_civ() <> 0) {
        ?>
        <!-- affiché uniquement s'il y a au moins une civilité -->
        <table width="100%" border="0">
            <tr>
                <td width="33%"
                    class="annot_gras_it"><?PHP aff_lnk_lst_rech('tec_lst.php?td=std&tl=' . $tl, _("Retour à la liste"), $_SERVER['HTTP_REFERER'], _("Retour à la page précédente")); ?></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 = "tec_maji.php?code=" . $coderech;
                        if (url_ok($urlimp) == TRUE) {
                            echo '<div id="imprim" align="right" title="' . $urlimp . '" class="falselnk">';
                            echo '<img src="../img/print.png" title="' . $urlimp . '" border="0" align="absmiddle"> ' . _("Imprimer");
                            echo '</div>';
                        } else
                            echo '&nbsp;';
                    } else
                        echo '&nbsp;';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="33%">&nbsp;</td>
                <td width="33%" align="center">
                    <?PHP if (($td == "edit") AND (@$_SESSION["niv_log"] >= 4) AND (($tl == 1) OR ($tl == 3))) {
                        $url_addcoloc = "coloc_maj.php?td=add";
                        if (url_ok($url_addcoloc) == TRUE) {
                            if ($tl == 1)
                                $url_addcoloc .= "&tc=2";
                            else
                                $url_addcoloc .= "&tc=4";
                            $url_addcoloc .= "&cc=" . $tec_code . "&ca=";
                            cre_falselnk('', 'coloc_add', 'span', '', _("Saisir contrat location"), $url_addcoloc, '../img/coloc.png', _("Saisir contrat location"));
                        }
                        $url_coloc = "coloc_lst.php?ord=DES&tri=Code&search=" . $tec_code . "&rech=Rechercher";
                        if (url_ok($url_coloc) == TRUE) {
                            if ($nbcoloc <> 0)
                                cre_falselnk('', 'coloc_view', 'span', '', _("Voir contrats location"), $url_coloc, '', _("Voir contrats location"),true);
                        }
                    } else
                        echo "&nbsp;";
                    ?>
                </td>
                <td width="33%" align="right">
                    <?PHP
                    if ((($td == "edit") OR ($td == "view")) AND ($nbinterventions <> 0)) {
                        $url_inter = "int_lst.php?ord=DES&tri=Code&search=" . $tec_code . "&rech=Rechercher";
                        if (url_ok($url_inter) == TRUE)
                            cre_falselnk('', 'int_view', 'span', '', _("Voir ses interventions") . ' (' . sprintf("%'03s", $nbinterventions) . ')', $url_inter, '', _("Voir ses interventions") . ' (' . sprintf("%'03s", $nbinterventions) . ')');
                    } else
                        echo "&nbsp;";
                    ?>
                </td>
            </tr>
        </table>

        <form name="tec_maj" method="post" id="tec_maj" action="tec_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="tl" type="hidden" id="tl" value="<?PHP echo $tl ?>">
        <input name="today" type="hidden" id="today" value="<?PHP echo $datef; ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <?PHP if ($td == "add") { ?>
            <input name="code" type="hidden" id="code" value="<?PHP echo $tec_code ?>">
            <input name="dateoutf" type="hidden" id="dateoutf" value="">
        <?PHP } ?>
        <?PHP if ($td <> "add") { ?>
            <table width="100%" border="0">
                <tr>
                    <td width="160" class="rubfrm" id="f_codetec" align="right"><?PHP echo _("Code"); ?></td>
                    <td>
                        <input name="code" type="text" id="code" value="<?PHP echo $tec_code ?>" readonly>
                        <?PHP
                        if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 10)) {
                            $url_tecpr = "tecpr_maj.php?td=add&ct=" . $tec_code . "&tl=" . $tl;
                            if (url_ok($url_tecpr) == TRUE)
                                cre_falselnk('', 'edit_tecpr', 'span', '', _("Prix de revient"), $url_tecpr, '../img/pr.png', _("Prix de revient"));
                        }

                        if ((@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 10)) {
                            // On vérifie si le module planning est bien en place
                            if ($mod_planning == TRUE) {
                                $url_planning = 'plan_maj.php?typd=1&coded=' . $tec_code . '&tx=tec&from=tec';
                                if (url_ok($url_planning) == TRUE)
                                    cre_falselnk('', 'edit_pla', 'span', '', _("Planning"), $url_planning, '../img/planning.png', _("Planning"),true);
                            }
                        }
                        ?>
                    </td>
                </tr>
            </table>
        <?PHP } ?>
        <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_datecreaf" align="right">
                    <?PHP echo _("Embauche"); ?>
                </td>
                <td>
                    <?PHP
                    echo '<input name="datecreaf" type="text" id="datecreaf"';
                    echo ' value="' . $tec_datecreaf . '" size="10"';
                    echo 'readonly="1"';
                    echo '>';
                    echo ' <img src="../img/raz.png" id="razdatecreaf" border="0" align="absmiddle">';
                    if ($td == "add")
                        echo ' <img src="../img/oblig.png" align="absmiddle" alt="' . _("Champ obligatoire") . '">';
                    ?>
                </td>
            </tr>
            <?PHP if (($td == "edit") OR ($td == "del") OR ($td == "view")) { ?>
                <tr>
                    <td width="160" class="rubfrm" id="f_dateoutf" align="right">
                        <?PHP echo _("Départ"); ?>
                    </td>
                    <td>
                        <?PHP
                        echo '<input name="dateoutf" type="text" id="dateoutf"';
                        echo ' value="' . $tec_dateoutf . '" size="10"';
                        echo 'readonly="1"';
                        echo '>';
                        echo ' <img src="../img/raz.png" id="razdateoutf" border="0" align="absmiddle">';
                        if ($ope_out == FALSE)
                            echo '<div class="annot_petit_it">' . _("Si vous saisissez une date, le technicien ne sera plus considéré comme salarié") . '</div>';
                        ?>
                    </td>
                </tr>
                <tr>
                    <td width="160" class="rubfrm" id="f_conges" align="right"><?PHP echo _("Congés"); ?></td>
                    <td colspan="3">
                        <span class="annot_petit_gras">du</span>
                        <input name="dconges" type="text" id="dconges" value="<?PHP echo $tec_congdf; ?>" size="10"
                               maxlength="10" readonly>
                        <span class="annot_petit_gras"> <?PHP echo _("au"); ?> </span>
                        <input name="fconges" type="text" id="fconges" value="<?PHP echo $tec_congff; ?>" size="10"
                               maxlength="10" readonly>
                        <?PHP
                        if ($ope_out == FALSE) {
                            echo ' <img src="../img/raz.png" id="razconges" border="0" align="absmiddle">';
                            echo '<div class="annot_petit_it">' . _("Prochains congés ou congés en cours") . '</div>';
                        }
                        ?>
                    </td>
                </tr>
            <?PHP } ?>
            <tr>
                <td width="160" class="rubfrm" id="f_emploi" align="right"><?PHP echo _("Emploi"); ?>
                </td>
                <td>
                    <input name="emploi" type="text" id="emploi" value="<?PHP echo $tec_emploi; ?>" size="50">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_qualif" align="right"><?PHP echo _("Qualification"); ?>
                </td>
                <td>
                    <input name="qualif" type="text" id="qualif" value="<?PHP echo $tec_qualif; ?>" size="50">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_niveau" align="right"><?PHP echo _("Niveau / Ech. / Coeff."); ?>
                </td>
                <td>
                    <input name="niveau" type="text" id="niveau" value="<?PHP echo $tec_niveau; ?>" size="5">
                    /
                    <input name="echelon" type="text" id="echelon" value="<?PHP echo $tec_echelon; ?>" size="5">
                    /
                    <input name="coeff" type="text" id="coeff" value="<?PHP echo $tec_coeff; ?>" size="5">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_couleur" align="right"><?PHP echo _("Couleur"); ?>
                    (<?PHP echo _("Plannings"); ?>)
                </td>
                <td>
                    <div id="boxpicker" class="pick_box">
                        <div style="float:right;">
                            <img id="colorpicker_valid" src="../img/ok.png" border="0" align="absmiddle" title="<?PHP echo _("Valider"); ?>" alt="<?PHP echo _("Valider"); ?>">
                            <img id="colorpicker_close" src="../img/rech_close.png" border="0" align="absmiddle" title="<?PHP echo _("Fermer"); ?>" alt="<?PHP echo _("Fermer"); ?>">
                        </div>
                        <div id="colorpicker" style="clear:both;">
                        </div>
                    </div>
                    <input id="couleur_init" name="couleur_init" type="hidden" value="<?PHP echo $tec_couleur; ?>"
                           readonly>
                    <input id="couleur" name="couleur" type="hidden" value="<?PHP echo $tec_couleur; ?>" readonly>
                    <input id="couleur_display" name="couleur_display" type="button" value=""
                           style="background-color:<?PHP echo $tec_couleur; ?>;" class="exemple_color">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">

                    <div class="annot_petit_it"><?PHP echo _("Cliquez sur la couleur pour la changer") ?></div>
                </td>
            </tr>
        </table>

        <table width="100%" border="0">
        <tr>
            <td width="160" class="rubfrm" id="f_agence" align="right">
                <?PHP
                switch ($tl) {
                    case 1 :
                        echo _("Agence");
                        break;
                    case 2 :
                        echo _("Donneur d'ordres");
                        break;
                    case 3 :
                        echo _("Sous-traitant");
                        break;
                    default :
                        break;
                }
                ?>
            </td>
            <td>
                <?PHP
                if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 6) AND (@$_SESSION["niv_log"] <> 10)) {
                    // Technicien présent
                    switch ($tl) {
                        // création de la liste des agences
                        case 1 :
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "SELECT * FROM `" . TBAGE . "`, `" . TBPW . "` WHERE " . TBAGE . ".age_code=" . TBPW . ".pw_code AND " . TBPW . ".pw_actif='1' ORDER BY age_code";
                            $rows = $db->get_results($rech, ARRAY_A);
                            $db->disconnect();
                            cre_select_tab('empl', 'empl', $rows, 'age_code', 'age_nom', 'age_code', $tec_codeage, '', _("-- Faites votre choix --"));
                            break;

                        // création de la liste des donneurs d'ordres
                        case 2 :
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "SELECT * FROM `" . TBDO . "`, `" . TBPW . "` WHERE " . TBDO . ".do_code=" . TBPW . ".pw_code AND " . TBPW . ".pw_actif='1' ORDER BY do_code";
                            $rows = $db->get_results($rech, ARRAY_A);;
                            $db->disconnect();
                            cre_select_tab('empl', 'empl', $rows, 'do_code', 'do_nom', 'do_code', $tec_codedo, '', _("-- Faites votre choix --"));
                            break;

                        // création de la liste des sous-traitants
                        case 3 :
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "SELECT * FROM `" . TBST . "`, `" . TBPW . "` WHERE " . TBST . ".st_code=" . TBPW . ".pw_code AND " . TBPW . ".pw_actif='1' ORDER BY st_code";
                            $rows = $db->get_results($rech, ARRAY_A);
                            $db->disconnect();
                            cre_select_tab('empl', 'empl', $rows, 'st_code', 'st_nom', 'st_code', $tec_codest, '', _("-- Faites votre choix --"));
                            break;
                        default :
                            break;
                    }
                } else {
                    switch (@$_SESSION["niv_log"]) {
                        case 4 :
                            if ($tec_codeage <> "") {
                                $row = lit_enr_age($tec_codeage, TRUE);
                                if (is_array($row)) {
                                    $row = encode_str($row);
                                    extract($row);
                                }
                                $empl = $tec_codeage;
                            }
                            break;
                        case 6 :
                            if ($tec_codedo <> "") {
                                $row = lit_enr_do($tec_codedo);
                                if (is_array($row)) {
                                    $row = encode_str($row);
                                    extract($row);
                                }
                                $empl = $tec_codedo;
                            }
                            break;
                        case 10 :
                            if ($tec_codest <> "") {
                                $row = lit_enr_st($tec_codest);
                                if (is_array($row)) {
                                    $row = encode_str($row);
                                    extract($row);
                                }
                                $empl = $tec_codest;
                            }
                            break;
                        default :
                            break;
                    }
                    echo '<input name="empl" type="hidden" id="empl" value="' . $empl . '">';
                    switch (@$_SESSION["niv_log"]) {
                        case 4 :
                            if ($tec_codeage <> "")
                                echo '<input name="nagence" type="text" id="nagence" value="' . $age_nom . '" size="50" readonly="1"> (Agence)';
                            break;
                        case 6 :
                            if ($tec_codedo <> "")
                                echo '<input name="ndo" type="text" id="ndo" value="' . $do_nom . '" size="50" readonly="1"> (Donneur d\'ordres)';
                            break;
                        case 10 :
                            if ($tec_codest <> "")
                                echo '<input name="nst" type="text" id="nst" value="' . $st_nom . '" size="50" readonly="1"> (Sous-traitant)';
                            break;
                    }
                }
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_civil" 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('civil', 'civil', $rows, 'civ_code', 'civ_desc', '', $tec_civilite, '', _("-- Faites votre choix --"));
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_prenom" align="right"><?PHP echo _("Prénom"); ?></td>
            <td>
                <input name="prenom" type="text" id="prenom" value="<?PHP echo $tec_prenom; ?>" size="50">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </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 $tec_nom ?>" size="50">
                <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 $tec_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 $tec_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', '', $tec_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($tec_codepays);
                cre_select_tab('dep', 'dep', $rows, 'dep_code', 'dep_code', 'dep_nom', $tec_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($tec_dep,$tec_codepays);
                cre_select_tab('ville', 'ville', $rows, 'villes_id', 'villes_nom', 'villes_cp', $tec_ville, '', _("-- Faites votre choix --"), 1, FALSE, '-1', _("-- Inconnu --"));
                ?>
            </td>
        </tr>
        <tr>
            <td width="160" 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 $tec_telf ?>" size="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_fax" align="right"><?PHP echo _("Télécopieur"); ?></td>
            <td>
                <input name="fax" type="text" id="fax" value="<?PHP echo $tec_fax ?>" size="20">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_telp" align="right"><?PHP echo _("Téléphone portable"); ?></td>
            <td>
                <input name="telp" type="text" id="telp" value="<?PHP echo $tec_telp ?>" size="20">
                <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_email" align="right"><?PHP echo _("Email"); ?></td>
            <td>
                <input name="email" type="text" id="email" value="<?PHP echo $tec_email ?>" size="50">
                <?PHP if ($td == "edit") { ?>
                    <a href="mailto:<?PHP echo $tec_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"); ?>">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_mess" align="right"><?PHP echo _("Messagerie"); ?></td>
            <td>
                <input name="mess" type="text" id="mess" value="<?PHP echo $tec_mess ?>" size="50">
            </td>
        </tr>
        <tr>
            <td width="160" class="rubfrm" id="f_nota" align="right"><?PHP echo _("Notes"); ?></td>
            <td>
                <textarea name="nota" rows="5" id="nota"><?PHP echo $tec_nota ?></textarea>
            </td>
        </tr>
        </table>
        <?PHP
        if ($tec_out == FALSE) {
            ?>
            <p align="center">
                <?PHP if (($td == "edit") or ($td == "add")) { ?>
                    <input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo _("Réinitialiser"); ?>">
                    <input name="enr" type="button" class="bton_std" id="enr" value="<?PHP echo _("Enregistrer"); ?>">
                <?PHP
                }
                if ($td == "del") {
                    ?>
                    <input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo _("Supprimer"); ?>">
                    <input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo _("Annuler"); ?>">
                <?PHP } ?>
            </p>
        <?PHP
        }
        ?>
        </form>
        <!-- Fin affiché uniquement s'il y a au moins une une civilité -->
    <?PHP
    } else
        pop_ret_auto(_("Aucune civilité"), 'warn', "civ_lst.php");
} else
    pop_ret_auto(_("Problème de paramètres"), 'warn', 'tec_lst.php?td=std&tl=' . $tl);
include_once("pied.php");
?>
</body>
</html>