From 511932d2606f67d35cf5dc17554777f611efb6f4 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Fri, 1 Nov 2024 15:17:52 +0000 Subject: [PATCH] Bug 32773: Add fast cataloging support for multiple frameworks This set of patches adds a new is_fast_add column to biblio_framework. In Admin > MARC bibliographic frameworks admin users can add or edit frameworks to be used as Fast Add frameworks. Users with only fast_cataloging permission will be able to add records using those frameworks in the Fast Cataloging module. Test plan: Apply patches, restart_all and updatedatabase 1. Go to Admin > MARC Bibliographic frameworks 2. Edit/create a new framework and check the 'Use as Fast Add Framework' box 3. Also edit a framework and uncheck the 'Use as Fast Add Framework' box 4. Notice a 'Fast Add' badge is displayed in the table 5. Create a staff user with only fast_cataloging permissions 6. Log in as that user and go to Cataloging > Fast Cataloging 7. Confirm you can add a Fast Add record and items 8. Use the 'Settings' drop down to Change Fast Add framework 9. Confirm you see the frameworks that you set as Fast Add earlier 10. Confirm you can add the reocord and items 11. Log in as a superlibrarian and confirm that you can add records and items using standard frameworks and frameworks set as fast add Sponsored-by: CLAMS --- cataloguing/addbiblio.pl | 12 +++++++++--- cataloguing/additem.pl | 19 ++++++++++++------- .../prog/en/modules/cataloguing/addbiblio.tt | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 985bede9a8..8e513c0cda 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -519,8 +519,13 @@ $op = $input->param('op') // q{}; $frameworkcode = &GetFrameworkCode($biblionumber) if ( $biblionumber and not( defined $frameworkcode) and $op ne 'cud-addbiblio' ); +my $is_fast_add = + defined $frameworkcode && $frameworkcode ne '' + ? Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add + : 0; + my $userflags = - $frameworkcode eq 'FA' + $frameworkcode eq 'FA' || $is_fast_add ? [ 'fast_cataloging', 'edit_catalogue' ] : 'edit_catalogue'; @@ -567,7 +572,7 @@ if ($biblionumber) { } } -if ($frameworkcode eq 'FA'){ +if ($frameworkcode eq 'FA' || $is_fast_add){ # We need to grab and set some variables in the template for use on the additems screen $template->param( 'circborrowernumber' => $fa_circborrowernumber, @@ -721,7 +726,7 @@ if ( $op eq "cud-addbiblio" ) { ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode ); } if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){ - if ($frameworkcode eq 'FA'){ + if ($frameworkcode eq 'FA' || $is_fast_add){ print $input->redirect( '/cgi-bin/koha/cataloguing/additem.pl?' .'biblionumber='.$biblionumber @@ -861,6 +866,7 @@ if ( $record ne '-1' ) { $template->param( popup => $mode, frameworkcode => $frameworkcode, + is_fast_add => $is_fast_add, itemtype => $frameworkcode, borrowernumber => $loggedinuser, tab => scalar $input->param('tab') diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 3d361ec1e6..f4203f1996 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -33,10 +33,10 @@ use C4::Members; use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); use C4::Search qw( enabled_staff_search_views ); use Koha::Biblios; +use Koha::BiblioFrameworks; use Koha::Item::Templates; use Koha::ItemTypes; use Koha::Items; -use Koha::Items; use Koha::Libraries; use Koha::Patrons; use Koha::SearchEngine::Indexer; @@ -143,14 +143,19 @@ my $display_order = $input->param('item_group_display_order'); our $frameworkcode = &GetFrameworkCode($biblionumber); +my $is_fast_add = + defined $frameworkcode && $frameworkcode ne '' + ? Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add + : 0; + # Defining which userflag is needing according to the framework currently used my $userflags; if ( defined $input->param('frameworkcode') ) { - $userflags = ( $input->param('frameworkcode') eq 'FA' ) ? "fast_cataloging" : "edit_items"; + $userflags = ( $input->param('frameworkcode') eq 'FA' || $is_fast_add ) ? "fast_cataloging" : "edit_items"; } if ( not defined $userflags ) { - $userflags = ( $frameworkcode eq 'FA' ) ? "fast_cataloging" : "edit_items"; + $userflags = ( $frameworkcode eq 'FA' || $is_fast_add ) ? "fast_cataloging" : "edit_items"; } my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -188,7 +193,7 @@ $restrictededition = 0 if ( $restrictededition != 0 && C4::Context->IsSuperLibra # In case user has fast cataloging permission (and we're in fast cataloging), editing is not restricted $restrictededition = 0 if ( $restrictededition != 0 - && $frameworkcode eq 'FA' + && ($frameworkcode eq 'FA' || $is_fast_add) && haspermission( $uid, { 'editcatalogue' => 'fast_cataloging' } ) ); our $tagslib = &GetMarcStructure( 1, $frameworkcode ); @@ -488,7 +493,7 @@ if ( $op eq "cud-additem" ) { undef($current_item); } } - if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) { + if ( ($frameworkcode eq 'FA' || $is_fast_add) && $fa_circborrowernumber ) { print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?' . 'borrowernumber=' . $fa_circborrowernumber @@ -781,7 +786,7 @@ my $subfields = } ); -if ( $frameworkcode eq 'FA' ) { +if ( $frameworkcode eq 'FA' || $is_fast_add ) { my ($barcode_field) = grep { $_->{kohafield} eq 'items.barcode' } @$subfields; $barcode_field->{marc_value}->{value} ||= $input->param('barcode'); } @@ -811,7 +816,7 @@ $template->param( ); $template->{'VARS'}->{'searchid'} = $searchid; -if ( $frameworkcode eq 'FA' ) { +if ( $frameworkcode eq 'FA' || $is_fast_add ) { # fast cataloguing datas $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 991a53c007..507fc5857c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -912,7 +912,7 @@ $(document).ready(function(){ [% END %]
- [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] + [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' || is_fast_add and CAN_user_editcatalogue_fast_cataloging ) %] [% IF (circborrowernumber) %][%# fast cataloging must lead to items %] -- 2.39.5