Bugzilla – Attachment 35214 Details for
Bug 10855
Custom fields for subscriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10855: New fields on adding/updating a subscription
Bug-10855-New-fields-on-addingupdating-a-subscript.patch (text/plain), 10.10 KB, created by
Jonathan Druart
on 2015-01-14 15:32:02 UTC
(
hide
)
Description:
Bug 10855: New fields on adding/updating a subscription
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-01-14 15:32:02 UTC
Size:
10.10 KB
patch
obsolete
>From 5e1641f00df23b24c8f37e1a4dcd43ea042f153f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 29 Aug 2013 13:37:40 +0200 >Subject: [PATCH] Bug 10855: New fields on adding/updating a subscription > >This patch adds the ability to add values for additional fields when >adding/updating a subscription. > >Test plan (test the following on adding a new subscription and on >editing an existent one): >- add/edit a subscription. >- verify all additional fields appears into the "Additional fields" > block. >- fill a value for af1 and af3. >- fill others values if you are adding a new subscription. >- save. >- verify values appears on the detail of the subscription page. >- verify the af2 field is automatically filled with the specified > marc field of the notice. >--- > C4/Serials.pm | 10 ++++++ > .../prog/en/modules/serials/subscription-add.tt | 34 ++++++++++++++++++ > .../prog/en/modules/serials/subscription-detail.tt | 25 ++++++++++++- > serials/subscription-add.pl | 41 ++++++++++++++++++++++ > serials/subscription-detail.pl | 8 +++++ > 5 files changed, 117 insertions(+), 1 deletion(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index d127066..072c317 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -31,6 +31,7 @@ use C4::Log; # logaction > use C4::Debug; > use C4::Serials::Frequency; > use C4::Serials::Numberpattern; >+use Koha::AdditionalField; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -351,7 +352,16 @@ sub GetSubscription { > my $sth = $dbh->prepare($query); > $sth->execute($subscriptionid); > my $subscription = $sth->fetchrow_hashref; >+ > $subscription->{cannotedit} = not can_edit_subscription( $subscription ); >+ >+ # Add additional fields to the subscription into a new key "additional_fields" >+ my $additional_field_values = Koha::AdditionalField->fetch_all_values({ >+ tablename => 'subscription', >+ record_id => $subscriptionid, >+ }); >+ $subscription->{additional_fields} = $additional_field_values->{$subscriptionid}; >+ > return $subscription; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index 8401968..7150dd5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -821,6 +821,40 @@ $(document).ready(function() { > </div> > </ol> > </fieldset> >+ >+ [% IF additional_fields_for_subscription %] >+ <div id="subscription_additional_fields"> >+ <fieldset class="rows"> >+ <legend>Additional fields</legend> >+ <ol> >+ [% FOR field IN additional_fields_for_subscription %] >+ <li> >+ <label for="additional_fields_[% field.name %]"> [% field.name %]: </label> >+ [% IF field.authorised_value_choices %] >+ <select name="additional_fields_[% field.name %]"> >+ [% FOREACH av IN field.authorised_value_choices %] >+ [% IF av.authorised_value == additional_fields.${field.name} %] >+ <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option> >+ [% ELSE %] >+ <option value="[% av.authorised_value %]">[% av.lib %]</option> >+ [% END %] >+ [% END %] >+ </select> (Authorised values for [% field.authorised_value_category %]) >+ [% ELSE %] >+ [% IF field.marcfield %] >+ <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" readonly="readonly" /> >+ This value will be filled with the [% field.marcfield %] subfield of the selected biblio. >+ [% ELSE %] >+ <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" /> >+ [% END %] >+ [% END %] >+ </li> >+ [% END %] >+ </ol> >+ </fieldset> >+ </div> >+ [% END %] >+ > <fieldset class="action"> > <input type="button" value="<< Previous" onclick="show_page_1();" style="float:left;"/> > <input id="testpatternbutton" type="button" value="Test prediction pattern" onclick="testPredictionPattern();" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index b684e5e..9222779 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -1,4 +1,5 @@ > [% USE Branches %] >+[% USE KohaAuthorisedValues %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials › Details for subscription #[% subscriptionid %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -122,7 +123,29 @@ $(document).ready(function() { > </ol> > </div> > </div> >-</div> >+ </div> >+ >+ [% IF additional_fields_for_subscription %] >+ <div class="yui-g"> >+ <div class="yui-u first"> >+ <div class="rows"> >+ <legend>Additional fields:</legend> >+ <ol> >+ [% FOR field IN additional_fields_for_subscription %] >+ <li> >+ <span class="label">[% field.name %]:</span> >+ [% IF field.authorised_value_category %] >+ [% KohaAuthorisedValues.GetByCode( field.authorised_value_category, additional_fields.${field.name} ) %] >+ [% ELSE %] >+ [% additional_fields.${field.name} %] >+ [% END %] >+ </li> >+ [% END %] >+ </ol> >+ </div> >+ </div> >+ </div> >+ [% END %] > </div> > > <div id="subscription_planning"> >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index fa75f06..cf6ac58 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -32,6 +32,7 @@ use C4::Serials; > use C4::Serials::Frequency; > use C4::Serials::Numberpattern; > use C4::Letters; >+use Koha::AdditionalField; > use Carp; > > #use Smart::Comments; >@@ -153,6 +154,16 @@ my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); > $template->param(branchloop => $branchloop, > locations_loop=>$locations_loop, > ); >+ >+ >+my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } ); >+for my $field ( @$additional_fields ) { >+ if ( $field->{authorised_value_category} ) { >+ $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} ); >+ } >+} >+$template->param( additional_fields_for_subscription => $additional_fields ); >+ > # prepare template variables common to all $op conditions: > if ($op!~/^mod/) { > my $letters = get_letter_loop(); >@@ -341,6 +352,16 @@ sub redirect_add_subscription { > $skip_serialseq > ); > >+ my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } ); >+ my @additional_field_values; >+ for my $field ( @$additional_fields ) { >+ my $af = Koha::AdditionalField->new({ id => $field->{id} }); >+ $af->{values} = { >+ $subscriptionid => $query->param('additional_fields_' . $field->{name}) >+ }; >+ $af->insert_values; >+ } >+ > print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); > return; > } >@@ -416,6 +437,26 @@ sub redirect_mod_subscription { > $skip_serialseq > ); > >+ my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } ); >+ my @additional_field_values; >+ for my $field ( @$additional_fields ) { >+ my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch; >+ if ( $af->{marcfield} ) { >+ my $record = GetMarcBiblio( $biblionumber, 1 ); >+ my ( $field, $subfield ) = split /\$/, $af->{marcfield}; >+ next unless $field and $subfield; >+ my $value = $record->subfield( $field, $subfield ); >+ $af->{values} = { >+ $subscriptionid => $value >+ }; >+ } else { >+ $af->{values} = { >+ $subscriptionid => $query->param('additional_fields_' . $field->{name}) >+ }; >+ } >+ $af->insert_values; >+ } >+ > print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); > return; > } >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index ebdc415..be1a3a7 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -139,6 +139,14 @@ if ( defined $subscriptionid ) { > } > } > >+my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); >+for my $field ( @$additional_fields ) { >+ if ( $field->{authorised_value_category} ) { >+ $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} ); >+ } >+} >+$template->param( additional_fields_for_subscription => $additional_fields ); >+ > $template->param( > subscriptionid => $subscriptionid, > serialslist => \@serialslist, >-- >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 10855
:
20937
|
20938
|
20939
|
20940
|
20941
|
20942
|
20943
|
20944
|
21184
|
21185
|
21186
|
21187
|
21188
|
21189
|
21190
|
21191
|
21663
|
22049
|
22050
|
22051
|
22052
|
22053
|
22054
|
22055
|
22056
|
22057
|
22359
|
22360
|
22600
|
22601
|
22602
|
22603
|
22604
|
22605
|
22606
|
22607
|
22608
|
22616
|
22698
|
22699
|
22700
|
22701
|
22702
|
22703
|
22722
|
22768
|
22769
|
22869
|
23052
|
23053
|
23142
|
23143
|
23301
|
23302
|
23594
|
23595
|
23596
|
23597
|
23598
|
23599
|
23600
|
23601
|
23602
|
23774
|
23775
|
23961
|
23962
|
23963
|
23964
|
24452
|
24453
|
24454
|
24455
|
24456
|
24457
|
24569
|
24570
|
26091
|
26092
|
26093
|
26094
|
26095
|
26096
|
26097
|
26254
|
26255
|
26256
|
26257
|
26258
|
26259
|
26260
|
26276
|
26651
|
26655
|
28929
|
28930
|
28931
|
28932
|
28933
|
28934
|
28935
|
28936
|
28937
|
28938
|
28939
|
28940
|
28941
|
29095
|
29161
|
35211
|
35212
|
35213
|
35214
|
35215
|
35216
|
35217
|
35218
|
35219
|
35220
|
35221
|
35309
|
35310
|
35369
|
35556
|
36359
|
36362
|
36363
|
36364
|
36365
|
36366
|
36367
|
36368
|
36369
|
36370
|
36371
|
36372
|
36373
|
36374
|
38549
|
38550
|
38551
|
38552
|
38553
|
38554
|
38555
|
38556
|
38557
|
38558
|
38559
|
38560
|
38561
|
42296
|
42297
|
42298
|
42299
|
42300
|
42301
|
42302
|
42303
|
42304
|
42305
|
42306
|
42307
|
42308
|
42309
|
42310
|
42332
|
42333
|
43076