Bug 30477: Add new UNIMARC installer translation files
[koha.git] / catalogue / updateitem.pl
1 #!/usr/bin/perl
2
3 # $Id: updateitem.pl,v 1.9.2.1.2.4 2006/10/05 18:36:50 kados Exp $
4 # Copyright 2006 LibLime
5 #
6 # This file is part of Koha.
7 #
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.
12 #
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.
17 #
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 Modern::Perl;
21 use CGI qw ( -utf8 );
22 use C4::Auth qw( checkauth );
23 use C4::Context;
24 use C4::Output;
25 use C4::Circulation qw( LostItem );
26 use C4::Reserves;
27
28 my $cgi= CGI->new;
29
30 checkauth($cgi, 0, {circulate => 'circulate_remaining_permissions'}, 'intranet');
31
32 my $op = $cgi->param('op') || "";
33 my $biblionumber=$cgi->param('biblionumber');
34 my $itemnumber=$cgi->param('itemnumber');
35 my $biblioitemnumber=$cgi->param('biblioitemnumber');
36 my $itemlost=$cgi->param('itemlost');
37 my $itemnotes=$cgi->param('itemnotes');
38 my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic');
39 my $withdrawn=$cgi->param('withdrawn');
40 my $damaged=$cgi->param('damaged');
41 my $exclude_from_local_holds_priority = $cgi->param('exclude_from_local_holds_priority');
42
43 my $confirm=$cgi->param('confirm');
44 my $dbh = C4::Context->dbh;
45
46 # get the rest of this item's information
47 my $item = Koha::Items->find($itemnumber);
48 my $item_data_hashref = $item->unblessed;
49
50 # make sure item statuses are set to 0 if empty or NULL
51 for ($damaged,$itemlost,$withdrawn) {
52     if (!$_ or $_ eq "") {
53         $_ = 0;
54     }
55 }
56
57 my $messages = q{};
58
59 # modify MARC item if input differs from items table.
60 if ( $op eq "set_non_public_note" ) {
61     checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
62     if ((not defined  $item_data_hashref->{'itemnotes_nonpublic'}) or $itemnotes_nonpublic ne $item_data_hashref->{'itemnotes_nonpublic'}) {
63         $item->itemnotes_nonpublic($itemnotes_nonpublic);
64     }
65 }
66 elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from form
67     checkauth($cgi, 0, {editcatalogue => 'edit_items'}, 'intranet');
68     if ((not defined  $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
69         $item->itemnotes($itemnotes);
70     }
71 } elsif ( $op eq "set_lost" && $itemlost ne $item_data_hashref->{'itemlost'}) {
72     $item->itemlost($itemlost);
73 } elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) {
74     $item->withdrawn($withdrawn);
75 } elsif ( $op eq "set_exclude_priority" && $exclude_from_local_holds_priority ne $item_data_hashref->{'exclude_from_local_holds_priority'}) {
76     $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority);
77     $messages = "updated_exclude_from_local_holds_priority=$exclude_from_local_holds_priority&";
78 } elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) {
79     $item->damaged($damaged);
80 } else {
81     #nothings changed, so do nothing.
82     print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
83         exit;
84 }
85
86 $item->store;
87
88 LostItem($itemnumber, 'moredetail') if $op eq "set_lost";
89
90 print $cgi->redirect("moredetail.pl?" . $messages . "biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");