[Koha-patches] [PATCH] updateitem.pl cleanup
Joe Atzberger
joe.atzberger at liblime.com
Wed Jan 28 20:25:49 CET 2009
updateitem.pl cleanup:
~ Comment out four unused dependencies!
~ Remove unused dbh.
~ Clarify defaults of "0" and add default of "" where needed for
data integrity and to avoid warnings on undef comparisons.
~ Convert if/elsif's to series of if's. The limitation that only
one edit at a time would be performed comes from the *interface*, and
is not a logical requirement. The interface may be adapted. For example,
changing "damaged" status and adding a note at the same time...
something like "Missing first 12 pages."
~ Tidy up declarations.
---
catalogue/updateitem.pl | 57 ++++++++++++++++++++--------------------------
1 files changed, 25 insertions(+), 32 deletions(-)
diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl
index 7b0b673..6566fb7 100755
--- a/catalogue/updateitem.pl
+++ b/catalogue/updateitem.pl
@@ -17,63 +17,56 @@
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
+
use strict;
use warnings;
use CGI;
use C4::Auth;
use C4::Context;
-use C4::Biblio;
use C4::Items;
-use C4::Output;
-use C4::Circulation;
use C4::Accounts;
-use C4::Reserves;
+
+# use C4::Biblio;
+# use C4::Circulation;
+# use C4::Reserves;
+# use C4::Output;
my $cgi= new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($cgi, 0, {circulate => 1}, 'intranet');
-my $biblionumber=$cgi->param('biblionumber');
-my $itemnumber=$cgi->param('itemnumber');
-my $biblioitemnumber=$cgi->param('biblioitemnumber');
-my $itemlost=$cgi->param('itemlost');
-my $itemnotes=$cgi->param('itemnotes');
-my $wthdrawn=$cgi->param('wthdrawn');
-my $damaged=$cgi->param('damaged');
-
-my $confirm=$cgi->param('confirm');
-my $dbh = C4::Context->dbh;
+my $biblionumber = $cgi->param('biblionumber' );
+my $itemnumber = $cgi->param('itemnumber' );
+my $itemnotes = $cgi->param('itemnotes' ) || '';
+my $itemlost = $cgi->param('itemlost' ) || 0;
+my $wthdrawn = $cgi->param('wthdrawn' ) || 0;
+my $damaged = $cgi->param('damaged' ) || 0;
+# make sure item statuses are set to 0 if empty or NULL
# get the rest of this item's information
my $item_data_hashref = GetItem($itemnumber, undef);
-# make sure item statuses are set to 0 if empty or NULL
-for ($damaged,$itemlost,$wthdrawn) {
- if (!$_ or $_ eq "") {
- $_ = 0;
- }
-}
-
# modify MARC item if input differs from items table.
my $item_changes = {};
if (defined $itemnotes) { # i.e., itemnotes parameter passed from form
if ((not defined $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
$item_changes->{'itemnotes'} = $itemnotes;
}
-} elsif ($itemlost ne $item_data_hashref->{'itemlost'}) {
+}
+if ($itemlost ne $item_data_hashref->{'itemlost'}) {
$item_changes->{'itemlost'} = $itemlost;
-} elsif ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) {
+}
+if ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) {
$item_changes->{'wthdrawn'} = $wthdrawn;
-} elsif ($damaged ne $item_data_hashref->{'damaged'}) {
+}
+if ($damaged ne $item_data_hashref->{'damaged'}) {
$item_changes->{'damaged'} = $damaged;
-} else {
- #nothings changed, so do nothing.
- print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
- exit;
-}
-
-ModItem($item_changes, $biblionumber, $itemnumber);
+}
-C4::Accounts::chargelostitem($itemnumber) if ($itemlost==1) ;
+if (scalar keys %$item_changes) {
+ ModItem($item_changes, $biblionumber, $itemnumber);
+ C4::Accounts::chargelostitem($itemnumber) if ($itemlost==1) ;
+} # else nothings changed, so do nothing.
print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
+exit;
--
1.5.5.GIT
More information about the Koha-patches
mailing list