Bugzilla – Attachment 83776 Details for
Bug 22098
The stocknumberAV cataloguing plugin should be updated to use Koha::Objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22098: Update stocknumberAV cataloguing plugin to use objects
Bug-22098-Update-stocknumberAV-cataloguing-plugin-.patch (text/plain), 3.91 KB, created by
Josef Moravec
on 2019-01-11 09:33:38 UTC
(
hide
)
Description:
Bug 22098: Update stocknumberAV cataloguing plugin to use objects
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-01-11 09:33:38 UTC
Size:
3.91 KB
patch
obsolete
>From 72181098c9c37a2b3cdc80b43a1c48ed386545a0 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Fri, 11 Jan 2019 09:25:00 +0000 >Subject: [PATCH] Bug 22098: Update stocknumberAV cataloguing plugin to use > objects > >This patch: >- changes SQL to Koha::AuthorisedValues >- remove type param from script tag >- fixes the plugin description > >0) Do not apply the patch >1) Set the plugin >1.1) Update a biblio framework and link plugin stocknumberAV.pl to some item >subfield >1.2) Add authorised values category called "INVENTORY" >1.3) Add some authorised values: authorised value is prefix and >description is a current stock/inventory number >2) Add an item and try to use this plugin to ensure you set it >correctly >2.1) Use a defined prefix to see if the number is correct >2.2) Ensure the number is correctly incremented in authorised values >2.3) Use not defined prefix to see the error message >2.4) Insert a not prefix string (eg number) to see it is not changed >3) Apply the patch >4) Repeat 2) and see it is working the same >5) Look into patch and confirm the description does make sense and is >rigth according to what you see in UI >6) Sign off :D >--- > cataloguing/value_builder/stocknumberAV.pl | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) > >diff --git a/cataloguing/value_builder/stocknumberAV.pl b/cataloguing/value_builder/stocknumberAV.pl >index ac9d41f537..395623eea6 100755 >--- a/cataloguing/value_builder/stocknumberAV.pl >+++ b/cataloguing/value_builder/stocknumberAV.pl >@@ -23,18 +23,18 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > > use C4::Auth; >-use C4::Context; > use C4::Output; >+use Koha::AuthorisedValues; > > =head1 DESCRIPTION > > This plugin is based on authorised values INVENTORY. > It is used for stocknumber computation. > >-If the user send an empty string, we return a simple incremented stocknumber. >+If no prefix is submitted, or prefix does not contain only nubers, it returns the inserted code (= keep a field unchanged) > If a prefix is submited, we look for the highest stocknumber with this prefix, and return it incremented. > In this case, a stocknumber has this form : "PREFIX 0009678570". >- - PREFIX is an upercase word >+ - PREFIX contains of letters > - a space separator > - 10 digits, with leading 0s if needed > >@@ -43,7 +43,7 @@ In this case, a stocknumber has this form : "PREFIX 0009678570". > my $builder = sub { > my ( $params ) = @_; > my $res = qq{ >- <script type='text/javascript'> >+ <script> > function Click$params->{id}() { > var code = document.getElementById('$params->{id}'); > \$.ajax({ >@@ -81,20 +81,19 @@ my $launcher = sub { > } > ); > >- my $dbh = C4::Context->dbh; >- > # 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 $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category='INVENTORY' AND authorised_value=?"); >- $sth->execute( $code); >- >- if ( my $valeur = $sth->fetchrow ) { >- $template->param( return => $code . ' ' . sprintf( '%010s', ( $valeur + 1 ) ), ); >- my $sth2 = $dbh->prepare("UPDATE authorised_values SET lib=? WHERE category='INVENTORY' AND authorised_value=?"); >- $sth2->execute($valeur+1,$code); >+ 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"); >+ $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 { >-- >2.11.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 22098
:
83776
|
91421
|
101329
|
101330
|
101373
|
101374
|
101375
|
101376