Bugzilla – Attachment 22053 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), 9.80 KB, created by
Jonathan Druart
on 2013-10-18 14:28:51 UTC
(
hide
)
Description:
Bug 10855: New fields on adding/updating a subscription
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-10-18 14:28:51 UTC
Size:
9.80 KB
patch
obsolete
>From 55c676dbf6a7d768937b839a9a046c5b3607959e 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 | 12 +++++- > .../prog/en/modules/serials/subscription-add.tt | 33 +++++++++++++++ > .../prog/en/modules/serials/subscription-detail.tt | 25 ++++++++++- > serials/subscription-add.pl | 44 ++++++++++++++++++++ > serials/subscription-detail.pl | 8 ++++ > 5 files changed, 120 insertions(+), 2 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index a2498c8..9b551f2 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -26,6 +26,7 @@ use POSIX qw(strftime); > use C4::Biblio; > use C4::Log; # logaction > use C4::Debug; >+use Koha::AdditionalField; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -345,7 +346,16 @@ sub GetSubscription { > $debug and warn "query : $query\nsubsid :$subscriptionid"; > my $sth = $dbh->prepare($query); > $sth->execute($subscriptionid); >- return $sth->fetchrow_hashref; >+ my $subscription = $sth->fetchrow_hashref; >+ >+ # 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, >+ }); >+ my %sub = ( %$subscription, additional_fields => $additional_field_values->{$subscriptionid} ); >+ >+ return \%sub > } > > =head2 GetFullSubscription >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 14f01ef..fd4b8cf 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 >@@ -1130,6 +1130,39 @@ $(document).ready(function() { > <fieldset class="action"><input type="submit" value="Save subscription history" /></fieldset> > </div> > >+[% 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 %] >+ > <div id="subscription_form_planning"> > <fieldset class="rows"> > <legend>Serials planning</legend> >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 959f14f..ae1f7e0 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 KohaBranchName %] >+[% USE KohaAuthorisedValues %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials › Details for subscription #[% subscriptionid %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -129,7 +130,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 1959b23..2f04d2b 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -30,6 +30,7 @@ use C4::Context; > use C4::Branch; # GetBranches > use C4::Serials; > use C4::Letters; >+use Koha::AdditionalField; > use Carp; > > #use Smart::Comments; >@@ -141,6 +142,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/) { > letter_loop(q{}, $template); >@@ -256,6 +267,7 @@ sub redirect_add_subscription { > my $missinglist = $query->param('missinglist'); > my $opacnote = $query->param('opacnote'); > my $librariannote = $query->param('librariannote'); >+ > my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, > $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, > $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, >@@ -267,6 +279,16 @@ sub redirect_add_subscription { > ); > ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote); > >+ 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; > } >@@ -352,6 +374,28 @@ sub redirect_mod_subscription { > $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid > ); > ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote); >+ >+ >+ 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 fc57d89..dd336fd 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -155,6 +155,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, >-- >1.7.10.4
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