From bf7eaca974c2e5403094b2830e28d822f8202a90 Mon Sep 17 00:00:00 2001 From: rangi Date: Sun, 15 Jul 2007 22:19:01 +0000 Subject: [PATCH] Fix for bug 1313, silent failure when entering manual invoice with invalid itemnumber --- C4/Accounts.pm | 3 +-- .../prog/en/members/maninvoice.tmpl | 10 +++++--- members/maninvoice.pl | 24 +++++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index e385443899..82262f2b1a 100755 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -314,8 +314,7 @@ sub manualinvoice{ 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) diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl index 649d49ef4d..c353a459a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/maninvoice.tmpl @@ -1,11 +1,15 @@ -Koha › Patrons › Create Manual Invoice +Koha › Borrowers › Create Manual Invoice - + + + ERROR an invalid itemnumber was entered, please hit back and try again + +
" /> @@ -27,7 +31,7 @@ " /> - + diff --git a/members/maninvoice.pl b/members/maninvoice.pl index a09f308ced..00157da8d8 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -42,8 +42,28 @@ if ($add){ my $desc=$input->param('desc'); my $amount=$input->param('amount'); my $type=$input->param('type'); - manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount); - print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); + 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", -- 2.39.2
Manual Invoice