Bug 19961: Move template JavaScript to the footer: Patron card creator

This patch modifies the staff client patron card creator templates so
that JavaScript is included in the footer instead of the header.

Also changed: Removed "type" attribute from script tags.

To test, apply the patch and test the JavaScript-driven features of
each modified template: All button controls, DataTables functionality,
form validation, etc.

- Creating and managing layouts
- Creating and managing card batches
- Creating and managing card templates
- Creating and managing printer profiles
- Creating and managing images

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2018-02-21 19:40:06 +00:00 committed by Jonathan Druart
parent f9f2d9d861
commit 95f881b969
7 changed files with 561 additions and 536 deletions

View file

@ -1,162 +1,10 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Batches &rsaquo; [% IF batch_id %]Edit ([% batch_id %])[% ELSE %]New[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'greybox.inc' %]
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
//<![CDATA[
function DeleteConfirm() {
var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id %]";
}
else {
return; // abort delete
}
};
function Remove() {
items = new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
items.push("label_id=" + document.items.action[i].value);
}
}
getstr = items.join("&");
var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
} else if (document.items.action.checked) {
alert(_("Deletion of patron from a batch with only one patron will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
return; // no deletion for single item batch
}
else {
alert(_("Please select at least one patron to delete."));
return; // no item selected
}
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
}
else {
return; // abort delete
}
};
function Add() {
var bor_nums = document.getElementById("bor_num_list");
if (bor_nums.value == '') {
window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
'PatronPopup',
'width=840,height=500,location=yes,toolbar=no,'
+ 'scrollbars=yes,resize=yes');
}
else {
document.forms["add_by_bor_num"].submit();
}
};
function add_user(borrowernumber) {
$("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
}
function DeDuplicate() {
window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
};
function Xport(mode) {
if (mode == 'label') {
patroncards= new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
patroncards.push("label_id=" + document.items.action[i].value);
}
}
if (patroncards.length < 1) {
alert(_("Please select at least one card to export."));
return; // no batch selected
}
getstr = patroncards.join("&");
}
else if (document.items.action.checked) {
getstr = document.items.action.value;
}
else {
alert(_("Please select at least one card to export."));
return; // no batch selected
}
return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 400, 800);
}
else if (mode == 'batch') {
return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 400, 800);
}
else {
// some pass-thru error trapping just in case...
}
};
function selected_layout() {
if (document.items.action.length) {
for (i=0;i<document.items.action.length;i++){
if (document.items.action[i].checked==true){
return(document.items.action[i].value);
}
};
}
else {
if (document.items.action.checked){
return(document.items.action.value);
}
};
alert(_("Please select at least one item."));
return (-1);
};
$(document).ready(function() {
$("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
],
"aaSorting": [[ 0, "asc" ]],
"sPaginationType": "four_button",
"autoWidth": false
}));
$("#additems").click(function(){
Add();
return false;
});
$("#removeitems").click(function(){
Remove();
return false;
});
$("#deletebatch").click(function(){
DeleteConfirm();
return false;
});
$("#deduplicate").click(function(){
DeDuplicate();
return false;
});
$("#exportitems").click(function(){
Xport('label');
return false;
});
$("#exportbatch").click(function(){
Xport('batch');
return false;
});
$(".delete").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
});
$(".export").on("click", function(e){
e.preventDefault();
var label_id = $(this).data("label-id");
var batch_id = $(this).data("batch-id");
GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id+'&label_id='+label_id, 400, 800);
});
});
//]]>
</script>
<link rel="stylesheet" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
</head>
<body id="pcard_edit-batch" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -274,4 +122,151 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'greybox.inc' %]
[% INCLUDE 'datatables.inc' %]
<script>
function DeleteConfirm() {
var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id %]";
} else {
return; // abort delete
}
};
function Remove() {
items = new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
items.push("label_id=" + document.items.action[i].value);
}
}
getstr = items.join("&");
var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
} else if (document.items.action.checked) {
alert(_("Deletion of patron from a batch with only one patron will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
return; // no deletion for single item batch
} else {
alert(_("Please select at least one patron to delete."));
return; // no item selected
}
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
} else {
return; // abort delete
}
};
function Add() {
var bor_nums = document.getElementById("bor_num_list");
if (bor_nums.value == '') {
window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
'PatronPopup',
'width=840,height=500,location=yes,toolbar=no,'
+ 'scrollbars=yes,resize=yes');
} else {
document.forms["add_by_bor_num"].submit();
}
};
function add_user(borrowernumber) {
$("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
}
function DeDuplicate() {
window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
};
function Xport(mode) {
if (mode == 'label') {
patroncards= new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
patroncards.push("label_id=" + document.items.action[i].value);
}
}
if (patroncards.length < 1) {
alert(_("Please select at least one card to export."));
return; // no batch selected
}
getstr = patroncards.join("&");
} else if (document.items.action.checked) {
getstr = document.items.action.value;
} else {
alert(_("Please select at least one card to export."));
return; // no batch selected
}
return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 400, 800);
} else if (mode == 'batch') {
return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 400, 800);
} else {
// some pass-thru error trapping just in case...
}
};
function selected_layout() {
if (document.items.action.length) {
for (i=0;i<document.items.action.length;i++){
if (document.items.action[i].checked==true){
return(document.items.action[i].value);
}
};
} else {
if (document.items.action.checked){
return(document.items.action.value);
}
};
alert(_("Please select at least one item."));
return (-1);
};
$(document).ready(function() {
$("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
],
"aaSorting": [[ 0, "asc" ]],
"sPaginationType": "four_button",
"autoWidth": false
}));
$("#additems").click(function(){
Add();
return false;
});
$("#removeitems").click(function(){
Remove();
return false;
});
$("#deletebatch").click(function(){
DeleteConfirm();
return false;
});
$("#deduplicate").click(function(){
DeDuplicate();
return false;
});
$("#exportitems").click(function(){
Xport('label');
return false;
});
$("#exportbatch").click(function(){
Xport('batch');
return false;
});
$(".delete").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
});
$(".export").on("click", function(e){
e.preventDefault();
var label_id = $(this).data("label-id");
var batch_id = $(this).data("batch-id");
GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id+'&label_id='+label_id, 400, 800);
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,111 +1,9 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Layout &rsaquo; [% IF ( layout_id ) %]Edit ([% layout_id %])[% ELSE %]New[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
$(document).ready(function() {
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#font_size,#field_1_llx,#field_1_lly,#field_2_llx,#field_2_lly,#field_3_llx,#field_3_lly,#barcode_Tx,#barcode_Ty,#image_1_Dx,#image_1_Tx,#image_1_Ty,#image_2_Dx,#image_2_Tx,#image_2_Ty");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
Go($("#image_1_image_source").val(), 'image_1_image_name');
Go($("#image_1_image_source").val(), 'image_1_image_metrics');
$("#image_1_image_source").change(function(){
$(".image_1_image_source").html(Go($(this).val(), 'image_1_image_name'));
$(".image_1_image_source").html(Go($(this).val(), 'image_1_image_metrics'));
});
Go($("#image_2_image_source").val(), 'image_2_image_name');
Go($("#image_2_image_source").val(), 'image_2_image_metrics');
$("#image_2_image_source").change(function(){
$(".image_2_image_source").html(Go($(this).val(), 'image_2_image_name'));
$(".image_2_image_source").html(Go($(this).val(), 'image_2_image_metrics'));
});
var selectFieldNames = ["field_1","field_2","field_3"];
for (var i=0; i < selectFieldNames.length; i++) {
Go($("#"+selectFieldNames[i]+"_enable").prop("checked"), selectFieldNames[i]+"_select");
}
$("#field_1_enable").change(function(){
$(".field_1_enable").html(Go($(this).prop("checked"), 'field_1_select'));
});
$("#field_2_enable").change(function(){
$(".field_2_enable").html(Go($(this).prop("checked"), 'field_2_select'));
});
$("#field_3_enable").change(function(){
$(".field_3_enable").html(Go($(this).prop("checked"), 'field_3_select'));
});
$("#barcode_print").load(barcode_text('barcode_param'));
$("#barcode_print").change(function(){
barcode_text('barcode_param');
});
function barcode_text(division) {
var eBarcode = document.getElementById(division);
if( $("input[name=barcode_print]:checked").prop("checked") ) {
eBarcode.style.display = 'block';
} else {
eBarcode.style.display = 'none';
$('input[name=barcode_text_print]').prop('checked', false);
}
}
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = " pt";
}
return unit;
}
function Go(oSelect, oElement){
var element = document.getElementById(oElement);
switch(true) {
case /^.*_name/.test(oElement):
if ((oSelect == 'patronimages') || (oSelect == 'none')) {
element.style.display = 'none';
}
else {
element.style.display = 'block';
}
break;
case /^.*_metrics/.test(oElement):
if ((oSelect == 'none') || (oSelect == '')) {
element.style.display = 'none';
}
else {
element.style.display = 'block';
}
break;
case /^.*_select/.test(oElement):
if (!oSelect) {
element.style.display = 'none';
}
else {
element.style.display = 'block';
}
break;
default:
return;
}
return;
}
});
//]]>
</script>
</head>
<body id="pcard_edit-layout" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -568,4 +466,107 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script>
$(document).ready(function() {
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#font_size,#field_1_llx,#field_1_lly,#field_2_llx,#field_2_lly,#field_3_llx,#field_3_lly,#barcode_Tx,#barcode_Ty,#image_1_Dx,#image_1_Tx,#image_1_Ty,#image_2_Dx,#image_2_Tx,#image_2_Ty");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
Go($("#image_1_image_source").val(), 'image_1_image_name');
Go($("#image_1_image_source").val(), 'image_1_image_metrics');
$("#image_1_image_source").change(function(){
$(".image_1_image_source").html(Go($(this).val(), 'image_1_image_name'));
$(".image_1_image_source").html(Go($(this).val(), 'image_1_image_metrics'));
});
Go($("#image_2_image_source").val(), 'image_2_image_name');
Go($("#image_2_image_source").val(), 'image_2_image_metrics');
$("#image_2_image_source").change(function(){
$(".image_2_image_source").html(Go($(this).val(), 'image_2_image_name'));
$(".image_2_image_source").html(Go($(this).val(), 'image_2_image_metrics'));
});
var selectFieldNames = ["field_1","field_2","field_3"];
for (var i=0; i < selectFieldNames.length; i++) {
Go($("#"+selectFieldNames[i]+"_enable").prop("checked"), selectFieldNames[i]+"_select");
}
$("#field_1_enable").change(function(){
$(".field_1_enable").html(Go($(this).prop("checked"), 'field_1_select'));
});
$("#field_2_enable").change(function(){
$(".field_2_enable").html(Go($(this).prop("checked"), 'field_2_select'));
});
$("#field_3_enable").change(function(){
$(".field_3_enable").html(Go($(this).prop("checked"), 'field_3_select'));
});
$("#barcode_print").load(barcode_text('barcode_param'));
$("#barcode_print").change(function(){
barcode_text('barcode_param');
});
function barcode_text(division) {
var eBarcode = document.getElementById(division);
if( $("input[name=barcode_print]:checked").prop("checked") ) {
eBarcode.style.display = 'block';
} else {
eBarcode.style.display = 'none';
$('input[name=barcode_text_print]').prop('checked', false);
}
}
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = " pt";
}
return unit;
}
function Go(oSelect, oElement){
var element = document.getElementById(oElement);
switch(true) {
case /^.*_name/.test(oElement):
if ((oSelect == 'patronimages') || (oSelect == 'none')) {
element.style.display = 'none';
} else {
element.style.display = 'block';
}
break;
case /^.*_metrics/.test(oElement):
if ((oSelect == 'none') || (oSelect == '')) {
element.style.display = 'none';
} else {
element.style.display = 'block';
}
break;
case /^.*_select/.test(oElement):
if (!oSelect) {
element.style.display = 'none';
} else {
element.style.display = 'block';
}
break;
default:
return;
}
return;
}
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,41 +1,9 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Profiles &rsaquo; [% IF ( profile_id ) %]Edit ([% profile_id %])[% ELSE %]New[% END%]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#offset_horz,#offset_vert,#creep_horz,#creep_vert");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = "";
}
return unit;
}
});
//]]>
</script>
</head>
<body id="pcard_edit-profile" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -138,4 +106,40 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script>
$(document).ready(function(){
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#offset_horz,#offset_vert,#creep_horz,#creep_vert");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = "";
}
return unit;
}
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,41 +1,9 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Templates &rsaquo; [% IF (template_id) %]Edit ([% template_id %])[% ELSE %]New[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#page_height,#page_width,#card_width,#card_height,#top_margin,#left_margin,#col_gap,#row_gap");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = "";
}
return unit;
}
});
//]]>
</script>
</head>
<body id="pcard_edit-template" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -188,4 +156,41 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
<script>
$(document).ready(function(){
var selectedUnit = $("#units option:selected").attr("value");
var unitfields = $("#page_height,#page_width,#card_width,#card_height,#top_margin,#left_margin,#col_gap,#row_gap");
$(unitfields).after("<span class=\"unit\">"+getUnit(selectedUnit)+"</span>");
$("#units").change(function(){
$(".unit").html(getUnit($(this).val()));
});
function getUnit(unit){
switch(unit){
case "POINT":
var unit = " pt";
break;
case "AGATE":
var unit = " ag";
break;
case "INCH":
var unit = " in";
break;
case "MM":
var unit = " mm";
break;
case "CM":
var unit = " cm";
break;
default:
var unit = "";
}
return unit;
}
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,52 +1,9 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Images</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
function DeleteConfirm() {
var results = selected_images("delete");
if (results.images) {
var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids);
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/image-manage.pl?op=delete&" + results.images;
} else {
return; // abort delete
}
} else {
alert(_("Please select image(s) to delete."));
}
}
function selected_images(op) {
var selected = new Array;
var image_ids = new Array;
if (document.delete_images.action.length) {
for (i=0;i<document.delete_images.action.length;i++){
if (document.delete_images.action[i].checked){
selected.push("image_id=" + document.delete_images.action[i].value);
image_ids.push(document.delete_images.action[i].value);
}
}
images = selected.join("&");
return {images:images, image_ids:image_ids};
}
else if (document.delete_images.action.checked){
return {images:"image_id="+document.delete_images.action.value, image_ids:document.delete_images.action.value};
}
return (-1);
}
$(document).ready(function() {
$("#delete").click(function(){
return DeleteConfirm();
});
$(".delete_image").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this image?") );
});
});
//]]>
</script>
</head>
<body id="pcard_image-manage" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -183,4 +140,51 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
<script>
function DeleteConfirm() {
var results = selected_images("delete");
if (results.images) {
var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids);
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/patroncards/image-manage.pl?op=delete&" + results.images;
} else {
return; // abort delete
}
} else {
alert(_("Please select image(s) to delete."));
}
}
function selected_images(op) {
var selected = new Array;
var image_ids = new Array;
if (document.delete_images.action.length) {
for (i=0;i<document.delete_images.action.length;i++){
if (document.delete_images.action[i].checked){
selected.push("image_id=" + document.delete_images.action[i].value);
image_ids.push(document.delete_images.action[i].value);
}
}
images = selected.join("&");
return {images:images, image_ids:image_ids};
}
else if (document.delete_images.action.checked){
return {images:"image_id="+document.delete_images.action.value, image_ids:document.delete_images.action.value};
}
return (-1);
}
$(document).ready(function() {
$("#delete").click(function(){
return DeleteConfirm();
});
$(".delete_image").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this image?") );
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,4 +1,5 @@
[% USE CGI %]
[% SET footerjs = 1 %]
[% BLOCK translate_card_element %]
[%- SWITCH element -%]
[%- CASE 'layout' -%]layout
@ -24,151 +25,8 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; [% PROCESS translate_card_element element=card_element_title %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'greybox.inc' %]
<script type="text/javascript">
//<![CDATA[
function DeleteConfirm() {
var element_ids = selected_layouts("delete");
var msg;
if (element_ids.length > 1) {
msg = _("Are you sure you want to delete %s %s?").format(element_ids.length, "[% PROCESS translate_card_elements element=card_element %]");
} else if (element_ids.length == 1) {
msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]);
}
if (msg && confirm(msg)) {
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, 400, 800);
};
function XportPatronlist() {
if ( patron_list_id.value.length < 1 ) {
alert(_("Please select a patron list."));
return; // no patron list selected
}
getstr = 'patronlist_id='+patron_list_id.value;
return GB_showCenter(_("Export patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
};
function selected_layout(op) {
if (document.layouts.action.length) {
var selected = new Array();
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));
} 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;
});
$("#printlist").click(function(){
XportPatronlist();
return false;
});
$(".delete").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this?") );
});
$(".export").on("click", function(e){
e.preventDefault();
var batch_id = $(this).data("batch-id");
GB_showCenter( _("Export single batch"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id, 400, 800);
});
});
//]]>
</script>
</head>
<body id="pcard_manage" class="tools pcard">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -270,4 +128,150 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'greybox.inc' %]
<script>
function DeleteConfirm() {
var element_ids = selected_layouts("delete");
var msg;
if (element_ids.length > 1) {
msg = _("Are you sure you want to delete %s %s?").format(element_ids.length, "[% PROCESS translate_card_elements element=card_element %]");
} else if (element_ids.length == 1) {
msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]);
}
if (msg && confirm(msg)) {
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, 400, 800);
};
function XportPatronlist() {
if ( patron_list_id.value.length < 1 ) {
alert(_("Please select a patron list."));
return; // no patron list selected
}
getstr = 'patronlist_id='+patron_list_id.value;
return GB_showCenter(_("Export patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
};
function selected_layout(op) {
if (document.layouts.action.length) {
var selected = new Array();
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));
} 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;
});
$("#printlist").click(function(){
XportPatronlist();
return false;
});
$(".delete").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this?") );
});
$(".export").on("click", function(e){
e.preventDefault();
var batch_id = $(this).data("batch-id");
GB_showCenter( _("Export single batch"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id, 400, 800);
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View file

@ -1,20 +1,15 @@
[% INCLUDE 'doc-head-open.inc' %]
[% SET footerjs = 1 %]
<!DOCTYPE html>
[% IF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]">[% ELSE %]<html lang="[% lang %]">[% END %]
<head>
<title>Koha &rsaquo; Tools &rsaquo; Patron cards &rsaquo; Patron card printing/exporting</title>
<link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" />
[% INCLUDE intranetstylesheet.inc %]
[% IF ( IntranetUserCSS ) %]<style type="text/css">[% IntranetUserCSS %]</style>[% END %]
[% INCLUDE 'doc-head-close.inc' popup => 1%]
<script type="text/javascript">
//<![CDATA[
function Done() {
window.location = "[% referer %]";
};
$(document).ready(function(){
$(".gb-close").on("click",function(){
parent.parent.GB_hide();
});
})
//]]>
</script>
<style type="text/css">#custom-doc {width:47.23em; *width:46.04em; min-width:610px; margin:auto; margin-top:0.4em;}</style>
</head>
<body id="pcard_print" class="tools pcard">
<div id="custom-doc">
<div id="bd">
@ -118,4 +113,21 @@
[% END %]
</div>
</div>
[% INCLUDE 'popup-bottom.inc' %]
[% IF ( IntranetUserJS ) %]
<script src="[% interface %]/lib/jquery/jquery-2.2.3.min_[% KOHA_VERSION %].js"></script>
<script src="[% interface %]/lib/jquery/jquery-migrate-1.3.0.min_[% KOHA_VERSION %].js"></script>
<script>
[% IntranetUserJS %]
function Done() {
window.location = "[% referer %]";
};
$(document).ready(function(){
$(".gb-close").on("click",function(){
parent.parent.GB_hide();
});
});
</script>
[% END %]
[% INCLUDE 'popup-bottom.inc' %]