X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=inline;f=C4%2FKoha.pm;h=a15080998a1b9ca1d7459b909d657ffe6f8066e4;hb=9f5a1bc7ebbe3954607da88b87bab6e9c2689dad;hp=48c55328b244d2e368cf0e51659dab0382988acf;hpb=bad06abf77bdb78fa3089b7a9b37eb69dd68245c;p=koha.git diff --git a/C4/Koha.pm b/C4/Koha.pm index 48c55328b2..a15080998a 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -40,21 +40,15 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw( - &GetPrinters &GetPrinter - &GetItemTypes &getitemtypeinfo - &GetItemTypesCategorized &GetItemTypesByCategory - &getframeworks &getframeworkinfo - &GetFrameworksLoop - &getallthemes - &getFacets - &getnbpages - &get_infos_of - &get_notforloan_label_of + &GetPrinters &GetPrinter + &GetItemTypesCategorized + &getallthemes + &getFacets + &getnbpages &getitemtypeimagedir &getitemtypeimagesrc &getitemtypeimagelocation &GetAuthorisedValues - &GetAuthorisedValueCategories &GetNormalizedUPC &GetNormalizedISBN &GetNormalizedEAN @@ -90,90 +84,6 @@ Koha.pm provides many functions for Koha scripts. =cut -=head2 GetItemTypes - - $itemtypes = &GetItemTypes( style => $style ); - -Returns information about existing itemtypes. - -Params: - style: either 'array' or 'hash', defaults to 'hash'. - 'array' returns an arrayref, - 'hash' return a hashref with the itemtype value as the key - -build a HTML select with the following code : - -=head3 in PERL SCRIPT - - my $itemtypes = GetItemTypes; - my @itemtypesloop; - foreach my $thisitemtype (sort keys %$itemtypes) { - my $selected = 1 if $thisitemtype eq $itemtype; - my %row =(value => $thisitemtype, - selected => $selected, - description => $itemtypes->{$thisitemtype}->{'description'}, - ); - push @itemtypesloop, \%row; - } - $template->param(itemtypeloop => \@itemtypesloop); - -=head3 in TEMPLATE - -
- -=cut - -sub GetItemTypes { - my ( %params ) = @_; - my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash'; - - require C4::Languages; - my $language = C4::Languages::getlanguage(); - # returns a reference to a hash of references to itemtypes... - my $dbh = C4::Context->dbh; - my $query = q| - SELECT - itemtypes.itemtype, - itemtypes.description, - itemtypes.rentalcharge, - itemtypes.notforloan, - itemtypes.imageurl, - itemtypes.summary, - itemtypes.checkinmsg, - itemtypes.checkinmsgtype, - itemtypes.sip_media_type, - itemtypes.hideinopac, - itemtypes.searchcategory, - 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 = ? - ORDER BY itemtype - |; - my $sth = $dbh->prepare($query); - $sth->execute( $language ); - - if ( $style eq 'hash' ) { - my %itemtypes; - while ( my $IT = $sth->fetchrow_hashref ) { - $itemtypes{ $IT->{'itemtype'} } = $IT; - } - return ( \%itemtypes ); - } else { - return [ sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @{ $sth->fetchall_arrayref( {} ) } ]; - } -} - =head2 GetItemTypesCategorized $categories = GetItemTypesCategorized(); @@ -210,185 +120,6 @@ sub GetItemTypesCategorized { return ($dbh->selectall_hashref($query,'itemtype')); } -=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 - - - -=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() - - - -=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; -} - =head2 getitemtypeimagedir my $directory = getitemtypeimagedir( 'opac' ); @@ -664,6 +395,11 @@ sub getFacets { idx => 'location', label => 'Location', tags => [ qw/ 995e / ], + }, + { + idx => 'ccode', + label => 'CollectionCodes', + tags => [ qw / 099t 955h / ], } ]; @@ -746,6 +482,11 @@ sub getFacets { label => 'Location', tags => [ qw / 952c / ], }, + { + idx => 'ccode', + label => 'CollectionCodes', + tags => [ qw / 9528 / ], + } ]; unless ( Koha::Libraries->search->count == 1 ) @@ -781,106 +522,6 @@ sub getFacets { return $facets; } -=head2 get_infos_of - -Return a href where a key is associated to a href. You give a query, -the name of the key among the fields returned by the query. If you -also give as third argument the name of the value, the function -returns a href of scalar. The optional 4th argument is an arrayref of -items passed to the C