Bug 5880 : C4/Koha.pm : adding two functions GetAutorisedValueByCode and GetKohaImage...
authorPaul Poulain <paul.poulain@biblibre.com>
Wed, 16 Mar 2011 10:36:49 +0000 (11:36 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 17 Mar 2011 01:44:38 +0000 (14:44 +1300)
just for convenience

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Koha.pm

index 2bdcc28..2f94aa0 100644 (file)
@@ -57,6 +57,8 @@ BEGIN {
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValueLib
+      &GetAuthorisedValueByCode
+      &GetKohaImageurlFromAuthorisedValues
                &GetAuthValCode
                &GetNormalizedUPC
                &GetNormalizedISBN
@@ -941,6 +943,25 @@ sub displayServers {
     return \@primaryserverloop;
 }
 
+
+=head2 GetKohaImageurlFromAuthorisedValues
+
+$authhorised_value = GetKohaImageurlFromAuthorisedValues( $category, $authvalcode );
+
+Return the first url of the authorised value image represented by $lib.
+
+=cut
+
+sub GetKohaImageurlFromAuthorisedValues {
+    my ( $category, $lib ) = @_;
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare("SELECT imageurl FROM authorised_values WHERE category=? AND lib =?");
+    $sth->execute( $category, $lib );
+     while ( my $data = $sth->fetchrow_hashref ) {
+       return $data->{'imageurl'};
+     }
+}
+
 =head2 GetAuthValCode
 
   $authvalcode = GetAuthValCode($kohafield,$frameworkcode);
@@ -1035,6 +1056,25 @@ sub GetAuthorisedValueCategories {
     return \@results;
 }
 
+=head2 GetAuthorisedValueByCode
+
+$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
+
+Return an hashref of the authorised value represented by $authvalcode.
+
+=cut
+
+sub GetAuthorisedValueByCode {
+       my ( $category, $authvalcode ) = @_;
+       
+    my $dbh = C4::Context->dbh;
+    my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
+    $sth->execute( $category, $authvalcode );
+     while ( my $data = $sth->fetchrow_hashref ) {
+       return $data->{'lib'};
+     }
+}
+
 =head2 GetKohaAuthorisedValues
 
 Takes $kohafield, $fwcode as parameters.