Bug 12692 - Markup improvements to holds awaiting pickup report
[koha.git] / catalogue / getitem-ajax.pl
blob3bab89152318c7506ac15addc6e181994083f2bc
1 #!/usr/bin/perl
3 # Copyright BibLibre 2012
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use Modern::Perl;
21 use CGI;
22 use JSON;
24 use C4::Biblio;
25 use C4::Branch;
26 use C4::Items;
27 use C4::Koha;
28 use C4::Output;
30 my $cgi = new CGI;
31 my $item = {};
32 my $itemnumber = $cgi->param('itemnumber');
34 if($itemnumber) {
35 my $acq_fw = GetMarcStructure(1, 'ACQ');
36 my $fw = ($acq_fw) ? 'ACQ' : '';
37 $item = GetItem($itemnumber);
39 if($item->{homebranch}) {
40 $item->{homebranchname} = GetBranchName($item->{homebranch});
43 if($item->{holdingbranch}) {
44 $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
47 if(my $code = GetAuthValCode("items.notforloan", $fw)) {
48 $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
51 if(my $code = GetAuthValCode("items.restricted", $fw)) {
52 $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
55 if(my $code = GetAuthValCode("items.location", $fw)) {
56 $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
59 if(my $code = GetAuthValCode("items.ccode", $fw)) {
60 $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
63 if(my $code = GetAuthValCode("items.materials", $fw)) {
64 $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
67 my $itemtype = getitemtypeinfo($item->{itype});
68 $item->{itemtype} = $itemtype->{description};
71 my $json_text = to_json( $item, { utf8 => 1 } );
73 output_with_http_headers $cgi, undef, $json_text, 'json';