{% macro render_additional_links(additional_links) %}
	{% if additional_links %}
		{% for item in additional_links %}
			<a href="{{item.href}}" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon"></span>
			{{_(item.label)}}</a>
		{% endfor %}
	{% endif %}
{% endmacro %}


{% macro render_field(field) %}
<div class="control-group">
	  {% if field.id != 'csrf_token' %}
	  {% if field.type == 'HiddenField' %}
	  	{{ field}}
	  {% else %}
		<div class="control-label">
		  <th class="col-lg-2">{{ field.label.text }}{% if field.flags.required %}<strong style="color: red">&#42;</strong>{% endif %}</th>
		</div>
		<div class="controls">
		  <td>{{ field(**kwargs)|safe }}
		<span class="help-block">{{ field.description }}</span>
	  {% endif %}
  	  {% if field.errors %}
	    <div class="alert alert-danger">
	    {% for error in field.errors %}
	      {{ _(error) }}
	    {% endfor %}
	    </div>
	  {% endif %}
	  {% endif %}
	</td></div>
</div>
{% endmacro %}

{% macro render_field_simple(field) %}
{% if field.id != 'csrf_token' %}
	<div class="control-label">
        	<th class="col-lg-2">{{ field.label.text }}</th>
        </div>
        <div class="controls">
                <td>{{ field(**kwargs)|safe }}</td>
	</div>
{% endif %}
{% endmacro %}

{% macro panel_begin(title) %}
<div class="panel panel-primary">
	<div class="panel-heading">
	<h4 class="panel-title">{{title}}</h4>
	</div>
{% endmacro %}
{% macro panel_end() %}
</div>
{% endmacro %}


{% macro accordion_tag(id, label, open) %}
<div class="panel-group" id="{{id}}">
 <div class="panel panel-default">
  <div class="panel-heading">
   <h4 class="panel-title">
   <a class="accordion-toggle" data-toggle="collapse" data-parent="#{{id}}" href="#{{id}}_href">{{label}}</a>
   </h4>
  </div>
  {% if open %}
  	<div id="{{id}}_href" class="panel-collapse collapse in">
  {% else %}
	<div id="{{id}}_href" class="panel-collapse collapse">
  {% endif %}
   <div class="panel-body">
	{{ caller() }}
   </div>
  </div>
 </div>
</div>
{% endmacro %}

{% macro render_form_controls() %}
<div class="well well-sm">
	<button type="submit" class="btn  btn-sm btn-primary">{{_("Save")}}
	<span class="glyphicon glyphicon-save"></span></button>
        <INPUT Type="button" class="btn  btn-sm btn-primary" VALUE="{{_('Back')}}" onClick="history.go(-1);return true;">
</div>
{% endmacro %}

{% macro btn_search() %}
<button type="submit" class="btn  btn-sm btn-primary">{{_("Search")}}
<span class="glyphicon glyphicon-search"></span>
</button>
{% endmacro %}

{% macro lnk_back() %}
<INPUT Type="button" class="btn  btn-sm btn-primary" VALUE="{{_('Back')}}" onClick="history.go(-1);return true;">
{% endmacro %}

{% macro lnk_add(my_href) %}
<a href="{{my_href}}" class="btn btn-sm btn-primary" data-toggle="tooltip" rel="tooltip" title="{{_('Add a new record')}}">
<span class="glyphicon glyphicon-plus"></span>
</a>
{% endmacro %}

{% macro lnk_edit(my_href) %}
<a href="{{my_href}}" class="btn btn-sm btn-primary" data-toggle="tooltip" rel="tooltip" title="{{_('Edit record')}}">
<span class="glyphicon glyphicon-edit"></span>
</a>
{% endmacro %}

{% macro lnk_show(my_href) %}
<a href="{{my_href}}" class="btn btn-sm btn-primary" data-toggle="tooltip" rel="tooltip" title="{{_('Show record')}}">
<span class="glyphicon glyphicon-search"></span>
</a>
{% endmacro %}

{% macro lnk_delete(my_href) %}
<a href="{{my_href}}" class="btn btn-sm btn-primary" data-toggle="tooltip" rel="tooltip" title="{{_('Delete record')}}" onclick="return confirm('{{ _('You sure you want to delete this item?') }}');">
<span class="glyphicon glyphicon-remove"></span>
</a>
{% endmacro %}

