htime => q!
CASE WHEN
copy_has_not_been_home.result
- THEN actor.org_unit_proximity(%d, h.request_lib)
+ THEN actor.org_unit_proximity(%d, acn.owning_lib)
ELSE 999
END
!,
shtime => q!
CASE WHEN
copy_has_not_been_home_even_to_idle.result
- THEN actor.org_unit_proximity(%d, h.request_lib)
+ THEN actor.org_unit_proximity(%d, acn.owning_lib)
ELSE 999
END
!,
)
) AS result
) !, $cp->id, $cp->circ_lib, $cp->circ_lib, $cp->id);
- $joins .= " JOIN copy_has_not_been_home ON (true) ";
+
+ $joins .= q!
+ JOIN copy_has_not_been_home ON (true)
+ JOIN asset.copy acp ON (hm.target_copy = acp.id)
+ JOIN asset.call_number acn ON (acn.id = acp.call_number)
+ !;
}
if ($ctes_needed == 2) {