Koha/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
Owen Leonard e5f1ada249 Bug 28937: Use Flatpickr on circulation and patron pages
This patch replaces the use of jQueryUI's datepicker on circulation and
patron-related pages.

The patch modifies Flatpickr's default configuration (in calendar.inc)
so that it has the following features:

 - A Flatpickr input with a "futuredate" class will require that the
   selected date be after today.
 - The Flatpickr input field will be wrapped in a container to
   facilitate better CSS styling.
 - Generic handling of paired date fields is enabled using
   ".flatpickrfrom" and ".flatpickrto" field classes. This mimics the
   same feature we have for jQueryUI datepickers using ".datepickerfrom"
   and ".datepickerto".

This patch also removes an unused function which was repeated in three
templates: validate1.

To test, apply the patch and rebuild the staff interface CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

- Go to Circulation and check out to a patron.
  - Open the Restrictions tab and click "Add manual restriction."
    - In the "Expiration" field, test that the Flatpickr widget works
      correctly and limits to dates after today.
  - Enable the SpecifyDueDate preference if necessary.
    - Test the behavior of the SpecifyDueDate controls: Setting a date,
      clearing a date, session persistence.
- Enable the SuspendHoldsIntranet system preference if necessary.
  - Check out to a patron with existing holds.
    - Open the Holds tab and click the "Suspend" button for one of the
      holds.
      - In the modal window which appears, check that the Flatpickr
        widget works correctly and limits to dates after today.
      - At the bottom of the table of holds, test that the "Suspend all
        holds" Flatpickr works correctly and limits to dates after
        today.
        - Perform this same test from the patron details page.
- Enable the  BatchCheckouts system preference if necessary.
  - Open a patron record and click "Batch check out" in the left-hand
    sidebar menu.
    - Test that the "Hard due date" Flatpickr works correctly as a date
      and time picker.
- Go to Circulation -> Overdues.
  - Test that the date due filters in the sidebar work correctly and
    are linked, e.g. the "to" field cannot be before the "from" field.
     - Perform the same test here: Circulation -> Holds to pull; and
       here: Circulation -> Hold ratios.
- Enable the  HouseboundModule system preference if necessary.
  - Check out to or view details of a patron.
    - Click "Housebound" in the sidebar menu.
      - Save delivery day and frequency settings for that patron.
      - Click "Add a new delivery."
      - Test that the "Date" Flatpickr widget works correctly.
- Go to Patrons -> A patron record -> Edit.
  - Test that Flatpickr widgets work on the following fields:
    - Date of birth
    - Registration date & Expiration date (linked).
    - Patron restrictions -> Add manual restriction -> Expiration.
- View a bibliographic record and start the process of placing a hold.
  - After selecting a patron, test the "Hold starts on" and "Hold
    expires on" date fields. The fields should be linked and each
    should limit to future dates.
  - Confirm that the dates are saved correctly when you submit the
    hold.
- Locate a bibliographic record with multiple holds and view the holds.
  - In the table of holds, test each date field: Date, expiration, and
    suspend-until.
- Test that Flatpickr's static "formatDate" method is working
  correctly:
  - Locate a bibliographic record's item so that there is text in both
    the "Public note" and "Non-public note" field.
  - Check that item out to a patron.
  - After the page reloads the public and non-public notes should be
    shown under the checkout title highlighted in red.
- Check for references to a "validate1" function. There should be none.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-09-29 12:47:33 +02:00

365 lines
15 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE TablesSettings %]
[% USE AuthorisedValues %]
[%- USE Branches -%]
[%- USE ItemTypes -%]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Holds to pull &rsaquo; Circulation &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="circ_pendingreserves" class="circ">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'circ-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
</li>
<li>
<a href="#" aria-current="page">
Holds to pull
</a>
</li>
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% FOR m IN messages %]
<div class="dialog [% m.type | html %]">
[% SWITCH m.code %]
[% CASE 'letter_enqueued' %]
<span>The notice has been correctly enqueued.</span>
[% CASE 'no_email_address' %]
<span>The patron does not have an email address defined.</span>
[% CASE 'no_template_notice' %]
<span>There is no notice template with a code 'CANCEL_HOLD_ON_LOST' defined in your system.</span>
[% CASE 'hold_cancelled' %]
<span>The hold has been correctly cancelled.</span>
[% CASE 'hold_placed_at_biblio_level' %]
<span>The hold has been placed on biblio level. It is not possible to determine the item to mark as lost.</span>
[% CASE %]
[% m.code | html %]
[% END %]
</div>
[% END %]
<h2>Holds to pull placed between [% from | $KohaDates %] and [% to | $KohaDates %]</h2>
<h3>Reported on [% todaysdate | $KohaDates %]</h3>
<p>The following holds have not been filled. Please retrieve them and check them in.</p>
<div id="searchresults">
[% IF holds_info %]
<table id="holdst">
<thead>
<tr>
<th>Pull this many items</th>
<th>Items available</th>
<th>Patrons with holds</th>
<th>First patron</th>
<th class="anti-the">Title</th>
<th class="string-sort">Libraries</th>
<th>Available barcodes</th>
<th>Available call numbers</th>
<th>Available copy numbers</th>
<th>Available enumeration</th>
<th class="string-sort">Available item types</th>
<th class="string-sort">Available locations</th>
<th>Earliest hold date</th>
<th>Reserve notes</th>
<th class="string-sort">Pickup location</th>
<th>Action</th>
</tr>
</thead>
<tbody>
[% FOREACH hold_info IN holds_info %]
<tr>
[% SET patron = hold_info.patron %]
[% SET item = hold_info.item %]
[% SET hold = hold_info.hold %]
[% IF patron %]
[% SET biblio = hold_info.biblio %]
<td><p><strong>[% hold_info.pull_count | html %]</strong></p></td>
<td>[% hold_info.items_count | html %]</td>
<td>[% hold_info.patrons_count | html %]</td>
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a></td>
<td>
<p>
[% INCLUDE 'biblio-title.inc' biblio=biblio link = 1 %]
</p>
[% IF ( biblio.author ) %]<p> by [% biblio.author | html %]</p>[% END %]
[% IF ( biblio.biblioitem.editionstatement ) %]<p>[% biblio.biblioitem.editionstatement | html %]</p>[% END %]
[% IF ( Koha.Preference('marcflavour') == 'MARC21' ) %]
[% IF ( biblio.copyrightdate ) %]<p>[% biblio.copyrightdate | html %]</p>[% END %]
[% ELSE %]
[% IF ( biblio.biblioitem.publicationyear ) %]<p>[% biblio.biblioitem.publicationyear | html %]</p>[% END %]
[% END %]
</td>
[% ELSE %]
<td>"</td>
<td>"</td>
<td>"</td>
<td>"</td>
<td>"</td>
[% END %]
<td>
[% IF ( hold_info.holdingbranches.size ) %]
<ul>
[% FOREACH holdingbranch IN hold_info.holdingbranches %]
<li>[% Branches.GetName ( holdingbranch ) | html %]</li>
[% END %]
</ul>
[% END %]
</td>
<td>
[% IF ( hold_info.barcodes.size ) %]
[% SET barcode = hold_info.barcodes.first %]
[% IF ( hold_info.itemnumber ) %]Only [% barcode | html %][% ELSE %][% barcode | html %] or any available.[% END %]
[% END %]
</td>
<td>
[% IF ( hold_info.callnumbers.size ) %]
<ul>
[% FOREACH callnumber IN hold_info.callnumbers %]
<li>
[% callnumber | html %]
</li>
[% END %]
</ul>
[% END %]
</td>
<td>
[% IF ( hold_info.copynumbers.size ) %]
<ul>
[% FOREACH copyno IN hold_info.copynumbers %]
<li>
[% copyno | html %]
</li>
[% END %]
</ul>
[% END %]
</td>
<td>
[% IF ( hold_info.enumchrons.size ) %]
<ul>
[% FOREACH enumchron IN hold_info.enumchrons %]
<li>
[% enumchron | html %]
</li>
[% END %]
</ul>
[% END %]
</td>
<td>
<ul>
[% FOREACH type IN hold_info.itemtypes %]
<li>[% ItemTypes.GetDescription( type ) | html %]</li>
[% END %]
</ul>
</td>
<td>
<ul>
[% FOREACH loc IN hold_info.locations %]
<li>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => loc ) | html %]</li>
[% END %]
</ul>
</td>
<td data-order="[% hold.reservedate | html %]">
[% hold.reservedate | $KohaDates %] in [% Branches.GetName ( hold.branchcode ) | html %]
</td>
<td>[% hold.reservenotes | html %]</td>
<td>
[% Branches.GetName ( hold.branchcode ) | html %]
</td>
<td>
<form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post">
<input type="hidden" name="op" value="cancel_reserve" />
<input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
[% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
[% IF hold_cancellation %]
<div class="form-group">
<label for="cancellation-reason">Cancellation reason:</label>
<select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
<option value="">No reason given</option>
[% FOREACH reason IN hold_cancellation %]
<option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
[% END %]
</select>
</div>
[% END %]
[% IF item.holdingbranch != item.homebranch %]
<input class="btn btn-default" type="submit" value="Cancel hold and return to : [% Branches.GetName( item.homebranch ) | html %]" />
[% ELSE %]
<input class="btn btn-default" type="submit" value="Cancel hold" />
[% END %]
</form>
[% IF Koha.Preference('CanMarkHoldsToPullAsLost') != 'do_not_allow' %]
[% IF hold.itemnumber %]
<form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post">
<input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
[% IF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow' %]
<input type="hidden" name="op" value="mark_as_lost" />
<input type="submit" value="Mark item as lost" />
[% ELSIF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow_and_notify' %]
<input type="hidden" name="op" value="mark_as_lost_and_notify" />
<input type="submit" value="Mark lost and notify patron" />
[% END %]
</form>
[% ELSE %]
<span>Biblio level hold.</span>
[% END %]
[% END %]
</td>
</tr>
[% END %]
</tbody>
<tfoot>
<tr>
<td><input type="text" class="filter" data-column_num="0" placeholder="Pull this many items" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="1" placeholder="Items available" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="2" placeholder="Patron holds" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="3" placeholder="Patron name" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="4" placeholder="Title" style="width:95%"/></td>
<td id="homebranchfilter"></td>
<td></td>
<td><input type="text" class="filter" data-column_num="7" placeholder="Call number" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="8" placeholder="Available copy" style="width:95%"/></td>
<td><input type="text" class="filter" data-column_num="9" placeholder="Available enumeration" style="width:95%"/></td>
<td id="itemtype-filter"></td>
<td id="locationfilter"></td>
<td></td>
<td></td>
<td id="pickup-location"></td>
<td></td>
</tr>
</tfoot>
</table>
[% ELSE %]
<strong>No items found.</strong>
[% END %]
</div>
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
<div id="filters">
<form action="/cgi-bin/koha/circ/pendingreserves.pl" method="post" >
<fieldset class="brief">
<h4>Refine results</h4>
<ol>
<li>
<label for="from">
Start date:
</label>
<input type="text" size="10" id="from" name="from" value="[% from | $KohaDates %]" class="flatpickrfrom" />
</li>
<li><label for="to">
End date:
</label>
<input type="text" size="10" id="to" name="to" value="[% to | $KohaDates %]" class="flatpickrto" />
</li>
</ol>
[% IF ( HoldsToPullEndDate ) %]
<p><em>(Inclusive, default is [% HoldsToPullStartDate | html %] days ago to [% HoldsToPullEndDate | html %] days ahead. Set other date ranges as needed.)</em></p>
[% ELSE %]
<p><em>(Inclusive, default is [% HoldsToPullStartDate | html %] days ago to today. Set other date ranges as needed.)</em></p>
[% END %]
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
</fieldset>
</form>
</div>
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
<script>
$(document).ready(function() {
var columns_settings = [% TablesSettings.GetColumns('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
var holdst = KohaTable("holdst", {
"sPaginationType": "full_numbers"
}, columns_settings);
holdst.fnAddFilters("filter");
[%# add separateData function to cleanse jQuery select lists by breaking apart strings glued with BR tags and then de-duplicating any repeated library codes %]
function separateData ( ColumnData ){
var cD = ColumnData;
var new_array = new Array();
for ( j=0 ; j<cD.length ; j++ ) {
var split_array = cD[j].split(/\n/gi);
for ( k=0 ; k<split_array.length ; k++ ){
var str = $.trim(split_array[k].replace(/[\n\r]/g, ''));
if ($.inArray(str, new_array) == -1 && str.length > 0 ) {
new_array.push(str);
}
}
}
new_array.sort();
return new_array;
}
[%# add SeparateData function into createSelect function, so that it does the createSelect on clean data %]
function createSelect( data ) {
data = separateData(data);
var r='<select style="width:99%"><option value="">' + _("None") + '</option>', i, len=data.length;
var regex = /(<([^>]+)>)/ig; // Remove html tags
for ( i=0 ; i<len ; i++ ) {
var cell_val = data[i].replace(regex, '');
if ( cell_val.length < 1 ) continue;
r += '<option value="'+cell_val+'">'+cell_val+'</option>';
}
return r+'</select>';
}
$("#homebranchfilter").each( function () {
$(this).html( createSelect( holdst.fnGetColumnData(5) ) );
$('select', this).change( function () {
holdst.fnFilter( $(this).val(), 5 );
});
});
$("#itemtype-filter").each( function () {
$(this).html( createSelect( holdst.fnGetColumnData(10) ) );
$('select', this).change( function () {
holdst.fnFilter( $(this).val(), 10 );
});
});
$("#locationfilter").each( function () {
$(this).html( createSelect( holdst.fnGetColumnData(11) ) );
$('select', this).change( function () {
holdst.fnFilter( $(this).val(), 11 );
});
});
$("#pickup-location").each( function () {
$(this).html( createSelect( holdst.fnGetColumnData(14) ) );
$('select', this).change( function () {
holdst.fnFilter( $(this).val(), 14 );
});
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]