<commit_before>{% extends 'site/base.twig' %}

{% import 'site/partials/form.twig' as forms %}

{% block content %}
    <div class="page-header">
        <h1>{{ translate('Book Textbooks') }}</h1>
    </div>
    <div class="page-alert">
        <div class="flashmessage alert alert-danger alert-fixed-top fade" id="keep_updated_error">
            <a class="close">&times;</a>
            <div class="content">
                {{ translate('An error occurred while updating your preferences.') }}
            </div>
        </div>
        <div class="flashmessage alert alert-success alert-fixed-top fade" id="keep_updated_success">
            <a class="close">&times;</a>
            <div class="content">
                {{ translate('Your preferences where succesfully saved.') }}
            </div>
        </div>
    </div>
    {% if isic.enable %}
        <div class="alert alert-info">
            <p>
                <b>{{ translate('VTK provides you with ISIC cards.') }} <a href="https://vtk.be/page/name/isic/">{{ translate('click here') }}</a> </b>
            </p>
        </div>
    {% endif %}

    {% if authenticatedPerson == null %}
        {{ translate('Please login to book textbooks.') }}
    {% else %}
        {% if hasAccess('cudi_booking', 'search') or hasAccess('cudi_booking', 'keepUpdated') %}
            <div style="height: 60px" class="hidden-xs hidden-sm">
                <div class="pull-right">
                    {% if hasAccess('cudi_booking', 'keepUpdated') %}
                        <button class="btn btn-warning" id="keepUpdated" {% if isSubscribed %}style="display: none"{% endif %} rel="tooltip" data-toggle="tooltip" title="{{ translate('You will receive an e-mail when the catalog is updated.') }}">{{ translate('Enable catalog update mails') }}</button>
                        <button class="btn btn-warning" id="dontKeepUpdated" {% if not isSubscribed %}style="display: none"{% endif %} rel="tooltip" data-toggle="tooltip" title="{{ translate('You won\'t receive an e-mail when the catalog is updated.') }}">{{ translate('Disable catalog update mails') }}</button>
                    {% endif %}
                    {% if hasAccess('cudi_booking', 'search') %}
                        <a href="#" id="searchArticles" class="btn btn-info">{{ translate('Search') }}</a>
                    {% endif %}
                </div>
            </div>

            {% if hasAccess('cudi_booking', 'search') %}
                <div id="searchArticlesPage" style="display: none;margin-top: 10px;">
                    {% import 'site/partials/form.twig' as forms %}
                    {{ forms.renderForm(searchForm) }}

                    <table class="table bookings">
                        <thead>
                            <tr>
                                <th>{{ translate('Title') }}</th>
                                <th class="hidden-xs">{{ translate('Authors') }}</th>
                                <th style="min-width: 100px">{{ translate('Price / Piece') }}</th>
                                <th class="hidden-xs" style="min-width: 60px">{{ translate('Mandatory') }}</th>
                                <th class="hidden-xs" style="min-width: 70px">{{ translate('Remarks') }}</th>
                                <th style="min-width: 100px"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="spacer">
                                <td colspan="7"></td>
                            </tr>
                            <tr class="course-title">
                                <td colspan="7"><i>{{ translate('No Articles Found') }}</i></td>
                            </tr>
                        </tbody>
                    </table>

                    <a class="btn btn-default pull-left" href="{{ url('cudi_booking', {'action' : 'view'}) }}">{{ translate('Back') }}</a>
                    <button id="bookSearchArticles" class="btn btn-primary pull-right" style="display: none">{{ translate('Book') }}</button>
                </div>
            {% endif %}
        {% endif %}

        <div id="viewArticlesPage">
            {% autoescape false %}
            {{ form().openTag(form) }}
                {{ formElement(form.get('csrf')) }}

                <table class="table bookings">
                    <thead>
                        <tr>
                            <th>{{ translate('Title') }}</th>
                            <th class="hidden-xs">{{ translate('Authors') }}</th>
                            <th style="min-width: 100px">{{ translate('Price / Piece') }}</th>
                            <th class="hidden-xs" style="min-width: 60px">{{ translate('Mandatory') }}</th>
                            <th class="hidden-xs" style="min-width: 70px">{{ translate('Remarks') }}</th>
                            <th style="min-width: 100px"></th>
                        </tr>
                    </thead>

                    <tbody>

                    {% for subjectArticle in subjectArticleMap %}
                        <tr class="spacer">
                            <td colspan="7"></td>
                        </tr>

                        <tr {% if null != subjectArticle['subject'] %}class="course-title"{% endif %}>
                            <td colspan="7" {% if null == subjectArticle['subject'] %}style="border: none;"{% endif %}>
                                {% if null == subjectArticle['subject'] %}
                                    <h1>{{ translate('General') }}</h1>
                                {% else %}
                                    {{ subjectArticle['subject'].getCode() }} - {{ subjectArticle['subject'].getName() }}
                                {% endif %}
                            </td>
                        </tr>

                        {% for map in subjectArticle['articles'] %}
                            <tr class="{% if map['booked'] > 0 %}warning{% endif %} {% if map['sold'] > 0 %}success{% endif %}">
                                <td>{{ map['article'].getMainArticle().getTitle() }}</td>
                                <td class="hidden-xs">{{ map['article'].getMainArticle().getAuthors() }}</td>
                                <td>
                                    {% if map['article'].getDiscounts()|length > 0 %}
                                        <span rel="popover" data-original-title="{{ translate('Discounts') }}" data-content="
                                        {% for discount in map['article'].getDiscounts() %}
                                            <span class='badge'>{{ translate(discount.getType()) }} {% if discount.getOrganization() %}{{ discount.getOrganization().getName() }}{% endif %}</span> &euro; {{ (discount.apply(map['article'].getSellPrice())/100)|number_format(2) }}<br/>
                                        {% endfor %}
                                    " data-placement="right" style="cursor: pointer">&euro; {{ (map['article'].getSellPrice()/100)|number_format(2) }} <span class="glyphicon glyphicon-info-sign"></span></span>
                                    {% else %}
                                        <span>&euro; {{ (map['article'].getSellPrice()/100)|number_format(2) }}</span>
                                    {% endif %}
                                </td>
                                <td class="hidden-xs">{{ map['mandatory'] ? '&times;' : '' }}</td>
                                <td class="hidden-xs">
                                    {% if map['comments']|length > 0 %}
                                        <a rel="popover" data-original-title="{{ translate('Comments') }}" data-content="

                                        {% for comment in map['comments'] %}
                                            <span class='badge badge-info'>{{ loop.index }}</span> {{ comment.getText()|escape }}<br/>
                                        {% endfor %}

                                        " data-placement="left" class="label label-warning">{{ map['comments']|length }} {{ map['comments']|length > 1 ? translate('Remarks') : translate('Remark') }}</a>
                                    {% endif %}
                                </td>
                                <td style="text-align: center;">
                                    {% if map['bookable'] %}
                                        {% set name = 'article-' ~ map['article'].getId() %}
                                        {% set element = form.get(name) %}
                                        {{ formElement(element) }}

                                        <a href="#" class="decrease-value"><span class="glyphicon glyphicon-minus-sign pull-left" style="margin-top: 3px;"></span></a><b>0</b><a href="#" class="increase-value"><span class="glyphicon glyphicon-plus-sign pull-right" style="margin-top: 3px;"></span></a>
                                    {% else %}
                                        <span class="label label-info hidden-xs">{{ translate('Not Bookable') }}</span>
                                    {% endif %}
                                </td>
                            </tr>

                            {% if element.getMessages()|length > 0  and map['bookable'] %}
                                <tr>
                                    <td colspan="7" style="border-top-width:0px;">
                                        <div class="help-block pull-right">
                                            {{ formElementErrors(element) }}
                                        </div>
                                    </td>
                                </tr>
                            {% endif %}
                        {% else %}
                            <tr>
                                <td colspan="7" style="border-top-width:0px;">
                                    <div>
                                        <em>{{ translate('No articles available for this subject.') }}</em>
                                    </div>
                                </td>
                            </tr>
                        {% endfor %}
                    {% endfor %}

                    </tbody>

                </table>

                <div>
                    <a class="btn btn-default" href="{{ url('cudi_booking', {'action' : 'view'}) }}">{{ translate('Back') }}</a>

                    {% if form.get('submit') %}
                        {{ formElement(form.get('submit')) }}
                    {% endif %}
                </div>

            {{ form().closeTag() }}

            {% endautoescape %}<commit_msg>Resolved booking form render bug<commit_after>{% extends 'site/base.twig' %}

{% import 'site/partials/form.twig' as forms %}

{% block content %}
    <div class="page-header">
        <h1>{{ translate('Book Textbooks') }}</h1>
    </div>
    <div class="page-alert">
        <div class="flashmessage alert alert-danger alert-fixed-top fade" id="keep_updated_error">
            <a class="close">&times;</a>
            <div class="content">
                {{ translate('An error occurred while updating your preferences.') }}
            </div>
        </div>
        <div class="flashmessage alert alert-success alert-fixed-top fade" id="keep_updated_success">
            <a class="close">&times;</a>
            <div class="content">
                {{ translate('Your preferences where succesfully saved.') }}
            </div>
        </div>
    </div>
    {% if isic.enable %}
        <div class="alert alert-info">
            <p>
                <b>{{ translate('VTK provides you with ISIC cards.') }} <a href="https://vtk.be/page/name/isic/">{{ translate('click here') }}</a> </b>
            </p>
        </div>
    {% endif %}

    {% if authenticatedPerson == null %}
        {{ translate('Please login to book textbooks.') }}
    {% else %}
        {% if hasAccess('cudi_booking', 'search') or hasAccess('cudi_booking', 'keepUpdated') %}
            <div style="height: 60px" class="hidden-xs hidden-sm">
                <div class="pull-right">
                    {% if hasAccess('cudi_booking', 'keepUpdated') %}
                        <button class="btn btn-warning" id="keepUpdated" {% if isSubscribed %}style="display: none"{% endif %} rel="tooltip" data-toggle="tooltip" title="{{ translate('You will receive an e-mail when the catalog is updated.') }}">{{ translate('Enable catalog update mails') }}</button>
                        <button class="btn btn-warning" id="dontKeepUpdated" {% if not isSubscribed %}style="display: none"{% endif %} rel="tooltip" data-toggle="tooltip" title="{{ translate('You won\'t receive an e-mail when the catalog is updated.') }}">{{ translate('Disable catalog update mails') }}</button>
                    {% endif %}
                    {% if hasAccess('cudi_booking', 'search') %}
                        <a href="#" id="searchArticles" class="btn btn-info">{{ translate('Search') }}</a>
                    {% endif %}
                </div>
            </div>

            {% if hasAccess('cudi_booking', 'search') %}
                <div id="searchArticlesPage" style="display: none;margin-top: 10px;">
                    {% import 'site/partials/form.twig' as forms %}
                    {{ forms.renderForm(searchForm) }}

                    <table class="table bookings">
                        <thead>
                            <tr>
                                <th>{{ translate('Title') }}</th>
                                <th class="hidden-xs">{{ translate('Authors') }}</th>
                                <th style="min-width: 100px">{{ translate('Price / Piece') }}</th>
                                <th class="hidden-xs" style="min-width: 60px">{{ translate('Mandatory') }}</th>
                                <th class="hidden-xs" style="min-width: 70px">{{ translate('Remarks') }}</th>
                                <th style="min-width: 100px"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="spacer">
                                <td colspan="7"></td>
                            </tr>
                            <tr class="course-title">
                                <td colspan="7"><i>{{ translate('No Articles Found') }}</i></td>
                            </tr>
                        </tbody>
                    </table>

                    <a class="btn btn-default pull-left" href="{{ url('cudi_booking', {'action' : 'view'}) }}">{{ translate('Back') }}</a>
                    <button id="bookSearchArticles" class="btn btn-primary pull-right" style="display: none">{{ translate('Book') }}</button>
                </div>
            {% endif %}
        {% endif %}

        <div id="viewArticlesPage">
            {% autoescape false %}
            {{ form().openTag(form) }}
                {% if form.get('csrf') %}
                    {{ formElement(form.get('csrf')) }}
                {% endif %}

                <table class="table bookings">
                    <thead>
                        <tr>
                            <th>{{ translate('Title') }}</th>
                            <th class="hidden-xs">{{ translate('Authors') }}</th>
                            <th style="min-width: 100px">{{ translate('Price / Piece') }}</th>
                            <th class="hidden-xs" style="min-width: 60px">{{ translate('Mandatory') }}</th>
                            <th class="hidden-xs" style="min-width: 70px">{{ translate('Remarks') }}</th>
                            <th style="min-width: 100px"></th>
                        </tr>
                    </thead>

                    <tbody>

                    {% for subjectArticle in subjectArticleMap %}
                        <tr class="spacer">
                            <td colspan="7"></td>
                        </tr>

                        <tr {% if null != subjectArticle['subject'] %}class="course-title"{% endif %}>
                            <td colspan="7" {% if null == subjectArticle['subject'] %}style="border: none;"{% endif %}>
                                {% if null == subjectArticle['subject'] %}
                                    <h1>{{ translate('General') }}</h1>
                                {% else %}
                                    {{ subjectArticle['subject'].getCode() }} - {{ subjectArticle['subject'].getName() }}
                                {% endif %}
                            </td>
                        </tr>

                        {% for map in subjectArticle['articles'] %}
                            <tr class="{% if map['booked'] > 0 %}warning{% endif %} {% if map['sold'] > 0 %}success{% endif %}">
                                <td>{{ map['article'].getMainArticle().getTitle() }}</td>
                                <td class="hidden-xs">{{ map['article'].getMainArticle().getAuthors() }}</td>
                                <td>
                                    {% if map['article'].getDiscounts()|length > 0 %}
                                        <span rel="popover" data-original-title="{{ translate('Discounts') }}" data-content="
                                        {% for discount in map['article'].getDiscounts() %}
                                            <span class='badge'>{{ translate(discount.getType()) }} {% if discount.getOrganization() %}{{ discount.getOrganization().getName() }}{% endif %}</span> &euro; {{ (discount.apply(map['article'].getSellPrice())/100)|number_format(2) }}<br/>
                                        {% endfor %}
                                    " data-placement="right" style="cursor: pointer">&euro; {{ (map['article'].getSellPrice()/100)|number_format(2) }} <span class="glyphicon glyphicon-info-sign"></span></span>
                                    {% else %}
                                        <span>&euro; {{ (map['article'].getSellPrice()/100)|number_format(2) }}</span>
                                    {% endif %}
                                </td>
                                <td class="hidden-xs">{{ map['mandatory'] ? '&times;' : '' }}</td>
                                <td class="hidden-xs">
                                    {% if map['comments']|length > 0 %}
                                        <a rel="popover" data-original-title="{{ translate('Comments') }}" data-content="

                                        {% for comment in map['comments'] %}
                                            <span class='badge badge-info'>{{ loop.index }}</span> {{ comment.getText()|escape }}<br/>
                                        {% endfor %}

                                        " data-placement="left" class="label label-warning">{{ map['comments']|length }} {{ map['comments']|length > 1 ? translate('Remarks') : translate('Remark') }}</a>
                                    {% endif %}
                                </td>
                                <td style="text-align: center;">
                                    {% if map['bookable'] %}
                                        {% set name = 'article-' ~ map['article'].getId() %}
                                        {% set element = form.get(name) %}
                                        {{ formElement(element) }}

                                        <a href="#" class="decrease-value"><span class="glyphicon glyphicon-minus-sign pull-left" style="margin-top: 3px;"></span></a><b>0</b><a href="#" class="increase-value"><span class="glyphicon glyphicon-plus-sign pull-right" style="margin-top: 3px;"></span></a>
                                    {% else %}
                                        <span class="label label-info hidden-xs">{{ translate('Not Bookable') }}</span>
                                    {% endif %}
                                </td>
                            </tr>

                            {% if element.getMessages()|length > 0  and map['bookable'] %}
                                <tr>
                                    <td colspan="7" style="border-top-width:0px;">
                                        <div class="help-block pull-right">
                                            {{ formElementErrors(element) }}
                                        </div>
                                    </td>
                                </tr>
                            {% endif %}
                        {% else %}
                            <tr>
                                <td colspan="7" style="border-top-width:0px;">
                                    <div>
                                        <em>{{ translate('No articles available for this subject.') }}</em>
                                    </div>
                                </td>
                            </tr>
                        {% endfor %}
                    {% endfor %}

                    </tbody>

                </table>

                <div>
                    <a class="btn btn-default" href="{{ url('cudi_booking', {'action' : 'view'}) }}">{{ translate('Back') }}</a>

                    {% if form.get('submit') %}
                        {{ formElement(form.get('submit')) }}
                    {% endif %}
                </div>
            {{ form().closeTag() }}
            {% endautoescape %}
{'fraction_non_alphanumeric': 0.16089764438043025, 'fraction_numerical': 0.005296659387631836, 'mean_word_length': 1.1898463729779225, 'pattern_counts': {'":': 0, '<': 325, '<?xml version=': 0, '>': 337, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 128, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3105220', 'n_tokens_mistral': 5586, 'n_tokens_neox': 4936, 'n_words': 1067}