Bugzilla – Attachment 11621 Details for
Bug 8643
Add ability to mark some MARC tags and subfields as important and alert on saving the record if they are found to be empty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed enhancement patch
0001-Add-an-Important-field-to-the-marc-structure-pages.-.patch (text/plain), 28.99 KB, created by
Maxime Pelletier
on 2012-08-14 19:17:12 UTC
(
hide
)
Description:
proposed enhancement patch
Filename:
MIME Type:
Creator:
Maxime Pelletier
Created:
2012-08-14 19:17:12 UTC
Size:
28.99 KB
patch
obsolete
>From d7b8d14d27016aef886b41a6bfe1daa704a8381a Mon Sep 17 00:00:00 2001 >From: Maxime Pelletier <maxime.pelletier@libeo.com> >Date: Tue, 14 Aug 2012 14:42:45 -0400 >Subject: [PATCH] Bug 8643 >Add an "Important" field to the marc structure pages. It works the same way as "Mandatory", but it oupts a non blocking alert if the field is not filled. >Sponsored by the CCSR. > >--- > C4/Biblio.pm | 12 +- > admin/marc_subfields_structure.pl | 24 ++++- > admin/marctagstructure.pl | 22 +++- > cataloguing/addbiblio.pl | 10 +- > installer/data/mysql/kohastructure.sql | 2 + > installer/data/mysql/updatedatabase.pl | 8 ++ > .../en/modules/admin/marc_subfields_structure.tt | 2 + > .../prog/en/modules/admin/marctagstructure.tt | 8 +- > .../prog/en/modules/cataloguing/addbiblio.tt | 117 ++++++++++++++++++++ > 9 files changed, 187 insertions(+), 18 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index fb052bb..cd5ba5d 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1066,23 +1066,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 >@@ -1106,13 +1107,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 bc6636a..f1eec38 100755 >--- a/admin/marc_subfields_structure.pl >+++ b/admin/marc_subfields_structure.pl >@@ -259,6 +259,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", >@@ -331,6 +338,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", >@@ -386,11 +400,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'); >@@ -416,6 +430,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]; >@@ -438,6 +453,7 @@ elsif ( $op eq 'add_validate' ) { > $libopac, > $repeatable, > $mandatory, >+ $important, > $kohafield, > $tab, > $seealso, >@@ -464,6 +480,7 @@ elsif ( $op eq 'add_validate' ) { > $libopac, > $repeatable, > $mandatory, >+ $important, > $kohafield, > $tab, > $seealso, >@@ -543,6 +560,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 a86d788..48deede 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; > } >@@ -136,6 +136,11 @@ if ($op eq 'add_form') { > -value => 1, > -label => '', > -id => 'mandatory'), >+ important => CGI::checkbox(-name => 'important', >+ -checked => $data->{'important'}?'checked':'', >+ -value => 1, >+ -label => '', >+ -id => 'important'), > authorised_value => $authorised_value, > frameworkcode => $frameworkcode, > ); # FIXME: move checkboxes to presentation layer >@@ -148,23 +153,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') == 1) { > 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, >@@ -172,7 +179,8 @@ if ($op eq 'add_form') { > $repeatable, > $mandatory, > $authorised_value, >- $frameworkcode >+ $frameworkcode, >+ $important > ); > } > } >@@ -240,6 +248,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 >@@ -261,6 +270,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; >@@ -274,6 +284,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'}; >@@ -300,6 +311,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; >@@ -333,7 +345,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 d9edf7a..0f48c74 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -320,6 +320,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, >@@ -333,17 +334,18 @@ 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')); > >- > # it's an authorised field > if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { > $subfield_data{marc_value} = >@@ -647,6 +649,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, >@@ -693,6 +696,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 488a4f0..b07b06e 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1211,6 +1211,7 @@ CREATE TABLE `marc_subfield_structure` ( > `link` varchar(80) default NULL, > `defaultvalue` text default NULL, > `maxlength` int(4) NOT NULL DEFAULT '9999', >+ `important` TINYINT(4) NOT NULL DEFAULT 0, > PRIMARY KEY (`frameworkcode`,`tagfield`,`tagsubfield`), > KEY `kohafield_2` (`kohafield`), > KEY `tab` (`frameworkcode`,`tab`), >@@ -1230,6 +1231,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; > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 2d4d2ab..5a95bdc 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5249,6 +5249,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = 'XXX'; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("ALTER TABLE `marc_subfield_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0 AFTER `mandatory` ; >+ ALTER TABLE `marc_tag_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0 AFTER `frameworkcode` ;"); >+ print "Upgrade to $DBversion done (Add mandatory to marc frameworks)\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 03fac60..59c5e8d 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 >@@ -100,6 +100,7 @@ $(document).ready(function() { > <li><label for="libopac[% loo.row %]">Text for OPAC: </label><input type="text" id="libopac[% loo.row %]" name="libopac" value="[% loo.libopac %]" size="40" maxlength="80" /></li> > <li><label for="repeatable[% loo.row %]">Repeatable: </label>[% loo.repeatable %]</li> > <li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li> >+ <li><label for="important[% loo.row %]">Important: </label>[% loo.important %]</li> > <li><label for="tab[% loo.row %]">Managed in tab: </label>[% loo.tab %] (ignore means that the subfield does not display in the record editor)</li> > </ol> > </fieldset> >@@ -200,6 +201,7 @@ $(document).ready(function() { > [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield %], [% END %] > [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %] > [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %] >+ [% IF ( loo.important ) %]Important, [% ELSE %]Not important,[% END %] > [% IF ( loo.seealso ) %] | See Also: [% loo.seealso %],[% END %] > [% IF ( loo.hidden ) %]hidden,[% END %] > [% IF ( loo.isurl ) %]is a URL,[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >index d0f0132..64b2547 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt >@@ -84,6 +84,7 @@ $(document).ready(function() { > <li><label for="libopac">Label for opac: </label><input type="text" id="libopac" name="libopac" value="[% libopac |html %]" size="40" maxlength="100" /></li> > <li><label for="repeatable">Repeatable: </label>[% repeatable %]</li> > <li><label for="mandatory">Mandatory: </label>[% mandatory %]</li> >+ <li><label for="important">Important: </label>[% important %]</li> > <li><label for="authorised_value">Authorized value: </label>[% authorised_value %] (if you select a value here, the indicators will be limited to the authorized value list)</li> > </ol></fieldset> > <fieldset class="action"> >@@ -166,6 +167,7 @@ $(document).ready(function() { > <th>Lib</th> > <th>Repeatable</th> > <th>Mandatory</th> >+ <th>Important</th> > <th>Auth value</th> > <th>Subfields</th> > <th>Edit</th> >@@ -179,6 +181,7 @@ $(document).ready(function() { > <td>[% loo.liblibrarian %]</td> > <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td> >+ <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% loo.authorised_value %]</td> > <td><a href="[% loo.subfield_link %]">subfields</a></td> > <td><a href="[% loo.edit %]">Edit</a></td> >@@ -188,8 +191,8 @@ $(document).ready(function() { > <td> </td> > <td colspan="7"> > [% FOREACH subfield IN loo.subfields %] >- <p> 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 %] >+ <p> 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.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 %] > </p> > [% END %] > </td> >@@ -202,6 +205,7 @@ $(document).ready(function() { > <td>[% loo.liblibrarian %]</td> > <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td> >+ <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td> > <td>[% loo.authorised_value %]</td> > <td><a href="[% loo.subfield_link %]">Subfields</a></td> > <td><a href="[% loo.edit %]">Edit</a></td> >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 b61e543..d6154f3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -55,6 +55,13 @@ function confirmnotdup(redirect){ > 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 { >@@ -236,6 +243,115 @@ function AreMandatoriesNotOk(){ > } > > /** >+ * 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<len ; i++){ >+ var tag=importants[i].substr(4,3); >+ var subfield=importants[i].substr(17,1); >+ var tagnumber=importants[i].substr(19,importants[i].lastIndexOf("_")-19); >+ tabflag[tag+subfield+tagnumber]=new Array(); >+ tabflag[tag+subfield+tagnumber][0]=0; >+ if( ! document.getElementById(importants[i]).value){ >+ tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ; >+ document.getElementById(importants[i]).setAttribute('class','subfield_not_filled'); >+ document.getElementById(importants[i]).focus(); >+ tabflag[tag+subfield+tagnumber][1]=label[i]; >+ tabflag[tag+subfield+tagnumber][2]=tab[i]; >+ } else { >+ tabflag[tag+subfield+tagnumber][0] = 1; >+ } >+ } >+ for (var tagsubfieldid in tabflag){ >+ if (tabflag[tagsubfieldid][0]==0){ >+ var tag=tagsubfieldid.substr(0,3); >+ var subfield=tagsubfieldid.substr(3,1); >+ StrWarning += "\t* "+_("tag ")+tag+_(" subfield ")+subfield+" "+tabflag[tagsubfieldid][1]+_(" in tab ")+tabflag[tagsubfieldid][2]+"\n"; >+ //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n"; >+ flag=1; >+ } >+ } >+ >+ /* Check for mandatories field(not subfields) */ >+ for(var i=0,len=importantsfields.length; i<len; i++){ >+ isempty = true; >+ arr = importantsfields[i]; >+ divid = "tag_" + arr[0] + "_" + arr[1]; >+ varegexp = new RegExp("^tag_" + arr[0] + "_code_"); >+ >+ if(parseInt(arr[0]) >= 10){ >+ elem = document.getElementById(divid); >+ eleminputs = elem.getElementsByTagName('input'); >+ >+ for(var j=0,len2=eleminputs.length; j<len2; j++){ >+ >+ if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){ >+ inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); >+ >+ for( var k=0; k<len2; k++){ >+ if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){ >+ isempty = false >+ } >+ } >+ >+ elemselect = elem.getElementsByTagName('select'); >+ for( var k=0; k<elemselect.length; k++){ >+ if(elemselect[k].id.match(inputregexp) && elemselect[k].value){ >+ isempty = false >+ } >+ } >+ } >+ } >+ >+ elemtextareas = elem.getElementsByTagName('textarea'); >+ for(var j=0,len2=elemtextareas.length; j<len2; j++){ >+ // this bit assumes that the only textareas in this context would be for subfields >+ if (elemtextareas[j].value) { >+ isempty = false; >+ } >+ } >+ }else{ >+ isempty = false; >+ } >+ >+ if(isempty){ >+ flag = 1; >+ StrWarning += _("\t* Field ") + arr[0] + _(" is important, at least one of its subfields should be filled.") + "\n"; >+ } >+ >+ } >+ >+ StrWarning += "\n" + _("Are you sure you want to save?"); >+ >+ if(flag){ >+ return StrWarning; >+ } else { >+ return flag; >+ } >+} >+ >+/** > * check if z3950 mandatories are set or not > */ > function GetZ3950Terms(){ >@@ -885,6 +1001,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ? > [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %] > [% subfield_loo.marc_lib_plain %] > [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %] >+ [% IF ( subfield_loo.important ) %]<span style="color:black" title="This field is important">*</span>[% END %] > </span> > </label> > [% END %] >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8643
:
11621
|
11622
|
30640
|
31032
|
40232
|
40237
|
41259
|
41261
|
41264
|
41265
|
45834
|
45835
|
45836
|
45837
|
60554
|
60555
|
65148
|
65149
|
65682
|
72154
|
72155
|
72156
|
72157
|
73591
|
73808
|
73809
|
73810
|
73811
|
73812
|
73813
|
73814
|
73815
|
73816
|
73817
|
73818
|
74267
|
74268
|
74269
|
74270
|
74271
|
74272
|
74273
|
81032
|
85982
|
91537
|
92081
|
92384
|
96625
|
96627
|
97325
|
97326
|
98607
|
98608
|
98702
|
98703
|
98712