use C4::Items;
use C4::Koha;
use C4::Biblio;
+use C4::Circulation;
use XML::LibXML;
use XML::LibXSLT;
my $biblio = GetBiblioData($biblionumber);
my $frameworkcode = GetFrameworkCode($biblionumber);
my $tagslib = &GetMarcStructure(1,$frameworkcode);
- my @fields = $record->fields();
+ my @fields;
+ # FIXME: wish there was a better way to handle exceptions
+ eval {
+ @fields = $record->fields();
+ };
+ if ($@) { warn "PROBLEM WITH RECORD"; next; }
my $list_of_authvalues = getAuthorisedValues4MARCSubfields($frameworkcode);
for my $authvalue (@$list_of_authvalues) {
for my $field ( $record->field($authvalue->{tagfield}) ) {
my $xml;
for my $item (@items) {
my $status;
- if ( $item->{notforloan} == -1 || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged}) {
+ my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
+ if ( $item->{notforloan} == -1 || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} ||
+ ($transfertwhen ne '') || $item->{itemnotforloan} ) {
if ( $item->{notforloan} == -1) {
$status = "On order";
+ }
+ if ( $item->{itemnotforloan} ) {
+ $status = "Not for loan";
}
if ($item->{onloan}) {
- $status = "On loan";
+ $status = "Checked out";
}
if ( $item->{wthdrawn}) {
$status = "Withdrawn";
if ($item->{damaged}) {
$status = "Damaged";
}
+ if ($transfertwhen ne '') {
+ $status = 'In transit';
+ }
} else {
$status = "available";
}
- $xml.="<item><homebranch>".$branches->{$item->{homebranch}}->{'branchname'}."</homebranch>"."<status>$status</status></item>";
+ $xml.="<item><homebranch>".$branches->{$item->{homebranch}}->{'branchname'}."</homebranch>".
+ "<status>$status</status>".
+ "<itemcallnumber>".$item->{'itemcallnumber'}."</itemcallnumber></item>";
+
}
return "<items xmlns='http://www.koha.org/items'>".$xml."</items>";
}