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

(-)a/C4/Koha.pm (-50 lines)
Lines 47-53 BEGIN { Link Here
47
		&GetSupportName &GetSupportList
47
		&GetSupportName &GetSupportList
48
		&get_itemtypeinfos_of
48
		&get_itemtypeinfos_of
49
		&getframeworks &getframeworkinfo
49
		&getframeworks &getframeworkinfo
50
        &GetFrameworksLoop
51
		&getallthemes
50
		&getallthemes
52
		&getFacets
51
		&getFacets
53
		&displayServers
52
		&displayServers
Lines 410-464 sub getframeworks { Link Here
410
    return ( \%itemtypes );
409
    return ( \%itemtypes );
411
}
410
}
412
411
413
=head2 GetFrameworksLoop
414
415
  $frameworks = GetFrameworksLoop( $frameworkcode );
416
417
Returns the loop suggested on getframework(), but ordered by framework description.
418
419
build a HTML select with the following code :
420
421
=head3 in PERL SCRIPT
422
423
  $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
424
425
=head3 in TEMPLATE
426
427
  Same as getframework()
428
429
  <form action="[% script_name %] method=post>
430
    <select name="frameworkcode">
431
        <option value="">Default</option>
432
        [% FOREACH framework IN frameworkloop %]
433
        [% IF ( framework.selected ) %]
434
        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
435
        [% ELSE %]
436
        <option value="[% framework.value %]">[% framework.description %]</option>
437
        [% END %]
438
        [% END %]
439
    </select>
440
    <input type=text name=searchfield value="[% searchfield %]">
441
    <input type="submit" value="OK" class="button">
442
  </form>
443
444
=cut
445
446
sub GetFrameworksLoop {
447
    my $frameworkcode = shift;
448
    my $frameworks = getframeworks();
449
    my @frameworkloop;
450
    foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
451
        my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
452
        my %row = (
453
                value       => $thisframework,
454
                selected    => $selected,
455
                description => $frameworks->{$thisframework}->{'frameworktext'},
456
            );
457
        push @frameworkloop, \%row;
458
  }
459
  return \@frameworkloop;
460
}
461
462
=head2 getframeworkinfo
412
=head2 getframeworkinfo
463
413
464
  $frameworkinfo = &getframeworkinfo($frameworkcode);
414
  $frameworkinfo = &getframeworkinfo($frameworkcode);
(-)a/catalogue/labeledMARCdetail.pl (-3 / +7 lines)
Lines 29-35 use C4::Items; Link Here
29
use C4::Members; # to use GetMember
29
use C4::Members; # to use GetMember
30
use C4::Search;		# enabled_staff_search_views
30
use C4::Search;		# enabled_staff_search_views
31
use C4::Acquisition qw(GetOrdersByBiblionumber);
31
use C4::Acquisition qw(GetOrdersByBiblionumber);
32
use C4::Koha qw( GetFrameworksLoop );
32
33
use Koha::BiblioFrameworks;
33
34
34
my $query        = new CGI;
35
my $query        = new CGI;
35
my $dbh          = C4::Context->dbh;
36
my $dbh          = C4::Context->dbh;
Lines 80-87 my $itemcount = GetItemsCount($biblionumber); Link Here
80
$template->param( count => $itemcount,
81
$template->param( count => $itemcount,
81
					bibliotitle => $biblio->{title}, );
82
					bibliotitle => $biblio->{title}, );
82
83
83
#Getting framework loop
84
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
84
$template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) );
85
$template->param(
86
    frameworks    => $frameworks,
87
    frameworkcode => $frameworkcode,
88
);
85
89
86
my @marc_data;
90
my @marc_data;
87
my $prevlabel = '';
91
my $prevlabel = '';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt (-4 / +4 lines)
Lines 60-70 Link Here
60
                    <p><b>With framework:
60
                    <p><b>With framework:
61
                    <select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);">
61
                    <select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);">
62
                        <option value="">Default</option>
62
                        <option value="">Default</option>
63
                        [% FOREACH framework IN frameworkloop %]
63
                        [% FOREACH framework IN frameworks %]
64
                        [% IF ( framework.selected ) %]
64
                        [% IF framework.frameworkcode == frameworkcode %]
65
                        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
65
                            <option value="[% framework.frameworkcode %]" selected="selected">[% framework.frameworktext %]</option>
66
                        [% ELSE %]
66
                        [% ELSE %]
67
                        <option value="[% framework.value %]">[% framework.description %]</option>
67
                            <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
68
                        [% END %]
68
                        [% END %]
69
                        [% END %]
69
                        [% END %]
70
                    </select>
70
                    </select>
(-)a/reports/guided_reports.pl (-5 / +6 lines)
Lines 29-38 use C4::Auth qw/:DEFAULT get_session/; Link Here
29
use C4::Output;
29
use C4::Output;
30
use C4::Debug;
30
use C4::Debug;
31
use C4::Branch; # XXX subfield_is_koha_internal_p
31
use C4::Branch; # XXX subfield_is_koha_internal_p
32
use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/;
32
use C4::Koha qw/IsAuthorisedValueCategory/;
33
use C4::Context;
33
use C4::Context;
34
use C4::Log;
34
use C4::Log;
35
use Koha::DateUtils qw/dt_from_string output_pref/;
35
use Koha::DateUtils qw/dt_from_string output_pref/;
36
use Koha::BiblioFrameworks;
36
37
37
=head1 NAME
38
=head1 NAME
38
39
Lines 675-687 elsif ($phase eq 'Run this report'){ Link Here
675
                        }
676
                        }
676
                    }
677
                    }
677
                    elsif ( $authorised_value eq "biblio_framework" ) {
678
                    elsif ( $authorised_value eq "biblio_framework" ) {
678
                        my $frameworks = GetFrameworksLoop();
679
                        my @frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
679
                        my $default_source = '';
680
                        my $default_source = '';
680
                        push @authorised_values,$default_source;
681
                        push @authorised_values,$default_source;
681
                        $authorised_lib{$default_source} = 'Default';
682
                        $authorised_lib{$default_source} = 'Default';
682
                        foreach my $framework (@$frameworks) {
683
                        foreach my $framework (@frameworks) {
683
                            push @authorised_values, $framework->{value};
684
                            push @authorised_values, $framework->frameworkcode;
684
                            $authorised_lib{$framework->{value}} = $framework->{description};
685
                            $authorised_lib{$framework->frameworkcode} = $framework->frameworktext;
685
                        }
686
                        }
686
                    }
687
                    }
687
                    elsif ( $authorised_value eq "cn_source" ) {
688
                    elsif ( $authorised_value eq "cn_source" ) {
(-)a/t/db_dependent/Koha.t (-45 / +1 lines)
Lines 8-14 use warnings; Link Here
8
use C4::Context;
8
use C4::Context;
9
use Koha::DateUtils qw(dt_from_string);
9
use Koha::DateUtils qw(dt_from_string);
10
10
11
use Test::More tests => 10;
11
use Test::More tests => 9;
12
use DateTime::Format::MySQL;
12
use DateTime::Format::MySQL;
13
13
14
BEGIN {
14
BEGIN {
Lines 255-303 subtest 'getFacets() tests' => sub { Link Here
255
    );
255
    );
256
};
256
};
257
257
258
subtest 'GetFrameworksLoop() tests' => sub {
259
    plan tests => 6;
260
261
    $dbh->do("DELETE FROM biblio_framework");
262
263
    my $frameworksloop = GetFrameworksLoop();
264
    is ( scalar(@$frameworksloop), 0, 'No frameworks' );
265
266
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework'  )");
267
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
268
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework'  )");
269
270
    $frameworksloop = GetFrameworksLoop();
271
    is ( scalar(@$frameworksloop), 3, 'All frameworks' );
272
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
273
274
    $frameworksloop = GetFrameworksLoop( 'B' );
275
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
276
    my @descriptions = map { $_->{'description'} } @$frameworksloop;
277
    is ( $descriptions[0], 'First framework', 'Ordered result' );
278
    cmp_deeply(
279
        $frameworksloop,
280
        [
281
            {
282
                'value' => 'C',
283
                'description' => 'First framework',
284
                'selected' => undef,
285
            },
286
            {
287
                'value' => 'B',
288
                'description' => 'Second framework',
289
                'selected' => 1,                # selected
290
            },
291
            {
292
                'value' => 'A',
293
                'description' => 'Third framework',
294
                'selected' => undef,
295
            }
296
        ],
297
        'Full check, sorted by description with selected val (Bug 12675)'
298
    );
299
};
300
301
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
258
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
302
    plan tests => 7;
259
    plan tests => 7;
303
260
304
- 

Return to bug 15801