Bug 8414 - Intranet header toplinks display white rather than blue in < IE8
[koha.git] / C4 / ILSDI / Services.pm
index ba0c429..4eed936 100644 (file)
@@ -33,6 +33,7 @@ use C4::ILSDI::Utility;
 use XML::Simple;
 use HTML::Entities;
 use CGI;
+use DateTime;
 
 =head1 NAME
 
@@ -193,15 +194,12 @@ sub GetRecords {
         # Get the biblioitem from the biblionumber
         my $biblioitem = ( GetBiblioItemByBiblioNumber( $biblionumber, undef ) )[0];
         if ( not $biblioitem->{'biblionumber'} ) {
-            $biblioitem = "RecordNotFound";
+            $biblioitem->{code} = "RecordNotFound";
         }
 
         # We don't want MARC to be displayed
         delete $biblioitem->{'marc'};
 
-        # nor the XML declaration of MARCXML
-        $biblioitem->{'marcxml'} =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go;
-
         # Get most of the needed data
         my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
         my @reserves         = GetReservesFromBiblionumber( $biblionumber, undef, undef );
@@ -224,8 +222,6 @@ sub GetRecords {
         $biblioitem->{'reserves'}->{'reserve'} = $reserves[1];
         $biblioitem->{'issues'}->{'issue'}     = $issues;
 
-        map { $biblioitem->{$_} = encode_entities( $biblioitem->{$_}, '&' ) } grep( !/marcxml/, keys %$biblioitem );
-        
         push @records, $biblioitem;
     }
 
@@ -256,18 +252,16 @@ sub GetAuthorityRecords {
         return { code => 'UnsupportedSchema' };
     }
 
-    my $records;
+    my @records;
 
     # Let's loop over the authority IDs
     foreach my $authid ( split( / /, $cgi->param('id') ) ) {
 
         # Get the record as XML string, or error code
-        my $record = GetAuthorityXML($authid) || "<record><code>RecordNotFound</code></record>";
-        $record =~ s/<\?xml(.*)\?>//go;
-        $records .= $record;
+        push @records, GetAuthorityXML($authid) || { code => 'RecordNotFound' };
     }
 
-    return $records;
+    return { record => \@records };
 }
 
 =head2 LookupPatron
@@ -322,7 +316,7 @@ sub AuthenticatePatron {
     my ($cgi) = @_;
 
     # Check if borrower exists, using a C4::Auth function...
-    unless( checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') ) ) {
+    unless( C4::Auth::checkpw( C4::Context->dbh, $cgi->param('username'), $cgi->param('password') ) ) {
         return { code => 'PatronNotFound' };
     }
 
@@ -565,7 +559,7 @@ sub RenewLoan {
     # Hashref building
     my $out;
     $out->{'renewals'} = $issue->{'renewals'};
-    $out->{'date_due'} = $issue->{'date_due'};
+    $out->{date_due}   = $issue->{date_due}->strftime('%Y-%m-%d %H:%S');
     $out->{'success'}  = $renewal[0];
     $out->{'error'}    = $renewal[1];
 
@@ -682,8 +676,8 @@ sub HoldItem {
     return { code => 'RecordNotFound' } if $$item{biblionumber} ne $$biblio{biblionumber};
 
     # Check for item disponibility
-    my $canitembereserved = CanItemBeReserved( $borrowernumber, $itemnumber );
-    my $canbookbereserved = CanBookBeReserved( $borrowernumber, $biblionumber );
+    my $canitembereserved = C4::Reserves::CanItemBeReserved( $borrowernumber, $itemnumber );
+    my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber );
     return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
 
     my $branch;
@@ -707,8 +701,8 @@ sub HoldItem {
     }
 
     # Add the reserve
-    #          $branch, $borrowernumber, $biblionumber, $constraint, $bibitems,  $priority, $notes, $title, $checkitem,  $found
-    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found );
+    # $branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found
+    AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, '', '', '', $title, $itemnumber, $found );
 
     # Hashref building
     my $out;