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

(-)a/C4/Koha.pm (-50 lines)
Lines 44-50 BEGIN { Link Here
44
                &GetItemTypesCategorized &GetItemTypesByCategory
44
                &GetItemTypesCategorized &GetItemTypesByCategory
45
		&GetSupportName &GetSupportList
45
		&GetSupportName &GetSupportList
46
		&getframeworks &getframeworkinfo
46
		&getframeworks &getframeworkinfo
47
        &GetFrameworksLoop
48
		&getallthemes
47
		&getallthemes
49
		&getFacets
48
		&getFacets
50
		&getnbpages
49
		&getnbpages
Lines 359-413 sub getframeworks { Link Here
359
    return ( \%itemtypes );
358
    return ( \%itemtypes );
360
}
359
}
361
360
362
=head2 GetFrameworksLoop
363
364
  $frameworks = GetFrameworksLoop( $frameworkcode );
365
366
Returns the loop suggested on getframework(), but ordered by framework description.
367
368
build a HTML select with the following code :
369
370
=head3 in PERL SCRIPT
371
372
  $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
373
374
=head3 in TEMPLATE
375
376
  Same as getframework()
377
378
  <form action="[% script_name %] method=post>
379
    <select name="frameworkcode">
380
        <option value="">Default</option>
381
        [% FOREACH framework IN frameworkloop %]
382
        [% IF ( framework.selected ) %]
383
        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
384
        [% ELSE %]
385
        <option value="[% framework.value %]">[% framework.description %]</option>
386
        [% END %]
387
        [% END %]
388
    </select>
389
    <input type=text name=searchfield value="[% searchfield %]">
390
    <input type="submit" value="OK" class="button">
391
  </form>
392
393
=cut
394
395
sub GetFrameworksLoop {
396
    my $frameworkcode = shift;
397
    my $frameworks = getframeworks();
398
    my @frameworkloop;
399
    foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
400
        my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
401
        my %row = (
402
                value       => $thisframework,
403
                selected    => $selected,
404
                description => $frameworks->{$thisframework}->{'frameworktext'},
405
            );
406
        push @frameworkloop, \%row;
407
  }
408
  return \@frameworkloop;
409
}
410
411
=head2 getframeworkinfo
361
=head2 getframeworkinfo
412
362
413
  $frameworkinfo = &getframeworkinfo($frameworkcode);
363
  $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 258-306 subtest 'ISBN tests' => sub { Link Here
258
258
259
};
259
};
260
260
261
subtest 'GetFrameworksLoop() tests' => sub {
262
    plan tests => 6;
263
264
    $dbh->do("DELETE FROM biblio_framework");
265
266
    my $frameworksloop = GetFrameworksLoop();
267
    is ( scalar(@$frameworksloop), 0, 'No frameworks' );
268
269
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework'  )");
270
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
271
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework'  )");
272
273
    $frameworksloop = GetFrameworksLoop();
274
    is ( scalar(@$frameworksloop), 3, 'All frameworks' );
275
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
276
277
    $frameworksloop = GetFrameworksLoop( 'B' );
278
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
279
    my @descriptions = map { $_->{'description'} } @$frameworksloop;
280
    is ( $descriptions[0], 'First framework', 'Ordered result' );
281
    cmp_deeply(
282
        $frameworksloop,
283
        [
284
            {
285
                'value' => 'C',
286
                'description' => 'First framework',
287
                'selected' => undef,
288
            },
289
            {
290
                'value' => 'B',
291
                'description' => 'Second framework',
292
                'selected' => 1,                # selected
293
            },
294
            {
295
                'value' => 'A',
296
                'description' => 'Third framework',
297
                'selected' => undef,
298
            }
299
        ],
300
        'Full check, sorted by description with selected val (Bug 12675)'
301
    );
302
};
303
304
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
261
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
305
    plan tests => 7;
262
    plan tests => 7;
306
263
307
- 

Return to bug 15801