Koha/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
Alex Buckley 5c2daf28a5
Bug 13552: (follow-up) Add debar option to batch patron modification
As per test feedback I've changed wording from debarrment to restriction

Added insertion into the borrower_debarments table and removal from
borrower_debarments table (and borrowers.debarred and
borrowers.debarredcomment) when either 'Restriction
expiration' or 'Restriction comment' are ticket to be disabled/deleted.

Test plan (please follow this instead of following test plan in the
first patch):

1. Go to Tools > Batch patron modification

2. Input the cardnumbers of several (undebarred/unrestricted) patrons
and submit

3. Notice there is no input for setting Restriction expiration date or
Restriction comment

Also notice in the list of matching borrowers at the top of the page
there is no display of the 'Restriction expiration' or 'Restriction
comment' values for the patron

4. Apply patch

5. Restart memcached and plack

6. Refresh the page notice 'Restriction expiration' (a date picker
input) and 'Restriction comment'are now input options

Also notice in the table at the top of the page 'Restriction
expiration' and 'Restriction comment' are shown on the far right of the table (you may need
to scroll to see this)

7. Pick a date in the 'Restriction expired' datepicker and write in text into
the 'Restriction comment' field and submit

8. Notice in the next loaded page the selected patrons have the
'Restriction expiration' and 'Restriction comment' values you entered

9. Query the borrower_debarments database table and check that the new
debarments are added to this table

10. Go back to the Batch patron modification page and re-input the same
cardnumbers

11. Write text into the 'Restriction comment' field and don't pick a
'Restriction expiration' value and submit

12. Notice in the next loaded page the selected patrons have the
'Restriction expiration' value of 9999-12-31 and 'Restriction comment'
value you just entered

13. Query the borrowers table and notice the borrowers.debarred value
for the modified patrons is '9999-12-31' and the
borrower.debarredcomment is what you inputted in step 11

14. Query the borrower_debarments table and notice the expiration value
is NULL and the comment value is set to what you entered in step 11

Also note the addition of the new debarment has not removed the existing
debarment on the patrons

15. Click on the cardnumber link of one of the patrons and notice the red
text on their patron account page informing you they are restricted
until the date you set

16. In the Koha home directory enter Koha shell:
sudo koha-shell <instancename>

17. Run: prove xt

18. All tests should pass

19. Repeat step 10 and tick the checkbox beside the 'Restriction
expiration' field and submit

20. In the next loaded screen notice the 'Restricted expiration'and
'Restricted comment' are empty

Check the borrower_debarments table and notice all restrictions for the
patron are removed.

Check the borrowers table and notice the debarred and debarredcomment
fields are empty for the patrons

21. Repeat steps 10 and 11 to make a new restriction

22. Repeat step 19 and this time check the 'Restriction comment' field
and submit and observe that also clears the restriction in the next
loaded page, in the borrower_debarments and borrowers table

23. Sign off

Sponsored-By: Brimbank Library, Australia
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-08-13 11:49:43 +01:00

444 lines
25 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE Branches %]
[% USE Categories %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Batch patron modification</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="tools_modborrowers" class="tools">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a>
</div>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% IF ( op == 'show_form' ) %]
<h1>Batch patron modification</h1>
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
<fieldset class="rows">
<legend>Use a file</legend>
<ol>
<li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
</ol>
</fieldset>
[% IF patron_lists %]
<fieldset class="rows">
<legend>Or use a patron list</legend>
<ol>
<li>
<label for="patron_list_id">Patron list: </label>
<select id="patron_list_id" name="patron_list_id">
<option value=""></option>
[% FOREACH pl IN patron_lists %]
<option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
[% END %]
</select>
</li>
</ol>
</fieldset>
[% END %]
<fieldset class="rows">
<legend>Or list cardnumbers one by one</legend>
<ol>
<li>
<label for="cardnumberlist">Card number list (one cardnumber per line): </label>
<textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
</li>
</ol>
</fieldset>
<input type="hidden" name="op" value="show" />
<fieldset class="action">
<input type="submit" value="Continue" class="button" />
<a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
</fieldset>
</form>
[% END %]
[% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
[% op = 'noshow' # Change op to prevent display in code below %]
<h1>Batch patrons modification</h1>
<div class="dialog alert">
<p>No patron card numbers given.</p>
<form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
<button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
</form>
</div>
[% END #Alert if no patrons %]
[% IF ( op == 'show' or op == 'show_results' ) %]
[% IF ( op == 'show' ) %]
<h1>Batch patrons modification</h1>
[% ELSE %]
<h1>Batch patrons results</h1>
[% END %]
[% IF ( notfoundcardnumbers ) %]
<div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
<table style="margin:auto;">
<thead>
<tr><th>Cardnumbers not found</th></tr>
</thead>
<tbody>
[% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
<tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
[% END %]
</tbody>
</table>
[% END %]
[% IF ( op == 'show_results' ) %]
[% IF ( errors ) %]
<div class="dialog alert">
<h4>Errors occurred:</h4>
<ul class="warnings">
[% FOREACH error IN errors %]
[% IF ( error.error == 'can_not_update' ) %]
<li>Can not update patron.
[% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %]
(Borrowernumber: [% error.borrowernumber | html %])
</li>
[% ELSE %]
<li>[% error.error | html %]</li>
[% END %]
[% END %]
</ul>
</div>
[% END %]
[% END %]
[% IF ( op == 'show' ) %]
<form name="f" action="modborrowers.pl" method="post">
<input type="hidden" name="op" value="do" />
[% IF ( borrowers ) %]
<div id="toolbar"><a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-remove"></i> Clear all</a></div>
[% END %]
[% END %]
[% IF borrowers %]
<div id="cataloguing_additem_itemlist">
<div style="overflow:auto">
<table id="borrowerst">
<thead>
<tr>
[% IF ( op == 'show' ) %]
<th>&nbsp;</th>
[% END %]
<th>Card number</th>
<th>Surname</th>
<th>First name</th>
<th>Library</th>
<th>Category</th>
<th>City</th>
<th>State</th>
<th>ZIP/Postal code</th>
<th>Country</th>
<th class="title-string">Registration date</th>
<th class="title-string">Expiry date</th>
<th>Circulation note</th>
<th>Opac Note</th>
<th>Restriction expiration</th>
<th>Restriction comment</th>
[% FOREACH attrh IN attributes_header %]
<th>[% attrh.attribute | html %]</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH borrower IN borrowers %]
<tr>
[% IF ( op == 'show' ) %]
<td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
[% END %]
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
<td>[% borrower.surname | html %]</td>
<td>[% borrower.firstname | html %]</td>
<td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
<td>[% Categories.GetName(borrower.categorycode) | html %]</td>
<td>[% borrower.city | html %]</td>
<td>[% borrower.state | html %]</td>
<td>[% borrower.zipcode | html %]</td>
<td>[% borrower.country | html %]</td>
<td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
<td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
<td>[% borrower.borrowernotes | html %]</td>
<td>[% borrower.opacnote | html %]</td>
<td><span title="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</span></td>
<td>[% borrower.debarredcomment | html %]</td>
[% FOREACH pa IN borrower.patron_attributes %]
[% IF ( pa.code ) %]
<td>[% pa.code | html %]=[% pa.value | html %]</td>
[% ELSE %]
<td></td>
[% END %]
[% END %]
</tr>
[% END %]
</tbody>
</table>
</div>
</div>
[% IF ( op == 'show' ) %]
<div id="cataloguing_additem_newitem">
<h2>Edit patrons</h2>
<div class="hint">Checking the box right next to the label will disable the entry and delete the values of that field on all selected patrons</div>
<fieldset class="rows" id="fields_list">
<ol>
[% FOREACH field IN fields %]
<li>
[% IF ( field.mandatory ) %]
<label for="[% field.name | html %]" class="required">
[% ELSE %]
<label for="[% field.name | html %]">
[% END %]
[% SWITCH ( field.name ) %]
[% CASE 'surname' %]
Surname:
[% CASE 'firstname' %]
First name:
[% CASE 'branchcode' %]
Library:
[% CASE 'categorycode' %]
Category
[% CASE 'city' %]
City
[% CASE 'state' %]
State
[% CASE 'zipcode' %]
ZIP/Postal code
[% CASE 'country' %]
Country
[% CASE 'sort1' %]
Sort 1:
[% CASE 'sort2' %]
Sort 2:
[% CASE 'dateenrolled' %]
Registration date:
[% CASE 'dateexpiry' %]
Expiry date:
[% CASE 'borrowernotes' %]
Circulation note:
[% CASE 'opacnote' %]
OPAC note:
[% CASE 'debarred' %]
Restriction expiration:
[% CASE 'debarredcomment' %]
Restriction comment:
[% END %]
</label>
[% IF ( field.type == 'text' ) %]
<input type="text" name="[% field.name | html %]" value="" />
[% END %]
[% IF ( field.type == 'select' ) %]
[% IF field.option.size %]
<select name="[% field.name | html %]" >
[% FOREACH opt IN field.option %]
<option value="[% opt.value | html %]">[% opt.lib | html %]</option>
[% END %]
</select>
[% ELSE %]
There is no value defined for [% field.name | html %]
[% END %]
[% END %]
[% IF ( field.type == 'date' ) %]
<input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
<a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
[% END %]
[% IF field.mandatory %]
<input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
<span class="required">Required fields cannot be cleared</span>
[% ELSE %]
<input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
[% END %]
</li>
[% END %]
[% IF ( patron_attributes_codes ) %]
<li class="attributes">
<label style="width:auto;">Attribute:
<select name="patron_attributes">
<option value=""></option>
[% FOREACH pac IN patron_attributes_codes %]
<option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
[% END %]
</select>
</label>
<input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
<span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
<a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
<span class="information_category hint" style="width:25%;float:right;"></span>
</li>
[% END %]
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" name="mainformsubmit" value="Save" />
<a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
</fieldset>
</div>
</form>
[% END %]
[% END %]
[% END %]
[% IF ( op == 'show_results' ) %]
<p>
<a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
</p>
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'tools-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/tools-menu.js") | $raw %]
<script>
var patron_attributes_lib = new Array();
var patron_attributes_values = new Array();
$(document).ready(function() {
[% IF borrowers %]
$("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
"sDom": 't',
[% IF ( op == 'show_results' ) %]
"aoColumnDefs": [
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] }
],
[% ELSE %]
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] }
],
[% END %]
"bPaginate": false
}));
$("#selectallbutton").click(function() {
$("#borrowerst").find("input:checkbox").each(function() {
$(this).prop("checked", true);
});
return false;
});
$("#clearallbutton").click(function() {
$("#borrowerst").find("input:checkbox").each(function() {
$(this).prop("checked", false);
});
return false;
});
[% END %]
var values = new Array();
var lib = new Array();
[% FOREACH pav IN patron_attributes_values %]
values = new Array();
lib = new Array();
[% FOREACH option IN pav.options %]
values.push("[% option.lib | html %]");
lib.push("[% option.authorised_value | html %]");
[% END %]
patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
[% END %]
$('select[name="patron_attributes"]').change(function() {
updateAttrValues(this);
} );
$('select[name="patron_attributes"]').change();
$(".clear-date").on("click",function(e){
e.preventDefault();
var fieldID = this.id.replace("clear-date-","");
$("#" + fieldID).val("");
});
$("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
e.preventDefault();
add_attributes();
});
$("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
e.preventDefault();
del_attributes(this);
});
});
function updateAttrValues (select_attr) {
var attr_code = $(select_attr).val();
var selected_option = $(select_attr).find("option:selected");
var type = $(selected_option).attr('data-type');
var category = $(selected_option).attr('data-category');
var li_node = $(select_attr).parent().parent();
var span = $(li_node).find('span.patron_attributes_value');
var information_category_node = $(li_node).find('span.information_category');
information_category_node.html("");
if ( category && category.length > 0 ) {
information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
}
var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
if ( type == 'select' ) {
var options = '<option value = ""></option>';
for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
}
span.html('<select name="patron_attributes_value">' + options + '</select>');
$(disable_input_node).show();
} else if ( $(selected_option).val() != "" ) {
span.html('<input type="text" name="patron_attributes_value"/>');
$(disable_input_node).show();
} else {
span.html('<input type="hidden" name="patron_attributes_value" />');
$(disable_input_node).hide();
}
}
function add_attributes() {
var li_node = $("li.attributes:last");
var li_clone = $(li_node).clone();
if ( $(li_clone).find("a.del_attributes").length == 0 ) {
$(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
}
$(li_clone).find('select[name="patron_attributes"]').change(function() {
updateAttrValues(this);
} );
$(li_clone).find('select[name="patron_attributes"]').change();
$("#fields_list>ol").append(li_clone);
update_attr_values();
}
function del_attributes(a_node) {
$(a_node).parent('li').remove();
update_attr_values();
}
function update_attr_values() {
$("li.attributes").each(function(i) {
$(this).find("input:checkbox").val("attr"+i+"_value");
});
}
function clearDate(nodeid) {
$("#"+nodeid).val("");
}
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]