@@ -, +, @@
---
C4/Accounts.pm | 175 +++++++++++++-------
C4/Circulation.pm | 16 +-
installer/data/mysql/en/mandatory/sysprefs.sql | 1 +
installer/data/mysql/kohastructure.sql | 3 +
installer/data/mysql/updatedatabase.pl | 12 ++-
.../prog/en/lib/jquery/plugins/jquery.numeric.js | 128 ++++++++++++++
.../prog/en/modules/members/boraccount.tmpl | 47 +++++-
.../prog/en/modules/members/mancredit.tmpl | 28 +++-
.../prog/en/modules/members/maninvoice.tmpl | 30 ++++-
.../intranet-tmpl/prog/en/modules/members/pay.tmpl | 65 +++++++-
kohaversion.pl | 2 +-
members/boraccount.pl | 10 +-
members/mancredit.pl | 4 +-
members/maninvoice.pl | 5 +-
members/pay.pl | 86 ++++++----
.../lib/KohaTest/Members/GetMemberDetails.pm | 10 +-
16 files changed, 493 insertions(+), 129 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.numeric.js
--- a/C4/Accounts.pm
+++ a/C4/Accounts.pm
@@ -35,7 +35,7 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&recordpayment &makepayment &manualinvoice
- &getnextacctno &reconcileaccount &getcharges &ModNote &getcredits
+ &getnextacctno &reconcileaccount &getcharges &ModNote &ModMeansOfPayment &ModManagerId &getMeansOfPaymentList &getcredits
&getrefunds &chargelostitem
&ReversePayment
); # removed &fixaccounts
@@ -104,10 +104,10 @@ sub recordpayment {
$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;
@@ -124,8 +124,8 @@ sub recordpayment {
# 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 +135,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 +144,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,7 +156,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 ( $accountlineid, $borrowernumber, $accountno, $amount, $user, $branch, $note, $meansofpayment, $manager_id, $partpaymentamount ) = @_;
my $dbh = C4::Context->dbh;
# begin transaction
@@ -164,41 +164,45 @@ sub makepayment {
my $newamtos = 0;
my $sth =
$dbh->prepare(
- "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno=?");
- $sth->execute( $borrowernumber, $accountno );
+ "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)
-# " );
-
# 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,
+ UpdateStats( $user, 'payment', $finalamount, '', '', '', $borrowernumber,
$accountno );
$sth->finish;
@@ -206,6 +210,12 @@ sub makepayment {
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
@@ -233,18 +243,17 @@ sub getnextacctno ($) {
=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,8 +265,7 @@ 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.
}
@@ -307,8 +315,8 @@ sub chargelostitem{
# 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',?,?)");
+ (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);
@@ -327,7 +335,7 @@ sub chargelostitem{
=head2 manualinvoice
&manualinvoice($borrowernumber, $itemnumber, $description, $type,
- $amount, $note);
+ $amount, $note, $meansofpayment);
C<$borrowernumber> is the patron's borrower number.
C<$description> is a description of the transaction.
@@ -351,7 +359,7 @@ should be the empty string.
#
sub manualinvoice {
- my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
+ my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment ) = @_;
my $manager_id = C4::Context->userenv->{'number'};
my $dbh = C4::Context->dbh;
my $notifyid = 0;
@@ -404,16 +412,16 @@ sub manualinvoice {
$desc .= " " . $itemnum;
my $sth = $dbh->prepare(
"INSERT INTO accountlines
- (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding, itemnumber,notify_id, note, manager_id)
- VALUES (?, ?, now(), ?,?, ?,?,?,?,?,?)");
- $sth->execute($borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $itemnum,$notifyid, $note, $manager_id) || return $sth->errstr;
+ (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, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
- VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
+ (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, $note, $manager_id );
+ $amountleft, $notifyid, $note, $manager_id, $meansofpayment );
}
return 0;
}
@@ -465,10 +473,10 @@ sub fixcredit {
$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;
@@ -504,12 +512,12 @@ sub fixcredit {
$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
@@ -557,7 +565,6 @@ sub refund {
);
$sth->execute($borrowernumber);
- # print $amountleft;
# offset transactions
while ( ( $accdata = $sth->fetchrow_hashref ) and ( $amountleft < 0 ) ) {
if ( $accdata->{'amountoutstanding'} > $amountleft ) {
@@ -569,13 +576,12 @@ sub refund {
$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
@@ -608,10 +614,51 @@ sub getcharges {
}
sub ModNote {
- my ( $borrowernumber, $accountno, $note ) = @_;
+ my ( $accountlineid, $note ) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');
- $sth->execute( $note, $borrowernumber, $accountno );
+ 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 {
@@ -656,20 +703,20 @@ sub getrefunds {
}
sub ReversePayment {
- my ( $borrowernumber, $accountno ) = @_;
+ my ( $accountlineid ) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare('SELECT amountoutstanding FROM accountlines WHERE borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
+ 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 borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
+ $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 borrowernumber = ? AND accountno = ?');
- $sth->execute( $borrowernumber, $accountno );
+ $sth = $dbh->prepare('UPDATE accountlines SET amountoutstanding = 0, description = CONCAT( description, " Reversed -" ) WHERE id = ?');
+ $sth->execute( $accountlineid );
}
}
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1788,7 +1788,7 @@ sub _FixOverduesOnReturn {
return 0 unless $data; # no warning, there's just nothing to fix
my $uquery;
- my @bind = ($borrowernumber, $item, $data->{'accountno'});
+ my @bind = ($data->{'id'});
if ($exemptfine) {
$uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0";
if (C4::Context->preference("FinesLog")) {
@@ -1808,7 +1808,7 @@ sub _FixOverduesOnReturn {
} else {
$uquery = "update accountlines set accounttype='F' ";
}
- $uquery .= " where (borrowernumber = ?) and (itemnumber = ?) and (accountno = ?)";
+ $uquery .= " where (id = ?)";
my $usth = $dbh->prepare($uquery);
return $usth->execute(@bind);
}
@@ -1850,9 +1850,8 @@ sub _FixAccountForLostAndReturned {
$amountleft = $data->{'amountoutstanding'} - $amount; # Um, isn't this the same as ZERO? We just tested those two things are ==
}
my $usth = $dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0'
- WHERE (borrowernumber = ?)
- AND (itemnumber = ?) AND (accountno = ?) ");
- $usth->execute($data->{'borrowernumber'},$itemnumber,$acctno); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in.
+ WHERE (id = ?) ");
+ $usth->execute($data->{'id'}); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in.
#check if any credit is left if so writeoff other accounts
my $nextaccntno = getnextacctno($data->{'borrowernumber'});
$amountleft *= -1 if ($amountleft < 0);
@@ -1871,12 +1870,11 @@ sub _FixAccountForLostAndReturned {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
- my $thisacct = $accdata->{'accountno'};
+ my $thisacct = $accdata->{'id'};
# FIXME: move prepares outside while loop!
my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
- WHERE (borrowernumber = ?)
- AND (accountno=?)");
- $usth->execute($newamtos,$data->{'borrowernumber'},'$thisacct'); # FIXME: '$thisacct' is a string literal!
+ WHERE (id = ?)");
+ $usth->execute($newamtos,'$thisacct'); # FIXME: '$thisacct' is a string literal!
$usth = $dbh->prepare("INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
VALUES
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ a/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -298,3 +298,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for subject tracings.','1','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages','1','',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MeansOfPayment','Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit','Define means of payment for borrowers payments','Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit','free');
--- a/installer/data/mysql/kohastructure.sql
+++ a/installer/data/mysql/kohastructure.sql
@@ -2279,10 +2279,12 @@ CREATE TABLE `messages` (
DROP TABLE IF EXISTS `accountlines`;
CREATE TABLE `accountlines` (
+ `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`borrowernumber` int(11) NOT NULL default 0,
`accountno` smallint(6) NOT NULL default 0,
`itemnumber` int(11) default NULL,
`date` date default NULL,
+ `time` time default NULL,
`amount` decimal(28,6) default NULL,
`description` mediumtext,
`dispute` mediumtext,
@@ -2294,6 +2296,7 @@ CREATE TABLE `accountlines` (
`notify_level` int(2) NOT NULL default 0,
`note` text NULL default NULL,
`manager_id` int(11) NULL,
+ `meansofpayment` text NULL default NULL;
KEY `acctsborridx` (`borrowernumber`),
KEY `timeidx` (`timestamp`),
KEY `itemnumber` (`itemnumber`),
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -4166,7 +4166,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
-$DBversion = 'XXX';
+$DBversion = '3.03.00.036';
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
$dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
$dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
@@ -4174,6 +4174,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
SetVersion($DBversion);
}
+$DBversion = '3.03.00.037';
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("ALTER TABLE `accountlines` ADD `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
+ $dbh->do("ALTER TABLE `accountlines` ADD `time` TIME DEFAULT NULL AFTER `date`");
+ $dbh->do("ALTER TABLE `accountlines` ADD `meansofpayment` text NULL default NULL");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MeansOfPayment', 'Undefined|Cash|Cheque|Bank card|Credit transfer|Direct debit', 'Define means of payment for borrowers payments', 'Undefined|Cash|Cheque|Bank card|Credit transfert|Direct debit', 'free')");
+ print "Upgrade to $DBversion done (adding id, time, and meansofpayment fields in accountlines table; and adding MeansOfPayment system preference";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
--- 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,128 @@
+/*
+ *
+ * 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,32 +33,56 @@
-
-
+
+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
@@ -1,6 +1,20 @@
Koha › Borrowers › Create Manual Credit
+
+
+
+
+
+
+
+
@@ -31,8 +62,10 @@
Fines & Charges |
+ Means of payment |
Description |
Note |
+ Part payment |
Account Type |
Notify id |
Level |
@@ -43,12 +76,14 @@
-
+ | " value="" />
+
- |
+
+
+ " id="meansofpayment">
+
+
+
+
+
+
+ |
|
@@ -69,6 +118,13 @@
" />
|
+
+
+ " name="partpaymentamount" value="
+
+
+ " onKeyUp="partpaymentchange(this.value,,)" />
+ |
|
|
|
@@ -78,14 +134,13 @@
-
- Sub Total |
+ Sub Total |
|
- Total Due |
+ Total Due |
|
--- a/kohaversion.pl
+++ a/kohaversion.pl
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
use strict;
sub kohaversion {
- our $VERSION = '3.03.00.035';
+ our $VERSION = '3.03.00.037';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
--- a/members/boraccount.pl
+++ a/members/boraccount.pl
@@ -52,7 +52,7 @@ my $action = $input->param('action') || '';
my $data=GetMember('borrowernumber' => $borrowernumber);
if ( $action eq 'reverse' ) {
- ReversePayment( $borrowernumber, $input->param('accountno') );
+ ReversePayment( $input->param('accountlineid') );
}
if ( $data->{'category_type'} eq 'C') {
@@ -90,6 +90,14 @@ foreach my $accountline ( @{$accts}) {
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' );
--- a/members/mancredit.pl
+++ a/members/mancredit.pl
@@ -48,10 +48,11 @@ if ($add){
my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
my $desc = $input->param('desc');
my $note = $input->param('note');
+ my $meansofpayment = $input->param('meansofpayment');
my $amount = $input->param('amount') || 0;
$amount = -$amount;
my $type = $input->param('type');
- manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
+ manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment );
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
}
} else {
@@ -94,5 +95,6 @@ if ($add){
branchname => GetBranchName($data->{'branchcode'}),
is_child => ($data->{'category_type'} eq 'C'),
);
+ $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
output_html_with_http_headers $input, $cookie, $template->output;
}
--- a/members/maninvoice.pl
+++ a/members/maninvoice.pl
@@ -50,7 +50,8 @@ if ($add){
my $amount=$input->param('amount');
my $type=$input->param('type');
my $note = $input->param('note');
- my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
+ my $meansofpayment = $input->param('meansofpayment');
+ my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $meansofpayment );
if ($error) {
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ template_name => "members/maninvoice.tmpl",
@@ -65,6 +66,7 @@ if ($add){
$template->param( 'ITEMNUMBER' => 1 );
}
$template->param( 'ERROR' => $error );
+ $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
output_html_with_http_headers $input, $cookie, $template->output;
} else {
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
@@ -122,5 +124,6 @@ if ($add){
branchname => GetBranchName($data->{'branchcode'}),
is_child => ($data->{'category_type'} eq 'C'),
);
+ $template->param( 'meansofpaymentoptions' => getMeansOfPaymentList() );
output_html_with_http_headers $input, $cookie, $template->output;
}
--- a/members/pay.pl
+++ a/members/pay.pl
@@ -41,6 +41,7 @@ use C4::Overdues;
use C4::Branch; # GetBranches
my $input = new CGI;
+my $lastinsertid = 0;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -53,6 +54,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');
@@ -70,26 +72,42 @@ 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 ( $temp eq 'no'||$temp eq 'yes'||$temp eq 'wo') {
- my $borrowernumber = $input->param( $names[ $i + 5 ] );
- my $accountno = $input->param( $names[ $i + 6 ] );
- my $note = $input->param( $names[ $i + 10 ] );
- ModNote( $borrowernumber, $accountno, $note );
- }
+ if(defined($input->param( $names[ $i + 1 ] )))
+ {
+ 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') || '';
@@ -113,7 +131,8 @@ if ( $check == 0 ) {
if ( $accts->[$i]{'amountoutstanding'} != 0 ) {
$accts->[$i]{'amount'} += 0.00;
$accts->[$i]{'amountoutstanding'} += 0.00;
- $line{i} = $j . "" . $i;
+ $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'} );
@@ -123,6 +142,8 @@ if ( $check == 0 ) {
$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'};
@@ -197,7 +218,8 @@ 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(
@@ -205,14 +227,14 @@ else {
}
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=?"
- );
+ my $sth = $dbh->prepare("
+ UPDATE accountlines SET amountoutstanding = 0
+ WHERE id = ?
+ ");
$sth->execute( $accountnum, $borrowernumber );
$sth->finish;
$sth = $dbh->prepare("select max(accountno) from accountlines");
@@ -220,10 +242,12 @@ sub writeoff {
my $account = $sth->fetchrow_hashref;
$sth->finish;
$account->{'max(accountno)'}++;
- $sth = $dbh->prepare(
-"insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
- values (?,?,?,now(),?,'Writeoff','W')"
- );
+ $sth = $dbh->prepare("
+ INSERT INTO accountlines (borrowernumber,accountno,itemnumber,
+ date,time,amount,description,accounttype,
+ manager_id)
+ VALUES (?,?,?,now(),CURRENT_TIME,?,'Writeoff','W',?)
+ ");
$sth->execute( $borrowernumber, $account->{'max(accountno)'},
$itemnum, $amount );
$sth->finish;
--- a/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm
+++ a/t/db_dependent/lib/KohaTest/Members/GetMemberDetails.pm
@@ -24,7 +24,7 @@ retrieval.
sub startup_create_detailed_borrower : Test( startup => 2 ) {
my $self = shift;
- my ( $description, $type, $amount, $user );
+ my ( $description, $type, $amount, $note, $meansofpayment );
my $memberinfo = {
surname => 'surname' . $self->random_string(),
@@ -50,11 +50,11 @@ sub startup_create_detailed_borrower : Test( startup => 2 ) {
$description = 'Test account';
$type = 'M';
$amount = 5.00;
- $user = '';
+ $note = '';
+ $meansofpayment = '';
- my $acct_added =
- C4::Accounts::manualinvoice( $borrowernumber, undef, $description, $type, $amount,
- $user );
+ my $acct_added = C4::Accounts::manualinvoice( $borrowernumber, undef,
+ $description, $type, $amount, $note, $meansofpayment );
ok( $acct_added == 0, 'added account for borrower' );
--