From 615c5caa63046f8ebcd85253cb115417f1d6e0e7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall <kyle@bywatersolutions.com> Date: Wed, 11 Dec 2013 10:47:39 -0500 Subject: [PATCH] Bug 6427 [Part 4] - Add new staff-side scripts for viewing/creating fees and payments --- .../prog/en/includes/browser-strings.inc | 27 ++ .../prog/en/modules/members/account.tt | 432 ++++++++++++++++++++ .../prog/en/modules/members/account_credit.tt | 92 +++++ .../prog/en/modules/members/account_debit.tt | 109 +++++ .../prog/en/modules/members/account_payment.tt | 247 +++++++++++ .../prog/en/modules/members/account_print.tt | 146 +++++++ koha-tmpl/intranet-tmpl/prog/img/details_close.png | Bin 0 -> 841 bytes koha-tmpl/intranet-tmpl/prog/img/details_open.png | Bin 0 -> 881 bytes members/account.pl | 112 +++++ members/account_credit.pl | 103 +++++ members/account_credit_do.pl | 66 +++ members/account_debit.pl | 104 +++++ members/account_debit_do.pl | 69 +++ members/account_payment.pl | 123 ++++++ members/account_payment_do.pl | 64 +++ members/account_print.pl | 60 +++ 16 files changed, 1754 insertions(+), 0 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/img/details_close.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/details_open.png create mode 100755 members/account.pl create mode 100755 members/account_credit.pl create mode 100755 members/account_credit_do.pl create mode 100755 members/account_debit.pl create mode 100755 members/account_debit_do.pl create mode 100755 members/account_payment.pl create mode 100755 members/account_payment_do.pl create mode 100755 members/account_print.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/browser-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/browser-strings.inc index 3dda230..f6c74f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/browser-strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/browser-strings.inc @@ -1,7 +1,34 @@ +[% USE KohaAuthorisedValues %] <script type="text/javascript"> //<![CDATA[ var BROWSER_RETURN_TO_SEARCH = _("Return to results"); var BROWSER_PREVIOUS = _("Previous"); var BROWSER_NEXT = _("Next"); + + var STRINGS = { + "DebitTypes": { + "FINE" : _("Fine"), + "ACCOUNT_MANAGEMENT_FEE" : _("Account management fee"), + "SUNDRY" : _("Sundry"), + "LOST" : _("Lost item"), + "HOLD" : _("Hold fee"), + "RENTAL" : _("Rental fee"), + "NEW_CARD" : _("New card"), + [% FOREACH a IN KohaAuthorisedValues.Get('MANUAL_INV') %] + "[% a.authorised_value %]" : "[% a.lib %]", + [% END %] + }, + + "CreditTypes": { + "CREDIT" : _("Credit"), + "PAYMENT" : _("Payment"), + "WRITEOFF" : _("Writeoff"), + "FOUND" : _("Lost item found"), + "FORGIVEN" : _("Forgiven"), + [% FOREACH a IN KohaAuthorisedValues.Get('MANUAL_CREDIT') %] + "[% a.authorised_value %]" : "[% a.lib %]", + [% END %] + } + } //]]> </script> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt new file mode 100644 index 0000000..859d3cf --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt @@ -0,0 +1,432 @@ +[% SET accounts_view = 1 %] +[% USE KohaDates %] +[% USE Currency %] +[% INCLUDE 'doc-head-open.inc' %] +<title>Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %]</title> +[% INCLUDE 'doc-head-close.inc' %] + +<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" /> +[% INCLUDE 'datatables.inc' %] +[% INCLUDE 'browser-strings.inc' %] + +<script type="text/javascript"> +//<![CDATA[ +$(document).ready(function() { + $('#account-credits').hide(); + $('#account-debits-switcher').click(function() { + $('#account-debits').slideUp(); + $('#account-credits').slideDown(); + }); + $('#account-credits-switcher').click(function() { + $('#account-credits').slideUp(); + $('#account-debits').slideDown(); + }); + + var anOpen = []; + var sImageUrl = "[% interface %]/[% theme %]/img/"; + + var debitsTable = $('#debits-table').dataTable( { + "bProcessing": true, + "aoColumns": [ + { + "mDataProp": null, + "sClass": "control center", + "sDefaultContent": '<img src="'+sImageUrl+'details_open.png'+'">' + }, + { "mDataProp": "debit_id" }, + { "mDataProp": "description" }, + { + "mDataProp": "type", + "fnRender": function ( o, val ) { + return STRINGS['DebitTypes'][val] || val; + }, + }, + { "mDataProp": "amount_original" }, + { "mDataProp": "amount_outstanding" }, + { "mDataProp": "created_on" }, + { "mDataProp": "updated_on" } + ], + "aaData": [ + [% FOREACH d IN debits %] + { + [% PROCESS format_data data=d highlight='debit' %] + + // Data for related item if there is one linked + "title": "[% d.item.biblio.title || d.deleted_item.biblio.title || d.deleted_item.deleted_biblio.title | replace('"', '\"') %]", + "biblionumber": "[% d.item.biblio.biblionumber || d.deleted_item.biblio.biblionumber %]", + "barcode": "[% d.item.barcode || d.deleted_item.barcode %]", + "itemnumber": "[% d.item.itemnumber %]", //This way itemnumber will be undef if deleted + + + // Data for related issue if there is one linked + [% IF d.issue %] + [% SET table = 'issue' %] + [% ELSIF d.old_issue %] + [% SET table = 'old_issue' %] + [% END %] + + [% IF table %] + "issue": { + [% PROCESS format_data data=d.$table %] + }, + [% END %] + + + "account_offsets": [ + [% FOREACH ao IN d.account_offsets %] + [% IF ao.credit %] + { + [% PROCESS format_data data=ao highlight='offset'%] + + "credit": { + [% PROCESS format_data data=ao.credit highlight='credit' %] + } + }, + [% END %] + [% END %] + ] + + }, + [% END %] + ] + } ); + + $('#debits-table td.control').live( 'click', function () { + var nTr = this.parentNode; + var i = $.inArray( nTr, anOpen ); + + if ( i === -1 ) { + $('img', this).attr( 'src', sImageUrl+"details_close.png" ); + var nDetailsRow = debitsTable.fnOpen( nTr, fnFormatDebitDetails(debitsTable, nTr), 'details' ); + $('div.innerDetails', nDetailsRow).slideDown(); + anOpen.push( nTr ); + } + else { + $('img', this).attr( 'src', sImageUrl+"details_open.png" ); + $('div.innerDetails', $(nTr).next()[0]).slideUp( function () { + debitsTable.fnClose( nTr ); + anOpen.splice( i, 1 ); + } ); + } + } ); + + var creditsTable = $('#credits-table').dataTable( { + "bProcessing": true, + "aoColumns": [ + { + "mDataProp": null, + "sClass": "control center", + "sDefaultContent": '<img src="'+sImageUrl+'details_open.png'+'">' + }, + { "mDataProp": "credit_id" }, + { "mDataProp": "notes" }, + { + "mDataProp": "type", + "fnRender": function ( o, val ) { + return STRINGS['CreditTypes'][val] || val; + }, + }, + { "mDataProp": "amount_paid" }, + { "mDataProp": "amount_remaining" }, + { "mDataProp": "created_on" }, + { "mDataProp": "updated_on" } + ], + "aaData": [ + [% FOREACH c IN credits %] + { + [% PROCESS format_data data=c highlight='credit' %] + + "account_offsets": [ + [% FOREACH ao IN c.account_offsets %] + { + [% PROCESS format_data data=ao highlight='offset' %] + + "debit": { + [% PROCESS format_data data=ao.debit highlight='debit' %] + } + }, + [% END %] + ] + + }, + [% END %] + ] + } ); + + $('#credits-table td.control').live( 'click', function () { + var nTr = this.parentNode; + var i = $.inArray( nTr, anOpen ); + + if ( i === -1 ) { + $('img', this).attr( 'src', sImageUrl+"details_close.png" ); + var nDetailsRow = creditsTable.fnOpen( nTr, fnFormatCreditDetails(creditsTable, nTr), 'details' ); + $('div.innerDetails', nDetailsRow).slideDown(); + anOpen.push( nTr ); + } + else { + $('img', this).attr( 'src', sImageUrl+"details_open.png" ); + $('div.innerDetails', $(nTr).next()[0]).slideUp( function () { + creditsTable.fnClose( nTr ); + anOpen.splice( i, 1 ); + } ); + } + } ); + +} ); + +function fnFormatDebitDetails( debitsTable, nTr ) { + var oData = debitsTable.fnGetData( nTr ); + + var sOut = "<div class='innerDetails' style='display:none;'>"; + + var account_offsets = oData.account_offsets; + + sOut += "<a class='debit_print btn btn-small' style='margin:5px;' onclick='accountPrint(\"debit\"," + oData.debit_id + ")'>" + + "<i class='icon-print'></i> " + _("Print receipt") + + "</a>"; + + sOut += "<ul>"; + if ( oData.title ) { + sOut += "<li>" + _("Title: "); + if ( oData.biblionumber ) { + sOut += "<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + oData.biblionumber + "'>"; + } + + sOut += oData.title; + + if ( oData.biblionumber ) { + sOut += "</a>"; + } + + sOut += "</li>"; + } + + if ( oData.barcode ) { + sOut += "<li>" + _("Barcode: "); + if ( oData.itemnumber ) { + sOut += "<a href='/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=11&biblionumber=" + oData.biblionumber + "&bi=" + oData.biblionumber + "#item" + oData.itemnumber + "" + oData.biblionumber + "'>"; + } + + sOut += oData.barcode; + + if ( oData.itemnumber ) { + sOut += "</a>"; + } + + sOut += "</li>"; + } + + if ( oData.notes ) { + sOut += "<li>" + _("Notes: ") + oData.notes + "</li>"; + } + + sOut += "</ul>"; + + if ( account_offsets.length ) { + sOut += + "<div class='innerDetails'>" + + "<table cellpadding='5' cellspacing='0' border='0' style='margin:10px;'>" + + "<thead>" + + "<tr><th colspan='99'>" + _("Payments applied") + "</th></tr>" + + "<tr>" + + "<th>" + _("ID") + "</th>" + + "<th>" + _("Created on") + "</th>" + + "<th>" + _("Payment amount") + "</th>" + + "<th>" + _("Applied amount") + "</th>" + + "<th>" + _("Type") + "</th>" + + "<th>" + _("Notes") + "</th>" + + "</tr>" + + "</thead>" + + "<tbody>"; + + for ( var i = 0; i < account_offsets.length; i++ ) { + ao = account_offsets[i]; + credit_type = STRINGS["CreditTypes"][ao.credit.type] || ao.credit.type; + sOut += + "<tr>" + + "<td>" + ao.credit_id + "</td>" + + "<td>" + ao.created_on + "</td>" + + "<td>" + ao.credit.amount_paid + "</td>" + + "<td>" + ao.amount + "</td>" + + "<td>" + credit_type + "</td>" + + "<td>" + ao.credit.notes + "</td>" + + "</tr>"; + } + + sOut += + "</tbody>"+ + "</table>"; + } + + sOut += + "</div>"; + + return sOut; +} + +function fnFormatCreditDetails( creditsTable, nTr ) { + var oData = creditsTable.fnGetData( nTr ); + + var sOut = "<div class='innerDetails' style='display:none;'>"; + + sOut += "<button class='credit_print btn btn-small' style='margin:5px;' onclick='accountPrint(\"credit\"," + oData.credit_id + ")'>" + + "<i class='icon-print'></i> " + _("Print receipt") + + "</button>"; + + var account_offsets = oData.account_offsets; + + if ( account_offsets.length ) { + sOut += + "<table cellpadding='5' cellspacing='0' border='0' style='margin:10px;'>" + + "<thead>" + + "<tr><th colspan='99'>" + _("Fees paid") + "</th></tr>" + + "<tr>" + + "<th>" + _("ID") + "</th>" + + "<th>" + _("Description") + "</th>" + + "<th>" + _("Type") + "</th>" + + "<th>" + _("Amount") + "</th>" + + "<th>" + _("Remaining") + "</th>" + + "<th>" + _("Created on") + "</th>" + + "<th>" + _("Updated on") + "</th>" + + "<th>" + _("Notes") + "</th>" + + "</tr>" + + "</thead>" + + "<tbody>"; + + for ( var i = 0; i < account_offsets.length; i++ ) { + ao = account_offsets[i]; + debit_type = STRINGS["DebitTypes"][ao.debit.type] || ao.debit.type; + sOut += + "<tr>" + + "<td>" + ao.debit.debit_id + "</td>" + + "<td>" + ao.debit.description + "</td>" + + "<td>" + debit_type + "</td>" + + "<td>" + ao.debit.amount_original + "</td>" + + "<td>" + ao.debit.amount_outstanding + "</td>" + + "<td>" + ao.debit.created_on + "</td>" + + "<td>" + ao.debit.updated_on + "</td>" + + "<td>" + ao.debit.notes + "</td>" + + "</tr>"; + } + + sOut += + "</tbody>"+ + "</table>"; + } + + sOut += + "</div>"; + + return sOut; +} + +function accountPrint( type, id ) { + window.open( "/cgi-bin/koha/members/account_print.pl?type=" + type + "&id=" + id ); +} +//]]> +</script> +</head> +<body> +[% 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> › Account for [% INCLUDE 'patron-title.inc' %]</div> + +<div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'members-toolbar.inc' %] + + <div class="statictabs"> + <ul> + <li class="active"> + <a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a> + </li> + + <li> + <a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a> + </li> + + <li> + <a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a> + </li> + + <li> + <a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a> + </li> + </ul> + </div> + + <div class="tabs-container"> + + <p> + <h3>Account balance: [% borrower.account_balance | $Currency %]</h3> + </p> + + <div> + <div id="account-debits"> + <a id="account-debits-switcher" href="#" onclick="return false">View payments</a> + <table cellpadding="0" cellspacing="0" border="0" class="display" id="debits-table"> + <thead> + <tr> + <th colspan="99">Fees</th> + </tr> + <tr> + <th></th> + <th>ID</th> + <th>Description</th> + <th>Type</th> + <th>Amount</th> + <th>Outsanding</th> + <th>Created on</th> + <th>Updated on</th> + </tr> + </thead> + <tbody></tbody> + </table> + </div> + + <div id="account-credits"> + <a id="account-credits-switcher" href="#" onclick="return false">View fees</a> + <table cellpadding="0" cellspacing="0" border="0" class="display" id="credits-table"> + <thead> + <tr> + <th colspan="99">Payments</th> + </tr> + <tr> + <th></th> + <th>ID</th> + <th>Notes</th> + <th>Type</th> + <th>Amount</th> + <th>Remaining</th> + <th>Created on</th> + <th>Updated on</th> + </tr> + </thead> + <tbody></tbody> + </table> + </div> + </div> + </div> + </div> + </div> + + <div class="yui-b"> + [% INCLUDE 'circ-menu.inc' %] + </div> +</div> +[% INCLUDE 'intranet-bottom.inc' %] + +[% BLOCK format_data %] + [% FOREACH key IN data.result_source.columns %] + [% IF key.match('^amount') %] + "[% key %]": "[% data.$key FILTER $Currency highlight => highlight %]", + [% ELSIF key.match('_on$') %] + "[% key %]": "[% data.$key | $KohaDates %]", + [% ELSE %] + "[% key %]": "[% data.$key | replace('"', '\"') %]", + [% END %] + [% END %] +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt new file mode 100644 index 0000000..d8e8883 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt @@ -0,0 +1,92 @@ +[% SET accounts_view = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +<title>Koha › Borrowers › Create manual credit</title> +[% INCLUDE 'doc-head-close.inc' %] +<script type="text/javascript"> +//<![CDATA[ +$(document).ready(function(){ + $('#account_credit').preventDoubleFormSubmit(); + $("fieldset.rows input").addClass("noEnterSubmit"); +}); +//]]> +</script> +</head> +<body id="pat_account_credit" 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> › Manual credit</div> + + <div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'members-toolbar.inc' %] + + <div class="statictabs"> + <ul> + <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li> + <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li> + <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li> + <li class="active"><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li> + </ul> + + <div class="tabs-container"> + + <form action="/cgi-bin/koha/members/account_credit_do.pl" method="post" id="account_credit"> + <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /> + + <fieldset class="rows"> + <legend>Manual credit</legend> + + <ol> + <li> + <label for="type">Credit Type: </label> + <select name="type" id="type"> + <option value="CREDIT">Credit</option> + <option value="FORGIVEN">Forgiven</option> + [% FOREACH c IN credit_types_loop %] + <option value="[% c.authorised_value %]">[% c.lib %]</option> + [% END %] + </select> + </li> + + <li> + <label for="barcode">Barcode: </label> + <input type="text" name="barcode" id="barcode" /> + </li> + + <li> + <label for="desc">Description: </label> + <input type="text" name="desc" size="50" id="desc" /> + </li> + + <li> + <label for="note">Note: </label> + <input type="text" name="note" size="50" id="note" /> + </li> + + <li> + <label for="amount">Amount: </label> + <input type="text" name="amount" id="amount" /> + Example: 5.00 + </li> + </ol> + + </fieldset> + + <fieldset class="action"> + <input type="submit" name="add" value="Add credit" /> + <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a> + </fieldset> + </form> + + </div> + </div> + </div> + </div> + <div class="yui-b"> + [% INCLUDE 'circ-menu.inc' %] + </div> + </div> +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt new file mode 100644 index 0000000..4055fd9 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt @@ -0,0 +1,109 @@ +[% SET accounts_view = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +<title>Koha › Borrowers › Create manual invoice</title> +[% INCLUDE 'doc-head-close.inc' %] +<script type="text/javascript"> +//<![CDATA[ +$(document).ready(function(){ + $('#maninvoice').preventDoubleFormSubmit(); + $("fieldset.rows input").addClass("noEnterSubmit"); + + var type_fees = new Array(); + type_fees['L'] = ''; + type_fees['F'] = ''; + type_fees['A'] = ''; + type_fees['N'] = ''; + type_fees['M'] = ''; + [% FOREACH invoice_types_loo IN invoice_types_loop %] + type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.lib %]"; + [% END %] +}); +//]]> +</script> +</head> + +<body> + [% 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> › Manual invoice</div> + + <div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'members-toolbar.inc' %] + + <div class="statictabs"> + <ul> + <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Account</a></li> + <li><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrowernumber %]" >Pay fines</a></li> + <li class="active"><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrowernumber %]" >Create manual invoice</a></li> + <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrowernumber %]" >Create manual credit</a></li> + </ul> + <div class="tabs-container"> + + <form action="/cgi-bin/koha/members/account_debit_do.pl" method="post" id="account_debit"> + <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /> + + <fieldset class="rows"> + <legend>Manual Invoice</legend> + + <ol> + <li> + <label for="type">Type: </label> + <select name="type" id="type"> + <option value="LOST">Lost item</option> + <option value="FINE">Fine</option> + <option value="ACCOUNT_MANAGEMENT_FEE">Account management fee</option> + <option value="NEW_CARD">New card</option> + <option value="SUNDRY">Sundry</option> + + [% FOREACH invoice_types_loo IN invoice_types_loop %] + <option value="[% invoice_types_loo.authorised_value %]">[% invoice_types_loo.lib %]</option> + [% END %] + </select> + </li> + + <!-- TODO: Write ajax barcode validator that appends the itemnumber for this form in a hidden input --> + <li> + <label for="barcode">Barcode: </label> + <input type="text" name="barcode" id="barcode" /> + </li> + + <li> + <label for="description">Description: </label> + <input type="text" name="description" id="description" size="50" /> + </li> + + <li> + <label for="notes">Notes: </label> + <input type="text" name="notes" size="50" id="notes" /> + </li> + + <li> + <label for="amount">Amount: </label> + <input type="text" name="amount" id="amount" /> Example: 5.00 + </li> + + </ol> + </fieldset> + + <fieldset class="action"> + <input type="submit" name="add" value="Save" /> + <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrowernumber %]">Cancel</a> + </fieldset> + + </form> + + </div> + </div> + </div> + </div> + +<div class="yui-b"> + [% INCLUDE 'circ-menu.inc' %] +</div> + +</div> +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt new file mode 100644 index 0000000..e37b1d9 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt @@ -0,0 +1,247 @@ +[% SET accounts_view = 1 %] +[% USE Currency %] +[% INCLUDE 'doc-head-open.inc' %] +<title>Koha › Patrons › Pay Fines for [% borrower.firstname %] [% borrower.surname %]</title> +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'browser-strings.inc' %] +<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> +<script type= "text/javascript"> +//<![CDATA[ +$( document ).ready(function() { + $('#account-payment-form').preventDoubleFormSubmit(); + + // Convert codes to translated strings + $(".debit-type").each(function() { + $(this).html( STRINGS['DebitTypes'][ $(this).html() ] ); + }); + + // Show amount recieved only if the "Receive different amount" checkbox is checked + $("#amount-received-p").hide(); + $("#receive_different_amount").bind('click focus blur', function() { + if( $(this).is(':checked')) { + $("#amount-received-p").show(); + $("#amount_received").focus(); + $("#amount_received").keyup(); + } else { + $("#amount-received-p").hide(); + $("#amount_to_pay").keyup(); + } + }); + + $("#amount_received").bind('keyup blur', function() { + // Allow only numbers in amount received + $(this).val($(this).val().replace(/[^\d.]/g, '')); + + if ( $("#receive_different_amount").attr('checked') ) { + // Make sure the amount recieved is greater than the amount to pay if it is being used + amount_received = parseFloat( $("#amount_received").val() ) || 0; + amount_to_pay = parseFloat( $("#amount_to_pay").val() ) || 0; + if ( amount_received < amount_to_pay ) { + $("#process").attr('disabled','disabled'); + } else { + $("#process").removeAttr('disabled'); + } + } + }); + + // Allow only numbers in amount to pay + $("#amount_to_pay").bind('keyup blur', function() { + // Allow only numbers in amount received + $(this).val($(this).val().replace(/[^\d.]/g, '')); + + // Disallow over-payments + if ( parseFloat( $(this).val() ) > parseFloat( $("#total_due").val() ) ) { + $("#process").attr('disabled','disabled'); + } else { + $("#process").removeAttr('disabled'); + } + + $("#amount_received").keyup(); + }); + + // Enable the "Select all/Clear all" links + $('#CheckAll').click(function() { + $("input[name='debit_id']" ).prop('checked', true).trigger("change"); + }); + $('#ClearAll').click(function() { + $("input[name='debit_id']" ).prop('checked', false).trigger("change"); + }); + + // Update the "amount to pay" field whenever a fee checkbox is changed + // Note, this is just a payment suggestion and can be changed to any amount + $("input[name='debit_id']" ).change(function() { + var sum = 0; + $("input[name='debit_id']:checked" ).each(function(i,n){ + sum += parseFloat( $( "#amount_outstanding_" + $(this).val() ).val() ); + }); + $('#amount_to_pay').val( sum ); + }); +}); + +function checkForm(){ + // If using the "amount to receive" field, make sure the librarian is recieving at + // least enough to pay those fees. + if ( $('#amount_received').val() ) { + if ( parseFloat( $('#amount_received').val() ) < parseFloat( $('#amount_to_pay').val() ) ) { + alert( _("Cannot pay more than receieved!") ); + return false; + } + } + + return true; +} +//]]> +</script> +</head> +<body id="pat_pay" 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> + › Pay fines for [% borrower.firstname %] [% borrower.surname %] + </div> + + <div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %] + + <div class="statictabs"> + <ul> + <li><a href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Account</a></li> + <li class="active"><a href="/cgi-bin/koha/members/account_payment.pl?borrowernumber=[% borrower.borrowernumber %]" >Pay fines</a></li> + <li><a href="/cgi-bin/koha/members/account_debit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual invoice</a></li> + <li><a href="/cgi-bin/koha/members/account_credit.pl?borrowernumber=[% borrower.borrowernumber %]" >Create manual credit</a></li> + </ul> + + <div class="tabs-container"> + + [% IF ( debits ) %] + <form action="/cgi-bin/koha/members/account_payment_do.pl" method="post" id="account-payment-form" onsubmit="return checkForm()"> + + <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrower.borrowernumber %]" /> + + <p> + <span class="checkall"> + <a id="CheckAll" href="#">Select all</a> + </span> + + | + + <span class="clearall"> + <a id="ClearAll" href="#">Clear all</a> + </span> + </p> + + <table id="finest"> + <thead> + <tr> + <th> </th> + <th>Description</th> + <th>Account type</th> + <th>Original amount</th> + <th>Amount outstanding</th> + </tr> + </thead> + + <tbody> + [% SET total_due = 0 %] + [% FOREACH d IN debits %] + [% SET total_due = total_due + d.amount_outstanding %] + <tr> + <td> + <input type="checkbox" checked="checked" name="debit_id" value="[% d.debit_id %]" /> + </td> + + <td> + [% d.description %] + + [% IF d.notes %] + ( <i>[% d.notes %]</i> ) + [% END %] + </td> + + <td> + <span class="debit-type">[% d.type %]</span> + </td> + + <td class="debit"> + [% d.amount_original | $Currency %] + <input type="hidden" id="amount_original_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_original ) %]" /> + </td> + + <td class="debit"> + [% d.amount_outstanding | $Currency %] + <input type="hidden" id="amount_outstanding_[% d.debit_id %]" value="[% Currency.format_without_symbol( d.amount_outstanding ) %]" /> + </td> + </tr> + [% END %] + </tbody> + + <tfoot> + <tr> + <td class="total" colspan="4">Total Due:</td> + <td>[% total_due | $Currency %]</td> + </tr> + </tfoot> + + </table> + + <fieldset> + <p> + <label for="amount_to_pay">Amount to pay: [% Currency.symbol() %]</label> + <input type="text" name="amount_to_pay" id="amount_to_pay" value="[% Currency.format_without_symbol( total_due ) %]" /> + <input type="hidden" name="total_due" id="total_due" value="[% total_due %]" /> + + <input type="checkbox" id="receive_different_amount" /> + <label for="receive_different_amount"><i>Receive different amount</i></label> + </p> + + <p id="amount-received-p"> + <label for="amount_received">Amount recieved: [% Currency.symbol() %]</label> + <input type="text" name="amount_received" id="amount_received" /> + </p> + + <p> + <label for="type">Type:</label> + <select id="type" name="type"> + <option value="PAYMENT">Payment</option> + <option value="WRITEOFF">Writeoff</option> + [% FOREACH c IN credit_types_loop %] + <option value="[% c.authorised_value %]">[% c.lib %]</option> + [% END %] + </select> + </p> + + <p> + <label for="notes">Payment notes:</label> + <input type="textbox" name="notes" id="notes" /> + <p> + </fieldset> + + <fieldset class="action"> + <input type="submit" id="process" value="Process" class="submit" /> + <a class="cancel" href="/cgi-bin/koha/members/account.pl?borrowernumber=[% borrower.borrowernumber %]">Cancel</a> + </fieldset> + + </form> + + [% ELSE %] + <p> + [% borrower.firstname %] [% borrower.surname %] has no outstanding fines. + </p> + [% END %] + + </div> + </div> + </div> + </div> + + <div class="yui-b"> + [% INCLUDE 'circ-menu.tt' %] + </div> + </div> +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt new file mode 100644 index 0000000..6201585 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt @@ -0,0 +1,146 @@ +[% USE KohaDates %] +[% USE Currency %] +[% USE EncodeUTF8 %] +[% INCLUDE 'doc-head-open.inc' %] +<title>Print Receipt for [% cardnumber %]</title> +[% INCLUDE 'doc-head-close.inc' %] +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" /> +<script type="text/javascript"> + function printThenClose() { + window.print(); + window.close(); + } +</script> +</head> + +[% SET account = debit || credit %] +[% SET borrower = account.borrower %] + +<body id="account-print-body" onload="printThenClose();"> + + <table> + <thead> + <tr> + <th colspan="99"> + [% IF debit %] + Invoice + [% ELSIF credit %] + Payment receipt + [% END %] + </th> + </tr> + + <tr> + <th colspan="99"> + [% borrower.branch.branchname | $EncodeUTF8 %] + </th> + </tr> + + <tr> + <th>Name:</th> + <th colspan="99">[% borrower.firstname | $EncodeUTF8 %] [% borrower.surname | $EncodeUTF8 %]</th> + </tr> + + <tr> + <th>Card number:</th> + <th colspan="99">[% borrower.cardnumber %]</th> + </tr> + + <tr> + <th>Date:</th> + <th colspan="99">[% account.created_on | $KohaDates %]</th> + </tr> + + [% IF account.description %] + <tr> + <th>Description:</th> + <th colspan="99">[% account.description | $EncodeUTF8 %]</th> + </tr> + [% END %] + + [% IF credit %] + <tr> + <th>Amount paid:</th> + <th colspan="99">[% credit.amount_paid | $Currency highlight => type %]</th> + </tr> + [% IF credit.amount_received > 0 %] + <tr> + <th>Amount received:</th> + <th colspan="99">[% credit.amount_received | $Currency highlight => type %]</th> + </tr> + <tr> + <th>Change due:</th> + <th colspan="99">[% credit.amount_received - credit.amount_paid | $Currency highlight => type %]</th> + </tr> + [% END %] + <tr> + <th>Balance:</th> + <th colspan="99">[% credit.amount_remaining | $Currency highlight => type %]</th> + </tr> + [% IF credit.account_offsets %] + <tr> + <th colspan="99">Fees paid</th> + </tr> + <tr> + <th>Description</th> + <th>Type</th> + <th>Amount</th> + <th>Paid</th> + <th>Outstanding</th> + <th>Date</th> + </tr> + [% END %] + [% ELSIF debit %] + <tr> + <th>Amount:</th> + <th colspan="99">[% debit.amount_original | $Currency highlight => type %]</th> + </tr> + <tr> + <th>Outstanding:</th> + <th colspan="99">[% debit.amount_outstanding | $Currency highlight => type %]</th> + </tr> + [% IF debit.account_offsets %] + <tr> + <th colspan="99">Payments applied</th> + </tr> + <tr> + <th>Date</th> + <th>Type</th> + <th>Payment</th> + <th>Applied</th> + <th>Balance</th> + <th>Notes</th> + </tr> + [% END %] + [% END %] + </thead> + + <tbody> + [% IF credit.account_offsets %] + [% FOREACH ao IN credit.account_offsets %] + <tr> + <td>[% ao.debit.description %]</td> + <td>[% ao.debit.type %]</td> + <td>[% ao.debit.amount_original | $Currency highlight => 'debit' %]</td> + <td>[% ao.amount | $Currency highlight => 'offset' %]</td> + <td>[% ao.debit.amount_outstanding | $Currency highlight => 'debit' %]</td> + <td>[% ao.debit.created_on | $KohaDates %]</td> + </tr> + [% END %] + [% ELSIF debit.account_offsets %] + [% FOREACH ao IN debit.account_offsets %] + <tr> + <td>[% ao.credit.created_on | $KohaDates %]</td> + <td>[% ao.credit.type %]</td> + <td>[% ao.credit.amount_paid | $Currency highlight => 'credit' %]</td> + <td>[% ao.amount | $Currency highlight => 'offset' %]</td> + <td>[% ao.credit.amount_remaining | $Currency highlight => 'credit' %]</td> + <td>[% ao.credit.notes %]</td> + </tr> + [% END %] + [% END %] + </tbody> + </table> + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/img/details_close.png b/koha-tmpl/intranet-tmpl/prog/img/details_close.png new file mode 100644 index 0000000000000000000000000000000000000000..fcc23c63e22f9883bef72c9e3adae3d5ddfb35cc GIT binary patch literal 841 zcmV-P1GfB$P)<h;3K|Lk000e1NJLTq000yK000yS1^@s6jfou%00004XF*Lt007q5 z)K6G40000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!+et)0RCwB~ zRZUD&K@grT6<e^<2BXxNUgYOsC0<Bt4}us23L()G;V2>DA_on|3pY;aiIaw_AzX~% z0wEzG!5U~A62!y<6#_3!Y0@BA($@0c+jVBUFF+~kfo;CbzTKH`cV=g%b|^n=hzi67 zM5UV3FcF6cUCnu^p}pjrsWm6Ug}98UR-~ZFvWN`g0Fg%+2vP1<MCL$TMcf(~7<d*A zhi8+?q{cZn2{flQ+9MsM>rl3*$mmwr5rOIH=?}WDABr;u?U4@YDw`9eOu1C&^?L7Z zY;1fZBc9KT-2A-Q9Uc}tJv}1T-7R)sycF4)8NstzNldzAgSOWc2V?31C|17Z<>j$J zAke}0_aQSe0l9^R;<1c^#DEC_0!<vD5Y!9~LPc#YEG;d~hC-p&sI^UTwO-OQG&J;} zzrX)Em?qnMGX}ZE&w!UeCJtN*B%>d$>Do3Jo15TlYl9m;-_3M7y&8+fG<qbPBCP4{ z?R~-+v*p8K$cDcFH%$rC<VDG8ZmM+-xs??>bP>p=udnZ^^3rY*Ry8&@-XZS}=H{ef zDUJ>}0_oCdYHA|eDvG0BC2ghK?XIQGd^|3d(Ko2a8<ZPAT3e+oY;8&Da=F}A0hA`T zOnuWd;BUh;4Eaz@*NbU_ZXd4{Sx%WuX3yjCT&eJS;dde-pZ0t3u1YLb2*-r10&kuC zM%$mNicFiT%iQ|<`l`Hsd%KE}aRfufjdK;xqP%p!T@uFQ@ipQgE{pKj<mBW>%4c^+ z2RQuxqA|Bf6p=-Yhg8<rgXi%hN+UisHT6l=w|*kAqtWQwmX?->1x*8ObQBJv5%iB0 zU9{XrXRDi=!8bAj&V~kvL?Uy+VDJ@gXo|Fa=^duiBKhvUSnKK%G5>85_4~!w&Q6gS z9~Xt4ozl{)vr6y0nuGJKj&rJgrBbPcMMU#|wJ-Lc4fdkiFZ`>)vh)56_#?mow%h=n ThIkt{00000NkvXXu0mjfW_^Rc literal 0 HcmV?d00001 diff --git a/koha-tmpl/intranet-tmpl/prog/img/details_open.png b/koha-tmpl/intranet-tmpl/prog/img/details_open.png new file mode 100644 index 0000000000000000000000000000000000000000..6f034d0f2d5c7902dce190355b12defdc07d6c9a GIT binary patch literal 881 zcmV-%1CIQOP)<h;3K|Lk000e1NJLTq000yK000yS1^@s6jfou%00004XF*Lt007q5 z)K6G40000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#14%?dRCwB~ zRozRIQ5b*Tx%`URmR7!^qREsHr4L~=rAQr;^QNxE%fy>P5xVIgh(4gM3Zjdy!n~2N zjD^FnHQ1(tR(9cJl^-l~RyvtO-;dMt9M4;+6T9$?ALpFs<F|93kMl~9dYBMthy#dp zv8JIRHV}$f>)Rcr6nirw3t>UzAPx#r5M&8N9I=W>B2)xRbt)puL>xs_c64-H@%#Or zXf!&j>$*muHOWXvHo`VD#lg6MPE~+#^!N8aRTO1|?J`J5He@S&wvbBVO8K%ZpNm8y zAIT}HC7Cxi$gY3tW-XzMtU1`kx+go?tM3CWp(Z#n*^&?X9upjrBoaWeDh>vNcO4E# z)3UM*kH0>GH%mi2IAp}6%}CKyd$<m+mR^J0^gIXz0v@N+c>~2W6jvjYwyv(OhW7UM zP7O5aPWUzq$A-}#e>#Hw16_xi<P1dCB5>hIJroxfm&IbSiP6!~SxS;g5FTo6ZM`H( zlIh)&4}38nXc|&$DyX^!-nt?1)(-JKW(QQ%jr|ydxA>>z)7I8@S=`cW5N4N`m!G77 zdZMpERgp|rK~d3JRsUp;<Xne@3X*%idAPiyqJn(0DUN1QwCPr>HJ6lA@hNmr@UjvF zT!Ag6;H&rZ+37vY=g+HO_-wIQtVRQvx7QEFj83+*vi=TLQ+cY^m5t3Z!D|~jv(ZlR zc>I^mX3LW^WSCo>=P5lkaGKBKE#utS*o(YFK~4deqwi1AMVd+U<ytr#o*<<w-^Js$ z884M5z!-{%A)S!cjdCNGPft&OAPzDy2v>S~dit;|^yb25sIpdZA`Wys(O1dAvo2(I ziyc~u+*C?>Z*T8&(cem%afeVS6nDGb_L8EKvNL%#5MBx6)#tX<qR#jZs%_P9tL7%i z*)oibj0|FLKS7R|cq~%4-ePi*J(zsR8eY2C@n?2cia7tGp51$YpG6bV?X8z@wBCL_ z4q3asI6I!Ng@uKAgNW99JzxL(z-9>j`d$yLwBMhA-vSH(T>k(8(cOU?00000NkvXX Hu0mjf8E%<j literal 0 HcmV?d00001 diff --git a/members/account.pl b/members/account.pl new file mode 100755 index 0000000..45d3161 --- /dev/null +++ b/members/account.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Dates qw/format_date/; +use C4::Members; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Database; + +my $cgi = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/account.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +my $borrowernumber = $cgi->param('borrowernumber'); + +my $borrower = GetMember( 'borrowernumber' => $borrowernumber ); + +my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search( + { 'me.borrowernumber' => $borrowernumber }, + { prefetch => { account_offsets => 'credit' } } +); + +my @credits = Koha::Database->new()->schema->resultset('AccountCredit')->search( + { 'me.borrowernumber' => $borrowernumber }, + { prefetch => { account_offsets => 'debit' } } +); + +$template->param( + debits => \@debits, + credits => \@credits, + borrower => $borrower, +); + +# Standard /members/ borrower details data +## FIXME: This code is in every /members/ script and should be unified + +if ( $borrower->{'category_type'} eq 'C' ) { + my ( $catcodes, $labels ) = + GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); + my $cnt = scalar(@$catcodes); + $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; +} + +my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} ); +$template->param( picture => 1 ) if $picture; + +if ( C4::Context->preference('ExtendedPatronAttributes') ) { + my $attributes = GetBorrowerAttributes($borrowernumber); + $template->param( + ExtendedPatronAttributes => 1, + extendedattributes => $attributes + ); +} + +$template->param( + borrowernumber => $borrowernumber, + firstname => $borrower->{'firstname'}, + surname => $borrower->{'surname'}, + cardnumber => $borrower->{'cardnumber'}, + categorycode => $borrower->{'categorycode'}, + category_type => $borrower->{'category_type'}, + categoryname => $borrower->{'description'}, + address => $borrower->{'address'}, + address2 => $borrower->{'address2'}, + city => $borrower->{'city'}, + state => $borrower->{'state'}, + zipcode => $borrower->{'zipcode'}, + country => $borrower->{'country'}, + phone => $borrower->{'phone'}, + email => $borrower->{'email'}, + branchcode => $borrower->{'branchcode'}, + branchname => GetBranchName( $borrower->{'branchcode'} ), + is_child => ( $borrower->{'category_type'} eq 'C' ), + activeBorrowerRelationship => + ( C4::Context->preference('borrowerRelationship') ne '' ), + RoutingSerials => C4::Context->preference('RoutingSerials'), +); + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/members/account_credit.pl b/members/account_credit.pl new file mode 100755 index 0000000..7e22a1c --- /dev/null +++ b/members/account_credit.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl + +#written 11/1/2000 by chris@katipo.oc.nz +#script to display borrowers account details + +# Copyright 2000-2002 Katipo Communications +# Copyright 2010 BibLibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +use C4::Auth; +use C4::Output; +use CGI; + +use C4::Koha; +use C4::Members; +use C4::Branch; +use C4::Items; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Database; + +my $cgi = new CGI; + +my $borrowernumber = $cgi->param('borrowernumber'); + +my $borrower = GetMember( 'borrowernumber' => $borrowernumber ); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/account_credit.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +$template->param( credit_types_loop => GetAuthorisedValues('MANUAL_CREDIT') ); + +# Standard /members/ borrower details data +## FIXME: This code is in every /members/ script and should be unified + +if ( $borrower->{'category_type'} eq 'C' ) { + my ( $catcodes, $labels ) = + GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); + my $cnt = scalar(@$catcodes); + $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; +} + +my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} ); +$template->param( picture => 1 ) if $picture; + +if ( C4::Context->preference('ExtendedPatronAttributes') ) { + my $attributes = GetBorrowerAttributes($borrowernumber); + $template->param( + ExtendedPatronAttributes => 1, + extendedattributes => $attributes + ); +} + +$template->param( + borrowernumber => $borrowernumber, + firstname => $borrower->{'firstname'}, + surname => $borrower->{'surname'}, + cardnumber => $borrower->{'cardnumber'}, + categorycode => $borrower->{'categorycode'}, + category_type => $borrower->{'category_type'}, + categoryname => $borrower->{'description'}, + address => $borrower->{'address'}, + address2 => $borrower->{'address2'}, + city => $borrower->{'city'}, + state => $borrower->{'state'}, + zipcode => $borrower->{'zipcode'}, + country => $borrower->{'country'}, + phone => $borrower->{'phone'}, + email => $borrower->{'email'}, + branchcode => $borrower->{'branchcode'}, + branchname => GetBranchName( $borrower->{'branchcode'} ), + is_child => ( $borrower->{'category_type'} eq 'C' ), + activeBorrowerRelationship => + ( C4::Context->preference('borrowerRelationship') ne '' ), + RoutingSerials => C4::Context->preference('RoutingSerials'), +); + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/members/account_credit_do.pl b/members/account_credit_do.pl new file mode 100755 index 0000000..b4d01c6 --- /dev/null +++ b/members/account_credit_do.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Members; +use C4::Items; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Accounts; +use Koha::Database; + +my $cgi = new CGI; + +my $borrowernumber = $cgi->param('borrowernumber'); +my $borrower = + Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber); + +if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) { + + my $barcode = $cgi->param('barcode'); + my $itemnumber = $cgi->param('itemnumber'); + my $description = $cgi->param('description'); + my $amount = $cgi->param('amount'); + my $type = $cgi->param('type'); + my $notes = $cgi->param('notes'); + + if ( !$itemnumber && $barcode ) { + $itemnumber = GetItemnumberFromBarcode($barcode); + } + + my $debit = AddCredit( + { + borrower => $borrower, + amount => $amount, + type => $type, + itemnumber => $itemnumber, + description => $description, + notes => $notes, + + } + ); + + print $cgi->redirect( + "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber"); +} diff --git a/members/account_debit.pl b/members/account_debit.pl new file mode 100755 index 0000000..86061cf --- /dev/null +++ b/members/account_debit.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +#written 11/1/2000 by chris@katipo.oc.nz +#script to display borrowers account details + +# Copyright 2000-2002 Katipo Communications +# Copyright 2010 BibLibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Members; +use C4::Items; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use C4::Koha; +use Koha::Accounts; +use Koha::Database; + +my $input = new CGI; + +my $borrowernumber = $input->param('borrowernumber'); + +my $borrower = GetMember( 'borrowernumber' => $borrowernumber ); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/account_debit.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +$template->param( invoice_types_loop => GetAuthorisedValues('MANUAL_INV') ); + +# Standard /members/ borrower details data +## FIXME: This code is in every /members/ script and should be unified + +if ( $borrower->{'category_type'} eq 'C' ) { + my ( $catcodes, $labels ) = + GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); + my $cnt = scalar(@$catcodes); + $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; +} + +my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} ); +$template->param( picture => 1 ) if $picture; + +if ( C4::Context->preference('ExtendedPatronAttributes') ) { + my $attributes = GetBorrowerAttributes($borrowernumber); + $template->param( + ExtendedPatronAttributes => 1, + extendedattributes => $attributes + ); +} + +$template->param( + borrowernumber => $borrowernumber, + firstname => $borrower->{'firstname'}, + surname => $borrower->{'surname'}, + cardnumber => $borrower->{'cardnumber'}, + categorycode => $borrower->{'categorycode'}, + category_type => $borrower->{'category_type'}, + categoryname => $borrower->{'description'}, + address => $borrower->{'address'}, + address2 => $borrower->{'address2'}, + city => $borrower->{'city'}, + state => $borrower->{'state'}, + zipcode => $borrower->{'zipcode'}, + country => $borrower->{'country'}, + phone => $borrower->{'phone'}, + email => $borrower->{'email'}, + branchcode => $borrower->{'branchcode'}, + branchname => GetBranchName( $borrower->{'branchcode'} ), + is_child => ( $borrower->{'category_type'} eq 'C' ), + activeBorrowerRelationship => + ( C4::Context->preference('borrowerRelationship') ne '' ), + RoutingSerials => C4::Context->preference('RoutingSerials'), +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/account_debit_do.pl b/members/account_debit_do.pl new file mode 100755 index 0000000..dd5c8b5 --- /dev/null +++ b/members/account_debit_do.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; + +use C4::Auth; +use C4::Output; +use C4::Members; +use C4::Items; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Accounts; +use Koha::Database; + +my $cgi = new CGI; + +my $borrowernumber = $cgi->param('borrowernumber'); +my $borrower = + Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber); + +if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) { + + # print $cgi->header; + my $barcode = $cgi->param('barcode'); + my $itemnumber = $cgi->param('itemnumber'); + my $description = $cgi->param('description'); + my $amount = $cgi->param('amount'); + my $type = $cgi->param('type'); + my $notes = $cgi->param('notes'); + + if ( !$itemnumber && $barcode ) { + $itemnumber = GetItemnumberFromBarcode($barcode); + } + + my $debit = AddDebit( + { + borrower => $borrower, + amount => $amount, + type => $type, + itemnumber => $itemnumber, + description => $description, + notes => $notes, + + } + ); + + my $debit_id = $debit->debit_id(); + + print $cgi->redirect( + "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber"); +} diff --git a/members/account_payment.pl b/members/account_payment.pl new file mode 100755 index 0000000..54b20e1 --- /dev/null +++ b/members/account_payment.pl @@ -0,0 +1,123 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# Copyright 2010 BibLibre +# Copyright 2010,2011 PTFS-Europe Ltd +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 account_payment.pl + + written 11/1/2000 by chris@katipo.oc.nz + part of the koha library system, script to facilitate paying off fines + +=cut + +use Modern::Perl; + +use CGI; + +use URI::Escape; + +use C4::Context; +use C4::Auth; +use C4::Output; +use C4::Members; +use C4::Stats; +use C4::Koha; +use C4::Overdues; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Database; + +our $cgi = CGI->new; + +our ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => 'members/account_payment.tt', + query => $cgi, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +my $borrowernumber = $cgi->param('borrowernumber'); + +my $borrower = GetMember( borrowernumber => $borrowernumber ); + +my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search( + { + 'me.borrowernumber' => $borrowernumber, + amount_outstanding => { '>' => 0 } + } +); + +$template->param( + debits => \@debits, + borrower => $borrower, + credit_types_loop => GetAuthorisedValues('MANUAL_CREDIT'), +); + +# Standard /members/ borrower details data +## FIXME: This code is in every /members/ script and should be unified + +if ( $borrower->{'category_type'} eq 'C' ) { + my ( $catcodes, $labels ) = + GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); + my $cnt = scalar(@$catcodes); + $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; +} + +my ( $picture, $dberror ) = GetPatronImage( $borrower->{'borrowernumber'} ); +$template->param( picture => 1 ) if $picture; + +if ( C4::Context->preference('ExtendedPatronAttributes') ) { + my $attributes = GetBorrowerAttributes($borrowernumber); + $template->param( + ExtendedPatronAttributes => 1, + extendedattributes => $attributes + ); +} + +$template->param( + borrowernumber => $borrowernumber, + firstname => $borrower->{'firstname'}, + surname => $borrower->{'surname'}, + cardnumber => $borrower->{'cardnumber'}, + categorycode => $borrower->{'categorycode'}, + category_type => $borrower->{'category_type'}, + categoryname => $borrower->{'description'}, + address => $borrower->{'address'}, + address2 => $borrower->{'address2'}, + city => $borrower->{'city'}, + state => $borrower->{'state'}, + zipcode => $borrower->{'zipcode'}, + country => $borrower->{'country'}, + phone => $borrower->{'phone'}, + email => $borrower->{'email'}, + branchcode => $borrower->{'branchcode'}, + branchname => GetBranchName( $borrower->{'branchcode'} ), + is_child => ( $borrower->{'category_type'} eq 'C' ), + activeBorrowerRelationship => + ( C4::Context->preference('borrowerRelationship') ne '' ), + RoutingSerials => C4::Context->preference('RoutingSerials'), +); + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/members/account_payment_do.pl b/members/account_payment_do.pl new file mode 100755 index 0000000..1f66052 --- /dev/null +++ b/members/account_payment_do.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; + +use C4::Auth; +use C4::Members; +use C4::Items; +use C4::Branch; +use C4::Members::Attributes qw(GetBorrowerAttributes); +use Koha::Accounts; +use Koha::Database; + +my $cgi = new CGI; + +if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) { + my $borrowernumber = $cgi->param('borrowernumber'); + + my $borrower = + Koha::Database->new()->schema->resultset('Borrower') + ->find($borrowernumber); + + my $amount_to_pay = $cgi->param('amount_to_pay'); + my $amount_received = $cgi->param('amount_received'); + my $type = $cgi->param('type'); + my $notes = $cgi->param('notes'); + my @debit_id = $cgi->param('debit_id'); + + $amount_received ||= $amount_to_pay + if $type eq Koha::Accounts::CreditTypes::Payment(); + + my $debit = AddCredit( + { + borrower => $borrower, + amount_received => $amount_received, + amount => $amount_to_pay, + type => $type, + notes => $notes, + debit_id => \@debit_id, + + } + ); + + print $cgi->redirect( + "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber"); +} diff --git a/members/account_print.pl b/members/account_print.pl new file mode 100755 index 0000000..3e1d302 --- /dev/null +++ b/members/account_print.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +# Copyright 2013 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use CGI; + +use C4::Auth; +use C4::Output; +use Koha::Database; + +my $cgi = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/account_print.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +my $type = $cgi->param('type'); +my $id = $cgi->param('id'); + +warn "No type passed in!" unless $type; +warn "No id passed in!" unless $id; + +if ( $type eq 'debit' ) { + my $debit = + Koha::Database->new()->schema->resultset('AccountDebit')->find($id); + $template->param( debit => $debit ); +} +elsif ( $type eq 'credit' ) { + my $credit = + Koha::Database->new()->schema->resultset('AccountCredit')->find($id); + $template->param( credit => $credit ); +} + +$template->param( type => $type ); + +output_html_with_http_headers $cgi, $cookie, $template->output; -- 1.7.2.5