=head2 GetKohaAuthorisedValues
- Takes $kohafield, $fwcode, $value as parameters.
- If C<$codedvalue> is supplied, returns scalar authorised value description.
- If C<$codedvalue> is undefined, returns hashref of Code => description
+ Takes $kohafield, $fwcode as parameters.
+ Returns hashref of Code => description
Returns undef
if no authorised value category is defined for the kohafield.
- or no authorised value is defined for C<$codedvalue> .
=cut
my $dbh = C4::Context->dbh;
my $avcode = GetAuthValCode($kohafield,$fwcode);
if ($avcode) {
- if($codedvalue || ($codedvalue==0)) {
- my $sth = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=? ");
- $sth->execute($avcode,$codedvalue);
- my ($avdesc) = $sth->fetchrow_array;
- return $avdesc;
- } else {
- my $sth = $dbh->prepare("select authorised_value, lib from authorised_values where category=? ");
- $sth->execute($avcode);
- while ( my ($val, $lib) = $sth->fetchrow_array ) {
- $values{$val}= $lib;
- }
- return \%values;
- }
+ my $sth = $dbh->prepare("select authorised_value, lib from authorised_values where category=? ");
+ $sth->execute($avcode);
+ while ( my ($val, $lib) = $sth->fetchrow_array ) {
+ $values{$val}= $lib;
+ }
+ return \%values;
} else {
return undef;
-}
+ }
}
=head2 GetManagedTagSubfields
while ( my $bdata = $bsth->fetchrow_hashref ) {
$branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'};
}
- my %locations;
- my $lsch =
- $dbh->prepare(
-"SELECT authorised_value,lib FROM authorised_values WHERE category = 'LOC'"
- );
- $lsch->execute();
- while ( my $ldata = $lsch->fetchrow_hashref ) {
- $locations{ $ldata->{'authorised_value'} } = $ldata->{'lib'};
- }
+# FIXME - We build an authorised values hash here, using the default framework
+# though it is possible to have different authvals for different fws.
+
+ my $shelflocations =GetKohaAuthorisedValues('items.location','');
+
+ # get notforloan authorised value list (see $shelflocations FIXME)
+ my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
#Build itemtype hash
#find itemtype & itemtype image
$sth->execute;
my ($itemtag) = $sth->fetchrow;
- # get notforloan authorised value list
- $sth =
- $dbh->prepare(
-"SELECT authorised_value FROM `marc_subfield_structure` WHERE kohafield = 'items.notforloan' AND frameworkcode=''"
- );
- $sth->execute;
- my ($notforloan_authorised_value) = $sth->fetchrow;
-
## find column names of items related to MARC
my $sth2 = $dbh->prepare("SHOW COLUMNS FROM items");
$sth2->execute;
$onloan_items->{$key}->{due_date} = format_date($item->{onloan});
$onloan_items->{$key}->{count}++ if $item->{homebranch};
$onloan_items->{$key}->{branchname} = $item->{branchname};
- $onloan_items->{$key}->{location} = $locations{ $item->{location} };
+ $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
$onloan_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
# if something's checked out and lost, mark it as 'long overdue'
}
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
$other_items->{$key}->{count}++ if $item->{homebranch};
- $other_items->{$key}->{location} = $locations{ $item->{location} };
+ $other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
$other_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
}
# item is available
foreach (qw(branchname itemcallnumber)) {
$available_items->{$prefix}->{$_} = $item->{$_};
}
- $available_items->{$prefix}->{location} = $locations{ $item->{location} };
+ $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
$available_items->{$prefix}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
}
}
$item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
}
#get shelf location and collection code description if they are authorised value.
- my $itemlocation = GetKohaAuthorisedValues('items.location',$fw, $item->{location} );
- $item->{location} = $itemlocation if($itemlocation);
- my $itemccode = $item->{ccode} ;
- $itemccode = GetKohaAuthorisedValues('items.ccode',$fw, $itemccode );
- $item->{'ccode'} = $itemccode if($itemccode);
+ my $shelflocations = GetKohaAuthorisedValues('items.location',$fw );
+ $item->{'location'} = $shelflocations->{$item->{'location'}} if($shelflocations->{$item->{'location'}});
+ my $collections = GetKohaAuthorisedValues('items.ccode',$fw );
+ $item->{'ccode'} = $collections->{$item->{'ccode'}} if($collections->{$item->{'ccode'}});
# checking for holds
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($item->{itemnumber});