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