Bug 5549 : Format Date in ILSDI::Services to include hhmm
[koha.git] / C4 / ILSDI / Services.pm
index 9284885..2940c00 100644 (file)
@@ -26,13 +26,14 @@ use C4::Circulation;
 use C4::Branch;
 use C4::Accounts;
 use C4::Biblio;
-use C4::Reserves;
+use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber);
 use C4::Context;
 use C4::AuthoritiesMarc;
 use C4::ILSDI::Utility;
 use XML::Simple;
 use HTML::Entities;
 use CGI;
+use DateTime;
 
 =head1 NAME
 
@@ -40,9 +41,9 @@ C4::ILS-DI::Services - ILS-DI Services
 
 =head1 DESCRIPTION
 
-       Each function in this module represents an ILS-DI service.
-       They all takes a CGI instance as argument and most of them return a 
-       hashref that will be printed by XML::Simple in opac/ilsdi.pl
+Each function in this module represents an ILS-DI service.
+They all takes a CGI instance as argument and most of them return a 
+hashref that will be printed by XML::Simple in opac/ilsdi.pl
 
 =head1 SYNOPSIS
 
@@ -65,28 +66,39 @@ C4::ILS-DI::Services - ILS-DI Services
 
 =cut
 
+=head1 FUNCTIONS
+
 =head2 GetAvailability
-    
-       Given a set of biblionumbers or itemnumbers, returns a list with 
-       availability of the items associated with the identifiers.
-       
-       Parameters :
-
-       - id (Required)
-               list of either biblionumbers or itemnumbers
-       - id_type (Required)
-               defines the type of record identifier being used in the request, 
-               possible values:
-                       - bib
-                       - item
-       - return_type (Optional)
-               requests a particular level of detail in reporting availability, 
-               possible values:
-                       - bib
-                       - item
-       - return_fmt (Optional)
-               requests a particular format or set of formats in reporting 
-               availability 
+
+Given a set of biblionumbers or itemnumbers, returns a list with 
+availability of the items associated with the identifiers.
+
+Parameters:
+
+=head3 id (Required)
+
+list of either biblionumbers or itemnumbers
+
+=head3 id_type (Required)
+
+defines the type of record identifier being used in the request, 
+possible values:
+
+  - bib
+  - item
+
+=head3 return_type (Optional)
+
+requests a particular level of detail in reporting availability, 
+possible values:
+
+  - bib
+  - item
+
+=head3 return_fmt (Optional)
+
+requests a particular format or set of formats in reporting 
+availability 
 
 =cut
 
@@ -143,25 +155,26 @@ sub GetAvailability {
 }
 
 =head2 GetRecords
-    
-       Given a list of biblionumbers, returns a list of record objects that 
-       contain bibliographic information, as well as associated holdings and item
-       information. The caller may request a specific metadata schema for the 
-       record objects to be returned.
-       This function behaves similarly to HarvestBibliographicRecords and 
-       HarvestExpandedRecords in Data Aggregation, but allows quick, real time 
-       lookup by bibliographic identifier.
-
-       You can use OAI-PMH ListRecords instead of this service.
-       
-       Parameters:
-
-       - id (Required)
-               list of system record identifiers
-       - id_type (Optional)
-               Defines the metadata schema in which the records are returned, 
-               possible values:
-                       - MARCXML
+
+Given a list of biblionumbers, returns a list of record objects that 
+contain bibliographic information, as well as associated holdings and item
+information. The caller may request a specific metadata schema for the 
+record objects to be returned.
+
+This function behaves similarly to HarvestBibliographicRecords and 
+HarvestExpandedRecords in Data Aggregation, but allows quick, real time 
+lookup by bibliographic identifier.
+
+You can use OAI-PMH ListRecords instead of this service.
+
+Parameters:
+
+  - id (Required)
+       list of system record identifiers
+  - id_type (Optional)
+       Defines the metadata schema in which the records are returned, 
+       possible values:
+         - MARCXML
 
 =cut
 
@@ -181,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 );
@@ -212,37 +222,25 @@ sub GetRecords {
         $biblioitem->{'reserves'}->{'reserve'} = $reserves[1];
         $biblioitem->{'issues'}->{'issue'}     = $issues;
 
-        map { $biblioitem->{$_} = encode_entities( $biblioitem->{$_}, '&' ) } grep( !/marcxml/, keys %$biblioitem );
-
-<<<<<<< HEAD:C4/ILSDI/Services.pm
         push @records, $biblioitem;
-=======
-            $_ = encode_entities( $$biblioitem{$_}, '&' ) for @$biblioitem{ grep {!/marcxml/} keys %$biblioitem };
-            
-            push @records, $biblioitem;
-            
-        } else {
-            push @records, { code => 'RecordNotFound' };
-        }
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
     }
 
     return { record => \@records };
 }
 
 =head2 GetAuthorityRecords
-    
-       Given a list of authority record identifiers, returns a list of record 
-       objects that contain the authority records. The function user may request 
-       a specific metadata schema for the record objects.
 
-       Parameters:
+Given a list of authority record identifiers, returns a list of record 
+objects that contain the authority records. The function user may request 
+a specific metadata schema for the record objects.
+
+Parameters:
 
-       - id (Required)
-           list of authority record identifiers
-       - schema (Optional)
-           specifies the metadata schema of records to be returned, possible values:
-                 - MARCXML
+  - id (Required)
+    list of authority record identifiers
+  - schema (Optional)
+    specifies the metadata schema of records to be returned, possible values:
+      - MARCXML
 
 =cut
 
@@ -254,38 +252,32 @@ 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
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-        my $record = GetAuthorityXML($authid) || "<record>RecordNotFound</record>";
-=======
-        my $record = GetAuthorityXML( $_ ) || "<record><code>RecordNotFound</code></record>";
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
-        $record =~ s/<\?xml(.*)\?>//go;
-        $records .= $record;
+        push @records, GetAuthorityXML($authid) || { code => 'RecordNotFound' };
     }
 
-    return $records;
+    return { record => \@records };
 }
 
 =head2 LookupPatron
-    
-       Looks up a patron in the ILS by an identifier, and returns the borrowernumber.
-       
-       Parameters:
-
-       - id (Required)
-               an identifier used to look up the patron in Koha
-       - id_type (Optional)
-               the type of the identifier, possible values:
-                       - cardnumber
-                       - firstname
-                       - userid
-                       - borrowernumber
+
+Looks up a patron in the ILS by an identifier, and returns the borrowernumber.
+
+Parameters:
+
+  - id (Required)
+       an identifier used to look up the patron in Koha
+  - id_type (Optional)
+       the type of the identifier, possible values:
+       - cardnumber
+       - firstname
+       - userid
+       - borrowernumber
 
 =cut
 
@@ -293,7 +285,6 @@ sub LookupPatron {
     my ($cgi) = @_;
 
     # Get the borrower...
-<<<<<<< HEAD:C4/ILSDI/Services.pm
     my $borrower = GetMember($cgi->param('id_type') => $cgi->param('id'));
     if ( not $borrower->{'borrowernumber'} ) {
         return { message => 'PatronNotFound' };
@@ -301,10 +292,7 @@ sub LookupPatron {
 
     # Build the hashref
     my $patron->{'id'} = $borrower->{'borrowernumber'};
-=======
-    my $borrower = GetMember( $cgi->param('id'), $cgi->param('id_type') );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # ...and return his ID
     return $patron;
@@ -312,30 +300,24 @@ sub LookupPatron {
 
 =head2 AuthenticatePatron
 
-       Authenticates a user's login credentials and returns the identifier for 
-       the patron.
-       
-       Parameters:
+Authenticates a user's login credentials and returns the identifier for 
+the patron.
+
+Parameters:
+
+  - username (Required)
+       user's login identifier
+  - password (Required)
+       user's password
 
-       - username (Required)
-               user's login identifier
-       - password (Required)
-               user's password
-               
 =cut
 
 sub AuthenticatePatron {
     my ($cgi) = @_;
 
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    # Check if borrower exists, using a C4::ILSDI::Utility function...
-    if ( not( BorrowerExists( $cgi->param('username'), $cgi->param('password') ) ) ) {
-        return { message => 'PatronNotFound' };
-=======
     # 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' };
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
     }
 
     # Get the borrower
@@ -350,23 +332,23 @@ sub AuthenticatePatron {
 
 =head2 GetPatronInfo
 
-       Returns specified information about the patron, based on options in the 
-       request. This function can optionally return patron's contact information, 
-       fine information, hold request information, and loan information.
-       
-       Parameters:
-
-       - patron_id (Required)
-               the borrowernumber
-       - show_contact (Optional, default 1)
-               whether or not to return patron's contact information in the response
-       - show_fines (Optional, default 0)
-               whether or not to return fine information in the response
-       - show_holds (Optional, default 0)
-               whether or not to return hold request information in the response
-       - show_loans (Optional, default 0)
-               whether or not to return loan information request information in the response 
-               
+Returns specified information about the patron, based on options in the 
+request. This function can optionally return patron's contact information, 
+fine information, hold request information, and loan information.
+
+Parameters:
+
+  - patron_id (Required)
+       the borrowernumber
+  - show_contact (Optional, default 1)
+       whether or not to return patron's contact information in the response
+  - show_fines (Optional, default 0)
+       whether or not to return fine information in the response
+  - show_holds (Optional, default 0)
+       whether or not to return hold request information in the response
+  - show_loans (Optional, default 0)
+       whether or not to return loan information request information in the response 
+
 =cut
 
 sub GetPatronInfo {
@@ -374,15 +356,8 @@ sub GetPatronInfo {
 
     # Get Member details
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # Cleaning the borrower hashref
     $borrower->{'charges'}    = $borrower->{'flags'}->{'CHARGES'}->{'amount'};
@@ -452,12 +427,12 @@ sub GetPatronInfo {
 
 =head2 GetPatronStatus
 
-       Returns a patron's status information.
-       
-       Parameters:
+Returns a patron's status information.
+
+Parameters:
 
-       - patron_id (Required)
-               the borrower ID
+  - patron_id (Required)
+       the borrower ID
 
 =cut
 
@@ -466,20 +441,6 @@ sub GetPatronStatus {
 
     # Get Member details
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-
-    # Hashref building
-    my $patron;
-    $patron->{'type'}   = $borrower->{'categorycode'};
-    $patron->{'status'} = 0;                             #TODO
-    $patron->{'expiry'} = $borrower->{'dateexpiry'};
-
-    return $patron;
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
 
@@ -489,20 +450,19 @@ sub GetPatronStatus {
         status => 0, # TODO
         expiry => $$borrower{dateexpiry},
     };
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 }
 
 =head2 GetServices
 
-       Returns information about the services available on a particular item for 
-       a particular patron.
-       
-       Parameters:
+Returns information about the services available on a particular item for 
+a particular patron.
+
+Parameters:
 
-       - patron_id (Required)
-               a borrowernumber
-       - item_id (Required)
-               an itemnumber
+  - patron_id (Required)
+       a borrowernumber
+  - item_id (Required)
+       an itemnumber
 =cut
 
 sub GetServices {
@@ -510,19 +470,6 @@ sub GetServices {
 
     # Get the member, or return an error code if not found
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-
-    # Get the item, or return an error code if not found
-    my $itemnumber = $cgi->param('item_id');
-    my $item = GetItem( $itemnumber, undef, undef );
-    if ( not $item->{'itemnumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
 
@@ -530,7 +477,6 @@ sub GetServices {
     my $itemnumber = $cgi->param('item_id');
     my $item = GetItem( $itemnumber );
     return { code => 'RecordNotFound' } unless $$item{itemnumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     my @availablefor;
 
@@ -578,16 +524,16 @@ sub GetServices {
 
 =head2 RenewLoan
 
-       Extends the due date for a borrower's existing issue.
-       
-       Parameters:
+Extends the due date for a borrower's existing issue.
+
+Parameters:
 
-       - patron_id (Required)
-               a borrowernumber
-       - item_id (Required)
-               an itemnumber
-       - desired_due_date (Required)
-               the date the patron would like the item returned by 
+  - patron_id (Required)
+       a borrowernumber
+  - item_id (Required)
+       an itemnumber
+  - desired_due_date (Required)
+       the date the patron would like the item returned by 
 
 =cut
 
@@ -596,27 +542,13 @@ sub RenewLoan {
 
     # Get borrower infos or return an error code
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # Get the item, or return an error code
     my $itemnumber = $cgi->param('item_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $item = GetItem( $itemnumber, undef, undef );
-    if ( not $item->{'itemnumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-=======
     my $item = GetItem( $itemnumber );
     return { code => 'RecordNotFound' } unless $$item{itemnumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # Add renewal if possible
     my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
@@ -627,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];
 
@@ -636,22 +568,22 @@ sub RenewLoan {
 
 =head2 HoldTitle
 
-       Creates, for a borrower, a biblio-level hold reserve.
-       
-       Parameters:
-
-       - patron_id (Required)
-               a borrowernumber
-       - bib_id (Required)
-               a biblionumber
-       - request_location (Required)
-               IP address where the end user request is being placed
-       - pickup_location (Optional)
-               a branch code indicating the location to which to deliver the item for pickup
-       - needed_before_date (Optional)
-               date after which hold request is no longer needed
-       - pickup_expiry_date (Optional)
-               date after which item returned to shelf if item is not picked up 
+Creates, for a borrower, a biblio-level hold reserve.
+
+Parameters:
+
+  - patron_id (Required)
+       a borrowernumber
+  - bib_id (Required)
+       a biblionumber
+  - request_location (Required)
+       IP address where the end user request is being placed
+  - pickup_location (Optional)
+       a branch code indicating the location to which to deliver the item for pickup
+  - needed_before_date (Optional)
+       date after which hold request is no longer needed
+  - pickup_expiry_date (Optional)
+       date after which item returned to shelf if item is not picked up 
 
 =cut
 
@@ -660,26 +592,6 @@ sub HoldTitle {
 
     # Get the borrower or return an error code
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-
-    # Get the biblio record, or return an error code
-    my $biblionumber = $cgi->param('bib_id');
-    my ( $count, $biblio ) = GetBiblio($biblionumber);
-    if ( not $biblio->{'biblionumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-    my $title = $biblio->{'title'};
-
-    # Check if the biblio can be reserved
-    my $canbereserved = CanBookBeReserved( $borrower, $biblionumber );
-    if ( not $canbereserved ) {
-        return { message => 'NotHoldable' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
 
@@ -692,26 +604,16 @@ sub HoldTitle {
 
     # Check if the biblio can be reserved
     return { code => 'NotHoldable' } unless CanBookBeReserved( $borrowernumber, $biblionumber );
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     my $branch;
 
     # Pickup branch management
     if ( $cgi->param('pickup_location') ) {
         $branch = $cgi->param('pickup_location');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-        my $branches = GetBranches();
-        if ( not $branches->{$branch} ) {
-            return { message => 'LocationNotFound' };
-        }
-    } else {    # if user provide no branch, use his own
-        $branch = $borrower->{'branchcode'};
-=======
         my $branches = GetBranches;
         return { code => 'LocationNotFound' } unless $$branches{$branch};
     } else { # if the request provide no branch, use the borrower's branch
         $branch = $$borrower{branchcode};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
     }
 
     # Add the reserve
@@ -730,23 +632,23 @@ sub HoldTitle {
 
 =head2 HoldItem
 
-       Creates, for a borrower, an item-level hold request on a specific item of 
-       a bibliographic record in Koha.
+Creates, for a borrower, an item-level hold request on a specific item of 
+a bibliographic record in Koha.
 
-       Parameters:
+Parameters:
 
-       - patron_id (Required)
-               a borrowernumber
-       - bib_id (Required)
-               a biblionumber
-       - item_id (Required)
-               an itemnumber
-       - pickup_location (Optional)
-               a branch code indicating the location to which to deliver the item for pickup
-       - needed_before_date (Optional)
-               date after which hold request is no longer needed
-       - pickup_expiry_date (Optional)
-               date after which item returned to shelf if item is not picked up 
+  - patron_id (Required)
+       a borrowernumber
+  - bib_id (Required)
+       a biblionumber
+  - item_id (Required)
+       an itemnumber
+  - pickup_location (Optional)
+       a branch code indicating the location to which to deliver the item for pickup
+  - needed_before_date (Optional)
+       date after which hold request is no longer needed
+  - pickup_expiry_date (Optional)
+       date after which item returned to shelf if item is not picked up 
 
 =cut
 
@@ -755,44 +657,12 @@ sub HoldItem {
 
     # Get the borrower or return an error code
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # Get the biblio or return an error code
     my $biblionumber = $cgi->param('bib_id');
     my ( $count, $biblio ) = GetBiblio($biblionumber);
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    if ( not $biblio->{'biblionumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-    my $title = $biblio->{'title'};
-
-    # Get the item or return an error code
-    my $itemnumber = $cgi->param('item_id');
-    my $item = GetItem( $itemnumber, undef, undef );
-    if ( not $item->{'itemnumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-
-    # if the biblio does not match the item, return an error code
-    if ( $item->{'biblionumber'} ne $biblio->{'biblionumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-
-    # Check for item disponibility
-    my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber);
-    my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber );
-    if ( ( not $canbookbereserved ) or not($canitembereserved) ) {
-        return { message => 'NotHoldable' };
-    }
-=======
     return { code => 'RecordNotFound' } unless $$biblio{biblionumber};
 
     my $title = $$biblio{title};
@@ -809,7 +679,6 @@ sub HoldItem {
     my $canitembereserved = CanItemBeReserved( $borrowernumber, $itemnumber );
     my $canbookbereserved = CanBookBeReserved( $borrowernumber, $biblionumber );
     return { code => 'NotHoldable' } unless $canbookbereserved and $canitembereserved;
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     my $branch;
 
@@ -817,17 +686,9 @@ sub HoldItem {
     if ( $cgi->param('pickup_location') ) {
         $branch = $cgi->param('pickup_location');
         my $branches = GetBranches();
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-        if ( not $branches->{$branch} ) {
-            return { message => 'LocationNotFound' };
-        }
-    } else {    # if user provide no branch, use his own
-        $branch = $borrower->{'branchcode'};
-=======
         return { code => 'LocationNotFound' } unless $$branches{$branch};
     } else { # if the request provide no branch, use the borrower's branch
         $branch = $$borrower{branchcode};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
     }
 
     my $rank;
@@ -854,14 +715,14 @@ sub HoldItem {
 
 =head2 CancelHold
 
-       Cancels an active reserve request for the borrower.
-       
-       Parameters:
+Cancels an active reserve request for the borrower.
+
+Parameters:
 
-       - patron_id (Required)
-               a borrowernumber
-       - item_id (Required)
-               an itemnumber 
+  - patron_id (Required)
+       a borrowernumber
+  - item_id (Required)
+       an itemnumber 
 
 =cut
 
@@ -870,19 +731,6 @@ sub CancelHold {
 
     # Get the borrower or return an error code
     my $borrowernumber = $cgi->param('patron_id');
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    my $borrower = GetMemberDetails( $borrowernumber, undef );
-    if ( not $borrower->{'borrowernumber'} ) {
-        return { message => 'PatronNotFound' };
-    }
-
-    # Get the item or return an error code
-    my $itemnumber = $cgi->param('item_id');
-    my $item = GetItem( $itemnumber, undef, undef );
-    if ( not $item->{'itemnumber'} ) {
-        return { message => 'RecordNotFound' };
-    }
-=======
     my $borrower = GetMemberDetails( $borrowernumber );
     return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
 
@@ -890,7 +738,6 @@ sub CancelHold {
     my $itemnumber = $cgi->param('item_id');
     my $item = GetItem( $itemnumber );
     return { code => 'RecordNotFound' } unless $$item{itemnumber};
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 
     # Get borrower's reserves
     my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef );
@@ -902,23 +749,12 @@ sub CancelHold {
     }
 
     # if the item was not reserved by the borrower, returns an error code
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    if ( not grep { $itemnumber eq $_ } @reserveditems ) {
-        return { message => 'NotCanceled' };
-    }
-=======
-    return { code => 'NotCanceled' } unless any { $itemnumber eq $_ } @reserveditemnumbers;
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
+    return { code => 'NotCanceled' } unless any { $itemnumber eq $_ } @reserveditems;
 
     # Cancel the reserve
     CancelReserve( $itemnumber, undef, $borrowernumber );
 
-<<<<<<< HEAD:C4/ILSDI/Services.pm
-    return { message => 'Canceled' };
-
-=======
     return { code => 'Canceled' };
->>>>>>> [MT2306_2271] ILS-DI Message codes consistence:C4/ILSDI.pm
 }
 
 1;