<!doctype html>
<html>
<head>
    <title>Timepiece: {% block title %}{% endblock %}</title>
    <link rel="icon" type="image/png" href="{{ STATIC_URL }}images/icons/clock.png">

    {% block javascript %}
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
        <script src="{{ STATIC_URL }}timepiece/js/widgets.js"></script>
        <script src="{{ STATIC_URL }}bootstrap/js/bootstrap-dropdown.js"></script>
        {% if perms.timepiece.view_business %}
            {{ quick_search_form.media.js }}
            <script type="text/javascript" src="{{ STATIC_URL }}js/quicksearch.js"></script>
        {% endif %}
        <script src="{{ STATIC_URL}}bootstrap/js/bootstrap-alert.js"></script>
    {% endblock javascript %}

    {% block extrajs %}
    {% endblock extrajs %}

    {% block css %}
        <link type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" />
        <link type="text/css" rel="stylesheet" media="screen" href="{{ STATIC_URL }}css/books.css" />
    {% endblock %}

    {% block staticfiles %}
        {% load compress %}
        {% if debug %}
            <link rel="stylesheet/less" type="text/css" href="{{ STATIC_URL }}timepiece/less/style.less" />
            <script src="{{ STATIC_URL }}timepiece/js/less-1.3.0.min.js"></script>
        {% else %}
            {% compress css %}
                <link rel="stylesheet" type="text/less" href="{{ STATIC_URL }}timepiece/less/style.less" />
            {% endcompress %}
        {% endif %}
    {% endblock staticfiles %}

    {% block extracss %}
    {% endblock %}
</head>

<body id="{% block bodyid %}{% endblock bodyid %}">
    {% block navigation %}
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    {% block navbar-left %}
                        <ul class="nav pull-left">
                            <li class="active"><a class="brand" href="/">Timepiece</a></li>
                            {% if perms.timepiece.add_entry and perms.timepiece.can_clock_in %}
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dashboard <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="{% url timepiece-entries %}">Time Tracking</a></li>
                                         <li><a href="{% url view_person_time_sheet request.user.pk %}">My Ledger</a></li>
                                    </ul>
                                </li>
                            {% endif %}
                            {% if perms.timepiece.view_project or perms.auth.view_user or perms.timepiece.view_business %}
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">CRM <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        {% if perms.timepiece.view_project %}
                                            <li><a href="{% url list_projects %}">Projects</a></li>
                                        {% endif %}
                                        {% if perms.auth.view_user %}
                                            <li><a href="{% url list_people %}">People</a></li>
                                        {% endif %}
                                        {% if perms.timepiece.view_business %}
                                            <li><a href="{% url list_businesses %}">Businesses</a></li>
                                        {% endif %}
                                    </ul>
                                </li>
                            {% endif %}
                            {% if perms.timepiece.view_entry_summary %}
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Reports <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="{% url hourly_report %}">Hourly</a></li>
                                        {% if perms.timepiece.view_payroll_summary %}
                                            <li><a href="{% url payroll_summary %}">Payroll</a></li>
                                        {% endif %}
                                        {% if perms.timepiece.add_project_contract %}
                                            <li><a href="{% url list_contracts %}">Contracts</a></li>
                                        {% endif %}
                                        <li><a href="{% url timepiece-summary %}">General Ledger</a></li>
                                        <li class="divider"></li>
                                        {% if perms.timepiece.edit_person_time_sheet %}
                                            <li><a href="{% url invoice_projects %}">Invoices</a></li>
                                        {% endif %}
                                    </ul>
                                </li>
                            {% endif %}
                        </ul>
                    {% endblock %}

                    {% block navbar-right %}
                        {% if user.is_authenticated %}
                            <ul class="nav pull-right">
                                <li class="dropdown">
                                    <a href="" class="dropdown-toggle" data-toggle="dropdown">{{ user.email }} <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        {% if user.is_staff %}
                                            <li><a href="{% url admin:index %}">Admin</a></li>
                                        {% endif %}
                                        <li><a href="{% url edit_settings %}">Settings</a></li>
                                        <li><a href="{% url change_password %}">Change Password</a></li>
                                        <li class="divider"></li>
                                        <li><a href="{% url auth_logout %}">Logout</a></li>
                                    </ul>
                                </li>
                            </ul>
                        {% else %}
                            <a class="btn btn-primary pull-right" href="{% url auth_login %}">Login</a>
                        {% endif %}

                        {% block quick-search %}
                            {% if perms.timepiece.view_business %}
                                <form class="navbar-search pull-right" action="{% url quick_search %}" method="get" accept-charset="utf-8">
                                    {{ quick_search_form.quick_search }}
                                </form>
                            {% endif %}
                        {% endblock %}
                    {% endblock %}
                </div>
            </div>
        </div>
    {% endblock navigation %}

    <div id="content" class="container">
        {% include "timepiece/messages.html" %}

        {% if user.is_authenticated %}
            {% block breadcrumb %}
                <ul class="breadcrumb">
                    {% block crumbs %}
                        <li><a href="{% url timepiece-entries %}">Home</a></li>
                    {% endblock crumbs %}
                </ul>
            {% endblock breadcrumb %}
        {% endif %}

        {% block content %}
        {% endblock content %}
    </div>

    {% block footer %}
        <footer class="footer">
            <div class="container">
                <p class="pull-right">
                    <a href="https://github.com/caktus/django-timepiece/">Source</a>
                    |
                    <a href="http://www.caktusgroup.com/">Caktus Group</a>
                </p>
            </div>
        </footer>
    {% endblock footer %}
</body>

</html>
