Bug 15344: Remove some other calls of GetMemberDetails from pl scripts
[koha.git] / C4 / Members.pm
index 9166b75..fafa02f 100644 (file)
@@ -23,7 +23,6 @@ package C4::Members;
 use strict;
 #use warnings; FIXME - Bug 2505
 use C4::Context;
-use C4::Dates qw(format_date_in_iso format_date);
 use String::Random qw( random_string );
 use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
 use C4::Log; # logaction
@@ -41,7 +40,11 @@ use Koha::Borrower::Debarments qw(IsDebarred);
 use Text::Unaccent qw( unac_string );
 use Koha::AuthUtils qw(hash_password);
 use Koha::Database;
-require Koha::NorwegianPatronDB;
+
+use Module::Load::Conditional qw( can_load );
+if ( ! can_load( modules => { 'Koha::NorwegianPatronDB' => undef } ) ) {
+   warn "Unable to load Koha::NorwegianPatronDB";
+}
 
 our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
 
@@ -239,16 +242,6 @@ sub GetMemberDetails {
     $borrower->{'flags'}     = $flags;
     $borrower->{'authflags'} = $accessflagshash;
 
-    # For the purposes of making templates easier, we'll define a
-    # 'showname' which is the alternate form the user's first name if 
-    # 'other name' is defined.
-    if ($borrower->{category_type} eq 'I') {
-        $borrower->{'showname'} = $borrower->{'othernames'};
-        $borrower->{'showname'} .= " $borrower->{'firstname'}" if $borrower->{'firstname'};
-    } else {
-        $borrower->{'showname'} = $borrower->{'firstname'};
-    }
-
     # Handle setting the true behavior for BlockExpiredPatronOpacActions
     $borrower->{'BlockExpiredPatronOpacActions'} =
       C4::Context->preference('BlockExpiredPatronOpacActions')
@@ -738,12 +731,12 @@ sub AddMember {
 
     # add expiration date if it isn't already there
     unless ( $data{'dateexpiry'} ) {
-        $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, C4::Dates->new()->output("iso") );
+        $data{'dateexpiry'} = GetExpiryDate( $data{'categorycode'}, output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) );
     }
 
     # add enrollment date if it isn't already there
     unless ( $data{'dateenrolled'} ) {
-        $data{'dateenrolled'} = C4::Dates->new()->output("iso");
+        $data{'dateenrolled'} = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
     }
 
     my $patron_category = $schema->resultset('Category')->find( $data{'categorycode'} );
@@ -1170,7 +1163,7 @@ sub GetMemberAccountRecords {
                         SELECT * 
                         FROM accountlines 
                         WHERE borrowernumber=?);
-    $strsth.=" ORDER BY date desc,timestamp DESC";
+    $strsth.=" ORDER BY accountlines_id desc";
     my $sth= $dbh->prepare( $strsth );
     $sth->execute( $borrowernumber );
 
@@ -1862,8 +1855,9 @@ sub ExtendMemberSubscriptionTo {
     my $borrower = GetMember('borrowernumber'=>$borrowerid);
     unless ($date){
       $date = (C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry') ?
-                                        C4::Dates->new($borrower->{'dateexpiry'}, 'iso')->output("iso") :
-                                        C4::Dates->new()->output("iso");
+                                        eval { output_pref( { dt => dt_from_string( $borrower->{'dateexpiry'}  ), dateonly => 1, dateformat => 'iso' } ); }
+                                        :
+                                        output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
       $date = GetExpiryDate( $borrower->{'categorycode'}, $date );
     }
     my $sth = $dbh->do(<<EOF);
@@ -2261,8 +2255,7 @@ sub GetMessages {
     my @results;
 
     while ( my $data = $sth->fetchrow_hashref ) {
-        my $d = C4::Dates->new( $data->{message_date}, 'iso' );
-        $data->{message_date_formatted} = $d->output;
+        $data->{message_date_formatted} = output_pref( { dt => dt_from_string( $data->{message_date} ), dateonly => 1, dateformat => 'iso' } );
         push @results, $data;
     }
     return \@results;