@@ -, +, @@ --- Koha/BiblioFramework.pm | 18 ++++++++++++++++ admin/preferences.pl | 9 ++++++++ cataloguing/addbiblio.pl | 8 +++++++- ...r290627_set_default_bibliographic_framework.sql | 1 + .../en/modules/admin/preferences/cataloguing.pref | 5 +++++ .../prog/en/modules/tools/manage-marc-import.tt | 24 +++++++++++++++------- tools/manage-marc-import.pl | 6 ++++++ 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql --- a/Koha/BiblioFramework.pm +++ a/Koha/BiblioFramework.pm @@ -41,4 +41,22 @@ sub _type { return 'BiblioFramework'; } +=head2 GetFrameworkSources + my $sources = GetFrameworkSources(); + + Returns reference to hash of references to + the framework sources, keyed on frameworkcode. +=cut + +sub GetFrameworkSources { + my %framework_sources = (); + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM `biblio_framework`"); + $sth->execute(); + while (my $source = $sth->fetchrow_hashref) { + $framework_sources{ $source->{'frameworkcode'} } = $source; + } + return \%framework_sources; + } + 1; --- a/admin/preferences.pl +++ a/admin/preferences.pl @@ -29,6 +29,7 @@ use C4::Log; use C4::Output; use C4::Templates; use Koha::Acquisition::Currencies; +use Koha::BiblioFramework; use File::Spec; use IO::File; use YAML::Syck qw(); @@ -89,6 +90,14 @@ sub _get_chunk { if ( $options{'choices'} eq 'class-sources' ) { my $sources = GetClassSources(); $options{'choices'} = { map { $_ => $sources->{$_}->{'description'} } keys %$sources }; + } elsif ( $options{'choices'} eq 'framework-sources' ) { + my $sources = Koha::BiblioFramework::GetFrameworkSources(); + + #Add framework to syspref dropdown with a frameworkcode of 'Default' so users can choose to not use + #custom bibliographic frameworks as default bib framework + $sources->{'Default'}->{'frameworkcode'} = 'Default'; + + $options{'choices'} = { map { $_ => $sources->{$_}->{'frameworkcode'} } keys %$sources }; } elsif ( $options{'choices'} eq 'opac-templates' ) { $options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) } } elsif ( $options{'choices'} eq 'staff-templates' ) { --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -35,6 +35,7 @@ use C4::ClassSource; use C4::ImportBatch; use C4::Charset; use Koha::BiblioFrameworks; +use Koha::BiblioFramework; use Koha::DateUtils; use Koha::ItemTypes; @@ -709,7 +710,12 @@ if ($frameworkcode eq 'FA'){ $userflags = 'fast_cataloging'; } -$frameworkcode = '' if ( $frameworkcode eq 'Default' ); +if (( C4::Context->preference("DefaultBibliographicFramework") && C4::Context->preference("DefaultBibliographicFramework") ne 'Default' )) { + $frameworkcode = C4::Context->preference("DefaultBibliographicFramework"); +} else { + $frameworkcode = '' if ( $frameworkcode eq 'Default' ); +} + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "cataloguing/addbiblio.tt", --- a/installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql +++ a/installer/data/mysql/atomicupdate/wr290627_set_default_bibliographic_framework.sql @@ -0,0 +1, @@ +INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('DefaultBibliographicFramework','Default',NULL,'Default bibliographic framework used by the Cataloging framework','FrameworkSources'); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -7,6 +7,11 @@ Cataloging: choices: class-sources - as the default classification source. - + - Use + - pref: DefaultBibliographicFramework + choices: framework-sources + - as the default bibliographic framework to be used by cataloging module. + - - pref: advancedMARCeditor choices: yes: "Don't display" --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -1,5 +1,6 @@ [% USE raw %] [% USE Asset %] +[% USE Koha %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Manage staged MARC records @@ -203,15 +204,24 @@ <input type="hidden" name="import_batch_id" value="[% import_batch_id | html %]" /> <fieldset class="action"> [% IF ( record_type != 'auth' ) %] - Add new bibliographic records into this framework: - <select name="framework" id="frameworks"> - <option value="">Default</option> - [% FOREACH framework IN frameworks %] - <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option> - [% END %] - </select> + Add new bibliographic records into this framework: + <select name="framework" id="frameworks"> + + [% IF defaultframework %] + <option value="[% defaultframework.frameworkcode | html %]" selected="selected">[% defaultframework.frameworktext | html %]</option> + [% ELSE %] + <option value="" selected="selected">Default</option> + [% END %] + + [% FOREACH framework IN frameworks %] + [% IF defaultframework.frameworkcode != framework.frameworkcode %] + <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option> + [% END %] + [% END %] + </select> [% END %] <br/> + <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" /> </fieldset> </form> --- a/tools/manage-marc-import.pl +++ a/tools/manage-marc-import.pl @@ -63,7 +63,13 @@ our $sessionID = $cookies{'CGISESSID'}->value; our $dbh = C4::Context->dbh; my $frameworks = Koha::BiblioFrameworks->search({ tagfield => { 'not' => undef } }, { join => 'marc_tag_structure', distinct => 'frameworkcode', order_by => ['frameworktext'] }); + $template->param( frameworks => $frameworks ); +if ( (C4::Context->preference('DefaultBibliographicFramework') && C4::Context->preference('DefaultBibliographicFramework') ne 'Default')) { + my $frameworkcode = C4::Context->preference('DefaultBibliographicFramework'); + my $defaultframework = Koha::BiblioFrameworks->find($frameworkcode); + $template->param( defaultframework => $defaultframework ); +} if ($op eq "create_labels") { #create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list. --