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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt (+518 lines)
Line 0 Link Here
1
[% SET accounts_view = 1 %]
2
[% USE KohaDates %]
3
[% USE Currency %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
8
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
9
[% INCLUDE 'datatables.inc' %]
10
[% INCLUDE 'browser-strings.inc' %]
11
12
<script type="text/javascript">
13
//<![CDATA[
14
$(document).ready(function() {
15
    void_compare = "[% 0 FILTER $Currency highlight => highlight %]";
16
17
    [% IF credit_id %]
18
        accountPrint( 'credit', [% credit_id %] );
19
    [% ELSIF debit_id %]
20
        accountPrint( 'debit', [% debit_id %] );
21
    [% END %]
22
23
    $('#account-credits').hide();
24
    $('#account-debits-switcher').click(function() {
25
         $('#account-debits').slideUp();
26
         $('#account-credits').slideDown();
27
    });
28
    $('#account-credits-switcher').click(function() {
29
         $('#account-credits').slideUp();
30
         $('#account-debits').slideDown();
31
    });
32
33
    var anOpen = [];
34
    var sImageUrl = "[% interface %]/[% theme %]/img/";
35
36
    var debitsTable = $('#debits-table').dataTable( {
37
        "sDom": "<'row-fluid'<'span6'T><'span6'>r>t<'row-fluid'><'top pager'ilpf>t<'bottom pager'ip>",
38
        "oTableTools": {
39
            "sSwfPath": "[% interface %]/lib/jquery/plugins/TableTools/media/swf/copy_csv_xls_pdf.swf",
40
            "aButtons": [
41
                {
42
                    "sExtends": "print",
43
                    "sButtonText": "<i class='icon-print'></i> " + _("Print")
44
                },
45
                {
46
                    "sExtends":    "collection",
47
                    "sButtonText": "<i class='icon-download'></i> " + _("Download") + " <span class='caret' />",
48
                    "aButtons": [
49
                        {
50
                            "sExtends": "csv",
51
                            "sButtonText": "<i class='icon-file'></i> " + _("CSV")
52
                        }
53
                    ]
54
                }
55
            ]
56
        },
57
        "bProcessing": true,
58
        "aoColumns": [
59
            {
60
                "mDataProp": null,
61
                "sClass": "control center",
62
                "sDefaultContent": '<img src="'+sImageUrl+'details_open.png'+'">'
63
            },
64
            { "mDataProp": "debit_id" },
65
            { "mDataProp": "description" },
66
            {
67
                "mDataProp": "type",
68
                "fnRender": function ( o, val ) {
69
                    return STRINGS['DebitTypes'][val] || val;
70
                },
71
            },
72
            { "mDataProp": "amount_original" },
73
            { "mDataProp": "amount_outstanding" },
74
            { "mDataProp": "created_on" },
75
            { "mDataProp": "updated_on" }
76
        ],
77
        "aaData": [
78
            [% FOREACH d IN debits %]
79
                {
80
                    [% PROCESS format_data data=d highlight='debit' %]
81
82
                    // Data for related item if there is one linked
83
                    "title": "[% d.item.biblio.title || d.deleted_item.biblio.title || d.deleted_item.deleted_biblio.title | replace('"', '\"') %]",
84
                    "biblionumber": "[% d.item.biblio.biblionumber || d.deleted_item.biblio.biblionumber %]",
85
                    "barcode": "[% d.item.barcode || d.deleted_item.barcode %]",
86
                    "itemnumber": "[% d.item.itemnumber %]", //This way itemnumber will be undef if deleted
87
88
89
                    // Data for related issue if there is one linked
90
                    [% IF d.issue %]
91
                        [% SET table = 'issue' %]
92
                    [% ELSIF d.old_issue %]
93
                        [% SET table = 'old_issue' %]
94
                    [% END %]
95
96
                    [% IF table %]
97
                        "issue": {
98
                            [% PROCESS format_data data=d.$table %]
99
                        },
100
                    [% END %]
101
102
103
                    "account_offsets": [
104
                        [% FOREACH ao IN d.account_offsets %]
105
                            [% IF ao.credit %]
106
                                {
107
                                    [% PROCESS format_data data=ao highlight='offset'%]
108
109
                                    "credit": {
110
                                        [% PROCESS format_data data=ao.credit highlight='credit' %]
111
                                    }
112
                                },
113
                            [% END %]
114
                        [% END %]
115
                    ]
116
117
                },
118
            [% END %]
119
        ]
120
    } );
121
122
    $('#debits-table td.control').live( 'click', function () {
123
        var nTr = this.parentNode;
124
        var i = $.inArray( nTr, anOpen );
125
126
        if ( i === -1 ) {
127
            $('img', this).attr( 'src', sImageUrl+"details_close.png" );
128
            var nDetailsRow = debitsTable.fnOpen( nTr, fnFormatDebitDetails(debitsTable, nTr), 'details' );
129
            $('div.innerDetails', nDetailsRow).slideDown();
130
            anOpen.push( nTr );
131
        }
132
        else {
133
            $('img', this).attr( 'src', sImageUrl+"details_open.png" );
134
            $('div.innerDetails', $(nTr).next()[0]).slideUp( function () {
135
                debitsTable.fnClose( nTr );
136
                anOpen.splice( i, 1 );
137
            } );
138
        }
139
    } );
140
141
    var creditsTable = $('#credits-table').dataTable( {
142
        "sDom": "<'row-fluid'<'span6'T><'span6'>r>t<'row-fluid'><'top pager'ilpf>t<'bottom pager'ip>",
143
        "oTableTools": {
144
            "sSwfPath": "[% interface %]/lib/jquery/plugins/TableTools/media/swf/copy_csv_xls_pdf.swf",
145
            "aButtons": [
146
                {
147
                    "sExtends": "print",
148
                    "sButtonText": "<i class='icon-print'></i> " + _("Print")
149
                },
150
                {
151
                    "sExtends":    "collection",
152
                    "sButtonText": "<i class='icon-download'></i> " + _("Download") + " <span class='caret' />",
153
                    "aButtons": [
154
                        {
155
                            "sExtends": "csv",
156
                            "sButtonText": "<i class='icon-file'></i> " + _("CSV")
157
                        }
158
                    ]
159
                }
160
            ]
161
        },
162
        "bProcessing": true,
163
        "aoColumns": [
164
            {
165
                "mDataProp": null,
166
                "sClass": "control center",
167
                "sDefaultContent": '<img src="'+sImageUrl+'details_open.png'+'">'
168
            },
169
            { "mDataProp": "credit_id" },
170
            { "mDataProp": "notes" },
171
            {
172
                "mDataProp": "type",
173
                "fnRender": function ( o, val ) {
174
                    return STRINGS['CreditTypes'][val] || val;
175
                },
176
            },
177
            {
178
                "mDataProp": "amount_paid",
179
                "mRender": function ( data, type, full ) {
180
                    if ( full.amount_voided != void_compare ) {
181
                        return "<strike>" + full.amount_voided + "</strike>";
182
                    } else {
183
                        return full.amount_paid;
184
                    }
185
                }
186
            },
187
            { "mDataProp": "amount_remaining" },
188
            { "mDataProp": "created_on" },
189
            { "mDataProp": "updated_on" }
190
        ],
191
        "aaData": [
192
            [% FOREACH c IN credits %]
193
                {
194
                    [% PROCESS format_data data=c highlight='credit' %]
195
196
                    "account_offsets": [
197
                        [% FOREACH ao IN c.account_offsets %]
198
                            {
199
                                [% PROCESS format_data data=ao highlight='offset' %]
200
201
                                "debit": {
202
                                    [% PROCESS format_data data=ao.debit highlight='debit' %]
203
                                }
204
                            },
205
                        [% END %]
206
                    ]
207
208
                },
209
            [% END %]
210
        ]
211
    } );
212
213
    $('#credits-table td.control').live( 'click', function () {
214
        var nTr = this.parentNode;
215
        var i = $.inArray( nTr, anOpen );
216
217
        if ( i === -1 ) {
218
            $('img', this).attr( 'src', sImageUrl+"details_close.png" );
219
            var nDetailsRow = creditsTable.fnOpen( nTr, fnFormatCreditDetails(creditsTable, nTr), 'details' );
220
            $('div.innerDetails', nDetailsRow).slideDown();
221
            anOpen.push( nTr );
222
        }
223
        else {
224
            $('img', this).attr( 'src', sImageUrl+"details_open.png" );
225
            $('div.innerDetails', $(nTr).next()[0]).slideUp( function () {
226
                creditsTable.fnClose( nTr );
227
                anOpen.splice( i, 1 );
228
            } );
229
        }
230
    } );
231
232
} );
233
234
function fnFormatDebitDetails( debitsTable, nTr ) {
235
    var oData = debitsTable.fnGetData( nTr );
236
237
    var sOut = "<div class='innerDetails' style='display:none;'>";
238
239
    var account_offsets = oData.account_offsets;
240
241
    sOut += "<a class='debit_print btn btn-small noprint' style='margin:5px;' onclick='accountPrint(\"debit\"," + oData.debit_id + ")'>" +
242
                "<i class='icon-print'></i> " + _("Print receipt") +
243
            "</a>";
244
245
    sOut += "<ul>";
246
    if ( oData.title ) {
247
        sOut += "<li>" + _("Title: ");
248
        if ( oData.biblionumber ) {
249
            sOut += "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + oData.biblionumber + "'>";
250
        }
251
252
        sOut += oData.title;
253
254
        if ( oData.biblionumber ) {
255
            sOut += "</a>";
256
        }
257
258
        sOut += "</li>";
259
    }
260
261
    if ( oData.barcode ) {
262
        sOut += "<li>" + _("Barcode: ");
263
        if ( oData.itemnumber ) {
264
            sOut += "<a href='/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=11&biblionumber=" + oData.biblionumber + "&bi=" + oData.biblionumber + "#item" + oData.itemnumber + "" + oData.biblionumber + "'>";
265
        }
266
267
        sOut += oData.barcode;
268
269
        if ( oData.itemnumber ) {
270
            sOut += "</a>";
271
        }
272
273
        sOut += "</li>";
274
    }
275
276
    if ( oData.notes ) {
277
        sOut += "<li>" + _("Notes: ") + oData.notes + "</li>";
278
    }
279
280
    sOut += "</ul>";
281
282
    if ( account_offsets.length ) {
283
        sOut +=
284
            "<div class='innerDetails'>" +
285
                "<table cellpadding='5' cellspacing='0' border='0' style='margin:10px;'>" +
286
                    "<thead>" +
287
                        "<tr><th colspan='99'>" + _("Payments applied") + "</th></tr>" +
288
                        "<tr>" +
289
                            "<th>" + _("ID") + "</th>" +
290
                            "<th>" + _("Created on") + "</th>" +
291
                            "<th>" + _("Payment amount") + "</th>" +
292
                            "<th>" + _("Applied amount") + "</th>" +
293
                            "<th>" + _("Type") + "</th>" +
294
                            "<th>" + _("Notes") + "</th>" +
295
                        "</tr>" +
296
                    "</thead>" +
297
                    "<tbody>";
298
299
        for ( var i = 0; i < account_offsets.length; i++ ) {
300
            ao = account_offsets[i];
301
            credit_type = STRINGS["CreditTypes"][ao.credit.type] || ao.credit.type;
302
            offset_type = STRINGS["OffsetTypes"][ao.type] || ao.type;
303
            if ( offset_type ) offset_type = " (" + offset_type + ") ";
304
305
            var payment_or_void;
306
            if ( ao.credit.amount_voided != void_compare ) {
307
                payment_or_void = "<strike>" + ao.credit.amount_voided + "</strike>";
308
            } else {
309
                payment_or_void = ao.credit.amount_paid;
310
            }
311
312
            sOut +=
313
            "<tr>" +
314
                "<td>" + ao.credit_id + "</td>" +
315
                "<td>" + ao.created_on + "</td>" +
316
                "<td>" + payment_or_void + "</td>" +
317
                "<td>" + ao.amount + "</td>" +
318
                "<td>" + credit_type + offset_type  + "</td>" +
319
                "<td>" + ao.credit.notes + "</td>" +
320
            "</tr>";
321
        }
322
323
        sOut +=
324
            "</tbody>"+
325
            "</table>";
326
    }
327
328
    sOut +=
329
        "</div>";
330
331
    return sOut;
332
}
333
334
function fnFormatCreditDetails( creditsTable, nTr ) {
335
    var oData = creditsTable.fnGetData( nTr );
336
337
    var sOut = "<div class='innerDetails' style='display:none;'>";
338
339
    sOut += "<button class='credit_print btn btn-small noprint' style='margin:5px;' onclick='accountPrint(\"credit\"," + oData.credit_id + ")'>" +
340
                "<i class='icon-print'></i> " + _("Print receipt") +
341
            "</button>";
342
343
    if ( ! oData.amount_voided_original ) {
344
    sOut += "<a class='credit_void btn btn-small noprint' style='margin:5px;' onclick='accountVoid(\"credit\"," + oData.credit_id + ")'>" +
345
                "<i class='icon-remove-sign'></i> " + _("Void payment") +
346
            "</a>";
347
    }
348
349
    var account_offsets = oData.account_offsets;
350
351
    if ( account_offsets.length ) {
352
        sOut +=
353
                "<table cellpadding='5' cellspacing='0' border='0' style='margin:10px;'>" +
354
                    "<thead>" +
355
                        "<tr><th colspan='99'>" + _("Fees paid") + "</th></tr>" +
356
                        "<tr>" +
357
                            "<th>" + _("ID") + "</th>" +
358
                            "<th>" + _("Description") + "</th>" +
359
                            "<th>" + _("Type") + "</th>" +
360
                            "<th>" + _("Amount") + "</th>" +
361
                            "<th>" + _("Amount applied") + "</th>" +
362
                            "<th>" + _("Remaining") + "</th>" +
363
                            "<th>" + _("Created on") + "</th>" +
364
                            "<th>" + _("Updated on") + "</th>" +
365
                            "<th>" + _("Notes") + "</th>" +
366
                        "</tr>" +
367
                    "</thead>" +
368
                    "<tbody>";
369
370
        for ( var i = 0; i < account_offsets.length; i++ ) {
371
            ao = account_offsets[i];
372
            debit_type = STRINGS["DebitTypes"][ao.debit.type] || ao.debit.type;
373
            offset_type = STRINGS["OffsetTypes"][ao.type] || ao.type;
374
            if ( offset_type ) offset_type = " (" + offset_type + ") ";
375
376
            sOut +=
377
            "<tr>" +
378
                "<td>" + ao.debit.debit_id + "</td>" +
379
                "<td>" + ao.debit.description + "</td>" +
380
                "<td>" + debit_type + offset_type + "</td>" +
381
                "<td>" + ao.debit.amount_original + "</td>" +
382
                "<td>" + ao.amount + "</td>" +
383
                "<td>" + ao.debit.amount_outstanding + "</td>" +
384
                "<td>" + ao.debit.created_on + "</td>" +
385
                "<td>" + ao.debit.updated_on + "</td>" +
386
                "<td>" + ao.debit.notes + "</td>" +
387
            "</tr>";
388
        }
389
390
        sOut +=
391
            "</tbody>"+
392
            "</table>";
393
    }
394
395
    sOut +=
396
        "</div>";
397
398
    return sOut;
399
}
400
401
function accountPrint( type, id ) {
402
    window.open( "/cgi-bin/koha/members/account_print.pl?type=" + type + "&id=" + id );
403
}
404
405
function accountVoid( type, id ) {
406
    if ( confirm(_("Are you sure you want to void this transaction?")) ) {
407
        window.location.href = "/cgi-bin/koha/members/account_void.pl?borrowernumber=" + [% borrowernumber %] + "&id=" + id;
408
    }
409
}
410
//]]>
411
</script>
412
</head>
413
<body>
414
[% INCLUDE 'header.inc' %]
415
[% INCLUDE 'patron-search.inc' %]
416
417
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</div>
418
419
<div id="doc3" class="yui-t2">
420
    <div id="bd">
421
           <div id="yui-main">
422
                <div class="yui-b">
423
                [% INCLUDE 'members-toolbar.inc' %]
424
425
                <div class="statictabs">
426
                    <ul>
427
                        <li class="active">
428
                            <a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a>
429
                        </li>
430
431
                        <li>
432
                            <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a>
433
                        </li>
434
435
                        <li>
436
                            <a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a>
437
                        </li>
438
439
                        <li>
440
                            <a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a>
441
                        </li>
442
                    </ul>
443
                </div>
444
445
                <div class="tabs-container">
446
447
                    <p>
448
                        <h3>Account balance: [% borrower.account_balance | $Currency %]</h3>
449
                    </p>
450
451
                    <div>
452
                        <div id="account-debits">
453
                            <p><a id="account-debits-switcher" href="#" onclick="return false">View payments</a></p>
454
                            <table cellpadding="0" cellspacing="0" border="0" class="display" id="debits-table">
455
                                <thead>
456
                                    <tr>
457
                                        <th colspan="99">Fees</th>
458
                                    </tr>
459
                                    <tr>
460
                                        <th></th>
461
                                        <th>ID</th>
462
                                        <th>Description</th>
463
                                        <th>Type</th>
464
                                        <th>Amount</th>
465
                                        <th>Outstanding</th>
466
                                        <th>Created on</th>
467
                                        <th>Updated on</th>
468
                                    </tr>
469
                                </thead>
470
                                <tbody></tbody>
471
                            </table>
472
                        </div>
473
474
                        <div id="account-credits">
475
                            <p><a id="account-credits-switcher" href="#"  onclick="return false">View fees</a></p>
476
                            <table cellpadding="0" cellspacing="0" border="0" class="display" id="credits-table">
477
                                <thead>
478
                                    <tr>
479
                                        <th colspan="99">Payments</th>
480
                                    </tr>
481
                                    <tr>
482
                                        <th></th>
483
                                        <th>ID</th>
484
                                        <th>Notes</th>
485
                                        <th>Type</th>
486
                                        <th>Amount</th>
487
                                        <th>Remaining</th>
488
                                        <th>Created on</th>
489
                                        <th>Updated on</th>
490
                                    </tr>
491
                                </thead>
492
                                <tbody></tbody>
493
                            </table>
494
                        </div>
495
                    </div>
496
                </div>
497
            </div>
498
        </div>
499
500
    <div class="yui-b">
501
        [% INCLUDE 'circ-menu.inc' %]
502
    </div>
503
</div>
504
[% INCLUDE 'intranet-bottom.inc' %]
505
506
[% BLOCK format_data %]
507
    [% FOREACH key IN data.result_source.columns %]
508
        [% IF key.match('^amount') %]
509
            "[% key %]_original": "[% data.$key %]",
510
            "[% key %]": "[% data.$key FILTER $Currency highlight => highlight %]",
511
        [% ELSIF key.match('_on$') %]
512
            "[% key %]_original": "[% data.$key %]",
513
            "[% key %]": "[% data.$key | $KohaDates %]",
514
        [% ELSE %]
515
            "[% key %]": "[% data.$key | replace('"', '\"') %]",
516
        [% END %]
517
    [% END %]
518
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt (+97 lines)
Line 0 Link Here
1
[% SET accounts_view = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Borrowers &rsaquo; Create manual credit</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript">
6
//<![CDATA[
7
$(document).ready(function(){
8
    $('#account_credit').preventDoubleFormSubmit();
9
    $("fieldset.rows input").addClass("noEnterSubmit");
10
11
    $("#amount").bind('keyup blur', function() {
12
        // Allow only numbers in amount received
13
        $(this).val($(this).val().replace(/[^\d.]/g, ''));
14
    });
15
});
16
//]]>
17
</script>
18
</head>
19
<body id="pat_account_credit" class="pat">
20
    [% INCLUDE 'header.inc' %]
21
    [% INCLUDE 'patron-search.inc' %]
22
23
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Manual credit</div>
24
25
    <div id="doc3" class="yui-t2">
26
        <div id="bd">
27
               <div id="yui-main">
28
            <div class="yui-b">
29
                    [% INCLUDE 'members-toolbar.inc' %]
30
31
                    <div class="statictabs">
32
                        <ul>
33
                            <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
34
                            <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
35
                            <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
36
                            <li class="active"><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
37
                        </ul>
38
39
                        <div class="tabs-container">
40
41
                            <form action="/cgi-bin/koha/members/account_credit_do.pl" method="post" id="account_credit">
42
                                <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
43
44
                                <fieldset class="rows">
45
                                    <legend>Manual credit</legend>
46
47
                                    <ol>
48
                                        <li>
49
                                            <label for="type">Credit Type: </label>
50
                                            <select name="type" id="type">
51
                                                <option value="CREDIT">Credit</option>
52
                                                <option value="FORGIVEN">Forgiven</option>
53
                                                [% FOREACH c IN credit_types_loop %]
54
                                                    <option value="[% c.authorised_value %]">[% c.lib %]</option>
55
                                                [% END %]
56
                                            </select>
57
                                        </li>
58
59
                                        <li>
60
                                            <label for="barcode">Barcode: </label>
61
                                            <input type="text" name="barcode" id="barcode" />
62
                                        </li>
63
64
                                        <li>
65
                                            <label for="desc">Description: </label>
66
                                            <input type="text" name="desc" size="50" id="desc" />
67
                                        </li>
68
69
                                        <li>
70
                                            <label for="note">Note: </label>
71
                                            <input type="text" name="note" size="50" id="note" />
72
                                        </li>
73
74
                                        <li>
75
                                            <label for="amount">Amount: </label>
76
                                            <input type="text" name="amount" id="amount" />
77
                                            Example: 5.00
78
                                        </li>
79
                                    </ol>
80
81
                                </fieldset>
82
83
                                <fieldset class="action">
84
                                    <input type="submit" name="add" value="Add credit" />
85
                                    <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
86
                                </fieldset>
87
                            </form>
88
89
                        </div>
90
                    </div>
91
                </div>
92
            </div>
93
        <div class="yui-b">
94
            [% INCLUDE 'circ-menu.inc' %]
95
        </div>
96
    </div>
97
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt (+114 lines)
Line 0 Link Here
1
[% SET accounts_view = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Borrowers &rsaquo; Create manual invoice</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript">
6
//<![CDATA[
7
$(document).ready(function(){
8
    $('#maninvoice').preventDoubleFormSubmit();
9
    $("fieldset.rows input").addClass("noEnterSubmit");
10
11
    var type_fees = new Array();
12
    type_fees['L'] = '';
13
    type_fees['F'] = '';
14
    type_fees['A'] = '';
15
    type_fees['N'] = '';
16
    type_fees['M'] = '';
17
    [% FOREACH invoice_types_loo IN invoice_types_loop %]
18
        type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.lib %]";
19
    [% END %]
20
21
    $("#amount").bind('keyup blur', function() {
22
        // Allow only numbers in amount received
23
        $(this).val($(this).val().replace(/[^\d.]/g, ''));
24
    });
25
});
26
//]]>
27
</script>
28
</head>
29
30
<body>
31
    [% INCLUDE 'header.inc' %]
32
    [% INCLUDE 'patron-search.inc' %]
33
34
    <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Manual invoice</div>
35
36
    <div id="doc3" class="yui-t2">
37
        <div id="bd">
38
            <div id="yui-main">
39
                <div class="yui-b">
40
                    [% INCLUDE 'members-toolbar.inc' %]
41
42
                    <div class="statictabs">
43
                    <ul>
44
                        <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li>
45
                        <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li>
46
                        <li class="active"><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li>
47
                        <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li>
48
                    </ul>
49
                    <div class="tabs-container">
50
51
                    <form action="/cgi-bin/koha/members/account_debit_do.pl" method="post" id="account_debit">
52
                        <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
53
54
                        <fieldset class="rows">
55
                            <legend>Manual Invoice</legend>
56
57
                            <ol>
58
                                <li>
59
                                    <label for="type">Type: </label>
60
                                    <select name="type" id="type">
61
                                        <option value="LOST">Lost item</option>
62
                                        <option value="FINE">Fine</option>
63
                                        <option value="ACCOUNT_MANAGEMENT_FEE">Account management fee</option>
64
                                        <option value="NEW_CARD">New card</option>
65
                                        <option value="SUNDRY">Sundry</option>
66
67
                                        [% FOREACH invoice_types_loo IN invoice_types_loop %]
68
                                            <option value="[% invoice_types_loo.authorised_value %]">[% invoice_types_loo.lib %]</option>
69
                                        [% END %]
70
                                    </select>
71
                                </li>
72
73
                                <!-- TODO: Write ajax barcode validator that appends the itemnumber for this form in a hidden input -->
74
                                 <li>
75
                                    <label for="barcode">Barcode: </label>
76
                                    <input type="text" name="barcode" id="barcode" />
77
                                </li>
78
79
                                <li>
80
                                    <label for="description">Description: </label>
81
                                    <input type="text" name="description" id="description" size="50" />
82
                                </li>
83
84
                                <li>
85
                                    <label for="notes">Notes: </label>
86
                                    <input type="text" name="notes" size="50" id="notes" />
87
                                </li>
88
89
                                <li>
90
                                    <label for="amount">Amount: </label>
91
                                    <input type="text" name="amount" id="amount" /> Example: 5.00
92
                                </li>
93
94
                            </ol>
95
                        </fieldset>
96
97
                        <fieldset class="action">
98
                            <input type="submit" name="add" value="Save" />
99
                            <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
100
                        </fieldset>
101
102
                    </form>
103
104
                </div>
105
            </div>
106
        </div>
107
    </div>
108
109
<div class="yui-b">
110
  [% INCLUDE 'circ-menu.inc' %]
111
</div>
112
113
</div>
114
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt (+246 lines)
Line 0 Link Here
1
[% SET accounts_view = 1 %]
2
[% USE Currency %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons &rsaquo; Pay Fines for  [% borrower.firstname %] [% borrower.surname %]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'browser-strings.inc' %]
7
<script type= "text/javascript">
8
//<![CDATA[
9
$( document ).ready(function() {
10
    $('#account-payment-form').preventDoubleFormSubmit();
11
12
    // Convert codes to translated strings
13
    $(".debit-type").each(function() {
14
        $(this).html( STRINGS['DebitTypes'][ $(this).html() ] );
15
    });
16
17
    // Show amount recieved only if the "Receive different amount" checkbox is checked
18
    $("#amount-received-p").hide();
19
    $("#receive_different_amount").bind('click focus blur', function() {
20
        if( $(this).is(':checked')) {
21
            $("#amount-received-p").show();
22
            $("#amount_received").focus();
23
            $("#amount_received").keyup();
24
        } else {
25
            $("#amount-received-p").hide();
26
            $("#amount_to_pay").keyup();
27
        }
28
    });
29
30
    $("#amount_received").bind('keyup blur', function() {
31
        // Allow only numbers in amount received
32
        $(this).val($(this).val().replace(/[^\d.]/g, ''));
33
34
        if ( $("#receive_different_amount").attr('checked') ) {
35
            // Make sure the amount recieved is greater than the amount to pay if it is being used
36
            amount_received = parseFloat( $("#amount_received").val() ) || 0;
37
            amount_to_pay = parseFloat( $("#amount_to_pay").val() ) || 0;
38
            if ( amount_received < amount_to_pay ) {
39
                $("#process").attr('disabled','disabled');
40
            } else {
41
                $("#process").removeAttr('disabled');
42
            }
43
        }
44
    });
45
46
    // Allow only numbers in amount to pay
47
    $("#amount_to_pay").bind('keyup blur', function() {
48
        // Allow only numbers in amount received
49
        $(this).val($(this).val().replace(/[^\d.]/g, ''));
50
51
        // Disallow over-payments
52
        if ( parseFloat( $(this).val() ) > parseFloat( $("#total_due").val() ) ) {
53
            $("#process").attr('disabled','disabled');
54
        } else {
55
            $("#process").removeAttr('disabled');
56
        }
57
58
        $("#amount_received").keyup();
59
    });
60
61
    // Enable the "Select all/Clear all" links
62
    $('#CheckAll').click(function() {
63
        $("input[name='debit_id']" ).prop('checked', true).trigger("change");
64
    });
65
    $('#ClearAll').click(function() {
66
        $("input[name='debit_id']" ).prop('checked', false).trigger("change");
67
    });
68
69
    // Update the "amount to pay" field whenever a fee checkbox is changed
70
    // Note, this is just a payment suggestion and can be changed to any amount
71
    $("input[name='debit_id']" ).change(function() {
72
        var sum = 0;
73
        $("input[name='debit_id']:checked" ).each(function(i,n){
74
            sum += parseFloat( $( "#amount_outstanding_" + $(this).val() ).val() );
75
        });
76
        $('#amount_to_pay').val( sum.toFixed(2) );
77
    });
78
});
79
80
function checkForm(){
81
    // If using the "amount to receive" field, make sure the librarian is recieving at
82
    // least enough to pay those fees.
83
    if ( $('#amount_received').val() ) {
84
        if ( parseFloat( $('#amount_received').val() ) < parseFloat( $('#amount_to_pay').val() ) ) {
85
            alert( _("Cannot pay more than receieved!") );
86
            return false;
87
        }
88
    }
89
90
    return true;
91
}
92
//]]>
93
</script>
94
</head>
95
<body id="pat_pay" class="pat">
96
    [% INCLUDE 'header.inc' %]
97
    [% INCLUDE 'patron-search.inc' %]
98
99
    <div id="breadcrumbs">
100
        <a href="/cgi-bin/koha/mainpage.pl">Home</a>
101
        &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
102
        &rsaquo; Pay fines for [% borrower.firstname %] [% borrower.surname %]
103
    </div>
104
105
    <div id="doc3" class="yui-t2">
106
        <div id="bd">
107
            <div id="yui-main">
108
                <div class="yui-b">
109
                    [% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %]
110
111
                    <div class="statictabs">
112
                        <ul>
113
                            <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li>
114
                            <li class="active"><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li>
115
                            <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li>
116
                            <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li>
117
                        </ul>
118
119
                        <div class="tabs-container">
120
121
                        [% IF ( debits ) %]
122
                            <form action="/cgi-bin/koha/members/account_payment_do.pl" method="post" id="account-payment-form" onsubmit="return checkForm()">
123
124
                                <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" />
125
126
                                <p>
127
                                    <span class="checkall">
128
                                        <a id="CheckAll" href="#">Select all</a>
129
                                    </span>
130
131
                                    |
132
133
                                    <span class="clearall">
134
                                        <a id="ClearAll" href="#">Clear all</a>
135
                                    </span>
136
                                </p>
137
138
                                <table id="finest">
139
                                    <thead>
140
                                        <tr>
141
                                            <th>&nbsp;</th>
142
                                            <th>Description</th>
143
                                            <th>Account type</th>
144
                                            <th>Original amount</th>
145
                                            <th>Amount outstanding</th>
146
                                        </tr>
147
                                    </thead>
148
149
                                    <tbody>
150
                                        [% SET total_due = 0 %]
151
                                        [% FOREACH d IN debits %]
152
                                            [% SET total_due = total_due + d.amount_outstanding %]
153
                                            <tr>
154
                                                <td>
155
                                                    <input type="checkbox" checked="checked" name="debit_id" value="[% d.debit_id %]" />
156
                                                </td>
157
158
                                                <td>
159
                                                    [% d.description %]
160
161
                                                    [% IF d.notes %]
162
                                                        ( <i>[% d.notes %]</i> )
163
                                                    [% END %]
164
                                                </td>
165
166
                                                <td>
167
                                                    <span class="debit-type">[% d.type %]</span>
168
                                                </td>
169
170
                                                <td class="debit">
171
                                                    [% d.amount_original | $Currency %]
172
                                                    <input type="hidden" id="amount_original_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_original ) %]" />
173
                                                </td>
174
175
                                                <td class="debit">
176
                                                    [% d.amount_outstanding | $Currency %]
177
                                                    <input type="hidden" id="amount_outstanding_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_outstanding ) %]" />
178
                                                </td>
179
                                            </tr>
180
                                        [% END %]
181
                                    </tbody>
182
183
                                    <tfoot>
184
                                        <tr>
185
                                            <td class="total" colspan="4">Total Due:</td>
186
                                            <td>[% total_due | $Currency %]</td>
187
                                        </tr>
188
                                    </tfoot>
189
190
                                </table>
191
192
                                <fieldset>
193
                                    <p>
194
                                        <label for="amount_to_pay">Amount to pay: [% Currency.symbol() %]</label>
195
                                        <input type="text" name="amount_to_pay" id="amount_to_pay" value="[% Currency.format_without_symbol( total_due ) %]" />
196
                                        <input type="hidden" name="total_due" id="total_due" value="[% total_due %]" />
197
198
                                        <input type="checkbox" id="receive_different_amount" />
199
                                        <label for="receive_different_amount"><i>Receive different amount</i></label>
200
                                    </p>
201
202
                                    <p id="amount-received-p">
203
                                        <label for="amount_received">Amount recieved: [% Currency.symbol() %]</label>
204
                                        <input type="text" name="amount_received" id="amount_received" />
205
                                    </p>
206
207
                                    <p>
208
                                        <label for="type">Type:</label>
209
                                        <select id="type" name="type">
210
                                            <option value="PAYMENT">Payment</option>
211
                                            <option value="WRITEOFF">Writeoff</option>
212
                                            [% FOREACH c IN credit_types_loop %]
213
                                                <option value="[% c.authorised_value %]">[% c.lib %]</option>
214
                                            [% END %]
215
                                        </select>
216
                                    </p>
217
218
                                    <p>
219
                                        <label for="notes">Payment notes:</label>
220
                                        <input type="textbox" name="notes" id="notes" />
221
                                    <p>
222
                                </fieldset>
223
224
                                <fieldset class="action">
225
                                    <input type="submit" id="process" value="Process" class="submit" />
226
                                    <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a>
227
                                </fieldset>
228
229
                            </form>
230
231
                        [% ELSE %]
232
                            <p>
233
                                [% borrower.firstname %] [% borrower.surname %] has no outstanding fines.
234
                            </p>
235
                        [% END %]
236
237
                    </div>
238
                </div>
239
            </div>
240
        </div>
241
242
        <div class="yui-b">
243
            [% INCLUDE 'circ-menu.tt' %]
244
        </div>
245
    </div>
246
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt (+146 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Currency %]
3
[% USE EncodeUTF8 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Print Receipt for [% cardnumber %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" />
9
<script type="text/javascript">
10
    function printThenClose() {
11
        window.print();
12
        window.close();
13
    }
14
</script>
15
</head>
16
17
[% SET account = debit || credit %]
18
[% SET borrower = account.borrower %]
19
20
<body id="account-print-body" onload="printThenClose();">
21
22
    <table>
23
        <thead>
24
            <tr>
25
                <th colspan="99">
26
                    [% IF debit %]
27
                        Invoice
28
                    [% ELSIF credit %]
29
                        Payment receipt
30
                    [% END %]
31
                </th>
32
            </tr>
33
34
            <tr>
35
                <th colspan="99">
36
                    [% borrower.branch.branchname | $EncodeUTF8 %]
37
                </th>
38
            </tr>
39
40
            <tr>
41
                <th>Name:</th>
42
                <th colspan="99">[% borrower.firstname | $EncodeUTF8 %] [% borrower.surname | $EncodeUTF8 %]</th>
43
            </tr>
44
45
            <tr>
46
                <th>Card number:</th>
47
                <th colspan="99">[% borrower.cardnumber %]</th>
48
            </tr>
49
50
            <tr>
51
                <th>Date:</th>
52
                <th colspan="99">[% account.created_on | $KohaDates %]</th>
53
            </tr>
54
55
            [% IF account.description %]
56
                <tr>
57
                    <th>Description:</th>
58
                    <th colspan="99">[% account.description | $EncodeUTF8 %]</th>
59
                </tr>
60
            [% END %]
61
62
            [% IF credit %]
63
                <tr>
64
                    <th>Amount paid:</th>
65
                    <th colspan="99">[% credit.amount_paid | $Currency highlight => type %]</th>
66
                </tr>
67
                [% IF credit.amount_received > 0 %]
68
                    <tr>
69
                        <th>Amount received:</th>
70
                        <th colspan="99">[% credit.amount_received | $Currency highlight => type %]</th>
71
                    </tr>
72
                    <tr>
73
                        <th>Change due:</th>
74
                        <th colspan="99">[% credit.amount_received - credit.amount_paid | $Currency highlight => type %]</th>
75
                    </tr>
76
                [% END %]
77
                <tr>
78
                    <th>Balance:</th>
79
                    <th colspan="99">[% credit.amount_remaining | $Currency highlight => type %]</th>
80
                </tr>
81
                [% IF credit.account_offsets %]
82
                    <tr>
83
                        <th colspan="99">Fees paid</th>
84
                    </tr>
85
                    <tr>
86
                        <th>Description</th>
87
                        <th>Type</th>
88
                        <th>Amount</th>
89
                        <th>Paid</th>
90
                        <th>Outstanding</th>
91
                        <th>Date</th>
92
                    </tr>
93
                [% END %]
94
            [% ELSIF debit %]
95
                <tr>
96
                    <th>Amount:</th>
97
                    <th colspan="99">[% debit.amount_original | $Currency highlight => type %]</th>
98
                </tr>
99
                <tr>
100
                    <th>Outstanding:</th>
101
                    <th colspan="99">[% debit.amount_outstanding | $Currency highlight => type %]</th>
102
                </tr>
103
                [% IF debit.account_offsets %]
104
                    <tr>
105
                        <th colspan="99">Payments applied</th>
106
                    </tr>
107
                    <tr>
108
                        <th>Date</th>
109
                        <th>Type</th>
110
                        <th>Payment</th>
111
                        <th>Applied</th>
112
                        <th>Balance</th>
113
                        <th>Notes</th>
114
                    </tr>
115
                [% END %]
116
            [% END %]
117
        </thead>
118
119
        <tbody>
120
            [% IF credit.account_offsets %]
121
                [% FOREACH ao IN credit.account_offsets %]
122
                    <tr>
123
                        <td>[% ao.debit.description %]</td>
124
                        <td>[% ao.debit.type %]</td>
125
                        <td>[% ao.debit.amount_original | $Currency highlight => 'debit' %]</td>
126
                        <td>[% ao.amount | $Currency highlight => 'offset' %]</td>
127
                        <td>[% ao.debit.amount_outstanding | $Currency highlight => 'debit' %]</td>
128
                        <td>[% ao.debit.created_on | $KohaDates %]</td>
129
                    </tr>
130
                [% END %]
131
            [% ELSIF debit.account_offsets %]
132
                [% FOREACH ao IN debit.account_offsets %]
133
                    <tr>
134
                        <td>[% ao.credit.created_on | $KohaDates %]</td>
135
                        <td>[% ao.credit.type %]</td>
136
                        <td>[% ao.credit.amount_paid | $Currency highlight => 'credit' %]</td>
137
                        <td>[% ao.amount | $Currency highlight => 'offset' %]</td>
138
                        <td>[% ao.credit.amount_remaining | $Currency highlight => 'credit' %]</td>
139
                        <td>[% ao.credit.notes %]</td>
140
                    </tr>
141
                [% END %]
142
            [% END %]
143
        </tbody>
144
    </table>
145
146
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/members/account.pl (+118 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2013 ByWater Solutions
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 3 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
use Modern::Perl;
22
23
use CGI;
24
25
use C4::Auth;
26
use C4::Output;
27
use C4::Dates qw/format_date/;
28
use C4::Members;
29
use C4::Branch;
30
use C4::Members::Attributes qw(GetBorrowerAttributes);
31
use Koha::Database;
32
33
my $cgi = new CGI;
34
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36
    {
37
        template_name   => "members/account.tt",
38
        query           => $cgi,
39
        type            => "intranet",
40
        authnotrequired => 0,
41
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
42
        debug           => 1,
43
    }
44
);
45
46
my $borrowernumber = $cgi->param('borrowernumber');
47
48
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
49
50
my $schema =  Koha::Database->new()->schema();
51
52
my @debits = $schema->resultset('AccountDebit')->search(
53
    { 'me.borrowernumber' => $borrowernumber },
54
    { prefetch            => { account_offsets => 'credit' } }
55
);
56
57
my @credits = $schema->resultset('AccountCredit')->search(
58
    { 'me.borrowernumber' => $borrowernumber },
59
    { prefetch            => { account_offsets => 'debit' } }
60
);
61
62
$template->param(
63
    debits   => \@debits,
64
    credits  => \@credits,
65
    borrower => $borrower,
66
67
    # IDs for automatic receipt printing
68
    debit_id  => $cgi->param('debit_id')  || undef,
69
    credit_id => $cgi->param('credit_id') || undef,
70
);
71
72
# Standard /members/ borrower details data
73
## FIXME: This code is in every /members/ script and should be unified
74
75
if ( $borrower->{'category_type'} eq 'C' ) {
76
    my ( $catcodes, $labels ) =
77
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
78
    my $cnt = scalar(@$catcodes);
79
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
80
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
81
}
82
83
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
84
$template->param( picture => 1 ) if $picture;
85
86
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
87
    my $attributes = GetBorrowerAttributes($borrowernumber);
88
    $template->param(
89
        ExtendedPatronAttributes => 1,
90
        extendedattributes       => $attributes
91
    );
92
}
93
94
$template->param(
95
    borrowernumber => $borrowernumber,
96
    firstname      => $borrower->{'firstname'},
97
    surname        => $borrower->{'surname'},
98
    cardnumber     => $borrower->{'cardnumber'},
99
    categorycode   => $borrower->{'categorycode'},
100
    category_type  => $borrower->{'category_type'},
101
    categoryname   => $borrower->{'description'},
102
    address        => $borrower->{'address'},
103
    address2       => $borrower->{'address2'},
104
    city           => $borrower->{'city'},
105
    state          => $borrower->{'state'},
106
    zipcode        => $borrower->{'zipcode'},
107
    country        => $borrower->{'country'},
108
    phone          => $borrower->{'phone'},
109
    email          => $borrower->{'email'},
110
    branchcode     => $borrower->{'branchcode'},
111
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
112
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
113
    activeBorrowerRelationship =>
114
      ( C4::Context->preference('borrowerRelationship') ne '' ),
115
    RoutingSerials => C4::Context->preference('RoutingSerials'),
116
);
117
118
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_credit.pl (+103 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#written 11/1/2000 by chris@katipo.oc.nz
4
#script to display borrowers account details
5
6
# Copyright 2000-2002 Katipo Communications
7
# Copyright 2010 BibLibre
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 3 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
27
use C4::Auth;
28
use C4::Output;
29
use CGI;
30
31
use C4::Koha;
32
use C4::Members;
33
use C4::Branch;
34
use C4::Items;
35
use C4::Members::Attributes qw(GetBorrowerAttributes);
36
use Koha::Database;
37
38
my $cgi = new CGI;
39
40
my $borrowernumber = $cgi->param('borrowernumber');
41
42
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
43
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45
    {
46
        template_name   => "members/account_credit.tt",
47
        query           => $cgi,
48
        type            => "intranet",
49
        authnotrequired => 0,
50
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
51
        debug           => 1,
52
    }
53
);
54
55
$template->param( credit_types_loop => GetAuthorisedValues('MANUAL_CREDIT') );
56
57
# Standard /members/ borrower details data
58
## FIXME: This code is in every /members/ script and should be unified
59
60
if ( $borrower->{'category_type'} eq 'C' ) {
61
    my ( $catcodes, $labels ) =
62
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
63
    my $cnt = scalar(@$catcodes);
64
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
65
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
66
}
67
68
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
69
$template->param( picture => 1 ) if $picture;
70
71
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
72
    my $attributes = GetBorrowerAttributes($borrowernumber);
73
    $template->param(
74
        ExtendedPatronAttributes => 1,
75
        extendedattributes       => $attributes
76
    );
77
}
78
79
$template->param(
80
    borrowernumber => $borrowernumber,
81
    firstname      => $borrower->{'firstname'},
82
    surname        => $borrower->{'surname'},
83
    cardnumber     => $borrower->{'cardnumber'},
84
    categorycode   => $borrower->{'categorycode'},
85
    category_type  => $borrower->{'category_type'},
86
    categoryname   => $borrower->{'description'},
87
    address        => $borrower->{'address'},
88
    address2       => $borrower->{'address2'},
89
    city           => $borrower->{'city'},
90
    state          => $borrower->{'state'},
91
    zipcode        => $borrower->{'zipcode'},
92
    country        => $borrower->{'country'},
93
    phone          => $borrower->{'phone'},
94
    email          => $borrower->{'email'},
95
    branchcode     => $borrower->{'branchcode'},
96
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
97
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
98
    activeBorrowerRelationship =>
99
      ( C4::Context->preference('borrowerRelationship') ne '' ),
100
    RoutingSerials => C4::Context->preference('RoutingSerials'),
101
);
102
103
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_credit_do.pl (+66 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use C4::Members;
27
use C4::Items;
28
use C4::Branch;
29
use C4::Members::Attributes qw(GetBorrowerAttributes);
30
use Koha::Accounts;
31
use Koha::Database;
32
33
my $cgi = new CGI;
34
35
my $borrowernumber = $cgi->param('borrowernumber');
36
my $borrower =
37
  Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber);
38
39
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
40
41
    my $barcode     = $cgi->param('barcode');
42
    my $itemnumber  = $cgi->param('itemnumber');
43
    my $description = $cgi->param('description');
44
    my $amount      = $cgi->param('amount');
45
    my $type        = $cgi->param('type');
46
    my $notes       = $cgi->param('notes');
47
48
    if ( !$itemnumber && $barcode ) {
49
        $itemnumber = GetItemnumberFromBarcode($barcode);
50
    }
51
52
    my $debit = AddCredit(
53
        {
54
            borrower    => $borrower,
55
            amount      => $amount,
56
            type        => $type,
57
            itemnumber  => $itemnumber,
58
            description => $description,
59
            notes       => $notes,
60
61
        }
62
    );
63
64
    print $cgi->redirect(
65
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
66
}
(-)a/members/account_debit.pl (+104 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#written 11/1/2000 by chris@katipo.oc.nz
4
#script to display borrowers account details
5
6
# Copyright 2000-2002 Katipo Communications
7
# Copyright 2010 BibLibre
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 3 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
27
use CGI;
28
29
use C4::Auth;
30
use C4::Output;
31
use C4::Members;
32
use C4::Items;
33
use C4::Branch;
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
use C4::Koha;
36
use Koha::Accounts;
37
use Koha::Database;
38
39
my $input = new CGI;
40
41
my $borrowernumber = $input->param('borrowernumber');
42
43
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "members/account_debit.tt",
48
        query           => $input,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
52
        debug           => 1,
53
    }
54
);
55
56
$template->param( invoice_types_loop => GetAuthorisedValues('MANUAL_INV') );
57
58
# Standard /members/ borrower details data
59
## FIXME: This code is in every /members/ script and should be unified
60
61
if ( $borrower->{'category_type'} eq 'C' ) {
62
    my ( $catcodes, $labels ) =
63
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
64
    my $cnt = scalar(@$catcodes);
65
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
66
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
67
}
68
69
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
70
$template->param( picture => 1 ) if $picture;
71
72
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
73
    my $attributes = GetBorrowerAttributes($borrowernumber);
74
    $template->param(
75
        ExtendedPatronAttributes => 1,
76
        extendedattributes       => $attributes
77
    );
78
}
79
80
$template->param(
81
    borrowernumber => $borrowernumber,
82
    firstname      => $borrower->{'firstname'},
83
    surname        => $borrower->{'surname'},
84
    cardnumber     => $borrower->{'cardnumber'},
85
    categorycode   => $borrower->{'categorycode'},
86
    category_type  => $borrower->{'category_type'},
87
    categoryname   => $borrower->{'description'},
88
    address        => $borrower->{'address'},
89
    address2       => $borrower->{'address2'},
90
    city           => $borrower->{'city'},
91
    state          => $borrower->{'state'},
92
    zipcode        => $borrower->{'zipcode'},
93
    country        => $borrower->{'country'},
94
    phone          => $borrower->{'phone'},
95
    email          => $borrower->{'email'},
96
    branchcode     => $borrower->{'branchcode'},
97
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
98
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
99
    activeBorrowerRelationship =>
100
      ( C4::Context->preference('borrowerRelationship') ne '' ),
101
    RoutingSerials => C4::Context->preference('RoutingSerials'),
102
);
103
104
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/account_debit_do.pl (+69 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use C4::Members;
27
use C4::Items;
28
use C4::Branch;
29
use C4::Members::Attributes qw(GetBorrowerAttributes);
30
use Koha::Accounts;
31
use Koha::Database;
32
33
my $cgi = new CGI;
34
35
my $borrowernumber = $cgi->param('borrowernumber');
36
my $borrower =
37
  Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber);
38
39
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
40
41
    #  print $cgi->header;
42
    my $barcode     = $cgi->param('barcode');
43
    my $itemnumber  = $cgi->param('itemnumber');
44
    my $description = $cgi->param('description');
45
    my $amount      = $cgi->param('amount');
46
    my $type        = $cgi->param('type');
47
    my $notes       = $cgi->param('notes');
48
49
    if ( !$itemnumber && $barcode ) {
50
        $itemnumber = GetItemnumberFromBarcode($barcode);
51
    }
52
53
    my $debit = AddDebit(
54
        {
55
            borrower    => $borrower,
56
            amount      => $amount,
57
            type        => $type,
58
            itemnumber  => $itemnumber,
59
            description => $description,
60
            notes       => $notes,
61
62
        }
63
    );
64
65
    my $debit_id = $debit->debit_id();
66
67
    print $cgi->redirect(
68
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
69
}
(-)a/members/account_payment.pl (+123 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Copyright 2010,2011 PTFS-Europe Ltd
6
# Copyright 2013 ByWater Solutions
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it under the
11
# terms of the GNU General Public License as published by the Free Software
12
# Foundation; either version 3 of the License, or (at your option) any later
13
# version.
14
#
15
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License along
20
# with Koha; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23
=head1 account_payment.pl
24
25
 written 11/1/2000 by chris@katipo.oc.nz
26
 part of the koha library system, script to facilitate paying off fines
27
28
=cut
29
30
use Modern::Perl;
31
32
use CGI;
33
34
use URI::Escape;
35
36
use C4::Context;
37
use C4::Auth;
38
use C4::Output;
39
use C4::Members;
40
use C4::Stats;
41
use C4::Koha;
42
use C4::Overdues;
43
use C4::Branch;
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use Koha::Database;
46
47
our $cgi = CGI->new;
48
49
our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
50
    {
51
        template_name   => 'members/account_payment.tt',
52
        query           => $cgi,
53
        type            => 'intranet',
54
        authnotrequired => 0,
55
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
56
        debug           => 1,
57
    }
58
);
59
60
my $borrowernumber = $cgi->param('borrowernumber');
61
62
my $borrower = GetMember( borrowernumber => $borrowernumber );
63
64
my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search(
65
    {
66
        'me.borrowernumber' => $borrowernumber,
67
        amount_outstanding  => { '>' => 0 }
68
    }
69
);
70
71
$template->param(
72
    debits   => \@debits,
73
    borrower => $borrower,
74
    credit_types_loop => GetAuthorisedValues('MANUAL_CREDIT'),
75
);
76
77
# Standard /members/ borrower details data
78
## FIXME: This code is in every /members/ script and should be unified
79
80
if ( $borrower->{'category_type'} eq 'C' ) {
81
    my ( $catcodes, $labels ) =
82
      GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
83
    my $cnt = scalar(@$catcodes);
84
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
85
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
86
}
87
88
my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} );
89
$template->param( picture => 1 ) if $picture;
90
91
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
92
    my $attributes = GetBorrowerAttributes($borrowernumber);
93
    $template->param(
94
        ExtendedPatronAttributes => 1,
95
        extendedattributes       => $attributes
96
    );
97
}
98
99
$template->param(
100
    borrowernumber => $borrowernumber,
101
    firstname      => $borrower->{'firstname'},
102
    surname        => $borrower->{'surname'},
103
    cardnumber     => $borrower->{'cardnumber'},
104
    categorycode   => $borrower->{'categorycode'},
105
    category_type  => $borrower->{'category_type'},
106
    categoryname   => $borrower->{'description'},
107
    address        => $borrower->{'address'},
108
    address2       => $borrower->{'address2'},
109
    city           => $borrower->{'city'},
110
    state          => $borrower->{'state'},
111
    zipcode        => $borrower->{'zipcode'},
112
    country        => $borrower->{'country'},
113
    phone          => $borrower->{'phone'},
114
    email          => $borrower->{'email'},
115
    branchcode     => $borrower->{'branchcode'},
116
    branchname     => GetBranchName( $borrower->{'branchcode'} ),
117
    is_child       => ( $borrower->{'category_type'} eq 'C' ),
118
    activeBorrowerRelationship =>
119
      ( C4::Context->preference('borrowerRelationship') ne '' ),
120
    RoutingSerials => C4::Context->preference('RoutingSerials'),
121
);
122
123
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_payment_do.pl (+66 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Members;
26
use C4::Items;
27
use C4::Branch;
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use Koha::Accounts;
30
use Koha::Database;
31
32
my $cgi = new CGI;
33
34
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
35
    my $borrowernumber = $cgi->param('borrowernumber');
36
37
    my $borrower =
38
      Koha::Database->new()->schema->resultset('Borrower')
39
      ->find($borrowernumber);
40
41
    my $amount_to_pay   = $cgi->param('amount_to_pay');
42
    my $amount_received = $cgi->param('amount_received');
43
    my $type            = $cgi->param('type');
44
    my $notes           = $cgi->param('notes');
45
    my @debit_id        = $cgi->param('debit_id');
46
47
    $amount_received ||= $amount_to_pay
48
      if $type eq Koha::Accounts::CreditTypes::Payment();
49
50
    my $credit = AddCredit(
51
        {
52
            borrower        => $borrower,
53
            amount_received => $amount_received,
54
            amount          => $amount_to_pay,
55
            type            => $type,
56
            notes           => $notes,
57
            debit_id        => \@debit_id,
58
59
        }
60
    );
61
62
    my $credit_id = $credit->credit_id();
63
64
    print $cgi->redirect(
65
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber&credit_id=$credit_id");
66
}
(-)a/members/account_print.pl (+60 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Database;
27
28
my $cgi = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "members/account_print.tt",
33
        query           => $cgi,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { borrowers => 1, updatecharges => 1 },
37
        debug           => 1,
38
    }
39
);
40
41
my $type = $cgi->param('type');
42
my $id   = $cgi->param('id');
43
44
warn "No type passed in!" unless $type;
45
warn "No id passed in!"   unless $id;
46
47
if ( $type eq 'debit' ) {
48
    my $debit =
49
      Koha::Database->new()->schema->resultset('AccountDebit')->find($id);
50
    $template->param( debit => $debit );
51
}
52
elsif ( $type eq 'credit' ) {
53
    my $credit =
54
      Koha::Database->new()->schema->resultset('AccountCredit')->find($id);
55
    $template->param( credit => $credit );
56
}
57
58
$template->param( type => $type );
59
60
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/members/account_void.pl (-1 / +38 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2013 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use C4::Output;
26
use Koha::Accounts;
27
28
my $cgi = new CGI;
29
30
my $id             = $cgi->param('id');
31
my $borrowernumber = $cgi->param('borrowernumber');
32
33
if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) {
34
    VoidCredit( { id => $id } );
35
36
    print $cgi->redirect(
37
        "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber");
38
}

Return to bug 6427