forked from DGNum/gestioCOF
simpler jquery selection
This commit is contained in:
parent
eb7d436b90
commit
31888e33ce
1 changed files with 15 additions and 10 deletions
|
@ -39,27 +39,27 @@
|
|||
<tr>
|
||||
{{ form.article }}
|
||||
<td class='name'>{{ form.name }}</td>
|
||||
<td class='box_capacity' id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
||||
<td class='stock_old'>{{ form.stock_old }}</td>
|
||||
<td class='box_capacity'>{{ form.box_capacity }}</td>
|
||||
<td><span class='current_stock'>{{ form.stock_old }}</span><span class='stock_diff'></span></td>
|
||||
<td class='box_cellar'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'>
|
||||
<input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_cellar' step='1'>
|
||||
<input type='number' class='form-control' step='1'>
|
||||
</div>
|
||||
</td>
|
||||
<td class='box_bar'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'><input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_bar' step='1'></div>
|
||||
<div class='col-md-8'><input type='number' class='form-control' step='1'></div>
|
||||
</td>
|
||||
<td class='misc'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'><input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-misc' step='1'></div>
|
||||
<div class='col-md-8'><input type='number' class='form-control' step='1'></div>
|
||||
</td>
|
||||
<td class='stock_new'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'>{{ form.stock_new }}</div>
|
||||
</td>
|
||||
<td class='finished'><input type='checkbox' prefix='{{form.prefix}}' class='form_control' id='id_{{form.prefix}}-finished'></td>
|
||||
<td class='finished'><input type='checkbox' class='form_control'></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{{ formset.management_form }}
|
||||
|
@ -88,10 +88,14 @@ $(document).ready(function() {
|
|||
$('input[type="number"]').on('input', function() {
|
||||
var $line = $(this).closest('tr');
|
||||
var box_capacity = +$line.find('.box_capacity').text();
|
||||
var box_cellar = +$line.find('.box_cellar input').val();
|
||||
var box_bar = +$line.find('.box_bar input').val();
|
||||
var misc = +$line.find('.misc input').val();
|
||||
$line.find('.stock_new input').val(box_capacity*(box_cellar +box_bar)+misc);
|
||||
var box_cellar = $line.find('.box_cellar input').val();
|
||||
var box_bar = $line.find('.box_bar input').val();
|
||||
var misc = $line.find('.misc input').val();
|
||||
if (box_cellar || box_bar || misc)
|
||||
$line.find('.stock_new input').val(
|
||||
box_capacity*((+box_cellar) +(+box_bar))+(+misc));
|
||||
else
|
||||
$line.find('.stock_new input').val('');
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -107,6 +111,7 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Websocket
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue