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 (-238 / +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-479 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
        $(document).ready(function(){
337
        $(document).ready(function(){
472
338
473
            if ( $("#receivedt").length ) {
339
            if ( $("#receivedt").length ) {
474
                var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
340
                var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
475
                    "bStateSave": true,
341
                    "bStateSave": true,
476
                    "iCookieDuration": 60*60*24*1000, // 1000 days
477
                    "iDisplayLength": 10,
342
                    "iDisplayLength": 10,
478
                    "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
343
                    "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
479
                    "aoColumnDefs": [
344
                    "aoColumnDefs": [
Lines 498-512 Link Here
498
                }));
363
                }));
499
            }
364
            }
500
365
501
            var base_query   = { "basket.vendor_id": [% booksellerid | html %]  };
502
            var query_params = query_from_filters( base_query );
503
504
            var THE_query = query_params.join("&");
505
506
            var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
507
            var pending_orders_table = $("#pending_orders").api({
366
            var pending_orders_table = $("#pending_orders").api({
508
                "ajax": {
367
                "ajax": {
509
                    "url": pending_orders_url + '&' + THE_query
368
                    "url": '/api/v1/acquisitions/orders?only_active=1'
510
                },
369
                },
511
                "header_filter": true,
370
                "header_filter": true,
512
                "embed": [
371
                "embed": [
Lines 520-527 Link Here
520
                    "items"
379
                    "items"
521
                ],
380
                ],
522
                "stateSave": true, // remember state on page reload
381
                "stateSave": true, // remember state on page reload
523
                "orderCellsTop": true, // tell the datatable sorting is done on the top row
524
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
525
                "drawCallback": function (settings) {
382
                "drawCallback": function (settings) {
526
                    $(".previewData").on("click", function(e){
383
                    $(".previewData").on("click", function(e){
527
                        e.preventDefault();
384
                        e.preventDefault();
Lines 532-561 Link Here
532
                        $('#dataPreview').modal({show:true});
389
                        $('#dataPreview').modal({show:true});
533
                    });
390
                    });
534
                },
391
                },
535
                "columnDefs": [ {
536
                    "targets": [3,4,5,9],
537
                    "render": function (data, type, row, meta) {
538
                        if ( data != null ) {
539
                            return data.escapeHtml();
540
                        }
541
                        else {
542
                            return "";
543
                        }
544
                    }
545
                },
546
                {
547
                    "targets": [8,10],
548
                    "render": function (data, type, row, meta) {
549
                        if ( data != null ) {
550
                            return data.escapeHtml().format_price();
551
                        }
552
                        else {
553
                            return "";
554
                        }
555
                    }
556
                } ],
557
                "columns": [
392
                "columns": [
558
                    { "data": "basket.name",
393
                    { "data": "basket.name",
394
                    "searchable": true,
559
                      "orderable": true,
395
                      "orderable": true,
560
                      "render": function(data, type, row, meta) {
396
                      "render": function(data, type, row, meta) {
561
                        if (type != 'display') return data;
397
                        if (type != 'display') return data;
Lines 592-618 Link Here
592
                        }
428
                        }
593
                    },
429
                    },
594
                    {
430
                    {
595
                        "data": "biblio.author",
431
                        "data": "biblio.author:biblio.title:biblio.isbn",
596
                        "visible": false,
432
                        "render": function(data, type, row, meta) {
597
                        "searchable": true,
598
                        "orderable": false
599
                    },
600
                    {
601
                        "data": "biblio.title",
602
                        "visible": false,
603
                        "searchable": true,
604
                        "orderable": false
605
                    },
606
                    {
607
                        "data": "biblio.isbn",
608
                        "visible": false,
609
                        "searchable": true,
610
                        "orderable": false
611
                    },
612
                    {
613
                        "data": function(row, type, val, meta) {
614
                            var result = '';
433
                            var result = '';
615
                            if ( row.biblio_id != null ) {
434
                            if ( row && row.biblio_id != null ) {
616
                                result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>";
435
                                result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>";
617
                                if ( row.biblio.author != null )
436
                                if ( row.biblio.author != null )
618
                                    result += _(" by ") + row.biblio.author.escapeHtml();
437
                                    result += _(" by ") + row.biblio.author.escapeHtml();
Lines 680-695 Link Here
680
499
681
                            return result;
500
                            return result;
682
                        },
501
                        },
683
                        "orderable": false
502
                        "orderable": false,
684
                    },
503
                    },
685
                    {
504
                    {
686
                        "data": function( row, type, val, meta) {
505
                        "data": "",
506
                        "render": function(data, type, row, meta) {
687
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>'
507
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>'
688
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>'
508
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>'
689
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>';
509
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>';
690
                            return result;
510
                            return result;
691
                        },
511
                        },
692
                        "orderable": false
512
                        "orderable": false,
513
                        "searchable": false
693
                    },
514
                    },
694
                    {
515
                    {
695
                        "data": "replacement_price"
516
                        "data": "replacement_price"
Lines 702-711 Link Here
702
                        "data": "ecost"
523
                        "data": "ecost"
703
                    },
524
                    },
704
                    {
525
                    {
705
                        "data": function ( row, type, val, meta ) {
526
                        "data": "",
527
                        "render": function(data, type, row, meta) {
706
                            return (row.quantity * row.ecost).format_price();
528
                            return (row.quantity * row.ecost).format_price();
707
                        },
529
                        },
708
                        "orderable": false // FIXME: How can we do it in DBIC?
530
                        "orderable": false, // FIXME: How can we do it in DBIC?
531
                        "searchable": false
709
                    },
532
                    },
710
                    {
533
                    {
711
                        "data": "fund_id",
534
                        "data": "fund_id",
Lines 715-731 Link Here
715
                        }
538
                        }
716
                    },
539
                    },
717
                    {
540
                    {
718
                        "data": function( row, type, val, meta ) {
541
                        "data": "",
542
                        "render": function(data, type, row, meta) {
719
                            return '<a href="orderreceive.pl?ordernumber='
543
                            return '<a href="orderreceive.pl?ordernumber='
720
                                    + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
544
                                    + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
721
                                    + _("Receive") + '</a><br/>'
545
                                    + _("Receive") + '</a><br/>'
722
                                    + '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">'
546
                                    + '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">'
723
                                    + _("Transfer") + '</a>';
547
                                    + _("Transfer") + '</a>';
724
                        },
548
                        },
725
                        "orderable": false
549
                        "orderable": false,
550
                        "searchable": false
726
                    },
551
                    },
727
                    {
552
                    {
728
                        "data": function( row, type, val, meta ) {
553
                        "data": "",
554
                        "render": function(data, type, row, meta) {
729
                            var result = "";
555
                            var result = "";
730
556
731
                            if ( row.current_holds_count > 0 ) {
557
                            if ( row.current_holds_count > 0 ) {
Lines 783-834 Link Here
783
609
784
                            return result;
610
                            return result;
785
                        },
611
                        },
786
                        "orderable": false
612
                        "orderable": false,
613
                        "searchable": false
787
                    }
614
                    }
788
                ]
615
                ]
789
            });
616
            }, {}, 1, {"basket.vendor_id": [% booksellerid | html %]});
790
791
            // column filter events handling
792
            $(".column-filter").each(function () {
793
                $(this).on( 'keyup change', function () {
794
                    // recalculate the query
795
                    var query_params = query_from_filters( base_query );
796
                    // refresh the datatable as appropriate
797
                    if ( query_params.length > 0 ) {
798
                        pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
799
                    }
800
                    else {
801
                        pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
802
                    }
803
                    pending_orders_table.api().ajax.reload( null, false );
804
                });
805
            });
806
807
            $("#filterform").on("submit", function(e) {
808
                e.preventDefault();
809
810
                // Save the filters in the cookie
811
                $.cookie("filter_parcel_summary", $("#summaryfilter").val());
812
                $.cookie("filter_parcel_basketname", $("#basketfilter").val());
813
                $.cookie("filter_parcel_orderno", $("#orderfilter").val());
814
                $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
815
                $.cookie("filter_parcel_ean", $("#eanfilter").val());
816
817
                var query_params = query_from_filters( base_query );
818
819
                if ( query_params.length > 0 ) {
820
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
821
                }
822
                else {
823
                    pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
824
                }
825
                pending_orders_table.api().ajax.reload( null, false );
826
            });
827
828
            $('#clear_form_filters').on("click", function(){
829
                $(this).closest('form').find("input[type=text], textarea").val("");
830
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
831
            });
832
617
833
            $(".previewData").on("click", function(e){
618
            $(".previewData").on("click", function(e){
834
                e.preventDefault();
619
                e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-12 / +35 lines)
Lines 510-516 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
510
510
511
(function($) {
511
(function($) {
512
512
513
    $.fn.api = function(options, columns_settings, add_filters) {
513
    $.fn.api = function(options, columns_settings, add_filters, default_filters) {
514
        var settings = null;
514
        var settings = null;
515
515
516
        if ( add_filters ) {
516
        if ( add_filters ) {
Lines 564-569 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
564
                                    _per_page: length
564
                                    _per_page: length
565
                                };
565
                                };
566
566
567
568
                                function build_query(col){
569
                                    var parts = [];
570
                                    var attributes = col.data.split(':');
571
                                    for (var i=0;i<attributes.length;i++){
572
                                        var part = {};
573
                                        var attr = attributes[i];
574
                                        var value = data.columns[col.idx].search.value;
575
                                        part[!attr.includes('.')?'me.'+attr:attr] = options.criteria === 'exact'
576
                                            ? value
577
                                            : {like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')};
578
                                        parts.push(part);
579
                                    }
580
                                    return parts;
581
                                }
582
567
                                var filter = data.search.value;
583
                                var filter = data.search.value;
568
                                // Build query for each column filter
584
                                // Build query for each column filter
569
                                var and_query_parameters = settings.aoColumns
585
                                var and_query_parameters = settings.aoColumns
Lines 571-580 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
571
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value != ''
587
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value != ''
572
                                })
588
                                })
573
                                .map(function(col) {
589
                                .map(function(col) {
574
                                    var part = {};
590
                                    return build_query(col)
575
                                    var value = data.columns[col.idx].search.value;
591
                                })
576
                                    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?'%':'')};
592
                                .map(function r(e){
577
                                    return part;
593
                                    return ($.isArray(e) ? $.map(e, r) : e);
578
                                });
594
                                });
579
595
580
                                // Build query for the global search filter
596
                                // Build query for the global search filter
Lines 583-594 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
583
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value == '' && filter != ''
599
                                    return col.bSearchable && typeof col.data == 'string' && data.columns[col.idx].search.value == '' && filter != ''
584
                                })
600
                                })
585
                                .map(function(col) {
601
                                .map(function(col) {
586
                                    var part = {};
602
                                    return build_query(col)
587
                                    value = filter;
603
                                })
588
                                    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?'%':'')};
604
                                .map(function r(e){
589
                                    return part;
605
                                    return ($.isArray(e) ? $.map(e, r) : e);
590
                                });
606
                                });
591
607
608
                                if ( default_filters ) {
609
                                    and_query_parameters.push(default_filters);
610
                                }
592
                                query_parameters = and_query_parameters;
611
                                query_parameters = and_query_parameters;
593
                                query_parameters.push(or_query_parameters);
612
                                query_parameters.push(or_query_parameters);
594
                                if(query_parameters.length) {
613
                                if(query_parameters.length) {
Lines 749-756 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
749
                var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
768
                var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
750
                if ( is_searchable ) {
769
                if ( is_searchable ) {
751
                    var title = $(this).text();
770
                    var title = $(this).text();
752
                    var search_title = _("Search %s").format(title);
771
                    var existing_search = table_dt.column(i).search();
753
                    $(this).html( '<input type="text" placeholder="%s" />'.format(search_title) );
772
                    if ( existing_search ) {
773
                        $(this).html( '<input type="text" value="%s" style="width: 100%" />'.format(existing_search) );
774
                    } else {
775
                        var search_title = _("Search %s").format(title);
776
                        $(this).html( '<input type="text" placeholder="%s" style="width: 100%" />'.format(search_title) );
777
                    }
754
778
755
                    $( 'input', this ).on( 'keyup change', function () {
779
                    $( 'input', this ).on( 'keyup change', function () {
756
                        if ( table_dt.column(i).search() !== this.value ) {
780
                        if ( table_dt.column(i).search() !== this.value ) {
757
- 

Return to bug 20212