Koha/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt
Jonathan Druart 81bc300957
Bug 36251: (bug 35329 follow-up) Fix patron search by first letter when placing a hold
Most of the patrons searches open in a modal. Except:
* the main one (members-home)
* when placing a hold
* when requesting an article
(did I miss one?)

The patron-search.inc BLOCKs need a parent block to know where to locate
the elements (form, table, etc), because we can have several patron
searches on the same page.

Bug 35329 reused '#searchresults':
  10 [% SET search_results_block_id = 'searchresults' %]
which is used on the main patron search.
The ones in the modal are correctly handled: we build the parent node in
the "patron_search_modal" block.
But for the 2 others the parent block id is wrong.

On reserve/request.tt we have one already, so we set the TT variable from the
.tt file
On circ/request-article we don't have one already, so we can reuse
searchresults (could be more specific however to include 'patrons'...)

Test plan:
Browse patrons by first letter when placing a hold and requesting an
article

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-12 17:47:36 +01:00

448 lines
24 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[% USE raw %]
[% USE Asset %]
[% USE Context %]
[% USE KohaDates %]
[% USE Branches %]
[% USE Categories %]
[% USE ItemTypes %]
[% USE AuthorisedValues %]
[% USE Price %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% SET article_requests_view = 1 %]
[% SET biblionumber = biblio.biblionumber %]
[% INCLUDE 'doc-head-open.inc' %]
[% SET libraries = Branches.all %]
[% SET categories = Categories.all.unblessed %]
[% SET columns = ['name', 'address', 'cardnumber', 'dateofbirth', 'category', 'branch', 'phone'] %]
[% PROCESS "patron-search.inc" %]
<title>[% FILTER collapse %]
[% t("Request article") | html %] &rsaquo;
[% t("Circulation") | html %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
[% BLOCK cancel_modal %]
<div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Confirm deletion</h3>
</div>
<div class="modal-body">
<p>Are you sure you want to cancel this article request?</p>
<fieldset class="action">
[% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
[% IF ar_cancellation.count %]
<label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
<select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
<option value="" selected>Other reasons</option>
[% FOREACH reason IN ar_cancellation %]
<option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
[% END %]
</select>
[% END %]
</fieldset>
<fieldset class="action">
<div class="hint col-sm-offset-4">Enter reason</div>
<input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
</fieldset>
</div>
<div class="modal-footer">
<button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
<a href="#" data-dismiss="modal">Cancel</a>
</div>
</div>
</div>
</div>
[% END %]
<body id="circ_request-article" class="circ">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'circ-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% IF blocking_error %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Catalog</span>
[% END %]
[% ELSE %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
[% END %]
[% WRAPPER breadcrumb_item %]
[% INCLUDE 'biblio-title.inc' link = 1 %]
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Request article</span>
[% END %]
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% INCLUDE 'messages.inc' %]
<h1>Request article from [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
[% IF error_message %]
<div class="dialog alert">
[% SWITCH error_message %]
[% CASE 'article_request_limit_reached' %]<p>Patron reached daily limit.</p>
[% CASE 'article_request_unhandled_exception' %]<p>An error has occurred. Check the logs for details.</p>
[% END %]
</div>
[% END %]
[% UNLESS patron %]
<fieldset id="searchresults" class="brief">
<label>Search patrons</label>
[% PROCESS patron_search_filters_simple %]
[% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
</fieldset>
[% ELSE %]
[% IF biblio.can_article_request( patron ) %]
[% IF article_request_fee > 0 %]
<div class="dialog alert">
Patron will be charged with <strong>[% article_request_fee | $Price %]</strong> for every request
</div>
[% END %]
<form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-create" />
<input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id | html %]" />
<fieldset class="rows">
<legend>Place article request from [% biblio.title | html %] for [% patron.firstname | html %] [% patron.surname | html %] ( [% patron.cardnumber | html %] )</legend>
<ol>
<li>
<label for="title">Title:</label>
<input type="text" name="title" id="title" size="50"/>
</li>
<li>
<label for="author">Author:</label>
<input type="text" name="author" id="author" size="50"/>
</li>
<li>
<label for="volume">Volume:</label>
<input type="text" name="volume" id="volume" size="50"/>
</li>
<li>
<label for="issue">Issue:</label>
<input type="text" name="issue" id="issue" size="50"/>
</li>
<li>
<label for="date">Date:</label>
<input type="text" name="date" id="date" size="50"/>
</li>
<li>
<label for="toc_request">Table of contents:</label>
<input type="checkbox" name="toc_request" value="1"/>
</li>
<li>
<label for="pages">Pages:</label>
<input type="text" name="pages" id="pages" size="50"/>
</li>
<li>
<label for="chapters">Chapters:</label>
<input type="text" name="chapters" id="chapters" size="50"/>
</li>
<li>
<label for="patron_notes">Patron notes:</label>
<input type="text" name="patron_notes" id="patron_notes" size="50"/>
</li>
<li>
<label for="format">Format:</label>
<select name="format" id="format">
<option value="PHOTOCOPY">Photocopy</option>
<option value="SCAN">Digital scan</option>
</select>
</li>
<li>
<label for="branchcode">Pickup library:</label>
<select name="branchcode" id="branchcode">
[% FOREACH b IN Branches.all %]
[% IF b.branchcode == Branches.GetLoggedInBranchcode %]
<option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
[% ELSE %]
<option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
[% END %]
[% END %]
</select>
</li>
</ol>
</fieldset>
[% SET article_request_type = biblio.article_request_type( patron ) %]
[% IF article_request_type != 'bib_only' %]
<div class="page-section">
<table id="current-requests-table" class="ar-table table table-bordered table-striped">
<caption>Select item:</caption>
<thead>
<tr>
<th>&nbsp;</th>
<th>Item type</th>
<th>Barcode</th>
<th>Home library</th>
<th>Call number</th>
<th>Enumeration</th>
</tr>
</thead>
<tbody>
[% FOREACH item IN biblio.items %]
[% IF item.can_article_request( patron ) %]
<tr>
<td>
[% IF article_request_type == 'item_only' && !checked %]
[% SET checked = 1 %]
<input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
[% ELSE %]
<input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
[% END %]
</td>
<td>
[% ItemTypes.GetDescription( item.itype ) | html %]
</td>
<td>
[% item.barcode | html %]
</td>
<td>
[% Branches.GetName( item.homebranch ) | html %]
</td>
<td>
[% item.itemcallnumber | html %]
</td>
<td>
[% item.enumchron | html %]
</td>
</tr>
[% END %]
[% END %]
[% IF article_request_type != 'item_only' %]
<tr>
<td>
<input type="radio" name="itemnumber" value="" checked="checked"/>
</td>
<td colspan="5">
Any item
</td>
</tr>
[% END %]
</tbody>
</table>
</div><!-- /.page-section -->
[% END %]
<p>
<input type="submit" class="btn btn-default" value="Place request" />
</p>
</form>
[% ELSE %]
No article requests can be made for this record.
[% END %]
[% END %]
[% SET biblio_current_article_requests = Context.Scalar( Context.Scalar( biblio, 'article_requests' ), 'filter_by_current' ) %]
[% IF biblio_current_article_requests.count > 0 && !patron %]
<fieldset class="rows left" id="current-article-requests-fieldset">
<legend>Current article requests</legend>
<table id="current-article-requests-table">
<tr>
<th>Placed on</th>
<th>Patron</th>
<th>Title</th>
<th>Author</th>
<th>Volume</th>
<th>Issue</th>
<th>Date</th>
<th>TOC</th>
<th>Pages</th>
<th>Chapters</th>
<th>Patron notes</th>
<th>Format</th>
<th>Item</th>
<th>Status</th>
<th>Pickup library</th>
<th>&nbsp;</th>
</tr>
[% FOREACH ar IN biblio_current_article_requests %]
<tr>
<td>[% ar.created_on | $KohaDates %]</td>
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber | uri %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
<td>[% ar.title | html %]</td>
<td>[% ar.author | html %]</td>
<td>[% ar.volume | html %]</td>
<td>[% ar.issue | html %]</td>
<td>[% ar.date | html %]</td>
<td>[% IF ar.toc_request %]Yes[% END %]</td>
<td>[% ar.pages | html %]</td>
<td>[% ar.chapters | html %]</td>
<td>[% ar.patron_notes | html %]</td>
<td>[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
<td>
[% IF ar.item %]
<a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber | uri %]&biblionumber=[% ar.biblionumber | uri %]">[% ar.item.barcode | html %]</a>
[% END %]
</td>
<td>
[% IF ar.status == 'PENDING' %]
<span>Pending</span>
[% ELSIF ar.status == 'PROCESSING' %]
<span>Processing</span>
[% ELSIF ar.status == 'REQUESTED' %]
<span>New</span>
[% ELSIF ar.status == 'COMPLETED' %]
<span>Completed</span>
[% ELSIF ar.status == 'CANCELED' %]
<span>Canceled</span>
[% END %]
</td>
<td>
<i id="update-processing-[% ar.id | html %]" class="fa fa-cog fa-spin hidden"></i>
<select name="branchcode" id="branchcode-[% ar.id | html %]" class="ar-update-branchcode">
[% FOREACH b IN Branches.all %]
[% IF b.branchcode == ar.branchcode %]
<option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
[% ELSE %]
<option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
[% END %]
[% END %]
</select>
</td>
<td>
<a title="Cancel article request" href="#" id="cancel-[% ar.id | html %]" class="ar-cancel-request">
<i id="cancel-processing-spinner-[% ar.id | html %]" class="fa fa-cog fa-spin hide"></i>
<i id="cancel-processing-[% ar.id | html %]" class="fa fa-times fa-lg" style="color:red"></i>
</a>
</td>
</tr>
[% END %]
</table>
</fieldset>
[% PROCESS cancel_modal %]
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'biblio-view-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script>
$('#current-article-requests').ready(function() {
$(".hide").hide();
});
$(document).ready(function() {
$( ".ar-update-branchcode" ).on('focus', function(){
previous_branchcode = this.value;
})
$('#modal-cancellation-reason').on('change', function(e) {
let reason = $(this).val();
$('#modal-notes').attr('disabled', !!reason);
})
let cancel_a;
$("#cancelModalConfirmBtn").on("click",function(e) {
var id = cancel_a.attr('id').split("cancel-")[1];
$("#cancel-processing-" + id ).hide('slow');
$("#cancel-processing-spinner-" + id ).show('slow');
let reason = $("#modal-cancellation-reason").val();
let notes = $("#modal-notes").val();
let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
$.ajax({
type: "DELETE",
url: '/api/v1/article_requests/'+id+query,
success: function( data ) {
cancel_a.parents('tr').hide('slow');
}
});
});
$(".ar-cancel-request").on("click", function(){
cancel_a = $(this);
$('#cancelModal').modal();
});
// Initialize format(s)
var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | $raw %]";
if( !supported_formats.match(/PHOTOCOPY/) )
$('#format option[value="PHOTOCOPY"]').remove();
if( !supported_formats.match(/SCAN/) )
$('#format option[value="SCAN"]').remove();
if( $('#format option').length > 1 ) {
// Select first listed format
var first_format = supported_formats.split('|')[0].replace(/^\s*|\s*$/g, '');
$('#format option[value="'+first_format+'"]').attr('selected', true);
}
});
$(".ar-update-branchcode").on('change', async function(e){
var branchcode = this.value;
var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
if ( c ) {
var id = this.id.split("branchcode-")[1];
$("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
const client = APIClient.article_request;
await client.articleRequests.update_library_id(id, branchcode).then(
success => {
$("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
},
error => {
console.warn("Something wrong happened: %s", error);
}
);
} else {
this.value = previous_branchcode;
}
});
</script>
[% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]