Bug 8329 - GetLostItems in C4::Items.pm has a SELECT * Provided a smaller list based...
[koha.git] / catalogue / updateitem.pl
blobabc809d3334d0c2681cab1d5d1e805ccd460ccec
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 under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
22 use CGI;
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 $wthdrawn=$cgi->param('wthdrawn');
41 my $damaged=$cgi->param('damaged');
43 my $confirm=$cgi->param('confirm');
44 my $dbh = C4::Context->dbh;
46 # get the rest of this item's information
47 my $item_data_hashref = GetItem($itemnumber, undef);
49 # make sure item statuses are set to 0 if empty or NULL
50 for ($damaged,$itemlost,$wthdrawn) {
51 if (!$_ or $_ eq "") {
52 $_ = 0;
56 # modify MARC item if input differs from items table.
57 my $item_changes = {};
58 if (defined $itemnotes) { # i.e., itemnotes parameter passed from form
59 checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
60 if ((not defined $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
61 $item_changes->{'itemnotes'} = $itemnotes;
63 } elsif ($itemlost ne $item_data_hashref->{'itemlost'}) {
64 $item_changes->{'itemlost'} = $itemlost;
65 } elsif ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) {
66 $item_changes->{'wthdrawn'} = $wthdrawn;
67 } elsif ($damaged ne $item_data_hashref->{'damaged'}) {
68 $item_changes->{'damaged'} = $damaged;
69 } else {
70 #nothings changed, so do nothing.
71 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
72 exit;
75 ModItem($item_changes, $biblionumber, $itemnumber);
77 LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $itemlost;
79 print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");