From a30fe6ea805af3a8a07a116eef5babe7bf367e1f Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 1 May 2024 23:33:47 +0200 Subject: [PATCH] Bug 36372: provide an interface to set the source of a record from the staff interface --- cataloguing/record_source.pl | 62 +++++++++++++++++++ .../prog/en/includes/cat-toolbar.inc | 8 ++- .../en/modules/cataloguing/record_source.tt | 40 ++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 cataloguing/record_source.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/record_source.tt diff --git a/cataloguing/record_source.pl b/cataloguing/record_source.pl new file mode 100644 index 00000000000..ffd141321bf --- /dev/null +++ b/cataloguing/record_source.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# Copyright 2004-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, see . + +use Modern::Perl; + +use CGI; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user haspermission ); +use C4::Biblio qw( ModBiblio ); +use C4::Context; +use Koha::DateUtils qw( dt_from_string ); +use Koha::Biblios; +use Koha::RecordSources; +use URI::Escape qw( uri_escape_utf8 ); + +# ======================== +# MAIN +#========================= +my $input = CGI->new; +my $biblionumber = $input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio. +my $record_source_id = $input->param('record_source_id') // ''; +my $save = $input->param('save') // ''; + +if ($save ne '') { + my $biblio = Koha::Biblios->find($biblionumber); + $biblio->metadata->set({record_source_id => $record_source_id})->store; + print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); +} + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "cataloguing/record_source.tt", + query => $input, + type => "intranet", + flagsrequired => { editcatalogue => 'set_record_sources' }, + }); + +my $record_sources = Koha::RecordSources->search(); + +$template->param( + biblionumber => $biblionumber, + record_sources => $record_sources, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 7b3582172fb..93780da78f3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -35,7 +35,7 @@ [% END %] -[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] +[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_editcatalogue_set_record_sources ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]