@@ -, +, @@ subscription defaults --- C4/Items.pm | 26 ++++++++++++++++++++-- C4/Serials.pm | 11 ++++----- .../prog/en/modules/serials/subscription-add.tt | 18 +++++++++++++++ serials/subscription-add.pl | 9 ++++++-- 4 files changed, 55 insertions(+), 9 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -2335,7 +2335,6 @@ The $frameworkcode returns the item for the given frameworkcode, ONLY if bibnum sub PrepareItemrecordDisplay { my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; - my $dbh = C4::Context->dbh; $frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum; my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" ); @@ -2422,7 +2421,8 @@ sub PrepareItemrecordDisplay { $defaultvalue = $defaultvalues->{callnumber}; } } - if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) + + if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) && $defaultvalues && $defaultvalues->{'branchcode'} ) { if ( $itemrecord and $defaultvalues and not $itemrecord->subfield($tag,$subfield) ) { @@ -2503,6 +2503,26 @@ sub PrepareItemrecordDisplay { $defaultvalue = $default_source; + #---- collection code CCODE + } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "CCODE") { + $authorised_values_sth->execute( + $tagslib->{$tag}->{$subfield}->{authorised_value}, + $branch_limit ? $branch_limit : () + ); + push @authorised_values, "" + unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); + while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { + push @authorised_values, $value; + $authorised_lib{$value} = $lib; + } + + # Set the default CCODE to what was set in subscription.ccode + if ($itemrecord and $defaultvalues) { + $defaultvalue = $defaultvalues->{'ccode'}; + } elsif (!$itemrecord and $defaultvalues) { + $defaultvalue = $defaultvalues->{'ccode'}; + } + #---- "true" authorised value } else { $authorised_values_sth->execute( @@ -2516,6 +2536,7 @@ sub PrepareItemrecordDisplay { $authorised_lib{$value} = $lib; } } + $subfield_data{marc_value} = { type => 'select', values => \@authorised_values, @@ -2534,6 +2555,7 @@ sub PrepareItemrecordDisplay { if ( $itemrecord and my $field = $itemrecord->field($tag) ) { $defaultvalue = $field->subfield($subfield); } + if( !$plugin->errstr ) { #TODO Move html to template; see report 12176/13397 my $tab= $plugin->noclick? '-1': ''; --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -1301,7 +1301,7 @@ sub ModSubscription { $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 $dbh = C4::Context->dbh; @@ -1314,7 +1314,7 @@ sub ModSubscription { callnumber=?, notes=?, letter=?, manualhistory=?, internalnotes=?, serialsadditems=?, staffdisplaycount=?, opacdisplaycount=?, graceperiod=?, location = ?, enddate=?, - skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=? + skip_serialseq=?, itemtype=?, previousitemtype=?, mana_id=?, ccode=? WHERE subscriptionid = ?"; my $sth = $dbh->prepare($query); @@ -1328,7 +1328,7 @@ sub ModSubscription { $letter, ($manualhistory ? $manualhistory : 0), $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, $skip_serialseq, - $itemtype, $previousitemtype, $mana_id, + $itemtype, $previousitemtype, $mana_id, $ccode, $subscriptionid ); my $rows = $sth->rows; @@ -1345,7 +1345,7 @@ $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, - $skip_serialseq, $itemtype, $previousitemtype); + $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode); Create a new subscription with value given on input args. @@ -1362,7 +1362,7 @@ sub NewSubscription { $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; @@ -1405,6 +1405,7 @@ sub NewSubscription { itemtype => $itemtype, previousitemtype => $previousitemtype, mana_id => $mana_id, + ccode => $ccode, } )->store; $subscription->discard_changes; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -319,6 +319,24 @@ fieldset.rows table { clear: none; margin: 0; } Required +