View | Details | Raw Unified | Return to bug 10855
Collapse All | Expand All

(-)a/C4/Serials.pm (+10 lines)
Lines 30-35 use C4::Log; # logaction Link Here
30
use C4::Debug;
30
use C4::Debug;
31
use C4::Serials::Frequency;
31
use C4::Serials::Frequency;
32
use C4::Serials::Numberpattern;
32
use C4::Serials::Numberpattern;
33
use Koha::AdditionalField;
33
34
34
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
35
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
35
36
Lines 346-352 sub GetSubscription { Link Here
346
    my $sth = $dbh->prepare($query);
347
    my $sth = $dbh->prepare($query);
347
    $sth->execute($subscriptionid);
348
    $sth->execute($subscriptionid);
348
    my $subscription = $sth->fetchrow_hashref;
349
    my $subscription = $sth->fetchrow_hashref;
350
349
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
351
    $subscription->{cannotedit} = not can_edit_subscription( $subscription );
352
353
    # Add additional fields to the subscription into a new key "additional_fields"
354
    my $additional_field_values = Koha::AdditionalField->fetch_all_values({
355
            tablename => 'subscription',
356
            record_id => $subscriptionid,
357
    });
358
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
359
350
    return $subscription;
360
    return $subscription;
351
}
361
}
352
362
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+34 lines)
Lines 835-840 $(document).ready(function() { Link Here
835
                                    </div>
835
                                    </div>
836
                                </ol>
836
                                </ol>
837
                            </fieldset>
837
                            </fieldset>
838
839
                            [% IF additional_fields_for_subscription %]
840
                              <div id="subscription_additional_fields">
841
                                <fieldset class="rows">
842
                                  <legend>Additional fields</legend>
843
                                  <ol>
844
                                    [% FOR field IN additional_fields_for_subscription %]
845
                                      <li>
846
                                        <label for="additional_fields_[% field.name %]"> [% field.name %]: </label>
847
                                        [% IF field.authorised_value_choices %]
848
                                          <select name="additional_fields_[% field.name %]">
849
                                            [% FOREACH av IN field.authorised_value_choices %]
850
                                              [% IF av.authorised_value == additional_fields.${field.name} %]
851
                                                <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option>
852
                                              [% ELSE %]
853
                                                <option value="[% av.authorised_value %]">[% av.lib %]</option>
854
                                              [% END %]
855
                                            [% END %]
856
                                          </select> (Authorised values for [% field.authorised_value_category %])
857
                                        [% ELSE %]
858
                                          [% IF field.marcfield %]
859
                                            <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" readonly="readonly" />
860
                                            This value will be filled with the [% field.marcfield %] subfield of the selected biblio.
861
                                          [% ELSE %]
862
                                            <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" />
863
                                          [% END %]
864
                                        [% END %]
865
                                      </li>
866
                                    [% END %]
867
                                  </ol>
868
                                </fieldset>
869
                              </div>
870
                            [% END %]
871
838
                            <fieldset class="action">
872
                            <fieldset class="action">
839
                                <input type="button" value="<< Previous" onclick="show_page_1();" style="float:left;"/>
873
                                <input type="button" value="<< Previous" onclick="show_page_1();" style="float:left;"/>
840
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" onclick="testPredictionPattern();" />
874
                                <input id="testpatternbutton" type="button" value="Test prediction pattern" onclick="testPredictionPattern();" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-1 / +24 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE KohaAuthorisedValues %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Serials &rsaquo; Details for subscription #[% subscriptionid %]</title>
4
<title>Koha &rsaquo; Serials &rsaquo; Details for subscription #[% subscriptionid %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 122-128 $(document).ready(function() { Link Here
122
     </ol>
123
     </ol>
123
     </div>
124
     </div>
124
     </div>
125
     </div>
125
</div>
126
     </div>
127
128
     [% IF additional_fields_for_subscription %]
129
    <div class="yui-g">
130
      <div class="yui-u first">
131
        <div class="rows">
132
          <legend>Additional fields:</legend>
133
          <ol>
134
            [% FOR field IN additional_fields_for_subscription %]
135
              <li>
136
                <span class="label">[% field.name %]:</span>
137
                [% IF field.authorised_value_category %]
138
                  [% KohaAuthorisedValues.GetByCode( field.authorised_value_category, additional_fields.${field.name} ) %]
139
                [% ELSE %]
140
                  [% additional_fields.${field.name} %]
141
                [% END %]
142
              </li>
143
            [% END %]
144
          </ol>
145
        </div>
146
      </div>
147
      </div>
148
     [% END %]
126
</div>
149
</div>
127
150
128
    <div id="subscription_planning">
151
    <div id="subscription_planning">
(-)a/serials/subscription-add.pl (+41 lines)
Lines 32-37 use C4::Serials; Link Here
32
use C4::Serials::Frequency;
32
use C4::Serials::Frequency;
33
use C4::Serials::Numberpattern;
33
use C4::Serials::Numberpattern;
34
use C4::Letters;
34
use C4::Letters;
35
use Koha::AdditionalField;
35
use Carp;
36
use Carp;
36
37
37
#use Smart::Comments;
38
#use Smart::Comments;
Lines 152-157 my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); Link Here
152
$template->param(branchloop => $branchloop,
153
$template->param(branchloop => $branchloop,
153
    locations_loop=>$locations_loop,
154
    locations_loop=>$locations_loop,
154
);
155
);
156
157
158
my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
159
for my $field ( @$additional_fields ) {
160
    if ( $field->{authorised_value_category} ) {
161
        $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} );
162
    }
163
}
164
$template->param( additional_fields_for_subscription => $additional_fields );
165
155
# prepare template variables common to all $op conditions:
166
# prepare template variables common to all $op conditions:
156
if ($op!~/^mod/) {
167
if ($op!~/^mod/) {
157
    letter_loop(q{}, $template);
168
    letter_loop(q{}, $template);
Lines 338-343 sub redirect_add_subscription { Link Here
338
        $skip_serialseq
349
        $skip_serialseq
339
    );
350
    );
340
351
352
    my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
353
    my @additional_field_values;
354
    for my $field ( @$additional_fields ) {
355
        my $af = Koha::AdditionalField->new({ id => $field->{id} });
356
        $af->{values} = {
357
            $subscriptionid => $query->param('additional_fields_' . $field->{name})
358
        };
359
        $af->insert_values;
360
    }
361
341
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
362
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
342
    return;
363
    return;
343
}
364
}
Lines 413-418 sub redirect_mod_subscription { Link Here
413
        $skip_serialseq
434
        $skip_serialseq
414
    );
435
    );
415
436
437
    my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
438
    my @additional_field_values;
439
    for my $field ( @$additional_fields ) {
440
        my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
441
        if ( $af->{marcfield} ) {
442
            my $record = GetMarcBiblio( $biblionumber, 1 );
443
            my ( $field, $subfield ) = split /\$/, $af->{marcfield};
444
            next unless $field and $subfield;
445
            my $value = $record->subfield( $field, $subfield );
446
            $af->{values} = {
447
                $subscriptionid => $value
448
            };
449
        } else {
450
            $af->{values} = {
451
                $subscriptionid => $query->param('additional_fields_' . $field->{name})
452
            };
453
        }
454
        $af->insert_values;
455
    }
456
416
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
457
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
417
    return;
458
    return;
418
}
459
}
(-)a/serials/subscription-detail.pl (-1 / +8 lines)
Lines 137-142 if ( defined $subscriptionid ) { Link Here
137
    }
137
    }
138
}
138
}
139
139
140
my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
141
for my $field ( @$additional_fields ) {
142
    if ( $field->{authorised_value_category} ) {
143
        $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} );
144
    }
145
}
146
$template->param( additional_fields_for_subscription => $additional_fields );
147
140
$template->param(
148
$template->param(
141
    subscriptionid => $subscriptionid,
149
    subscriptionid => $subscriptionid,
142
    serialslist => \@serialslist,
150
    serialslist => \@serialslist,
143
- 

Return to bug 10855