<?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_droits.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_pen.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/fic_taxes.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_time.inc.php");
include_once("../inc/func_txt.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 = @$_GET['td'];
$codepdt = @$_GET['cp'];
$codepl = @$_GET['pl'];

$pbm_bar = FALSE;

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

if (($codepdt <> "") AND ($codepl <> "")) {
    // Récupération des données de la fiche article
    $row = lit_enr_pdtloc($codepdt);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);

        $codeadev = give_dev_codea_defaut_pdtloc($codepdt, $_SESSION["lng"]);

        $row = lit_enr_perloc($codepl);

        if (is_array($row)) {
            $row = encode_str($row);
            extract($row);

            if ($td == "add") {
                $barloc_codeperloc = $codepl;
                $barloc_codepdtloc = $pdtloc_code;
            }

            if ($td == "edit") {
                $row = lit_enr_barloc_in_pdtloc($codepl, $codepdt);
                if (is_array($row))
                {
                    $row = encode_str($row);
                    extract($row);
                }
                else
                    $pbm_bar = TRUE;
            }

            if ($td == "del") {
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                $rech = "SELECT * FROM `" . TBBARLOC . "` WHERE `barloc_codeperloc` = '" . $db->escape($codepl) . "' AND `barloc_codepdtloc` = '" . $db->escape($codepdt) . "'";
                $row = $db->get_row($rech, ARRAY_A);
                if ($row)
                {
                    $row = encode_str($row);
                    extract($row);
                }
                else
                    $pbm_bar = TRUE;
                $db->disconnect();
            }

            // Récupération des informations TVA
            $row = lit_enr_tva($barloc_codetva, TRUE);
            if (is_array($row))
            {
                $row = encode_str($row);
                extract($row);
            }
            $txtva = $tva_tx / 100;
            $puttc = round(($barloc_pvht * (1 + $txtva)) * 100) / 100;

            $row = lit_enr_tva($barloc_codetvaass, TRUE);
            if (is_array($row))
            {
                $row = encode_str($row);
                extract($row);
            }
            $txtva = $tva_tx / 100;
            $mtassttc = round(($barloc_mtass * (1 + $txtva)) * 100) / 100;

            // vérification de la validité du barème
            if ((datetolocal($barloc_dateval2) <> "") AND (comp_date($datea, $barloc_dateval2) == FALSE))
                $barloc_actif = 0;

            // Formatage des dates en français
            $barloc_dateval1f = datetolocal($barloc_dateval1);
            $barloc_dateval2f = datetolocal($barloc_dateval2);
        } else
            $pbm_bar = TRUE;
    } else
        $pbm_bar = TRUE;
} else
    $pbm_bar = TRUE;

switch ($td) {
    case "add" :
        $titre = _("SAISIE BAREME");
        $barloc_codetva = give_code_tva_default(TRUE);
        $barloc_codetvaass = give_code_tva_default(TRUE);
        $barloc_dateval1f = datetolocal($datea);
        $barloc_mtass = 0;
        $barloc_assobl = 0;
        $barloc_mutl = 1;
        $barloc_actif = 1;
        $barloc_qconsi1 = 0;
        $barloc_qconsi2 = 0;
        $nextmin1 = 1;
        $nextmin2 = 1;
        break;
    case "edit" :
        $titre = _("EDITION BAREME");
        $nextmin1 = next_min_tcons($barloc_id, $barloc_qconsi1, 1, TRUE);
        $nextmin2 = next_min_tcons($barloc_id, $barloc_qconsi2, 2, TRUE);
        break;
    case "del" :
        $titre = _("SUPPRESSION BAREME");
        break;
    default :
        $pbm_bar = 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 _("Barème Location"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:desbl; format:txt ; req:Y ; txt:<?PHP echo _("Libellé"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            "nom:dateval1f; format:date ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; req:Y ; txt:<?PHP echo _("Date validité (première date)"); ?>  ; stok:frmok ; stbad:frmbad",
            "nom:tva; format:liste ; req:Y ; txt:<?PHP echo _("TVA"); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:puht; format:reel_ns ; req:Y ; txt:<?PHP echo _("PU HT"); ?> ; lmx:10 ; vmn : 0.01; stok:frmok ; stbad:frmbad",
            "nom:pu; format:reel_ns ; req:Y ; txt:<?PHP echo _("PU TTC"); ?> ; lmx:10 ; vmn : 0.01; stok:frmok ; stbad:frmbad",
            "nom:mtass; format:reel_ns ; req:N ; txt:<?PHP echo _("Montant assurance"); ?> ; lmx:10 ; stok:frmok ; stbad:frmbad",
            <?PHP
            if ($td == "edit")
            {
            ?>
            "nom:typarr; format:liste ; req:Y ; txt:<?PHP echo _("Type arrondi"); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:pen; format:liste ; req:Y ; txt:<?PHP echo _("Pénalité applicable"); ?>; vmn:1 ; stok:frmok ; stbad:frmbad",
            <?PHP
                if ((trim($pdtloc_pdtucons1)<>"") AND (trim($pdtloc_pdtucons1)<>"-1")) { ?>
            "nom:qconsi1; format:reel_ns ; req:Y ; txt:<?PHP echo _("Quantité consommables 1 incluse"); ?>  ; lmx:10 ; stok:frmok ; stbad:frmbad",
            <?PHP }
                if ((trim($pdtloc_pdtucons2)<>"") AND (trim($pdtloc_pdtucons2)<>"-1")) { ?>
            "nom:qconsi2; format:reel_ns ; req:Y ; txt:<?PHP echo _("Quantité consommables 2 incluse"); ?>  ; lmx:10 ; stok:frmok ; stbad:frmbad",
            <?PHP }} ?>
            "nom:tvaass; format:liste ; req:Y ; txt:<?PHP echo _("TVA Assurance"); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <script type="text/javascript">
        <!--
        <?PHP cre_html_tarcons('dettarcons1', 'dettarcons2', $td, $barloc_id, ''); ?>

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

        function init_all() {
            init_Body();
            init_fdeci('puht', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('puht', 'puht', 'pu', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            init_fdeci('pu', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('pu', 'puht', 'pu', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ht');
            init_calc_taxe('tva', 'puht', 'pu', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            init_fdeci('mtass', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('mtass', 'mtass', 'mtassttc', 'tvaass', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            init_fdeci('mtassttc', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('mtassttc', 'mtass', 'mtassttc', 'tvaass', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ht');
            init_calc_taxe('tvaass', 'mtass', 'mtassttc', 'tvaass', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            init_fdeci('puconsi1', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_fdeci('puconsi2', <?PHP echo $_SESSION['num_nbdec']; ?>);
            <?php
            switch ($td)
            {
                case "add" :
                    echo "init_datepicker();";
                    echo "tbtarcons1();";
                    echo "init_autoraz('razdateval1f','dateval1f','click');";
                    echo "init_autoraz('razdateval2f','dateval2f','click');";
                    echo "init_chk_mtass('mtass','assobl',".$_SESSION['num_nbdec'].");";
                    echo "init_chk_mtass('mtassttc','assobl',".$_SESSION['num_nbdec'].");";
                    echo "init_valid_form('enr','barloc_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    break;
                case "edit" :
                    if (exist_infini_tcons_id($barloc_id, 1, TRUE) == TRUE)
                        echo "$('#addtc1').hide();";
                    else
                        echo "$('#addtc1').show();";
                    echo "init_datepicker();";
                    echo "tbtarcons1();";
                    echo "init_autoraz('razdateval1f','dateval1f','click');";
                    echo "init_autoraz('razdateval2f','dateval2f','click');";
                    echo "init_chk_mtass('mtass','assobl',".$_SESSION['num_nbdec'].");";
                    echo "init_chk_mtass('mtassttc','assobl',".$_SESSION['num_nbdec'].");";
                    echo "init_valid_form('enr','barloc_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    break;
                case "view" :
                    echo "readonly_all();";
                    break;
                case "del" :
                    echo "readonly_all();";
                    echo "warn_del('');";
                    break;
            }
            ?>
            tbtarcons2();
            init_fen_barloc('addtc1','add','<?PHP echo $barloc_id; ?>','',1);
            init_fen_barloc('addtc2','add','<?PHP echo $barloc_id; ?>','',2);
            add_func_click('annul', 'sclose','');
            Focus_first();
        }

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

</head>

<body>

<?PHP
if ($pbm_bar == FALSE) {
    ?>
    <p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
    <p align="center"><?PHP echo _("Pour le produit"); ?> : <br /><span class="titre_gras"><?php echo $pdtloc_des; ?> </span></p>

    <form name="barloc_maj" id="barloc_maj" method="post" action="barloc_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="codepdt" type="hidden" id="codepdt" value="<?PHP echo $pdtloc_code; ?>">
    <input name="nextmin1" type="hidden" id="nextmin1" value="<?PHP echo $nextmin1; ?>">
    <input name="nextmin2" type="hidden" id="nextmin2" value="<?PHP echo $nextmin2; ?>">
    <?PHP if (($td == "edit") OR ($td == "del")) { ?>
        <input name="nbl" type="hidden" id="nbl" value="<?PHP echo $barloc_id; ?>">
    <?PHP } ?>
    <input name="nbutton" type="hidden" id="nbutton" value="">
    <table width="100%" border="0">
    <tr>
        <td class="rubfrm" colspan="2" align="center"><?PHP echo _("Période de location"); ?></td>
    </tr>
    <tr>
        <td width="25%" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
        <td width="75%">
            <input name="code" type="text" id="code" value="<?PHP echo $perloc_code ?>" size="10" maxlength="10"
                   readonly>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_des" align="right"><?PHP echo _("Libellé"); ?></td>
        <td>
            <input name="des" type="text" id="des" value="<?PHP echo $perloc_desc; ?>" size="50" readonly>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_jourd1" align="right"><?PHP echo _("Commence entre un"); ?><br /><?PHP echo("et un"); ?>
        </td>
        <td>
            <input name="njourd1" type="text" id="njourd1"
                   value="<?PHP echo $lng_tjouri[$perloc_jourd1]; ?>" readonly>
            <br />
            <input name="njourd2" type="text" id="njourd2"
                   value="<?PHP echo $lng_tjouri[$perloc_jourd2]; ?>" readonly>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_duree" align="right"><?PHP echo _("Sur une durée de"); ?></td>
        <td>
            <input name="nduree" type="text" id="nduree" value="<?PHP echo $perloc_nduree ?>" size="3" readonly>
            <input name="tduree" type="hidden" id="tduree" value="<?PHP echo $perloc_tduree; ?>">
            <input name="ntduree" type="text" id="ntduree" value="<?PHP echo $lng_tduree[$perloc_tduree]; ?>" readonly>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" colspan="2" align="center">Barême</td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_actif" align="right"><?PHP echo _("Barême actif ?"); ?></td>
        <td>
            <?PHP
            cre_select('actif', 'actif', $non_oui, (int)$barloc_actif);
            ?>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_desbl" align="right"><?PHP echo _("Libellé"); ?></td>
        <td>
            <input name="desbl" type="text" id="desbl" value="<?PHP echo $barloc_des; ?>" size="50">
            <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_rdv" align="right"><?PHP echo _("Validité"); ?></td>
        <td>
            <input name="dateval1f" type="text" id="dateval1f" value="<?PHP echo $barloc_dateval1f ?>" size="10" maxlength="10" readonly>
            <?PHP
            if (($td == "add") OR ($td == "edit"))
                echo ' <img id="razdateval1f" src="../img/raz.png" border="0" align="absmiddle">';
            echo  ' '._("au").' ';
            ?>
            <input name="dateval2f" type="text" id="dateval2f" value="<?PHP echo $barloc_dateval2f ?>" size="10" maxlength="10" readonly>
            <?PHP
            if (($td == "add") OR ($td == "edit"))
                echo ' <img id="razdateval2f" src="../img/raz.png" border="0" align="absmiddle">';
            ?>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_pu" align="right"><?PHP echo _("Tarif location"); ?></td>
        <td>
            <?PHP
            echo '<span class="annot_std_gras">' . _("HT") . '</span> :';
            cre_input_num('puht', $barloc_pvht, TRUE, FALSE);

            echo '<span class="annot_std_gras">' . _("TVA") . '</span> : ';
            // création de la liste des TVA
            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
            $rech = "SELECT * FROM `" . TBTVA . "` WHERE tva_actif=1 ORDER BY tva_desc";
            $rows = $db->get_results($rech, ARRAY_A);
            $db->disconnect();
            cre_select_tab('tva', 'tva', $rows, 'tva_code', 'tva_desc', '', $barloc_codetva, '', _("-- Faites votre choix --"));

            echo ' <span class="annot_std_gras">' . _("TTC") . '</span> : ';
            cre_input_num('pu', $puttc, TRUE, FALSE);

            // création des taux de TVA (champs cachés)
            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
            $rech = "SELECT * FROM `" . TBTVA . "` WHERE tva_actif=1 ORDER BY tva_desc";

            $rows = $db->get_results($rech, ARRAY_A);
            if ($rows) {
                foreach ($rows as $row) {
                    extract($row);
                    echo '<input name="' . $tva_code . '" type="hidden" id="' . $tva_code . '" value="' . $tva_tx . '">';
                }
            }
            $db->disconnect();
            ?>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_mtass" align="right"><?PHP echo _("Assurance"); ?><br /><span
                class="annot_petit"><?PHP echo _("Par période de location"); ?></span></td>
        <td>
            <?PHP
            echo '<span class="annot_std_gras">' . _("HT") . '</span> : ';
            cre_input_num('mtass', $barcloc_mtass, TRUE, FALSE);

            echo ' <span class="annot_std_gras">' . _("TVA") . '</span> : ';

            // création de la liste des TVA
            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
            $rech = "SELECT * FROM `" . TBTVA . "` WHERE tva_actif=1 ORDER BY tva_desc";
            $rows = $db->get_results($rech, ARRAY_A);
            $db->disconnect();
            cre_select_tab('tvaass', 'tvaass', $rows, 'tva_code', 'tva_desc', '', $barloc_codetvaass, '', _("-- Faites votre choix --"));

            echo '<span class="annot_std_gras">'._("TTC").'</span> : ';
            cre_input_num('mtassttc', $mtassttc, TRUE, FALSE);
            ?>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_actif" align="right"><?PHP echo _("Assurance Obligatoire ?"); ?></td>
        <td>
            <?PHP
            cre_select('assobl', 'assobl', $non_oui, (int)$barloc_assobl);
            ?>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_mult" align="right"><?PHP echo _("Multiple ?"); ?></td>
        <td>
            <?PHP
            cre_select('mult', 'mult', $non_oui, (int)$barcloc_mult);
            ?>
            <span class="annot_petit_it">(<?PHP echo _("Si 'Oui', on peut saisir une quantité supérieure à 1"); ?>)</span>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_typarr" align="right"><?PHP echo _("Type arrondi"); ?></td>
        <td>
            <?PHP
            cre_select('typarr', 'typarr', $bloc_typarr, (int)$barloc_typarr, '', _("-- Faites votre choix --"));
            ?>
            <br /><span class="annot_petit_it">(<?PHP echo("'Aucun' : prorata au réel. 'Inférieur' : Arrondi à l'entier inférieur. 'Supérieur' : Toute période entamée est dûe"); ?>)</span>
        </td>
    </tr>
    <tr>
        <td class="rubfrm" id="f_pen" align="right"><?PHP echo _("Pénalité applicable"); ?></td>
        <td>
            <?PHP
            $tab_first_options = [];
            $tab_first_options['-1'] = _("Pas de pénalité");
            // création de la liste des pénalités
            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
            $rech = "SELECT * FROM `" . TBPEN . "` WHERE pen_actif=1 ORDER BY pen_desc";
            $rows = $db->get_results($rech, ARRAY_A);
            $db->disconnect();
            cre_select_tab('pen', 'pen', $rows, 'pen_code', 'pen_desc', '', $barloc_codepen, '', _("-- Faites votre choix --"), 1, FALSE, '', '', TRUE, FALSE, FALSE, $tab_first_options);
            ?>
        </td>
    </tr>
    </table>
    <input name="tvacons1" type="hidden" id="tvacons1" value="<?PHP echo $pdtloc_tvacons1; ?>">
    <input name="tvacons2" type="hidden" id="tvacons2" value="<?PHP echo $pdtloc_tvacons2; ?>">
    <!-- Zone de saisie de la grille tarifaire des consommables -->
    <?PHP
    if (($td == "edit") OR ($td == "del") OR ($td == "view")) {
        ?>
        <table width="100%" border="0">
            <tr>
                <td class="rubfrm" colspan="2" align="center"><?PHP echo _("CONSOMMABLES"); ?></td>
            </tr>
        </table>
        <?PHP if ((trim($pdtloc_pdtucons1) <> "") AND (trim($pdtloc_pdtucons1) <> "-1")) { ?>
            <table width="100%" border="0">
                <tr>
                    <td colspan="2">
                        <?PHP
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        $rech = "SELECT * FROM `" . TBPDTU . "` WHERE `pdtu_code`= '" . $pdtloc_pdtucons1 . "'";
                        $row = $db->get_row($rech, ARRAY_A);
                        if ($row)
                        {
                            $row = encode_str($row);
                            extract($row);
                        }
                        $db->disconnect();
                        echo '<div class="titre_gras_soul">' . _("Consommable 1") . ' (' . $pdtu_desc . ')</div>';
                        echo '<div align="center">';
                        echo ' ' . _("Quantité incluse dans ce barême") . ' : ';
                        cre_input_num('qconsi1', $barloc_qconsi1);
                        echo ', ' . _("pour un montant de") . ' : ';
                        cre_input_num('pucons1', $barloc_puconsi1, TRUE);
                        echo '</div>';
                        ?>
                    </td>
                </tr>
            </table>
            <div id="dettarcons1">
            </div>

            <!-- Lien d'ajout de barèmes -->
            <?PHP
            if ($td == "edit")
                cre_falselnk('addtc1', 'addtc1', 'div', '', _("Ajouter tarif consommable"), '', '../img/add.png', _("Ajouter tarif consommable"));

            if ((trim($pdtloc_pdtucons1) <> "") && (trim($pdtloc_pdtucons2) <> "")) {
                ?>
                <hr noshade width="50%" size="1" align="center" color="#93742D">
            <?PHP
            }
        }
        if ((trim($pdtloc_pdtucons2) <> "") AND (trim($pdtloc_pdtucons2) <> "-1")) {
            ?>
            <table width="100%" border="0">
                <tr>
                    <td colspan="2">
                        <?PHP
                        $pdtu_desc = "";
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        $rech = "SELECT * FROM `" . TBPDTU . "` WHERE `pdtu_code`= '" . $pdtloc_pdtucons2 . "'";
                        $row = $db->get_row($rech, ARRAY_A);
                        if ($row)
                            extract($row);
                        $db->disconnect();
                        echo '<div class="titre_gras_soul">'._("Consommable 2").' (' . $pdtu_desc . ')</div>';
                        echo '<div align="center">';
                        echo ' ' . _("Quantité incluse dans ce barême") . ' : ';
                        cre_input_num('qconsi2', $barloc_qconsi2);
                        echo ', ' . _("pour un montant de") . ' : ';
                        cre_input_num('pucons2', $barloc_puconsi2, TRUE);
                        echo '</div>';
                        ?>
                    </td>
                </tr>
            </table>
            <div id="dettarcons2">
            </div>

            <!-- Lien d'ajout de barèmes consommables -->
            <?PHP
            if ($td == "edit")
                cre_falselnk('addtc2', 'addtc2', 'div', '', _("Ajouter tarif consommable"), '', '../img/add.png', _("Ajouter tarif consommable"));

        }
    }
    ?>
    <p align="center">
        <?PHP
        switch ($td)
        {
            case "add" :
            case "edit" :
                echo '<input name="enr" type="button" class="bton_std" id="enr" value="'._("Valider").'">';
                echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
                break;
            case "del" :
                echo '<input name="del" type="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                break;
        }
        echo '<input name="annul" type="button" class="bton_std" id="annul" value="'._("Annuler").'">';
        ?>
    </p>
    </form>
<?PHP
} else
    close_fen_auto('', 'fscomp', '');
?>
</body>
</html>
