&GetItemTypes &getitemtypeinfo
&GetItemTypesCategorized &GetItemTypesByCategory
&getframeworks &getframeworkinfo
- &GetFrameworksLoop
&getallthemes
&getFacets
&getnbpages
return ( \%itemtypes );
}
-=head2 GetFrameworksLoop
-
- $frameworks = GetFrameworksLoop( $frameworkcode );
-
-Returns the loop suggested on getframework(), but ordered by framework description.
-
-build a HTML select with the following code :
-
-=head3 in PERL SCRIPT
-
- $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) );
-
-=head3 in TEMPLATE
-
- Same as getframework()
-
- <form action="[% script_name %] method=post>
- <select name="frameworkcode">
- <option value="">Default</option>
- [% FOREACH framework IN frameworkloop %]
- [% IF ( framework.selected ) %]
- <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
- [% ELSE %]
- <option value="[% framework.value %]">[% framework.description %]</option>
- [% END %]
- [% END %]
- </select>
- <input type=text name=searchfield value="[% searchfield %]">
- <input type="submit" value="OK" class="button">
- </form>
-
-=cut
-
-sub GetFrameworksLoop {
- my $frameworkcode = shift;
- my $frameworks = getframeworks();
- my @frameworkloop;
- foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) {
- my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef;
- my %row = (
- value => $thisframework,
- selected => $selected,
- description => $frameworks->{$thisframework}->{'frameworktext'},
- );
- push @frameworkloop, \%row;
- }
- return \@frameworkloop;
-}
-
=head2 getframeworkinfo
$frameworkinfo = &getframeworkinfo($frameworkcode);
use C4::Members; # to use GetMember
use C4::Search; # enabled_staff_search_views
use C4::Acquisition qw(GetOrdersByBiblionumber);
-use C4::Koha qw( GetFrameworksLoop );
+
+use Koha::BiblioFrameworks;
my $query = new CGI;
my $dbh = C4::Context->dbh;
$template->param( count => $itemcount,
bibliotitle => $biblio->{title}, );
-#Getting framework loop
-$template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) );
+my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
+$template->param(
+ frameworks => $frameworks,
+ frameworkcode => $frameworkcode,
+);
my @marc_data;
my $prevlabel = '';
<p><b>With framework:
<select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);">
<option value="">Default</option>
- [% FOREACH framework IN frameworkloop %]
- [% IF ( framework.selected ) %]
- <option value="[% framework.value %]" selected="selected">[% framework.description %]</option>
+ [% FOREACH framework IN frameworks %]
+ [% IF framework.frameworkcode == frameworkcode %]
+ <option value="[% framework.frameworkcode %]" selected="selected">[% framework.frameworktext %]</option>
[% ELSE %]
- <option value="[% framework.value %]">[% framework.description %]</option>
+ <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
[% END %]
[% END %]
</select>
use C4::Auth qw/:DEFAULT get_session/;
use C4::Output;
use C4::Debug;
-use C4::Koha qw/GetFrameworksLoop/;
use C4::Context;
use Koha::Caches;
use C4::Log;
use Koha::DateUtils qw/dt_from_string output_pref/;
use Koha::AuthorisedValue;
use Koha::AuthorisedValues;
+use Koha::BiblioFrameworks;
use Koha::Libraries;
use Koha::Patron::Categories;
}
}
elsif ( $authorised_value eq "biblio_framework" ) {
- my $frameworks = GetFrameworksLoop();
+ my @frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
my $default_source = '';
push @authorised_values,$default_source;
$authorised_lib{$default_source} = 'Default';
- foreach my $framework (@$frameworks) {
- push @authorised_values, $framework->{value};
- $authorised_lib{$framework->{value}} = $framework->{description};
+ foreach my $framework (@frameworks) {
+ push @authorised_values, $framework->frameworkcode;
+ $authorised_lib{$framework->frameworkcode} = $framework->frameworktext;
}
}
elsif ( $authorised_value eq "cn_source" ) {
};
-subtest 'GetFrameworksLoop() tests' => sub {
- plan tests => 6;
-
- $dbh->do("DELETE FROM biblio_framework");
-
- my $frameworksloop = GetFrameworksLoop();
- is ( scalar(@$frameworksloop), 0, 'No frameworks' );
-
- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework' )");
- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )");
- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework' )");
-
- $frameworksloop = GetFrameworksLoop();
- is ( scalar(@$frameworksloop), 3, 'All frameworks' );
- is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' );
-
- $frameworksloop = GetFrameworksLoop( 'B' );
- is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' );
- my @descriptions = map { $_->{'description'} } @$frameworksloop;
- is ( $descriptions[0], 'First framework', 'Ordered result' );
- cmp_deeply(
- $frameworksloop,
- [
- {
- 'value' => 'C',
- 'description' => 'First framework',
- 'selected' => undef,
- },
- {
- 'value' => 'B',
- 'description' => 'Second framework',
- 'selected' => 1, # selected
- },
- {
- 'value' => 'A',
- 'description' => 'Third framework',
- 'selected' => undef,
- }
- ],
- 'Full check, sorted by description with selected val (Bug 12675)'
- );
-};
-
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
plan tests => 7;