Bugzilla – Attachment 175370 Details for
Bug 38663
Add additional fields to libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38663: Add AdditionalFields to Library
Bug-38663-Add-AdditionalFields-to-Library.patch (text/plain), 5.21 KB, created by
Pedro Amorim
on 2024-12-11 10:30:51 UTC
(
hide
)
Description:
Bug 38663: Add AdditionalFields to Library
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-12-11 10:30:51 UTC
Size:
5.21 KB
patch
obsolete
>From d0e9200d2137655d8b2effa21649c491001752fc Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Tue, 10 Dec 2024 14:42:39 +0000 >Subject: [PATCH] Bug 38663: Add AdditionalFields to Library > >Test plan, k-t-d: >1) Add a new additional field to 'branches': > <staff_url>/cgi-bin/koha/admin/additional-fields.pl?tablename=branches >2) Click 'New field'. Add a name. Click Save. >3) Repeat step 2 but repeatable. Repeat again for 2 more of AV category > (one repeatable, one not repeatable) >4) Edit a library: > <staff_url>/cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=CPL >5) Input various values in the different additional fields. Click > 'Submit' >6) Visit the detail page of the library and verify the additional fields > data is displayed correctly: ><staff_url>/cgi-bin/koha/admin/branches.pl?op=view&branchcode=CPL >--- > Koha/Libraries.pm | 2 +- > Koha/Library.pm | 2 +- > admin/branches.pl | 20 +++++++++++++++++++ > .../prog/en/modules/admin/branches.tt | 8 ++++++++ > 4 files changed, 30 insertions(+), 2 deletions(-) > >diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm >index 20ceb8aa348..ed39fa77724 100644 >--- a/Koha/Libraries.pm >+++ b/Koha/Libraries.pm >@@ -29,7 +29,7 @@ use Koha::Items; > use Koha::Library; > use Koha::Patrons; > >-use base qw(Koha::Objects); >+use base qw(Koha::Objects::Mixin::AdditionalFields Koha::Objects); > > =head1 NAME > >diff --git a/Koha/Library.pm b/Koha/Library.pm >index 8056c702920..e970495a362 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -29,7 +29,7 @@ use Koha::StockRotationStages; > use Koha::SMTP::Servers; > use Koha::Library::Hours; > >-use base qw(Koha::Object); >+use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object); > > my $cache = Koha::Caches->get_instance(); > >diff --git a/admin/branches.pl b/admin/branches.pl >index b6d705cd185..65e50a5efbc 100755 >--- a/admin/branches.pl >+++ b/admin/branches.pl >@@ -28,6 +28,7 @@ use C4::Context; > use C4::Output qw( output_html_with_http_headers ); > use C4::Koha; > >+use Koha::AdditionalFields; > use Koha::Database; > use Koha::Patrons; > use Koha::Items; >@@ -49,6 +50,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >+if ($branchcode) { >+ my @additional_fields = Koha::AdditionalFields->search( { tablename => 'branches' } )->as_list; >+ my @additional_field_values; >+ @additional_field_values = Koha::Libraries->find($branchcode)->get_additional_field_values_for_template; >+ >+ $template->param( >+ additional_fields => \@additional_fields, >+ additional_field_values => @additional_field_values, >+ ); >+} >+ > if ( $op eq 'add_form' ) { > $template->param( > library => Koha::Libraries->find($branchcode), >@@ -146,6 +158,10 @@ if ( $op eq 'add_form' ) { > $index++; > } > >+ my @additional_fields = >+ Koha::Libraries->find($branchcode)->prepare_cgi_additional_field_values( $input, 'branches' ); >+ Koha::Libraries->find($branchcode)->set_additional_fields( \@additional_fields ); >+ > push @messages, { type => 'message', code => 'success_on_update' }; > } > ); >@@ -208,6 +224,10 @@ if ( $op eq 'add_form' ) { > $index++; > } > >+ my @additional_fields = >+ Koha::Libraries->find($branchcode)->prepare_cgi_additional_field_values( $input, 'branches' ); >+ Koha::Libraries->find($branchcode)->set_additional_fields( \@additional_fields ); >+ > push @messages, { type => 'message', code => 'success_on_insert' }; > } > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index cdf73a5b864..d4d6e400ec0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -368,6 +368,7 @@ > </li> > </ol> > </fieldset> >+ [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values wrap_fieldset=1 %] > <fieldset class="action"> > <input type="submit" class="btn btn-primary" value="Submit" /> > <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a> >@@ -602,6 +603,12 @@ > </div> <!-- /.rows --> > </div> <!-- /.col-sm-6 --> > </div> <!-- /.row --> >+ [% IF additional_fields && additional_field_values %] >+ <div class="rows page-section"> >+ <h2>Additional fields</h2> >+ [% INCLUDE 'additional-fields-display.inc' available=additional_fields values=additional_field_values %] >+ </div> >+ [% END %] > [% IF OpacLibraryInfo %]<!-- opac_info --> > <div class="row page-section"> > <div class="col-sm-12"> >@@ -626,6 +633,7 @@ > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/admin-menu.js") | $raw %] >+ [% Asset.js("js/additional-fields-entry.js") | $raw %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'columns_settings.inc' %] >-- >2.39.5
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 38663
:
175355
|
175356
|
175357
|
175358
|
175359
| 175370