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

Return to bug 15801