Lines 35-43
function addMulti( count, node, unique_item_fields){
Link Here
|
35 |
var current_qty = parseInt( $('#quantity').val(), 10 ); |
35 |
var current_qty = parseInt( $('#quantity').val(), 10 ); |
36 |
$("#procModal").modal('show'); |
36 |
$("#procModal").modal('show'); |
37 |
$("#" + index).hide(); |
37 |
$("#" + index).hide(); |
|
|
38 |
var cur_barc = $("#"+index + " #subfieldp input[name='field_value']").val() |
39 |
if ( cur_barc != '' && unique_item_fields.indexOf('barcode')>-1 ){ |
40 |
tmp_uif = unique_item_fields.replace("barcode",''); |
41 |
unique_item_fields=tmp_uif; |
42 |
} |
43 |
else { cur_barc=''} |
44 |
|
38 |
for(var i=0;i<count;i++){ |
45 |
for(var i=0;i<count;i++){ |
|
|
46 |
if( cur_barc!='') { |
47 |
var old_barc = $("#"+index + " #subfieldp input[name='field_value']").val(); |
48 |
} |
39 |
cloneItemBlock(index, unique_item_fields, function(cloneIndex){ |
49 |
cloneItemBlock(index, unique_item_fields, function(cloneIndex){ |
40 |
addItemInList(cloneIndex,unique_item_fields, function(){ |
50 |
addItemInList(cloneIndex,unique_item_fields, function(){i |
|
|
51 |
if( cur_barc != '' ){ |
52 |
cur_barc = incrementBarcode(cur_barc); |
53 |
$("#"+index + " #subfieldp input[name='field_value']").val(cur_barc); |
54 |
} |
41 |
if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ |
55 |
if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ |
42 |
$("#multiValue").val(''); |
56 |
$("#multiValue").val(''); |
43 |
$('#'+index).show(); |
57 |
$('#'+index).show(); |
Lines 55-68
function addMulti( count, node, unique_item_fields){
Link Here
|
55 |
} |
69 |
} |
56 |
} |
70 |
} |
57 |
|
71 |
|
|
|
72 |
function incrementBarcode(barcode){ |
73 |
var split_barcode =/(.*?)(\d+)$/; |
74 |
var barcode_parts = split_barcode.exec(barcode); |
75 |
if( barcode_parts == null ) return undefined; |
76 |
var length_of_inc_barcode = barcode_parts[2].length; |
77 |
if( barcode_parts[2].match(/^9+$/) ) length_of_inc_barcode++; |
78 |
var inc_number = parseInt(barcode_parts[2], 10) + 1; |
79 |
var inc_string = inc_number.toString(); |
80 |
while ( inc_string.length < length_of_inc_barcode ) inc_string = "0" + inc_string; |
81 |
barcode = barcode_parts[1]+inc_string; |
82 |
return barcode; |
83 |
} |
58 |
|
84 |
|
59 |
function checkCount(node, unique_item_fields){ |
85 |
function checkInputs(node, unique_item_fields){ |
60 |
var count = parseInt( $("#multiValue").val(), 10 ); |
86 |
var count = parseInt( $("#multiValue").val(), 10 ); |
61 |
if ( isNaN( count ) || count <=0) { |
87 |
if ( isNaN( count ) || count <=0) { |
62 |
$("#multiCountModal").modal('show'); |
88 |
$("#multiCountModal").modal('show'); |
63 |
} |
89 |
} |
64 |
else{ |
90 |
else{ |
65 |
addMulti( count, node, unique_item_fields); |
91 |
var index = $(node).closest("div").attr('id'); |
|
|
92 |
var barcode = $("#"+index + " #subfieldp input[name='field_value']").val(); |
93 |
if ( barcode !='' && unique_item_fields.indexOf('barcode')>-1 ){ |
94 |
if ( incrementBarcode(barcode) != undefined ) { |
95 |
addMulti( count, node, unique_item_fields); |
96 |
} |
97 |
else { $("#incrementBarcodeModal").modal('show');} |
98 |
} |
99 |
else { addMulti( count, node, unique_item_fields); } |
66 |
} |
100 |
} |
67 |
} |
101 |
} |
68 |
|
102 |
|
Lines 72-78
function showItem(index) {
Link Here
|
72 |
$(this).show(); |
106 |
$(this).show(); |
73 |
} else { |
107 |
} else { |
74 |
if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) { |
108 |
if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) { |
75 |
$(this).remove(); |
109 |
$(this).remove(); |
76 |
} else { |
110 |
} else { |
77 |
$(this).hide(); |
111 |
$(this).hide(); |
78 |
} |
112 |
} |
Lines 180-186
function cloneItemBlock(index, unique_item_fields, callback) {
Link Here
|
180 |
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')+ '" />'; |
214 |
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 cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear')+ '" />'; |
215 |
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" name="buttonPlusMulti" data-toggle="modal" data-target="#uniqueFieldsModal" onclick="javascript:this.nextSibling.style.visibility=\'visible\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + (window.MSG_ADDITEM_JS_ADDMULTI || 'Add multiple items')+ '" />'; |
216 |
buttonPlus += '<input type="button" class="addItemControl" name="buttonPlusMulti" data-toggle="modal" data-target="#uniqueFieldsModal" onclick="javascript:this.nextSibling.style.visibility=\'visible\'; return false;" style="cursor:pointer; margin:0 1em;" value="' + (window.MSG_ADDITEM_JS_ADDMULTI || 'Add multiple items')+ '" />'; |
183 |
buttonPlus +='<span id="add_multiple_copies" style="visibility:hidden"><input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="'+window.MSG_ADDITEM_JS_MULTIVAL+'" /><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') + '" /></span>'; |
217 |
buttonPlus +='<span id="add_multiple_copies" style="visibility:hidden"><input type="number" class="addItemControl" id="multiValue" name="multiValue" placeholder="'+window.MSG_ADDITEM_JS_MULTIVAL+'" /><input type="button" class="addItemControl" name=buttonAddMulti" style="cursor:pointer; margin:0 1em;" onclick="checkInputs( this ,\'' + unique_item_fields + '\')" value="' + (window.MSG_ADDITEM_JS_SUBMITMULTI || 'Add') + '" /></span>'; |
184 |
buttonPlus += "</fieldset>"; |
218 |
buttonPlus += "</fieldset>"; |
185 |
$(clone).append(buttonPlus); |
219 |
$(clone).append(buttonPlus); |
186 |
/* Copy values from the original block (input) */ |
220 |
/* Copy values from the original block (input) */ |