<input type="submit" id="paycollect" name="paycollect" value="Pay amount" class="submit" />
[% IF CAN_user_updatecharges_writeoff %]<input type="submit" name="woall" id="woall" value="Write off all" class="submit" />[% END %]
<input type="submit" id="payselected" name="payselected" value="Pay selected" class="submit" />
+<input type="submit" id="writeoff-selected" name="writeoff_selected" value="Write off selected" class="submit" />
<a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
</fieldset>
</form>
<body id="pat_paycollect" class="pat">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'patron-search.inc' %]
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Pay fines for [% patron.firstname %] [% patron.surname %]</a> › [% IF ( pay_individual ) %]Pay an individual fine[% ELSIF ( writeoff_individual ) %]Write off an individual fine[% ELSE %][% IF ( selected_accts ) %]Pay an amount toward selected fines[% ELSE %]Pay an amount toward all fines[% END %][% END %]</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Pay fines for [% patron.firstname %] [% patron.surname %]</a> › [% IF ( pay_individual ) %]Pay an individual fine[% ELSIF ( writeoff_individual ) %]Write off an individual fine[% ELSE %][% IF ( selected_accts ) %][% IF type == 'write off' %]Write off an amount toward selected fines[% ELSE %]Pay an amount toward selected fines[% END %][% ELSE %]Pay an amount toward all fines[% END %][% END %]</div>
<div id="doc3" class="yui-t2">
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber %]" />
<input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts %]" />
<input type="hidden" name="total" id="total" value="[% total %]" />
+ <input type="hidden" name="type" value="[% type %]" />
<fieldset class="rows">
- [% IF ( selected_accts ) %]<legend>Pay an amount toward selected fines</legend>[% ELSE %]<legend>Pay an amount toward all fines</legend>[% END %]
+ [% IF ( selected_accts ) %]
+ [% IF type == 'writeoff' %]
+ <legend>Write off an amount toward selected fines</legend>
+ [% ELSE %]
+ <legend>Pay an amount toward selected fines</legend>
+ [% END %]
+ [% ELSE %]
+ <legend>Pay an amount toward all fines</legend>
+ [% END %]
+
<ol>
<li>
<span class="label">Total amount outstanding: </span>
<span class="debit">[% total | format('%.2f') %]</span>
</li>
<li>
- <label for="paid">Collect from patron: </label>
+ [% IF type == 'writeoff' %]
+ <label for="paid">Writeoff amount: </label>
+ [% ELSE %]
+ <label for="paid">Collect from patron: </label>
+ [% END %]
<!-- default to paying all -->
<input name="paid" id="paid" value="[% total | format('%.2f') %]" />
</li>
</li>
</ol>
</fieldset>
- <div class="action"><input type="submit" name="submitbutton" value="Confirm" />
- <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
+ <div class="action">
+ <input type="submit" name="submitbutton" value="Confirm" />
+ <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
+ </div>
</form>
[% END %]
</div></div>
our $branch = C4::Context->userenv->{'branch'};
-my $writeoff_item = $input->param('confirm_writeoff');
-my $paycollect = $input->param('paycollect');
-if ($paycollect) {
+if ( $input->param('paycollect') ) {
print $input->redirect(
"/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber");
}
-my $payselected = $input->param('payselected');
-if ($payselected) {
- payselected(@names);
+elsif ( $input->param('payselected') ) {
+ payselected({ params => \@names });
}
-
-my $writeoff_all = $input->param('woall'); # writeoff all fines
-if ($writeoff_all) {
+elsif ( $input->param('writeoff_selected') ) {
+ payselected({ params => \@names, type => 'writeoff' });
+}
+elsif ( $input->param('woall') ) {
writeoff_all(@names);
-} elsif ($writeoff_item) {
+}
+elsif ( $input->param('confirm_writeoff') ) {
my $accountlines_id = $input->param('accountlines_id');
- my $amount = $input->param('amountwrittenoff');
- my $payment_note = $input->param("payment_note");
+ my $amount = $input->param('amountwrittenoff');
+ my $payment_note = $input->param("payment_note");
my $accountline = Koha::Account::Lines->find( $accountlines_id );
}
sub payselected {
- my @params = @_;
+ my $parameters = shift;
+
+ my @params = @{ $parameters->{params} };
+ my $type = $parameters->{type} || 'payment';
+
my $amt = 0;
my @lines_to_pay;
foreach (@params) {
my $notes = '¬es=' . join("%0A", map { scalar $input->param("payment_note_$_") } @lines_to_pay );
my $redirect =
"/cgi-bin/koha/members/paycollect.pl?borrowernumber=$borrowernumber"
+ . "&type=$type"
. $amt
. $sel
. $notes;
my $select = $input->param('selected_accts');
my $payment_note = uri_unescape scalar $input->param('payment_note');
my $payment_type = scalar $input->param('payment_type');
+my $type = scalar $input->param('type') || 'payment',
my $accountlines_id;
if ( $individual || $writeoff ) {
}
)->pay(
{
+ type => $type,
amount => $total_paid,
lines => \@lines,
note => $note,
}
$template->param(
+ type => $type,
borrowernumber => $borrowernumber, # some templates require global
patron => $patron,
total => $total_due,