Bugzilla – Attachment 34783 Details for
Bug 11023
Automatic item modification by age (Was "Toggle new status for items")
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11023: Add the ability to specify fields from biblioitems table.
Bug-11023-Add-the-ability-to-specify-fields-from-b.patch (text/plain), 6.62 KB, created by
Jonathan Druart
on 2014-12-29 10:22:16 UTC
(
hide
)
Description:
Bug 11023: Add the ability to specify fields from biblioitems table.
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-12-29 10:22:16 UTC
Size:
6.62 KB
patch
obsolete
>From 2e76c286d50eec623f4a87812c902b4ca587dcdf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 5 Nov 2013 17:20:04 +0100 >Subject: [PATCH] Bug 11023: Add the ability to specify fields from biblioitems > table. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: >Same as before but try with fields from the biblioitems table. > >Signed-off-by: juliette et rémy <juliette.levast@iepg.fr> >--- > C4/Items.pm | 48 ++++++++++++++++++++-- > .../prog/en/modules/tools/toggle_new_status.tt | 20 ++++----- > tools/toggle_new_status.pl | 4 +- > 3 files changed, 58 insertions(+), 14 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index c4d55e7..0036ede 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -3092,6 +3092,39 @@ sub columns { > return @data; > } > >+=head2 biblioitems_columns >+ >+ my @columns = C4::Items::biblioitems_columns(); >+ >+Returns an array of biblioitems' table columns on success, >+and an empty array on failure. >+ >+=cut >+ >+sub biblioitems_columns { >+ # Pure ANSI SQL goodness. >+ my $sql = 'SELECT * FROM biblioitems WHERE 1=0;'; >+ >+ # Get the database handle. >+ my $dbh = C4::Context->dbh; >+ >+ # Run the SQL statement to load STH's readonly properties. >+ my $sth = $dbh->prepare($sql); >+ my $rv = $sth->execute(); >+ >+ # This only fails if the table doesn't exist. >+ # This will always be called AFTER an install or upgrade, >+ # so borrowers will exist! >+ my @data; >+ if ($sth->{NUM_OF_FIELDS}>0) { >+ @data = @{$sth->{NAME}}; >+ } >+ else { >+ @data = (); >+ } >+ return @data; >+} >+ > sub ToggleNewStatus { > my ( $params ) = @_; > my @rules = @{ $params->{rules} }; >@@ -3099,7 +3132,8 @@ sub ToggleNewStatus { > > my $dbh = C4::Context->dbh; > my @errors; >- my @items_columns = C4::Items::columns; >+ my @item_columns = map { "items.$_" } C4::Items::columns; >+ my @biblioitem_columns = map { "biblioitems.$_" } C4::Items::biblioitems_columns; > my $report; > for my $rule ( @rules ) { > my $duration = $rule->{duration}; >@@ -3107,9 +3141,17 @@ sub ToggleNewStatus { > my $substitutions = $rule->{substitutions}; > my @params; > >- my $query = q|SELECT biblionumber, itemnumber FROM items WHERE 1 |; >+ my $query = q| >+ SELECT items.biblionumber, items.itemnumber >+ FROM items >+ LEFT JOIN biblioitems ON items.biblioitemnumber = items.itemnumber >+ WHERE 1 >+ |; > for my $condition ( @$conditions ) { >- if ( grep {/^$condition->{field}$/} @items_columns ) { >+ if ( >+ grep {/^$condition->{field}$/} @item_columns >+ or grep {/^$condition->{field}$/} @biblioitem_columns >+ ) { > if ( $condition->{value} =~ /\|/ ) { > my @values = split /\|/, $condition->{value}; > $query .= qq| AND $condition->{field} IN (| >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt >index d1a0d2e..8a0d5ae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt >@@ -155,11 +155,11 @@ > <div class="block"> > <select name="condition_field_[% id %]"> > <option value="">Choose a field name</option> >- [% FOR field IN item_fields %] >+ [% FOR field IN fields %] > [% IF condition.field == field %] >- <option value="[% field %]" selected="selected">items.[% field %]</option> >+ <option value="[% field %]" selected="selected">[% field %]</option> > [% ELSE %] >- <option value="[% field %]">items.[% field %]</option> >+ <option value="[% field %]">[% field %]</option> > [% END %] > [% END %] > </select> >@@ -176,11 +176,11 @@ > <div class="block"> > <select name="substitution_field_[% id %]"> > <option value="">Choose a field name</option> >- [% FOR field IN item_fields %] >+ [% FOR field IN fields %] > [% IF substitution.field == field %] >- <option value="[% field %]" selected="selected">items.[% field %]</option> >+ <option value="[% field %]" selected="selected">[% field %]</option> > [% ELSE %] >- <option value="[% field %]">items.[% field %]</option> >+ <option value="[% field %]">[% field %]</option> > [% END %] > [% END %] > </select> >@@ -217,8 +217,8 @@ > <div class="block"> > <select name="condition_field"> > <option value="">Choose a field name</option> >- [% FOR field IN item_fields %] >- <option value="[% field %]">items.[% field %]</option> >+ [% FOR field IN fields %] >+ <option value="[% field %]">[% field %]</option> > [% END %] > </select> > = >@@ -232,8 +232,8 @@ > <div class="block"> > <select name="substitution_field"> > <option value="">Choose a field name</option> >- [% FOR field IN item_fields %] >- <option value="[% field %]">items.[% field %]</option> >+ [% FOR field IN fields %] >+ <option value="[% field %]">[% field %]</option> > [% END %] > </select> > = >diff --git a/tools/toggle_new_status.pl b/tools/toggle_new_status.pl >index 9b7bf02..c7b88d4 100755 >--- a/tools/toggle_new_status.pl >+++ b/tools/toggle_new_status.pl >@@ -106,10 +106,12 @@ if ( $@ ) { > exit; > } > >+my @item_fields = map { "items.$_" } C4::Items::columns; >+my @biblioitem_fields = map { "biblioitems.$_" } C4::Items::biblioitems_columns; > $template->param( > op => $op, > messages => \@messages, >- item_fields => [ C4::Items::columns ], >+ fields => [ @item_fields, @biblioitem_fields ], > rules => $rules, > ); > >-- >2.1.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 11023
:
21926
|
21932
|
21982
|
21983
|
22004
|
22386
|
22734
|
22735
|
24068
|
24069
|
24070
|
24146
|
24147
|
24148
|
25767
|
25833
|
26817
|
26818
|
26819
|
26820
|
26821
|
26822
|
26855
|
27810
|
29216
|
29217
|
29218
|
29219
|
29220
|
29221
|
29222
|
31820
|
31821
|
31822
|
33226
|
33227
|
33228
|
33229
|
33230
|
33231
|
33232
|
33233
|
33234
|
33235
|
34782
|
34783
|
34784
|
34785
|
34786
|
34787
|
34788
|
34789
|
34790
|
34791
|
34870
|
34871
|
34872
|
34873
|
34874
|
34875
|
34876
|
34877
|
34878
|
34879
|
34880
|
34881
|
34882
|
34883
|
35375
|
35376
|
41147
|
41148