From 7592fb0c2b1d6657a7db15c9eed1775537a9d48b Mon Sep 17 00:00:00 2001 From: simith Date: Fri, 8 Aug 2014 15:04:49 -0400 Subject: [PATCH] Bug 8643 - Add important constraint to marc subfields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix permits to add an "Important" option to the marc structure pages. Testing: I Apply the patch II Run updatedatabase.pl 0) Define 100 as an "important" field ( Administration » MARC bibliographic framework » MARC structure ( Default Frameword) » Edit ) 1) Define 100$a as an "important" subfield (Administration » MARC bibliographic framework » MARC structure (Default Frameword) » Subfield » Onglet a) 2) Edit a record to clear the field 100 3) Save the record. 4) Validate the following message: A few important fields are not filled: * tag 100 subfield a Nom de personne in tab * Field 100 is important, at least one of its subfields should be filled. Are you sure you want to save? sponsored by the CCSR ( http://www.ccsr.qc.ca ) --- C4/Biblio.pm | 12 ++- admin/marc_subfields_structure.pl | 24 ++++- admin/marctagstructure.pl | 18 +++- cataloguing/addbiblio.pl | 9 +- installer/data/mysql/kohastructure.sql | 25 ++--- installer/data/mysql/updatedatabase.pl | 8 ++ .../en/modules/admin/marc_subfields_structure.tt | 2 + .../prog/en/modules/admin/marctagstructure.tt | 12 ++- .../prog/en/modules/cataloguing/addbiblio.tt | 119 ++++++++++++++++++++- 9 files changed, 199 insertions(+), 30 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index d465cf6..810d472 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1118,23 +1118,24 @@ sub GetMarcStructure { # my ($total) = $sth->fetchrow; # $frameworkcode = "" unless ( $total > 0 ); my $sth = $dbh->prepare( - "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable + "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,important FROM marc_tag_structure WHERE frameworkcode=? ORDER BY tagfield" ); $sth->execute($frameworkcode); - my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable ); + my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $important ); - while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) { + while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $important ) = $sth->fetchrow ) { $res->{$tag}->{lib} = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac; $res->{$tag}->{tab} = ""; $res->{$tag}->{mandatory} = $mandatory; + $res->{$tag}->{important} = $important; $res->{$tag}->{repeatable} = $repeatable; } $sth = $dbh->prepare( - "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength + "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important FROM marc_subfield_structure WHERE frameworkcode=? ORDER BY tagfield,tagsubfield @@ -1158,13 +1159,14 @@ sub GetMarcStructure { while ( ( $tag, $subfield, $liblibrarian, $libopac, $tab, $mandatory, $repeatable, $authorised_value, $authtypecode, $value_builder, $kohafield, $seealso, $hidden, $isurl, $link, $defaultvalue, - $maxlength + $maxlength, $important ) = $sth->fetchrow ) { $res->{$tag}->{$subfield}->{lib} = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac; $res->{$tag}->{$subfield}->{tab} = $tab; $res->{$tag}->{$subfield}->{mandatory} = $mandatory; + $res->{$tag}->{$subfield}->{important} = $important; $res->{$tag}->{$subfield}->{repeatable} = $repeatable; $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value; $res->{$tag}->{$subfield}->{authtypecode} = $authtypecode; diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 475555e..d4ed01c 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -228,6 +228,13 @@ if ( $op eq 'add_form' ) { -label => '', -id => "mandatory$i" ); + $row_data{important} = CGI::checkbox( + -name => "important$i", + -checked => $data->{'important'} ? 'checked' : '', + -value => 1, + -label => '', + -id => "important$i" + ); $row_data{hidden} = CGI::escapeHTML( $data->{hidden} ); $row_data{isurl} = CGI::checkbox( -name => "isurl$i", @@ -279,6 +286,13 @@ if ( $op eq 'add_form' ) { -value => 1, -label => '' ); + $row_data{important} = CGI::checkbox( + -name => "important$i", + -id => "important$i", + -checked => '', + -value => 1, + -label => '' + ); $row_data{isurl} = CGI::checkbox( -name => "isurl$i", -id => "isurl$i", @@ -327,11 +341,11 @@ elsif ( $op eq 'add_validate' ) { # values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" # ); my $sth_insert = $dbh->prepare(qq{ - insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue,maxlength) - values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + insert into marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,important,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl,frameworkcode, link,defaultvalue,maxlength) + values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }); my $sth_update = $dbh->prepare(qq{ - update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?, link=?, defaultvalue=?, maxlength=? + update marc_subfield_structure set tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, important=?, kohafield=?, tab=?, seealso=?, authorised_value=?, authtypecode=?, value_builder=?, hidden=?, isurl=?, frameworkcode=?, link=?, defaultvalue=?, maxlength=? where tagfield=? and tagsubfield=? and frameworkcode=? }); my @tagsubfield = $input->param('tagsubfield'); @@ -357,6 +371,7 @@ elsif ( $op eq 'add_validate' ) { my $libopac = $libopac[$i]; my $repeatable = $input->param("repeatable$i") ? 1 : 0; my $mandatory = $input->param("mandatory$i") ? 1 : 0; + my $important = $input->param("important$i") ? 1 : 0; my $kohafield = $kohafield[$i]; my $tab = $tab[$i]; my $seealso = $seealso[$i]; @@ -379,6 +394,7 @@ elsif ( $op eq 'add_validate' ) { $libopac, $repeatable, $mandatory, + $important, $kohafield, $tab, $seealso, @@ -405,6 +421,7 @@ elsif ( $op eq 'add_validate' ) { $libopac, $repeatable, $mandatory, + $important, $kohafield, $tab, $seealso, @@ -484,6 +501,7 @@ else { # DEFAULT $row_data{kohafield} = $results->[$i]{'kohafield'}; $row_data{repeatable} = $results->[$i]{'repeatable'}; $row_data{mandatory} = $results->[$i]{'mandatory'}; + $row_data{important} = $results->[$i]{'important'}; $row_data{tab} = $results->[$i]{'tab'}; $row_data{seealso} = $results->[$i]{'seealso'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 3ff48b4..55f900f 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -96,7 +96,7 @@ if ($op eq 'add_form') { #---- if primkey exists, it's a modify action, so read values to modify... my $data; if ($searchfield) { - $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?"); + $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value, important from marc_tag_structure where tagfield=? and frameworkcode=?"); $sth->execute($searchfield,$frameworkcode); $data=$sth->fetchrow_hashref; } @@ -128,6 +128,7 @@ if ($op eq 'add_form') { libopac => $data->{'libopac'}, repeatable => $data->{'repeatable'}, mandatory => $data->{'mandatory'}, + important => $data->{'important'}, authorised_value => $authorised_value, frameworkcode => $frameworkcode, ); # FIXME: move checkboxes to presentation layer @@ -140,23 +141,25 @@ if ($op eq 'add_form') { my $libopac = $input->param('libopac'); my $repeatable = $input->param('repeatable') ? 1 : 0; my $mandatory = $input->param('mandatory') ? 1 : 0; + my $important = $input->param('important') ? 1 : 0; my $authorised_value = $input->param('authorised_value'); unless (C4::Context->config('demo')) { if ($input->param('modif')) { $sth = $dbh->prepare( - "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?" + "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,important=?, authorised_value=? WHERE frameworkcode=? AND tagfield=?" ); $sth->execute( $liblibrarian, $libopac, $repeatable, $mandatory, + $important, $authorised_value, $frameworkcode, $tagfield ); } else { $sth = $dbh->prepare( - "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)" + "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode,important) values (?,?,?,?,?,?,?,?)" ); $sth->execute($tagfield, $liblibrarian, @@ -164,7 +167,8 @@ if ($op eq 'add_form') { $repeatable, $mandatory, $authorised_value, - $frameworkcode + $frameworkcode, + $important ); } } @@ -232,6 +236,7 @@ if ($op eq 'add_form') { marc_tag_structure.libopac as mts_libopac, marc_tag_structure.repeatable as mts_repeatable, marc_tag_structure.mandatory as mts_mandatory, + marc_tag_structure.important as mts_important, marc_tag_structure.authorised_value as mts_authorized_value, marc_subfield_structure.* FROM marc_tag_structure @@ -253,6 +258,7 @@ if ($op eq 'add_form') { $row_data{liblibrarian} = $results[$i]->{'mts_liblibrarian'}; $row_data{repeatable} = $results[$i]->{'mts_repeatable'}; $row_data{mandatory} = $results[$i]->{'mts_mandatory'}; + $row_data{important} = $results[$i]->{'mts_important'}; $row_data{authorised_value} = $results[$i]->{'mts_authorised_value'}; $row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode; $row_data{edit} = "$script_name?op=add_form&searchfield=" .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode; @@ -266,6 +272,7 @@ if ($op eq 'add_form') { $subfield_data{kohafield} = $results[$j]->{'kohafield'}; $subfield_data{repeatable} = $results[$j]->{'repeatable'}; $subfield_data{mandatory} = $results[$j]->{'mandatory'}; + $subfield_data{important} = $results[$j]->{'important'}; $subfield_data{tab} = $results[$j]->{'tab'}; $subfield_data{seealso} = $results[$j]->{'seealso'}; $subfield_data{authorised_value} = $results[$j]->{'authorised_value'}; @@ -292,6 +299,7 @@ if ($op eq 'add_form') { $row_data{liblibrarian} = $results->[$i]{'liblibrarian'}; $row_data{repeatable} = $results->[$i]{'repeatable'}; $row_data{mandatory} = $results->[$i]{'mandatory'}; + $row_data{important} = $results->[$i]{'important'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; $row_data{subfield_link} = "marc_subfields_structure.pl?tagfield=" .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode; $row_data{edit} = "$script_name?op=add_form&searchfield=" .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode; @@ -325,7 +333,7 @@ output_html_with_http_headers $input, $cookie, $template->output; sub StringSearch { my ($searchstring,$frameworkcode)=@_; my $sth = C4::Context->dbh->prepare(" - SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value + SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important FROM marc_tag_structure WHERE (tagfield >= ? and frameworkcode=?) ORDER BY tagfield diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 5b06706..7dd0b42 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -326,6 +326,7 @@ sub create_input { marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, tag_mandatory => $tagslib->{$tag}->{mandatory}, mandatory => $tagslib->{$tag}->{$subfield}->{mandatory}, + important => $tagslib->{$tag}->{$subfield}->{important}, repeatable => $tagslib->{$tag}->{$subfield}->{repeatable}, kohafield => $tagslib->{$tag}->{$subfield}->{kohafield}, index => $index_tag, @@ -339,13 +340,15 @@ sub create_input { $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield}; } # Subfield is hidden depending of hidden and mandatory flag, and is always - # shown if it contains anything or if its field is mandatory. + # shown if it contains anything or if its field is mandatory or important. my $tdef = $tagslib->{$tag}; $subfield_data{visibility} = "display:none;" if $tdef->{$subfield}->{hidden} % 2 == 1 && $value eq '' && !$tdef->{$subfield}->{mandatory} && - !$tdef->{mandatory}; + !$tdef->{mandatory} && + !$tdef->{$subfield}->{important} && + !$tdef->{important}; # expand all subfields of 773 if there is a host item provided in the input $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber')); @@ -634,6 +637,7 @@ sub build_tabs { tag_lib => $tagslib->{$tag}->{lib}, repeatable => $tagslib->{$tag}->{repeatable}, mandatory => $tagslib->{$tag}->{mandatory}, + important => $tagslib->{$tag}->{important}, subfield_loop => \@subfields_data, fixedfield => $tag < 10?1:0, random => CreateKey, @@ -680,6 +684,7 @@ sub build_tabs { tag_lib => $tagslib->{$tag}->{lib}, repeatable => $tagslib->{$tag}->{repeatable}, mandatory => $tagslib->{$tag}->{mandatory}, + important => $tagslib->{$tag}->{important}, indicator1 => $indicator1, indicator2 => $indicator2, subfield_loop => \@subfields_data, diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b46dc6a..2e82d89 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2,7 +2,7 @@ -- -- Host: localhost Database: koha30test -- ------------------------------------------------------ --- Server version 4.1.22 +-- Server version 4.1.22 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1376,6 +1376,7 @@ CREATE TABLE `marc_subfield_structure` ( `libopac` varchar(255) NOT NULL default '', `repeatable` tinyint(4) NOT NULL default 0, `mandatory` tinyint(4) NOT NULL default 0, + `important` tinyint(4) NOT NULL DEFAULT '0', `kohafield` varchar(40) default NULL, `tab` tinyint(1) default NULL, `authorised_value` varchar(20) default NULL, @@ -1407,6 +1408,7 @@ CREATE TABLE `marc_tag_structure` ( `mandatory` tinyint(4) NOT NULL default 0, `authorised_value` varchar(10) default NULL, `frameworkcode` varchar(4) NOT NULL default '', + `important` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`frameworkcode`,`tagfield`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -2174,10 +2176,10 @@ CREATE TABLE `suggestions` ( -- purchase suggestions branchcode VARCHAR(10) default NULL, -- foreign key linking the suggested branch to the branches table collectiontitle text default NULL, -- collection name for the suggested item itemtype VARCHAR(30) default NULL, -- suggested item type - quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased - currency VARCHAR(3) default NULL, -- suggested currency for the suggested price - price DECIMAL(28,6) default NULL, -- suggested price - total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency) + quantity SMALLINT(6) default NULL, -- suggested quantity to be purchased + currency VARCHAR(3) default NULL, -- suggested currency for the suggested price + price DECIMAL(28,6) default NULL, -- suggested price + total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency) PRIMARY KEY (`suggestionid`), KEY `suggestedby` (`suggestedby`), KEY `managedby` (`managedby`) @@ -2475,12 +2477,12 @@ CREATE TABLE `permissions` ( DROP TABLE IF EXISTS `serialitems`; CREATE TABLE `serialitems` ( - `itemnumber` int(11) NOT NULL, - `serialid` int(11) NOT NULL, - UNIQUE KEY `serialitemsidx` (`itemnumber`), - KEY `serialitems_sfk_1` (`serialid`), - CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE + `itemnumber` int(11) NOT NULL, + `serialid` int(11) NOT NULL, + UNIQUE KEY `serialitemsidx` (`itemnumber`), + KEY `serialitems_sfk_1` (`serialid`), + CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -3430,4 +3432,3 @@ CREATE TABLE IF NOT EXISTS `misc_files` ( -- miscellaneous files attached to rec /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3f1af57..af40703 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8603,6 +8603,14 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE `marc_subfield_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0 AFTER `mandatory`"); + $dbh->do("ALTER TABLE `marc_tag_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0 AFTER `frameworkcode`"); + print "Upgrade to $DBversion done (Bug 8643 - Add important constraint to marc subfields)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt index c12ddf1..158fe48 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt @@ -229,6 +229,7 @@ function populateHiddenCheckboxes(tab) {
  • [% loo.repeatable %]
  • [% loo.mandatory %]
  • +
  • [% loo.important %]
  • [% END %]
  • +
  • + [% IF ( important ) %] + + [% ELSE %] + + [% END %] +
  • [% authorised_value %] (if you select a value here, the indicators will be limited to the authorized value list)
  • @@ -173,6 +180,7 @@ $(document).ready(function() { Lib Repeatable Mandatory + Important Auth value Subfields Edit @@ -187,6 +195,7 @@ $(document).ready(function() { [% loo.liblibrarian %] [% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %] [% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %] + [% IF ( loo.important ) %]Yes[% ELSE %]No[% END %] [% loo.authorised_value %] subfields Edit @@ -197,7 +206,7 @@ $(document).ready(function() { [% FOREACH subfield IN loo.subfields %]

    Tab:[% subfield.tab %] | $[% subfield.tagsubfield %] - [% subfield.liblibrarian %] [% IF ( subfield.kohafield ) %][% subfield.kohafield %][% END %][% IF ( subfield.repeatable ) %], repeatable[% END %][% IF ( subfield.mandatory ) %], Mandatory[% END %][% IF ( subfield.seealso ) %], See [% subfield.seealso %][% END %][% IF ( subfield.authorised_value ) %], [% subfield.authorised_value %][% END %][% IF ( subfield.authtypecode ) %], [% subfield.authtypecode %][% END %][% IF ( subfield.value_builder ) %], [% subfield.value_builder %][% END %] + [% subfield.liblibrarian %] [% IF ( subfield.kohafield ) %][% subfield.kohafield %][% END %][% IF ( subfield.repeatable ) %], repeatable[% END %][% IF ( subfield.mandatory ) %], Mandatory[% END %][% IF ( subfield.important ) %], Important[% END %][% IF ( subfield.seealso ) %], See [% subfield.seealso %][% END %][% IF ( subfield.authorised_value ) %], [% subfield.authorised_value %][% END %][% IF ( subfield.authtypecode ) %], [% subfield.authtypecode %][% END %][% IF ( subfield.value_builder ) %], [% subfield.value_builder %][% END %]

    [% END %] @@ -210,6 +219,7 @@ $(document).ready(function() { [% loo.liblibrarian %] [% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %] [% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %] + [% IF ( loo.important ) %]Yes[% ELSE %]No[% END %] [% loo.authorised_value %] Subfields Edit diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 5dc1a5f..856f999 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -222,7 +222,7 @@ function AreMandatoriesNotOk(){ var flag=0; var tabflag= new Array(); [% FOREACH BIG_LOO IN BIG_LOOP %] - [% FOREACH innerloo IN BIG_LOO.innerloop %] + [% FOREACH innerloo IN BIG_LOO.innerloop %] [% IF ( innerloo.mandatory ) %] mandatoriesfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]")); [% END %] @@ -308,7 +308,7 @@ function AreMandatoriesNotOk(){ if(isempty){ flag = 1; - StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n"; + StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n"; } } @@ -327,6 +327,13 @@ function AreMandatoriesNotOk(){ function Check(){ var StrAlert = AreMandatoriesNotOk(); if( ! StrAlert ){ + var StrWarning = AreImportantsNotOk(); + if (StrWarning){ + var r=confirm(StrWarning); + if (! r){ + return false; + } + } document.f.submit(); return true; } else { @@ -336,6 +343,113 @@ function Check(){ } /** + * check if mandatory subfields are written + */ +function AreImportantsNotOk(){ + var importants = new Array(); + var importantsfields = new Array(); + var tab = new Array(); + var label = new Array(); + var flag=0; + var tabflag= new Array(); + [% FOREACH BIG_LOO IN BIG_LOOP %] + [% FOREACH innerloo IN BIG_LOO.innerloop %] + [% IF ( innerloo.important ) %] + importantsfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]")); + [% END %] + [% FOREACH subfield_loo IN innerloo.subfield_loop %] + [% IF ( subfield_loo.important ) %]importants.push("[% subfield_loo.id %]"); + tab.push("[% subfield_loo.number %]"); + label.push("[% subfield_loo.marc_lib %]"); + [% END %] + [% END %] + [% END %] + [% END %] + var StrWarning = _("A few important fields are not filled:"); + StrWarning += "\n\n"; + for(var i=0,len=importants.length; i= 10){ + elem = document.getElementById(divid); + eleminputs = elem.getElementsByTagName('input'); + for(var j=0,len2=eleminputs.length; j[% ELSE %][% END %] [% subfield_loo.marc_lib_plain %] [% IF ( subfield_loo.mandatory ) %]*[% END %] + [% IF ( subfield_loo.important ) %]*[% END %] [% END %] -- 1.9.1