<fieldset class="rows">
<legend>Manual credit</legend><ol>
<li><label for="type">Credit type: </label><select name="type" id="type">
-<option value="C">Credit</option>
-<option value="FOR">Forgiven</option>
+<option value="credit">Credit</option>
+<option value="forgiven">Forgiven</option>
</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>
use C4::Accounts;
use C4::Items;
use C4::Members::Attributes qw(GetBorrowerAttributes);
-use Koha::Patrons;
+use Koha::Account;
+use Koha::Patrons;
use Koha::Patron::Categories;
use Koha::Token;
my $add=$input->param('add');
if ($add){
- if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
+
+ my ( $user_id ) = checkauth( $input, 0, $flagsrequired, 'intranet' );
+
+ if ( $user_id ) {
die "Wrong CSRF token"
unless Koha::Token->new->check_csrf( {
# Note: If the logged in user is not allowed to see this patron an invoice can be forced
# Here we are trusting librarians not to hack the system
my $barcode = $input->param('barcode');
- my $itemnum;
+ my $item_id;
if ($barcode) {
- $itemnum = GetItemnumberFromBarcode($barcode);
+ $item_id = GetItemnumberFromBarcode($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, $note );
+ my $description = $input->param('desc');
+ my $note = $input->param('note');
+ my $amount = $input->param('amount') || 0;
+ my $type = $input->param('type');
+
+ Koha::Account->new({ patron_id => $borrowernumber })->add_credit({
+ amount => $amount,
+ description => $description,
+ item_id => $item_id,
+ note => $note,
+ type => $type,
+ user_id => $user_id
+ });
+
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
}
} else {