[Koha-cvs] koha moredetail.pl updateitem.pl [dev_week]

Joshua Ferraro jmf at kados.org
Thu Oct 5 20:36:50 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Joshua Ferraro <kados>	06/10/05 18:36:50

Modified files:
	.              : moredetail.pl updateitem.pl 

Log message:
	Complete re-write of updateitem.pl. Currently, it only allows status
	changing and when changing statuses it doesn't alter any data but what
	is in items table (leave it to the cron job to update zebra and marc).
	This function, to my knowledge, is only used in moredetail.pl so the re-write
	shouldn't break anything.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/moredetail.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.25.2.4&r2=1.25.2.4.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/updateitem.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.9.2.1.2.3&r2=1.9.2.1.2.4

Patches:
Index: moredetail.pl
===================================================================
RCS file: /sources/koha/koha/Attic/moredetail.pl,v
retrieving revision 1.25.2.4
retrieving revision 1.25.2.4.2.1
diff -u -b -r1.25.2.4 -r1.25.2.4.2.1
--- moredetail.pl	5 Feb 2006 21:59:20 -0000	1.25.2.4
+++ moredetail.pl	5 Oct 2006 18:36:50 -0000	1.25.2.4.2.1
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # NOTE: Use standard 8-space tabs for this file (indents are 4 spaces)
 
-# $Id: moredetail.pl,v 1.25.2.4 2006/02/05 21:59:20 kados Exp $
+# $Id: moredetail.pl,v 1.25.2.4.2.1 2006/10/05 18:36:50 kados Exp $
 
 # Copyright 2000-2003 Katipo Communications
 #
@@ -79,6 +79,10 @@
 $results[0]=$data;
 
 foreach my $item (@items){
+	my ($itemlost, at itemlost_loop) = GetAuthItemlost($item->{'itemlost'});
+	my ($itembinding, at itembinding_loop) = GetAuthItembinding($item->{'binding'});
+	$item->{itembindingloop}=\@itembinding_loop;
+	$item->{itemlostloop}=\@itemlost_loop;
     $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
     $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
     $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
@@ -96,7 +100,8 @@
     }
 }
 
-$template->param(BIBITEM_DATA => \@results,
+$template->param(
+		BIBITEM_DATA => \@results,
 		ITEM_DATA => \@items,
 		loggedinuser => $loggedinuser,
 		intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),

Index: updateitem.pl
===================================================================
RCS file: /sources/koha/koha/Attic/updateitem.pl,v
retrieving revision 1.9.2.1.2.3
retrieving revision 1.9.2.1.2.4
diff -u -b -r1.9.2.1.2.3 -r1.9.2.1.2.4
--- updateitem.pl	4 Oct 2006 15:56:02 -0000	1.9.2.1.2.3
+++ updateitem.pl	5 Oct 2006 18:36:50 -0000	1.9.2.1.2.4
@@ -1,8 +1,7 @@
 #!/usr/bin/perl
 
-# $Id: updateitem.pl,v 1.9.2.1.2.3 2006/10/04 15:56:02 kados Exp $
-
-# Copyright 2000-2002 Katipo Communications
+# $Id: updateitem.pl,v 1.9.2.1.2.4 2006/10/05 18:36:50 kados Exp $
+# Copyright 2006 LibLime
 #
 # This file is part of Koha.
 #
@@ -18,8 +17,7 @@
 # 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 strict; use warnings;
 use CGI;
 use C4::Context;
 use C4::Biblio;
@@ -27,141 +25,66 @@
 use C4::Circulation::Circ2;
 use C4::Accounts2;
 
-my $env;
-my $input= new CGI;
+my $cgi= new CGI;
 
-# our inputs
-my $bibnum=checkinp($input->param('bibnum'));
-my $itemnum=checkinp($input->param('itemnumber'));
-my $copyright=checkinp($input->param('copyright'));
-my $seriestitle=checkinp($input->param('series'));
-my $serial=checkinp($input->param('serial'));
-my $unititle=checkinp($input->param('unititle'));
-my $notes=checkinp($input->param('itemnotes'));
-my $barcode=$input->param('barcode');
-my $bibitemnum=checkinp($input->param('bibitemnum'));
-my $itemtype=checkinp($input->param('itemtype'));
-my $isbn=checkinp($input->param('isbn'));
-my $publishercode=checkinp($input->param('publisher'));
-my $publicationdate=checkinp($input->param('publication'));
-my $class=checkinp($input->param('class'));
-my $homebranch=checkinp($input->param('homebranch'));
-my $holdingbranch=checkinp($input->param('holdingbranch'));
-my $lost=$input->param('lost');
-my $wthdrawn=$input->param('withdrawn');
-my $binding=$input->param('binding');
-my $classification;
-my $dewey;
-my $subclass;
-my $override=$input->param('override');
-
-if ($itemtype ne 'NF'){
-	$classification=$class;
-}
-
-if ($class =~/[0-9]+/){
-	$dewey= $class;
-	$dewey=~ s/[a-z]+//gi;
-	my @temp;
-	if ($class =~ /\./){
-		@temp=split(/[0-9]+\.[0-9]+/,$class);
-	} else {
-		@temp=split(/[0-9]+/,$class);
-	}
-	$classification=$temp[0];
-	$subclass=$temp[1];
-}
-else{
-	$dewey='';
+my $biblionumber=$cgi->param('biblionumber');
+my $itemnumber=$cgi->param('itemnumber');
+my $biblioitemnumber=$cgi->param('biblioitemnumber');
+my $itemlost=$cgi->param('itemlost');
+my $wthdrawn=$cgi->param('wthdrawn');
+my $binding=$cgi->param('binding');
+
+my $confirm=$cgi->param('confirm');
+my $dbh = C4::Context->dbh;
+# get the rest of this item's information
+my $item_data_sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?");
+$item_data_sth->execute($itemnumber);
+my $item_data_hashref = $item_data_sth->fetchrow_hashref();
+
+# superimpose the new on the old
+$item_data_hashref->{'itemlost'} = $itemlost if $itemlost;
+$item_data_hashref->{'wthdrawn'} = $wthdrawn if $wthdrawn;
+$item_data_hashref->{'binding'} = $binding if $binding;
+
+# check reservations
+my ($status, $reserve) = C4::Reserves2::CheckReserves($itemnumber, $item_data_hashref->{'barcode'});
+if ($reserve){
+	print $cgi->header;
+	print "Reservation found";
 }
-my $illus=checkinp($input->param('illustrations'));
-my $pages=checkinp($input->param('pages'));
-my $volumeddesc=checkinp($input->param('volume'));
-
-if ($wthdrawn == 0 && $override ne 'yes'){
-  moditem( 
-  		{ biblionumber => $bibnum,
-	     loan         =>'loan',
-	     itemnum      => $itemnum,
-	     bibitemnum   => $bibitemnum,
-	     barcode      => $barcode,
-	     notes        => $notes,
-	     homebranch   => $homebranch,
-		 holdingbranch => $holdingbranch,
-	     lost         => $lost,
-	     wthdrawn     => $wthdrawn,
-		 binding	  => $binding
-	     });
-  if ($lost ==1){
-    my $dbh = C4::Context->dbh;
-    my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
-    $sth->execute($itemnum);
-    my $data=$sth->fetchrow_hashref;
-    if ($data->{'borrowernumber'} ne '') {
-      #item on issue add replacement cost to borrowers record
-      my $accountno=getnextacctno($env,$data->{'borrowernumber'},$dbh);
-      my $item=getiteminformation($env, $itemnum);
-      my $sth2=$dbh->prepare("Insert into accountlines
+# check issues
+my $sth=$dbh->prepare("SELECT * FROM issues WHERE (itemnumber=? AND returndate IS NULL)");
+$sth->execute($itemnumber);
+my $issues=$sth->fetchrow_hashref();
+
+# if a borrower lost the item, add a replacement cost to the their record
+if ( ($issues->{borrowernumber}) && ($itemlost==1) ){
+
+		# first make sure the borrower hasn't already been charged for this item
+		my $sth1=$dbh->prepare("SELECT * from accountlines
+		WHERE borrowernumber=? AND itemnumber=?");
+		$sth1->execute($issues->{'borrowernumber'},$itemnumber);
+		my $existing_charge_hashref=$sth1->fetchrow_hashref();
+
+		# OK, they haven't
+		unless ($existing_charge_hashref) {
+			# This item is on issue ... add replacement cost to the borrower's record and mark it returned
+			my $accountno = getnextacctno('',$issues->{'borrowernumber'},$dbh);
+			my $sth2=$dbh->prepare("INSERT INTO accountlines
       (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
-      values
+			VALUES
       (?,?,now(),?,?,'L',?,?)");
-      $sth2->execute($data->{'borrowernumber'},$accountno,$item->{'replacementprice'},
-      "Lost Item $item->{'title'} $item->{'barcode'}",
-      $item->{'replacementprice'},$itemnum);
+			$sth2->execute($issues->{'borrowernumber'},$accountno,$item_data_hashref->{'replacementprice'},
+			"Lost Item $item_data_hashref->{'title'} $item_data_hashref->{'barcode'}",
+			$item_data_hashref->{'replacementprice'},$itemnumber);
       $sth2->finish;
     }
-    $sth->finish;
-  }
-  print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
-} else {
-
-#  print "marking cancelled";
-  #need to check if it is on reserve or issued
-  my $dbh = C4::Context->dbh;
-  my $flag=0;
-  my ($resbor,$resrec)=C4::Reserves2::CheckReserves($env,$dbh,$itemnum);
- # print $resbor;
-  if ($resbor){
-    print $input->header;
-    print "The biblio or biblioitem this item belongs to has a reserve on it";
-    $flag=1;
-  }
-  my $sth=$dbh->prepare("Select * from issues where (itemnumber=?) and (returndate is null)");
-  $sth->execute($itemnum);
-  my $data=$sth->fetchrow_hashref;
-  if ($data->{'borrowernumber'} ne '') {
-    print $input->header;
-    print "<p>Item is on issue";
-    $flag=1;
-  }
-  $sth->finish;
-  if ($flag == 1){
-    my $url=$input->self_url;
-    $url.="&override=yes";
-    print "<p> <a href=$url>Cancel Anyway</a> &nbsp; or <a href=\"\">Back</a>";
-  }else {
-    moditem({ biblionumber => $bibnum,
-	      loan         => 'loan',
-	      itemnum      => $itemnum,
-	      bibitemnum   => $bibitemnum,
-	      barcode      => $barcode,
-	      notes        => $notes,
-	      homebranch   => $homebranch,
-		  holdingbranch => $holdingbranch,
-	      lost         => $lost,
-	      wthdrawn     => $wthdrawn,
-		  binding      => $binding
-	      });
-    print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
-  }
 }
-#print $bibitemnum;
+$sth->finish;
 
-sub checkinp{
-  my ($inp)=@_;
-  $inp=~ s/\'/\\\'/g;
-  $inp=~ s/\"/\\\"/g;
-  return($inp);
-}
+# FIXME: eventually we'll use Biblio.pm, but it's currently too buggy
+#ModItem( $dbh,'',$biblionumber,$itemnumber,'',$item_hashref );
+$sth = $dbh->prepare("UPDATE items SET wthdrawn=?,itemlost=?,binding=? WHERE itemnumber=?");
+$sth->execute($wthdrawn,$itemlost,$binding,$itemnumber);
 
-#sub checkissue{
+print $cgi->redirect("moredetail.pl?type=intra&bib=$biblionumber&bi=$biblioitemnumber");





More information about the Koha-cvs mailing list