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

(-)a/C4/AuthoritiesMarc.pm (-5 / +7 lines)
Lines 471-480 sub GetTagsLabels { Link Here
471
        $res->{$tag}->{repeatable} = $repeatable;
471
        $res->{$tag}->{repeatable} = $repeatable;
472
  }
472
  }
473
  $sth=      $dbh->prepare(
473
  $sth=      $dbh->prepare(
474
"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue
474
"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue, display_order
475
FROM auth_subfield_structure 
475
FROM auth_subfield_structure 
476
WHERE authtypecode=? 
476
WHERE authtypecode=? 
477
ORDER BY tagfield,tagsubfield"
477
ORDER BY tagfield, display_order, tagsubfield"
478
    );
478
    );
479
    $sth->execute($authtypecode);
479
    $sth->execute($authtypecode);
480
480
Lines 485-501 ORDER BY tagfield,tagsubfield" Link Here
485
    my $seealso;
485
    my $seealso;
486
    my $hidden;
486
    my $hidden;
487
    my $isurl;
487
    my $isurl;
488
    my $link;
489
    my $defaultvalue;
488
    my $defaultvalue;
489
    my $display_order;
490
490
491
    while (
491
    while (
492
        ( $tag,         $subfield,   $liblibrarian,   , $libopac,      $tab,
492
        ( $tag,         $subfield,   $liblibrarian,   , $libopac,      $tab,
493
        $mandatory,     $repeatable, $authorised_value, $authtypecode,
493
        $mandatory,     $repeatable, $authorised_value, $authtypecode,
494
        $value_builder, $kohafield,  $seealso,          $hidden,
494
        $value_builder, $kohafield,  $seealso,          $hidden,
495
        $isurl,         $defaultvalue, $link )
495
        $isurl,         $defaultvalue, $display_order )
496
        = $sth->fetchrow
496
        = $sth->fetchrow
497
      )
497
      )
498
    {
498
    {
499
        $res->{$tag}->{$subfield}->{subfield}         = $subfield;
499
        $res->{$tag}->{$subfield}->{lib}              = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
500
        $res->{$tag}->{$subfield}->{lib}              = ($forlibrarian or !$libopac)?$liblibrarian:$libopac;
500
        $res->{$tag}->{$subfield}->{tab}              = $tab;
501
        $res->{$tag}->{$subfield}->{tab}              = $tab;
501
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
502
        $res->{$tag}->{$subfield}->{mandatory}        = $mandatory;
Lines 507-515 ORDER BY tagfield,tagsubfield" Link Here
507
        $res->{$tag}->{$subfield}->{seealso}          = $seealso;
508
        $res->{$tag}->{$subfield}->{seealso}          = $seealso;
508
        $res->{$tag}->{$subfield}->{hidden}           = $hidden;
509
        $res->{$tag}->{$subfield}->{hidden}           = $hidden;
509
        $res->{$tag}->{$subfield}->{isurl}            = $isurl;
510
        $res->{$tag}->{$subfield}->{isurl}            = $isurl;
510
        $res->{$tag}->{$subfield}->{link}            = $link;
511
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
511
        $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
512
        $res->{$tag}->{$subfield}->{display_order}    = $display_order;
512
    }
513
    }
514
513
    return $res;
515
    return $res;
514
}
516
}
515
517
(-)a/admin/auth_subfields_structure.pl (-5 / +10 lines)
Lines 34-40 sub string_search { Link Here
34
	my $dbh = C4::Context->dbh;
34
	my $dbh = C4::Context->dbh;
35
	$searchstring=~ s/\'/\\\'/g;
35
	$searchstring=~ s/\'/\\\'/g;
36
	my @data=split(' ',$searchstring);
36
	my @data=split(' ',$searchstring);
37
	my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield");
37
    my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield, display_order");
38
	$sth->execute("$searchstring%",$authtypecode);
38
	$sth->execute("$searchstring%",$authtypecode);
39
	my $results = $sth->fetchall_arrayref({});
39
	my $results = $sth->fetchall_arrayref({});
40
	return (scalar(@$results), $results);
40
	return (scalar(@$results), $results);
Lines 124-130 if ($op eq 'add_form') { Link Here
124
	closedir DIR;
124
	closedir DIR;
125
125
126
	# build values list
126
	# build values list
127
	my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=?"); # and tagsubfield='$tagsubfield'");
127
    my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=? order by display_order"); # and tagsubfield='$tagsubfield'");
128
	$sth->execute($tagfield,$authtypecode);
128
	$sth->execute($tagfield,$authtypecode);
129
	my @loop_data = ();
129
	my @loop_data = ();
130
	my $i=0;
130
	my $i=0;
Lines 189-197 if ($op eq 'add_form') { Link Here
189
	$template->param(tagfield => "$input->param('tagfield')");
189
	$template->param(tagfield => "$input->param('tagfield')");
190
#	my $sth=$dbh->prepare("replace auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl)
190
#	my $sth=$dbh->prepare("replace auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl)
191
#									values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
191
#									values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
192
    my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl,defaultvalue)
192
    my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl,defaultvalue, display_order)
193
                                    values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
193
                                    values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
194
    my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=?
194
    my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=?, display_order=?
195
                                    where authtypecode=? and tagfield=? and tagsubfield=?");
195
                                    where authtypecode=? and tagfield=? and tagsubfield=?");
196
	my @tagsubfield	= $input->multi_param('tagsubfield');
196
	my @tagsubfield	= $input->multi_param('tagsubfield');
197
	my @liblibrarian	= $input->multi_param('liblibrarian');
197
	my @liblibrarian	= $input->multi_param('liblibrarian');
Lines 205-210 if ($op eq 'add_form') { Link Here
205
	my @frameworkcodes	= $input->multi_param('frameworkcode');
205
	my @frameworkcodes	= $input->multi_param('frameworkcode');
206
	my @value_builder	=$input->multi_param('value_builder');
206
	my @value_builder	=$input->multi_param('value_builder');
207
    my @defaultvalue = $input->multi_param('defaultvalue');
207
    my @defaultvalue = $input->multi_param('defaultvalue');
208
209
    my $display_order;
208
	for (my $i=0; $i<= $#tagsubfield ; $i++) {
210
	for (my $i=0; $i<= $#tagsubfield ; $i++) {
209
		my $tagfield			=$input->param('tagfield');
211
		my $tagfield			=$input->param('tagfield');
210
		my $tagsubfield		=$tagsubfield[$i];
212
		my $tagsubfield		=$tagsubfield[$i];
Lines 241-246 if ($op eq 'add_form') { Link Here
241
						$hidden,
243
						$hidden,
242
						$isurl,
244
						$isurl,
243
                        $defaultvalue,
245
                        $defaultvalue,
246
                        $display_order->{$tagfield} || 0,
244
						(
247
						(
245
							$authtypecode,
248
							$authtypecode,
246
							$tagfield,
249
							$tagfield,
Lines 265-272 if ($op eq 'add_form') { Link Here
265
						$hidden,
268
						$hidden,
266
						$isurl,
269
						$isurl,
267
                        $defaultvalue,
270
                        $defaultvalue,
271
                        display_order    => $display_order->{$tagfield} || 0,
268
					);
272
					);
269
				}
273
				}
274
            $display_order->{$tagfield}++;
270
		}
275
		}
271
	}
276
	}
272
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&amp;authtypecode=$authtypecode");
277
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&amp;authtypecode=$authtypecode");
(-)a/authorities/authorities.pl (-5 / +8 lines)
Lines 474-487 sub build_tabs { Link Here
474
            }
474
            }
475
            else {
475
            else {
476
                my @subfields_data;
476
                my @subfields_data;
477
                foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
477
                foreach my $subfield (
478
                    next if ( length $subfield != 1 );
478
                    sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} }
479
                    next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
479
                    grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty
480
                    next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
480
                    values %{ $tagslib->{$tag} } )
481
                {
482
                    next if $subfield->{hidden} && $subfield->{subfield} ne '9';
483
                    next if ( $subfield->{tab} ne $tabloop );
481
                    push(
484
                    push(
482
                        @subfields_data,
485
                        @subfields_data,
483
                        &create_input(
486
                        &create_input(
484
                            $tag, $subfield, '', $index_tag, $tabloop, $record,
487
                            $tag, $subfield->{subfield}, '', $index_tag, $tabloop, $record,
485
                            $authorised_values_sth,$input
488
                            $authorised_values_sth,$input
486
                        )
489
                        )
487
                    );
490
                    );
(-)a/installer/data/mysql/atomicupdate/bug_8976.perl (-1 / +8 lines)
Lines 8-13 if( CheckVersion( $DBversion ) ) { Link Here
8
        });
8
        });
9
    }
9
    }
10
10
11
    unless ( column_exists( 'auth_subfield_structure', 'display_order' ) ) {
12
        $dbh->do(q{
13
            ALTER TABLE auth_subfield_structure
14
            ADD COLUMN display_order INT(2) NOT NULL DEFAULT 0 AFTER defaultvalue
15
        });
16
    }
17
11
    # Always end with this (adjust the bug info)
18
    # Always end with this (adjust the bug info)
12
    NewVersion( $DBversion, XXXXX, "Description");
19
    NewVersion( $DBversion, 8976, "Description");
13
}
20
}
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 70-75 CREATE TABLE `auth_subfield_structure` ( Link Here
70
  `kohafield` varchar(45) NULL default '',
70
  `kohafield` varchar(45) NULL default '',
71
  `frameworkcode` varchar(10) NOT NULL default '',
71
  `frameworkcode` varchar(10) NOT NULL default '',
72
  `defaultvalue` MEDIUMTEXT,
72
  `defaultvalue` MEDIUMTEXT,
73
  `display_order` INT(2) NOT NULL DEFAULT 0,
73
  PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
74
  PRIMARY KEY  (`authtypecode`,`tagfield`,`tagsubfield`),
74
  KEY `tab` (`authtypecode`,`tab`),
75
  KEY `tab` (`authtypecode`,`tab`),
75
  CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
76
  CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt (-9 / +31 lines)
Lines 44-56 Link Here
44
        <div id="subfieldtabs" class="toptabs numbered">
44
        <div id="subfieldtabs" class="toptabs numbered">
45
            <ul>
45
            <ul>
46
                [% FOREACH loo IN loop %]
46
                [% FOREACH loo IN loop %]
47
                    [% IF ( loo.new_subfield ) %]
47
                    <li id="tab_subfield_[% loo.tagsubfield | html %]">
48
                        <li><a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">New</a></li>
48
                        [% IF ( loo.new_subfield ) %]
49
                    [% ELSE %]
49
                            <a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">New</a>
50
                        <li><a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">
50
                        [% ELSE %]
51
                            [% loo.tagsubfield | html %]
51
                            <a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">[% loo.tagsubfield | html %]</a>
52
                    </a></li>
52
                        [% END %]
53
                    [% END %]
53
                    </li>
54
                [% END %]
54
                [% END %]
55
            </ul>
55
            </ul>
56
56
Lines 350-362 Link Here
350
    [% Asset.js("js/admin-menu.js") | $raw %]
350
    [% Asset.js("js/admin-menu.js") | $raw %]
351
    <script>
351
    <script>
352
        $(document).ready(function() {
352
        $(document).ready(function() {
353
            $('#subfieldtabs').tabs();
354
            $("#table_authsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
353
            $("#table_authsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
355
                "columnDefs": [
354
                "columnDefs": [
356
                    { 'sortable': false, 'targets': [ 'NoSort' ] }
355
                    { 'sortable': false, 'targets': [ 'NoSort' ] }
357
                ],
356
                ],
357
                aaSorting: [],
358
                paginate: false
358
                paginate: false
359
            }));
359
            }));
360
361
            var tabs = $('#subfieldtabs').tabs();
362
            var current_index;
363
            tabs.find( ".ui-tabs-nav" ).sortable({
364
                axis: "x",
365
                start: function (e, ui) {
366
                    current_index = $(ui.item[0]).index();
367
                },
368
                stop: function (e, ui) {
369
                    var new_index = $(ui.item[0]).index();
370
                    if (current_index < new_index) new_index++;
371
                    var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, '');
372
                    var content = $('#sub' + subfield_code + 'field');
373
                    var panels = $("#subfieldtabs > div");
374
                    if ( new_index < $(panels).size() ){
375
                        $(content).insertBefore($("#subfieldtabs > div")[new_index]);
376
                    } else {
377
                        $(content).insertAfter($("#subfieldtabs > div")[new_index-1]);
378
                    }
379
                    tabs.tabs("refresh");
380
                }
381
            });
382
360
        });
383
        });
361
    </script>
384
    </script>
362
[% END %]
385
[% END %]
363
- 

Return to bug 8976