diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html
index b76a3fc1..2a6eec56 100644
--- a/kfet/templates/kfet/kpsul.html
+++ b/kfet/templates/kfet/kpsul.html
@@ -310,9 +310,11 @@ $(document).ready(function() {
// -----
function requestAuth(data, callback) {
+ var content = getErrorsHtml(data);
+ content += '',
$.confirm({
title: 'Authentification requise',
- content: '',
+ content: content,
backgroundDismiss: true,
animation:'top',
closeAnimation:'bottom',
@@ -332,6 +334,44 @@ $(document).ready(function() {
});
}
+ // -----
+ // Errors ajax
+ // -----
+
+ function getErrorsHtml(data) {
+ var content = '';
+ if ('operation_group' in data['errors']) {
+ content += 'Général';
+ content += '
';
+ if (data['errors']['operation_group'].indexOf('on_acc') != -1)
+ content += '- Pas de compte sélectionné
';
+ if (data['errors']['operation_group'].indexOf('checkout') != -1)
+ content += '- Pas de caisse sélectionnée
';
+ content += '
';
+ }
+ if ('missing_perms' in data['errors']) {
+ content += 'Permissions manquantes';
+ content += '';
+ for (var i=0; i'+data['errors']['missing_perms'][i]+'';
+ content += '
';
+ }
+ if ('negative' in data['errors'])
+ content += 'Autorisation de négatif requise';
+ return content;
+ }
+
+ function displayErrors(html) {
+ $.alert({
+ title: 'Erreurs',
+ content: html,
+ backgroundDismiss: true,
+ animation: 'top',
+ closeAnimation: 'bottom',
+ keyboardEnabled: true,
+ });
+ }
+
// -----
// Perform operations
// -----
@@ -362,6 +402,9 @@ $(document).ready(function() {
case 403:
requestAuth(data, performOperations);
break;
+ case 400:
+ displayErrors(getErrorsHtml(data));
+ break;
}
});
}
@@ -828,7 +871,7 @@ $(document).ready(function() {
operation_html
.find('#id_form-__prefix__-type').val(type).end()
- .find('#id_form-__prefix__-amount').val(amount).end()
+ .find('#id_form-__prefix__-amount').val((parseFloat(amount)).toFixed(2)).end()
.find('#id_form-__prefix__-article').val(article).end()
.find('#id_form-__prefix__-article_nb').val(article_nb).end()
.find('#id_form-__prefix__-is_checkout').val(is_checkout);