The ACQ MARC framework is only used for the ‘Item’ block.
This patch add the ability to define biblio fields (!= 995 or 952) to
customize the display of the bibliographic details when ordering.
This new feature is controlled by a new pref:
UseACQFrameworkForBiblioRecords
Test plan:
- Create a new installation to populate the ACQ framework correctly
- Set the pref UseACQFrameworkForBiblioRecords to "Use"
- Create a new order
=> You will see the lib from the ACQ framework
- Add/remove/update biblio subfields in the ACQ framework
- Create a new order
=> You should see the new subfields displayed
Note for QA: I though I would be able to refactor existing code to make
it more flexible, but it is a bit messy and lost a lot of time. I
finally decided to copy/paste the existing code. I simplified it as, I
think, we do not want the plugin, etc. like in the full biblio editor.
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
# not just blindly call C4 functions and print a redirect.
my $input = new CGI;
+my $use_ACQ_framework = $input->param('use_ACQ_framework');
# Check if order total amount exceed allowed budget
my $confirm_budget_exceeding = $input->param('confirm_budget_exceeding');
if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) {
#TODO:check to see if biblio exists
unless ( $$orderinfo{biblionumber} ) {
- #if it doesn't create it
- my $record = TransformKohaToMarc(
- {
- "biblio.title" => "$$orderinfo{title}",
- "biblio.author" => $$orderinfo{author} ? $$orderinfo{author} : "",
- "biblio.seriestitle" => $$orderinfo{series} ? $$orderinfo{series} : "",
- "biblioitems.isbn" => $$orderinfo{isbn} ? $$orderinfo{isbn} : "",
- "biblioitems.ean" => $$orderinfo{ean} ? $$orderinfo{ean} : "",
- "biblioitems.publishercode" => $$orderinfo{publishercode} ? $$orderinfo{publishercode} : "",
- "biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
- "biblio.copyrightdate" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
- "biblioitems.itemtype" => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "",
- "biblioitems.editionstatement"=> $$orderinfo{editionstatement} ? $$orderinfo{editionstatement} : "",
- });
+ my $record;
+ if ( $use_ACQ_framework ) {
+ my @tags = $input->multi_param('bib_tag');
+ my @subfields = $input->multi_param('bib_subfield');
+ my @field_values = $input->multi_param('bib_field_value');
+ my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values );
+ $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+ } else {
+ #if it doesn't create it
+ $record = TransformKohaToMarc(
+ {
+ "biblio.title" => "$$orderinfo{title}",
+ "biblio.author" => $$orderinfo{author} ? $$orderinfo{author} : "",
+ "biblio.seriestitle" => $$orderinfo{series} ? $$orderinfo{series} : "",
+ "biblioitems.isbn" => $$orderinfo{isbn} ? $$orderinfo{isbn} : "",
+ "biblioitems.ean" => $$orderinfo{ean} ? $$orderinfo{ean} : "",
+ "biblioitems.publishercode" => $$orderinfo{publishercode} ? $$orderinfo{publishercode} : "",
+ "biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
+ "biblio.copyrightdate" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
+ "biblioitems.itemtype" => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "",
+ "biblioitems.editionstatement"=> $$orderinfo{editionstatement} ? $$orderinfo{editionstatement} : "",
+ });
+
+ }
C4::Acquisition::FillWithDefaultValues( $record );
# create the record in catalogue, with framework ''
unless ($itemhash{$itemid[$i]}){
$countdistinct++;
}
- push @{$itemhash{$itemid[$i]}->{'tags'}},$tags[$i];
- push @{$itemhash{$itemid[$i]}->{'subfields'}},$subfields[$i];
+ push @{$itemhash{$itemid[$i]}->{'tags'}},$tags[$i];
+ push @{$itemhash{$itemid[$i]}->{'subfields'}},$subfields[$i];
push @{$itemhash{$itemid[$i]}->{'field_values'}},$field_values[$i];
push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i];
push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i];
use Koha::Acquisition::Booksellers;
use Koha::Acquisition::Currencies;
+use Koha::BiblioFrameworks;
+use Koha::DateUtils qw( dt_from_string );
+use Koha::MarcSubfieldStructures;
use Koha::ItemTypes;
use Koha::Patrons;
+use Koha::RecordProcessor;
our $input = new CGI;
my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR!
-my ( @order_user_ids, @order_users );
-if ( $ordernumber eq '' ) { # create order
+my ( @order_user_ids, @order_users, @catalog_details );
+our $tagslib = GetMarcStructure(1, 'ACQ', { unsafe => 1 } );
+my ( $itemnumber_tag, $itemnumber_subtag ) = GetMarcFromKohaField( 'items.itemnumber', 'ACQ' );
+if ( not $ordernumber ) { # create order
$new = 'yes';
- # $ordernumber=newordernum;
- if ( $biblionumber && !$suggestionid ) {
+ if ( $biblionumber ) {
$data = GetBiblioData($biblionumber);
}
-
-# get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
-# otherwise, retrieve suggestion information.
- if ($suggestionid) {
- $data = ($biblionumber) ? GetBiblioData($biblionumber) : GetSuggestion($suggestionid);
+ # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
+ # otherwise, retrieve suggestion information.
+ elsif ($suggestionid) {
+ $data = GetSuggestion($suggestionid);
$budget_id ||= $data->{'budgetid'} // 0;
}
+
+ if ( not $biblionumber and Koha::BiblioFrameworks->find('ACQ') ) {
+ #my $acq_mss = Koha::MarcSubfieldStructures->search({ frameworkcode => 'ACQ', tagfield => { '!=' => $itemnumber_tag } });
+ foreach my $tag ( sort keys %{$tagslib} ) {
+ next if $tag eq '';
+ next if $tag eq $itemnumber_tag; # skip items fields
+ foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
+ my $mss = $tagslib->{$tag}{$subfield};
+ next if IsMarcStructureInternal($mss);
+ next if $mss->{tab} == -1;
+ my $value = $mss->{defaultvalue};
+
+ if ($suggestionid and $mss->{kohafield}) {
+ # Reading suggestion info if ordering from a suggestion
+ if ( $mss->{kohafield} eq 'biblio.title' ) {
+ $value = $data->{title};
+ }
+ elsif ( $mss->{kohafield} eq 'biblio.author' ) {
+ $value = $data->{author};
+ }
+ elsif ( $mss->{kohafield} eq 'biblioitems.publishercode' ) {
+ $value = $data->{publishercode};
+ }
+ elsif ( $mss->{kohafield} eq 'biblioitems.editionstatement' ) {
+ $value = $data->{editionstatement};
+ }
+ elsif ( $mss->{kohafield} eq 'biblioitems.publicationyear' ) {
+ $value = $data->{publicationyear};
+ }
+ elsif ( $mss->{kohafield} eq 'biblioitems.isbn' ) {
+ $value = $data->{isbn};
+ }
+ elsif ( $mss->{kohafield} eq 'biblio.seriestitle' ) {
+ $value = $data->{seriestitle};
+ }
+ }
+
+ if ( $value eq '' ) {
+
+ # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value
+ my $today_dt = dt_from_string;
+ my $year = $today_dt->strftime('%Y');
+ my $month = $today_dt->strftime('%m');
+ my $day = $today_dt->strftime('%d');
+ $value =~ s/<<YYYY>>/$year/g;
+ $value =~ s/<<MM>>/$month/g;
+ $value =~ s/<<DD>>/$day/g;
+
+ # And <<USER>> with surname (?)
+ my $username =
+ ( C4::Context->userenv
+ ? C4::Context->userenv->{'surname'}
+ : "superlibrarian" );
+ $value =~ s/<<USER>>/$username/g;
+ }
+ push @catalog_details, {
+ tag => $tag,
+ subfield => $subfield,
+ %$mss, # Do we need plugins support (?)
+ value => $value,
+ };
+ }
+ }
+ }
}
else { #modify order
$data = GetOrder($ordernumber);
}
}
+# We can have:
+# - no ordernumber but a biblionumber: from a subscription, from an existing record
+# - no ordernumber, no biblionumber: from a suggestion, from a new order
+if ( not $ordernumber or $biblionumber ) {
+ if ( C4::Context->preference('UseACQFrameworkForBiblioRecords') ) {
+ my $record = $biblionumber ? GetMarcBiblio({ biblionumber => $biblionumber }) : undef;
+ foreach my $tag ( sort keys %{$tagslib} ) {
+ next if $tag eq '';
+ next if $tag eq $itemnumber_tag; # skip items fields
+ my @fields = $biblionumber ? $record->field($tag) : ();
+ foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
+ my $mss = $tagslib->{$tag}{$subfield};
+ next if IsMarcStructureInternal($mss);
+ next if $mss->{tab} == -1;
+ # We only need to display the values
+ my $value = join '; ', map { $_->subfield( $subfield ) } @fields;
+ if ( $value ) {
+ push @catalog_details, {
+ tag => $tag,
+ subfield => $subfield,
+ %$mss,
+ value => $value,
+ };
+ }
+ }
+ }
+ }
+}
+
+$template->param( catalog_details => \@catalog_details, );
+
my $suggestion;
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
UniqueItemFields => C4::Context->preference('UniqueItemFields'),
);
}
+
# Get the item types list, but only if item_level_itype is YES. Otherwise, it will be in the item, no need to display it in the biblio
my @itemtypes;
@itemtypes = Koha::ItemTypes->search unless C4::Context->preference('item-level_itypes');
filters => 'ViewPolicy',
options => {
interface => 'intranet',
- frameworkcode => $framework
+ frameworkcode => 'ACQ'
},
});
$record_processor->process($record);
--- /dev/null
+INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
+VALUES ('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo');
('UsageStatsLibraryType', '', 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription', 'The library type to be shown on the Hea Koha community website', 'Choice'),
('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
('UsageStatsPublicID', '', NULL, 'Public ID for Hea website', 'Free'),
+('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo'),
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'),
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
[% END %]
[% END %]
[% END %]
+
+[% BLOCK options_for_item_types %]
+ [% FOREACH itemtype IN itemtypes %]
+ [% IF itemtype.itemtype == selected_itemtype %]
+ <option value="[% itemtype.itemtype %]" selected="selected">
+ [% ELSE %]
+ <option value="[% itemtype.itemtype %]">
+ [% END %]
+ [% itemtype.translated_description %]
+ </option>
+ [% END %]
+[% END %]
<input type="hidden" id="currency_rate_[% c.currency %]" name="[% c.currency %]" value="[% c.rate %]" />
[% END %]
- <ol><li>
- [% IF ( biblionumber ) %]
- <span class="label">Title</span>
- <input type="hidden" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
- [% ELSE %]
- <label for="entertitle" class="required">Title: </label>
- <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" class="focus" />
- <span class="required">Required</span>
- [% END %]
- </li>
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">Author: </span>
- <input type="hidden" name="author" id="author" value="[% author %]" />[% author %]
- [% ELSE %]
- <label for="author">Author: </label>
- <input type="text" size="50" name="author" id="author" value="[% author %]" />
- [% END %]
- </li>
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">Publisher: </span>
- <input type="hidden" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
- [% ELSE %]
- <label for="publishercode"> Publisher: </label>
- <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
- [% END %]
- </li>
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">Edition: </span>
- <input type="hidden" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
+ [% IF NOT Koha.Preference('UseACQFrameworkForBiblioRecords') OR NoACQframework %]
+ <ol><li>
+ [% IF ( biblionumber ) %]
+ <span class="label">Title</span>
+ <input type="hidden" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
+ [% ELSE %]
+ <label for="entertitle" class="required">Title: </label>
+ <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" class="focus" />
+ <span class="required">Required</span>
+ [% END %]
+ </li>
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">Author: </span>
+ <input type="hidden" name="author" id="author" value="[% author %]" />[% author %]
+ [% ELSE %]
+ <label for="author">Author: </label>
+ <input type="text" size="50" name="author" id="author" value="[% author %]" />
+ [% END %]
+ </li>
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">Publisher: </span>
+ <input type="hidden" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
+ [% ELSE %]
+ <label for="publishercode"> Publisher: </label>
+ <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
+ [% END %]
+ </li>
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">Edition: </span>
+ <input type="hidden" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
- [% ELSE %]
- <label for="editionstatement">Edition: </label>
- <input type="text" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />
- [% END %]
- </li>
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">Publication year: </span>
- <input type="hidden" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
- [% ELSE %]
- <label for="publicationyear">Publication year: </label>
- <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
- [% END %]
- </li>
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">ISBN: </span>
- <input type="hidden" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
- [% ELSE %]
- <label for="ISBN">ISBN: </label>
- <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
- [% END %]
- </li>
- [% IF (UNIMARC) %]
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">EAN: </span>
- <input type="hidden" name="ean" id="EAN" value="[% ean %]" />[% ean %]
- [% ELSE %]
- <label for="EAN">EAN: </label>
- <input type="text" size="20" name="ean" id="EAN" value="[% ean %]" />
- [% END %]
- </li>
- [% END %]
- <li>
- [% IF ( biblionumber ) %]
- <span class="label">Series: </span>
- <input type="hidden" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
- [% ELSE %]
- <label for="series">Series: </label>
- <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
- [% END %]
- </li>
- [% UNLESS ( biblionumber ) %]
- [% IF ( itemtypeloop ) %]
+ [% ELSE %]
+ <label for="editionstatement">Edition: </label>
+ <input type="text" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />
+ [% END %]
+ </li>
<li>
- <span class="label">Item type:</span>
- <select name="itemtype" style="width:12em;">
- [% FOREACH itemtype IN itemtypeloop %]
- <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
+ [% IF ( biblionumber ) %]
+ <span class="label">Publication year: </span>
+ <input type="hidden" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
+ [% ELSE %]
+ <label for="publicationyear">Publication year: </label>
+ <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
+ [% END %]
+ </li>
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">ISBN: </span>
+ <input type="hidden" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
+ [% ELSE %]
+ <label for="ISBN">ISBN: </label>
+ <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
+ [% END %]
+ </li>
+ [% IF (UNIMARC) %]
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">EAN: </span>
+ <input type="hidden" name="ean" id="EAN" value="[% ean %]" />[% ean %]
+ [% ELSE %]
+ <label for="EAN">EAN: </label>
+ <input type="text" size="20" name="ean" id="EAN" value="[% ean %]" />
[% END %]
- </select>
</li>
[% END %]
+ <li>
+ [% IF ( biblionumber ) %]
+ <span class="label">Series: </span>
+ <input type="hidden" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
+ [% ELSE %]
+ <label for="series">Series: </label>
+ <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
+ [% END %]
+ </li>
+ [% UNLESS ( biblionumber ) %]
+ [% IF ( itemtypeloop ) %]
+ <li>
+ <span class="label">Item type:</span>
+ <select name="itemtype" style="width:12em;">
+ [% FOREACH itemtype IN itemtypeloop %]
+ <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
+ [% END %]
+ </select>
+ </li>
+ [% END %]
+ [% END %]
+ </ol>
+ [% ELSE %]
+ <input type="hidden" name="use_ACQ_framework" value="1" />
+ [% IF biblionumber %]
+ <ol>
+ [% FOREACH field IN catalog_details %]
+ <li>
+ <div class="subfield_line">
+ <label>[% field.lib %] ([% field.tag %][% field.subfield %])</label>
+ [% field.value %]
+ </div>
+ </li>
+ [% END %]
+ </ol>
+ [% ELSE %]
+ <ol>
+ [% FOREACH field IN catalog_details %]
+ <li>
+ <div class="subfield_line">
+ [% PROCESS display_subfield field=field %]
+ </div>
+ </li>
+ [% END %]
+ </ol>
[% END %]
- </ol>
+ [% END %]
</fieldset>
[% IF ( suggestionid ) %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]
+
+[% BLOCK display_subfield %]
+ [% IF field.mandatory %]
+ <label class="required">[% field.lib %] ([% field.tag %][% field.subfield %])</label>
+ [% ELSE %]
+ <label>[% field.lib %] ([% field.tag %][% field.subfield %])</label>
+ [% END %]
+ [% IF field.authorised_value %]
+ [% SWITCH field.authorised_value %]
+ [% CASE 'branches' %]
+ <select name="bib_field_value">
+ <option value=""></option>
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => "FIXME" ) %]
+ </select>
+ [% CASE 'itemtypes' %]
+ <select name="bib_field_value">
+ <option value=""></option>
+ [% PROCESS options_for_itemtypes itemtypes => ItemTypes.Get(), selected_itemtype => "FIXME" %]
+ </select>
+ [% CASE 'cn_source' %]
+ [% CASE %]
+ [% PROCESS 'av-build-dropbox.inc' name="bib_field_value", category=field.authorised_value, default="FIXME" %]
+ [% END %]
+ [% ELSE %]
+ <input type="text" name="bib_field_value" value="[% field.value %]" />
+ [% END %]
+ <input type="hidden" name="bib_kohafield" value="[% field.kohafield %]" />
+ <input type="hidden" name="bib_tag" value="[% field.tag %]" />
+ <input type="hidden" name="bib_subfield" value="[% field.subfield %]" />
+ [% IF field.mandatory %] <span class="required">Required</span>[% END %]
+[% END %]
- "<br>Example: [30] Sets purgation of suggestions for those older than 30 days."
- <br>(Used when the cronjob purge_suggestions.pl is active and called without a specific number of days)
+ -
+ - pref: UseACQFrameworkForBiblioRecords
+ default: no
+ choices:
+ yes: "Use"
+ no: "Don't use"
+ - " the framework 'ACQ' for bibliographic records fields"
Printing:
-
- Use the