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

(-)a/C4/Serials.pm (-1 / +11 lines)
Lines 26-31 use POSIX qw(strftime); Link Here
26
use C4::Biblio;
26
use C4::Biblio;
27
use C4::Log;    # logaction
27
use C4::Log;    # logaction
28
use C4::Debug;
28
use C4::Debug;
29
use Koha::AdditionalField;
29
30
30
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31
32
Lines 345-351 sub GetSubscription { Link Here
345
    $debug and warn "query : $query\nsubsid :$subscriptionid";
346
    $debug and warn "query : $query\nsubsid :$subscriptionid";
346
    my $sth = $dbh->prepare($query);
347
    my $sth = $dbh->prepare($query);
347
    $sth->execute($subscriptionid);
348
    $sth->execute($subscriptionid);
348
    return $sth->fetchrow_hashref;
349
    my $subscription = $sth->fetchrow_hashref;
350
351
    # Add additional fields to the subscription into a new key "additional_fields"
352
    my $additional_field_values = Koha::AdditionalField->fetch_all_values({
353
            tablename => 'subscription',
354
            record_id => $subscriptionid,
355
    });
356
    my %sub = ( %$subscription, additional_fields => $additional_field_values->{$subscriptionid} );
357
358
    return \%sub
349
}
359
}
350
360
351
=head2 GetFullSubscription
361
=head2 GetFullSubscription
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+33 lines)
Lines 1130-1135 $(document).ready(function() { Link Here
1130
    <fieldset class="action"><input type="submit" value="Save subscription history"  /></fieldset>
1130
    <fieldset class="action"><input type="submit" value="Save subscription history"  /></fieldset>
1131
</div>
1131
</div>
1132
1132
1133
[% IF additional_fields_for_subscription %]
1134
  <div id="subscription_additional_fields">
1135
    <fieldset class="rows">
1136
      <legend>Additional fields</legend>
1137
      <ol>
1138
        [% FOR field IN additional_fields_for_subscription %]
1139
          <li>
1140
            <label for="additional_fields_[% field.name %]"> [% field.name %]: </label>
1141
            [% IF field.authorised_value_choices %]
1142
              <select name="additional_fields_[% field.name %]">
1143
                [% FOREACH av IN field.authorised_value_choices %]
1144
                  [% IF av.authorised_value == additional_fields.${field.name} %]
1145
                    <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option>
1146
                  [% ELSE %]
1147
                    <option value="[% av.authorised_value %]">[% av.lib %]</option>
1148
                  [% END %]
1149
                [% END %]
1150
              </select> (Authorised values for [% field.authorised_value_category %])
1151
            [% ELSE %]
1152
              [% IF field.marcfield %]
1153
                <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" readonly="readonly" />
1154
                This value will be filled with the [% field.marcfield %] subfield of the selected biblio.
1155
              [% ELSE %]
1156
                <input type="text" value="[% additional_fields.${field.name} %]" name="additional_fields_[% field.name %]" />
1157
              [% END %]
1158
            [% END %]
1159
          </li>
1160
        [% END %]
1161
      </ol>
1162
    </fieldset>
1163
  </div>
1164
[% END %]
1165
1133
<div id="subscription_form_planning">
1166
<div id="subscription_form_planning">
1134
	<fieldset class="rows">
1167
	<fieldset class="rows">
1135
	<legend>Serials planning</legend>
1168
	<legend>Serials planning</legend>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-1 / +24 lines)
Lines 1-4 Link Here
1
[% USE KohaBranchName %]
1
[% USE KohaBranchName %]
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 129-135 $(document).ready(function() { Link Here
129
     </ol>
130
     </ol>
130
     </div>
131
     </div>
131
     </div>
132
     </div>
132
</div>
133
     </div>
134
135
     [% IF additional_fields_for_subscription %]
136
    <div class="yui-g">
137
      <div class="yui-u first">
138
        <div class="rows">
139
          <legend>Additional fields:</legend>
140
          <ol>
141
            [% FOR field IN additional_fields_for_subscription %]
142
              <li>
143
                <span class="label">[% field.name %]:</span>
144
                [% IF field.authorised_value_category %]
145
                  [% KohaAuthorisedValues.GetByCode( field.authorised_value_category, additional_fields.${field.name} ) %]
146
                [% ELSE %]
147
                  [% additional_fields.${field.name} %]
148
                [% END %]
149
              </li>
150
            [% END %]
151
          </ol>
152
        </div>
153
      </div>
154
      </div>
155
     [% END %]
133
</div>
156
</div>
134
157
135
    <div id="subscription_planning">
158
    <div id="subscription_planning">
(-)a/serials/subscription-add.pl (+44 lines)
Lines 30-35 use C4::Context; Link Here
30
use C4::Branch; # GetBranches
30
use C4::Branch; # GetBranches
31
use C4::Serials;
31
use C4::Serials;
32
use C4::Letters;
32
use C4::Letters;
33
use Koha::AdditionalField;
33
use Carp;
34
use Carp;
34
35
35
#use Smart::Comments;
36
#use Smart::Comments;
Lines 141-146 my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); Link Here
141
$template->param(branchloop => $branchloop,
142
$template->param(branchloop => $branchloop,
142
    locations_loop=>$locations_loop,
143
    locations_loop=>$locations_loop,
143
);
144
);
145
146
147
my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
148
for my $field ( @$additional_fields ) {
149
    if ( $field->{authorised_value_category} ) {
150
        $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} );
151
    }
152
}
153
$template->param( additional_fields_for_subscription => $additional_fields );
154
144
# prepare template variables common to all $op conditions:
155
# prepare template variables common to all $op conditions:
145
if ($op!~/^mod/) {
156
if ($op!~/^mod/) {
146
    letter_loop(q{}, $template);
157
    letter_loop(q{}, $template);
Lines 256-261 sub redirect_add_subscription { Link Here
256
    my $missinglist = $query->param('missinglist');
267
    my $missinglist = $query->param('missinglist');
257
    my $opacnote = $query->param('opacnote');
268
    my $opacnote = $query->param('opacnote');
258
    my $librariannote = $query->param('librariannote');
269
    my $librariannote = $query->param('librariannote');
270
259
	my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
271
	my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
260
					$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
272
					$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
261
					$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
273
					$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
Lines 267-272 sub redirect_add_subscription { Link Here
267
				);
279
				);
268
    ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
280
    ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
269
281
282
    my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
283
    my @additional_field_values;
284
    for my $field ( @$additional_fields ) {
285
        my $af = Koha::AdditionalField->new({ id => $field->{id} });
286
        $af->{values} = {
287
            $subscriptionid => $query->param('additional_fields_' . $field->{name})
288
        };
289
        $af->insert_values;
290
    }
291
270
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
292
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
271
    return;
293
    return;
272
}
294
}
Lines 352-357 sub redirect_mod_subscription { Link Here
352
            $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid
374
            $serialsadditems, $staffdisplaycount,$opacdisplaycount,$graceperiod,$location,$enddate,$subscriptionid
353
        );
375
        );
354
        ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
376
        ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
377
378
379
    my $additional_fields = Koha::AdditionalField->all( { table => 'subscription' } );
380
    my @additional_field_values;
381
    for my $field ( @$additional_fields ) {
382
        my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
383
        if ( $af->{marcfield} ) {
384
            my $record = GetMarcBiblio( $biblionumber, 1 );
385
            my ( $field, $subfield ) = split /\$/, $af->{marcfield};
386
            next unless $field and $subfield;
387
            my $value = $record->subfield( $field, $subfield );
388
            $af->{values} = {
389
                $subscriptionid => $value
390
            };
391
        } else {
392
            $af->{values} = {
393
                $subscriptionid => $query->param('additional_fields_' . $field->{name})
394
            };
395
        }
396
        $af->insert_values;
397
    }
398
355
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
399
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
356
    return;
400
    return;
357
}
401
}
(-)a/serials/subscription-detail.pl (-1 / +8 lines)
Lines 155-160 if ( defined $subscriptionid ) { Link Here
155
    }
155
    }
156
}
156
}
157
157
158
my $additional_fields = Koha::AdditionalField->all( { tablename => '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
158
$template->param(
166
$template->param(
159
    subscriptionid => $subscriptionid,
167
    subscriptionid => $subscriptionid,
160
    serialslist => \@serialslist,
168
    serialslist => \@serialslist,
161
- 

Return to bug 10855