getitemtypes moved in Koha.pm
This commit is contained in:
parent
275542c036
commit
9ac07b38be
2 changed files with 102 additions and 36 deletions
21
C4/Biblio.pm
21
C4/Biblio.pm
|
@ -40,7 +40,7 @@ $VERSION = 0.01;
|
|||
&newitems &modbibitem
|
||||
&modsubtitle &modsubject &modaddauthor &moditem &countitems
|
||||
&delitem &deletebiblioitem &delbiblio
|
||||
&getitemtypes &getbiblio
|
||||
&getbiblio
|
||||
&getbiblioitembybiblionumber
|
||||
&getbiblioitem &getitemsbybiblioitem
|
||||
&skip
|
||||
|
@ -1867,22 +1867,6 @@ sub delbiblio {
|
|||
&MARCdelbiblio($dbh,$bibid,0);
|
||||
}
|
||||
|
||||
sub getitemtypes {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare("select * from itemtypes order by description");
|
||||
my $count = 0;
|
||||
my @results;
|
||||
|
||||
$sth->execute;
|
||||
while (my $data = $sth->fetchrow_hashref) {
|
||||
$results[$count] = $data;
|
||||
$count++;
|
||||
} # while
|
||||
|
||||
$sth->finish;
|
||||
return($count, @results);
|
||||
} # sub getitemtypes
|
||||
|
||||
sub getbiblio {
|
||||
my ($biblionumber) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
@ -2194,6 +2178,9 @@ Paul POULAIN paul.poulain@free.fr
|
|||
|
||||
# $Id$
|
||||
# $Log$
|
||||
# Revision 1.87 2004/05/18 11:54:07 tipaul
|
||||
# getitemtypes moved in Koha.pm
|
||||
#
|
||||
# Revision 1.86 2004/05/03 09:19:22 tipaul
|
||||
# some fixes for mysql prepare & execute
|
||||
#
|
||||
|
|
117
C4/Koha.pm
117
C4/Koha.pm
|
@ -55,15 +55,16 @@ Koha.pm provides many functions for Koha scripts.
|
|||
&borrowercategories
|
||||
ðnicitycategories
|
||||
&subfield_is_koha_internal_p
|
||||
&getbranches &getbranch &CGIbranches
|
||||
&getbranches &getbranch
|
||||
&getprinters &getprinter
|
||||
&getitemtypes &getitemtypeinfo
|
||||
$DEBUG);
|
||||
|
||||
use vars qw();
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
=item slashifyDate
|
||||
=head2 slashifyDate
|
||||
|
||||
$slash_date = &slashifyDate($dash_date);
|
||||
|
||||
|
@ -79,7 +80,7 @@ sub slashifyDate {
|
|||
return("$dateOut[2]/$dateOut[1]/$dateOut[0]")
|
||||
}
|
||||
|
||||
=item fixEthnicity
|
||||
=head2 fixEthnicity
|
||||
|
||||
$ethn_name = &fixEthnicity($ethn_code);
|
||||
|
||||
|
@ -101,7 +102,7 @@ sub fixEthnicity($) {
|
|||
return $data->{'name'};
|
||||
}
|
||||
|
||||
=item borrowercategories
|
||||
=head2 borrowercategories
|
||||
|
||||
($codes_arrayref, $labels_hashref) = &borrowercategories();
|
||||
|
||||
|
@ -127,7 +128,7 @@ sub borrowercategories {
|
|||
return(\@codes,\%labels);
|
||||
}
|
||||
|
||||
=item ethnicitycategories
|
||||
=head2 ethnicitycategories
|
||||
|
||||
($codes_arrayref, $labels_hashref) = ðnicitycategories();
|
||||
|
||||
|
@ -164,23 +165,33 @@ sub subfield_is_koha_internal_p ($) {
|
|||
return length $subfield != 1;
|
||||
}
|
||||
|
||||
=item getbranches
|
||||
=head2 getbranches
|
||||
|
||||
$branches = &getbranches();
|
||||
@branch_codes = keys %$branches;
|
||||
%main_branch_info = %{$branches->{"MAIN"}};
|
||||
returns informations about branches.
|
||||
Create a branch selector with the following code
|
||||
|
||||
Returns information about existing library branches.
|
||||
=head3 in PERL SCRIPT
|
||||
|
||||
C<$branches> is a reference-to-hash. Its keys are the branch codes for
|
||||
all of the existing library branches, and its values are
|
||||
references-to-hash describing that particular branch.
|
||||
my $branches = getbranches;
|
||||
my @branchloop;
|
||||
foreach my $thisbranch (keys %$branches) {
|
||||
my $selected = 1 if $thisbranch eq $branch;
|
||||
my %row =(value => $thisbranch,
|
||||
selected => $selected,
|
||||
branchname => $branches->{$thisbranch}->{'branchname'},
|
||||
);
|
||||
push @branchloop, \%row;
|
||||
}
|
||||
|
||||
In each branch description (C<%main_branch_info>, above), there is a
|
||||
key for each field in the branches table of the Koha database. In
|
||||
addition, there is a key for each branch category code to which the
|
||||
branch belongs (the category codes are taken from the branchrelations
|
||||
table).
|
||||
|
||||
=head3 in TEMPLATE
|
||||
<select name="branch">
|
||||
<option value="">Default</option>
|
||||
<!-- TMPL_LOOP name="branchloop" -->
|
||||
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</select>
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -210,7 +221,75 @@ sub getbranches {
|
|||
return (\%branches);
|
||||
}
|
||||
|
||||
=item getprinters
|
||||
=head2 itemtypes
|
||||
|
||||
$itemtypes = &getitemtypes();
|
||||
|
||||
Returns information about existing itemtypes.
|
||||
|
||||
build a HTML select with the following code :
|
||||
|
||||
=head3 in PERL SCRIPT
|
||||
|
||||
my $itemtypes = getitemtypes;
|
||||
my @itemtypesloop;
|
||||
foreach my $thisitemtype (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
|
||||
|
||||
<form action='<!-- TMPL_VAR name="script_name" -->' method=post>
|
||||
<select name="itemtype">
|
||||
<option value="">Default</option>
|
||||
<!-- TMPL_LOOP name="itemtypeloop" -->
|
||||
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</select>
|
||||
<input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
|
||||
<input type="submit" value="OK" class="button">
|
||||
</form>
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
sub getitemtypes {
|
||||
# returns a reference to a hash of references to branches...
|
||||
my %itemtypes;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from itemtypes");
|
||||
$sth->execute;
|
||||
while (my $IT=$sth->fetchrow_hashref) {
|
||||
$itemtypes{$IT->{'itemtype'}}=$IT;
|
||||
}
|
||||
return (\%itemtypes);
|
||||
}
|
||||
|
||||
|
||||
=head2 itemtypes
|
||||
|
||||
$itemtype = &getitemtype($itemtype);
|
||||
|
||||
Returns information about an itemtype.
|
||||
|
||||
=cut
|
||||
|
||||
sub getitemtypeinfo {
|
||||
my ($itemtype) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select * from itemtypes where itemtype=?");
|
||||
$sth->execute($itemtype);
|
||||
my $res = $sth->fetchrow_hashref;
|
||||
return $res;
|
||||
}
|
||||
|
||||
=head2 getprinters
|
||||
|
||||
$printers = &getprinters($env);
|
||||
@queues = keys %$printers;
|
||||
|
@ -260,6 +339,6 @@ __END__
|
|||
|
||||
=head1 AUTHOR
|
||||
|
||||
Pat Eyler, pate@gnu.org
|
||||
Koha Team
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in a new issue