{% extends 'base_rigs.html' %}
{% block title %}RIGS{% endblock %}

{% block js %}
<script>
    $(function () {
          $('[data-toggle="tooltip"]').tooltip();
        })
</script>
{% endblock %}

{% block content %}
    <div class="col-sm-12">
        <h1>R<small>ig</small> I<small>nformation</small> G<small>athering</small> S<small>ystem</small></h1>
    </div>
    <div class="col-sm-12">
        <p><h4 class="list-group-item-heading" style="margin:0;">Welcome back {{ user.get_full_name }}, there are {{ rig_count }} rigs coming up.</h4>
        </p>
    </div>
    <div class="row">
    <div class="col-sm-{% if perms.RIGS.view_event %}6{% else %}12{% endif %}">

        <div class="panel panel-default">
            <div class="panel-heading">
                 <h4 class="list-group-item-heading">Quick Links</h4>
            </div>
            <div class="list-group">
                    <a class="list-group-item" href="{% url 'rigboard' %}"><span class="glyphicon glyphicon-list"></span> Rigboard</a>
                    <a class="list-group-item" href="{% url 'web_calendar' %}"><span class="glyphicon glyphicon-calendar"></span> Calendar</a>
                    {% if perms.RIGS.add_event %}<a class="list-group-item" href="{% url 'event_create' %}"><span class="glyphicon glyphicon-plus"></span> New Event</a>{% endif %}
                    <a class="list-group-item" href="{% url 'asset_index' %}"><span class="glyphicon glyphicon-tag"></span> Asset Database </a>

                    <div class="list-group-item default"></div>

                    <a class="list-group-item" href="https://forum.nottinghamtec.co.uk" target="_blank"><span class="glyphicon glyphicon-link"></span> TEC Forum</a>
                    <a class="list-group-item" href="//members.nottinghamtec.co.uk/wiki" target="_blank"><span class="glyphicon glyphicon-link"></span> TEC Wiki</a>
                    {% if perms.RIGS.view_event %}
                    <a class="list-group-item" href="//members.nottinghamtec.co.uk/ra" target="_blank"><span class="glyphicon glyphicon-link"></span> Pre-Event Risk Assessment</a>
                    <a class="list-group-item" href="//members.nottinghamtec.co.uk/price" target="_blank"><span class="glyphicon glyphicon-link"></span> Price List</a>
                    <a class="list-group-item" href="https://goo.gl/forms/jdPWov8PCNPoXtbn2" target="_blank"><span class="glyphicon glyphicon-link"></span> Subhire Insurance Form</a>
                    {% endif %}
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-heading">
              <h4 class="panel-title">Search Rigboard
                <a href="{% url 'search_help' %}" class="pull-right modal-href"><span class="glyphicon glyphicon-question-sign"</span></a></h4>
            </div>
            <script>
                $(document).ready(function(){
                    $('#search-options li a').click(function(){
                        $('#searchForm').attr('action', $(this).data('action')).submit();
                    });
                    $('#id_search_input').keypress(function (e) {
                      if (e.which == 13) {
                        $('#searchForm').attr('action', $('#search-options li a').first().data('action')).submit();
                        return false;
                      }
                    });

                });
            </script>
            <div class="list-group">
                <div class="list-group-item">
                    <form id="searchForm" class="form" role="form" method="GET">
                        <div class="input-group" data-toggle="tooltip" title="Use the dropdown button to select what to search. The default is Event Archive.">
                            <input id="id_search_input" type="search" name="q" class="form-control" placeholder="Search..." />
                            <span class="input-group-btn">
                                <div class="btn-group" role="group">
                                    <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-search"></span> Search <span class="caret"></span></button>
                                     <ul id="search-options" class="dropdown-menu">
                                      <li><a data-action="{% url 'event_archive' %}" href="#">Events</a></li>
                                      <li><a data-action="{% url 'person_list' %}" href="#">People</a></li>
                                      <li><a data-action="{% url 'organisation_list' %}" href="#">Organisations</a></li>
                                      <li><a data-action="{% url 'venue_list' %}" href="#">Venues</a></li>
                                      {% if perms.RIGS.view_invoice %}
                                      <li><a data-action="{% url 'invoice_archive' %}" href="#">Invoices</a></li>
                                      {% endif %}
                                    </ul>
                                </div>
                            </span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    {% if perms.RIGS.view_event %}
    <div class="col-sm-6">
        {% include 'RIGS/activity_feed.html' %}
    </div>
    {% endif %}
</div>
{% endblock %}
