2
0

control.js 1.8 KB

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