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 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Price %]
3
[% SET footerjs = 1 %]
4
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
6
<title>Koha &rsaquo; Patrons &rsaquo; Collect fine payment for  [% patron.firstname %] [% patron.surname %]</title>
Lines 105-110 Link Here
105
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
106
    <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id %]" />
106
    <input type="hidden" name="title" id="title" value="[% title %]" />
107
    <input type="hidden" name="title" id="title" value="[% title %]" />
107
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
108
    <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note %]" />
109
    <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding %]" />
110
    <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
108
    <table>
111
    <table>
109
    <thead><tr>
112
    <thead><tr>
110
            <th>Description</th>
113
            <th>Description</th>
Lines 125-136 Link Here
125
                <li>
128
                <li>
126
                    <label for="paid">Writeoff amount: </label>
129
                    <label for="paid">Writeoff amount: </label>
127
                    <!-- default to writing off all -->
130
                    <!-- default to writing off all -->
128
                    <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding %]" />
131
                    <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price %]" />
129
                </li>
132
                </li>
130
            </ol>
133
            </ol>
131
        </fieldset>
134
        </fieldset>
132
        <div class="action"><input type="submit" name="confirm_writeoff" id="confirm_writeoff" value="Write off this charge" />
135
        <div class="action">
133
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></div>
136
            <input type="submit" value="Write off this charge" />
137
            <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
138
        </div>
134
    </form>
139
    </form>
135
[% ELSE %]
140
[% ELSE %]
136
141
Lines 175-186 Link Here
175
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
180
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
176
    <script type= "text/javascript">
181
    <script type= "text/javascript">
177
        $(document).ready(function() {
182
        $(document).ready(function() {
178
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
183
            $('#payindivfine, #payfine').preventDoubleFormSubmit();
179
            $("#paid").on("change",function(){
184
            $("#paid").on("change",function(){
180
                moneyFormat( this );
185
                moneyFormat( this );
181
            });
186
            });
182
        });
187
        });
183
188
189
        prevent_default = 1;
190
        $('#woindivfine').on('submit', function(e){
191
            if ( prevent_default ) {
192
                e.preventDefault();
193
194
                let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
195
                let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
196
                if ( amount_writeoff > amount_outstanding ) {
197
                    alert(_("You are attemping to writeoff more than the value of the fee."));
198
                    $('#woindivfine').beenSubmitted = false;
199
                } else {
200
                    prevent_default = 0;
201
                    $('#woindivfine').preventDoubleFormSubmit();
202
                    $('#woindivfine').submit();
203
                }
204
            }
205
        });
206
184
        function moneyFormat(textObj) {
207
        function moneyFormat(textObj) {
185
            var newValue = textObj.value;
208
            var newValue = textObj.value;
186
            var decAmount = "";
209
            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 174-179 borrower_add_additional_fields($borrower, $template); Link Here
174
174
175
$template->param(%$borrower);
175
$template->param(%$borrower);
176
176
177
if ( $input->param('error_over') ) {
178
    $template->param( error_over => 1, total_due => $input->param('amountoutstanding') );
179
}
180
177
$template->param(
181
$template->param(
178
    borrowernumber => $borrowernumber,    # some templates require global
182
    borrowernumber => $borrowernumber,    # some templates require global
179
    patron        => $patron,
183
    patron        => $patron,
180
- 

Return to bug 20120