View | Details | Raw Unified | Return to bug 14962
Collapse All | Expand All

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

Return to bug 14962