Bugzilla – Attachment 180500 Details for
Bug 39177
Add additional fields support to credit types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39177: Add additional fields to credit types
Bug-39177-Add-additional-fields-to-credit-types.patch (text/plain), 7.78 KB, created by
Martin Renvoize (ashimema)
on 2025-04-03 12:16:27 UTC
(
hide
)
Description:
Bug 39177: Add additional fields to credit types
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-04-03 12:16:27 UTC
Size:
7.78 KB
patch
obsolete
>From 232218076549117e3b3a536b1afcd3e483f2d95e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 20 Feb 2025 13:01:39 +0000 >Subject: [PATCH] Bug 39177: Add additional fields to credit types > >Test plan, k-t-d: >1) Before defining any additional fields for account_credit_types, > confirm that the 'Additional fields' section does not appear when > attempting to add a new or edit an existing credit type. >2) Add a new additional field to 'account_credit_types': > <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=account_credit_types >3) Click 'New field'. Add a name. Click Save. >4) Repeat step 2 but repeatable. Repeat again for 2 more of AV category > (one repeatable, one not repeatable) >5) Edit an account credit type: > <staff_url>/cgi-bin/koha/admin/credit_types.pl?op=add_form&code=MANUAL >6) Input various values in the different additional fields. Click > 'Submit' >7) Edit the same credit type again and note the additional fields added > in the previous step are visible > <staff_url>/cgi-bin/koha/admin/credit_types.pl?op=add_form&code=MANUAL > >Sponsored-by: PTFS Europe <https://ptfs-europe.com> >--- > Koha/Account/CreditType.pm | 2 +- > Koha/Account/CreditTypes.pm | 2 +- > admin/credit_types.pl | 15 +++++++++++++-- > .../en/modules/admin/additional-fields.tt | 1 + > .../prog/en/modules/admin/credit_types.tt | 19 ++++++++++++++++++- > 5 files changed, 34 insertions(+), 5 deletions(-) > >diff --git a/Koha/Account/CreditType.pm b/Koha/Account/CreditType.pm >index faf65cfce4e..6eb41c8e760 100644 >--- a/Koha/Account/CreditType.pm >+++ b/Koha/Account/CreditType.pm >@@ -22,7 +22,7 @@ use Modern::Perl; > use Koha::Database; > use Koha::Exceptions; > >-use base qw(Koha::Object Koha::Object::Limit::Library); >+use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object Koha::Object::Limit::Library); > > =head1 NAME > >diff --git a/Koha/Account/CreditTypes.pm b/Koha/Account/CreditTypes.pm >index 27b43e6d923..40c0ce7ae5a 100644 >--- a/Koha/Account/CreditTypes.pm >+++ b/Koha/Account/CreditTypes.pm >@@ -22,7 +22,7 @@ use Modern::Perl; > use Koha::Database; > use Koha::Account::CreditType; > >-use base qw(Koha::Objects Koha::Objects::Limit::Library); >+use base qw(Koha::Objects::Mixin::AdditionalFields Koha::Objects Koha::Objects::Limit::Library); > > =head1 NAME > >diff --git a/admin/credit_types.pl b/admin/credit_types.pl >index a0eb1bfb6fc..962e533babc 100755 >--- a/admin/credit_types.pl >+++ b/admin/credit_types.pl >@@ -27,6 +27,7 @@ use C4::Output qw( output_html_with_http_headers ); > > use Koha::Account::CreditType; > use Koha::Account::CreditTypes; >+use Koha::AdditionalFields; > > my $input = CGI->new; > my $code = $input->param('code'); >@@ -42,6 +43,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+my @additional_fields = Koha::AdditionalFields->search( { tablename => 'account_credit_types' } )->as_list; >+$template->param( additional_fields => \@additional_fields, ); >+ > my $credit_type; > if ($code) { > $credit_type = Koha::Account::CreditTypes->find($code); >@@ -66,9 +70,12 @@ if ( $op eq 'add_form' ) { > }; > } > >+ my @additional_field_values = $credit_type ? $credit_type->get_additional_field_values_for_template : (); >+ > $template->param( >- credit_type => $credit_type, >- branches_loop => \@branches_loop >+ credit_type => $credit_type, >+ branches_loop => \@branches_loop, >+ additional_field_values => @additional_field_values, > ); > } elsif ( $op eq 'cud-add_validate' ) { > my $description = $input->param('description'); >@@ -90,6 +97,10 @@ if ( $op eq 'add_form' ) { > unless ( $credit_type->is_system ) { > $credit_type->replace_library_limits( \@branches ); > } >+ >+ my @additional_fields = $credit_type->prepare_cgi_additional_field_values( $input, 'account_credit_types' ); >+ $credit_type->set_additional_fields( \@additional_fields ); >+ > push @messages, { type => 'message', code => 'success_on_saving' }; > } catch { > push @messages, { type => 'error', code => 'error_on_saving' }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >index f7ec537e612..3a23c02ce2d 100755 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt >@@ -155,6 +155,7 @@ > [% WRAPPER table_option value="accountlines:debit" %]Account lines (debit)[% END %] > [% END %] > [% IF ( CAN_user_parameters_manage_accounts ) %] >+ [% WRAPPER table_option value="account_credit_types" %]Account credit types[% END %] > [% WRAPPER table_option value="account_debit_types" %]Account debit types[% END %] > [% END %] > </ul> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/credit_types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/credit_types.tt >index 04fe052dc51..80ef8565e64 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/credit_types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/credit_types.tt >@@ -143,7 +143,9 @@ > </li> > </ol> > </fieldset> >- >+ [% IF additional_fields.size %] >+ [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values wrap_fieldset=1 %] >+ [% END %] > <fieldset class="action"> > <button id="save_credit_type" class="btn btn-primary">Save</button> > <a class="cancel" href="/cgi-bin/koha/admin/credit_types.pl">Cancel</a> >@@ -165,6 +167,9 @@ > <th>System</th> > <th>Code</th> > <th>Description</th> >+ [% IF additional_fields.size %] >+ <th>Additional fields</th> >+ [% END %] > <th>Available for</th> > <th>Credit number enabled</th> > <th>Library limitations</th> >@@ -177,6 +182,17 @@ > <td>[% credit_type.is_system | html %]</td> > <td>[% credit_type.code | html %]</td> > <td>[%- PROCESS credit_type_description credit_type = credit_type -%]</td> >+ [% IF additional_fields.size %] >+ <td> >+ [% IF credit_type.additional_field_values.count > 0 %] >+ [% FOREACH additional_field IN credit_type.additional_field_values %] >+ <div><span class="label">[% additional_field.field.name | html %]</span>: [% additional_field.value | html %]</div> >+ [% END %] >+ [% ELSE %] >+ <span>No additional fields</span> >+ [% END %] >+ </td> >+ [% END %] > <td>[% IF credit_type.can_be_added_manually %]Manual credit[% END %]</td> > <td>[% IF credit_type.credit_number_enabled %]Yes[% ELSE %]No[% END %]</td> > <td> >@@ -236,6 +252,7 @@ > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/admin-menu.js") | $raw %] >+ [% Asset.js("js/additional-fields-entry.js") | $raw %] > [% INCLUDE 'datatables.inc' %] > <script> > $(document).ready(function () { >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39177
:
178409
|
178410
|
180499
|
180500
|
180501
|
180502