Bug 17680: Fix conflict with bug 18651
[koha.git] / C4 / SIP / interactive_item_dump.pl
1 #!/usr/bin/perl
2 #
3
4 use warnings;
5 use strict;
6
7 use C4::SIP::ILS::Item;
8 use Data::Dumper;
9
10 my $compare = (@ARGV) ? shift : 0;
11 while (1) {
12         print "Enter item barcode: ";
13         my $in = <>;
14         defined($in) or last;
15         chomp($in);
16         last unless $in;
17         my $item = C4::SIP::ILS::Item->new($in);
18     unless ($item) {
19         print "No item ($in)";
20         next;
21     }
22     for (qw(marc marcxml)) { # Letting it just in case but should not longer be useful
23         $item->{$_} = 'suppressed...';
24     }
25     my $queue = $item->hold_queue();
26     print "Item ($in): ", Dumper($item);
27     print "hold_queue: ", Dumper($queue);
28     my $holdernumber;
29         if ($queue and scalar(@$queue)) {
30         $holdernumber = $queue->[0]->{borrowernumber};
31         print "first borrowernumber: $holdernumber\n";
32     }
33     if ($compare) {
34         print "Enter patron barcode: ";
35         my $barcode = <>;
36         defined($barcode) or next;
37         chomp($barcode);
38         next unless $barcode;
39         my $x = ILS::Item::_barcode_to_borrowernumber($barcode) || 'UNDEF';
40         print  "         converts to: $x\n";
41         printf "         compares as: %s\n", 
42             ($item->barcode_is_borrowernumber($barcode,$holdernumber) ? 'TRUE' : 'FALSE');
43     }
44 }