View | Details | Raw Unified | Return to bug 17387
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt (-9 / +88 lines)
Lines 30-41 Link Here
30
    [% END #/ WRAPPER breadcrumbs %]
30
    [% END #/ WRAPPER breadcrumbs %]
31
[% END #/ WRAPPER sub-header.inc %]
31
[% END #/ WRAPPER sub-header.inc %]
32
32
33
[% SET asides = [] %]
33
<div class="main container-fluid">
34
[% asides.push('cat-menu') %]
35
36
[% WRAPPER 'main-container.inc' %]
37
    <div class="row">
34
    <div class="row">
38
        <div class="col-md-10 col-md-push-2">
35
        <div class="col-md-10 order-md-2 order-sm-1">
39
            <main>
36
            <main>
40
                <h1>Restore deleted records</h1>
37
                <h1>Restore deleted records</h1>
41
38
Lines 74-81 Link Here
74
                </div>
71
                </div>
75
            </main>
72
            </main>
76
        </div>
73
        </div>
74
75
        <div class="col-md-2 order-sm-2 order-md-1">
76
            <aside>
77
                <div id="filters">
78
                    <fieldset class="brief">
79
                        <h4>Filter results</h4>
80
                        <ol>
81
                            <li>
82
                                <label for="from">Deleted from:</label>
83
                                <input type="text" size="10" id="from" name="from" class="flatpickr" data-date_to="to" />
84
                                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
85
                            </li>
86
                            <li>
87
                                <label for="to">Deleted to:</label>
88
                                <input type="text" size="10" id="to" name="to" class="flatpickr" />
89
                                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
90
                            </li>
91
                        </ol>
92
                        <fieldset class="action">
93
                            <button type="button" id="filter_table" class="btn btn-primary btn-sm">Apply</button>
94
                            <button type="button" id="clear_filters" class="btn btn-default btn-sm">Clear</button>
95
                        </fieldset>
96
                    </fieldset>
97
                </div>
98
99
                [% INCLUDE 'cat-menu.inc' %]
100
            </aside>
101
        </div>
77
    </div>
102
    </div>
78
[% END #/ WRAPPER main-container.inc %]
103
</div>
79
104
80
<!-- Modal for deleted biblio warning -->
105
<!-- Modal for deleted biblio warning -->
81
<div class="modal" id="deletedBiblioModal" tabindex="-1" role="dialog" aria-labelledby="deletedBiblioModalLabel">
106
<div class="modal" id="deletedBiblioModal" tabindex="-1" role="dialog" aria-labelledby="deletedBiblioModalLabel">
Lines 151-156 Link Here
151
[% MACRO jsinclude BLOCK %]
176
[% MACRO jsinclude BLOCK %]
152
    [% Asset.js("js/tools-menu.js") | $raw %]
177
    [% Asset.js("js/tools-menu.js") | $raw %]
153
    [% INCLUDE 'datatables.inc' %]
178
    [% INCLUDE 'datatables.inc' %]
179
    [% INCLUDE 'calendar.inc' %]
154
    <script>
180
    <script>
155
        function showMessage(message, type) {
181
        function showMessage(message, type) {
156
            var alert = $('<div class="alert alert-' + type + '">' + message + "</div>");
182
            var alert = $('<div class="alert alert-' + type + '">' + message + "</div>");
Lines 164-173 Link Here
164
        }
190
        }
165
191
166
        $(document).ready(function () {
192
        $(document).ready(function () {
193
            var oneYearAgo = new Date();
194
            oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
195
            var today = new Date();
196
197
            var fromDate = oneYearAgo.toISOString().split("T")[0];
198
            var toDate = today.toISOString().split("T")[0];
199
200
            setTimeout(function () {
201
                if ($("#from")[0]._flatpickr) {
202
                    $("#from")[0]._flatpickr.setDate(fromDate);
203
                }
204
                if ($("#to")[0]._flatpickr) {
205
                    $("#to")[0]._flatpickr.setDate(toDate);
206
                }
207
            }, 100);
208
209
            function buildApiUrl(baseUrl) {
210
                var from = $("#from").val();
211
                var to = $("#to").val();
212
213
                if (!from && !to) {
214
                    return baseUrl;
215
                }
216
217
                var query = {};
218
                if (from && to) {
219
                    query["me.timestamp"] = {
220
                        "-between": [from + "T00:00:00Z", to + "T23:59:59Z"],
221
                    };
222
                } else if (from) {
223
                    query["me.timestamp"] = {
224
                        ">=": from + "T00:00:00Z",
225
                    };
226
                } else if (to) {
227
                    query["me.timestamp"] = {
228
                        "<=": to + "T23:59:59Z",
229
                    };
230
                }
231
232
                return baseUrl + "?q=" + encodeURIComponent(JSON.stringify(query));
233
            }
234
167
            // Deleted biblios DataTable
235
            // Deleted biblios DataTable
168
            var biblios_table = $("#deleted_biblios_table").kohaTable({
236
            var biblios_table = $("#deleted_biblios_table").kohaTable({
169
                ajax: {
237
                ajax: {
170
                    url: "/api/v1/deleted/biblios",
238
                    url: buildApiUrl("/api/v1/deleted/biblios"),
171
                },
239
                },
172
                embed: "items",
240
                embed: "items",
173
                order: [[3, "desc"]],
241
                order: [[3, "desc"]],
Lines 235-241 Link Here
235
            // Deleted items DataTable
303
            // Deleted items DataTable
236
            var items_table = $("#deleted_items_table").kohaTable({
304
            var items_table = $("#deleted_items_table").kohaTable({
237
                ajax: {
305
                ajax: {
238
                    url: "/api/v1/deleted/items",
306
                    url: buildApiUrl("/api/v1/deleted/items"),
239
                },
307
                },
240
                embed: "biblio",
308
                embed: "biblio",
241
                order: [[5, "desc"]],
309
                order: [[5, "desc"]],
Lines 581-586 Link Here
581
                    },
649
                    },
582
                });
650
                });
583
            });
651
            });
652
653
            $("#filter_table").on("click", function () {
654
                biblios_table_api.ajax.url(buildApiUrl("/api/v1/deleted/biblios")).load();
655
                items_table_api.ajax.url(buildApiUrl("/api/v1/deleted/items")).load();
656
            });
657
658
            $("#clear_filters").on("click", function () {
659
                $("#from").val("");
660
                $("#to").val("");
661
                biblios_table_api.ajax.url("/api/v1/deleted/biblios").load();
662
                items_table_api.ajax.url("/api/v1/deleted/items").load();
663
            });
584
        });
664
        });
585
    </script>
665
    </script>
586
[% END %]
666
[% END %]
587
- 

Return to bug 17387