Remove hardcoded LOC AND CCODE authvals; fix no display of location on staff details page.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Ryan Higgins 2008-04-04 19:05:07 -05:00 committed by Joshua Ferraro
parent 04399ef895
commit 1af6c8be85
3 changed files with 30 additions and 21 deletions

View File

@ -852,26 +852,38 @@ sub GetAuthorisedValues {
=head2 GetKohaAuthorisedValues
Takes $dbh , $kohafield as parameters.
returns hashref of authvalCode => liblibrarian
or undef if no authvals defined for kohafield.
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
Returns undef
if no authorised value category is defined for the kohafield.
or no authorised value is defined for C<$codedvalue> .
=cut
sub GetKohaAuthorisedValues {
my ($kohafield,$fwcode) = @_;
my ($kohafield,$fwcode,$codedvalue) = @_;
$fwcode='' unless $fwcode;
my %values;
my $dbh = C4::Context->dbh;
my $avcode = GetAuthValCode($kohafield,$fwcode);
if ($avcode) {
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;
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;
}
} else {
return undef;
}
}
=head2 GetManagedTagSubfields

View File

@ -62,14 +62,8 @@ my $marcseriesarray = GetMarcSeries($record,$marcflavour);
my $branches = GetBranches();
my $itemtypes = GetItemTypes();
my %locations;
# FIXME: move this to a pm, check waiting status for holds
my $dbh = C4::Context->dbh;
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'};
}
# change back when ive fixed request.pl
my @items = &GetItemsInfo( $biblionumber, 'intra' );
@ -112,14 +106,17 @@ foreach my $item (@items) {
$item->{datedue} = format_date($item->{datedue});
$item->{datelastseen} = format_date($item->{datelastseen});
$item->{onloan} = format_date($item->{onloan});
$item->{locationname} = $locations{$item->{location}};
# item damaged, lost, withdrawn loops
$item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
if ($item->{damaged}) {
$item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
}
#get collection code description, too
$item->{'ccode'} = GetAuthorisedValueDesc('','', $item->{'ccode'} ,'','','ccode');
#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);
# checking for holds
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($item->{itemnumber});

View File

@ -158,7 +158,7 @@ function verify_images() {
<!-- TMPL_LOOP NAME="itemloop" -->
<tr>
<!-- TMPL_IF NAME="item-level_itypes" --><td><!-- TMPL_IF NAME="noItemTypeImages" --><!-- TMPL_VAR NAME="description" --><!-- TMPL_ELSE --><img src="<!-- TMPL_VAR NAME="imageurl" -->" alt="<!-- TMPL_VAR NAME="description" -->" title="<!-- TMPL_VAR NAME="description" -->"><!-- /TMPL_IF --></td><!-- /TMPL_IF -->
<td><!-- TMPL_VAR NAME="branchname" --></td>
<td><!-- TMPL_UNLESS NAME="singlebranchmode" --><!-- TMPL_VAR NAME="branchname" --><!-- /TMPL_UNLESS --> <!-- TMPL_VAR NAME="location" --> </td>
<td><!-- TMPL_VAR name="ccode" --></td>
<td><!-- TMPL_IF NAME="itemcallnumber" --> <!-- TMPL_VAR NAME="itemcallnumber" --><!-- /TMPL_IF --></td>
<td>