forked from DGNum/gestioCOF
Affichage majoration K-Psul
- Le fond change de couleur lorsqu'il y a une majoration. La majoration est indiquée dans le cadre sur la caisse (et clignote !) - Meilleure prise en charge des paramètres sur K-Psul
This commit is contained in:
parent
e27559d123
commit
4941b11f56
4 changed files with 79 additions and 9 deletions
|
@ -12,6 +12,12 @@ input[type=number]::-webkit-outer-spin-button {
|
|||
background:#fff;
|
||||
}
|
||||
|
||||
@keyframes colorchange {
|
||||
0% { background: yellow; }
|
||||
50% { background: #660066; }
|
||||
100% { background: yellow; }
|
||||
}
|
||||
|
||||
/*
|
||||
* Top row
|
||||
*/
|
||||
|
@ -163,6 +169,24 @@ input[type=number]::-webkit-outer-spin-button {
|
|||
right:0;
|
||||
}
|
||||
|
||||
#addcost {
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
left:0;
|
||||
|
||||
height:32px;
|
||||
line-height:32px;
|
||||
padding:0 10px;
|
||||
|
||||
background:#c8102e;
|
||||
color:#fff;
|
||||
|
||||
font-weight:bold;
|
||||
|
||||
animation: blink 1.5s steps(1) infinite;
|
||||
}
|
||||
@keyframes blink { 50% { visibility: hidden; } }
|
||||
|
||||
/*
|
||||
* Second part
|
||||
*/
|
||||
|
|
|
@ -126,14 +126,30 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
var subvention_cof = 25;
|
||||
|
||||
function amountToUKF(amount, is_cof=false) {
|
||||
if (is_cof)
|
||||
return Math.round(amount * (1+subvention_cof/100) * 10);
|
||||
return Math.round(amount * 10);
|
||||
var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1;
|
||||
return Math.round(amount * coef_cof * 10);
|
||||
}
|
||||
|
||||
// Retrieve settings
|
||||
|
||||
var settings = {}
|
||||
|
||||
function resetSettings() {
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url : "{% url 'kfet.kpsul.get_settings' %}",
|
||||
method : "POST",
|
||||
})
|
||||
.done(function(data) {
|
||||
settings['addcost_for'] = data['addcost_for'];
|
||||
settings['addcost_amount'] = parseFloat(data['addcost_amount']);
|
||||
settings['subvention_cof'] = parseFloat(data['subvention_cof']);
|
||||
displayAddcost();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// -----
|
||||
// Account data management
|
||||
// -----
|
||||
|
@ -665,7 +681,7 @@ $(document).ready(function() {
|
|||
article_data = articlesList[i];
|
||||
var reduc_divisor = 1;
|
||||
if (account_data['is_cof'])
|
||||
reduc_divisor = 1 + subvention_cof / 100;
|
||||
reduc_divisor = 1 + settings['subvention_cof'] / 100;
|
||||
return - article_data[3] * nb / reduc_divisor;
|
||||
}
|
||||
|
||||
|
@ -1027,6 +1043,20 @@ $(document).ready(function() {
|
|||
// Addcost
|
||||
// -----
|
||||
|
||||
var addcost_default_html = '<div id="addcost">Majoration vers <span class="addcost_for"></span> de <span class="addcost_amount"></span>€</div>';
|
||||
|
||||
function displayAddcost() {
|
||||
checkout_container.find('#addcost').remove();
|
||||
$('body').css('animation', 'none');
|
||||
if (settings['addcost_for'] && settings['addcost_amount']) {
|
||||
var addcost_html = $(addcost_default_html);
|
||||
addcost_html
|
||||
.find('.addcost_for').text(settings['addcost_for']).end()
|
||||
.find('.addcost_amount').text(settings['addcost_amount'].toFixed(2)).end();
|
||||
checkout_container.prepend(addcost_html);
|
||||
$('body').css('animation', 'colorchange 3s infinite');
|
||||
}
|
||||
}
|
||||
function sendAddcost(trigramme, amount, password='') {
|
||||
var data = {
|
||||
trigramme: trigramme,
|
||||
|
@ -1043,9 +1073,6 @@ $(document).ready(function() {
|
|||
$xhr.setRequestHeader("KFetPassword", password);
|
||||
},
|
||||
})
|
||||
.done(function(data) {
|
||||
location.reload();
|
||||
})
|
||||
.fail(function($xhr) {
|
||||
var data = $xhr.responseJSON;
|
||||
switch ($xhr.status) {
|
||||
|
@ -1160,6 +1187,11 @@ $(document).ready(function() {
|
|||
articles_container.find('[data-article='+article['id']+'] .stock')
|
||||
.text(article['stock']);
|
||||
}
|
||||
if (data['addcost']) {
|
||||
settings['addcost_for'] = data['addcost']['for'];
|
||||
settings['addcost_amount'] = parseFloat(data['addcost']['amount']);
|
||||
displayAddcost();
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -1181,6 +1213,7 @@ $(document).ready(function() {
|
|||
resetCheckout();
|
||||
resetArticles();
|
||||
resetHistory();
|
||||
resetSettings();
|
||||
getArticles();
|
||||
getHistory();
|
||||
}
|
||||
|
|
|
@ -121,6 +121,8 @@ urlpatterns = [
|
|||
name = 'kfet.kpsul.articles_data'),
|
||||
url('^k-psul/update_addcost$', views.kpsul_update_addcost,
|
||||
name = 'kfet.kpsul.update_addcost'),
|
||||
url('^k-psul/get_settings$', views.kpsul_get_settings,
|
||||
name = 'kfet.kpsul.get_settings'),
|
||||
|
||||
# -----
|
||||
# Settings urls
|
||||
|
|
|
@ -479,8 +479,19 @@ def kpsul(request):
|
|||
data['checkout_form'] = KPsulCheckoutForm()
|
||||
operation_formset = KPsulOperationFormSet(queryset=Operation.objects.none())
|
||||
data['operation_formset'] = operation_formset
|
||||
addcost_for = Settings.ADDCOST_FOR()
|
||||
return render(request, 'kfet/kpsul.html', data)
|
||||
|
||||
@permission_required('kfet.is_team')
|
||||
def kpsul_get_settings(request):
|
||||
addcost_for = Settings.ADDCOST_FOR()
|
||||
data = {
|
||||
'subvention_cof': Settings.SUBVENTION_COF(),
|
||||
'addcost_for' : addcost_for and addcost_for.trigramme or '',
|
||||
'addcost_amount': Settings.ADDCOST_AMOUNT(),
|
||||
}
|
||||
return JsonResponse(data)
|
||||
|
||||
@permission_required('kfet.is_team')
|
||||
def kpsul_account_data(request):
|
||||
trigramme = request.POST.get('trigramme', '')
|
||||
|
|
Loading…
Reference in a new issue