<!DOCTYPE html>
<html>
<?php
/*
 * Gère les Entrees, Plats, Desserts
 *
 * */

    $ClassLpf   = new ClassLpf();

// Enregsitre la configuration Menu
    if( isset($_REQUEST['btn_modif']) || $_REQUEST['btn_ajout'] || $_REQUEST['btn_suppr']) {
        $Message = $ClassLpf->EnregType();
    }

    $Type = $ClassLpf->Composition($no);
?>

<?php if($Message) echo $Message['msg'];?>

<div class="form-group row">

<!-- ADMIN - MENU VERTICAL (Enrtree, Base, plat, ... ) -->
    <div class="col-4" >
        <h2>
        <?php
            foreach(Type as $Item=>$f) {
                ($no == $Item) ? $s="color:#e5692c;" : $s="color:#dddddd;";
                ($Item=="sauce_v2" || $Item=="plat_v2") ? $Espace = "&nbsp;&nbsp;" : $Espace = "";
                echo "$Espace<a style='$s  text-decoration: none;'  href='?p=c,$Item'>".ucwords(Type[$Item])."s</a><br>";
            }
        ?>
        </h2>
    </div>

<!-- GESTION -->
    <div class="col-8" >
        <form action="" method="post" class="">
            <input name="type" type="hidden" value="<?=$no?>">
        <!-- Intitulé du Plat-->
            <?php
                if($no=="base_v2")  $MsgAccueil ="Pour ce type, seule la modification est disponible.";
                else                $MsgAccueil ="Créez, modifiez et supprimez vos enregistrements.";
                echo "<br><b>".$MsgAccueil."</b><br><br>";
            ?>

            <table border="0" width="100%">
            <?php
            foreach($Type as $k=>$dtl_type) {
                $CheckCustom = "CC_".$k;
                ?>
                <tr>
                <td width="70%">
                <input class="form-control" name="nom[<?=$k?>]" value="<?=($dtl_type['nom']) ?>">

                </td>
                <?php //if ($no=="vin") { ?>
                <td >
                    <input class="form-control" name="prix[<?=$k?>]" value="<?=($dtl_type['prix']) ?>" style="width:60px">
                </td>
                <?php //} ?>
                <td>
                    <button type="submit" name="btn_modif" value="<?=$k?>" class="btn btn-light"><i class="fas fa-check"></i></button>
                    <?php if($no!='base_v2') { ?><button type="submit" name="btn_suppr" value="<?=$k?>" class="btn btn-danger"><i class="far fa-trash-alt"></i></button><?php } ?>
                </td>
                </tr>
            <?php } ?>
<!-- AJOUTER un article-->

                <?php if($no!='base_v2') { ?>

                <tr>
                    <td colspan="2">
                        <br>
                        <small>Pour ajouter un nouvel enregistrement  </small>
                    </td>
                </tr>
                <tr>
                    <td>
                    <input class="form-control" name="btn_ajout" value="" placeholder="indiquez ici votre <?=Type[$no]?>">
                    </td>
                    <?php //if ($no=="vin") { ?>
                    <td>
                        <input class="form-control" name="prix_ajout" value="" style="width:60px" placeholder="€">
                    </td>
                    <?php //} ?>
                    <td>

                    <button type="submit" value="0" class="btn btn-success"><i class="fas fa-plus"></i></button>

                    </td>
                </tr>
                <?php } ?>
            </table>
            <br>
            <hr>
            <div class="float-right">
                <button type="button"   class="btn btn-orange" style="width:200px" Onclick="location=('index.php')">Accueil</button>
            </div>
        </form>
    </div>
</div>