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

(-)a/C4/Biblio.pm (-5 / +8 lines)
Lines 961-970 sub GetMarcStructure { Link Here
961
    }
961
    }
962
962
963
    $sth = $dbh->prepare(
963
    $sth = $dbh->prepare(
964
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important
964
        "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue,maxlength,important, display_order
965
         FROM   marc_subfield_structure 
965
         FROM   marc_subfield_structure 
966
         WHERE  frameworkcode=? 
966
         WHERE  frameworkcode=? 
967
         ORDER BY tagfield,tagsubfield
967
         ORDER BY tagfield, tagsubfield
968
        "
968
        "
969
    );
969
    );
970
970
Lines 981-996 sub GetMarcStructure { Link Here
981
    my $link;
981
    my $link;
982
    my $defaultvalue;
982
    my $defaultvalue;
983
    my $maxlength;
983
    my $maxlength;
984
    my $display_order;
984
985
985
    while (
986
    while (
986
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
987
        (   $tag,          $subfield,      $liblibrarian, $libopac, $tab,    $mandatory, $repeatable, $authorised_value,
987
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
988
            $authtypecode, $value_builder, $kohafield,    $seealso, $hidden, $isurl,     $link,       $defaultvalue,
988
            $maxlength, $important
989
            $maxlength, $important, $display_order
989
        )
990
        )
990
        = $sth->fetchrow
991
        = $sth->fetchrow
991
      ) {
992
      ) {
992
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
993
        $res->{$tag}->{$subfield}->{lib}              = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
993
        $res->{$tag}->{$subfield}->{tab}              = $tab;
994
        $res->{$tag}->{$subfield}->{tab}              = $tab;
995
        $res->{$tag}->{$subfield}->{subfield}         = $subfield;
994
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
996
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
995
        $res->{$tag}->{$subfield}->{important}        = $important;
997
        $res->{$tag}->{$subfield}->{important}        = $important;
996
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
998
        $res->{$tag}->{$subfield}->{repeatable}       = $repeatable;
Lines 1004-1009 sub GetMarcStructure { Link Here
1004
        $res->{$tag}->{$subfield}->{'link'}           = $link;
1006
        $res->{$tag}->{$subfield}->{'link'}           = $link;
1005
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
1007
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
1006
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
1008
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
1009
        $res->{$tag}->{$subfield}->{display_order}    = $display_order;
1007
    }
1010
    }
1008
1011
1009
    $cache->set_in_cache($cache_key, $res);
1012
    $cache->set_in_cache($cache_key, $res);
Lines 1031-1037 sub GetUsedMarcStructure { Link Here
1031
        FROM   marc_subfield_structure
1034
        FROM   marc_subfield_structure
1032
        WHERE   tab > -1 
1035
        WHERE   tab > -1 
1033
            AND frameworkcode = ?
1036
            AND frameworkcode = ?
1034
        ORDER BY tagfield, tagsubfield
1037
        ORDER BY tagfield, display_order, tagsubfield
1035
    };
1038
    };
1036
    my $sth = C4::Context->dbh->prepare($query);
1039
    my $sth = C4::Context->dbh->prepare($query);
1037
    $sth->execute($frameworkcode);
1040
    $sth->execute($frameworkcode);
Lines 1096-1102 sub GetMarcSubfieldStructure { Link Here
1096
        FROM marc_subfield_structure
1099
        FROM marc_subfield_structure
1097
        WHERE frameworkcode = ?
1100
        WHERE frameworkcode = ?
1098
        AND kohafield > ''
1101
        AND kohafield > ''
1099
        ORDER BY frameworkcode,tagfield,tagsubfield
1102
        ORDER BY frameworkcode, tagfield, display_order, tagsubfield
1100
    |, { Slice => {} }, $frameworkcode );
1103
    |, { Slice => {} }, $frameworkcode );
1101
    # Now map the output to a hash structure
1104
    # Now map the output to a hash structure
1102
    my $subfield_structure = {};
1105
    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