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

(-)a/catalogue/moredetail.pl (-61 / +57 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->search_ordered;
112
113
my @items;
114
my $patron = Koha::Patrons->find( $loggedinuser );
115
while ( my $item = $all_items->next ) {
116
    push @items, $item
117
      unless $item->itemlost
118
      && $patron->category->hidelostitems
119
      && !$showallitems;
120
}
121
122
my $hostrecords;
122
my $hostrecords;
123
# adding items linked via host biblios
123
my $hostitems = $biblio->host_items;
124
my @hostitems = GetHostItemsInfo($record);
124
if ( $hostitems->count ) {
125
if (@hostitems){
125
    $hostrecords = 1;
126
        $hostrecords =1;
126
    push @items, $hostitems->as_list;
127
        push (@items,@hostitems);
128
}
127
}
129
128
130
my $totalcount=@all_items;
129
my $totalcount = $all_items->count;
131
my $showncount=@items;
130
my $showncount = scalar @items;
132
my $hiddencount = $totalcount - $showncount;
131
my $hiddencount = $totalcount - $showncount;
133
$data->{'count'}=$totalcount;
132
$data->{'count'}=$totalcount;
134
$data->{'showncount'}=$showncount;
133
$data->{'showncount'}=$showncount;
Lines 147-199 foreach ( keys %{$data} ) { Link Here
147
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
146
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
148
}
147
}
149
148
150
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
149
my @item_data;
151
foreach my $item (@items){
150
foreach my $item (@items){
152
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
151
153
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
152
    my $item_info = $item->unblessed;
154
    $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
153
    $item_info->{object} = $item;
155
    $item->{'replacementprice'}        = $item->{'replacementprice'};
154
    $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype};
156
    if ( defined $item->{'copynumber'} ) {
155
    $item_info->{'ccode'}              = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode };
157
        $item->{'displaycopy'} = 1;
156
    if ( defined $item->copynumber ) {
158
        if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
157
        $item_info->{'displaycopy'} = 1;
159
            $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
158
        if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) {
159
            $item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} }
160
        }
160
        }
161
        else {
161
        else {
162
            $item->{'copyvol'} = $item->{'copynumber'};
162
            $item_info->{'copyvol'} = $item_info->{'copynumber'};
163
        }
163
        }
164
    }
164
    }
165
165
166
    # item has a host number if its biblio number does not match the current bib
166
    # item has a host number if its biblio number does not match the current bib
167
    if ($item->{biblionumber} ne $biblionumber){
167
    if ($item->biblionumber ne $biblionumber){
168
        $item->{hostbiblionumber} = $item->{biblionumber};
168
        $item_info->{hostbiblionumber} = $item->{biblionumber};
169
        $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
169
        $item_info->{hosttitle} = $item->biblio->title;
170
    }
170
    }
171
171
172
    # FIXME The acquisition code below could be improved using methods from Koha:: objects
172
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
173
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
173
    $item->{'ordernumber'}             = $order->{'ordernumber'};
174
    $item_info->{'basketno'}                = $order->{'basketno'};
174
    $item->{'basketno'}                = $order->{'basketno'};
175
    $item_info->{'orderdate'}               = $order->{'entrydate'};
175
    $item->{'orderdate'}               = $order->{'entrydate'};
176
    if ($item_info->{'basketno'}){
176
    if ($item->{'basketno'}){
177
        my $basket = GetBasket($item_info->{'basketno'});
177
	    my $basket = GetBasket($item->{'basketno'});
178
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
178
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
179
        $item->{'vendor'} = $bookseller->name;
179
        $item_info->{'vendor'} = $bookseller->name;
180
    }
180
    }
181
    $item->{'invoiceid'}               = $order->{'invoiceid'};
181
    $item_info->{'invoiceid'}               = $order->{'invoiceid'};
182
    if($item->{invoiceid}) {
182
    if($item_info->{invoiceid}) {
183
        my $invoice = GetInvoice($item->{invoiceid});
183
        my $invoice = GetInvoice($item_info->{invoiceid});
184
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
184
        $item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
185
    }
185
    }
186
    $item->{'datereceived'}            = $order->{'datereceived'};
186
    $item_info->{'datereceived'}            = $order->{'datereceived'};
187
187
188
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) {
188
    if (   $item->notforloan
189
        $item->{status_advisory} = 1;
189
        || $item->itemtype->notforloan
190
        || $item->itemlost
191
        || $item->damaged
192
        || $item->withdrawn )
193
    {
194
        $item_info->{status_advisory} = 1;
190
    }
195
    }
191
196
192
    # Add paidfor info
197
    # Add paidfor info
193
    if ( $item->{itemlost} ) {
198
    if ( $item->itemlost ) {
194
        my $accountlines = Koha::Account::Lines->search(
199
        my $accountlines = Koha::Account::Lines->search(
195
            {
200
            {
196
                itemnumber        => $item->{itemnumber},
201
                itemnumber        => $item->itemnumber,
197
                debit_type_code   => 'LOST',
202
                debit_type_code   => 'LOST',
198
                status            => [ undef, { '<>' => 'RETURNED' } ],
203
                status            => [ undef, { '<>' => 'RETURNED' } ],
199
                amountoutstanding => 0
204
                amountoutstanding => 0
Lines 217-223 foreach my $item (@items){ Link Here
217
            if ($payment_offsets->count) {
222
            if ($payment_offsets->count) {
218
                my $patron = $accountline->patron;
223
                my $patron = $accountline->patron;
219
                my $payment_offset = $payment_offsets->next;
224
                my $payment_offset = $payment_offsets->next;
220
                $item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
225
                $item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
221
            }
226
            }
222
        }
227
        }
223
    }
228
    }
Lines 225-244 foreach my $item (@items){ Link Here
225
    if (C4::Context->preference("IndependentBranches")) {
230
    if (C4::Context->preference("IndependentBranches")) {
226
        #verifying rights
231
        #verifying rights
227
        my $userenv = C4::Context->userenv();
232
        my $userenv = C4::Context->userenv();
228
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
233
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) {
229
                $item->{'nomod'}=1;
234
                $item_info->{'nomod'}=1;
230
        }
235
        }
231
    }
236
    }
232
    if ($item->{'datedue'}) {
237
    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
}
238
}
243
239
244
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
240
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
Lines 293-299 $template->param( Link Here
293
);
289
);
294
290
295
$template->param(
291
$template->param(
296
    ITEM_DATA           => \@items,
292
    ITEM_DATA           => \@item_data,
297
    moredetailview      => 1,
293
    moredetailview      => 1,
298
    loggedinuser        => $loggedinuser,
294
    loggedinuser        => $loggedinuser,
299
    biblionumber        => $biblionumber,
295
    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 31315