-=head2 GetItemTypesByCategory
-
- @results = GetItemTypesByCategory( $searchcategory );
-
-Returns the itemtype code of all itemtypes included in a searchcategory.
-
-=cut
-
-sub GetItemTypesByCategory {
- my ($category) = @_;
- my $count = 0;
- my @results;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT itemtype FROM itemtypes WHERE searchcategory=?|;
- my $tmp=$dbh->selectcol_arrayref($query,undef,$category);
- return @$tmp;
-}
-
-=head2 getframework
-
- $frameworks = &getframework();
-
-Returns information about existing frameworks
-
-build a HTML select with the following code :
-
-=head3 in PERL SCRIPT
-
- my $frameworks = getframeworks();
- my @frameworkloop;
- foreach my $thisframework (keys %$frameworks) {
- my $selected = 1 if $thisframework eq $frameworkcode;
- my %row =(
- value => $thisframework,
- selected => $selected,
- description => $frameworks->{$thisframework}->{'frameworktext'},
- );
- push @frameworksloop, \%row;
- }
- $template->param(frameworkloop => \@frameworksloop);
-
-=head3 in TEMPLATE
-
- <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 getframeworks {
-
- # returns a reference to a hash of references to branches...
- my %itemtypes;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("select * from biblio_framework");
- $sth->execute;
- while ( my $IT = $sth->fetchrow_hashref ) {
- $itemtypes{ $IT->{'frameworkcode'} } = $IT;
- }
- 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);
-
-Returns information about an frameworkcode.
-
-=cut
-
-sub getframeworkinfo {
- my ($frameworkcode) = @_;
- my $dbh = C4::Context->dbh;
- my $sth =
- $dbh->prepare("select * from biblio_framework where frameworkcode=?");
- $sth->execute($frameworkcode);
- my $res = $sth->fetchrow_hashref;
- return $res;
-}
-
-=head2 getitemtypeinfo
-
- $itemtype = &getitemtypeinfo($itemtype, [$interface]);
-
-Returns information about an itemtype. The optional $interface argument
-sets which interface ('opac' or 'intranet') to return the imageurl for.
-Defaults to intranet.
-
-=cut
-
-sub getitemtypeinfo {
- my ($itemtype, $interface) = @_;
- my $dbh = C4::Context->dbh;
- require C4::Languages;
- my $language = C4::Languages::getlanguage();
- my $it = $dbh->selectrow_hashref(q|
- SELECT
- itemtypes.itemtype,
- itemtypes.description,
- itemtypes.rentalcharge,
- itemtypes.notforloan,
- itemtypes.imageurl,
- itemtypes.summary,
- itemtypes.checkinmsg,
- itemtypes.checkinmsgtype,
- itemtypes.sip_media_type,
- COALESCE( localization.translation, itemtypes.description ) AS translated_description
- FROM itemtypes
- LEFT JOIN localization ON itemtypes.itemtype = localization.code
- AND localization.entity = 'itemtypes'
- AND localization.lang = ?
- WHERE itemtypes.itemtype = ?
- |, undef, $language, $itemtype );
-
- $it->{imageurl} = getitemtypeimagelocation( ( ( defined $interface && $interface eq 'opac' ) ? 'opac' : 'intranet' ), $it->{imageurl} );
-
- return $it;
-}
-