{% load i18n staticfiles leprikon_tags %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="cs-CZ">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <title>
        Deník zájmového útvaru: {{ course.name }}
    </title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"/>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style>
        body {
            background: grey;
            padding: 10px;
        }
        .paper {
            background: white;
            margin: 20px auto;
            padding-bottom: 25px;
            font-size: 9pt;
        }
        h1 {
            font-size: 14pt;
        }
        table {
            width: 100%;
            margin-top: 1em;
            margin-bottom: 1em;
        }
        tr, th, td {
            padding: 5px;
            border: solid 1px black;
        }
        .presence tr:hover {
            backgound: #eee;
        }
        .presence th.vertical {
            height: 12em;
            vertical-align: bottom;
        }
        .vertical div {
            width: 1em;
            white-space: nowrap;
            -webkit-transform: rotate(-90deg);
            -moz-transform: rotate(-90deg);
            -ms-transform: rotate(-90deg);
            -o-transform: rotate(-90deg);
            transform: rotate(-90deg);
        }
        .empty {
            width: 90%;
        }
        .placeholder {
            height: 100px;
        }
        p {
            margin: 0;
        }
        .btn {
            float: right;
        }
        @media print {
            html, body, .paper {
                margin: 0;
                padding: 0;
            }
            .paper {
                width: 100%;
                page-break-after: always;
            }
            .btn, .noprint {
                display: none;
            }
            .presence th.vertical {
                height: 11em;
            }
            a[href]:after {
                 content: '';
            }
        }
    </style>

    <!-- Shortcut icon -->
    <link rel="shortcut icon" href="{% static 'leprikon/img/favicon.ico' %}" />
</head>

<body>
    {% if not admin %}
    <div class="container noprint">
        <a class="btn btn-default" href="{% url_back %}" title="{% trans 'back' %}">
            &#x2716;
        </a>
    </div>
    {% endif %}
    {% if messages %}
    <div class="container noprint">
        {% for message in messages %}
        <div class="alert alert-{{ message.level_tag }} alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="zavřít">
                <span class="glyphicon glyphicon-remove"></span>
            </button>
            {{ message }}
        </div>
        {% endfor %}
    </div>
    {% endif %}
    {% for period in course.all_journal_periods %}
    {% with period.journal_entries.count|add:2 as columns_count %}
    <div class="container paper">
        <h1>{% trans 'Attendance' %} - {{ period.period.name }}</h1>
        <div style="overflow: auto">
        <table class="table-hover presence">
            <tr>
                <th>{% trans 'Name' context 'person' %}</th>
                {% for entry in period.all_journal_entries %}
                <th class="vertical">
                    <div>
                        {% if not admin %}
                        <a class="noprint" href="{% url_with_back 'leprikon:coursejournalentry_update' entry.id %}" title="{% trans 'edit' %}">
                            <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                        </a>
                        {% endif %}
                        {{ entry.date }}
                    </div>
                </th>
                {% endfor %}
                {% if not admin %}
                <th class="vertical">
                    <div>
                        <a class="noprint" href="{% url_with_back 'leprikon:coursejournalentry_create' course.id %}">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                            {% trans 'add entry' %}
                        </a>
                        &nbsp;
                    </div>
                </td>
                {% endif %}
            </tr>
            <tr>
                <th colspan="{{ columns_count }}">{% trans 'Leaders' %}</td>
            </tr>
            {% for pr in period.get_leader_presences %}
            <tr>
                <td>{{ pr.name }}</td>
                {% for p in pr.presences %}
                <td>{% if p %}<a href="{{ p.get_edit_url }}?{% param_back %}={% current_url %}">&#x2717;</a>{% endif %}</td>
                {% endfor %}
                <td>&nbsp;</td>
            </tr>
            {% endfor %}
            {% for pr in period.get_alternate_presences %}
            <tr>
                <td>{{ pr.name }}</td>
                {% for p in pr.presences %}
                <td>{% if p %}<a href="{{ p.get_edit_url }}?{% param_back %}={% current_url %}">&#x2717;</a>{% endif %}</td>
                {% endfor %}
                <td>&nbsp;</td>
            </tr>
            {% endfor %}
            <tr>
                <th colspan="{{ columns_count }}">{% trans 'Participants' %}</td>
            </tr>
            {% for pr in period.get_participant_presences %}
            <tr>
                <td>{{ pr.name }}</td>
                {% for p in pr.presences %}
                <td>{% if p %}&#x2717;{% endif %}</td>
                {% endfor %}
                <td class="empty"></td>
            </tr>
            {% endfor %}
        </table>
        </div>
    </div>
    {% endwith %}
    {% endfor %}

    {% for period in course.all_periods %}
    <div class="container paper">

        <h1>{% trans 'Agenda' %} - {{ period.name }}</h1>
        <table class="journal">
            <tr>
                <th>{% trans 'Date' %}</th>
                <th>{% trans 'Time' %}</th>
                <th>{% trans 'Number of hours' %}</th>
                <th>{% trans 'Number of leaders' %}</th>
                <th>{% trans 'Number of participants' %}</th>
                <th>{% trans 'Session agenda' %}</th>
            </tr>
            {% for entry in period.all_journal_entries %}
            <tr>
                <td>{{ entry.date }}</td>
                <td>{% if entry.duration %}{{ entry.start }}{% else %}{% trans 'canceled' %}{% endif %}</td>
                <td>{% if entry.duration %}{{ entry.duration }}{% else %}{% trans 'canceled' %}{% endif %}</td>
                <td>{{ entry.all_leader_entries|length }}</td>
                <td>{{ entry.all_registrations|length }}</td>
                <td>
                    {% if not admin %}
                    <a class="btn btn-primary btn-xs" href="{% url_with_back 'leprikon:coursejournalentry_update' entry.id %}">
                        <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                        {% trans 'edit' %}
                    </a>
                    {% endif %}
                    {{ entry.agenda | safe }}
                </td>
            </tr>
            {% endfor %}
            {% if not admin %}
            <tr class="noprint">
                <td colspan="6">
                    <a class="btn btn-primary btn-xs" href="{% url_with_back 'leprikon:coursejournalentry_create' course.id %}">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                        {% trans 'add entry' %}
                    </a>
                </td>
            </tr>
            {% endif %}
        </table>

    </div>
    {% endfor %}

    <div class="container paper">

        <h1>
            {% trans 'Risks' %}
            {% if not admin %}
            <a class="btn btn-primary btn-xs" href="{% url_with_back 'leprikon:subject_update' course.subject_type.slug course.id %}">
                <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                {% trans 'edit' %}
            </a>
            {% endif %}
        </h1>

        <table id="risks">
            <tr>
                <th>{% trans 'Place / Risk' %}</th>
            </tr>
            <tr>
                <td class="placeholder">{{ course.risks | safe }}</td>
            </tr>
        </table>

        <h1>
            {% trans 'Plan for the whole year course activity' %}
            {% if not admin %}
            <a class="btn btn-primary btn-xs" href="{% url_with_back 'leprikon:subject_update' course.subject_type.slug course.id %}">
                <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                {% trans 'edit' %}
            </a>
            {% endif %}
        </h1>
        <table id="plan">
            <tr>
                <td class="placeholder" colspan="2">{{ course.plan | safe }}</td>
            </tr>
            <tr>
                <th>{% trans 'Signature' %}</th>
                <td class="empty"></td>
            </tr>
        </table>

        <h1>
            {% trans 'Evaluation of the whole year course activity' %}
            {% if not admin %}
            <a class="btn btn-primary btn-xs" href="{% url_with_back 'leprikon:subject_update' course.subject_type.slug course.id %}">
                <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                {% trans 'edit' %}
            </a>
            {% endif %}
        </h1>
        <table id="evaluation">
            <tr>
                <td class="placeholder" colspan="2">{{ course.evaluation | safe }}</td>
            </tr>
            <tr>
                <th>{% trans 'Signature' %}</th>
                <td class="empty"></td>
            </tr>
        </table>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.2/jquery.min.js" integrity="sha384-o6l2EXLcx4A+q7ls2O2OP2Lb2W7iBgOsYvuuRI6G+Efbjbk6J4xbirJpHZZoHbfs" crossorigin="anonymous"></script>

    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

</body>

</html>
