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

(-)a/acqui/parcel.pl (-2 / +20 lines)
Lines 74-81 use Koha::Biblios; Link Here
74
74
75
use JSON;
75
use JSON;
76
76
77
my $input=CGI->new;
77
my $input = CGI->new;
78
my $sticky_filters = $input->param('sticky_filters') || 0;
79
78
80
my ($template, $loggedinuser, $cookie)
79
my ($template, $loggedinuser, $cookie)
81
    = get_template_and_user({template_name => "acqui/parcel.tt",
80
    = get_template_and_user({template_name => "acqui/parcel.tt",
Lines 110-115 unless( $invoiceid and $invoice->{invoiceid} ) { Link Here
110
    exit;
109
    exit;
111
}
110
}
112
111
112
my $sticky_filters = $input->param('sticky_filters') || 0;
113
114
if ($sticky_filters) {
115
    my $search          = $input->cookie("filter_parcel_summary");
116
    my $ean             = $input->cookie("filter_parcel_ean");
117
    my $basketname      = $input->cookie("filter_parcel_basketname");
118
    my $orderno         = $input->cookie("filter_parcel_orderno");
119
    my $basketgroupname = $input->cookie("filter_parcel_basketgroupname");
120
121
    $template->param(
122
        summaryfilter         => $search,
123
        eanfilter             => $ean,
124
        basketfilter          => $basketname,
125
        orderfilter           => $orderno,
126
        basketgroupnamefilter => $basketgroupname,
127
    );
128
}
129
130
113
my $booksellerid = $invoice->{booksellerid};
131
my $booksellerid = $invoice->{booksellerid};
114
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
132
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
115
133
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-47 / +71 lines)
Lines 372-377 Link Here
372
        dt_overwrite_html_sorting_localeCompare();
372
        dt_overwrite_html_sorting_localeCompare();
373
        var sticky_filters = [% sticky_filters | html %];
373
        var sticky_filters = [% sticky_filters | html %];
374
374
375
        function query_from_filters( base_query, params ) {
376
377
            var query_and = [];
378
379
            if ( params.basket_name != "" ) {
380
                query_and.push( { "basket.name": { "like": '%'+params.basket_name+'%' } } );
381
            }
382
            if (params.basket_group != "") {
383
                query_and.push( { "basket.basket_group.name": { "like": '%'+params.basket_group+'%' } } );
384
            }
385
            if (params.summary != "") {
386
                query_and.push( { "-or": [{"biblio.title":  { "like": '%'+params.summary+'%' } },
387
                            {"biblio.author": { "like": '%'+params.summary+'%' } },
388
                            {"biblio.isbn":   { "like": '%'+params.summary+'%' } } ] } );
389
            }
390
            if (params.ean != "") {
391
                query_and.push( { "biblio.ean": params.ean } );
392
            }
393
394
            var query_params = [];
395
396
            if ( query_and.length > 0 ) {
397
                query_and.push(base_query);
398
                query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and })));
399
            }
400
401
            if ( params.order_id != "" ) {
402
                query_params.push("order_id="+params.order_id);
403
            }
404
405
            return query_params;
406
        }
407
375
        $(document).ready(function(){
408
        $(document).ready(function(){
376
409
377
            if ( $("#receivedt").length ) {
410
            if ( $("#receivedt").length ) {
Lines 403-412 Link Here
403
            }
436
            }
404
437
405
            var base_query = { "basket.vendor_id": [% booksellerid | html %]  };
438
            var base_query = { "basket.vendor_id": [% booksellerid | html %]  };
439
440
            var summary      = $("#summaryfilter").val();
441
            var basket_name  = $("#basketfilter").val();
442
            var basket_group = $("#basketgroupnamefilter").val();
443
            var order_id     = $("#orderfilter").val();
444
            var ean          = $("#eanfilter").val();
445
446
            var query_params = query_from_filters(
447
                base_query,
448
                {
449
                    "summary": summary,
450
                    "basket_name": basket_name,
451
                    "basket_group": basket_group,
452
                    "order_id": order_id,
453
                    "ean": (ean === undefined) ? '' : ean // ean == undefined if the DOM doens't have it
454
                }
455
            );
456
457
            var THE_query = query_params.join("&");
458
406
            var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
459
            var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
407
            var pending_orders_table = $("#pending_orders").api({
460
            var pending_orders_table = $("#pending_orders").api({
408
                "ajax": {
461
                "ajax": {
409
                    "url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))
462
                    "url": pending_orders_url + '&' + THE_query
410
                },
463
                },
411
                "header_filter": true,
464
                "header_filter": true,
412
                "embed": [
465
                "embed": [
Lines 688-732 Link Here
688
741
689
            $("#filterform").on("submit", function(e) {
742
            $("#filterform").on("submit", function(e) {
690
                e.preventDefault();
743
                e.preventDefault();
691
                // Update the datatable URL
744
692
                var summary      = $("#summaryfilter").val();
745
                var summary      = $("#summaryfilter").val();
693
                var basket_name  = $("#basketfilter").val();
746
                var basket_name  = $("#basketfilter").val();
694
                var basket_group = $("#basketgroupnamefilter").val();
747
                var basket_group = $("#basketgroupnamefilter").val();
695
                var order_id     = $("#orderfilter").val();
748
                var order_id     = $("#orderfilter").val();
696
                var ean          = $("#eanfilter").val();
749
                var ean          = $("#eanfilter").val();
697
750
698
                var query_and = [];
751
                // Save the filters in the cookie
699
752
                $.cookie("filter_parcel_summary", summary);
700
                if (basket_name != "") {
753
                $.cookie("filter_parcel_basketname", basket_name);
701
                    query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } );
754
                $.cookie("filter_parcel_orderno", basket_group);
702
                }
755
                $.cookie("filter_parcel_basketgroupname", order_id);
703
                if (basket_group != "") {
756
                $.cookie("filter_parcel_ean", ean);
704
                    query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } );
705
                }
706
                if (summary != "") {
707
                    query_and.push( { "-or": [{"biblio.title":  { "like": '%'+summary+'%' } },
708
                                {"biblio.author": { "like": '%'+summary+'%' } },
709
                                {"biblio.isbn":   { "like": '%'+summary+'%' } } ] } );
710
                }
711
            [% IF (UNIMARC) %]
712
                if (ean != "") {
713
                    query_and.push( { "biblio.ean": ean } );
714
                }
715
            [% END %]
716
717
                if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) {
718
719
                    var query_params = [];
720
721
                    if ( order_id != "" ) {
722
                        query_params.push("order_id="+order_id);
723
                    }
724
757
725
                    if ( !jQuery.isEmptyObject(query_and) ) {
758
                var query_params = query_from_filters(
726
                        query_and.push(base_query);
759
                    base_query,
727
                        query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and })));
760
                    {
761
                        "summary": summary,
762
                        "basket_name": basket_name,
763
                        "basket_group": basket_group,
764
                        "order_id": order_id,
765
                        "ean": (ean === undefined) ? '' : ean // ean == undefined if the HTML doens't have it
728
                    }
766
                    }
767
                );
729
768
769
                if ( query_params.length > 0 ) {
730
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
770
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
731
                }
771
                }
732
                else {
772
                else {
Lines 740-760 Link Here
740
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
780
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
741
            });
781
            });
742
782
743
            // Keep filters from finishreceive.pl to parcel.pl
744
            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
745
            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
746
            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
747
            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
748
            $.cookie("filter_parcel_ean", $("#eanfilter").val());
749
750
            $("#filterform").on('submit', function(){
751
                $.cookie("filter_parcel_summary", $("#summaryfilter").val());
752
                $.cookie("filter_parcel_basketname", $("#basketfilter").val());
753
                $.cookie("filter_parcel_orderno", $("#orderfilter").val());
754
                $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
755
                $.cookie("filter_parcel_ean", $("#eanfilter").val());
756
            });
757
758
            $(".previewData").on("click", function(e){
783
            $(".previewData").on("click", function(e){
759
                e.preventDefault();
784
                e.preventDefault();
760
                var ltitle = $(this).text();
785
                var ltitle = $(this).text();
761
- 

Return to bug 20212