View | Details | Raw Unified | Return to bug 8643
Collapse All | Expand All

(-)a/C4/Biblio.pm (-5 / +7 lines)
Lines 1102-1124 sub GetMarcStructure { Link Here
1102
    return $cached if $cached;
1102
    return $cached if $cached;
1103
1103
1104
    my $sth = $dbh->prepare(
1104
    my $sth = $dbh->prepare(
1105
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
1105
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,important
1106
        FROM marc_tag_structure 
1106
        FROM marc_tag_structure 
1107
        WHERE frameworkcode=? 
1107
        WHERE frameworkcode=? 
1108
        ORDER BY tagfield"
1108
        ORDER BY tagfield"
1109
    );
1109
    );
1110
    $sth->execute($frameworkcode);
1110
    $sth->execute($frameworkcode);
1111
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
1111
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $important );
1112
1112
1113
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
1113
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $important ) = $sth->fetchrow ) {
1114
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1114
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1115
        $res->{$tag}->{tab}        = "";
1115
        $res->{$tag}->{tab}        = "";
1116
        $res->{$tag}->{mandatory}  = $mandatory;
1116
        $res->{$tag}->{mandatory}  = $mandatory;
1117
        $res->{$tag}->{important}  = $important;
1117
        $res->{$tag}->{repeatable} = $repeatable;
1118
        $res->{$tag}->{repeatable} = $repeatable;
1118
    }
1119
    }
1119
1120
1120
    $sth = $dbh->prepare(
1121
    $sth = $dbh->prepare(
1121
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength
1122
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important
1122
         FROM   marc_subfield_structure 
1123
         FROM   marc_subfield_structure 
1123
         WHERE  frameworkcode=? 
1124
         WHERE  frameworkcode=? 
1124
         ORDER BY tagfield,tagsubfield
1125
         ORDER BY tagfield,tagsubfield
Lines 1142-1154 sub GetMarcStructure { Link Here
1142
    while (
1143
    while (
1143
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
1144
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
1144
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
1145
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
1145
            $maxlength
1146
            $maxlength, $important
1146
        )
1147
        )
1147
        = $sth->fetchrow
1148
        = $sth->fetchrow
1148
      ) {
1149
      ) {
1149
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1150
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1150
        $res->{$tag}->{$subfield}->{tab}              = $tab;
1151
        $res->{$tag}->{$subfield}->{tab}              = $tab;
1151
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
1152
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
1153
        $res->{$tag}->{$subfield}->{important}        = $important;
1152
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
1154
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
1153
        $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
1155
        $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
1154
        $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
1156
        $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
(-)a/admin/marc_subfields_structure.pl (-3 / +21 lines)
Lines 230-235 if ( $op eq 'add_form' ) { Link Here
230
            -label    => '',
230
            -label    => '',
231
            -id       => "mandatory$i"
231
            -id       => "mandatory$i"
232
        );
232
        );
233
        $row_data{important} = CGI::checkbox(
234
            -name     => "important$i",
235
            -checked  => $data->{'important'} ? 'checked' : '',
236
            -value    => 1,
237
            -label    => '',
238
            -id       => "important$i"
239
        );
233
        $row_data{hidden} = CGI::escapeHTML( $data->{hidden} );
240
        $row_data{hidden} = CGI::escapeHTML( $data->{hidden} );
234
        $row_data{isurl}  = CGI::checkbox(
241
        $row_data{isurl}  = CGI::checkbox(
235
            -name     => "isurl$i",
242
            -name     => "isurl$i",
Lines 281-286 if ( $op eq 'add_form' ) { Link Here
281
            -value    => 1,
288
            -value    => 1,
282
            -label    => ''
289
            -label    => ''
283
        );
290
        );
291
        $row_data{important} = CGI::checkbox(
292
            -name     => "important$i",
293
            -id       => "important$i",
294
            -checked  => '',
295
            -value    => 1,
296
            -label    => ''
297
        );
284
        $row_data{isurl} = CGI::checkbox(
298
        $row_data{isurl} = CGI::checkbox(
285
            -name     => "isurl$i",
299
            -name     => "isurl$i",
286
            -id       => "isurl$i",
300
            -id       => "isurl$i",
Lines 329-339 elsif ( $op eq 'add_validate' ) { Link Here
329
#                                     values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
343
#                                     values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
330
#     );
344
#     );
331
    my $sth_insert = $dbh->prepare(qq{
345
    my $sth_insert = $dbh->prepare(qq{
332
        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)
346
        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)
333
        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
347
        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
334
    });
348
    });
335
    my $sth_update = $dbh->prepare(qq{
349
    my $sth_update = $dbh->prepare(qq{
336
        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=?
350
        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=?
337
        where tagfield=? and tagsubfield=? and frameworkcode=?
351
        where tagfield=? and tagsubfield=? and frameworkcode=?
338
    });
352
    });
339
    my @tagsubfield       = $input->param('tagsubfield');
353
    my @tagsubfield       = $input->param('tagsubfield');
Lines 359-364 elsif ( $op eq 'add_validate' ) { Link Here
359
        my $libopac          = $libopac[$i];
373
        my $libopac          = $libopac[$i];
360
        my $repeatable       = $input->param("repeatable$i") ? 1 : 0;
374
        my $repeatable       = $input->param("repeatable$i") ? 1 : 0;
361
        my $mandatory        = $input->param("mandatory$i") ? 1 : 0;
375
        my $mandatory        = $input->param("mandatory$i") ? 1 : 0;
376
        my $important        = $input->param("important$i") ? 1 : 0;
362
        my $kohafield        = $kohafield[$i];
377
        my $kohafield        = $kohafield[$i];
363
        my $tab              = $tab[$i];
378
        my $tab              = $tab[$i];
364
        my $seealso          = $seealso[$i];
379
        my $seealso          = $seealso[$i];
Lines 381-386 elsif ( $op eq 'add_validate' ) { Link Here
381
                        $libopac,
396
                        $libopac,
382
                        $repeatable,
397
                        $repeatable,
383
                        $mandatory,
398
                        $mandatory,
399
                        $important,
384
                        $kohafield,
400
                        $kohafield,
385
                        $tab,
401
                        $tab,
386
                        $seealso,
402
                        $seealso,
Lines 407-412 elsif ( $op eq 'add_validate' ) { Link Here
407
                        $libopac,
423
                        $libopac,
408
                        $repeatable,
424
                        $repeatable,
409
                        $mandatory,
425
                        $mandatory,
426
                        $important,
410
                        $kohafield,
427
                        $kohafield,
411
                        $tab,
428
                        $tab,
412
                        $seealso,
429
                        $seealso,
Lines 488-493 else { # DEFAULT Link Here
488
        $row_data{kohafield}        = $results->[$i]{'kohafield'};
505
        $row_data{kohafield}        = $results->[$i]{'kohafield'};
489
        $row_data{repeatable}       = $results->[$i]{'repeatable'};
506
        $row_data{repeatable}       = $results->[$i]{'repeatable'};
490
        $row_data{mandatory}        = $results->[$i]{'mandatory'};
507
        $row_data{mandatory}        = $results->[$i]{'mandatory'};
508
        $row_data{important}        = $results->[$i]{'important'};
491
        $row_data{tab}              = $results->[$i]{'tab'};
509
        $row_data{tab}              = $results->[$i]{'tab'};
492
        $row_data{seealso}          = $results->[$i]{'seealso'};
510
        $row_data{seealso}          = $results->[$i]{'seealso'};
493
        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
511
        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
(-)a/admin/marctagstructure.pl (-5 / +13 lines)
Lines 98-104 if ($op eq 'add_form') { Link Here
98
	#---- if primkey exists, it's a modify action, so read values to modify...
98
	#---- if primkey exists, it's a modify action, so read values to modify...
99
	my $data;
99
	my $data;
100
	if ($searchfield) {
100
	if ($searchfield) {
101
		$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
101
        $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value, important from marc_tag_structure where tagfield=? and frameworkcode=?");
102
		$sth->execute($searchfield,$frameworkcode);
102
		$sth->execute($searchfield,$frameworkcode);
103
		$data=$sth->fetchrow_hashref;
103
		$data=$sth->fetchrow_hashref;
104
	}
104
	}
Lines 123-128 if ($op eq 'add_form') { Link Here
123
			libopac => $data->{'libopac'},
123
			libopac => $data->{'libopac'},
124
            repeatable => $data->{'repeatable'},
124
            repeatable => $data->{'repeatable'},
125
            mandatory => $data->{'mandatory'},
125
            mandatory => $data->{'mandatory'},
126
            important => $data->{'important'},
126
			authorised_value => $authorised_value,
127
			authorised_value => $authorised_value,
127
			frameworkcode => $frameworkcode,
128
			frameworkcode => $frameworkcode,
128
    );  # FIXME: move checkboxes to presentation layer
129
    );  # FIXME: move checkboxes to presentation layer
Lines 135-157 if ($op eq 'add_form') { Link Here
135
	my $libopac          = $input->param('libopac');
136
	my $libopac          = $input->param('libopac');
136
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
137
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
137
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
138
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
139
    my $important        = $input->param('important')  ? 1 : 0;
138
	my $authorised_value = $input->param('authorised_value');
140
	my $authorised_value = $input->param('authorised_value');
139
    unless (C4::Context->config('demo')) {
141
    unless (C4::Context->config('demo')) {
140
        if ($input->param('modif')) {
142
        if ($input->param('modif')) {
141
            $sth = $dbh->prepare(
143
            $sth = $dbh->prepare(
142
            "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
144
            "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,important=?, authorised_value=? WHERE frameworkcode=? AND tagfield=?"
143
            );
145
            );
144
            $sth->execute(  $liblibrarian,
146
            $sth->execute(  $liblibrarian,
145
                            $libopac,
147
                            $libopac,
146
                            $repeatable,
148
                            $repeatable,
147
                            $mandatory,
149
                            $mandatory,
150
                            $important,
148
                            $authorised_value,
151
                            $authorised_value,
149
                            $frameworkcode,
152
                            $frameworkcode,
150
                            $tagfield
153
                            $tagfield
151
            );
154
            );
152
        } else {
155
        } else {
153
            $sth = $dbh->prepare(
156
            $sth = $dbh->prepare(
154
            "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
157
            "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode,important) values (?,?,?,?,?,?,?,?)"
155
            );
158
            );
156
            $sth->execute($tagfield,
159
            $sth->execute($tagfield,
157
                          $liblibrarian,
160
                          $liblibrarian,
Lines 159-165 if ($op eq 'add_form') { Link Here
159
                          $repeatable,
162
                          $repeatable,
160
                          $mandatory,
163
                          $mandatory,
161
                          $authorised_value,
164
                          $authorised_value,
162
                          $frameworkcode
165
                          $frameworkcode,
166
                          $important
163
            );
167
            );
164
        }
168
        }
165
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
169
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
Lines 231-236 if ($op eq 'add_form') { Link Here
231
		              marc_tag_structure.libopac as mts_libopac,
235
		              marc_tag_structure.libopac as mts_libopac,
232
		              marc_tag_structure.repeatable as mts_repeatable,
236
		              marc_tag_structure.repeatable as mts_repeatable,
233
		              marc_tag_structure.mandatory as mts_mandatory,
237
		              marc_tag_structure.mandatory as mts_mandatory,
238
                      marc_tag_structure.important as mts_important,
234
		              marc_tag_structure.authorised_value as mts_authorized_value,
239
		              marc_tag_structure.authorised_value as mts_authorized_value,
235
		              marc_subfield_structure.*
240
		              marc_subfield_structure.*
236
                FROM marc_tag_structure 
241
                FROM marc_tag_structure 
Lines 252-257 if ($op eq 'add_form') { Link Here
252
			$row_data{liblibrarian}     = $results[$i]->{'mts_liblibrarian'};
257
			$row_data{liblibrarian}     = $results[$i]->{'mts_liblibrarian'};
253
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
258
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
254
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
259
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
260
            $row_data{important}        = $results[$i]->{'mts_important'};
255
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
261
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
256
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
262
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
257
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
263
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
Lines 265-270 if ($op eq 'add_form') { Link Here
265
				$subfield_data{kohafield}        = $results[$j]->{'kohafield'};
271
				$subfield_data{kohafield}        = $results[$j]->{'kohafield'};
266
				$subfield_data{repeatable}       = $results[$j]->{'repeatable'};
272
				$subfield_data{repeatable}       = $results[$j]->{'repeatable'};
267
				$subfield_data{mandatory}        = $results[$j]->{'mandatory'};
273
				$subfield_data{mandatory}        = $results[$j]->{'mandatory'};
274
                $subfield_data{important}        = $results[$j]->{'important'};
268
				$subfield_data{tab}              = $results[$j]->{'tab'};
275
				$subfield_data{tab}              = $results[$j]->{'tab'};
269
				$subfield_data{seealso}          = $results[$j]->{'seealso'};
276
				$subfield_data{seealso}          = $results[$j]->{'seealso'};
270
				$subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
277
				$subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
Lines 291-296 if ($op eq 'add_form') { Link Here
291
			$row_data{liblibrarian}     = $results->[$i]{'liblibrarian'};
298
			$row_data{liblibrarian}     = $results->[$i]{'liblibrarian'};
292
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
299
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
293
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
300
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
301
            $row_data{important}        = $results->[$i]{'important'};
294
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
302
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
295
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
303
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
296
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
304
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
Lines 324-330 output_html_with_http_headers $input, $cookie, $template->output; Link Here
324
sub StringSearch  {
332
sub StringSearch  {
325
	my ($searchstring,$frameworkcode)=@_;
333
	my ($searchstring,$frameworkcode)=@_;
326
	my $sth = C4::Context->dbh->prepare("
334
	my $sth = C4::Context->dbh->prepare("
327
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value
335
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important
328
     FROM  marc_tag_structure
336
     FROM  marc_tag_structure
329
     WHERE (tagfield >= ? and frameworkcode=?)
337
     WHERE (tagfield >= ? and frameworkcode=?)
330
    ORDER BY tagfield
338
    ORDER BY tagfield
(-)a/cataloguing/addbiblio.pl (-2 / +7 lines)
Lines 318-323 sub create_input { Link Here
318
        marc_lib       => $tagslib->{$tag}->{$subfield}->{lib},
318
        marc_lib       => $tagslib->{$tag}->{$subfield}->{lib},
319
        tag_mandatory  => $tagslib->{$tag}->{mandatory},
319
        tag_mandatory  => $tagslib->{$tag}->{mandatory},
320
        mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
320
        mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
321
        important      => $tagslib->{$tag}->{$subfield}->{important},
321
        repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
322
        repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
322
        kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
323
        kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
323
        index          => $index_tag,
324
        index          => $index_tag,
Lines 331-343 sub create_input { Link Here
331
        $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
332
        $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
332
    }
333
    }
333
    # Subfield is hidden depending of hidden and mandatory flag, and is always
334
    # Subfield is hidden depending of hidden and mandatory flag, and is always
334
    # shown if it contains anything or if its field is mandatory.
335
    # shown if it contains anything or if its field is mandatory or important.
335
    my $tdef = $tagslib->{$tag};
336
    my $tdef = $tagslib->{$tag};
336
    $subfield_data{visibility} = "display:none;"
337
    $subfield_data{visibility} = "display:none;"
337
        if $tdef->{$subfield}->{hidden} % 2 == 1 &&
338
        if $tdef->{$subfield}->{hidden} % 2 == 1 &&
338
           $value eq '' &&
339
           $value eq '' &&
339
           !$tdef->{$subfield}->{mandatory} &&
340
           !$tdef->{$subfield}->{mandatory} &&
340
           !$tdef->{mandatory};
341
           !$tdef->{mandatory} &&
342
           !$tdef->{$subfield}->{important} &&
343
           !$tdef->{important};
341
    # expand all subfields of 773 if there is a host item provided in the input
344
    # expand all subfields of 773 if there is a host item provided in the input
342
    $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
345
    $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
343
346
Lines 617-622 sub build_tabs { Link Here
617
                            tag_lib       => $tagslib->{$tag}->{lib},
620
                            tag_lib       => $tagslib->{$tag}->{lib},
618
                            repeatable       => $tagslib->{$tag}->{repeatable},
621
                            repeatable       => $tagslib->{$tag}->{repeatable},
619
                            mandatory       => $tagslib->{$tag}->{mandatory},
622
                            mandatory       => $tagslib->{$tag}->{mandatory},
623
                            important       => $tagslib->{$tag}->{important},
620
                            subfield_loop => \@subfields_data,
624
                            subfield_loop => \@subfields_data,
621
                            fixedfield    => $tag < 10?1:0,
625
                            fixedfield    => $tag < 10?1:0,
622
                            random        => CreateKey,
626
                            random        => CreateKey,
Lines 663-668 sub build_tabs { Link Here
663
                        tag_lib          => $tagslib->{$tag}->{lib},
667
                        tag_lib          => $tagslib->{$tag}->{lib},
664
                        repeatable       => $tagslib->{$tag}->{repeatable},
668
                        repeatable       => $tagslib->{$tag}->{repeatable},
665
                        mandatory       => $tagslib->{$tag}->{mandatory},
669
                        mandatory       => $tagslib->{$tag}->{mandatory},
670
                        important       => $tagslib->{$tag}->{important},
666
                        indicator1       => $indicator1,
671
                        indicator1       => $indicator1,
667
                        indicator2       => $indicator2,
672
                        indicator2       => $indicator2,
668
                        subfield_loop    => \@subfields_data,
673
                        subfield_loop    => \@subfields_data,
(-)a/installer/data/mysql/kohastructure.sql (-6 / +8 lines)
Lines 1408-1413 CREATE TABLE `marc_subfield_structure` ( Link Here
1408
  `libopac` varchar(255) NOT NULL default '',
1408
  `libopac` varchar(255) NOT NULL default '',
1409
  `repeatable` tinyint(4) NOT NULL default 0,
1409
  `repeatable` tinyint(4) NOT NULL default 0,
1410
  `mandatory` tinyint(4) NOT NULL default 0,
1410
  `mandatory` tinyint(4) NOT NULL default 0,
1411
  `important` tinyint(4) NOT NULL DEFAULT '0',
1411
  `kohafield` varchar(40) default NULL,
1412
  `kohafield` varchar(40) default NULL,
1412
  `tab` tinyint(1) default NULL,
1413
  `tab` tinyint(1) default NULL,
1413
  `authorised_value` varchar(20) default NULL,
1414
  `authorised_value` varchar(20) default NULL,
Lines 1439-1444 CREATE TABLE `marc_tag_structure` ( Link Here
1439
  `mandatory` tinyint(4) NOT NULL default 0,
1440
  `mandatory` tinyint(4) NOT NULL default 0,
1440
  `authorised_value` varchar(10) default NULL,
1441
  `authorised_value` varchar(10) default NULL,
1441
  `frameworkcode` varchar(4) NOT NULL default '',
1442
  `frameworkcode` varchar(4) NOT NULL default '',
1443
  `important` tinyint(4) NOT NULL DEFAULT '0',
1442
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1444
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1443
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1445
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1444
1446
Lines 2488-2499 CREATE TABLE `permissions` ( Link Here
2488
2490
2489
DROP TABLE IF EXISTS `serialitems`;
2491
DROP TABLE IF EXISTS `serialitems`;
2490
CREATE TABLE `serialitems` (
2492
CREATE TABLE `serialitems` (
2491
	`itemnumber` int(11) NOT NULL,
2493
    `itemnumber` int(11) NOT NULL,
2492
	`serialid` int(11) NOT NULL,
2494
    `serialid` int(11) NOT NULL,
2493
	UNIQUE KEY `serialitemsidx` (`itemnumber`),
2495
    UNIQUE KEY `serialitemsidx` (`itemnumber`),
2494
	KEY `serialitems_sfk_1` (`serialid`),
2496
    KEY `serialitems_sfk_1` (`serialid`),
2495
	CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
2497
    CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE,
2496
	CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2498
    CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
2497
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2499
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2498
2500
2499
--
2501
--
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 8651-8656 if ( CheckVersion($DBversion) ) { Link Here
8651
    SetVersion ($DBversion);
8651
    SetVersion ($DBversion);
8652
}
8652
}
8653
8653
8654
8654
$DBversion = '3.17.00.014';
8655
$DBversion = '3.17.00.014';
8655
if ( CheckVersion($DBversion) ) {
8656
if ( CheckVersion($DBversion) ) {
8656
    $dbh->do("
8657
    $dbh->do("
Lines 11390-11395 if ( CheckVersion($DBversion) ) { Link Here
11390
    SetVersion ($DBversion);
11391
    SetVersion ($DBversion);
11391
}
11392
}
11392
11393
11394
$DBversion = "XXX";
11395
if ( CheckVersion($DBversion) ) {
11396
    $dbh->do("ALTER TABLE `marc_subfield_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0  AFTER `mandatory`");
11397
    $dbh->do("ALTER TABLE `marc_tag_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0  AFTER `frameworkcode`");
11398
    print "Upgrade to $DBversion done (Bug 8643 - Add important constraint to marc subfields)\n";
11399
    SetVersion($DBversion);
11400
}
11401
11393
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11402
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11394
# SEE bug 13068
11403
# SEE bug 13068
11395
# if there is anything in the atomicupdate, read and execute it.
11404
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt (+2 lines)
Lines 229-234 function populateHiddenCheckboxes(tab) { Link Here
229
                		<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>
229
                		<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>
230
                		<li><label for="repeatable[% loo.row %]">Repeatable: </label>[% loo.repeatable %]</li>
230
                		<li><label for="repeatable[% loo.row %]">Repeatable: </label>[% loo.repeatable %]</li>
231
                		<li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li>
231
                		<li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li>
232
                        <li><label for="important[% loo.row %]">Important: </label>[% loo.important %]</li>
232
                        <li><label for="tab[% loo.row %]">Managed in tab: </label>
233
                        <li><label for="tab[% loo.row %]">Managed in tab: </label>
233
                            <select name="tab" tabindex="" size="1" id="[% loo.tab.id %]">
234
                            <select name="tab" tabindex="" size="1" id="[% loo.tab.id %]">
234
                            [%- IF ( loo.tab.default ==  -1 ) -%]
235
                            [%- IF ( loo.tab.default ==  -1 ) -%]
Lines 408-413 function populateHiddenCheckboxes(tab) { Link Here
408
            [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield %], [% END %]
409
            [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield %], [% END %]
409
            [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %]
410
            [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %]
410
            [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %]
411
            [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %]
412
            [% IF ( loo.important ) %]Important, [% ELSE %]Not important,[% END %]
411
            [% IF ( loo.seealso ) %] | See Also: [% loo.seealso %],[% END %]
413
            [% IF ( loo.seealso ) %] | See Also: [% loo.seealso %],[% END %]
412
            [% IF ( loo.hidden ) %]hidden,[% END %]
414
            [% IF ( loo.hidden ) %]hidden,[% END %]
413
            [% IF ( loo.isurl ) %]is a URL,[% END %]
415
            [% IF ( loo.isurl ) %]is a URL,[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt (+21 lines)
Lines 104-109 $(document).ready(function() { Link Here
104
        [% END %]
104
        [% END %]
105
        </select>
105
        </select>
106
        (if you select a value here, the indicators will be limited to the authorized value list)</li>
106
        (if you select a value here, the indicators will be limited to the authorized value list)</li>
107
    <li><label for="important">Important: </label>
108
        [% IF ( important ) %]
109
            <input type="checkbox" name="important" id="important" value="1" checked="checked" />
110
        [% ELSE %]
111
            <input type="checkbox" name="important" id="important" value="1" />
112
        [% END %]
113
    </li>
114
    <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>
107
</ol></fieldset> 
115
</ol></fieldset> 
108
    <fieldset class="action">
116
    <fieldset class="action">
109
        <input type="submit" value="Save changes" />
117
        <input type="submit" value="Save changes" />
Lines 184-189 $(document).ready(function() { Link Here
184
        <th>Lib</th>
192
        <th>Lib</th>
185
        <th>Repeatable</th>
193
        <th>Repeatable</th>
186
        <th>Mandatory</th>
194
        <th>Mandatory</th>
195
        <th>Important</th>
187
        <th>Auth value</th>
196
        <th>Auth value</th>
188
        <th>Subfields</th>
197
        <th>Subfields</th>
189
        <th>Edit</th>
198
        <th>Edit</th>
Lines 206-216 $(document).ready(function() { Link Here
206
            </td>
215
            </td>
207
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
216
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
208
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
217
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
218
            <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td>
209
            <td>[% loo.authorised_value %]</td>
219
            <td>[% loo.authorised_value %]</td>
210
            <td><a href="[% loo.subfield_link %]">subfields</a></td>
220
            <td><a href="[% loo.subfield_link %]">subfields</a></td>
211
            <td><a href="[% loo.edit %]">Edit</a></td>
221
            <td><a href="[% loo.edit %]">Edit</a></td>
212
            <td><a href="[% loo.delete %]">Delete</a></td>
222
            <td><a href="[% loo.delete %]">Delete</a></td>
213
        </tr>
223
        </tr>
224
        [% IF ( loop.odd ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
225
            <td>&nbsp;</td>
226
            <td colspan="7">
227
                [% FOREACH subfield IN loo.subfields %]
228
                    <p style="text-indent: 5em">Tab:[% subfield.tab %] | $[% subfield.tagsubfield %]
229
                            [% 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 %]
230
                    </p>
231
                [% END %]
232
            </td>
233
        </tr>
214
        [% END %]
234
        [% END %]
215
    [% ELSE %]
235
    [% ELSE %]
216
    [% FOREACH loo IN loop %]
236
    [% FOREACH loo IN loop %]
Lines 219-224 $(document).ready(function() { Link Here
219
        <td>[% loo.liblibrarian %]</td>
239
        <td>[% loo.liblibrarian %]</td>
220
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
240
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
221
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
241
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
242
        <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td>
222
        <td>[% loo.authorised_value %]</td>
243
        <td>[% loo.authorised_value %]</td>
223
        <td><a href="[% loo.subfield_link %]">Subfields</a></td>
244
        <td><a href="[% loo.subfield_link %]">Subfields</a></td>
224
        <td><a href="[% loo.edit %]">Edit</a></td>
245
        <td><a href="[% loo.edit %]">Edit</a></td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-3 / +117 lines)
Lines 246-252 function AreMandatoriesNotOk(){ Link Here
246
    var flag=0;
246
    var flag=0;
247
    var tabflag= new Array();  
247
    var tabflag= new Array();  
248
    [% FOREACH BIG_LOO IN BIG_LOOP %]
248
    [% FOREACH BIG_LOO IN BIG_LOOP %]
249
    	[% FOREACH innerloo IN BIG_LOO.innerloop %]
249
        [% FOREACH innerloo IN BIG_LOO.innerloop %]
250
	        [% IF ( innerloo.mandatory ) %]
250
	        [% IF ( innerloo.mandatory ) %]
251
    	    	mandatoriesfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]"));
251
    	    	mandatoriesfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]"));
252
        	[% END %]
252
        	[% END %]
Lines 332-338 function AreMandatoriesNotOk(){ Link Here
332
    	
332
    	
333
    	if(isempty){
333
    	if(isempty){
334
    		flag = 1;
334
    		flag = 1;
335
                StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
335
            StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
336
    	}
336
    	}
337
    	
337
    	
338
    }
338
    }
Lines 351-356 function AreMandatoriesNotOk(){ Link Here
351
function Check(){
351
function Check(){
352
    var StrAlert = AreMandatoriesNotOk();
352
    var StrAlert = AreMandatoriesNotOk();
353
    if( ! StrAlert ){
353
    if( ! StrAlert ){
354
        var StrWarning = AreImportantsNotOk();
355
        if (StrWarning){
356
            var r=confirm(StrWarning);
357
            if (! r){
358
                return false;
359
            }
360
        }
354
        document.f.submit();
361
        document.f.submit();
355
        return true;
362
        return true;
356
    } else {
363
    } else {
Lines 360-365 function Check(){ Link Here
360
}
367
}
361
368
362
/** 
369
/** 
370
 * check if mandatory subfields are written
371
 */
372
function AreImportantsNotOk(){
373
    var importants = new Array();
374
    var importantsfields = new Array();
375
    var tab = new Array();
376
    var label = new Array();
377
    var flag=0;
378
    var tabflag= new Array();
379
    [% FOREACH BIG_LOO IN BIG_LOOP %]
380
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
381
        [% IF ( innerloo.important ) %]
382
           importantsfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]"));
383
        [% END %]
384
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
385
            [% IF ( subfield_loo.important ) %]importants.push("[% subfield_loo.id %]");
386
                tab.push("[% subfield_loo.number %]");
387
                label.push("[% subfield_loo.marc_lib %]");
388
                [% END %]
389
            [% END %]
390
        [% END %]
391
    [% END %]
392
    var StrWarning = _("A few important fields are not filled:");
393
    StrWarning += "\n\n";
394
    for(var i=0,len=importants.length; i<len ; i++){
395
        var tag=importants[i].substr(4,3);
396
        var subfield=importants[i].substr(17,1);
397
        var tagnumber=importants[i].substr(19,importants[i].lastIndexOf("_")-19);
398
        tabflag[tag+subfield+tagnumber]=new Array();
399
        tabflag[tag+subfield+tagnumber][0]=0;
400
        if( ! document.getElementById(importants[i]).value){
401
            tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
402
            document.getElementById(importants[i]).setAttribute('class','subfield_not_filled');
403
            document.getElementById(importants[i]).focus();
404
            tabflag[tag+subfield+tagnumber][1]=label[i];
405
            tabflag[tag+subfield+tagnumber][2]=tab[i];
406
        } else {
407
            tabflag[tag+subfield+tagnumber][0] = 1;
408
        }
409
    }
410
    for (var tagsubfieldid in tabflag){
411
      if (tabflag[tagsubfieldid][0]==0){
412
        var tag=tagsubfieldid.substr(0,3);
413
        var subfield=tagsubfieldid.substr(3,1);
414
        StrWarning += "\t* "+_("tag ")+tag+_(" subfield ")+subfield+" "+tabflag[tagsubfieldid][1]+_(" in tab ")+tabflag[tagsubfieldid][2]+"\n";
415
        //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
416
        flag=1;
417
      }
418
    }
419
420
    /* Check for mandatories field(not subfields) */
421
    for(var i=0,len=importantsfields.length; i<len; i++){
422
        isempty  = true;
423
        arr      = importantsfields[i];
424
        divid    = "tag_" + arr[0] + "_" + arr[1];
425
        varegexp = new RegExp("^tag_" + arr[0] + "_code_");
426
427
        if(parseInt(arr[0]) >= 10){
428
           elem = document.getElementById(divid);
429
           eleminputs = elem.getElementsByTagName('input');
430
           for(var j=0,len2=eleminputs.length; j<len2; j++){
431
432
              if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
433
                 inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
434
435
                   for( var k=0; k<len2; k++){
436
                        if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
437
                            isempty = false
438
                        }
439
                    }
440
441
                    elemselect = elem.getElementsByTagName('select');
442
                    for( var k=0; k<elemselect.length; k++){
443
                        if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
444
                           isempty = false
445
                        }
446
                    }
447
              }
448
           }
449
450
           elemtextareas = elem.getElementsByTagName('textarea');
451
           for(var j=0,len2=elemtextareas.length; j<len2; j++){
452
                // this bit assumes that the only textareas in this context would be for subfields
453
               if (elemtextareas[j].value) {
454
                   isempty = false;
455
               }
456
           }
457
       }else{
458
          isempty = false;
459
       }
460
461
       if(isempty){
462
          flag = 1;
463
          StrWarning += _("\t* Field ") + arr[0] + _(" is important, at least one of its subfields should be filled.") + "\n";
464
       }
465
    }
466
467
    StrWarning += "\n" + _("Are you sure you want to save?");
468
469
    if(flag){
470
        return StrWarning;
471
    } else {
472
        return flag;
473
    }
474
}
475
476
/**
363
 * check if z3950 mandatories are set or not
477
 * check if z3950 mandatories are set or not
364
 */
478
 */
365
function GetZ3950Terms(){
479
function GetZ3950Terms(){
Lines 633-638 function Changefwk(FwkList) { Link Here
633
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
747
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
634
                        [% subfield_loo.marc_lib %]
748
                        [% subfield_loo.marc_lib %]
635
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
749
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
750
                        [% IF ( subfield_loo.important ) %]<span style="color:black" title="This field is important">*</span>[% END %]
636
                    </span>
751
                    </span>
637
                    </label>
752
                    </label>
638
                [% END %]
753
                [% END %]
639
- 

Return to bug 8643