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

(-)a/Koha/REST/V1/Acquisitions/Orders.pm (-12 / +8 lines)
Lines 143-161 sub list { Link Here
143
143
144
        # Perform search
144
        # Perform search
145
        my $orders = $orders_rs->search( $filtered_params, $attributes );
145
        my $orders = $orders_rs->search( $filtered_params, $attributes );
146
        my $total  = $orders_rs->search->count;
146
147
147
        if ($orders->is_paged) {
148
        $c->add_pagination_headers(
148
            $c->add_pagination_headers({
149
            {
149
                total => $orders->pager->total_entries,
150
                total      => ($orders->is_paged ? $orders->pager->total_entries : $orders->count),
150
                params => $args,
151
                base_total => $total,
151
            });
152
                params     => $args,
152
        }
153
            }
153
        else {
154
        );
154
            $c->add_pagination_headers({
155
                total => $orders->count,
156
                params => $args,
157
            });
158
        }
159
155
160
        return $c->render(
156
        return $c->render(
161
            status  => 200,
157
            status  => 200,
(-)a/acqui/finishreceive.pl (-1 / +1 lines)
Lines 190-193 if ($suggestion_id) { Link Here
190
    $suggestion->update( { reason => $reason } ) if $suggestion;
190
    $suggestion->update( { reason => $reason } ) if $suggestion;
191
}
191
}
192
192
193
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&sticky_filters=1");
193
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
(-)a/acqui/parcel.pl (-20 lines)
Lines 109-133 unless( $invoiceid and $invoice->{invoiceid} ) { Link Here
109
    exit;
109
    exit;
110
}
110
}
111
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
131
my $booksellerid = $invoice->{booksellerid};
112
my $booksellerid = $invoice->{booksellerid};
132
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
113
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
133
114
Lines 211-216 $template->param( Link Here
211
    total_tax_excluded    => $total_tax_excluded,
192
    total_tax_excluded    => $total_tax_excluded,
212
    total_tax_included    => $total_tax_included,
193
    total_tax_included    => $total_tax_included,
213
    subtotal_for_funds    => $subtotal_for_funds,
194
    subtotal_for_funds    => $subtotal_for_funds,
214
    sticky_filters        => $sticky_filters,
215
);
195
);
216
output_html_with_http_headers $input, $cookie, $template->output;
196
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-1 / +1 lines)
Lines 370-376 Link Here
370
</div>
370
</div>
371
</div><div class="row"><fieldset class="action">
371
</div><div class="row"><fieldset class="action">
372
        <input type="submit"  value="Save" class="button" accesskey="w" />
372
        <input type="submit"  value="Save" class="button" accesskey="w" />
373
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Cancel</a>
373
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a>
374
</fieldset></div>    </form>
374
</fieldset></div>    </form>
375
[% ELSE %]
375
[% ELSE %]
376
    This ordernumber does not exist.
376
    This ordernumber does not exist.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-228 / +23 lines)
Lines 105-113 Link Here
105
                    <th>Basket</th>
105
                    <th>Basket</th>
106
                    <th>Basket group</th>
106
                    <th>Basket group</th>
107
                    <th>Order line</th>
107
                    <th>Order line</th>
108
                    <th class="hidden">Title</th>
109
                    <th class="hidden">Author</th>
110
                    <th class="hidden">ISBN</th>
111
                    <th>Summary</th>
108
                    <th>Summary</th>
112
                    <th>More</th>
109
                    <th>More</th>
113
                    <th>Replacement price</th>
110
                    <th>Replacement price</th>
Lines 118-141 Link Here
118
                    <th>&nbsp;</th>
115
                    <th>&nbsp;</th>
119
                    <th>&nbsp;</th>
116
                    <th>&nbsp;</th>
120
                </tr>
117
                </tr>
121
                <tr>
122
                    <th><div class="input-group input-group-sm"><input id="basket_name_column_search" type="text" class="form-control column-filter" data-search-fields='["basket.name"]'></div></th>
123
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["basket.basket_group.name"]'></div></th>
124
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.order_id"]'></div></th>
125
                    <th class="hidden">&nbsp;</th>
126
                    <th class="hidden">&nbsp;</th>
127
                    <th class="hidden">&nbsp;</th>
128
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.internal_note","me.vendor_note","biblio.title","biblio.author","biblio.isbn","biblio.publisher","biblio.publication_year","biblio.copyright_date","biblio.suggestions.suggester.surname","biblio.suggestions.suggester.firstname"]'></div></th>
129
                    <th>&nbsp;</th>
130
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.replacement_price"]'></div></th>
131
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.quantity"]'></div></th>
132
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.ecost"]'></div></th>
133
                    <th>&nbsp;</th>
134
                    <!--th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["order_cost"]'></div></th-->
135
                    <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["fund.name"]'></div></th>
136
                    <th>&nbsp;</th>
137
                    <th>&nbsp;</th>
138
                </tr>
139
            </thead>
118
            </thead>
140
        </table>
119
        </table>
141
    </div>
120
    </div>
Lines 340-380 Link Here
340
<div class="col-sm-2 col-sm-pull-10">
319
<div class="col-sm-2 col-sm-pull-10">
341
<aside>
320
<aside>
342
321
343
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
344
  <fieldset class="brief">
345
    <h4>Filter</h4>
346
    <ol>
347
      <li>
348
        <label for="summaryfilter">ISBN, author or title:</label>
349
        <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter | html %]"/>
350
      </li>
351
      <li>
352
        <label for="basketfilter">Basket name:</label>
353
        <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter | html %]"/>
354
      </li>
355
      <li>
356
          <label for="basketgroupnamefilter">Basket group name:</label>
357
          <input type="text" name="basketgroupnamefilter" id="basketgroupnamefilter" value="[% basketgroupnamefilter | html %]" />
358
      </li>
359
      <li>
360
        <label for="orderfilter">Order line:</label>
361
        <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter | html %]"/>
362
      </li>
363
      [% IF (UNIMARC) %]
364
        <li>
365
          <label for="eanfilter">EAN:</label>
366
          <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter | html %]"/>
367
        </li>
368
      [% END %]
369
    </ol>
370
    <fieldset class="action">
371
      <input type="hidden" value="search" name="op" />
372
      <input type="hidden" value="[% invoiceid | html %]" name="invoiceid" />
373
      <input type="submit" value="Filter" />
374
      <a href="#" id="clear_form_filters">Clear</a>
375
    </fieldset>
376
  </fieldset>
377
</form>
378
[% INCLUDE 'acquisitions-menu.inc' %]
322
[% INCLUDE 'acquisitions-menu.inc' %]
379
    </aside>
323
    </aside>
380
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
324
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
Lines 388-473 Link Here
388
    <style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
332
    <style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
389
    <script>
333
    <script>
390
        dt_overwrite_html_sorting_localeCompare();
334
        dt_overwrite_html_sorting_localeCompare();
391
        var sticky_filters = [% sticky_filters | html %];
392
        var columns_filter = {};
335
        var columns_filter = {};
393
336
394
        function query_from_filters( base_query ) {
395
396
            var query_and = [];
397
398
            var summary      = $("#summaryfilter").val();
399
            var basket_group = $("#basketgroupnamefilter").val();
400
            var basket_name  = $("#basketfilter").val();
401
            var order_id     = $("#orderfilter").val();
402
            var ean          = $("#eanfilter").val();
403
404
            // ean == undefined if the HTML doesn't have it
405
            ean = (ean === undefined) ? '' : ean;
406
407
            if ( basket_name != "" ) {
408
                query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } );
409
            }
410
            if (basket_group != "") {
411
                query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } );
412
            }
413
            if (summary != "") {
414
                query_and.push( { "-or": [{"biblio.title":  { "like": '%'+summary+'%' } },
415
                            {"biblio.author": { "like": '%'+summary+'%' } },
416
                            {"biblio.isbn":   { "like": '%'+summary+'%' } } ] } );
417
            }
418
            if (ean != "") {
419
                query_and.push( { "biblio.ean": ean } );
420
            }
421
422
            $(".column-filter").each(function () {
423
                var search_fields = $(this).data('search-fields');
424
                var value = this.value;
425
426
                if ( value != '' &&
427
                     value != undefined ) { // skip if empty
428
429
                    var columns_filters = [];
430
431
                    search_fields.forEach( function (item) {
432
                        if ( item === "me.order_id" ||
433
                             item === "me.replacement_price" ||
434
                             item === "me.quantity" ||
435
                             item === "me.ecost" ) {
436
                            // For numbers, we do 'starts with'
437
                            var object = {};
438
                            object[item] = { "like": value+'%' };
439
                            columns_filters.push( object );
440
                        }
441
                        else {
442
                            var object = {};
443
                            object[item] = { "like": '%'+value+'%' };
444
                            columns_filters.push( object );
445
                        }
446
                    });
447
448
                    if ( columns_filters.length > 1 ) {
449
                        query_and.push( { "-or": columns_filters } );
450
                    }
451
                    else if ( columns_filters.length > 0 ) {
452
                        query_and.push( columns_filters[0] );
453
                    }
454
                }
455
            });
456
457
            var query_params = [];
458
459
            if ( query_and.length > 0 ) {
460
                query_and.push(base_query);
461
                query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and })));
462
            }
463
464
            if ( order_id != "" ) {
465
                query_params.push("order_id="+order_id);
466
            }
467
468
            return query_params;
469
        }
470
471
        function _escape_str(s){
337
        function _escape_str(s){
472
            return s != null ? s.escapeHtml() : "";
338
            return s != null ? s.escapeHtml() : "";
473
        }
339
        }
Lines 480-486 Link Here
480
            if ( $("#receivedt").length ) {
346
            if ( $("#receivedt").length ) {
481
                var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
347
                var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
482
                    "bStateSave": true,
348
                    "bStateSave": true,
483
                    "iCookieDuration": 60*60*24*1000, // 1000 days
484
                    "iDisplayLength": 10,
349
                    "iDisplayLength": 10,
485
                    "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
350
                    "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
486
                    "aoColumnDefs": [
351
                    "aoColumnDefs": [
Lines 505-519 Link Here
505
                }));
370
                }));
506
            }
371
            }
507
372
508
            var base_query   = { "basket.vendor_id": [% booksellerid | html %]  };
509
            var query_params = query_from_filters( base_query );
510
511
            var THE_query = query_params.join("&");
512
513
            var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
514
            var pending_orders_table = $("#pending_orders").api({
373
            var pending_orders_table = $("#pending_orders").api({
515
                "ajax": {
374
                "ajax": {
516
                    "url": pending_orders_url + '&' + THE_query
375
                    "url": '/api/v1/acquisitions/orders?only_active=1'
517
                },
376
                },
518
                "header_filter": true,
377
                "header_filter": true,
519
                "embed": [
378
                "embed": [
Lines 527-534 Link Here
527
                    "items"
386
                    "items"
528
                ],
387
                ],
529
                "stateSave": true, // remember state on page reload
388
                "stateSave": true, // remember state on page reload
530
                "orderCellsTop": true, // tell the datatable sorting is done on the top row
531
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
532
                "drawCallback": function (settings) {
389
                "drawCallback": function (settings) {
533
                    $(".previewData").on("click", function(e){
390
                    $(".previewData").on("click", function(e){
534
                        e.preventDefault();
391
                        e.preventDefault();
Lines 539-558 Link Here
539
                        $('#dataPreview').modal({show:true});
396
                        $('#dataPreview').modal({show:true});
540
                    });
397
                    });
541
                },
398
                },
542
                "columnDefs": [ {
543
                    "targets": [3,4,5,9],
544
                    "render": function (data, type, row, meta) {
545
                        return _escape_str(data);
546
                    }
547
                },
548
                {
549
                    "targets": [8,10],
550
                    "render": function (data, type, row, meta) {
551
                        return _escape_price(data);
552
                    }
553
                } ],
554
                "columns": [
399
                "columns": [
555
                    { "data": "basket.name",
400
                    { "data": "basket.name",
401
                    "searchable": true,
556
                      "orderable": true,
402
                      "orderable": true,
557
                      "render": function(data, type, row, meta) {
403
                      "render": function(data, type, row, meta) {
558
                        if (type != 'display') return _escape_str(data);
404
                        if (type != 'display') return _escape_str(data);
Lines 584-610 Link Here
584
                        }
430
                        }
585
                    },
431
                    },
586
                    {
432
                    {
587
                        "data": "biblio.author",
433
                        "data": "biblio.author:biblio.title:biblio.isbn",
588
                        "visible": false,
434
                        "render": function(data, type, row, meta) {
589
                        "searchable": true,
590
                        "orderable": false
591
                    },
592
                    {
593
                        "data": "biblio.title",
594
                        "visible": false,
595
                        "searchable": true,
596
                        "orderable": false
597
                    },
598
                    {
599
                        "data": "biblio.isbn",
600
                        "visible": false,
601
                        "searchable": true,
602
                        "orderable": false
603
                    },
604
                    {
605
                        "data": function(row, type, val, meta) {
606
                            var result = '';
435
                            var result = '';
607
                            if ( row.biblio_id != null ) {
436
                            if ( row && row.biblio_id != null ) {
608
                                result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>";
437
                                result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>";
609
                                if ( row.biblio.author != null )
438
                                if ( row.biblio.author != null )
610
                                    result += _(" by ") + row.biblio.author.escapeHtml();
439
                                    result += _(" by ") + row.biblio.author.escapeHtml();
Lines 672-687 Link Here
672
501
673
                            return result;
502
                            return result;
674
                        },
503
                        },
675
                        "orderable": false
504
                        "orderable": false,
676
                    },
505
                    },
677
                    {
506
                    {
678
                        "data": function( row, type, val, meta) {
507
                        "data": "",
508
                        "render": function(data, type, row, meta) {
679
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>'
509
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>'
680
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>'
510
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>'
681
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>';
511
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>';
682
                            return result;
512
                            return result;
683
                        },
513
                        },
684
                        "orderable": false
514
                        "orderable": false,
515
                        "searchable": false
685
                    },
516
                    },
686
                    {
517
                    {
687
                        "data": "replacement_price"
518
                        "data": "replacement_price"
Lines 694-703 Link Here
694
                        "data": "ecost"
525
                        "data": "ecost"
695
                    },
526
                    },
696
                    {
527
                    {
697
                        "data": function ( row, type, val, meta ) {
528
                        "data": "",
529
                        "render": function(data, type, row, meta) {
698
                            return (row.quantity * row.ecost).format_price();
530
                            return (row.quantity * row.ecost).format_price();
699
                        },
531
                        },
700
                        "orderable": false // FIXME: How can we do it in DBIC?
532
                        "orderable": false, // FIXME: How can we do it in DBIC?
533
                        "searchable": false
701
                    },
534
                    },
702
                    {
535
                    {
703
                        "data": "fund.name",
536
                        "data": "fund.name",
Lines 707-723 Link Here
707
                        }
540
                        }
708
                    },
541
                    },
709
                    {
542
                    {
710
                        "data": function( row, type, val, meta ) {
543
                        "data": "",
544
                        "render": function(data, type, row, meta) {
711
                            return '<a href="orderreceive.pl?ordernumber='
545
                            return '<a href="orderreceive.pl?ordernumber='
712
                                    + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
546
                                    + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
713
                                    + _("Receive") + '</a><br/>'
547
                                    + _("Receive") + '</a><br/>'
714
                                    + '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">'
548
                                    + '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">'
715
                                    + _("Transfer") + '</a>';
549
                                    + _("Transfer") + '</a>';
716
                        },
550
                        },
717
                        "orderable": false
551
                        "orderable": false,
552
                        "searchable": false
718
                    },
553
                    },
719
                    {
554
                    {
720
                        "data": function( row, type, val, meta ) {
555
                        "data": "",
556
                        "render": function(data, type, row, meta) {
721
                            var result = "";
557
                            var result = "";
722
558
723
                            if ( row.current_holds_count > 0 ) {
559
                            if ( row.current_holds_count > 0 ) {
Lines 775-826 Link Here
775
611
776
                            return result;
612
                            return result;
777
                        },
613
                        },
778
                        "orderable": false
614
                        "orderable": false,
615
                        "searchable": false
779
                    }
616
                    }
780
                ]
617
                ]
781
            });
618
            }, {}, 1, {"basket.vendor_id": [% booksellerid | html %]});
782
783
            // column filter events handling
784
            $(".column-filter").each(function () {
785
                $(this).on( 'keyup change', function () {
786
                    // recalculate the query
787
                    var query_params = query_from_filters( base_query );
788
                    // refresh the datatable as appropriate
789
                    if ( query_params.length > 0 ) {
790
                        pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
791
                    }
792
                    else {
793
                        pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
794
                    }
795
                    pending_orders_table.api().ajax.reload( null, false );
796
                });
797
            });
798
799
            $("#filterform").on("submit", function(e) {
800
                e.preventDefault();
801
802
                // Save the filters in the cookie
803
                $.cookie("filter_parcel_summary", $("#summaryfilter").val());
804
                $.cookie("filter_parcel_basketname", $("#basketfilter").val());
805
                $.cookie("filter_parcel_orderno", $("#orderfilter").val());
806
                $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
807
                $.cookie("filter_parcel_ean", $("#eanfilter").val());
808
809
                var query_params = query_from_filters( base_query );
810
811
                if ( query_params.length > 0 ) {
812
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
813
                }
814
                else {
815
                    pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
816
                }
817
                pending_orders_table.api().ajax.reload( null, false );
818
            });
819
820
            $('#clear_form_filters').on("click", function(){
821
                $(this).closest('form').find("input[type=text], textarea").val("");
822
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
823
            });
824
619
825
            $(".previewData").on("click", function(e){
620
            $(".previewData").on("click", function(e){
826
                e.preventDefault();
621
                e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-12 / +35 lines)
Lines 509-515 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
509
509
510
(function($) {
510
(function($) {
511
511
512
    $.fn.api = function(options, columns_settings, add_filters) {
512
    $.fn.api = function(options, columns_settings, add_filters, default_filters) {
513
        var settings = null;
513
        var settings = null;
514
514
515
        if ( add_filters ) {
515
        if ( add_filters ) {
Lines 563-568 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
563
                                    _per_page: length
563
                                    _per_page: length
564
                                };
564
                                };
565
565
566
567
                                function build_query(col){
568
                                    var parts = [];
569
                                    var attributes = col.data.split(':');
570
                                    for (var i=0;i<attributes.length;i++){
571
                                        var part = {};
572
                                        var attr = attributes[i];
573
                                        var value = data.columns[col.idx].search.value;
574
                                        part[!attr.includes('.')?'me.'+attr:attr] = options.criteria === 'exact'
575
                                            ? value
576
                                            : {like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')};
577
                                        parts.push(part);
578
                                    }
579
                                    return parts;
580
                                }
581
566
                                var filter = data.search.value;
582
                                var filter = data.search.value;
567
                                // Build query for each column filter
583
                                // Build query for each column filter
568
                                var and_query_parameters = settings.aoColumns
584
                                var and_query_parameters = settings.aoColumns
Lines 570-579 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
570
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value != ''
586
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value != ''
571
                                })
587
                                })
572
                                .map(function(col) {
588
                                .map(function(col) {
573
                                    var part = {};
589
                                    return build_query(col)
574
                                    var value = data.columns[col.idx].search.value;
590
                                })
575
                                    part[!col.data.includes('.')?'me.'+col.data:col.data] = options.criteria === 'exact'?value:{like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'')+value+(['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')};
591
                                .map(function r(e){
576
                                    return part;
592
                                    return ($.isArray(e) ? $.map(e, r) : e);
577
                                });
593
                                });
578
594
579
                                // Build query for the global search filter
595
                                // Build query for the global search filter
Lines 582-593 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
582
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value == '' && filter != ''
598
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value == '' && filter != ''
583
                                })
599
                                })
584
                                .map(function(col) {
600
                                .map(function(col) {
585
                                    var part = {};
601
                                    return build_query(col)
586
                                    value = filter;
602
                                })
587
                                    part[!col.data.includes('.')?'me.'+col.data:col.data] = options.criteria === 'exact'?value:{like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'')+value+(['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')};
603
                                .map(function r(e){
588
                                    return part;
604
                                    return ($.isArray(e) ? $.map(e, r) : e);
589
                                });
605
                                });
590
606
607
                                if ( default_filters ) {
608
                                    and_query_parameters.push(default_filters);
609
                                }
591
                                query_parameters = and_query_parameters;
610
                                query_parameters = and_query_parameters;
592
                                query_parameters.push(or_query_parameters);
611
                                query_parameters.push(or_query_parameters);
593
                                if(query_parameters.length) {
612
                                if(query_parameters.length) {
Lines 748-755 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
748
                var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
767
                var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
749
                if ( is_searchable ) {
768
                if ( is_searchable ) {
750
                    var title = $(this).text();
769
                    var title = $(this).text();
751
                    var search_title = _("Search %s").format(title);
770
                    var existing_search = table_dt.column(i).search();
752
                    $(this).html( '<input type="text" placeholder="%s" />'.format(search_title) );
771
                    if ( existing_search ) {
772
                        $(this).html( '<input type="text" value="%s" style="width: 100%" />'.format(existing_search) );
773
                    } else {
774
                        var search_title = _("Search %s").format(title);
775
                        $(this).html( '<input type="text" placeholder="%s" style="width: 100%" />'.format(search_title) );
776
                    }
753
777
754
                    $( 'input', this ).on( 'keyup change', function () {
778
                    $( 'input', this ).on( 'keyup change', function () {
755
                        if ( table_dt.column(i).search() !== this.value ) {
779
                        if ( table_dt.column(i).search() !== this.value ) {
756
- 

Return to bug 20212