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

(-)a/C4/Koha.pm (-50 lines)
Lines 43-49 BEGIN { Link Here
43
                &GetItemTypesCategorized &GetItemTypesByCategory
43
                &GetItemTypesCategorized &GetItemTypesByCategory
44
		&GetSupportName &GetSupportList
44
		&GetSupportName &GetSupportList
45
		&getframeworks &getframeworkinfo
45
		&getframeworks &getframeworkinfo
46
        &GetFrameworksLoop
47
		&getallthemes
46
		&getallthemes
48
		&getFacets
47
		&getFacets
49
		&getnbpages
48
		&getnbpages
Lines 358-412 sub getframeworks { Link Here
358
    return ( \%itemtypes );
357
    return ( \%itemtypes );
359
}
358
}
360
359
361
=head2 GetFrameworksLoop
362
363
  $frameworks = GetFrameworksLoop( $frameworkcode );
364
365
Returns the loop suggested on getframework(), but ordered by framework description.
366
367
build a HTML select with the following code :
368
369
=head3 in PERL SCRIPT
370
371
  $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
372
373
=head3 in TEMPLATE
374
375
  Same as getframework()
376
377
  <form action="[% script_name %] method=post>
378
    <select name="frameworkcode">
379
        <option value="">Default</option>
380
        [% FOREACH framework IN frameworkloop %]
381
        [% IF ( framework.selected ) %]
382
        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
383
        [% ELSE %]
384
        <option value="[% framework.value %]">[% framework.description %]</option>
385
        [% END %]
386
        [% END %]
387
    </select>
388
    <input type=text name=searchfield value="[% searchfield %]">
389
    <input type="submit" value="OK" class="button">
390
  </form>
391
392
=cut
393
394
sub GetFrameworksLoop {
395
    my $frameworkcode = shift;
396
    my $frameworks = getframeworks();
397
    my @frameworkloop;
398
    foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
399
        my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
400
        my %row = (
401
                value       => $thisframework,
402
                selected    => $selected,
403
                description => $frameworks->{$thisframework}->{'frameworktext'},
404
            );
405
        push @frameworkloop, \%row;
406
  }
407
  return \@frameworkloop;
408
}
409
410
=head2 getframeworkinfo
360
=head2 getframeworkinfo
411
361
412
  $frameworkinfo = &getframeworkinfo($frameworkcode);
362
  $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 / +5 lines)
Lines 28-40 use C4::Reports::Guided; Link Here
28
use C4::Auth qw/:DEFAULT get_session/;
28
use C4::Auth qw/:DEFAULT get_session/;
29
use C4::Output;
29
use C4::Output;
30
use C4::Debug;
30
use C4::Debug;
31
use C4::Koha qw/GetFrameworksLoop/;
32
use C4::Branch;
31
use C4::Branch;
33
use C4::Context;
32
use C4::Context;
34
use C4::Log;
33
use C4::Log;
35
use Koha::DateUtils qw/dt_from_string output_pref/;
34
use Koha::DateUtils qw/dt_from_string output_pref/;
36
use Koha::AuthorisedValue;
35
use Koha::AuthorisedValue;
37
use Koha::AuthorisedValues;
36
use Koha::AuthorisedValues;
37
use Koha::BiblioFrameworks;
38
38
39
=head1 NAME
39
=head1 NAME
40
40
Lines 677-689 elsif ($phase eq 'Run this report'){ Link Here
677
                        }
677
                        }
678
                    }
678
                    }
679
                    elsif ( $authorised_value eq "biblio_framework" ) {
679
                    elsif ( $authorised_value eq "biblio_framework" ) {
680
                        my $frameworks = GetFrameworksLoop();
680
                        my @frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
681
                        my $default_source = '';
681
                        my $default_source = '';
682
                        push @authorised_values,$default_source;
682
                        push @authorised_values,$default_source;
683
                        $authorised_lib{$default_source} = 'Default';
683
                        $authorised_lib{$default_source} = 'Default';
684
                        foreach my $framework (@$frameworks) {
684
                        foreach my $framework (@frameworks) {
685
                            push @authorised_values, $framework->{value};
685
                            push @authorised_values, $framework->frameworkcode;
686
                            $authorised_lib{$framework->{value}} = $framework->{description};
686
                            $authorised_lib{$framework->frameworkcode} = $framework->frameworktext;
687
                        }
687
                        }
688
                    }
688
                    }
689
                    elsif ( $authorised_value eq "cn_source" ) {
689
                    elsif ( $authorised_value eq "cn_source" ) {
(-)a/t/db_dependent/Koha.t (-45 / +1 lines)
Lines 8-14 use C4::Context; Link Here
8
use Koha::DateUtils qw(dt_from_string);
8
use Koha::DateUtils qw(dt_from_string);
9
use Koha::AuthorisedValue;
9
use Koha::AuthorisedValue;
10
10
11
use Test::More tests => 9;
11
use Test::More tests => 8;
12
use DateTime::Format::MySQL;
12
use DateTime::Format::MySQL;
13
13
14
BEGIN {
14
BEGIN {
Lines 252-300 subtest 'ISBN tests' => sub { Link Here
252
252
253
};
253
};
254
254
255
subtest 'GetFrameworksLoop() tests' => sub {
256
    plan tests => 6;
257
258
    $dbh->do("DELETE FROM biblio_framework");
259
260
    my $frameworksloop = GetFrameworksLoop();
261
    is ( scalar(@$frameworksloop), 0, 'No frameworks' );
262
263
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework'  )");
264
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
265
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework'  )");
266
267
    $frameworksloop = GetFrameworksLoop();
268
    is ( scalar(@$frameworksloop), 3, 'All frameworks' );
269
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
270
271
    $frameworksloop = GetFrameworksLoop( 'B' );
272
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
273
    my @descriptions = map { $_->{'description'} } @$frameworksloop;
274
    is ( $descriptions[0], 'First framework', 'Ordered result' );
275
    cmp_deeply(
276
        $frameworksloop,
277
        [
278
            {
279
                'value' => 'C',
280
                'description' => 'First framework',
281
                'selected' => undef,
282
            },
283
            {
284
                'value' => 'B',
285
                'description' => 'Second framework',
286
                'selected' => 1,                # selected
287
            },
288
            {
289
                'value' => 'A',
290
                'description' => 'Third framework',
291
                'selected' => undef,
292
            }
293
        ],
294
        'Full check, sorted by description with selected val (Bug 12675)'
295
    );
296
};
297
298
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
255
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
299
    plan tests => 7;
256
    plan tests => 7;
300
257
301
- 

Return to bug 15801