Displaying Sort Authorised values if linked to authorisedvalue list.
[koha_fer] / C4 / Members.pm
index bcb0f00..96b47fe 100644 (file)
@@ -19,7 +19,6 @@ package C4::Members;
 
 
 use strict;
-require Exporter;
 use C4::Context;
 use C4::Dates qw(format_date_in_iso);
 use Digest::MD5 qw(md5_base64);
@@ -32,8 +31,76 @@ use C4::Accounts;
 our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
 
 BEGIN {
-    $VERSION = 3.02;
-    $debug = $ENV{DEBUG} || 0;
+       $VERSION = 3.02;
+       $debug = $ENV{DEBUG} || 0;
+       require Exporter;
+       @ISA = qw(Exporter);
+       #Get data
+       push @EXPORT, qw(
+               &SearchMember 
+               &GetMemberDetails
+               &GetMember
+
+               &GetGuarantees 
+
+               &GetMemberIssuesAndFines
+               &GetPendingIssues
+               &GetAllIssues
+
+               &get_institutions 
+               &getzipnamecity 
+               &getidcity
+
+               &GetAge 
+               &GetCities 
+               &GetRoadTypes 
+               &GetRoadTypeDetails 
+               &GetSortDetails
+               &GetTitles
+                &GetPatronImage
+
+               &GetMemberAccountRecords
+               &GetBorNotifyAcctRecord
+
+               &GetborCatFromCatType 
+               &GetBorrowercategory
+
+               &GetBorrowersWhoHaveNotBorrowedSince
+               &GetBorrowersWhoHaveNeverBorrowed
+               &GetBorrowersWithIssuesHistoryOlderThan
+
+               &GetExpiryDate
+       );
+
+       #Modify data
+       push @EXPORT, qw(
+               &ModMember
+               &changepassword
+       );
+
+       #Delete data
+       push @EXPORT, qw(
+               &DelMember
+       );
+
+       #Insert data
+       push @EXPORT, qw(
+               &AddMember
+               &add_member_orgs
+               &MoveMemberToDeleted
+               &ExtendMemberSubscriptionTo 
+       );
+
+       #Check data
+       push @EXPORT, qw(
+               &checkuniquemember 
+               &checkuserpassword
+               &Check_Userid
+               &fixEthnicity
+               &ethnicitycategories 
+               &fixup_cardnumber
+               &checkcardnumber
+       );
 }
 
 =head1 NAME
@@ -52,77 +119,6 @@ This module contains routines for adding, modifying and deleting members/patrons
 
 =over 2
 
-=cut
-
-@ISA = qw(Exporter);
-
-#Get data
-push @EXPORT, qw(
-  &SearchMember 
-  &GetMemberDetails
-  &GetMember
-  
-  &GetGuarantees 
-  
-  &GetMemberIssuesAndFines
-  &GetPendingIssues
-  &GetAllIssues
-  
-  &get_institutions 
-  &getzipnamecity 
-  &getidcity
-   
-  &GetAge 
-  &GetCities 
-  &GetRoadTypes 
-  &GetRoadTypeDetails 
-  &GetSortDetails
-  &GetTitles    
-  
-  &GetMemberAccountRecords
-  &GetBorNotifyAcctRecord
-  
-  &GetborCatFromCatType 
-  &GetBorrowercategory
-  
-  
-  &GetBorrowersWhoHaveNotBorrowedSince
-  &GetBorrowersWhoHaveNeverBorrowed
-  &GetBorrowersWithIssuesHistoryOlderThan
-  
-  &GetExpiryDate
-);
-
-#Modify data
-push @EXPORT, qw(
-  &ModMember
-  &changepassword
-);
-  
-#Delete data
-push @EXPORT, qw(
-  &DelMember
-);
-
-#Insert data
-push @EXPORT, qw(
-  &AddMember
-  &add_member_orgs
-  &MoveMemberToDeleted
-  &ExtendMemberSubscriptionTo 
-);
-
-#Check data
-push @EXPORT, qw(
-  &checkuniquemember 
-  &checkuserpassword
-    &Check_Userid
-  &fixEthnicity
-  &ethnicitycategories 
-  &fixup_cardnumber
-    &checkcardnumber
-);
-
 =item SearchMember
 
   ($count, $borrowers) = &SearchMember($searchstring, $type,$category_type,$filter,$showallbranches);
@@ -524,7 +520,7 @@ LEFT JOIN categories on borrowers.categorycode=categories.categorycode
         $sth->execute($information);
         $data = $sth->fetchrow_hashref;
         $sth->finish;
-        return ($data);
+        ($data) and return ($data);
     }
     return undef;        
 }
@@ -551,7 +547,7 @@ sub GetMemberIssuesAndFines {
       "Select count(*) from issues where borrowernumber='$borrowernumber' and
     returndate is NULL";
 
-    $debug and print $query, "\n";
+    $debug and warn $query."\n";
     my $sth = $dbh->prepare($query);
     $sth->execute;
     my $data = $sth->fetchrow_hashref;
@@ -1537,7 +1533,8 @@ sub GetSortDetails {
     my $sth = $dbh->prepare($query);
     $sth->execute( $category, $sortvalue );
     my $lib = $sth->fetchrow;
-    return ($lib);
+    return ($lib) if ($lib);
+    return ($sortvalue) unless ($lib);
 }
 
 =head2 DeleteBorrower 
@@ -1700,7 +1697,26 @@ sub GetTitles {
     }
 }
 
+=head2 GetPatronImage
+
+    $patronimage = &GetPatronImage('cardnumber');
+
+Returns the path/filename.jpg of the image for the patron with the supplied cardnumber.
+
+=cut
 
+sub GetPatronImage {
+    my $cardnumber = shift;
+    warn "Cardnumber passed to GetPatronImage is $cardnumber" if $debug;
+    my $htdocs = C4::Context->config('intrahtdocs');
+    my $picture = "patronimages/" . $cardnumber . ".jpg";
+    if ( -e "$htdocs/$picture" ) {
+           return ( "/intranet-tmpl/$picture" );   # FIXME: This is a real hack and should be handled better, but I'm in a hurry... -fbcit
+    }
+    else {
+        return ();
+    }
+}
 
 =head2 GetRoadTypeDetails (OUEST-PROVENCE)