text: $(document).ready(function(){const n=function(){var n={derniersBucquages:function(){$("#table-derniers-bucquages").DataTable({ajax:"/api/admin/derniersbucquages",bDestroy:!0,order:[]})},modifierCompte:function(){$("#card-modif-utilisateur").hide();var t=$("#table-modifier-compte").DataTable({ajax:"/api/admin/modifiercompte",bDestroy:!0,drawCallback:function(){const n=this.api();$("#total-utilisateurs").text(n.column(1,{filter:"applied"}).data().sum().toFixed(2))}});$("#table-modifier-compte").on("click","tbody tr",function(){const i=t.row(this).data()[0];n.recupererInfosCompte(i)})},bucquageManip:function(){var n=null,i=[],t=null,r=null;$("#manip-proms-panel").hide();$("#bucquage-patience").hide();$("#a-manip-proms-confirmer").on("click",function(){$("#manip-proms-panel").show();var i=$("#manip-proms").val();t=$("#table-manip-proms").DataTable({ajax:`/api/admin/chargerproms/${i}`,select:!0,order:[]});$("#table-manip-proms").on("click","tbody tr",function(){r=this;n=t.row(this).data()})});$(document).on("keydown",function(u){if($("#manip").hasClass("active")&&n!==null&&!$("input").is(":focus"))if(u.keyCode===13)n[1]=""+(parseInt(n[1])+1),t.row(r).data(n),i.push({UserName:n[0],Montant:Math.round(parseFloat($("#manip-prix").val().replace(",","."))*100)/100,Manip:$("#manip-nom").val()});else if(u.keyCode===8&&i.length!==0){var o=i.pop(),e=t.rows(function(n,t){return t[0]===o.UserName}),f=e.data()[0];f[1]=""+(parseInt(f[1])-1);t.row(e).data(f)}});$("#a-manip-confirmer").on("click",function(){$("#a-manip-confirmer").click(function(n){n.preventDefault()});$("#a-manip-confirmer").addClass("disabled");$("#bucquage-patience").show();const t=JSON.stringify({Historique:i}),n=new FormData;n.append("json",t);$.ajax({type:"POST",url:"/api/admin/bucquermanip",cache:!1,data:n,contentType:!1,processData:!1,success:function(){$("#modal-succes").modal("show")},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}})})},recupererInfosCompte:function(n){$.ajax({type:"GET",url:`/api/admin/recupererinfocompte/${n}`,success:function(t){$("#card-modif-utilisateur").show();$("#utilisateur-a-modifier").text(n);t=JSON.parse(t);$("#mode-archi").prop("checked",t.ModeArchi);$("#hors-foys").prop("checked",t.HorsFoys);$("#prenom").val(t.Prenom);$("#nom").val(t.Nom);$("#surnom").val(t.Surnom);$("#nums").val(t.Nums);$("#tbk").val(t.TBK);$("#proms").val(t.Proms)},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}});$("#a-bucquage-manuel").off("click").click(function(){const i={UserName:n,Montant:$("#bucquage-montant").val(),Commentaire:$("#bucquage-raison").val()},r=JSON.stringify(i),t=new FormData;t.append("json",r);$.ajax({type:"POST",url:"/api/admin/bucquagemanuel",cache:!1,data:t,contentType:!1,processData:!1,success:function(){$("#modal-succes").modal("show")},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}})});$("#a-confirmer").off("click").click(function(){const r={UserName:n,Prenom:$("#prenom").val(),Nom:$("#nom").val(),Surnom:$("#surnom").val(),Nums:$("#nums").val(),TBK:$("#tbk").val(),Proms:$("#proms").val(),ModeArchi:$("#mode-archi").is(":checked")||!1,HorsFoys:$("#hors-foys").is(":checked")||!1},t=JSON.stringify(r);console.log(t);const i=new FormData;i.append("json",t);$.ajax({type:"POST",url:"/api/admin/modifiercompte",cache:!1,data:i,contentType:!1,processData:!1,success:function(){$("#modal-succes").modal("show")},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}})});$("#a-supprimer-mdp").off("click").click(function(){const r={UserName:n},t=JSON.stringify(r);console.log(t);const i=new FormData;i.append("json",t);$.ajax({type:"POST",url:"/api/admin/supprimermdp",cache:!1,data:i,contentType:!1,processData:!1,success:function(){$("#modal-succes").modal("show")},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}})})},historique:function(){$("#timepicker-debut").datetimepicker({format:"DD-MM-YYYY HH:mm"});$("#timepicker-fin").datetimepicker({format:"DD-MM-YYYY HH:mm"});$("#a-historique").off("click").click(function(){const n=$("#timepicker-debut").datetimepicker("viewDate").toISOString(),t=$("#timepicker-fin").datetimepicker("viewDate").toISOString();$("#table-historique").DataTable({ajax:`/api/admin/historique/${n}/${t}`,bDestroy:!0,drawCallback:function(){const n=this.api();$("#total-historique").text(n.column(3,{filter:"applied"}).data().sum().toFixed(2))}})})},modeArchiPost:function(n,t){const r={proms:$("#liste-proms-mode-archi").val(),exclusive:n,remove:t},u=JSON.stringify(r),i=new FormData;i.append("json",u);$.ajax({type:"POST",url:"/api/admin/modearchi",cache:!1,data:i,contentType:!1,processData:!1,success:function(){$("#modal-succes").modal("show")},error:function(n){$("#modal-texte-erreur").text(`(${n.status}) ${n.responseText}`);$("#modal-erreur").modal("show")}})},modeArchi:function(){$("#a-mode-archi").click(function(){n.modeArchiPost(!1,!1)});$("#a-mode-archi-exclusif").click(function(){n.modeArchiPost(!0,!1)});$("#a-mode-archi-remove").click(function(){n.modeArchiPost(!1,!0)});$("#a-mode-archi-remove-exclusif").click(function(){n.modeArchiPost(!0,!0)})},init:()=>{$.ajaxSetup({cache:!1});n.derniersBucquages();n.modifierCompte();n.bucquageManip();n.historique();n.modeArchi();$("#modal-succes").on("hidden.bs.modal",function(){window.location.reload(!0)})}};return n}();n.init()});