2
0

control.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $(document).ready(function () {
  2. showDate('showDate');
  3. feather.replace();
  4. $(".qrcodeReader").qrCodeReader();
  5. });
  6. $("#qrr-close").on("click", function () {
  7. $("#form-event").val("");
  8. });
  9. function checkEmagementControl() {
  10. if (checkconnection()) {
  11. $.ajax({
  12. url: $("#QRCodeRead").val(),
  13. dataType: "json",
  14. encode: true,
  15. }).done(function (data) {
  16. $('#ResultQRCode').remove();
  17. $("#confirmationModal").append(getConfirmModal(data));
  18. $('#ResultQRCode').modal("show");
  19. if (data["result"] == true) {
  20. $('#ResultQRCode').on('hidden.bs.modal', function () {
  21. getEvements();
  22. });
  23. }
  24. }).fail(function (xhr, status, error) {
  25. retour = Array;
  26. retour["result"] = false;
  27. retour["description"] = "Le QR-Code n'est pas valide";
  28. retour["salarie"] = null;
  29. retour["evenement"] = null;
  30. $('#ResultQRCode').remove();
  31. $("#confirmationModal").append(getConfirmModal(retour));
  32. $('#ResultQRCode').modal("show");
  33. });
  34. $("#QRCodeRead").removeAttr('value');
  35. } else {
  36. $("#divOffline").empty();
  37. $("#divOffline").append('<div class="alert alert-warning alertLogin" role="alert">Vous n\'êtes pas connecté à internet</div>');
  38. $("#divOffline").show();
  39. window.setTimeout(function () {
  40. $("#divOffline").fadeTo(600, 0).slideUp(600, function () {
  41. $(this).hide();
  42. $(this).css('opacity', '1');
  43. });
  44. }, 1000);
  45. }
  46. }
  47. $("#QRCodeRead").bind("DOMSubtreeModified", function () {
  48. if ($("#QRCodeRead").val() !== null && $("#QRCodeRead").val() !== '') {
  49. checkEmagementControl();
  50. }
  51. });