From 4b9400f6e1abf405a589e08f371967cbaf0a0507 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 23 Nov 2016 14:15:58 +0000 Subject: [PATCH] Bug 17702: Account types configuration - Manual invoice and credit --- .../prog/en/modules/members/mancredit.tt | 13 +++++++-- .../prog/en/modules/members/maninvoice.tt | 34 ++++++++++------------ members/mancredit.pl | 5 ++++ members/maninvoice.pl | 14 +++------ 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt index 65a61a5..bab7e7d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt @@ -7,6 +7,11 @@ $(document).ready(function(){ $('#mancredit').preventDoubleFormSubmit(); $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); + + $("#mancredit #desc").val($("#mancredit #type option:selected").text()); + $("#mancredit #type").change(function(){ + $("#mancredit #desc").val($(this).find("option:selected").text()); + }); }); //]]> @@ -39,9 +44,11 @@ $(document).ready(function(){
Manual credit
    -
  1. + [% FOREACH credit_type IN credit_types %] + + [% END %]
  2. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt index 7d35c73..711214b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt @@ -7,6 +7,18 @@ $(document).ready(function(){ $('#maninvoice').preventDoubleFormSubmit(); $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); + var type_fees = new Array(); + [% FOREACH debit_type IN debit_types %] + type_fees['[% debit_type.type_code %]'] = "[% debit_type.default_amount %]"; + [% END %] + + $("#maninvoice #desc").val($("#maninvoice #type option:selected").text()); + $("#maninvoice #amount").val(type_fees[$("#maninvoice #type option:selected").val()]); + + $("#maninvoice #type").change(function(){ + $("#maninvoice #desc").val($(this).find("option:selected").text()); + $("#maninvoice #amount").val(type_fees[$(this).val()]); + }); }); //]]> @@ -44,26 +56,10 @@ $(document).ready(function(){ Manual invoice
    1. - - + [% FOREACH debit_type IN debit_types %] + [% END %]
    2. diff --git a/members/mancredit.pl b/members/mancredit.pl index 76b3492..32904ed 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -36,6 +36,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Patron::Images; use Koha::Patron::Categories; +use Koha::Account::CreditTypes; my $input=new CGI; my $flagsrequired = { borrowers => 1, updatecharges => 1 }; @@ -92,6 +93,10 @@ if ($add){ ); } + my @credit_types = Koha::Account::CreditTypes->search({ can_be_added_manually => 1 }); + + $template->param( credit_types => \@credit_types ); + $template->param(%$data); $template->param( diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 906e2fe..34bb58c 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -35,6 +35,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Patron::Images; use Koha::Patron::Categories; +use Koha::Account::DebitTypes; my $input=new CGI; my $flagsrequired = { borrowers => 1 }; @@ -89,16 +90,9 @@ if ($add){ updatecharges => 'remaining_permissions' }, debug => 1, }); - - # get authorised values with type of MANUAL_INV - my @invoice_types; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare('SELECT * FROM authorised_values WHERE category = "MANUAL_INV"'); - $sth->execute(); - while ( my $row = $sth->fetchrow_hashref() ) { - push @invoice_types, $row; - } - $template->param( invoice_types_loop => \@invoice_types ); + + my @debit_types = Koha::Account::DebitTypes->search({ can_be_added_manually => 1 }); + $template->param( debit_types => \@debit_types ); if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); -- 2.1.4