@@ -, +, @@
---
C4/Accounts.pm | 439 +++++++++++---------
.../prog/en/lib/jquery/plugins/jquery.numeric.js | 127 ++++++
.../prog/en/modules/members/boraccount.tmpl | 61 ++-
.../intranet-tmpl/prog/en/modules/members/pay.tmpl | 67 +++-
members/boraccount.pl | 113 +++---
members/pay.pl | 190 +++++----
6 files changed, 651 insertions(+), 346 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.numeric.js
--- a/C4/Accounts.pm
+++ a/C4/Accounts.pm
@@ -17,8 +17,8 @@ package C4::Accounts;
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
use strict;
+
#use warnings; FIXME - Bug 2505
use C4::Context;
use C4::Stats;
@@ -29,16 +29,17 @@ use C4::Circulation qw(MarkIssueReturned);
use vars qw($VERSION @ISA @EXPORT);
BEGIN {
- # set the version for version checking
- $VERSION = 3.03;
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw(
- &recordpayment &makepayment &manualinvoice
- &getnextacctno &reconcileaccount &getcharges &getcredits
- &getrefunds &chargelostitem
- &ReversePayment
- ); # removed &fixaccounts
+ # set the version for version checking
+ $VERSION = 3.03;
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(
+ &recordpayment &makepayment &manualinvoice
+ &getnextacctno &reconcileaccount &getcharges
+ &ModNote &ModMeansOfPayment &ModManagerId &getMeansOfPaymentList &getcredits
+ &getrefunds &chargelostitem
+ &ReversePayment
+ ); # removed &fixaccounts
}
=head1 NAME
@@ -99,33 +100,33 @@ sub recordpayment {
if ( $accdata->{'amountoutstanding'} < $amountleft ) {
$newamtos = 0;
$amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
+ } else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
- my $thisacct = $accdata->{accountno};
+ my $thisacct = $accdata->{id};
my $usth = $dbh->prepare(
"UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
+ WHERE (id = ?)"
);
$usth->execute( $newamtos, $borrowernumber, $thisacct );
$usth->finish;
-# $usth = $dbh->prepare(
-# "INSERT INTO accountoffsets
-# (borrowernumber, accountno, offsetaccount, offsetamount)
-# VALUES (?,?,?,?)"
-# );
-# $usth->execute( $borrowernumber, $accdata->{'accountno'},
-# $nextaccntno, $newamtos );
+
+ # $usth = $dbh->prepare(
+ # "INSERT INTO accountoffsets
+ # (borrowernumber, accountno, offsetaccount, offsetamount)
+ # VALUES (?,?,?,?)"
+ # );
+ # $usth->execute( $borrowernumber, $accdata->{'accountno'},
+ # $nextaccntno, $newamtos );
$usth->finish;
}
# create new line
my $usth = $dbh->prepare(
"INSERT INTO accountlines
- (borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
- VALUES (?,?,now(),?,'Payment,thanks','Pay',?)"
+ (borrowernumber, accountno,date,time,amount,description,accounttype,amountoutstanding)
+ VALUES (?,?,now(),CURRENT_TIME,?,'Payment,thanks','Pay',?)"
);
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft );
$usth->finish;
@@ -135,7 +136,7 @@ sub recordpayment {
=head2 makepayment
- &makepayment($borrowernumber, $acctnumber, $amount, $branchcode);
+ &makepayment($accountlineid, $borrowernumber, $acctnumber, $amount, $branchcode, $note, $meansofpayment, $manager_id, $partpaymentamount);
Records the fact that a patron has paid off the entire amount he or
she owes.
@@ -144,7 +145,7 @@ C<$borrowernumber> is the patron's borrower number. C<$acctnumber> is
the account that was credited. C<$amount> is the amount paid (this is
only used to record the payment. It is assumed to be equal to the
amount owed). C<$branchcode> is the code of the branch where payment
-was made.
+was made. if $partpaymentamount > 0 it's a part payment
=cut
@@ -156,56 +157,70 @@ 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 ( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount ) = @_;
my $dbh = C4::Context->dbh;
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
my $newamtos = 0;
- my $sth =
- $dbh->prepare(
- "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?");
- $sth->execute( $borrowernumber, $accountno );
+ my $sth = $dbh->prepare("SELECT * FROM accountlines WHERE id=?");
+ $sth->execute( $accountlineid );
my $data = $sth->fetchrow_hashref;
$sth->finish;
-
+ my $newamountoutstanding=0;
+ my $payment = 0 - $amount;
+ $payment = 0-$data->{'amountoutstanding'};
+ my $finalamount = $amount;
+ my $descriptionpayment="Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'};
+ if($partpaymentamount!=0)
+ {
+ $newamountoutstanding=$data->{'amountoutstanding'}-$partpaymentamount;
+ $payment = 0 - $partpaymentamount;
+ $finalamount = $partpaymentamount;
+ $descriptionpayment="Part Payment for account n°".$accountno.",thanks - ".$user." : ".$data->{'description'};
+ }
$dbh->do(
"UPDATE accountlines
- SET amountoutstanding = 0
- WHERE borrowernumber = $borrowernumber
- AND accountno = $accountno
+ SET amountoutstanding = $newamountoutstanding
+ WHERE id = $accountlineid
"
);
# print $updquery;
-# $dbh->do( "
-# INSERT INTO accountoffsets
-# (borrowernumber, accountno, offsetaccount,
-# offsetamount)
-# VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos)
-# " );
+ # $dbh->do( "
+ # INSERT INTO accountoffsets
+ # (borrowernumber, accountno, offsetaccount,
+ # offsetamount)
+ # VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos)
+ # " );
# create new line
- my $payment = 0 - $amount;
+
+
$dbh->do( "
INSERT INTO accountlines
- (borrowernumber, accountno, date, amount,
- description, accounttype, amountoutstanding)
- VALUES ($borrowernumber, $nextaccntno, now(), $payment,
- 'Payment,thanks - $user', 'Pay', 0)
+ (borrowernumber, accountno, date, time, amount,
+ description, accounttype, amountoutstanding, note, meansofpayment, manager_id)
+ VALUES ($borrowernumber, $nextaccntno, now(), CURRENT_TIME, $payment,
+ '$descriptionpayment', 'Pay', 0, '$note', '$meansofpayment', '$manager_id')
" );
# FIXME - The second argument to &UpdateStats is supposed to be the
# branch code.
# UpdateStats is now being passed $accountno too. MTJ
- UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber,
- $accountno );
+ UpdateStats( $user, 'payment', $finalamount, '', '', '', $borrowernumber, $accountno );
$sth->finish;
#check to see what accounttype
if ( $data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L' ) {
returnlost( $borrowernumber, $data->{'itemnumber'} );
}
+
+ my $sth = $dbh->prepare("SELECT max(id) AS lastinsertid FROM accountlines");
+ $sth->execute();
+ my $datalastinsertid = $sth->fetchrow_hashref;
+ $sth->finish;
+ return $datalastinsertid->{'lastinsertid'};
}
=head2 getnextacctno
@@ -228,23 +243,22 @@ sub getnextacctno ($) {
LIMIT 1"
);
$sth->execute($borrowernumber);
- return ($sth->fetchrow || 1);
+ return ( $sth->fetchrow || 1 );
}
=head2 fixaccounts (removed)
- &fixaccounts($borrowernumber, $accountnumber, $amount);
+ &fixaccounts($accountlineid,$borrowernumber, $accountnumber, $amount);
#'
# FIXME - I don't understand what this function does.
sub fixaccounts {
- my ( $borrowernumber, $accountno, $amount ) = @_;
+ my ( $accountlineid, $borrowernumber, $accountno, $amount ) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(
- "SELECT * FROM accountlines WHERE borrowernumber=?
- AND accountno=?"
+ "SELECT * FROM accountlines WHERE id=?"
);
- $sth->execute( $borrowernumber, $accountno );
+ $sth->execute( $accountlineid );
my $data = $sth->fetchrow_hashref;
# FIXME - Error-checking
@@ -256,70 +270,83 @@ sub fixaccounts {
UPDATE accountlines
SET amount = '$amount',
amountoutstanding = '$outstanding'
- WHERE borrowernumber = $borrowernumber
- AND accountno = $accountno
+ WHERE id = $accountlineid
EOT
# FIXME: exceedingly bad form. Use prepare with placholders ("?") in query and execute args.
}
=cut
-sub returnlost{
+sub returnlost {
my ( $borrowernumber, $itemnum ) = @_;
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum );
- my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber );
- my @datearr = localtime(time);
- my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
- my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
- ModItem({ paidfor => "Paid for by $bor $date" }, undef, $itemnum);
+ my $borrower = C4::Members::GetMember( 'borrowernumber' => $borrowernumber );
+ my @datearr = localtime(time);
+ my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
+ my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";
+ ModItem( { paidfor => "Paid for by $bor $date" }, undef, $itemnum );
}
+sub chargelostitem {
-sub chargelostitem{
-# lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for
-# FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that
-# a charge has been added
-# FIXME : if no replacement price, borrower just doesn't get charged?
-
- my $dbh = C4::Context->dbh();
+ # lost ==1 Lost, lost==2 longoverdue, lost==3 lost and paid for
+ # FIXME: itemlost should be set to 3 after payment is made, should be a warning to the interface that
+ # a charge has been added
+ # FIXME : if no replacement price, borrower just doesn't get charged?
+
+ my $dbh = C4::Context->dbh();
my ($itemnumber) = @_;
- my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title
+ my $sth = $dbh->prepare(
+ "SELECT issues.*,items.*,biblio.title
FROM issues
JOIN items USING (itemnumber)
JOIN biblio USING (biblionumber)
- WHERE issues.itemnumber=?");
+ WHERE issues.itemnumber=?"
+ );
$sth->execute($itemnumber);
- my $issues=$sth->fetchrow_hashref();
+ my $issues = $sth->fetchrow_hashref();
# if a borrower lost the item, add a replacement cost to the their record
- if ( $issues->{borrowernumber} ){
+ if ( $issues->{borrowernumber} ) {
# first make sure the borrower hasn't already been charged for this item
- my $sth1=$dbh->prepare("SELECT * from accountlines
- WHERE borrowernumber=? AND itemnumber=? and accounttype='L'");
- $sth1->execute($issues->{'borrowernumber'},$itemnumber);
- my $existing_charge_hashref=$sth1->fetchrow_hashref();
+ my $sth1 = $dbh->prepare(
+ "SELECT * from accountlines
+ WHERE borrowernumber=? AND itemnumber=? and accounttype='L'"
+ );
+ $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
# Note that we add this to the account even if there's no replacement price, allowing some other
# process (or person) to update it, since we don't handle any defaults for replacement prices.
- my $accountno = getnextacctno($issues->{'borrowernumber'});
- my $sth2=$dbh->prepare("INSERT INTO accountlines
- (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
- VALUES (?,?,now(),?,?,'L',?,?)");
- $sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'},
- "Lost Item $issues->{'title'} $issues->{'barcode'}",
- $issues->{'replacementprice'},$itemnumber);
+ my $accountno = getnextacctno( $issues->{'borrowernumber'} );
+ my $sth2 = $dbh->prepare(
+ "INSERT INTO accountlines
+ (borrowernumber,accountno,date,time,amount,description,accounttype,amountoutstanding,itemnumber)
+ VALUES (?,?,now(),CURRENT_TIME,?,?,'L',?,?)"
+ );
+ $sth2->execute(
+ $issues->{'borrowernumber'},
+ $accountno,
+ $issues->{'replacementprice'},
+ "Lost Item $issues->{'title'} $issues->{'barcode'}",
+ $issues->{'replacementprice'}, $itemnumber
+ );
$sth2->finish;
- # FIXME: Log this ?
+
+ # FIXME: Log this ?
}
+
#FIXME : Should probably have a way to distinguish this from an item that really was returned.
warn " $issues->{'borrowernumber'} / $itemnumber ";
- C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber);
- # Shouldn't MarkIssueReturned do this?
- C4::Items::ModItem({ onloan => undef }, undef, $itemnumber);
+ C4::Circulation::MarkIssueReturned( $issues->{borrowernumber}, $itemnumber );
+
+ # Shouldn't MarkIssueReturned do this?
+ C4::Items::ModItem( { onloan => undef }, undef, $itemnumber );
}
$sth->finish;
}
@@ -327,7 +354,7 @@ sub chargelostitem{
=head2 manualinvoice
&manualinvoice($borrowernumber, $itemnumber, $description, $type,
- $amount, $user);
+ $amount, $note, $meansofpayment);
C<$borrowernumber> is the patron's borrower number.
C<$description> is a description of the transaction.
@@ -340,7 +367,7 @@ should be the empty string.
#'
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
-# are :
+# are :
# 'C' = CREDIT
# 'FOR' = FORGIVEN (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
# 'N' = New Card fee
@@ -351,7 +378,8 @@ should be the empty string.
#
sub manualinvoice {
- my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_;
+ my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment ) = @_;
+ my $manager_id = C4::Context->userenv->{'number'};
my $dbh = C4::Context->dbh;
my $notifyid = 0;
my $insert;
@@ -359,16 +387,16 @@ sub manualinvoice {
my $accountno = getnextacctno($borrowernumber);
my $amountleft = $amount;
-# if ( $type eq 'CS'
-# || $type eq 'CB'
-# || $type eq 'CW'
-# || $type eq 'CF'
-# || $type eq 'CL' )
-# {
-# my $amount2 = $amount * -1; # FIXME - $amount2 = -$amount
-# $amountleft =
-# fixcredit( $borrowernumber, $amount2, $itemnum, $type, $user );
-# }
+ # if ( $type eq 'CS'
+ # || $type eq 'CB'
+ # || $type eq 'CW'
+ # || $type eq 'CF'
+ # || $type eq 'CL' )
+ # {
+ # my $amount2 = $amount * -1; # FIXME - $amount2 = -$amount
+ # $amountleft =
+ # fixcredit( $borrowernumber, $amount2, $itemnum, $type, $user );
+ # }
if ( $type eq 'N' ) {
$desc .= " New Card";
}
@@ -386,16 +414,16 @@ sub manualinvoice {
$desc = " Lost Item";
}
-# if ( $type eq 'REF' ) {
-# $desc .= " Cash Refund";
-# $amountleft = refund( '', $borrowernumber, $amount );
-# }
+
+ # if ( $type eq 'REF' ) {
+ # $desc .= " Cash Refund";
+ # $amountleft = refund( '', $borrowernumber, $amount );
+ # }
if ( ( $type eq 'L' )
or ( $type eq 'F' )
or ( $type eq 'A' )
or ( $type eq 'N' )
- or ( $type eq 'M' ) )
- {
+ or ( $type eq 'M' ) ) {
$notifyid = 1;
}
@@ -403,16 +431,17 @@ sub manualinvoice {
$desc .= " " . $itemnum;
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, $itemnum,$notifyid) || return $sth->errstr;
- } else {
- my $sth=$dbh->prepare("INSERT INTO accountlines
- (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)
- VALUES (?, ?, now(), ?, ?, ?, ?,?)"
+ (borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id, meansofpayment)
+ VALUES (?, ?, now(),CURRENT_TIME, ?,?, ?,?,?,?,?,?,?)"
+ );
+ $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum, $notifyid, $note, $manager_id, $meansofpayment ) || return $sth->errstr;
+ } else {
+ my $sth = $dbh->prepare(
+ "INSERT INTO accountlines
+ (borrowernumber, accountno, date, time, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id, meansofpayment)
+ VALUES (?, ?, now(),CURRENT_TIME, ?, ?, ?, ?,?,?,?,?)"
);
- $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
- $amountleft, $notifyid );
+ $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $notifyid, $note, $manager_id, $meansofpayment );
}
return 0;
}
@@ -442,12 +471,10 @@ sub fixcredit {
AND itemnumber=? AND amountoutstanding > 0)";
if ( $type eq 'CL' ) {
$query .= " AND (accounttype = 'L' OR accounttype = 'Rep')";
- }
- elsif ( $type eq 'CF' ) {
+ } elsif ( $type eq 'CF' ) {
$query .= " AND (accounttype = 'F' OR accounttype = 'FU' OR
accounttype='Res' OR accounttype='Rent')";
- }
- elsif ( $type eq 'CB' ) {
+ } elsif ( $type eq 'CB' ) {
$query .= " and accounttype='A'";
}
@@ -459,25 +486,23 @@ sub fixcredit {
if ( $accdata->{'amountoutstanding'} < $amountleft ) {
$newamtos = 0;
$amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
+ } else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
- my $thisacct = $accdata->{accountno};
+ my $thisacct = $accdata->{id};
my $usth = $dbh->prepare(
"UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
+ WHERE (id = ?)"
);
- $usth->execute( $newamtos, $borrowernumber, $thisacct );
+ $usth->execute( $newamtos, $thisacct );
$usth->finish;
$usth = $dbh->prepare(
"INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
VALUES (?,?,?,?)"
);
- $usth->execute( $borrowernumber, $accdata->{'accountno'},
- $nextaccntno, $newamtos );
+ $usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos );
$usth->finish;
}
@@ -498,25 +523,23 @@ sub fixcredit {
if ( $accdata->{'amountoutstanding'} < $amountleft ) {
$newamtos = 0;
$amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
+ } else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
- my $thisacct = $accdata->{accountno};
+ my $thisacct = $accdata->{id};
my $usth = $dbh->prepare(
"UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
+ WHERE (id = ?)"
);
- $usth->execute( $newamtos, $borrowernumber, $thisacct );
+ $usth->execute( $newamtos, $thisacct );
$usth->finish;
$usth = $dbh->prepare(
"INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
VALUE (?,?,?,?)"
);
- $usth->execute( $borrowernumber, $accdata->{'accountno'},
- $nextaccntno, $newamtos );
+ $usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos );
$usth->finish;
}
$sth->finish;
@@ -562,27 +585,25 @@ sub refund {
if ( $accdata->{'amountoutstanding'} > $amountleft ) {
$newamtos = 0;
$amountleft -= $accdata->{'amountoutstanding'};
- }
- else {
+ } else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
# print $amountleft;
- my $thisacct = $accdata->{accountno};
+ my $thisacct = $accdata->{id};
my $usth = $dbh->prepare(
"UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?) AND (accountno=?)"
+ WHERE (id = ?)"
);
- $usth->execute( $newamtos, $borrowernumber, $thisacct );
+ $usth->execute( $newamtos, $thisacct );
$usth->finish;
$usth = $dbh->prepare(
"INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
VALUES (?,?,?,?)"
);
- $usth->execute( $borrowernumber, $accdata->{'accountno'},
- $nextaccntno, $newamtos );
+ $usth->execute( $borrowernumber, $accdata->{'accountno'}, $nextaccntno, $newamtos );
$usth->finish;
}
$sth->finish;
@@ -590,48 +611,91 @@ sub refund {
}
sub getcharges {
- my ( $borrowerno, $timestamp, $accountno ) = @_;
- my $dbh = C4::Context->dbh;
- my $timestamp2 = $timestamp - 1;
- my $query = "";
- my $sth = $dbh->prepare(
- "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
- );
- $sth->execute( $borrowerno, $accountno );
-
+ my ( $borrowerno, $timestamp, $accountno ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $timestamp2 = $timestamp - 1;
+ my $query = "";
+ my $sth = $dbh->prepare( "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" );
+ $sth->execute( $borrowerno, $accountno );
+
my @results;
while ( my $data = $sth->fetchrow_hashref ) {
- push @results,$data;
- }
+ push @results, $data;
+ }
return (@results);
}
+sub ModNote {
+ my ( $accountlineid, $note ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE id = ?');
+ $sth->execute( $note, $accountlineid );
+}
+
+sub ModMeansOfPayment {
+ my ( $accountlineid, $meansofpayment ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('UPDATE accountlines SET meansofpayment = ? WHERE id = ?');
+ $sth->execute( $meansofpayment, $accountlineid );
+}
+
+sub ModManagerId {
+ my ( $accountlineid, $manager_id ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('UPDATE accountlines SET manager_id = ? WHERE id = ?');
+ $sth->execute( $manager_id, $accountlineid );
+}
+
+sub getMeansOfPaymentList {
+ my ($selectedoption) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare( "SELECT * FROM `systempreferences` WHERE variable='MeansOfPayment'" );
+ $sth->execute();
+ my @options;
+ my $booloption=0;
+ while ( my $data = $sth->fetchrow_hashref ) {
+ foreach my $option ( split( /\|/, $data->{'value'} ) ) {
+ my $selected = '';
+ if($option eq $selectedoption)
+ {
+ $selected = ' selected="selected"';
+ $booloption=1;
+ }
+ push @options, { option => $option, selected => $selected };
+ }
+ }
+ if($booloption==0 && $selectedoption ne "")
+ {
+ push @options, { option => $selectedoption, selected => ' selected="selected"' };
+ }
+ $sth->finish;
+ return \@options;
+}
sub getcredits {
- my ( $date, $date2 ) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
- "SELECT * FROM accountlines,borrowers
+ my ( $date, $date2 ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare(
+ "SELECT * FROM accountlines,borrowers
WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber
AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)"
- );
+ );
- $sth->execute( $date, $date2 );
- my @results;
+ $sth->execute( $date, $date2 );
+ my @results;
while ( my $data = $sth->fetchrow_hashref ) {
- $data->{'date'} = $data->{'timestamp'};
- push @results,$data;
- }
+ $data->{'date'} = $data->{'timestamp'};
+ push @results, $data;
+ }
return (@results);
-}
-
+}
sub getrefunds {
- my ( $date, $date2 ) = @_;
- my $dbh = C4::Context->dbh;
-
- my $sth = $dbh->prepare(
- "SELECT *,timestamp AS datetime
+ my ( $date, $date2 ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare(
+ "SELECT *,timestamp AS datetime
FROM accountlines,borrowers
WHERE (accounttype = 'REF'
AND accountlines.borrowernumber = borrowers.borrowernumber
@@ -642,28 +706,29 @@ sub getrefunds {
my @results;
while ( my $data = $sth->fetchrow_hashref ) {
- push @results,$data;
-
- }
+ push @results, $data;
+
+ }
return (@results);
}
sub ReversePayment {
- my ( $borrowernumber, $accountno ) = @_;
- my $dbh = C4::Context->dbh;
-
- my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
- my $row = $sth->fetchrow_hashref();
- my $amount_outstanding = $row->{'amountoutstanding'};
-
- if ( $amount_outstanding <= 0 ) {
- $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
- } else {
- $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
- }
+ my ( $accountlineid ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE id = ?');
+ $sth->execute( $accountlineid );
+ my $row = $sth->fetchrow_hashref();
+ my $amount_outstanding = $row->{'amountoutstanding'};
+
+ if ( $amount_outstanding <= 0 ) {
+ $sth =
+ $dbh->prepare('UPDATE accountlines SET amountoutstanding = amount * -1, description = CONCAT( description, " Reversed -" ) WHERE id = ?');
+ $sth->execute( $accountlineid );
+ } else {
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE id = ?');
+ $sth->execute( $accountlineid );
+ }
}
END { } # module clean-up code here (global destructor)
--- a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.numeric.js
+++ a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.numeric.js
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
+ * Licensed under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Version 1.0
+ * Demo: http://www.texotela.co.uk/code/jquery/numeric/
+ *
+ * $LastChangedDate: 2007-05-29 11:31:36 +0100 (Tue, 29 May 2007) $
+ * $Rev: 2005 $
+ */
+
+/*
+ * Allows only valid characters to be entered into input boxes.
+ * Note: does not validate that the final text is a valid number
+ * (that could be done by another script, or server-side)
+ *
+ * @name numeric
+ * @param decimal Decimal separator (e.g. '.' or ',' - default is '.')
+ * @param callback A function that runs if the number is not valid (fires onblur)
+ * @author Sam Collett (http://www.texotela.co.uk)
+ * @example $(".numeric").numeric();
+ * @example $(".numeric").numeric(",");
+ * @example $(".numeric").numeric(null, callback);
+ *
+ */
+jQuery.fn.numeric = function(decimal, callback)
+{
+ decimal = decimal || ".";
+ callback = typeof callback == "function" ? callback : function(){};
+ this.keypress(
+ function(e)
+ {
+ var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
+ // allow enter/return key (only when in an input box)
+ if(key == 13 && this.nodeName.toLowerCase() == "input")
+ {
+ return true;
+ }
+ else if(key == 13)
+ {
+ return false;
+ }
+ var allow = false;
+ // allow Ctrl+A
+ if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
+ // allow Ctrl+X (cut)
+ if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
+ // allow Ctrl+C (copy)
+ if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
+ // allow Ctrl+Z (undo)
+ if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
+ // allow or deny Ctrl+V (paste), Shift+Ins
+ if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
+ || (e.shiftKey && key == 45)) return true;
+ // if a number was not pressed
+ if(key < 48 || key > 57)
+ {
+ /* '-' only allowed at start */
+ if(key == 45 && this.value.length == 0) return true;
+ /* only one decimal separator allowed */
+ if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
+ {
+ allow = false;
+ }
+ // check for other keys that have special purposes
+ if(
+ key != 8 /* backspace */ &&
+ key != 9 /* tab */ &&
+ key != 13 /* enter */ &&
+ key != 35 /* end */ &&
+ key != 36 /* home */ &&
+ key != 37 /* left */ &&
+ key != 39 /* right */ &&
+ key != 46 /* del */
+ )
+ {
+ allow = false;
+ }
+ else
+ {
+ // for detecting special keys (listed above)
+ // IE does not support 'charCode' and ignores them in keypress anyway
+ if(typeof e.charCode != "undefined")
+ {
+ // special keys have 'keyCode' and 'which' the same (e.g. backspace)
+ if(e.keyCode == e.which && e.which != 0)
+ {
+ allow = true;
+ }
+ // or keyCode != 0 and 'charCode'/'which' = 0
+ else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
+ {
+ allow = true;
+ }
+ }
+ }
+ // if key pressed is the decimal and it is not already in the field
+ if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) == -1)
+ {
+ allow = true;
+ }
+ }
+ else
+ {
+ allow = true;
+ }
+ return allow;
+ }
+ )
+ .blur(
+ function()
+ {
+ var val = jQuery(this).val();
+ if(val != "")
+ {
+ var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
+ if(!re.exec(val))
+ {
+ callback.apply(this);
+ }
+ }
+ }
+ );
+ return this;
+}
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tmpl
@@ -1,6 +1,13 @@
Koha › Patrons › Account for
+
+
+
@@ -26,49 +33,73 @@
-
-
+
+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
@@ -1,6 +1,37 @@
Koha › Patrons › Pay Fines for
+
+
+
+
@@ -31,7 +62,10 @@
--- a/members/boraccount.pl
+++ a/members/boraccount.pl
@@ -1,10 +1,8 @@
#!/usr/bin/perl
-
#writen 11/1/2000 by chris@katipo.oc.nz
#script to display borrowers account details
-
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@@ -33,46 +31,46 @@ use C4::Members;
use C4::Branch;
use C4::Accounts;
-my $input=new CGI;
+my $input = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "members/boraccount.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { borrowers => 1, updatecharges => 1 },
+ debug => 1,
+ }
+);
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "members/boraccount.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {borrowers => 1, updatecharges => 1},
- debug => 1,
- });
-
-my $borrowernumber=$input->param('borrowernumber');
+my $borrowernumber = $input->param('borrowernumber');
my $action = $input->param('action') || '';
#get borrower details
-my $data=GetMember('borrowernumber' => $borrowernumber);
+my $data = GetMember( 'borrowernumber' => $borrowernumber );
if ( $action eq 'reverse' ) {
- ReversePayment( $borrowernumber, $input->param('accountno') );
+ ReversePayment( $input->param('accountlineid') );
}
-if ( $data->{'category_type'} eq 'C') {
- my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
- my $cnt = scalar(@$catcodes);
- $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
- $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
+if ( $data->{'category_type'} eq 'C' ) {
+ my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
+ my $cnt = scalar(@$catcodes);
+ $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
+ $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
}
#get account details
-my ($total,$accts,undef)=GetMemberAccountRecords($borrowernumber);
+my ( $total, $accts, undef ) = GetMemberAccountRecords($borrowernumber);
my $totalcredit;
-if($total <= 0){
- $totalcredit = 1;
+if ( $total <= 0 ) {
+ $totalcredit = 1;
}
-my $reverse_col = 0; # Flag whether we need to show the reverse column
-foreach my $accountline ( @{$accts}) {
+my $reverse_col = 0; # Flag whether we need to show the reverse column
+foreach my $accountline ( @{$accts} ) {
$accountline->{amount} += 0.00;
- if ($accountline->{amount} <= 0 ) {
+ if ( $accountline->{amount} <= 0 ) {
$accountline->{amountcredit} = 1;
}
$accountline->{amountoutstanding} += 0.00;
@@ -80,45 +78,54 @@ foreach my $accountline ( @{$accts}) {
$accountline->{amountoutstandingcredit} = 1;
}
- $accountline->{date} = format_date($accountline->{date});
- $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
+ $accountline->{date} = format_date( $accountline->{date} );
+ $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
$accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
- if ($accountline->{accounttype} eq 'Pay') {
+ if ( $accountline->{accounttype} eq 'Pay' ) {
$accountline->{payment} = 1;
$reverse_col = 1;
}
- if ($accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU'){
+ if ( $accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU' ) {
$accountline->{printtitle} = 1;
}
+
+ if ( $accountline->{accounttype} ne 'F' && $accountline->{accounttype} ne 'FU' ) {
+ $accountline->{printtitle} = 1;
+ }
+ if ( $accountline->{manager_id} ne '' ) {
+ my $datamanager = GetMember( 'borrowernumber' => $accountline->{manager_id} );
+ $accountline->{manager_details}=$datamanager->{'firstname'}." ".$datamanager->{'surname'};
+ }
}
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
-my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
+my ( $picture, $dberror ) = GetPatronImage( $data->{'cardnumber'} );
$template->param( picture => 1 ) if $picture;
$template->param(
- finesview => 1,
- firstname => $data->{'firstname'},
- surname => $data->{'surname'},
- borrowernumber => $borrowernumber,
- cardnumber => $data->{'cardnumber'},
- categorycode => $data->{'categorycode'},
- category_type => $data->{'category_type'},
- categoryname => $data->{'description'},
- address => $data->{'address'},
- address2 => $data->{'address2'},
- city => $data->{'city'},
- zipcode => $data->{'zipcode'},
- country => $data->{'country'},
- phone => $data->{'phone'},
- email => $data->{'email'},
- branchcode => $data->{'branchcode'},
- branchname => GetBranchName($data->{'branchcode'}),
- total => sprintf("%.2f",$total),
- totalcredit => $totalcredit,
- is_child => ($data->{'category_type'} eq 'C'),
- reverse_col => $reverse_col,
- accounts => $accts );
+ finesview => 1,
+ firstname => $data->{'firstname'},
+ surname => $data->{'surname'},
+ borrowernumber => $borrowernumber,
+ cardnumber => $data->{'cardnumber'},
+ categorycode => $data->{'categorycode'},
+ category_type => $data->{'category_type'},
+ categoryname => $data->{'description'},
+ address => $data->{'address'},
+ address2 => $data->{'address2'},
+ city => $data->{'city'},
+ zipcode => $data->{'zipcode'},
+ country => $data->{'country'},
+ phone => $data->{'phone'},
+ email => $data->{'email'},
+ branchcode => $data->{'branchcode'},
+ branchname => GetBranchName( $data->{'branchcode'} ),
+ total => sprintf( "%.2f", $total ),
+ totalcredit => $totalcredit,
+ is_child => ( $data->{'category_type'} eq 'C' ),
+ reverse_col => $reverse_col,
+ accounts => $accts
+);
output_html_with_http_headers $input, $cookie, $template->output;
--- a/members/pay.pl
+++ a/members/pay.pl
@@ -17,10 +17,8 @@
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
=head1 pay.pl
- written 11/1/2000 by chris@katipo.oc.nz
part of the koha library system, script to facilitate paying off fines
=cut
@@ -33,17 +31,18 @@ use C4::Auth;
use C4::Output;
use CGI;
use C4::Members;
+use C4::Context;
use C4::Accounts;
use C4::Stats;
use C4::Koha;
use C4::Overdues;
-use C4::Branch; # GetBranches
+use C4::Branch; # GetBranches
my $input = new CGI;
-
+my $lastinsertid = 0;
+#warn Data::Dumper::Dumper $input;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "members/pay.tmpl",
+ { template_name => "members/pay.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
@@ -52,6 +51,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
+my $manager_id = C4::Context->userenv->{'number'};
my $borrowernumber = $input->param('borrowernumber');
if ( $borrowernumber eq '' ) {
$borrowernumber = $input->param('borrowernumber0');
@@ -63,34 +63,57 @@ my $user = $input->remote_user;
# get account details
my $branches = GetBranches();
-my $branch = GetBranch( $input, $branches );
+my $branch = GetBranch( $input, $branches );
my @names = $input->param;
my %inp;
my $check = 0;
for ( my $i = 0 ; $i < @names ; $i++ ) {
- my $temp = $input->param( $names[$i] );
- if ( $temp eq 'wo' ) {
- $inp{ $names[$i] } = $temp;
- $check = 1;
- }
- if ( $temp eq 'yes' ) {
-
-# FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
- my $amount = $input->param( $names[ $i + 4 ] );
- my $borrowernumber = $input->param( $names[ $i + 5 ] );
- my $accountno = $input->param( $names[ $i + 6 ] );
- makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
- $check = 2;
- }
+ if(defined($input->param( $names[ $i + 1 ] )) && $names[ $i + 1 ] =~ /^accountlineid/)
+ {
+ if(defined($input->param( "payfine".$input->param( $names[ $i + 1 ] ) )))
+ {
+ my $accountlineid = $input->param( $names[ $i + 1 ] );#7
+ my $temp = $input->param( "payfine".$accountlineid );
+ if ( $temp eq 'wo' ) {
+ $inp{ $names[$i] } = $temp;
+ $check = 1;
+ }
+ if ( $temp eq 'yes' ) {
+ #my $accountlineid = $input->param( $names[ $i + 1 ] );#7
+ # FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
+ my $amount = $input->param( "amount".$accountlineid );#4
+ my $borrowernumber = $input->param( "borrowernumber".$accountlineid );#5
+ my $accountno = $input->param( "accountno".$accountlineid );#6
+ my $note = $input->param( "note".$accountlineid );#12
+ my $meansofpayment = $input->param( "meansofpayment".$accountlineid );#11
+ #$accountnoupdated = getnextacctno($borrowernumber);
+ $lastinsertid = makepayment( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, 0 );
+ $check = 2;
+ }
+ elsif($temp eq 'pp')
+ {
+ #my $accountlineid = $input->param( $names[ $i +1 ] );#7
+ my $amount = $input->param( "amount".$accountlineid );#4
+ my $borrowernumber = $input->param( "borrowernumber".$accountlineid );#5
+ my $accountno = $input->param( "accountno".$accountlineid );#6
+ my $note = $input->param( "note".$accountlineid );#12
+ my $meansofpayment = $input->param( "meansofpayment".$accountlineid );#11
+ my $partpaymentamount = $input->param( "partpaymentamount".$accountlineid );#13
+ $lastinsertid = makepayment( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount);
+ $check = 2;
+ }
+ }
+ }
}
+
my $total = $input->param('total') || '';
if ( $check == 0 ) {
if ( $total ne '' ) {
recordpayment( $borrowernumber, $total );
}
- my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
+ my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
my @allfile;
my @notify = NumberNotifyId($borrowernumber);
@@ -98,77 +121,77 @@ if ( $check == 0 ) {
my $numberofnotify = scalar(@notify);
for ( my $j = 0 ; $j < scalar(@notify) ; $j++ ) {
my @loop_pay;
- my ( $total , $accts, $numaccts) =
- GetBorNotifyAcctRecord( $borrowernumber, $notify[$j] );
+ my ( $total, $accts, $numaccts ) = GetBorNotifyAcctRecord( $borrowernumber, $notify[$j] );
for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
my %line;
if ( $accts->[$i]{'amountoutstanding'} != 0 ) {
$accts->[$i]{'amount'} += 0.00;
$accts->[$i]{'amountoutstanding'} += 0.00;
- $line{i} = $j . "" . $i;
- $line{itemnumber} = $accts->[$i]{'itemnumber'};
- $line{accounttype} = $accts->[$i]{'accounttype'};
- $line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} );
- $line{amountoutstanding} =
- sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} );
- $line{borrowernumber} = $borrowernumber;
- $line{accountno} = $accts->[$i]{'accountno'};
- $line{description} = $accts->[$i]{'description'};
- $line{title} = $accts->[$i]{'title'};
- $line{notify_id} = $accts->[$i]{'notify_id'};
- $line{notify_level} = $accts->[$i]{'notify_level'};
- $line{net_balance} = 1 if($accts->[$i]{'amountoutstanding'} > 0); # you can't pay a credit.
+ $line{i} = $accts->[$i]{'id'};
+ $line{accountlineid} = $accts->[$i]{'id'};
+ $line{itemnumber} = $accts->[$i]{'itemnumber'};
+ $line{accounttype} = $accts->[$i]{'accounttype'};
+ $line{amount} = sprintf( "%.2f", $accts->[$i]{'amount'} );
+ $line{amountoutstanding} = sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} );
+ $line{borrowernumber} = $borrowernumber;
+ $line{accountno} = $accts->[$i]{'accountno'};
+ $line{description} = $accts->[$i]{'description'};
+ $line{note} = $accts->[$i]{'note'};
+ $line{meansofpaymentoptions}=getMeansOfPaymentList($accts->[$i]{'meansofpayment'});
+ $line{meansofpayment} = $accts->[$i]{'meansofpayment'};
+ $line{title} = $accts->[$i]{'title'};
+ $line{notify_id} = $accts->[$i]{'notify_id'};
+ $line{notify_level} = $accts->[$i]{'notify_level'};
+ $line{net_balance} = 1 if ( $accts->[$i]{'amountoutstanding'} > 0 ); # you can't pay a credit.
push( @loop_pay, \%line );
}
}
my $totalnotify = AmountNotify( $notify[$j], $borrowernumber );
( $totalnotify = '0' ) if ( $totalnotify =~ /^0.00/ );
- push @allfile,
- {
+ push @allfile, {
'loop_pay' => \@loop_pay,
'notify' => $notify[$j],
- 'total' => sprintf( "%.2f",$totalnotify),
-
- };
+ 'total' => sprintf( "%.2f", $totalnotify ),
+
+ };
}
-
-if ( $data->{'category_type'} eq 'C') {
- my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
- my $cnt = scalar(@$catcodes);
- $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
- $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
-}
-
-$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
-my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
-$template->param( picture => 1 ) if $picture;
-
+
+ if ( $data->{'category_type'} eq 'C' ) {
+ my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
+ my $cnt = scalar(@$catcodes);
+ $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
+ $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
+ }
+
+ $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
+ my ( $picture, $dberror ) = GetPatronImage( $data->{'cardnumber'} );
+ $template->param( picture => 1 ) if $picture;
+
$template->param(
allfile => \@allfile,
firstname => $data->{'firstname'},
surname => $data->{'surname'},
borrowernumber => $borrowernumber,
- cardnumber => $data->{'cardnumber'},
- categorycode => $data->{'categorycode'},
- category_type => $data->{'category_type'},
- categoryname => $data->{'description'},
- address => $data->{'address'},
- address2 => $data->{'address2'},
- city => $data->{'city'},
- zipcode => $data->{'zipcode'},
- country => $data->{'country'},
- phone => $data->{'phone'},
- email => $data->{'email'},
- branchcode => $data->{'branchcode'},
- branchname => GetBranchName($data->{'branchcode'}),
- is_child => ($data->{'category_type'} eq 'C'),
+ cardnumber => $data->{'cardnumber'},
+ categorycode => $data->{'categorycode'},
+ category_type => $data->{'category_type'},
+ categoryname => $data->{'description'},
+ address => $data->{'address'},
+ address2 => $data->{'address2'},
+ city => $data->{'city'},
+ zipcode => $data->{'zipcode'},
+ country => $data->{'country'},
+ phone => $data->{'phone'},
+ email => $data->{'email'},
+ branchcode => $data->{'branchcode'},
+ branchname => GetBranchName( $data->{'branchcode'} ),
+ is_child => ( $data->{'category_type'} eq 'C' ),
total => sprintf( "%.2f", $total )
);
output_html_with_http_headers $input, $cookie, $template->output;
-}
-else {
+} else {
my %inp;
my @name = $input->param;
@@ -188,23 +211,20 @@ else {
my $itemno = $input->param("itemnumber$value");
my $amount = $input->param("amount$value");
my $accountno = $input->param("accountno$value");
- writeoff( $borrowernumber, $accountno, $itemno, $accounttype, $amount );
+ my $accountlineid = $input->param("accountlineid$value");
+ writeoff( $borrowernumber, $accountno, $itemno, $accounttype, $amount, $accountlineid );
}
$borrowernumber = $input->param('borrowernumber');
- print $input->redirect(
- "/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
+ print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
}
sub writeoff {
- my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount ) = @_;
+ my ( $borrowernumber, $accountnum, $itemnum, $accounttype, $amount, $accountlineid ) = @_;
my $user = $input->remote_user;
my $dbh = C4::Context->dbh;
- undef $itemnum unless $itemnum; # if no item is attached to fine, make sure to store it as a NULL
- my $sth =
- $dbh->prepare(
-"Update accountlines set amountoutstanding=0 where accountno=? and borrowernumber=?"
- );
- $sth->execute( $accountnum, $borrowernumber );
+ undef $itemnum unless $itemnum; # if no item is attached to fine, make sure to store it as a NULL
+ my $sth = $dbh->prepare( "Update accountlines set amountoutstanding=0 where id=?" );
+ $sth->execute( $accountlineid );
$sth->finish;
$sth = $dbh->prepare("select max(accountno) from accountlines");
$sth->execute;
@@ -212,12 +232,10 @@ sub writeoff {
$sth->finish;
$account->{'max(accountno)'}++;
$sth = $dbh->prepare(
-"insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
- values (?,?,?,now(),?,'Writeoff','W')"
+ "insert into accountlines (borrowernumber,accountno,itemnumber,date,time,amount,description,accounttype,manager_id)
+ values (?,?,?,now(),CURRENT_TIME,?,?,'W', ?)"
);
- $sth->execute( $borrowernumber, $account->{'max(accountno)'},
- $itemnum, $amount );
+ $sth->execute( $borrowernumber, $account->{'max(accountno)'}, $itemnum, $amount,"Writeoff for account n°".$accountnum, $manager_id);
$sth->finish;
- UpdateStats( $branch, 'writeoff', $amount, '', '', '',
- $borrowernumber );
+ UpdateStats( $branch, 'writeoff', $amount, '', '', '', $borrowernumber );
}
--