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

(-)a/C4/Items.pm (+12 lines)
Lines 1673-1678 sub PrepareItemrecordDisplay { Link Here
1673
                        $defaultvalue = $defaultvalues->{location};
1673
                        $defaultvalue = $defaultvalues->{location};
1674
                    }
1674
                    }
1675
                }
1675
                }
1676
                if (   ( $subfield->{kohafield} eq 'items.ccode' )
1677
                    && $defaultvalues
1678
                    && $defaultvalues->{'ccode'} ) {
1679
1680
                    if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ) {
1681
                        # if the item record exists, only use default value if the item has no ccode
1682
                        $defaultvalue = $defaultvalues->{ccode};
1683
                    } elsif ( !$itemrecord and $defaultvalues ) {
1684
                        # if the item record *doesn't* exists, always use the default value
1685
                        $defaultvalue = $defaultvalues->{ccode};
1686
                    }
1687
                }
1676
                if ( $subfield->{authorised_value} ) {
1688
                if ( $subfield->{authorised_value} ) {
1677
                    my @authorised_values;
1689
                    my @authorised_values;
1678
                    my %authorised_lib;
1690
                    my %authorised_lib;
(-)a/C4/Serials.pm (-2 / +4 lines)
Lines 1319-1325 sub ModSubscription { Link Here
1319
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1319
    $biblionumber, $callnumber, $notes, $letter, $manualhistory,
1320
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1320
    $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
1321
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1321
    $graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
1322
    $itemtype, $previousitemtype, $mana_id
1322
    $itemtype, $previousitemtype, $mana_id, $ccode
1323
    ) = @_;
1323
    ) = @_;
1324
1324
1325
    my $subscription = Koha::Subscriptions->find($subscriptionid);
1325
    my $subscription = Koha::Subscriptions->find($subscriptionid);
Lines 1362-1367 sub ModSubscription { Link Here
1362
            itemtype          => $itemtype,
1362
            itemtype          => $itemtype,
1363
            previousitemtype  => $previousitemtype,
1363
            previousitemtype  => $previousitemtype,
1364
            mana_id           => $mana_id,
1364
            mana_id           => $mana_id,
1365
            ccode             => $ccode,
1365
        }
1366
        }
1366
    )->store;
1367
    )->store;
1367
    # FIXME Must be $subscription->serials
1368
    # FIXME Must be $subscription->serials
Lines 1399-1405 sub NewSubscription { Link Here
1399
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1400
    $innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
1400
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1401
    $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
1401
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1402
    $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
1402
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
1403
    $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
1403
    ) = @_;
1404
    ) = @_;
1404
    my $dbh = C4::Context->dbh;
1405
    my $dbh = C4::Context->dbh;
1405
1406
Lines 1442-1447 sub NewSubscription { Link Here
1442
            itemtype          => $itemtype,
1443
            itemtype          => $itemtype,
1443
            previousitemtype  => $previousitemtype,
1444
            previousitemtype  => $previousitemtype,
1444
            mana_id           => $mana_id,
1445
            mana_id           => $mana_id,
1446
            ccode             => $ccode
1445
        }
1447
        }
1446
    )->store;
1448
    )->store;
1447
    $subscription->discard_changes;
1449
    $subscription->discard_changes;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (+12 lines)
Lines 200-205 fieldset.rows table { clear: none; margin: 0; } Link Here
200
                                    </select>
200
                                    </select>
201
                                </li>
201
                                </li>
202
                                <li>
202
                                <li>
203
                                    <label for="ccode">Collection code:</label>
204
                                    <select name="ccode" id="ccode">
205
                                        [% FOREACH ccode_loo IN ccodes_loop %]
206
                                            [% IF (ccode_loo.selected) %]
207
                                                <option value="[% ccode_loo.authorised_value | html %]" selected="selected">[% ccode_loo.lib | html %]</option>
208
                                            [% ELSE %]
209
                                                <option value="[% ccode_loo.authorised_value | html %]">[% ccode_loo.lib | html %]</option>
210
                                            [% END %]
211
                                        [% END %]
212
                                    </select>
213
                                </li>
214
                                <li>
203
                                    <label for="itemtype">Item type:</label>
215
                                    <label for="itemtype">Item type:</label>
204
                                    <select name="itemtype" id="itemtype">
216
                                    <select name="itemtype" id="itemtype">
205
                                        <option value=""></option>
217
                                        <option value=""></option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (+1 lines)
Lines 143-148 Link Here
143
                                    <ol>
143
                                    <ol>
144
                                        [% IF ( location ) %]<li><span class="label">Location:</span> [% location | html %]</li>[% END %]
144
                                        [% IF ( location ) %]<li><span class="label">Location:</span> [% location | html %]</li>[% END %]
145
                                        [% IF ( callnumber ) %]<li><span class="label">Call number:</span> [% callnumber | html %]</li>[% END %]
145
                                        [% IF ( callnumber ) %]<li><span class="label">Call number:</span> [% callnumber | html %]</li>[% END %]
146
                                        [% IF ( ccode ) %]<li><span class="label">Collection code:</span> [% ccode | html %]</li>[% END %]
146
                                        [% IF ( staffdisplaycount ) %]<li><span class="label">Number of issues to display to staff:</span>[% staffdisplaycount | html %]</li>[% END %]
147
                                        [% IF ( staffdisplaycount ) %]<li><span class="label">Number of issues to display to staff:</span>[% staffdisplaycount | html %]</li>[% END %]
147
                                        [% IF ( opacdisplaycount ) %]<li><span class="label">Number of issues to display in OPAC:</span>[% opacdisplaycount | html %]</li>[% END %]
148
                                        [% IF ( opacdisplaycount ) %]<li><span class="label">Number of issues to display in OPAC:</span>[% opacdisplaycount | html %]</li>[% END %]
148
                                        [% IF ( letter ) %]
149
                                        [% IF ( letter ) %]
(-)a/serials/subscription-add.pl (-2 / +6 lines)
Lines 124-133 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
124
}
124
}
125
125
126
my $locations_loop = GetAuthorisedValues("LOC");
126
my $locations_loop = GetAuthorisedValues("LOC");
127
my $ccodes_loop     = GetAuthorisedValues("CCODE");
127
128
128
$template->param(
129
$template->param(
129
    branchcode => $subs->{branchcode},
130
    branchcode => $subs->{branchcode},
130
    locations_loop=>$locations_loop,
131
    locations_loop=>$locations_loop,
132
    ccodes_loop=>$ccodes_loop
131
);
133
);
132
134
133
my @additional_fields = Koha::AdditionalFields->search({ tablename => 'subscription' })->as_list;
135
my @additional_fields = Koha::AdditionalFields->search({ tablename => 'subscription' })->as_list;
Lines 328-333 sub redirect_add_subscription { Link Here
328
    my $itemtype          = $query->param('itemtype');
330
    my $itemtype          = $query->param('itemtype');
329
    my $previousitemtype  = $query->param('previousitemtype');
331
    my $previousitemtype  = $query->param('previousitemtype');
330
    my $skip_serialseq    = $query->param('skip_serialseq');
332
    my $skip_serialseq    = $query->param('skip_serialseq');
333
    my $ccode             = $query->param('ccode');
331
334
332
    my $mana_id;
335
    my $mana_id;
333
    if ( $query->param('mana_id') ne "" ) {
336
    if ( $query->param('mana_id') ne "" ) {
Lines 354-360 sub redirect_add_subscription { Link Here
354
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
357
        join(";",@irregularity), $numberpattern, $locale, $callnumber,
355
        $manualhistory, $internalnotes, $serialsadditems,
358
        $manualhistory, $internalnotes, $serialsadditems,
356
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
359
        $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
357
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
360
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
358
    );
361
    );
359
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
362
    if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
360
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
363
        my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
Lines 441-446 sub redirect_mod_subscription { Link Here
441
    my $itemtype          = $query->param('itemtype');
444
    my $itemtype          = $query->param('itemtype');
442
    my $previousitemtype  = $query->param('previousitemtype');
445
    my $previousitemtype  = $query->param('previousitemtype');
443
    my $skip_serialseq    = $query->param('skip_serialseq');
446
    my $skip_serialseq    = $query->param('skip_serialseq');
447
    my $ccode             = $query->param('ccode');
444
448
445
    my $mana_id;
449
    my $mana_id;
446
    if ( $query->param('mana_id') ne "" ) {
450
    if ( $query->param('mana_id') ne "" ) {
Lines 476-482 sub redirect_mod_subscription { Link Here
476
        $status, $biblionumber, $callnumber, $notes, $letter,
480
        $status, $biblionumber, $callnumber, $notes, $letter,
477
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
481
        $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
478
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
482
        $opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
479
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id
483
        $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
480
    );
484
    );
481
485
482
    my @additional_fields;
486
    my @additional_fields;
(-)a/serials/subscription-detail.pl (+2 lines)
Lines 114-119 for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) Link Here
114
}
114
}
115
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
115
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
116
$subs->{location} = $av->count ? $av->next->lib : '';
116
$subs->{location} = $av->count ? $av->next->lib : '';
117
$av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $subs->{ccode} });
118
$subs->{ccode} = $av->count ? $av->next->lib : '';
117
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
119
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
118
$template->param(%{ $subs });
120
$template->param(%{ $subs });
119
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
121
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
(-)a/t/db_dependent/Serials.t (-4 / +12 lines)
Lines 16-22 use Koha::DateUtils qw( dt_from_string output_pref ); Link Here
16
use Koha::Acquisition::Booksellers;
16
use Koha::Acquisition::Booksellers;
17
use t::lib::Mocks;
17
use t::lib::Mocks;
18
use t::lib::TestBuilder;
18
use t::lib::TestBuilder;
19
use Test::More tests => 50;
19
use Test::More tests => 52;
20
20
21
BEGIN {
21
BEGIN {
22
    use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
22
    use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
Lines 74-92 my $pattern_id = AddSubscriptionNumberpattern({ Link Here
74
74
75
my $notes = "a\nnote\non\nseveral\nlines";
75
my $notes = "a\nnote\non\nseveral\nlines";
76
my $internalnotes = 'intnotes';
76
my $internalnotes = 'intnotes';
77
my $ccode = 'FIC';
77
my $subscriptionid = NewSubscription(
78
my $subscriptionid = NewSubscription(
78
    undef,      "",     undef, undef, $budget_id, $biblionumber,
79
    undef,      "",     undef, undef, $budget_id, $biblionumber,
79
    '2013-01-01', $frequency_id, undef, undef,  undef,
80
    '2013-01-01', $frequency_id, undef, undef,  undef,
80
    undef,      undef,  undef, undef, undef, undef,
81
    undef,      undef,  undef, undef, undef, undef,
81
    1,          $notes, ,undef, '2013-01-01', undef, $pattern_id,
82
    1,          $notes, ,undef, '2013-01-01', undef, $pattern_id,
82
    undef,       undef,  0,    $internalnotes,  0,
83
    undef,       undef,  0,    $internalnotes,  0,
83
    undef, undef, 0,          undef,         '2013-12-31', 0
84
    undef, undef, 0,          undef,         '2013-12-31', 0,
85
    undef, undef, undef, $ccode
86
84
);
87
);
85
88
86
my $subscriptioninformation = GetSubscription( $subscriptionid );
89
my $subscriptioninformation = GetSubscription( $subscriptionid );
87
90
88
is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' );
91
is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' );
89
is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' );
92
is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' );
93
is( $subscriptioninformation->{ccode}, $ccode, 'NewSubscription should set ccode' );
90
94
91
my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
95
my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
92
is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' );
96
is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' );
Lines 114-119 if (not $frequency->{unit}) { Link Here
114
    $frequency->{description} = "Frequency created by t/db_dependant/Serials.t";
118
    $frequency->{description} = "Frequency created by t/db_dependant/Serials.t";
115
    $subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency);
119
    $subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency);
116
    $subscriptioninformation->{serialsadditems} = 1;
120
    $subscriptioninformation->{serialsadditems} = 1;
121
    $subscriptioninformation->{ccode} = 'NFIC';
117
122
118
    ModSubscription( @$subscriptioninformation{qw(
123
    ModSubscription( @$subscriptioninformation{qw(
119
        librarian branchcode aqbooksellerid cost aqbudgetid startdate
124
        librarian branchcode aqbooksellerid cost aqbudgetid startdate
Lines 122-133 if (not $frequency->{unit}) { Link Here
122
        innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes
127
        innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes
123
        letter manualhistory internalnotes serialsadditems staffdisplaycount
128
        letter manualhistory internalnotes serialsadditems staffdisplaycount
124
        opacdisplaycount graceperiod location enddate subscriptionid
129
        opacdisplaycount graceperiod location enddate subscriptionid
125
        skip_serialseq
130
        skip_serialseq itemtype previousitemtype mana_id ccode
126
    )} );
131
    )} );
127
}
132
}
128
my $expirationdate = GetExpirationDate($subscriptionid) ;
133
my $expirationdate = GetExpirationDate($subscriptionid) ;
129
ok( $expirationdate, "expiration date is not NULL" );
134
ok( $expirationdate, "expiration date is not NULL" );
130
135
136
# Check ModSubscription has updated the ccode
137
my $subscriptioninformation2 = GetSubscription($subscriptionid);
138
is( $subscriptioninformation2->{ccode}, 'NFIC', 'ModSubscription should update ccode' );
139
131
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription');
140
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription');
132
141
133
my ($serials_count, @serials) = GetSerials($subscriptionid);
142
my ($serials_count, @serials) = GetSerials($subscriptionid);
134
- 

Return to bug 23352