808ec53c14
Allows the user to delete multiple patron card batches. Test plan: 1. Add first some 20 batches 2. Go to the edit page of some X batch by first selecting from the batch list the batch you want to edit and then after that by clicking edit. 3. Delete one batch by selecting one batch and then clicking delete. 4. Select 0 batches and click delete, notice you cannot delete. 5. Select 0 batches and click edit, notice you cannot edit. 6. Select 2 batches and click edit, notice you cannot edit. 7. Apply patch 8. Check that steps from 2-6 work like they worked before. (and add more batches so that you have ~20 of them) 9. Select 2 batches and click delete. Make sure they are deleted. 10. Try to figure out some anomalies this patch might have caused. Sponsored-by: Vaara-kirjastot Followed test plan, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
213 lines
10 KiB
Text
213 lines
10 KiB
Text
[% BLOCK translate_card_element %]
|
|
[%- SWITCH element -%]
|
|
[%- CASE 'layout' -%]layout
|
|
[%- CASE 'Layouts' -%]Layouts
|
|
[%- CASE 'template' -%]template
|
|
[%- CASE 'Templates' -%]Templates
|
|
[%- CASE 'profile' -%]profile
|
|
[%- CASE 'Profiles' -%]Profiles
|
|
[%- CASE 'batch' -%]batch
|
|
[%- CASE 'Batches' -%]Batches
|
|
[%- CASE 'Actions' -%]Actions
|
|
[%- END -%]
|
|
[% END %]
|
|
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
<title>Koha › Tools › Patron card creator › [% PROCESS translate_card_element element=card_element_title %]</title>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
[% INCLUDE 'greybox.inc' %]
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this?");
|
|
function DeleteConfirm() {
|
|
var element_ids = selected_layouts("delete");
|
|
|
|
var answer;
|
|
if (element_ids.length > 1) {
|
|
var msg = _("Are you sure you want to delete %s batches?").format(element_ids.length);
|
|
answer = confirm(msg);
|
|
} else if (element_ids.length == 1) {
|
|
var msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]);
|
|
answer = confirm(msg);
|
|
}
|
|
|
|
if (answer) {
|
|
var elements = "";
|
|
for (var i = 0; i < element_ids.length; i++) {
|
|
if (element_ids[i] > -1) {
|
|
elements += element_ids[i] + ","
|
|
}
|
|
else {
|
|
return; // no layout selected
|
|
}
|
|
}
|
|
|
|
window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=" + elements;
|
|
}
|
|
else {
|
|
return; // abort delete
|
|
}
|
|
|
|
};
|
|
|
|
function Edit() {
|
|
var element_id = selected_layouts("edit");
|
|
if (element_id>-1) {
|
|
window.location = "/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=" + element_id;
|
|
}
|
|
else {
|
|
return; // no layout selected
|
|
};
|
|
};
|
|
function Xport() {
|
|
batches= new Array;
|
|
if(document.layouts.action.length > 0) {
|
|
for (var i=0; i < document.layouts.action.length; i++) {
|
|
if (document.layouts.action[i].checked) {
|
|
batches.push("batch_id=" + document.layouts.action[i].value);
|
|
}
|
|
}
|
|
if (batches.length < 1) {
|
|
alert(_("Please select at least one batch to export."));
|
|
return; // no batch selected
|
|
}
|
|
getstr = batches.join("&");
|
|
}
|
|
else if (document.layouts.action.checked) {
|
|
getstr = "batch_id="+document.layouts.action.value;
|
|
}
|
|
else {
|
|
alert(_("Please select at least one batch to export."));
|
|
return; // no batch selected
|
|
}
|
|
return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
|
|
};
|
|
function selected_layouts(op) {
|
|
var selected = new Array;
|
|
if (document.layouts.action.length) {
|
|
for (i=0;i<document.layouts.action.length;i++){
|
|
if (document.layouts.action[i].checked){
|
|
selected.push(i);
|
|
}
|
|
};
|
|
if (selected.length == 1 || (op == "delete" && selected.length >= 1)) {
|
|
if (op == "delete") {
|
|
var selectedDelete = new Array;
|
|
for (i = 0; i < selected.length; i++) {
|
|
selectedDelete.push(document.layouts.action[selected[i]].value);
|
|
}
|
|
return(selectedDelete);
|
|
} else {
|
|
// op == 'edit' returns only the object and not list
|
|
return(document.layouts.action[selected[0]].value);
|
|
}
|
|
}
|
|
else if (selected.length < 1) {
|
|
if (op == "edit") {
|
|
alert(_("Please select one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
|
|
return (-1);
|
|
} else {
|
|
alert(_("Please select at least one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
|
|
return (-1);
|
|
}
|
|
}
|
|
else {
|
|
alert(_("Please select only one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
|
|
return (-1);
|
|
}
|
|
}
|
|
else {
|
|
if (document.layouts.action.checked){
|
|
return(document.layouts.action.value);
|
|
}
|
|
};
|
|
alert(_("Please select a %s.").format("[% PROCESS translate_card_element element=card_element %]"));
|
|
return (-1);
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
$("#edit").click(function(){
|
|
Edit();
|
|
return false;
|
|
});
|
|
$("#delete").click(function(){
|
|
DeleteConfirm();
|
|
return false;
|
|
});
|
|
$("#print").click(function(){
|
|
Xport();
|
|
return false;
|
|
});
|
|
});
|
|
//]]>
|
|
</script>
|
|
</head>
|
|
<body id="pcard_manage" class="tools pcard">
|
|
[% INCLUDE 'header.inc' %]
|
|
[% INCLUDE 'cat-search.inc' %]
|
|
<div id="breadcrumbs">
|
|
<a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
|
|
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
|
|
<a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> ›
|
|
[% PROCESS translate_card_element element=card_element_title %]
|
|
</div>
|
|
<div id="doc3" class="yui-t2">
|
|
<div id="bd">
|
|
<div id="yui-main">
|
|
<div class="yui-b">
|
|
[% INCLUDE 'patroncards-toolbar.inc' %]
|
|
[% INCLUDE 'patroncards-errors.inc' %]
|
|
<div class="yui-gc">
|
|
<div class="yui-u first" id="manage-patroncards-layouts">
|
|
<div class="hint">Current library: [% LoginBranchname %]</div>
|
|
[% IF ( table_loop ) %]
|
|
<form name="layouts" action="/cgi-bin/koha/manage.pl?card_element=[% card_element %]">
|
|
<h2>Currently available [% PROCESS translate_card_element element=card_element_title FILTER lower %]</h2>
|
|
<table>
|
|
[% FOREACH table_loo IN table_loop %]
|
|
[% IF ( table_loo.header_fields ) %]
|
|
<tr>
|
|
[% FOREACH header_field IN table_loo.header_fields %]
|
|
[% SWITCH header_field.field_label -%]
|
|
[% CASE "Select" -%]
|
|
[% IF ( print ) %]<th>Select</th>[% END %]
|
|
[% CASE %]
|
|
<th>[% header_field.field_label %]</th>
|
|
[% END -%]
|
|
[% END %]
|
|
</tr>
|
|
[% ELSE %]
|
|
<tr>
|
|
[% FOREACH text_field IN table_loo.text_fields %]
|
|
[% IF ( text_field.select_field ) %]
|
|
<td>
|
|
<a class="btn btn-mini" href="/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=[% text_field.field_value %]"><icon class="fa fa-edit"></icon> Edit</a>
|
|
[% IF ( print ) %]<a class="btn btn-mini" href="#" onclick="GB_showCenter('Export single batch','/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]')"><icon class="fa fa-share-square-o"></icon> Export</a>[% END %]
|
|
<a class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_DELETE);" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=[% text_field.field_value %]"><icon class="fa fa-trash"></icon> Delete</a>
|
|
</td>
|
|
[% IF ( print ) %]<td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>[% END %]
|
|
[% ELSIF ( text_field.field_value ) %]
|
|
<td>[% text_field.field_value %]</td>
|
|
[% ELSE %]
|
|
<td> </td>
|
|
[% END %]
|
|
[% END %]
|
|
</tr>
|
|
[% END %]
|
|
[% END %]
|
|
</table>
|
|
<fieldset class="action">
|
|
[% IF ( print ) %]<input class="btn btn-sm" type="button" id="print" value="Export selected batches" />[% END %]
|
|
</fieldset>
|
|
</form>
|
|
[% ELSE %]
|
|
<div class="dialog message">
|
|
<h4>There are no [% PROCESS translate_card_element element=card_element_title %] currently available.</h4>
|
|
<p>Use the toolbar above to create a new [% PROCESS translate_card_element element=card_element %].</p></div>
|
|
[% END %]
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|