$defaultvalue = $defaultvalues->{location};
}
}
+ if ( ( $subfield->{kohafield} eq 'items.ccode' )
+ && $defaultvalues
+ && $defaultvalues->{'ccode'} ) {
+
+ if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield->{subfield}) ) {
+ # if the item record exists, only use default value if the item has no ccode
+ $defaultvalue = $defaultvalues->{ccode};
+ } elsif ( !$itemrecord and $defaultvalues ) {
+ # if the item record *doesn't* exists, always use the default value
+ $defaultvalue = $defaultvalues->{ccode};
+ }
+ }
if ( $subfield->{authorised_value} ) {
my @authorised_values;
my %authorised_lib;
$biblionumber, $callnumber, $notes, $letter, $manualhistory,
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount,
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq,
- $itemtype, $previousitemtype, $mana_id
+ $itemtype, $previousitemtype, $mana_id, $ccode
) = @_;
my $subscription = Koha::Subscriptions->find($subscriptionid);
itemtype => $itemtype,
previousitemtype => $previousitemtype,
mana_id => $mana_id,
+ ccode => $ccode,
}
)->store;
# FIXME Must be $subscription->serials
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity,
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes,
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod,
- $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id
+ $location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
) = @_;
my $dbh = C4::Context->dbh;
itemtype => $itemtype,
previousitemtype => $previousitemtype,
mana_id => $mana_id,
+ ccode => $ccode
}
)->store;
$subscription->discard_changes;
</select>
</li>
<li>
+ <label for="ccode">Collection code:</label>
+ <select name="ccode" id="ccode">
+ [% FOREACH ccode_loo IN ccodes_loop %]
+ [% IF (ccode_loo.selected) %]
+ <option value="[% ccode_loo.authorised_value | html %]" selected="selected">[% ccode_loo.lib | html %]</option>
+ [% ELSE %]
+ <option value="[% ccode_loo.authorised_value | html %]">[% ccode_loo.lib | html %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </li>
+ <li>
<label for="itemtype">Item type:</label>
<select name="itemtype" id="itemtype">
<option value=""></option>
<ol>
[% IF ( location ) %]<li><span class="label">Location:</span> [% location | html %]</li>[% END %]
[% IF ( callnumber ) %]<li><span class="label">Call number:</span> [% callnumber | html %]</li>[% END %]
+ [% IF ( ccode ) %]<li><span class="label">Collection code:</span> [% ccode | html %]</li>[% END %]
[% IF ( staffdisplaycount ) %]<li><span class="label">Number of issues to display to staff:</span>[% staffdisplaycount | html %]</li>[% END %]
[% IF ( opacdisplaycount ) %]<li><span class="label">Number of issues to display in OPAC:</span>[% opacdisplaycount | html %]</li>[% END %]
[% IF ( letter ) %]
}
my $locations_loop = GetAuthorisedValues("LOC");
+my $ccodes_loop = GetAuthorisedValues("CCODE");
$template->param(
branchcode => $subs->{branchcode},
locations_loop=>$locations_loop,
+ ccodes_loop=>$ccodes_loop
);
my @additional_fields = Koha::AdditionalFields->search({ tablename => 'subscription' })->as_list;
my $itemtype = $query->param('itemtype');
my $previousitemtype = $query->param('previousitemtype');
my $skip_serialseq = $query->param('skip_serialseq');
+ my $ccode = $query->param('ccode');
my $mana_id;
if ( $query->param('mana_id') ne "" ) {
join(";",@irregularity), $numberpattern, $locale, $callnumber,
$manualhistory, $internalnotes, $serialsadditems,
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate,
- $skip_serialseq, $itemtype, $previousitemtype, $mana_id
+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
);
if ( (C4::Context->preference('Mana') == 1) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){
my $result = Koha::SharedContent::send_entity( $query->param('mana_language') || '', $loggedinuser, $subscriptionid, 'subscription');
my $itemtype = $query->param('itemtype');
my $previousitemtype = $query->param('previousitemtype');
my $skip_serialseq = $query->param('skip_serialseq');
+ my $ccode = $query->param('ccode');
my $mana_id;
if ( $query->param('mana_id') ne "" ) {
$status, $biblionumber, $callnumber, $notes, $letter,
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount,
$opacdisplaycount, $graceperiod, $location, $enddate, $subscriptionid,
- $skip_serialseq, $itemtype, $previousitemtype, $mana_id
+ $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode
);
my @additional_fields;
}
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
$subs->{location} = $av->count ? $av->next->lib : '';
+$av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $subs->{ccode} });
+$subs->{ccode} = $av->count ? $av->next->lib : '';
$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid});
$template->param(%{ $subs });
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
use Koha::Acquisition::Booksellers;
use t::lib::Mocks;
use t::lib::TestBuilder;
-use Test::More tests => 50;
+use Test::More tests => 52;
BEGIN {
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 ));
my $notes = "a\nnote\non\nseveral\nlines";
my $internalnotes = 'intnotes';
+my $ccode = 'FIC';
my $subscriptionid = NewSubscription(
undef, "", undef, undef, $budget_id, $biblionumber,
'2013-01-01', $frequency_id, undef, undef, undef,
undef, undef, undef, undef, undef, undef,
1, $notes, ,undef, '2013-01-01', undef, $pattern_id,
undef, undef, 0, $internalnotes, 0,
- undef, undef, 0, undef, '2013-12-31', 0
+ undef, undef, 0, undef, '2013-12-31', 0,
+ undef, undef, undef, $ccode
+
);
my $subscriptioninformation = GetSubscription( $subscriptionid );
is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' );
is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' );
+is( $subscriptioninformation->{ccode}, $ccode, 'NewSubscription should set ccode' );
my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' );
$frequency->{description} = "Frequency created by t/db_dependant/Serials.t";
$subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency);
$subscriptioninformation->{serialsadditems} = 1;
+ $subscriptioninformation->{ccode} = 'NFIC';
ModSubscription( @$subscriptioninformation{qw(
librarian branchcode aqbooksellerid cost aqbudgetid startdate
innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes
letter manualhistory internalnotes serialsadditems staffdisplaycount
opacdisplaycount graceperiod location enddate subscriptionid
- skip_serialseq
+ skip_serialseq itemtype previousitemtype mana_id ccode
)} );
}
my $expirationdate = GetExpirationDate($subscriptionid) ;
ok( $expirationdate, "expiration date is not NULL" );
+# Check ModSubscription has updated the ccode
+my $subscriptioninformation2 = GetSubscription($subscriptionid);
+is( $subscriptioninformation2->{ccode}, 'NFIC', 'ModSubscription should update ccode' );
+
ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription');
my ($serials_count, @serials) = GetSerials($subscriptionid);