{#
# This file is part of Invenio.
# Copyright (C) 2014, 2015 CERN.
#
# Invenio 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.
#
# Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#}

{%- macro panel_start(title, icon="", btn_text='', btn='', btn_icon='',
                      btn_href='', btn_class='btn-default', btn_name='',
                      btn2='', btn_icon2='', btn_href2='', btn_class2='btn-default',
                      btn_name2='', id="", with_body=True, panel_extra_class="panel-default") %}
{%- block panel_start scoped %}
<div class="panel-group panel-bot-margin"{% if id %} id="{{id}}"{% endif %}>
    <div class="panel {{panel_extra_class}}">
        {%- block panel_heading scoped %}
        <div class="panel-heading">
            <strong>{%if icon %}<i class="{{icon}}"></i>{% endif %} {{title}}</strong>
            {%- if btn and (btn_href or btn_text) -%}
            <div class="pull-right" style="margin-left: 5px;">
            {%- if btn_text %}
                <small class="text-muted" style="padding-right: 10px;">(updated {{last_sync}})</small>
            {%- endif %}
            {%- if btn_href %}
            <a class="pull-right btn btn-xs {{btn_class}}" href="{{btn_href}}">{% if btn_icon %}<i class="{{btn_icon}}"></i> {% endif %}{{btn}}</a>
            {%- else %}
            {%- if btn_name %}
            <button name="{{btn_name}}" class="btn btn-xs {{btn_class}}">{% if btn_icon %}<i class="{{btn_icon}}"></i> {% endif %}{{btn}}</button>
            {%- endif %}
            {%- endif %}
            </div>
            {%- endif -%}
            {%- if btn2 and btn_href2 -%}
            <div class="pull-right" style="margin-left: 5px;">
            {%- if btn_href2 %}
            <a class="pull-right btn btn-xs {{btn_class2}}" href="{{btn_href2}}">{% if btn_icon2 %}<i class="{{btn_icon2}}"></i> {% endif %}{{btn2}}</a>
            {%- else %}
            {%- if btn_name2 %}
            <button name="{{btn_name2}}" class="btn btn-xs {{btn_class2}}">{% if btn_icon2 %}<i class="{{btn_icon2}}"></i> {% endif %}{{btn2}}</button>
            {%- endif %}
            {%- endif %}
            </div>
            {%- endif -%}
        </div>
        {%- endblock %}
        {%- if with_body %}
        <div class="panel-body">
        {%- endif %}
{%- endblock %}
{%- endmacro %}


{%- macro panel_end(with_body=True) %}
{%- block panel_end scoped %}
        {%- if with_body %}
        </div>
        {%- endif %}
    </div>
</div>
{%- endblock %}
{%- endmacro %}
