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

(-)a/catalogue/moredetail.pl (-61 / +68 lines)
Lines 24-30 use C4::Koha qw( GetAuthorisedValues ); Link Here
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use HTML::Entities;
25
use HTML::Entities;
26
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
26
use C4::Biblio qw( GetBiblioData GetFrameworkCode );
27
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
28
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice );
27
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice );
29
use C4::Output qw( output_and_exit output_html_with_http_headers );
28
use C4::Output qw( output_and_exit output_html_with_http_headers );
30
use C4::Auth qw( get_template_and_user );
29
use C4::Auth qw( get_template_and_user );
Lines 102-134 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); Link Here
102
# $dewey=~ s/\.$//;
101
# $dewey=~ s/\.$//;
103
# $data->{'dewey'}=$dewey;
102
# $data->{'dewey'}=$dewey;
104
103
105
my $fw = GetFrameworkCode($biblionumber);
106
my @all_items= GetItemsInfo($biblionumber);
107
my @items;
108
my $patron = Koha::Patrons->find( $loggedinuser );
109
for my $itm (@all_items) {
110
    push @items, $itm unless ( $itm->{itemlost} && 
111
                               $patron->category->hidelostitems &&
112
                               !$showallitems && 
113
                               ($itemnumber != $itm->{itemnumber}));
114
}
115
116
my $biblio = Koha::Biblios->find( $biblionumber );
104
my $biblio = Koha::Biblios->find( $biblionumber );
117
my $record = $biblio ? $biblio->metadata->record : undef;
105
my $record = $biblio ? $biblio->metadata->record : undef;
118
106
119
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
107
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
120
    unless $biblio && $record;
108
    unless $biblio && $record;
121
109
110
my $fw = GetFrameworkCode($biblionumber);
111
my $all_items = $biblio->items(
112
    {},
113
    {
114
        # FIXME A different order is expected if at least one items.serial is true
115
        order_by => [
116
            'homebranch.branchname',
117
            'me.enumchron',
118
            \"LDAP( me.copynumber, 8, '0' )",
119
            -asc => 'me.dateacessioned'
120
        ],
121
        join => ['homebranch']
122
    }
123
);
124
my @items;
125
my $patron = Koha::Patrons->find( $loggedinuser );
126
while ( my $item = $all_items->next ) {
127
    push @items, $item
128
      unless $item->itemlost
129
      && $patron->category->hidelostitems
130
      && !$showallitems;
131
}
132
122
my $hostrecords;
133
my $hostrecords;
123
# adding items linked via host biblios
134
my $hostitems = $biblio->host_items;
124
my @hostitems = GetHostItemsInfo($record);
135
if ( $hostitems->count ) {
125
if (@hostitems){
136
    $hostrecords = 1;
126
        $hostrecords =1;
137
    push @items, $hostitems->as_list;
127
        push (@items,@hostitems);
128
}
138
}
129
139
130
my $totalcount=@all_items;
140
my $totalcount = $all_items->count;
131
my $showncount=@items;
141
my $showncount = scalar @items;
132
my $hiddencount = $totalcount - $showncount;
142
my $hiddencount = $totalcount - $showncount;
133
$data->{'count'}=$totalcount;
143
$data->{'count'}=$totalcount;
134
$data->{'showncount'}=$showncount;
144
$data->{'showncount'}=$showncount;
Lines 147-199 foreach ( keys %{$data} ) { Link Here
147
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
157
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
148
}
158
}
149
159
150
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
160
my @item_data;
151
foreach my $item (@items){
161
foreach my $item (@items){
152
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
162
153
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
163
    my $item_info = $item->unblessed;
154
    $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
164
    $item_info->{object} = $item;
155
    $item->{'replacementprice'}        = $item->{'replacementprice'};
165
    $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype};
156
    if ( defined $item->{'copynumber'} ) {
166
    $item_info->{'ccode'}              = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode };
157
        $item->{'displaycopy'} = 1;
167
    if ( defined $item->copynumber ) {
158
        if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
168
        $item_info->{'displaycopy'} = 1;
159
            $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
169
        if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) {
170
            $item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} }
160
        }
171
        }
161
        else {
172
        else {
162
            $item->{'copyvol'} = $item->{'copynumber'};
173
            $item_info->{'copyvol'} = $item_info->{'copynumber'};
163
        }
174
        }
164
    }
175
    }
165
176
166
    # item has a host number if its biblio number does not match the current bib
177
    # item has a host number if its biblio number does not match the current bib
167
    if ($item->{biblionumber} ne $biblionumber){
178
    if ($item->biblionumber ne $biblionumber){
168
        $item->{hostbiblionumber} = $item->{biblionumber};
179
        $item_info->{hostbiblionumber} = $item->{biblionumber};
169
        $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
180
        $item_info->{hosttitle} = $item->biblio->title;
170
    }
181
    }
171
182
183
    # FIXME The acquisition code below could be improved using methods from Koha:: objects
172
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
184
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
173
    $item->{'ordernumber'}             = $order->{'ordernumber'};
185
    $item_info->{'basketno'}                = $order->{'basketno'};
174
    $item->{'basketno'}                = $order->{'basketno'};
186
    $item_info->{'orderdate'}               = $order->{'entrydate'};
175
    $item->{'orderdate'}               = $order->{'entrydate'};
187
    if ($item_info->{'basketno'}){
176
    if ($item->{'basketno'}){
188
        my $basket = GetBasket($item_info->{'basketno'});
177
	    my $basket = GetBasket($item->{'basketno'});
178
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
189
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
179
        $item->{'vendor'} = $bookseller->name;
190
        $item_info->{'vendor'} = $bookseller->name;
180
    }
191
    }
181
    $item->{'invoiceid'}               = $order->{'invoiceid'};
192
    $item_info->{'invoiceid'}               = $order->{'invoiceid'};
182
    if($item->{invoiceid}) {
193
    if($item_info->{invoiceid}) {
183
        my $invoice = GetInvoice($item->{invoiceid});
194
        my $invoice = GetInvoice($item_info->{invoiceid});
184
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
195
        $item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
185
    }
196
    }
186
    $item->{'datereceived'}            = $order->{'datereceived'};
197
    $item_info->{'datereceived'}            = $order->{'datereceived'};
187
198
188
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) {
199
    if (   $item->notforloan
189
        $item->{status_advisory} = 1;
200
        || $item->itemtype->notforloan
201
        || $item->itemlost
202
        || $item->damaged
203
        || $item->withdrawn )
204
    {
205
        $item_info->{status_advisory} = 1;
190
    }
206
    }
191
207
192
    # Add paidfor info
208
    # Add paidfor info
193
    if ( $item->{itemlost} ) {
209
    if ( $item->itemlost ) {
194
        my $accountlines = Koha::Account::Lines->search(
210
        my $accountlines = Koha::Account::Lines->search(
195
            {
211
            {
196
                itemnumber        => $item->{itemnumber},
212
                itemnumber        => $item->itemnumber,
197
                debit_type_code   => 'LOST',
213
                debit_type_code   => 'LOST',
198
                status            => [ undef, { '<>' => 'RETURNED' } ],
214
                status            => [ undef, { '<>' => 'RETURNED' } ],
199
                amountoutstanding => 0
215
                amountoutstanding => 0
Lines 217-223 foreach my $item (@items){ Link Here
217
            if ($payment_offsets->count) {
233
            if ($payment_offsets->count) {
218
                my $patron = $accountline->patron;
234
                my $patron = $accountline->patron;
219
                my $payment_offset = $payment_offsets->next;
235
                my $payment_offset = $payment_offsets->next;
220
                $item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
236
                $item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
221
            }
237
            }
222
        }
238
        }
223
    }
239
    }
Lines 225-244 foreach my $item (@items){ Link Here
225
    if (C4::Context->preference("IndependentBranches")) {
241
    if (C4::Context->preference("IndependentBranches")) {
226
        #verifying rights
242
        #verifying rights
227
        my $userenv = C4::Context->userenv();
243
        my $userenv = C4::Context->userenv();
228
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
244
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) {
229
                $item->{'nomod'}=1;
245
                $item_info->{'nomod'}=1;
230
        }
246
        }
231
    }
247
    }
232
    if ($item->{'datedue'}) {
248
    push @item_data, $item_info;
233
        $item->{'issue'}= 1;
234
    } else {
235
        $item->{'issue'}= 0;
236
    }
237
238
    if ( $item->{'borrowernumber'} ) {
239
        my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} );
240
        $item->{patron} = $curr_borrower;
241
    }
242
}
249
}
243
250
244
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
251
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
Lines 293-299 $template->param( Link Here
293
);
300
);
294
301
295
$template->param(
302
$template->param(
296
    ITEM_DATA           => \@items,
303
    ITEM_DATA           => \@item_data,
297
    moredetailview      => 1,
304
    moredetailview      => 1,
298
    loggedinuser        => $loggedinuser,
305
    loggedinuser        => $loggedinuser,
299
    biblionumber        => $biblionumber,
306
    biblionumber        => $biblionumber,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-10 / +21 lines)
Lines 88-95 Link Here
88
    [% END %]
88
    [% END %]
89
89
90
    [% FOREACH ITEM_DAT IN ITEM_DATA %]
90
    [% FOREACH ITEM_DAT IN ITEM_DATA %]
91
        [% SET not_for_loan = 0 %]
92
        [% IF ITEM_DAT.notforloan || ITEM_DAT.itemtype.notforloan %]
93
            [% SET not_for_loan = 1 %]
94
            [% SET not_for_loan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %]
95
        [% END %]
91
        <div class="listgroup">
96
        <div class="listgroup">
92
        <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %]  [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %]</h3>
97
        <h3 id="item[% ITEM_DAT.itemnumber | html %]">Barcode [% ITEM_DAT.barcode | html %]  [% IF not_for_loan %][% not_for_loan_description | html %] [% END %]</h3>
93
98
94
        <h4>Item information [% UNLESS ( ITEM_DAT.nomod ) %]
99
        <h4>Item information [% UNLESS ( ITEM_DAT.nomod ) %]
95
         [% IF ( CAN_user_editcatalogue_edit_items ) %]
100
         [% IF ( CAN_user_editcatalogue_edit_items ) %]
Lines 102-115 Link Here
102
	    [% IF ( item_level_itypes ) %]
107
	    [% IF ( item_level_itypes ) %]
103
            <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %]&nbsp;</li>
108
            <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %]&nbsp;</li>
104
	    [% END %]
109
	    [% END %]
105
            [% IF ( ITEM_DAT.collection ) %]<li><span class="label">Collection:</span> [% ITEM_DAT.collection | html %]</li> [% END %]
110
            [% IF ( ITEM_DAT.ccode) %]<li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li> [% END %]
106
            <li><span class="label">Item callnumber:</span> [% ITEM_DAT.itemcallnumber | html %]&nbsp;</li>
111
            <li><span class="label">Item callnumber:</span> [% ITEM_DAT.itemcallnumber | html %]&nbsp;</li>
107
            [% IF ( ITEM_DAT.displaycopy ) %]<li><span class="label">Copy number:</span> [% ITEM_DAT.copyvol | html %]&nbsp;</li> [% END %]
112
            [% IF ( ITEM_DAT.displaycopy ) %]<li><span class="label">Copy number:</span> [% ITEM_DAT.copyvol | html %]&nbsp;</li> [% END %]
108
            [% IF ( ITEM_DAT.replacementprice ) %]<li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | $Price %]&nbsp;</li> [% END %]
113
            [% IF ( ITEM_DAT.replacementprice ) %]<li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | $Price %]&nbsp;</li> [% END %]
109
	    [% IF ITEM_DAT.materials %]<li><span class="label">Materials specified:</span> [% ITEM_DAT.materials | html %] </li> [% END %]
114
	    [% IF ITEM_DAT.materials %]<li><span class="label">Materials specified:</span> [% ITEM_DAT.materials | html %] </li> [% END %]
110
            </ol></div></div>
115
            </ol></div></div>
111
           <div class="listgroup"><h4><span>Statuses</span> [% IF ( ITEM_DAT.status_advisory ) %](
116
           <div class="listgroup"><h4><span>Statuses</span> [% IF ( ITEM_DAT.status_advisory ) %](
112
                [% IF ( ITEM_DAT.notforloantext ) %][% ITEM_DAT.notforloantext | html %] [% END %]
117
                [% IF ( not_for_loan ) %]
118
                    [% IF not_for_loan_description %]
119
                        [% not_for_loan_description | html %]
120
                    [% ELSE %]
121
                        <span>Not for loan</span>
122
                    [% END %]
123
                [% END %]
113
                [% IF ( ITEM_DAT.itemlost ) %]<span>Lost</span>[% END %]
124
                [% IF ( ITEM_DAT.itemlost ) %]<span>Lost</span>[% END %]
114
                [% IF ( ITEM_DAT.damaged ) %]<span>Damaged</span>[% END %]
125
                [% IF ( ITEM_DAT.damaged ) %]<span>Damaged</span>[% END %]
115
                [% IF ( ITEM_DAT.withdrawn ) %]<span>Withdrawn</span>[% END %]
126
                [% IF ( ITEM_DAT.withdrawn ) %]<span>Withdrawn</span>[% END %]
Lines 119-131 Link Here
119
            <ol class="bibliodetails">
130
            <ol class="bibliodetails">
120
            <li><span class="label">Current library:</span> [% Branches.GetName( ITEM_DAT.holdingbranch ) | html %]&nbsp;</li>
131
            <li><span class="label">Current library:</span> [% Branches.GetName( ITEM_DAT.holdingbranch ) | html %]&nbsp;</li>
121
            <li><span class="label">Checkout status:</span>
132
            <li><span class="label">Checkout status:</span>
122
            [% IF ( ITEM_DAT.issue ) %]<span>Checked out to
133
            [% SET checkout = ITEM_DAT.object.checkout %]
123
                [% INCLUDE 'patron-title.inc' patron => ITEM_DAT.patron hide_patron_infos_if_needed=1 %]</span>
134
            [% IF ( checkout ) %]<span>Checked out to
124
                [% IF ( ITEM_DAT.lastreneweddate ) %]
135
                [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]</span>
125
                    <span>Last renewed [% ITEM_DAT.lastreneweddate | $KohaDates %]</span>,
136
                [% IF ( checkout.lastreneweddate ) %]
137
                    <span>Last renewed [% checkout.lastreneweddate | $KohaDates %]</span>,
126
                [% END %]
138
                [% END %]
127
                [% IF ( ITEM_DAT.datedue ) %]
139
                [% IF ( checkout.date_due ) %]
128
                    <span>Due back on [% ITEM_DAT.datedue | $KohaDates %]</span>
140
                    <span>Due back on [% ITEM_DAT.date_due | $KohaDates %]</span>
129
                [% ELSE %]
141
                [% ELSE %]
130
                    <span>Not checked out</span>
142
                    <span>Not checked out</span>
131
                [% END %]
143
                [% END %]
132
- 

Return to bug 27272