Bug 32712: Fix OPAC breakage when OPACShowCheckoutName enabled
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / includes / item-status.inc
1 [% USE Branches %]
2 [% USE AuthorisedValues %]
3 [% SET itemavailable = 1 %]
4
5 [%#- This include takes two parameters: an item structure -%]
6 [%#- and an optional loan (issue) structure.  The issue -%]
7 [%#- structure is used by course reserves pages, which do -%]
8 [%#- not use an API to fetch items that populates item.datedue. -%]
9
10 [% UNLESS item.isa('Koha::Item') %]
11     <div>Programming error, item-status.inc must be called with a Koha::Item object.<div>
12     [% STOP %]
13 [% END %]
14
15 [% SET transfer = item.get_transfer %]
16 [% IF transfer AND transfer.in_transit %]
17     [% SET transfertwhen = transfer.datesent %]
18     [% SET transfertfrom = transfer.frombranch %]
19     [% SET transfertto = transfer.tobranch %]
20 [% END %]
21
22 [% SET checkout = item.checkout %]
23 [% SET waiting  = item.holds.waiting.count %]
24 [% IF include_schema_org %]
25     [% IF item.damaged or checkout or item.itemlost or transfertwhen or waiting %]
26         <link property="availability" href="http://schema.org/OutOfStock" />
27     [% ELSIF item.withdrawn %]
28         <link property="availability" href="http://schema.org/Discontinued" />
29     [% ELSIF item.notforloan or item.itemtype.notforloan %]
30         <link property="availability" href="http://schema.org/InStoreOnly" />
31     [% ELSE %]
32         <link property="availability" href="http://schema.org/InStock" />
33     [% END %]
34 [% END %]
35
36 [% IF ( item.itemlost ) %]
37     [% SET itemavailable = 0 %]
38     [% itemlost_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost, opac => 1 ) %]
39     [% IF itemlost_lib %]
40         <span class="item-status lost">[% itemlost_lib | html %]</span>
41     [% ELSE %]
42         <span class="item-status lost">Item lost</span>
43     [% END %]
44 [% END %]
45
46 [% IF checkout %]
47     [% SET checkout_patron = checkout.patron %]
48     [% SET onsite_checkout = checkout.onsite_checkout %]
49
50     [% SET itemavailable = 0 %]
51     [% IF onsite_checkout %]
52         [% IF ( OPACShowCheckoutName ) %]
53             <span class="item-status checkedout">Currently in local use by [% checkout_patron.firstname | html %] [% checkout_patron.surname | html %] [% IF ( checkout_patron.cardnumber ) %]([% checkout_patron.cardnumber | html %])[% END %]</span>
54         [% ELSE %]
55             <span class="item-status checkedout">Currently in local use</span>
56         [% END %]
57     [% ELSE %]
58         [% IF ( OPACShowCheckoutName ) %]
59             <span class="item-status checkedout">Checked out to [% checkout_patron.firstname | html %] [% checkout_patron.surname | html %] [% IF ( checkout_patron.cardnumber ) %]([% checkout_patron.cardnumber | html %])[% END %]</span>
60         [% ELSE %]
61             <span class="item-status checkedout">Checked out</span>
62         [% END %]
63     [% END %]
64     [% IF show_recall_link %]
65         [% IF logged_in_user.borrowernumber != issue.borrowernumber %]
66             <a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>
67         [% END %]
68     [% END %]
69 [% END %]
70
71 [% IF transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
72     [% SET itemavailable = 0 %]
73     <span class="item-status intransit">In transit from [% Branches.GetName( transfertfrom ) | html %]
74     to [% Branches.GetName( transfertto ) | html %] since [% transfertwhen | $KohaDates %]</span>
75 [% END %]
76
77 [% IF waiting OR item.holds.processing.count %]
78     [% SET itemavailable = 0 %]
79     <span class="item-status onhold">On hold</span>
80 [% END %]
81
82 [% IF ( item.withdrawn ) %]
83     [% SET itemavailable = 0 %]
84     [% withdrawn_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn, opac => 1 ) %]
85     [% IF withdrawn_lib %]
86         <span class="item-status withdrawn">[% withdrawn_lib | html %]</span>
87     [% ELSE %]
88         <span class="item-status withdrawn">Item withdrawn</span>
89     [% END %]
90 [% END %]
91
92
93 [% SET restricted_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn, opac => 1 ) %]
94 [% IF item.notforloan %]
95     [% SET itemavailable = 0 %]
96     [% notforloan_lib = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn, opac => 1 ) %]
97     [% IF notforloan_lib %]
98         <span class="item-status notforloan">[% notforloan_lib | html %] [% IF restricted_lib %]<span class="restricted">([% restricted_lib | html %])</span>[% END %]</span>
99     [% ELSE %]
100         <span class="item-status notforloan">Not for loan [% IF restricted_lib %]<span class="restricted">([% restricted_lib | html %])</span>[% END %]</span>
101     [% END %]
102 [% ELSIF item.itemtype.notforloan %]
103     [% SET itemavailable = 0 %]
104     <span class="item-status notforloan">Not for loan [% IF restricted_lib %]<span class="restricted">([% restricted_lib | html %])</span>[% END %]</span>
105 [% END %]
106
107 [% IF ( item.bundle_host ) %]
108     <span class="bundled">In bundle: <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% item.bundle_host.biblionumber | uri %]">[% INCLUDE 'biblio-title.inc' biblio = item.bundle_host.biblio %]</a></span>
109 [% END %]
110
111 [% IF ( item.damaged ) %]
112     [% SET itemavailable = 0 %]
113     [% av_lib_include = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged, opac => 1 ) %]
114     [% IF av_lib_include %]
115         <span class="item-status damaged">[% av_lib_include | html %]</span>
116     [% ELSE %]
117         <span class="item-status damaged">Item damaged</span>
118     [% END %]
119 [% END %]
120
121 [% IF Koha.Preference('OPACAcquisitionDetails') AND item.orders.filter_by_active.count %]
122     [% SET itemavailable = 0 %]
123     <span class="item-status onorder">On order</span>
124 [% END %]
125
126 [% IF item.has_pending_hold %]
127     [% SET itemavailable = 0 %]
128     <span class="item-status pendinghold">Pending hold</span>
129 [% END %]
130
131 [% IF Koha.Preference('UseRecalls') && item.has_pending_recall %]
132     [% SET itemavailable = 0 %]
133     <span class="item-status pendingrecall">Pending recall</span>
134 [% END %]
135
136 [% IF ( itemavailable ) %]
137     <span class="item-status available">Available [% IF restricted_lib %]<span class="restricted">([% restricted_lib | html %])</span>[% END %]</span>
138 [% END %]