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 104-136 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); Link Here
104
# $dewey=~ s/\.$//;
103
# $dewey=~ s/\.$//;
105
# $data->{'dewey'}=$dewey;
104
# $data->{'dewey'}=$dewey;
106
105
107
my $fw = GetFrameworkCode($biblionumber);
108
my @all_items= GetItemsInfo($biblionumber);
109
my @items;
110
my $patron = Koha::Patrons->find( $loggedinuser );
111
for my $itm (@all_items) {
112
    push @items, $itm unless ( $itm->{itemlost} && 
113
                               $patron->category->hidelostitems &&
114
                               !$showallitems && 
115
                               ($itemnumber != $itm->{itemnumber}));
116
}
117
118
my $biblio = Koha::Biblios->find( $biblionumber );
106
my $biblio = Koha::Biblios->find( $biblionumber );
119
my $record = $biblio ? $biblio->metadata->record : undef;
107
my $record = $biblio ? $biblio->metadata->record : undef;
120
108
121
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
109
output_and_exit( $query, $cookie, $template, 'unknown_biblio')
122
    unless $biblio && $record;
110
    unless $biblio && $record;
123
111
112
my $fw = GetFrameworkCode($biblionumber);
113
my $all_items = $biblio->items(
114
    {},
115
    {
116
        # FIXME A different order is expected if at least one items.serial is true
117
        order_by => [
118
            'homebranch.branchname',
119
            'me.enumchron',
120
            \"LDAP( me.copynumber, 8, '0' )",
121
            -asc => 'me.dateacessioned'
122
        ],
123
        join => ['homebranch']
124
    }
125
);
126
my @items;
127
my $patron = Koha::Patrons->find( $loggedinuser );
128
while ( my $item = $all_items->next ) {
129
    push @items, $item
130
      unless $item->itemlost
131
      && $patron->category->hidelostitems
132
      && !$showallitems;
133
}
134
124
my $hostrecords;
135
my $hostrecords;
125
# adding items linked via host biblios
136
my $hostitems = $biblio->host_items;
126
my @hostitems = GetHostItemsInfo($record);
137
if ( $hostitems->count ) {
127
if (@hostitems){
138
    $hostrecords = 1;
128
        $hostrecords =1;
139
    push @items, $hostitems->as_list;
129
        push (@items,@hostitems);
130
}
140
}
131
141
132
my $totalcount=@all_items;
142
my $totalcount = $all_items->count;
133
my $showncount=@items;
143
my $showncount = scalar @items;
134
my $hiddencount = $totalcount - $showncount;
144
my $hiddencount = $totalcount - $showncount;
135
$data->{'count'}=$totalcount;
145
$data->{'count'}=$totalcount;
136
$data->{'showncount'}=$showncount;
146
$data->{'showncount'}=$showncount;
Lines 149-201 foreach ( keys %{$data} ) { Link Here
149
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
159
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
150
}
160
}
151
161
152
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
162
my @item_data;
153
foreach my $item (@items){
163
foreach my $item (@items){
154
    $item->{object} = Koha::Items->find( $item->{itemnumber} );
164
155
    $item->{'collection'}              = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} };
165
    my $item_info = $item->unblessed;
156
    $item->{'itype'}                   = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} };
166
    $item_info->{object} = $item;
157
    $item->{'replacementprice'}        = $item->{'replacementprice'};
167
    $item_info->{itemtype} = $itemtypes->{$item->effective_itemtype};
158
    if ( defined $item->{'copynumber'} ) {
168
    $item_info->{'ccode'}              = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode };
159
        $item->{'displaycopy'} = 1;
169
    if ( defined $item->copynumber ) {
160
        if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
170
        $item_info->{'displaycopy'} = 1;
161
            $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
171
        if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) {
172
            $item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} }
162
        }
173
        }
163
        else {
174
        else {
164
            $item->{'copyvol'} = $item->{'copynumber'};
175
            $item_info->{'copyvol'} = $item_info->{'copynumber'};
165
        }
176
        }
166
    }
177
    }
167
178
168
    # item has a host number if its biblio number does not match the current bib
179
    # item has a host number if its biblio number does not match the current bib
169
    if ($item->{biblionumber} ne $biblionumber){
180
    if ($item->biblionumber ne $biblionumber){
170
        $item->{hostbiblionumber} = $item->{biblionumber};
181
        $item_info->{hostbiblionumber} = $item->{biblionumber};
171
        $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
182
        $item_info->{hosttitle} = $item->biblio->title;
172
    }
183
    }
173
184
185
    # FIXME The acquisition code below could be improved using methods from Koha:: objects
174
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
186
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
175
    $item->{'ordernumber'}             = $order->{'ordernumber'};
187
    $item_info->{'basketno'}                = $order->{'basketno'};
176
    $item->{'basketno'}                = $order->{'basketno'};
188
    $item_info->{'orderdate'}               = $order->{'entrydate'};
177
    $item->{'orderdate'}               = $order->{'entrydate'};
189
    if ($item_info->{'basketno'}){
178
    if ($item->{'basketno'}){
190
        my $basket = GetBasket($item_info->{'basketno'});
179
	    my $basket = GetBasket($item->{'basketno'});
180
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
191
        my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
181
        $item->{'vendor'} = $bookseller->name;
192
        $item_info->{'vendor'} = $bookseller->name;
182
    }
193
    }
183
    $item->{'invoiceid'}               = $order->{'invoiceid'};
194
    $item_info->{'invoiceid'}               = $order->{'invoiceid'};
184
    if($item->{invoiceid}) {
195
    if($item_info->{invoiceid}) {
185
        my $invoice = GetInvoice($item->{invoiceid});
196
        my $invoice = GetInvoice($item_info->{invoiceid});
186
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
197
        $item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
187
    }
198
    }
188
    $item->{'datereceived'}            = $order->{'datereceived'};
199
    $item_info->{'datereceived'}            = $order->{'datereceived'};
189
200
190
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) {
201
    if (   $item->notforloan
191
        $item->{status_advisory} = 1;
202
        || $item->itemtype->notforloan
203
        || $item->itemlost
204
        || $item->damaged
205
        || $item->withdrawn )
206
    {
207
        $item_info->{status_advisory} = 1;
192
    }
208
    }
193
209
194
    # Add paidfor info
210
    # Add paidfor info
195
    if ( $item->{itemlost} ) {
211
    if ( $item->itemlost ) {
196
        my $accountlines = Koha::Account::Lines->search(
212
        my $accountlines = Koha::Account::Lines->search(
197
            {
213
            {
198
                itemnumber        => $item->{itemnumber},
214
                itemnumber        => $item->itemnumber,
199
                debit_type_code   => 'LOST',
215
                debit_type_code   => 'LOST',
200
                status            => [ undef, { '<>' => 'RETURNED' } ],
216
                status            => [ undef, { '<>' => 'RETURNED' } ],
201
                amountoutstanding => 0
217
                amountoutstanding => 0
Lines 219-225 foreach my $item (@items){ Link Here
219
            if ($payment_offsets->count) {
235
            if ($payment_offsets->count) {
220
                my $patron = $accountline->patron;
236
                my $patron = $accountline->patron;
221
                my $payment_offset = $payment_offsets->next;
237
                my $payment_offset = $payment_offsets->next;
222
                $item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
238
                $item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on };
223
            }
239
            }
224
        }
240
        }
225
    }
241
    }
Lines 227-246 foreach my $item (@items){ Link Here
227
    if (C4::Context->preference("IndependentBranches")) {
243
    if (C4::Context->preference("IndependentBranches")) {
228
        #verifying rights
244
        #verifying rights
229
        my $userenv = C4::Context->userenv();
245
        my $userenv = C4::Context->userenv();
230
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
246
        unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) {
231
                $item->{'nomod'}=1;
247
                $item_info->{'nomod'}=1;
232
        }
248
        }
233
    }
249
    }
234
    if ($item->{'datedue'}) {
250
    push @item_data, $item_info;
235
        $item->{'issue'}= 1;
236
    } else {
237
        $item->{'issue'}= 0;
238
    }
239
240
    if ( $item->{'borrowernumber'} ) {
241
        my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} );
242
        $item->{patron} = $curr_borrower;
243
    }
244
}
251
}
245
252
246
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
253
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
Lines 295-301 $template->param( Link Here
295
);
302
);
296
303
297
$template->param(
304
$template->param(
298
    ITEM_DATA           => \@items,
305
    ITEM_DATA           => \@item_data,
299
    moredetailview      => 1,
306
    moredetailview      => 1,
300
    loggedinuser        => $loggedinuser,
307
    loggedinuser        => $loggedinuser,
301
    biblionumber        => $biblionumber,
308
    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>Statuses [% IF ( ITEM_DAT.status_advisory ) %](
116
           <div class="listgroup"><h4>Statuses [% 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 %]
120
                    [% ELSE %]
121
                        <span>Not for loan</span>
122
                    [% END %]
123
                [% END %]
113
                [% IF ( ITEM_DAT.itemlost ) %]Lost[% END %]
124
                [% IF ( ITEM_DAT.itemlost ) %]Lost[% END %]
114
                [% IF ( ITEM_DAT.damaged ) %]Damaged[% END %]
125
                [% IF ( ITEM_DAT.damaged ) %]Damaged[% END %]
115
                [% IF ( ITEM_DAT.withdrawn ) %]Withdrawn[% END %]
126
                [% IF ( ITEM_DAT.withdrawn ) %]Withdrawn[% 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 ) %]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 %]
134
            [% IF ( checkout ) %]Checked out to
124
                [% IF ( ITEM_DAT.lastreneweddate ) %]
135
                [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %]
125
                    Last renewed [% ITEM_DAT.lastreneweddate | $KohaDates %],
136
                [% IF ( checkout.lastreneweddate ) %]
137
                    Last renewed [% checkout.lastreneweddate | $KohaDates %],
126
                [% END %]
138
                [% END %]
127
                [% IF ( ITEM_DAT.datedue ) %]
139
                [% IF ( checkout.date_due ) %]
128
                    Due back on [% ITEM_DAT.datedue | $KohaDates %]
140
                    Due back on [% ITEM_DAT.date_due | $KohaDates %]
129
                [% ELSE %]
141
                [% ELSE %]
130
                    Not checked out
142
                    Not checked out
131
                [% END %]
143
                [% END %]
132
- 

Return to bug 27272