forked from DGNum/gestioCOF
Add "count finished" checkbox
This commit is contained in:
parent
e6a1d16860
commit
eb7d436b90
2 changed files with 65 additions and 47 deletions
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
.jconfirm .jconfirm-box .content {
|
.jconfirm .jconfirm-box .content {
|
||||||
border-bottom:1px solid #ddd;
|
border-bottom:1px solid #ddd;
|
||||||
|
padding:5px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.jconfirm .jconfirm-box input {
|
.jconfirm .jconfirm-box input {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<td>Caisses en arrière</td>
|
<td>Caisses en arrière</td>
|
||||||
<td>Vrac</td>
|
<td>Vrac</td>
|
||||||
<td>Stock total</td>
|
<td>Stock total</td>
|
||||||
|
<td>Compte terminé</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -32,40 +33,41 @@
|
||||||
{% ifchanged form.category %}
|
{% ifchanged form.category %}
|
||||||
<tr class='section'>
|
<tr class='section'>
|
||||||
<td>{{ form.category_name }}</td>
|
<td>{{ form.category_name }}</td>
|
||||||
<td colspan="6"></td>
|
<td colspan="7"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endifchanged %}
|
{% endifchanged %}
|
||||||
<tr>
|
<tr>
|
||||||
{{ form.article }}
|
{{ form.article }}
|
||||||
<td>{{ form.name }}</td>
|
<td class='name'>{{ form.name }}</td>
|
||||||
<td id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
<td class='box_capacity' id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
||||||
<td>{{ form.stock_old }}</td>
|
<td class='stock_old'>{{ form.stock_old }}</td>
|
||||||
<td>
|
<td class='box_cellar'>
|
||||||
<div class='col-md-2'></div>
|
<div class='col-md-2'></div>
|
||||||
<div class='col-md-8'>
|
<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' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_cellar' step='1'>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class='box_bar'>
|
||||||
<div class='col-md-2'></div>
|
<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' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_bar' step='1'></div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class='misc'>
|
||||||
<div class='col-md-2'></div>
|
<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' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-misc' step='1'></div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class='stock_new'>
|
||||||
<div class='col-md-2'></div>
|
<div class='col-md-2'></div>
|
||||||
<div class='col-md-8'>{{ form.stock_new }}</div>
|
<div class='col-md-8'>{{ form.stock_new }}</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td class='finished'><input type='checkbox' prefix='{{form.prefix}}' class='form_control' id='id_{{form.prefix}}-finished'></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ formset.management_form }}
|
{{ formset.management_form }}
|
||||||
{% if not perms.kfet.add_inventory %}
|
{% if not perms.kfet.add_inventory %}
|
||||||
<td colspan='3'><label for='pwd'>Mot de passe : </label><input type="password" name="KFETPASSWORD"></td>
|
<td colspan='3'><label for='pwd'>Mot de passe : </label><input type="password" name="KFETPASSWORD"></td>
|
||||||
<td colspan='4'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
<td colspan='5'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td colspan='7'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
<td colspan='8'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
</form>
|
</form>
|
||||||
|
@ -84,20 +86,32 @@ $(document).ready(function() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$('input[type="number"]').on('input', function() {
|
$('input[type="number"]').on('input', function() {
|
||||||
var prefix = $(this).attr('prefix');
|
|
||||||
var $line = $(this).closest('tr');
|
var $line = $(this).closest('tr');
|
||||||
var box_capacity = +$line.find('#id_'+prefix+'-box_capacity').text();
|
var box_capacity = +$line.find('.box_capacity').text();
|
||||||
var box_cellar = +$line.find('#id_'+prefix+'-box_cellar').val();
|
var box_cellar = +$line.find('.box_cellar input').val();
|
||||||
var box_bar = +$line.find('#id_'+prefix+'-box_bar').val();
|
var box_bar = +$line.find('.box_bar input').val();
|
||||||
var misc = +$line.find('#id_'+prefix+'-misc').val();
|
var misc = +$line.find('.misc input').val();
|
||||||
$line.find('#id_'+prefix+'-stock_new').val(box_capacity*(box_cellar +box_bar)+misc);
|
$line.find('.stock_new input').val(box_capacity*(box_cellar +box_bar)+misc);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove warning if .finished is unchecked
|
||||||
|
*/
|
||||||
|
|
||||||
|
$('.finished input').change(function() {
|
||||||
|
if (!$(this).is(":checked")) {
|
||||||
|
var $line = $(this).closest('tr');
|
||||||
|
var id = $line.find('input[type="hidden"]').val();
|
||||||
|
$(this).closest('tr').removeClass('inventory_modified');
|
||||||
|
conflicts = conflicts.filter(item => item != id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Websocket
|
* Websocket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var modified = [];
|
var conflicts = [];
|
||||||
var websocket_msg_default = {'articles':[]}
|
var websocket_msg_default = {'articles':[]}
|
||||||
|
|
||||||
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||||
|
@ -107,50 +121,53 @@ $(document).ready(function() {
|
||||||
socket.onmessage = function(e) {
|
socket.onmessage = function(e) {
|
||||||
var data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
var data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
||||||
for (let article of data['articles']) {
|
for (let article of data['articles']) {
|
||||||
modified.push(article.id);
|
var $line = $('input[value="'+article.id+'"]').parent();
|
||||||
$('input[value="'+article.id+'"]').parent().addClass('inventory_modified');
|
if ($line.find('.finished input').prop("checked")) {
|
||||||
|
conflicts.push(article.id);
|
||||||
|
$line.addClass('inventory_modified');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input[type="submit"]').on("click", function(e) {
|
$('input[type="submit"]').on("click", function(e) {
|
||||||
|
console.log(e.keyCode);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var conflicts = [];
|
conflicts = [...new Set(conflicts)]; //remove duplicates
|
||||||
for (let id of modified) {
|
|
||||||
var $input = $('input[value="'+id+'"]');
|
|
||||||
if ($input.siblings(":last").find('input').val() !== "") {
|
|
||||||
conflicts.push($input.next().text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conflicts.length) {
|
if (conflicts.length) {
|
||||||
content = '';
|
content = '';
|
||||||
content += "Conflits possibles :"
|
content += "Conflits possibles :"
|
||||||
content += '<ul>';
|
content += '<ul>';
|
||||||
for (let article of conflicts) {
|
for (let id of conflicts) {
|
||||||
content += '<li>'+article+'</li>';
|
var name = $('input[value="'+id+'"]').siblings('.name').text();
|
||||||
|
content += '<li>'+name+'</li>';
|
||||||
}
|
}
|
||||||
content += '</ul>'
|
content += '</ul>'
|
||||||
return $.confirm({
|
|
||||||
title: "Confirmer l'inventaire",
|
|
||||||
content: content,
|
|
||||||
backgroundDismiss: true,
|
|
||||||
animation: 'top',
|
|
||||||
closeAnimation: 'bottom',
|
|
||||||
keyboardEnabled: true,
|
|
||||||
confirm: function() {
|
|
||||||
$('#inventoryform').submit();
|
|
||||||
},
|
|
||||||
onOpen: function() {
|
|
||||||
var that = this;
|
|
||||||
this.$content.find('input').on('keydown', function(e) {
|
|
||||||
if (e.keyCode == 13)
|
|
||||||
that.$confirmButton.click();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
$('#inventoryform').submit();
|
// Prevent erroneous enter key confirmations
|
||||||
|
// Kinda complicated to filter if click or enter key...
|
||||||
|
content="Voulez-vous confirmer l'inventaire ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.confirm({
|
||||||
|
title: "Confirmer l'inventaire",
|
||||||
|
content: content,
|
||||||
|
backgroundDismiss: true,
|
||||||
|
animation: 'top',
|
||||||
|
closeAnimation: 'bottom',
|
||||||
|
keyboardEnabled: true,
|
||||||
|
confirm: function() {
|
||||||
|
$('#inventoryform').submit();
|
||||||
|
},
|
||||||
|
onOpen: function() {
|
||||||
|
var that = this;
|
||||||
|
this.$content.find('input').on('keydown', function(e) {
|
||||||
|
if (e.keyCode == 13)
|
||||||
|
that.$confirmButton.click();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue