Koha/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.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

329 lines
14 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE AuthorisedValues %]
[% USE KohaDates %]
[%- USE Branches -%]
[%- USE Price -%]
[%- USE ItemTypes -%]
[%- USE Categories -%]
[%- USE TablesSettings -%]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Items overdue as of [% todaysdate | html %] &rsaquo; Circulation &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
[% FILTER collapse %]
<style>
.sql {display:none;}
.select2-container--open .select2-dropdown--below,
.select2-search.select2-search--dropdown {
border: 1px solid #AAA;
}
.select2-container--open .select2-dropdown--below,
.select2-search.select2-search--dropdown,
.select2-results {
background-color: #FFF;
width: 20em !important;
}
</style>
[% END %]
</head>
<body id="circ_overdue" 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">
Overdues as of [% todaysdate | html %]
</a>
</li>
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% IF ( noreport ) %]
<h2>Overdue report</h2>
<p>Please choose one or more filters to proceed.</p>
[% ELSE %]
[% IF ( overdueloop ) %]
<h2>[% nnoverdue | html %] [% IF ( noverdue_is_plural ) %]Items[% ELSE %]Item[% END %] overdue as of [% todaysdate | html %][% IF ( isfiltered ) %] <span style="font-size:70%;">(Filtered. <a href="/cgi-bin/koha/circ/overdue.pl">Reset filter</a>)</span>[% END %]</h2>
<p>
[% IF ( isfiltered ) %]
[% SET url_params = '' %]
[% FOR var IN filters.keys %]
[% url_params = BLOCK %][% url_params | $raw %]&amp;[% var | uri %]=[% filters.$var | uri %][% END %]
[% END %]
<a href="overdue.pl?op=csv[% url_params | $raw %]">Download file of displayed overdues</a>
[% ELSE %]
<a href="overdue.pl?op=csv">Download file of all overdues</a>
[% END %]
</p>
<div class="sql"><pre>[% sql | html %]</pre></div>
<div class="searchresults">
<table id="overduest">
<thead>
<tr>
<th>Due date</th>
<th>Patron</th>
<th>Patron category</th>
<th>Patron library</th>
<th class="anti-the">Title</th>
<th>Home library</th>
<th>Holding library</th>
<th>Shelving location</th>
<th>Barcode</th>
<th>Call number</th>
<th>Item type</th>
<th>Price</th>
<th>Non-public note</th>
</tr>
</thead>
[%- BLOCK subject -%]Overdue:[%- END -%]
<tbody>
[% FOREACH overdueloo IN overdueloop %]
<tr>
<td data-order="[% overdueloo.duedate | html %]">[% overdueloo.duedate | $KohaDates %]</td>
<td>
[% INCLUDE 'patron-title.inc' patron=overdueloo.patron hide_patron_infos_if_needed=1 %]
[% IF logged_in_user.can_see_patron_infos( overdueloo.patron ) %]
[% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email | uri %]?subject=[% INCLUDE subject %] [% overdueloo.title | uri %]">email</a>][% END %]
[% IF ( overdueloo.phone ) %]([% overdueloo.phone | html %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile | html %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro | html %])[% END %]</td>
[% END %]
<td>[% Categories.GetName( overdueloo.patron.categorycode ) | html %]</td>
<td>[% Branches.GetName( overdueloo.patron.branchcode ) | html %]</td>
<td>[% INCLUDE 'biblio-title.inc' biblio=overdueloo link = 1 %] [% IF ( overdueloo.author ) %], by [% overdueloo.author | html %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron | html %][% END %]</td>
<td>[% Branches.GetName( overdueloo.homebranchcode ) | html %]</td>
<td>[% Branches.GetName( overdueloo.holdingbranchcode ) | html %]</td>
<td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => overdueloo.location ) | html %]</td>
<td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber | uri %]&amp;itemnumber=[% overdueloo.itemnum | uri %]#item[% overdueloo.itemnum | uri %]">[% overdueloo.barcode | html %]</a></td>
<td>[% overdueloo.itemcallnumber | html %]</td>
<td>[% ItemTypes.GetDescription( overdueloo.itemtype ) | html %]</td>
<td>[% overdueloo.replacementprice | $Price %]</td>
<td>[% overdueloo.itemnotes_nonpublic | html %]</td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% ELSE %]
<h2>Overdue report</h2>
[% IF ( isfiltered ) %]
<p>There are no overdues matching your search. <a href="/cgi-bin/koha/circ/overdue.pl">Reset filter</a></p>
[% ELSE %]
<p>There are no overdues.</p>
[% END %]
[% END %] <!-- overdueloop -->
[% END %] <!-- noreport -->
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
<form method="post" action="/cgi-bin/koha/circ/overdue.pl">
<fieldset class="brief">
<h4>Filter on:</h4>
<fieldset><legend>Date due:</legend>
<ol>
<li class="radio">
<label for="showall">Show any items currently checked out:</label>
[% IF ( showall ) %]
<input type="checkbox" id="showall" name="showall" value="show" checked="checked" />
[% ELSE %]
<input type="checkbox" id="showall" name="showall" value="show" />
[% END %]
</li>
<li class="date_due_filter">
<label for="from">From:</label>
<input type="text" id="from" name="dateduefrom" size="10" value="[% filters.dateduefrom | $KohaDates %]" class="flatpickrfrom" />
</li>
<li class="date_due_filter">
<label for="to">To:</label>
<input type="text" id="to" name="datedueto" size="10" value="[% filters.datedueto | $KohaDates %]" class="flatpickrto" />
</li>
</ol>
</fieldset>
<ol>
<li><label>Name or cardnumber:</label><input type="text" name="borname" value="[% filters.borname | html %]" /></li>
<li><label>Patron category:</label><select name="borcat" id="borcat"><option value="">Any</option>
[% FOREACH borcatloo IN borcatloop %]
[% IF ( borcatloo.selected ) %]<option value="[% borcatloo.value | html %]" selected="selected">[% borcatloo.catname | html %]</option>[% ELSE %]<option value="[% borcatloo.value | html %]">[% borcatloo.catname | html %]</option>[% END %]
[% END %]
</select>
</li>
<li><label>Patron flags:</label>
<select name="borflag" id="borflag">
<option value="">None</option>
[% IF ( borflag_gonenoaddress ) %]<option value="gonenoaddress" selected="selected">Address in question</option>
[% ELSE %]<option value="gonenoaddress">Address in question</option>[% END %]
[% IF ( borflag_debarred ) %]<option value="debarred" selected="selected">Restricted</option>
[% ELSE %]<option value="debarred">Restricted</option>[% END %]
[% IF ( borflag_lost ) %]<option value="lost" selected="selected">Lost card</option>
[% ELSE %]<option value="lost">Lost card</option>[% END %]
</select>
</li>
[% FOREACH patron_attr_filter_loo IN patron_attr_filter_loop %]
<!-- domid cgivalue ismany isclone ordinal code description repeatable authorised_value_category -->
<li>
<label>[% patron_attr_filter_loo.description | html %]:</label>
[% IF ( patron_attr_filter_loo.authorised_value_category ) %]
[% SET authvals = AuthorisedValues.GetAuthValueDropbox( patron_attr_filter_loo.authorised_value_category ) %]
<select id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" class="pattrodue-input">
<option></option>
[% FOREACH authval IN authvals %]
[% IF ( patron_attr_filter_loo.cgivalue == authval.authorised_value ) -%]
<option value="[% authval.authorised_value | html %]" selected="selected">[% authval.lib | html %]</option>
[% ELSE -%]
<option value="[% authval.authorised_value | html %]">[% authval.lib | html %]</option>
[% END %]
[% END %]
</select>
[% ELSE %]
<input type="text" name="patron_attr_filter_[% patron_attr_filter_loo.code | html %]" value="[% patron_attr_filter_loo.cgivalue | html %]"/>
[% END %]
[% IF ( patron_attr_filter_loo.repeatable ) %]
<a href="#" class="btn btn-link clone-attribute" data-original-id="pattrodue-input-[% patron_attr_filter_loo.domid | html %]"><i class="fa fa-plus"></i> Add</a>
[% IF ( patron_attr_filter_loo.isclone ) %]
<a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
[% ELSIF ( patron_attr_filter_loo.ismany ) %]
<a href="#" class="btn btn-link delete_clone"><i class="fa fa-remove"></i> Delete</a>
[% ELSE %]
<a href="#" class="btn btn-link delete_clone" style="display:none"><i class="fa fa-remove"></i> Delete</a>
[% END %]
[% END %]
</li>
[% END %]
<li><label>Item type:</label><select name="itemtype" id="itemtype"><option value="">Any</option>
[% FOREACH itemtypeloo IN itemtypeloop %][% IF ( itemtypeloo.selected ) %]
<option value="[% itemtypeloo.value | html %]" selected="selected">[% itemtypeloo.itemtypename | html %]</option>[% ELSE %]
<option value="[% itemtypeloo.value | html %]">[% itemtypeloo.itemtypename | html %]</option>[% END %]
[% END %]
</select>
</li>
<li>
<label>Item home library:</label>
<select name="homebranch" id="homebranch">
<option value="">Any</option>
[% PROCESS options_for_libraries libraries => Branches.all( selected => filters.homebranch ) %]
</select>
</li>
<li>
<label>Item holding library:</label>
<select name="holdingbranch" id="holdingbranch">
<option value="">Any</option>
[% PROCESS options_for_libraries libraries => Branches.all( selected => filters.holdingbranch ) %]
</select>
</li>
<li>
<label>Library of the patron:</label>
<select name="branch" id="branch">
<option value="">Any</option>
[% PROCESS options_for_libraries libraries => Branches.all( selected => filters.branch, only_from_group => 1 ) %]
</select>
</li>
</ol>
<fieldset class="action">
<input type="submit" value="Apply filter" class="submit" />
<input type="hidden" name="op" value="apply filter" />
</fieldset>
</fieldset>
</form>
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
[% INCLUDE 'select2.inc' %]
<script>
function clone_input( node, original_id ) {
var original = node;
var clone = original.clone();
var appendid = original_id + "-" + Math.floor(Math.random()*1000+1);
clone.find(".delete_clone").show();
if( clone.find("select").length ){
/* <select> element is present */
clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid );
clone.find(".select2").remove();
original.after( clone );
$("#" + appendid ).select2();
} else {
clone.attr("id", appendid );
original.after( clone );
}
}
function update_date_due_filters_visibility(){
if( $("#showall").is(":checked")) {
$(".date_due_filter").hide();
$("#from").prop("disabled", true);
$("#to").prop("disabled", true);
} else {
$(".date_due_filter").show();
$("#from").prop("disabled", false);
$("#to").prop("disabled", false);
}
}
$(document).ready(function(){
var columns_settings = [% TablesSettings.GetColumns( 'circ', 'overdues', 'circ-overdues', 'json' ) | $raw %];
KohaTable("overduest", {
"sPaginationType": "full",
"aaSorting": [[0, 'asc']],
"autoWidth": false,
"stateSave": true
}, columns_settings);
$("#showall").on("change", function(){
update_date_due_filters_visibility();
});
update_date_due_filters_visibility();
$(".pattrodue-input").each(function(){
$(this).select2();
});
$("body").on("click", ".delete_clone", function(e){
e.preventDefault();
$(this).parent().remove();
});
$("body").on("click", ".clone-attribute", function(e){
e.preventDefault();
clone_input( $(this).parent(), $(this).data("original-id") );
})
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]