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


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

include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/lst.inc.php");
include_once("../classes/ezSQL/shared/ez_sql_core.php");
include_once("../classes/ezSQL/mysqli/ez_sql_mysqli.php");
include_once("../inc/func_sql.inc.php");
Archivelog(@$_SESSION["code_log"]);
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$td = "";
if (isset($_GET['td']))
    $td = @$_GET['td'];
else
    $td = @$_POST['td'];
$codetec = "";
if (isset($_GET['ct']))
    $codetec = @$_GET['ct'];
else
    $codetec = @$_POST['ct'];
$tl = "";
if (isset($_GET['tl']))
    $tl = intval(@$_GET['tl']);
else
    $tl = intval(@$_POST['tl']);

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

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

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

$id = 0;
if (isset($_GET['id']))
    $id = intval(@$_GET['id']);
else
    if (isset($_POST['id']))
        $id = intval(@$_POST['id']);

$pbm_tec = FALSE;
$pbm_enr_tecpr = FALSE;
$msg = "";
$lastid = 0;
$lastdate = "";
$datecrea = "";
if ($codetec <> "") {
    $row = lit_enr_tec($codetec, TRUE);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
        // vérification tentative de hack d'une agence
        if (@$_SESSION["niv_log"] == 4) {
            if ($tec_codeage <> $_SESSION["code_age"])
                $pbm_tec = TRUE;
        }

        // vérification tentative de hack d'un sous-traitant
        if (@$_SESSION["niv_log"] == 10) {
            if ($tec_codest <> $_SESSION["code_st"])
                $pbm_tec = TRUE;
        }

        if ($pbm_tec == FALSE) {
            switch ($tl) {
                case 1 :
                    $row = lit_enr_age($tec_codeage, TRUE);
                    $codeadev = give_dev_codea_defaut_age($tec_codeage, $_SESSION["lng"]);
                    break;
                case 3 :
                    $row = lit_enr_st($tec_codest, TRUE);
                    $codeadev = give_dev_codea_defaut_st($tec_codest, $_SESSION["lng"]);
                    break;
            }
            if (is_array($row)) {

                extract($row);
                switch ($tl) {
                    case 1 :
                        $datecrea = $age_datecrea;
                        break;
                    case 3 :
                        $datecrea = $st_datecrea;
                        break;
                }

                if (last_id_tecpr($codetec) == 0)
                    $td = "add";

                if (@$_POST["nbutton"] == "enr") {
                    $datesais = @$_POST["date"];
                    if ($datesais <> "")
                        $datesaisa = datetomysql($datesais);
                    else
                        $datesaisa = "";
                    $hj = @$_POST["hj"] . ":00";
                    $hjs = heure_sec($hj);
                    $hh = @$_POST["hh"] . ":00";
                    $hhs = heure_sec($hh);
                    $hm = @$_POST["hm"] . ":00";
                    $hms = heure_sec($hm);
                    $salm = floatval(@$_POST["salm"]);
                    $couth = floatval(@$_POST["couth"]);

                    if (($datesaisa <> "") AND (floatval($couth) > 0)) {
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        if (@$_POST["nbutton"] == "enr") {
                            switch ($td) {
                                case "add" :
                                    $rech = "INSERT INTO `" . TBTECPR . "`";
                                    $rech .= " (tecpr_codetec,tecpr_date,tecpr_hjs,tecpr_hhs,tecpr_hms,tecpr_salm,";
                                    for ($key = 1; $key < 8; $key++) {
                                        $variable = "j" . $key . "m1";
                                        $rech .= " tecpr_" . $variable . ",";
                                        $variable = "j" . $key . "m2";
                                        $rech .= " tecpr_" . $variable . ",";
                                        $variable = "j" . $key . "a1";
                                        $rech .= " tecpr_" . $variable . ",";
                                        $variable = "j" . $key . "a2";
                                        $rech .= " tecpr_" . $variable . ",";
                                    }
                                    $rech .= "tecpr_couth) VALUES";
                                    $rech .= " ('$codetec','$datesaisa','$hjs','$hhs','$hms','$salm',";
                                    for ($key = 1; $key < 8; $key++) {
                                        $variable = "j" . $key . "m1";
                                        $rech .= " '" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "m2";
                                        $rech .= " '" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "a1";
                                        $rech .= " '" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "a2";
                                        $rech .= " '" . $_POST[$variable] . ":00',";
                                    }
                                    $rech .= "'$couth')";
                                    break;
                            case "edit" :
                                if ($id <> 0) {
                                    $rech = "UPDATE `" . TBTECPR;
                                    $rech .= "` SET `tecpr_date`='" . $datesaisa . "',`tecpr_couth`='" . $couth . "',";
                                    $rech .= " `tecpr_hjs`='" . $hjs . "',`tecpr_hhs`='" . $hhs . "',";
                                    $rech .= " `tecpr_hms`='" . $hms . "',";
                                    for ($key = 1; $key < 8; $key++) {
                                        $variable = "j" . $key . "m1";
                                        $rech .= " `tecpr_" . $variable . "`='" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "m2";
                                        $rech .= " `tecpr_" . $variable . "`='" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "a1";
                                        $rech .= " `tecpr_" . $variable . "`='" . $_POST[$variable] . ":00',";
                                        $variable = "j" . $key . "a2";
                                        $rech .= " `tecpr_" . $variable . "`='" . $_POST[$variable] . ":00',";
                                    }
                                    $rech .= "`tecpr_salm`='" . $salm . "'";
                                    $rech .= "  WHERE `tecpr_id` = '" . $id . "'";
                                }
                                break;
                            }
                        }
                        $db->query($rech);
                        $db->disconnect();
                        unset($_POST);
                        $td = "add";
                    } else {
                        $pbm_enr_tecpr = TRUE;
                        $msg = _("Problème de saisie");
                    }
                } else {
                    if (@$_POST["nbutton"] == "del") {
                        if ($id <> 0) {
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "DELETE FROM `" . TBTECPR . "` WHERE `tecpr_id` = '$id'";
                            $db->query($rech);
                            $db->disconnect();
                        }
                        unset($_POST);
                        $td = "add";
                    }
                }
            } else
                $pbm_tec = TRUE;
        }
    } else
        $pbm_tec = TRUE;
} else
    $pbm_tec = TRUE;

if ($pbm_tec == FALSE) {
    $lastid = last_id_tecpr($codetec);
    $datemini = datetolocal($datecrea);
    $datesais = datetolocal($datecrea);

    switch ($td) {
        case "add" :
            $titre = _("Ajouter prix de revient");
            if ($lastid > 0) {
                $row = lit_enr_tecpr($lastid);
                if (is_array($row)) {
                    $row = encode_str($row);
                    extract($row);
                }
                $lastdate = $tecpr_date;
                $datesais = datetolocal(nouv_date_plus_jours($tecpr_date, 1));
                $datemini = $datesais;
                // Récupération horaires
                $tecpr_hj = heure_to_hhmm(sec_heure($tecpr_hjs));
                $tab_heure = explode(":", sec_heure($tecpr_hhs));
                $tecpr_hh = $tab_heure[0] . ":" . $tab_heure[1];
                $tab_heure = explode(":", sec_heure($tecpr_hms));
                $tecpr_hm = $tab_heure[0] . ":" . $tab_heure[1];
            } else
                $tecpr_hj = "07:00";
            break;
        case "edit" :
        case "view" :
        case "del" :
            if ($id <> 0) {
                $row = lit_enr_tecpr($id);
                if (is_array($row)) {
                    $row = encode_str($row);
                    extract($row);
                }
                $datesais = datetolocal($tecpr_date);
                $previd = last_id_tecpr($codetec, TRUE, $id);
                if ($previd <> 0)
                    $datemini = datetolocal(nouv_date_plus_jours(last_date_tecpr($previd),1));
                // Récupération horaires
                $tecpr_hj = heure_to_hhmm(sec_heure($tecpr_hjs));
                $tab_heure = explode(":", sec_heure($tecpr_hhs));
                $tecpr_hh = $tab_heure[0] . ":" . $tab_heure[1];
                $tab_heure = explode(":", sec_heure($tecpr_hms));
                $tecpr_hm = $tab_heure[0] . ":" . $tab_heure[1];
            }
            if ($td == "edit")
                $titre = _("Editer prix de revient");
            if ($td == "view")
                $titre = _("Voir prix de revient");
            if ($td == "del")
                $titre = _("Supprimer prix de revient");
            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 _("Prix de revient technicien"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:date ; format:date ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; req:Y ; txt:<?PHP echo _("Date"); ?> ; stok:frmok ; stbad:frmbad",
            "nom:hj; format:dureehhmm ; req:N ; txt:<?PHP echo _("Horaire journalier"); ?> ; stok:frmok ; stbad:frmbad",
            "nom:hh; format:dureehhmm ; req:N ; txt:<?PHP echo _("Horaire hebdomadaire"); ?> ; stok:frmok ; stbad:frmbad",
            "nom:hm; format:dureehhmm ; req:N ; txt:<?PHP echo _("Horaire mensuel"); ?> ; stok:frmok ; stbad:frmbad",
            "nom:salm; format:reel_ns ; req:N ; txt:<?PHP echo _("Salaire mensuel"); ?> ; stok:frmok ; stbad:frmbad",
            <?PHP
                foreach ($lng_tjourf as $key=>$value)
                {
                    $variable="j".$key."m1";
                    echo '"nom:'.$variable.'; format:heurehhmm ; req:N ; txt:'._("Horaire début matin").' '.$value.' ; stok:frmok ; stbad:frmbad",';
                    $variable="j".$key."m2";
                    echo '"nom:'.$variable.'; format:heurehhmm ; req:N ; txt:'._("Horaire fin matin").' '.$value.' ; stok:frmok ; stbad:frmbad",';
                    $variable="j".$key."a1";
                    echo '"nom:'.$variable.'; format:heurehhmm ; req:N ; txt:'._("Horaire début après-midi").' '.$value.' ; stok:frmok ; stbad:frmbad",';
                    $variable="j".$key."a2";
                    echo '"nom:'.$variable.'; format:heurehhmm ; req:N ; txt:'._("Horaire fin après-midi").' '.$value.' ; stok:frmok ; stbad:frmbad",';
                }
            ?>
            "nom:couth; format:reel_ns ; req:Y ; txt:<?PHP echo _("coût horaire"); ?> ; vmn:0.01 ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

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

            function init_all() {
                init_Body();
                init_autohref_classe('falselnkimg','');
                init_fdeci('salm', <?PHP echo $_SESSION['num_nbdec']; ?>);
                init_fdeci('couth', <?PHP echo $_SESSION['num_nbdec']; ?>);
                init_datepicker();
                <?php
                switch ($td)
                {
                    case "add" :
                    case "edit" :
                        echo '$("#date").datepicker({';
                        echo '    onSelect: function (datesel) {';
                        echo '        $("#date").blur();';
                        echo "        chk_datedif(datesel, this.id, '".$_SESSION['date_fmtshort']."', true, 'datemini', '', '',false)";
                        echo '    }';
                        echo '});';
                        echo "init_autoraz('razdate','date','click');";
                        echo "init_valid_form('enr','tecpr_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        break;
                    case "del" :
                        echo "init_valid_form('del','tecpr_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        echo "warn_del('');";
                        echo "readonly_all();";
                        break;
                    case "view" :
                        echo "readonly_all();";
                        break;
                }
                ?>
                init_autoraz('raz', 'date', 'click');
                init_autohref('annul', 'click', 'tecpr_maj.php?td=add&ct=<?PHP echo $codetec; ?>',false);
                add_func_click('quit', 'sclose','');
                init_fmtduree('hj', 'hhm', 'change');
                init_fmtduree('hh', 'hhhm', 'change');
                init_fmtduree('hm', 'hhhm', 'change');
                Focus_first();
            }

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

<body>
<?PHP
if (($pbm_tec == FALSE) AND ($pbm_enr_tecpr == FALSE)) {
    ?>
    <p align="center"><span class="titrepage"><?PHP echo _("PRIX DE REVIENT"); ?></span></p>
    <p align="center"><span class="titre_gras"><?PHP echo _("Pour le technicien"). ' : '.$tec_nom . ' ' . $tec_prenom; ?> </span></p>
    <div align="right">
        <input name="quit" type="button" class="bton_std" id="quit" value="<?PHP echo _("Quitter"); ?>">
    </div>
    <br />
<?PHP
$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
$rech = "SELECT * FROM `" . TBTECPR . "` WHERE `tecpr_codetec`= '" . $codetec . "' ORDER BY tecpr_id";
$rows = $db->get_results($rech, ARRAY_A);

if ($rows) {
    echo "<table class=\"MtableD\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";

    // création de l'entête de la table "détail prix de revient"
    echo "<th>";
    echo _("Date");
    echo "</th>\n";
    echo "<th>";
    echo _("Coût horaire");
    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 align=\"center\">\n";
        echo datetolocal($row["tecpr_date"]);
        echo "<td align=\"right\">\n";
        echo full_num_format($row["tecpr_couth"], '', FALSE);
        echo "</td>\n";
        echo "<td align=\"center\">\n";
        if (($td <> "view") AND ($lastid == $row["tecpr_id"])) {
            $lst_maj = TRUE;
            cre_falselnk_img('', 'tecpr_edit_'.$row["tecpr_id"], 'span', 'center', _("Edition"), 'lnk', 'tecpr_maj.php?td=edit&ct=' . $codetec . '&id=' . $row["tecpr_id"], '../img/edit.png');
            $lst_del = TRUE;
            cre_falselnk_img('', 'tecpr_del_'.$row["tecpr_id"], 'span', 'center', _("Edition"), 'lnk', 'tecpr_maj.php?td=del&ct=' . $codetec . '&id=' . $row["tecpr_id"], '../img/del.png');
        } else
            echo "-";
        echo "</td>\n";

        echo "</tr>\n";

        $j++;
    }

    echo "</table>\n";
    // Fin affichage table détail horaire
} else
    echo '<p class="annot_petit_it">'._("Aucun prix de revient enregistré").'</p>';

$db->disconnect();

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

if ($td <> "view")
{
?>
<br />
    <form name="tecpr_maj" id="tecpr_maj" class="bord_pointilles" method="post" action="tecpr_maj.php">
        <p align="center" class="annot_std_gras"><?PHP echo $titre; ?></p>

        <p align="center" class="annot_petit_it"><?PHP echo _("Tous les champs sont obligatoires"); ?></p>
        <input name="td" type="hidden" id="td" value="<?PHP echo $td; ?>">
        <input name="ct" type="hidden" id="ct" value="<?PHP echo $codetec; ?>">
        <input name="id" type="hidden" id="id" value="<?PHP echo $id; ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <input name="datemini" type="hidden" id="datemini" value="<?PHP echo $datemini; /* if ($lastid>0) {if ($td=="add") echo datetolocal(nouv_date_plus_jours($lastdate,1)); else echo datetolocal($lastdate); } else echo datetolocal($datecrea); */?> ">
        <table width="650" border="0" align="center">
            <tr>
                <td width="30%" class="rubfrm" id="f_date" align="right"><?PHP echo _("Date"); ?></td>
                <td align="left">
                    <input name="date" type="text" id="date" value="<?PHP echo $datesais; ?>" size="10" maxlength="10" readonly="1">
                    <?PHP
                    if (($td == "add") OR ($td == "edit"))
                        echo ' <img src="../img/raz.png" id="razdate" border="0" align="absmiddle">';
                    echo '<div class="annot_petit_it">('._("Supérieur ou égal au").' '.$datemini.')</div>';
                    /*
                    switch ($td)
                    {
                        case "add" :
                            if ($lastid > 0)
                                echo '<div class="annot_petit_it">('._("Strictement supérieur à dernière date de modification").')</span>';
                            else {
                                echo '<div class="annot_petit_it">(' . _("Supérieur ou égal à la date de création");
                                switch ($tl) {
                                    case 1 :
                                        echo ' ' . _("de l'agence");
                                        break;
                                    case 3 :
                                        echo ' ' . _("du sous-traitant");
                                        break;
                                }
                                echo - datetolocal($age_datecrea) . ')';
                                echo '</div>';
                            }
                            break;
                        case "edit" :
                            echo '<div class="annot_petit_it">('._("Ne peut être inférieure à la date précédemment saisie").')</div>';
                            break;
                    }
                    */
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_hj" align="right"><?PHP echo _("Heures journalières"); ?></td>
                <td>
                    <input name="hj" type="text" id="hj" style="text-align:right" value="<?PHP echo $tecpr_hj ?>"
                           size="5" maxlength="8">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_hh" align="right"><?PHP echo _("Heures hebdomadaires"); ?></td>
                <td>
                    <input name="hh" type="text" id="hh" style="text-align:right" value="<?PHP echo $tecpr_hh ?>"
                           size="5" maxlength="8">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_hm" align="right"><?PHP echo _("Heures mensuelles"); ?></td>
                <td>
                    <input name="hm" type="text" id="hm" style="text-align:right" value="<?PHP echo $tecpr_hm ?>"
                           size="6" maxlength="9">
                </td>
            </tr>
            <tr>
                <td width="30%" class="rubfrm" id="f_salm" align="right"><?PHP echo _("Salaire mensuel"); ?></td>
                <td align="left">
                    <?PHP
                    cre_input_num('salm', $tecpr_salm, TRUE);
                    ?>
                </td>
            </tr>
            <tr>
                <td width="30%" class="rubfrm" id="f_horaires" align="right"><?PHP echo _("Horaires"); ?></td>
                <td align="left">
                    <table width="100%" border="0" align="center">
                        <tr>
                            <td>&nbsp;</td>
                            <td align="center" class="annot_std_it"><?PHP echo _("Matin"); ?></td>
                            <td align="center" class="annot_std_it"><?PHP echo _("Après-midi"); ?></td>
                        </tr>
                        <?PHP
                        foreach ($lng_tjourf as $key => $value) {
                            echo '<tr>';
                            echo '<td>' . $value . '</td>';
                            echo '<td align="center">';
                            echo _("de") . ' ';

                            // Création de la liste des heures début matinée
                            $variable = "\$tecpr_j" . $key . "m1";
                            eval ("\$valeur = substr($variable,0,5);");
                            echo '<select name="j' . $key . 'm1" id="j' . $key . 'm1">';
                            for ($i = 0; $i < 86400; $i += ($pla_stepmin * 60)) {
                                $heure = heure_to_hhmm(sec_heure($i));

                                if ($valeur == $heure)
                                    echo '<option value="' . $heure . '" selected>' . $heure . '</option>';
                                else
                                    echo '<option value="' . $heure . '">' . $heure . '</option>';
                            }
                            echo '</select>';
                            echo ' ' . _("à") . ' ';

                            // création de la liste des heures fin matinée
                            $variable = "\$tecpr_j" . $key . "m2";
                            eval ("\$valeur = substr($variable,0,5);");
                            echo '<select name="j' . $key . 'm2" id="j' . $key . 'm2">';
                            for ($i = 0; $i < 86400; $i += ($pla_stepmin * 60)) {
                                $heure = heure_to_hhmm(sec_heure($i));

                                if ($valeur == $heure)
                                    echo '<option value="' . $heure . '" selected>' . $heure . '</option>';
                                else
                                    echo '<option value="' . $heure . '">' . $heure . '</option>';
                            }
                            echo '</select>';
                            echo '</td>';
                            echo '<td align="center">';
                            echo _("de") . ' ';

                            // Création de la liste des heures début après-midi
                            $variable = "\$tecpr_j" . $key . "a1";
                            eval ("\$valeur = substr($variable,0,5);");
                            echo '<select name="j' . $key . 'a1" id="j' . $key . 'a1">';
                            for ($i = 0; $i < 86400; $i += ($pla_stepmin * 60)) {
                                $heure = heure_to_hhmm(sec_heure($i));

                                if ($valeur == $heure)
                                    echo '<option value="' . $heure . '" selected>' . $heure . '</option>';
                                else
                                    echo '<option value="' . $heure . '">' . $heure . '</option>';
                            }
                            echo '</select>';
                            echo ' ' . _("à") . ' ';

                            // Création de la liste des heures fin après-midi
                            $variable = "\$tecpr_j" . $key . "a2";
                            eval ("\$valeur = substr($variable,0,5);");
                            echo '<select name="j' . $key . 'a2" id="j' . $key . 'a2">';
                            for ($i = 0; $i < 86400; $i += ($pla_stepmin * 60)) {
                                $heure = heure_to_hhmm(sec_heure($i));

                                if ($valeur == $heure)
                                    echo '<option value="' . $heure . '" selected>' . $heure . '</option>';
                                else
                                    echo '<option value="' . $heure . '">' . $heure . '</option>';
                            }
                            echo '</select>';
                            echo '</td>';
                            echo '</tr>';
                        }
                        ?>
                    </table>
                </td>
            </tr>
            <tr>
                <td width="30%" class="rubfrm" id="f_tec" align="right"><?PHP echo _("Coût horaire"); ?></td>
                <td align="left">
                    <?PHP
                    cre_input_num('couth', $tecpr_couth, TRUE);
                    ?>
                </td>
            </tr>
        </table>
        <p align="center">
            <input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo _("Annuler"); ?>">
            <?PHP
            switch ($td) {
                case "add" :
                case "edit" :
                    echo '<input name="enr" type="button" class="bton_std" id="enr" value="' . _("Enregistrer") . '">';
                    break;
                case "del" :
                    echo '<input name="del" type="button" class="bton_std" id="del" value="' . _("Supprimer") . '">';
                    break;
            }
            ?>
        </p>
    </form>
<?PHP
}
} else {
    if ($pbm_tec == TRUE)
        close_fen_auto('', 'fscomp');

    if ($pbm_enr_tecpr == TRUE)
        pop_ret_auto($msg, 'ok', "tecpr_maj.php?ct=" . $codetec . "&td=" . $td . "&id=" . $id);
}
?>

</body>
</html>
