lib_batch.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // or see http://www.gnu.org/
  16. //
  17. // \file htdocs/core/js/lib_batch.js
  18. // \brief File that include javascript functions used when dispatching batch-enabled product
  19. //
  20. /**
  21. * addLineBatch
  22. * @deprecated replaced by addDispatchLine and moved to module folder and file fourn/js/lib_dispatch.js
  23. *
  24. * @param index int number of produt. 0 = first product line
  25. */
  26. function addLineBatch(index)
  27. {
  28. var nme = 'dluo_0_'+index;
  29. $row=$("tr[name='"+nme+"']").clone(true);
  30. $row.find("input[name^='qty']").val('');
  31. var trs = $("tr[name^='dluo_'][name$='_"+index+"']"); /* trs.length = position of line for batch */
  32. var newrow=$row.html().replace(/_0_/g,"_"+(trs.length)+"_");
  33. $row.html(newrow);
  34. //clear value
  35. $row.find("input[name^='qty']").val('');
  36. //change name of row
  37. $row.attr('name','dluo_'+trs.length+'_'+index);
  38. $("tr[name^='dluo_'][name$='_"+index+"']:last").after($row);
  39. /* Suffix of lines are: _ trs.length _ index */
  40. jQuery("#lot_number_"+trs.length+"_"+index).focus();
  41. nb = jQuery("#qty_"+(trs.length - 1)+"_"+index).val();
  42. if (nb > 0)
  43. {
  44. jQuery("#qty_"+(trs.length - 1)+"_"+index).val(1);
  45. jQuery("#qty_"+trs.length+"_"+index).val(nb - 1);
  46. }
  47. }