<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.4
 *
 * Copyright (C) 2006-2016  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');
$ok_inc = FALSE;
if ($pos === FALSE) {
    $ok_inc = TRUE;
}
if ($ok_inc == FALSE) {
    header('Location: ../index.php');
}


include_once('../inc/config.inc.php');
include_once('../inc/func.inc.php');
include_once('../inc/func_date.inc.php');
include_once('../inc/func_log.inc.php');
include_once('../inc/func_geo.inc.php');
include_once('../inc/func_txt.inc.php');
include_once('../inc/fic_droits.inc.php');
include_once('../inc/fic_st.inc.php');
include_once('../inc/fic_hum.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(valsession('code_log'));
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$coderech = $_GET['cs'];

if (CheckNivLog('10')) {
    $coderech = valsession('code_log');
}

$pbm_st = FALSE;

if (valsession('niv_log') <= 4) {
    $pbm_st = TRUE;
}

if ($coderech <> '') {
    // Récupération des informations sous-traitant
    $row = lit_enr_st($coderech);
    if (is_array($row)) {
        extract($row);
    } else {
        $pbm_st = TRUE;
    }
} else {
    $pbm_st = TRUE;
}
?>
<!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 _('Impression Fiche Sous-traitant'); ?></title>

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

    <script type="text/javascript">
        <!--
        function init_all() {
            init_Body();
            warn_print(2);
        }

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

</head>

<body>

<?php
if ($pbm_st == FALSE) {
    entimpfic(_('FICHE SOUS-TRAITANT'));
    ?>
    <table class="Ftable" width="740" border="0">
        <?php
        if (CheckNivLog('5-9')) {
            ?>
            <tr>
                <td class="rubNormal" id="f_code" align="right">Actif ?</td>
                <td width="62%">
                    <?php
                    if ($st_ouvert == 1) {
                        echo _('Ouvert');
                    } else {
                        echo _('Fermé');
                    }
                    ?>
                </td>
            </tr>
            <?php
        }
        ?>
        <tr>
            <td width="21%" class="rubNormal" id="f_code" align="right"><?php echo _('Code'); ?></td>
            <td>
                <?php
                echo $st_code;
                ?>
            </td>
        </tr>
        <tr>
            <td height="21" class="rubNormal" id="f_logo" align="right"><?php echo _('Logo'); ?></td>
            <td>
                <?php
                echo '<div align="left">';
                echo ' <img src="' . $chemin_logos . '/log' . strtolower($st_code) . '.png"><br />';
                echo '</div>';
                ?>
            </td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_nom" align="right"><?php echo _('Nom'); ?></td>
            <td><?php echo $st_nom; ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rcs" align="right"><?php echo _('Siret'); ?></td>
            <td><?php echo $st_rcs ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rcs" align="right"><?php echo _('APE'); ?></td>
            <td><?php echo $st_rcs ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rcs" align="right"><?php echo _('TVA intra.'); ?></td>
            <td><?php echo $st_rcs ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_tcom" align="right"><?php echo _('Tribunal com.'); ?></td>
            <td><?php echo $st_tcom ?></td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_adr1" align="right"><?php echo _('Adresse'); ?></td>
            <td><?php echo $st_adr1 ?></td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_adr2" align="right"><?php echo _('Adresse (2)'); ?></td>
            <td><?php echo $st_adr2 ?></td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_ville" align="right"><?php echo _('Code Postal'); ?></td>
            <td>
                <?php
                // Affichage du Code Postal
                echo Retournecp_Id($st_ville, TRUE);
                ?>
            </td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_ville" align="right"><?php echo _('Ville'); ?></td>
            <td>
                <?php
                // Affichage de la ville
                echo Retourneville_Id($st_ville, TRUE);
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_pays" align="right"><?php echo _('Pays'); ?></td>
            <td>
                <?php
                // Affichage du pays
                echo Retournepays($st_codepays, TRUE);
                ?>
            </td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_telf" align="right"><?php echo _('Téléphone Fixe'); ?> </td>
            <td>
                <?php
                echo $st_telf . '<br />';
                echo $st_txttelf;
                ?>
            </td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_fax" align="right"><?php echo _('Télécopieur'); ?></td>
            <td>
                <?php
                echo $st_fax . '<br />';
                echo $st_txtfax;
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_web" align="right"><?php echo _('Site Web'); ?></td>
            <td><?php echo $st_web ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_heures" align="right"><?php echo _('Horaires'); ?></td>
            <td><?php echo $st_heures ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_heures" align="right"><?php echo _('Entête'); ?></td>
            <td>
                <?php
                echo formatetxt($st_txtent);
                ?>
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" class="rubNormal" id="f_web" align="center"><?php echo _('Contact principal'); ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rcivil" align="right"><?php echo _('Civilité'); ?></td>
            <td>
                <?php
                // Affichage de la civilité
                $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');

                $rech = 'SELECT civ_desc FROM `' . TBCIV . "` WHERE civ_code = '" . $st_resp_civilite . "'";
                $row = $db->get_row($rech, ARRAY_A);
                if ($row) {
                    extract($row);
                    echo $civ_desc;
                }
                close_database();
                ?>
            </td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rprenom" align="right"><?php echo _('Prénom'); ?></td>
            <td><?php echo $st_resp_prenom ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rnom" align="right"><?php echo _('Nom'); ?></td>
            <td><?php echo $st_resp_nom ?></td>
        </tr>
        <tr>
            <td class="rubNormal" id="f_rtelf" align="right"><?php echo _('Tel. Fixe'); ?></td>
            <td><?php echo $st_resp_telf ?></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" class="rubNormal" align="center"><span
                    class="annot_gras_it"><?php echo _('Emails'); ?></span></td>
            <td width="17%">
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_email" align="right"><?php echo _('Général'); ?></td>
            <td><?php echo $st_email ?>
                <span class="annot_std_it">(<?php echo _('Pour contacts clients'); ?>)</span>
            </td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_emaild" align="right"><?php echo _('Direction'); ?></td>
            <td><?php echo $st_emaild ?></td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_emailc" align="right"><?php echo _('Comptabilité'); ?></td>
            <td><?php echo $st_emailc ?></td>
        </tr>
        <tr>
            <td width="21%" class="rubNormal" id="f_emailt" align="right"><?php echo _('Technique'); ?></td>
            <td><?php echo $st_emailt ?></td>
        </tr>
        <tr>
            <td width="21%">&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <?php
        if (CheckNivLog('5-9')) {
            ?>
            <tr>
                <td width="21%" class="rubNormal" id="f_nota" align="right"><?php echo _('Notes'); ?></td>
                <td><?php
                    echo '<span class="txtnotes">';
                    echo formatetxt($st_nota);
                    echo '</span>';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="21%">&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td width="21%" class="rubNormal" id="f_factures"
                    align="right"><?php echo _('Emet ses factures'); ?></td>
                <td><?php echo $non_oui[$st_fact]; ?></td>
            </tr>
            <?php
        }
        ?>
    </table>

<?php
}
else
{
?>
    <script type="text/javascript">
        <!--
        window.close();
        //-->
    </script>
    <?php
}
?>
</body>
</html>