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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-47 / +45 lines)
Lines 210-285 Link Here
210
        <script>
210
        <script>
211
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %];
211
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %];
212
        </script>
212
        </script>
213
214
        <script>
213
        <script>
215
            dt_overwrite_html_sorting_localeCompare();
214
            dt_overwrite_html_sorting_localeCompare();
216
215
217
            $(document).ready(function() {
216
            $(document).ready(function () {
218
                var oTable = $("#accounts").kohaTable({
217
                var oTable = $("#accounts").kohaTable(
219
                    drawCallback: function ( oSettings ) {
218
                    {
220
                        if ( oSettings.aiDisplay.length == 0 )
219
                        drawCallback: function (oSettings) {
221
                        {
220
                            if (oSettings.aiDisplay.length == 0) {
222
                            return;
221
                                return;
223
                        }
222
                            }
224
223
225
                        var nTrs = $('#accounts tbody tr');
224
                            var nTrs = $("#accounts tbody tr");
226
                        var iColspan = nTrs[0].getElementsByTagName('td').length;
225
                            var iColspan = nTrs[0].getElementsByTagName("td").length;
227
                        var sLastGroup = "";
226
                            var sLastGroup = "";
228
                        for ( var i=0 ; i<nTrs.length ; i++ )
227
                            for (var i = 0; i < nTrs.length; i++) {
229
                        {
228
                                var iDisplayIndex = oSettings._iDisplayStart + i;
230
                            var iDisplayIndex = oSettings._iDisplayStart + i;
229
                                var sGroup = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[1];
231
                            var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
230
                                if (sGroup != sLastGroup) {
232
                            if ( sGroup != sLastGroup )
231
                                    var nGroup = document.createElement("tr");
233
                            {
232
                                    var nCell = document.createElement("td");
234
                                var nGroup = document.createElement( 'tr' );
233
                                    nCell.colSpan = iColspan;
235
                                var nCell = document.createElement( 'td' );
234
                                    nCell.className = "group";
236
                                nCell.colSpan = iColspan;
235
                                    nCell.innerHTML = sGroup;
237
                                nCell.className = "group";
236
                                    nGroup.appendChild(nCell);
238
                                nCell.innerHTML = sGroup;
237
                                    nTrs[i].parentNode.insertBefore(nGroup, nTrs[i]);
239
                                nGroup.appendChild( nCell );
238
                                    sLastGroup = sGroup;
240
                                nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
239
                                }
241
                                sLastGroup = sGroup;
242
                            }
240
                            }
243
                        }
241
                        },
244
                    },
242
                        footerCallback: function (row, data, start, end, display) {
245
                    footerCallback: function ( row, data, start, end, display ) {
243
                            var api = this.api(),
246
                        var api = this.api(), data;
244
                                data;
247
                        footer_column_sum( api, [ 6, 7, 8, 9 ] );
245
                            footer_column_sum(api, [6, 7, 8, 9]);
246
                        },
247
                        columnDefs: [{ orderable: false, targets: ["_all"] }],
248
                        ordering: true,
249
                        orderFixed: [[1, "asc"]],
250
                        paging: false,
251
                        autoWidth: false,
248
                    },
252
                    },
249
                    columnDefs: [
253
                    table_settings
250
                        { "orderable": false, "targets": ["_all"] }
254
                );
251
                    ],
252
                    ordering: true,
253
                    orderFixed: [[ 1, 'asc' ]],
254
                    paging: false,
255
                    autoWidth: false
256
                }, table_settings );
257
                let table_dt = oTable.DataTable();
255
                let table_dt = oTable.DataTable();
258
256
259
                $(oTable).treetable({
257
                $(oTable).treetable({
260
                    expandable: true
258
                    expandable: true,
261
                });
259
                });
262
                $(oTable).treetable('expandAll');
260
                $(oTable).treetable("expandAll");
263
                $("#expand_all").click(function(e){
261
                $("#expand_all").click(function (e) {
264
                    e.preventDefault();
262
                    e.preventDefault();
265
                    $(oTable).treetable('expandAll');
263
                    $(oTable).treetable("expandAll");
266
                });
264
                });
267
                $("#collapse_all").click(function(e){
265
                $("#collapse_all").click(function (e) {
268
                    e.preventDefault();
266
                    e.preventDefault();
269
                    $(oTable).treetable('collapseAll');
267
                    $(oTable).treetable("collapseAll");
270
                });
268
                });
271
269
272
                $("#hide_inactive").click(function(e){
270
                $("#hide_inactive").click(function (e) {
273
                    e.preventDefault();
271
                    e.preventDefault();
274
                    table_dt.columns(0).search(1).draw(); // Show only active=1
272
                    table_dt.columns(0).search(1).draw(); // Show only active=1
275
                });
273
                });
276
                $("#show_inactive").click(function(e){
274
                $("#show_inactive").click(function (e) {
277
                    e.preventDefault();
275
                    e.preventDefault();
278
                    table_dt.columns(0).search("").draw();
276
                    table_dt.columns(0).search("").draw();
279
                });
277
                });
280
                $("#hide_inactive").click();
278
                $("#hide_inactive").click();
281
279
282
                $("#library-filter").change(function(){
280
                $("#library-filter").change(function () {
283
                    $("#accounts").DataTable().search(this.value);
281
                    $("#accounts").DataTable().search(this.value);
284
                    $("#accounts").DataTable().draw();
282
                    $("#accounts").DataTable().draw();
285
                });
283
                });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-32 / +35 lines)
Lines 1434-1506 Link Here
1434
1434
1435
        let skip_confirm_reopen = [% skip_confirm_reopen ? 1 : 0 | html %];
1435
        let skip_confirm_reopen = [% skip_confirm_reopen ? 1 : 0 | html %];
1436
    </script>
1436
    </script>
1437
1438
    <script>
1437
    <script>
1439
        $(document).ready(function() {
1438
        $(document).ready(function () {
1440
            $("#orders").kohaTable({
1439
            $("#orders").kohaTable(
1441
                bKohaColumnsUseNames: true,
1440
                {
1442
                pagingType: "full",
1441
                    bKohaColumnsUseNames: true,
1443
                autoWidth: false,
1442
                    pagingType: "full",
1444
            }, orders_table_settings);
1443
                    autoWidth: false,
1444
                },
1445
                orders_table_settings
1446
            );
1445
1447
1446
            $("#cancelledorderst").kohaTable({
1448
            $("#cancelledorderst").kohaTable({
1447
                pagingType: "full"
1449
                pagingType: "full",
1448
            });
1450
            });
1449
            $("#reopenform").on("submit",function(e){
1451
            $("#reopenform").on("submit", function (e) {
1450
                var is_confirmed = skip_confirm_reopen || confirm(_("Are you sure you want to reopen this basket?"));
1452
                var is_confirmed = skip_confirm_reopen || confirm(_("Are you sure you want to reopen this basket?"));
1451
                if( is_confirmed ){ return true; }
1453
                if (is_confirmed) {
1452
                else{ return false }
1454
                    return true;
1455
                } else {
1456
                    return false;
1457
                }
1453
            });
1458
            });
1454
            // Generates a dynamic link for exporting the selections data as CSV
1459
            // Generates a dynamic link for exporting the selections data as CSV
1455
            $("#exportbutton, #export-csv-menu a").click(function() {
1460
            $("#exportbutton, #export-csv-menu a").click(function () {
1456
                // Building the url from currently checked boxes
1461
                // Building the url from currently checked boxes
1457
                var url = '/cgi-bin/koha/acqui/basket.pl';
1462
                var url = "/cgi-bin/koha/acqui/basket.pl";
1458
                url += $('#exportbutton').attr('href');
1463
                url += $("#exportbutton").attr("href");
1459
                if($(this).attr("data-value")) {
1464
                if ($(this).attr("data-value")) {
1460
                    url += '&amp;csv_profile=' + $(this).attr("data-value");
1465
                    url += "&amp;csv_profile=" + $(this).attr("data-value");
1461
                }
1466
                }
1462
                // And redirecting to the CSV page
1467
                // And redirecting to the CSV page
1463
                location.href = url;
1468
                location.href = url;
1464
                return false;
1469
                return false;
1465
            });
1470
            });
1466
            $("#select_managing_library").on("change", function(){
1471
            $("#select_managing_library").on("change", function () {
1467
                $(this).parent().submit();
1472
                $(this).parent().submit();
1468
            });
1473
            });
1469
1474
1470
            $(".edit_delivery_date").on("click", function(e) {
1475
            $(".edit_delivery_date").on("click", function (e) {
1471
                e.preventDefault();
1476
                e.preventDefault();
1472
                var ordernumber = $(this).data("ordernumber");
1477
                var ordernumber = $(this).data("ordernumber");
1473
                var order_number_text = _("(order number %s)").format(ordernumber);
1478
                var order_number_text = _("(order number %s)").format(ordernumber);
1474
                var modalTitle = $(this).attr("title") + " " + order_number_text;
1479
                var modalTitle = $(this).attr("title") + " " + order_number_text;
1475
                var delivery_date = $( "#delivery_date_" + ordernumber ).data("delivery_date");
1480
                var delivery_date = $("#delivery_date_" + ordernumber).data("delivery_date");
1476
                const estimated_delivery_date = document.querySelector("#estimated_delivery_date")._flatpickr;
1481
                const estimated_delivery_date = document.querySelector("#estimated_delivery_date")._flatpickr;
1477
                estimated_delivery_date.setDate( delivery_date );
1482
                estimated_delivery_date.setDate(delivery_date);
1478
                $("#dateEditor .modal-title").text(modalTitle);
1483
                $("#dateEditor .modal-title").text(modalTitle);
1479
                $("#date_ordernumber").val(ordernumber);
1484
                $("#date_ordernumber").val(ordernumber);
1480
                $("#dateEditor").modal("show");
1485
                $("#dateEditor").modal("show");
1481
            });
1486
            });
1482
1487
1483
             $("#dateEditor").on('hidden.bs.modal', function (e) {
1488
            $("#dateEditor").on("hidden.bs.modal", function (e) {
1484
                $("#dateEditorLabel").html("");
1489
                $("#dateEditorLabel").html("");
1485
                $("#dateEditor .modal-title").text("");
1490
                $("#dateEditor .modal-title").text("");
1486
                $("#estimated_delivery_date").html( "" );
1491
                $("#estimated_delivery_date").html("");
1487
                $("#date_ordernumber").val("");
1492
                $("#date_ordernumber").val("");
1488
            });
1493
            });
1489
        });
1494
        });
1490
1495
1491
        function add_user(borrowernumber, borrowername) {
1496
        function add_user(borrowernumber, borrowername) {
1492
            var ids = $("#users_ids").val();
1497
            var ids = $("#users_ids").val();
1493
            if(ids.length > 0) {
1498
            if (ids.length > 0) {
1494
                ids = ids.split(':');
1499
                ids = ids.split(":");
1495
            } else {
1500
            } else {
1496
                ids = new Array;
1501
                ids = new Array();
1497
            }
1502
            }
1498
            if (ids.indexOf(borrowernumber.toString()) < 0) {
1503
            if (ids.indexOf(borrowernumber.toString()) < 0) {
1499
                ids.push(borrowernumber);
1504
                ids.push(borrowernumber);
1500
                $("#users_ids").val(ids.join(':'));
1505
                $("#users_ids").val(ids.join(":"));
1501
                var li = '<li id="user_'+borrowernumber+'">'+borrowername
1506
                var li = '<li id="user_' + borrowernumber + '">' + borrowername + ' <a href="#" data-borrowernumber="' + borrowernumber + '" class="del_user"><i class="fa fa-trash-can"></i> ' + _("Delete user") + "</a></li>";
1502
                + ' <a href="#" data-borrowernumber="'+borrowernumber+'" class="del_user"><i class="fa fa-trash-can"></i> '
1503
                    + _("Delete user") + '</a></li>';
1504
                $("#users_names").prepend(li);
1507
                $("#users_names").prepend(li);
1505
                $("#add_user_submit").show();
1508
                $("#add_user_submit").show();
1506
                return 0;
1509
                return 0;
Lines 1509-1518 Link Here
1509
        }
1512
        }
1510
1513
1511
        function del_user(borrowernumber) {
1514
        function del_user(borrowernumber) {
1512
            $("#user_"+borrowernumber).remove();
1515
            $("#user_" + borrowernumber).remove();
1513
            var ids = $("#users_ids").val().split(':');
1516
            var ids = $("#users_ids").val().split(":");
1514
            ids.splice(ids.indexOf(borrowernumber.toString()), 1);
1517
            ids.splice(ids.indexOf(borrowernumber.toString()), 1);
1515
            $("#users_ids").val(ids.join(':'));
1518
            $("#users_ids").val(ids.join(":"));
1516
            $("#add_user_submit").show();
1519
            $("#add_user_submit").show();
1517
        }
1520
        }
1518
    </script>
1521
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (-23 / +28 lines)
Lines 400-406 Link Here
400
        let listclosed = [% listclosed ? 1 : 0 | html %];
400
        let listclosed = [% listclosed ? 1 : 0 | html %];
401
        let grouping = [% grouping ? 1 : 0 | html %];
401
        let grouping = [% grouping ? 1 : 0 | html %];
402
    </script>
402
    </script>
403
404
    <script>
403
    <script>
405
        function submitForm(form) {
404
        function submitForm(form) {
406
            if (form.closedbg.checked == true) {
405
            if (form.closedbg.checked == true) {
Lines 413-436 Link Here
413
            form.submit();
412
            form.submit();
414
        }
413
        }
415
414
416
        function closeandprint(bg){
415
        function closeandprint(bg) {
417
            if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&amp;basketgroupid=' + bg ){
416
            if ((document.location = "/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&amp;basketgroupid=" + bg)) {
418
                setTimeout(() => {
417
                setTimeout(() => {
419
                    window.location.reload();
418
                    window.location.reload();
420
                }, 3000);
419
                }, 3000);
421
            } else {
420
            } else {
422
                alert( _("Error downloading the file") );
421
                alert(_("Error downloading the file"));
423
            }
422
            }
424
        }
423
        }
425
424
426
        $(document).ready(function() {
425
        $(document).ready(function () {
427
            if (listclosed){
426
            if (listclosed) {
428
                $("#basket_groups a[href='#closed']").tab("show");
427
                $("#basket_groups a[href='#closed']").tab("show");
429
            } else {
428
            } else {
430
                $("#basket_groups a[href='#opened']").tab("show");
429
                $("#basket_groups a[href='#opened']").tab("show");
431
            }
430
            }
432
431
433
            if (!grouping){
432
            if (!grouping) {
434
                let dt_params = {
433
                let dt_params = {
435
                    autoWidth: false,
434
                    autoWidth: false,
436
                    pagingType: "full",
435
                    pagingType: "full",
Lines 456-494 Link Here
456
                });
455
                });
457
            }
456
            }
458
457
459
            $("#basketgroupcolumns").on("click", ".addtogroup", function(){
458
            $("#basketgroupcolumns").on("click", ".addtogroup", function () {
460
                const row = $("#" + $(this).data("basketid") );
459
                const row = $("#" + $(this).data("basketid"));
461
                if( row ){
460
                if (row) {
462
                    $(this).removeClass("addtogroup").addClass("removefromgroup").html("<i class=\"fa fa-trash-can\" aria-hidden=\"true\"></i> " + _("Remove") );
461
                    $(this)
462
                        .removeClass("addtogroup")
463
                        .addClass("removefromgroup")
464
                        .html('<i class="fa fa-trash-can" aria-hidden="true"></i> ' + _("Remove"));
463
                    row.removeClass("ungrouped").addClass("grouped");
465
                    row.removeClass("ungrouped").addClass("grouped");
464
                    ungrouped.row( row ).remove().draw();
466
                    ungrouped.row(row).remove().draw();
465
                    grouped.row.add( row ).draw();
467
                    grouped.row.add(row).draw();
466
                }
468
                }
467
            });
469
            });
468
470
469
            $("#basketgroupcolumns").on("click", ".removefromgroup", function(){
471
            $("#basketgroupcolumns").on("click", ".removefromgroup", function () {
470
                const row = $("#" + $(this).data("basketid") );
472
                const row = $("#" + $(this).data("basketid"));
471
                if( row ){
473
                if (row) {
472
                    $(this).removeClass("removefromgroup").addClass("addtogroup").html("<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> " + _("Add to group") );
474
                    $(this)
475
                        .removeClass("removefromgroup")
476
                        .addClass("addtogroup")
477
                        .html('<i class="fa fa-plus" aria-hidden="true"></i> ' + _("Add to group"));
473
                    $(this).removeClass("").addClass("");
478
                    $(this).removeClass("").addClass("");
474
                    row.removeClass("grouped").addClass("ungrouped");
479
                    row.removeClass("grouped").addClass("ungrouped");
475
                    grouped.row( row ).remove().draw();
480
                    grouped.row(row).remove().draw();
476
                    ungrouped.row.add( row ).draw();
481
                    ungrouped.row.add(row).draw();
477
                }
482
                }
478
            });
483
            });
479
484
480
            $("#close_and_print").on("click", function(e){
485
            $("#close_and_print").on("click", function (e) {
481
                e.preventDefault();
486
                e.preventDefault();
482
                const basketgroupid = $(this).data("basketgroupid");
487
                const basketgroupid = $(this).data("basketgroupid");
483
                closeandprint( basketgroupid );
488
                closeandprint(basketgroupid);
484
            });
489
            });
485
490
486
            $("#groupingform").on("submit", function(e){
491
            $("#groupingform").on("submit", function (e) {
487
                e.preventDefault();
492
                e.preventDefault();
488
                submitForm(this);
493
                submitForm(this);
489
            });
494
            });
490
495
491
            $("#delete_basketgroup").on("click", function(e){
496
            $("#delete_basketgroup").on("click", function (e) {
492
                return confirm(_("Are you sure you want to delete this basket group?"));
497
                return confirm(_("Are you sure you want to delete this basket group?"));
493
            });
498
            });
494
        });
499
        });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt (-48 / +57 lines)
Lines 318-360 Link Here
318
        const op = "[% op | html %]";
318
        const op = "[% op | html %]";
319
        const has_results = [% result_order_loop ? 1 : 0 | html %];
319
        const has_results = [% result_order_loop ? 1 : 0 | html %];
320
    </script>
320
    </script>
321
322
    <script>
321
    <script>
323
        function update_ordernumber_list(){
322
        function update_ordernumber_list() {
324
            var ordernumbers = [];
323
            var ordernumbers = [];
325
            $("input[name='ordernumber']").filter(":checked").each(function(){
324
            $("input[name='ordernumber']")
326
                ordernumbers.push($(this).val());
325
                .filter(":checked")
327
            });
326
                .each(function () {
328
            $("input[name='ordernumbers']").val(ordernumbers.join(','));
327
                    ordernumbers.push($(this).val());
328
                });
329
            $("input[name='ordernumbers']").val(ordernumbers.join(","));
329
        }
330
        }
330
331
331
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
332
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
332
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
333
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
333
        $(document).ready(function() {
334
        $(document).ready(function () {
334
            $('span.hint').hide();
335
            $("span.hint").hide();
335
            $("#table_orders").kohaTable({
336
            $("#table_orders").kohaTable({
336
                paging: false,
337
                paging: false,
337
            });
338
            });
338
339
339
            if (op == 'search' || op == 'select'){
340
            if (op == "search" || op == "select") {
340
                patron_autocomplete($("#find_patron"), {
341
                patron_autocomplete($("#find_patron"), {
341
                    "on-select-add-to": {
342
                    "on-select-add-to": {
342
                        container: $("#basket_creators"),
343
                        container: $("#basket_creators"),
343
                        input_name: 'created_by'
344
                        input_name: "created_by",
344
                    },
345
                    },
345
                    "on-select-callback": function( event, ui ) {
346
                    "on-select-callback": function (event, ui) {
346
                        $("#find_patron").val('').focus();
347
                        $("#find_patron").val("").focus();
347
                        return false;
348
                        return false;
348
                    }
349
                    },
349
                });
350
                });
350
            }
351
            }
351
352
352
            $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
353
            $("#show_orders_filters, #hide_orders_filters").on("click", function (e) {
353
                e.preventDefault();
354
                e.preventDefault();
354
                $('#orders_filters').toggle();
355
                $("#orders_filters").toggle();
355
                $('.toggle_orders_filters').toggle();
356
                $(".toggle_orders_filters").toggle();
356
            });
357
            });
357
            if ( op == 'search' || op == 'select' && !has_result ){
358
            if (op == "search" || (op == "select" && !has_result)) {
358
                $("#show_orders_filters").hide();
359
                $("#show_orders_filters").hide();
359
                $("#orders_filters").show();
360
                $("#orders_filters").show();
360
            } else {
361
            } else {
Lines 362-434 Link Here
362
                $("#orders_filters").hide();
363
                $("#orders_filters").hide();
363
            }
364
            }
364
365
365
            $("input[name='ordernumber']").on("change", function(){
366
            $("input[name='ordernumber']")
366
                if ( $(this).is(':checked') ) {
367
                .on("change", function () {
367
                    $(this).parents("tr").addClass("picked_to_duplicate");
368
                    if ($(this).is(":checked")) {
368
                } else {
369
                        $(this).parents("tr").addClass("picked_to_duplicate");
369
                    $(this).parents("tr").removeClass("picked_to_duplicate");
370
                    } else {
370
                }
371
                        $(this).parents("tr").removeClass("picked_to_duplicate");
371
            }).on("click", function(e){
372
                    }
372
                update_ordernumber_list();
373
                })
373
            });
374
                .on("click", function (e) {
375
                    update_ordernumber_list();
376
                });
374
377
375
            $("#select_all").on("click",function(e){
378
            $("#select_all").on("click", function (e) {
376
                e.preventDefault();
379
                e.preventDefault();
377
                selectAll();
380
                selectAll();
378
                update_ordernumber_list();
381
                update_ordernumber_list();
379
            });
382
            });
380
383
381
            $("#clear_all").on("click",function(e){
384
            $("#clear_all").on("click", function (e) {
382
                e.preventDefault();
385
                e.preventDefault();
383
                clearAll();
386
                clearAll();
384
                update_ordernumber_list();
387
                update_ordernumber_list();
385
            });
388
            });
386
            function selectAll () {
389
            function selectAll() {
387
                $("#table_orders").find("input[type='checkbox'][name='ordernumber']").each(function(){
390
                $("#table_orders")
388
                    $(this).prop("checked", true).change();
391
                    .find("input[type='checkbox'][name='ordernumber']")
389
                });
392
                    .each(function () {
393
                        $(this).prop("checked", true).change();
394
                    });
390
                return false;
395
                return false;
391
            }
396
            }
392
            function clearAll () {
397
            function clearAll() {
393
                $("#table_orders").find("input[type='checkbox'][name='ordernumber']").each(function(){
398
                $("#table_orders")
394
                    $(this).prop("checked", false).change();
399
                    .find("input[type='checkbox'][name='ordernumber']")
395
                });
400
                    .each(function () {
401
                        $(this).prop("checked", false).change();
402
                    });
396
                return false;
403
                return false;
397
            }
404
            }
398
405
399
            $(".go_to_batch_edit").on("click",function(e){
406
            $(".go_to_batch_edit").on("click", function (e) {
400
                if ($("input[name='ordernumber']").filter(":checked").length == 0){
407
                if ($("input[name='ordernumber']").filter(":checked").length == 0) {
401
                    alert(MSG_NO_ITEM_SELECTED);
408
                    alert(MSG_NO_ITEM_SELECTED);
402
                    e.preventDefault();
409
                    e.preventDefault();
403
                }
410
                }
404
            });
411
            });
405
412
406
            $("#batch_edit_form").on("submit", function(e){
413
            $("#batch_edit_form").on("submit", function (e) {
407
                var budget_value_will_be_reused = $("input[name='copy_existing_value'][value='budget_id']").is(':checked');
414
                var budget_value_will_be_reused = $("input[name='copy_existing_value'][value='budget_id']").is(":checked");
408
                if ( ! budget_value_will_be_reused ) {
415
                if (!budget_value_will_be_reused) {
409
                    if ($("#all_budget_id").find("option:selected").val() == "" ) {
416
                    if ($("#all_budget_id").find("option:selected").val() == "") {
410
                        alert(MSG_NO_FUND_SELECTED);
417
                        alert(MSG_NO_FUND_SELECTED);
411
                        e.preventDefault();
418
                        e.preventDefault();
412
                    }
419
                    }
413
                }
420
                }
414
            });
421
            });
415
            $("input[name='copy_existing_value']").click(function(){
422
            $("input[name='copy_existing_value']").click(function () {
416
                render_disabled(this);
423
                render_disabled(this);
417
            });
424
            });
418
425
419
            $("input[name='copy_existing_value']").each(function(){
426
            $("input[name='copy_existing_value']").each(function () {
420
                render_disabled(this);
427
                render_disabled(this);
421
            });
428
            });
422
        });
429
        });
423
        function render_disabled (elt) {
430
        function render_disabled(elt) {
424
            var field = $(elt).val();
431
            var field = $(elt).val();
425
            var hint_node = $("#hint_" + field);
432
            var hint_node = $("#hint_" + field);
426
            var input_element = $(elt).parent().find("[name='all_"+field+"']");
433
            var input_element = $(elt)
434
                .parent()
435
                .find("[name='all_" + field + "']");
427
            if ($(elt).is(":checked")) {
436
            if ($(elt).is(":checked")) {
428
                $(input_element).prop('disabled', true);
437
                $(input_element).prop("disabled", true);
429
                $(hint_node).show();
438
                $(hint_node).show();
430
            } else {
439
            } else {
431
                $(input_element).prop('disabled', false);
440
                $(input_element).prop("disabled", false);
432
                $(hint_node).hide();
441
                $(hint_node).hide();
433
            }
442
            }
434
        }
443
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-7 / +5 lines)
Lines 170-178 Link Here
170
    <script>
170
    <script>
171
        var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
171
        var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
172
    </script>
172
    </script>
173
174
    <script>
173
    <script>
175
        $(document).ready(function() {
174
        $(document).ready(function () {
176
            $("#histsearcht").kohaTable(
175
            $("#histsearcht").kohaTable(
177
                {
176
                {
178
                    pagingType: "full",
177
                    pagingType: "full",
Lines 181-193 Link Here
181
            );
180
            );
182
181
183
            patron_autocomplete($("#find_patron"), {
182
            patron_autocomplete($("#find_patron"), {
184
                'on-select-add-to': {container: $("#basket_creators"), input_name: 'created_by' },
183
                "on-select-add-to": { container: $("#basket_creators"), input_name: "created_by" },
185
                'on-select-callback': function( event, ui ) {
184
                "on-select-callback": function (event, ui) {
186
                    $("#find_patron").val('').focus();
185
                    $("#find_patron").val("").focus();
187
                    return false;
186
                    return false;
188
                }
187
                },
189
            });
188
            });
190
191
        });
189
        });
192
    </script>
190
    </script>
193
[% END %]
191
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (-62 / +64 lines)
Lines 583-595 Link Here
583
        const invoiceincgst = [% invoiceincgst ? 1 : 0 | html %];
583
        const invoiceincgst = [% invoiceincgst ? 1 : 0 | html %];
584
        const has_files = [% files ? 1 : 0 | html %];
584
        const has_files = [% files ? 1 : 0 | html %];
585
    </script>
585
    </script>
586
587
    <script>
586
    <script>
588
        function updateColumnsVisibility(visible) {
587
        function updateColumnsVisibility(visible) {
589
            if ( visible ) {
588
            if (visible) {
590
                $("table .tax_excluded, .tax_included").show();
589
                $("table .tax_excluded, .tax_included").show();
591
            } else {
590
            } else {
592
                if (invoiceincgst){
591
                if (invoiceincgst) {
593
                    $("table .tax_excluded").hide();
592
                    $("table .tax_excluded").hide();
594
                } else {
593
                } else {
595
                    $("table .tax_included").hide();
594
                    $("table .tax_included").hide();
Lines 597-610 Link Here
597
            }
596
            }
598
        }
597
        }
599
598
600
        $(document).ready(function() {
599
        $(document).ready(function () {
601
            $("#orderst").kohaTable({
600
            $("#orderst").kohaTable({
602
                info: false,
601
                info: false,
603
                paging: false,
602
                paging: false,
604
                searching: false,
603
                searching: false,
605
                dom: "t",
604
                dom: "t",
606
            });
605
            });
607
            if (prefs.AcqEnableFiles && has_files){
606
            if (prefs.AcqEnableFiles && has_files) {
608
                $("#invoice_files_table").kohaTable({
607
                $("#invoice_files_table").kohaTable({
609
                    info: false,
608
                    info: false,
610
                    paging: false,
609
                    paging: false,
Lines 612-723 Link Here
612
                    dom: "t",
611
                    dom: "t",
613
                });
612
                });
614
            }
613
            }
615
            $("#show_all_details").click(function(){
614
            $("#show_all_details").click(function () {
616
                updateColumnsVisibility( $(this).is(":checked") );
615
                updateColumnsVisibility($(this).is(":checked"));
617
            });
616
            });
618
617
619
            $("#show_all_details").prop('checked', false);
618
            $("#show_all_details").prop("checked", false);
620
            updateColumnsVisibility(false);
619
            updateColumnsVisibility(false);
621
            $(".toggle_invoice_adjustment").on("click", function(e){
620
            $(".toggle_invoice_adjustment").on("click", function (e) {
622
                e.preventDefault();
621
                e.preventDefault();
623
                $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
622
                $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
624
            });
623
            });
625
624
626
            //keep a copy of all budgets before removing the inactives
625
            //keep a copy of all budgets before removing the inactives
627
            var disabledBudgetsCopy = $("#all_fund_dropdown").html();
626
            var disabledBudgetsCopy = $("#all_fund_dropdown").html();
628
            $(".fund_dropdown").each(function(){
627
            $(".fund_dropdown").each(function () {
629
                $(this).html( disabledBudgetsCopy);
628
                $(this).html(disabledBudgetsCopy);
630
                var selected = $(this).data('selected');
629
                var selected = $(this).data("selected");
631
                $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
630
                $(this)
632
                $(this).val( selected );
631
                    .find('option[value="' + selected + '"]')
632
                    .removeClass("b_inactive");
633
                $(this).val(selected);
633
            });
634
            });
634
635
635
            $('.b_inactive').remove();
636
            $(".b_inactive").remove();
636
637
637
            $('.showallfunds').on("change", function() {
638
            $(".showallfunds").on("change", function () {
638
                var the_dropdown = $("#" + $(this).data("select-id") );
639
                var the_dropdown = $("#" + $(this).data("select-id"));
639
                var selected = the_dropdown.val();
640
                var selected = the_dropdown.val();
640
                if ($(this).is(":checked")) {
641
                if ($(this).is(":checked")) {
641
                    the_dropdown.html( disabledBudgetsCopy ).val(selected);
642
                    the_dropdown.html(disabledBudgetsCopy).val(selected);
642
                } else {
643
                } else {
643
                    the_dropdown.find( 'option[value="' + selected + '"]' ).removeClass('b_inactive');
644
                    the_dropdown.find('option[value="' + selected + '"]').removeClass("b_inactive");
644
                    the_dropdown.find('.b_inactive').remove();
645
                    the_dropdown.find(".b_inactive").remove();
645
                }
646
                }
646
            });
647
            });
647
648
648
            $(".modify_fund").on('click',function(e){
649
            $(".modify_fund").on("click", function (e) {
649
                e.preventDefault();
650
                e.preventDefault();
650
                var selected = $(this).data('budget_id');
651
                var selected = $(this).data("budget_id");
651
                var sort1 = $(this).data('sort1');
652
                var sort1 = $(this).data("sort1");
652
                var sort2 = $(this).data('sort2');
653
                var sort2 = $(this).data("sort2");
653
                $("#update_fund").data('order_id',$(this).data('order_id'));
654
                $("#update_fund").data("order_id", $(this).data("order_id"));
654
                $("#modify_budget_id").html(disabledBudgetsCopy);
655
                $("#modify_budget_id").html(disabledBudgetsCopy);
655
                $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
656
                $("#modify_budget_id")
657
                    .val(selected)
658
                    .find('option[value="' + selected + '"]')
659
                    .removeClass("b_inactive");
656
                $("#updateFund").find('[name="sort1"]').val(sort1);
660
                $("#updateFund").find('[name="sort1"]').val(sort1);
657
                $("#updateFund").find('[name="sort2"]').val(sort2);
661
                $("#updateFund").find('[name="sort2"]').val(sort2);
658
                $("#modify_budget_id").find('.b_inactive').remove();
662
                $("#modify_budget_id").find(".b_inactive").remove();
659
                $("#modify_budget_id").change();
663
                $("#modify_budget_id").change();
660
                $("#updateFund").modal('show');
664
                $("#updateFund").modal("show");
661
            });
665
            });
662
            $("#update_fund").on('click',function(){
666
            $("#update_fund").on("click", function () {
663
                var new_fund = $("#modify_budget_id").val();
667
                var new_fund = $("#modify_budget_id").val();
664
                var sort1 = $("#updateFund").find('[name="sort1"]').val();
668
                var sort1 = $("#updateFund").find('[name="sort1"]').val();
665
                var sort2 = $("#updateFund").find('[name="sort2"]').val();
669
                var sort2 = $("#updateFund").find('[name="sort2"]').val();
666
                var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
670
                var new_fund_name = $('#modify_budget_id option[value="' + new_fund + '"]').text();
667
                var order_id = $(this).data('order_id');
671
                var order_id = $(this).data("order_id");
668
                let options = {
672
                let options = {
669
                    url: "/api/v1/acquisitions/orders/" + order_id,
673
                    url: "/api/v1/acquisitions/orders/" + order_id,
670
                    method: 'PUT',
674
                    method: "PUT",
671
                    contentType: 'application/json',
675
                    contentType: "application/json",
672
                    data: JSON.stringify({
676
                    data: JSON.stringify({
673
                        fund_id: new_fund,
677
                        fund_id: new_fund,
674
                        statistics_1: sort1,
678
                        statistics_1: sort1,
675
                        statistics_2: sort2
679
                        statistics_2: sort2,
676
                    })
680
                    }),
677
                };
681
                };
678
                $.ajax(options)
682
                $.ajax(options)
679
                    .then(function(thing,result){
683
                    .then(function (thing, result) {
680
                        $("#updateFund").modal('hide');
684
                        $("#updateFund").modal("hide");
681
                        $('#updateFund .showallfunds').prop('checked',false);
685
                        $("#updateFund .showallfunds").prop("checked", false);
682
                        $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
686
                        $('.modify_fund[data-order_id="' + order_id + '"]').data("budget_id", new_fund);
683
                        $('.modify_fund[data-order_id="'+order_id+'"]').data('sort1',sort1);
687
                        $('.modify_fund[data-order_id="' + order_id + '"]').data("sort1", sort1);
684
                        $('.modify_fund[data-order_id="'+order_id+'"]').data('sort2',sort2);
688
                        $('.modify_fund[data-order_id="' + order_id + '"]').data("sort2", sort2);
685
                        $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
689
                        $('.order_name[data-order_id="' + order_id + '"]').text(new_fund_name);
686
                        humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
690
                        humanMsg.displayAlert(_("Order updated"), { className: "humanError" });
687
                    })
691
                    })
688
                    .fail(function(err){
692
                    .fail(function (err) {
689
                        humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
693
                        humanMsg.displayAlert(_("Failed to update order:") + err.responseText, { className: "humanError" });
690
                    });
694
                    });
691
            });
695
            });
692
            $("#modify_budget_id").change(function(){
696
            $("#modify_budget_id").change(function () {
693
                var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
697
                var destination_sort1 = $(this).parents(".modal-body").find('input[name="sort1"]');
694
                var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
698
                var sort1_authcat = $(this).find("option:selected").attr("data-sort1-authcat");
695
                if ( destination_sort1.length < 1 ) {
699
                if (destination_sort1.length < 1) {
696
                    destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
700
                    destination_sort1 = $(this).parents(".modal-body").find('select[name="sort1"]');
697
                }
701
                }
698
                var sort1 = $(destination_sort1).val() || "";
702
                var sort1 = $(destination_sort1).val() || "";
699
                var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
703
                var destination_sort2 = $(this).parents(".modal-body").find('input[name="sort2"]');
700
                var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
704
                var sort2_authcat = $(this).find("option:selected").attr("data-sort2-authcat");
701
                if ( destination_sort2.length < 1 ) {
705
                if (destination_sort2.length < 1) {
702
                    destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
706
                    destination_sort2 = $(this).parents(".modal-body").find('select[name="sort2"]');
703
                }
707
                }
704
                var sort2 = $(destination_sort2).val() || "";
708
                var sort2 = $(destination_sort2).val() || "";
705
                getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
709
                getAuthValueDropbox("sort1", sort1_authcat, destination_sort1, sort1);
706
                getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
710
                getAuthValueDropbox("sort2", sort2_authcat, destination_sort2, sort2);
707
            });
711
            });
708
            // same effort for the adjustments
712
            // same effort for the adjustments
709
            var adjBudgetId = $("#budget_id_new");
713
            var adjBudgetId = $("#budget_id_new");
710
            var disabledAdjBudgetsCopy = adjBudgetId.html();
714
            var disabledAdjBudgetsCopy = adjBudgetId.html();
711
            $('.ab_inactive').remove();
715
            $(".ab_inactive").remove();
712
            $('#showallfunds_adj').click(function() {
716
            $("#showallfunds_adj").click(function () {
713
                if ($(this).is(":checked")) {
717
                if ($(this).is(":checked")) {
714
                    adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
718
                    adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
715
                }
719
                } else {
716
                else {
720
                    $(".ab_inactive").remove();
717
                    $('.ab_inactive').remove();
718
                }
721
                }
719
            });
722
            });
720
721
        });
723
        });
722
    </script>
724
    </script>
723
[% END %]
725
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-37 / +40 lines)
Lines 377-420 Link Here
377
    <script>
377
    <script>
378
        var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
378
        var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
379
    </script>
379
    </script>
380
381
    <script>
380
    <script>
382
        var late_orderst;
381
        var late_orderst;
383
        function check_uncheck() {
382
        function check_uncheck() {
384
            var all_nodes = late_orderst.DataTable().rows().nodes();
383
            var all_nodes = late_orderst.DataTable().rows().nodes();
385
            if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
384
            if ($(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
386
                var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
385
                var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
387
                $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
386
                $(all_nodes)
387
                    .find("input:checkbox[name=ordernumber][data-booksellerid!=" + booksellerid + "]")
388
                    .prop("disabled", true);
388
            } else {
389
            } else {
389
                $("input:checkbox[name=ordernumber]").prop('disabled', false);
390
                $("input:checkbox[name=ordernumber]").prop("disabled", false);
390
            }
391
            }
391
        }
392
        }
392
393
393
        $(document).ready(function() {
394
        $(document).ready(function () {
394
395
            late_orderst = $("#late_orders").kohaTable(
395
            late_orderst = $("#late_orders").kohaTable({
396
                {
396
                order: [[ 1, "asc" ]],
397
                    order: [[1, "asc"]],
397
                pagingType: "full",
398
                    pagingType: "full",
398
                autoWidth: false,
399
                    autoWidth: false,
399
                drawCallback: function() {
400
                    drawCallback: function () {
400
                    if ( typeof late_orderst != 'undefined' ) {
401
                        if (typeof late_orderst != "undefined") {
401
                        check_uncheck();
402
                            check_uncheck();
402
                        $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
403
                            $("input:checkbox[name=ordernumber]").bind("click", check_uncheck);
403
                    };
404
                        }
404
                }
405
                    },
405
            }, table_settings );
406
                },
406
            $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
407
                table_settings
407
            $('#CheckAll').click(function(e){
408
            );
409
            $("input:checkbox[name=ordernumber]").bind("click", check_uncheck);
410
            $("#CheckAll").click(function (e) {
408
                e.preventDefault();
411
                e.preventDefault();
409
                $("#late_orders input:checkbox").prop("checked", true);
412
                $("#late_orders input:checkbox").prop("checked", true);
410
            });
413
            });
411
            $('#CheckNone').click(function(e){
414
            $("#CheckNone").click(function (e) {
412
                e.preventDefault();
415
                e.preventDefault();
413
                $("#late_orders input:checkbox").prop("checked", false);
416
                $("#late_orders input:checkbox").prop("checked", false);
414
            });
417
            });
415
418
416
            // Generates a dynamic link for exporting the selection's data as CSV
419
            // Generates a dynamic link for exporting the selection's data as CSV
417
            $("#exportbutton, #export-csv-menu a").click(function() {
420
            $("#exportbutton, #export-csv-menu a").click(function () {
418
                var all_nodes = late_orderst.DataTable().rows().nodes();
421
                var all_nodes = late_orderst.DataTable().rows().nodes();
419
                var selected = $(all_nodes).find("input[name='ordernumber']:checked");
422
                var selected = $(all_nodes).find("input[name='ordernumber']:checked");
420
423
Lines 423-480 Link Here
423
                    return false;
426
                    return false;
424
                }
427
                }
425
428
426
                var url = $('#exportbutton').attr('href') + '?';
429
                var url = $("#exportbutton").attr("href") + "?";
427
                // Building the url from currently checked boxes
430
                // Building the url from currently checked boxes
428
                for (var i = 0; i < selected.length; i++) {
431
                for (var i = 0; i < selected.length; i++) {
429
                    url += '&amp;ordernumber=' + selected[i].value;
432
                    url += "&amp;ordernumber=" + selected[i].value;
430
                }
433
                }
431
                if($(this).attr("data-value")) {
434
                if ($(this).attr("data-value")) {
432
                    url += '&amp;csv_profile=' + $(this).attr("data-value");
435
                    url += "&amp;csv_profile=" + $(this).attr("data-value");
433
                }
436
                }
434
                // And redirecting to the CSV page
437
                // And redirecting to the CSV page
435
                location.href = url;
438
                location.href = url;
436
                return false;
439
                return false;
437
            });
440
            });
438
441
439
            $(".edit_note").on("click", function(e) {
442
            $(".edit_note").on("click", function (e) {
440
                e.preventDefault();
443
                e.preventDefault();
441
                var ordernumber = $(this).data("ordernumber");
444
                var ordernumber = $(this).data("ordernumber");
442
                var note_type = $(this).data("note_type");
445
                var note_type = $(this).data("note_type");
443
                var modalTitle = _("%s (order number %s)").format($(this).attr("title"), ordernumber);
446
                var modalTitle = _("%s (order number %s)").format($(this).attr("title"), ordernumber);
444
                var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
447
                var note_text = $("#" + note_type + "-note-" + ordernumber).html();
445
                $("#noteEditor .modal-title").text(modalTitle);
448
                $("#noteEditor .modal-title").text(modalTitle);
446
                $("#notes_ordernumber").val( ordernumber );
449
                $("#notes_ordernumber").val(ordernumber);
447
                $("#ordernotes").html( note_text );
450
                $("#ordernotes").html(note_text);
448
                $("#type").val( note_type );
451
                $("#type").val(note_type);
449
                $("#noteEditor").modal("show");
452
                $("#noteEditor").modal("show");
450
                $("#ordernotes").focus();
453
                $("#ordernotes").focus();
451
            });
454
            });
452
455
453
             $("#noteEditor").on('hidden.bs.modal', function (e) {
456
            $("#noteEditor").on("hidden.bs.modal", function (e) {
454
                $("#noteEditorLabel").html("");
457
                $("#noteEditorLabel").html("");
455
                $("#noteEditor .modal-title").text("");
458
                $("#noteEditor .modal-title").text("");
456
                $("#ordernotes").html( "" );
459
                $("#ordernotes").html("");
457
                $("#notes_ordernumber").val("");
460
                $("#notes_ordernumber").val("");
458
                $("#type").val("");
461
                $("#type").val("");
459
            });
462
            });
460
463
461
            $(".edit_delivery_date").on("click", function(e) {
464
            $(".edit_delivery_date").on("click", function (e) {
462
                e.preventDefault();
465
                e.preventDefault();
463
                var ordernumber = $(this).data("ordernumber");
466
                var ordernumber = $(this).data("ordernumber");
464
                var order_number_text = _("(order number %s)").format(ordernumber);
467
                var order_number_text = _("(order number %s)").format(ordernumber);
465
                var modalTitle = $(this).attr("title") + " " + order_number_text;
468
                var modalTitle = $(this).attr("title") + " " + order_number_text;
466
                var delivery_date = $( "#delivery_date_" + ordernumber ).data("delivery_date");
469
                var delivery_date = $("#delivery_date_" + ordernumber).data("delivery_date");
467
                const estimated_delivery_date = document.querySelector("#estimated_delivery_date")._flatpickr;
470
                const estimated_delivery_date = document.querySelector("#estimated_delivery_date")._flatpickr;
468
                estimated_delivery_date.setDate( delivery_date );
471
                estimated_delivery_date.setDate(delivery_date);
469
                $("#dateEditor .modal-title").text(modalTitle);
472
                $("#dateEditor .modal-title").text(modalTitle);
470
                $("#date_ordernumber").val(ordernumber);
473
                $("#date_ordernumber").val(ordernumber);
471
                $("#dateEditor").modal("show");
474
                $("#dateEditor").modal("show");
472
            });
475
            });
473
476
474
             $("#dateEditor").on('hidden.bs.modal', function (e) {
477
            $("#dateEditor").on("hidden.bs.modal", function (e) {
475
                $("#dateEditorLabel").html("");
478
                $("#dateEditorLabel").html("");
476
                $("#dateEditor .modal-title").text("");
479
                $("#dateEditor .modal-title").text("");
477
                $("#estimated_delivery_date").html( "" );
480
                $("#estimated_delivery_date").html("");
478
                $("#date_ordernumber").val("");
481
                $("#date_ordernumber").val("");
479
            });
482
            });
480
        });
483
        });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt (-17 / +16 lines)
Lines 133-156 Link Here
133
    <script>
133
    <script>
134
        const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %];
134
        const logged_in_user = [% To.json(logged_in_user.unblessed) | $raw %];
135
    </script>
135
    </script>
136
137
    <script>
136
    <script>
138
        $(document).ready(function() {
137
        $(document).ready(function () {
139
           var suggestionst = $("#suggestionst").kohaTable({
138
            var suggestionst = $("#suggestionst").kohaTable({
140
               columnDefs: [
139
                columnDefs: [
141
                   { targets: [0], visible: false, searchable: true }, // must be searchable for filtering
140
                    { targets: [0], visible: false, searchable: true }, // must be searchable for filtering
142
               ],
141
                ],
143
               pagingType: "full",
142
                pagingType: "full",
144
           });
143
            });
145
           let table_dt = suggestionst.DataTable();
144
            let table_dt = suggestionst.DataTable();
146
           $("#show_only_mine").on('click', function(e){
145
            $("#show_only_mine").on("click", function (e) {
147
               e.preventDefault();
146
                e.preventDefault();
148
               table_dt.columns(0).search(`^${logged_in_user.borrowernumber}$`, true).draw();
147
                table_dt.columns(0).search(`^${logged_in_user.borrowernumber}$`, true).draw();
149
           });
148
            });
150
           $("#show_all").on('click', function(e){
149
            $("#show_all").on("click", function (e) {
151
               e.preventDefault();
150
                e.preventDefault();
152
               table_dt.columns(0).search("").draw();
151
                table_dt.columns(0).search("").draw();
153
           });
152
            });
154
        });
153
        });
155
    </script>
154
    </script>
156
[% END %]
155
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-409 / +426 lines)
Lines 468-541 Link Here
468
            CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %],
468
            CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %],
469
        });
469
        });
470
    </script>
470
    </script>
471
472
    <script>
471
    <script>
473
        function display_string(key, strings, fallback) {
472
        function display_string(key, strings, fallback) {
474
            if ( strings.hasOwnProperty(key) ) {
473
            if (strings.hasOwnProperty(key)) {
475
                return strings[key].str && escape_str(strings[key].str) || '';
474
                return (strings[key].str && escape_str(strings[key].str)) || "";
476
            }
475
            }
477
            return fallback != null ? fallback : '';
476
            return fallback != null ? fallback : "";
478
        }
477
        }
479
478
480
        var _build_item = function(item, tr) {
479
        var _build_item = function (item, tr) {
481
            var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />')
480
            var chb = $('<input type="checkbox" name="items_to_receive" value="' + item.item_id + '" />')
482
                .prop('checked', item._checked)
481
                .prop("checked", item._checked)
483
                .change(function() {
482
                .change(function () {
484
                    item._checked = $(this).prop('checked');
483
                    item._checked = $(this).prop("checked");
485
                });
484
                });
486
            tr.append($('<td style="text-align:center"></td>').append(chb));
485
            tr.append($('<td style="text-align:center"></td>').append(chb));
487
            tr.append('<td><a style="cursor:pointer" href="#" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>');
486
            tr.append('<td><a style="cursor:pointer" href="#" onclick="PopupEditPage(' + item.biblio_id + ", " + item.item_id + ');">' + EDIT[0].toUpperCase() + EDIT.substr(1).toLowerCase() + "</a></td>");
488
            tr.append('<td>'+(item.external_id||'')+'</td>');
487
            tr.append("<td>" + (item.external_id || "") + "</td>");
489
            tr.append('<td>'+display_string( 'home_library_id', item._strings, item.home_library_id ) || ''+'</td>');
488
            tr.append("<td>" + display_string("home_library_id", item._strings, item.home_library_id) || "" + "</td>");
490
            tr.append('<td>'+display_string( 'holding_library_id', item._strings, item.holding_library_id )+'</td>');
489
            tr.append("<td>" + display_string("holding_library_id", item._strings, item.holding_library_id) + "</td>");
491
            tr.append('<td>'+display_string( 'not_for_loan_status', item._strings, item.not_for_loan_status )+'</td>');
490
            tr.append("<td>" + display_string("not_for_loan_status", item._strings, item.not_for_loan_status) + "</td>");
492
            tr.append('<td>'+display_string( 'restricted_status', item._strings, item.restricted_status )+'</td>');
491
            tr.append("<td>" + display_string("restricted_status", item._strings, item.restricted_status) + "</td>");
493
            tr.append('<td><span class="shelvingloc">'+display_string( 'location', item._strings, item.location )+'</span></td>');
492
            tr.append('<td><span class="shelvingloc">' + display_string("location", item._strings, item.location) + "</span></td>");
494
            tr.append('<td>'+(item.callnumber||'')+'</td>');
493
            tr.append("<td>" + (item.callnumber || "") + "</td>");
495
            tr.append('<td>'+(item.copy_number||'')+'</td>');
494
            tr.append("<td>" + (item.copy_number || "") + "</td>");
496
            tr.append('<td>'+(item.inventory_number||'')+'</td>');
495
            tr.append("<td>" + (item.inventory_number || "") + "</td>");
497
            tr.append('<td>'+display_string( 'collection', item._strings, item.collection )+'</td>');
496
            tr.append("<td>" + display_string("collection", item._strings, item.collection) + "</td>");
498
            tr.append('<td>'+display_string( 'item_type_id', item._strings, item.item_type_id )+'</td>');
497
            tr.append("<td>" + display_string("item_type_id", item._strings, item.item_type_id) + "</td>");
499
            tr.append('<td>'+display_string( 'materials_notes', item._strings, item.materials_notes )+'</td>');
498
            tr.append("<td>" + display_string("materials_notes", item._strings, item.materials_notes) + "</td>");
500
            tr.append('<td>'+(item.public_notes||'')+'</td>');
499
            tr.append("<td>" + (item.public_notes || "") + "</td>");
501
        };
500
        };
502
501
503
        var items_columns = [null, null, 'external_id', 'home_library_id',
502
        var items_columns = [
504
                'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location',
503
            null,
505
                'callnumber', 'copy_number', 'inventory_number', 'collection_code',
504
            null,
506
                'item_type', 'materials_notes', 'public_notes'];
505
            "external_id",
506
            "home_library_id",
507
            "holding_library_id",
508
            "not_for_loan_status",
509
            "restricted_status",
510
            "location",
511
            "callnumber",
512
            "copy_number",
513
            "inventory_number",
514
            "collection_code",
515
            "item_type",
516
            "materials_notes",
517
            "public_notes",
518
        ];
507
519
508
        function PopupEditPage(biblionumber, itemnumber) {
520
        function PopupEditPage(biblionumber, itemnumber) {
509
            var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
521
            var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
510
                + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
511
            var w = window.open(url);
522
            var w = window.open(url);
512
            var watchClose = setInterval(function() {
523
            var watchClose = setInterval(function () {
513
                if (w.closed) {
524
                if (w.closed) {
514
                    clearTimeout(watchClose);
525
                    clearTimeout(watchClose);
515
                    $.ajax({
526
                    $.ajax({
516
                        dataType: "json",
527
                        dataType: "json",
517
                        headers: {
528
                        headers: {
518
                            "x-koha-embed": "+strings"
529
                            "x-koha-embed": "+strings",
519
                        },
530
                        },
520
                        url: '/api/v1/items/'+itemnumber,
531
                        url: "/api/v1/items/" + itemnumber,
521
                        success: function(item) {
532
                        success: function (item) {
522
                            var tr = $("#item_"+itemnumber);
533
                            var tr = $("#item_" + itemnumber);
523
                            item._checked = $(tr).find('input[type="checkbox"]').prop('checked');
534
                            item._checked = $(tr).find('input[type="checkbox"]').prop("checked");
524
                            tr.html('');
535
                            tr.html("");
525
                            _build_item(item, tr);
536
                            _build_item(item, tr);
526
537
527
                            var row = $("#order_edit").data('row');
538
                            var row = $("#order_edit").data("row");
528
                            row.items.forEach((it, i) => { if (it.item_id == itemnumber) {
539
                            row.items.forEach((it, i) => {
529
                                row.items[i] = item;
540
                                if (it.item_id == itemnumber) {
530
                            }});
541
                                    row.items[i] = item;
531
                        }
542
                                }
543
                            });
544
                        },
532
                    });
545
                    });
533
                }
546
                }
534
            }, 500);
547
            }, 500);
535
        }
548
        }
536
549
537
        var periods={};
550
        var periods = {};
538
        var funds={};
551
        var funds = {};
539
        var funds_tree = [];
552
        var funds_tree = [];
540
553
541
        var QTY_TOTAL = _("Receiving %0$s out of %1$s");
554
        var QTY_TOTAL = _("Receiving %0$s out of %1$s");
Lines 554-674 Link Here
554
        var SAVE_WARNING_TITLE = _("Warning");
567
        var SAVE_WARNING_TITLE = _("Warning");
555
        var SAVE_ERROR_TITLE = _("Error");
568
        var SAVE_ERROR_TITLE = _("Error");
556
569
557
        $(document).ready(function(){
570
        $(document).ready(function () {
558
            // keep a copy for re-rendering
571
            // keep a copy for re-rendering
559
            var $funds_tree = $('#bookfund').html();
572
            var $funds_tree = $("#bookfund").html();
560
            var base_query = { "order_id": {"-in": multiple_orders.split(',')}};
573
            var base_query = { order_id: { "-in": multiple_orders.split(",") } };
561
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
574
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
562
            var options = {
575
            var options = {
563
                ajax: {
576
                ajax: {
564
                    "url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query))
577
                    url: pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)),
565
                },
578
                },
566
                embed: [
579
                embed: ["basket", "biblio.suggestions.suggester", "fund.budget", "items+strings", "creator"],
567
                    "basket",
568
                    "biblio.suggestions.suggester",
569
                    "fund.budget",
570
                    "items+strings",
571
                    "creator"
572
                ],
573
                dom: 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
580
                dom: 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
574
                columns: [
581
                columns: [
575
                    {
582
                    {
576
                        data: "order_id",
583
                        data: "order_id",
577
                        searchable: true,
584
                        searchable: true,
578
                        orderable: true
585
                        orderable: true,
579
                    },
586
                    },
580
                    {
587
                    {
581
                        data: "biblio.title",
588
                        data: "biblio.title",
582
                        searchable: true,
589
                        searchable: true,
583
                        orderable: true,
590
                        orderable: true,
584
                        render: function(data, type, row, meta) {
591
                        render: function (data, type, row, meta) {
585
                            if ( data == null ) {
592
                            if (data == null) {
586
                                return "";
593
                                return "";
587
                            }
594
                            } else {
588
                            else {
589
                                return data;
595
                                return data;
590
                            }
596
                            }
591
                        }
597
                        },
592
                    },
598
                    },
593
                    {
599
                    {
594
                        data: "biblio.author",
600
                        data: "biblio.author",
595
                        searchable: true,
601
                        searchable: true,
596
                        orderable: true,
602
                        orderable: true,
597
                        render: function(data, type, row, meta) {
603
                        render: function (data, type, row, meta) {
598
                            if ( data == null ) {
604
                            if (data == null) {
599
                                return "";
605
                                return "";
600
                            }
606
                            } else {
601
                            else {
602
                                return data;
607
                                return data;
603
                            }
608
                            }
604
                        }
609
                        },
605
                    },
610
                    },
606
                    {
611
                    {
607
                        data: "biblio.isbn",
612
                        data: "biblio.isbn",
608
                        searchable: true,
613
                        searchable: true,
609
                        orderable: true,
614
                        orderable: true,
610
                        render: function(data, type, row, meta) {
615
                        render: function (data, type, row, meta) {
611
                            if ( data == null ) {
616
                            if (data == null) {
612
                                return "";
617
                                return "";
613
                            }
618
                            } else {
614
                            else {
615
                                return data;
619
                                return data;
616
                            }
620
                            }
617
                        }
621
                        },
618
                    },
622
                    },
619
                    {
623
                    {
620
                        searchable: false,
624
                        searchable: false,
621
                        orderable: false,
625
                        orderable: false,
622
                        data: function(row, type, val, meta) {
626
                        data: function (row, type, val, meta) {
623
                            return $date(row.date_received||new Date().toISOString());
627
                            return $date(row.date_received || new Date().toISOString());
624
                        }
628
                        },
625
                    },
629
                    },
626
                    {
630
                    {
627
                        data: "fund.name",
631
                        data: "fund.name",
628
                        searchable: true,
632
                        searchable: true,
629
                        orderable: false,
633
                        orderable: false,
630
                        render: function(data, type, row, meta) {
634
                        render: function (data, type, row, meta) {
631
                            return row.fund.budget.budget_period_description+" - "+row.fund.name;
635
                            return row.fund.budget.budget_period_description + " - " + row.fund.name;
632
                        }
636
                        },
633
                    },
637
                    },
634
                    {
638
                    {
635
                        searchable: false,
639
                        searchable: false,
636
                        orderable: true,
640
                        orderable: true,
637
                        data: "quantity_received",
641
                        data: "quantity_received",
638
                        render: function(data, type, row, meta) {
642
                        render: function (data, type, row, meta) {
639
                            var data = $("#order_edit").data();
643
                            var data = $("#order_edit").data();
640
                            return QTY_TOTAL.format(row.subscription_id&&(!data.saved||!data.saved.hasOwnProperty(row.order_id))?row.quantity:row.quantity_received, row.quantity);
644
                            return QTY_TOTAL.format(row.subscription_id && (!data.saved || !data.saved.hasOwnProperty(row.order_id)) ? row.quantity : row.quantity_received, row.quantity);
641
                        }
645
                        },
642
                    },
646
                    },
643
                    {
647
                    {
644
                        searchable: false,
648
                        searchable: false,
645
                        orderable: false,
649
                        orderable: false,
646
                        render: function(data, type, row, meta) {
650
                        render: function (data, type, row, meta) {
647
                            return '<a class="btn btn-default btn-xs order_edit_toggle" data-bs-toggle="modal" href="#order_edit" data-row="'+meta.row+'" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> '+EDIT+'</a>';
651
                            return '<a class="btn btn-default btn-xs order_edit_toggle" data-bs-toggle="modal" href="#order_edit" data-row="' + meta.row + '" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> ' + EDIT + "</a>";
648
                        }
652
                        },
649
                    }
650
                ],
651
                ...(only_one_order?
652
                    {
653
                    drawCallback: function( settings ) {
654
                        $("#order_edit").modal("show");
655
                    },
653
                    },
656
                    } : {}),
654
                ],
655
                ...(only_one_order
656
                    ? {
657
                          drawCallback: function (settings) {
658
                              $("#order_edit").modal("show");
659
                          },
660
                      }
661
                    : {}),
657
            };
662
            };
658
            var orders_table = $("#multiple_orders").kohaTable(options);
663
            var orders_table = $("#multiple_orders").kohaTable(options);
659
            var api = orders_table.api();
664
            var api = orders_table.api();
660
665
661
            api.on('preDraw', function() {
666
            api.on("preDraw", function () {
662
                var saved = $("#order_edit").data('saved');
667
                var saved = $("#order_edit").data("saved");
663
                if(saved) {
668
                if (saved) {
664
                    var data = api.data();
669
                    var data = api.data();
665
                    for(var i = 0; i<data.length; i++) {
670
                    for (var i = 0; i < data.length; i++) {
666
                        var row = data[i];
671
                        var row = data[i];
667
                        var srow = saved[row.order_id];
672
                        var srow = saved[row.order_id];
668
                        if(srow) {
673
                        if (srow) {
669
                            if(row.fund_id != srow.fund_id) {
674
                            if (row.fund_id != srow.fund_id) {
670
                                row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label');
675
                                row.fund.budget.budget_period_description = $("#bookfund option[value=" + srow.fund_id + "]")
671
                                row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html();
676
                                    .parent()
677
                                    .attr("label");
678
                                row.fund.name = $("#bookfund option[value=" + srow.fund_id + "]").html();
672
                            }
679
                            }
673
                            row.date_received = srow.date_received;
680
                            row.date_received = srow.date_received;
674
                            row.quantity = srow.quantity;
681
                            row.quantity = srow.quantity;
Lines 678-846 Link Here
678
                }
685
                }
679
            });
686
            });
680
687
681
            if (only_one_order){
688
            if (only_one_order) {
682
                $("#quantity").on('change', function() {
689
                $("#quantity").on("change", function () {
683
                    $('.modal-save').prop('disabled', $(this).val() < 1 );
690
                    $(".modal-save").prop("disabled", $(this).val() < 1);
684
                });
691
                });
685
            }
692
            }
686
693
687
            var _doSave = function(params) {
694
            var _doSave = function (params) {
688
                params.data.csrf_token = $('meta[name="csrf-token"]').attr('content');
695
                params.data.csrf_token = $('meta[name="csrf-token"]').attr("content");
689
                $.ajax($.extend({
696
                $.ajax(
690
                    method: 'POST',
697
                    $.extend(
691
                    url: '/cgi-bin/koha/acqui/finishreceive.pl'
698
                        {
692
                }, params));
699
                            method: "POST",
700
                            url: "/cgi-bin/koha/acqui/finishreceive.pl",
701
                        },
702
                        params
703
                    )
704
                );
693
            };
705
            };
694
706
695
            var _transform_row = function(row, origrec) {
707
            var _transform_row = function (row, origrec) {
696
                var params = {};
708
                var params = {};
697
                params['biblionumber'] = row.biblio_id;
709
                params["biblionumber"] = row.biblio_id;
698
                params['invoiceid'] = invoice_id;
710
                params["invoiceid"] = invoice_id;
699
                params['ordernumber'] = row.order_id;
711
                params["ordernumber"] = row.order_id;
700
                params['booksellerid'] = row.basket.vendor_id;
712
                params["booksellerid"] = row.basket.vendor_id;
701
713
702
                if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
714
                if (row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
703
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
715
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
704
                    const options = Array.from(document.querySelectorAll('#reason option'));
716
                    const options = Array.from(document.querySelectorAll("#reason option"));
705
                    if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
717
                    if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
706
                        params['reason'] =  row.biblio.suggestions[0].reason;
718
                        params["reason"] = row.biblio.suggestions[0].reason;
707
                    } else {
719
                    } else {
708
                        params['reason'] = 'other';
720
                        params["reason"] = "other";
709
                        params['other_reason'] = row.biblio.suggestions[0].reason;
721
                        params["other_reason"] = row.biblio.suggestions[0].reason;
710
                    }
722
                    }
711
                }
723
                }
712
                params['datereceived'] = row.date_received;
724
                params["datereceived"] = row.date_received;
713
                params['bookfund'] = row.fund_id;
725
                params["bookfund"] = row.fund_id;
714
                params['quantity'] = row.quantity;
726
                params["quantity"] = row.quantity;
715
                params['quantityrec'] = row.quantity_received;
727
                params["quantityrec"] = row.quantity_received;
716
                params['origquantityrec'] = origrec;
728
                params["origquantityrec"] = origrec;
717
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
729
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
718
                params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering;
730
                params["tax_rate"] = effective_create_items == "receiving" ? row.tax_rate_on_receiving : row.tax_rate_on_ordering;
719
                params['replacementprice'] = row.replacement_price;
731
                params["replacementprice"] = row.replacement_price;
720
                params['unitprice'] = ( invoiceincgst=="1" ) ? ( row.unit_price_tax_included || row.ecost_tax_included ) : ( row.unit_price_tax_excluded || row.ecost_tax_excluded );
732
                params["unitprice"] = invoiceincgst == "1" ? row.unit_price_tax_included || row.ecost_tax_included : row.unit_price_tax_excluded || row.ecost_tax_excluded;
721
                params['order_internalnote'] = row.internal_note;
733
                params["order_internalnote"] = row.internal_note;
722
                if (effective_create_items == 'receiving') {
734
                if (effective_create_items == "receiving") {
723
                    row.items.forEach(function(item){
735
                    row.items.forEach(function (item) {
724
                        Object.keys(item).forEach(function(item_field){
736
                        Object.keys(item).forEach(function (item_field) {
725
                            Object.keys(item[item_field]).forEach(function(key){
737
                            Object.keys(item[item_field]).forEach(function (key) {
726
                                if (!params[key]) params[key] = [];
738
                                if (!params[key]) params[key] = [];
727
                                params[key].push(item[item_field][key]);
739
                                params[key].push(item[item_field][key]);
728
                            });
740
                            });
729
                        });
741
                        });
730
                    });
742
                    });
731
                } else if(effective_create_items == 'ordering') {
743
                } else if (effective_create_items == "ordering") {
732
                    params['items_to_receive[]'] = (row.items||[])
744
                    params["items_to_receive[]"] = (row.items || [])
733
                        .filter(function(item) {
745
                        .filter(function (item) {
734
                            return item._checked
746
                            return item._checked;
735
                        })
747
                        })
736
                        .map(function(item) {
748
                        .map(function (item) {
737
                            return item.item_id;
749
                            return item.item_id;
738
                        })
750
                        });
739
                }
751
                }
740
                params['invoice_currency'] = row.invoice_currency;
752
                params["invoice_currency"] = row.invoice_currency;
741
                params['invoice_unitprice'] = row.invoice_unit_price;
753
                params["invoice_unitprice"] = row.invoice_unit_price;
742
                return params;
754
                return params;
743
            };
755
            };
744
756
745
            var save_rows = function(rows, data) {
757
            var save_rows = function (rows, data) {
746
                if(rows.length) {
758
                if (rows.length) {
747
                    $('#jobpanel, #jobstatus').show();
759
                    $("#jobpanel, #jobstatus").show();
748
                    errors = []
760
                    errors = [];
749
                    var loopRows = function(i) {
761
                    var loopRows = function (i) {
750
                        var row = rows[i];
762
                        var row = rows[i];
751
                        if(!row) {
763
                        if (!row) {
752
                            if(!errors.length) {
764
                            if (!errors.length) {
753
                                location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id
765
                                location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid=" + invoice_id;
754
                            } else {
766
                            } else {
755
                                $('#modal_messages .modal-header h1').html(SAVE_ERROR_TITLE);
767
                                $("#modal_messages .modal-header h1").html(SAVE_ERROR_TITLE);
756
                                $('#modal_messages .modal-body ul').html('');
768
                                $("#modal_messages .modal-body ul").html("");
757
                                errors.forEach(function(error) {
769
                                errors.forEach(function (error) {
758
                                    $('#modal_messages .modal-body ul').append('<li>'+error+'</li>');
770
                                    $("#modal_messages .modal-body ul").append("<li>" + error + "</li>");
759
                                });
771
                                });
760
                                $('#modal_messages .modal-footer .cancel').hide();
772
                                $("#modal_messages .modal-footer .cancel").hide();
761
                                $('#modal_messages .modal-footer .accept').html(_("Accept"));
773
                                $("#modal_messages .modal-footer .accept").html(_("Accept"));
762
                                $('#modal_messages .modal-footer .accept').one('click', function() {
774
                                $("#modal_messages .modal-footer .accept").one("click", function () {
763
                                    location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id
775
                                    location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid=" + invoice_id;
764
                                });
776
                                });
765
                                $('#modal_messages').modal('show');
777
                                $("#modal_messages").modal("show");
766
                            }
778
                            }
767
                            return;
779
                            return;
768
                        }
780
                        }
769
                        if(data.saved && data.saved[row.order_id]) {
781
                        if (data.saved && data.saved[row.order_id]) {
770
                            row = data.saved[row.order_id];
782
                            row = data.saved[row.order_id];
771
                            var origrec = data.origrec[row.order_id];
783
                            var origrec = data.origrec[row.order_id];
772
                        } else {
784
                        } else {
773
                            var origrec = row.quantity_received;
785
                            var origrec = row.quantity_received;
774
                        }
786
                        }
775
                        var _set_percentage = function() {
787
                        var _set_percentage = function () {
776
                            var percentage = Math.round(( (i+1) / rows.length) * 100);
788
                            var percentage = Math.round(((i + 1) / rows.length) * 100);
777
                            var bgproperty = (parseInt(percentage*2)-300)+"px 0px";
789
                            var bgproperty = parseInt(percentage * 2) - 300 + "px 0px";
778
                            $("#jobprogress").css("background-position",bgproperty);
790
                            $("#jobprogress").css("background-position", bgproperty);
779
                            $("#jobprogresspercent").text(percentage);
791
                            $("#jobprogresspercent").text(percentage);
780
                        }
792
                        };
781
                        _doSave({
793
                        _doSave({
782
                            data: _transform_row(row, origrec),
794
                            data: _transform_row(row, origrec),
783
                            success: function() {
795
                            success: function () {
784
                                _set_percentage();
796
                                _set_percentage();
785
                                loopRows(i+1);
797
                                loopRows(i + 1);
786
                            },
798
                            },
787
                            error: function() {
799
                            error: function () {
788
                                _set_percentage()
800
                                _set_percentage();
789
                                errors.push(SAVE_ERROR.format(row.order_id));
801
                                errors.push(SAVE_ERROR.format(row.order_id));
790
                                loopRows(i+1);
802
                                loopRows(i + 1);
791
                            }
803
                            },
792
                        });
804
                        });
793
                    };
805
                    };
794
                    loopRows(0)
806
                    loopRows(0);
795
                }
807
                }
796
            };
808
            };
797
809
798
            var get_warnings = function(rows) {
810
            var get_warnings = function (rows) {
799
                var warnings = [];
811
                var warnings = [];
800
                rows.forEach(function(row) {
812
                rows.forEach(function (row) {
801
                    if(row.quantity_received > row.quantity) {
813
                    if (row.quantity_received > row.quantity) {
802
                        warnings.push(SAVE_WARNING.format(row.order_id));
814
                        warnings.push(SAVE_WARNING.format(row.order_id));
803
                        row.quantity_received = row.quantity;
815
                        row.quantity_received = row.quantity;
804
                    }
816
                    }
805
                    if(row.quantity_received == '0') {
817
                    if (row.quantity_received == "0") {
806
                        warnings.push(SAVE_WARNING_NO_ITEMS.format(row.order_id));
818
                        warnings.push(SAVE_WARNING_NO_ITEMS.format(row.order_id));
807
                    }
819
                    }
808
                })
820
                });
809
                return warnings;
821
                return warnings;
810
            }
822
            };
811
823
812
            $('#modal_messages .modal-footer .cancel').on('click', function() {
824
            $("#modal_messages .modal-footer .cancel").on("click", function () {
813
                $('#modal_messages .modal-footer .accept').off('click');
825
                $("#modal_messages .modal-footer .accept").off("click");
814
                $('#modal_messages').modal('hide');
826
                $("#modal_messages").modal("hide");
815
            })
827
            });
816
            $('.save').click(function() {
828
            $(".save").click(function () {
817
                var data = $("#order_edit").data();
829
                var data = $("#order_edit").data();
818
                var rows = api.rows().data().toArray();
830
                var rows = api.rows().data().toArray();
819
                var redirect = true;
831
                var redirect = true;
820
                var warnings = get_warnings(rows);
832
                var warnings = get_warnings(rows);
821
                if(warnings.length) {
833
                if (warnings.length) {
822
                    $('#modal_messages .modal-header h1').html(SAVE_WARNING_TITLE);
834
                    $("#modal_messages .modal-header h1").html(SAVE_WARNING_TITLE);
823
                    $('#modal_messages .modal-body ul').html('');
835
                    $("#modal_messages .modal-body ul").html("");
824
                    warnings.forEach(function(warning) {
836
                    warnings.forEach(function (warning) {
825
                        $('#modal_messages .modal-body ul').append('<li>'+warning+'</li>');
837
                        $("#modal_messages .modal-body ul").append("<li>" + warning + "</li>");
826
                    });
838
                    });
827
                    $('#modal_messages .modal-footer .cancel').show();
839
                    $("#modal_messages .modal-footer .cancel").show();
828
                    $('#modal_messages .modal-footer .accept').html(_("Continue"));
840
                    $("#modal_messages .modal-footer .accept").html(_("Continue"));
829
                    $('#modal_messages .modal-footer .accept').one('click', function() {
841
                    $("#modal_messages .modal-footer .accept").one("click", function () {
830
                        $('#modal_messages').modal('hide');
842
                        $("#modal_messages").modal("hide");
831
                        save_rows(rows, data);
843
                        save_rows(rows, data);
832
                    });
844
                    });
833
                    $('#modal_messages').modal('show');
845
                    $("#modal_messages").modal("show");
834
                } else {
846
                } else {
835
                    save_rows(rows, data);
847
                    save_rows(rows, data);
836
                }
848
                }
837
            });
849
            });
838
850
839
851
            $("#order_edit").on("change", "#reason", function () {
840
            $("#order_edit").on("change", "#reason", function() {
841
                var val = $(this).val();
852
                var val = $(this).val();
842
                var row = $("#order_edit").data('row');
853
                var row = $("#order_edit").data("row");
843
                if(val == 'other') {
854
                if (val == "other") {
844
                    $("#other_reason").show();
855
                    $("#other_reason").show();
845
                    $(this).hide();
856
                    $(this).hide();
846
                } else {
857
                } else {
Lines 848-953 Link Here
848
                }
859
                }
849
            });
860
            });
850
861
851
            $("#order_edit").on("change", "#select-other_reason", function() {
862
            $("#order_edit").on("change", "#select-other_reason", function () {
852
                var val = $(this).val();
863
                var val = $(this).val();
853
                var row = $("#order_edit").data('row');
864
                var row = $("#order_edit").data("row");
854
                row.biblio.suggestions[0].reason = val;
865
                row.biblio.suggestions[0].reason = val;
855
            });
866
            });
856
867
857
            $("#order_edit").on("click", "#other_reason a", function() {
868
            $("#order_edit").on("click", "#other_reason a", function () {
858
                $("#other_reason").hide();
869
                $("#other_reason").hide();
859
                $("#reason").val(null).show();
870
                $("#reason").val(null).show();
860
            });
871
            });
861
872
862
            $("#order_edit").on("change", "#datereceived", function() {
873
            $("#order_edit").on("change", "#datereceived", function () {
863
                var val = $(this).val();
874
                var val = $(this).val();
864
                var row = $("#order_edit").data('row');
875
                var row = $("#order_edit").data("row");
865
                row.date_received = val;
876
                row.date_received = val;
866
            });
877
            });
867
878
868
            $("#order_edit").on("change", "#bookfund", function() {
879
            $("#order_edit").on("change", "#bookfund", function () {
869
                var val = $(this).val();
880
                var val = $(this).val();
870
                var row = $("#order_edit").data('row');
881
                var row = $("#order_edit").data("row");
871
                row.fund_id = val;
882
                row.fund_id = val;
872
            });
883
            });
873
884
874
            $("#order_edit").on("change", "#quantity_to_receive", function() {
885
            $("#order_edit").on("change", "#quantity_to_receive", function () {
875
                var val = $(this).val();
886
                var val = $(this).val();
876
                var row = $("#order_edit").data('row');
887
                var row = $("#order_edit").data("row");
877
                row.quantity = val;
888
                row.quantity = val;
878
                if(row.subscription_id) {
889
                if (row.subscription_id) {
879
                    $("#quantity").val(val).change();
890
                    $("#quantity").val(val).change();
880
                }
891
                }
881
            });
892
            });
882
893
883
            $("#order_edit").on("change", "#quantity", function() {
894
            $("#order_edit").on("change", "#quantity", function () {
884
                var val = $(this).val();
895
                var val = $(this).val();
885
                var row = $("#order_edit").data('row');
896
                var row = $("#order_edit").data("row");
886
                row.quantity_received = val;
897
                row.quantity_received = val;
887
                var qtyto = parseInt($("#quantity_to_receive").val());
898
                var qtyto = parseInt($("#quantity_to_receive").val());
888
                if(parseInt(val) > qtyto) {
899
                if (parseInt(val) > qtyto) {
889
                    $("#qtyrecerror").show();
900
                    $("#qtyrecerror").show();
890
                } else {
901
                } else {
891
                    $("#qtyrecerror").hide();
902
                    $("#qtyrecerror").hide();
892
                }
903
                }
893
                $("input[name='items_to_receive']").each(function() {
904
                $("input[name='items_to_receive']").each(function () {
894
                    $(this).prop('checked', false).change();
905
                    $(this).prop("checked", false).change();
895
                });
906
                });
896
                $("input[name='items_to_receive']:lt("+val+")").each(function () {
907
                $("input[name='items_to_receive']:lt(" + val + ")").each(function () {
897
                    $(this).prop('checked', true).change();
908
                    $(this).prop("checked", true).change();
898
                });
909
                });
899
            });
910
            });
900
911
901
            $("#order_edit").on("change", "input[name='items_to_receive']", function() {
912
            $("#order_edit").on("change", "input[name='items_to_receive']", function () {
902
                var qty = $("input[name='items_to_receive']:checked").length;
913
                var qty = $("input[name='items_to_receive']:checked").length;
903
                $("#quantity").val(qty);
914
                $("#quantity").val(qty);
904
                var row = $("#order_edit").data('row');
915
                var row = $("#order_edit").data("row");
905
                row.quantity_received = qty;
916
                row.quantity_received = qty;
906
                if (only_one_order){
917
                if (only_one_order) {
907
                    $('.modal-save').prop('disabled', qty < 1 );
918
                    $(".modal-save").prop("disabled", qty < 1);
908
                }
919
                }
909
            })
920
            });
910
921
911
            $("#order_edit").on("change", "#tax_rate", function() {
922
            $("#order_edit").on("change", "#tax_rate", function () {
912
                var val = $(this).val();
923
                var val = $(this).val();
913
                if(val === null) $(this).val($('option:first-child', this).attr('value'));
924
                if (val === null) $(this).val($("option:first-child", this).attr("value"));
914
                val = $(this).val();
925
                val = $(this).val();
915
                var row = $("#order_edit").data('row');
926
                var row = $("#order_edit").data("row");
916
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
927
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
917
                if(effective_create_items == 'receiving') {
928
                if (effective_create_items == "receiving") {
918
                    row.tax_rate_on_receiving = val;
929
                    row.tax_rate_on_receiving = val;
919
                } else {
930
                } else {
920
                    row.tax_rate_on_ordering = val;
931
                    row.tax_rate_on_ordering = val;
921
                }
932
                }
922
923
            });
933
            });
924
934
925
            $("#order_edit").on("change", "#unitprice", function() {
935
            $("#order_edit").on("change", "#unitprice", function () {
926
                var val = $(this).val();
936
                var val = $(this).val();
927
                var row = $("#order_edit").data('row');
937
                var row = $("#order_edit").data("row");
928
                if(invoiceincgst == "1") {
938
                if (invoiceincgst == "1") {
929
                    row.unit_price_tax_included = val;
939
                    row.unit_price_tax_included = val;
930
                } else {
940
                } else {
931
                    row.unit_price_tax_excluded = val;
941
                    row.unit_price_tax_excluded = val;
932
                }
942
                }
933
934
            });
943
            });
935
944
936
            function _update_unitprice() {
945
            function _update_unitprice() {
937
                let row = $("#order_edit").data('row');
946
                let row = $("#order_edit").data("row");
938
947
939
                let unitprice = $("#unitprice").val();
948
                let unitprice = $("#unitprice").val();
940
                let invoice_currency = $("#invoice_currency").val();
949
                let invoice_currency = $("#invoice_currency").val();
941
                let invoice_unitprice = $("#invoice_unitprice").val();
950
                let invoice_unitprice = $("#invoice_unitprice").val();
942
                let change_currency = $("#change_currency").is(":checked");
951
                let change_currency = $("#change_currency").is(":checked");
943
952
944
                if ( change_currency ) {
953
                if (change_currency) {
945
                    $("#select_currency").show();
954
                    $("#select_currency").show();
946
                    if(!$("#invoice_unitprice").val()){
955
                    if (!$("#invoice_unitprice").val()) {
947
                        invoice_unitprice = unitprice;
956
                        invoice_unitprice = unitprice;
948
                    }
957
                    }
949
                    var rate = Number($("#invoice_currency option:selected").data('rate'));
958
                    var rate = Number($("#invoice_currency option:selected").data("rate"));
950
                    unitprice = Number( invoice_unitprice * rate ).toFixed(2);
959
                    unitprice = Number(invoice_unitprice * rate).toFixed(2);
951
                    $("#unitprice").prop("readonly", "true");
960
                    $("#unitprice").prop("readonly", "true");
952
                } else {
961
                } else {
953
                    $("#select_currency").hide();
962
                    $("#select_currency").hide();
Lines 963-1170 Link Here
963
                row.invoice_currency = invoice_currency;
972
                row.invoice_currency = invoice_currency;
964
                row.invoice_unit_price = invoice_unitprice;
973
                row.invoice_unit_price = invoice_unitprice;
965
            }
974
            }
966
            $("#order_edit").on("change", "#invoice_currency",  _update_unitprice );
975
            $("#order_edit").on("change", "#invoice_currency", _update_unitprice);
967
            $("#order_edit").on("change", "#invoice_unitprice", _update_unitprice );
976
            $("#order_edit").on("change", "#invoice_unitprice", _update_unitprice);
968
            $("#order_edit").on("change", "#change_currency",   _update_unitprice );
977
            $("#order_edit").on("change", "#change_currency", _update_unitprice);
969
978
970
            $("#order_edit").on("change", "#replacementprice", function() {
979
            $("#order_edit").on("change", "#replacementprice", function () {
971
                var val = $(this).val();
980
                var val = $(this).val();
972
                var row = $("#order_edit").data('row');
981
                var row = $("#order_edit").data("row");
973
                row.replacement_price = val;
982
                row.replacement_price = val;
974
            });
983
            });
975
984
976
            $("#order_edit").on("change", "#order_internalnote", function() {
985
            $("#order_edit").on("change", "#order_internalnote", function () {
977
                var val = $(this).val();
986
                var val = $(this).val();
978
                var row = $("#order_edit").data('row');
987
                var row = $("#order_edit").data("row");
979
                row.internal_note = val;
988
                row.internal_note = val;
980
981
            });
989
            });
982
990
983
            var keep_row = function() {
991
            var keep_row = function () {
984
                var row = $("#order_edit").data('row');
992
                var row = $("#order_edit").data("row");
985
                var kept = $("#order_edit").data('kept')||{};
993
                var kept = $("#order_edit").data("kept") || {};
986
                if($('#items_list tbody tr').length) {
994
                if ($("#items_list tbody tr").length) {
987
                    row.items = [];
995
                    row.items = [];
988
                    $('#items_list tbody tr').each(function() {
996
                    $("#items_list tbody tr").each(function () {
989
                        var item = {};
997
                        var item = {};
990
                        $('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() {
998
                        $("#" + $(this).attr("idblock"))
991
                            var kf = $(this).val();
999
                            .find("*[name=kohafield]")
992
                            var obj = {};
1000
                            .each(function () {
993
                            $(this).parent().find('*[name]').each(function() {
1001
                                var kf = $(this).val();
994
                                obj[$(this).prop('name')] = $(this).val();
1002
                                var obj = {};
1003
                                $(this)
1004
                                    .parent()
1005
                                    .find("*[name]")
1006
                                    .each(function () {
1007
                                        obj[$(this).prop("name")] = $(this).val();
1008
                                    });
1009
                                item[kf] = obj;
995
                            });
1010
                            });
996
                            item[kf] = obj;
997
                        });
998
                        row.items.push(item);
1011
                        row.items.push(item);
999
                    });
1012
                    });
1000
                }
1013
                }
1001
                kept[row.order_id] = row;
1014
                kept[row.order_id] = row;
1002
                $("#order_edit").data('kept', kept);
1015
                $("#order_edit").data("kept", kept);
1003
            };
1016
            };
1004
1017
1005
            var save_row = function() {
1018
            var save_row = function () {
1006
                keep_row();
1019
                keep_row();
1007
                var saved = $("#order_edit").data('saved')||{};
1020
                var saved = $("#order_edit").data("saved") || {};
1008
                var kept = $("#order_edit").data('kept');
1021
                var kept = $("#order_edit").data("kept");
1009
                var saved_rows = $.extend(saved, kept);
1022
                var saved_rows = $.extend(saved, kept);
1010
                $("#order_edit").data('saved', saved_rows);
1023
                $("#order_edit").data("saved", saved_rows);
1011
                api.draw();
1024
                api.draw();
1012
                return saved_rows;
1025
                return saved_rows;
1013
            }
1026
            };
1014
1027
1015
            var set_modal_buttons = function() {
1028
            var set_modal_buttons = function () {
1016
                var n = $("#order_edit").data('n');
1029
                var n = $("#order_edit").data("n");
1017
                var info = api.page.info();
1030
                var info = api.page.info();
1018
1031
1019
                $('.modal-prev').prop('disabled', info.page == 0 && n == 0);
1032
                $(".modal-prev").prop("disabled", info.page == 0 && n == 0);
1020
                $('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n);
1033
                $(".modal-next").prop("disabled", info.pages - 1 == info.page && info.end - info.start - 1 == n);
1021
            };
1034
            };
1022
1035
1023
            var show_subs = function(row) {
1036
            var show_subs = function (row) {
1024
                //$("#child_orders").show();
1037
                //$("#child_orders").show();
1025
                var had_rows = false;
1038
                var had_rows = false;
1026
                var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}};
1039
                var base_query = { subscription_id: row.subscription_id, parent_order_id: row.order_id, order_id: { "!=": row.order_id } };
1027
                var pending_orders_url = "/api/v1/acquisitions/orders";
1040
                var pending_orders_url = "/api/v1/acquisitions/orders";
1028
                var options = {
1041
                var options = {
1029
                    ajax: {
1042
                    ajax: {
1030
                        "url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query))
1043
                        url: pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query)),
1031
                    },
1044
                    },
1032
                    embed: [
1045
                    embed: ["invoice", "basket"],
1033
                        "invoice",
1046
                    order: [[1, "asc"]],
1034
                        "basket"
1035
                    ],
1036
                    order: [[1, 'asc']],
1037
                    dom: 'C<"top pager"ilpfB>tr<"bottom pager"ip>',
1047
                    dom: 'C<"top pager"ilpfB>tr<"bottom pager"ip>',
1038
                    columns: [
1048
                    columns: [
1039
                        {
1049
                        {
1040
                            searchable: false,
1050
                            searchable: false,
1041
                            orderable: false,
1051
                            orderable: false,
1042
                            data: function(row, type, val, meta) {
1052
                            data: function (row, type, val, meta) {
1043
                                if(row.invoice) {
1053
                                if (row.invoice) {
1044
                                    if(permissions.CAN_user_acquisition) {
1054
                                    if (permissions.CAN_user_acquisition) {
1045
                                        return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>";
1055
                                        return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=' + row.invoice_id + '" title="Invoice detail page">' + row.invoice.invoice_number + "</a>";
1046
                                    }
1056
                                    }
1047
                                    return row.invoice.invoice_number;
1057
                                    return row.invoice.invoice_number;
1048
                                }
1058
                                }
1049
                            }
1059
                            },
1050
                        },
1060
                        },
1051
                        {
1061
                        {
1052
                            data: "order_id",
1062
                            data: "order_id",
1053
                            searchable: false,
1063
                            searchable: false,
1054
                            orderable: false
1064
                            orderable: false,
1055
                        },
1065
                        },
1056
                        {
1066
                        {
1057
                            searchable: false,
1067
                            searchable: false,
1058
                            orderable: false,
1068
                            orderable: false,
1059
                            data: "basket.creation_date",
1069
                            data: "basket.creation_date",
1060
                            render: function(data, type, row, meta) {
1070
                            render: function (data, type, row, meta) {
1061
                                return $date(row.basket.creation_date);
1071
                                return $date(row.basket.creation_date);
1062
                            }
1072
                            },
1063
                        },
1073
                        },
1064
                        {
1074
                        {
1065
                            searchable: false,
1075
                            searchable: false,
1066
                            orderable: false,
1076
                            orderable: false,
1067
                            data: function(row, type, val, meta) {
1077
                            data: function (row, type, val, meta) {
1068
                                return $date(row.date_received);
1078
                                return $date(row.date_received);
1069
                            }
1079
                            },
1070
                        },
1080
                        },
1071
                        {
1081
                        {
1072
                            searchable: false,
1082
                            searchable: false,
1073
                            orderable: false,
1083
                            orderable: false,
1074
                            data: function(row, type, val, meta) {
1084
                            data: function (row, type, val, meta) {
1075
                                return row.quantity_received;
1085
                                return row.quantity_received;
1076
                            }
1086
                            },
1077
                        },
1087
                        },
1078
                        {
1088
                        {
1079
                            searchable: false,
1089
                            searchable: false,
1080
                            orderable: true,
1090
                            orderable: true,
1081
                            data: function(row, type, val, meta) {
1091
                            data: function (row, type, val, meta) {
1082
                                if(!row.status) return;
1092
                                if (!row.status) return;
1083
                                var first_letter = row.status[0].toUpperCase();
1093
                                var first_letter = row.status[0].toUpperCase();
1084
                                return first_letter+row.status.substr(1).toLowerCase();
1094
                                return first_letter + row.status.substr(1).toLowerCase();
1085
                            }
1095
                            },
1086
                        },
1096
                        },
1087
                        {
1097
                        {
1088
                            searchable: false,
1098
                            searchable: false,
1089
                            orderable: false,
1099
                            orderable: false,
1090
                            data: function(row, type, val, meta) {
1100
                            data: function (row, type, val, meta) {
1091
                                if(!row.date_received) return;
1101
                                if (!row.date_received) return;
1092
                                return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price()
1102
                                return Number(row.unit_price_tax_excluded * row.quantity_received).format_price() + " / " + Number(row.unit_price_tax_included * row.quantity_received).format_price();
1093
                            }
1103
                            },
1094
                        },
1104
                        },
1095
                        {
1105
                        {
1096
                            searchable: false,
1106
                            searchable: false,
1097
                            orderable: false,
1107
                            orderable: false,
1098
                            data: function(row, type, val, meta) {
1108
                            data: function (row, type, val, meta) {
1099
                                return row.internal_note;
1109
                                return row.internal_note;
1100
                            }
1110
                            },
1101
                        }
1111
                        },
1102
                    ]
1112
                    ],
1103
                };
1113
                };
1104
                var child_orders_table = $("#child_orders_table").api(options);
1114
                var child_orders_table = $("#child_orders_table").api(options);
1105
                var child_api = child_orders_table.api();
1115
                var child_api = child_orders_table.api();
1106
                child_api.on('preDraw', function() {
1116
                child_api.on("preDraw", function () {
1107
                    if(!child_api.data().length && !had_rows) return;
1117
                    if (!child_api.data().length && !had_rows) return;
1108
                    $("#history-panel").show();
1118
                    $("#history-panel").show();
1109
                    had_rows = true;
1119
                    had_rows = true;
1110
                });
1120
                });
1111
            };
1121
            };
1112
1122
1113
            var set_editor = function() {
1123
            var set_editor = function () {
1114
                var modal = $("#order_edit");
1124
                var modal = $("#order_edit");
1115
                var row = modal.data('row');
1125
                var row = modal.data("row");
1116
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
1126
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
1117
                var origrec = $("#order_edit").data('origrec')||{};
1127
                var origrec = $("#order_edit").data("origrec") || {};
1118
                if(!origrec.hasOwnProperty(row.order_id)) {
1128
                if (!origrec.hasOwnProperty(row.order_id)) {
1119
                    origrec[row.order_id] = row.quantity_received;
1129
                    origrec[row.order_id] = row.quantity_received;
1120
                    $("#order_edit").data('origrec', origrec);
1130
                    $("#order_edit").data("origrec", origrec);
1121
                }
1131
                }
1122
                if(row.subscription_id || ( row.basket.standing === true && effective_create_items == 'cataloguing') ) {
1132
                if (row.subscription_id || (row.basket.standing === true && effective_create_items == "cataloguing")) {
1123
                    row.quantity_received = row.quantity;
1133
                    row.quantity_received = row.quantity;
1124
                }
1134
                }
1125
                var keep = $("#order_edit").data('kept');
1135
                var keep = $("#order_edit").data("kept");
1126
                if(keep && keep[row.order_id]) {
1136
                if (keep && keep[row.order_id]) {
1127
                    row = keep[row.order_id];
1137
                    row = keep[row.order_id];
1128
                    modal.data('row', row);
1138
                    modal.data("row", row);
1129
                }
1139
                }
1130
                $('input, select, textarea', '.modal-body').val(null)
1140
                $("input, select, textarea", ".modal-body").val(null);
1131
                modal.find(".modal-title").text(MOD_TITLE.format(escape_str(row.order_id),escape_str(row.biblio.title)));
1141
                modal.find(".modal-title").text(MOD_TITLE.format(escape_str(row.order_id), escape_str(row.biblio.title)));
1132
                ["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){
1142
                ["title", "author", "copyright_date", "isbn", "series_title"].forEach(function (key) {
1133
                    var o = modal.find(".modal-body #biblio_"+key);
1143
                    var o = modal.find(".modal-body #biblio_" + key);
1134
                    if(row.biblio[key] !== null) {
1144
                    if (row.biblio[key] !== null) {
1135
                        o.parent().show();
1145
                        o.parent().show();
1136
                        o.html(row.biblio[key]);
1146
                        o.html(row.biblio[key]);
1137
                    } else {
1147
                    } else {
1138
                        o.parent().hide();
1148
                        o.parent().hide();
1139
                    }
1149
                    }
1140
                });
1150
                });
1141
                if(row.biblio.suggestions.length) {
1151
                if (row.biblio.suggestions.length) {
1142
                    $("#suggestion_fieldset").show();
1152
                    $("#suggestion_fieldset").show();
1143
                    if(row.biblio.suggestions[0].suggester) {
1153
                    if (row.biblio.suggestions[0].suggester) {
1144
                        $("#biblio_suggestion_suggester").parent().show();
1154
                        $("#biblio_suggestion_suggester").parent().show();
1145
                        $("#biblio_suggestion_suggester")
1155
                        $("#biblio_suggestion_suggester").html(
1146
                            .html(
1156
                            [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1147
                                [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1157
                                .filter(function (name) {
1148
                                    .filter(function(name){
1158
                                    return name;
1149
                                        return name
1159
                                })
1150
                                    })
1160
                                .join(", ") +
1151
                                    .join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestion_id+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestion_id)+'</a>)'
1161
                                ' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' +
1152
                            );
1162
                                row.biblio.suggestions[0].suggestion_id +
1163
                                '&op=show">' +
1164
                                SUGGESTION.format(row.biblio.suggestions[0].suggestion_id) +
1165
                                "</a>)"
1166
                        );
1153
                    } else {
1167
                    } else {
1154
                        $("#biblio_suggestion_suggester").parent().hide();
1168
                        $("#biblio_suggestion_suggester").parent().hide();
1155
                    }
1169
                    }
1156
                    if(row.biblio.suggestions[0].reason) {
1170
                    if (row.biblio.suggestions[0].reason) {
1157
                        $("#suggestion_reason").show();
1171
                        $("#suggestion_reason").show();
1158
                        const options = Array.from(document.querySelectorAll('#reason option'));
1172
                        const options = Array.from(document.querySelectorAll("#reason option"));
1159
                        if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
1173
                        if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
1160
                             $("#other_reason a").click();
1174
                            $("#other_reason a").click();
1161
                            $("#reason").val(row.biblio.suggestions[0].reason);
1175
                            $("#reason").val(row.biblio.suggestions[0].reason);
1162
                            $("#select-other_reason").val(null);
1176
                            $("#select-other_reason").val(null);
1163
                        } else {
1177
                        } else {
1164
                            $("#reason").val("other").change();
1178
                            $("#reason").val("other").change();
1165
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1179
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1166
                        }
1180
                        }
1167
1168
                    } else {
1181
                    } else {
1169
                        $("#suggestion_reason").hide();
1182
                        $("#suggestion_reason").hide();
1170
                    }
1183
                    }
Lines 1173-1218 Link Here
1173
                }
1186
                }
1174
1187
1175
                // set today if no date_received in row
1188
                // set today if no date_received in row
1176
                document.querySelector("#datereceived")._flatpickr.setDate(row.date_received||new Date());
1189
                document.querySelector("#datereceived")._flatpickr.setDate(row.date_received || new Date());
1177
1190
1178
                // restore the full tree
1191
                // restore the full tree
1179
                $("#bookfund").html($funds_tree);
1192
                $("#bookfund").html($funds_tree);
1180
                $("#selected_bookfund")
1193
                $("#selected_bookfund").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name)).attr("data-sort1-authcat", row.fund.sort1_authcat).attr("data-sort2-authcat", row.fund.sort2_authcat);
1181
                    .html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name))
1182
                    .attr( 'data-sort1-authcat', row.fund.sort1_authcat )
1183
                    .attr( 'data-sort2-authcat', row.fund.sort2_authcat );
1184
                if (row.fund_id != row.fund.fund_id) {
1194
                if (row.fund_id != row.fund.fund_id) {
1185
                    $("#bookfund").val(row.fund_id);
1195
                    $("#bookfund").val(row.fund_id);
1186
                }
1196
                }
1187
                $("#bookfund").select2({ width: '50%', dropdownParent: $('#order_edit') });
1197
                $("#bookfund").select2({ width: "50%", dropdownParent: $("#order_edit") });
1188
                $("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name));
1198
                $("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name));
1189
                if( row.creator ) {
1199
                if (row.creator) {
1190
                    $("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')')
1200
                    $("#creator").html(
1201
                        [row.creator.surname, row.creator.firstname]
1202
                            .filter(function (name) {
1203
                                return name;
1204
                            })
1205
                            .join(", ") +
1206
                            " (" +
1207
                            row.creator.patron_id +
1208
                            ")"
1209
                    );
1191
                } else {
1210
                } else {
1192
                    $("#creator").html(_("Account has been deleted"));
1211
                    $("#creator").html(_("Account has been deleted"));
1193
                }
1212
                }
1194
                $("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id);
1213
                $("#quantity_to_receive").val(row.quantity).prop("readonly", !row.subscription_id);
1195
                if (effective_create_items == 'cataloguing' && ! row.quantity_received) {
1214
                if (effective_create_items == "cataloguing" && !row.quantity_received) {
1196
                    row.quantity_received = 1;
1215
                    row.quantity_received = 1;
1197
                }
1216
                }
1198
                $("#quantity").val( row.quantity_received )
1217
                $("#quantity")
1199
                              .prop('readonly', !row.subscription_id && effective_create_items == 'receiving');
1218
                    .val(row.quantity_received)
1200
                if (only_one_order){
1219
                    .prop("readonly", !row.subscription_id && effective_create_items == "receiving");
1201
                    $(".modal-save").prop('disabled', $("#quantity").val() == 0);
1220
                if (only_one_order) {
1221
                    $(".modal-save").prop("disabled", $("#quantity").val() == 0);
1202
                }
1222
                }
1203
                $('#qtyrecerror').hide();
1223
                $("#qtyrecerror").hide();
1204
                var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering;
1224
                var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering;
1205
                $("#tax_rate").val(tax_rate).change();
1225
                $("#tax_rate").val(tax_rate).change();
1206
                var rrp_txt;
1226
                var rrp_txt;
1207
                var ecost_txt;
1227
                var ecost_txt;
1208
                if(invoiceincgst == "1") {
1228
                if (invoiceincgst == "1") {
1209
                    rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint"> '+ADJ_TAX_INC.format(active_currency)+"</span>";
1229
                    rrp_txt = Number(row.rrp_tax_included).format_price() + '<span class="hint"> ' + ADJ_TAX_INC.format(active_currency) + "</span>";
1210
                    ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint"> '+TAX_INC+"</span>";
1230
                    ecost_txt = Number(row.ecost_tax_included).format_price() + '<span class="hint"> ' + TAX_INC + "</span>";
1211
                    $("#unitprice").val(row.unit_price_tax_included > 0 ? Number(row.unit_price_tax_included).format_price() : Number(row.ecost_tax_included).format_price());
1231
                    $("#unitprice").val(row.unit_price_tax_included > 0 ? Number(row.unit_price_tax_included).format_price() : Number(row.ecost_tax_included).format_price());
1212
                    $("#unitprice_hint").html(TAX_INC);
1232
                    $("#unitprice_hint").html(TAX_INC);
1213
                } else {
1233
                } else {
1214
                    rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint"> '+ADJ_TAX_EXC.format(active_currency)+"</span>";
1234
                    rrp_txt = Number(row.rrp_tax_excluded).format_price() + '<span class="hint"> ' + ADJ_TAX_EXC.format(active_currency) + "</span>";
1215
                    ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint"> '+TAX_EXC+"</span>";
1235
                    ecost_txt = Number(row.ecost_tax_excluded).format_price() + '<span class="hint"> ' + TAX_EXC + "</span>";
1216
                    $("#unitprice").val(row.unit_price_tax_excluded > 0 ? Number(row.unit_price_tax_excluded).format_price() : Number(row.ecost_tax_excluded).format_price());
1236
                    $("#unitprice").val(row.unit_price_tax_excluded > 0 ? Number(row.unit_price_tax_excluded).format_price() : Number(row.ecost_tax_excluded).format_price());
1217
                    $("#unitprice_hint").html(TAX_EXC);
1237
                    $("#unitprice_hint").html(TAX_EXC);
1218
                }
1238
                }
Lines 1220-1379 Link Here
1220
                $("#replacementprice").val(row.replacement_price);
1240
                $("#replacementprice").val(row.replacement_price);
1221
                $("#ecost").html(ecost_txt);
1241
                $("#ecost").html(ecost_txt);
1222
                $("#order_internalnote").val(row.internal_note);
1242
                $("#order_internalnote").val(row.internal_note);
1223
                if(row.vendor_note) {
1243
                if (row.vendor_note) {
1224
                    $("#order_vendornote").html(row.vendor_note);
1244
                    $("#order_vendornote").html(row.vendor_note);
1225
                    $("#order_vendornote").parent().show();
1245
                    $("#order_vendornote").parent().show();
1226
                } else {
1246
                } else {
1227
                    $("#order_vendornote").parent().hide();
1247
                    $("#order_vendornote").parent().hide();
1228
                }
1248
                }
1229
1249
1230
1231
                $("#history-panel").hide();
1250
                $("#history-panel").hide();
1232
1251
1233
                $('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove();
1252
                $("#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr").remove();
1234
                $('#items_list').hide();
1253
                $("#items_list").hide();
1235
                if(row.subscription_id) {
1254
                if (row.subscription_id) {
1236
                    $('#modal-order-main #items-panel').removeClass('show').addClass('hide');
1255
                    $("#modal-order-main #items-panel").removeClass("show").addClass("hide");
1237
                    $('#modal-order-main #history-panel').removeClass('hide').addClass('show');
1256
                    $("#modal-order-main #history-panel").removeClass("hide").addClass("show");
1238
                } else {
1257
                } else {
1239
                    $('#modal-order-main #history-panel').removeClass('show').addClass('hide');
1258
                    $("#modal-order-main #history-panel").removeClass("show").addClass("hide");
1240
                    $('#modal-order-main #items-panel').removeClass('hide').addClass('show');
1259
                    $("#modal-order-main #items-panel").removeClass("hide").addClass("show");
1241
                    if(effective_create_items == 'receiving') {
1260
                    if (effective_create_items == "receiving") {
1242
                        $("#acq-create-receiving").show();
1261
                        $("#acq-create-receiving").show();
1243
                        $("#acq-create-ordering").hide();
1262
                        $("#acq-create-ordering").hide();
1244
                        if(row.items && row.items.length) {
1263
                        if (row.items && row.items.length) {
1245
                            row.items.forEach(function(item, index) {
1264
                            row.items.forEach(function (item, index) {
1246
                                cloneItemBlock(index, prefs.UniqueItemFields, function(block_id) {
1265
                                cloneItemBlock(index, prefs.UniqueItemFields, function (block_id) {
1247
                                    var block = $('#'+block_id).hide();
1266
                                    var block = $("#" + block_id).hide();
1248
                                    Object.keys(item).forEach(function(key) {
1267
                                    Object.keys(item).forEach(function (key) {
1249
                                        block
1268
                                        block
1250
                                            .find('*[name=kohafield][value="'+key+'"]')
1269
                                            .find('*[name=kohafield][value="' + key + '"]')
1251
                                            .parent()
1270
                                            .parent()
1252
                                            .find('*[name=field_value]')
1271
                                            .find("*[name=field_value]")
1253
                                            .val(item[key].field_value);
1272
                                            .val(item[key].field_value);
1254
                                    });
1273
                                    });
1255
                                    addItemInList(block_id, prefs.UniqueItemFields);
1274
                                    addItemInList(block_id, prefs.UniqueItemFields);
1256
                                    block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) );
1275
                                    block.find("input[name='buttonPlus']").val(window.MSG_ADDITEM_JS_UPDATEITEM);
1257
                                    block.find("input[name='buttonPlusMulti']").remove();
1276
                                    block.find("input[name='buttonPlusMulti']").remove();
1258
                                    block.find("input[name='multiValue']").remove();
1277
                                    block.find("input[name='multiValue']").remove();
1259
                                });
1278
                                });
1260
                            });
1279
                            });
1261
                        }
1280
                        }
1262
                        cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields);
1281
                        cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields);
1263
                    } else if (effective_create_items == 'ordering') {
1282
                    } else if (effective_create_items == "ordering") {
1264
                        $("#acq-create-receiving").hide();
1283
                        $("#acq-create-receiving").hide();
1265
                        $("#acq-create-ordering").show();
1284
                        $("#acq-create-ordering").show();
1266
                        if(row.items.length) {
1285
                        if (row.items.length) {
1267
                            $("#acq-create-ordering tbody").append(
1286
                            $("#acq-create-ordering tbody").append(
1268
                                row.items.map(function(item) {
1287
                                row.items.map(function (item) {
1269
                                    var tr = $('<tr id="item_'+item.item_id+'"/>');
1288
                                    var tr = $('<tr id="item_' + item.item_id + '"/>');
1270
                                    _build_item(item, tr);
1289
                                    _build_item(item, tr);
1271
                                    return tr;
1290
                                    return tr;
1272
                                })
1291
                                })
1273
                            );
1292
                            );
1274
                        }
1293
                        }
1275
                    } else {
1294
                    } else {
1276
                        $('#modal-order-main #items-panel').removeClass('show').addClass('hide');
1295
                        $("#modal-order-main #items-panel").removeClass("show").addClass("hide");
1277
                    }
1296
                    }
1278
                }
1297
                }
1279
                if(row.invoice_currency && row.invoice_currency != active_currency) {
1298
                if (row.invoice_currency && row.invoice_currency != active_currency) {
1280
                    $("#select_currency").show();
1299
                    $("#select_currency").show();
1281
                    $("#unitprice").prop("readonly", true);
1300
                    $("#unitprice").prop("readonly", true);
1282
                    $("#change_currency").prop('checked', true);
1301
                    $("#change_currency").prop("checked", true);
1283
                    $("#invoice_currency").val(row.invoice_currency);
1302
                    $("#invoice_currency").val(row.invoice_currency);
1284
                    $("#invoice_unitprice").val(row.invoice_unit_price);
1303
                    $("#invoice_unitprice").val(row.invoice_unit_price);
1285
                } else {
1304
                } else {
1286
                    $("#select_currency").hide();
1305
                    $("#select_currency").hide();
1287
                    $("#unitprice").prop("readonly", "");
1306
                    $("#unitprice").prop("readonly", "");
1288
                    $("#change_currency").prop('checked', false);
1307
                    $("#change_currency").prop("checked", false);
1289
                    $("#invoice_currency").val(active_currency);
1308
                    $("#invoice_currency").val(active_currency);
1290
                    $("#invoice_unitprice").val('');
1309
                    $("#invoice_unitprice").val("");
1291
                }
1310
                }
1292
1311
1293
                disabledBudgetsCopy = $('#bookfund').html();
1312
                disabledBudgetsCopy = $("#bookfund").html();
1294
                $('#bookfund .inactive_budget').remove();
1313
                $("#bookfund .inactive_budget").remove();
1295
1314
1296
                $('#showallbudgets').click(function() {
1315
                $("#showallbudgets").click(function () {
1297
                    if ($(this).is(":checked")) {
1316
                    if ($(this).is(":checked")) {
1298
                        $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
1317
                        $("#bookfund").html(disabledBudgetsCopy); //Puts back all the funds
1299
                    }
1318
                    } else {
1300
                    else {
1319
                        $("#bookfund .inactive_budget").remove();
1301
                        $('#bookfund .inactive_budget').remove();
1302
                    }
1320
                    }
1303
                });
1321
                });
1304
                set_modal_buttons();
1322
                set_modal_buttons();
1305
            };
1323
            };
1306
1324
1307
            $('.modal-prev').click(function() {
1325
            $(".modal-prev").click(function () {
1308
                var modal = $("#order_edit");
1326
                var modal = $("#order_edit");
1309
                keep_row();
1327
                keep_row();
1310
                var n = modal.data('n');
1328
                var n = modal.data("n");
1311
                if(n > 0) {
1329
                if (n > 0) {
1312
                    n--;
1330
                    n--;
1313
                    modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1331
                    modal.data("row", JSON.parse(JSON.stringify(api.row(n).data())));
1314
                    modal.data('n', n);
1332
                    modal.data("n", n);
1315
                    set_editor();
1333
                    set_editor();
1316
                } else {
1334
                } else {
1317
                    $('.modal-next, .modal-prev').prop('disabled', true);
1335
                    $(".modal-next, .modal-prev").prop("disabled", true);
1318
                    orders_table.one('draw.dt', function() {
1336
                    orders_table.one("draw.dt", function () {
1319
                        var info = api.page.info();
1337
                        var info = api.page.info();
1320
                        n = info.end - info.start - 1;
1338
                        n = info.end - info.start - 1;
1321
                        modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1339
                        modal.data("row", JSON.parse(JSON.stringify(api.row(n).data())));
1322
                        modal.data('n', n);
1340
                        modal.data("n", n);
1323
                        set_editor();
1341
                        set_editor();
1324
                    });
1342
                    });
1325
                    api.page('previous').draw( 'page' );
1343
                    api.page("previous").draw("page");
1326
                }
1344
                }
1327
            });
1345
            });
1328
1346
1329
            $('.modal-next').click(function() {
1347
            $(".modal-next").click(function () {
1330
                var modal = $("#order_edit");
1348
                var modal = $("#order_edit");
1331
                keep_row();
1349
                keep_row();
1332
                var n = modal.data('n');
1350
                var n = modal.data("n");
1333
                var info = api.page.info();
1351
                var info = api.page.info();
1334
                if(n < info.end - info.start - 1) {
1352
                if (n < info.end - info.start - 1) {
1335
                    n++;
1353
                    n++;
1336
                    modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1354
                    modal.data("row", JSON.parse(JSON.stringify(api.row(n).data())));
1337
                    modal.data('n', n);
1355
                    modal.data("n", n);
1338
                    set_editor();
1356
                    set_editor();
1339
                } else {
1357
                } else {
1340
                    $('.modal-next, .modal-prev').prop('disabled', true);
1358
                    $(".modal-next, .modal-prev").prop("disabled", true);
1341
                    orders_table.one('draw.dt', function() {
1359
                    orders_table.one("draw.dt", function () {
1342
                        var info = api.page.info();
1360
                        var info = api.page.info();
1343
                        n = 0;
1361
                        n = 0;
1344
                        modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1362
                        modal.data("row", JSON.parse(JSON.stringify(api.row(n).data())));
1345
                        modal.data('n', n);
1363
                        modal.data("n", n);
1346
                        set_editor();
1364
                        set_editor();
1347
                    });
1365
                    });
1348
                    api.page('next').draw( 'page' );
1366
                    api.page("next").draw("page");
1349
                }
1367
                }
1350
            });
1368
            });
1351
1369
1352
            $('.modal-save').click(function() {
1370
            $(".modal-save").click(function () {
1353
1354
                //We need to validate the item forms here - if one is opened with missing subfields at
1371
                //We need to validate the item forms here - if one is opened with missing subfields at
1355
                //confirm, it would be submitted without this
1372
                //confirm, it would be submitted without this
1356
                var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
1373
                var _alertString = _("Form not submitted because of the following problem(s)") + "\n";
1357
                _alertString +="-------------------------------------------------------------------\n\n";
1374
                _alertString += "-------------------------------------------------------------------\n\n";
1358
                var empty_mandatory_fields = 0;
1375
                var empty_mandatory_fields = 0;
1359
                $('div[id^="itemblock"]').each(function(){
1376
                $('div[id^="itemblock"]').each(function () {
1360
                    var item_form = $(this);
1377
                    var item_form = $(this);
1361
                    var empty_item_mandatory = CheckMandatorySubfields(item_form);
1378
                    var empty_item_mandatory = CheckMandatorySubfields(item_form);
1362
                    empty_mandatory_fields += empty_item_mandatory;
1379
                    empty_mandatory_fields += empty_item_mandatory;
1363
                });
1380
                });
1364
                if (empty_mandatory_fields > 0) {
1381
                if (empty_mandatory_fields > 0) {
1365
                    _alertString +="\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields);
1382
                    _alertString += "\n- " + _("%s item mandatory fields empty").format(empty_mandatory_fields);
1366
                    alert(_alertString);
1383
                    alert(_alertString);
1367
                    return false;
1384
                    return false;
1368
                }
1385
                }
1369
1386
1370
                var saved_rows = save_row();
1387
                var saved_rows = save_row();
1371
                if(Object.keys(saved_rows).length) $('.save').prop('disabled', false);
1388
                if (Object.keys(saved_rows).length) $(".save").prop("disabled", false);
1372
                $("#order_edit").modal('hide');
1389
                $("#order_edit").modal("hide");
1373
                if (only_one_order){
1390
                if (only_one_order) {
1374
                    $(".save").click();
1391
                    $(".save").click();
1375
                }
1392
                }
1376
            })
1393
            });
1377
1394
1378
            $("#order_edit").on("show.bs.modal", function (event) {
1395
            $("#order_edit").on("show.bs.modal", function (event) {
1379
                var anchor = $(event.relatedTarget);
1396
                var anchor = $(event.relatedTarget);
Lines 1381-1395 Link Here
1381
                var row = api.row(n).data();
1398
                var row = api.row(n).data();
1382
1399
1383
                var modal = $(this);
1400
                var modal = $(this);
1384
                modal.data('row', JSON.parse(JSON.stringify(row)));
1401
                modal.data("row", JSON.parse(JSON.stringify(row)));
1385
                modal.data('n', n);
1402
                modal.data("n", n);
1386
                modal.data('keep', modal.data('saved')||{});
1403
                modal.data("keep", modal.data("saved") || {});
1387
                //$('#modal-order-main').tabs("option", "active", 0);
1404
                //$('#modal-order-main').tabs("option", "active", 0);
1388
                set_editor();
1405
                set_editor();
1389
            });
1406
            });
1390
1407
1391
            $("#order_edit").on("hide.bs.modal", function() {
1408
            $("#order_edit").on("hide.bs.modal", function () {
1392
                $("#child_orders_table").DataTable().off('preDraw').destroy();
1409
                $("#child_orders_table").DataTable().off("preDraw").destroy();
1393
            });
1410
            });
1394
        });
1411
        });
1395
    </script>
1412
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-1 lines)
Lines 374-380 Link Here
374
            order: "[%tp("noun", "Order") | html %]",
374
            order: "[%tp("noun", "Order") | html %]",
375
        };
375
        };
376
    </script>
376
    </script>
377
378
    <script>
377
    <script>
379
        dt_overwrite_html_sorting_localeCompare();
378
        dt_overwrite_html_sorting_localeCompare();
380
        var PENDING_MULTI_SELECTION = _("Receive selected (%s)");
379
        var PENDING_MULTI_SELECTION = _("Receive selected (%s)");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt (-53 / +64 lines)
Lines 213-275 Link Here
213
    <script>
213
    <script>
214
        const vendor_id = [% vendor.id | html %];
214
        const vendor_id = [% vendor.id | html %];
215
    </script>
215
    </script>
216
217
    <script>
216
    <script>
218
        $(document).ready(function() {
217
        $(document).ready(function () {
219
            var issues_table_url = `/api/v1/acquisitions/vendors/${vendor_id}/issues?`;
218
            var issues_table_url = `/api/v1/acquisitions/vendors/${vendor_id}/issues?`;
220
219
221
            var issues_table = $("#vendor_issues").kohaTable({
220
            var issues_table = $("#vendor_issues").kohaTable(
222
                ajax: {
221
                {
223
                    url: issues_table_url
222
                    ajax: {
224
                },
223
                        url: issues_table_url,
225
                embed: ["+strings"],
226
                order: [[ 0, "desc" ]],
227
                columns: [
228
                    {
229
                        data: "issue_id",
230
                        searchable: true,
231
                        orderable: true,
232
                        render: function(data, type, row, meta) {
233
                            return '<a href="/cgi-bin/koha/acqui/vendor_issues.pl?op=show&amp;issue_id=' + encodeURIComponent(row.issue_id) +'">' + escape_str(row.issue_id) + '</a>';
234
                        },
235
                    },
236
                    {
237
                        data: "type",
238
                        searchable: true,
239
                        orderable: true,
240
                        render: function(data, type, row, meta) {
241
                            return row._strings.type ? escape_str(row._strings.type.str) : "";
242
                        }
243
                    },
224
                    },
244
                    {
225
                    embed: ["+strings"],
245
                        data: "started_on",
226
                    order: [[0, "desc"]],
246
                        searchable: true,
227
                    columns: [
247
                        orderable: true,
228
                        {
248
                        render: function(data, type, row, meta) {
229
                            data: "issue_id",
249
                            return $date(row.started_on);
230
                            searchable: true,
250
                        }
231
                            orderable: true,
251
                    },
232
                            render: function (data, type, row, meta) {
252
                    {
233
                                return '<a href="/cgi-bin/koha/acqui/vendor_issues.pl?op=show&amp;issue_id=' + encodeURIComponent(row.issue_id) + '">' + escape_str(row.issue_id) + "</a>";
253
                        data: "ended_on",
234
                            },
254
                        searchable: true,
255
                        orderable: true,
256
                        render: function(data, type, row, meta) {
257
                            return $date(row.ended_on);
258
                        }
259
                    },
260
                    {
261
                        data: function( row, type, val, meta ) {
262
263
                            var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_issues.pl?op=add_form&amp;issue_id='+ encodeURIComponent(row.issue_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
264
                            result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_issues.pl?op=delete_confirm&amp;issue_id='+ encodeURIComponent(row.issue_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
265
                            return result;
266
                        },
235
                        },
267
                        searchable: false,
236
                        {
268
                        orderable: false
237
                            data: "type",
269
                    }
238
                            searchable: true,
270
                ]
239
                            orderable: true,
271
            }, null, 1);
240
                            render: function (data, type, row, meta) {
272
241
                                return row._strings.type ? escape_str(row._strings.type.str) : "";
242
                            },
243
                        },
244
                        {
245
                            data: "started_on",
246
                            searchable: true,
247
                            orderable: true,
248
                            render: function (data, type, row, meta) {
249
                                return $date(row.started_on);
250
                            },
251
                        },
252
                        {
253
                            data: "ended_on",
254
                            searchable: true,
255
                            orderable: true,
256
                            render: function (data, type, row, meta) {
257
                                return $date(row.ended_on);
258
                            },
259
                        },
260
                        {
261
                            data: function (row, type, val, meta) {
262
                                var result =
263
                                    '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_issues.pl?op=add_form&amp;issue_id=' +
264
                                    encodeURIComponent(row.issue_id) +
265
                                    '"><i class="fa fa-pencil" aria-hidden="true"></i> ' +
266
                                    _("Edit") +
267
                                    "</a>" +
268
                                    "\n";
269
                                result +=
270
                                    '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/vendor_issues.pl?op=delete_confirm&amp;issue_id=' +
271
                                    encodeURIComponent(row.issue_id) +
272
                                    '"><i class="fa fa-trash" aria-hidden="true"></i> ' +
273
                                    _("Delete") +
274
                                    "</a>";
275
                                return result;
276
                            },
277
                            searchable: false,
278
                            orderable: false,
279
                        },
280
                    ],
281
                },
282
                null,
283
                1
284
            );
273
        });
285
        });
274
    </script>
286
    </script>
275
[% END %]
287
[% END %]
276
- 

Return to bug 41563