Bugzilla – Attachment 47477 Details for
Bug 14752
Add multiple copies to a basket at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14752 - increment barcodes when adding multiples if present and uniqueness enforced
Bug-14752---increment-barcodes-when-adding-multipl.patch (text/plain), 7.38 KB, created by
Nick Clemens (kidclamp)
on 2016-01-29 19:29:58 UTC
(
hide
)
Description:
Bug 14752 - increment barcodes when adding multiples if present and uniqueness enforced
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-01-29 19:29:58 UTC
Size:
7.38 KB
patch
obsolete
>From 99b6a4173311a50144edb7518510ec8128f7dbf2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 29 Jan 2016 19:25:16 +0000 >Subject: [PATCH] Bug 14752 - increment barcodes when adding multiples if > present and uniqueness enforced > >To test: >1 - Enter a barcode value that ends in a number >2 - Attempt to add multiple items >3 - Items should eb added with increasing barcodes >4 - Enter a barcode not ending in a number >5 - Attempt to add multiple items >6 - You should get an error modal >--- > koha-tmpl/intranet-tmpl/prog/en/js/additem.js | 44 +++++++++++++++++++--- > .../prog/en/modules/acqui/neworderempty.tt | 10 ++++- > 2 files changed, 47 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >index c77a089..490f1fc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >@@ -35,9 +35,23 @@ function addMulti( count, node, unique_item_fields){ > var current_qty = parseInt( $('#quantity').val(), 10 ); > $("#procModal").modal('show'); > $("#" + index).hide(); >+ var cur_barc = $("#"+index + " #subfieldp input[name='field_value']").val() >+ if ( cur_barc != '' && unique_item_fields.indexOf('barcode')>-1 ){ >+ tmp_uif = unique_item_fields.replace("barcode",''); >+ unique_item_fields=tmp_uif; >+ } >+ else { cur_barc=''} >+ > for(var i=0;i<count;i++){ >+ if( cur_barc!='') { >+ var old_barc = $("#"+index + " #subfieldp input[name='field_value']").val(); >+ } > cloneItemBlock(index, unique_item_fields, function(cloneIndex){ >- addItemInList(cloneIndex,unique_item_fields, function(){ >+ addItemInList(cloneIndex,unique_item_fields, function(){i >+ if( cur_barc != '' ){ >+ cur_barc = incrementBarcode(cur_barc); >+ $("#"+index + " #subfieldp input[name='field_value']").val(cur_barc); >+ } > if( ($("#items_list tbody tr").length-countItemsBefore)==(count)){ > $("#multiValue").val(''); > $('#'+index).show(); >@@ -55,14 +69,34 @@ function addMulti( count, node, unique_item_fields){ > } > } > >+function incrementBarcode(barcode){ >+ var split_barcode =/(.*?)(\d+)$/; >+ var barcode_parts = split_barcode.exec(barcode); >+ if( barcode_parts == null ) return undefined; >+ var length_of_inc_barcode = barcode_parts[2].length; >+ if( barcode_parts[2].match(/^9+$/) ) length_of_inc_barcode++; >+ var inc_number = parseInt(barcode_parts[2], 10) + 1; >+ var inc_string = inc_number.toString(); >+ while ( inc_string.length < length_of_inc_barcode ) inc_string = "0" + inc_string; >+ barcode = barcode_parts[1]+inc_string; >+ return barcode; >+} > >-function checkCount(node, unique_item_fields){ >+function checkInputs(node, unique_item_fields){ > var count = parseInt( $("#multiValue").val(), 10 ); > if ( isNaN( count ) || count <=0) { > $("#multiCountModal").modal('show'); > } > else{ >- addMulti( count, node, unique_item_fields); >+ var index = $(node).closest("div").attr('id'); >+ var barcode = $("#"+index + " #subfieldp input[name='field_value']").val(); >+ if ( barcode !='' && unique_item_fields.indexOf('barcode')>-1 ){ >+ if ( incrementBarcode(barcode) != undefined ) { >+ addMulti( count, node, unique_item_fields); >+ } >+ else { $("#incrementBarcodeModal").modal('show');} >+ } >+ else { addMulti( count, node, unique_item_fields); } > } > } > >@@ -72,7 +106,7 @@ function showItem(index) { > $(this).show(); > } else { > if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) { >- $(this).remove(); >+ $(this).remove(); > } else { > $(this).hide(); > } >@@ -180,7 +214,7 @@ function cloneItemBlock(index, unique_item_fields, callback) { > 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')+ '" />'; > buttonPlus += '<input type="button" class="addItemControl cancel" name="buttonClear" style="cursor:pointer;" onclick="clearItemBlock(this)" value="' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear')+ '" />'; > 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')+ '" />'; >- 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>'; >+ 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>'; > buttonPlus += "</fieldset>"; > $(clone).append(buttonPlus); > /* Copy values from the original block (input) */ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index c993e1c..0b63827 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -651,7 +651,8 @@ $(document).ready(function() > [% IF UniqueItemFields %] > <div id="uniqueFieldsModal" class="modal hide fade" aria-labelledby="uniqueFieldsModal" aria-hidden="true"> > <div class="modal-body"> >- <h3>The following fields are listed in the UniqueItemFields system preference and will not be copied</h3> >+ <h3>The following fields are listed in the UniqueItemFields system preference and will not be copied.</h3> >+ <h4>Note: If barcode is unique it will be incremented or throw an error</h4> > <ul id="uniqueItemFields"> > [% FOREACH uniqueField IN UniqueItemFields.split(" ") %] > <li>[% uniqueField %]</li> >@@ -663,7 +664,12 @@ $(document).ready(function() > > <div id="multiCountModal" class="modal hide fade" aria-labelledby="multiCountModal" aria-hidden="true"> > <h3>Invalid number of copies</h3> >- <p>Please enter a <b>number</b>, greater than or equal to 1</p> >+ <p>Please enter a number, greater than or equal to 1</p> >+</div> >+ >+<div id="incrementBarcodeModal" class="modal hide fade" aria-labelledby="incrementBarcodeModal" aria-hidden="true"> >+ <h3>Barcode cannot be incremented</h3> >+ <p>Unable to automatically determine values for barcodes. No items have been generated</p> > </div> > > </div> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14752
:
46093
|
46439
|
46832
|
46833
|
47223
|
47252
|
47477
|
48254
|
51481
|
52083
|
52587
|
52588
|
52605
|
52606
|
55527
|
55528
|
56649
|
56684