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

(-)a/catalogue/itemsearch.pl (+16 lines)
Lines 75-80 if (defined $format and $format eq 'json') { Link Here
75
75
76
    # Retrieve all results
76
    # Retrieve all results
77
    $cgi->param('rows', 0);
77
    $cgi->param('rows', 0);
78
} elsif (defined $format and $format eq 'barcodes') {
79
    # Retrieve all results
80
    $cgi->param('rows', 0);
78
} elsif (defined $format) {
81
} elsif (defined $format) {
79
    die "Unsupported format $format";
82
    die "Unsupported format $format";
80
}
83
}
Lines 196-201 if (scalar keys %params > 0) { Link Here
196
    };
199
    };
197
200
198
    my ($results, $total_rows) = SearchItems($filter, $search_params);
201
    my ($results, $total_rows) = SearchItems($filter, $search_params);
202
203
    if ($format eq 'barcodes') {
204
        print $cgi->header({
205
            type => 'text/plain',
206
            attachment => 'barcodes.txt',
207
        });
208
209
        foreach my $item (@$results) {
210
            print $item->{barcode} . "\n";
211
        }
212
        exit;
213
    }
214
199
    if ($results) {
215
    if ($results) {
200
        # Get notforloan labels
216
        # Get notforloan labels
201
        my $notforloan_map = {};
217
        my $notforloan_map = {};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt (-30 / +50 lines)
Lines 226-236 Link Here
226
        + '  <thead>' + tr + tr + '</thead>'
226
        + '  <thead>' + tr + tr + '</thead>'
227
        + '  <tbody></tbody>'
227
        + '  <tbody></tbody>'
228
        + '</table>';
228
        + '</table>';
229
      var results_heading = "<h1>" + _("Item search results") + "</h1>";
229
230
      results_heading += "<p><a href=\"/cgi-bin/koha/catalogue/search.pl\">" + _("Go to advanced search") + "</a></p>";
230
      var advSearchLink = $('<a>')
231
      results_heading += "<p><a class=\"editsearchlink\" href=\"#\">" + _("Edit search") + "</a>";
231
        .attr('href', '/cgi-bin/koha/catalogue/search.pl')
232
      results_heading += " | <a class=\"resultstocsv\" href=\"#\">" + _("Output results to csv") + "</a></p>";
232
        .html(_("Go to advanced search"));
233
      $('#results-wrapper').empty().html(results_heading + table);
233
      var editSearchLink = $('<a>')
234
        .attr('href', '#')
235
        .html(_("Edit search"))
236
        .addClass('btn btn-default btn-xs')
237
        .on('click', function(e) {
238
          e.preventDefault();
239
          $('#item-search-block').show();
240
        });
241
242
      var csvExportLink = $('<a>')
243
        .attr('href', '#')
244
        .html(_("Export results to CSV"))
245
        .addClass('btn btn-default btn-xs')
246
        .on('click', function(e) {
247
          e.preventDefault();
248
          $('#format-csv').prop('checked', true);
249
          $('#itemsearchform').submit();
250
          $('#format-html').prop('checked', true);
251
        });
252
      var barcodesExportLink = $('<a>')
253
        .attr('href', '#')
254
        .html(_("Export results to barcodes file"))
255
        .addClass('btn btn-default btn-xs')
256
        .on('click', function(e) {
257
          e.preventDefault();
258
          $('#format-barcodes').prop('checked', true);
259
          $('#itemsearchform').submit();
260
          $('#format-html').prop('checked', true);
261
        });
262
263
      var editSearchAndExportLinks = $('<p>')
264
        .append(editSearchLink)
265
        .append(' | ')
266
        .append(csvExportLink)
267
        .append(' ')
268
        .append(barcodesExportLink);
269
270
      var results_heading = $('<div>').addClass('results-heading')
271
        .append("<h1>" + _("Item search results") + "</h1>")
272
        .append($('<p>').append(advSearchLink))
273
        .append(editSearchAndExportLinks);
274
      $('#results-wrapper').empty()
275
        .append(results_heading)
276
        .append(table);
234
277
235
      var params = [];
278
      var params = [];
236
      $form.find('select').not(':disabled').find('option:selected').each(function () {
279
      $form.find('select').not(':disabled').find('option:selected').each(function () {
Lines 310-320 Link Here
310
      });
353
      });
311
    }
354
    }
312
355
313
    function hideForm() {
314
      $("#item-search-block").hide();
315
      $('.editsearchlink').show();
316
    }
317
318
    $(document).ready(function () {
356
    $(document).ready(function () {
319
      $('#toolbar').fixFloat();
357
      $('#toolbar').fixFloat();
320
      // Add the "New field" link.
358
      // Add the "New field" link.
Lines 351-376 Link Here
351
        var format = searchform.find('input[name="format"]:checked').val();
389
        var format = searchform.find('input[name="format"]:checked').val();
352
        if (format == 'html') {
390
        if (format == 'html') {
353
          submitForm(searchform);
391
          submitForm(searchform);
354
          hideForm();
392
          $("#item-search-block").hide();
355
          return false;
393
          return false;
356
        }
394
        }
357
      });
395
      });
358
359
      $("body").on("click",".editsearchlink",function(e) {
360
        e.preventDefault();
361
        $('#item-search-block').show();
362
        $(this).hide();
363
        return false;
364
      });
365
366
      $("body").on("click",".resultstocsv",function(e) {
367
        e.preventDefault();
368
        $('#format-csv').prop("checked",true);
369
        $('#itemsearchform').submit();
370
        hideForm();
371
        $('#format-html').prop("checked",true);
372
        return false;
373
      });
374
    });
396
    });
375
    //]]>
397
    //]]>
376
  </script>
398
  </script>
Lines 479-489 Link Here
479
              <label>Output:</label>
501
              <label>Output:</label>
480
              <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
502
              <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
481
              <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
503
              <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
504
              <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
482
            </div>
505
            </div>
483
          </fieldset>
506
          </fieldset>
484
      </form>
507
      </form>
485
486
      <p><a id="editsearchlink" href="#" style="display:none">Edit search</a></p>
487
    </div>
508
    </div>
488
  </div>
509
  </div>
489
  <div id="doc3" class="yui-t7">
510
  <div id="doc3" class="yui-t7">
490
- 

Return to bug 18394