Bug 15719: Silence warning in C4/Language.pm during web install
[koha.git] / catalogue / updateitem.pl
blob90c6de604a53a47635553990f1ded509d2a15c8e
1 #!/usr/bin/perl
3 # $Id: updateitem.pl,v 1.9.2.1.2.4 2006/10/05 18:36:50 kados Exp $
4 # Copyright 2006 LibLime
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use strict;
21 use warnings;
22 use CGI qw ( -utf8 );
23 use C4::Auth;
24 use C4::Context;
25 use C4::Biblio;
26 use C4::Items;
27 use C4::Output;
28 use C4::Circulation;
29 use C4::Reserves;
31 my $cgi= new CGI;
33 checkauth($cgi, 0, {circulate => 'circulate_remaining_permissions'}, 'intranet');
35 my $biblionumber=$cgi->param('biblionumber');
36 my $itemnumber=$cgi->param('itemnumber');
37 my $biblioitemnumber=$cgi->param('biblioitemnumber');
38 my $itemlost=$cgi->param('itemlost');
39 my $itemnotes=$cgi->param('itemnotes');
40 my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic');
41 my $withdrawn=$cgi->param('withdrawn');
42 my $damaged=$cgi->param('damaged');
44 my $confirm=$cgi->param('confirm');
45 my $dbh = C4::Context->dbh;
47 # get the rest of this item's information
48 my $item_data_hashref = GetItem($itemnumber, undef);
50 # make sure item statuses are set to 0 if empty or NULL
51 for ($damaged,$itemlost,$withdrawn) {
52 if (!$_ or $_ eq "") {
53 $_ = 0;
57 # modify MARC item if input differs from items table.
58 my $item_changes = {};
59 if (defined $itemnotes_nonpublic) { # i.e., itemnotes_nonpublic parameter passed from form
60 checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
61 if ((not defined $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
62 $item_changes->{'itemnotes_nonpublic'} = $itemnotes_nonpublic;
65 elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form
66 checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
67 if ((not defined $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
68 $item_changes->{'itemnotes'} = $itemnotes;
70 } elsif ($itemlost ne $item_data_hashref->{'itemlost'}) {
71 $item_changes->{'itemlost'} = $itemlost;
72 } elsif ($withdrawn ne $item_data_hashref->{'withdrawn'}) {
73 $item_changes->{'withdrawn'} = $withdrawn;
74 } elsif ($damaged ne $item_data_hashref->{'damaged'}) {
75 $item_changes->{'damaged'} = $damaged;
76 } else {
77 #nothings changed, so do nothing.
78 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
79 exit;
82 ModItem($item_changes, $biblionumber, $itemnumber);
84 LostItem($itemnumber, 'MARK RETURNED') if $itemlost;
86 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");