Lines 1-3
Link Here
|
|
|
1 |
/* global __ */ |
1 |
function addItem( node, unique_item_fields ) { |
2 |
function addItem( node, unique_item_fields ) { |
2 |
var index = $(node).closest("div").attr('id'); |
3 |
var index = $(node).closest("div").attr('id'); |
3 |
var current_qty = parseInt($("#quantity").val()); |
4 |
var current_qty = parseInt($("#quantity").val()); |
Lines 12-24
function addItem( node, unique_item_fields ) {
Link Here
|
12 |
if ( current_qty < max_qty - 1 ) |
13 |
if ( current_qty < max_qty - 1 ) |
13 |
cloneItemBlock(index, unique_item_fields); |
14 |
cloneItemBlock(index, unique_item_fields); |
14 |
addItemInList(index, unique_item_fields); |
15 |
addItemInList(index, unique_item_fields); |
15 |
$("#" + index).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
16 |
$("#" + index).find("input[name='buttonPlus']").val( __("Update item") ); |
16 |
$("#"+ index).find("input[name='buttonPlusMulti']").remove(); |
17 |
$("#"+ index).find("input[name='buttonPlusMulti']").remove(); |
17 |
$("#" + index).find("input[name='multiValue']").remove(); |
18 |
$("#" + index).find("input[name='multiValue']").remove(); |
18 |
$("#quantity").val(current_qty + 1).change(); |
19 |
$("#quantity").val(current_qty + 1).change(); |
19 |
} else if ( current_qty >= max_qty ) { |
20 |
} else if ( current_qty >= max_qty ) { |
20 |
alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS |
21 |
alert( __("You can't receive any more items") ); |
21 |
|| "You can't receive any more items."); |
|
|
22 |
} |
22 |
} |
23 |
} else { |
23 |
} else { |
24 |
if ( current_qty < max_qty ) |
24 |
if ( current_qty < max_qty ) |
Lines 46-52
function addMulti( count, node, unique_item_fields){
Link Here
|
46 |
$("#procModal").modal('hide'); |
46 |
$("#procModal").modal('hide'); |
47 |
} |
47 |
} |
48 |
}); |
48 |
}); |
49 |
$("#" + cloneIndex).find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); |
49 |
$("#" + cloneIndex).find("input[name='buttonPlus']").val( ( __("Update item") ) ); |
50 |
$("#" + cloneIndex).find("input[name='buttonPlusMulti']").remove(); |
50 |
$("#" + cloneIndex).find("input[name='buttonPlusMulti']").remove(); |
51 |
$("#" + cloneIndex).find("input[name='multiValue']").remove(); |
51 |
$("#" + cloneIndex).find("input[name='multiValue']").remove(); |
52 |
$("#" + cloneIndex).hide(); |
52 |
$("#" + cloneIndex).hide(); |
Lines 88-97
function constructTrNode(index, unique_item_fields) {
Link Here
|
88 |
|
88 |
|
89 |
var result = "<tr idblock='" + index + "'>"; |
89 |
var result = "<tr idblock='" + index + "'>"; |
90 |
var edit_link = "<a href='#itemfieldset' style='text-decoration:none' onclick='showItem(\"" + index + "\");' class='btn btn-default btn-xs'><i class='fa fa-pencil'></i> " |
90 |
var edit_link = "<a href='#itemfieldset' style='text-decoration:none' onclick='showItem(\"" + index + "\");' class='btn btn-default btn-xs'><i class='fa fa-pencil'></i> " |
91 |
+ (window.MSG_ADDITEM_JS_EDIT || "Edit") + "</a>"; |
91 |
+ ( __("Edit") ) + "</a>"; |
92 |
var del_link = "<a style='cursor:pointer' " |
92 |
var del_link = "<a style='cursor:pointer' " |
93 |
+ "onclick='deleteItemBlock(this, \"" + index + "\", \"" + unique_item_fields + "\");' class='btn btn-default btn-xs'><i class='fa fa-trash'></i> " |
93 |
+ "onclick='deleteItemBlock(this, \"" + index + "\", \"" + unique_item_fields + "\");' class='btn btn-default btn-xs'><i class='fa fa-trash'></i> " |
94 |
+ (window.MSG_ADDITEM_JS_DELETE || "Delete") + "</a>"; |
94 |
+ ( __("Delete") ) + "</a>"; |
95 |
result += "<td class='actions'>" + edit_link + " " + del_link + "</td>"; |
95 |
result += "<td class='actions'>" + edit_link + " " + del_link + "</td>"; |
96 |
for(i in fields) { |
96 |
for(i in fields) { |
97 |
var field = fields[i]; |
97 |
var field = fields[i]; |
Lines 178-190
function cloneItemBlock(index, unique_item_fields, callback) {
Link Here
|
178 |
}); |
178 |
}); |
179 |
/* Add buttons + and Clear */ |
179 |
/* Add buttons + and Clear */ |
180 |
var buttonPlus = "<fieldset class=\"action\">"; |
180 |
var buttonPlus = "<fieldset class=\"action\">"; |
181 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_ADDITEM || 'Add item')+ '" />'; |
181 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlus" style="cursor:pointer; margin:0 1em;" onclick="addItem(this,\'' + unique_item_fields + '\')" value="' + ( __("Add item") )+ '" />'; |
182 |
buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear')+ '" />'; |
182 |
buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + __("Clear") + '" />'; |
183 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" onclick="javascript:this.nextSibling.style.display=\'inline\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + (window.MSG_ADDITEM_JS_ADDMULTI || 'Add multiple items')+ '" />'; |
183 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" onclick="javascript:this.nextSibling.style.display=\'inline\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + __("Add multiple items") + '" />'; |
184 |
buttonPlus += '<span id="add_multiple_copies" style="display:none">' |
184 |
buttonPlus += '<span id="add_multiple_copies" style="display:none">' |
185 |
+ '<input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="'+window.MSG_ADDITEM_JS_MULTIVAL+'" />' |
185 |
+ '<input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="' + __("Number of items to add") + '" />' |
186 |
+ '<input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkCount( this ,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_SUBMITMULTI || 'Add') + '" />' |
186 |
+ '<input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkCount( this ,\'' + unique_item_fields + '\')" value="' + __("Add") + '" />' |
187 |
+ '<div class="dialog message">' + window.MSG_ADDITEM_JS_MULTI_UNIQUE_NOTE + '</div>' |
187 |
+ '<div class="dialog message">' + __("NOTE: Fields listed in the 'UniqueItemsFields' system preference will not be copied") + '</div>' |
188 |
+ '</span>'; |
188 |
+ '</span>'; |
189 |
buttonPlus += "</fieldset>"; |
189 |
buttonPlus += "</fieldset>"; |
190 |
$(clone).append(buttonPlus); |
190 |
$(clone).append(buttonPlus); |
Lines 271-277
function check_additem(unique_item_fields) {
Link Here
|
271 |
if (sorted_arr[i + 1] == sorted_arr[i]) { |
271 |
if (sorted_arr[i + 1] == sorted_arr[i]) { |
272 |
$(".order_error").append( |
272 |
$(".order_error").append( |
273 |
fieldname + " '" + sorted_arr[i] + "' " |
273 |
fieldname + " '" + sorted_arr[i] + "' " |
274 |
+ (window.MSG_ADDITEM_JS_IS_DUPLICATE || "is duplicated") |
274 |
+ __("is duplicated") |
275 |
+ "<br/>"); |
275 |
+ "<br/>"); |
276 |
success = false; |
276 |
success = false; |
277 |
} |
277 |
} |
Lines 296-303
function check_additem(unique_item_fields) {
Link Here
|
296 |
var value = data[field][i]; |
296 |
var value = data[field][i]; |
297 |
$(".order_error").append( |
297 |
$(".order_error").append( |
298 |
field + " '" + value + "' " |
298 |
field + " '" + value + "' " |
299 |
+ (window.MSG_ADDITEM_JS_ALREADY_EXISTS_IN_DB |
299 |
+ __("already exists in database") |
300 |
|| "already exists in database") |
|
|
301 |
+ "<br />" |
300 |
+ "<br />" |
302 |
); |
301 |
); |
303 |
} |
302 |
} |
304 |
- |
|
|