From f7f783226abd73c3a4bd58b76fcd8b3893e9022d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Aug 2009 08:36:34 -0400 Subject: [PATCH] ran ILS-DI code through perltidy Signed-off-by: Galen Charlton --- C4/ILSDI/Services.pm | 830 ++++++++++++++++++++++--------------------- C4/ILSDI/Utility.pm | 155 ++++---- opac/ilsdi.pl | 306 ++++++++-------- 3 files changed, 653 insertions(+), 638 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index f0d86d7131..ffd4792a2f 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -91,59 +91,55 @@ C4::ILS-DI::Services - ILS-DI Services =cut sub GetAvailability { - my ( $cgi ) = @_; - - my $out = "\n"; - $out .= "\n"; - - foreach my $id (split(/ /, $cgi->param('id'))) - { - if ($cgi->param('id_type') eq "item") - { - my ($biblionumber, $status, $msg, $location) = Availability($id); - - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " " . $id . "\n"; - $out .= " " . $status . "\n"; - if ($msg) { $out .= " " . $msg . "\n"; } - if ($location) { $out .= " " . $location . "\n"; } - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - } - else - { - my $status; - my $msg; - my $biblioitem = (GetBiblioItemByBiblioNumber($id, undef))[0]; - if ($biblioitem) { - - } else { - $status = "unknown"; - $msg = "Error: could not retrieve availability for this ID"; - } - $out .= " \n"; - $out .= " \n"; - $out .= " \n"; - $out .= " " . $id . "\n"; - $out .= " " . $status . "\n"; - $out .= " " . $msg . "\n"; - $out .= " \n"; - $out .= " \n"; - } - } - $out .= "\n"; - - return $out; + my ($cgi) = @_; + + my $out = "\n"; + $out .= "\n"; + + foreach my $id ( split( / /, $cgi->param('id') ) ) { + if ( $cgi->param('id_type') eq "item" ) { + my ( $biblionumber, $status, $msg, $location ) = Availability($id); + + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + if ($msg) { $out .= " " . $msg . "\n"; } + if ($location) { $out .= " " . $location . "\n"; } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + } else { + my $status; + my $msg; + my $biblioitem = ( GetBiblioItemByBiblioNumber( $id, undef ) )[0]; + if ($biblioitem) { + + } else { + $status = "unknown"; + $msg = "Error: could not retrieve availability for this ID"; + } + $out .= " \n"; + $out .= " \n"; + $out .= " \n"; + $out .= " " . $id . "\n"; + $out .= " " . $status . "\n"; + $out .= " " . $msg . "\n"; + $out .= " \n"; + $out .= " \n"; + } + } + $out .= "\n"; + + return $out; } =head2 GetRecords @@ -170,55 +166,58 @@ sub GetAvailability { =cut sub GetRecords { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Check if the schema is supported. For now, GetRecords only supports MARCXML - if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + # Check if the schema is supported. For now, GetRecords only supports MARCXML + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML" ) { return { message => 'UnsupportedSchema' }; - } - - my @records; - # Loop over biblionumbers - foreach my $biblionumber (split(/ /, $cgi->param('id'))) - { - # Get the biblioitem from the biblionumber - my $biblioitem = (GetBiblioItemByBiblioNumber($biblionumber, undef))[0]; - if ( not $biblioitem->{'biblionumber'} ) { - $biblioitem = "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); - my $issues = GetBiblioIssues($biblionumber); - my $items = GetItemsByBiblioitemnumber($biblioitemnumber); - - # We loop over the items to clean them - foreach my $item (@$items) - { - # This hides additionnal XML subfields, we don't need these info - delete $item->{'more_subfields_xml'}; - # Display branch names instead of branch codes - $item->{'homebranchname'} = GetBranchName($item->{'homebranch'}); - $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'}); - } - - # Hashref building... - $biblioitem->{'items'}->{'item'} = $items; - $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; - $biblioitem->{'issues'}->{'issue'} = $issues; - - map { $biblioitem->{$_} = encode_entities($biblioitem->{$_},'&') } grep(!/marcxml/, keys %$biblioitem); - - push @records, $biblioitem; - } + } + + my @records; + + # Loop over biblionumbers + foreach my $biblionumber ( split( / /, $cgi->param('id') ) ) { + + # Get the biblioitem from the biblionumber + my $biblioitem = ( GetBiblioItemByBiblioNumber( $biblionumber, undef ) )[0]; + if ( not $biblioitem->{'biblionumber'} ) { + $biblioitem = "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 ); + my $issues = GetBiblioIssues($biblionumber); + my $items = GetItemsByBiblioitemnumber($biblioitemnumber); - return { record => \@records }; + # We loop over the items to clean them + foreach my $item (@$items) { + + # This hides additionnal XML subfields, we don't need these info + delete $item->{'more_subfields_xml'}; + + # Display branch names instead of branch codes + $item->{'homebranchname'} = GetBranchName( $item->{'homebranch'} ); + $item->{'holdingbranchname'} = GetBranchName( $item->{'holdingbranch'} ); + } + + # Hashref building... + $biblioitem->{'items'}->{'item'} = $items; + $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; + $biblioitem->{'issues'}->{'issue'} = $issues; + + map { $biblioitem->{$_} = encode_entities( $biblioitem->{$_}, '&' ) } grep( !/marcxml/, keys %$biblioitem ); + + push @records, $biblioitem; + } + + return { record => \@records }; } =head2 GetAuthorityRecords @@ -238,24 +237,25 @@ sub GetRecords { =cut sub GetAuthorityRecords { - my ( $cgi ) = @_; + my ($cgi) = @_; - # If the user asks for an unsupported schema, return an error code - if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML") { + # If the user asks for an unsupported schema, return an error code + if ( $cgi->param('schema') and $cgi->param('schema') ne "MARCXML" ) { return { message => 'UnsupportedSchema' }; - } - - 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) || "RecordNotFound"; - $record =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; - $records .= $record; - } - - return $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) || "RecordNotFound"; + $record =~ s/<\?xml version="1.0" encoding="UTF-8"\?>//go; + $records .= $record; + } + + return $records; } =head2 LookupPatron @@ -276,19 +276,19 @@ sub GetAuthorityRecords { =cut sub LookupPatron { - my ( $cgi ) = @_; - - # Get the borrower... - my $borrower = GetMember($cgi->param('id'), $cgi->param('id_type')); - if ( not $borrower->{'borrowernumber'} ) { + my ($cgi) = @_; + + # Get the borrower... + my $borrower = GetMember( $cgi->param('id'), $cgi->param('id_type') ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Build the hashref - my $patron->{'id'} = $borrower->{'borrowernumber'}; - - # ...and return his ID - return $patron; + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; + + # ...and return his ID + return $patron; } =head2 AuthenticatePatron @@ -306,21 +306,21 @@ sub LookupPatron { =cut sub AuthenticatePatron { - my ( $cgi ) = @_; - - # Check if borrower exists, using a C4::ILSDI::Utility function... - if ( not (BorrowerExists($cgi->param('username'), $cgi->param('password')))) { + my ($cgi) = @_; + + # Check if borrower exists, using a C4::ILSDI::Utility function... + if ( not( BorrowerExists( $cgi->param('username'), $cgi->param('password') ) ) ) { return { message => 'PatronNotFound' }; - } - - # Get the borrower - my $borrower = GetMember($cgi->param('username'), "userid"); - - # Build the hashref - my $patron->{'id'} = $borrower->{'borrowernumber'}; + } + + # Get the borrower + my $borrower = GetMember( $cgi->param('username'), "userid" ); + + # Build the hashref + my $patron->{'id'} = $borrower->{'borrowernumber'}; - # ... and return his ID - return $patron; + # ... and return his ID + return $patron; } =head2 GetPatronInfo @@ -345,73 +345,79 @@ sub AuthenticatePatron { =cut sub GetPatronInfo { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get Member details - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'}) { + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } - - # Cleaning the borrower hashref - $borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; - $borrower->{'branchname'} = GetBranchName($borrower->{'branchcode'}); - delete $borrower->{'flags'}; - delete $borrower->{'userid'}; - delete $borrower->{'password'}; - - # Contact fields management - if ($cgi->param('show_contact') eq "0") { - # Define contact fields - my @contactfields = ('email', 'emailpro', 'fax', 'mobile', - 'phone', 'phonepro', 'streetnumber', 'zipcode', 'city', - 'streettype', 'B_address', 'B_city', 'B_email', 'B_phone', - 'B_zipcode', 'address', 'address2', 'altcontactaddress1', - 'altcontactaddress2', 'altcontactaddress3', 'altcontactfirstname', - 'altcontactphone', 'altcontactsurname', 'altcontactzipcode'); - # and delete them - foreach my $field (@contactfields) { - delete $borrower->{$field}; - } - } - - # Fines management - if ($cgi->param('show_fines') eq "1") { - my @charges; - for(my $i = 1; my @charge = getcharges($borrowernumber, undef, $i); $i++) { - push(@charges, @charge); - } - $borrower->{'fines'}->{'fine'} = \@charges; - } - - # Reserves management - if ($cgi->param('show_holds') eq "1") { - # Get borrower's reserves - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - foreach my $reserve (@reserves) { - # Get additional informations - my $item = GetBiblioFromItemNumber($reserve->{'itemnumber'}, undef); - my $branchname = GetBranchName($reserve->{'branchcode'}); - # Remove unwanted fields - delete $item->{'marc'}; - delete $item->{'marcxml'}; - delete $item->{'more_subfields_xml'}; - # Add additional fields - $reserve->{'item'} = $item; - $reserve->{'branchname'} = $branchname; - $reserve->{'title'} = (GetBiblio($reserve->{'biblionumber'}))[1]->{'title'}; - } - $borrower->{'holds'}->{'hold'} = \@reserves; - } - - # Issues management - if ($cgi->param('show_loans') eq "1") { - my $issues = GetPendingIssues($borrowernumber); - $borrower->{'loans'}->{'loan'} = $issues; - } - - return $borrower; + } + + # Cleaning the borrower hashref + $borrower->{'charges'} = $borrower->{'flags'}->{'CHARGES'}->{'amount'}; + $borrower->{'branchname'} = GetBranchName( $borrower->{'branchcode'} ); + delete $borrower->{'flags'}; + delete $borrower->{'userid'}; + delete $borrower->{'password'}; + + # Contact fields management + if ( $cgi->param('show_contact') eq "0" ) { + + # Define contact fields + my @contactfields = ( + 'email', 'emailpro', 'fax', 'mobile', 'phone', 'phonepro', + 'streetnumber', 'zipcode', 'city', 'streettype', 'B_address', 'B_city', + 'B_email', 'B_phone', 'B_zipcode', 'address', 'address2', 'altcontactaddress1', + 'altcontactaddress2', 'altcontactaddress3', 'altcontactfirstname', 'altcontactphone', 'altcontactsurname', 'altcontactzipcode' + ); + + # and delete them + foreach my $field (@contactfields) { + delete $borrower->{$field}; + } + } + + # Fines management + if ( $cgi->param('show_fines') eq "1" ) { + my @charges; + for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) { + push( @charges, @charge ); + } + $borrower->{'fines'}->{'fine'} = \@charges; + } + + # Reserves management + if ( $cgi->param('show_holds') eq "1" ) { + + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + foreach my $reserve (@reserves) { + + # Get additional informations + my $item = GetBiblioFromItemNumber( $reserve->{'itemnumber'}, undef ); + my $branchname = GetBranchName( $reserve->{'branchcode'} ); + + # Remove unwanted fields + delete $item->{'marc'}; + delete $item->{'marcxml'}; + delete $item->{'more_subfields_xml'}; + + # Add additional fields + $reserve->{'item'} = $item; + $reserve->{'branchname'} = $branchname; + $reserve->{'title'} = ( GetBiblio( $reserve->{'biblionumber'} ) )[1]->{'title'}; + } + $borrower->{'holds'}->{'hold'} = \@reserves; + } + + # Issues management + if ( $cgi->param('show_loans') eq "1" ) { + my $issues = GetPendingIssues($borrowernumber); + $borrower->{'loans'}->{'loan'} = $issues; + } + + return $borrower; } =head2 GetPatronStatus @@ -426,22 +432,22 @@ sub GetPatronInfo { =cut sub GetPatronStatus { - my ( $cgi ) = @_; - - # Get Member details - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + my ($cgi) = @_; + + # Get Member details + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } + } - # Hashref building + # Hashref building my $patron; - $patron->{'type'} = $borrower->{'categorycode'}; - $patron->{'status'} = 0; #TODO - $patron->{'expiry'} = $borrower->{'dateexpiry'}; - - return $patron; + $patron->{'type'} = $borrower->{'categorycode'}; + $patron->{'status'} = 0; #TODO + $patron->{'expiry'} = $borrower->{'dateexpiry'}; + + return $patron; } =head2 GetServices @@ -458,63 +464,64 @@ sub GetPatronStatus { =cut sub GetServices { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the member, or return an error code if not found - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the member, or return an error code if not found + my $borrowernumber = $cgi->param('patron_id'); + 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'} ) { + # 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 @availablefor; - - # Reserve level management - my $biblionumber = $item->{'biblionumber'}; - my $canbookbereserved = CanBookBeReserved($borrower, $biblionumber); - if ( $canbookbereserved ) { - push @availablefor, 'title level hold'; - my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); - if ( $canitembereserved ) { - push @availablefor, 'item level hold'; - } - } - - # Reserve cancellation management - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - my @reserveditems; - foreach my $reserve (@reserves) { - push @reserveditems, $reserve->{'itemnumber'}; - } - if ( grep {$itemnumber eq $_} @reserveditems) { - push @availablefor, 'hold cancellation'; - } - - # Renewal management - my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if ( $renewal[0] ) { - push @availablefor, 'loan renewal'; - } - - # Issuing management - my $barcode = $item->{'barcode'} || ''; - $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter')); - if ($barcode) { - my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); - # TODO push @availablefor, 'loan'; - } + } + + my @availablefor; + + # Reserve level management + my $biblionumber = $item->{'biblionumber'}; + my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ($canbookbereserved) { + push @availablefor, 'title level hold'; + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + if ($canitembereserved) { + push @availablefor, 'item level hold'; + } + } + + # Reserve cancellation management + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + my @reserveditems; + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + if ( grep { $itemnumber eq $_ } @reserveditems ) { + push @availablefor, 'hold cancellation'; + } + + # Renewal management + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if ( $renewal[0] ) { + push @availablefor, 'loan renewal'; + } + + # Issuing management + my $barcode = $item->{'barcode'} || ''; + $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') ); + if ($barcode) { + my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $borrower, $barcode ); + + # TODO push @availablefor, 'loan'; + } my $out; - $out->{'AvailableFor'} = \@availablefor; - - return $out; + $out->{'AvailableFor'} = \@availablefor; + + return $out; } =head2 RenewLoan @@ -533,36 +540,36 @@ sub GetServices { =cut sub RenewLoan { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get borrower infos or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get borrower infos or return an error code + my $borrowernumber = $cgi->param('patron_id'); + 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'} ) { + # 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' }; - } + } - # Add renewal if possible - my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); - if ($renewal[0]) { AddRenewal( $borrowernumber, $itemnumber ); } + # Add renewal if possible + my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); + if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); } - my $issue = GetItemIssue($itemnumber); + my $issue = GetItemIssue($itemnumber); - # Hashref building + # Hashref building my $out; - $out->{'renewals'} = $issue->{'renewals'}; - $out->{'date_due'} = $issue->{'date_due'}; - $out->{'success'} = $renewal[0]; - $out->{'error'} = $renewal[1]; - - return $out; + $out->{'renewals'} = $issue->{'renewals'}; + $out->{'date_due'} = $issue->{'date_due'}; + $out->{'success'} = $renewal[0]; + $out->{'error'} = $renewal[1]; + + return $out; } =head2 HoldTitle @@ -587,52 +594,54 @@ sub RenewLoan { =cut sub HoldTitle { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + 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'} ) { + } + + # 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 ) { + } + my $title = $biblio->{'title'}; + + # Check if the biblio can be reserved + my $canbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ( not $canbereserved ) { return { message => 'NotHoldable' }; - } - - my $branch; - # Pickup branch management - if ($cgi->param('pickup_location')) { - $branch = $cgi->param('pickup_location'); - my $branches = GetBranches(); - if ( not $branches->{$branch} ) { + } + + my $branch; + + # Pickup branch management + if ( $cgi->param('pickup_location') ) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { return { message => 'LocationNotFound' }; - } - } else { # if user provide no branch, use his own - $branch = $borrower->{'branchcode'}; - } + } + } else { # if user provide no branch, use his own + $branch = $borrower->{'branchcode'}; + } - # Add the reserve - # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found - AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef); + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, 0, undef, $title, undef, undef ); - # Hashref building + # Hashref building my $out; - $out->{'title'} = $title; - $out->{'pickup_location'} = GetBranchName($branch); - # TODO $out->{'date_available'} = ''; + $out->{'title'} = $title; + $out->{'pickup_location'} = GetBranchName($branch); - return $out; + # TODO $out->{'date_available'} = ''; + + return $out; } =head2 HoldItem @@ -658,72 +667,75 @@ sub HoldTitle { =cut sub HoldItem { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $borrower = GetMemberDetails( $borrowernumber, undef ); + if ( not $borrower->{'borrowernumber'} ) { return { message => 'PatronNotFound' }; - } - - # Get the biblio or return an error code - my $biblionumber = $cgi->param('bib_id'); - my ($count, $biblio) = GetBiblio($biblionumber); - if ( not $biblio->{'biblionumber'} ) { + } + + # Get the biblio 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'}; + } + 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'} ) { + # 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'} ) { + } + + # 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) ) { + } + + # Check for item disponibility + my $canitembereserved = IsAvailableForItemLevelRequest($itemnumber); + my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber ); + if ( ( not $canbookbereserved ) or not($canitembereserved) ) { return { message => 'NotHoldable' }; - } - - my $branch; - # Pickup branch management - if ($cgi->param('pickup_location')) { - $branch = $cgi->param('pickup_location'); - my $branches = GetBranches(); - if ( not $branches->{$branch} ) { + } + + my $branch; + + # Pickup branch management + if ( $cgi->param('pickup_location') ) { + $branch = $cgi->param('pickup_location'); + my $branches = GetBranches(); + if ( not $branches->{$branch} ) { return { message => 'LocationNotFound' }; - } - } else { # if user provide no branch, use his own - $branch = $borrower->{'branchcode'}; - } - - my $rank; - my $found; - # Get rank and found - $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); - if ( $item->{'holdingbranch'} eq $branch ){ - $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); - } - - # Add the reserve - # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found - AddReserve($branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found); - - # Hashref building + } + } else { # if user provide no branch, use his own + $branch = $borrower->{'branchcode'}; + } + + my $rank; + my $found; + + # Get rank and found + $rank = '0' unless C4::Context->preference('ReservesNeedReturns'); + if ( $item->{'holdingbranch'} eq $branch ) { + $found = 'W' unless C4::Context->preference('ReservesNeedReturns'); + } + + # Add the reserve + # $branch, $borrowernumber, $biblionumber, $constraint, $bibitems, $priority, $notes, $title, $checkitem, $found + AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $rank, undef, $title, $itemnumber, $found ); + + # Hashref building my $out; - $out->{'pickup_location'} = GetBranchName($branch); - # TODO $out->{'date_available'} = ''; + $out->{'pickup_location'} = GetBranchName($branch); + + # TODO $out->{'date_available'} = ''; - return $out; + return $out; } =head2 CancelHold @@ -740,39 +752,41 @@ sub HoldItem { =cut sub CancelHold { - my ( $cgi ) = @_; + my ($cgi) = @_; - # Get the borrower or return an error code - my $borrowernumber = $cgi->param('patron_id'); - my $borrower = GetMemberDetails($borrowernumber, undef); - if ( not $borrower->{'borrowernumber'} ) { + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + 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'} ) { + # 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' }; - } - - # Get borrower's reserves - my @reserves = GetReservesFromBorrowernumber($borrowernumber, undef); - my @reserveditems; - # ...and loop over it to build an array of reserved itemnumbers - foreach my $reserve (@reserves) { - push @reserveditems, $reserve->{'itemnumber'}; - } - # if the item was not reserved by the borrower, returns an error code - if ( not grep {$itemnumber eq $_} @reserveditems) { + } + + # Get borrower's reserves + my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); + my @reserveditems; + + # ...and loop over it to build an array of reserved itemnumbers + foreach my $reserve (@reserves) { + push @reserveditems, $reserve->{'itemnumber'}; + } + + # if the item was not reserved by the borrower, returns an error code + if ( not grep { $itemnumber eq $_ } @reserveditems ) { return { message => 'NotCanceled' }; - } + } - # Cancel the reserve - CancelReserve($itemnumber, undef, $borrowernumber); + # Cancel the reserve + CancelReserve( $itemnumber, undef, $borrowernumber ); return { message => 'Canceled' }; - + } 1; diff --git a/C4/ILSDI/Utility.pm b/C4/ILSDI/Utility.pm index ab270dfe74..77886ca118 100644 --- a/C4/ILSDI/Utility.pm +++ b/C4/ILSDI/Utility.pm @@ -32,13 +32,14 @@ use Digest::MD5 qw(md5_base64); use vars qw($VERSION @ISA @EXPORT); BEGIN { - # set the version for version checking - $VERSION = 3.00; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw( - &BorrowerExists &CanBookBeReserved &Availability - ); + + # set the version for version checking + $VERSION = 3.00; + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &BorrowerExists &CanBookBeReserved &Availability + ); } =head1 NAME @@ -58,13 +59,12 @@ Checks, for a given userid and password, if the borrower exists. =cut sub BorrowerExists { - my ( $userid, $password ) = @_; - $password = md5_base64($password); - my $dbh = C4::Context->dbh; - my $sth = - $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? "); - $sth->execute( $userid, $password ); - return $sth->fetchrow; + my ( $userid, $password ) = @_; + $password = md5_base64($password); + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT COUNT(*) FROM borrowers WHERE userid =? and password=? "); + $sth->execute( $userid, $password ); + return $sth->fetchrow; } =head2 CanBookBeReserved @@ -78,42 +78,42 @@ Checks if a book (at bibliographic level) can be reserved by a borrower. =cut sub CanBookBeReserved { - my ( $borrower, $biblionumber ) = @_; - - my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); - my $MAXOUTSTANDING = C4::Context->preference("maxoutstanding"); - - my $out = 1; - - if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) { - $out = undef; - } - if ( $borrower->{gonenoaddress} eq 1 ) { - $out = undef; - } - if ( $borrower->{lost} eq 1 ) { - $out = undef; - } - if ( $borrower->{debarred} eq 1 ) { - $out = undef; - } - my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} ); - if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { - $out = undef; - } - foreach my $res (@reserves) { - if ( $res->{'biblionumber'} == $biblionumber ) { - $out = undef; - } - } - my $issues = GetPendingIssues($borrower->{'borrowernumber'}); - foreach my $issue (@$issues) { - if ( $issue->{'biblionumber'} == $biblionumber ) { - $out = undef; - } - } - - return $out; + my ( $borrower, $biblionumber ) = @_; + + my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves"); + my $MAXOUTSTANDING = C4::Context->preference("maxoutstanding"); + + my $out = 1; + + if ( $borrower->{'amountoutstanding'} > $MAXOUTSTANDING ) { + $out = undef; + } + if ( $borrower->{gonenoaddress} eq 1 ) { + $out = undef; + } + if ( $borrower->{lost} eq 1 ) { + $out = undef; + } + if ( $borrower->{debarred} eq 1 ) { + $out = undef; + } + my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} ); + if ( scalar(@reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { + $out = undef; + } + foreach my $res (@reserves) { + if ( $res->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + my $issues = GetPendingIssues( $borrower->{'borrowernumber'} ); + foreach my $issue (@$issues) { + if ( $issue->{'biblionumber'} == $biblionumber ) { + $out = undef; + } + } + + return $out; } =head2 Availability @@ -125,36 +125,31 @@ Returns, for an itemnumber, an array containing availability information. =cut sub Availability { - my ( $itemnumber ) = @_; - my $item = GetItem($itemnumber, undef, undef); - - if ( not $item->{'itemnumber'} ) { - return (undef, 'unknown', 'Error: could not retrieve availability for this ID', undef); - } - - my $biblionumber = $item->{'biblioitemnumber'}; - my $location = GetBranchName($item->{'holdingbranch'}); - - if ($item->{'notforloan'}) { - return ($biblionumber, 'not available', 'Not for loan', $location); - } - elsif ($item->{'onloan'}) { - return ($biblionumber, 'not available', 'Checked out', $location); - } - elsif ($item->{'itemlost'}) { - return ($biblionumber, 'not available', 'Item lost', $location); - } - elsif ($item->{'wthdrawn'}) { - return ($biblionumber, 'not available', 'Item withdrawn', $location); - } - elsif ($item->{'damaged'}) { - return ($biblionumber, 'not available', 'Item damaged', $location); - } - else { - return ($biblionumber, 'available', undef, $location); - } - - die Data::Dumper::Dumper($item); + my ($itemnumber) = @_; + my $item = GetItem( $itemnumber, undef, undef ); + + if ( not $item->{'itemnumber'} ) { + return ( undef, 'unknown', 'Error: could not retrieve availability for this ID', undef ); + } + + my $biblionumber = $item->{'biblioitemnumber'}; + my $location = GetBranchName( $item->{'holdingbranch'} ); + + if ( $item->{'notforloan'} ) { + return ( $biblionumber, 'not available', 'Not for loan', $location ); + } elsif ( $item->{'onloan'} ) { + return ( $biblionumber, 'not available', 'Checked out', $location ); + } elsif ( $item->{'itemlost'} ) { + return ( $biblionumber, 'not available', 'Item lost', $location ); + } elsif ( $item->{'wthdrawn'} ) { + return ( $biblionumber, 'not available', 'Item withdrawn', $location ); + } elsif ( $item->{'damaged'} ) { + return ( $biblionumber, 'not available', 'Item damaged', $location ); + } else { + return ( $biblionumber, 'available', undef, $location ); + } + + die Data::Dumper::Dumper($item); } 1; diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index 50004980ed..18f424d30f 100755 --- a/opac/ilsdi.pl +++ b/opac/ilsdi.pl @@ -41,106 +41,109 @@ my $cgi = new CGI; # List of available services, sorted by level my @services = ( - 'Describe', # Not part of ILS-DI, online API doc -# Level 1: Basic Discovery Interfaces -# 'HarvestBibliographicRecords', # OAI-PMH -# 'HarvestExpandedRecords', # OAI-PMH - 'GetAvailability', # FIXME Add bibbliographic level -# 'GoToBibliographicRequestPage' # I don't understant this one -# Level 2: Elementary OPAC supplement -# 'HarvestAuthorityRecords', # OAI-PMH -# 'HarvestHoldingsRecords', # OAI-PMH - 'GetRecords', # Note that we can use OAI-PMH for this too -# 'Search', # TODO -# 'Scan', # TODO - 'GetAuthorityRecords', -# 'OutputRewritablePage', # I don't understant this one -# 'OutputIntermediateFormat', # I don't understant this one -# Level 3: Elementary OPAC alternative - 'LookupPatron', - 'AuthenticatePatron', - 'GetPatronInfo', - 'GetPatronStatus', - 'GetServices', # FIXME Loans - 'RenewLoan', - 'HoldTitle', # FIXME Add dates support - 'HoldItem', # FIXME Add dates support - 'CancelHold', -# 'RecallItem', # Not supported by Koha -# 'CancelRecall', # Not supported by Koha -# Level 4: Robust/domain specific discovery platforms -# 'SearchCourseReserves', # TODO -# 'Explain' # TODO + 'Describe', # Not part of ILS-DI, online API doc + + # Level 1: Basic Discovery Interfaces + # 'HarvestBibliographicRecords', # OAI-PMH + # 'HarvestExpandedRecords', # OAI-PMH + 'GetAvailability', # FIXME Add bibbliographic level + + # 'GoToBibliographicRequestPage' # I don't understant this one + # Level 2: Elementary OPAC supplement + # 'HarvestAuthorityRecords', # OAI-PMH + # 'HarvestHoldingsRecords', # OAI-PMH + 'GetRecords', # Note that we can use OAI-PMH for this too + + # 'Search', # TODO + # 'Scan', # TODO + 'GetAuthorityRecords', + + # 'OutputRewritablePage', # I don't understant this one + # 'OutputIntermediateFormat', # I don't understant this one + # Level 3: Elementary OPAC alternative + 'LookupPatron', + 'AuthenticatePatron', + 'GetPatronInfo', + 'GetPatronStatus', + 'GetServices', # FIXME Loans + 'RenewLoan', + 'HoldTitle', # FIXME Add dates support + 'HoldItem', # FIXME Add dates support + 'CancelHold', + + # 'RecallItem', # Not supported by Koha + # 'CancelRecall', # Not supported by Koha + # Level 4: Robust/domain specific discovery platforms + # 'SearchCourseReserves', # TODO + # 'Explain' # TODO ); # List of required arguments my %required = ( - 'Describe' => ['verb'], - 'GetAvailability' => ['id', 'id_type'], - 'GetRecords' => ['id'], - 'GetAuthorityRecords' => ['id'], - 'LookupPatron' => ['id'], - 'AuthenticatePatron' => ['username', 'password'], - 'GetPatronInfo' => ['patron_id'], - 'GetPatronStatus' => ['patron_id'], - 'GetServices' => ['patron_id', 'item_id'], - 'RenewLoan' => ['patron_id', 'item_id'], - 'HoldTitle' => ['patron_id', 'bib_id', 'request_location'], - 'HoldItem' => ['patron_id', 'bib_id', 'item_id'], - 'CancelHold' => ['patron_id', 'item_id'], + 'Describe' => ['verb'], + 'GetAvailability' => [ 'id', 'id_type' ], + 'GetRecords' => ['id'], + 'GetAuthorityRecords' => ['id'], + 'LookupPatron' => ['id'], + 'AuthenticatePatron' => [ 'username', 'password' ], + 'GetPatronInfo' => ['patron_id'], + 'GetPatronStatus' => ['patron_id'], + 'GetServices' => [ 'patron_id', 'item_id' ], + 'RenewLoan' => [ 'patron_id', 'item_id' ], + 'HoldTitle' => [ 'patron_id', 'bib_id', 'request_location' ], + 'HoldItem' => [ 'patron_id', 'bib_id', 'item_id' ], + 'CancelHold' => [ 'patron_id', 'item_id' ], ); # List of optional arguments my %optional = ( - 'Describe' => [], - 'GetAvailability' => ['return_type', 'return_fmt'], - 'GetRecords' => ['schema'], - 'GetAuthorityRecords' => ['schema'], - 'LookupPatron' => ['id_type'], - 'AuthenticatePatron' => [], - 'GetPatronInfo' => ['show_contact', 'show_fines', 'show_holds', 'show_loans'], - 'GetPatronStatus' => [], - 'GetServices' => [], - 'RenewLoan' => ['desired_due_date'], - 'HoldTitle' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], - 'HoldItem' => ['pickup_location', 'needed_before_date', 'pickup_expiry_date'], - 'CancelHold' => [], + 'Describe' => [], + 'GetAvailability' => [ 'return_type', 'return_fmt' ], + 'GetRecords' => ['schema'], + 'GetAuthorityRecords' => ['schema'], + 'LookupPatron' => ['id_type'], + 'AuthenticatePatron' => [], + 'GetPatronInfo' => [ 'show_contact', 'show_fines', 'show_holds', 'show_loans' ], + 'GetPatronStatus' => [], + 'GetServices' => [], + 'RenewLoan' => ['desired_due_date'], + 'HoldTitle' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], + 'HoldItem' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], + 'CancelHold' => [], ); # If ILS-DI module is disabled in System->Preferences, redirect to 404 -if (not C4::Context->preference('ILS-DI')) { - print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); +if ( not C4::Context->preference('ILS-DI') ) { + print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); } # If no service is requested, display the online documentation -if (not $cgi->param('service')) { - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "ilsdi.tmpl", - query => $cgi, - type => "opac", - authnotrequired => 1, - debug => 1, - } - ); - output_html_with_http_headers $cgi, $cookie, $template->output; - exit 0; +if ( not $cgi->param('service') ) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; } # If user requested a service description, then display it -if ($cgi->param('service') eq "Describe" and grep {$cgi->param('verb') eq $_} @services) { - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "ilsdi.tmpl", - query => $cgi, - type => "opac", - authnotrequired => 1, - debug => 1, - } - ); - $template->param( $cgi->param('verb') => 1 ); - output_html_with_http_headers $cgi, $cookie, $template->output; - exit 0; +if ( $cgi->param('service') eq "Describe" and grep { $cgi->param('verb') eq $_ } @services ) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "ilsdi.tmpl", + query => $cgi, + type => "opac", + authnotrequired => 1, + debug => 1, + } + ); + $template->param( $cgi->param('verb') => 1 ); + output_html_with_http_headers $cgi, $cookie, $template->output; + exit 0; } my $service = $cgi->param('service') || "ilsdi"; @@ -148,75 +151,78 @@ my $service = $cgi->param('service') || "ilsdi"; my $out; # Check if the requested service is in the list -if ($service and grep {$service eq $_} @services) { - - my @parmsrequired = @{$required{$service}}; - my @parmsoptional = @{$optional{$service}}; - my @parmsall = (@parmsrequired, @parmsoptional); - my @names = $cgi->param; - my %paramhash = (); - foreach my $name (@names) { - $paramhash{$name} = 1; - } - - # check for missing parameters - foreach my $name (@parmsrequired) { - if ((! exists $paramhash{$name})) { - $out->{'message'} = "missing $name parameter"; - } - } - - # check for illegal parameters - foreach my $name (@names) { - my $found = 0; - foreach my $name2 (@parmsall) { - if ($name eq $name2) { - $found = 1; - } - } - if (($found == 0) && ($name ne 'service')) { - $out->{'message'} = "$name is an illegal parameter"; - } - } - - # check for multiple parameters - foreach my $name (@names) { - my @values = $cgi->param($name); - if ($#values != 0) { - $out->{'message'} = "multiple values are not allowed for the $name parameter"; - } - } - - if (! $out->{'message'}) { - # GetAvailability is a special case, as it cannot use XML::Simple - if ($service eq "GetAvailability") { - print CGI::header('text/xml'); - print C4::ILSDI::Services::GetAvailability($cgi); - exit 0; - } - else { - # Variable functions - my $sub = do{ - no strict 'refs'; - my $symbol = 'C4::ILSDI::Services::'.$service; - \&{"$symbol"}; - }; - # Call the requested service, and get its return value - $out = &$sub($cgi); - } - } -} -else { - $out->{'message'} = "NotSupported"; +if ( $service and grep { $service eq $_ } @services ) { + + my @parmsrequired = @{ $required{$service} }; + my @parmsoptional = @{ $optional{$service} }; + my @parmsall = ( @parmsrequired, @parmsoptional ); + my @names = $cgi->param; + my %paramhash = (); + foreach my $name (@names) { + $paramhash{$name} = 1; + } + + # check for missing parameters + foreach my $name (@parmsrequired) { + if ( ( !exists $paramhash{$name} ) ) { + $out->{'message'} = "missing $name parameter"; + } + } + + # check for illegal parameters + foreach my $name (@names) { + my $found = 0; + foreach my $name2 (@parmsall) { + if ( $name eq $name2 ) { + $found = 1; + } + } + if ( ( $found == 0 ) && ( $name ne 'service' ) ) { + $out->{'message'} = "$name is an illegal parameter"; + } + } + + # check for multiple parameters + foreach my $name (@names) { + my @values = $cgi->param($name); + if ( $#values != 0 ) { + $out->{'message'} = "multiple values are not allowed for the $name parameter"; + } + } + + if ( !$out->{'message'} ) { + + # GetAvailability is a special case, as it cannot use XML::Simple + if ( $service eq "GetAvailability" ) { + print CGI::header('text/xml'); + print C4::ILSDI::Services::GetAvailability($cgi); + exit 0; + } else { + + # Variable functions + my $sub = do { + no strict 'refs'; + my $symbol = 'C4::ILSDI::Services::' . $service; + \&{"$symbol"}; + }; + + # Call the requested service, and get its return value + $out = &$sub($cgi); + } + } +} else { + $out->{'message'} = "NotSupported"; } # Output XML by passing the hashref to XMLOut print CGI::header('text/xml'); -print XMLout($out, - noattr => 1, - noescape => 1, - nosort => 1, - xmldecl => '', - RootName => $service, - SuppressEmpty => 1); +print XMLout( + $out, + noattr => 1, + noescape => 1, + nosort => 1, + xmldecl => '', + RootName => $service, + SuppressEmpty => 1 +); -- 2.39.2