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

(-)a/C4/Biblio.pm (-5 / +8 lines)
Lines 947-956 sub GetMarcStructure { Link Here
947
    }
947
    }
948
948
949
    $sth = $dbh->prepare(
949
    $sth = $dbh->prepare(
950
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important
950
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important, display_order
951
         FROM   marc_subfield_structure 
951
         FROM   marc_subfield_structure 
952
         WHERE  frameworkcode=? 
952
         WHERE  frameworkcode=? 
953
         ORDER BY tagfield,tagsubfield
953
         ORDER BY tagfield, tagsubfield
954
        "
954
        "
955
    );
955
    );
956
956
Lines 967-982 sub GetMarcStructure { Link Here
967
    my $link;
967
    my $link;
968
    my $defaultvalue;
968
    my $defaultvalue;
969
    my $maxlength;
969
    my $maxlength;
970
    my $display_order;
970
971
971
    while (
972
    while (
972
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
973
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
973
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
974
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
974
            $maxlength, $important
975
            $maxlength, $important, $display_order
975
        )
976
        )
976
        = $sth->fetchrow
977
        = $sth->fetchrow
977
      ) {
978
      ) {
978
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
979
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
979
        $res->{$tag}->{$subfield}->{tab}              = $tab;
980
        $res->{$tag}->{$subfield}->{tab}              = $tab;
981
        $res->{$tag}->{$subfield}->{subfield}         = $subfield;
980
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
982
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
981
        $res->{$tag}->{$subfield}->{important}        = $important;
983
        $res->{$tag}->{$subfield}->{important}        = $important;
982
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
984
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
Lines 990-995 sub GetMarcStructure { Link Here
990
        $res->{$tag}->{$subfield}->{'link'}           = $link;
992
        $res->{$tag}->{$subfield}->{'link'}           = $link;
991
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
993
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
992
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
994
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
995
        $res->{$tag}->{$subfield}->{display_order}    = $display_order;
993
    }
996
    }
994
997
995
    $cache->set_in_cache($cache_key, $res);
998
    $cache->set_in_cache($cache_key, $res);
Lines 1017-1023 sub GetUsedMarcStructure { Link Here
1017
        FROM   marc_subfield_structure
1020
        FROM   marc_subfield_structure
1018
        WHERE   tab > -1 
1021
        WHERE   tab > -1 
1019
            AND frameworkcode = ?
1022
            AND frameworkcode = ?
1020
        ORDER BY tagfield, tagsubfield
1023
        ORDER BY tagfield, display_order, tagsubfield
1021
    };
1024
    };
1022
    my $sth = C4::Context->dbh->prepare($query);
1025
    my $sth = C4::Context->dbh->prepare($query);
1023
    $sth->execute($frameworkcode);
1026
    $sth->execute($frameworkcode);
Lines 1082-1088 sub GetMarcSubfieldStructure { Link Here
1082
        FROM marc_subfield_structure
1085
        FROM marc_subfield_structure
1083
        WHERE frameworkcode = ?
1086
        WHERE frameworkcode = ?
1084
        AND kohafield > ''
1087
        AND kohafield > ''
1085
        ORDER BY frameworkcode,tagfield,tagsubfield
1088
        ORDER BY frameworkcode, tagfield, display_order, tagsubfield
1086
    |, { Slice => {} }, $frameworkcode );
1089
    |, { Slice => {} }, $frameworkcode );
1087
    # Now map the output to a hash structure
1090
    # Now map the output to a hash structure
1088
    my $subfield_structure = {};
1091
    my $subfield_structure = {};
(-)a/admin/marc_subfields_structure.pl (-4 / +8 lines)
Lines 37-43 sub string_search { Link Here
37
    my $count = @data;
37
    my $count = @data;
38
    my $sth   =
38
    my $sth   =
39
      $dbh->prepare(
39
      $dbh->prepare(
40
"Select * from marc_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield"
40
"Select * from marc_subfield_structure where (tagfield like ? and frameworkcode=?) order by tagfield, display_order"
41
      );
41
      );
42
    $sth->execute( "$searchstring%", $frameworkcode );
42
    $sth->execute( "$searchstring%", $frameworkcode );
43
    my @results;
43
    my @results;
Lines 161-167 if ( $op eq 'add_form' ) { Link Here
161
    # build values list
161
    # build values list
162
    my $sth =
162
    my $sth =
163
      $dbh->prepare(
163
      $dbh->prepare(
164
"select * from marc_subfield_structure where tagfield=? and frameworkcode=?"
164
"select * from marc_subfield_structure where tagfield=? and frameworkcode=? order by display_order"
165
      );    # and tagsubfield='$tagsubfield'");
165
      );    # and tagsubfield='$tagsubfield'");
166
    $sth->execute( $tagfield, $frameworkcode );
166
    $sth->execute( $tagfield, $frameworkcode );
167
    my @loop_data = ();
167
    my @loop_data = ();
Lines 263-269 elsif ( $op eq 'add_validate' ) { Link Here
263
    my $dbh = C4::Context->dbh;
263
    my $dbh = C4::Context->dbh;
264
    $template->param( tagfield => "$input->param('tagfield')" );
264
    $template->param( tagfield => "$input->param('tagfield')" );
265
    my $sth_update = $dbh->prepare(qq{
265
    my $sth_update = $dbh->prepare(qq{
266
        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=?
266
        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=?, display_order=?
267
        where tagfield=? and tagsubfield=? and frameworkcode=?
267
        where tagfield=? and tagsubfield=? and frameworkcode=?
268
    });
268
    });
269
    my @tagsubfield       = $input->multi_param('tagsubfield');
269
    my @tagsubfield       = $input->multi_param('tagsubfield');
Lines 279-285 elsif ( $op eq 'add_validate' ) { Link Here
279
    my @link              = $input->multi_param('link');
279
    my @link              = $input->multi_param('link');
280
    my @defaultvalue      = $input->multi_param('defaultvalue');
280
    my @defaultvalue      = $input->multi_param('defaultvalue');
281
    my @maxlength         = $input->multi_param('maxlength');
281
    my @maxlength         = $input->multi_param('maxlength');
282
    
282
283
    my $display_order;
283
    for ( my $i = 0 ; $i <= $#tagsubfield ; $i++ ) {
284
    for ( my $i = 0 ; $i <= $#tagsubfield ; $i++ ) {
284
        my $tagfield    = $input->param('tagfield');
285
        my $tagfield    = $input->param('tagfield');
285
        my $tagsubfield = $tagsubfield[$i];
286
        my $tagsubfield = $tagsubfield[$i];
Lines 323-328 elsif ( $op eq 'add_validate' ) { Link Here
323
                    $link,
324
                    $link,
324
                    $defaultvalue,
325
                    $defaultvalue,
325
                    $maxlength,
326
                    $maxlength,
327
                    $display_order->{$tagfield} || 0,
326
                    (
328
                    (
327
                        $tagfield,
329
                        $tagfield,
328
                        $tagsubfield,
330
                        $tagsubfield,
Lines 356-364 elsif ( $op eq 'add_validate' ) { Link Here
356
                        link             => $link,
358
                        link             => $link,
357
                        defaultvalue     => $defaultvalue,
359
                        defaultvalue     => $defaultvalue,
358
                        maxlength        => $maxlength,
360
                        maxlength        => $maxlength,
361
                        display_order    => $display_order->{$tagfield} || 0,
359
                    }
362
                    }
360
                )->store;
363
                )->store;
361
            }
364
            }
365
            $display_order->{$tagfield}++;
362
        }
366
        }
363
    }
367
    }
364
    $sth_update->finish;
368
    $sth_update->finish;
(-)a/cataloguing/addbiblio.pl (-8 / +11 lines)
Lines 580-586 sub build_tabs { Link Here
580
                    }
580
                    }
581
581
582
                    # now, loop again to add parameter subfield that are not in the MARC::Record
582
                    # now, loop again to add parameter subfield that are not in the MARC::Record
583
                    foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
583
                    foreach my $subfield ( keys %{ $tagslib->{$tag} } )
584
                    {
584
                    {
585
                        next if ( length $subfield != 1 );
585
                        next if ( length $subfield != 1 );
586
                        next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
586
                        next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
Lines 633-644 sub build_tabs { Link Here
633
            }
633
            }
634
            else {
634
            else {
635
                my @subfields_data;
635
                my @subfields_data;
636
                foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
636
                foreach my $subfield (
637
                    next if ( length $subfield != 1 );
637
                    sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} }
638
                    grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty
639
                    values %{ $tagslib->{$tag} } )
640
                {
638
                    next
641
                    next
639
                      if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
642
                      if ( ( $subfield->{hidden} <= -4 )
640
                        or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 ) )
643
                        or ( $subfield->{hidden} >= 5 ) )
641
                      and not ( $subfield eq "9" and
644
                      and not ( $subfield->{subfield} eq "9" and
642
                                exists($tagslib->{$tag}->{'a'}->{authtypecode}) and
645
                                exists($tagslib->{$tag}->{'a'}->{authtypecode}) and
643
                                defined($tagslib->{$tag}->{'a'}->{authtypecode}) and
646
                                defined($tagslib->{$tag}->{'a'}->{authtypecode}) and
644
                                $tagslib->{$tag}->{'a'}->{authtypecode} ne ""
647
                                $tagslib->{$tag}->{'a'}->{authtypecode} ne ""
Lines 647-657 sub build_tabs { Link Here
647
                           # if subfield is $9 in a field whose $a is authority-controlled,
650
                           # if subfield is $9 in a field whose $a is authority-controlled,
648
                           # always include in the form regardless of the hidden setting - bug 2206
651
                           # always include in the form regardless of the hidden setting - bug 2206
649
                    next
652
                    next
650
                      if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
653
                      if ( $subfield->{tab} ne $tabloop );
651
			push(
654
			push(
652
                        @subfields_data,
655
                        @subfields_data,
653
                        &create_input(
656
                        &create_input(
654
                            $tag, $subfield, '', $index_tag, $tabloop, $record,
657
                            $tag, $subfield->{subfield}, '', $index_tag, $tabloop, $record,
655
                            $authorised_values_sth,$input
658
                            $authorised_values_sth,$input
656
                        )
659
                        )
657
                    );
660
                    );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt (-7 / +9 lines)
Lines 80-92 Link Here
80
                            <div id="subfieldtabs" class="toptabs numbered">
80
                            <div id="subfieldtabs" class="toptabs numbered">
81
                                <ul>
81
                                <ul>
82
                                    [% FOREACH loo IN loop %]
82
                                    [% FOREACH loo IN loop %]
83
                                        [% IF ( loo.new_subfield ) %]
83
                                        <li id="tab_subfield_[% loo.urisubfieldcode | html %]">
84
                                            <li><a href="#sub[% loo.urisubfieldcode | uri %]field" title="[% loo.liblibrarian | html_entity %]">New</a></li>
84
                                            [% IF ( loo.new_subfield ) %]
85
                                        [% ELSE %]
85
                                                <a href="#sub[% loo.urisubfieldcode | uri %]field" title="[% loo.liblibrarian | html_entity %]">New</a>
86
                                            <li><a href="#sub[% loo.urisubfieldcode | uri %]field" title="[% loo.liblibrarian | html_entity %]">
86
                                            [% ELSE %]
87
                                                [% loo.subfieldcode | html %]
87
                                                <a href="#sub[% loo.urisubfieldcode | uri %]field" title="[% loo.liblibrarian | html_entity %]">
88
                                        </a></li>
88
                                                    [% loo.subfieldcode | html %]
89
                                        [% END %]
89
                                                </a>
90
                                            [% END %]
91
                                        </li>
90
                                    [% END %]
92
                                    [% END %]
91
                                </ul>
93
                                </ul>
92
94
(-)a/koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js (-2 / +22 lines)
Lines 1-6 Link Here
1
/* global dataTablesDefaults */
1
/* global dataTablesDefaults */
2
$(document).ready(function() {
2
$(document).ready(function() {
3
    $('#subfieldtabs').tabs();
3
    var tabs = $('#subfieldtabs').tabs();
4
    var current_index;
5
    tabs.find( ".ui-tabs-nav" ).sortable({
6
        axis: "x",
7
        start: function (e, ui) {
8
            current_index = $(ui.item[0]).index();
9
        },
10
        stop: function (e, ui) {
11
            var new_index = $(ui.item[0]).index();
12
            if (current_index < new_index) new_index++;
13
            var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, '');
14
            var content = $('#sub' + subfield_code + 'field');
15
            var panels = $("#subfieldtabs > div");
16
            if ( new_index < $(panels).size() ){
17
                $(content).insertBefore($("#subfieldtabs > div")[new_index]);
18
            } else {
19
                $(content).insertAfter($("#subfieldtabs > div")[new_index-1]);
20
            }
21
            tabs.tabs("refresh");
22
        }
23
    });
4
    $("input[id^='hidden_']").click(setHiddenValue);
24
    $("input[id^='hidden_']").click(setHiddenValue);
5
    $("input[id^='hidden-']").each(function() {
25
    $("input[id^='hidden-']").each(function() {
6
        populateHiddenCheckboxes($(this).attr('id').split('-')[1]);
26
        populateHiddenCheckboxes($(this).attr('id').split('-')[1]);
Lines 9-14 $(document).ready(function() { Link Here
9
        "columnDefs": [
29
        "columnDefs": [
10
            { 'sortable': false, 'targets': [ 'NoSort' ] }
30
            { 'sortable': false, 'targets': [ 'NoSort' ] }
11
        ],
31
        ],
32
        aaSorting: [],
12
        paginate: false
33
        paginate: false
13
    }));
34
    }));
14
});
35
});
15
- 

Return to bug 8976