[Koha-cvs] koha C4/Accounts.pm koha-tmpl/intranet-tmpl/pro...

Chris Cormack crc at liblime.com
Mon Jul 16 00:19:02 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Chris Cormack <rangi>	07/07/15 22:19:02

Modified files:
	C4             : Accounts.pm 
	koha-tmpl/intranet-tmpl/prog/en/members: maninvoice.tmpl 
	members        : maninvoice.pl 

Log message:
	Fix for bug 1313, silent failure when entering manual invoice with invalid
	itemnumber

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Accounts.pm?cvsroot=koha&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl?cvsroot=koha&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/members/maninvoice.pl?cvsroot=koha&r1=1.10&r2=1.11

Patches:
Index: C4/Accounts.pm
===================================================================
RCS file: /sources/koha/koha/C4/Accounts.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- C4/Accounts.pm	2 Jul 2007 00:44:25 -0000	1.23
+++ C4/Accounts.pm	15 Jul 2007 22:19:01 -0000	1.24
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Accounts.pm,v 1.23 2007/07/02 00:44:25 rangi Exp $
+# $Id: Accounts.pm,v 1.24 2007/07/15 22:19:01 rangi Exp $
 
 use strict;
 require Exporter;
@@ -28,7 +28,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.23 $' =~ /\d+/g; 
+$VERSION = do { my @v = '$Revision: 1.24 $' =~ /\d+/g; 
 shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -314,8 +314,7 @@
     my $sth=$dbh->prepare("INSERT INTO  accountlines
                         (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id)
         VALUES (?, ?, now(), ?,?, ?,?,?,?)");
-#     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $data->{'itemnumber'});
-     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid);
+     $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid) || return $sth->errstr;
   } else {
     my $sth=$dbh->prepare("INSERT INTO  accountlines
             (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)

Index: koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl	3 Jul 2007 18:19:50 -0000	1.4
+++ koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl	15 Jul 2007 22:19:01 -0000	1.5
@@ -1,11 +1,15 @@
 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha &rsaquo; Patrons &rsaquo; Create Manual Invoice</title>
+<title>Koha &rsaquo; Borrowers &rsaquo; Create Manual Invoice</title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 
 <!-- TMPL_INCLUDE NAME="menus.inc" -->
 <!-- TMPL_INCLUDE NAME="menu-members.inc" -->
 
-
+<!-- TMPL_IF NAME="ERROR" -->
+<!-- TMPL_IF NAME="ITEMNUMBER" -->
+  ERROR an invalid itemnumber was entered, please hit back and try again
+<!-- /TMPL_IF -->
+<!-- TMPL_ELSE -->
 <form action="/cgi-bin/koha/members/maninvoice.pl" method="post"><input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
 	<table>
 	<caption>Manual Invoice</caption>
@@ -27,7 +31,7 @@
 
 <form action="/cgi-bin/koha/members/boraccount.pl" method="get"><input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR Name="borrowernumber" -->" /><input type="submit" value="Cancel" /></form>
 
-
+<!-- /TMPL_IF -->
 
 
 <!-- TMPL_INCLUDE Name="intranet-bottom.inc" -->

Index: members/maninvoice.pl
===================================================================
RCS file: /sources/koha/koha/members/maninvoice.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- members/maninvoice.pl	5 Jun 2007 08:54:21 -0000	1.10
+++ members/maninvoice.pl	15 Jul 2007 22:19:02 -0000	1.11
@@ -42,8 +42,28 @@
     my $desc=$input->param('desc');
     my $amount=$input->param('amount');
     my $type=$input->param('type');
-    manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
+    my $error=manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
+	if ($error){
+		my ($template, $loggedinuser, $cookie)
+		  = get_template_and_user({template_name => "members/maninvoice.tmpl",
+					query => $input,
+					type => "intranet",
+					authnotrequired => 0,
+					flagsrequired => {borrowers => 1},
+					debug => 1,
+					});
+		if ($error =~ /FOREIGN KEY/ && $error =~ /itemnumber/){
+			$template->param('ITEMNUMBER' => 1);
+		}
+		$template->param('ERROR' => $error);
+		print $input->header(
+			-type => 'utf-8',
+			-cookie => $cookie
+		),$template->output;
+	}
+	else {
     print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
+	}
 } else {
 	my ($template, $loggedinuser, $cookie)
 	= get_template_and_user({template_name => "members/maninvoice.tmpl",





More information about the Koha-cvs mailing list