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

(-)a/catalogue/itemsearch.pl (-1 / +4 lines)
Lines 90-95 if (defined $format and $format eq 'json') { Link Here
90
} elsif (defined $format and $format eq 'barcodes') {
90
} elsif (defined $format and $format eq 'barcodes') {
91
    # Retrieve all results
91
    # Retrieve all results
92
    $cgi->param('rows', 0);
92
    $cgi->param('rows', 0);
93
} elsif (defined $format and $format eq 'shareable') {
94
    # get the item search parameters from the url and fill form
93
} elsif (defined $format) {
95
} elsif (defined $format) {
94
    die "Unsupported format $format";
96
    die "Unsupported format $format";
95
}
97
}
Lines 119-125 if ( Koha::MarcSubfieldStructures->search( { frameworkcode => '', kohafield => ' Link Here
119
    $template->param( has_new_status => 1 );
121
    $template->param( has_new_status => 1 );
120
}
122
}
121
123
122
if ( defined $format ) {
124
if ( defined $format and $format ne 'shareable') {
123
    # Parameters given, it's a search
125
    # Parameters given, it's a search
124
126
125
    my $filter = {
127
    my $filter = {
Lines 351-356 $template->param( Link Here
351
    damageds => \@damageds,
353
    damageds => \@damageds,
352
    items_search_fields => \@items_search_fields,
354
    items_search_fields => \@items_search_fields,
353
    authorised_values_json => to_json($authorised_values),
355
    authorised_values_json => to_json($authorised_values),
356
    query => $cgi,
354
);
357
);
355
358
356
output_html_with_http_headers $cgi, $cookie, $template->output;
359
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt (-52 / +144 lines)
Lines 37-66 Link Here
37
  <div class="form-field form-field-select">
37
  <div class="form-field form-field-select">
38
    <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
38
    <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
39
    <select id="[% name | html %]_op" name="[% name | html %]_op">
39
    <select id="[% name | html %]_op" name="[% name | html %]_op">
40
      <option value="=">is</option>
40
      [% IF query.param(name _ '_op') == '=' || !query.param(name _ '_op') %]
41
      <option value="!=" >is not</option>
41
        <option value="=" selected="selected">is</option>
42
        <option value="!=" >is not</option>
43
      [% ELSE %]
44
        <option value="=">is</option>
45
        <option value="!=" selected="selected">is not</option>
46
      [% END %]
42
    </select>
47
    </select>
43
    <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
48
    <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
44
      <option value="" selected="selected">
49
      [% IF query.param(name).size == 0 %]
45
        [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
50
        <option value="" selected="selected">
46
      </option>
51
            [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
52
        </option>
53
      [% END %]
47
      [% FOREACH option IN options %]
54
      [% FOREACH option IN options %]
55
        [% IF query.param(name).grep(option.value).size %]
56
            <option value="[% option.value | html %]" selected="selected">[% option.label | html %]</option>
57
        [% ELSE %]
48
        <option value="[% option.value | html %]">[% option.label | html %]</option>
58
        <option value="[% option.value | html %]">[% option.label | html %]</option>
59
        [% END %]
49
      [% END %]
60
      [% END %]
50
    </select>
61
    </select>
51
  </div>
62
  </div>
52
[% END %]
63
[% END %]
53
64
54
[% BLOCK form_field_select_option %]
65
[% BLOCK form_field_select_option %]
55
  <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
66
  [% IF query.param('f').$i == value || query.param('f') == value %]
67
    <option value="[% value | html %]" selected="selected">[% INCLUDE form_label label=value %]</option>
68
  [% ELSE %]
69
    <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
70
  [% END %]
56
[% END %]
71
[% END %]
57
72
58
[% BLOCK form_field_select_text %]
73
[% BLOCK form_field_select_text %]
74
  [% SET i = loop.index %]
59
  <div class="form-field form-field-select-text">
75
  <div class="form-field form-field-select-text">
60
    <select name="c" class="form-field-conjunction" disabled="disabled">
76
    [% IF loop.first || !query.param('f') %]
61
      <option value="and">AND</option>
77
        <select name="c" class="form-field-conjunction" disabled="disabled">
62
      <option value="or">OR</option>
78
        <option value="and">AND</option>
63
    </select>
79
        <option value="or">OR</option>
80
        </select>
81
    [% ELSE %]
82
        [% SET j = i - 1 %]
83
        <select name="c" class="form-field-conjunction">
84
            [% IF query.param('c').$j == 'and' %]
85
                <option value="and" selected="selected">AND</option>
86
                <option value="or">OR</option>
87
            [% ELSE %]
88
                <option value="and">AND</option>
89
                <option value="or" selected="selected">OR</option>
90
            [% END %]
91
        </select>
92
    [% END %]
64
    <select name="f" class="form-field-column">
93
    <select name="f" class="form-field-column">
65
      [% INCLUDE form_field_select_option value='barcode' %]
94
      [% INCLUDE form_field_select_option value='barcode' %]
66
      [% INCLUDE form_field_select_option value='itemcallnumber' %]
95
      [% INCLUDE form_field_select_option value='itemcallnumber' %]
Lines 84-105 Link Here
84
        </optgroup>
113
        </optgroup>
85
      [% END %]
114
      [% END %]
86
    </select>
115
    </select>
87
    [% IF params.exists('op') %]
116
    <select name="op" class="form-field-not">
88
        <select name="op" class="form-field-not">
117
        [% IF query.param('op').$i == 'not like' || query.param('op') == 'not like' %]
89
           <option value="like">is</option>
118
            <option value="like">is</option>
90
            [% IF params.op == 'not like' %]
119
            <option value="not like" selected="selected">is not</option>
91
               <option value="not like" selected="selected">is not</option>
120
        [% ELSE %]
92
            [% ELSE %]
121
            <option value="like">is</option>
93
               <option value="not like">is not</option>
122
            <option value="not like">is not</option>
94
            [% END %]
123
        [% END %]
95
        </select>
124
    </select>
96
    [% ELSE %]
125
    <input type="text" name="q" class="form-field-value" value="[% query.param('q').$i ? query.param('q').$i : query.param('q') | html %]"/>
97
        <select name="op" class="form-field-not">
98
           <option value="like">is</option>
99
           <option value="not like">is not</option>
100
        </select>
101
    [% END %]
102
    <input type="text" name="q" class="form-field-value" value="" />
103
  </div>
126
  </div>
104
[% END %]
127
[% END %]
105
128
Lines 210-225 Link Here
210
            [% END %]
233
            [% END %]
211
            <div class="form-field">
234
            <div class="form-field">
212
                <label class="form-field-label">Availability:</label>
235
                <label class="form-field-label">Availability:</label>
213
                <input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/>
236
                [% IF query.param('onloan') == '' %]
237
                    <input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/>
238
                [% ELSE %]
239
                    <input type="radio" name="onloan" id="onloan_indifferent" value=""/>
240
                [% END %]
214
                <label for="onloan_indifferent">Ignore</label>
241
                <label for="onloan_indifferent">Ignore</label>
215
                <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" />
242
                [% IF query.param('onloan') == 'IS NOT NULL' %]
243
                    <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" checked="checked"/>
244
                [% ELSE %]
245
                    <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL"/>
246
                [% END %]
216
                <label for="onloan_yes">Checked out</label>
247
                <label for="onloan_yes">Checked out</label>
217
                <input type="radio" name="onloan" id="onloan_no" value="IS NULL" />
248
                [% IF query.param('onloan') == 'IS NULL' %]
249
                    <input type="radio" name="onloan" id="onloan_no" value="IS NULL" checked="checked"/>
250
                [% ELSE %]
251
                    <input type="radio" name="onloan" id="onloan_no" value="IS NULL"/>
252
                [% END %]
218
                <label for="onloan_no">Not checked out</label>
253
                <label for="onloan_no">Not checked out</label>
219
            </div>
254
            </div>
220
          </fieldset>
255
          </fieldset>
221
          <fieldset>
256
          <fieldset>
222
            [% INCLUDE form_field_select_text %]
257
            [% IF !query.param('f') %]
258
                [% INCLUDE form_field_select_text %]
259
            [% ELSE %]
260
                [% FOREACH field IN query.param('f') %]
261
                    [% INCLUDE form_field_select_text %]
262
                [% END  %]
263
            [% END %]
223
            <p class="hint">You can use the following wildcard characters: % _</p>
264
            <p class="hint">You can use the following wildcard characters: % _</p>
224
            <p class="hint">% matches any number of characters</p>
265
            <p class="hint">% matches any number of characters</p>
225
            <p class="hint">_ matches only a single character</p>
266
            <p class="hint">_ matches only a single character</p>
Lines 227-238 Link Here
227
          <fieldset>
268
          <fieldset>
228
            <div class="form-field">
269
            <div class="form-field">
229
              <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
270
              <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
230
              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
271
              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% query.param('itemcallnumber_from') | html %]" />
231
              <span class="hint">(inclusive)</span>
272
              <span class="hint">(inclusive)</span>
232
            </div>
273
            </div>
233
            <div class="form-field">
274
            <div class="form-field">
234
              <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
275
              <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
235
              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
276
              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% query.param('itemcallnumber_to') | html %]" />
236
              <span class="hint">(inclusive)</span>
277
              <span class="hint">(inclusive)</span>
237
            </div>
278
            </div>
238
            [% IF ( has_new_status ) %]
279
            [% IF ( has_new_status ) %]
Lines 241-261 Link Here
241
            <div class="form-field">
282
            <div class="form-field">
242
              <label class="form-field-label" for="issues_op">Checkout count:</label>
283
              <label class="form-field-label" for="issues_op">Checkout count:</label>
243
              <select id="issues_op" name="issues_op">
284
              <select id="issues_op" name="issues_op">
244
                <option value=">">&gt;</option>
285
                [% IF query.param('issues_op') == '>' %]
245
                <option value="<">&lt;</option>
286
                  <option value=">" selected="selected">&gt;</option>
246
                <option value="=">=</option>
287
                [% ELSE %]
247
                <option value="!=">!=</option>
288
                  <option value=">">&gt;</option>
289
                [% END %]
290
                [% IF query.param('issues_op') == '<' %]
291
                  <option value="<" selected="selected">&lt;</option>
292
                [% ELSE %]
293
                  <option value="<">&lt;</option>
294
                [% END %]
295
                [% IF query.param('issues_op') == '=' %]
296
                  <option value="=" selected="selected">=</option>
297
                [% ELSE %]
298
                  <option value="=">=</option>
299
                [% END %]
300
                [% IF query.param('issues_op') == '!=' %]
301
                  <option value="!=" selected="selected">!=</option>
302
                [% ELSE %]
303
                  <option value="!=">!=</option>
304
                [% END %]
248
              </select>
305
              </select>
249
              <input type="text" name="issues" />
306
              <input type="text" name="issues" value="[% query.param('issues') | html %]"/>
250
            </div>
307
            </div>
251
            <div class="form-field">
308
            <div class="form-field">
252
              <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
309
              <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
253
              <select id="datelastborrowed_op" name="datelastborrowed_op">
310
              <select id="datelastborrowed_op" name="datelastborrowed_op">
254
                <option value=">">After</option>
311
                [% IF query.param('datelastborrowed_op') == '>' %]
255
                <option value="<">Before</option>
312
                  <option value=">" selected="selected">After</option>
256
                <option value="=">On</option>
313
                [% ELSE %]
314
                  <option value=">">After</option>
315
                [% END %]
316
                [% IF query.param('datelastborrowed_op') == '<' %]
317
                  <option value="<" selected="selected">Before</option>
318
                [% ELSE %]
319
                  <option value="<">Before</option>
320
                [% END %]
321
                [% IF query.param('datelastborrowed_op') == '=' %]
322
                  <option value="=" selected="selected">On</option>
323
                [% ELSE %]
324
                  <option value="=">On</option>
325
                [% END %]
257
              </select>
326
              </select>
258
              <input type="text" name="datelastborrowed" />
327
              <input type="text" name="datelastborrowed" value="[% query.param('datelastborrowed') | html %]"/>
259
              <span class="hint">ISO Format (YYYY-MM-DD)</span>
328
              <span class="hint">ISO Format (YYYY-MM-DD)</span>
260
            </div>
329
            </div>
261
          </fieldset>
330
          </fieldset>
Lines 368-373 Link Here
368
            }
437
            }
369
        }
438
        }
370
439
440
        function getParams($form) {
441
            var params = [];
442
            $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
443
                if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
444
                    var name = $(this).parents('select').first().attr('name');
445
                    var value = $(this).val();
446
                    params.push({ 'name': name, 'value': value });
447
                } else {
448
                    params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
449
                }
450
            });
451
            return params;
452
        }
453
371
        function submitForm($form) {
454
        function submitForm($form) {
372
            var tr = ''
455
            var tr = ''
373
                + '    <tr>'
456
                + '    <tr>'
Lines 451-456 Link Here
451
                    $('#item-search-block').show();
534
                    $('#item-search-block').show();
452
                });
535
                });
453
536
537
            var getShareableLink = $('<a>')
538
                .attr('href', '#')
539
                .html("<i class='fa fa-copy'></i> " + _("Copy shareable link") )
540
                .addClass('btn btn-secondary')
541
                .on('click', function(e) {
542
                    e.preventDefault();
543
                    var params = getParams( $('#itemsearchform') );
544
                    params = params.map(p => {
545
                        if(p.name === 'format') {
546
                            return { ...p, value: 'shareable' };
547
                        }
548
                        return p;
549
                    })
550
                    var url = window.location.origin + window.location.pathname + '?' + $.param(params);
551
                    navigator.clipboard.writeText(url);
552
                    $(this).tooltip({trigger: 'manual', title: 'Copied!'}).tooltip('show');
553
                });
554
454
            var results_heading = $('<div>').addClass('results-heading')
555
            var results_heading = $('<div>').addClass('results-heading')
455
                .append("<h1>" + _("Item search results") + "</h1>")
556
                .append("<h1>" + _("Item search results") + "</h1>")
456
                .append($('<p>').append(advSearchLink))
557
                .append($('<p>').append(advSearchLink))
Lines 458-478 Link Here
458
                    .addClass("btn-toolbar")
559
                    .addClass("btn-toolbar")
459
                    .attr("id","toolbar")
560
                    .attr("id","toolbar")
460
                    .append(editSearchLink)
561
                    .append(editSearchLink)
562
                    .append(getShareableLink)
461
                );
563
                );
462
            $('#results-wrapper').empty()
564
            $('#results-wrapper').empty()
463
                .append(results_heading)
565
                .append(results_heading)
464
                .append(table);
566
                .append(table);
465
567
466
            var params = [];
568
            var params = getParams($form);
467
            $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
468
                if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
469
                    var name = $(this).parents('select').first().attr('name');
470
                    var value = $(this).val();
471
                    params.push({ 'name': name, 'value': value });
472
                } else {
473
                    params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
474
                }
475
            });
476
569
477
            $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
570
            $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
478
                "destroy": true,
571
                "destroy": true,
479
- 

Return to bug 14322