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

(-)a/C4/Biblio.pm (-5 / +7 lines)
Lines 1066-1088 sub GetMarcStructure { Link Here
1066
    #     my ($total) = $sth->fetchrow;
1066
    #     my ($total) = $sth->fetchrow;
1067
    #     $frameworkcode = "" unless ( $total > 0 );
1067
    #     $frameworkcode = "" unless ( $total > 0 );
1068
    my $sth = $dbh->prepare(
1068
    my $sth = $dbh->prepare(
1069
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
1069
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,important
1070
        FROM marc_tag_structure 
1070
        FROM marc_tag_structure 
1071
        WHERE frameworkcode=? 
1071
        WHERE frameworkcode=? 
1072
        ORDER BY tagfield"
1072
        ORDER BY tagfield"
1073
    );
1073
    );
1074
    $sth->execute($frameworkcode);
1074
    $sth->execute($frameworkcode);
1075
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
1075
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $important );
1076
1076
1077
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
1077
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $important ) = $sth->fetchrow ) {
1078
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1078
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1079
        $res->{$tag}->{tab}        = "";
1079
        $res->{$tag}->{tab}        = "";
1080
        $res->{$tag}->{mandatory}  = $mandatory;
1080
        $res->{$tag}->{mandatory}  = $mandatory;
1081
        $res->{$tag}->{important}  = $important;
1081
        $res->{$tag}->{repeatable} = $repeatable;
1082
        $res->{$tag}->{repeatable} = $repeatable;
1082
    }
1083
    }
1083
1084
1084
    $sth = $dbh->prepare(
1085
    $sth = $dbh->prepare(
1085
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength
1086
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important
1086
         FROM   marc_subfield_structure 
1087
         FROM   marc_subfield_structure 
1087
         WHERE  frameworkcode=? 
1088
         WHERE  frameworkcode=? 
1088
         ORDER BY tagfield,tagsubfield
1089
         ORDER BY tagfield,tagsubfield
Lines 1106-1118 sub GetMarcStructure { Link Here
1106
    while (
1107
    while (
1107
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
1108
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
1108
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
1109
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
1109
            $maxlength
1110
            $maxlength,    $important
1110
        )
1111
        )
1111
        = $sth->fetchrow
1112
        = $sth->fetchrow
1112
      ) {
1113
      ) {
1113
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1114
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
1114
        $res->{$tag}->{$subfield}->{tab}              = $tab;
1115
        $res->{$tag}->{$subfield}->{tab}              = $tab;
1115
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
1116
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
1117
        $res->{$tag}->{$subfield}->{important}        = $important;
1116
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
1118
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
1117
        $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
1119
        $res->{$tag}->{$subfield}->{authorised_value} = $authorised_value;
1118
        $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
1120
        $res->{$tag}->{$subfield}->{authtypecode}     = $authtypecode;
(-)a/admin/marc_subfields_structure.pl (-3 / +21 lines)
Lines 259-264 if ( $op eq 'add_form' ) { Link Here
259
            -label    => '',
259
            -label    => '',
260
            -id       => "mandatory$i"
260
            -id       => "mandatory$i"
261
        );
261
        );
262
        $row_data{important} = CGI::checkbox(
263
            -name     => "important$i",
264
            -checked  => $data->{'important'} ? 'checked' : '',
265
            -value    => 1,
266
            -label    => '',
267
            -id       => "important$i"
268
        );
262
        $row_data{hidden} = CGI::escapeHTML( $data->{hidden} );
269
        $row_data{hidden} = CGI::escapeHTML( $data->{hidden} );
263
        $row_data{isurl}  = CGI::checkbox(
270
        $row_data{isurl}  = CGI::checkbox(
264
            -name     => "isurl$i",
271
            -name     => "isurl$i",
Lines 331-336 if ( $op eq 'add_form' ) { Link Here
331
            -value    => 1,
338
            -value    => 1,
332
            -label    => ''
339
            -label    => ''
333
        );
340
        );
341
        $row_data{important} = CGI::checkbox(
342
            -name     => "important$i",
343
            -id       => "important$i",
344
            -checked  => '',
345
            -value    => 1,
346
            -label    => ''
347
        );
334
        $row_data{isurl} = CGI::checkbox(
348
        $row_data{isurl} = CGI::checkbox(
335
            -name     => "isurl$i",
349
            -name     => "isurl$i",
336
            -id       => "isurl$i",
350
            -id       => "isurl$i",
Lines 386-396 elsif ( $op eq 'add_validate' ) { Link Here
386
#                                     values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
400
#                                     values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
387
#     );
401
#     );
388
    my $sth_insert = $dbh->prepare(qq{
402
    my $sth_insert = $dbh->prepare(qq{
389
        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)
403
        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)
390
        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
404
        values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
391
    });
405
    });
392
    my $sth_update = $dbh->prepare(qq{
406
    my $sth_update = $dbh->prepare(qq{
393
        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=?
407
        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=?
394
        where tagfield=? and tagsubfield=? and frameworkcode=?
408
        where tagfield=? and tagsubfield=? and frameworkcode=?
395
    });
409
    });
396
    my @tagsubfield       = $input->param('tagsubfield');
410
    my @tagsubfield       = $input->param('tagsubfield');
Lines 416-421 elsif ( $op eq 'add_validate' ) { Link Here
416
        my $libopac          = $libopac[$i];
430
        my $libopac          = $libopac[$i];
417
        my $repeatable       = $input->param("repeatable$i") ? 1 : 0;
431
        my $repeatable       = $input->param("repeatable$i") ? 1 : 0;
418
        my $mandatory        = $input->param("mandatory$i") ? 1 : 0;
432
        my $mandatory        = $input->param("mandatory$i") ? 1 : 0;
433
        my $important        = $input->param("important$i") ? 1 : 0;
419
        my $kohafield        = $kohafield[$i];
434
        my $kohafield        = $kohafield[$i];
420
        my $tab              = $tab[$i];
435
        my $tab              = $tab[$i];
421
        my $seealso          = $seealso[$i];
436
        my $seealso          = $seealso[$i];
Lines 438-443 elsif ( $op eq 'add_validate' ) { Link Here
438
                        $libopac,
453
                        $libopac,
439
                        $repeatable,
454
                        $repeatable,
440
                        $mandatory,
455
                        $mandatory,
456
                        $important,
441
                        $kohafield,
457
                        $kohafield,
442
                        $tab,
458
                        $tab,
443
                        $seealso,
459
                        $seealso,
Lines 464-469 elsif ( $op eq 'add_validate' ) { Link Here
464
                        $libopac,
480
                        $libopac,
465
                        $repeatable,
481
                        $repeatable,
466
                        $mandatory,
482
                        $mandatory,
483
                        $important,
467
                        $kohafield,
484
                        $kohafield,
468
                        $tab,
485
                        $tab,
469
                        $seealso,
486
                        $seealso,
Lines 543-548 else { # DEFAULT Link Here
543
        $row_data{kohafield}        = $results->[$i]{'kohafield'};
560
        $row_data{kohafield}        = $results->[$i]{'kohafield'};
544
        $row_data{repeatable}       = $results->[$i]{'repeatable'};
561
        $row_data{repeatable}       = $results->[$i]{'repeatable'};
545
        $row_data{mandatory}        = $results->[$i]{'mandatory'};
562
        $row_data{mandatory}        = $results->[$i]{'mandatory'};
563
        $row_data{important}        = $results->[$i]{'important'};
546
        $row_data{tab}              = $results->[$i]{'tab'};
564
        $row_data{tab}              = $results->[$i]{'tab'};
547
        $row_data{seealso}          = $results->[$i]{'seealso'};
565
        $row_data{seealso}          = $results->[$i]{'seealso'};
548
        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
566
        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
(-)a/admin/marctagstructure.pl (-5 / +17 lines)
Lines 96-102 if ($op eq 'add_form') { Link Here
96
	#---- if primkey exists, it's a modify action, so read values to modify...
96
	#---- if primkey exists, it's a modify action, so read values to modify...
97
	my $data;
97
	my $data;
98
	if ($searchfield) {
98
	if ($searchfield) {
99
		$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
99
		$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important from marc_tag_structure where tagfield=? and frameworkcode=?");
100
		$sth->execute($searchfield,$frameworkcode);
100
		$sth->execute($searchfield,$frameworkcode);
101
		$data=$sth->fetchrow_hashref;
101
		$data=$sth->fetchrow_hashref;
102
	}
102
	}
Lines 136-141 if ($op eq 'add_form') { Link Here
136
						-value => 1,
136
						-value => 1,
137
						-label => '',
137
						-label => '',
138
						-id => 'mandatory'),
138
						-id => 'mandatory'),
139
			important => CGI::checkbox(-name => 'important',
140
						-checked => $data->{'important'}?'checked':'',
141
						-value => 1,
142
						-label => '',
143
						-id => 'important'),
139
			authorised_value => $authorised_value,
144
			authorised_value => $authorised_value,
140
			frameworkcode => $frameworkcode,
145
			frameworkcode => $frameworkcode,
141
    );  # FIXME: move checkboxes to presentation layer
146
    );  # FIXME: move checkboxes to presentation layer
Lines 148-170 if ($op eq 'add_form') { Link Here
148
	my $libopac          = $input->param('libopac');
153
	my $libopac          = $input->param('libopac');
149
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
154
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
150
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
155
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
156
	my $important        = $input->param('important')  ? 1 : 0;
151
	my $authorised_value = $input->param('authorised_value');
157
	my $authorised_value = $input->param('authorised_value');
152
    unless (C4::Context->config('demo') == 1) {
158
    unless (C4::Context->config('demo') == 1) {
153
        if ($input->param('modif')) {
159
        if ($input->param('modif')) {
154
            $sth = $dbh->prepare(
160
            $sth = $dbh->prepare(
155
            "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
161
            "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,important=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
156
            );
162
            );
157
            $sth->execute(  $liblibrarian,
163
            $sth->execute(  $liblibrarian,
158
                            $libopac,
164
                            $libopac,
159
                            $repeatable,
165
                            $repeatable,
160
                            $mandatory,
166
                            $mandatory,
167
                            $important,
161
                            $authorised_value,
168
                            $authorised_value,
162
                            $frameworkcode,
169
                            $frameworkcode,
163
                            $tagfield
170
                            $tagfield
164
            );
171
            );
165
        } else {
172
        } else {
166
            $sth = $dbh->prepare(
173
            $sth = $dbh->prepare(
167
            "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
174
            "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode,important) values (?,?,?,?,?,?,?,?)"
168
            );
175
            );
169
            $sth->execute($tagfield,
176
            $sth->execute($tagfield,
170
                          $liblibrarian,
177
                          $liblibrarian,
Lines 172-178 if ($op eq 'add_form') { Link Here
172
                          $repeatable,
179
                          $repeatable,
173
                          $mandatory,
180
                          $mandatory,
174
                          $authorised_value,
181
                          $authorised_value,
175
                          $frameworkcode
182
                          $frameworkcode,
183
                          $important
176
            );
184
            );
177
        }
185
        }
178
	}
186
	}
Lines 240-245 if ($op eq 'add_form') { Link Here
240
		              marc_tag_structure.libopac as mts_libopac,
248
		              marc_tag_structure.libopac as mts_libopac,
241
		              marc_tag_structure.repeatable as mts_repeatable,
249
		              marc_tag_structure.repeatable as mts_repeatable,
242
		              marc_tag_structure.mandatory as mts_mandatory,
250
		              marc_tag_structure.mandatory as mts_mandatory,
251
		              marc_tag_structure.important as mts_important,
243
		              marc_tag_structure.authorised_value as mts_authorized_value,
252
		              marc_tag_structure.authorised_value as mts_authorized_value,
244
		              marc_subfield_structure.*
253
		              marc_subfield_structure.*
245
                FROM marc_tag_structure 
254
                FROM marc_tag_structure 
Lines 261-266 if ($op eq 'add_form') { Link Here
261
			$row_data{liblibrarian}     = $results[$i]->{'mts_liblibrarian'};
270
			$row_data{liblibrarian}     = $results[$i]->{'mts_liblibrarian'};
262
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
271
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
263
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
272
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
273
			$row_data{important}        = $results[$i]->{'mts_important'};
264
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
274
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
265
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
275
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
266
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
276
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
Lines 274-279 if ($op eq 'add_form') { Link Here
274
				$subfield_data{kohafield}        = $results[$j]->{'kohafield'};
284
				$subfield_data{kohafield}        = $results[$j]->{'kohafield'};
275
				$subfield_data{repeatable}       = $results[$j]->{'repeatable'};
285
				$subfield_data{repeatable}       = $results[$j]->{'repeatable'};
276
				$subfield_data{mandatory}        = $results[$j]->{'mandatory'};
286
				$subfield_data{mandatory}        = $results[$j]->{'mandatory'};
287
				$subfield_data{important}        = $results[$j]->{'important'};
277
				$subfield_data{tab}              = $results[$j]->{'tab'};
288
				$subfield_data{tab}              = $results[$j]->{'tab'};
278
				$subfield_data{seealso}          = $results[$j]->{'seealso'};
289
				$subfield_data{seealso}          = $results[$j]->{'seealso'};
279
				$subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
290
				$subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
Lines 300-305 if ($op eq 'add_form') { Link Here
300
			$row_data{liblibrarian}     = $results->[$i]{'liblibrarian'};
311
			$row_data{liblibrarian}     = $results->[$i]{'liblibrarian'};
301
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
312
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
302
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
313
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
314
			$row_data{important}        = $results->[$i]{'important'};
303
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
315
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
304
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
316
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
305
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
317
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
Lines 333-339 output_html_with_http_headers $input, $cookie, $template->output; Link Here
333
sub StringSearch  {
345
sub StringSearch  {
334
	my ($searchstring,$frameworkcode)=@_;
346
	my ($searchstring,$frameworkcode)=@_;
335
	my $sth = C4::Context->dbh->prepare("
347
	my $sth = C4::Context->dbh->prepare("
336
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value
348
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,important
337
     FROM  marc_tag_structure
349
     FROM  marc_tag_structure
338
     WHERE (tagfield >= ? and frameworkcode=?)
350
     WHERE (tagfield >= ? and frameworkcode=?)
339
    ORDER BY tagfield
351
    ORDER BY tagfield
(-)a/cataloguing/addbiblio.pl (-3 / +7 lines)
Lines 320-325 sub create_input { Link Here
320
        marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, 
320
        marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, 
321
        tag_mandatory  => $tagslib->{$tag}->{mandatory},
321
        tag_mandatory  => $tagslib->{$tag}->{mandatory},
322
        mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
322
        mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
323
        important      => $tagslib->{$tag}->{$subfield}->{important},
323
        repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
324
        repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
324
        kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
325
        kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
325
        index          => $index_tag,
326
        index          => $index_tag,
Lines 333-349 sub create_input { Link Here
333
        $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
334
        $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
334
    }
335
    }
335
    # Subfield is hidden depending of hidden and mandatory flag, and is always
336
    # Subfield is hidden depending of hidden and mandatory flag, and is always
336
    # shown if it contains anything or if its field is mandatory.
337
    # shown if it contains anything or if its field is mandatory or important.
337
    my $tdef = $tagslib->{$tag};
338
    my $tdef = $tagslib->{$tag};
338
    $subfield_data{visibility} = "display:none;"
339
    $subfield_data{visibility} = "display:none;"
339
        if $tdef->{$subfield}->{hidden} % 2 == 1 &&
340
        if $tdef->{$subfield}->{hidden} % 2 == 1 &&
340
           $value eq '' &&
341
           $value eq '' &&
341
           !$tdef->{$subfield}->{mandatory} &&
342
           !$tdef->{$subfield}->{mandatory} &&
342
           !$tdef->{mandatory};
343
           !$tdef->{mandatory} &&
344
           !$tdef->{$subfield}->{important} &&
345
           !$tdef->{important};
343
    # expand all subfields of 773 if there is a host item provided in the input
346
    # expand all subfields of 773 if there is a host item provided in the input
344
    $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
347
    $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
345
348
346
347
    # it's an authorised field
349
    # it's an authorised field
348
    if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
350
    if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
349
        $subfield_data{marc_value} =
351
        $subfield_data{marc_value} =
Lines 647-652 sub build_tabs { Link Here
647
                            tag_lib       => $tagslib->{$tag}->{lib},
649
                            tag_lib       => $tagslib->{$tag}->{lib},
648
                            repeatable       => $tagslib->{$tag}->{repeatable},
650
                            repeatable       => $tagslib->{$tag}->{repeatable},
649
                            mandatory       => $tagslib->{$tag}->{mandatory},
651
                            mandatory       => $tagslib->{$tag}->{mandatory},
652
                            important       => $tagslib->{$tag}->{important},
650
                            subfield_loop => \@subfields_data,
653
                            subfield_loop => \@subfields_data,
651
                            fixedfield    => $tag < 10?1:0,
654
                            fixedfield    => $tag < 10?1:0,
652
                            random        => CreateKey,
655
                            random        => CreateKey,
Lines 693-698 sub build_tabs { Link Here
693
                        tag_lib          => $tagslib->{$tag}->{lib},
696
                        tag_lib          => $tagslib->{$tag}->{lib},
694
                        repeatable       => $tagslib->{$tag}->{repeatable},
697
                        repeatable       => $tagslib->{$tag}->{repeatable},
695
                        mandatory       => $tagslib->{$tag}->{mandatory},
698
                        mandatory       => $tagslib->{$tag}->{mandatory},
699
                        important       => $tagslib->{$tag}->{important},
696
                        indicator1       => $indicator1,
700
                        indicator1       => $indicator1,
697
                        indicator2       => $indicator2,
701
                        indicator2       => $indicator2,
698
                        subfield_loop    => \@subfields_data,
702
                        subfield_loop    => \@subfields_data,
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 1211-1216 CREATE TABLE `marc_subfield_structure` ( Link Here
1211
  `link` varchar(80) default NULL,
1211
  `link` varchar(80) default NULL,
1212
  `defaultvalue` text default NULL,
1212
  `defaultvalue` text default NULL,
1213
  `maxlength` int(4) NOT NULL DEFAULT '9999',
1213
  `maxlength` int(4) NOT NULL DEFAULT '9999',
1214
  `important` TINYINT(4) NOT NULL DEFAULT 0,
1214
  PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
1215
  PRIMARY KEY  (`frameworkcode`,`tagfield`,`tagsubfield`),
1215
  KEY `kohafield_2` (`kohafield`),
1216
  KEY `kohafield_2` (`kohafield`),
1216
  KEY `tab` (`frameworkcode`,`tab`),
1217
  KEY `tab` (`frameworkcode`,`tab`),
Lines 1230-1235 CREATE TABLE `marc_tag_structure` ( Link Here
1230
  `mandatory` tinyint(4) NOT NULL default 0,
1231
  `mandatory` tinyint(4) NOT NULL default 0,
1231
  `authorised_value` varchar(10) default NULL,
1232
  `authorised_value` varchar(10) default NULL,
1232
  `frameworkcode` varchar(4) NOT NULL default '',
1233
  `frameworkcode` varchar(4) NOT NULL default '',
1234
  `important` TINYINT(4) NOT NULL DEFAULT 0,
1233
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1235
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1234
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1236
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1235
1237
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 5249-5254 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5249
    SetVersion($DBversion);
5249
    SetVersion($DBversion);
5250
}
5250
}
5251
5251
5252
$DBversion = 'XXX';
5253
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5254
   $dbh->do("ALTER TABLE `marc_subfield_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0  AFTER `mandatory` ;
5255
    ALTER TABLE `marc_tag_structure` ADD COLUMN `important` TINYINT(4) NOT NULL DEFAULT 0  AFTER `frameworkcode` ;");
5256
   print "Upgrade to $DBversion done (Add mandatory to marc frameworks)\n";
5257
   SetVersion ($DBversion);
5258
}
5259
5252
=head1 FUNCTIONS
5260
=head1 FUNCTIONS
5253
5261
5254
=head2 TableExists($table)
5262
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt (+2 lines)
Lines 100-105 $(document).ready(function() { Link Here
100
                		<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>
100
                		<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>
101
                		<li><label for="repeatable[% loo.row %]">Repeatable: </label>[% loo.repeatable %]</li>
101
                		<li><label for="repeatable[% loo.row %]">Repeatable: </label>[% loo.repeatable %]</li>
102
                		<li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li>
102
                		<li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li>
103
                        <li><label for="important[% loo.row %]">Important: </label>[% loo.important %]</li>
103
                		<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>
104
                		<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>
104
                	</ol>
105
                	</ol>
105
            </fieldset>
106
            </fieldset>
Lines 200-205 $(document).ready(function() { Link Here
200
            [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield %], [% END %]
201
            [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield %], [% END %]
201
            [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %]
202
            [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %]
202
            [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %]
203
            [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %]
204
            [% IF ( loo.important ) %]Important, [% ELSE %]Not important,[% END %]
203
            [% IF ( loo.seealso ) %] | See Also: [% loo.seealso %],[% END %]
205
            [% IF ( loo.seealso ) %] | See Also: [% loo.seealso %],[% END %]
204
            [% IF ( loo.hidden ) %]hidden,[% END %]
206
            [% IF ( loo.hidden ) %]hidden,[% END %]
205
            [% IF ( loo.isurl ) %]is a URL,[% END %]
207
            [% IF ( loo.isurl ) %]is a URL,[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt (-2 / +6 lines)
Lines 84-89 $(document).ready(function() { Link Here
84
    <li><label for="libopac">Label for opac: </label><input type="text" id="libopac" name="libopac" value="[% libopac |html %]" size="40" maxlength="100" /></li>
84
    <li><label for="libopac">Label for opac: </label><input type="text" id="libopac" name="libopac" value="[% libopac |html %]" size="40" maxlength="100" /></li>
85
    <li><label for="repeatable">Repeatable: </label>[% repeatable %]</li>
85
    <li><label for="repeatable">Repeatable: </label>[% repeatable %]</li>
86
    <li><label for="mandatory">Mandatory: </label>[% mandatory %]</li>
86
    <li><label for="mandatory">Mandatory: </label>[% mandatory %]</li>
87
    <li><label for="important">Important: </label>[% important %]</li>
87
    <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>
88
    <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>
88
</ol></fieldset> 
89
</ol></fieldset> 
89
    <fieldset class="action">
90
    <fieldset class="action">
Lines 166-171 $(document).ready(function() { Link Here
166
        <th>Lib</th>
167
        <th>Lib</th>
167
        <th>Repeatable</th>
168
        <th>Repeatable</th>
168
        <th>Mandatory</th>
169
        <th>Mandatory</th>
170
        <th>Important</th>
169
        <th>Auth value</th>
171
        <th>Auth value</th>
170
        <th>Subfields</th>
172
        <th>Subfields</th>
171
        <th>Edit</th>
173
        <th>Edit</th>
Lines 179-184 $(document).ready(function() { Link Here
179
            <td>[% loo.liblibrarian %]</td>
181
            <td>[% loo.liblibrarian %]</td>
180
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
182
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
181
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
183
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
184
            <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td>
182
            <td>[% loo.authorised_value %]</td>
185
            <td>[% loo.authorised_value %]</td>
183
            <td><a href="[% loo.subfield_link %]">subfields</a></td>
186
            <td><a href="[% loo.subfield_link %]">subfields</a></td>
184
            <td><a href="[% loo.edit %]">Edit</a></td>
187
            <td><a href="[% loo.edit %]">Edit</a></td>
Lines 188-195 $(document).ready(function() { Link Here
188
            <td>&nbsp;</td>
191
            <td>&nbsp;</td>
189
            <td colspan="7">
192
            <td colspan="7">
190
                [% FOREACH subfield IN loo.subfields %]
193
                [% FOREACH subfield IN loo.subfields %]
191
                    <p>	Tab:[% subfield.tab %] | $[% subfield.tagsubfield %]
194
                    <p>	Tab:[% subfield.tab %] | $[% subfield.tagsubfield %]                        
192
                            [% 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 %]
195
                        [% 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 %]
193
                    </p>
196
                    </p>
194
                [% END %]
197
                [% END %]
195
            </td>
198
            </td>
Lines 202-207 $(document).ready(function() { Link Here
202
        <td>[% loo.liblibrarian %]</td>
205
        <td>[% loo.liblibrarian %]</td>
203
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
206
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
204
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
207
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
208
        <td>[% IF ( loo.important ) %]Yes[% ELSE %]No[% END %]</td>
205
        <td>[% loo.authorised_value %]</td>
209
        <td>[% loo.authorised_value %]</td>
206
        <td><a href="[% loo.subfield_link %]">Subfields</a></td>
210
        <td><a href="[% loo.subfield_link %]">Subfields</a></td>
207
        <td><a href="[% loo.edit %]">Edit</a></td>
211
        <td><a href="[% loo.edit %]">Edit</a></td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-1 / +117 lines)
Lines 55-60 function confirmnotdup(redirect){ Link Here
55
function Check(){
55
function Check(){
56
    var StrAlert = AreMandatoriesNotOk();
56
    var StrAlert = AreMandatoriesNotOk();
57
    if( ! StrAlert ){
57
    if( ! StrAlert ){
58
        var StrWarning = AreImportantsNotOk();
59
        if (StrWarning){
60
            var r=confirm(StrWarning);
61
            if (! r){
62
                return false;
63
            }
64
        }
58
        document.f.submit();
65
        document.f.submit();
59
        return true;
66
        return true;
60
    } else {
67
    } else {
Lines 236-241 function AreMandatoriesNotOk(){ Link Here
236
}
243
}
237
244
238
/** 
245
/** 
246
 * check if mandatory subfields are written
247
 */
248
function AreImportantsNotOk(){
249
    var importants = new Array();
250
    var importantsfields = new Array();
251
    var tab = new Array();
252
    var label = new Array();
253
    var flag=0;
254
    var tabflag= new Array();
255
    [% FOREACH BIG_LOO IN BIG_LOOP %]
256
        [% FOREACH innerloo IN BIG_LOO.innerloop %]
257
            [% IF ( innerloo.important ) %]
258
                importantsfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]"));
259
            [% END %]
260
            [% FOREACH subfield_loo IN innerloo.subfield_loop %]
261
                [% IF ( subfield_loo.important ) %]importants.push("[% subfield_loo.id %]");
262
                    tab.push("[% subfield_loo.number %]");
263
                    label.push("[% subfield_loo.marc_lib %]");
264
                [% END %]
265
            [% END %]
266
        [% END %]
267
    [% END %]
268
    var StrWarning = _("A few important fields are not filled:");
269
    StrWarning += "\n\n";
270
    for(var i=0,len=importants.length; i<len ; i++){
271
        var tag=importants[i].substr(4,3);
272
        var subfield=importants[i].substr(17,1);
273
        var tagnumber=importants[i].substr(19,importants[i].lastIndexOf("_")-19);
274
        tabflag[tag+subfield+tagnumber]=new Array();
275
        tabflag[tag+subfield+tagnumber][0]=0;
276
        if( ! document.getElementById(importants[i]).value){
277
            tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
278
            document.getElementById(importants[i]).setAttribute('class','subfield_not_filled');
279
            document.getElementById(importants[i]).focus();
280
            tabflag[tag+subfield+tagnumber][1]=label[i];
281
            tabflag[tag+subfield+tagnumber][2]=tab[i];
282
        } else {
283
            tabflag[tag+subfield+tagnumber][0] = 1;
284
        }
285
    }
286
    for (var tagsubfieldid in tabflag){
287
      if (tabflag[tagsubfieldid][0]==0){
288
        var tag=tagsubfieldid.substr(0,3);
289
        var subfield=tagsubfieldid.substr(3,1);
290
        StrWarning += "\t* "+_("tag ")+tag+_(" subfield ")+subfield+" "+tabflag[tagsubfieldid][1]+_(" in tab ")+tabflag[tagsubfieldid][2]+"\n";
291
        //StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
292
        flag=1;
293
      }
294
    }
295
296
    /* Check for mandatories field(not subfields) */
297
    for(var i=0,len=importantsfields.length; i<len; i++){
298
        isempty  = true;
299
        arr      = importantsfields[i];
300
        divid    = "tag_" + arr[0] + "_" + arr[1];
301
        varegexp = new RegExp("^tag_" + arr[0] + "_code_");
302
303
        if(parseInt(arr[0]) >= 10){
304
            elem = document.getElementById(divid);
305
            eleminputs = elem.getElementsByTagName('input');
306
307
            for(var j=0,len2=eleminputs.length; j<len2; j++){
308
309
                if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
310
                    inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
311
312
                    for( var k=0; k<len2; k++){
313
                        if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
314
                            isempty = false
315
                        }
316
                    }
317
318
                    elemselect = elem.getElementsByTagName('select');
319
                    for( var k=0; k<elemselect.length; k++){
320
                        if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
321
                            isempty = false
322
                        }
323
                    }
324
                }
325
            }
326
327
            elemtextareas = elem.getElementsByTagName('textarea');
328
            for(var j=0,len2=elemtextareas.length; j<len2; j++){
329
                // this bit assumes that the only textareas in this context would be for subfields
330
                if (elemtextareas[j].value) {
331
                    isempty = false;
332
                }
333
            }
334
        }else{
335
            isempty = false;
336
        }
337
338
        if(isempty){
339
            flag = 1;
340
            StrWarning += _("\t* Field ") + arr[0] + _(" is important, at least one of its subfields should be filled.") + "\n";
341
        }
342
343
    }
344
345
    StrWarning += "\n" + _("Are you sure you want to save?");
346
347
    if(flag){
348
        return StrWarning;
349
    } else {
350
        return flag;
351
    }
352
}
353
354
/**
239
 * check if z3950 mandatories are set or not
355
 * check if z3950 mandatories are set or not
240
 */
356
 */
241
function GetZ3950Terms(){
357
function GetZ3950Terms(){
Lines 885-890 function unHideSubfield(index,labelindex) { // FIXME :: is it used ? Link Here
885
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
1001
                    [% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
886
                        [% subfield_loo.marc_lib_plain %]
1002
                        [% subfield_loo.marc_lib_plain %]
887
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
1003
                        [% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
1004
                        [% IF ( subfield_loo.important ) %]<span style="color:black" title="This field is important">*</span>[% END %]
888
                    </span>
1005
                    </span>
889
                    </label>
1006
                    </label>
890
                [% END %]
1007
                [% END %]
891
- 

Return to bug 8643