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
		&GetItemTypes &getitemtypeinfo
43
		&GetItemTypes &getitemtypeinfo
44
                &GetItemTypesCategorized &GetItemTypesByCategory
44
                &GetItemTypesCategorized &GetItemTypesByCategory
45
		&getframeworks &getframeworkinfo
45
		&getframeworks &getframeworkinfo
46
        &GetFrameworksLoop
47
		&getallthemes
46
		&getallthemes
48
		&getFacets
47
		&getFacets
49
		&getnbpages
48
		&getnbpages
Lines 279-333 sub getframeworks { Link Here
279
    return ( \%itemtypes );
278
    return ( \%itemtypes );
280
}
279
}
281
280
282
=head2 GetFrameworksLoop
283
284
  $frameworks = GetFrameworksLoop( $frameworkcode );
285
286
Returns the loop suggested on getframework(), but ordered by framework description.
287
288
build a HTML select with the following code :
289
290
=head3 in PERL SCRIPT
291
292
  $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
293
294
=head3 in TEMPLATE
295
296
  Same as getframework()
297
298
  <form action="[% script_name %] method=post>
299
    <select name="frameworkcode">
300
        <option value="">Default</option>
301
        [% FOREACH framework IN frameworkloop %]
302
        [% IF ( framework.selected ) %]
303
        <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
304
        [% ELSE %]
305
        <option value="[% framework.value %]">[% framework.description %]</option>
306
        [% END %]
307
        [% END %]
308
    </select>
309
    <input type=text name=searchfield value="[% searchfield %]">
310
    <input type="submit" value="OK" class="button">
311
  </form>
312
313
=cut
314
315
sub GetFrameworksLoop {
316
    my $frameworkcode = shift;
317
    my $frameworks = getframeworks();
318
    my @frameworkloop;
319
    foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
320
        my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
321
        my %row = (
322
                value       => $thisframework,
323
                selected    => $selected,
324
                description => $frameworks->{$thisframework}->{'frameworktext'},
325
            );
326
        push @frameworkloop, \%row;
327
  }
328
  return \@frameworkloop;
329
}
330
331
=head2 getframeworkinfo
281
=head2 getframeworkinfo
332
282
333
  $frameworkinfo = &getframeworkinfo($frameworkcode);
283
  $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 (-44 lines)
Lines 239-287 subtest 'ISBN tests' => sub { Link Here
239
239
240
};
240
};
241
241
242
subtest 'GetFrameworksLoop() tests' => sub {
243
    plan tests => 6;
244
245
    $dbh->do("DELETE FROM biblio_framework");
246
247
    my $frameworksloop = GetFrameworksLoop();
248
    is ( scalar(@$frameworksloop), 0, 'No frameworks' );
249
250
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework'  )");
251
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
252
    $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework'  )");
253
254
    $frameworksloop = GetFrameworksLoop();
255
    is ( scalar(@$frameworksloop), 3, 'All frameworks' );
256
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
257
258
    $frameworksloop = GetFrameworksLoop( 'B' );
259
    is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
260
    my @descriptions = map { $_->{'description'} } @$frameworksloop;
261
    is ( $descriptions[0], 'First framework', 'Ordered result' );
262
    cmp_deeply(
263
        $frameworksloop,
264
        [
265
            {
266
                'value' => 'C',
267
                'description' => 'First framework',
268
                'selected' => undef,
269
            },
270
            {
271
                'value' => 'B',
272
                'description' => 'Second framework',
273
                'selected' => 1,                # selected
274
            },
275
            {
276
                'value' => 'A',
277
                'description' => 'Third framework',
278
                'selected' => undef,
279
            }
280
        ],
281
        'Full check, sorted by description with selected val (Bug 12675)'
282
    );
283
};
284
285
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
242
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
286
    plan tests => 7;
243
    plan tests => 7;
287
244
288
- 

Return to bug 15801