From 264c83556c907366e756584705ccf4c0a88b79c1 Mon Sep 17 00:00:00 2001 From: Kyle M Hall <kyle@bywatersolutions.com> Date: Tue, 15 Jul 2014 10:51:58 -0400 Subject: [PATCH] Bug 6427 - Update OPAC scripts Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Sean McGarvey <seanm@pascolibraries.org> --- .../bootstrap/en/includes/browser-strings.inc | 34 ++ .../opac-tmpl/bootstrap/en/modules/opac-account.tt | 411 +++++++++++++++++--- .../opac-tmpl/bootstrap/images/details_close.png | Bin 0 -> 841 bytes .../opac-tmpl/bootstrap/images/details_open.png | Bin 0 -> 881 bytes opac/opac-account.pl | 46 +-- opac/opac-user.pl | 17 +- 6 files changed, 407 insertions(+), 101 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/browser-strings.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/details_close.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/details_open.png diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/browser-strings.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/browser-strings.inc new file mode 100644 index 0000000..0b61e01 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/browser-strings.inc @@ -0,0 +1,34 @@ +[% USE AuthorisedValues %] +<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 AuthorisedValues.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 AuthorisedValues.Get('MANUAL_CREDIT') %] + "[% a.authorised_value %]" : "[% a.lib %]", + [% END %] + } + } +//]]> +</script> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt index 03fa58e..381afc2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -1,9 +1,13 @@ [% USE Koha %] [% USE KohaDates %] +[% USE Currency %] [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your fines and charges [% INCLUDE 'doc-head-close.inc' %] [% BLOCK cssinclude %][% END %] + +[% INCLUDE 'browser-strings.inc' %] + </head> <body id="opac-account" class="scrollto"> [% INCLUDE 'bodytag.inc' bodyid='opac-account' bodyclass='scrollto' %] @@ -12,7 +16,7 @@ <div class="main"> <ul class="breadcrumb"> <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> - <li>[% FOREACH BORROWER_INF IN BORROWER_INFO %]<a href="/cgi-bin/koha/opac-user.pl">[% BORROWER_INF.firstname %] [% BORROWER_INF.surname %]</a>[% END %] <span class="divider">›</span></li> + <li><a href="/cgi-bin/koha/opac-user.pl">[% borrower.firstname %] [% borrower.surname %]</a> <span class="divider">›</span></li> <li><a href="#">Your fines and charges</a></li> </ul> @@ -26,61 +30,57 @@ <div class="span10"> <div id="useraccount" class="maincontent"> <h3>Fines and charges</h3> + [% IF credits || debits %] + + <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>Outstanding</th> + <th>Created on</th> + <th>Updated on</th> + </tr> + </thead> + <tbody></tbody> + </table> + </div> - [% IF ( ACCOUNT_LINES ) %] - <table class="table table-bordered table-striped"> - <thead> - <tr> - <th>Date</th> - <th>Description</th> - <th>Fine amount</th> - <th>Amount outstanding</th> - </tr> - </thead> - - <tfoot> - <tr> - <th class="sum" colspan="3">Total due</th> - <td class="sum">[% total %]</td> - </tr> - </tfoot> - - <tbody> - [% FOREACH ACCOUNT_LINE IN ACCOUNT_LINES %] - [% IF ( ACCOUNT_LINE.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %] - <td>[% ACCOUNT_LINE.date | $KohaDates %]</td> - <td> - [% SWITCH ACCOUNT_LINE.accounttype %] - [% CASE 'Pay' %]Payment, thanks - [% CASE 'Pay00' %]Payment, thanks (cash via SIP2) - [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2) - [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2) - [% CASE 'N' %]New card - [% CASE 'F' %]Fine - [% CASE 'A' %]Account management fee - [% CASE 'M' %]Sundry - [% CASE 'L' %]Lost item - [% CASE 'W' %]Writeoff - [% CASE 'FU' %]Accruing fine - [% CASE 'Rent' %]Rental fee - [% CASE 'FOR' %]Forgiven - [% CASE 'LR' %]Lost item fee refund - [% CASE 'PAY' %]Payment - [% CASE 'WO' %]Writeoff - [% CASE 'C' %]Credit - [% CASE 'CR' %]Credit - [% CASE %][% ACCOUNT_LINE.accounttype %] - [%- END -%] - [%- IF ACCOUNT_LINE.description %], [% ACCOUNT_LINE.description %][% END %] - [% IF ACCOUNT_LINE.title %]([% ACCOUNT_LINE.title %])[% END %] - </td> - [% IF ( ACCOUNT_LINE.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amount %]</td> - [% IF ( ACCOUNT_LINE.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% ACCOUNT_LINE.amountoutstanding %]</td> - </tr> - [% END %] - </tbody> - - </table> + <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> [% ELSE %] <h4>You have no fines or charges</h4> [% END %] @@ -91,4 +91,305 @@ </div> <!-- / .main --> [% INCLUDE 'opac-bottom.inc' %] + +[% INCLUDE 'datatables.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 %]/images/"; + + 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 %]", + "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 %] + { + [% PROCESS format_data data=ao highlight='offset'%] + + "credit": { + [% PROCESS format_data data=ao.credit highlight='credit' %] + } + }, + [% 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" }, + { "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 += "<ul>"; + if ( oData.title ) { + sOut += "<li>" + _("Title: "); + if ( oData.biblionumber ) { + sOut += "<a href='/cgi-bin/koha/opac-detail.pl?biblionumber=" + oData.biblionumber + "'>"; + } + + sOut += oData.title; + + if ( oData.biblionumber ) { + sOut += "</a>"; + } + + sOut += "</li>"; + } + + if ( oData.barcode ) { + sOut += "<li>" + _("Barcode: ") + oData.barcode + "</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]; + sOut += + "<tr>" + + "<td>" + ao.credit_id + "</td>" + + "<td>" + ao.created_on + "</td>" + + "<td>" + ao.credit.amount_paid + "</td>" + + "<td>" + ao.amount + "</td>" + + "<td>" + ao.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;'>"; + + 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]; + sOut += + "<tr>" + + "<td>" + ao.debit.debit_id + "</td>" + + "<td>" + ao.debit.description + "</td>" + + "<td>" + ao.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; +} + +//]]> +</script> + [% BLOCK jsinclude %][% END %] + +[% BLOCK format_data %] + [% FOREACH key IN data.result_source.columns %] + [% IF key.match('^amount') %] + "[% key %]": "[% data.$key FILTER $Currency %]", + [% ELSIF key.match('_on$') %] + "[% key %]": "[% data.$key | $KohaDates %]", + [% ELSE %] + "[% key %]": "[% data.$key %]", + [% END %] + [% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/images/details_close.png b/koha-tmpl/opac-tmpl/bootstrap/images/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/opac-tmpl/bootstrap/images/details_open.png b/koha-tmpl/opac-tmpl/bootstrap/images/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/opac/opac-account.pl b/opac/opac-account.pl index 7bbdc6e..d249ed1 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -18,7 +18,6 @@ # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - use strict; use CGI qw ( -utf8 ); use C4::Members; @@ -39,40 +38,21 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -# get borrower information .... -my $borr = GetMemberDetails( $borrowernumber ); -my @bordat; -$bordat[0] = $borr; - -$template->param( BORROWER_INFO => \@bordat ); - -#get account details -my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); - -for ( my $i = 0 ; $i < $numaccts ; $i++ ) { - $accts->[$i]{'amount'} = sprintf( "%.2f", $accts->[$i]{'amount'} || '0.00'); - if ( $accts->[$i]{'amount'} >= 0 ) { - $accts->[$i]{'amountcredit'} = 1; - } - $accts->[$i]{'amountoutstanding'} = - sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} || '0.00' ); - if ( $accts->[$i]{'amountoutstanding'} >= 0 ) { - $accts->[$i]{'amountoutstandingcredit'} = 1; - } -} +my @debits = Koha::Database->new()->schema->resultset('AccountDebit')->search( + { 'me.borrowernumber' => $borrowernumber }, + { prefetch => { account_offsets => 'credit' } } +); -# add the row parity -my $num = 0; -foreach my $row (@$accts) { - $row->{'even'} = 1 if $num % 2 == 0; - $row->{'odd'} = 1 if $num % 2 == 1; - $num++; -} +my @credits = Koha::Database->new()->schema->resultset('AccountCredit')->search( + { 'me.borrowernumber' => $borrowernumber }, + { prefetch => { account_offsets => 'debit' } } +); -$template->param ( - ACCOUNT_LINES => $accts, - total => sprintf( "%.2f", $total ), - accountview => 1 +$template->param( + borrower => GetMemberDetails($borrowernumber), + debits => \@debits, + credits => \@credits, + accountview => 1 ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 995db7b..2d4dadf 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -36,6 +36,7 @@ use C4::Letters; use C4::Branch; # GetBranches use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Database; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -46,6 +47,7 @@ use Date::Calc qw( ); my $query = new CGI; +my $schema = Koha::Database->new()->schema(); BEGIN { if (C4::Context->preference('BakerTaylorEnabled')) { @@ -165,6 +167,7 @@ my @overdues; my @issuedat; my $itemtypes = GetItemTypes(); my $issues = GetPendingIssues($borrowernumber); +my $account_debit_rs = $schema->resultset('AccountDebit'); if ($issues){ foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) { # check for reserves @@ -173,19 +176,7 @@ if ($issues){ $issue->{'reserved'} = 1; } - my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); - my $charges = 0; - foreach my $ac (@$accts) { - if ( $ac->{'itemnumber'} == $issue->{'itemnumber'} ) { - $charges += $ac->{'amountoutstanding'} - if $ac->{'accounttype'} eq 'F'; - $charges += $ac->{'amountoutstanding'} - if $ac->{'accounttype'} eq 'FU'; - $charges += $ac->{'amountoutstanding'} - if $ac->{'accounttype'} eq 'L'; - } - } - $issue->{'charges'} = $charges; + $issue->{'charges'} = $account_debit_rs->search({ borrowernumber => $borrowernumber, itemnumber => $issue->{'itemnumber'} })->get_column('amount_outstanding')->sum(); $issue->{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($issue->{'biblionumber'}), GetFrameworkCode($issue->{'biblionumber'})); # check if item is renewable my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} ); -- 1.7.2.5