Koha/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc
Nick Clemens cc4fe788e4 Bug 29049: Simplify holds priority dropdown logic on request.pl
This patch makes a few changes:
1 - If we are not splitting the queue ( HoldsSplitQueue == 'nothing' ) then
    there are no changes for 'virtual' vs 'actual' numbering
2 - If we are splitting the queue you cannot use the dropdown, so we do not need to process the options
3 - If the hold is 'found' we do not need to process the options
4 - We can simply use the 'last priority' to build the options, we do not need to process in the script
5 - We can use a block to build the options
6 - Remove a stray holds.index

To test:
 1 - Place 5 holds on a bib
 2 - 'Find' two of the holds i.e. check them in to set status to 'transit' or 'waiting'
 3 - View the holds page for the biblio
 4 - Inspect the priorty dropdown for the found holds, note they have options for 1-5 but are disabled
 5 - Note the dropdowns for other holds have options 1-5
 6 - Note options 4&5 in the dropdowns have no effect
 7 - Apply patch
 8 - Inspect the priority dopdowns on the found holds
 9 - Note they only show their found status
10 - Note the other dropdowns only show options 1-3
11 - Test with other HoldsSplitQueue options and HoldsSplitQueueNumbering
12 - When holds queue is split, no dropdowns should be active and should show only their current priority
13 - When  HoldsSplitQueueNumbering is 'virtual' the dropdown should be disabled and correctly count the number of unfound holds in the list

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
JK: Fixed grammar in commit title
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

JD: Remove trailing 'i'

Bug 29049: (QA follow-up) Remove excessive whitespace

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-09-28 15:12:45 +02:00

230 lines
14 KiB
HTML

[% USE Koha %]
[% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
[% USE AuthorisedValues %]
<table>
<tr>
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
<th>Priority</th>
<th>&nbsp;</th>
[% ELSE %]
<th>Delete?</th>
[% END %]
<th>Patron</th>
<th>Notes</th>
<th>Date</th>
<th>Expiration</th>
<th>Pickup library</th>
<th>Details</th>
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
<th><img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Toggle set to lowest priority" /></th>
[% END %]
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
[% SET first_priority = 0 %]
[% SET last_priority = holds.last.priority %]
[% BLOCK priority_dropdown %]
[% SET loop_priority = 1 %]
[% WHILE loop_priority <= last_priority %]
[% IF this_priority == loop_priority %]
<option value="[% loop_priority | html %]" selected="selected">[% loop_priority | html %]</option>
[% ELSE %]
<option value="[% loop_priority | html %]">[% loop_priority | html %]</option>
[% END %]
[% loop_priority = loop_priority + 1 %]
[% END %]
[% END %]
[% FOREACH hold IN holds %]
[% IF !hold.found && first_priority == 0 %]
[% first_priority = hold.priority %]
[% found_holds = loop.index() %]
[% END %]
[% IF Koha.Preference('HoldsSplitQueueNumbering') == 'actual' %]
[% this_priority = hold.priority %]
[% ELSE %]
[% this_priority = loop.count() - found_holds %]
[% END %]
<tr>
<td>
<input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
<input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
<input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" />
[% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %]
<select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id | html %]">
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
[% PROCESS priority_dropdown %]
[% ELSE %]
<option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
[% END %]
<option value="del">del</option>
</select>
[% ELSE %]
<input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
<select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id | html %]">
[% IF ( hold.found ) %]
[% IF ( hold.intransit ) %]
<option value="T" selected="selected">In transit</option>
[% ELSIF (hold.inprocessing) %]
<option value="P" selected="selected">In processing</option>
[% ELSE %]
<option value="W" selected="selected">Waiting</option>
[% END %]
[% ELSE %]
<option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
[% END %]
</select>
[% END %]
</td>
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
[% UNLESS hold.found %]
[% SET prev_priority = loop.prev.priority %]
[% SET next_priority = loop.next.priority %]
<td style="white-space:nowrap;">
<a title="Move hold up" href="request.pl?action=move&amp;where=up&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
<img src="[% interface | html %]/[% theme | html %]/img/go-up.png" alt="Go up" />
</a>
<a title="Move hold to top" href="request.pl?action=move&amp;where=top&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
<img src="[% interface | html %]/[% theme | html %]/img/go-top.png" alt="Go top" />
</a>
<a title="Move hold to bottom" href="request.pl?action=move&amp;where=bottom&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
<img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Go bottom" />
</a>
<a title="Move hold down" href="request.pl?action=move&amp;where=down&amp;first_priority=[% first_priority | html %]&amp;last_priority=[% last_priority | html %]&amp;prev_priority=[% prev_priority | html %]&amp;next_priority=[% next_priority | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
<img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Go down" />
</a>
</td>
[% ELSE %]
<td></td>
[% END %]
[% END %]
<td>
[% INCLUDE 'patron-title.inc' patron=hold.patron hide_patron_infos_if_needed=1 %]
</td>
<td>[% hold.notes | html | html_line_break %]</td>
<td>
[% IF Koha.Preference('AllowHoldDateInFuture') %]
<input type="text" class="datepicker" value="[% hold.date | $KohaDates %]" required="required" size="10" name="reservedate" />
[% ELSE %]
[% hold.date | $KohaDates %]
[% END %]
</td>
<td><input type="text" class="datepicker futuredate" value="[% hold.expirationdate | $KohaDates %]" size="10" name="expirationdate" /></td>
<td>
[% IF ( hold.found ) %]
[% IF ( hold.atdestination ) %]
Item waiting at <strong> [% hold.wbrname | html %]</strong>[% IF hold.desk_name %], [% hold.desk_name | html %],[% END %] <input type="hidden" name="pickup" value="[% hold.wbrcode | html %]" /> since [% hold.waiting_date | $KohaDates %]
[% ELSIF (hold.intransit) %]
Item being transferred to <strong> [% hold.wbrname | html %]</strong> <input type="hidden" name="pickup" value="[% hold.wbrcode | html %]" />
[% ELSIF (hold.inprocessing) %]
Item being processed at <strong> [% hold.wbrname | html %]</strong> <input type="hidden" name="pickup" value="[% hold.wbrcode | html %]" />
[% END %]
[% ELSE %]
[% IF Koha.Preference('IndependentBranches') && Branches.all().size == 1 %]
[% Branches.GetName(hold.branchcode) | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" />
[% ELSE %]
<select class="pickup_location_dropdown" data-selected="[% hold.branchcode | html %]" data-hold_id="[% hold.reserve_id | html %]" name="pickup">
<option selected="selected" value="[% hold.branchcode | html %]">[% Branches.GetName(hold.branchcode) | html %]</option>
<option value="" disabled="disabled" class="loading">Loading...</option>
</select>
<img class="loading_[% hold.reserve_id | html %]" src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" style="display:none;"/>
[% END %]
[% END %]
</td>
<td>
[% IF ( hold.found ) %]
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% hold.biblionumber | uri %]&amp;itemnumber=[% hold.itemnumber | uri %]#item[% hold.itemnumber | uri %]">
[% IF ( hold.barcodenumber ) %]
[% hold.barcodenumber | html %]
<input type="hidden" name="itemnumber" value="[% hold.itemnumber | html %]" />
[% ELSE %]
No barcode
[% END %]
</a>
[% ELSE %]
[% IF ( hold.item_level_hold ) %]
<em>
Only item
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% hold.biblionumber | uri %]&amp;itemnumber=[% hold.itemnumber | uri %]#item[% hold.itemnumber | uri %]">
[% IF ( hold.barcodenumber ) %]
[% hold.barcodenumber | html %]
<input type="hidden" name="itemnumber" value="[% hold.itemnumber | html %]" />
[% ELSE %]
No barcode
[% END %]
</a>
</em>
[% ELSE %]
[% IF hold.itemtype %]
<em>Next available [% ItemTypes.GetDescription( hold.itemtype ) | html %] item</em>
[% ELSE %]
<em>Next available</em>
[% END %]
<input type="hidden" name="itemnumber" value="" />
[% END %]
[% END %]
[% IF hold.non_priority %]
<br><i>Non priority hold</i>
[% END %]
</td>
[% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
[% UNLESS hold.found %]
<td>
<a title="Toggle lowest priority" href="request.pl?action=setLowestPriority&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
[% IF ( hold.lowestPriority ) %]
<img src="[% interface | html %]/[% theme | html %]/img/go-bottom.png" alt="Unset lowest priority" />
[% ELSE %]
<img src="[% interface | html %]/[% theme | html %]/img/go-down.png" alt="Set to lowest priority" />
[% END %]
</a>
</td>
[% ELSE %]
<td></td>
[% END %]
[% END %]
<td>
<a class="cancel-hold" title="Cancel hold" data-borrowernumber="[% hold.borrowernumber | html %]" data-biblionumber="[% hold.biblionumber | html %]" data-id="[% hold.reserve_id | html %]" href="request.pl?action=cancel&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;reserve_id=[% hold.reserve_id | html %]&amp;date=[% hold.date | html %]">
<img src="[% interface | html %]/[% theme | html %]/img/x.png" alt="Cancel" />
</a>
</td>
<td>
[% IF Koha.Preference('SuspendHoldsIntranet') %]
[% UNLESS ( hold.found ) %]
<input type="button" value="[% IF ( hold.suspend ) %]Unsuspend[% ELSE %]Suspend[% END %]" onclick="window.location.href='request.pl?action=toggleSuspend&amp;reserve_id=[% hold.reserve_id | html %]&amp;borrowernumber=[% hold.borrowernumber | html %]&amp;biblionumber=[% hold.biblionumber | html %]&amp;date=[% hold.date | html %]&amp;suspend_until=' + $('#suspend_until_[% hold.reserve_id | html %]').val()" />
[% IF Koha.Preference('AutoResumeSuspendedHolds') %]
<label for="suspend_until_[% hold.reserve_id | html %]">[% IF ( hold.suspend ) %] on [% ELSE %] until [% END %]</label>
<input type="text" name="suspend_until_[% hold.reserve_id | html %]" id="suspend_until_[% hold.reserve_id | html %]" size="10" value="[% hold.suspend_until | $KohaDates %]" class="datepicker suspend_until_datepicker" />
<a href='#' onclick="document.getElementById('suspend_until_[% hold.reserve_id | html %]').value='';">Clear date</a>
[% ELSE %]
<input type="hidden" name="suspend_until_[% hold.reserve_id | html %]" id="suspend_until_[% hold.reserve_id | html %]" value=""/>
[% END %]
[% END %]
[% END # IF SuspendHoldsIntranet %]
[% IF ( hold.found ) %]
<input type="button" id="revert_hold_[% hold.reserve_id | html %]" value="[% IF hold.intransit %]Revert transit status[% ELSE %]Revert waiting status[% END %]" onclick="window.location.href='request.pl?action=move&amp;where=down&amp;first_priority=[% first_priority | uri %]&amp;last_priority=[% last_priority | uri %]&amp;prev_priority=0&amp;next_priority=1&amp;borrowernumber=[% hold.borrowernumber | uri %]&amp;biblionumber=[% hold.biblionumber | uri %]&amp;itemnumber=[% hold.itemnumber | uri %]&amp;reserve_id=[% hold.reserve_id | uri %]&amp;date=[% hold.date | uri %]'">
[% END %]
</td>
</tr>
[% END %]
</table>