From d2f3d6a9a5f8292c6e437a4ba60e703bceb3cfba Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 21 Feb 2024 02:51:25 +0000 Subject: [PATCH] Bug 35067: [WIP] --- cataloguing/value_builder/multipleAV.pl | 95 +++++++++++++++++++ .../cataloguing/value_builder/multipleAV.tt | 46 +++++++++ 2 files changed, 141 insertions(+) create mode 100755 cataloguing/value_builder/multipleAV.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/multipleAV.tt diff --git a/cataloguing/value_builder/multipleAV.pl b/cataloguing/value_builder/multipleAV.pl new file mode 100755 index 00000000000..17ff0b4cb65 --- /dev/null +++ b/cataloguing/value_builder/multipleAV.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Copyright 2024 Aleisha Amohia +# +# 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 qw ( -utf8 ); + +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::AuthorisedValues; + +=head1 DESCRIPTION + +This plugin allows the cataloguer to choose one or more authorised value categories that should be available for selection in the dropdown for this subfield. + +=cut + +my $builder = sub { + my ( $params ) = @_; + my $res = qq{ + + }; + + return $res; +}; + +my $launcher = sub { + my ( $params ) = @_; + my $input = $params->{cgi}; + my $code = $input->param('code'); + + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "cataloguing/value_builder/ajax.tt", + query => $input, + type => "intranet", + flagsrequired => { editcatalogue => '*' }, + } + ); + + # If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented + $code =~ s/ *$//g; + if ( $code =~ m/^[a-zA-Z]+$/ ) { + my $av = Koha::AuthorisedValues->find({ + 'category' => 'INVENTORY', + 'authorised_value' => $code + }); + if ( $av ) { + $av->lib($av->lib + 1); + $av->store; + $template->param( return => $code . ' ' . sprintf( '%010s', ( $av->lib ) ), ); + } else { + $template->param( return => "There is no defined value for $code"); + } + # The user entered a custom value, we don't touch it, this could be handled in js + } else { + $template->param( return => $code, ); + } + + output_html_with_http_headers $input, $cookie, $template->output; +}; + +return { builder => $builder, launcher => $launcher }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/multipleAV.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/multipleAV.tt new file mode 100644 index 00000000000..c11ed17de09 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/multipleAV.tt @@ -0,0 +1,46 @@ +[% USE raw %] +[% USE Koha %] +[% PROCESS 'i18n.inc' %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +[% FILTER collapse %] + [% t("Multiple authorised values dropdown builder") | html %] › + [% t("Cataloging") | html %] › + [% t("Koha") | html %] +[% END %] +[% INCLUDE 'doc-head-close.inc' %] + + + +
+ +

Multiple authorised values dropdown builder

+ +
+
+
+ +[% MACRO jsinclude BLOCK %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' popup_window=1 %] -- 2.30.2