forked from DGNum/gestioCOF
Merge branch 'master' of git.eleves.ens.fr:cof-geek/gestioCOF into Aufinal/editions
This commit is contained in:
commit
44fbc92893
75 changed files with 35726 additions and 270 deletions
|
@ -23,6 +23,7 @@
|
|||
{{ trigramme_form.trigramme }}
|
||||
</div>
|
||||
<div id="trigramme_valid"></div>
|
||||
<p class="help-block">Les mots contenant des caractères non alphanumériques seront ignorés</p>
|
||||
<input type="text" name="q" id="search_autocomplete" spellcheck="false" placeholder="Chercher un utilisateur par nom, prénom ou identifiant clipper" class="form-control">
|
||||
<div style="position:relative;">
|
||||
<div id="search_results"></div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
</a>
|
||||
</li>
|
||||
{% if kfet %}
|
||||
<li class="user_category"><span class="text">Comptes existant</span></li>
|
||||
<li class="user_category"><span class="text">Comptes existants</span></li>
|
||||
{% for account, user in kfet %}
|
||||
<li><span class="text">{{ account }} [{{ user|highlight_user:q }}]</span></li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -10,6 +10,18 @@
|
|||
<script type="text/javascript" src="{% static 'kfet/js/moment-timezone-with-data-2010-2020.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/kfet.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/history.js' %}"></script>
|
||||
{% if account.user == request.user %}
|
||||
<script type="text/javascript" src="{% static 'kfet/js/Chart.bundle.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/statistic.js' %}"></script>
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
var stat_last = new StatsGroup("{% url 'kfet.account.stat.last' trigramme=account.trigramme %}",
|
||||
$("#stat_last"));
|
||||
var stat_balance = new StatsGroup("{% url 'kfet.account.stat.balance' trigramme=account.trigramme %}",
|
||||
$("#stat_balance"));
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
|
@ -51,6 +63,27 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if account.user == request.user %}
|
||||
<div class="content-right-block content-right-block-transparent">
|
||||
<h2>Statistiques</h2>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 nopadding">
|
||||
<div class="panel-md-margin">
|
||||
<h3>Ma balance</h3>
|
||||
<div id="stat_balance" class"stat-graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
<div class="row">
|
||||
<div class="col-sm-12 nopadding">
|
||||
<div class="panel-md-margin">
|
||||
<h3>Ma consommation</h3>
|
||||
<div id="stat_last" class"stat-graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="content-right-block">
|
||||
<h2>Historique</h2>
|
||||
<div id="history">
|
||||
|
|
14
kfet/templates/kfet/account_search_autocomplete.html
Normal file
14
kfet/templates/kfet/account_search_autocomplete.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% load kfet_tags %}
|
||||
|
||||
<ul>
|
||||
{% if accounts %}
|
||||
{% for trigramme, user in accounts %}
|
||||
<li class='choice'>{{ user|highlight_text:q }} (<span class="trigramme">{{ trigramme }}</span>)</li>
|
||||
{% endfor %}
|
||||
{% elif not q %}
|
||||
<li class="user_category"><span class="text">Pas de recherche, pas de résultats !</span></li>
|
||||
{% else %}
|
||||
<li class="user_category"><span class="text">Aucune correspondance trouvée :-(</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
<td class="text-right">Prix</td>
|
||||
<td class="text-right">Stock</td>
|
||||
<td class="text-right">En vente</td>
|
||||
<td class="text-right">Affiché</td>
|
||||
<td class="text-right">Dernier inventaire</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -40,7 +41,7 @@
|
|||
{% for article in articles %}
|
||||
{% ifchanged article.category %}
|
||||
<tr class="section">
|
||||
<td colspan="6">{{ article.category.name }}</td>
|
||||
<td colspan="7">{{ article.category.name }}</td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
|
@ -52,7 +53,8 @@
|
|||
<td>{{ article.name }}</td>
|
||||
<td class="text-right">{{ article.price }}€</td>
|
||||
<td class="text-right">{{ article.stock }}</td>
|
||||
<td class="text-right">{{ article.is_sold }}</td>
|
||||
<td class="text-right">{{ article.is_sold | yesno:"En vente,Non vendu"}}</td>
|
||||
<td class="text-right">{{ article.hidden | yesno:"Caché,Affiché" }}</td>
|
||||
<td class="text-right">{{ article.inventory.0.at }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends 'kfet/base.html' %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block title %}Informations sur l'article {{ article }}{% endblock %}
|
||||
{% block content-header-title %}Article - {{ article.name }}{% endblock %}
|
||||
|
@ -14,7 +15,8 @@
|
|||
<div class="block">
|
||||
<div class="line">Prix (hors réduc.): {{ article.price }}€</div>
|
||||
<div class="line">Stock: {{ article.stock }}</div>
|
||||
<div class="line">En vente: {{ article.is_sold }}</div>
|
||||
<div class="line">En vente: {{ article.is_sold | yesno:"Oui,Non" }}</div>
|
||||
<div class="line">Affiché: {{ article.hidden | yesno:"Non,Oui" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
|
@ -76,10 +78,32 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /row-->
|
||||
</div>
|
||||
<div class="content-right-block content-right-block-transparent">
|
||||
<h2>Statistiques</h2>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 nopadding">
|
||||
<div class="panel-md-margin">
|
||||
<h3>Ventes de {{ article.name }}</h3>
|
||||
<div id="stat_last"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<script type="text/javascript" src="{% static 'kfet/js/Chart.bundle.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/statistic.js' %}"></script>
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
var stat_last = $("#stat_last");
|
||||
var stat_last_url = "{% url 'kfet.article.stat.last' article.id %}";
|
||||
STAT.get_thing(stat_last_url, stat_last, "Stat non trouvées :(");
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
65
kfet/templates/kfet/home.html
Normal file
65
kfet/templates/kfet/home.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
{% extends "kfet/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load kfet_tags %}
|
||||
|
||||
{% block title %}Accueil{% endblock %}
|
||||
{% block content-header-title %}Accueil{% endblock %}
|
||||
{% block extra_head %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/home.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-3 col-content-left">
|
||||
<div class="content-left">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8 col-md-9 col-content-right">
|
||||
{% include 'kfet/base_messages.html' %}
|
||||
<div class="content-right">
|
||||
<div class="content-right-block">
|
||||
<h2>Carte</h2>
|
||||
<div class="column-row">
|
||||
<div class="column-sm-1 column-md-2 column-lg-3">
|
||||
<div class="unbreakable carte-inverted">
|
||||
<h3>Pressions du moment</h3>
|
||||
<ul class="carte">
|
||||
{% for article in pressions %}
|
||||
<li class="carte-line">
|
||||
<div class="filler"></div>
|
||||
<span class="carte-label">{{ article.name }}</span>
|
||||
<span class="carte-ukf">{{ article.price | ukf:False}} UKF</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div><!-- endblock unbreakable -->
|
||||
{% for article in articles %}
|
||||
{% ifchanged article.category %}
|
||||
{% if not forloop.first %}
|
||||
</ul>
|
||||
</div><!-- endblock unbreakable -->
|
||||
{% endif %}
|
||||
<div class="unbreakable">
|
||||
<h3>{{ article.category.name }}</h3>
|
||||
<ul class="carte">
|
||||
{% endifchanged %}
|
||||
<li class="carte-line">
|
||||
<div class="filler"></div>
|
||||
<span class="carte-label">{{ article.name }}</span>
|
||||
<span class="carte-ukf">{{ article.price | ukf:False}} UKF</span>
|
||||
</li>
|
||||
{% if foorloop.last %}
|
||||
</ul>
|
||||
</div><!-- endblock unbreakable -->
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
{% block extra_head %}
|
||||
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/jquery-ui.min.css' %}">
|
||||
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/kpsul_grid.css' %}">
|
||||
<script src="{% static "autocomplete_light/autocomplete.js" %}" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
||||
|
@ -122,6 +123,7 @@
|
|||
<div id="article_selection">
|
||||
<input type="text" id="article_autocomplete" autocomplete="off">
|
||||
<input type="number" id="article_number" step="1" min="1">
|
||||
<span type="stock" id="article_stock"></span>
|
||||
<input type="hidden" id="article_id" value="">
|
||||
</div>
|
||||
<div id="articles_data">
|
||||
|
@ -220,7 +222,7 @@ $(document).ready(function() {
|
|||
function displayAccountData() {
|
||||
var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : '';
|
||||
if (balance != '')
|
||||
balance = amountToUKF(account_data['balance'], account_data['is_cof']);
|
||||
balance = amountToUKF(account_data['balance'], account_data['is_cof'], true);
|
||||
var is_cof = account_data['trigramme'] ? account_data['is_cof'] : '';
|
||||
if (is_cof !== '')
|
||||
is_cof = is_cof ? '<b>COF</b>' : '<b>Non-COF</b>';
|
||||
|
@ -260,12 +262,58 @@ $(document).ready(function() {
|
|||
buttons += '<a href="'+url_base+'?trigramme='+trigramme+'" class="btn btn-primary" target="_blank" title="Créer"><span class="glyphicon glyphicon-plus"></span></a>';
|
||||
} else {
|
||||
var url_base = '{% url 'kfet.account' %}'
|
||||
buttons += '<a href="'+url_base+'" class="btn btn-primary" target="_blank" title="Rechercher"><span class="glyphicon glyphicon-search"></span></a>';
|
||||
buttons += '<button class="btn btn-primary search" title="Rechercher"><span class="glyphicon glyphicon-search"></span></button>';
|
||||
}
|
||||
}
|
||||
account_container.find('.buttons').html(buttons);
|
||||
}
|
||||
|
||||
// Search for an account
|
||||
function searchAccount() {
|
||||
var content = '<input type="text" name="q" id="search_autocomplete" spellcheck="false" autofocus><div id="account_results"></div>' ;
|
||||
$.dialog({
|
||||
title: 'Recherche de compte',
|
||||
content: content,
|
||||
backgroundDismiss: true,
|
||||
animation: 'top',
|
||||
closeAnimation: 'bottom',
|
||||
keyboardEnabled: true,
|
||||
|
||||
onOpen: function() {
|
||||
var that=this ;
|
||||
$('input#search_autocomplete').yourlabsAutocomplete({
|
||||
url: '{% url "kfet.account.search.autocomplete" %}',
|
||||
minimumCharacters: 2,
|
||||
id: 'search_autocomplete',
|
||||
choiceSelector: '.choice',
|
||||
placeholder: "Chercher un utilisateur K-Fêt",
|
||||
box: $("#account_results"),
|
||||
fixPosition: function() {},
|
||||
});
|
||||
$('input#search_autocomplete').bind(
|
||||
'selectChoice',
|
||||
function(e, choice, autocomplete) {
|
||||
autocomplete.hide() ;
|
||||
triInput.val(choice.find('.trigramme').text()) ;
|
||||
triInput.trigger('input') ;
|
||||
that.close() ;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
account_container.on('click', '.search', function () {
|
||||
searchAccount() ;
|
||||
}) ;
|
||||
|
||||
account_container.on('keydown', function(e) {
|
||||
if (e.which == 70 && e.ctrlKey) {
|
||||
// Ctrl + F : universal search shortcut
|
||||
searchAccount() ;
|
||||
e.preventDefault() ;
|
||||
}
|
||||
});
|
||||
|
||||
// Clear data
|
||||
function resetAccountData() {
|
||||
account_data = account_data_default;
|
||||
|
@ -571,7 +619,10 @@ $(document).ready(function() {
|
|||
for (var elem in article) {
|
||||
article_html.find('.'+elem).text(article[elem])
|
||||
}
|
||||
article_html.find('.price').text(amountToUKF(article['price'], false));
|
||||
if (-5 <= article['stock'] && article['stock'] <= 5) {
|
||||
article_html.addClass('low-stock');
|
||||
}
|
||||
article_html.find('.price').text(amountToUKF(article['price'], false, false)+' UKF');
|
||||
var category_html = articles_container
|
||||
.find('#data-category-'+article['category_id']);
|
||||
if (category_html.length == 0) {
|
||||
|
@ -597,7 +648,7 @@ $(document).ready(function() {
|
|||
});
|
||||
$after.after(article_html);
|
||||
// Pour l'autocomplétion
|
||||
articlesList.push([article['name'],article['id'],article['category_id'],article['price']]);
|
||||
articlesList.push([article['name'],article['id'],article['category_id'],article['price'], article['stock']]);
|
||||
}
|
||||
|
||||
function getArticles() {
|
||||
|
@ -625,8 +676,9 @@ $(document).ready(function() {
|
|||
var articleSelect = $('#article_autocomplete');
|
||||
var articleId = $('#article_id');
|
||||
var articleNb = $('#article_number');
|
||||
// 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|119-123:F8-F12
|
||||
var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|119|120|121|122|123)$/;
|
||||
var articleStock = $('#article_stock');
|
||||
// 8:Backspace|9:Tab|13:Enter|38-40:Arrows|46:DEL|112-117:F1-6|119-123:F8-F12
|
||||
var normalKeys = /^(8|9|13|37|38|39|40|46|112|113|114|115|116|117|119|120|121|122|123)$/;
|
||||
var articlesList = [];
|
||||
|
||||
function deleteNonMatching(array, str) {
|
||||
|
@ -682,6 +734,7 @@ $(document).ready(function() {
|
|||
if (commit) {
|
||||
articleId.val(articlesMatch[0][1]);
|
||||
articleSelect.val(articlesMatch[0][0]);
|
||||
articleStock.text('/'+articlesMatch[0][4]);
|
||||
displayMatchedArticles(articlesList);
|
||||
return true;
|
||||
}
|
||||
|
@ -728,10 +781,15 @@ $(document).ready(function() {
|
|||
return $article.find('.name').text();
|
||||
}
|
||||
|
||||
function getArticleStock($article) {
|
||||
return $article.find('.stock').text();
|
||||
}
|
||||
|
||||
// Sélection des articles à la souris/tactile
|
||||
articles_container.on('click', '.article', function() {
|
||||
articleId.val(getArticleId($(this)));
|
||||
articleSelect.val(getArticleName($(this)));
|
||||
articleStock.text('/'+getArticleStock($(this)));
|
||||
displayMatchedArticles(articlesList);
|
||||
goToArticleNb();
|
||||
});
|
||||
|
@ -745,6 +803,7 @@ $(document).ready(function() {
|
|||
addPurchase(articleId.val(), articleNb.val());
|
||||
articleSelect.val('');
|
||||
articleNb.val('');
|
||||
articleStock.text('');
|
||||
articleSelect.focus();
|
||||
displayMatchedArticles(articlesList);
|
||||
return false;
|
||||
|
@ -764,7 +823,7 @@ $(document).ready(function() {
|
|||
// Basket
|
||||
// -----
|
||||
|
||||
var item_basket_default_html = '<tr><td class="amount"></td><td class="number"></td><td class="name"></td></tr>';
|
||||
var item_basket_default_html = '<tr><td class="amount"></td><td class="number"></td><td ><span class="lowstock glyphicon glyphicon-alert"></span></td><td class="name"></td></tr>';
|
||||
var basket_container = $('#basket table');
|
||||
var arrowKeys = /^(37|38|39|40)$/;
|
||||
|
||||
|
@ -782,16 +841,39 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
function addPurchase(id, nb) {
|
||||
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
||||
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||
article_basket_html = $(item_basket_default_html);
|
||||
article_basket_html
|
||||
.attr('data-opeindex', index)
|
||||
.find('.number').text(nb).end()
|
||||
.find('.name').text(article_data[0]).end()
|
||||
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof']));
|
||||
basket_container.prepend(article_basket_html);
|
||||
updateBasketRel();
|
||||
var existing = false;
|
||||
formset_container.find('[data-opeindex]').each(function () {
|
||||
var opeindex = $(this).attr('data-opeindex');
|
||||
var article_id = $(this).find('#id_form-'+opeindex+'-article').val();
|
||||
if (article_id == id) {
|
||||
existing = true ;
|
||||
addExistingPurchase(opeindex, nb);
|
||||
}
|
||||
});
|
||||
if (!existing) {
|
||||
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
||||
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||
article_basket_html = $(item_basket_default_html);
|
||||
article_basket_html
|
||||
.attr('data-opeindex', index)
|
||||
.find('.number').text('('+nb+'/'+article_data[4]+')').end()
|
||||
.find('.name').text(article_data[0]).end()
|
||||
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof']), false);
|
||||
basket_container.prepend(article_basket_html);
|
||||
if (is_low_stock(id, nb))
|
||||
article_basket_html.find('.lowstock')
|
||||
.show();
|
||||
updateBasketRel();
|
||||
}
|
||||
}
|
||||
|
||||
function is_low_stock(id, nb) {
|
||||
var i = 0 ;
|
||||
while (i<articlesList.length && id != articlesList[i][1]) i++;
|
||||
article_data = articlesList[i];
|
||||
|
||||
stock = article_data[4] ;
|
||||
return (-5 <= stock - nb && stock - nb <= 5);
|
||||
}
|
||||
|
||||
function addDeposit(amount) {
|
||||
|
@ -802,7 +884,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Charge').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -815,7 +897,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Édition').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -828,7 +910,7 @@ $(document).ready(function() {
|
|||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Retrait').end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||
basket_container.prepend(withdraw_basket_html);
|
||||
updateBasketRel();
|
||||
}
|
||||
|
@ -838,11 +920,25 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
$(document).on('keydown', function (e) {
|
||||
if (e.keyCode == 46) {
|
||||
// DEL (Suppr)
|
||||
basket_container.find('.ui-selected').each(function () {
|
||||
deleteFromBasket($(this).data('opeindex'));
|
||||
});
|
||||
switch(e.which) {
|
||||
case 46:
|
||||
// DEL (Suppr)
|
||||
basket_container.find('.ui-selected').each(function () {
|
||||
deleteFromBasket($(this).data('opeindex'));
|
||||
});
|
||||
break;
|
||||
case 38:
|
||||
// Arrow up
|
||||
basket_container.find('.ui-selected').each(function () {
|
||||
addExistingPurchase($(this).data('opeindex'), 1);
|
||||
});
|
||||
break;
|
||||
case 40:
|
||||
// Arrow down
|
||||
basket_container.find('.ui-selected').each(function () {
|
||||
addExistingPurchase($(this).data('opeindex'), -1);
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -870,7 +966,7 @@ $(document).ready(function() {
|
|||
var amount = $(this).find('#id_form-'+opeindex+'-amount');
|
||||
if (!deleted && type == "purchase")
|
||||
amount.val(amountEuroPurchase(article_id, article_nb));
|
||||
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof']));
|
||||
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof'], false));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -889,9 +985,9 @@ $(document).ready(function() {
|
|||
basketrel_html += '<div>Sur 20€: '+ (20-amount).toFixed(2) +' €</div>';
|
||||
} else if (account_data['trigramme'] != '' && !isBasketEmpty()) {
|
||||
var amount = getAmountBasket();
|
||||
var amountUKF = amountToUKF(amount, account_data['is_cof']);
|
||||
var amountUKF = amountToUKF(amount, account_data['is_cof'], false);
|
||||
var newBalance = account_data['balance'] + amount;
|
||||
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof']);
|
||||
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof'], true);
|
||||
basketrel_html += '<div>Total: '+amountUKF+'</div>';
|
||||
basketrel_html += '<div>Nouveau solde: '+newBalanceUKF+'</div>';
|
||||
if (newBalance < 0)
|
||||
|
@ -906,6 +1002,46 @@ $(document).ready(function() {
|
|||
updateBasketRel();
|
||||
}
|
||||
|
||||
function addExistingPurchase(opeindex, nb) {
|
||||
var type = formset_container.find("#id_form-"+opeindex+"-type").val();
|
||||
var id = formset_container.find("#id_form-"+opeindex+"-article").val();
|
||||
var nb_before = formset_container.find("#id_form-"+opeindex+"-article_nb").val();
|
||||
var nb_after = parseInt(nb_before) + parseInt(nb);
|
||||
var amountEuro_after = amountEuroPurchase(id, nb_after);
|
||||
var amountUKF_after = amountToUKF(amountEuro_after, account_data['is_cof']);
|
||||
|
||||
if (type == 'purchase') {
|
||||
if (nb_after == 0) {
|
||||
deleteFromBasket(opeindex);
|
||||
} else if (nb_after > 0 && nb_after <= 25) {
|
||||
if (nb_before > 0) {
|
||||
var article_html = basket_container.find('[data-opeindex='+opeindex+']');
|
||||
article_html.find('.amount').text(amountUKF_after).end()
|
||||
.find('.number').text('('+nb_after+'/'+article_data[4]+')').end() ;
|
||||
|
||||
} else {
|
||||
article_html = $(item_basket_default_html);
|
||||
article_html
|
||||
.attr('data-opeindex', opeindex)
|
||||
.find('.number').text('('+nb_after+'/'+article_data[4]+')').end()
|
||||
.find('.name').text(article_data[0]).end()
|
||||
.find('.amount').text(amountUKF_after);
|
||||
basket_container.prepend(article_basket_html);
|
||||
|
||||
}
|
||||
|
||||
if (is_low_stock(id, nb_after))
|
||||
article_html.find('.lowstock')
|
||||
.show();
|
||||
else
|
||||
article_html.find('.lowstock')
|
||||
.hide();
|
||||
updateExistingFormset(opeindex, nb_after, amountEuro_after);
|
||||
updateBasketRel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetBasket() {
|
||||
basket_container.find('tr').remove();
|
||||
mngmt_total_forms = 1;
|
||||
|
@ -915,6 +1051,7 @@ $(document).ready(function() {
|
|||
articleId.val(0);
|
||||
articleSelect.val('');
|
||||
articleNb.val('');
|
||||
articleStock.text('');
|
||||
displayMatchedArticles(articlesList);
|
||||
}
|
||||
|
||||
|
@ -925,7 +1062,7 @@ $(document).ready(function() {
|
|||
function askDeposit() {
|
||||
$.confirm({
|
||||
title: 'Montant de la charge',
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
content: '<input type="number" lang="en" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
|
@ -952,7 +1089,7 @@ $(document).ready(function() {
|
|||
function askEdit() {
|
||||
$.confirm({
|
||||
title: "Montant de l'édition",
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
content: '<input type="number" lang="en" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
|
@ -979,7 +1116,7 @@ $(document).ready(function() {
|
|||
function askWithdraw() {
|
||||
$.confirm({
|
||||
title: 'Montant du retrait',
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
content: '<input type="number" lang="en" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
|
@ -1068,7 +1205,14 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
function deleteFromFormset(opeindex) {
|
||||
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true);
|
||||
updateExistingFormset(opeindex, 0, '0.00');
|
||||
}
|
||||
|
||||
function updateExistingFormset(opeindex, nb, amount) {
|
||||
formset_container
|
||||
.find('#id_form-'+opeindex+'-amount').val((parseFloat(amount)).toFixed(2)).end()
|
||||
.find('#id_form-'+opeindex+'-article_nb').val(nb).end()
|
||||
.find('#id_form-'+opeindex+'-DELETE').prop('checked', !nb);
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -1160,7 +1304,7 @@ $(document).ready(function() {
|
|||
function askAddcost(errors = '') {
|
||||
$.confirm({
|
||||
title: 'Majoration',
|
||||
content: errors + '<input type="text" placeholder="Trigramme" autocomplete="off" name="trigramme" spellcheck="false" style="text-transform:uppercase" autofocus><input type="number" step="0.01" min="0.01" placeholder="€" name="amount">',
|
||||
content: errors + '<input type="text" placeholder="Trigramme" autocomplete="off" name="trigramme" spellcheck="false" style="text-transform:uppercase" autofocus><input type="number" lang="en" step="0.01" min="0.01" placeholder="€" name="amount">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
|
@ -1247,7 +1391,9 @@ $(document).ready(function() {
|
|||
}
|
||||
for (var i=0; i<data['articles'].length; i++) {
|
||||
article = data['articles'][i];
|
||||
articles_container.find('[data-article='+article['id']+'] .stock')
|
||||
articles_container.find('#data-article-'+article['id'])
|
||||
.addClass('low-stock');
|
||||
articles_container.find('#data-article-'+article['id']+' .stock')
|
||||
.text(article['stock']);
|
||||
}
|
||||
if (data['addcost']) {
|
||||
|
|
|
@ -5,19 +5,31 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
<div class="content-center">
|
||||
<div>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<table class="table text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<td rowspan="2">Article</td>
|
||||
<td colspan="5">Ventes</td>
|
||||
<td rowspan="2">V. moy.</td>
|
||||
<td rowspan="2">E.T.</td>
|
||||
<td rowspan="2">Prév.</td>
|
||||
<td colspan="5">Ventes
|
||||
<span class='glyphicon glyphicon-question-sign' title="Ventes des 5 dernières semaines" data-placement="bottom"></span>
|
||||
</td>
|
||||
<td rowspan="2">V. moy.
|
||||
<span class='glyphicon glyphicon-question-sign' title="Moyenne des ventes" data-placement="bottom"></span>
|
||||
</td>
|
||||
<td rowspan="2">E.T.
|
||||
<span class='glyphicon glyphicon-question-sign' title="Écart-type des ventes" data-placement="bottom"></span>
|
||||
</td>
|
||||
<td rowspan="2">Prév.
|
||||
<span class='glyphicon glyphicon-question-sign' title="Prévision de ventes" data-placement="bottom"></span>
|
||||
</td>
|
||||
<td rowspan="2">Stock</td>
|
||||
<td rowspan="2">Rec.</td>
|
||||
<td rowspan="2">Com.</td>
|
||||
<td rowspan="2">Rec.
|
||||
<span class='glyphicon glyphicon-question-sign' title="Quantité conseillée" data-placement="bottom"></span>
|
||||
</td>
|
||||
<td rowspan="2">Commande</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>S1</td>
|
||||
|
@ -30,8 +42,9 @@
|
|||
<tbody>
|
||||
{% for form in formset %}
|
||||
{% ifchanged form.category %}
|
||||
<tr>
|
||||
<td colspan="11">{{ form.category_name }}</td>
|
||||
<tr class='section'>
|
||||
<td> {{ form.category_name }}</td>
|
||||
<td colspan="11"></td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
|
@ -56,7 +69,15 @@
|
|||
<input type="password" name="KFETPASSWORD">
|
||||
{% endif %}
|
||||
{{ formset.management_form }}
|
||||
<input type="submit" class="btn btn-primary btn-lg" value="Envoyer">
|
||||
<input type="submit" class="btn btn-primary btn-lg btn-block" value="Envoyer">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function () {
|
||||
$('.glyphicon-question-sign').tooltip({'html': true}) ;
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,24 +7,27 @@
|
|||
|
||||
{% include 'kfet/base_messages.html' %}
|
||||
|
||||
<div class="content-center">
|
||||
<div>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
<table class='table text-center'>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Article</td>
|
||||
<td>HT</td>
|
||||
<td style="width:25%">Article</td>
|
||||
<td>Prix HT</td>
|
||||
<td>TVA</td>
|
||||
<td>Droits</td>
|
||||
<td>Com.</td>
|
||||
<td>Commandé</td>
|
||||
<td>Reçu</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for form in formset %}
|
||||
{% ifchanged form.category %}
|
||||
<tr>
|
||||
<td colspan="6">{{ form.category_name }}</td>
|
||||
<tr class='section'>
|
||||
<td>{{ form.category_name }}</td>
|
||||
<td colspan="5"></td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
|
@ -42,7 +45,9 @@
|
|||
<input type="password" name="KFETPASSWORD">
|
||||
{% endif %}
|
||||
{{ formset.management_form }}
|
||||
<input type="submit" value="Enregistrer">
|
||||
<input type="submit" class="btn btn-primary btn-lg btn-block" value="Enregistrer">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue