From 1af6c8be85509cfb40ec3969fe9bafbfc89e7b7b Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Fri, 4 Apr 2008 19:05:07 -0500 Subject: [PATCH] Remove hardcoded LOC AND CCODE authvals; fix no display of location on staff details page. Signed-off-by: Joshua Ferraro --- C4/Koha.pm | 34 +++++++++++++------ catalogue/detail.pl | 15 ++++---- .../prog/en/modules/catalogue/detail.tmpl | 2 +- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index f653271dc7..1f3aa79296 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -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 diff --git a/catalogue/detail.pl b/catalogue/detail.pl index bc251a3908..53d8303850 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -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}); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl index 32d98a43de..5fd3c91e93 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl @@ -158,7 +158,7 @@ function verify_images() { " alt="" title=""> - + -- 2.39.5