<?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/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_co.inc.php");
include_once("../inc/fic_cocl.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/fic_rel.inc.php");
include_once("../inc/fic_taxes.inc.php");
include_once("../inc/fic_tac.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/fic_zc.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.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();
$_POST = clean_str($_POST);
$_GET = clean_str($_GET);

$pbm_cocl = FALSE;
$pbm_cocla = FALSE;
$pbm_cli = FALSE;
$pv_ttc = 0;
$tab_cli = [];
$str_tlp = '';
$cocla_id = 0;
$td = '';
$_SESSION["scli_choisis"] = "";
$_SESSION["sclia_choisis"] = "";
$_SESSION["rlp_choisis"] = "";

if (isset($_GET['td']))
    $td = $_GET['td']; // Récupération type demande
else
    $pbm_cocl = TRUE;

// Niveau <=3 ne peut que voir les annexes contrats
if (@$_SESSION["niv_log"] <= 3)
    $td = "view";

$co = '';
if (isset($_GET['co']))
    $co = $_GET['co']; // Récupération code Contrat
else
    $pbm_cocl = TRUE;

$coa = '';
if (isset($_GET['coa']))
    $coa = $_GET['coa']; // Récupération code annexe Contrat
else {
    if ($td <> "add")
        $pbm_cocla = TRUE;
}

if (($pbm_cocl == FALSE) AND ($pbm_cocla == FALSE)) {
    $codeadev = give_dev_codea_defaut($_SESSION["lng"], TRUE);

    if ($co <> "") {
        // Récupération des informations contrat client
        $row = lit_enr_cocl($co);
        if (is_array($row)) {
            $row = encode_str($row);
            extract($row);

            if (trim($cocl_codeadev) == '')
                $cocl_codeadev = give_dev_codea_defaut_cocl($cocl_code, $_SESSION["lng"]);

            // Si contrat n'est pas signé ou est terminé, on ne peut pas ajouter d'annexe
            if ((($cocl_signe == '') OR (datetolocal($cocl_datefin) <> '')) AND ($td == "add"))
                $pbm_cocl = TRUE;

            // Si contrat terminé, force le mode "view"
            if (datetolocal($cocl_datefin) <> '')
                $td = "view";

            if ($pbm_cocl == FALSE) {
                // Récupération des informations client
                $row = lit_enr_cli($cocl_codecli);
                if (is_array($row))
                {
                    $row = encode_str($row);
                    extract($row);
                }

                // Récupération des informations TVA
                $row = lit_enr_tva($cocl_codetva, TRUE);
                if (is_array($row))
                    extract($row);

                $txtva = $tva_tx / 100;

                switch (@$_SESSION["niv_log"]) {
                    // Contrôle qu'un client n'essaye pas de "hacker" un contrat
                    case 1 :
                        $tab_cli = give_tab_rcli($_SESSION["code_log"], TRUE);
                        if (exist_in_array($cocl_codecli, $tab_cli) == FALSE)
                            $pbm_cocl = TRUE;
                        break;
                    // Contrôle qu'une agence n'essaye pas de "hacker" un contrat
                    case 3 :
                    case 4 :
                        if ($cocl_codeage <> @$_SESSION["code_age"])
                            $pbm_cocl = TRUE;
                        break;
                }
            }
        } else
            $pbm_cocl = TRUE;
    } else
        $pbm_cocl = TRUE;
}

if (($pbm_cocl == FALSE) AND ($pbm_cocla == FALSE)) {

    // Construction de la chaîne des sites sélectionnés sur le contrat et TOUTES les annexes de celui-ci
    $lstsites_annexes = cree_str_lstsites_cocl($co, TRUE);
    // $lstsites_annexes = cree_str_lstsites_cocla($co,0);
    $_SESSION["sclia_choisis"] = $lstsites_annexes;

    if ($coa <> "") {
        // Récupération des informations annexe contrat client
        $row = lit_enr_cocla($coa, $co);
        if (is_array($row)) {
            $row = encode_str($row);
            extract($row);

            if ($cocla_codecocl <> $co)
                $pbm_cocla = TRUE;

            if ($pbm_cocla == FALSE) {
                $cocla_datecreaf = datetolocal($cocla_datecrea);
                $cocla_dateenvf = datetolocal($cocla_dateenv);
                $cocla_daterecf = datetolocal($cocla_daterec);
                $cocla_datesigf = datetolocal($cocla_datesig);
                $cocla_daterelf = datetolocal($cocla_daterel);
                $pvttc = round(($cocla_pvht * (1 + $txtva)) * 100) / 100;

                // Construction de la chaîne des sites sélectionnés pour cette annexe
                $lstsites = cree_str_lstsites_cocla($co,$cocla_id);
                $_SESSION["scli_choisis"] = $lstsites;

                // Construction de la liste et du texte des produits sur relevés
                $_SESSION["rlp_choisis"] = $cocla_coderlp;
                if ($cocla_coderlp <> "")
                    $str_rlp = cree_txt_matos_cocl($cocla_coderlp);

                // Si l'annexe est signée, on passe en mode "view"
                if ($cocla_signe <> '')
                    $td = 'view';


            }
        }
    } else {
        if ($td == "add") {
            $cocla_code = '';
            $cocla_datecreaf = $datef;
            $cocla_dateenvf = $datef;
            $cocla_daterecf = '';
            $cocla_datesigf = '';
            $cocla_daterelf = '';
            $cocla_codecocl = $co;
            $_SESSION["scli_choisis"] = "";
        } else
            $pbm_cocla = TRUE;
    }

    // Si aucun site secondaire choisi, on force le site principal
    if ((trim($_SESSION["scli_choisis"]) == '') AND trim($_SESSION["sclia_choisis"]) == '')
        $cocla_sitep = 1;
}

// Vérification du nombre de licences et matériels actifs pour les sites sélectionnés
if (($pbm_cocl == FALSE) AND ($pbm_cocla == FALSE)) {
    $exist_rlic_aselect =  (count(cre_tab_rlic_aselect_coa($co,$cocla_id,$_SESSION["sclia_choisis"], $cocla_sitep))>0);
    // $exist_rlic_aselect = exist_rlic_actif($cocl_codecli, $_SESSION["sclia_choisis"], $cocla_sitep);
    $exist_rpdt_aselect =  (count(cre_tab_rpdt_aselect_coa($co,$cocla_id,$_SESSION["sclia_choisis"], $cocla_sitep))>0);
    // $exist_rpdt_aselect = exist_rpdt_actif($cocl_codecli, $_SESSION["sclia_choisis"], $cocla_sitep);
}

switch ($td) {
    case "add" :
        $titre = _("CREATION ANNEXE CONTRAT CLIENT");
        break;
    case "edit" :
        $titre = _("MISE A JOUR ANNEXE CONTRAT CLIENT");
        break;
    case "del" :
        $titre = _("SUPPRESSION ANNEXE CONTRAT CLIENT");
        break;
    case "view" :
        if (@$_SESSION["niv_log"] == 1)
            $titre = _("VISUALISATION ANNEXE CONTRAT");
        else
            $titre = _("VISUALISATION ANNEXE CONTRAT CLIENT");
        break;
    default :
        $pbm_cocl = 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 Annexe Contrat Client"); ?></title>

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

    <script language="javascript">
        var tab1_champ = ["nom:codea ; format:txt ; req:Y ; txt:<?PHP echo _("Code annexe contrat"); ?> ; stok:frmok ; stbad:frmbad",
            "nom:datecreaf ; format:date ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; req:Y ; vmn:<?PHP echo datetolocal($cocl_datesig); ?> ; txt:<?PHP echo _("Date création"); ?>  ; stok:frmok ; stbad:frmbad",
            "nom:matos ; format:txt ; req:N ; txt:<?PHP echo _("matériel"); ?>; stok:frmok ; stbad:frmbad",
            <?PHP if ($td <> "add") { ?>
            "nom:datesigf ; format:date ; masque jj-mm-aaa ; req:N ; txt:<?PHP echo _("signé le") ; ?> ; stok:frmok ; stbad:frmbad",
            "nom:signe ; format:txt ; req:N ; txt:<?PHP echo _("signé par"); ?> ; lmx:70 ; stok:frmok ; stbad:frmbad",
            <?PHP } ?>
            "nom:pu ; format:reel_ns ; req:Y ; txt:<?PHP echo _("Prix de vente hors taxes"); ?> ; lmx:10 ; stok:frmok ; stbad:frmbad"];
    </script>

    <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_datepicker();
            init_fdeci('pu', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('pu', 'pu', 'puttc', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            init_fdeci('puttc', <?PHP echo $_SESSION['num_nbdec']; ?>);
            init_calc_taxe('puttc', 'pu', 'puttc', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ht');
            init_calc_taxe('tva', 'pu', 'puttc', 'tva', <?PHP echo $_SESSION['num_nbdec']; ?>, 'to_ttc');
            readonly_id('tva',false);
            <?php
            $url_choixsites = "sites_lst.php?tx=coa&cc=".$cocl_codecli."&co=".$cocl_code."&coa=".$cocla_code."&td=".$td;
            switch ($td)
            {
                case "add" :
                    echo '$( "#datecreaf" ).datepicker();';
                    if (@$_SESSION["niv_log"] >= 3)
                        echo 'warn_cpta('.$cli_cpta.',"cocl");';
                    echo "init_valid_cocla('enr','cocla_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    echo "init_valid_cocla('enrimp','cocla_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    echo "init_warn('".nb_age_actives()."age','','back','','');";
                    echo "init_fen_mat('addmat','fscomp',1024,600);";
                    echo "chk_disp_addmat(false,'addmat','".(int)$exist_rlic_aselect."','".(int)$exist_rpdt_aselect."');";
                    echo "init_display_id('viewmat','popmatselected',true,'click');";
                    echo "init_hide_id('closemat','popmatselected','click');";
                    echo "update_detail_rlp(false,'detailmat','".str_replace("'","\'",$str_rlp)."','viewmat');";
                    break;
                case "edit" :
                    if (@$_SESSION["niv_log"] >= 3)
                        echo 'warn_cpta('.$cli_cpta.',"cocl");';
                    echo "init_valid_cocla('enr','cocla_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    echo "init_valid_cocla('enrimp','cocla_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                    echo "init_fen_mat('addmat','fscomp',1024,600);";
                    echo "chk_disp_addmat(false,'addmat','".(int)$exist_rlic_aselect."','".(int)$exist_rpdt_aselect."');";
                    echo "init_display_id('viewmat','popmatselected',true,'click');";
                    echo "init_hide_id('closemat','popmatselected','click');";
                    echo "update_detail_rlp(false,'detailmat','".str_replace("'","\'",$str_rlp)."','viewmat');";
                    break;
                case "view" :
                    echo "readonly_all();";
                    break;
                case "del" :
                    echo "warn_del('');";
                    echo "readonly_all();";
                    echo "init_display_id('viewmat','popmatselected',true,'click');";
                    echo "update_detail_rlp(false,'detailmat','".str_replace("'","\'",$str_rlp)."','viewmat');";
                    echo "init_hide_id('closemat','popmatselected','click');";
                    break;
            }
            if (@$_SESSION["niv_log"] >= 3)
                echo "init_fensaisie('notes_cli',930,380);";
            ?>
            init_fensaisie('sites_cocl', 920, 500);
            Focus_first();
        }

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

</head>

<body>

<?PHP include_once("../inc/entete.inc.php");
if (($pbm_cocla == FALSE) AND($pbm_cocl == FALSE) AND ($pbm_cli == FALSE)) {
    cre_ent_form($titre, 'cocl_lst.php?ord=DES&tri=Code', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="cocla_maj" id="cocla_maj" method="post" action="cocla_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="tx" type="hidden" id="tx" value="coa">
    <input name="codecli" type="hidden" id="codecli" value="<?PHP echo $cocl_codecli; ?>">
    <input name="nbutton" type="hidden" id="nbutton" value="">

    <!-- détails internes de la fiche contrat -->

    <!-- Date de création -->
    <table width="100%" border="0">
        <tr>
            <td width="250" class="rubfrm" id="f_datecreaf" align="right"><?PHP echo _("Date Création"); ?> </td>
            <td>
                <input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $cocla_datecreaf ?>" size="10" maxlength="10" readonly>
                <?PHP if ($td == "add")
                {
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    echo '<div class="annot_petit_it">';
                    echo _("Contrat signé le").' '.datetolocal($cocl_datesig);
                    echo '</div>';
                } ?>
            </td>
        </tr>
    </table>

    <!-- Code de l'annexe au contrat client -->
    <table width="100%" border="0">
        <tr>
            <td width="250" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
            <td>
                <input name="code" type="text" id="code" value="<?PHP echo $cocla_codecocl; ?>" readonly> -
                <input name="codea" type="text" id="codea" value="<?PHP echo $cocla_code ?>" size="20"
                       maxlength="20" <?PHP if ($td <> "add") echo 'readonly="1"'; ?>>
                <?PHP
                if ((datetolocal($cocla_datesig) == "") AND ($td <> "add")) {
                    echo ' <span class="alerte1">';
                    echo _("Non signée");
                    echo '</span>';
                }
                ?>
            </td>
        </tr>
    </table>

    <!-- Affichage du client -->
    <table width="100%" border="0">
        <tr>
            <td class="rubfrm" id="f_codecli" align="center"><?PHP echo _("Client"); ?>
                <?PHP
                if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
                    echo " <img src=\"../img/" . $ico_cpta[$cli_cpta] . "\" title =\"" . $mess_cpta[$cli_cpta] . "\" border=\"0\" align=\"absmiddle\">";
                ?>
            </td>
        </tr>
    </table>

    <!-- détails client -->
    <table width="100%" border="0">
        <tr>
            <td valign="top" bgcolor="#C5CED7">
                <?PHP
                echo "<span class=\"annot_std_gras\">";
                if ($cli_ste <> "")
                    echo $cli_ste . "<br />";
                else
                    echo $cli_civilite . " " . $cli_prenom . " " . $cli_nom . "<br />";
                echo "</span>";
                echo $cli_adr1 . "<br />";
                if ($cli_adr2 <> "")
                    echo $cli_adr2 . "<br />";
                echo Retournecp_Id($cli_ville, TRUE) . " " . Retourneville_Id($cli_ville, TRUE) . "<br />";
                $chemin_imagesco = $chemin_images . "/telc.png";
                echo "<img src=\"" . $chemin_imagesco . "\" align=\"bottom\">";
                echo " " . $cli_telf . "<br />";
                ?>
            </td>
            <td width="350" valign="top">
                <?PHP
                if (@$_SESSION["niv_log"] >= 3) {
                    $url_affnotesc = "aff_notesc.php?cc=" . $cocl_codecli;
                    if (url_ok($url_affnotesc, TRUE) == TRUE)
                        cre_falselnk('', 'notes_cli', 'span', '', _("Notes"), $url_affnotesc, '../img/eye.png', _("Notes"));
                }

                echo "<br />";


                $sitep_inclus = sitep_in_cocl_except($cocl_code, $cocla_code);
                $nbscli_libres = nb_scli_non_affectes($cocl_codecli, $cocl_code, $cocla_code);

                echo '<input name="sitep" type="hidden" id="sitep" value="';
                if (($sitep_inclus == TRUE) OR ($cocla_sitep == 1))
                    echo '1';
                else
                    echo '0';
                echo '">';
                echo '<input name="sitesec" type="hidden" id="sitesec" value="' . $_SESSION["scli_choisis"] . '">';

                // On ne peut choisir un site que s'il y en a de possibles
                if (($nbscli_libres > 0) OR ($sitep_inclus == FALSE)) {
                    if (url_ok($url_choixsites, TRUE) == TRUE)
                        cre_falselnk('', 'sites_cocl', 'div', '', _("Sites couverts"), $url_choixsites, '../img/sites.png', _("Sites couverts"));
                }

                ?>
            </td>
        </tr>
    </table>

    <!-- détail matériel concerné -->
    <table width="100%" border="0">
        <tr>
            <td width="250" class="rubfrm" id="f_matos" align="right"><?PHP echo _("Matériel / Licences"); ?></td>
            <td>
                <?PHP
                if (($td == "add") OR ($td == "edit")) {
                    echo '<span id="addmat" class="falselnk">';
                    echo ' <img src="../img/addmat.gif" title="' . _("Gérer Matériels & Licences") . '" border="0" align="absmiddle"> ' . _("Gérer Matériels & Licences");
                    echo ' / ';
                    echo '</span>';
                }

                echo '<span id="viewmat" class="falselnk">';
                echo ' <img src="../img/eye.png" title="' . _("Voir Matériels & Licences") . '" border="0" align="absmiddle"> ' . _("Voir Matériels & Licences");
                echo '</span>';


                echo '<div id="popmatselected" class="pop_detailpbm">';

                echo '<div align="right">';
                echo '<img src="../img/close.gif" id="closemat" title="' . _("Fermer") . '" border="0" align="absmiddle">';
                echo '</div>';

                echo '<div class="annot_gras_it" align="center">';
                echo _("MATERIELS / LICENCES");
                echo '</div>';
                echo '<textarea name="detailmat" rows="10" id="detailmat" readonly>';
                echo '</textarea>';

                echo '</div>';

                echo '<textarea name="matos" rows="10" id="matos">' . $cocla_matos . '</textarea>';

                ?>
            </td>
            <td width="16">
                <?PHP
                if (($td == "add") OR ($td == "edit"))
                    echo '<img src="../img/oblig.png" align="absmiddle" align="top">';
                else
                    echo '&nbsp;';
                ?>
        </tr>
    </table>

    <!-- Montant du contrat -->
    <table width="100%" border="0">
        <tr>
        <tr>
            <td width="250" class="rubfrm" id="f_pu" align="right"><?PHP echo _("PV HT"); ?></td>
            <td>
                <?PHP
                switch ($td) {
                    case "add" :
                    case "edit" :
                        cre_input_num('pu', $cocla_pvht, TRUE, FALSE);
                        break;
                    default :
                        cre_input_num('pu', $cocla_pvht, TRUE, TRUE);
                        break;
                }
                ?>
        </tr>
        <tr>
            <td width="250" class="rubfrm" id="f_tva" align="right"><?PHP echo _("TVA"); ?></td>
            <td>
                <?PHP
                // 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', '', $cocl_codetva, '', _("-- Faites votre choix --"));

                // création des taux de TVA (champs cachés)
                if ($rows) {
                    foreach ($rows as $row) {
                        $row = encode_str($row);
                        extract($row);
                        echo '<input name="' . $tva_code . '" type="hidden" id="' . $tva_code . '" value="' . $tva_tx . '">';
                    }
                }
                ?>
            </td>
        </tr>
        <tr>
            <td width="250" class="rubfrm" id="f_puttc" align="right"><?PHP echo _("PV TTC"); ?></td>
            <td>
                <?PHP
                switch ($td) {
                    case "add" :
                    case "edit" :
                        cre_input_num('puttc', $pvttc, TRUE, FALSE);
                        break;
                    default :
                        cre_input_num('puttc', $pvttc, TRUE, TRUE);
                        break;
                }
                ?>
            </td>
        </tr>
    </table>

    <?PHP if ($td <> "add") { ?>
        <!-- Signataire du contrat -->
        <table width="100%" border="0">
            <tr>
                <td width="250" class="rubfrm" id="f_datesig" align="right"><?PHP echo("Signée le"); ?></td>
                <td>
                    <input name="datesigf" type="text" id="datesigf" value="<?PHP echo $cocla_datesigf ?>" size="10"
                           maxlength="10" readonly>
                </td>
            </tr>
            <tr>
                <td width="250" class="rubfrm" id="f_signe" align="right"><?PHP echo _("Signée par"); ?></td>
                <td>
                    <input name="signe" type="text" id="signe" value="<?PHP echo $cocla_signe ?>" size="70" readonly>
                </td>
            </tr>
        </table>
        <br />

        <?PHP if ($cocla_daterelf <> "") { ?>
            <!-- Date de relance du contrat -->
            <table width="100%" border="0">
                <tr>
                    <td width="250" class="rubfrm" id="f_daterelf" align="right"><?PHP echo _("Relancé le"); ?></td>
                    <td>
                        <input name="daterelf" type="text" id="daterelf" value="<?PHP echo $cocla_daterelf ?>" size="10"
                               maxlength="10" readonly>
        <span class="annot_petit_it">
		<?PHP
        echo "(" . $cocla_nivrel . " fois)";
        ?>
		</span>
                    </td>
                </tr>
            </table>
        <?PHP
        }
    }
    ?>

    <p align="center">
        <?PHP
        switch ($td)
        {
            case "add" :
            case "edit" :
                echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
                echo '<input name="enr" id="enr" type="button" class="bton_std"value="'._("Enregistrer").'">';
                echo '<input name="enrimp" id="enrimp" type="button" class="bton_std" value="'._("Enregistrer & Imprimer").'">';
                break;
            case "del" :
                echo '<input name="del" type="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                break;
        }
        ?>
    </p>
    </form>
    <!-- Fin affiché uniquement s'il y a un code client -->
<?PHP
} else {
    if ($pbm_cocl == TRUE)
        pop_ret_auto(_("Merci de choisir un de vos contrats"), 'warn',"cocl_lst.php?ord=DES&tri=Code");
    else {
        if (@$_SESSION["niv_log"] == 1)
            pop_ret_auto(_("Merci de choisir votre compte"), 'warn', "index.php");
        if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
            pop_ret_auto(_("Merci de choisir un de vos clients"), 'warn', "cli_lst.php&td=con");
    }
}
include_once("pied.php");
?>
</body>
</html>