form.twig 7.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{% extends "layout.twig" %}

{% macro itemSelect(name, label, options, selected) %}
    <select class="form-control input-sm" name="items[<%= index %>][{{ name }}]">
    <option value="" disabled selected>{{ label|striptags }}</option>
    {% for option in options %}
        <option value="{{ option.value|e }}"{% if selected == option.value %} selected{% endif %}>
            {{ option.label }}
        </option>
    {% endfor %}
    </select>
{% endmacro %}

{% macro itemCount(name, label, value) %}
    <div class="form-group">
        <div class="col-xs-12 col-sm-12 col-md-9">
            <input placeholder="{{ label|striptags }}" class="form-control input-sm"
                type="number" name="items[<%= index %>][{{ name }}]" value="{{ value|default('')|raw }}">
        </div>
    </div>
{% endmacro %}

{% macro select(name, label, options, selected) %}
    <div class="form-group">
        <label class="control-label hidden-xs hidden-sm" for="el-{{ name }}">{{ label|raw }}</label>
        <select class="form-control" name="{{ name }}" id="el-{{ name }}">
            <option value="" disabled selected>{{ label|striptags }}</option>
            {% for option in options %}
            <option value="{{ option.value|e }}"{% if selected == option.value %} selected{% endif %}>
                {{ option.label }}
            </option>
            {% endfor %}
        </select>
    </div>
{% endmacro %}

{% macro yesno(name, label) %}
    <div class="form-group">
        <label class="control-label hidden-xs hidden-sm" for="el-{{ name }}">{{ label|raw }}</label>
        <select class="form-control" name="{{ name }}" id="el-{{ name }}">
            <option value="" disabled selected>{{ label|striptags }}</option>
            <option value="1">Ναι</option>
            <option value="0">Όχι</option>
        </select>
    </div>
{% endmacro %}

{% macro text(name, label, value) %}
    <div class="form-group">
        <label class="control-label hidden-xs hidden-sm" for="el-{{ name }}">{{ label|raw }}</label>
        <textarea class="form-control" name="{{ name }}" id="el-{{ name }}" placeholder="{{ label|striptags }}">{{ value|default('') }}</textarea>
    </div>
{% endmacro %}

{% import _self as macros %}

{% block content %}
<div id="app-form">
    <h1>
    {% block title %}
        Αίτηση <small>για νέο εξοπλισμό</small>
    {% endblock %}
    </h1>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
64
    <form method="post" action="">
65
        <div class="form-group">
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
66
67
68
69
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pulvinar tincidunt
                    odio, vel pretium mauris imperdiet at. In tempor fermentum enim, euismod posuere
                    purus venenatis sit amet. Sed tincidunt, sapien et varius congue, orci urna rutrum
                    magna, in porttitor tellus ante nec quam. Praesent non ante commodo, ornare tellus
70
71
                    ut, commodo dolor.</p>
        </div>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
        <div class="table-responsive">
            <fieldset>
                <legend>Υπάρχον εξοπλισμός</legend>

                    <table class="table table-hover table-striped table-condensed">
                        <thead>
                            <tr>
                                <th>Χώρος</th>
                                <th>Τύπος</th>
                                <th>Πλήθος</th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for asset in assets %}
                            <tr>
                                <td>{{ asset.labName }}</td>
                                <td>{{ asset.typeName }}</td>
                                <td>{{ asset.quantity }}</td>
                            </tr>
                        {% else %}
                            <tr>
                                <td colspan="6" class="text-center">Δεν έχει καταχωρηθεί εξοπλισμός</td>
                            </tr>
                        {% endfor %}
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="6"></td>
                            </tr>
                        </tfoot>
                    </table>

            </fieldset>
        </div>
        <div class="table-responsive">
            <fieldset>
                <legend>Νέος εξοπλισμός</legend>
                <div class="form-group" id="items-list">
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
                    <table class="table table-hover table-striped">
                        <thead>
                            <tr>
                                <th>Χώρος</th>
                                <th>Τύπος</th>
                                <th>Πλήθος</th>
                                <th>Αιτιολογία χρήσης</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                        <tfoot>
                            <tr>
                                <td colspan="5" class="text-right">
                                    <button type="button" class="btn btn-sm btn-primary add-row">
                                        <i class="fa fa-plus"></i>
                                        Προσθήκη εξοπλισμού
                                    </button>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
133
134
            </fieldset>
        </div>
135
136
        <fieldset>
            <legend>Επιπλέον</legend>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
137
138
            {{ macros.select('apply_for', 'Αίτημα του σχολείου για', apply_for_choices) }}
            {{ macros.yesno('new_lab_perspective', 'Ύπαρξη - προοπτική αίθουσας για δημιουργία νέου εργαστηρίου')}}
139
140
141
142
143
144
145
            {{ macros.text('comments', 'Σχόλια/Παρατηρήσεις', '') }}

        </fieldset>
        <hr>
        <div class="form-group text-center">
            <button name="submit" value="submit" type="submit" class="btn btn-lg btn-primary">Υποβολή</button>
        </div>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
146
147
        <input type="hidden" name="{{ csrf.name_key }}" value="{{ csrf.name }}">
        <input type="hidden" name="{{ csrf.value_key }}" value="{{ csrf.value }}">
148
149
    </form>
    <script type="text/template" id="app-form-item-row-template">
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
150
151
152
153
        <td>{{ macros.itemSelect('lab_id', 'Χώρος', lab_choices) }}</td>
        <td>{{ macros.itemSelect('itemcategory_id', 'Τύπος', type_choices) }}</td>
        <td>{{ macros.itemCount('qty', 'Πλήθος') }}</td>
        <td><textarea class="form-control input-sm" rows="1" cols="20" name="items[<%= index %>][reasons]" placeholder="Αιτιολογία χρήσης"></textarea></td>
154
155
156
157
158
159
160
161
162
163
164
        <td><button type="button" class="btn btn-xs text-danger remove-row">
            <i class="fa fa-remove"></i>
        </button</td>
    </script>
</div>
{% endblock %}

{% block inlinejs %}
    {{ parent() }}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script>
Vassilis Kanellopoulos's avatar
Vassilis Kanellopoulos committed
165
    <script src="{{ base_url }}/js/application_form/index.js"></script>
166
{% endblock %}