From 63f069951290dbdd7f2dc91b732f7691dc13cb06 Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Thu, 26 Jan 2012 16:04:53 +1300 Subject: [PATCH] Bug 6413 Added ability to add a note when paying or writing off a fine Code will also respect notes when using the "Writeoff All" button but WILL NOT when using either the "Pay Amount" or "Pay Selected" buttons Fixed uri encoding of arguments --- C4/Accounts.pm | 18 ++++++++++-------- .../intranet-tmpl/prog/en/modules/members/pay.tt | 2 ++ .../prog/en/modules/members/paycollect.tt | 2 ++ members/pay.pl | 18 +++++++++++------- members/paycollect.pl | 9 ++++++--- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index e822b6a..a996263 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -157,7 +157,7 @@ sub makepayment { #here we update both the accountoffsets and the account lines #updated to check, if they are paying off a lost item, we return the item # from their card, and put a note on the item record - my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_; + my ( $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_; my $dbh = C4::Context->dbh; my $manager_id = 0; $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; @@ -197,14 +197,15 @@ sub makepayment { # create new line my $payment = 0 - $amount; + $payment_note = "" unless defined $payment_note; my $ins = $dbh->prepare( "INSERT - INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding) - VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0)" + INTO accountlines (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, note) + VALUES ( ?, ?, now(), ?, 'Payment,thanks', 'Pay', 0, ?)" ); - $ins->execute($borrowernumber, $nextaccntno, $payment); + $ins->execute($borrowernumber, $nextaccntno, $payment, $payment_note); $ins->finish; } @@ -724,10 +725,11 @@ sub recordpayment_selectaccts { # makepayment needs to be fixed to handle partials till then this separate subroutine # fills in sub makepartialpayment { - my ( $borrowernumber, $accountno, $amount, $user, $branch ) = @_; + my ( $borrowernumber, $accountno, $amount, $user, $branchm, $payment_note ) = @_; if (!$amount || $amount < 0) { return; } + $payment_note = "" unless defined $payment_note; my $dbh = C4::Context->dbh; my $nextaccntno = getnextacctno($borrowernumber); @@ -743,11 +745,11 @@ sub makepartialpayment { # create new line my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, ' - . 'description, accounttype, amountoutstanding) ' - . ' VALUES (?, ?, now(), ?, ?, ?, 0)'; + . 'description, accounttype, amountoutstanding, note) ' + . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?)'; $dbh->do( $insert, undef, $borrowernumber, $nextaccntno, $amount, - "Payment, thanks - $user", 'Pay'); + "Payment, thanks - $user", 'Pay', $payment_note); UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber, $accountno ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index 8b0a545..3aefc66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -42,6 +42,7 @@ function confirmWriteoffAll() { Fines & Charges Sel Description + Payment Note Account Type Notify id Level @@ -74,6 +75,7 @@ function confirmWriteoffAll() { [% END %] [% line.description %] [% line.title |html_entity %] + [% line.accounttype %] [% line.notify_id %] [% line.notify_level %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index ba18215..d62f846 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -103,6 +103,7 @@ function moneyFormat(textObj) { + @@ -158,6 +159,7 @@ function moneyFormat(textObj) { +
Description
diff --git a/members/pay.pl b/members/pay.pl index 72a109f..dab3976 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -29,6 +29,7 @@ use strict; use warnings; +use URI::Escape; use C4::Context; use C4::Auth; use C4::Output; @@ -90,7 +91,8 @@ if ($writeoff_all) { my $itemno = $input->param('itemnumber'); my $account_type = $input->param('accounttype'); my $amount = $input->param('amount'); - writeoff( $accountno, $itemno, $account_type, $amount ); + my $payment_note = $input->param("payment_note"); + writeoff( $accountno, $itemno, $account_type, $amount, $payment_note ); } for (@names) { @@ -110,7 +112,8 @@ add_accounts_to_template(); output_html_with_http_headers $input, $cookie, $template->output; sub writeoff { - my ( $accountnum, $itemnum, $accounttype, $amount ) = @_; + my ( $accountnum, $itemnum, $accounttype, $amount, $payment_note ) = @_; + $payment_note = "" unless defined $payment_note; # if no item is attached to fine, make sure to store it as a NULL $itemnum ||= undef; @@ -118,7 +121,7 @@ sub writeoff { $writeoff_sth->execute( $accountnum, $borrowernumber ); my $acct = getnextacctno($borrowernumber); - $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount ); + $add_writeoff_sth->execute( $borrowernumber, $acct, $itemnum, $amount, $payment_note); UpdateStats( $branch, 'writeoff', $amount, q{}, q{}, q{}, $borrowernumber ); @@ -180,11 +183,11 @@ sub redirect_to_paycollect { $redirect .= get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 ); $redirect .= get_for_redirect( 'accountno', "accountno$line_no", 0 ); - $redirect .= get_for_redirect( 'description', "description$line_no", 0 ); $redirect .= get_for_redirect( 'title', "title$line_no", 0 ); $redirect .= get_for_redirect( 'itemnumber', "itemnumber$line_no", 0 ); $redirect .= get_for_redirect( 'notify_id', "notify_id$line_no", 0 ); $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 ); + $redirect .= q{&} . 'payment_note' . q{=} . uri_escape $input->param("payment_note_$line_no"); $redirect .= '&remote_user='; $redirect .= $user; return print $input->redirect($redirect); @@ -202,7 +205,8 @@ sub writeoff_all { my $itemno = $input->param("itemnumber$value"); my $amount = $input->param("amount$value"); my $accountno = $input->param("accountno$value"); - writeoff( $accountno, $itemno, $accounttype, $amount ); + my $payment_note = $input->param("payment_note_$value"); + writeoff( $accountno, $itemno, $accounttype, $amount, $payment_note ); } } @@ -282,8 +286,8 @@ sub get_writeoff_sth { . 'WHERE accountno=? and borrowernumber=?'; $writeoff_sth = $dbh->prepare($sql); my $insert = -q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)} - . q{values (?,?,?,now(),?,'Writeoff','W')}; +q{insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,note)} + . q{values (?,?,?,now(),?,'Writeoff','W',?)}; $add_writeoff_sth = $dbh->prepare($insert); } return; diff --git a/members/paycollect.pl b/members/paycollect.pl index 7dfb622..bb79c10 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -19,6 +19,7 @@ use strict; use warnings; +use URI::Escape; use C4::Context; use C4::Auth; use C4::Output; @@ -55,6 +56,7 @@ my $individual = $input->param('pay_individual'); my $writeoff = $input->param('writeoff_individual'); my $select_lines = $input->param('selected'); my $select = $input->param('selected_accts'); +my $payment_note = uri_unescape $input->param('payment_note'); my $accountno; if ( $individual || $writeoff ) { @@ -83,6 +85,7 @@ if ( $individual || $writeoff ) { description => $description, notify_id => $notify_id, notify_level => $notify_level, + payment_note => $payment_note, ); } elsif ($select_lines) { $total_due = $input->param('amt'); @@ -100,12 +103,12 @@ if ( $total_paid and $total_paid ne '0.00' ) { ); } else { if ($individual) { - if ( $total_paid == $total_due ) { + if ( $total_paid == $total_due ) { makepayment( $borrowernumber, $accountno, $total_paid, $user, - $branch ); + $branch, $payment_note ); } else { makepartialpayment( $borrowernumber, $accountno, $total_paid, - $user, $branch ); + $user, $branch, $payment_note ); } print $input->redirect( "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber"); -- 1.7.4.1
Description