View | Details | Raw Unified | Return to bug 20120
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-4 / +27 lines)
Lines 2-7 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE AuthorisedValues %]
4
[% USE AuthorisedValues %]
5
[% USE Price %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
8
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
Lines 119-124 Link Here
119
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
120
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
120
    <input type="hidden" name="title" id="title" value="[% title %]" />
121
    <input type="hidden" name="title" id="title" value="[% title %]" />
121
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
122
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
123
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
124
    <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
122
    <table>
125
    <table>
123
    <thead><tr>
126
    <thead><tr>
124
            <th>Description</th>
127
            <th>Description</th>
Lines 139-150 Link Here
139
                <li>
142
                <li>
140
                    <label for="paid">Writeoff amount: </label>
143
                    <label for="paid">Writeoff amount: </label>
141
                    <!-- default to writing off all -->
144
                    <!-- default to writing off all -->
142
                    <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding %]" />
145
                    <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price %]" />
143
                </li>
146
                </li>
144
            </ol>
147
            </ol>
145
        </fieldset>
148
        </fieldset>
146
        <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" />
149
        <div class="action">
147
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
150
            <input type="submit" value="Write off this charge" />
151
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
152
        </div>
148
    </form>
153
    </form>
149
[% ELSE %]
154
[% ELSE %]
150
155
Lines 201-212 Link Here
201
    [% Asset.js("js/members-menu.js") %]
206
    [% Asset.js("js/members-menu.js") %]
202
    <script type= "text/javascript">
207
    <script type= "text/javascript">
203
        $(document).ready(function() {
208
        $(document).ready(function() {
204
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
209
            $('#payindivfine, #payfine').preventDoubleFormSubmit();
205
            $("#paid").on("change",function(){
210
            $("#paid").on("change",function(){
206
                moneyFormat( this );
211
                moneyFormat( this );
207
            });
212
            });
208
        });
213
        });
209
214
215
        prevent_default = 1;
216
        $('#woindivfine').on('submit', function(e){
217
            if ( prevent_default ) {
218
                e.preventDefault();
219
220
                let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
221
                let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
222
                if ( amount_writeoff > amount_outstanding ) {
223
                    alert(_("You are attemping to writeoff more than the value of the fee."));
224
                    $('#woindivfine').beenSubmitted = false;
225
                } else {
226
                    prevent_default = 0;
227
                    $('#woindivfine').preventDoubleFormSubmit();
228
                    $('#woindivfine').submit();
229
                }
230
            }
231
        });
232
210
        function moneyFormat(textObj) {
233
        function moneyFormat(textObj) {
211
            var newValue = textObj.value;
234
            var newValue = textObj.value;
212
            var decAmount = "";
235
            var decAmount = "";
(-)a/members/pay.pl (-9 / +23 lines)
Lines 93-107 if ($writeoff_all) { Link Here
93
    my $amount       = $input->param('amountwrittenoff');
93
    my $amount       = $input->param('amountwrittenoff');
94
    my $payment_note = $input->param("payment_note");
94
    my $payment_note = $input->param("payment_note");
95
95
96
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
96
    my $accountline = Koha::Account::Lines->find( $accountlines_id );
97
        {
97
98
            amount     => $amount,
98
    if ( $amount > $accountline->amountoutstanding ) {
99
            lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
99
        print $input->redirect( "/cgi-bin/koha/members/paycollect.pl?"
100
            type       => 'writeoff',
100
              . "borrowernumber=$borrowernumber"
101
            note       => $payment_note,
101
              . "&amount=$amount"
102
            library_id => $branch,
102
              . "&amountoutstanding=" . $accountline->amountoutstanding
103
        }
103
              . "&accounttype=" . $accountline->accounttype
104
    );
104
              . "&accountlines_id=" . $accountlines_id
105
              . "&writeoff_individual=1"
106
              . "&error_over=1" );
107
108
    } else {
109
        Koha::Account->new( { patron_id => $borrowernumber } )->pay(
110
            {
111
                amount     => $amount,
112
                lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
113
                type       => 'writeoff',
114
                note       => $payment_note,
115
                library_id => $branch,
116
            }
117
        );
118
    }
105
}
119
}
106
120
107
for (@names) {
121
for (@names) {
(-)a/members/paycollect.pl (-1 / +4 lines)
Lines 182-187 borrower_add_additional_fields($borrower, $template); Link Here
182
182
183
$template->param(%$borrower);
183
$template->param(%$borrower);
184
184
185
if ( $input->param('error_over') ) {
186
    $template->param( error_over => 1, total_due => $input->param('amountoutstanding') );
187
}
188
185
$template->param(
189
$template->param(
186
    borrowernumber => $borrowernumber,    # some templates require global
190
    borrowernumber => $borrowernumber,    # some templates require global
187
    patron        => $patron,
191
    patron        => $patron,
188
- 

Return to bug 20120