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

(-)a/acqui/orderreceive.pl (-10 / +9 lines)
Lines 166-181 unless ($acq_fw) { Link Here
166
my @gst_values = map { option => $_ + 0.0 }, split( '\|', C4::Context->preference("TaxRates") );
166
my @gst_values = map { option => $_ + 0.0 }, split( '\|', C4::Context->preference("TaxRates") );
167
167
168
$template->param(
168
$template->param(
169
    freight          => $freight,
169
    freight         => $freight,
170
    name             => $bookseller->name,
170
    name            => $bookseller->name,
171
    active_currency  => $active_currency,
171
    active_currency => $active_currency,
172
    currencies       => $currencies->search( { rate => { '!=' => 1 } } ),
172
    currencies      => $currencies->search( { rate => { '!=' => 1 } } ),
173
    invoiceincgst    => $bookseller->invoiceincgst,
173
    invoiceincgst   => $bookseller->invoiceincgst,
174
    invoiceid        => $invoice->{invoiceid},
174
    invoiceid       => $invoice->{invoiceid},
175
    invoice          => $invoice->{invoicenumber},
175
    invoice         => $invoice->{invoicenumber},
176
    gst_values       => \@gst_values,
176
    gst_values      => \@gst_values,
177
    vendor           => $bookseller,
177
    vendor          => $bookseller,
178
    UniqueItemFields => C4::Context->preference('UniqueItemFields'),
179
);
178
);
180
179
181
my $patron = Koha::Patrons->find($loggedinuser)->unblessed;
180
my $patron = Koha::Patrons->find($loggedinuser)->unblessed;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-31 / +39 lines)
Lines 453-458 Link Here
453
    [% INCLUDE 'datatables.inc' %]
453
    [% INCLUDE 'datatables.inc' %]
454
    [% INCLUDE 'js-date-format.inc' %]
454
    [% INCLUDE 'js-date-format.inc' %]
455
    [% INCLUDE 'format_price.inc' %]
455
    [% INCLUDE 'format_price.inc' %]
456
    <script>
457
        var edit_mode = "[% edit | html %]";
458
        var invoiceincgst = "[% invoiceincgst | html %]";
459
        var active_currency = "[% active_currency.currency | html %]";
460
        var invoice_id = "[% invoiceid | html %]";
461
        const multiple_orders = "[% multiple_orders | html %]";
462
        const only_one_order = [% only_one_order ? 1 : 0 | html %];
463
        addPrefs({
464
            AcqCreateItem: [% Koha.Preference('AcqCreateItem') ? 1 : 0 | html %],
465
            UniqueItemFields: [% Koha.Preference('UniqueItemFields') ? 1 : 0 | html %],
466
        });
467
        addPermissions({
468
            CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %],
469
        });
470
    </script>
471
456
    <script>
472
    <script>
457
        function display_string(key, strings, fallback) {
473
        function display_string(key, strings, fallback) {
458
            if ( strings.hasOwnProperty(key) ) {
474
            if ( strings.hasOwnProperty(key) ) {
Lines 538-555 Link Here
538
        var SAVE_WARNING_TITLE = _("Warning");
554
        var SAVE_WARNING_TITLE = _("Warning");
539
        var SAVE_ERROR_TITLE = _("Error");
555
        var SAVE_ERROR_TITLE = _("Error");
540
556
541
542
        var CAN_user_acquisition = "[% CAN_user_acquisition | html %]";
543
        var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]";
544
        var edit_mode = "[% edit | html %]";
545
        var invoiceincgst = "[% invoiceincgst | html %]";
546
        var active_currency = "[% active_currency.currency | html %]";
547
        var invoice_id = "[% invoiceid | html %]";
548
549
        $(document).ready(function(){
557
        $(document).ready(function(){
550
            // keep a copy for re-rendering
558
            // keep a copy for re-rendering
551
            var $funds_tree = $('#bookfund').html();
559
            var $funds_tree = $('#bookfund').html();
552
            var base_query = { "order_id": {"-in": [[% multiple_orders | html %]]}};
560
            var base_query = { "order_id": {"-in": multiple_orders.split(',')}};
553
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
561
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
554
            var options = {
562
            var options = {
555
                ajax: {
563
                ajax: {
Lines 640-650 Link Here
640
                        }
648
                        }
641
                    }
649
                    }
642
                ],
650
                ],
643
                [% IF only_one_order %]
651
                ...(only_one_order?
652
                    {
644
                    drawCallback: function( settings ) {
653
                    drawCallback: function( settings ) {
645
                        $("#order_edit").modal("show");
654
                        $("#order_edit").modal("show");
646
                    },
655
                    },
647
                [% END %]
656
                    } : {}),
648
            };
657
            };
649
            var orders_table = $("#multiple_orders").kohaTable(options);
658
            var orders_table = $("#multiple_orders").kohaTable(options);
650
            var api = orders_table.api();
659
            var api = orders_table.api();
Lines 669-679 Link Here
669
                }
678
                }
670
            });
679
            });
671
680
672
            [% IF only_one_order %]
681
            if (only_one_order){
673
            $("#quantity").on('change', function() {
682
                $("#quantity").on('change', function() {
674
                $('.modal-save').prop('disabled', $(this).val() < 1 );
683
                    $('.modal-save').prop('disabled', $(this).val() < 1 );
675
            });
684
                });
676
            [% END %]
685
            }
677
686
678
            var _doSave = function(params) {
687
            var _doSave = function(params) {
679
                params.data.csrf_token = $('meta[name="csrf-token"]').attr('content');
688
                params.data.csrf_token = $('meta[name="csrf-token"]').attr('content');
Lines 705-711 Link Here
705
                params['quantity'] = row.quantity;
714
                params['quantity'] = row.quantity;
706
                params['quantityrec'] = row.quantity_received;
715
                params['quantityrec'] = row.quantity_received;
707
                params['origquantityrec'] = origrec;
716
                params['origquantityrec'] = origrec;
708
                var effective_create_items = row.basket.create_items || AcqCreateItem;
717
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
709
                params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering;
718
                params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering;
710
                params['replacementprice'] = row.replacement_price;
719
                params['replacementprice'] = row.replacement_price;
711
                params['unitprice'] = ( invoiceincgst=="1" ) ? ( row.unit_price_tax_included || row.ecost_tax_included ) : ( row.unit_price_tax_excluded || row.ecost_tax_excluded );
720
                params['unitprice'] = ( invoiceincgst=="1" ) ? ( row.unit_price_tax_included || row.ecost_tax_included ) : ( row.unit_price_tax_excluded || row.ecost_tax_excluded );
Lines 894-902 Link Here
894
                $("#quantity").val(qty);
903
                $("#quantity").val(qty);
895
                var row = $("#order_edit").data('row');
904
                var row = $("#order_edit").data('row');
896
                row.quantity_received = qty;
905
                row.quantity_received = qty;
897
            [% IF only_one_order %]
906
                if (only_one_order){
898
                $('.modal-save').prop('disabled', qty < 1 );
907
                    $('.modal-save').prop('disabled', qty < 1 );
899
            [% END %]
908
                }
900
            })
909
            })
901
910
902
            $("#order_edit").on("change", "#tax_rate", function() {
911
            $("#order_edit").on("change", "#tax_rate", function() {
Lines 904-910 Link Here
904
                if(val === null) $(this).val($('option:first-child', this).attr('value'));
913
                if(val === null) $(this).val($('option:first-child', this).attr('value'));
905
                val = $(this).val();
914
                val = $(this).val();
906
                var row = $("#order_edit").data('row');
915
                var row = $("#order_edit").data('row');
907
                var effective_create_items = row.basket.create_items || AcqCreateItem;
916
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
908
                if(effective_create_items == 'receiving') {
917
                if(effective_create_items == 'receiving') {
909
                    row.tax_rate_on_receiving = val;
918
                    row.tax_rate_on_receiving = val;
910
                } else {
919
                } else {
Lines 1032-1038 Link Here
1032
                            orderable: false,
1041
                            orderable: false,
1033
                            data: function(row, type, val, meta) {
1042
                            data: function(row, type, val, meta) {
1034
                                if(row.invoice) {
1043
                                if(row.invoice) {
1035
                                    if(CAN_user_acquisition) {
1044
                                    if(permissions.CAN_user_acquisition) {
1036
                                        return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>";
1045
                                        return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>";
1037
                                    }
1046
                                    }
1038
                                    return row.invoice.invoice_number;
1047
                                    return row.invoice.invoice_number;
Lines 1104-1110 Link Here
1104
            var set_editor = function() {
1113
            var set_editor = function() {
1105
                var modal = $("#order_edit");
1114
                var modal = $("#order_edit");
1106
                var row = modal.data('row');
1115
                var row = modal.data('row');
1107
                var effective_create_items = row.basket.create_items || AcqCreateItem;
1116
                var effective_create_items = row.basket.create_items || prefs.AcqCreateItem;
1108
                var origrec = $("#order_edit").data('origrec')||{};
1117
                var origrec = $("#order_edit").data('origrec')||{};
1109
                if(!origrec.hasOwnProperty(row.order_id)) {
1118
                if(!origrec.hasOwnProperty(row.order_id)) {
1110
                    origrec[row.order_id] = row.quantity_received;
1119
                    origrec[row.order_id] = row.quantity_received;
Lines 1188-1196 Link Here
1188
                }
1197
                }
1189
                $("#quantity").val( row.quantity_received )
1198
                $("#quantity").val( row.quantity_received )
1190
                              .prop('readonly', !row.subscription_id && effective_create_items == 'receiving');
1199
                              .prop('readonly', !row.subscription_id && effective_create_items == 'receiving');
1191
                [% IF only_one_order %]
1200
                if (only_one_order){
1192
                    $(".modal-save").prop('disabled', $("#quantity").val() == 0);
1201
                    $(".modal-save").prop('disabled', $("#quantity").val() == 0);
1193
                [% END %]
1202
                }
1194
                $('#qtyrecerror').hide();
1203
                $('#qtyrecerror').hide();
1195
                var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering;
1204
                var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering;
1196
                $("#tax_rate").val(tax_rate).change();
1205
                $("#tax_rate").val(tax_rate).change();
Lines 1234-1240 Link Here
1234
                        $("#acq-create-ordering").hide();
1243
                        $("#acq-create-ordering").hide();
1235
                        if(row.items && row.items.length) {
1244
                        if(row.items && row.items.length) {
1236
                            row.items.forEach(function(item, index) {
1245
                            row.items.forEach(function(item, index) {
1237
                                cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) {
1246
                                cloneItemBlock(index, prefs.UniqueItemFields, function(block_id) {
1238
                                    var block = $('#'+block_id).hide();
1247
                                    var block = $('#'+block_id).hide();
1239
                                    Object.keys(item).forEach(function(key) {
1248
                                    Object.keys(item).forEach(function(key) {
1240
                                        block
1249
                                        block
Lines 1243-1256 Link Here
1243
                                            .find('*[name=field_value]')
1252
                                            .find('*[name=field_value]')
1244
                                            .val(item[key].field_value);
1253
                                            .val(item[key].field_value);
1245
                                    });
1254
                                    });
1246
                                    addItemInList(block_id, '[% UniqueItemFields | html %]');
1255
                                    addItemInList(block_id, prefs.UniqueItemFields);
1247
                                    block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) );
1256
                                    block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) );
1248
                                    block.find("input[name='buttonPlusMulti']").remove();
1257
                                    block.find("input[name='buttonPlusMulti']").remove();
1249
                                    block.find("input[name='multiValue']").remove();
1258
                                    block.find("input[name='multiValue']").remove();
1250
                                });
1259
                                });
1251
                            });
1260
                            });
1252
                        }
1261
                        }
1253
                        cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]');
1262
                        cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields);
1254
                    } else if (effective_create_items == 'ordering') {
1263
                    } else if (effective_create_items == 'ordering') {
1255
                        $("#acq-create-receiving").hide();
1264
                        $("#acq-create-receiving").hide();
1256
                        $("#acq-create-ordering").show();
1265
                        $("#acq-create-ordering").show();
Lines 1361-1369 Link Here
1361
                var saved_rows = save_row();
1370
                var saved_rows = save_row();
1362
                if(Object.keys(saved_rows).length) $('.save').prop('disabled', false);
1371
                if(Object.keys(saved_rows).length) $('.save').prop('disabled', false);
1363
                $("#order_edit").modal('hide');
1372
                $("#order_edit").modal('hide');
1364
                [% IF only_one_order %]
1373
                if (only_one_order){
1365
                    $(".save").click();
1374
                    $(".save").click();
1366
                [% END %]
1375
                }
1367
            })
1376
            })
1368
1377
1369
            $("#order_edit").on("show.bs.modal", function (event) {
1378
            $("#order_edit").on("show.bs.modal", function (event) {
1370
- 

Return to bug 41563