mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-04-23 17:08:03 +02:00
8990dac44c
* on n'initialise la dropzone des PJ du journal que si la PJ est marqué comme required * la dropzone est ensuite initialisée à la demande
178 lines
7.9 KiB
HTML
178 lines
7.9 KiB
HTML
{if $action == 'lister' || $action == 'debit' || $action == 'credit' }
|
|
|
|
{literal}
|
|
<script>
|
|
// Ventiler une ligne
|
|
function ventiler(idLigne, montant) {
|
|
ventilation = prompt('Combien souhaitez-vous ventiler ? (utilisez le séparateur ; pour ventiler sur plusieurs lignes)' + "\n" + '(toutes les values saisies seront déduites de la ligne existante)', montant);
|
|
if (ventilation) {
|
|
if (ventilation >= montant) {
|
|
alert('Vous ne pouvez pas saisir une valeur égale ou supérieur à la valeur initiale !')
|
|
} else {
|
|
window.location='index.php?page=compta_journal&action=ventiler&id=' + idLigne + '&montant=' + ventilation;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Paybox link in popup
|
|
(function ($) {
|
|
$(document).ready(function () {
|
|
$('.js-paybox-link').click(function () {
|
|
var url = $(this).attr('href');
|
|
window.open(url, "paybox", "width=1100, height=650");
|
|
return false;
|
|
});
|
|
});
|
|
})(jQuery);
|
|
|
|
// Update line column value using select
|
|
// Or update comment using simple link and dialog box
|
|
(function ($) {
|
|
$(document).ready(function () {
|
|
// Init dropzones
|
|
var initDropzone = function(container) {
|
|
$('.js-dropzone', container).each(function () {
|
|
var elmt = $(this);
|
|
elmt.dropzone({
|
|
url: elmt.attr('href'),
|
|
previewTemplate: $('.js-dz-preview-template').html(),
|
|
init: function() {
|
|
this.on("error", function(file, errorMessage, xhr) {
|
|
$('.js-upload-loader').hide();
|
|
alert(errorMessage);
|
|
});
|
|
this.on("success", function(file) {
|
|
$(elmt.parents('td').get(0)).find('.js-has-attachment').show();
|
|
$('.js-upload-loader').hide();
|
|
});
|
|
this.on("uploadprogress", function(file, progress, bytesSent) {
|
|
// Display the progress
|
|
if (!(progress >= 100)) {
|
|
$('.js-upload-loader').show();
|
|
} else {
|
|
$('.js-upload-loader').hide();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
elmt.show();
|
|
});
|
|
}
|
|
initDropzone(document);
|
|
// When we change the checked flag of a checkbox
|
|
$('.js-attachment-change').change(function (e) {
|
|
var checkbox = e.target;
|
|
var val = checkbox.checked ? checkbox.value : null;
|
|
|
|
// Process request to change the column
|
|
$.ajax({
|
|
url: $(checkbox).data('post-url'),
|
|
type: 'post',
|
|
data: {
|
|
val: val
|
|
},
|
|
dataType: 'json',
|
|
success: function (/* data, textStatus, jqXHR */) {
|
|
// Change visibility of the form
|
|
var formContainer = $(checkbox).parent().find('.js-attachment-form-container');
|
|
if (val) {
|
|
formContainer.find('.js-dropzone--lazy')
|
|
.addClass('js-dropzone')
|
|
.removeClass('js-dropzone--lazy')
|
|
;
|
|
initDropzone(formContainer);
|
|
formContainer.show();
|
|
} else {
|
|
formContainer.hide();
|
|
}
|
|
},
|
|
error: function (/* data, textStatus, jqXHR */) {
|
|
// Reverse checked status (put it back)
|
|
checkbox.checked = !checkbox.checked;
|
|
alert('Oops… something went wrong. Still logged in?');
|
|
}
|
|
});
|
|
});
|
|
|
|
// When we change the value of a select
|
|
$('.js-select-change').change(function (e) {
|
|
var elmt = $(e.target);
|
|
|
|
// Process request to change the column
|
|
$.ajax({
|
|
url: elmt.data('post-url'),
|
|
type: 'post',
|
|
data: {
|
|
val: elmt.val()
|
|
},
|
|
dataType: 'json',
|
|
success: function (data, textStatus, jqXHR) {
|
|
// remove all span in td
|
|
elmt.parent().find('span').remove();
|
|
|
|
// update td content
|
|
var span = $('<span></span>');
|
|
span.html(elmt.find('option:selected').html() + " ✅"); // success emoji: ✅
|
|
elmt.parent().append(span);
|
|
elmt.remove();
|
|
},
|
|
error: function (data, textStatus, jqXHR) {
|
|
// remove all span in td
|
|
elmt.parent().find('span').remove();
|
|
|
|
// update td content
|
|
var span = $('<span></span>');
|
|
span.html(" 🚫"); // error emoji: 🚫
|
|
elmt.parent().append(span);
|
|
elmt.val("");
|
|
}
|
|
});
|
|
});
|
|
|
|
// When we click on the comment link
|
|
$('a.js-edit-comment').click(function (e) {
|
|
e.stopPropagation(); // Stop here
|
|
|
|
if (e.target.nodeName === "I") {
|
|
var elmt = $(e.target).parent();
|
|
} else {
|
|
var elmt = $(e.target);
|
|
}
|
|
|
|
// Get comment
|
|
var comment = prompt("Commentaire :", elmt.data('comment'));
|
|
|
|
// We have a comment, so update it!
|
|
if (comment !== null) {
|
|
$.ajax({
|
|
url: elmt.data('post-url'),
|
|
type: 'post',
|
|
data: {
|
|
val: comment
|
|
},
|
|
dataType: 'json',
|
|
success: function () {
|
|
var icon = $('.icon', elmt);
|
|
icon.toggleClass('outline', comment.length === 0);
|
|
var tooltipLabel = 'Editer le commentaire';
|
|
if (comment.length > 0) {
|
|
tooltipLabel += ' ("' + comment + '")';
|
|
}
|
|
$(elmt).attr("data-tooltip", tooltipLabel);
|
|
$(elmt).data('comment', comment);
|
|
},
|
|
error: function () {
|
|
alert('Oops… something went wrong. Still logged in?');
|
|
}
|
|
});
|
|
}
|
|
|
|
return false;
|
|
});
|
|
});
|
|
})(jQuery);
|
|
</script>
|
|
{/literal}
|
|
|
|
{/if}
|