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 (-47 / +78 lines)
Lines 37-58 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').grep(value).0 == 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 %]
Lines 84-105 Link Here
84
        </optgroup>
99
        </optgroup>
85
      [% END %]
100
      [% END %]
86
    </select>
101
    </select>
87
    [% IF params.exists('op') %]
102
    <select name="op" class="form-field-not">
88
        <select name="op" class="form-field-not">
103
        [% IF query.param('op') == 'not like' %]
89
           <option value="like">is</option>
104
            <option value="like">is</option>
90
            [% IF params.op == 'not like' %]
105
            <option value="not like" selected="selected">is not</option>
91
               <option value="not like" selected="selected">is not</option>
106
        [% ELSE %]
92
            [% ELSE %]
107
            <option value="like">is</option>
93
               <option value="not like">is not</option>
108
            <option value="not like">is not</option>
94
            [% END %]
109
        [% END %]
95
        </select>
110
    </select>
96
    [% ELSE %]
111
    <input type="text" name="q" class="form-field-value" value="[% 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>
112
  </div>
104
[% END %]
113
[% END %]
105
114
Lines 210-220 Link Here
210
            [% END %]
219
            [% END %]
211
            <div class="form-field">
220
            <div class="form-field">
212
                <label class="form-field-label">Availability:</label>
221
                <label class="form-field-label">Availability:</label>
213
                <input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/>
222
                <input type="radio" name="onloan" id="onloan_indifferent" value="" [% query.param('onloan') == '' ? 'checked="checked"' : '' | html %]/>
214
                <label for="onloan_indifferent">Ignore</label>
223
                <label for="onloan_indifferent">Ignore</label>
215
                <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" />
224
                <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" [% query.param('onloan') == 'IS NOT NULL' ? 'checked="checked"' : '' | html %]/>
216
                <label for="onloan_yes">Checked out</label>
225
                <label for="onloan_yes">Checked out</label>
217
                <input type="radio" name="onloan" id="onloan_no" value="IS NULL" />
226
                <input type="radio" name="onloan" id="onloan_no" value="IS NULL" [% query.param('onloan') == 'IS NULL' ? 'checked="checked"' : '' | html %]/>
218
                <label for="onloan_no">Not checked out</label>
227
                <label for="onloan_no">Not checked out</label>
219
            </div>
228
            </div>
220
          </fieldset>
229
          </fieldset>
Lines 227-238 Link Here
227
          <fieldset>
236
          <fieldset>
228
            <div class="form-field">
237
            <div class="form-field">
229
              <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
238
              <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
230
              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
239
              <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% query.param('itemcallnumber_from') %]" />
231
              <span class="hint">(inclusive)</span>
240
              <span class="hint">(inclusive)</span>
232
            </div>
241
            </div>
233
            <div class="form-field">
242
            <div class="form-field">
234
              <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
243
              <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
235
              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
244
              <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% query.param('itemcallnumber_to') %]" />
236
              <span class="hint">(inclusive)</span>
245
              <span class="hint">(inclusive)</span>
237
            </div>
246
            </div>
238
            [% IF ( has_new_status ) %]
247
            [% IF ( has_new_status ) %]
Lines 241-261 Link Here
241
            <div class="form-field">
250
            <div class="form-field">
242
              <label class="form-field-label" for="issues_op">Checkout count:</label>
251
              <label class="form-field-label" for="issues_op">Checkout count:</label>
243
              <select id="issues_op" name="issues_op">
252
              <select id="issues_op" name="issues_op">
244
                <option value=">">&gt;</option>
253
                <option value=">" [% query.param('issues_op') == '>' ? 'selected="selected"' : '' %]>&gt;</option>
245
                <option value="<">&lt;</option>
254
                <option value="<" [% query.param('issues_op') == '<' ? 'selected="selected"' : '' %]>&lt;</option>
246
                <option value="=">=</option>
255
                <option value="=" [% query.param('issues_op') == '=' ? 'selected="selected"' : '' %]>=</option>
247
                <option value="!=">!=</option>
256
                <option value="!=" [% query.param('issues_op') == '!=' ? 'selected="selected"' : '' %]>!=</option>
248
              </select>
257
              </select>
249
              <input type="text" name="issues" />
258
              <input type="text" name="issues" value="[% query.param('issues') %]"/>
250
            </div>
259
            </div>
251
            <div class="form-field">
260
            <div class="form-field">
252
              <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
261
              <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
253
              <select id="datelastborrowed_op" name="datelastborrowed_op">
262
              <select id="datelastborrowed_op" name="datelastborrowed_op">
254
                <option value=">">After</option>
263
                <option value=">" [% query.param('datelastborrowed_op') == '>' ? 'selected="selected"' : '' %]>After</option>
255
                <option value="<">Before</option>
264
                <option value="<" [% query.param('datelastborrowed_op') == '<' ? 'selected="selected"' : '' %]>Before</option>
256
                <option value="=">On</option>
265
                <option value="=" [% query.param('datelastborrowed_op') == '=' ? 'selected="selected"' : '' %]>On</option>
257
              </select>
266
              </select>
258
              <input type="text" name="datelastborrowed" />
267
              <input type="text" name="datelastborrowed" value="[% query.param('datelastborrowed') %]"/>
259
              <span class="hint">ISO Format (YYYY-MM-DD)</span>
268
              <span class="hint">ISO Format (YYYY-MM-DD)</span>
260
            </div>
269
            </div>
261
          </fieldset>
270
          </fieldset>
Lines 368-373 Link Here
368
            }
377
            }
369
        }
378
        }
370
379
380
        function getParams($form) {
381
            var params = [];
382
            $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
383
                if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
384
                    var name = $(this).parents('select').first().attr('name');
385
                    var value = $(this).val();
386
                    params.push({ 'name': name, 'value': value });
387
                } else {
388
                    params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
389
                }
390
            });
391
            return params;
392
        }
393
371
        function submitForm($form) {
394
        function submitForm($form) {
372
            var tr = ''
395
            var tr = ''
373
                + '    <tr>'
396
                + '    <tr>'
Lines 451-456 Link Here
451
                    $('#item-search-block').show();
474
                    $('#item-search-block').show();
452
                });
475
                });
453
476
477
            var getShareableLink = $('<a>')
478
                .attr('href', '#')
479
                .html("<i class='fa fa-link'></i> " + _("Copy shareable link") )
480
                .addClass('btn btn-default')
481
                .on('click', function(e) {
482
                    e.preventDefault();
483
                    var params = getParams( $('#itemsearchform') );
484
                    params = params.map(p => {
485
                        if(p.name === 'format') {
486
                            return { ...p, value: 'shareable' };
487
                        }
488
                        return p;
489
                    })
490
                    var url = window.location.origin + window.location.pathname + '?' + $.param(params);
491
                    navigator.clipboard.writeText(url);
492
                });
493
454
            var results_heading = $('<div>').addClass('results-heading')
494
            var results_heading = $('<div>').addClass('results-heading')
455
                .append("<h1>" + _("Item search results") + "</h1>")
495
                .append("<h1>" + _("Item search results") + "</h1>")
456
                .append($('<p>').append(advSearchLink))
496
                .append($('<p>').append(advSearchLink))
Lines 458-478 Link Here
458
                    .addClass("btn-toolbar")
498
                    .addClass("btn-toolbar")
459
                    .attr("id","toolbar")
499
                    .attr("id","toolbar")
460
                    .append(editSearchLink)
500
                    .append(editSearchLink)
501
                    .append(getShareableLink)
461
                );
502
                );
462
            $('#results-wrapper').empty()
503
            $('#results-wrapper').empty()
463
                .append(results_heading)
504
                .append(results_heading)
464
                .append(table);
505
                .append(table);
465
506
466
            var params = [];
507
            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
508
477
            $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
509
            $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
478
                "destroy": true,
510
                "destroy": true,
479
- 

Return to bug 14322