Commit c4bf4f2c authored by Petter Goksøyr Åsen's avatar Petter Goksøyr Åsen Committed by Petter Goksøyr Åsen
Browse files

DEICH-5887 consider co-branch as homebranch for items viewed on deichman.no

parent 7d55a25d
......@@ -131,77 +131,82 @@ sub GetExpanded {
my @items;
while (my $item = $sth->fetchrow_hashref() ) {
my $it = Deichman::Item->new();
$it->{item} = $item;
$it->Deichman::Spore::DB::GetLocation();
$it->Deichman::Spore::DB::CalculateDestination();
$it->Deichman::Spore::DB::GetLocationMeta($it->{destination}->{dest});
$it->Deichman::Spore::DB::GetLocationPoi($it->{destination}->{dest});
# DEICH-5814 replace homebranch with co branch if present
if (my $co = $it->{location}->{co}) {
$it->{item}->{homebranch} = substr($co, 0, index($co, "."));
}
# we assume item is available, countable and reservable by default
$item->{public_status} = "Ledig";
$item->{countable} = 1;
$item->{reservable} = 1;
# we assume item is available, countable and reservable by def$it->ault
$it->{item}->{public_status} = "Ledig";
$it->{item}->{countable} = 1;
$it->{item}->{reservable} = 1;
if ($item->{intransfer} || $item->{holdingbranch} ne $item->{homebranch}) {
$item->{public_status} = "Utlånt";
if ($it->{item}->{intransfer} || $it->{item}->{holdingbranch} ne $it->{item}->{homebranch}) {
$it->{item}->{public_status} = "Utlånt";
}
# Non reservable by item type or holding branch
if ( $item->{itype} =~ m/^(PERIODIKA|DAGSLAAN|UKESLAAN|10DLAAN|TOUKESLAAN)$/) {
$item->{reservable} = 0;
if ($it->{item}->{itype} =~ m/^(PERIODIKA|DAGSLAAN|UKESLAAN|10DLAAN|TOUKESLAAN)$/) {
$it->{item}->{reservable} = 0;
}
if (not $askingForKLBorrower and ($item->{itype} eq "SETT" or $item->{homebranch} eq 'hsko')) {
$item->{reservable} = 0;
if (not $askingForKLBorrower and ($it->{item}->{itype} eq "SETT" or $it->{item}->{homebranch} eq 'hsko')) {
$it->{item}->{reservable} = 0;
}
# On loan
if ($item->{onloan} || $item->{onhold}) {
$item->{public_status} = "Utlånt";
if ($it->{item}->{onloan} || $it->{item}->{onhold}) {
$it->{item}->{public_status} = "Utlånt";
}
my $notloan = $item->{notforloan};
my $notloan = $it->{item}->{notforloan};
if ($notloan) {
# -2 Bestilt
# -1 Til klargjøring
# 2 Til reparasjon
# 4 Til retting
if ($notloan == -2 || $notloan == -1 || $notloan == 2 || $notloan == 4 ) {
$item->{public_status} = "Utlånt";
$it->{item}->{public_status} = "Utlånt";
} elsif ($notloan == 8) { # Ikke til utlån
$item->{public_status} = "Ikke til hjemlån";
$item->{reservable} = 0;
if ($item->{onloan}) {
$item->{public_status} = "Ikke til hjemlån (utlånt)"
$it->{item}->{public_status} = "Ikke til hjemlån";
$it->{item}->{reservable} = 0;
if ($it->{item}->{onloan}) {
$it->{item}->{public_status} = "Ikke til hjemlån (utlånt)"
}
} elsif ($notloan == 1) { # Til internt bruk
$item->{public_status} = "Utilgjengelig";
$item->{countable} = 0;
$item->{reservable} = 0;
$it->{item}->{public_status} = "Utilgjengelig";
$it->{item}->{countable} = 0;
$it->{item}->{reservable} = 0;
}
}
# Not reservable, countable or available
if ($item->{itemlost} || $item->{damaged}) {
$item->{public_status} = "Utilgjengelig";
$item->{countable} = 0;
$item->{reservable} = 0;
if ($it->{item}->{itemlost} || $it->{item}->{damaged}) {
$it->{item}->{public_status} = "Utilgjengelig";
$it->{item}->{countable} = 0;
$it->{item}->{reservable} = 0;
}
# DEICH-5481
# Following lost-statuses are reservable and countable:
# 7 På hentehylle - avbestilt
# 9 På hentehylle - utgått
if ($item->{itemlost} and ($item->{itemlost} == 7 || $item->{itemlost} == 9)) {
$item->{countable} = 1;
$item->{reservable} = 1;
if ($it->{item}->{itemlost} and ($it->{item}->{itemlost} == 7 || $it->{item}->{itemlost} == 9)) {
$it->{item}->{countable} = 1;
$it->{item}->{reservable} = 1;
}
# TODO: Remove $item->{status} when no longer needed
$item->{status} = $item->{public_status};
my $fullitem = Deichman::Item->new();
$fullitem->{item} = $item;
$fullitem->Deichman::Spore::DB::GetLocation();
$fullitem->Deichman::Spore::DB::CalculateDestination();
$fullitem->Deichman::Spore::DB::GetLocationMeta($fullitem->{destination}->{dest});
$fullitem->Deichman::Spore::DB::GetLocationPoi($fullitem->{destination}->{dest});
my $outitem = $fullitem->{item};
$outitem->{newLocation} = $fullitem->{location};
$outitem->{newLocation}->{destination} = $fullitem->{destination};
# TODO: Remove $it->{item}->{status} when no longer needed
$it->{item}->{status} = $it->{item}->{public_status};
my $outitem = $it->{item};
$outitem->{newLocation} = $it->{location};
$outitem->{newLocation}->{destination} = $it->{destination};
push @items, $outitem;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment