Bug 12556: Simplify and correct logic in holds-table.inc template
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / includes / holds-table.inc
blob332480072edfcda0d3b47480f2c63cf758750b7d
1 [% USE Branches %]
2 [% USE ItemTypes %]
3 [% USE KohaDates %]
5 [% IF ( HOLDS.count ) %]
6     <div id="opac-user-holds">
7         <table id="holdst" class="table table-bordered table-striped">
8             <caption>Holds <span class="count">([% HOLDS.count | html %] total)</span></caption>
9             <!-- HOLDS TABLE ROWS -->
10             <thead>
11                 <tr>
12                     <th class="anti-the">Title</th>
13                     [% IF ( showpriority ) %]
14                         <th class="title-string">Placed on</th>
15                     [% ELSE %]
16                         <th class="psort title-string">Placed on</th>
17                     [% END %]
18                     <th class="title-string">Expires on</th>
19                     [% UNLESS( singleBranchMode) %]
20                         <th>Pick up location</th>
21                     [% END %]
22                     [% IF ( showpriority ) %]
23                         <th class="psort">Priority</th>
24                     [% END %]
25                     <th>Status</th>
26                     [% IF SuspendHoldsOpac and ! onlyinfo %]
27                             <th class="nosort" >Suspend</th>
28                     [% END %]
29                     [% IF ! onlyinfo %]
30                         <th class="nosort">Modify</th>
31                     [% END %]
32                 </tr>
33             </thead>
34             <tbody>
35                 [% SET all_holds_waiting = 1 %]
36                 [% FOREACH HOLD IN HOLDS %]
37                     [% UNLESS ( HOLD.is_waiting || HOLD.is_in_transit ) %]
38                         [% SET all_holds_waiting = 0 %]
39                     [% END %]
40                     [% IF ( HOLD.is_at_destination ) %]
41                         <tr class="reserved">
42                     [% ELSIF HOLD.is_in_transit %]
43                         <tr class="transfered">
44                     [% ELSE %]
45                         <tr>
46                     [% END %]
47                         <td class="title">
48                             [% IF ! onlyinfo %]
49                                 <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% HOLD.biblionumber | html %]">
50                                     [% INCLUDE 'biblio-title.inc' biblio=HOLD.biblio %]
51                                     [% HOLD.item.enumchron | html %]
52                                 </a>
53                             [% ELSE %]
54                                 <strong>
55                                     [% INCLUDE 'biblio-title.inc' biblio=HOLD.biblio %]
56                                     [% HOLD.item.enumchron | html %]
57                                 </strong>
58                             [% END %]
59                             [% HOLD.biblio.author | html %]
60                         </td>
61                         <td class="reservedate">
62                             <span title="[% HOLD.reservedate | html %]">
63                                 <span class="tdlabel">Hold date:</span>
64                                 [% HOLD.reservedate | $KohaDates %]
65                             </span>
66                         </td>
67                         <td class="expirationdate">
68                             [% IF ! HOLD.found %]
69                                 [% IF ( HOLD.expirationdate ) %]
70                                     <span title="[% HOLD.expirationdate | html %]">
71                                         <span class="tdlabel">Expiration:</span>
72                                             [% HOLD.expirationdate | $KohaDates %]
73                                     </span>
74                                 [% ELSE %]
75                                     <span title="0000-00-00">
76                                         <span class="tdlabel">Expiration:</span>
77                                         Never expires
78                                     </span>
79                                 [% END %]
80                             [% ELSE %]
81                                 <span title="0000-00-00">-</span>
82                             [% END %]
83                         </td>
84                         [% UNLESS( singleBranchMode) %]
85                             <td class="branch">
86                                 <span class="tdlabel">Pick up location:</span>
87                                 [% HOLD.branch.branchname | html %]
88                             </td>
89                         [% END %]
90                         [% IF ( showpriority ) %]
91                                 <td data-order="[% HOLD.priority | html %]" class="priority">
92                                 <span class="tdlabel">Priority:</span>
93                                 [% HOLD.priority | html %]
94                             </td>
95                         [% END %]
96                         <td class="status">
97                             <span class="tdlabel">Status:</span>
98                             [% IF ( HOLD.is_waiting ) %]
99                                 <i class="fa fa-exclamation-circle text-warning" aria-hidden="true"></i>
100                                 [% IF ( HOLD.is_at_destination ) %]
101                                     Item waiting at <strong> [% HOLD.branch.branchname | html %]</strong>
102                                     [% IF ( HOLD.waitingdate ) %]
103                                         since [% HOLD.waitingdate | $KohaDates %]
104                                         [% IF HOLD.expirationdate %]
105                                             until [% HOLD.expirationdate | $KohaDates %]
106                                         [% END %]
107                                     [% END %]
108                                     <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" />
109                                 [% ELSE %]
110                                     Item in transit to <strong> [% Branches.GetName( HOLD.branchcode ) | html %]</strong> <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" />
111                                 [% END %]
112                             [% ELSE %]
113                                 [% IF ( HOLD.is_in_transit ) %]
114                                     [% SET transfer = HOLD.item.get_transfer %]
115                                     Item in transit from <strong> [% Branches.GetName( transfer.frombranch ) | html %]</strong> since
116                                     [% transfer.datesent | $KohaDates %]
117                                 [% ELSIF ( HOLD.suspend ) %]
118                                     Suspended [% IF ( HOLD.suspend_until ) %] until [% HOLD.suspend_until | $KohaDates %] [% END %]
119                                 [% ELSE %]
120                                     [% IF HOLD.itemtype %]
121                                         Pending for next available item of item type '[% ItemTypes.GetDescription( HOLD.itemtype ) | html %]'
122                                     [% ELSE %]
123                                         Pending
124                                     [% END %]
125                                 [% END %]
126                             [% END %]
127                         </td>
128                         [% IF SuspendHoldsOpac and ! onlyinfo %]
129                             <td>
130                                 [% IF ( HOLD.is_cancelable_from_opac ) %]
131                                     [% IF HOLD.suspend %]
132                                         <form class="form-inline" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
133                                             <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
134                                             <button class="btn btn-link" type="submit" name="submit"><i class="fa fa-play" aria-hidden="true"></i> Resume</button>
135                                         </form>
136                                     [% ELSE %]
137                                         [% IF AutoResumeSuspendedHolds %]
138                                             <a class="btn btn-link js-show" href="#suspendModal[% HOLD.reserve_id | html %]" role="button" data-toggle="modal"><i class="fa fa-pause" aria-hidden="true"></i> Suspend</a>
139                                             [% # hold suspend modal form %]
140                                             <div id="suspendModal[% HOLD.reserve_id | html %]" class="modal-nojs" tabindex="-1" role="dialog" aria-labelledby="suspendModal[% HOLD.reserve_id | html %]Label" aria-hidden="true">
141                                                 <div class="modal-dialog">
142                                                     <div class="modal-content">
143                                                         <form action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
144                                                             <div class="modal-header">
145                                                                 [% IF HOLD.suspend %]
146                                                                     <h3 class="modal-title" id="suspendModal[% HOLD.reserve_id | html %]Label">Resume your hold on <em>[% HOLD.biblio.title | html %]</em></h3>
147                                                                 [% ELSE %]
148                                                                     <h3 class="modal-title" id="suspendModal[% HOLD.reserve_id | html %]Label">Suspend your hold on <em>[% HOLD.biblio.title | html %]</em></h3>
149                                                                 [% END %]
150                                                                 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">
151                                                                     <span aria-hidden="true">x</span>
152                                                                 </button>
153                                                             </div>
154                                                             <div class="modal-body">
155                                                                 <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
156                                                                 <label for="suspend_until_[% HOLD.reserve_id | html %]">Suspend until:</label>
157                                                                 <input type="text" name="suspend_until" id="suspend_until_[% HOLD.reserve_id | html %]" class="suspend-until" size="10" />
158                                                                 [% INCLUDE 'date-format.inc' %]
159                                                                 <p class="js-show"><a href="#" onclick="document.getElementById('suspend_until_[% HOLD.reserve_id | html %]').value='';return false;">Clear date to suspend indefinitely</a></p>
160                                                                 <button class="btn btn-primary btn-sm js-hide" type="submit" name="submit">Suspend</button>
161                                                             </div>
162                                                             <div class="modal-footer">
163                                                                 <button class="btn btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Suspend</button>
164                                                                 <button data-dismiss="modal" class="btn btn-secondary"><i class="fa fa-remove" aria-hidden="true"></i> Do not suspend</button>
165                                                             </div>
166                                                         </form>
167                                                     </div> <!-- /.modal-content -->
168                                                 </div> <!-- /.modal-dialog -->
169                                             </div>  <!-- /#suspendModal[% HOLD.reserve_id | html %] -->
170                                         [% ELSE %]
171                                             <form class="form-inline" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
172                                                 <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
173                                                 <button class="btn btn-link" type="submit" name="submit"><i class="fa fa-pause" aria-hidden="true"></i> Suspend</button>
174                                             </form>
175                                         [% END # / IF AutoResumeSuspendedHolds %]
176                                     [% END # / IF HOLD.suspend %]
177                                 [% END # / IF ( HOLD.is_cancelable_from_opac )%]
178                             </td>
179                         [% END # / IF SuspendHoldsOpac %]
180                         [% IF ! onlyinfo %]
181                             <td class="modify">
182                                 [% IF ( HOLD.is_cancelable_from_opac ) %]
183                                     <form id="delete_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
184                                     <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
185                                     <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
186                                     <button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> Cancel</button>
187                                 </form>
188                                 [% END %]
189                             </td>
190                         [% END # / IF onlyinfo %]
191                     </tr>
192                 [% END # /FOREACH HOLDS %]
193             </tbody>
194         </table>
196         [% IF SuspendHoldsOpac and ! onlyinfo %]
197             [% UNLESS ( all_holds_waiting ) %]
198                 <div>
199                     <form class="form-inline" id="suspend_all_holds" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
200                         <button type="submit" id="suspend_all_submit" class="btn btn-primary"><i class="fa fa-pause" aria-hidden="true"></i> Suspend all holds</button>
201                         <input type="hidden" name="suspend" value="1" />
203                         [% IF AutoResumeSuspendedHolds %]
204                             <label for="suspend_until"> until </label>
205                             <input type="text" name="suspend_until" id="suspend_until" class="suspend-until" readonly="readonly" size="10" />
206                             <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('suspend_until').value='';return false;">Clear date to suspend indefinitely</a>
207                         [% END %]
208                     </form>
209                 </div>
210                 <br/>
211                 <div>
212                     <form id="resume_all_holds" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
213                         <button type="submit" id="resume_all_submit" class="btn btn-primary"><i class="fa fa-play" aria-hidden="true"></i> Resume all suspended holds</button>
214                         <input type="hidden" name="suspend" value="0" />
215                     </form>
216                 </div>
217             [% END %]
218         [% END %]
219     </div> <!-- / #opac-user-holds -->
220 [% END # / #HOLDS.count %]