From 98c7f0d0761abd1df8f36f5a9e24c4c59dbba7a9 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 15 Jul 2014 10:49:18 -0400 Subject: [PATCH] Bug 6427 - Add new staff scripts for managing accounts --- Koha/Schema/Result/AccountCredit.pm | 5 + .../prog/en/modules/members/account.tt | 552 ++++++++++++++++++++ .../prog/en/modules/members/account_credit.tt | 97 ++++ .../prog/en/modules/members/account_debit.tt | 114 ++++ .../prog/en/modules/members/account_payment.tt | 246 +++++++++ .../prog/en/modules/members/account_print.tt | 150 ++++++ 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 | 132 +++++ 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 | 66 +++ members/account_print.pl | 60 +++ members/account_void.pl | 38 ++ 17 files changed, 1925 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 create mode 100755 members/account_void.pl diff --git a/Koha/Schema/Result/AccountCredit.pm b/Koha/Schema/Result/AccountCredit.pm index ebe13ab..154974c 100644 --- a/Koha/Schema/Result/AccountCredit.pm +++ b/Koha/Schema/Result/AccountCredit.pm @@ -197,4 +197,9 @@ __PACKAGE__->belongs_to( { borrowernumber => "borrowernumber" }, ); +__PACKAGE__->belongs_to( + "branch", + "Koha::Schema::Result::Branch", + { branchcode => "branchcode" }, +); 1; 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..f02538e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account.tt @@ -0,0 +1,552 @@ +[% SET accounts_view = 1 %] +[% USE KohaDates %] +[% USE Currency %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › Account for [% INCLUDE 'patron-title.inc' %] +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'datatables.inc' %] +[% INCLUDE 'browser-strings.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patron-search.inc' %] + + + +
+
+
+
+ [% INCLUDE 'members-toolbar.inc' %] + +
+ +
+ +
+ +

+

Account balance: [% borrower.account_balance | $Currency %]

+

+ +
+
+ + + + + + + + + + + + + + + + + +
Fees
IDDescriptionTypeAmountOutstandingCreated onUpdated on
+
+ +
+ + + + + + + + + + + + + + + + + +
Payments
IDNotesTypeAmountRemainingCreated onUpdated on
+
+
+
+
+
+ +
+ [% INCLUDE 'circ-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] + +[% BLOCK format_data %] + [% FOREACH key IN data.result_source.columns %] + [% IF key.match('^amount') %] + "[% key %]_original": "[% data.$key %]", + "[% key %]": "[% data.$key FILTER $Currency highlight => highlight %]", + [% ELSIF key.match('_on$') %] + "[% key %]_original": "[% data.$key %]", + "[% 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..98015be --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_credit.tt @@ -0,0 +1,97 @@ +[% SET accounts_view = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Borrowers › Create manual credit +[% INCLUDE 'doc-head-close.inc' %] + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'patron-search.inc' %] + + + +
+
+
+
+ [% INCLUDE 'members-toolbar.inc' %] + +
+ + +
+ +
+ + +
+ Manual credit + +
    +
  1. + + +
  2. + +
  3. + + +
  4. + +
  5. + + +
  6. + +
  7. + + +
  8. + +
  9. + + + Example: 5.00 +
  10. +
+ +
+ +
+ + Cancel +
+
+ +
+
+
+
+
+ [% INCLUDE 'circ-menu.inc' %] +
+
+[% 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..125179c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_debit.tt @@ -0,0 +1,114 @@ +[% SET accounts_view = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Borrowers › Create manual invoice +[% INCLUDE 'doc-head-close.inc' %] + + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'patron-search.inc' %] + + + +
+
+
+
+ [% INCLUDE 'members-toolbar.inc' %] + +
+ +
+ +
+ + +
+ Manual Invoice + +
    +
  1. + + +
  2. + + +
  3. + + +
  4. + +
  5. + + +
  6. + +
  7. + + +
  8. + +
  9. + + Example: 5.00 +
  10. + +
+
+ +
+ + Cancel +
+ +
+ +
+
+
+
+ +
+ [% INCLUDE 'circ-menu.inc' %] +
+ +
+[% 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..3866773 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_payment.tt @@ -0,0 +1,246 @@ +[% SET accounts_view = 1 %] +[% USE Currency %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Patrons › Pay Fines for [% borrower.firstname %] [% borrower.surname %] +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'browser-strings.inc' %] + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'patron-search.inc' %] + + + +
+
+
+
+ [% INCLUDE 'members-toolbar.inc' borrowernumber=borrower.borrowernumber %] + +
+ + +
+ + [% IF ( debits ) %] +
+ + + +

+ + Select all + + + | + + + Clear all + +

+ + + + + + + + + + + + + + [% SET total_due = 0 %] + [% FOREACH d IN debits %] + [% SET total_due = total_due + d.amount_outstanding %] + + + + + + + + + + + + [% END %] + + + + + + + + + +
 DescriptionAccount typeOriginal amountAmount outstanding
+ + + [% d.description %] + + [% IF d.notes %] + ( [% d.notes %] ) + [% END %] + + [% d.type %] + + [% d.amount_original | $Currency %] + + + [% d.amount_outstanding | $Currency %] + +
Total Due:[% total_due | $Currency %]
+ +
+

+ + + + + + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+

+ +
+ + Cancel +
+ +
+ + [% ELSE %] +

+ [% borrower.firstname %] [% borrower.surname %] has no outstanding fines. +

+ [% END %] + +
+
+
+
+ +
+ [% INCLUDE 'circ-menu.tt' %] +
+
+[% 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..a16cdde --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/account_print.tt @@ -0,0 +1,150 @@ +[% USE KohaDates %] +[% USE Currency %] +[% USE EncodeUTF8 %] +[% INCLUDE 'doc-head-open.inc' %] +Print Receipt for [% cardnumber %] +[% INCLUDE 'doc-head-close.inc' %] + + + + + +[% SET account = debit || credit %] +[% SET borrower = account.borrower %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [% IF account.description %] + + + + + [% END %] + + [% IF credit %] + + + + + [% IF credit.amount_received > 0 %] + + + + + + + + + [% END %] + + + + + [% IF credit.account_offsets %] + + + + + + + + + + + + [% END %] + [% ELSIF debit %] + + + + + + + + + [% IF debit.account_offsets %] + + + + + + + + + + + + [% END %] + [% END %] + + + + [% IF credit.account_offsets %] + [% FOREACH ao IN credit.account_offsets %] + + + + + + + + + [% END %] + [% ELSIF debit.account_offsets %] + [% FOREACH ao IN debit.account_offsets %] + + + + + + + + + [% END %] + [% END %] + +
+ [% IF debit %] + Invoice + [% ELSIF credit %] + Payment receipt + [% END %] +
+ [% IF credit %] + [% account.branch.branchname | $EncodeUTF8 %] + [% ELSE %] + [% borrower.branch.branchname | $EncodeUTF8 %] + [% END %] +
Name:[% borrower.firstname | $EncodeUTF8 %] [% borrower.surname | $EncodeUTF8 %]
Card number:[% borrower.cardnumber %]
Date:[% account.created_on | $KohaDates %]
Description:[% account.description | $EncodeUTF8 %]
Amount paid:[% credit.amount_paid | $Currency highlight => type %]
Amount received:[% credit.amount_received | $Currency highlight => type %]
Change due:[% credit.amount_received - credit.amount_paid | $Currency highlight => type %]
Balance:[% credit.amount_remaining | $Currency highlight => type %]
Fees paid
DescriptionTypeAmountPaidOutstandingDate
Amount:[% debit.amount_original | $Currency highlight => type %]
Outstanding:[% debit.amount_outstanding | $Currency highlight => type %]
Payments applied
DateTypePaymentAppliedBalanceNotes
[% ao.debit.description %][% ao.debit.type %][% ao.debit.amount_original | $Currency highlight => 'debit' %][% ao.amount | $Currency highlight => 'offset' %][% ao.debit.amount_outstanding | $Currency highlight => 'debit' %][% ao.debit.created_on | $KohaDates %]
[% ao.credit.created_on | $KohaDates %][% ao.credit.type %][% ao.credit.amount_paid | $Currency highlight => 'credit' %][% ao.amount | $Currency highlight => 'offset' %][% ao.credit.amount_remaining | $Currency highlight => 'credit' %][% ao.credit.notes %]
+ +[% 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)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%+2vP1rl3*$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!d$>Do3Jo15TlYl9m;-_3M7y&8+fGbP>p=udnZ^^3rY*Ry8&@-XZS}=H{ef zDUJ>}0_oCdYHA|eDvG0BC2ghK?XIQGd^|3d(Ko2a8%4c^+ z2RQuxqA|Bf6p=-Yhg81x*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)P5xVIgh(4gM3Zjdy!n~2N zjD^FnHQ1(tR(9cJl^-l~RyvtO-;dMt9M4;+6T9$?ALpFs)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$~2W6jvjYwyv(OhW7UM zP7O5aPWUzq$A-}#e>#Hw16_xihIJroxfm&IbSiP6!~SxS;g5FTo6ZM`H( zlIh)&4}38nXc|&$DyX^!-nt?1)(-JKW(QQ%jr|ydxA>>z)7I8@S=`cW5N4N`m!G77 zdZMpERgp|rK~d3JRsUp;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+US~dit;|^yb25sIpdZA`Wys(O1dAvo2(I ziyc~u+*C?>Z*T8&(cem%afeVS6nDGb_L8EKvNL%#5MBx6)#tXj`d$yLwBMhA-vSH(T>k(8(cOU?00000NkvXX Hu0mjf8E% "members/account.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { borrowers => 1, updatecharges => 1 }, + debug => 1, + } +); + +my $show_all = $cgi->param('show_all'); + +my $borrowernumber = $cgi->param('borrowernumber'); + +my $borrower = GetMember( 'borrowernumber' => $borrowernumber ); + +my $schema = Koha::Database->new()->schema(); + +my %params; +$params{-not} = { amount_outstanding => '0' } unless $show_all; +my @debits = $schema->resultset('AccountDebit')->search( + { + 'me.borrowernumber' => $borrowernumber, + %params, + }, + { prefetch => { account_offsets => 'credit' } } +); + +%params = (); +$params{-not} = { amount_remaining => '0' } unless $show_all; +my @credits = $schema->resultset('AccountCredit')->search( + { + 'me.borrowernumber' => $borrowernumber, + %params, + }, + { prefetch => { account_offsets => 'debit' } } +); + +$template->param( + debits => \@debits, + credits => \@credits, + borrower => $borrower, + + # IDs for automatic receipt printing + debit_id => $cgi->param('debit_id') || undef, + credit_id => $cgi->param('credit_id') || undef, + + show_all => $show_all, +); + +# 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..9f0802f --- /dev/null +++ b/members/account_payment_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::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 $credit = AddCredit( + { + borrower => $borrower, + amount_received => $amount_received, + amount => $amount_to_pay, + type => $type, + notes => $notes, + debit_id => \@debit_id, + + } + ); + + my $credit_id = $credit->credit_id(); + + print $cgi->redirect( + "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber&credit_id=$credit_id"); +} 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; diff --git a/members/account_void.pl b/members/account_void.pl new file mode 100755 index 0000000..fffc995 --- /dev/null +++ b/members/account_void.pl @@ -0,0 +1,38 @@ +#!/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::Accounts; + +my $cgi = new CGI; + +my $id = $cgi->param('id'); +my $borrowernumber = $cgi->param('borrowernumber'); + +if ( checkauth( $cgi, 0, { borrowers => 1 }, 'intranet' ) ) { + VoidCredit( { id => $id } ); + + print $cgi->redirect( + "/cgi-bin/koha/members/account.pl?borrowernumber=$borrowernumber"); +} -- 1.7.2.5