Bug 28726: Add sort1 and sort2 to patron card creator - patron search.

Also adds a select all / clear all and checkboxes.

Test plan:

1. start a new batch in the patron card creator (Tools -> Patron card creator -> New -> card batch)
2. click the Add patron(s) button.  Observe that Category and Library are the only options.
3. Close search for patron window.
4. Apply patch.
5. click the Add patron(s) button.  Observe that you can now search for patrons by their sort1 and sort2 values.
6. perform a search and observe the 'Select all | Clear all | Add selected patrons' links and button.
7. use the Select all link to select all the patrons found by the search.
8. use the Add selected patrons button to add the selected patrons to the card batch's Add by borrowernumber(s) text input field.
9. close the search for patron window.

Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 79f8e148af)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit f1e90cc4c2)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Michael Hafen 2021-07-20 12:12:42 -06:00 committed by Matt Blenkinsop
parent bafe8a2652
commit c897101348
3 changed files with 103 additions and 4 deletions

View file

@ -56,6 +56,16 @@
[% END %]
</select>
</li>
[% CASE 'sort1' %]
<li>
<label for="sort1_filter">Sort1:</label>
[% PROCESS 'av-build-dropbox.inc' name="sort1_filter", category="Bsort1", empty=1, size = 20 %]
</li>
[% CASE 'sort2' %]
<li>
<label for="sort2_filter">Sort2:</label>
[% PROCESS 'av-build-dropbox.inc' name="sort2_filter", category="Bsort2", empty=1, size = 20 %]
</li>
[% CASE 'search_field' %]
<li>
[% INCLUDE patron_fields_dropdown %]
@ -197,6 +207,8 @@
[% IF redirect_if_one_result && !redirect_url %]
<script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
[% END %]
[% INCLUDE 'select2.inc' %]
<script>
let categories = [% To.json(categories) | $raw %].map(e => {
e['_id'] = e.categorycode.toLowerCase();
@ -221,6 +233,10 @@
let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
[% END %]
$(document).ready(function() {
$('select#sort1_filter').select2({allowClear:true});
$('select#sort2_filter').select2({allowClear:true});
});
</script>
[% INCLUDE 'datatables.inc' %]
@ -298,11 +314,31 @@
return { "like": start_with + "%" }
},
"-and": function(){
let filters = [];
let f_sort1 = $("#sort1_filter").val();
if ( f_sort1 ) {
filters.push({
"me.sort1": f_sort1
});
}
let f_sort2 = $("#sort2_filter").val();
if ( f_sort2 ) {
filters.push({
"me.sort2": f_sort2
});
}
let pattern = $("#search_patron_filter").val();
if (!pattern) return "";
if (!pattern) {
if ( filters.length == 0 ) {
return "";
}
else {
return filters;
}
}
let patterns = pattern.split(/[\s,]+/).filter(function(s){ return s.length });
let filters = [];
let search_type = $("#searchtype_filter").val() || "contain";
let search_fields = $("#searchfieldstype_filter").val();
if ( !search_fields ) {
@ -738,6 +774,24 @@
if ( $("#branchcode_filter").val() ) {
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
}
if ( $("#sort1_filter").val() ) {
searched += _(" with sort1 ")
if ( $("select#sort1_filter") ) {
searched += $("select#sort1_filter").find("option:selected").text();
}
else {
searched += $("#sort1_filter").val();
}
}
if ( $("#sort2_filter").val() ) {
searched += _(" with sort2 ");
if ( $("select#sort2_filter") ) {
searched += $("select#sort2_filter").find("option:selected").text();
}
else {
searched += $("#sort2_filter").val();
}
}
$("#searchpattern").text(searched);
$("#searchpattern").parent().show();
}
@ -795,6 +849,8 @@
$("#searchtype_filter option[value='contain']").prop("selected", true);
$("#categorycode_filter option:first").prop("selected", true);
$("#branchcode_filter option:first").prop("selected", true);
$("#sort1_filter").val('').trigger("change");
$("#sort2_filter").val('').trigger("change");
$("#firstletter_filter").val('');
$("#search_patron_filter").val('');
/* remove any search string added by firstletter search */

View file

@ -17,10 +17,24 @@
<div id="patron_search">
<div class="container-fluid">
[% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['branch', 'category'], search_filter => searchmember %]
[% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['branch','category','sort1','sort2'], search_filter => searchmember %]
</form>
<div id="searchresults">
<div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
<div>
[% IF columns.grep('checkbox').size %]
<a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
|
<a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
[% IF selection_type == 'add' %]
<button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
[% END %]
[% END %]
</div>
</div>
[% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
</div>
<div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
@ -28,6 +42,35 @@
</div>
[% MACRO jsinclude BLOCK %]
<script>
$(document).ready(function() {
$("#select_all").on("click",function(e){
e.preventDefault();
$(".selection").prop("checked", true).change();
});
$("#clear_all").on("click",function(e){
e.preventDefault();
$(".selection").prop("checked", false).change();
});
$("#searchheader").hide();
$("#patron_search_form").on('submit', function(){$("#searchheader").show();});
$("#clear_search").on("click",function(e){$("#searchheader").hide();});
$('#add-selected').on('click', function(e) {
e.preventDefault();
var counter = 0;
$('tr:has(.selection:checked) .add_user').each(function(){
var borrowernumber = $(this).data('borrowernumber');
var firstname = $(this).data('firstname');
var surname = $(this).data('surname');
add_user( borrowernumber, firstname + ' ' + surname );
counter++;
});
$('#info').html(_("%s Patrons added.").format(counter));
});
});
</script>
[% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %]
[% END %]

View file

@ -188,7 +188,7 @@
function Add() {
var bor_nums = document.getElementById("bor_num_list");
if (bor_nums.value == '') {
window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
window.open("/cgi-bin/koha/members/search.pl?columns=checkbox,cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
'PatronPopup',
'width=1024,height=768,location=yes,toolbar=no,'
+ 'scrollbars=yes,resize=yes');