<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <title>Malaria Bar - Menú</title>

    <link href="{{ asset('assets/css/style.css?v=07122021') }}" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
    <script src="https://kit.fontawesome.com/dd87e83dab.js"></script>
    <meta name="facebook-domain-verification" content="201dzv1xxxhi5c4gbdonjsb7q972kk" />
</head>
<body id="top" class="page-menu">
<div class="container">
    <header class="content">
        <div class="cont-logo-menu">
            <div class="logo">
                <a href="{{ URL::to('/') }}#top" class="logo">
                    <img src="{{ URL::to('/') }}/img/logo-7.jpg" alt="">
                </a>
            </div>
            <div class="close-mobile-menu close"></div>
            <nav class="burger">
                <span></span>
                <ul class="cont-mobile-menu">
                    <li class="menu-logo">
                        <a href="{{ URL::to('/') }}#top" class="logo">
                            <img src="{{ URL::to('/') }}/img/logo-7.jpg" alt="">
                        </a>
                    </li>
                    <li>
                        <a href="/menu">Menú</a>
                    </li>
                    <li>
                        <a @if ($linkReservations) href="{{ $linkReservations->link }}" target="_blank" @endif>Reservas</a>
                    </li>
{{--                    <li>--}}
{{--                        @if ($seasons->count() != 0)--}}
{{--                            <div class="item-sub">Miniserie</div>--}}
{{--                            <ul class="submenu">--}}
{{--                                @foreach($seasons as $season)--}}
{{--                                    <li>--}}
{{--                                        <div id="temp{{ $season->id }}" class="item-sub1">Temporada {{ $season->number }}</div>--}}
{{--                                        @if ($season->episodes)--}}
{{--                                            <ul class="nivel2">--}}
{{--                                                @foreach($season->episodes as $e)--}}
{{--                                                    <li>--}}
{{--                                                            <?php--}}
{{--                                                            $videoID = explode('/', $e->link);--}}
{{--                                                            ?>--}}
{{--                                                        <a id="episode" href="{{ URL::to('/') }}?episodio={{ $videoID[3] }}&titulo={{ $e->title }}">{{ $e->title }}</a>--}}
{{--                                                    </li>--}}
{{--                                                @endforeach--}}
{{--                                            </ul>--}}
{{--                                        @endif--}}
{{--                                    </li>--}}
{{--                                @endforeach--}}
{{--                            </ul>--}}
{{--                        @else--}}
{{--                            <a href="/#containerVideoPreview">Miniserie</a>--}}
{{--                        @endif--}}
{{--                    </li>--}}
                    <li class="mobile redes-mobile">
                        <a target="_blank" href="https://www.instagram.com/malasangre.bar/?hl=es">
                            <i class="fab fa-instagram"></i>
                        </a>
{{--                        <a target="_blank" href="https://www.facebook.com/Malasangrebar-108101731605739">--}}
{{--                            <i class="fab fa-facebook-square"></i>--}}
{{--                        </a>--}}
                    </li>
                </ul>
            </nav>
        </div>
        <div class="redes">
            <a target="_blank" href="https://www.instagram.com/malasangre.bar/?hl=es">
                <i class="fab fa-instagram"></i>
            </a>
{{--            <a target="_blank" href="https://www.facebook.com/Malasangrebar-108101731605739">--}}
{{--                <i class="fab fa-facebook-square"></i>--}}
{{--            </a>--}}
        </div>
    </header>

    <div class="content titulo">
        <h1>Menú</h1>
    </div>
    <section class="cont-menu">
        <div class="" id="tab-menu">
            <?php
            $contCategories = 0;
            asort($sortCategories);
            asort($sortSubCategories);
            ?>
            <ul class="tab" id="listCategories">
                @foreach($sortCategories as $x => $x_value)
                    <li id="list_{{ $x }}" class="btn-tab" style="
                    @php($categoryHidden = 0)
                    @if (!is_numeric(substr($x_value, 0, 1)))
                        display:none;
                        @php($categoryHidden = 1)
                    @endif
                    ">
                        <a onclick="selectionCategory({{ $x }})" style="cursor: pointer;"  class="" >
                                <?php
                                $firstCategoryName = explode('-', $x_value);
                                if (count($firstCategoryName) > 1){
                                    $titleCategoryName = $firstCategoryName[1];
                                } else {
                                    $titleCategoryName = $x_value;
                                }
                                ?>
                            {{ $titleCategoryName }}
                        </a>
                    </li>
                        <?php
                        $contCategories ++;
                        ?>
                @endforeach
                    @if ($categoryHidden == 1)
                    <li id="seeAllCategories" class="btn-tab" >
                        <a style="cursor: pointer;font-size: 2.4rem;" >+</a>
                    </li>
                    @endif
            </ul>

            @foreach($categories as $category)
                @foreach($category as $c)
                    @if ($c['productCategoryId'] == '' && $c['name'] != 'Inactivos')
                        <div id="tab_{{ $c['id']}}" class="tabcontent info" style="display: none;">
                                <?php
                                $categoryName = explode('-', $c['name']);
                                if (count($categoryName) > 1){
                                    $nameCategory = $categoryName[1];
                                } else {
                                    $nameCategory = $c['name'];
                                }
                                ?>
                            <h2>{{ $nameCategory }}</h2>
                            <ul id="products_{{ $c['id']}}">
                                    <?php
                                    $contProducts = 0;
                                    $contProductsActives = 0;
                                    ?>
                                @foreach($products as $product)
                                    @foreach($product as $p)
                                        @if($p['productCategoryId'] == $c['id'] && $p['price'] != 0 && $p['active'] == true && substr($p['name'], -1) == '@')
                                                <?php
                                                $style = '';
                                                $class = '';
                                                $productName = explode('-', $p['name']);
                                                if (count($productName) > 1){
                                                    $name = $productName[1];
                                                    $contProductsActives++;
                                                } else {
                                                    $name = $p['name'];
                                                    $style = 'display:none';
                                                    $class = 'productHidden';
                                                }
                                                ?>
                                            @if (substr($p['name'], 0, 1) != '#')
                                                <li id="{{ $p['name'] }}" class="{{ $class }}" style="{{ $style }}">
                                                    <div class="producto">
                                                        <div class="producto"> {{ trim($name, '@') }}</div>
                                                        <div class="desc-producto producto"> {{ $p['description'] }}</div>
                                                    </div>
                                                </li>
                                                    <?php
                                                    $contCategories ++;
                                                    $contProducts++;
                                                    ?>
                                            @endif
                                        @endif
                                    @endforeach
                                @endforeach
                                @if($contProducts != $contProductsActives)
                                    <li id="zzzzzzz" class="seeAllProducts" style="">
                                        <div class="producto">
                                            <div class="producto">
                                                <a style="cursor: pointer;" >+ Ver Más</a>
                                            </div>
                                        </div>
                                    </li>
                                @endif
                            </ul>
                            @foreach($sortSubCategories as $x => $x_value)
                                    <?php
                                    $id = explode('-',$x);
                                    ?>
                                @if ($id[1] == $c['id'] )
                                        <?php
                                        $subCategoryName = explode('-', $x_value);
                                        if (count($subCategoryName) > 1){
                                            $categorySubName = $subCategoryName[1];
                                        } else {
                                            $categorySubName = $x_value;
                                        }
                                        ?>
                                    <h2>{{ $categorySubName }}</h2>
                                    <ul id="products_{{ $id[0]}}">
                                            <?php
                                            $contProductsSub = 0;
                                            $contProductsActivesSub = 0;
                                            ?>
                                        @foreach($products as $product)
                                            @foreach($product as $p)
                                                @if($p['productCategoryId'] == $id[0] && $p['price'] != 0 && $p['active'] == true && substr($p['name'], -1) == '@')
                                                        <?php
                                                        $style = '';
                                                        $class = '';
                                                        $productName = explode('-', $p['name']);
                                                        if (count($productName) > 1){
                                                            $name = $productName[1];
                                                            $contProductsActivesSub++;
                                                        } else {
                                                            $name = $p['name'];
                                                            $style = 'display:none';
                                                            $class = 'productHidden';
                                                        }
                                                        ?>
                                                    @if (substr($p['name'], 0, 1) != '#')
                                                        <li id="{{ $p['name'] }}" class="{{ $class }}" style="{{ $style }}">
                                                            <div class="producto">
                                                                <div class="producto"> {{ trim($name, '@') }}</div>
                                                                <div class="desc-producto producto"> {{ $p['description'] }}</div>
                                                            </div>
                                                        </li>
                                                            <?php
                                                            $contProductsSub ++;
                                                            ?>
                                                    @endif
                                                @endif
                                            @endforeach
                                        @endforeach
                                        @if($contProductsSub != $contProductsActivesSub && $contProductsActivesSub != 0)
                                            <li id="zzzzzzz" class="seeAllProducts" style="">
                                                <div class="producto">
                                                    <div class="producto">
                                                        <a style="cursor: pointer;" >+ Ver Más</a>
                                                    </div>
                                                </div>
                                            </li>
                                        @endif
                                    </ul>
                                @endif
                            @endforeach
                        </div>
                    @endif
                @endforeach
            @endforeach
        </div>
    </section>

    <footer class="content">
        <div class="direccion">
            Av. Cramer 2830, Belgrano, CABA
        </div>
        <div class="copyright">
            Todos los derechos reservados
        </div>
    </footer>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="{{ asset('assets/js/burguer.js?v=234234') }}"></script>
<script src="{{ asset('assets/js/smooth.js') }}"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="{{ asset('assets/js/sticky.js') }}"></script>

<script>
    $( function() {
        let firstCategory = '<?php echo array_key_first($sortCategories);?>';
        $('#list_'+firstCategory).addClass('ui-tabs-active ui-state-active');
        selectionCategory(firstCategory);

        $('#seeAllCategories').click(function (){
            $('#listCategories li').each(function() {
                $(this).css('display', 'block');
            })
            $(this).css('display', 'none');
        });

        $('.seeAllProducts').click(function (){
            let listContainer = $(this).closest('ul').attr('id');
            $('#'+listContainer+ ' li').each(function() {
                $(this).css('display', 'block');
            })
            $(this).css('display', 'none');
        });
    } );
    function sort(id){
        const ul = document.getElementById('products_' + id);
        Array.from(ul.getElementsByTagName("LI"))
            .sort((a, b) => a.id.localeCompare(b.id))
            .forEach(li => ul.appendChild(li));
    }

    function selectionCategory(id){
        $('.seeAllProducts').css('display', 'block');
        $('.productHidden').css('display', 'none');
        $('.btn-tab').removeClass('ui-tabs-active ui-state-active');
        $('#list_'+id).addClass('ui-tabs-active ui-state-active');
        $('.info').css('display', 'none');
        $('#tab_'+id).css('display', 'block');
    }

    @foreach($sortSubCategories as $x => $x_value)
            <?php
            $idSubProduct = explode('-',$x);
            echo 'sort('.$idSubProduct[0].');';
            ?>
    @endforeach
    @foreach($sortCategories as $x => $x_value)
            <?php
            echo 'sort('.$x.');';
            ?>
    @endforeach
</script>
</body>
</html>


