{% extends "layout.html" %}

{% block content_header %}
  {{ build_breadcrumbs(current_breadcrumbs + [
    { 'name': resource.caller_id_name, 'link': url_for('.IncallView:get', id=resource.id), 'icon': 'long-arrow-right' }
  ]) }}
{% endblock %}

{% block content %}
  {% call build_section_row() %}

    {% call build_form_tabs_box() %}
      {% call build_tabs_navigation() %}
        {{ add_tab_navigation_header(_('Incall'), '', 'long-arrow-right') }}
        {{ add_tab_navigation_item('incall', _('Incall'), active=True) }}
        {{ add_tab_navigation_item('schedule', _('Schedule')) }}
      {% endcall %}

      {% call build_form(action=url_for('.IncallView:put', id=resource.id)) %}
        {% call build_tabs_content() %}

          {% call build_tab_content_item('incall', active=True) %}
            {% call add_default_fields(form=form, submit_value=_('Update')) %}
              {{ render_field(form.extensions[0].context,
                              label='Exten',
                              inputclass='ui-helper-clearfix',
                              divclass='col-sm-4',
                              class_='incall-context',
                              placeholder=_('Choose Incall Context'),
                              data_listing_href=url_for(listing_urls['context_by_type'], type_='incall')) }}
              {{ render_field(form.extensions[0].exten,
                              data_allow_custom_values=True,
                              divclass='col-sm-2',
                              with_label=False,
                              class_='incall-exten',
                              data_listing_href=url_for(listing_urls['available_extension_incall'])) }}
              {{ render_field(form.destination, with_label=False) }}
              {{ render_field(form.preprocess_subroutine) }}
              {{ render_field(form.greeting_sound) }}
              {{ render_field(form.caller_id_mode, data_allow_clear='true') }}
              {{ render_field(form.caller_id_name) }}
            {% endcall %}
          {% endcall %}

          {% call build_tab_content_item('schedule') %}
            {% call add_default_fields(form=form, submit_value=_('Update')) %}
                {{ render_field(form.schedules[0]['name']) }}
                {{ render_field(form.schedules[0]['id'],
                                data_listing_href=url_for(listing_urls['schedule']),
                                data_allow_clear='true',
                                data_placeholder=_('Choose Schedules')) }}
            {% endcall %}
          {% endcall %}

        {% endcall %}
      {% endcall %}

    {% endcall %}

  {% endcall %}
{% endblock %}

{% block additional_js %}
  <script src="{{ url_for('.static', filename='js/incall.js') }}"></script>
{% endblock %}
