<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="shortcut icon" type="image/x-icon" href="{{ asset('icons/favicon.ico') }}">
    <link rel="apple-touch-icon" sizes="180x180" href="{{ asset('icons/apple-touch-icon.png') }}">
    <link rel="icon" type="image/png" href="{{ asset('icons/favicon-32x32.png') }}" sizes="32x32">
    <link rel="icon" type="image/png" href="{{  asset('icons/favicon-16x16.png') }}" sizes="16x16">
    <link rel="manifest" href="{{ asset('manifest.json') }}">
    <link rel="mask-icon" href="{{ asset('icons/safari-pinned-tab.svg') }}" color="#5bbad5">
    <meta name="msapplication-config" content="{{ asset('icons/browserconfig.xml') }}">
    <meta name="theme-color" content="#ffffff">

    <title>{% block title %}{{ partdb_title }}{% endblock %}</title>
    {% block stylesheets %}
        {{ encore_entry_link_tags('app') }}
    {% endblock %}
</head>
<body>
{% block body %}

    <header>

        <nav class="navbar navbar-expand-md navbar-light bg-light border-bottom shadow-sm fixed-top py-0" id="navbar">

            <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#sidebar-container">
                <span class="sr-only">{% trans %}sidebar.toggle{% endtrans %}</span>
                <!-- <span class="navbar-toggler-icon"></span> -->
                <i class="fas fa-folder-open fa-lg fa-fw"></i>
            </button>

            <a class="navbar-brand" href="{{ path('homepage') }}"><i class="fa fa-microchip" aria-hidden="true"></i> {{ partdb_title }}</a>

            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
                <!-- <span class="navbar-toggler-icon"></span> -->
                <i class="fas fa-bars  fa-lg"></i>
            </button>



            <div class="collapse navbar-collapse" id="navbarContent">
                <div class="form-inline my-2 my-lg-0 ml-auto" id="searchbar">
                    <!-- Searchbar -->
                    <form action="{$relative_path}show_search_parts.php" method="get">
                        <div class="dropdown d-inline">
                            <button class="btn btn-light dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                {% trans %}search.options.label{% endtrans %}
                                <span class="caret"></span>
                            </button>
                            <div class="dropdown-menu" aria-labelledby="SearchOptions">
                                <div class="abc-checkbox form-check-dropdown"><input type="checkbox" class="form-check-input" name="search_name" value="true" checked>
                                    <label for="search_name" class="form-check-label">{% trans %}name.label{% endtrans %}</label></div>
                                <div class="abc-checkbox form-check-dropdown"><input type="checkbox" class="form-check-input" name="search_category" value="true" checked>
                                    <label for="search_category" class="form-check-label">{% trans %}category.label{% endtrans %}</label></div>
                                <div class="abc-checkbox form-check-dropdown"><input type="checkbox" class="form-check-input" name="search_description" value="true" checked>
                                    <label for="search_description" class="form-check-label"></label>{% trans %}description.label{% endtrans %}</div>
                                <div class="abc-checkbox form-check-dropdown"><input type="checkbox" class="form-check-input" name="search_storelocation" value="true" checked>
                                    <label for="search_storelocation" class="form-check-label">{% trans %}storelocation.label{% endtrans %}</label></div>
                                <div class="form-check-dropdown abc-checkbox" class="form-check-label"><input type="checkbox" class="form-check-input" name="search_comment" value="true" checked>
                                    <label for="search_comment" class="form-check-label">{% trans %}comment.label{% endtrans %}</label></div>
                                {% if true %}
                                    <div class="form-check-dropdown abc-checkbox"><input type="checkbox" class="form-check-input" name="search_supplierpartnr" value="true" checked>
                                        <label for="search_supplierpartnr" class="form-check-label">{% trans %}ordernumber.label.short{% endtrans %}</label></div>
                                    <li class="form-check-dropdown abc-checkbox"><input type="checkbox" class="form-check-input" name="search_supplier" value="true">
                                        <label for="search_supplier" class="form-check-label">{% trans %}supplier.label{% endtrans %}</label></li> {% endif %}
                                {% if true %}
                                    <div class="form-check-dropdown abc-checkbox"><input type="checkbox"  class="form-check-input" name="search_manufacturer" value="true">
                                    <label for="search_manufacturer" class="form-check-label">{% trans %}manufacturer.label{% endtrans %}</label></div>{% endif %}
                                {% if true %}
                                    <div class="form-check-dropdown abc-checkbox"><input type="checkbox" class="form-check-input" name="search_footprint" value="true">
                                    <label for="search_footprint" class="form-check-label">{% trans %}footprint.label{% endtrans %}</label></div>{% endif %}
                                <div class="form-c heck-dropdown abc-checkbox"><input type="checkbox" class="form-check-input" name="disable_pid_input" value="false">
                                    <label for="disable_pid_input" class="form-check-label">{% trans %}search.deactivateBarcode{% endtrans %}</label></div>
                                <div class="form-check-dropdown abc-checkbox"><input type="checkbox" class="form-check-input" name="regex" value="true">
                                    <label for="regex" class="form-check-label">{% trans %}search.regexmatching{% endtrans %}</label></div>
                            </div>
                        </div>
                        <input type="search" class="form-control mr-sm-2" placeholder="{% trans %}search.placeholder{% endtrans %}" name="keyword" onkeyup="livesearch(event, this, 2);">
                        <button type="submit" id="search-submit" class="btn btn-outline-secondary my-2">{% trans %}go.exclamation{% endtrans %}</button>
                    </form>
                </div>

                <a class="d-block d-md-none  nav-link link-datasheet" style="color: black;"
                   href="zxing://scan/?ret={if isset($smarty.server.HTTPS)}https{else}http{/if}%3A%2F%2F{$smarty.server.HTTP_HOST|escape:'url'}{$relative_path|escape:'url'}show_search_parts.php%3Fkeyword%3D%7BCODE%7D&SCAN_FORMATS=EAN_8,CODE_39">
                    <i class="fa fa-barcode fa-fw fa-lg" aria-hidden="true"></i>
                    <span class="ml-2 text-muted">{% trans %}barcode.scan{% endtrans %}</span>
                </a>

                <ul class="navbar-nav ml-3">
                    <li class="nav-item dropdown">
                        <a href="#" class="dropdown-toggle link-anchor nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            {% if app.user %}<i class="fa fa-user" aria-hidden="true"></i>{% else %}<i class="far fa-user" aria-hidden="true"></i>{% endif %} <span class="caret"></span></a>
                        <ul class="dropdown-menu dropdown-menu-right" id="login-menu">
                            {% if app.user %}
                                <a class="dropdown-item disabled" href="#" >{% trans %}user.loggedin.label{% endtrans %} {{ app.user.firstName }} {{app.user.lastName}} ({{app.user.name}})</a>
                                <a class="dropdown-item" href="{{ path("user_settings") }}"><i class="fa fa-cogs fa-fw" aria-hidden="true"></i> {% trans %}user.settings.label{% endtrans %}</a>
                                <a class="dropdown-item" href="{{ path("user_info_self") }}"><i class="fa fa-info-circle fa-fw" aria-hidden="true"></i> {% trans %}user.info.label{% endtrans %}</a>
                                <li role="separator" class="dropdown-divider"></li>
                                <a class="dropdown-item"  href="{{ path('logout') }}"><i class="fa fa-sign-out-alt fa-fw" aria-hidden="true"></i> {% trans %}user.logout{% endtrans %}</a>
                            {% else %}
                                <a class="dropdown-item" href="{{ path('login', {'_target_path':app.request.pathinfo}) }}" id="login-link"><i class="fa fa-sign-in-alt fa-fw" aria-hidden="true"></i> {% trans %}user.login{% endtrans %}</a>
                            {% endif %}
                            <li role="separator" class="dropdown-divider"></li>
                            <a class="dropdown-item disabled" href="#">{% trans %}user.language_select{% endtrans %}</a>
                            <a class="dropdown-item" href="{{ path(app.request.attributes.get('_route'),
                                   app.request.attributes.get('_route_params')|merge({'_locale': 'en'})) }}">
                                {% trans %}language.english{% endtrans %}</a>
                            <a class="dropdown-item" href="{{ path(app.request.attributes.get('_route'),
                                app.request.attributes.get('_route_params')|merge({'_locale': 'de'})) }}">
                                {% trans %}language.german{% endtrans %}</a>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>


        <div class="toast-container ">
            {% for label, messages in app.flashes() %}
                {% for message in messages %}
                    {% set flash_title = label|replace({'success': 'flash.success', 'error': 'flash.error'
                        , 'warning': 'flash.warning', 'notice': 'flash.notice', 'info': 'flash.info'}) %}
                    {% set flash_symbol = label|replace({'success': 'fa-check-circle', 'error': 'fa-exclamation-triangle'
                    , 'warning': 'fa-exclamation-circle', 'notice': 'fa-flag', 'info': 'fa-flag'}) %}

                    {% set flash_bg = label|replace({'success': 'bg-success text-white',
                        'error': 'bg-danger text-white', 'warning': 'bg-warning text-white',
                        'notice': 'bg-info text-white', 'info': 'bg'})%}

                    <div class="toast " role="alert" aria-live="assertive" aria-atomic="true" data-delay="2000">
                        <div class="toast-header {{ flash_bg }}">
                            {# <img src="..." class="rounded mr-2" alt="...">#}
                            <i class="fas fa-fw {{ flash_symbol }} mr-2"></i>
                            <strong class="mr-auto">{{ flash_title|trans }}</strong>
                            {#<small class="text-muted">11 mins ago</small> #}
                            <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="toast-body {{ flash_bg }}">
                            {{ message}}
                        </div>
                    </div>
                {% endfor %}
            {% endfor %}
        </div>

    </header>

    <main>
        <div class="container-fluid">
            <div class="row">
                <div class="collapse d-md-block bg-light" id="sidebar-container">
                    <nav  class="fixed-sidebar col-md-3 col-lg-2 " id="fixed-sidebar">
                        <ul class="nav flex-column">
                            <li id="treeBox-categories">
                                <div class="dropdown">
                                    <button class="btn-text dropdown-toggle mb-2" type="button" id="dropdownCat" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                        <span class="sidebar-title" id="tree-categories-title">{% trans %}category.labelp{% endtrans %}</span>
                                    </button>
                                    <ul class="dropdown-menu" aria-labelledby="dropdownCat">
                                        <li class="dropdown-header">{% trans %}actions{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="expand" data-target="tree-categories">{% trans %}expandAll{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="collapse" data-target="tree-categories">{% trans %}reduceAll{% endtrans %}</a></li>
                                        <li role="separator" class="dropdown-divider"></li>
                                        <li class="dropdown-header">{% trans %}datasource{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="categories" data-target="tree-categories">{% trans %}category.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="locations" data-target="tree-categories">{% trans %}storelocation.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="footprints" data-target="tree-categories">{% trans %}footprint.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="manufacturers" data-target="tree-categories">{% trans %}manufacturer.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="suppliers" data-target="tree-categories">{% trans %}supplier.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="devices" data-target="tree-categories">{% trans %}device.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="tools" data-target="tree-categories">{% trans %}tools.label{% endtrans %}</a></li>
                                    </ul>
                                </div>
                                <div id="tree-categories"></div>
                            </li>
                            <li id="treeBox-devices">
                                <div class="dropdown">
                                    <button class="btn-text dropdown-toggle mb-2 mt-2" type="button" id="dropdownDev" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                        <span class="sidebar-title" id="tree-devices-title">{% trans %}device.labelp{% endtrans %}</span>
                                    </button>
                                    <ul class="dropdown-menu" aria-labelledby="dropdownDev">
                                        <li class="dropdown-header">{% trans %}actions{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="expand" data-target="tree-devices">{% trans %}expandAll{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="collapse" data-target="tree-devices">{% trans %}reduceAll{% endtrans %}</a></li>
                                        <li role="separator" class="dropdown-divider"></li>
                                        <li class="dropdown-header">{% trans %}datasource{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="categories" data-target="tree-devices">{% trans %}category.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="locations" data-target="tree-devices">{% trans %}storelocation.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="footprints" data-target="tree-devices">{% trans %}footprint.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="manufacturers" data-target="tree-devices">{% trans %}manufacturer.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="suppliers" data-target="tree-devices">{% trans %}supplier.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="devices" data-target="tree-devices">{% trans %}device.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="tools" data-target="tree-devices">{% trans %}tools.label{% endtrans %}</a></li>
                                    </ul>
                                </div>
                                <div id="tree-devices"></div>
                            </li>

                            <li id="treeBox-tools">
                                <div class="dropdown">
                                    <button class="btn-text dropdown-toggle mb-2 mt-2" type="button" id="dropdownTools" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                        <span class="sidebar-title" id="tree-tools-title">{% trans %}tools.label{% endtrans %}</span>
                                    </button>
                                    <ul class="dropdown-menu" aria-labelledby="dropdownTools">
                                        <li class="dropdown-header">{% trans %}actions{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="expand" data-target="tree-tools">{% trans %}expandAll{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="collapse" data-target="tree-tools">{% trans %}reduceAll{% endtrans %}</a></li>
                                        <li role="separator" class="dropdown-divider"></li>
                                        <li class="dropdown-header">{% trans %}datasource{% endtrans %}</li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="categories" data-target="tree-tools">{% trans %}category.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="locations" data-target="tree-tools">{% trans %}storelocation.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="footprints" data-target="tree-tools">{% trans %}footprint.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="manufacturers" data-target="tree-tools">{% trans %}manufacturer.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="suppliers" data-target="tree-tools">{% trans %}supplier.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="devices" data-target="tree-tools">{% trans %}device.labelp{% endtrans %}</a></li>
                                        <li><a href="#" class="tree-btns dropdown-item" data-mode="tools" data-target="tree-tools">{% trans %}tools.label{% endtrans %}</a></li>
                                    </ul>
                                </div>
                                <div id="tree-tools"></div>
                            </li>
                        </ul>


                        <noscript><b>{% trans %}vendor.base.javascript_hint{% endtrans %}</b></noscript>

                    </nav>
                </div>

                <div class="col-md-9 col-lg-10 offset-md-3 offset-lg-2 pl-0" id="main">
                    <div class="container-fluid mr-0 pr-0" id="content">
                        <div id="content-data">

                            {#
                            {if isset($messages)}
                            {assign "alert_style" "alert-info"}
                            {assign "alert_icon" "fas fa-info"}
                            {foreach $messages as $msg}
                            {if isset($msg.color) && $msg.color == "red"}
                            {assign "alert_style" "alert-danger"}
                            {assign "alert_icon" "fas fa-exclamation"}
                            {elseif isset($msg.color) && ( $msg.color == "green" || $msg.color == "darkgreen")}
                            {assign "alert_style" "alert-success"}
                            {assign "alert_icon" "fas fa-check"}
                            {elseif isset($msg.color) && ($msg.color == "yellow" || $msg.color == "orange")}
                            {assign "alert_style" "alert-warning"}
                            {assign "alert_icon" "fas fa-bell"}
                            {/if}
                            {/foreach}
                            <div class="alert {$alert_style}" id="messages">
                                <div class="row vertical-align">
                                    <div class="col-md-1">
                                        <i class="{$alert_icon} fa-5x" style="text-align: center; width: 1em;"></i>
                                    </div>
                                    <div class="col-md-11">
                                        <div>
                                            {if !empty($messages_div_title)}<h4>{$messages_div_title}</h4>{/if}
                                            <form action="" method="post" class="no-progbar">
                                                {foreach $messages as $msg}
                                                {if isset($msg.text)}
                                                {if isset($msg.strong) && $msg.strong}<strong>{/if}
                                                    {$msg.text nofilter}
                                                    {if isset($msg.strong) && $msg.strong}</strong>{/if}
                                                {/if}

                                                {if isset($msg.html)}
                                                {$msg.html nofilter}
                                                {/if}

                                                {if !isset($msg.no_linebreak) || !$msg.no_linebreak}<br>{/if}
                                                {/foreach}

                                                {if !empty($reload_link)}
                                                <a href="{$reload_link}">
                                                    <br>
                                                    <button class="btn btn-secondary">Seite neu laden</button>
                                                </a>
                                                {/if}
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            #}

                            {# Here will be the real content be injected#}

                            {% block content %}
                            {% endblock %}

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
{% endblock %}
{% block javascripts %}
    {{ encore_entry_script_tags('app') }}

    <script src="{{ asset('helper/datatables.js') }}"></script>

    <script>
        $(".toast").toast('show');
    </script>

{% endblock %}


<script>
    $.getJSON("{{ path("tree_tools") }}",null, function (data) {
        $('#tree-tools').treeview({
            data: data,
            showIcon: false
        });
    });

    $.getJSON("{{ path("tree_category", {"id": 1}) }}",null, function (data) {
        $('#tree-categories').treeview({
            data: data,
            showIcon: false,
            enableLinks: true
        });
    });
</script>

{% block scripts %}

{% endblock %}
</body>
</html>
