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,9 +25,113 @@
[% 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' %]
</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> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
[% 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 'Layout ID' -%]<th>Layout ID</th>
[%- CASE 'Layout' -%]<th>Layout</th>
[%- CASE 'Action' -%]<th>Action</th>
[%- CASE 'Actions' -%]<th>Actions</th>
[%- CASE 'Select' -%][% IF ( print ) %]<th>Select</th>[% END %]
[%- CASE 'Template ID' -%]<th>Template ID</th>
[%- CASE 'Template Name' -%]<th>Template name</th>
[%- CASE 'Description' -%]<th>Description</th>
[%- CASE 'Profile ID' -%]<th>Profile ID</th>
[%- CASE 'Printer Name' -%]<th>Printer name</th>
[%- CASE 'Paper Bin' -%]<th>Paper bin</th>
[%- CASE 'Batch ID' -%]<th>Batch ID</th>
[%- CASE 'Patron Count' -%]<th>Patron count</th>
[%- 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-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=[% text_field.field_value %]"><i class="fa fa-edit"></i> Edit</a>
[% IF ( print ) %]<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa fa-share-square-o"></i> Export</a>[% END %]
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=[% text_field.field_value %]"><i class="fa fa-trash"></i> Delete</a>
</td>
[% IF ( print ) %]<td><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>&nbsp;</td>
[% END %]
[% END %]
</tr>
[% END %]
[% END %]
</table>
<fieldset class="action">
[% IF ( print ) %]<input type="button" id="print" value="Export selected batches" />[% END %]
</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 %]">[% pl.name %]</option>
[% END %]
</select>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="button" id="printlist" value="Export from patron list" />
</fieldset>
[% END %]
</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 class="yui-b">
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'greybox.inc' %]
<script type="text/javascript">
//<![CDATA[
<script>
function DeleteConfirm() {
var element_ids = selected_layouts("delete");
@ -166,108 +271,7 @@
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' %]
<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/patroncards/home.pl">Patron card creator</a> &rsaquo;
[% 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 'Layout ID' -%]<th>Layout ID</th>
[%- CASE 'Layout' -%]<th>Layout</th>
[%- CASE 'Action' -%]<th>Action</th>
[%- CASE 'Actions' -%]<th>Actions</th>
[%- CASE 'Select' -%][% IF ( print ) %]<th>Select</th>[% END %]
[%- CASE 'Template ID' -%]<th>Template ID</th>
[%- CASE 'Template Name' -%]<th>Template name</th>
[%- CASE 'Description' -%]<th>Description</th>
[%- CASE 'Profile ID' -%]<th>Profile ID</th>
[%- CASE 'Printer Name' -%]<th>Printer name</th>
[%- CASE 'Paper Bin' -%]<th>Paper bin</th>
[%- CASE 'Batch ID' -%]<th>Batch ID</th>
[%- CASE 'Patron Count' -%]<th>Patron count</th>
[%- 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-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element %].pl?op=edit&element_id=[% text_field.field_value %]"><i class="fa fa-edit"></i> Edit</a>
[% IF ( print ) %]<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa fa-share-square-o"></i> Export</a>[% END %]
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element %]&element_id=[% text_field.field_value %]"><i class="fa fa-trash"></i> Delete</a>
</td>
[% IF ( print ) %]<td><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>&nbsp;</td>
[% END %]
[% END %]
</tr>
[% END %]
[% END %]
</table>
<fieldset class="action">
[% IF ( print ) %]<input type="button" id="print" value="Export selected batches" />[% END %]
</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 %]">[% pl.name %]</option>
[% END %]
</select>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="button" id="printlist" value="Export from patron list" />
</fieldset>
[% END %]
</form>
</script>
[% END %]
[% 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 class="yui-b">
[% INCLUDE 'tools-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]
[% 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' %]