[27/40] Fixing up the labels batches toolbar functionality.

This commit is contained in:
Chris Nighswonger 2009-08-13 12:13:08 -04:00
parent 02822ac805
commit 02b759bbc5
2 changed files with 176 additions and 147 deletions

View File

@ -1,13 +1,101 @@
<div id="toolbar">
<script type="text/javascript">
<script type="text/JavaScript">
//<![CDATA[
function Plugin(batch_id) {
window.open("label-item-search.pl?batch_id="+batch_id+"&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
return false;
}
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);
}
}
if (items.length < 1) {
alert("Please select at least one item to delete.");
return; // no item selected
}
getstr = items.join("&");
item_msg = item_num.join(", ");
var msg = "Are you sure you want to remove label number(s): " + item_msg + " from this batch?"
}
// else if (document.items.action.checked) {
// getstr = "label_id="+document.items.action.value;
// var msg = "Are you sure you want to remove selected item from this batch?"
// }
else {
alert("Please select at least 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=<!-- TMPL_VAR NAME="batch_id" -->&amp;" + getstr;
}
else {
return; // abort delete
}
};
function Add() {
window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
};
function DeDuplicate() {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->";
};
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=<!-- TMPL_VAR NAME="batch_id" -->&" + getstr, 700, 800);
}
else if (mode == 'batch') {
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->", 700, 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);
};
// prepare DOM for YUI Toolbar
$(document).ready(function() {
$("#additemsc").empty();
$("#removeitemsc").empty();
$("#deduplicatec").empty();
$("#exportitemsc").empty();
$("#exportbatchc").empty();
yuiToolbar();
});
// YUI Toolbar Functions
@ -16,21 +104,57 @@
id: "additems",
type: "link",
href: "#",
label: _("Add item(s) to batch"),
label: _("Add Item(s)"),
container: "additemsc",
onclick: {fn:function(){Plugin(<!-- TMPL_VAR NAME="batch_id" -->)}}
onclick: {fn:function(){Add()}}
});
new YAHOO.widget.Button({
id: "removeitems",
type: "link",
href: "#",
label: _("Remove Item(s)"),
container: "removeitemsc",
onclick: {fn:function(){Remove()}}
});
new YAHOO.widget.Button({
id: "deduplicate",
type: "link",
href: "#",
label: _("Remove Duplicates"),
container: "deduplicatec",
onclick: {fn:function(){DeDuplicate()}}
});
new YAHOO.widget.Button({
id: "exportitems",
type: "link",
href: "#",
label: _("Export Item(s)"),
container: "exportitemsc",
onclick: {fn:function(){Xport('label')}}
});
new YAHOO.widget.Button({
id: "exportbatch",
type: "link",
href: "#",
label: _("Export Batch"),
container: "exportbatchc",
onclick: {fn:function(){Xport('batch')}}
});
new YAHOO.widget.Button("deletebatch");
new YAHOO.widget.Button("dedup");
new YAHOO.widget.Button("generate");
}
//]]>
</script>
<ul class="toolbar">
<li id="additemsc"><a id="additems" href="#">Add item(s) to batch</a></li>
<li><a id="deletebatch" href="/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=<!-- TMPL_VAR NAME="batch_id" -->">Delete current batch</a></li>
<li id="additemsc"><a id="additems" href="#">Add Item(s)</a></li>
<li id="removeitemsc"><a id="removeitems" href="#">Remove Item(s)</a></li>
<li><a id="deletebatch" href="/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=<!-- TMPL_VAR NAME="batch_id" -->">Delete Batch</a></li>
<!-- FIXME: should use POST to change server state, not GET -->
<li><a id="dedup" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->">Remove duplicate items</a></li>
<li><a id="generate" href="/cgi-bin/koha/labels/label-print-<!-- TMPL_VAR NAME="outputformat" -->.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;type=<!-- TMPL_VAR NAME="batch_type" -->">Generate labels for Batch</a></li>
<li id="deduplicatec"><a id="deduplicate" href="#">Remove Duplicates</a></li>
<li id="exportitemsc"><a id="exportitems" href="#">Export Item(s)</a></li>
<li id="exportbatchc"><a id="exportbatch" href="#">Export Batch</a></li>
</ul>
</div>

View File

@ -2,95 +2,6 @@
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage Label Batches</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="greybox.inc" -->
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
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);
}
}
if (items.length < 1) {
alert("Please select at least one item to delete.");
return; // no item selected
}
getstr = items.join("&");
}
else if (document.items.action.checked) {
getstr = "label_id="+document.items.action.value;
}
else {
alert("Please select at least one item to delete.");
return; // no item selected
}
var msg = "Are you sure you want to remove the selected item(s) from this batch?"
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->&amp;" + getstr;
}
else {
return; // abort delete
}
};
function Add() {
window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=add&amp;batch_id=<!-- TMPL_VAR NAME="batch_id" -->";
};
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
}
//<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=<!-- TMPL_VAR NAME="breedingid" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
//window.location = "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&" + getstr;
//return GB_show('Google', this.href)
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->&" + getstr, 700, 800);
}
else if (mode == 'batch') {
//window.location = "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->";
//$(".checkboxed").uncheckCheckboxes();
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=<!-- TMPL_VAR NAME="batch_id" -->", 700, 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);
};
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
@ -106,59 +17,53 @@
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-batches-toolbar.inc" -->
<div class="yui-gc">
<div class="yui-g">
<div class="yui-u first" id="manage-label-batches">
<div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
<form name="items" class="checkboxed">
<h2>Items in batch number <!-- TMPL_VAR NAME="batch_id" --></h2>
<table>
<!-- TMPL_LOOP NAME="table_loop" -->
<!-- TMPL_IF NAME="header_fields" -->
<tr>
<!-- TMPL_LOOP NAME="header_fields" -->
<th><!-- TMPL_VAR NAME="field_label" --></th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_ELSE -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSE -->
<td><!-- TMPL_VAR NAME="field_value" --></td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</table>
</form>
<div style="margin: 10px 10px 10px 0px;">
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="add" onclick="Add()" value="Add Item(s)"></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="remove" onclick="Remove()" value="Remove Item(s)"></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="export_item" onclick="Xport('label')" value="Export Item(s)"></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="export_batch" onclick="Xport('batch')" value="Export Batch"></span></span>
<form name="items" class="checkboxed">
<h2>Items in batch number <!-- TMPL_VAR NAME="batch_id" --></h2>
<table>
<!-- TMPL_LOOP NAME="table_loop" -->
<!-- TMPL_IF NAME="header_fields" -->
<tr>
<!-- TMPL_LOOP NAME="header_fields" -->
<th><!-- TMPL_VAR NAME="field_label" --></th>
<!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_ELSE -->
<tr>
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSE -->
<td><!-- TMPL_VAR NAME="field_value" --></td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</table>
</form>
</div>
</div>
<!-- TMPL_IF NAME="err" -->
<div class="yui-u">
<div class="alert">
<strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="errstr" --> Please have your system administrator check the syslog for details.</strong>
<!-- TMPL_IF NAME="err" -->
<div class="yui-u">
<div class="alert">
<strong>WARNING: An error was encountered and <!-- TMPL_VAR NAME="errstr" --> Please have your system administrator check the syslog for details.</strong>
</div>
</div>
</div>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="duplicate_message" -->
<div class="yui-u">
<div class="dialog">
<strong><!-- TMPL_VAR NAME="duplicate_count" --> duplicate item(s) found and removed from batch <!-- TMPL_VAR NAME="batch_id" -->.</strong>
<!-- TMPL_ELSIF NAME="duplicate_message" -->
<div class="yui-u">
<div class="dialog">
<strong><!-- TMPL_VAR NAME="duplicate_count" --> duplicate item(s) found and removed from batch <!-- TMPL_VAR NAME="batch_id" -->.</strong>
</div>
</div>
<!-- /TMPL_IF -->
</div>
<!-- /TMPL_IF -->
</div>
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="labels-menu.inc" -->
</div>
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->