Koha/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt
Owen Leonard 8a3392bbbe Bug 28041: Improve breadcrumbs and headings on label creator pages
This patch changes various label creator templates so that breadcrumbs
menus and headings are more specific to each operation.

To test, apply the patch and confirm that headings, page titles, and
breadcrumbs menus are correct for the various pages:

- New -> Label batch: "Label creator -> Batches -> New label batch."
- New -> Layout: "Label creator -> Layouts -> New label layout."
- New -> Label template: "Label creator -> New label template."
- New -> Printer profile: "Label creator -> New printer profile."
- New -> Barcode range: "Label creator -> Print barcode range."
- Manage -> Label batch -> Edit: "Label creator -> Batches -> Edit
  label batch X."
- Manage -> Layout -> Edit: "Label creator -> Layouts -> Edit label
  layout X."
- Manage -> Label templates -> Edit: "Label creator -> Templates -> Edit
  label template X."
- Manage -> Printer profiles -> Edit: "Label creator -> Profiles -> Edit
  printer profile X."

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-04-06 15:56:31 +02:00

401 lines
21 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE ItemTypes %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Tools &rsaquo; Label creator &rsaquo; Batches &rsaquo; [% IF batch_id %]Edit label batch [% batch_id | html %][% ELSE %]New label batch[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="labels_label-edit-batch" class="tools labels" onload="dofocus();">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
</li>
<li>
<a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a>
</li>
<li>
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Batches</a>
</li>
[% IF description %]
<li>
<a href="#" aria-current="page">
Edit [% description | html %]
</a>
</li>
[% ELSIF batch_id %]
<li>
<a href="#" aria-current="page">
Edit label batch [% batch_id | html %]
</a>
</li>
[% ELSE %]
<li>
<a href="#" aria-current="page">
New label batch
</a>
</li>
[% END %]
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% INCLUDE 'labels-toolbar.inc' %]
[% IF description %]
<h1>Edit [% description | html %]</h1>
[% ELSIF batch_id %]
<h1>Edit label batch [% batch_id | html %]</h1>
[% ELSE %]
<h1>New label batch</h1>
[% END %]
[% IF ( err ) %]
[% BLOCK xlate_errtype %]
[% SWITCH errtype %]
[% CASE 'ITEM_NOT_REMOVED' %]
<span>Item(s) not removed from batch [% batch_id | html %].</span>
[% CASE 'BATCH_NOT_DELETED' %]
<span>Batch [% batch_id | html %] was not deleted.</span>
[% CASE 'ITEM_NOT_ADDED' %]
<span>Item(s) not added to batch [% batch_id | html %].</span>
[% CASE 'BRANCH_NOT_SET' %]
<span>Library is not set, please set your library before adding items to a batch.</span>
[% CASE 'BATCH_NOT_DEDUP' %]
<span>Batch [% batch_id | html %] not fully de-duplicated.</span>
[% CASE %]
<span>Unknown error type [% errtype | html %].</span>
[% END %]
[% END %]
<div class="dialog alert">
<strong>WARNING:</strong> An error was encountered: [% PROCESS xlate_errtype %] Please have your system administrator check the error log for details.
</div>
[% ELSIF ( duplicate_message ) %]
<div class="dialog message">
<strong>Duplicate item(s) removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
</div>
[% END %]
<div id="manage-label-batches">
<form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
<div>
<fieldset class="rows" style="border-bottom: 0px; border: 0px;">
<ol><li id="description">
<input type="hidden" name="op" value="add" />
<input type="hidden" name="batch_id" value="[% batch_id | html %]" />
<label for="description">Batch description: </label>
<input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
</li>
<li>
<input type="radio" name="number_type" id="barcode_enter" value="barcode" checked />
<label for="barcode_enter">Enter by barcode:</label>
</li>
<li>
<input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" />
<label for="itemnum_enter">Enter by itemnumber:</label>
</li>
<li>
<label for="number_list">
Add by barcode(s) or itemnumbers(s):
</label>
<textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea>
<div class="hint">
One number per line.
<br /> Leave empty to add via item search (itemnumber)
</div>
</li></ol>
</fieldset>
</div>
</form>
<div id="batch-manage" class="btn-toolbar">
<a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add item(s)</a>[% IF ( table_loop ) %]
<a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
<a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected items</a>
<a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
<a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
<a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected items</a>
<a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export full batch</a>[% END %]
</div>
[% IF ( table_loop ) %]
<form name="items">
<h2>Items in batch number [% batch_id | html %]</h2>
<table id="batcht">
[% FOREACH table_loo IN table_loop %]
[% IF ( table_loo.header_fields ) %]
<thead>
<tr>
[% FOREACH header_field IN table_loo.header_fields %]
[% SWITCH header_field.field_label -%]
[% CASE "Label number" -%]
<th>Label number</th>
[% CASE "Summary" -%]
<th class="anti-the">Summary</th>
[% CASE "Item type" %]
<th>Item type</th>
[% CASE "Call number" %]
<th>Call number</th>
[% CASE "Barcode" %]
<th>Barcode</th>
[% CASE "Select" -%]
<th>Select</th>
[% CASE %]
<th>[% header_field.field_label | html %]</th>
[% END -%]
[% END %]
</tr>
</thead>
<tbody>
[% ELSE %]
<tr>
[% FOREACH text_field IN table_loo.text_fields %]
[% IF ( text_field.select_field ) %]
<td>
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id |url %]&amp;label_id=[% text_field.field_value |url %]"><i class="fa fa-trash"></i> Delete</a>
<a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa fa-share-square-o"></i> Export</a>
</td>
<td><input type="checkbox" name="action" value="[% text_field.field_value | html %]"></td>
[% ELSE %]
<td>
[% IF ( text_field.field_name == '_item_type_tbl' ) %]
[% ItemTypes.GetDescription( text_field.field_value ) | html %]
[% ELSE %]
[% text_field.field_value | $raw %]
[% END %]
</td>
[% END %]
[% END %]
</tr>
[% END %]
[% END %]
</tbody>
</table>
</form>
[% ELSE %]
<div class="dialog message">
<h4>There are no items in this batch yet</h4>
<p>Add items by using the text area above or leave empty to add via item search.</p>
</div>
[% END %]
</div>
</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 %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% INCLUDE 'greybox.inc' %]
[% INCLUDE 'datatables.inc' %]
<script>
function DeleteConfirm() {
var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=[% batch_id | html %]";
}
else {
return; // abort delete
}
}
function dofocus() { // named function req'd for body onload event by some FF and IE7 security models
$(".focus:last").select();
}
function verifyBarcodes(barcodes) {
if (barcodes.value == '') {
alert(_("Please add barcodes using either the direct entry text area or the item search."));
return false; // not ok
}
else {
return true; // ok
}
}
function Remove() {
items = new Array;
item_num = 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);
item_num.push(i+1);
}
}
getstr = items.join("&");
item_msg = item_num.join(", ");
var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
} else if (document.items.action.checked) {
alert(_("Deletion of label from a batch with only one label 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 label to delete."));
return; // no item selected
}
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;" + getstr;
} else {
return; // abort delete
}
}
function Add() {
var number_list = document.getElementById("number_list");
if (number_list.value == '') {
window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id | html %]&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
} else {
document.forms["add_by_number"].submit();
}
}
function add_item(item_number) {
$("#itemnum_enter").prop("checked",true);
$("#number_list").val($("#number_list").val()+item_number+"\r\n");
}
function DeDuplicate() {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id | html %]";
}
function Xport(mode) {
if (mode == 'label') {
labels= new Array;
if(document.items.action.length > 0) {
for (var i=0; i < document.items.action.length; i++) {
if (document.items.action[i].checked) {
labels.push("label_id=" + document.items.action[i].value);
}
}
if (labels.length < 1) {
alert(_("Please select at least one label to export."));
return; // no batch selected
}
getstr = labels.join("&");
}
else if (document.items.action.checked) {
getstr = document.items.action.value;
} else {
alert(_("Please select at least one label to export."));
return; // no batch selected
}
return GB_showCenter(_("Export labels"), "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
} else if (mode == 'batch') {
return GB_showCenter(_("Export labels"), "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id | html %]", 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() {
[% IF table_loop %]
$("#description").show();
[% ELSE %]
$("#description").hide();
[% END %]
$("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
"autoWidth": false,
"aoColumnDefs": [
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
],
"aaSorting": [[ 0, "asc" ]],
"sPaginationType": "full"
}));
$("#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?") );
});
$(".export").on("click", function(e){
e.preventDefault();
var label_id = $(this).data("label-id");
var batch_id = $(this).data("batch-id");
GB_showCenter(_("Export labels"),"/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id, 400, 800);
});
$("#savedesc").click(function(event){
event.preventDefault(); // prevent form submission
var newdescription = $('input[name="description"]').val();
var batch_id = $(this).data('batch_id');
var ajaxData = {
'newdescription': newdescription,
'batch_id': batch_id,
'card_element': "batch",
'creator': "label",
};
$.ajax({
url: '/cgi-bin/koha/svc/creator_batches',
type: 'POST',
dataType: 'json',
data: ajaxData,
})
.done(function(data){
if (data.status == 'success') {
$("input[name='description']").text(data.newdesc);
$("#change-status").text(_("Saved"));
} else {
$("#change-status").text(_("Unable to save description"));
}
});
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]