summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/templates/ishtar/sheet_warehouse.html
blob: 76a419e7824e3c9ced7262355adb1a1ee3a0cb83 (plain)
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
64
65
66
67
68
69
70
71
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
{% extends "ishtar/sheet.html" %}
{% load i18n l10n ishtar_helpers window_header window_field window_tables %}

{% block head_title %}<strong>{% trans "Warehouse" %}</strong> - {{item.name}} ({{item.warehouse_type}}){% endblock %}
{% block toolbar %}
{% window_nav item window_id 'show-warehouse' 'warehouse_modify' 'show-historized-warehouse' 'revert-warehouse' previous next 1 %}
{% endblock %}

{% block content %}
{% with can_view_documents=permission_view_own_document|or_:permission_view_document %}
{% with has_documents=item.documents.count %}
{% with display_documents=can_view_documents|and_:has_documents %}

{% with permission_change_own_geovectordata=permission_change_own_geovectordata %}
{% with permission_change_geovectordata=permission_change_geovectordata %}
{% with permission_change_geo=permission_change_own_geovectordata|or_:permission_change_geovectordata %}

{% if output != "ODT" and output != "PDF"%}
<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" id="{{window_id}}-general-tab"
           data-toggle="tab" href="#{{window_id}}-general" role="tab"
           aria-controls="{{window_id}}-general" aria-selected="true">
            {% trans "General" %}
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="{{window_id}}-content-tab"
           data-toggle="tab" href="#{{window_id}}-content" role="tab"
           aria-controls="{{window_id}}-content" aria-selected="true">
            {% trans "Content" %}
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" id="{{window_id}}-stats-tab"
           data-toggle="tab" href="#{{window_id}}-stats" role="tab"
           aria-controls="{{window_id}}-stats" aria-selected="false">
            {% trans "Statistics" %}
        </a>
    </li>
    {% if display_documents %}
    <li class="nav-item">
        <a class="nav-link" id="{{window_id}}-documents-tab"
           data-toggle="tab" href="#{{window_id}}-documents" role="tab"
           aria-controls="{{window_id}}-documents" aria-selected="false">
            {% trans "Documents" %}
        </a>
    </li>
    {% endif %}
    {% if not is_external and PROFILE.locate_warehouses %}
    <li class="nav-item">
        <a class="nav-link" id="{{window_id}}-geodata-tab"
           data-toggle="tab" href="#{{window_id}}-geodata" role="tab"
           aria-controls="{{window_id}}-geodata" aria-selected="false">
            {% trans "Geographic data" %}
        </a>
    </li>
    {% endif %}
</ul>
{% endif %}

<div class="tab-content" id="{{window_id}}-tab-content">

    <div class="tab-pane fade show active" id="{{window_id}}-general"
         role="tabpanel" aria-labelledby="{{window_id}}-general-tab">
        <div class="row">
            <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12">
                <div class="card">
                    {% include "ishtar/blocks/window_image.html" %}
                    <div class="card-body">
                        <div class="card-text">
                        <p class="window-refs">
                            <strong>{{ item.name|default:"" }}</strong>
                        </p>
                        {% if item.complete_identifier and item.name != item.complete_identifier %}<p class="window-refs"
                                    title="{% trans 'Complete identifier' %}">
                        <strong>{{ item.complete_identifier }}</strong></p>{% endif %}
                        <p class="window-refs">
                            {{ item.warehouse_type|default:"" }}
                        </p>
                        {% include "ishtar/blocks/sheet_external_id.html" %}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class='row'>
            <dl class="col-6 col-md-3 flex-wrap">
                <dt>{% trans "Number of containers" %}</dt>
                <dd>{{item.number_containers}}</dd>
            </dl>
            <dl class="col-6 col-md-3 flex-wrap">
                <dt>{% trans "Number of divisions" %}</dt>
                <dd>{{item.number_divisions}}</dd>
            </dl>
            <dl class="col-6 col-md-3 flex-wrap">
                <dt>{% trans "Number of finds" %}</dt>
                <dd>{{item.number_of_finds_hosted}}</dd>
            </dl>
            <dl class="col-6 col-md-3 flex-wrap">
                <dt>{% trans "Number of owned finds" %}</dt>
                <dd>{{item.number_of_finds}}</dd>
            </dl>
            {% field_flex_detail "Person in charge" item.person_in_charge %}
            {% field_flex_detail "Organization" item.organization %}
            {% trans "Default divisions (imports)" as def_div_label %}
            {% field_flex def_div_label item.default_location_types|join:", " %}
            {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %}
        </div>
        {% include "ishtar/blocks/sheet_json.html" %}

        {% if item.get_address or item.get_address_complement or item.get_postal_code or item.get_town or item.phone or item.mobile_phone %}
        <h3>{% trans "Geographic localisation/contact details" %}</h3>
        {% if PROFILE.locate_warehouses and SHOW_GEO %}
        <div class='row'>
            {% with geo_item=item %}
            {% include "ishtar/blocks/sheet_map.html"%}
            {% endwith %}
        </div>
        {% endif %}
        <div class="row">
            {% with full=True %}{% include "ishtar/blocks/sheet_address_section.html" %}{% endwith %}
            {% field_flex _("Phone") item.phone %}
            {% field_flex _("Mobile phone") item.mobile_phone %}
        </div>
        {% endif %}

        {% if not is_external %}
        <h3>{% trans "Sheet"%}</h3>
        <div class="row">
            {% include "ishtar/blocks/sheet_creation_section.html" %}
        </div>
        {% endif %}
    </div>

    <div class="tab-pane fade" id="{{window_id}}-content"
         role="tabpanel" aria-labelledby="{{window_id}}-content-tab">
        {% if item.containers.count %}
        <h4>{% trans "Divisions" %}</h4>
        {% dynamic_table_document '' 'divisions' 'location_id' item.pk 'TABLE_COLS' output %}
        <h4>{% trans "Containers" %}</h4>
        {% dynamic_table_document '' 'non-divisions' 'location_id' item.pk 'TABLE_COLS' output %}
        {% else %}
        <div class="alert alert-info">
            <i class="fa fa-exclamation-triangle"></i>
            {% trans "No container inside this warehouse" %}
        </div>
        {% endif %}
        {% if item.number_of_finds_hosted %}
        <h4>{% trans "Finds (hosted)" %}</h4>
        {% dynamic_table_document '' 'finds' 'container__location' item.pk 'TABLE_COLS' output %}
        {% else %}
        <div class="alert alert-info">
            <i class="fa fa-exclamation-triangle"></i>
            {% trans "No find inside this warehouse" %}
        </div>
        {% endif %}
        {% if item.number_of_finds %}
        <h4>{% trans "Finds (owned)" %}</h4>
        {% dynamic_table_document '' 'finds' 'container_ref__location' item.pk 'TABLE_COLS' output %}
        {% else %}
        <div class="alert alert-info">
            <i class="fa fa-exclamation-triangle"></i>
            {% trans "No find owned by this warehouse" %}
        </div>
        {% endif %}
    </div>

    <div class="tab-pane fade" id="{{window_id}}-stats"
         role="tabpanel" aria-labelledby="{{window_id}}-stats-tab">
        <h3>{% trans "Statistics" %}</h3>

        {% if item.number_containers > 1000 or item.number_divisions > 200 %}
        <div class="alert alert-info">
            <i class="fa fa-exclamation-triangle"></i>
            &nbsp;<em>{% trans "Statistics disabled when too many containers are attached to a warehouse. In a future version, statistics will be optimized." %}</em>
        </div>
        {% else %}
        <div class="row mt-2 mb-2">
            <div class="col">
                <div class="btn-group btn-group-sm" role="group"
                     aria-label="{% trans 'Export' %}">
                    <a class="btn btn-success"
                       onclick="long_wait();return true;"
                       href="{% url 'generate-stats-warehouse' item.pk %}">

                        {% trans "Regenerate statistics" %}
                    </a>
                </div>
                {% with item.last_stats_update as last_stats_update%}
                {% if last_stats_update %}<small class="ml-2">
                    <em>{% trans "Last update:" %} {{last_stats_update}}</em>
                </small>{% endif %}{% endwith %}
            </div>
        </div>

        {% if not item.number_containers and not item.number_divisions %}
        <div class="alert alert-info">
            <i class="fa fa-exclamation-triangle"></i>
            &nbsp;<em>{% trans "No container/division inside this container" %}</em>
        </div>

        {% else %}

        <h4>{% trans "Finds" %}</h4>
        <h4>{% trans "Finds by location in the warehouse" %}</h4>
        {% for items in item.number_of_finds_by_place %}
        {% if items %}
        <table class='table table-striped datatables'
               id="{{window_id}}-find-by-loca-{{forloop.counter}}">
            <thead>
            <tr>{% for location_type in item.division_labels %}
                <th class="text-center">{{location_type|title}}</th>{% endfor %}
                <th class="text-center">{% trans "Total" %}</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
            <tr>
                {% for local in item.0 %}<td>{{local|safe}}</td>{% endfor %}
                <td class="text-right">{{item.1}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
        {% endif %}
        {% endfor %}

        <h4>{% trans "Containers" %}</h4>

        <h4>{% trans "Containers by location in the warehouse" %}</h4>
        {% for items in item.number_of_containers_by_place %}
        {% if items %}
        <table class='table table-striped datatables'
               id="{{window_id}}-container-by-loca-{{forloop.counter}}">
            <thead>
            <tr>{% for location_type in item.division_labels %}
                <th class="text-center">{{location_type|title}}</th>{% endfor %}
                <th class="text-center">{% trans "Total" %}</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
            <tr>
                {% for local in item.0 %}<td>{{local|safe}}</td>{% endfor %}
                <td class="text-right">{{item.1}}</td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
        {% endif %}
        {% endfor %}

        {% endif %}
        {% endif %}
    </div>
    {% if display_documents %}
    <div class="tab-pane fade" id="{{window_id}}-documents"
         role="tabpanel" aria-labelledby="{{window_id}}-documents-tab">
        {% trans "Document for this warehouse" as w_docs %}
        {% if permission_view_own_document or permission_view_document %}
        {% if item.documents.count %}
        {% dynamic_table_document w_docs 'documents' 'warehouses' item.pk '' output %}
        {% endif %}
        {% endif %}
    </div>
    {% endif %}
    {% if not is_external and PROFILE.locate_warehouses %}
    <div class="tab-pane fade" id="{{window_id}}-geodata"
         role="tabpanel" aria-labelledby="{{window_id}}-geodata-tab">
        {% with geo_item=item %}{% include "ishtar/blocks/sheet_geographic.html" %}{% endwith %}
    </div>
    {% endif %}
</div>

<script type="text/javascript">{% localize off %}
$(document).ready( function () {
    datatable_options = {
        "dom": 'ltip',
    };
    $.extend(datatable_options, datatables_static_default);
    if (datatables_i18n) datatable_options['language'] = datatables_i18n;
    $('.datatables').each(
        function(){
            var dt_id = "#" + $(this).attr('id');
            if (! $.fn.DataTable.isDataTable(dt_id) ) {
                $(dt_id).DataTable(datatable_options);
            }
         });
} );
{% endlocalize %}</script>

{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}
{% endblock %}