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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt (-83 / +77 lines)
Lines 266-403 Link Here
266
    <script>
266
    <script>
267
        const record_type = "[% recordtype | html %]";
267
        const record_type = "[% recordtype | html %]";
268
    </script>
268
    </script>
269
270
    <script>
269
    <script>
271
        var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
270
        var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
272
        $(document).ready(function() {
271
        $(document).ready(function () {
273
272
            $("input[type='radio']").click(function () {
274
            $("input[type='radio']").click(function() {
273
                if ($(this).attr("id") == "authority_type") {
275
                if ($(this).attr('id') == 'authority_type') {
276
                    $("a[href='#shelves_tab_panel']").parent().hide();
274
                    $("a[href='#shelves_tab_panel']").parent().hide();
277
                    $("li.skip_open_orders").hide();
275
                    $("li.skip_open_orders").hide();
278
                } else if ($(this).attr('id') == 'biblio_type') {
276
                } else if ($(this).attr("id") == "biblio_type") {
279
                    $("a[href='#shelves_tab_panel']").parent().show();
277
                    $("a[href='#shelves_tab_panel']").parent().show();
280
                    $("li.skip_open_orders").show();
278
                    $("li.skip_open_orders").show();
281
                }
279
                }
282
            });
280
            });
283
281
284
            $("#selectall").click(function(e){
282
            $("#selectall").click(function (e) {
285
                e.preventDefault();
283
                e.preventDefault();
286
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
284
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
287
                    $(this).prop("checked", true);
285
                    $(this).prop("checked", true);
288
                });
286
                });
289
            });
287
            });
290
288
291
            $("#clearall").click(function(e){
289
            $("#clearall").click(function (e) {
292
                e.preventDefault();
290
                e.preventDefault();
293
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
291
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
294
                    $(this).prop("checked", false);
292
                    $(this).prop("checked", false);
295
                });
293
                });
296
            });
294
            });
297
295
298
            $("#selectwithoutitems").click(function(e){
296
            $("#selectwithoutitems").click(function (e) {
299
                e.preventDefault();
297
                e.preventDefault();
300
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
298
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
301
                    if( $(this).data("items") == 0 ){
299
                    if ($(this).data("items") == 0) {
302
                        $(this).prop("checked", true );
300
                        $(this).prop("checked", true);
303
                    } else {
301
                    } else {
304
                        $(this).prop("checked", false );
302
                        $(this).prop("checked", false);
305
                    }
303
                    }
306
                });
304
                });
307
            });
305
            });
308
306
309
            $("#selectnotreserved").click(function(e){
307
            $("#selectnotreserved").click(function (e) {
310
                e.preventDefault();
308
                e.preventDefault();
311
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
309
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
312
                    if( $(this).data("reserves") == 0 ){
310
                    if ($(this).data("reserves") == 0) {
313
                        $(this).prop("checked", true );
311
                        $(this).prop("checked", true);
314
                    } else {
312
                    } else {
315
                        $(this).prop("checked", false );
313
                        $(this).prop("checked", false);
316
                    }
314
                    }
317
                });
315
                });
318
            });
316
            });
319
317
320
            $("#selectwithoutsubscriptions").click(function(e){
318
            $("#selectwithoutsubscriptions").click(function (e) {
321
                e.preventDefault();
319
                e.preventDefault();
322
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
320
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
323
                    if( $(this).data("subscriptions") == 0 ){
321
                    if ($(this).data("subscriptions") == 0) {
324
                        $(this).prop("checked", true );
322
                        $(this).prop("checked", true);
325
                    } else {
323
                    } else {
326
                        $(this).prop("checked", false );
324
                        $(this).prop("checked", false);
327
                    }
325
                    }
328
                });
326
                });
329
            });
327
            });
330
328
331
            $("#clearlinkedtobiblio").click(function(e){
329
            $("#clearlinkedtobiblio").click(function (e) {
332
                e.preventDefault();
330
                e.preventDefault();
333
                $(".records input[type='checkbox']:not(:disabled)").each(function(){
331
                $(".records input[type='checkbox']:not(:disabled)").each(function () {
334
                    if( $(this).data("usage") == 0 ){
332
                    if ($(this).data("usage") == 0) {
335
                        $(this).prop("checked", true );
333
                        $(this).prop("checked", true);
336
                    } else {
334
                    } else {
337
                        $(this).prop("checked", false );
335
                        $(this).prop("checked", false);
338
                    }
336
                    }
339
                });
337
                });
340
            });
338
            });
341
339
342
          $("#selectall").click();
340
            $("#selectall").click();
343
341
344
          // Show a red cross if a biblio cannot be deleted
342
            // Show a red cross if a biblio cannot be deleted
345
          if (recordtype == 'biblio'){
343
            if (recordtype == "biblio") {
346
            $(".records input:checkbox[data-issues!='0']").each(function(){
344
                $(".records input:checkbox[data-issues!='0']").each(function () {
347
              $(this).parents('tr').find('td').css('background-color', '#ffff99')
345
                    $(this).parents("tr").find("td").css("background-color", "#ffff99");
348
              $(this).replaceWith("<span class='error'><i class='fa fa-times fa-lg'></i></span>")
346
                    $(this).replaceWith("<span class='error'><i class='fa fa-times fa-lg'></i></span>");
349
              $(".records i").attr('title', MSG_CANNOT_BE_DELETED)
347
                    $(".records i").attr("title", MSG_CANNOT_BE_DELETED);
350
            });
348
                });
351
          }
349
            }
352
353
          $("#biblios").kohaTable({
354
              columnDefs: [
355
                  { targets: [3, 4], type: "num-html" },
356
              ],
357
              dom: "t",
358
              order: [],
359
              paging: false,
360
          });
361
350
362
          $("#authorities").kohaTable({
351
            $("#biblios").kohaTable({
363
              columnDefs: [
352
                columnDefs: [{ targets: [3, 4], type: "num-html" }],
364
                  { targets: [3], type: "num-html" },
353
                dom: "t",
365
              ],
354
                order: [],
366
              dom: "t",
355
                paging: false,
367
              order: [],
356
            });
368
              paging: false,
369
          });
370
357
371
          $("#selectrecords").on("submit",function(){
358
            $("#authorities").kohaTable({
372
            var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
359
                columnDefs: [{ targets: [3], type: "num-html" }],
373
            if (nb_checked == 0){
360
                dom: "t",
374
              alert(_("No records have been selected."));
361
                order: [],
375
              return false;
362
                paging: false,
376
            }
363
            });
377
          });
378
364
379
          $("#selectauths").on("submit",function(){
365
            $("#selectrecords").on("submit", function () {
380
            var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
366
                var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
381
            if (checked == 0) {
367
                if (nb_checked == 0) {
382
              alert(_("No authorities have been selected."));
368
                    alert(_("No records have been selected."));
383
              return false;
369
                    return false;
384
            }
370
                }
385
          });
371
            });
386
372
387
          $("#record_ids_selection").on("submit", function(e){
373
            $("#selectauths").on("submit", function () {
388
            var tab = $(this).find('#batch_del_form li a.active:first').attr('href');
374
                var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
389
            if ( tab == '#uploadfile_tab_panel' ) {
375
                if (checked == 0) {
390
                $("#shelf_number").empty('');
376
                    alert(_("No authorities have been selected."));
391
                $("#recordnumber_list").val('');
377
                    return false;
392
            } else if ( tab == '#shelves_tab_panel' ) {
378
                }
393
                $("#uploadfile").val('')
379
            });
394
                $("#recordnumber_list").val('');
395
            } else { // enterlist
396
                $("#uploadfile").val('')
397
                $("#shelf_number").empty('');
398
            }
399
          });
400
380
381
            $("#record_ids_selection").on("submit", function (e) {
382
                var tab = $(this).find("#batch_del_form li a.active:first").attr("href");
383
                if (tab == "#uploadfile_tab_panel") {
384
                    $("#shelf_number").empty("");
385
                    $("#recordnumber_list").val("");
386
                } else if (tab == "#shelves_tab_panel") {
387
                    $("#uploadfile").val("");
388
                    $("#recordnumber_list").val("");
389
                } else {
390
                    // enterlist
391
                    $("#uploadfile").val("");
392
                    $("#shelf_number").empty("");
393
                }
394
            });
401
        });
395
        });
402
    </script>
396
    </script>
403
[% END %]
397
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt (-238 / +229 lines)
Lines 252-311 Link Here
252
        var holds_to_modify_table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_hold_modification', 'holds_to_modify', 'json' ) | $raw %];
252
        var holds_to_modify_table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_hold_modification', 'holds_to_modify', 'json' ) | $raw %];
253
        var modified_holds_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %];
253
        var modified_holds_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %];
254
    </script>
254
    </script>
255
256
    <script>
255
    <script>
257
        $(document).ready(function() {
256
        $(document).ready(function () {
258
259
            // Apply select2 to all select fields having a "multiple" attribute
257
            // Apply select2 to all select fields having a "multiple" attribute
260
            let selectFields = document.querySelectorAll('select[multiple]');
258
            let selectFields = document.querySelectorAll("select[multiple]");
261
            selectFields.forEach((selectField) => {
259
            selectFields.forEach(selectField => {
262
                selectField.style.minWidth = '200px';
260
                selectField.style.minWidth = "200px";
263
                $(selectField).select2();
261
                $(selectField).select2();
264
            });
262
            });
265
263
266
            //Empty local storage from previous selections
264
            //Empty local storage from previous selections
267
            localStorage.removeItem("holds_modify_selections");
265
            localStorage.removeItem("holds_modify_selections");
268
266
269
            $("#holds_to_modify").on("change", "input[type='checkbox']", function(){
267
            $("#holds_to_modify").on("change", "input[type='checkbox']", function () {
270
                var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || [];
268
                var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || [];
271
                var hold_id = $(this).val();
269
                var hold_id = $(this).val();
272
                if ($(this).prop("checked")) {
270
                if ($(this).prop("checked")) {
273
274
                    hold_data = {
271
                    hold_data = {
275
                        hold_id: hold_id,
272
                        hold_id: hold_id,
276
                        found_status: $(this).closest('tr').find('.found_status').children('span').data('found-status'),
273
                        found_status: $(this).closest("tr").find(".found_status").children("span").data("found-status"),
277
                        suspended: $(this).closest('tr').find('.suspended').children('span').data('suspended'),
274
                        suspended: $(this).closest("tr").find(".suspended").children("span").data("suspended"),
278
                    }
275
                    };
279
276
280
                    holds_modify_selections.push(hold_data);
277
                    holds_modify_selections.push(hold_data);
281
                    localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections));
278
                    localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections));
282
                    showHoldSelections(holds_modify_selections.length);
279
                    showHoldSelections(holds_modify_selections.length);
283
                } else {
280
                } else {
284
                    var filtered = holds_modify_selections.filter(function( hold_obj ){
281
                    var filtered = holds_modify_selections.filter(function (hold_obj) {
285
                        return hold_obj.hold_id !== hold_id;
282
                        return hold_obj.hold_id !== hold_id;
286
                    });
283
                    });
287
                    if( filtered.length > 0 ){
284
                    if (filtered.length > 0) {
288
                        localStorage.setItem("holds_modify_selections", JSON.stringify( filtered ));
285
                        localStorage.setItem("holds_modify_selections", JSON.stringify(filtered));
289
                        holds_modify_selections = filtered;
286
                        holds_modify_selections = filtered;
290
                        showHoldSelections( filtered.length );
287
                        showHoldSelections(filtered.length);
291
                    } else {
288
                    } else {
292
                        holds_modify_selections = [];
289
                        holds_modify_selections = [];
293
                        localStorage.removeItem("holds_modify_selections");
290
                        localStorage.removeItem("holds_modify_selections");
294
                        showHoldSelections( 0 );
291
                        showHoldSelections(0);
295
                    }
292
                    }
296
                }
293
                }
297
            });
294
            });
298
295
299
            $("#select_all").on("click", function(e){
296
            $("#select_all").on("click", function (e) {
300
                e.preventDefault();
297
                e.preventDefault();
301
                $("#holds_to_modify input[type='checkbox']").each(function(){
298
                $("#holds_to_modify input[type='checkbox']").each(function () {
302
                    $(this).prop("checked", true).change();
299
                    $(this).prop("checked", true).change();
303
                });
300
                });
304
            });
301
            });
305
302
306
            $("#clear_all").on("click", function(e){
303
            $("#clear_all").on("click", function (e) {
307
                e.preventDefault();
304
                e.preventDefault();
308
                $("#holds_to_modify input[type='checkbox']").each(function(){
305
                $("#holds_to_modify input[type='checkbox']").each(function () {
309
                    $(this).prop("checked", false).change();
306
                    $(this).prop("checked", false).change();
310
                });
307
                });
311
            });
308
            });
Lines 317-396 Link Here
317
                $("#table_search_selections").hide();
314
                $("#table_search_selections").hide();
318
            });
315
            });
319
316
320
            $('#modify_holds_form').submit(function() {
317
            $("#modify_holds_form").submit(function () {
321
                var modify_holds_form = $(this);
318
                var modify_holds_form = $(this);
322
                search_holds(modify_holds_form);
319
                search_holds(modify_holds_form);
323
                $("#modify_holds_search").hide();
320
                $("#modify_holds_search").hide();
324
                $('#edit_search').show();
321
                $("#edit_search").show();
325
                return false;
322
                return false;
326
            });
323
            });
327
324
328
            if(hold_ids_from_sql.length > 0){
325
            if (hold_ids_from_sql.length > 0) {
329
                $('#modify_holds_form').trigger('submit');
326
                $("#modify_holds_form").trigger("submit");
330
            }
327
            }
331
328
332
            $("#edit_search").on("click", function(e){
329
            $("#edit_search").on("click", function (e) {
333
                e.preventDefault();
330
                e.preventDefault();
334
                $('#modify_holds_search').show();
331
                $("#modify_holds_search").show();
335
                $('#edit_search').hide();
332
                $("#edit_search").hide();
336
            });
333
            });
337
334
338
            function showHoldSelections( number ){
335
            function showHoldSelections(number) {
339
                if (number === 0) {
336
                if (number === 0) {
340
                    $("#table_search_selections").hide();
337
                    $("#table_search_selections").hide();
341
                } else {
338
                } else {
342
                    $("#table_search_selections")
339
                    $("#table_search_selections").show().find("span").text(_("Holds selected: %s").format(number));
343
                        .show()
344
                        .find("span")
345
                        .text(_("Holds selected: %s").format(number));
346
                }
340
                }
347
            }
341
            }
348
342
349
            function search_holds(modify_holds_form){
343
            function search_holds(modify_holds_form) {
350
                var searchpattern = "";
344
                var searchpattern = "";
351
                var filters = {
345
                var filters = {
352
                    "me.expirationdate": function(){
346
                    "me.expirationdate": function () {
353
                        var expirationdate_from = modify_holds_form.find("#expirationdate_from").val();
347
                        var expirationdate_from = modify_holds_form.find("#expirationdate_from").val();
354
                        var expirationdate_to   = modify_holds_form.find("#expirationdate_to").val();
348
                        var expirationdate_to = modify_holds_form.find("#expirationdate_to").val();
355
349
356
                        if (expirationdate_from && expirationdate_to){
350
                        if (expirationdate_from && expirationdate_to) {
357
                            searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " ";
351
                            searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " ";
358
                            return {"-between": [expirationdate_from, expirationdate_to]};
352
                            return { "-between": [expirationdate_from, expirationdate_to] };
359
                        }
353
                        } else if (expirationdate_from && !expirationdate_to) {
360
                        else if (expirationdate_from && !expirationdate_to){
361
                            searchpattern += _("expiration date from ") + expirationdate_from + " ";
354
                            searchpattern += _("expiration date from ") + expirationdate_from + " ";
362
                            return {">=": expirationdate_from };
355
                            return { ">=": expirationdate_from };
363
                        } else if (!expirationdate_from && expirationdate_to){
356
                        } else if (!expirationdate_from && expirationdate_to) {
364
                            searchpattern += _("expiration date to ") + expirationdate_to + " ";
357
                            searchpattern += _("expiration date to ") + expirationdate_to + " ";
365
                            return {"<=": expirationdate_to };
358
                            return { "<=": expirationdate_to };
366
                        }
359
                        }
367
                    },
360
                    },
368
                    "me.branchcode": function(){
361
                    "me.branchcode": function () {
369
                        var branchcodes = modify_holds_form.find("#branchcodes").val();
362
                        var branchcodes = modify_holds_form.find("#branchcodes").val();
370
                        if( branchcodes.length > 0 ){
363
                        if (branchcodes.length > 0) {
371
                            searchpattern += _("from libraries ");
364
                            searchpattern += _("from libraries ");
372
                            var selected_libraries = modify_holds_form.find("#branchcodes option:selected");
365
                            var selected_libraries = modify_holds_form.find("#branchcodes option:selected");
373
                            $.each(selected_libraries, function(key, value) {
366
                            $.each(selected_libraries, function (key, value) {
374
                                searchpattern += value.text + " ";
367
                                searchpattern += value.text + " ";
375
                            });
368
                            });
376
                            return {"-in": branchcodes };
369
                            return { "-in": branchcodes };
377
                        }
370
                        }
378
                    },
371
                    },
379
                    "me.status": function(){
372
                    "me.status": function () {
380
                        var found_status = modify_holds_form.find("#found_status").val();
373
                        var found_status = modify_holds_form.find("#found_status").val();
381
                        if( found_status.length > 0 ){
374
                        if (found_status.length > 0) {
382
                            var filters = [{"-in": found_status}];
375
                            var filters = [{ "-in": found_status }];
383
                            if(jQuery.inArray("NULL", found_status) !== -1){
376
                            if (jQuery.inArray("NULL", found_status) !== -1) {
384
                                filters.push({"=": null});
377
                                filters.push({ "=": null });
385
                            }
378
                            }
386
                            searchpattern += _("found status in ");
379
                            searchpattern += _("found status in ");
387
                            $.each(found_status, function(key, value) {
380
                            $.each(found_status, function (key, value) {
388
                                let status = _("No status ");
381
                                let status = _("No status ");
389
                                if ( value == "T" ) {
382
                                if (value == "T") {
390
                                    status = _("In transit ");
383
                                    status = _("In transit ");
391
                                } else if( value == "P" ) {
384
                                } else if (value == "P") {
392
                                    status = _("In processing ");
385
                                    status = _("In processing ");
393
                                } else if( value == "W" ) {
386
                                } else if (value == "W") {
394
                                    status = _("Waiting ");
387
                                    status = _("Waiting ");
395
                                }
388
                                }
396
                                searchpattern += status;
389
                                searchpattern += status;
Lines 398-656 Link Here
398
                            return filters;
391
                            return filters;
399
                        }
392
                        }
400
                    },
393
                    },
401
                    "me.suspended": function(){
394
                    "me.suspended": function () {
402
                        var suspend_status = modify_holds_form.find("#suspend_status").val();
395
                        var suspend_status = modify_holds_form.find("#suspend_status").val();
403
396
404
                        if(suspend_status != "none"){
397
                        if (suspend_status != "none") {
405
                            var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended");
398
                            var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended");
406
                            searchpattern += _("with suspend status ") + suspended_text;
399
                            searchpattern += _("with suspend status ") + suspended_text;
407
400
408
                            return {"=": suspend_status};
401
                            return { "=": suspend_status };
409
                        }
402
                        }
410
                    },
403
                    },
411
                    "me.suspend_until": function(){
404
                    "me.suspend_until": function () {
412
                        var suspend_until_from = modify_holds_form.find("#suspend_until_from").val();
405
                        var suspend_until_from = modify_holds_form.find("#suspend_until_from").val();
413
                        var suspend_until_to   = modify_holds_form.find("#suspend_until_to").val();
406
                        var suspend_until_to = modify_holds_form.find("#suspend_until_to").val();
414
407
415
                        if (suspend_until_from && suspend_until_to){
408
                        if (suspend_until_from && suspend_until_to) {
416
                            searchpattern += _("suspend date between ") + suspend_until_from + " and " + suspend_until_to + " ";
409
                            searchpattern += _("suspend date between ") + suspend_until_from + " and " + suspend_until_to + " ";
417
                            return {"-between": [suspend_until_from, suspend_until_to]};
410
                            return { "-between": [suspend_until_from, suspend_until_to] };
418
                        }
411
                        } else if (suspend_until_from && !suspend_until_to) {
419
                        else if (suspend_until_from && !suspend_until_to){
420
                            searchpattern += _("suspend date from ") + suspend_until_from + " ";
412
                            searchpattern += _("suspend date from ") + suspend_until_from + " ";
421
                            return {">=": suspend_until_from };
413
                            return { ">=": suspend_until_from };
422
                        } else if (!suspend_until_from && suspend_until_to){
414
                        } else if (!suspend_until_from && suspend_until_to) {
423
                            searchpattern += _("suspend date to ") + suspend_until_to + " ";
415
                            searchpattern += _("suspend date to ") + suspend_until_to + " ";
424
                            return {"<=": suspend_until_to };
416
                            return { "<=": suspend_until_to };
425
                        }
417
                        }
426
                    },
418
                    },
427
                    "me.notes": function(){
419
                    "me.notes": function () {
428
                        var holdnotes = modify_holds_form.find("#holdnotes").val();
420
                        var holdnotes = modify_holds_form.find("#holdnotes").val();
429
421
430
                        searchpattern += holdnotes ? _("hold notes like ") + holdnotes : "";
422
                        searchpattern += holdnotes ? _("hold notes like ") + holdnotes : "";
431
423
432
                        return holdnotes ? {"-like": "%"+holdnotes+"%"} : "";
424
                        return holdnotes ? { "-like": "%" + holdnotes + "%" } : "";
433
                    },
425
                    },
434
                    "me.hold_id": function(){
426
                    "me.hold_id": function () {
435
                        return hold_ids_from_sql.length > 0 ? { "-in": hold_ids_from_sql } : "";
427
                        return hold_ids_from_sql.length > 0 ? { "-in": hold_ids_from_sql } : "";
436
                    }
437
                }
438
439
                var holds_modify_table = $("#holds_to_modify").kohaTable({
440
                    ajax: {
441
                        "url": "/api/v1/holds"
442
                    },
428
                    },
443
                    embed: [
429
                };
444
                        "biblio",
430
445
                        "item",
431
                var holds_modify_table = $("#holds_to_modify").kohaTable(
446
                        "pickup_library",
432
                    {
447
                        "patron"
433
                        ajax: {
448
                    ],
434
                            url: "/api/v1/holds",
449
                    destroy: true,
450
                    autoWidth: false,
451
                    processing: true,
452
                    order: [
453
                        [1, 'asc']
454
                    ],
455
                    columns: [
456
                        {
457
                            "data": "hold_id",
458
                            "name": "checkbox",
459
                            "orderable": false,
460
                            "render": function(data, type, row, meta) {
461
                                return '<input class="selection" type="checkbox" value="'+ encodeURIComponent(data) +'"/>'
462
                            }
463
                        },
464
                        {
465
                            "data": "hold_date",
466
                            "name": "hold_date",
467
                            "type": "date",
468
                            "title": _("Hold date"),
469
                            "orderable": true,
470
                            "render": function( data, type, row, meta ) {
471
                                return $date(data);
472
                            }
473
                        },
474
                        {
475
                            "data": "expiration_date",
476
                            "name": "expiration_date",
477
                            "type": "date",
478
                            "title": _("Expiration date"),
479
                            "orderable": true,
480
                            "render": function( data, type, row, meta ) {
481
                                return $date(data);
482
                            }
483
                        },
484
                        {
485
                            "data": "biblio.title:biblio.subtitle:biblio.medium",
486
                            "title": _("Title"),
487
                            "searchable": true,
488
                            "orderable": true,
489
                            "render": function(data, type, row, meta) {
490
                                return $biblio_to_html(row.biblio, { link: 1 });
491
                            }
492
                        },
493
                        {
494
                            "data": "item.external_id",
495
                            "name": "barcode",
496
                            "title": _("Barcode"),
497
                            "defaultContent": _(""),
498
                            "orderable": true,
499
                            "render": function( data, type, row, meta ) {
500
                                if( row.item ){
501
                                    let item_id = encodeURIComponent( row.item_id );
502
                                    let biblio_id = encodeURIComponent( row.biblio_id );
503
                                    return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' +
504
                                    'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' +
505
                                    'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>'
506
                                }
507
                            }
508
                        },
509
                        {
510
                            "data": "patron_id",
511
                            "name": "patron",
512
                            "title": _("Patron"),
513
                            "orderable": true,
514
                            "render": function( data, type, row, meta ) {
515
                                let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name });
516
                                return patron_to_html;
517
                            }
518
                        },
519
                        {
520
                            "data": "status",
521
                            "name": "status",
522
                            "title": _("Status"),
523
                            "className": "found_status",
524
                            "orderable": true,
525
                            "render": function( data, type, row, meta ) {
526
                                let status = _("No status");
527
                                if ( data == "T" ) {
528
                                    status = _("In transit");
529
                                } else if( data == "P" ) {
530
                                    status = _("In processing");
531
                                } else if( data == "W" ) {
532
                                    status = _("Waiting");
533
                                }
534
                                return "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>";
535
                            }
536
                        },
537
                        {
538
                            "data": "pickup_library_id",
539
                            "name": "pickup_library",
540
                            "title": _("Hold pickup library"),
541
                            "orderable": true,
542
                            "render": function( data, type, row, meta ) {
543
                                return escape_str( row.pickup_library.name );
544
                            }
545
                        },
546
                        {
547
                            "data": "suspended",
548
                            "name": "suspended",
549
                            "className": "suspended",
550
                            "title": _("Suspended"),
551
                            "orderable": true,
552
                            "render": function( data, type, row, meta ) {
553
                                var suspended_string = data == 0 ? _("No") : _("Yes");
554
                                return "<span data-suspended='" + data + "'>" + suspended_string + "</span>";
555
                            }
556
                        },
557
                        {
558
                            "data": "suspended_until",
559
                            "name": "suspended_until",
560
                            "title": _("Suspended until"),
561
                            "orderable": true,
562
                            "render": function( data, type, row, meta ) {
563
                                return $date( data );
564
                            }
565
                        },
435
                        },
566
                        {
436
                        embed: ["biblio", "item", "pickup_library", "patron"],
567
                            "data": "notes",
437
                        destroy: true,
568
                            "name": "notes",
438
                        autoWidth: false,
569
                            "title": _("Notes"),
439
                        processing: true,
570
                            "orderable": true,
440
                        order: [[1, "asc"]],
571
                            "render": function( data, type, row, meta ) {
441
                        columns: [
572
                                return escape_str( data );
442
                            {
573
                            }
443
                                data: "hold_id",
574
                        }
444
                                name: "checkbox",
575
                    ],
445
                                orderable: false,
576
                }, holds_to_modify_table_settings, 0, filters);
446
                                render: function (data, type, row, meta) {
447
                                    return '<input class="selection" type="checkbox" value="' + encodeURIComponent(data) + '"/>';
448
                                },
449
                            },
450
                            {
451
                                data: "hold_date",
452
                                name: "hold_date",
453
                                type: "date",
454
                                title: _("Hold date"),
455
                                orderable: true,
456
                                render: function (data, type, row, meta) {
457
                                    return $date(data);
458
                                },
459
                            },
460
                            {
461
                                data: "expiration_date",
462
                                name: "expiration_date",
463
                                type: "date",
464
                                title: _("Expiration date"),
465
                                orderable: true,
466
                                render: function (data, type, row, meta) {
467
                                    return $date(data);
468
                                },
469
                            },
470
                            {
471
                                data: "biblio.title:biblio.subtitle:biblio.medium",
472
                                title: _("Title"),
473
                                searchable: true,
474
                                orderable: true,
475
                                render: function (data, type, row, meta) {
476
                                    return $biblio_to_html(row.biblio, { link: 1 });
477
                                },
478
                            },
479
                            {
480
                                data: "item.external_id",
481
                                name: "barcode",
482
                                title: _("Barcode"),
483
                                defaultContent: _(""),
484
                                orderable: true,
485
                                render: function (data, type, row, meta) {
486
                                    if (row.item) {
487
                                        let item_id = encodeURIComponent(row.item_id);
488
                                        let biblio_id = encodeURIComponent(row.biblio_id);
489
                                        return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + "itemnumber=" + item_id + "&biblionumber=" + biblio_id + "&" + "bi=" + biblio_id + "#item" + item_id + '">' + escape_str(data) + "</a>";
490
                                    }
491
                                },
492
                            },
493
                            {
494
                                data: "patron_id",
495
                                name: "patron",
496
                                title: _("Patron"),
497
                                orderable: true,
498
                                render: function (data, type, row, meta) {
499
                                    let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name });
500
                                    return patron_to_html;
501
                                },
502
                            },
503
                            {
504
                                data: "status",
505
                                name: "status",
506
                                title: _("Status"),
507
                                className: "found_status",
508
                                orderable: true,
509
                                render: function (data, type, row, meta) {
510
                                    let status = _("No status");
511
                                    if (data == "T") {
512
                                        status = _("In transit");
513
                                    } else if (data == "P") {
514
                                        status = _("In processing");
515
                                    } else if (data == "W") {
516
                                        status = _("Waiting");
517
                                    }
518
                                    return "<span data-found-status='" + escape_str(data) + "'>" + status + "</span>";
519
                                },
520
                            },
521
                            {
522
                                data: "pickup_library_id",
523
                                name: "pickup_library",
524
                                title: _("Hold pickup library"),
525
                                orderable: true,
526
                                render: function (data, type, row, meta) {
527
                                    return escape_str(row.pickup_library.name);
528
                                },
529
                            },
530
                            {
531
                                data: "suspended",
532
                                name: "suspended",
533
                                className: "suspended",
534
                                title: _("Suspended"),
535
                                orderable: true,
536
                                render: function (data, type, row, meta) {
537
                                    var suspended_string = data == 0 ? _("No") : _("Yes");
538
                                    return "<span data-suspended='" + data + "'>" + suspended_string + "</span>";
539
                                },
540
                            },
541
                            {
542
                                data: "suspended_until",
543
                                name: "suspended_until",
544
                                title: _("Suspended until"),
545
                                orderable: true,
546
                                render: function (data, type, row, meta) {
547
                                    return $date(data);
548
                                },
549
                            },
550
                            {
551
                                data: "notes",
552
                                name: "notes",
553
                                title: _("Notes"),
554
                                orderable: true,
555
                                render: function (data, type, row, meta) {
556
                                    return escape_str(data);
557
                                },
558
                            },
559
                        ],
560
                    },
561
                    holds_to_modify_table_settings,
562
                    0,
563
                    filters
564
                );
577
565
578
                $(".searchpattern").text(searchpattern);
566
                $(".searchpattern").text(searchpattern);
579
567
580
                $("#modify_holds_results-wrapper").show();
568
                $("#modify_holds_results-wrapper").show();
581
            }
569
            }
582
570
583
            $("#process_mods").on('submit', function(e) {
571
            $("#process_mods").on("submit", function (e) {
584
572
                var hold_ids = JSON.parse(localStorage.getItem("holds_modify_selections")) || [];
585
                var hold_ids = JSON.parse( localStorage.getItem("holds_modify_selections") ) || [];
586
573
587
                $("#process_mods input[name='hold_id']").remove();
574
                $("#process_mods input[name='hold_id']").remove();
588
575
589
                hold_ids.forEach(function(hold) {
576
                hold_ids.forEach(function (hold) {
590
                    $('<input>').attr({
577
                    $("<input>")
591
                        type: 'hidden',
578
                        .attr({
592
                        name: 'hold_id',
579
                            type: "hidden",
593
                        value: hold.hold_id
580
                            name: "hold_id",
594
                    }).appendTo('#process_mods');
581
                            value: hold.hold_id,
582
                        })
583
                        .appendTo("#process_mods");
595
                });
584
                });
596
585
597
                var errors = [];
586
                var errors = [];
598
587
599
                var new_expiration_date = $("#new_expiration_date").val();
588
                var new_expiration_date = $("#new_expiration_date").val();
600
                var new_pickup_loc      = $("#new_pickup_loc").val();
589
                var new_pickup_loc = $("#new_pickup_loc").val();
601
                var new_suspend_status  = $("#new_suspend_status").val();
590
                var new_suspend_status = $("#new_suspend_status").val();
602
                var new_suspend_date    = $("#new_suspend_date").val();
591
                var new_suspend_date = $("#new_suspend_date").val();
603
                var new_hold_note       = $("#new_hold_note").val();
592
                var new_hold_note = $("#new_hold_note").val();
604
                var clear_hold_notes    = $("#clear_hold_notes").val();
593
                var clear_hold_notes = $("#clear_hold_notes").val();
605
594
606
                if ( hold_ids.length == 0 ) {
595
                if (hold_ids.length == 0) {
607
                    e.preventDefault();
596
                    e.preventDefault();
608
                    errors.push(_("Please select at least one hold to process."));
597
                    errors.push(_("Please select at least one hold to process."));
609
                }
598
                }
610
599
611
                if( new_pickup_loc || new_suspend_status || new_suspend_date ){
600
                if (new_pickup_loc || new_suspend_status || new_suspend_date) {
612
                    var found = false;
601
                    var found = false;
613
                    hold_ids.forEach(function(hold){
602
                    hold_ids.forEach(function (hold) {
614
                        if( hold.found_status ){
603
                        if (hold.found_status) {
615
                            e.preventDefault();
604
                            e.preventDefault();
616
                            found = true;
605
                            found = true;
617
                        }
606
                        }
618
                    });
607
                    });
619
                    if( ( new_suspend_status || new_suspend_date ) && found ){
608
                    if ((new_suspend_status || new_suspend_date) && found) {
620
                        errors.push(_("One or more holds have found status and can't be suspended."));
609
                        errors.push(_("One or more holds have found status and can't be suspended."));
621
                    }
610
                    }
622
                    if( new_pickup_loc && found ){
611
                    if (new_pickup_loc && found) {
623
                        errors.push(_("One or more holds have found status and their pick up location can't be changed."));
612
                        errors.push(_("One or more holds have found status and their pick up location can't be changed."));
624
                    }
613
                    }
625
                }
614
                }
626
615
627
                var suspended = false;
616
                var suspended = false;
628
617
629
                hold_ids.forEach(function(hold){
618
                hold_ids.forEach(function (hold) {
630
                    if( hold.suspened ){
619
                    if (hold.suspened) {
631
                        suspended = true;
620
                        suspended = true;
632
                    }
621
                    }
633
                });
622
                });
634
623
635
                if( ( !new_suspend_status || new_suspend_status == "0" || !suspended ) && new_suspend_date ){
624
                if ((!new_suspend_status || new_suspend_status == "0" || !suspended) && new_suspend_date) {
636
                    new_suspend_status = 1;
625
                    new_suspend_status = 1;
637
                }
626
                }
638
627
639
                if (errors.length > 0) {
628
                if (errors.length > 0) {
640
                    e.preventDefault();
629
                    e.preventDefault();
641
                    $("#errorList").html(errors.map(error => `<li>${error}</li>`).join(""));
630
                    $("#errorList").html(errors.map(error => `<li>${error}</li>`).join(""));
642
                    $("#errorModal").modal('show');
631
                    $("#errorModal").modal("show");
643
                    return false;
632
                    return false;
644
                }
633
                }
645
                return true;
634
                return true;
646
            });
635
            });
647
636
648
            //Modified holds table
637
            //Modified holds table
649
            $("#modified_holds").kohaTable({
638
            $("#modified_holds").kohaTable(
650
                pagingType: "full",
639
                {
651
                autoWidth: false
640
                    pagingType: "full",
652
            }, modified_holds_table_settings);
641
                    autoWidth: false,
653
642
                },
643
                modified_holds_table_settings
644
            );
654
        });
645
        });
655
    </script>
646
    </script>
656
[% END %]
647
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt (-33 / +28 lines)
Lines 323-357 Link Here
323
        const interface = "[% interface | html %]";
323
        const interface = "[% interface | html %]";
324
        const theme = "[% theme | html %]";
324
        const theme = "[% theme | html %]";
325
    </script>
325
    </script>
326
327
    <script>
326
    <script>
328
        function update_tab_display(){
327
        function update_tab_display() {
329
            let selected_type = $('input[name="recordtype"]:checked').val();
328
            let selected_type = $('input[name="recordtype"]:checked').val();
330
            if (selected_type == 'authority') {
329
            if (selected_type == "authority") {
331
                $("a[href='#shelves_tab_panel']").parent().hide();
330
                $("a[href='#shelves_tab_panel']").parent().hide();
332
                $("a[href='#uploadfile_tab_panel']").tab("show");
331
                $("a[href='#uploadfile_tab_panel']").tab("show");
333
            } else if (selected_type == 'biblio') {
332
            } else if (selected_type == "biblio") {
334
                $("a[href='#shelves_tab_panel']").parent().show();
333
                $("a[href='#shelves_tab_panel']").parent().show();
335
                $("a[href='#uploadfile_tab_panel']").tab("show");
334
                $("a[href='#uploadfile_tab_panel']").tab("show");
336
            }
335
            }
337
        }
336
        }
338
        $(document).ready(function() {
337
        $(document).ready(function () {
339
340
            update_tab_display();
338
            update_tab_display();
341
            $("input[type='radio']").click(function() {
339
            $("input[type='radio']").click(function () {
342
                update_tab_display();
340
                update_tab_display();
343
            });
341
            });
344
342
345
            $("#selectall").click(function(e){
343
            $("#selectall").click(function (e) {
346
                e.preventDefault();
344
                e.preventDefault();
347
                $(".records input[type='checkbox']").each(function(){
345
                $(".records input[type='checkbox']").each(function () {
348
                    $(this).prop("checked", true);
346
                    $(this).prop("checked", true);
349
                });
347
                });
350
            });
348
            });
351
349
352
            $("#clearall").click(function(e){
350
            $("#clearall").click(function (e) {
353
                e.preventDefault();
351
                e.preventDefault();
354
                $(".records input[type='checkbox']").each(function(){
352
                $(".records input[type='checkbox']").each(function () {
355
                    $(this).prop("checked", false);
353
                    $(this).prop("checked", false);
356
                });
354
                });
357
            });
355
            });
Lines 359-382 Link Here
359
            $("#selectall").click();
357
            $("#selectall").click();
360
358
361
            $("#biblios").kohaTable({
359
            $("#biblios").kohaTable({
362
                columnDefs: [
360
                columnDefs: [{ targets: [1], type: "num-html" }],
363
                    { targets: [1], type: "num-html" },
364
                ],
365
                dom: "t",
361
                dom: "t",
366
                order: [],
362
                order: [],
367
                paging: false,
363
                paging: false,
368
            });
364
            });
369
365
370
            $("#authorities").kohaTable({
366
            $("#authorities").kohaTable({
371
                columnDefs: [
367
                columnDefs: [{ targets: [1], type: "num-html" }],
372
                    { targets: [1], type: "num-html" },
373
                ],
374
                dom: "t",
368
                dom: "t",
375
                order: [],
369
                order: [],
376
                paging: false,
370
                paging: false,
377
            });
371
            });
378
372
379
            $("#mainformsubmit").click(function() {
373
            $("#mainformsubmit").click(function () {
380
                if ($("input[type=checkbox][name='record_id']:checked").length == 0) {
374
                if ($("input[type=checkbox][name='record_id']:checked").length == 0) {
381
                    alert(_("Please select at least one record to process"));
375
                    alert(_("Please select at least one record to process"));
382
                    return false;
376
                    return false;
Lines 388-423 Link Here
388
                return true;
382
                return true;
389
            });
383
            });
390
384
391
            $("#record_ids_selection").on("submit", function(e) {
385
            $("#record_ids_selection").on("submit", function (e) {
392
                var tab = $(this).find('#batch_mod_form li a.active:first').attr('href');
386
                var tab = $(this).find("#batch_mod_form li a.active:first").attr("href");
393
                if (tab == '#uploadfile_tab_panel') {
387
                if (tab == "#uploadfile_tab_panel") {
394
                    $("#recordnumber_list, #shelf_number").val('');
388
                    $("#recordnumber_list, #shelf_number").val("");
395
                } else if (tab == '#shelves_tab_panel') {
389
                } else if (tab == "#shelves_tab_panel") {
396
                    $("#recordnumber_list, #uploadfile").val('');
390
                    $("#recordnumber_list, #uploadfile").val("");
397
                } else { // enterlist
391
                } else {
398
                    $("#uploadfile, #shelf_number").val('')
392
                    // enterlist
393
                    $("#uploadfile, #shelf_number").val("");
399
                }
394
                }
400
            });
395
            });
401
396
402
            $("#marc_modification_template_id").change(function() {
397
            $("#marc_modification_template_id").change(function () {
403
                var url = "/cgi-bin/koha/svc/records/preview?"
398
                var url = "/cgi-bin/koha/svc/records/preview?";
404
                var mmtid = $(this).val();
399
                var mmtid = $(this).val();
405
                $("a.previewMARC").each(function() {
400
                $("a.previewMARC").each(function () {
406
                    $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod");
401
                    $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid + "&overlay_context=batchmod");
407
                });
402
                });
408
            });
403
            });
409
404
410
            $("body").on("click", ".previewMARC", function(e) {
405
            $("body").on("click", ".previewMARC", function (e) {
411
                e.preventDefault();
406
                e.preventDefault();
412
                var ltitle = $(this).text();
407
                var ltitle = $(this).text();
413
                var page = $(this).attr("href");
408
                var page = $(this).attr("href");
414
                $("#marcPreviewLabel").text(ltitle);
409
                $("#marcPreviewLabel").text(ltitle);
415
                $("#marcPreview .modal-body").load(page + " div");
410
                $("#marcPreview .modal-body").load(page + " div");
416
                $('#marcPreview').modal("show");
411
                $("#marcPreview").modal("show");
417
            });
412
            });
418
            $("#marcPreview").on("hidden.bs.modal", function() {
413
            $("#marcPreview").on("hidden.bs.modal", function () {
419
                $("#marcPreviewLabel").html("");
414
                $("#marcPreviewLabel").html("");
420
                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> " + _("Loading") + "</div>");
415
                $("#marcPreview .modal-body").html('<div id="loading"><img src="' + interface + "/" + theme + '/img/spinner-small.gif" alt="" /> ' + _("Loading") + "</div>");
421
            });
416
            });
422
        });
417
        });
423
    </script>
418
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-1 lines)
Lines 452-458 Link Here
452
        const calendardate = "[% calendardate | html %]";
452
        const calendardate = "[% calendardate | html %]";
453
        const keydate = "[% keydate | html %]";
453
        const keydate = "[% keydate | html %]";
454
    </script>
454
    </script>
455
456
    <script>
455
    <script>
457
        function holidayOperation(formObject, opType) {
456
        function holidayOperation(formObject, opType) {
458
            var op = document.getElementsByName('operation');
457
            var op = document.getElementsByName('operation');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-86 / +82 lines)
Lines 413-434 Link Here
413
    </script>
413
    </script>
414
    <script>
414
    <script>
415
        function checkForm() {
415
        function checkForm() {
416
            if ( $('#uploadbarcodes').val() && $('#barcodelist').val() ) {
416
            if ($("#uploadbarcodes").val() && $("#barcodelist").val()) {
417
                alert(_("You have uploaded a barcode file and scanned barcodes at the same time. Please choose one of the two options."));
417
                alert(_("You have uploaded a barcode file and scanned barcodes at the same time. Please choose one of the two options."));
418
                return false;
418
                return false;
419
            }
419
            }
420
            if ( $('#uploadbarcodes').val() || $('#barcodelist').val() ) {
420
            if ($("#uploadbarcodes").val() || $("#barcodelist").val()) {
421
                if ( !(
421
                if (!($("#branchloop").val() || $("#locationloop").val() || $("#minlocation").val() || $("#maxlocation").val() || $("#statuses input:checked").length)) {
422
                    $('#branchloop').val()   ||
423
                    $('#locationloop').val() ||
424
                    $('#minlocation').val()  ||
425
                    $('#maxlocation').val()  ||
426
                    $('#statuses input:checked').length
427
                ) ) {
428
                    return confirm(
422
                    return confirm(
429
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
423
                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") +
430
                        _("For large catalogs this can result in unexpected behavior") + "\n\n" +
424
                            "\n\n" +
431
                        _("Are you sure you want to do this?")
425
                            _("For large catalogs this can result in unexpected behavior") +
426
                            "\n\n" +
427
                            _("Are you sure you want to do this?")
432
                    );
428
                    );
433
                }
429
                }
434
            }
430
            }
Lines 437-541 Link Here
437
        }
433
        }
438
434
439
        function barcodesProvided() {
435
        function barcodesProvided() {
440
            if( $("#uploadbarcodes").val() || $("#barcodelist").val() ) {
436
            if ($("#uploadbarcodes").val() || $("#barcodelist").val()) {
441
                $("#setdate").prop('disabled',false);
437
                $("#setdate").prop("disabled", false);
442
                $("#compareinv2barcd").prop('disabled',false);
438
                $("#compareinv2barcd").prop("disabled", false);
443
                $("#compareinv2barcd").attr('checked',true); // default
439
                $("#compareinv2barcd").attr("checked", true); // default
444
                $("#dont_checkin").prop('disabled',false);
440
                $("#dont_checkin").prop("disabled", false);
445
                $("#out_of_order").prop('disabled',false);
441
                $("#out_of_order").prop("disabled", false);
446
                if( $("#compareinv2barcd").attr('checked') ) {
442
                if ($("#compareinv2barcd").attr("checked")) {
447
                    $("fieldset#optionalfilters").show();
443
                    $("fieldset#optionalfilters").show();
448
                    $("#ignoreissued").attr('checked',true); // default
444
                    $("#ignoreissued").attr("checked", true); // default
449
                } else {
445
                } else {
450
                    $("fieldset#optionalfilters").hide();
446
                    $("fieldset#optionalfilters").hide();
451
                    $("#ignoreissued").attr('checked',false);
447
                    $("#ignoreissued").attr("checked", false);
452
                }
448
                }
453
            } else {
449
            } else {
454
                $("#setdate").prop('disabled',true);
450
                $("#setdate").prop("disabled", true);
455
                $("#compareinv2barcd").prop('disabled',true);
451
                $("#compareinv2barcd").prop("disabled", true);
456
                $("#compareinv2barcd").attr('checked',false);
452
                $("#compareinv2barcd").attr("checked", false);
457
                $("#dont_checkin").prop('disabled',true);
453
                $("#dont_checkin").prop("disabled", true);
458
                $("#dont_checkin").attr('checked',false);
454
                $("#dont_checkin").attr("checked", false);
459
                $("#out_of_order").prop('disabled',true);
455
                $("#out_of_order").prop("disabled", true);
460
                $("#out_of_order").attr('checked',false);
456
                $("#out_of_order").attr("checked", false);
461
                $("fieldset#optionalfilters").show();
457
                $("fieldset#optionalfilters").show();
462
            }
458
            }
463
        }
459
        }
464
460
465
        $(document).ready(function(){
461
        $(document).ready(function () {
466
            inventorydt = $("#inventoryt").kohaTable({
462
            inventorydt = $("#inventoryt").kohaTable(
467
                pagingType: 'full_numbers',
463
                {
468
                bKohaColumnsUseNames: true,
464
                    pagingType: "full_numbers",
469
                ...(uploadedbarcodesflag
465
                    bKohaColumnsUseNames: true,
470
                ? {
466
                    ...(uploadedbarcodesflag
471
                    // sort on callnumber
467
                        ? {
472
                    order: [[ 2, "asc" ]]
468
                              // sort on callnumber
473
                }
469
                              order: [[2, "asc"]],
474
                : {
470
                          }
475
                    // first column contains checkboxes
471
                        : {
476
                    columnDefs: [
472
                              // first column contains checkboxes
477
                        { orderable: false, searchable:  false, targets: [ 0 ] }
473
                              columnDefs: [{ orderable: false, searchable: false, targets: [0] }],
478
                    ],
474
                              // 3rd column is callnumber
479
                    // 3rd column is callnumber
475
                              order: [[2, "asc"]],
480
                    order: [[ 2, "asc" ]],
476
                          }),
481
                }),
477
                    drawCallback: function () {
482
                drawCallback: function() {
478
                        //bind the click handler script to the newly created elements held in the table
483
                    //bind the click handler script to the newly created elements held in the table
479
                        $(".openWin").bind("click", function (e) {
484
                    $('.openWin').bind('click',function(e){
480
                            e.preventDefault();
485
                        e.preventDefault();
481
                            openWindow(this.href, "marcview", 800, 600);
486
                        openWindow(this.href,'marcview',800,600);
482
                        });
487
                    });
483
                    },
488
                }
484
                },
489
            }, table_settings );
485
                table_settings
490
486
            );
491
487
492
            $("#continuewithoutmarkingbutton").click(function(){
488
            $("#continuewithoutmarkingbutton").click(function () {
493
                inventorydt.DataTable().page('next').draw('page');
489
                inventorydt.DataTable().page("next").draw("page");
494
                return false;
490
                return false;
495
            });
491
            });
496
492
497
            $("#markseenandcontinuebutton").click(function(){
493
            $("#markseenandcontinuebutton").click(function () {
498
                var param = '';
494
                var param = "";
499
                $("input:checked").each(function() {
495
                $("input:checked").each(function () {
500
                    param += "|" + $(this).attr('name');
496
                    param += "|" + $(this).attr("name");
501
                });
497
                });
502
                $.post('/cgi-bin/koha/tools/ajax-inventory.pl', { seen: param, op: 'cud-seen', csrf_token: $('meta[name="csrf-token"]').attr("content") });
498
                $.post("/cgi-bin/koha/tools/ajax-inventory.pl", { seen: param, op: "cud-seen", csrf_token: $('meta[name="csrf-token"]').attr("content") });
503
                inventorydt.DataTable().page('next').draw('page');
499
                inventorydt.DataTable().page("next").draw("page");
504
                return false;
500
                return false;
505
            });
501
            });
506
502
507
            $("#markseenandquit").click(function(){
503
            $("#markseenandquit").click(function () {
508
                var param = '';
504
                var param = "";
509
                $("input:checked").each(function() {
505
                $("input:checked").each(function () {
510
                    param += "|" + $(this).attr('name');
506
                    param += "|" + $(this).attr("name");
511
                });
507
                });
512
                $.ajax({
508
                $.ajax({
513
                  type: 'POST',
509
                    type: "POST",
514
                  url: '/cgi-bin/koha/tools/ajax-inventory.pl',
510
                    url: "/cgi-bin/koha/tools/ajax-inventory.pl",
515
                  data: { seen: param, op: 'cud-seen', csrf_token: $('meta[name="csrf-token"]').attr("content") },
511
                    data: { seen: param, op: "cud-seen", csrf_token: $('meta[name="csrf-token"]').attr("content") },
516
                  async: false
512
                    async: false,
517
                });
513
                });
518
                document.location.href = '/cgi-bin/koha/tools/inventory.pl';
514
                document.location.href = "/cgi-bin/koha/tools/inventory.pl";
519
                return false;
515
                return false;
520
            });
516
            });
521
517
522
            $(".checkall").click(function(e){
518
            $(".checkall").click(function (e) {
523
                e.preventDefault();
519
                e.preventDefault();
524
                $("#inventoryt input:checkbox").each(function(){
520
                $("#inventoryt input:checkbox").each(function () {
525
                    $(this).prop("checked", true);
521
                    $(this).prop("checked", true);
526
                });
522
                });
527
            });
523
            });
528
            $(".clearall").click(function(e){
524
            $(".clearall").click(function (e) {
529
                e.preventDefault();
525
                e.preventDefault();
530
                $("#inventoryt input:checkbox").each(function(){
526
                $("#inventoryt input:checkbox").each(function () {
531
                    $(this).prop("checked", false);
527
                    $(this).prop("checked", false);
532
                });
528
                });
533
            });
529
            });
534
            $("#inventory_form").on("submit",function(){
530
            $("#inventory_form").on("submit", function () {
535
                return checkForm();
531
                return checkForm();
536
            });
532
            });
537
533
538
            $("#resetuploadbarcodes").click(function() {
534
            $("#resetuploadbarcodes").click(function () {
539
                $("#uploadbarcodes").val("");
535
                $("#uploadbarcodes").val("");
540
                barcodesProvided();
536
                barcodesProvided();
541
            });
537
            });
Lines 545-567 Link Here
545
            $("#uploadbarcodes").change(barcodesProvided);
541
            $("#uploadbarcodes").change(barcodesProvided);
546
            $("#barcodelist").on("change keyup paste", barcodesProvided);
542
            $("#barcodelist").on("change keyup paste", barcodesProvided);
547
543
548
            $("#compareinv2barcd").click(function() {
544
            $("#compareinv2barcd").click(function () {
549
                if( $("#compareinv2barcd").attr('checked') ) {
545
                if ($("#compareinv2barcd").attr("checked")) {
550
                    $("fieldset#optionalfilters").show();
546
                    $("fieldset#optionalfilters").show();
551
                    $("#ignoreissued").attr('checked',true); // default
547
                    $("#ignoreissued").attr("checked", true); // default
552
                } else {
548
                } else {
553
                    $("#ignoreissued").attr('checked',false);
549
                    $("#ignoreissued").attr("checked", false);
554
                    $("fieldset#optionalfilters").hide();
550
                    $("fieldset#optionalfilters").hide();
555
                }
551
                }
556
            });
552
            });
557
553
558
            $("#checkallitemtypes").on("click",function(e){
554
            $("#checkallitemtypes").on("click", function (e) {
559
                e.preventDefault();
555
                e.preventDefault();
560
                $(".branch_select").prop("checked",1);
556
                $(".branch_select").prop("checked", 1);
561
            });
557
            });
562
            $("#checknoneitemtypes").on("click",function(e){
558
            $("#checknoneitemtypes").on("click", function (e) {
563
                e.preventDefault();
559
                e.preventDefault();
564
                $(".branch_select").prop("checked",0);
560
                $(".branch_select").prop("checked", 0);
565
            });
561
            });
566
        });
562
        });
567
    </script>
563
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-5 / +5 lines)
Lines 466-472 Link Here
466
            CAN_user_editcatalogue_edit_catalogue: [% CAN_user_editcatalogue_edit_catalogue ? 1 : 0 | html %],
466
            CAN_user_editcatalogue_edit_catalogue: [% CAN_user_editcatalogue_edit_catalogue ? 1 : 0 | html %],
467
        });
467
        });
468
    </script>
468
    </script>
469
470
    <script>
469
    <script>
471
        $(document).ready(function() {
470
        $(document).ready(function() {
472
            $("#staged-record-matching-rules select").change(function() {
471
            $("#staged-record-matching-rules select").change(function() {
Lines 646-658 Link Here
646
            });
645
            });
647
        });
646
        });
648
    </script>
647
    </script>
649
650
    [% IF job_enqueued %]
648
    [% IF job_enqueued %]
651
        <script>
649
        <script>
652
            $(document).ready(function() {
650
            $(document).ready(function () {
653
                setTimeout(
651
                setTimeout(
654
                    function() { window.location.href=$('a.job_details').attr('href'); },
652
                    function () {
655
                    5000, // 5 secs to read
653
                        window.location.href = $("a.job_details").attr("href");
654
                    },
655
                    5000 // 5 secs to read
656
                );
656
                );
657
            });
657
            });
658
        </script>
658
        </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt (-61 / +64 lines)
Lines 513-542 Link Here
513
            patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
513
            patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
514
        [% END %]
514
        [% END %]
515
    </script>
515
    </script>
516
517
    <script>
516
    <script>
518
        $(document).ready(function() {
517
        $(document).ready(function () {
519
            if (has_patrons){
518
            if (has_patrons) {
520
                let selections_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_selections');
519
                let selections_column = table_settings.columns.find(c => c.columnname == "batch_patron_edit_selections");
521
                selections_column.cannot_be_modified = 1;
520
                selections_column.cannot_be_modified = 1;
522
                selections_column.cannot_be_toggled = 1;
521
                selections_column.cannot_be_toggled = 1;
523
                selections_column.force_visibility = 1;
522
                selections_column.force_visibility = 1;
524
                if (op == 'show'){
523
                if (op == "show") {
525
                    selections_column.is_hidden = 0;
524
                    selections_column.is_hidden = 0;
526
                } else {
525
                } else {
527
                    selections_column.is_hidden = 1;
526
                    selections_column.is_hidden = 1;
528
                }
527
                }
529
528
530
                if (!permissions.CanUpdatePasswordExpiration){
529
                if (!permissions.CanUpdatePasswordExpiration) {
531
                    let password_expiration_date_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_password_expiration_date');
530
                    let password_expiration_date_column = table_settings.columns.find(c => c.columnname == "batch_patron_edit_password_expiration_date");
532
                    password_expiration_date_column.is_hidden = 1;
531
                    password_expiration_date_column.is_hidden = 1;
533
                    password_expiration_date_column.cannot_be_modified = 1;
532
                    password_expiration_date_column.cannot_be_modified = 1;
534
                    password_expiration_date_column.cannot_be_toggled = 1;
533
                    password_expiration_date_column.cannot_be_toggled = 1;
535
                    password_expiration_date_column.force_visibility = 1;
534
                    password_expiration_date_column.force_visibility = 1;
536
                }
535
                }
537
536
538
                if (!permissions.CanUpdateProtectPatron){
537
                if (!permissions.CanUpdateProtectPatron) {
539
                    let protected_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_protected');
538
                    let protected_column = table_settings.columns.find(c => c.columnname == "batch_patron_edit_protected");
540
                    protected_column.is_hidden = 1;
539
                    protected_column.is_hidden = 1;
541
                    protected_column.cannot_be_modified = 1;
540
                    protected_column.cannot_be_modified = 1;
542
                    protected_column.cannot_be_toggled = 1;
541
                    protected_column.cannot_be_toggled = 1;
Lines 552-642 Link Here
552
                    table_settings
551
                    table_settings
553
                );
552
                );
554
553
555
                $("#selectallbutton").click(function() {
554
                $("#selectallbutton").click(function () {
556
                    $("#borrowerst").find("input:checkbox").each(function() {
555
                    $("#borrowerst")
557
                        $(this).prop("checked", true);
556
                        .find("input:checkbox")
558
                    });
557
                        .each(function () {
558
                            $(this).prop("checked", true);
559
                        });
559
                    return false;
560
                    return false;
560
                });
561
                });
561
                $("#clearallbutton").click(function() {
562
                $("#clearallbutton").click(function () {
562
                    $("#borrowerst").find("input:checkbox").each(function() {
563
                    $("#borrowerst")
563
                        $(this).prop("checked", false);
564
                        .find("input:checkbox")
564
                    });
565
                        .each(function () {
566
                            $(this).prop("checked", false);
567
                        });
565
                    return false;
568
                    return false;
566
                });
569
                });
567
            }
570
            }
568
571
569
            $('select[name="patron_attributes"]').change(function() {
572
            $('select[name="patron_attributes"]').change(function () {
570
                updateAttrValues(this);
573
                updateAttrValues(this);
571
            } );
574
            });
572
575
573
            $('select[name="patron_attributes"]').change();
576
            $('select[name="patron_attributes"]').change();
574
577
575
            $(".clear-date").on("click",function(e){
578
            $(".clear-date").on("click", function (e) {
576
                e.preventDefault();
579
                e.preventDefault();
577
                var fieldID = this.id.replace("clear-date-","");
580
                var fieldID = this.id.replace("clear-date-", "");
578
                $("#" + fieldID).val("");
581
                $("#" + fieldID).val("");
579
            });
582
            });
580
            $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
583
            $("#cataloguing_additem_newitem").on("click", ".add_attributes", function (e) {
581
                e.preventDefault();
584
                e.preventDefault();
582
                add_attributes();
585
                add_attributes();
583
            });
586
            });
584
            $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
587
            $("#cataloguing_additem_newitem").on("click", ".del_attributes", function (e) {
585
                e.preventDefault();
588
                e.preventDefault();
586
                del_attributes(this);
589
                del_attributes(this);
587
            });
590
            });
588
            $("#patron_batchmod_form").on("submit", function(){
591
            $("#patron_batchmod_form").on("submit", function () {
589
                /* Reset form fields on inactive tabs */
592
                /* Reset form fields on inactive tabs */
590
                var tab = $(this).find('ul.nav-tabs li a.active').attr('href');
593
                var tab = $(this).find("ul.nav-tabs li a.active").attr("href");
591
                if ( tab == '#usecardnumber_panel' ) {
594
                if (tab == "#usecardnumber_panel") {
592
                    $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
595
                    $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
593
                } else if ( tab == '#useborrowernumber_panel' ) {
596
                } else if (tab == "#useborrowernumber_panel") {
594
                    $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
597
                    $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
595
                } else { // uselist_panel
598
                } else {
599
                    // uselist_panel
596
                    $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
600
                    $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
597
                }
601
                }
598
            });
602
            });
599
603
600
            $('form[name="f"]').on("submit", function(){
604
            $('form[name="f"]').on("submit", function () {
601
                // Add the checkboxes to the DOM before we submit the form
605
                // Add the checkboxes to the DOM before we submit the form
602
                var form = this;
606
                var form = this;
603
                var checkboxes = $(patron_table).find('input:checkbox:checked').serializeArray();
607
                var checkboxes = $(patron_table).find("input:checkbox:checked").serializeArray();
604
                $.each(checkboxes, function(){
608
                $.each(checkboxes, function () {
605
                    let borrowernumber = this.value;
609
                    let borrowernumber = this.value;
606
                    if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){
610
                    if (!$(form).find('input[name="borrowernumber"][value="' + borrowernumber + '"]').length) {
607
                        $(form).append(
611
                        $(form).append($("<input>").attr("type", "hidden").attr("name", "borrowernumber").val(borrowernumber));
608
                            $('<input>')
609
                                .attr('type', 'hidden')
610
                                .attr('name', 'borrowernumber')
611
                                .val(borrowernumber)
612
                        );
613
                    }
612
                    }
614
                });
613
                });
615
            });
614
            });
616
        });
615
        });
617
616
618
        function updateAttrValues (select_attr) {
617
        function updateAttrValues(select_attr) {
619
            var attr_code = $(select_attr).val();
618
            var attr_code = $(select_attr).val();
620
            var selected_option = $(select_attr).find("option:selected");
619
            var selected_option = $(select_attr).find("option:selected");
621
            var type = $(selected_option).attr('data-type');
620
            var type = $(selected_option).attr("data-type");
622
            var category = $(selected_option).attr('data-category');
621
            var category = $(selected_option).attr("data-category");
623
            var li_node = $(select_attr).parent();
622
            var li_node = $(select_attr).parent();
624
            var span = $(li_node).find('span.patron_attributes_value');
623
            var span = $(li_node).find("span.patron_attributes_value");
625
            var information_category_node = $(li_node).find('span.information_category');
624
            var information_category_node = $(li_node).find("span.information_category");
626
            information_category_node.html("");
625
            information_category_node.html("");
627
626
628
            if ( category && category.length > 0 ) {
627
            if (category && category.length > 0) {
629
                information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
628
                information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
630
            }
629
            }
631
            var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
630
            var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
632
            if ( type == 'select' ) {
631
            if (type == "select") {
633
                var options = '<option value = ""></option>';
632
                var options = '<option value = ""></option>';
634
                for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
633
                for (var i = 0; i < patron_attributes_values[attr_code].length; i++) {
635
                    options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
634
                    options += '<option value="' + patron_attributes_values[attr_code][i] + '">' + patron_attributes_lib[attr_code][i] + "</option>";
636
                }
635
                }
637
                span.html('<select name="patron_attributes_value">' + options + '</select>');
636
                span.html('<select name="patron_attributes_value">' + options + "</select>");
638
                $(disable_input_node).show();
637
                $(disable_input_node).show();
639
            } else if ( $(selected_option).val() != "" ) {
638
            } else if ($(selected_option).val() != "") {
640
                span.html('<input type="text" name="patron_attributes_value"/>');
639
                span.html('<input type="text" name="patron_attributes_value"/>');
641
                $(disable_input_node).show();
640
                $(disable_input_node).show();
642
            } else {
641
            } else {
Lines 649-664 Link Here
649
            var count = $("li.attributes").length;
648
            var count = $("li.attributes").length;
650
            var li_node = $("li.attributes:last");
649
            var li_node = $("li.attributes:last");
651
            var li_clone = $(li_node).clone();
650
            var li_clone = $(li_node).clone();
652
            if ( $(li_clone).find("a.del_attributes").length == 0 ) {
651
            if ($(li_clone).find("a.del_attributes").length == 0) {
653
                var add_attributes = $(li_clone).find("a.add_attributes")
652
                var add_attributes = $(li_clone).find("a.add_attributes");
654
                $(add_attributes).after('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash-can"></i> ' + _("Delete") + '</a>');
653
                $(add_attributes).after('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash-can"></i> ' + _("Delete") + "</a>");
655
            }
654
            }
656
            li_node.find("label").attr("for", li_node.find("label").attr("for") + "_" + count );
655
            li_node.find("label").attr("for", li_node.find("label").attr("for") + "_" + count);
657
            li_node.find("input, select").attr("id", li_node.find("select").attr("id") + "_" + count );
656
            li_node.find("input, select").attr("id", li_node.find("select").attr("id") + "_" + count);
658
657
659
            $(li_clone).find('select[name="patron_attributes"]').change(function() {
658
            $(li_clone)
660
                updateAttrValues(this);
659
                .find('select[name="patron_attributes"]')
661
            } );
660
                .change(function () {
661
                    updateAttrValues(this);
662
                });
662
663
663
            $(li_clone).find('select[name="patron_attributes"]').change();
664
            $(li_clone).find('select[name="patron_attributes"]').change();
664
665
Lines 667-683 Link Here
667
        }
668
        }
668
669
669
        function del_attributes(a_node) {
670
        function del_attributes(a_node) {
670
            $(a_node).parent('li').remove();
671
            $(a_node).parent("li").remove();
671
            update_attr_values();
672
            update_attr_values();
672
        }
673
        }
673
674
674
        function update_attr_values() {
675
        function update_attr_values() {
675
            $("li.attributes").each(function(i) {
676
            $("li.attributes").each(function (i) {
676
                $(this).find("input:checkbox").val("attr"+i+"_value");
677
                $(this)
678
                    .find("input:checkbox")
679
                    .val("attr" + i + "_value");
677
            });
680
            });
678
        }
681
        }
679
        function clearDate(nodeid) {
682
        function clearDate(nodeid) {
680
            $("#"+nodeid).val("");
683
            $("#" + nodeid).val("");
681
        }
684
        }
682
    </script>
685
    </script>
683
[% END %]
686
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt (-86 / +86 lines)
Lines 375-466 Link Here
375
        });
375
        });
376
        const msg_alert = "[% msg | html %]";
376
        const msg_alert = "[% msg | html %]";
377
    </script>
377
    </script>
378
379
    <script>
378
    <script>
380
        function StartUpload() {
379
        function StartUpload() {
381
            if( $('#fileToUpload').prop('files').length == 0 ) return;
380
            if ($("#fileToUpload").prop("files").length == 0) return;
382
            $('#fileToUpload').prop('disabled',true);
381
            $("#fileToUpload").prop("disabled", true);
383
            $('#fileuploadbutton').hide();
382
            $("#fileuploadbutton").hide();
384
            $("#fileuploadcancel").show();
383
            $("#fileuploadcancel").show();
385
            $("#fileuploadfailed").html('');
384
            $("#fileuploadfailed").html("");
386
            $("#myalerts").hide('');
385
            $("#myalerts").hide("");
387
            $("#myalerts").html('');
386
            $("#myalerts").html("");
388
            $("#fileuploadstatus").show();
387
            $("#fileuploadstatus").show();
389
            $("#uploadedfileid").val('');
388
            $("#uploadedfileid").val("");
390
            $("#searchfile").hide();
389
            $("#searchfile").hide();
391
            $("#lastbreadcrumb").text( _("Add a new upload") );
390
            $("#lastbreadcrumb").text(_("Add a new upload"));
392
391
393
            var cat, xtra='';
392
            var cat,
394
            if( $("#uploadcategory").val() )
393
                xtra = "";
395
                cat = encodeURIComponent( $("#uploadcategory").val() );
394
            if ($("#uploadcategory").val()) cat = encodeURIComponent($("#uploadcategory").val());
396
            if( cat ) xtra= 'category=' + cat + '&';
395
            if (cat) xtra = "category=" + cat + "&";
397
            if (plugin){
396
            if (plugin) {
398
                xtra = xtra + 'public=1&temp=0';
397
                xtra = xtra + "public=1&temp=0";
399
            } else {
398
            } else {
400
                if( !cat ) xtra = 'temp=1&';
399
                if (!cat) xtra = "temp=1&";
401
                if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
400
                if ($("#public").prop("checked")) xtra = xtra + "public=1";
402
            }
401
            }
403
            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
402
            xhr = AjaxUpload($("#fileToUpload"), $("#fileuploadprogress"), xtra, cbUpload);
404
        }
403
        }
405
        function CancelUpload() {
404
        function CancelUpload() {
406
            if( xhr ) xhr.abort();
405
            if (xhr) xhr.abort();
407
            $("#fileuploadstatus").hide();
406
            $("#fileuploadstatus").hide();
408
            $('#fileToUpload').prop('disabled', false);
407
            $("#fileToUpload").prop("disabled", false);
409
            $('#fileuploadbutton').show();
408
            $("#fileuploadbutton").show();
410
            $("#fileuploadcancel").hide();
409
            $("#fileuploadcancel").hide();
411
            $("#fileuploadfailed").show();
410
            $("#fileuploadfailed").show();
412
            $("#fileuploadfailed").text( _("Upload status: Cancelled ") );
411
            $("#fileuploadfailed").text(_("Upload status: Cancelled "));
413
        }
412
        }
414
        function cbUpload( status, fileid, err ) {
413
        function cbUpload(status, fileid, err) {
415
            $('#fileToUpload').prop('disabled', false);
414
            $("#fileToUpload").prop("disabled", false);
416
            if( status=='done' ) {
415
            if (status == "done") {
417
                var e = err? JSON.stringify(err): '';
416
                var e = err ? JSON.stringify(err) : "";
418
                SubmitMe( 'search', fileid, e );
417
                SubmitMe("search", fileid, e);
419
            } else {
418
            } else {
420
                $('#fileuploadbutton').show();
419
                $("#fileuploadbutton").show();
421
                $("#fileuploadcancel").hide();
420
                $("#fileuploadcancel").hide();
422
                $("#fileuploadstatus").hide();
421
                $("#fileuploadstatus").hide();
423
                $("#fileuploadfailed").show();
422
                $("#fileuploadfailed").show();
424
                $("#fileuploadfailed").html( _("Upload status: ") +
423
                $("#fileuploadfailed").html(_("Upload status: ") + (status == "failed" ? _("Failed") : status == "denied" ? _("Denied") : status));
425
                    ( status=='failed'? _("Failed"):
424
                ShowAlerts(err);
426
                    ( status=='denied'? _("Denied"): status ))
427
                );
428
                ShowAlerts( err );
429
            }
425
            }
430
        }
426
        }
431
        function ShowAlerts(err) {
427
        function ShowAlerts(err) {
432
            var str = '';
428
            var str = "";
433
            for( var file in err ) {
429
            for (var file in err) {
434
                str= str + '<p>' + file + ': ' +
430
                str = str + "<p>" + file + ": " + errMESSAGES(err[file].code) + "</p>";
435
                    errMESSAGES( err[file].code ) + '</p>';
436
            }
431
            }
437
            if( str ) {
432
            if (str) {
438
                $('#myalerts').html(str);
433
                $("#myalerts").html(str);
439
                $('#myalerts').show();
434
                $("#myalerts").show();
440
            }
435
            }
441
        }
436
        }
442
        function errMESSAGES(code) {
437
        function errMESSAGES(code) {
443
            var rv;
438
            var rv;
444
            switch(code) {
439
            switch (code) {
445
                case 'UPLERR_ALREADY_EXISTS':
440
                case "UPLERR_ALREADY_EXISTS":
446
                    rv = _("This file already exists (in this category).");
441
                    rv = _("This file already exists (in this category).");
447
                    break;
442
                    break;
448
                case 'UPLERR_CANNOT_WRITE':
443
                case "UPLERR_CANNOT_WRITE":
449
                    rv = _("File could not be created. Check permissions.");
444
                    rv = _("File could not be created. Check permissions.");
450
                    break;
445
                    break;
451
                case 'UPLERR_NO_ROOT_DIR':
446
                case "UPLERR_NO_ROOT_DIR":
452
                    rv = _("Your koha-conf.xml does not contain a valid upload_path.");
447
                    rv = _("Your koha-conf.xml does not contain a valid upload_path.");
453
                    break;
448
                    break;
454
                case 'UPLERR_NO_TEMP_DIR':
449
                case "UPLERR_NO_TEMP_DIR":
455
                    rv = _("No temporary directory found.");
450
                    rv = _("No temporary directory found.");
456
                    break;
451
                    break;
457
                case 'UPLERR_FILE_NOT_READ':
452
                case "UPLERR_FILE_NOT_READ":
458
                    rv = _("File could not be read.");
453
                    rv = _("File could not be read.");
459
                    break;
454
                    break;
460
                case 'UPL_FILE_DELETED': // An alert, no error
455
                case "UPL_FILE_DELETED": // An alert, no error
461
                    rv = _("File has been deleted.");
456
                    rv = _("File has been deleted.");
462
                    break;
457
                    break;
463
                case 'UPLERR_FILE_NOT_DELETED':
458
                case "UPLERR_FILE_NOT_DELETED":
464
                    rv = _("File or upload record could not be deleted.");
459
                    rv = _("File or upload record could not be deleted.");
465
                    break;
460
                    break;
466
                default:
461
                default:
Lines 469-560 Link Here
469
            return rv;
464
            return rv;
470
        }
465
        }
471
        function CheckSearch() {
466
        function CheckSearch() {
472
            if( $("#term").val()=="" ) {
467
            if ($("#term").val() == "") {
473
                alert( _("Please enter a search term.") );
468
                alert(_("Please enter a search term."));
474
                return false;
469
                return false;
475
            }
470
            }
476
            return true;
471
            return true;
477
        }
472
        }
478
        function SubmitMe(op, id, msg ) {
473
        function SubmitMe(op, id, msg) {
479
            $("#submitter #op").val( op );
474
            $("#submitter #op").val(op);
480
            $("#submitter #id").val( id );
475
            $("#submitter #id").val(id);
481
            $("#submitter #msg").val( msg );
476
            $("#submitter #msg").val(msg);
482
            $("#submitter").submit();
477
            $("#submitter").submit();
483
        }
478
        }
484
        function DeleteEntry(id) {
479
        function DeleteEntry(id) {
485
            if( !confirm( _("Do you really want to delete this upload?") ))
480
            if (!confirm(_("Do you really want to delete this upload?"))) return false;
486
                return false;
487
            ClearField();
481
            ClearField();
488
            $("#form_delete #id").val( id );
482
            $("#form_delete #id").val(id);
489
            $("#form_delete").submit();
483
            $("#form_delete").submit();
490
        }
484
        }
491
        function ClearField() {
485
        function ClearField() {
492
            if (plugin){
486
            if (plugin) {
493
                $(window.opener.document).find('#' + plugin_index).val( '' );
487
                $(window.opener.document)
488
                    .find("#" + plugin_index)
489
                    .val("");
494
            }
490
            }
495
        }
491
        }
496
        function Choose(hashval) {
492
        function Choose(hashval) {
497
            var res = prefs.OPACBaseURL;
493
            var res = prefs.OPACBaseURL;
498
            res = res.replace( /\/$/, '');
494
            res = res.replace(/\/$/, "");
499
            res = res + '/cgi-bin/koha/opac-retrieve-file.pl?id=' + hashval;
495
            res = res + "/cgi-bin/koha/opac-retrieve-file.pl?id=" + hashval;
500
            var index = plugin_index;
496
            var index = plugin_index;
501
            index = index.replace( /^buttonDot_/, '' );
497
            index = index.replace(/^buttonDot_/, "");
502
            if(index) $(window.opener.document).find('#'+index).val( res );
498
            if (index)
499
                $(window.opener.document)
500
                    .find("#" + index)
501
                    .val(res);
503
            window.close();
502
            window.close();
504
        }
503
        }
505
504
506
        $(document).ready(function() {
505
        $(document).ready(function () {
507
            $("#uploadresults").kohaTable({}, table_settings);
506
            $("#uploadresults").kohaTable({}, table_settings);
508
507
509
            if (msg_alert){
508
            if (msg_alert) {
510
                ShowAlerts(msg_alert);
509
                ShowAlerts(msg_alert);
511
            }
510
            }
512
            $("#fileuploadcancel").hide();
511
            $("#fileuploadcancel").hide();
513
            $("#public_cb").click(function() {
512
            $("#public_cb").click(function () {
514
                $("#public").click();
513
                $("#public").click();
515
            });
514
            });
516
            $("#fileuploadbutton").on("click",function(e){
515
            $("#fileuploadbutton").on("click", function (e) {
517
                e.preventDefault();
516
                e.preventDefault();
518
                StartUpload();
517
                StartUpload();
519
            });
518
            });
520
            $("#fileuploadcancel").on("click",function(e){
519
            $("#fileuploadcancel").on("click", function (e) {
521
                e.preventDefault();
520
                e.preventDefault();
522
                CancelUpload();
521
                CancelUpload();
523
            });
522
            });
524
            $("#searchbutton").on("click",function(){
523
            $("#searchbutton").on("click", function () {
525
                return CheckSearch();
524
                return CheckSearch();
526
            });
525
            });
527
            $("#uploadresults tbody").on("click",".choose_entry",function(e){
526
            $("#uploadresults tbody").on("click", ".choose_entry", function (e) {
528
                e.preventDefault();
527
                e.preventDefault();
529
                var record_hashvalue = $(this).data("record-hashvalue");
528
                var record_hashvalue = $(this).data("record-hashvalue");
530
                Choose( record_hashvalue );
529
                Choose(record_hashvalue);
531
            });
530
            });
532
            $("#uploadresults tbody").on("click",".download_entry",function(e){
531
            $("#uploadresults tbody").on("click", ".download_entry", function (e) {
533
                e.preventDefault();
532
                e.preventDefault();
534
                var record_id = $(this).data("record-id");
533
                var record_id = $(this).data("record-id");
535
                SubmitMe( 'download', record_id );
534
                SubmitMe("download", record_id);
536
            });
535
            });
537
            $("#uploadresults tbody").on("click",".delete_entry",function(e){
536
            $("#uploadresults tbody").on("click", ".delete_entry", function (e) {
538
                e.preventDefault();
537
                e.preventDefault();
539
                var record_id = $(this).data("record-id");
538
                var record_id = $(this).data("record-id");
540
                DeleteEntry( record_id );
539
                DeleteEntry(record_id);
541
            });
540
            });
542
            $("#new_search").on("click",function(e){
541
            $("#new_search").on("click", function (e) {
543
                e.preventDefault();
542
                e.preventDefault();
544
                SubmitMe('new');
543
                SubmitMe("new");
545
            });
544
            });
546
545
547
            if ( window.isSecureContext ) {
546
            if (window.isSecureContext) {
548
                $(".get-file").on("click", function(e){
547
                $(".get-file").on("click", function (e) {
549
                    e.preventDefault();
548
                    e.preventDefault();
550
                    if( navigator.clipboard && navigator.clipboard.writeText){
549
                    if (navigator.clipboard && navigator.clipboard.writeText) {
551
                        navigator.clipboard.writeText( $(this).attr("href") );
550
                        navigator.clipboard.writeText($(this).attr("href"));
552
                        $(this).tooltip("dispose").attr('data-bs-title', _( "Link copied to the clipboard" )).tooltip("show");
551
                        $(this).tooltip("dispose").attr("data-bs-title", _("Link copied to the clipboard")).tooltip("show");
553
                    }
552
                    }
554
                });
553
                });
555
                $(".get-file").tooltip().on("hidden.bs.tooltip", function(){
554
                $(".get-file")
556
                    $(this).tooltip("dispose").attr("data-bs-title", _( "Copy link to this file" ) ).tooltip();
555
                    .tooltip()
557
                });
556
                    .on("hidden.bs.tooltip", function () {
557
                        $(this).tooltip("dispose").attr("data-bs-title", _("Copy link to this file")).tooltip();
558
                    });
558
            }
559
            }
559
        });
560
        });
560
    </script>
561
    </script>
561
- 

Return to bug 41580