|
Lines 1-5
Link Here
|
| 1 |
function addItem( node, unique_item_fields ) { |
1 |
function addItem( node, unique_item_fields ) { |
| 2 |
var index = $(node).parent().attr('id'); |
2 |
var index = $(node).closest("div").attr('id'); |
| 3 |
var current_qty = parseInt($("#quantity").val()); |
3 |
var current_qty = parseInt($("#quantity").val()); |
| 4 |
var max_qty; |
4 |
var max_qty; |
| 5 |
if($("#quantity_to_receive").length != 0){ |
5 |
if($("#quantity_to_receive").length != 0){ |
|
Lines 12-18
function addItem( node, unique_item_fields ) {
Link Here
|
| 12 |
if ( current_qty < max_qty - 1 ) |
12 |
if ( current_qty < max_qty - 1 ) |
| 13 |
cloneItemBlock(index, unique_item_fields); |
13 |
cloneItemBlock(index, unique_item_fields); |
| 14 |
addItemInList(index, unique_item_fields); |
14 |
addItemInList(index, unique_item_fields); |
| 15 |
$("#" + index).find("a[name='buttonPlus']").text("Update"); |
15 |
$("#" + index).find("input[name='buttonPlus']").val("Update"); |
| 16 |
$("#quantity").val(current_qty + 1).change(); |
16 |
$("#quantity").val(current_qty + 1).change(); |
| 17 |
} else if ( current_qty >= max_qty ) { |
17 |
} else if ( current_qty >= max_qty ) { |
| 18 |
alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS |
18 |
alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS |
|
Lines 134-142
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
| 134 |
$(this).val(random); |
134 |
$(this).val(random); |
| 135 |
}); |
135 |
}); |
| 136 |
/* Add buttons + and Clear */ |
136 |
/* Add buttons + and Clear */ |
| 137 |
var buttonPlus = '<a name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')">Add</a>'; |
137 |
var buttonPlus = "<fieldset class=\"action\">"; |
| 138 |
var buttonClear = '<a name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)">' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear') + '</a>'; |
138 |
var buttonPlusText = _("Add item"); |
| 139 |
$(clone).append(buttonPlus).append(buttonClear); |
139 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + buttonPlusText + '" />'; |
|
|
140 |
buttonPlus += '<a class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)">' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear') + '</a>'; |
| 141 |
buttonPlus += "</fieldset>"; |
| 142 |
$(clone).append(buttonPlus); |
| 140 |
/* Copy values from the original block (input) */ |
143 |
/* Copy values from the original block (input) */ |
| 141 |
$(original).find("input[name='field_value']").each(function(){ |
144 |
$(original).find("input[name='field_value']").each(function(){ |
| 142 |
var kohafield = $(this).siblings("input[name='kohafield']").val(); |
145 |
var kohafield = $(this).siblings("input[name='kohafield']").val(); |
|
Lines 164-170
function cloneItemBlock(index, unique_item_fields) {
Link Here
|
| 164 |
} |
167 |
} |
| 165 |
|
168 |
|
| 166 |
function clearItemBlock(node) { |
169 |
function clearItemBlock(node) { |
| 167 |
var index = $(node).parent().attr('id'); |
170 |
var index = $(node).closest("div").attr('id'); |
| 168 |
var block = $("#"+index); |
171 |
var block = $("#"+index); |
| 169 |
$(block).find("input[type='text']").each(function(){ |
172 |
$(block).find("input[type='text']").each(function(){ |
| 170 |
$(this).val(""); |
173 |
$(this).val(""); |
| 171 |
- |
|
|