diff --git a/Js/fonctions.js b/Js/fonctions.js index 05b0b100..cf8687d6 100755 --- a/Js/fonctions.js +++ b/Js/fonctions.js @@ -49491,46 +49491,64 @@ function dataTableServeur(){ } } -function rattacher_prestataires_reseau(){ - var nbcoche = $('#nbcoche').val(); - var nomReseau = $('#nomReseau').val(); - var msg_fr = "Aucun prestataire n'est sélectionné pour être rattaché au reséau de soins : "+nomReseau+"!"; - var msg_en = "No provider is selected to be attached to the care network: "+nomReseau+"'"; - - if(nbcoche == '0' || nbcoche =='' || nbcoche ==undefined){ - alert_ebene(msg_fr,msg_en); - return; - }else{ - msg_fr = "Confirmez-vous le rattachement des "+ nbcoche +" prestataires sélectionnés au reséau de soins :"+nomReseau+"?"; - msg_en = "Do you confirm the attachment of the "+ nbcoche +" selected providers to the care network"+nomReseau+"?"; - - confirm_ebene(msg_fr, msg_en) - .then((isConfirmed) => { - if (isConfirmed) { - // L'utilisateur a confirmé - donnees = ""; +function rattacher_prestataires_reseau() { + const racine = $("#racineWeb").val(); + const lang = $("#codeLangue").val(); + const nomReseau = $('#nomReseau').val(); + + // 1. Extraction propre du nombre (on ne garde que les chiffres) + // Utile si le champ contient "Lignes Cochées : 5" + let nbcocheRaw = $('#nbcoche').val(); + let nbcoche = parseInt(nbcocheRaw.replace(/[^0-9]/g, ''), 10) || 0; - $.ajax({ - url: $("#racineWeb").val()+"Ajaxlisteprestataireparlot/rattacher/", - type : 'post', - data: donnees, - error: function(errorData) { - //alert("Erreur : "+errorData); - }, - success: function(data) { - //alert("Success : "+data); - }, - complete: function() { - afficher_lite_prestataire_lot(); - } - }); - } else { - // L'utilisateur a annulé - console.log("Confirmation refusée"); - } - }); - } + // 2. Vérification si sélection vide + if (nbcoche === 0) { + const msg_fr = "Aucun prestataire n'est sélectionné pour être rattaché au réseau de soins : " + nomReseau + " !"; + const msg_en = "No provider is selected to be attached to the care network: " + nomReseau + " !"; + alert_ebene(msg_fr, msg_en); + return; + } + // 3. Confirmation de l'action + const conf_fr = "Confirmez-vous le rattachement des " + nbcoche + " prestataires sélectionnés au réseau de soins : " + nomReseau + " ?"; + const conf_en = "Do you confirm the attachment of the " + nbcoche + " selected providers to the care network: " + nomReseau + " ?"; + + confirm_ebene(conf_fr, conf_en).then((isConfirmed) => { + if (isConfirmed) { + + // 4. Loader de traitement Neutral Pro + const loader = ` +
+
+
+
+ ${(lang === 'en_US') ? 'Processing attachment...' : 'Rattachement en cours...'} +
+
+
`; + + $("#div_liste_prestataire").html(loader); + + $.ajax({ + url: racine + "Ajaxlisteprestataireparlot/rattacher/", + type: 'POST', + data: { codeReseau: $("#codeReseau").val() }, // On passe l'ID du réseau par sécurité + success: function(data) { + // Optionnel : Notification de succès + const s_msg = (lang === 'en_US') ? "Attachment completed successfully!" : "Rattachement effectué avec succès !"; + // toast_ebene(s_msg); // Si vous avez un système de toast + }, + error: function(xhr) { + console.error("Erreur Rattachement INTER-SANTE:", xhr.statusText); + alert_ebene("Erreur technique lors du rattachement.", "Technical error during attachment."); + }, + complete: function() { + // 5. Rafraîchissement de la liste (pour vider les déjà rattachés) + afficher_lite_prestataire_lot(); + } + }); + } + }); } function modifier_college_type(idTable)