<?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
 ****************************************************************************************/

/*******************************************************************************/
/* Mise à jour tableau de session pour liste des spécialités par sous-traitant */
/* Sur suppression spécialité                                                  */
/*******************************************************************************/

@session_start();
sleep(1);
if (array_key_exists("sp", $_REQUEST)) {
    $tomorrow = 0; //60*60*24; // en nb de secondes
    header("Cache-Control: max-age=$tomorrow");
    print_plain();
} else {
    echo "Usage : $_SERVER[PHP_SELF]?sp = un-code";
}

function print_plain()
{
    require_once("../lib/gettext/gettext.inc");
    include_once("../inc/config.inc.php");
    include_once("../inc/func.inc.php");
    include_once("../inc/func_txt.inc.php");

    $tab_sp_st = [];

    header("Content-type: text/html; charset=UTF-8");
    extract($_REQUEST);
    if ($sp <> '')
    {
        // On crée le nouveau tableau des spécialités
        foreach ($_SESSION["tab_spdes"] as $key=>$value)
        {
            if ($key <> $sp)
            {
                $tab_sp_st[$key] = $value;
            }
        }
        $_SESSION["tab_spdes"] = $tab_sp_st;

        echo '<table width="80%" id="t_spec" class="MtableD">';
        echo '<tr>';
        echo '<th width="500">' . _("Spécialité") . '</th>';
        echo '<th witdh="300">' . _("Niveau de compétences") . '</th>';
        echo '<th witdh="100">' . _("Supprimer") . '</th>';
        echo '</tr>';
        if (count($_SESSION["tab_spdes"])>0)
        {
            foreach ($_SESSION["tab_spdes"] as $key=>$value)
            {
                echo '<tr>';
                echo '<td align="center">' . $value["des"] . '</td>';
                echo '<td align="center">';
                cre_select('niv_'.$key, 'niv_'.$key, $sp_niveau_st, $value["niv"], '', '', 1, FALSE, '', '', TRUE, FALSE, 'falselnksel');
                echo '</td>';
                echo '<td align="center">';
                cre_falselnk_img_ajax('', 'sp_del_'.$key, 'span', 'center', _("Suppression"), 'prmajax', $key, '../img/del.png');
                echo '</td>';
                echo '</tr>';
            }
        }
        echo '</table>';
  }
}


?>