@extends('layouts.admin')
@section('title' ,$title)

@push("js")

    <script>
        var $card = $("#card-payment-management");
        var activeTableId = "payments-table";

        $card.find('.nav a[data-toggle="tab"]').on('shown.bs.tab', function(e){
            var $active_tab = $(e.target); // active tab
            let tableId = $active_tab.attr("data-table-id");
            activeTableId = tableId;
          //  let warehouseType = parseInt($active_tab.attr("data-warehouse-type"));
            let url = $active_tab.attr("data-url");
            refresh_datatable(tableId,url)
        });


    </script>
@endpush

@section('content')
<div class="card shadow mb-4" id="card-payment-management">
        <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
            <h6 class="m-0 font-weight-bold text-success">{{$title}}</h6>
        </div>
        <ul class="nav nav-tabs" id="tab-stocks-management" role="tablist">
            @foreach($menus as $index => $options)
                <li class="nav-item">
                    <a data-toggle="tab" role="tab"
                       class="nav-link {{($loop->first) ?"border-left-0 active show":""}}"
                       id="{{$options['id']}}"
                       href="#{{$options['href']}}"
                       data-table-id ="{{$options['content']['table']['id']}}"
                       data-url ="{{$options['url']}}"
                       aria-controls="{{$options['id']}}"
                       aria-selected="{{($loop->first) ?"true":"false"}}">
                        <span class="{{$options['icon'] }}"></span>
                        {{__($options['title'])}}
                    </a>
                </li>
            @endforeach
        </ul>

        <div class="tab-content" id="tab-content-warehouses-management">
            @foreach($menus as $index => $options)
                <div role="tabpanel"
                     class="tab-pane fade {{($loop->first) ?"active show":""}}"
                     id="{{$options['href']}}"
                     aria-labelledby="{{$options['id']}}">
                    <?php  $dataTable = new $options['content']['dataTable'];
                    ?>
                    {!! $dataTable->render("backend.payments.tabs.index") !!}
                </div>
            @endforeach
        </div>
    </div>
@endsection
