ce760ba9e8
This patch depends on my previous one "Begin cleanup on additem" and fixes one bug introduced in that patch. Overhaul of additem sections to factor out common pieces especially attributes. Plugin js vastly simplified and reimplemented in jquery. Performance improved. Note that a particularly busy cataloging department should still leave barcode blank for server-side autopopulation to avoid collision. Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
247 lines
11 KiB
Cheetah
247 lines
11 KiB
Cheetah
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
|
|
<title>Koha › Cataloging › <!-- TMPL_VAR name="title" escape="html" --> <!-- TMPL_IF NAME="author" --> by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> (Record #<!-- TMPL_VAR NAME="biblionumber" -->) › Items</title>
|
|
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
$(document).ready(function(){
|
|
$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
|
|
});
|
|
function active(numlayer)
|
|
{
|
|
for (i=10; i < 11 ; i++ ) {
|
|
ong = i+"XX";
|
|
link = "link"+i;
|
|
if (numlayer==i) {
|
|
document.getElementById(ong).style.visibility="visible";
|
|
document.getElementById(link).style.backgroundColor="#11AA11";
|
|
document.getElementById(link).style.backgroundImage="url(<!-- TMPL_VAR NAME="themelang" -->/images/background-mem.gif)";
|
|
} else {
|
|
document.getElementById(ong).style.visibility="hidden";
|
|
document.getElementById(link).style.backgroundColor="#FFFFFF";
|
|
document.getElementById(link).style.backgroundImage="";
|
|
}
|
|
}
|
|
}
|
|
function Check(f) {
|
|
var total_errors=0;
|
|
// alert(f.field_value.length);
|
|
for (i=0 ; i<f.field_value.length ; i++) {
|
|
// alert (f.field_value[i].value);
|
|
if (f.field_value[i].value.length==0 && f.mandatory[i].value==1) {
|
|
document.getElementById("error"+i).style.backgroundColor="#FF0000";
|
|
total_errors++;
|
|
} else {
|
|
// document.getElementById("error"+i).style.backgroundColor="#FFFFFF";
|
|
}
|
|
}
|
|
var alertString2;
|
|
if (total_errors==0) {
|
|
return true;
|
|
} else {
|
|
alertString2 = _("Form not submitted because of the following problem(s)");
|
|
alertString2 += "\n------------------------------------------------------------------------------------\n";
|
|
alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (see bold subfields)");
|
|
alert(alertString2);
|
|
return false;
|
|
}
|
|
}
|
|
function Dopop(link,i) {
|
|
defaultvalue=document.forms[0].field_value[i].value;
|
|
newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
|
|
}
|
|
|
|
function confirm_deletion(biblionumber,itemnumber) {
|
|
var original = $("#row"+itemnumber).attr("class");
|
|
$("#row"+itemnumber).attr("class","confirm");
|
|
var is_confirmed = confirm(_("Are you sure you want to delete this item?"));
|
|
if (is_confirmed) {
|
|
window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber;
|
|
} else {
|
|
$("#row"+itemnumber).attr("class","");
|
|
}
|
|
}
|
|
|
|
function CloneSubfield(index){
|
|
var original = document.getElementById(index); //original <div>
|
|
var clone = original.cloneNode(true);
|
|
var new_key = CreateKey();
|
|
var old_id = original.getAttribute('id');
|
|
old_id=old_id.substr(12);
|
|
var new_id = old_id+new_key;
|
|
|
|
// set the attribute for the new 'div' subfields
|
|
var inputs = clone.getElementsByTagName('input');
|
|
var selects = clone.getElementsByTagName('select');
|
|
var textareas = clone.getElementsByTagName('textarea');
|
|
|
|
// input
|
|
var id_input = "";
|
|
for(var i=0,len=inputs.length; i<len ; i++ ){
|
|
id_input = inputs[i].getAttribute('id')+new_key;
|
|
inputs[i].setAttribute('id',id_input);
|
|
inputs[i].setAttribute('name',inputs[i].getAttribute('name'));
|
|
}
|
|
|
|
// select
|
|
for(var i=0,len=selects.length; i<len ; i++ ){
|
|
id_input = selects[i].getAttribute('id')+new_key;
|
|
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
|
|
selects[i].setAttribute('name',selects[i].getAttribute('name'));
|
|
}
|
|
|
|
// textarea
|
|
for(var i=0,len=textareas.length; i<len ; i++ ){
|
|
id_input = textareas[i].getAttribute('id')+new_key;
|
|
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
|
|
textareas[i].setAttribute('name',textareas[i].getAttribute('name'));
|
|
}
|
|
|
|
<!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
|
|
// when cloning a subfield, reset its label too.
|
|
var label = clone.getElementsByTagName('label')[0];
|
|
label.setAttribute('for',id_input);
|
|
<!-- /TMPL_UNLESS -->
|
|
|
|
// setting a new if for the parent div
|
|
clone.setAttribute('id',new_id);
|
|
|
|
var CloneButtonPlus;
|
|
try {
|
|
var spans = clone.getElementsByTagName('span');
|
|
if(spans.length){
|
|
for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
|
|
if(spans[i].getAttribute('class') == 'buttonPlus'){
|
|
CloneButtonPlus = spans[i];
|
|
CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
|
|
var buttonUp = clone.getElementsByTagName('img')[0];
|
|
buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(e){
|
|
// do nothing if ButtonPlus & CloneButtonPlus don't exist.
|
|
}
|
|
// insert this line on the page
|
|
original.parentNode.insertBefore(clone,original.nextSibling);
|
|
}
|
|
|
|
/**
|
|
* This function creates a random number
|
|
*/
|
|
function CreateKey(){
|
|
return parseInt(Math.random() * 100000);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$("#cataloguing_additem_itemlist tr").hover(
|
|
function () {$(this).attr("class","highlight");},
|
|
function () {$(this).attr("class","" );}
|
|
);
|
|
});
|
|
|
|
function set_to_today(id, force) {
|
|
if (! id) { alert("Bad id " + id + " sent to set_to_today()"); return 0; }
|
|
if ($("#" + id).val() == '' || $("#" + id).val() == '0000-00-00' || force) {
|
|
$("#" + id).val("<!-- TMPL_VAR NAME="today_iso" -->");
|
|
}
|
|
}
|
|
//]]>
|
|
</script>
|
|
<link type="text/css" rel="stylesheet" href="<!-- TMPL_VAR NAME="themelang" -->/css/addbiblio.css" />
|
|
</head>
|
|
<body>
|
|
<!-- TMPL_INCLUDE NAME="header.inc" -->
|
|
<div id="breadcrumbs">
|
|
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
|
|
› <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
|
|
› Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR name="title" escape="html" --> <!-- TMPL_IF NAME="author" --> by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> (Record #<!-- TMPL_VAR NAME="biblionumber" -->)</a>
|
|
› <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Items</a>
|
|
</div>
|
|
|
|
<div id="doc3" class="yui-t2">
|
|
|
|
<div id="bd">
|
|
<div id="yui-main">
|
|
<div class="yui-b">
|
|
|
|
|
|
<h1>Items for <!-- TMPL_VAR name="title" escape="html" --> <!-- TMPL_IF NAME="author" --> by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> (Record #<!-- TMPL_VAR NAME="biblionumber" -->)</h1>
|
|
|
|
<!-- TMPL_IF NAME="barcode_not_unique" --><div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div><!-- /TMPL_IF -->
|
|
<!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF -->
|
|
<!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF -->
|
|
|
|
<div id="cataloguing_additem_itemlist">
|
|
<!-- TMPL_IF name="item_loop" -->
|
|
<div style="overflow:auto">
|
|
<table>
|
|
<tr>
|
|
<th colspan="2"> </th>
|
|
<!-- TMPL_LOOP NAME="item_header_loop" -->
|
|
<th>
|
|
<!-- TMPL_VAR NAME="header_value" -->
|
|
</th>
|
|
<!-- /TMPL_LOOP -->
|
|
</tr>
|
|
<!-- TMPL_LOOP NAME="item_loop" -->
|
|
<tr id="row<!-- TMPL_VAR NAME="itemnumber" -->">
|
|
<!-- TMPL_IF Name="nomod"--> <td colspan="2"> </td><!--TMPL_ELSE--><td><a href="additem.pl?op=edititem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">Edit</a></td>
|
|
<td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->" onclick="confirm_deletion(<!-- TMPL_VAR NAME="biblionumber" -->,<!-- TMPL_VAR NAME="itemnumber" -->); return false;">Delete</a></td><!--/TMPL_IF-->
|
|
<!-- TMPL_VAR NAME="item_value" -->
|
|
</tr>
|
|
<!-- /TMPL_LOOP -->
|
|
</table>
|
|
</div>
|
|
<!-- /TMPL_IF -->
|
|
</div>
|
|
|
|
<div id="cataloguing_additem_newitem">
|
|
<form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
|
|
<input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" />
|
|
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
|
|
<!-- TMPL_IF name="opisadd" -->
|
|
<h2 id="additema">Add Item</h2>
|
|
<!-- TMPL_ELSE -->
|
|
<h2>Edit Item #<!-- TMPL_VAR NAME="itemnumber" --></h2>
|
|
<!-- /TMPL_IF -->
|
|
<fieldset class="rows">
|
|
<ol>
|
|
<!-- TMPL_LOOP NAME="item" -->
|
|
<li><div class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
|
|
|
|
<label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
|
|
<!-- TMPL_VAR NAME="marc_value" -->
|
|
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
|
|
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
|
|
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
|
|
<!-- TMPL_IF NAME="repeatable" -->
|
|
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
|
|
<!-- /TMPL_IF -->
|
|
|
|
</div></li>
|
|
<!-- /tmpl_loop -->
|
|
</ol>
|
|
</fieldset>
|
|
<input type="hidden" name="indicator" value=" " />
|
|
<input type="hidden" name="indicator" value=" " />
|
|
<input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
|
|
|
|
<fieldset class="action"> <!-- TMPL_IF name="opisadd" -->
|
|
<input type="submit" value="Add item" onclick="return Check(this.form)" />
|
|
<!-- TMPL_ELSE -->
|
|
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="itemtagfield" -->" />
|
|
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="itemtagsubfield" -->" />
|
|
<input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
|
|
<input type="submit" value="Save Changes" onclick="return Check(this.form)" />
|
|
<!-- /TMPL_IF --></fieldset>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="yui-b">
|
|
<!-- TMPL_INCLUDE NAME="biblio-view-menu.inc" -->
|
|
</div>
|
|
</div>
|
|
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
|