[Koha-patches] [PATCH 01/54] MT1874 adding note and manager_id fields to accountlines
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu Dec 16 11:53:55 CET 2010
From: Paul Poulain <paul.poulain at biblibre.com>
* manager_id contains the librarian that created the line
* note is a field that can be entered by the librarian
The fields are added later in updatedatabase
(written by Stephane Delaune)
---
C4/Accounts.pm | 29 ++++++++++++-------
.../prog/en/modules/members/mancredit.tmpl | 1 +
.../prog/en/modules/members/maninvoice.tmpl | 1 +
.../intranet-tmpl/prog/en/modules/members/pay.tmpl | 12 +++++++-
members/mancredit.pl | 5 +++-
members/maninvoice.pl | 6 +++-
members/pay.pl | 8 +++++
7 files changed, 47 insertions(+), 15 deletions(-)
diff --git a/C4/Accounts.pm b/C4/Accounts.pm
index d73fc2e..a02c173 100644
--- a/C4/Accounts.pm
+++ b/C4/Accounts.pm
@@ -24,7 +24,8 @@ use C4::Context;
use C4::Stats;
use C4::Members;
use C4::Items;
-use C4::Circulation qw(MarkIssueReturned);
+use C4::Circulation ;
+use C4::Context;
use vars qw($VERSION @ISA @EXPORT);
@@ -35,7 +36,7 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&recordpayment &makepayment &manualinvoice
- &getnextacctno &reconcileaccount &getcharges &getcredits
+ &getnextacctno &reconcileaccount &getcharges &ModNote &getcredits
&getrefunds &chargelostitem
&ReversePayment
); # removed &fixaccounts
@@ -327,7 +328,7 @@ sub chargelostitem{
=head2 manualinvoice
&manualinvoice($borrowernumber, $itemnumber, $description, $type,
- $amount, $user);
+ $amount, $note);
C<$borrowernumber> is the patron's borrower number.
C<$description> is a description of the transaction.
@@ -351,7 +352,8 @@ should be the empty string.
#
sub manualinvoice {
- my ( $borrowernumber, $itemnum, $desc, $type, $amount, $user ) = @_;
+ my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
+ my $manager_id = C4::Context->userenv->{'number'};
my $dbh = C4::Context->dbh;
my $notifyid = 0;
my $insert;
@@ -403,16 +405,15 @@ 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;
+ (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;
} else {
my $sth=$dbh->prepare("INSERT INTO accountlines
- (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id)
- VALUES (?, ?, now(), ?, ?, ?, ?,?)"
+ (borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding,notify_id, note, manager_id)
+ VALUES (?, ?, now(), ?, ?, ?, ?,?,?,?)"
);
- $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type,
- $amountleft, $notifyid );
+ $sth->execute( $borrowernumber, $accountno, $amount, $desc, $type, $amountleft, $notifyid, $note, $manager_id );
}
return 0;
}
@@ -606,6 +607,12 @@ sub getcharges {
return (@results);
}
+sub ModNote {
+ my ( $borrowernumber, $accountno, $note ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('UPDATE accountlines SET note = ? WHERE borrowernumber = ? AND accountno = ?');
+ $sth->execute( $note, $borrowernumber, $accountno );
+}
sub getcredits {
my ( $date, $date2 ) = @_;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
index 16f7a7b..995767b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tmpl
@@ -43,6 +43,7 @@ $(document).ready(function(){
</select></li>
<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
+ <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
</ol></fieldset>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
index a7c49e8..2a6af2d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tmpl
@@ -67,6 +67,7 @@ type_fees['<!-- TMPL_VAR NAME="authorised_value" -->'] = "<!-- TMPL_VAR NAME="li
</li>
<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
+ <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
<li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" /> Example: 5.00</li>
</ol></fieldset>
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Cancel</a></fieldset>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
index 1177ba2..3772bda 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tmpl
@@ -32,6 +32,7 @@
<tr>
<th>Fines & Charges</th>
<th>Description</th>
+ <th>Note</th>
<th>Account Type</th>
<th>Notify id</th>
<th>Level</th>
@@ -61,6 +62,13 @@
<input type="hidden" name="totals<!-- TMPL_VAR name="i" -->" value="<!-- TMPL_VAR name="totals" -->" />
</td>
<td><!-- TMPL_VAR name="description" --> <!-- TMPL_VAR name="title" escape="html" --></td>
+ <td>
+ <!-- TMPL_IF NAME="net_balance" -->
+ <input type="text" name="note<!-- TMPL_VAR name="i" -->" value="
+ <!-- /TMPL_IF -->
+ <!-- TMPL_VAR name="note" -->
+ <!-- TMPL_IF NAME="net_balance" -->" /><!-- /TMPL_IF -->
+ </td>
<td><!-- TMPL_VAR name="accounttype" --></td>
<td><!-- TMPL_VAR name="notify_id" --></td>
<td><!-- TMPL_VAR name="notify_level" --></td>
@@ -71,13 +79,13 @@
<!-- TMPL_IF NAME="total"-->
<tr>
- <td colspan="6">Sub Total</td>
+ <td colspan="7">Sub Total</td>
<td><!-- TMPL_VAR name="total" --></td>
</tr>
<!--/TMPL_IF-->
<!-- /TMPL_LOOP -->
<tr>
- <td colspan="6">Total Due</td>
+ <td colspan="7">Total Due</td>
<td><!-- TMPL_VAR name="total" --></td>
</tr>
</table>
diff --git a/members/mancredit.pl b/members/mancredit.pl
index 51b71d6..c02dde9 100755
--- a/members/mancredit.pl
+++ b/members/mancredit.pl
@@ -42,14 +42,17 @@ my $data=GetMember('borrowernumber' => $borrowernumber);
my $add=$input->param('add');
if ($add){
+ if(checkauth($input)){
my $barcode=$input->param('barcode');
my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
my $desc=$input->param('desc');
+ my $note = $input->param('note');
my $amount=$input->param('amount') || 0;
$amount = -$amount;
my $type=$input->param('type');
- manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
+ manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
+ }
} else {
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/mancredit.tmpl",
diff --git a/members/maninvoice.pl b/members/maninvoice.pl
index df12a2a..eb2ba91 100755
--- a/members/maninvoice.pl
+++ b/members/maninvoice.pl
@@ -42,12 +42,15 @@ my $data=GetMember('borrowernumber'=>$borrowernumber);
my $add=$input->param('add');
if ($add){
# print $input->header;
+ if(checkauth($input))
+ {
my $barcode=$input->param('barcode');
my $itemnum = GetItemnumberFromBarcode($barcode) if $barcode;
my $desc=$input->param('desc');
my $amount=$input->param('amount');
my $type=$input->param('type');
- my $error=manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount);
+ my $note = $input->param('note');
+ my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
if ($error){
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/maninvoice.tmpl",
@@ -66,6 +69,7 @@ if ($add){
else {
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
exit;
+ }
}
} else {
diff --git a/members/pay.pl b/members/pay.pl
index 5a36bd7..c25f800 100755
--- a/members/pay.pl
+++ b/members/pay.pl
@@ -83,7 +83,14 @@ for ( my $i = 0 ; $i < @names ; $i++ ) {
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 );
}
+}
+
my $total = $input->param('total') || '';
if ( $check == 0 ) {
if ( $total ne '' ) {
@@ -115,6 +122,7 @@ if ( $check == 0 ) {
$line{accountno} = $accts->[$i]{'accountno'};
$line{description} = $accts->[$i]{'description'};
$line{title} = $accts->[$i]{'title'};
+ $line{note} = $accts->[$i]{'note'};
$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.
--
1.7.1
More information about the Koha-patches
mailing list