Fix for Bug 6260 - Missing space in availability information of OPAC XSLT results
[koha.git] / C4 / Members.pm
index 4eb9979..ce694e5 100644 (file)
@@ -802,8 +802,10 @@ Returns as undef upon any db error without further processing
 sub AddMember {
     my (%data) = @_;
     my $dbh = C4::Context->dbh;
-    $data{'userid'} = '' unless $data{'password'};
-    $data{'password'} = md5_base64( $data{'password'} ) if $data{'password'};
+       # generate a proper login if none provided
+       $data{'userid'} = Generate_Userid($data{'borrowernumber'}, $data{'firstname'}, $data{'surname'}) if $data{'userid'} eq '';
+       # create a disabled account if no password provided
+       $data{'password'} = ($data{'password'})? md5_base64($data{'password'}) : '!';
        $data{'borrowernumber'}=InsertInTable("borrowers",\%data);      
     # mysql_insertid is probably bad.  not necessarily accurate and mysql-specific at best.
     logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
@@ -907,7 +909,6 @@ sub fixup_cardnumber ($) {
 
     #     if ($cardnumber !~ /\S/ && $autonumber_members) {
     ($autonumber_members) or return $cardnumber;
-    defined($cardnumber) or return $cardnumber;
     my $checkdigit = C4::Context->preference('checkdigit');
     my $dbh = C4::Context->dbh;
     if ( $checkdigit and $checkdigit eq 'katipo' ) {
@@ -1123,7 +1124,7 @@ sub GetAllIssues {
   LEFT JOIN items on items.itemnumber=old_issues.itemnumber
   LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
   LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
-  WHERE borrowernumber=? 
+  WHERE borrowernumber=? AND old_issues.itemnumber IS NOT NULL
   order by $order";
     if ( $limit != 0 ) {
         $query .= " limit $limit";
@@ -1175,9 +1176,11 @@ sub GetMemberAccountRecords {
     $sth->execute( @bind );
     my $total = 0;
     while ( my $data = $sth->fetchrow_hashref ) {
-               my $biblio = GetBiblioFromItemNumber($data->{itemnumber}) if $data->{itemnumber};
-               $data->{biblionumber} = $biblio->{biblionumber};
-               $data->{title} = $biblio->{title};
+        if ( $data->{itemnumber} ) {
+            my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} );
+            $data->{biblionumber} = $biblio->{biblionumber};
+            $data->{title}        = $biblio->{title};
+        }
         $acctlines[$numlines] = $data;
         $numlines++;
         $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
@@ -1301,10 +1304,10 @@ sub getzipnamecity {
     my $dbh      = C4::Context->dbh;
     my $sth      =
       $dbh->prepare(
-        "select city_name,city_zipcode from cities where cityid=? ");
+        "select city_name,city_state,city_zipcode,city_country from cities where cityid=? ");
     $sth->execute($cityid);
     my @data = $sth->fetchrow;
-    return $data[0], $data[1];
+    return $data[0], $data[1], $data[2], $data[3];
 }
 
 
@@ -1624,13 +1627,15 @@ sub GetCities {
 
     my $dbh   = C4::Context->dbh;
     my $city_arr = $dbh->selectall_arrayref(
-        q|SELECT cityid,city_zipcode,city_name FROM cities ORDER BY city_name|,
+        q|SELECT cityid,city_zipcode,city_name,city_state,city_country FROM cities ORDER BY city_name|,
         { Slice => {} });
     if ( @{$city_arr} ) {
         unshift @{$city_arr}, {
             city_zipcode => q{},
             city_name    => q{},
             cityid       => q{},
+            city_state   => q{},
+            city_country => q{},
         };
     }