|
Lines 66-71
binmode STDOUT, ":encoding(UTF-8)";
Link Here
|
| 66 |
print $input->header( -type => 'application/json', -charset => 'UTF-8' ); |
66 |
print $input->header( -type => 'application/json', -charset => 'UTF-8' ); |
| 67 |
|
67 |
|
| 68 |
my @parameters; |
68 |
my @parameters; |
|
|
69 |
my $use_display_module = C4::Context->preference('UseDisplayModule'); |
| 70 |
|
| 69 |
my $sql = ' |
71 |
my $sql = ' |
| 70 |
SELECT |
72 |
SELECT |
| 71 |
issues.issue_id, |
73 |
issues.issue_id, |
|
Lines 119-126
my $sql = '
Link Here
|
| 119 |
return_claims.id AS return_claim_id, |
121 |
return_claims.id AS return_claim_id, |
| 120 |
return_claims.notes AS return_claim_notes, |
122 |
return_claims.notes AS return_claim_notes, |
| 121 |
return_claims.created_on AS return_claim_created_on, |
123 |
return_claims.created_on AS return_claim_created_on, |
| 122 |
return_claims.updated_on AS return_claim_updated_on |
124 |
return_claims.updated_on AS return_claim_updated_on'; |
|
|
125 |
|
| 126 |
if ($use_display_module) { |
| 127 |
$sql .= ', |
| 128 |
COALESCE(active_display.display_location, items.location) AS effective_location, |
| 129 |
active_display.display_name, |
| 130 |
active_display.display_location AS raw_display_location'; |
| 131 |
} else { |
| 132 |
$sql .= ', |
| 133 |
items.location AS effective_location, |
| 134 |
NULL AS display_name, |
| 135 |
NULL AS raw_display_location'; |
| 136 |
} |
| 123 |
|
137 |
|
|
|
138 |
$sql .= ' |
| 124 |
FROM issues |
139 |
FROM issues |
| 125 |
LEFT JOIN items USING ( itemnumber ) |
140 |
LEFT JOIN items USING ( itemnumber ) |
| 126 |
LEFT JOIN biblio USING ( biblionumber ) |
141 |
LEFT JOIN biblio USING ( biblionumber ) |
|
Lines 128-134
my $sql = '
Link Here
|
| 128 |
LEFT JOIN borrowers USING ( borrowernumber ) |
143 |
LEFT JOIN borrowers USING ( borrowernumber ) |
| 129 |
LEFT JOIN branches ON ( issues.branchcode = branches.branchcode ) |
144 |
LEFT JOIN branches ON ( issues.branchcode = branches.branchcode ) |
| 130 |
LEFT JOIN branches branches2 ON ( items.homebranch = branches2.branchcode ) |
145 |
LEFT JOIN branches branches2 ON ( items.homebranch = branches2.branchcode ) |
| 131 |
LEFT JOIN return_claims USING ( issue_id ) |
146 |
LEFT JOIN return_claims USING ( issue_id )'; |
|
|
147 |
|
| 148 |
if ($use_display_module) { |
| 149 |
$sql .= ' |
| 150 |
LEFT JOIN ( |
| 151 |
SELECT |
| 152 |
di.itemnumber, |
| 153 |
d.display_location, |
| 154 |
d.display_name, |
| 155 |
ROW_NUMBER() OVER (PARTITION BY di.itemnumber ORDER BY di.date_added DESC) as rn |
| 156 |
FROM display_items di |
| 157 |
JOIN displays d ON di.display_id = d.display_id |
| 158 |
WHERE d.enabled = 1 |
| 159 |
AND (d.start_date IS NULL OR d.start_date <= CURDATE()) |
| 160 |
AND (d.end_date IS NULL OR d.end_date >= CURDATE()) |
| 161 |
AND (di.date_remove IS NULL OR di.date_remove >= CURDATE()) |
| 162 |
) active_display ON items.itemnumber = active_display.itemnumber AND active_display.rn = 1'; |
| 163 |
} |
| 164 |
|
| 165 |
$sql .= ' |
| 132 |
WHERE issues.borrowernumber |
166 |
WHERE issues.borrowernumber |
| 133 |
'; |
167 |
'; |
| 134 |
|
168 |
|
|
Lines 184-193
while ( my $c = $sth->fetchrow_hashref() ) {
Link Here
|
| 184 |
$type_for_stat = $item_level_itypes ? $itemtype : $recordtype; |
218 |
$type_for_stat = $item_level_itypes ? $itemtype : $recordtype; |
| 185 |
|
219 |
|
| 186 |
my $location; |
220 |
my $location; |
| 187 |
if ( $c->{location} ) { |
221 |
if ( $c->{display_name} && !$c->{raw_display_location} ) { |
|
|
222 |
# Item is on display with no specific display location |
| 223 |
$location = "DISPLAY: " . $c->{display_name}; |
| 224 |
} else { |
| 225 |
# Use AuthorisedValues to get effective location description |
| 188 |
my $av = Koha::AuthorisedValues->get_description_by_koha_field( |
226 |
my $av = Koha::AuthorisedValues->get_description_by_koha_field( |
| 189 |
{ kohafield => 'items.location', authorised_value => $c->{location} } ); |
227 |
{ kohafield => 'items.location', authorised_value => $c->{effective_location} } |
| 190 |
$location = $av->{lib} ? $av->{lib} : ''; |
228 |
); |
|
|
229 |
$location = $av->{lib} || ''; |
| 191 |
} |
230 |
} |
| 192 |
my $collection; |
231 |
my $collection; |
| 193 |
if ( $c->{collection} ) { |
232 |
if ( $c->{collection} ) { |
|
Lines 219-227
while ( my $c = $sth->fetchrow_hashref() ) {
Link Here
|
| 219 |
|
258 |
|
| 220 |
my $recalled = 0; |
259 |
my $recalled = 0; |
| 221 |
if ( C4::Context->preference('UseRecalls') ) { |
260 |
if ( C4::Context->preference('UseRecalls') ) { |
| 222 |
my $item = Koha::Items->find( $c->{itemnumber} ); |
261 |
my $item = Koha::Items->find( $c->{itemnumber} ); |
| 223 |
my $recall = undef; |
262 |
my $recall = undef; |
| 224 |
$recall = $item->check_recalls if $item->can_be_waiting_recall; |
263 |
$recall = $item->check_recalls if $item && $item->can_be_waiting_recall; |
| 225 |
if ( defined $recall ) { |
264 |
if ( defined $recall ) { |
| 226 |
if ( $recall->item_level ) { |
265 |
if ( $recall->item_level ) { |
| 227 |
if ( $recall->item_id == $c->{itemnumber} ) { |
266 |
if ( $recall->item_id == $c->{itemnumber} ) { |
| 228 |
- |
|
|