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

(-)a/C4/Koha.pm (-50 lines)
Lines 41-47 BEGIN { Link Here
41
		&GetItemTypes &getitemtypeinfo
41
		&GetItemTypes &getitemtypeinfo
42
                &GetItemTypesCategorized &GetItemTypesByCategory
42
                &GetItemTypesCategorized &GetItemTypesByCategory
43
		&getframeworks &getframeworkinfo
43
		&getframeworks &getframeworkinfo
44
        &GetFrameworksLoop
45
		&getallthemes
44
		&getallthemes
46
		&getFacets
45
		&getFacets
47
		&getnbpages
46
		&getnbpages
Lines 282-336 sub getframeworks { Link Here
282
    return ( \%itemtypes );
281
    return ( \%itemtypes );
283
}
282
}
284
283
285
=head2 GetFrameworksLoop
286
287
  $frameworks = GetFrameworksLoop( $frameworkcode );
288
289
Returns the loop suggested on getframework(), but ordered by framework description.
290
291
build a HTML select with the following code :
292
293
=head3 in PERL SCRIPT
294
295
  $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
296
297
=head3 in TEMPLATE
298
299
  Same as getframework()
300
301
  <form action="[% script_name %] method=post>
302
    <select name="frameworkcode">
303
        <option value="">Default</option>
304
        [% FOREACH framework IN frameworkloop %]
305
        [% IF ( framework.selected ) %]
306
        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
307
        [% ELSE %]
308
        <option value="[% framework.value %]">[% framework.description %]</option>
309
        [% END %]
310
        [% END %]
311
    </select>
312
    <input type=text name=searchfield value="[% searchfield %]">
313
    <input type="submit" value="OK" class="button">
314
  </form>
315
316
=cut
317
318
sub GetFrameworksLoop {
319
    my $frameworkcode = shift;
320
    my $frameworks = getframeworks();
321
    my @frameworkloop;
322
    foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
323
        my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
324
        my %row = (
325
                value       => $thisframework,
326
                selected    => $selected,
327
                description => $frameworks->{$thisframework}->{'frameworktext'},
328
            );
329
        push @frameworkloop, \%row;
330
  }
331
  return \@frameworkloop;
332
}
333
334
=head2 getframeworkinfo
284
=head2 getframeworkinfo
335
285
336
  $frameworkinfo = &getframeworkinfo($frameworkcode);
286
  $frameworkinfo = &getframeworkinfo($frameworkcode);
(-)a/catalogue/labeledMARCdetail.pl (-3 / +7 lines)
Lines 30-36 use C4::Items; Link Here
30
use C4::Members; # to use GetMember
30
use C4::Members; # to use GetMember
31
use C4::Search;		# enabled_staff_search_views
31
use C4::Search;		# enabled_staff_search_views
32
use C4::Acquisition qw(GetOrdersByBiblionumber);
32
use C4::Acquisition qw(GetOrdersByBiblionumber);
33
use C4::Koha qw( GetFrameworksLoop );
33
34
use Koha::BiblioFrameworks;
34
35
35
my $query        = new CGI;
36
my $query        = new CGI;
36
my $dbh          = C4::Context->dbh;
37
my $dbh          = C4::Context->dbh;
Lines 82-89 my $itemcount = GetItemsCount($biblionumber); Link Here
82
$template->param( count => $itemcount,
83
$template->param( count => $itemcount,
83
					bibliotitle => $biblio->{title}, );
84
					bibliotitle => $biblio->{title}, );
84
85
85
#Getting framework loop
86
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
86
$template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) );
87
$template->param(
88
    frameworks    => $frameworks,
89
    frameworkcode => $frameworkcode,
90
);
87
91
88
my @marc_data;
92
my @marc_data;
89
my $prevlabel = '';
93
my $prevlabel = '';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt (-4 / +4 lines)
Lines 65-75 Link Here
65
                    <p><b>With framework:
65
                    <p><b>With framework:
66
                    <select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);">
66
                    <select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);">
67
                        <option value="">Default</option>
67
                        <option value="">Default</option>
68
                        [% FOREACH framework IN frameworkloop %]
68
                        [% FOREACH framework IN frameworks %]
69
                        [% IF ( framework.selected ) %]
69
                        [% IF framework.frameworkcode == frameworkcode %]
70
                        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
70
                            <option value="[% framework.frameworkcode %]" selected="selected">[% framework.frameworktext %]</option>
71
                        [% ELSE %]
71
                        [% ELSE %]
72
                        <option value="[% framework.value %]">[% framework.description %]</option>
72
                            <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
73
                        [% END %]
73
                        [% END %]
74
                        [% END %]
74
                        [% END %]
75
                    </select>
75
                    </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::Context;
31
use C4::Context;
33
use Koha::Caches;
32
use Koha::Caches;
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
use Koha::Libraries;
38
use Koha::Libraries;
39
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
40
40
Lines 686-698 elsif ($phase eq 'Run this report'){ Link Here
686
                        }
686
                        }
687
                    }
687
                    }
688
                    elsif ( $authorised_value eq "biblio_framework" ) {
688
                    elsif ( $authorised_value eq "biblio_framework" ) {
689
                        my $frameworks = GetFrameworksLoop();
689
                        my @frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
690
                        my $default_source = '';
690
                        my $default_source = '';
691
                        push @authorised_values,$default_source;
691
                        push @authorised_values,$default_source;
692
                        $authorised_lib{$default_source} = 'Default';
692
                        $authorised_lib{$default_source} = 'Default';
693
                        foreach my $framework (@$frameworks) {
693
                        foreach my $framework (@frameworks) {
694
                            push @authorised_values, $framework->{value};
694
                            push @authorised_values, $framework->frameworkcode;
695
                            $authorised_lib{$framework->{value}} = $framework->{description};
695
                            $authorised_lib{$framework->frameworkcode} = $framework->frameworktext;
696
                        }
696
                        }
697
                    }
697
                    }
698
                    elsif ( $authorised_value eq "cn_source" ) {
698
                    elsif ( $authorised_value eq "cn_source" ) {
(-)a/t/db_dependent/Koha.t (-45 / +1 lines)
Lines 9-15 use Koha::DateUtils qw(dt_from_string); Link Here
9
use Koha::AuthorisedValue;
9
use Koha::AuthorisedValue;
10
use Koha::AuthorisedValueCategories;
10
use Koha::AuthorisedValueCategories;
11
11
12
use Test::More tests => 9;
12
use Test::More tests => 8;
13
use DateTime::Format::MySQL;
13
use DateTime::Format::MySQL;
14
14
15
BEGIN {
15
BEGIN {
Lines 246-294 subtest 'ISBN tests' => sub { Link Here
246
246
247
};
247
};
248
248
249
subtest 'GetFrameworksLoop() tests' => sub {
250
    plan tests => 6;
251
252
    $dbh->do("DELETE FROM biblio_framework");
253
254
    my $frameworksloop = GetFrameworksLoop();
255
    is ( scalar(@$frameworksloop), 0, 'No frameworks' );
256
257
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework'  )");
258
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
259
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework'  )");
260
261
    $frameworksloop = GetFrameworksLoop();
262
    is ( scalar(@$frameworksloop), 3, 'All frameworks' );
263
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
264
265
    $frameworksloop = GetFrameworksLoop( 'B' );
266
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
267
    my @descriptions = map { $_->{'description'} } @$frameworksloop;
268
    is ( $descriptions[0], 'First framework', 'Ordered result' );
269
    cmp_deeply(
270
        $frameworksloop,
271
        [
272
            {
273
                'value' => 'C',
274
                'description' => 'First framework',
275
                'selected' => undef,
276
            },
277
            {
278
                'value' => 'B',
279
                'description' => 'Second framework',
280
                'selected' => 1,                # selected
281
            },
282
            {
283
                'value' => 'A',
284
                'description' => 'Third framework',
285
                'selected' => undef,
286
            }
287
        ],
288
        'Full check, sorted by description with selected val (Bug 12675)'
289
    );
290
};
291
292
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
249
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
293
    plan tests => 7;
250
    plan tests => 7;
294
251
295
- 

Return to bug 15801