PageSourceSearch

https://www.gites-de-france-22-35-56.fr/lib_2/js/foncs/cptClient.js?t=2024-05-14

js gites-de-france-22-35-56.fr collected 2026-10-07 13:38:36 UTC 146,594 bytes, 3,747 lines download raw bytes

1function afficheLoaderGlobal(){
2    jQuery('#div_loaderUnload').show();
3}
4function effaceLoaderGlobal(){
5    jQuery('#div_loaderUnload').hide();
6}
7
8function initCptClient(tabInstances, autoConnectLocalStorage){
9    (function($){
10        initFormsCptClient();
11        if ($('#form_modifCoordCli').length) {
12            initFormCoordonneesClient();
13        }
14        if ($('#form_chg_mdp').length) {
15            initFormModifPass();
16        }
17        init_champsConnexion();
18        // paiement paybox
19        init_paiement_paybox();
20        initCentralPayCompteClient();
21
22        if ($('.couplagePaybox').length > 0) {
23            $('.couplagePaybox #a_btChoixPaiementReserver').on('click', function () {
24                setFormPaiementCptCliPayboxPourCouplageAvecCPay();
25            });
26        }
27
28        // paiement ancv
29        if (typeof initSaisieANCV_CVCO !== 'undefined') {
30            initSaisieANCV_CVCO(false);
31        }
32        if (typeof initSaisieChequeKDO !== 'undefined') {
33            initSaisieChequeKDO(false);
34        }
35        initChoixPaiementAncv();
36        initModifsResa();
37        initActionCreerAvis();
38        initEffectsCptClient();
39        $('.lienReserverDeNouveau').click(function (e) {
40            e.stopPropagation();
41        });
42        initModalTaxeSejour();
43        initCautionCompteClient();
44
45        if ($('#div_btnPaiementCbLdCptCli').length>0) {
46            initBtnPaiementCbLdCptCli();
47        }
48        if ($('#div_rbstAvoirCptCli').length>0) {
49            initRemboursementAvoirCompteClient();
50        }
51        if ($('#divMessagerieCptCli').length > 0 || $('.btnEcrireAuGestionnaire').length > 0) {
52            initMessagerieCptCli();
53        }
54
55        if(typeof leaflet_initMapFiche === 'function'){ // 1217211
56            leaflet_initMapFiche();
57        }
58
59        if ($('#div_popinCreationCompteVacancesConnect').length > 0) {
60            initConnexionCptCliVacancesConnect();
61        }
62
63        // Autoconnexion avec les infos du sessionStorage (nouveau script de résa)
64        if ($('#div_identificationCptClientContent').length > 0 && Array.isArray(tabInstances)) {
65            let infosClient;
66            tabInstances.forEach((instance) => {
67                if (localStorage.getItem('client_'+instance)) {
68                    if (autoConnectLocalStorage === 'N') {
69                        localStorage.removeItem('client_'+instance);
70                    } else if (!infosClient) {
71                        infosClient = JSON.parse(localStorage.getItem('client_'+instance));
72                        if (instance === 'VC' && infosClient && !infosClient.estVacancesConnect) {
73                            infosClient = null;
74                        }
75                    }
76                }
77            });
78            if (autoConnectLocalStorage === 'O' && infosClient && infosClient.gestloc === 'O' && infosClient.mdp_md5) {
79                $('#input_email').val(infosClient.e_mail);
80                $('#input_motPasse').val(infosClient.mdp_md5);
81                $('#inpt_loginCptClient').click();
82            }
83        }
84        
85        // 2001623 Historisation connexion et consultation dossier
86        if ($('#div_cptClient_accueil').length > 0) {
87            historiseConnexion();
88        }
89        if ($('#div_cptClient_detailResa').length > 0) {
90            historiseConsultationDossier();
91        }
92
93        $(window).on('message', (event) => {
94            if (event.originalEvent.data === 'actualiserCompteClient') {
95                refreshPage();
96            }
97        });
98
99        if ($('divModifAssurance')) {
100            var montantAssurance = $('#divModifAssurance').data('montant-assurance');
101            var choixAssurance = getCookie("CHOIX_ASSURANCE");
102            if (montantAssurance == 0 && choixAssurance != 'O') {
103                var identResa = $('#divModifAssurance').data('ident-resa');
104                var identProd = $('#divModifAssurance').data('ident-prod');
105                var tokenAuth = $('#div_cptClient_detailResa').data('auth-token');
106                if (tokenAuth) {
107                    ouvrePopinIframeVueCptCli('assurance', identProd, identResa, '1150', tokenAuth);
108                }
109            }
110        }
111    })(jQuery);
112}
113
114function initCentralPayCompteClient() {
115    (function ($) {
116        console.log('PASSE initCentralPayCompteClient');
117        if (typeof initSaisieCB_centralPay !== 'undefined') {
118            initSaisieCB_centralPay();
119            
120            $("#a_btChoixPaiementANCV").click(function () {
121                setFormPaiementCptCliANCVCentralPay();
122            });
123            
124            initPopinConfirmeEANCV();
125            
126            $('input[name="choixPaiementCB"]').on('change', function(){
127                gereActionsChoixMontantLibre(this);                
128            });
129            
130            gereModifChoixMontantLibre();
131        } else if ($('.formCentralPay').length>0) {
132            $("#a_btChoixPaiementANCV").click(function () {
133                setFormPaiementCptCliANCVCentralPay();
134            });
135
136            initPopinConfirmeEANCV();
137        }
138        
139        if ($('.div_unPaiementPossible').length > 0) {
140            $('.div_unPaiementPossible > div.titre').bind('click', function () {
141                $('.div_unPaiementPossible').removeClass('open');
142                $(this).parent().addClass('open');
143            });
144        }
145
146        if ($('.div_uneDatePaiementPossible').length > 0) {
147            if ($('input[name="choixDatePaiement"]:checked').val() === 'DEBITAUTOCB') {
148                gereAffichagePaiementDebitAutoCb();
149            }
150            $('input[name="choixDatePaiement"]').bind('click', function () {
151                if ($(this).val() === 'DEBITAUTOCB') {
152                    gereAffichagePaiementDebitAutoCb();
153                    return;
154                }
155                gereAffichagePaiementMaintenant();
156            });
157        }
158    })(jQuery);
159}
160
161function initFormsCptClient() {
162    (function ($) {
163
164        $('#a_submit_recup_email').click(function (event) {
165            event.preventDefault();
166            var vars = $('#form_recup_email').serialize();
167            var url = urlCptClient;
168            $.ajax({
169                url: url,
170                data: vars,
171                beforeSend: function (xhr) {
172                    afficheLoaderGlobal_site();
173                },
174                success: function (data) {
175                    displayValidationSendPassword(data);
176                },
177                complete: function (jqXHR, textStatus) {
178                    effaceLoaderGlobal_site();
179                }
180            });
181        });
182    })(jQuery);
183}
184
185
186function displayValidationSendPassword(response){
187   (function($){
188   response = '<p>'+response+'</p>';
189   getNewDivToBody('divGraph_affDialog','dialogJquery');
190    $("#divGraph_affDialog").dialog({
191		/*width:width,
192		height:height,
193		resizable: true,*/
194        buttons:{"OK": function() {$(this).dialog("close");}},
195		modal: true
196	}).html(response);
197    })(jQuery);
198}
199
200// ne sert plus puisqu'on n'a plus de log qui se fait en ajax
201function log_client(reponse){
202    (function($){
203    if(reponse == '1'){
204        var loc = $('#a_login_cpt_client').attr('data-href');
205        $(location).attr('href',loc);
206    }
207    else{
208        $('#p_ident_error').show("0.3");
209             
210    }
211   })(jQuery);
212}
213
214function initFormCoordonneesClient(){
215    (function($){
216        $('#form_modifCoordCli').validationEngine({promptPosition : "topLeft",scroll: true,ajaxFormValidation:true,onAjaxFormComplete:refreshAccountWithXMLAndHtml,ajaxFormValidationURL:urlCptClient,dataTypeAjaxFormResponse:'xml'});
217        $('#a_comfirm_saisie_coord').click(function(event){
218            event.preventDefault();
219            $('#form_modifCoordCli').submit();
220        });
221    })(jQuery);
222}
223
224function initFormModifPass(){
225    (function($){
226        var tabAValider = [];
227        var mdp = new LiveValidation("newPass_input", {validMessage: $("#inpt_msgOk").val()});
228        mdp.add(Validate.Format, {pattern: /^[\w\W]{8,}$/, failureMessage: $("#inpt_msgSeulementChiffresLettres").val()});
229        mdp.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
230        tabAValider.push(mdp);
231        var mdpConfirm = new LiveValidation("newPassConfirm_input", {validMessage: $("#inpt_msgOk").val()});
232        mdpConfirm.add(Validate.Confirmation, {match: "newPass_input", failureMessage: $("#inpt_msgCorresMdp").val()});
233        tabAValider.push(mdpConfirm);
234        $('#a_valid_enreg_pass').click(function(event){
235            $('#div_msgErreursInfosClient,#div_msgValideInfosClient').html('').hide('fast');
236            event.preventDefault();
237            $.ajax({
238                   url:urlCptClient,
239                   data:'action=CHECKCLIENTPASS&oldPass='+$('#oldPass_input').val(),
240                   success:function(reponse){ 
241                        if(reponse == '1'){
242                            if(LiveValidation.massValidate(tabAValider)){ 
243                                $('#form_chg_mdp').submit();
244                            }
245                        }
246                        else{
247                            $('#div_msgErreursInfosClient').html('<p>'+reponse+'</p>').show('fast');
248                            
249                        }
250                   }
251               });
252            
253        });
254    })(jQuery);
255    
256}
257function init_champsConnexion(){
258	(function($){
259        if($("#div_ligneIdentCptClient_Email #input_email").length){
260			$("#div_ligneIdentCptClient_Email #input_email").live("focus",function(){
261				if($(this).val()==$(this).attr("data-defaut")) $(this).val("");
262			});
263			$("#div_ligneIdentCptClient_Email #input_email").live("blur",function(){
264				if($(this).val()=="") $(this).val($(this).attr("data-defaut"));
265			});
266
267			$("#div_ligneIdentCptClient_Password #input_motPasse").live("focus",function(){
268				if($(this).val()==$(this).attr("data-defaut")) $(this).val("");
269			});
270			$("#div_ligneIdentCptClient_Password #input_motPasse").live("blur",function(){
271				if($(this).val()=="") $(this).val($(this).attr("data-defaut"));
272			});
273		}
274    })(jQuery);
275}
276
277function init_paiement_paybox(){
278    (function($){
279        $('#a_boutonValiderCptClientPbx').unbind('click');
280        $('#a_boutonValiderCptClientPbx').bind('click', function(){
281            if (!$('#a_boutonValiderCptClientPbx').is('.disabled')) {
282                // TODO : masquer le bouton et le remettre après le retour de l'appel AJAX, pour ça il faut passer l'appel AJAX en synchrone
283                setFormPaiementCptCliPaybox();
284            }
285        });
286        initPaiementVersementCompteClient();
287    })(jQuery);
288}
289
290// peremt de rafraichir le détail de la réservation dans le compte client suivant la réponse d'ajax
291function refreshAccount(response){
292    (function($){
293        var message = response.getElementsByTagName('MESSAGE')[0].textContent;
294        if(message){
295            message = '<p>'+message+'</p>';
296        }
297        var valid = response.getElementsByTagName('VALIDATION')[0].textContent;
298   
299    getNewDivToBody('divGraph_affDialog','dialogJquery');
300    $("#divGraph_affDialog").dialog({
301        buttons:{"OK": function() {$(this).dialog("close");}},
302		modal: true,
303		close: function() {
304			if(valid== '1'){
305				refreshPage();
306			}
307		}
308	}).html(message);
309    })(jQuery);
310}
311
312function refreshAccountWithXMLAndHtml(form,response){
313    (function($){
314        var message = response.getElementsByTagName('MESSAGE')[0].textContent;
315        if(message){
316            message = '<p>'+message+'</p>';
317        }
318        var valid = response.getElementsByTagName('VALIDATION')[0].textContent;
319   
320    getNewDivToBody('divGraph_affDialog','dialogJquery');
321    $("#divGraph_affDialog").dialog({
322        buttons:{"OK": function() {$(this).dialog("close");}},
323		modal: true,
324		close: function() {
325			if(valid== '1'){
326				redirectAccueil();
327			}
328		}
329	}).html(message);
330    })(jQuery);
331}
332
333function refreshPage(){
334    window.location.reload();
335}
336function redirectAccueil(){document.location.href='?';}
337
338function initEffectsCptClient(){
339    (function($){
340        $('.div_to_bounce').each(function(){
341           if($(this).attr('show') == '1'){
342               $(this).show( 'bounce', {distance:40}, 500 );
343           } 
344        });
345    })(jQuery);
346}
347
348
349
350function enregistrePreferences() {
351    (function ($) {
352        var tabPref = new Array();
353
354        $('#div_modifFavorisCliContent input').each(function () {
355            if ($(this).val() != '') {
356                var obj = {
357                    'name': $(this).attr('name'),
358                    'valeur': $(this).val()
359                }
360                tabPref.push(obj);
361            }
362            if ($(this).prop('checked')) {
363                var obj = {
364                    'name': $(this).attr('name'),
365                    'valeur': 'O'
366                }
367                tabPref.push(obj);
368            }
369        });
370        $.ajax({
371            url: urlCptClient,
372            data: { action: 'enregistrePreferences', tabPref: tabPref },
373            beforeSend: function () {
374                afficheLoaderGlobal_site();
375            },
376            complete: function () {
377                effaceLoaderGlobal();
378            },
379            success: function (result) {
380                effaceLoaderGlobal();
381                var tabRep = $.parseJSON(result);
382                if (tabRep.code == 'OK') {
383                    refreshPage();
384                }
385                else {
386                    alertAJquery(tabRep.msg);
387                }
388            }
389        });
390    })(jQuery);
391}
392
393function initModifsResa(){
394    (function($){
395        $('input[name="inputTypeClientAssurance"]').each(function(){
396            if($(this).is(':checked')){
397                $('.divFormuleAssurance').hide();
398                $('.divFormuleAssuranceType'+$(this).val()).show();
399            }
400        });
401        $('#a_valid_modif_assurance').click(function(event){
402            event.preventDefault();
403            var vars = $('#frmChgtAssurance').serialize();
404               var url = urlCptClient;
405               $.ajax({
406                   url:url,
407                   data:vars,
408                   success:function(data){
409                       var tabRep = $.parseJSON(data);
410                       if(tabRep.CODE == 'OK'){
411                           refreshPage();
412                       }
413                       else{
414                           alertAJquery(tabRep.MESSAGE);
415                       }
416                   },
417                   error:function(){
418                   }
419                        
420               });
421                 
422        });
423        $('#a_modif_nb_pers').click(function(event){
424            event.preventDefault();
425            var vars = $('#frmChgtNbPers').serialize();
426            var url = urlCptClient;
427            $.ajax({
428                   url:url,
429                   data:vars,
430                   success:function(data){
431                       refreshAccount(data);
432                   }
433               });
434            
435        });
436        $('.inpt_choixFormuleAssurance').change(function(){
437            affMsgAttenteParDessusInDiv('frmChgtAssurance');
438            $.ajax({
439                type:'POST',
440                url : urlCptClient,
441                data : $('#frmChgtAssurance').serialize(),
442                success:function(data){
443                    //rafraichir la resa
444                    refreshPage();
445                }
446            });
447        });
448        $('input[name="inputTypeClientAssurance"]').click(function(){
449            $('.divFormuleAssurance').hide();
450            $('.divFormuleAssuranceType'+$(this).val()).show();
451        });
452        $('#lienSupprimeAutoriseDebitAuto').click(function () {
453            var data = 'action=supprimeDebitAuto';
454            data += '&instance=' + $(this).data('instance');
455            data += '&exe=' + $(this).data('exe');
456            data += '&numero_resa=' + $(this).data('numero-resa');
457            data += '&pre_resa=' + $(this).data('pre-resa');
458            
459            $.ajax({
460                type:'POST',
461                url : urlCptClient,
462                data:data,
463                beforeSend: function (xhr) {
464                    afficheLoaderGlobal_site();
465                },
466                complete: function (jqXHR, textStatus) {
467                    
468                },
469                success: function (data) {
470                    //rafraichir la resa
471                    if(data.code === 'KO') {
472                        //TODO : afficher un message d'erreur (créer une div pour ça)
473                        effaceLoaderGlobal_site();
474                        return false;
475                    }
476                    refreshPage();
477                }
478            });
479        });
480        
481    })(jQuery)
482}
483
484function initActionCreerAvis() {
485    (function($){
486        $('.btCreerAvisDetailResa').click(function(){
487            var data = 'action=creerAvis';
488            data += '&instance='+$(this).data('instance');
489            data += '&exe='+$(this).data('exe');
490            data += '&numero_resa='+$(this).data('numero-resa');
491            data += '&pre_resa='+$(this).data('pre-resa');
492            $.ajax({
493                type:'POST',
494                url : urlCptClient,
495                data : data,
496                success:function(result){
497                    var tabRetour = JSON.parse(result);
498                    if(tabRetour.code === 'KO') {
499                        //TODO : afficher un message d'erreur (créer une div pour ça)
500                        return false;
501                    }
502                    window.open(tabRetour.url);
503                }
504            });
505        });
506    })(jQuery);
507}
508
509function initCompteClientV5surV4() {
510    (function($) {
511        if ($('#compteClientV5surV4').length > 0) {
512//            $('#page_content').remove();
513//            //on appelle les scripts et css qui vont bien, 
514//            // on replace le compte client dans la page.
515//            $('#compteClientV5surV4').appendTo("#page");
516            $('head').append('<link rel="stylesheet" media="screen" href="../config_v3/css_defaut/v5/commun/defaut/compte_client.css" type="text/css" />');
517            $('head').append('<link rel="stylesheet" media="screen" href="../config_v3/css_defaut/v5/admin/jquery/jquery-ui.min.css" type="text/css" />');
518            $('head').append('<link rel="stylesheet" media="screen" href="../config_v3/css_defaut/v5/admin/jquery/validationEngine.jquery.css" type="text/css" />');
519            $('#compteClientV5surV4').slideDown('fast');
520            initCptClient();
521            var tab = $('img,input', $('#compteClientV5surV4'));
522            $('img,input', $('#compteClientV5surV4')).each(function() {
523                var src = $(this).attr('src') || '';
524                if (src.match(/^\/imgs_defaut/)) {
525                    $(this).attr('src', '/config_v3/' + $(this).attr('src'));
526                }
527            });
528            if ($('.div_itea_GMAP', $('#compteClientV5surV4')).length > 0) {
529                loadScriptGoogleMap();
530                // je mets un retardateur sinon on exécute la fonction avant même d'avoir le script de google.
531                window.setTimeout(function(){chargeGMap();}, 2000);
532            }
533        }
534    })(jQuery)
535}
536
537
538/***** Fonctions pour compte client national *****/
539
540function initCptClientGDF() {
541    cptGDF_initActionsListeResas();
542    cptGDF_initActionsDetailResas();
543    cptGDF_initActionsDetailFavoris();
544    cptGDF_initActionsDetailFicheVisitee();
545    cptGDF_initActionsProfil();
546    cptGDF_initActionsPopInPaiement();
547    cptGDF_initActionsBandeau();
548    cptGDF_initAfficheDetailViaFrance();
549}
550
551
552function cptGDF_initActionsPopInPaiement() {
553    (function ($) {
554        $('body').undelegate('.payer_compte_fngf', 'click');
555        $('body').delegate('.payer_compte_fngf', 'click', function () {
556            var data = 'action=getHTML_formCptCliPaiement';
557            data += '&instance='+$(this).data('instance');
558            data += '&numresa='+$(this).data('numresa');
559            data += '&exercice='+$(this).data('exercice');
560            data += '&id_famille='+$(this).data('id_famille');
561            $.ajax({
562                type: 'POST',
563                url: urlCptClient,
564                data: data,
565                success: function (result) {
566                    var tabRetour = JSON.parse(result);
567                    if(tabRetour.code === 'KO') {
568                        return false;
569                    }
570                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
571                        return false;
572                    }
573                    $.fancybox(
574                    $('#'+$(this).data('idformpaiement')), {
575                        maxWidth: 800,
576                        autoHeight: true,
577                        autoWidth: true,
578                        autoResize: true,
579                        autoSize: true,
580                        padding:0,
581                        wrapCSS:'popin_compteGDF popin_paiementCompteGDF',
582                        content : tabRetour.html
583                    });
584                    init_paiement_paybox();
585                }
586            });
587        });
588    })(jQuery);
589}
590
591
592function cptGDF_initActionsListeResas(){
593     (function($) {               
594        $('#div_plusDeResaEnCours a').click(function(){
595           $('div.compteGDF_uneResa_enCours').show(); 
596        });
597        $('#div_plusDeResaPassees a').click(function(){
598           $('div.compteGDF_uneResa_passees').show(); 
599        });
600        $('#div_plusDeResaAnnulees a').click(function(){
601           $('div.compteGDF_uneResa_annulees').show(); 
602        });
603    })(jQuery);
604}
605
606function cptGDF_initActionsDetailResas(){
607    var tabAValider;
608    
609    (function($) {
610        
611        if($(".afficheDetail a").length>0){
612            $(".afficheDetail a").unbind('click');
613            $(".afficheDetail a").click(function(){
614               var numResa = $(this).attr("data-numresa"); 
615               cptGDF_afficheMasqueDetailResa(numResa);   
616            });
617        }
618        
619        if($(".cptGDF_afficheAvis").length>0){
620            $(".cptGDF_afficheAvis").unbind('click');
621            $(".cptGDF_afficheAvis").click(function(){
622               var numResa = $(this).attr("data-numresa"); 
623               cptGDF_afficheMasqueAvisResa(numResa);   
624            });
625        }
626        
627        if($(".compteGDF_detailMontant").length>0){
628            $(".compteGDF_detailMontant").unbind('click');
629            $(".compteGDF_detailMontant").click(function(e){
630               var numResa = $(this).attr("data-numresa"); 
631               cptGDF_afficheMasqueDetailMontants(numResa);  
632               e.stopPropagation();
633            });
634        }
635        
636        if($('.compteGDF_detailMontantsSejour-overlay').length>0){
637            $(".compteGDF_detailMontantsSejour-overlay").unbind('click');
638            $('.compteGDF_detailMontantsSejour-overlay').click(function(){
639               var numResa = $(this).data("numresa");
640               $(this).hide();
641               $('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]').hide();
642            });
643        }
644        
645        if($(".compteGDF_titreDoc a").length>0){
646            $(".compteGDF_titreDoc a").unbind('click');
647            $(".compteGDF_titreDoc a").click(function(){
648                $(this).toggleClass("opened");
649               var numResa = $(this).attr("data-numresa"); 
650               cptGDF_afficheMasqueDetailDocs(numResa);               
651            });
652        }
653        
654        if($(".compteGDF_afficheCarte").length>0){
655            $(".compteGDF_afficheCarte").unbind('click');
656            $(".compteGDF_afficheCarte").click(function(){
657               var numResa = $(this).attr("data-numresa"); 
658               cptGDF_afficheMasqueCarteResa(numResa,false);     
659            });
660        }
661        if($(".compteGDF_afficheCarteinPopin").length>0){
662            $(".compteGDF_afficheCarteinPopin").unbind('click');
663            $(".compteGDF_afficheCarteinPopin").click(function(){
664               var numResa = $(this).attr("data-numresa"); 
665               cptGDF_afficheMasqueCarteResa(numResa,true);     
666            });
667        }   
668        
669        if($(".contentCarteFermer a").length>0){
670            $(".contentCarteFermer a").unbind('click');
671            $(".contentCarteFermer a").click(function(){
672               var numResa = $(this).attr("data-numresa"); 
673               cptGDF_afficheMasqueCarteResa(numResa);               
674            });
675        }
676        
677        if($(".contentDetailContactEventEtPartage .sp_partageResauxSociaux").length>0){
678            $(".contentDetailContactEventEtPartage .sp_partageResauxSociaux").unbind('click');
679            $(".contentDetailContactEventEtPartage .sp_partageResauxSociaux").click(function(){
680                if($(this).next().is(":hidden")){
681                    $(this).toggleClass("opened");
682                    $(this).next().show("blind");                    
683                }
684                else{
685                    $(this).next().hide("blind")
686                    $(this).toggleClass("opened");
687                }
688            });
689        }
690        
691        $('body').undelegate('.btEnvoiMessageCptGDF', 'click');
692        $('body').delegate('.btEnvoiMessageCptGDF', 'click', function() {
693            var data = 'action=getHTML_popInMailProp';
694            data += '&ident_resa='+$(this).data('ident-resa');
695            data += '&type_dest='+$(this).data('type-dest');
696            data += '&dest='+$(this).data('dest');
697            $.ajax({
698                type: 'POST',
699                url: urlCptClient,
700                data: data,
701                success: function (result) {
702                    var tabRetour = JSON.parse(result);
703                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
704                        return false;
705                    }
706                    widget_affichePopinMailPropCptGDF(tabRetour.html);
707                    //on place ce livevalidation après l'affichage du html de la popin sinon ça ne marche pas
708                    tabAValider = [];
709                    var txtMailCptGDF = new LiveValidation('textarea_formMessageCptGDF', {validMessage: ' ', onlyOnSubmit: true});
710                    txtMailCptGDF.add(Validate.Presence, {failureMessage: $('#inpt_msgChampObligatoire_messageCptGDF').val()});
711                    tabAValider.push(txtMailCptGDF);
712                }
713            });
714        });
715
716        $('body').undelegate('#btValidEnvoiMessageCptGDF', 'click');
717        $('body').delegate('#btValidEnvoiMessageCptGDF', 'click', function(e) {
718            e.preventDefault();
719            if (LiveValidation.massValidate(tabAValider)) {
720                var $divMsgInfo = $('#div_msgEnvoiMessagePropCptGDF');
721                $.ajax({
722                    type: 'POST',
723                    url: urlCptClient,
724                    data: 'action=envoiMailProp&'+$('#form_envoiMessageCptGDF').seri
724alize(),
725                    beforeSend: function(){
726                        setMsgInfoCptGDF($divMsgInfo);
727                    },
728                    success: function (result) {
729                        var tabRetour = JSON.parse(result);
730                        if(!traiteRepKoCnxCptGDF(tabRetour)) {
731                            return false;
732                        }
733                        if(tabRetour.code === 'KO') {
734                            $divMsgInfo.addClass("ko").removeClass("ok");
735                            setMsgInfoCptGDF($divMsgInfo, tabRetour.msg);
736                            return false;
737                        }
738                        $('#form_envoiMessageCptGDF').hide();
739                        $divMsgInfo.addClass("ok").removeClass("ko");
740                        $('.divPopInMailPropCptGDFTitre').hide();
741                        setMsgInfoCptGDF($divMsgInfo, tabRetour.msg);
742                    }
743                });
744           }
745        });
746       
747    })(jQuery);
748}
749
750function cptGDF_afficheMasqueDetailResa(numResa){
751    (function($) {        
752        if($('.contentDetail[data-numresa="'+numResa+'"]').is(":hidden")){
753            $('.contentDetail[data-numresa="'+numResa+'"]').show('blind');
754            $('.afficheDetail a[data-numresa="'+numResa+'"]').text($('.afficheDetail a[data-numresa="'+numResa+'"]').attr("data-lbl-masque"));
755
756            //chargement des activites et evenements
757            var htmlActivite = $('.contentDetail[data-numresa="'+numResa+'"]').find('.contentDetailActivites').html();
758            if(htmlActivite.length==0){
759                var tab = numResa.split('_');
760
761                var data = 'action=getHTML_activiteProdCptCli';
762                data += '&instance='+tab[0];
763                data += '&exercice='+tab[1];
764                data += '&numresa='+tab[2];
765                data += '&typeresa='+tab[3];
766
767                $.ajax({
768                    type: 'POST',
769                    url: urlCptClient,
770                    data: data,
771                    success: function (result) {
772                        var tabRetour = JSON.parse(result);
773                        if(tabRetour.code === 'KO') {
774                            return false;
775                        }
776                        if(!traiteRepKoCnxCptGDF(tabRetour)) {
777                            return false;
778                        }
779                        $('.contentDetail[data-numresa="'+numResa+'"]').find('.contentDetailActivites').html(tabRetour.html);
780                        $('.contentDetailActivites .titreDetail').click(function(){
781                           if($(this).next().is(":hidden")) {
782                               $(this).next().show("blind");
783                           }
784                           else{
785                               $(this).next().hide("blind");
786                           }
787                        });
788                    }
789                });
790            }
791        }
792        else{
793            $('.contentDetail[data-numresa="'+numResa+'"]').hide('blind');
794            $('.afficheDetail a[data-numresa="'+numResa+'"]').text($('.afficheDetail a[data-numresa="'+numResa+'"]').attr("data-lbl-affiche"));
795            
796            var offset = $('.compteGDF_uneResa[data-numresa="'+numResa+'"]').offset().top;
797            $('html, body').animate({scrollTop: offset-80}, 'slow'); 
798        }
799        $('.afficheDetail a[data-numresa="'+numResa+'"]').toggleClass("opened");
800    })(jQuery);
801}
802
803function cptGDF_afficheMasqueAvisResa(numResa){
804    (function($) {        
805        if($('.contentAvis[data-numresa="'+numResa+'"]').is(":hidden")){
806            $('.contentAvis[data-numresa="'+numResa+'"]').show("blind",function(){
807                rendVisibleEcran('.compteGDF_uneResa[data-numresa="'+numResa+'"]',100);
808            });
809            
810        }
811        else{
812            $('.contentAvis[data-numresa="'+numResa+'"]').hide("blind");
813        }
814        $('.contentAvis a[data-numresa="'+numResa+'"]').toggleClass("opened");
815    })(jQuery);
816}
817
818function cptGDF_afficheMasqueCarteResa(numResa,popin){
819    (function($) {    
820        if(popin){         
821            var idDivCarte = $('.contentCarte[data-numresa="'+numResa+'"]').children(".div_itea_GMAP").attr("id"); 
822            var lat = $('.compteGDF_afficheCarteinPopin[data-numresa="'+numResa+'"]').data("latitude");
823            var long = $('.compteGDF_afficheCarteinPopin[data-numresa="'+numResa+'"]').data("longitude");
824            var coords=lat+','+long;
825            $.fancybox(
826                {
827                href:'https://maps.google.com/maps?hl=fr&q='+coords+'&ie=UTF8&t=m&z=10&iwloc=B&output=embed&z=12',
828                type:'iframe',
829                width: '90%',
830                height:'90%',
831                autoHeight:true,
832                autoWidth:true,
833                autoResize:true,
834                autoSize: true,
835                padding:0,
836                wrapCSS:'popin_compteGDF popin_carte_cptGDF'
837            });
838        }
839        else{
840            if($('.contentCarte[data-numresa="'+numResa+'"]').is(":hidden")){
841                $('.contentCarte[data-numresa="'+numResa+'"]').show();            
842                var idDivCarte = $('.contentCarte[data-numresa="'+numResa+'"]').children(".div_itea_GMAP").attr("id"); 
843                iteaGMAP_initForListe(idDivCarte);            
844            }
845            else{
846                $('.contentCarte[data-numresa="'+numResa+'"]').hide();
847            }  
848        }
849    })(jQuery);
850}
851
852function cptGDF_initAfficheDetailViaFrance(){
853    (function($){
854    $('.contentDetailActivites .a_viaFranceDetail').live('click', function(){
855      var id = $(this).attr('data-id');
856      var type = $(this).attr('data-type');
857      var div = $(this).parents('.div_lagendaContent');
858      // TODO : récupérer le détail
859
860      $.ajax({
861        type: 'POST',
862        url: '/lib_2/ajax/infosDist.php',
863        data: {
864          info: 'getHTMLDetail_viaFrance',
865          id: id,
866          type: type
867        },
868        success: function(result){
869          if (result.length>0) {
870            div.find('.div_viaFrance_detailElement').html('<div class="div_viaFrance_detailElementContent">'+result+'</div>');
871            $.fancybox(
872                div.find('.div_viaFrance_detailElement'), {
873                maxWidth: 650,
874                autoHeight:true,
875                autoWidth:true,
876                autoResize:true,
877                autoSize: true,
878                padding:0,
879                wrapCSS:'popin_compteGDF popin_detailEventViaFrance_cptGDF'
880            });
881          } else {
882
883          }
884        }
885      });
886    });
887  })(jQuery);
888}
889
890function cptGDF_afficheMasqueDetailMontants(numResa){
891    (function($) {   
892        if($(document).width()<768){
893            $.fancybox(
894                $('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]'), {
895                maxWidth: 650,
896                autoHeight:true,
897                autoWidth:true,
898                autoResize:true,
899                autoSize: true,
900                padding:0,
901                wrapCSS:'popin_compteGDF popin_detailMontants_cptGDF'
902            });
903        }
904        else{
905            if($('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]').is(":hidden")){
906                if($(document).width()>=768){
907                    $('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]').show("blind");                    
908                }                
909                else{
910                    $('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]').show();
911                }
912                $('.compteGDF_detailMontantsSejour-overlay[data-numresa="'+numResa+'"]').show();
913            }
914            else{
915                $('.compteGDF_detailMontantsSejour[data-numresa="'+numResa+'"]').hide("blind");
916            }
917        }
918    })(jQuery);
919}
920
921function cptGDF_afficheMasqueDetailDocs(numResa){
922    (function($) {        
923        if($('.compteGDF_detailDoc[data-numresa="'+numResa+'"]').is(":hidden")){
924            $('.compteGDF_detailDoc[data-numresa="'+numResa+'"]').show("blind");
925        }
926        else{
927            $('.compteGDF_detailDoc[data-numresa="'+numResa+'"]').hide("blind");
928        }
929    })(jQuery);
930}
931
932function cptGDF_initActionsDetailFavoris(){
933    (function($) {
934        
935        //affichage/masquage du html permettant la modification du libellé
936        $('body').undelegate('.bt_cptGDF_editFavori', 'click');
937        $('body').delegate('.bt_cptGDF_editFavori', 'click', function() {
938            var favoriId = $(this).attr('data-id');
939            afficheMasqueTitreFavori(favoriId); // ligne à placer avant l'appel à focus() car focus() ne marche que sur les champs visibles
940            $('#inpt_cptGDF_modifFavori_'+favoriId).val($('#div_cptGDF_modifFavori_'+favoriId).text()).focus();
941        });
942        
943        //enregistrement du libellé modifié d'un favori
944        $('body').undelegate('.bt_cptGDF_validmodifFavori', 'click');
945        $('body').delegate('.bt_cptGDF_validmodifFavori', 'click', function(e) {
946            e.preventDefault();
947            enregistreModifFavori($(this).attr('data-id'));
948        });
949        
950        //affichage de la pop-in permettant de supprimer un favori
951        $('body').undelegate('.bt_cptGDF_delFavori', 'click');
952        $('body').delegate('.bt_cptGDF_delFavori', 'click', function() {
953            var favoriId = $(this).attr('data-id');
954            var libelleFavori = $('#div_cptGDF_modifFavori_'+favoriId).text();
955            $('#popIn_delFavori_cptGDF_btConfirm').attr('data-id', favoriId);
956            $('#popIn_delFavori_cptGDF_libelle').html(libelleFavori);
957            widget_affichePopin_delFavori_cptGDF();
958        });
959        
960        //suppression d'un favori
961        $('body').undelegate('#popIn_delFavori_cptGDF_btConfirm', 'click');
962        $('body').delegate('#popIn_delFavori_cptGDF_btConfirm', 'click', function() {
963            delFavori($(this).attr('data-id'));
964        });
965        
966        //suppression de l'hébergement d'un favori
967        $('body').undelegate('.btDelFavoriHeber', 'click');
968        $('body').delegate('.btDelFavoriHeber', 'click', function() {
969            delFavoriHeber($(this).attr('data-id'), $(this).attr('data-favori-id'), $(this).attr('data-ref'));
970        });
971                
972        //affichage/masquage de la liste des heber d'un favori
973        $('body').undelegate('.btAfficheLstFavoriHeber, .div_cptGDF_titreFavori', 'click');
974        $('body').delegate('.btAfficheLstFavoriHeber, .div_cptGDF_titreFavori', 'click', function() {
975            $(this).afficheLstFavoriHeber();
976        });
977        
978        $('body').undelegate('.div_cptGDF_principalFavori_partage_lbl', 'click');
979        $('body').delegate('.div_cptGDF_principalFavori_partage_lbl', 'click', function() {
980            var favoriId = $(this).attr('data-id');
981            if($('.div_cptGDF_principalFavori_partage_listeReseaux[data-id="'+favoriId+'"]').hasClass("closed")){
982                $('.div_cptGDF_principalFavori_partage_listeReseaux[data-id="'+favoriId+'"]').removeClass("closed").addClass("opened");
983            }
984            else{
985                $('.div_cptGDF_principalFavori_partage_listeReseaux[data-id="'+favoriId+'"]').removeClass("opened").addClass("closed");
986            }
987        });
988        $('body').undelegate('.div_partageResauxSociaux_lbl', 'click');
989        $('body').delegate('.div_partageResauxSociaux_lbl', 'click', function() {
990            var partageId = $(this).attr('data-id');
991            if($('.div_partageResauxSociaux_listeReseaux[data-id="'+partageId+'"]').hasClass("closed")){
992                $('.div_partageResauxSociaux_listeReseaux[data-id="'+partageId+'"]').removeClass("closed").addClass("opened");
993            }
994            else{
995                $('.div_partageResauxSociaux_listeReseaux[data-id="'+partageId+'"]').removeClass("opened").addClass("closed");
996            }
997        });
998        
999        //envoi à un ami
1000        $('body').undelegate('.bt_cptGDF_ficheEnvoiAmi', 'click');
1001        $('body').delegate('.bt_cptGDF_ficheEnvoiAmi', 'click', function() {
1002            var favoriId = $(this).attr('data-id');
1003            var divfavoriHeber = $('#div_cptGDF_favoriHeber_'+favoriId);
1004            var divMsgInfo = $('#lstFavoriHeber_msgInfo_'+favoriId);
1005            var data = 'action=GET_TABINFO_ENVOIMAILAMI_CPTGDF';
1006            data += '&id='+favoriId;
1007            $.ajax({
1008                type: 'POST',
1009                url: urlCptClient,
1010                data: data,
1011                beforeSend: function(){
1012                    divfavoriHeber.hide();
1013                    divMsgInfo.text('');
1014                },
1015                success: function (result) {
1016                    var tabRetour = JSON.parse(result);
1017                    if(tabRetour.code === 'KO') {
1018                        if(tabRetour.msg) {
1019                            divfavoriHeber.show();
1020                            divMsgInfo.text(tabRetour.msg).show();
1021                        }
1022                        return false;
1023                    }
1024                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1025                        return false;
1026                    }
1027                    sendThisToFriend(tabRetour.cmd, tabRetour.w , tabRetour.h, tabRetour.titreDiv, tabRetour.objet, tabRetour.url, tabRetour.lien, tabRetour.message, tabRetour.tabident);
1028                }
1029            });
1030        });
1031        
1032        // partage sur site externe (FB, Google, Twitter...)
1033        // on récupère cette url par req ajax car ça prendrait trop de temps de la récupérer au chargement de la page pour chaque liste de favoris 
1034        $('body').undelegate('.bt_cptGDF_partageSiteExterne', 'click');
1035        $('body').delegate('.bt_cptGDF_partageSiteExterne', 'click', function() {
1036            var favoriId = $(this).attr('data-id');
1037            var url = $(this).attr('data-url');
1038            var divfavoriHeber = $('#div_cptGDF_favoriHeber_'+favoriId);
1039            var divMsgInfo = $('#lstFavoriHeber_msgInfo_'+favoriId);
1040            var data = 'action=GET_URL_PARTAGE_CPTGDF';
1041            data += '&id='+favoriId;
1042            $.ajax({
1043                type: 'POST',
1044                url: urlCptClient,
1045                data: data,
1046                beforeSend: function(){
1047                    divfavoriHeber.hide();
1048                    divMsgInfo.text('');
1049                },
1050                success: function (result) {
1051                    var tabRetour = JSON.parse(result);
1052                    if(tabRetour.code === 'KO') {
1053                        if(tabRetour.msg) {
1054                            divfavoriHeber.show();
1055                            divMsgInfo.text(tabRetour.msg).show();
1056                        }
1057                        return false;
1058                    }
1059                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1060                        return false;
1061                    }
1062                    window.open(url+tabRetour.url);
1063                }
1064            });
1065        });
1066        
1067    })(jQuery);
1068}
1069
1070//permet d'afficher l'input du libellé du favori et de cacher en même temps ce libellé qui est en lecture seule dans une autre div, ou de faire inverse
1071function afficheMasqueTitreFavori(favoriId) {
1072    (function($) {
1073        $('.div_cptGDF_titreFavori_'+favoriId).toggle();
1074    })(jQuery);
1075}
1076
1077function setMsgInfoFavoriExistantCptGDF(favoriId, msg) {
1078    (function($) {
1079        setMsgInfoCptGDF($('#cptGDF_detailFavori_msgInfo_'+favoriId), msg);
1080    })(jQuery);
1081}
1082
1083function enregistreModifFavori(favoriId) {
1084    (function($) {
1085        var newLibelle = $('#inpt_cptGDF_modifFavori_'+favoriId).val();
1086        var newLibelleTraite = traiteTexteAvantReqAjax($('#inpt_cptGDF_modifFavori_'+favoriId).val());
1087        if(newLibelleTraite.trim().length === 0) {
1088            setMsgInfoFavoriExistantCptGDF(favoriId, $('#div_cptGdf_lbl_error_favori_lib_vide').text());
1089            return false;
1090        }
1091        setMsgInfoFavoriExistantCptGDF(favoriId);
1092        var data = 'action=UPDATE_FAVORI';
1093        data += '&id='+favoriId;
1094        data += '&libelle='+newLibelleTraite;
1095        $.ajax({
1096            type: 'POST',
1097            url: urlCptClient,
1098            data: data,
1099            success: function (result) {
1100                var tabRetour = JSON.parse(result);
1101                if(tabRetour.code === 'KO') {
1102                    setMsgInfoFavoriExistantCptGDF(favoriId, tabRetour.msg);
1103                    return false;
1104                }
1105                if(!traiteRepKoCnxCptGDF(tabRetour)) {
1106                    return false;
1107                }
1108                setMsgInfoFavoriExistantCptGDF(favoriId);
1109                $('#div_cptGDF_titreActuelFavori_'+favoriId).html(newLibelle);
1110                afficheMasqueTitreFavori(favoriId);
1111                $('#div_cptGDF_modifFavori_'+favoriId).html(newLibelle);
1112            }
1113        });
1114    })(jQuery);
1115}
1116
1117function delFavori(favoriId) {
1118    (function($) {
1119        var data = 'action=DEL_FAVORI';
1120        data += '&id='+favoriId;
1121        $.ajax({
1122            type: 'POST',
1123            url: urlCptClient,
1124            data: data,
1125            success: function (result) {
1126                var tabRetour = JSON.parse(result);
1127                $.fancybox.close();
1128                if(tabRetour.code === 'KO') {
1129                    setMsgInfoFavoriExistantCptGDF(favoriId, tabRetour.msg);
1130                    return false;
1131                }
1132                if(!traiteRepKoCnxCptGDF(tabRetour)) {
1133                    return false;
1134                }
1135                setMsgInfoFavoriExistantCptGDF(favoriId);
1136                $('#li_cptGDF_detailFavori_'+favoriId).remove();
1137                if($('.li_cptGDF_detailFavori').length === 0) {
1138                    $('#compteGDF_pasDeFavoris').show();
1139                }
1140            }
1141        });
1142    })(jQuery);
1143}
1144
1145function delFavoriHeber(id, favoriId, ref) {
1146    (function($) {
1147        var divMsgInfo = $('#favoriHeber_msgInfo_'+id);
1148        divMsgInfo.text('');
1149        var data = 'action=DEL_FAVORI_HEBER';
1150        data += '&favori_id='+favoriId;
1151        data += '&ref='+ref;
1152        $.ajax({
1153            type: 'POST',
1154            url: urlCptClient,
1155            data: data,
1156            success: function (result) {
1157                var tabRetour = JSON.parse(result);
1158                if(tabRetour.code === 'KO') {
1159                    if(tabRetour.msg) {
1160                        divMsgInfo.text(tabRetour.msg).show();
1161                    }
1162                    return false;
1163                }
1164                if(!traiteRepKoCnxCptGDF(tabRetour)) {
1165                    return false;
1166                }
1167                var delay = 600;
1168                var liFavoriHeber = $('#li_cptGDF_detailFavoriHeber_'+id);
1169                liFavoriHeber.hide(delay);
1170                setTimeout(function () {
1171                    liFavoriHeber.remove();
1172                    // s'il n'y a plus d'hébergements dans le favori, on referme la liste des hébergements de ce favori
1173                    if($('.liDetailFavoriHeber_'+favoriId).length === 0) {
1174                        $('#div_cptGDF_favoriHeber_'+favoriId).hide();
1175                        $('#btAfficheLstFavoriHeber_'+favoriId).toggleClass('opened', false);
1176                    }
1177                }, delay);
1178            }
1179        });
1180    })(jQuery);
1181}
1182
1183(function ($) {
1184    $.fn.afficheLstFavoriHeber = function () {
1185        var favoriId = this.attr('data-id');
1186        var nomUl = 'ul_cptGDF_favoriHeber_'+favoriId;
1187        var ul = $('#'+nomUl);
1188        var divfavoriHeber = $('#div_cptGDF_favoriHeber_'+favoriId);
1189        var divMsgInfo = $('#lstFavoriHeber_msgInfo_'+favoriId);
1190
1191        $(".btAfficheLstFavoriHeber[data-id='"+favoriId+"']").toggleClass('opened');
1192
1193        if($(".btAfficheLstFavoriHeber[data-id='"+favoriId+"']").hasClass('opened')) {
1194            var data = 'action=AFFICHE_LST_FAVORI_HEBER';
1195            data += '&id='+favoriId;
1196            $.ajax({
1197                type: 'POST',
1198                url: urlCptClient,
1199                data: data,
1200                beforeSend: function(){
1201                    ul.html('');
1202                    divMsgInfo.text('').hide();
1203                    divfavoriHeber.show();
1204                    affMsgAttenteInDiv(nomUl);
1205                },
1206                success: function (result) {
1207                    var tabRetour = JSON.parse(result);
1208                    ul.html('');    // pour enlever la roue de chargement
1209                    if(tabRetour.code === 'KO') {
1210                        if(tabRetour.msg) {
1211                            divMsgInfo.text(tabRetour.msg).show();
1212                        }
1213                        return false;
1214                    }
1215                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1216                        return false;
1217                    }
1218                    ul.hide();
1219                    ul.html(tabRetour.html);
1220                    ul.show("blind");
1221                    rendVisibleEcran(ul,270);
1222                }
1223            });
1224        } else {
1225            divfavoriHeber.hide("blind");
1226        }
1227    };
1228})(jQuery);
1229
1230function widget_affichePopin_delFavori_cptGDF(){
1231    (function($) {
1232        $.fancybox(
1233                $('#popIn_delFavori_cptGDF'), {
1234            maxWidth: 650,
1235            autoHeight:true,
1236            autoWidth:true,
1237            autoResize:true,
1238            autoSize: true,
1239            closeClick: false,
1240            openEffect: 'none',
1241            closeEffect: 'none',
1242            padding: 0,
1243            wrapCSS : 'popin_compteGDF popin_compteGDF_delFavoris'
1244        });
1245    })(jQuery);
1246}
1247
1248function widget_affichePopin_delLstFicheVisitee_cptGDF(){
1249    (function($) {
1250        $.fancybox(
1251                $('#popIn_delLstFicheVisitee_cptGDF'), {
1252            autoResize:true,
1253            autoSize: true,
1254            closeClick: false,
1255            openEffect: 'none',
1256            closeEffect: 'none',
1257            padding: 0,
1258            wrapCSS : 'popin_compteGDF popin_compteGDF_delHistorique'
1259        });
1260    })(jQuery);
1261}
1262
1263function widget_affichePopin_deconnecteSiteExt_cptGDF() {
1264    (function($) {
1265        $.fancybox({
1266            maxWidth: 650,
1267            autoHeight:true,
1268            autoWidth:true,
1269            autoResize:true,
1270            autoSize: true,
1271            closeClick: false,
1272            openEffect: 'none',
1273            closeEffect: 'none',
1274            padding: 0,
1275            href : '#cptGDF_popInDeconnecteSiteExt',
1276            wrapCSS : 'popin_compteGDF popin_compteGDF_deconnectExterne'
1277         });
1278    })(jQuery);
1279}
1280
1281function widget_affichePopinMailPropCptGDF(html){
1282    (function($) {
1283        $.fancybox({
1284            maxWidth: 650,
1285            minWidth: 600,
1286            closeClick: false,
1287            openEffect: 'none',
1288            closeEffect: 'none',
1289            padding: 0,
1290            content : html,
1291            wrapCSS : 'popin_compteGDF popin_compteGDF_envoiMessage',
1292            fitToView:false
1293         });
1294    })(jQuery);
1295}
1296
1297function cptGDF_initActionsDetailFicheVisitee(){
1298    var delaiMasquage = 600;
1299    
1300    (function($) {
1301        
1302        //affichage/masquage de la liste des heber d'une journée d'historique
1303        $('body').undelegate('.compteGDF_lstFicheVisitee_titreDate', 'click');
1304        $('body').delegate('.compteGDF_lstFicheVisitee_titreDate', 'click', function() {
1305            var date_visite = $(this).data('datevisite');
1306            if($('ul[data-datevisite='+date_visite+']').is(":hidden")){
1307                $('ul[data-datevisite='+date_visite+']').show("blind");
1308                rendVisibleEcran('ul[data-datevisite='+date_visite+']',270)
1309            }
1310            else{
1311                $('ul[data-datevisite='+date_visite+']').hide("blind");
1312            }
1313            $(this).toggleClass('closed');
1314        });
1315        
1316        //suppression d'une structure de l'historique
1317        $('body').undelegate('.btDelFicheVisitee', 'click');
1318        $('body').delegate('.btDelFicheVisitee', 'click', function() {
1319            var ref = $(this).data('ref');
1320            var date_visite = $(this).data('datevisite');
1321            
1322            var liDate = $('li[data-datevisite='+date_visite+']');
1323            var ulFiche = $('ul[data-datevisite='+date_visite+']');
1324            var liFiche = $('li[data-ref='+ref+']');
1325       
1326            var conteneurMsgInfo = $('#div_ficheVisitee_msgInfo_'+ref);
1327            
1328            var data = 'action=DEL_FICHE_VISITEE';
1329            data += '&ref='+ref;
1330            
1331            $.ajax({
1332                type: 'POST',
1333                url: urlCptClient,
1334                data: data,
1335                success: function (result) {
1336                    var tabRetour = JSON.parse(result);
1337                    if(tabRetour.code === 'KO') {
1338                        if(tabRetour.msg) {
1339                            setMsgInfoCptGDF(conteneurMsgInfo, tabRetour.msg);
1340                        }
1341                        return false;
1342                    }
1343                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1344                        return false;
1345                    }
1346                    setMsgInfoCptGDF(conteneurMsgInfo);
1347                    liFiche.hide(delaiMasquage);
1348                    setTimeout(function () {
1349                        liFiche.remove();
1350                        // s'il n'y a plus d'hébergements dans le jour en question, on supprime ce jour de l'affichage
1351                        if(ulFiche.children().length === 0) {
1352                            liDate.remove();
1353                        }
1354                    }, delaiMasquage);
1355                }
1356            });
1357        });
1358        
1359        //affichage de la pop-in permettant de supprimer tout l'historique
1360        $('body').undelegate('#bt_cptGDF_delLstFicheVisitee', 'click');
1361        $('body').delegate('#bt_cptGDF_delLstFicheVisitee', 'click', function() {
1362            if($('#ul_cptGDF_ficheVisitee_date').html().length === 0) {    // s'il n'y a pas d'historique on ne fait rien
1363                return false;
1364            }
1365            widget_affichePopin_delLstFicheVisitee_cptGDF();
1366        });
1367        
1368        //suppression de tout l'historique
1369        $('body').undelegate('#popIn_delLstFicheVisitee_cptGDF_btConfirm', 'click');
1370        $('body').delegate('#popIn_delLstFicheVisitee_cptGDF_btConfirm', 'click', function() {
1371            $.ajax({
1372                type: 'POST',
1373                url: urlCptClient,
1374                data: 'action=DEL_LST_FICHE_VISITEE',
1375                success: function (result) {
1376                    var tabRetour = JSON.parse(result);
1377                    $.fancybox.close();
1378                    if(tabRetour.code === 'KO') {
1379                        if(tabRetour.msg) {
1380                            setMsgInfoCptGDF($('#cptGDF_delLstFicheVisitee_msgInfo'), tabRetour.msg);
1381                        }
1382                        return false;
1383                    }
1384                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1385                        return false;
1386                    }
1387                    var ulFicheVisiteeDate = $('#ul_cptGDF_ficheVisitee_date');
1388                    ulFicheVisiteeDate.hide(delaiMasquage);
1389                    setTimeout(function () {
1390                        ulFicheVisiteeDate.html('');
1391                        $("#compteGDF_pasDeHistorique").show();
1392                    }, delaiMasquage);
1393                }
1394            });
1395        });
1396        
1397    })(jQuery);
1398}
1399
1400
1401function cptGDF_majJauge(){
1402    (function ($) {
1403        var data = 'action=getHTML_remplissageJauge';
1404        $.ajax({
1405            type: 'POST',
1406            url: urlCptClient,
1407            data: data,
1408            success: function (result) {
1409                var tabRetour = JSON.parse(result);
1410                if (tabRetour.code === 'KO') {
1411                    return false;
1412                }
1413                if(!traiteRepKoCnxCptGDF(tabRetour)) {
1414                    return false;
1415                }
1416                $('div.div_jaugeProfilBandeau').html(tabRetour.html);
1417            }
1418        });
1419    })(jQuery);
1420}
1421
1422function cptGDF_initActionsProfil(){
1423    (function($){
1424        cptGDF_initTouchOutDatepicker();
1425        cptGDF_initBoutonsModifierInfos();
1426        cptGDF_initCheckOuiNon();
1427        cptGDF_initCheckboxes();
1428        cptGdf_initInputChampsVides();
1429        cptGdf_initActionsSuppCompte();
1430        autocompleteurCpVille($('#inpt_CP'),$('#inpt_ville'));
1431        
1432        //fiche 258091
1433        $('#inpt_dateNaissance').change(function () {
1434            $(this).val($.trim($(this).val()));
1435        });
1436        
1437        // On fait un LiveValidation sur le formulaire des informations personnelles
1438        if ($('#inpt_validInfosPersos').length>0) {
1439            var tabChampsLV = getTabChampsLV_infosPersos();
1440        }
1441        
1442        $('#inpt_validInfosPersos').click(function(){
1443            if (!LiveValidation.massValidate(tabChampsLV)) {
1444                var infos = $('#form_infosProfil').serialize();
1445                errLogJS('liveValidationInfosPersoCompteGdF', infos);
1446                return;
1447            }
1448            var infosObligatoires = true;
1449            $('.div_saisieInfosPersoCptGDF .inpt_obligatoire').each(function(){
1450                if ($(this).val()=='') {
1451                    infosObligatoires = false;
1452                }
1453            });
1454            if (!infosObligatoires) {
1455                afficheMessageInfosObligatoires();
1456                var infos = $('#form_infosProfil').serialize();
1457                errLogJS('infosObligatoiresCompteGdF', infos);
1458                return;
1459            }
1460            
1461            var form = $('#form_infosProfil');
1462            var formData = new FormData(form[0]);
1463            
1464            // Si les champs sont masqués il ne faut pas les prendre en compte, je change donc leur attribut name
1465            // Afin de ne pas les utiliser dans le traitement AJAX
1466            // Yoann 31/03/2016 : Pour être sûr de bien les prendre en compte je les ajoute directement dans le formData
1467            if ($('#inpt_newsletterFd_responsive').not(':visible').length>0) {
1468                $('#inpt_newsletterFd_responsive').attr('name', 'ne_pas_prendre_en_compte_newsletter_fd');
1469                formData.append('ne_pas_prendre_en_compte_newsletter_fd', 'O');
1470            }
1471            if ($('#inpt_newsletterPart_responsive').not(':visible').length>0) {
1472                $('#inpt_newsletterPart_responsive').attr('name', 'ne_pas_prendre_en_compte_newsletter_part');
1473                formData.append('ne_pas_prendre_en_compte_newsletter_part', 'O');
1474            }
1475            
1476            $.ajax({
1477                processData: false,
1478                contentType: false,
1479                type: 'POST',
1480                url: urlCptClient,
1481                data: formData,
1482                beforeSend: function(){
1483                    
1484                },
1485                success: function(result){
1486                    var tabRetour = JSON.parse(result);
1487                    if(tabRetour.code === 'KO') {
1488                        if(tabRetour.msg) {
1489                            afficheMessageRetour_cptGDF(tabRetour);
1490                        }
1491                        return false;
1492                    }
1493                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1494                        return false;
1495                    }
1496                    if (tabRetour.cheminPhoto) {
1497                        remplacePhotoProfilApresModif(tabRetour.cheminPhoto);
1498                    }
1499                    afficheMessageRetour_cptGDF(tabRetour);
1500                    cptGDF_initDivProfil($('#div_profilInfosPersos'));
1501                    effaceLiveValidation();
1502                    cptGDF_majJauge();
1503                    // Yoann 15/03/2016 : Au cas où le client ait modifié son adresse mail il faut mettre à jour le champ mail dans le bloc des infos de connexion
1504                    $('#inpt_mailCptGdf').val($('#inpt_email').val());
1505                    if(tabRetour.action === 'getLandingPage') {
1506                        window.location.href = '/?getLandingPage=1';
1507                    }
1508                }
1509            });
1510            
1511            
1512            if ($('#inpt_validCentresInterets').is(':visible')) {
1513                $('#inpt_validInfosPersos').parent('.div_btnValidProfilCptGDF').hide();
1514                $('#inpt_validCentresInterets').click();
1515            }
1516        });
1517        
1518        $('#div_profilMesOffres input').change(function(){
1519            var newsletter_fd = 'N';
1520            if ($('#inpt_newsletterFd').is(':checked')) {
1521                newsletter_fd = 'O';
1522            }
1523            var newsletter_part = 'N';
1524            if ($('#inpt_newsletterPart').is(':checked')) {
1525                newsletter_part = 'O';
1526            }
1527            
1528            $.ajax({
1529                url: urlCptClient,
1530                data: {action: 'enregistreOffresGDF', newsletter_fd: newsletter_fd, newsletter_part: newsletter_part},
1531                beforeSend: function(){
1532                    // TODO : loader ?
1533                },
1534                success: function(result){
1535                    var tabRetour = JSON.parse(result);
1536                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1537                        return false;
1538                    }
1539                }
1540            });
1541        });
1542        
1543        $('.select_typeSejour').change(function(){
1544            var nb = $(this).find('option:selected').attr('nb');
1545            var inptTypeSejour = $(this).attr('data-typesejour');
1546            $('#'+inptTypeSejour).attr('checked', (nb>0)).change();
1547        });
1548        $('.div_centresInteretsCptGDF input').change(function(){
1549            if ($(this).is(':checked')) {
1550                $('label[for="'+$(this).attr("id")+'"]').addClass('selected');
1551            } else {
1552                $('label[for="'+$(this).attr("id")+'"]').removeClass('selected');
1553            }
1554        });
1555        $('#inpt_validCentresInterets').click(function(){
1556            var tabCI = new Array();
1557            var tabPS = new Array();
1558            var tabTD = new Array();
1559            var tabTH = new Array();
1560            var tabTS = new Array();
1561            
1562            $('.div_centresInteretsCptGDF input').each(function(){
1563                if ($(this).is(':checked')) {
1564                    tabCI.push(($(this).val()));
1565                }
1566            });
1567            $('.div_periodesSejoursCptGDF input').each(function(){
1568                if ($(this).is(':checked')) {
1569                    tabPS.push(($(this).val()));
1570                }
1571            });
1572            $('.div_typesDestinationsCptGDF input').each(function(){
1573                if ($(this).is(':checked')) {
1574                    tabTD.push(($(this).val()));
1575                }
1576            });
1577            $('.div_typesHebergementsCptGDF input').each(function(){
1578                if ($(this).is(':checked')) {
1579                    tabTH.push(($(this).val()));
1580                }
1581            });
1582            $('.div_typesSejoursCptGDF input').each(function(){
1583                if ($(this).is(':checked')) {
1584                    tabTS.push(($(this).val()));
1585                }
1586            });
1587            $('.div_typesSejoursCptGDF select').each(function(){
1588                var inptTypeSejour = $(this).attr('data-typeSejour');
1589                if ($('#'+inptTypeSejour).is(':checked')) {
1590                    tabTS.push(($(this).val()));
1591                }
1592            });
1593            
1594            $.ajax({
1595                url: urlCptClient,
1596                data: {action: 'enregistreCentresInterets', tabCI: tabCI, tabPS: tabPS, tabTD: tabTD, tabTH: tabTH, tabTS: tabTS},
1597                beforeSend: function(){
1598                    
1599                },
1600                success: function(result){
1601                    var tabRetour = JSON.parse(result);
1602                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
1603                        return false;
1604                    }
1605                    afficheMessageRetour_cptGDF(tabRetour);
1606                    cptGDF_majJauge();
1607                    cptGDF_initDivProfil($('#div_profilCentresInterets'));
1608                }
1609            });
1610            
1611            if ($('#inpt_validInfosPersos').is(':visible')) {
1612                $('#inpt_validCentresInterets').parent('.div_btnValidProfilCptGDF').hide();
1613                $('#inpt_validInfosPersos').click();
1614            }
1615        });
1616        
1617        //Caro affichage de la pop in de confirmation de suppression
1618        $('.a_suppPhotoProfil').click(function(){
1619            affichePopinSuppPhotoProfil();
1620        });
1621       
1622        
1623        $('.a_modifInfosConnexion').click(function(){
1624            // TODO : envoi d'un mail et affichage d'une popin
1625            $.ajax({
1626                type: 'POST',
1627                url: urlCptClient,
1628                data: {action: 'envoiMailModifInfosConnexion'},
1629                success: function(result){
1630                    // TODO : afficher la popin de confirmation
1631                    var tabRetour = JSON.parse(result);
1632                    affichePopinModifInformationsConnexion(tabRetour.html);
1633                }
1634            });
1635        });
1636        
1637        $('#inpt_modifInfosConnexion').click(function(){
1638            if($(this).data('site-externe') !== undefined) {
1639                widget_affichePopin_deconnecteSiteExt_cptGDF();
1640            } else {
1641                var email = $('#inpt_mailCptGdf').val();
1642                var ancienMdp = $('#inpt_mdpdCptGdf').val();
1643                var nouveauMdp = $('#inpt_nouveauMdpCptGdf').val();
1644                var confirmMdp = $('#inpt_confirmMdpCptGdf').val();
1645                
1646                if (email!='' && ancienMdp!='' && nouveauMdp!='' && confirmMdp!='') {
1647                    if (nouveauMdp==confirmMdp && ancienMdp!=nouveauMdp) {
1648                        $.ajax({
1649                            url: urlCptClient,
1650                            data: {action: 'metAJourMotDePasse', email: email, ancienMdp: ancienMdp, nouveauMdp: nouveauMdp},
1651                            beforeSend: function(){
1652                                // TODO : loader ?
1653                            },
1654                            success: function(result){
1655                                var tabRetour = JSON.parse(result);
1656                                if(!traiteRepKoCnxCptGDF(tabRetour)) {
1657                                    return false;
1658                                }
1659                                afficheMessageRetour_cptGDF(tabRetour);
1660                                cptGDF_initDivProfil($('#div_profilInfosConnexion'));
1661                            }
1662                        });
1663                    } else {
1664//                        afficheMessageRetour();
1665                    }
1666                } else {
1667//                    afficheMessageRetour();
1668                }
1669            }
1670        });
1671        
1672        
1673    })(jQuery);
1674    
1675    cptGDF_initActionsNewPass();
1676    cptGDF_initActionsDeconnecteSiteExt();
1677}
1678
1679function cptGDF_initTouchOutDatepicker(){
1680    (function($){
1681        // Le code permettant de fermer les datepicker quand on clic en dehors, sur iPad ça ne fonctionnait pas sans ce code
1682        $(document).bind('touchstart', function(e) {
1683            var ele = $(e.toElement); 
1684            if (!ele.hasClass("hasDatepicker") && !ele.hasClass("ui-datepicker") && !ele.hasClass("ui-icon") && !$(ele).parent().parents(".ui-datepicker").length)
1685               $(".hasDatepicker").datepicker("hide"); 
1686        });
1687    })(jQuery);
1688}
1689
1690function getTabChampsLV_infosPersos(){
1691    var retour = [];
1692    (function($){
1693        var nom = new LiveValidation("inpt_nom", {validMessage: ' '});
1694        nom.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
1695        retour.push(nom);
1696        
1697        var prenom = new LiveValidation("inpt_prenom", {validMessage: ' '});
1698        prenom.add(Validate.Presence, {failureMessage:  $("#inpt_msgVide").val()});
1699        retour.push(prenom);
1700        
1701        var dateNaissance = new LiveValidation("inpt_dateNaissance", {validMessage: ' ', onlyOnSubmit: true});
1702        dateNaissance.add(Validate.Format, {pattern: /(^[0-9]{8}$)/, failureMessage: $("#inpt_formatDateNaissanceIncorrect").val()});
1703        dateNaissance.add(Validate.Custom, {against: function(value){
1704            var jour = parseInt(value.substr(0, 2));
1705            var mois = parseInt(value.substr(2, 2));
1706            mois--;
1707            if (jour>31 || mois>12 || annee<1900) {
1708                return false;
1709            }
1710            var annee = parseInt(value.substr(4, 4));
1711            
1712            var dateSaisie = new Date(annee, mois, jour, 12, 0, 0, 0);
1713            if (dateSaisie.getDay()>6 || dateSaisie.getDay()<0 || dateSaisie.getMonth()>12 || dateSaisie.getMonth()<0 || dateSaisie.getFullYear()<1900) {
1714                return false;
1715            }
1716            
1717            return true;
1718        }, failureMessage: $("#inpt_dateNaissanceIncorrect").val()});
1719        dateNaissance.add(Validate.Custom, {against: function(value){ // verif pour avoir 18 ans
1720            var date_courante = new Date();
1721            var jour = parseInt(value.substr(0, 2));
1722            var mois = parseInt(value.substr(2, 2));
1723            mois--;
1724            var annee = parseInt(value.substr(4, 4));
1725            
1726            var dateSaisie = new Date(annee, mois, jour, 12, 0, 0, 0);
1727            if (getEcartAnneeEntreObjsDates(date_courante,dateSaisie)<18) {
1728                return false;
1729            }
1730            
1731            return true;
1732        }, failureMessage: $("#inpt_dateNaissanceIncorrectPas18Ans").val()});
1733        retour.push(dateNaissance);
1734        
1735        var adresse = new LiveValidation("inpt_adresse", {validMessage: ' '});
1736        adresse.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
1737        retour.push(adresse);
1738        
1739        var cp = new LiveValidation("inpt_CP", {validMessage: ' '});
1740        cp.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
1741        retour.push(cp);
1742        
1743        var ville = new LiveValidation("inpt_ville", {validMessage: ' '});
1744        ville.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
1745        //ville.add(Validate.Format, {pattern: /(^[a-zA-Z0-9éèçà'-]*$)/, failureMessage: $("#inpt_villeIncorrect").val()});
1746        retour.push(ville);
1747
1748        var tel = new LiveValidation("inpt_telephone", {validMessage: ' ', onlyOnBlur: true});
1749        tel.add(Validate.Format, {pattern: /(^0[1-9][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$|^00[0-9,\s]+[0-9]$)/, failureMessage: $("#inpt_msgTelIncorrect").val()});
1750        tel.add(Validate.Length, {minimum: 6, tooShortMessage: $("#inpt_msgTelIncorrect").val()});
1751        tel.add(Validate.Length, {maximum: 20, tooLongMessage: $('#inpt_msgTelIncorrect').val()});
1752        retour.push(tel);
1753
1754        if ($('#inpt_email:visible').length>0) {
1755            var email = new LiveValidation("inpt_email", {validMessage: ' ',onlyOnBlur: true});
1756            addValidateOnLiveValidationEmail(email, undefined, true, $("#inpt_msgMailNonValide").val());
1757            email.add(Validate.Custom, {
1758                against: function(value, args){
1759                    var ancienEmail = $('#inpt_ancienEmail').val();
1760                    if (ancienEmail!=value) {
1761                        var args = {};
1762                        args.info = 'checkEmailClientCompilNotExist';
1763                        return checkEmailIteaPourValidate(value, args);
1764                    } else {
1765                        return true;
1766                    }
1767                },
1768                failureMessage: $('#inpt_msgMailCompteExistant').val()
1769            });
1770            retour.push(email);
1771        }
1772        
1773        
1774        var adresse = new LiveValidation("select_pays", {validMessage: ' '});
1775        adresse.add(Validate.Presence, {failureMessage: $("#inpt_msgVide").val()});
1776        retour.push(adresse);
1777        
1778        var csp = new LiveValidation('select_csp', {validMessage: ' '});
1779        csp.add(Validate.Presence, {failureMessage: $('#inpt_msgVide').val()});
1780        retour.push(csp);
1781    })(jQuery);
1782    return retour;
1783}
1784
1785function afficheMessageRetour_cptGDF(tabRetour){
1786    (function($){
1787        if (!tabRetour.msg || tabRetour.msg=='') {
1788            return;
1789        }
1790        var classe = 'confirm';
1791        if (tabRetour.code=='KO') {
1792            classe = 'erreur';
1793        }
1794        
1795        $('.div_messageRetourProfil').removeClass("confirm").removeClass("erreur").addClass(classe);
1796        $('.div_messageRetourProfil').text(tabRetour.msg);
1797        
1798        $('.div_messageRetourProfil').fadeIn().delay(5000).fadeOut();
1799        
1800        $('html, body').animate({ scrollTop: 0 }, 'fast');
1801    })(jQuery);
1802}
1803
1804function cptGDF_initActionsNewPass(decoFinTraitement){
1805    (function($){
1806        if($('#btNewPassCptGdf_email').length === 0) {  // on est obligé de faire cette vérif sinon le LiveValidation peut renvoyer une erreur
1807            return false;
1808        }
1809        var seDecoLorsDuRedirect = false;
1810        if(decoFinTraitement === true){
1811            seDecoLorsDuRedirect = true;
1812        }
1813        var tabAValider = [];
1814        
1815        var mdp = new LiveValidation('inptNewPassCptGdf_newpass', {validMessage: ' ', onlyOnBlur: true});
1816        mdp.add(Validate.Presence, {failureMessage: $('#inptNewPass_msgChampObligatoire').val()});
1817        mdp.add(Validate.Format,{pattern: /^[0-9a-zA-Z-_]+$/, failureMessage: $('#inptNewPass_msgSeulementChiffresLettres').val()});
1818        mdp.add(Validate.Length, {minimum: 4, tooShortMessage: $('#inptNewPass_msgNbCar').val()});
1819        tabAValider.push(mdp);
1820
1821        var mdpConfirm = new LiveValidation('inptNewPassCptGdf_newpass_confirm', {validMessage: ' ', onlyOnBlur: true});
1822        mdpConfirm.add(Validate.Presence, {failureMessage: $('#inptNewPass_msgChampObligatoire').val()});
1823        mdpConfirm.add(Validate.Confirmation, {match: 'inptNewPassCptGdf_newpass', failureMessage: $('#inptNewPass_msgCorresMdp').val()});
1824        tabAValider.push(mdpConfirm);
1825        
1826        $(this).unbind('click');    //fiche 258304
1827        $('#btNewPassCptGdf_email').bind('click', function(e){
1828            e.preventDefault();
1829            if (LiveValidation.massValidate(tabAValider)) {
1830                $('#btNewPassCptGdf_email').hide();
1831                $('#btNewPassCptGdf_loader').show();
1832                var tabArgs = getVarsFromUrl();
1833                var data = 'action=reinitMotDePasse';
1834                data += '&newpass='+$('#inptNewPassCptGdf_newpass').val();
1835                if(tabArgs.login !== undefined && tabArgs.pass !== undefined) {
1836                    data += '&email='+tabArgs.login;
1837                    data += '&pass='+tabArgs.pass;
1838                }
1839                if(tabArgs.loginGdf !== undefined && tabArgs.passGdf !== undefined) {
1840                    data += '&email='+tabArgs.loginGdf;
1841                    data += '&pass='+tabArgs.passGdf;
1842                }
1843                $.ajax({
1844                    type: 'POST',
1845                    url: urlCptClient,
1846                    data: data,
1847                    dataType: 'json',
1848                    success: function (tabRetour) {
1849                        if(tabRetour.code === 'KO') {
1850                            setMsgInfoCptGDF($('#newPassCptGDF_msgInfo'), tabRetour.msg);
1851                            return false;
1852                        }
1853                        setMsgInfoCptGDF($('#newPassCptGDF_msgInfo'));
1854                        widget_affichePopinNewPassModifieCptGDF(tabRetour.msg, seDecoLorsDuRedirect);
1855                    }, complete: function(){
1856                        $('#btNewPassCptGdf_email').show();
1857                        $('#btNewPassCptGdf_loader').hide();
1858                    }
1859                });
1860            }
1861        });
1862        
1863    })(jQuery);
1864}
1865
1866function cptGDF_initActionsDeconnecteSiteExt(){
1867    (function($){
1868        $('body').undelegate('.inpt_modifSiteExterne', 'click');
1869        $('body').delegate('.inpt_modifSiteExterne', 'click', function() {
1870            widget_affichePopin_deconnecteSiteExt_cptGDF();
1871        });
1872        
1873        $('body').undelegate('#cptGDF_btDeconnecteSiteExt', 'click');
1874        $('body').delegate('#cptGDF_btDeconnecteSiteExt', 'click', function() {
1875            var data = 'action=deconnecteSiteExt';
1876            data += '&site='+$(this).data('site');
1877            $.ajax({
1878                type: 'POST',
1879                url: urlCptClient,
1880                data: data,
1881                success: function (result) {
1882                    var tabRetour = JSON.parse(result);
1883                    if(tabRetour.code === 'KO') {
1884                        setMsgInfoCptGDF($('#cptGDF_deconnecteSiteExt_msgInfo'), tabRetour.msg);
1885                        return false;
1886                    }
1887                    setMsgInfoCptGDF($('#cptGDF_deconnecteSiteExt_msgInfo'));
1888                    widget_affichePopinConfirmDemandePassword_cptGDF_mailEnvoye(tabRetour.msg);
1889                }
1890            });
1891        });
1892    })(jQuery);
1893}
1894
1895function cptGDF_initBoutonsModifierInfos(){
1896    (function($){
1897        $('.div_profilCptGDF:not(.sansDisabled)').each(function(){
1898            cptGDF_initDivProfil($(this));
1899        });
1900        
1901        // Les boutons servent à désactiver les élément du formulaire correspondant
1902        $('.a_enteteProfilCptGDF_modifier').click(function(){
1903            var divAModifier = $(this).parents('.div_profilCptGDF');
1904            divAModifier.find('input, select').attr('disabled', false);
1905            divAModifier.find('.div_btnValidProfilCptGDF').show();
1906        });
1907    })(jQuery);
1908}
1909
1910function cptGDF_initCheckOuiNon(){
1911    (function($){
1912        $('.inptOuiNon').change(function(){
1913            var idLabel = $(this).attr('data-label');
1914            if ($(this).is(':checked')) {
1915                $('#'+idLabel).addClass('Oui');
1916                $('#'+idLabel).removeClass('Non');
1917            } else {
1918                $('#'+idLabel).addClass('Non');
1919                $('#'+idLabel).removeClass('Oui');
1920            }
1921        });
1922    })(jQuery);
1923}
1924
1925function cptGDF_initCheckboxes(){
1926    (function($){
1927        $('.div_contentProfilCptGDF input[type=checkbox]').change(function(){
1928            $('label[for='+$(this).attr('id')+']').toggleClass('selected', $(this).is(':checked'));
1929        });
1930    })(jQuery);
1931}
1932
1933function cptGDF_initDivProfil(divProfil){
1934    (function($){
1935        divProfil.find('input, select').attr('disabled', true);
1936        divProfil.find('.div_btnValidProfilCptGDF').hide();
1937    })(jQuery);
1938}
1939
1940
1941function cptGdf_initActionsSuppCompte(){
1942    (function($){
1943        $('body').undelegate('#a_suppCompteGdf', 'click');
1944        $('body').delegate('#a_suppCompteGdf', 'click', function() {
1945            $.fancybox(
1946                $('#div_confirmSuppCptGdf'), {
1947                maxWidth: 650,
1948                autoHeight:true,
1949                autoWidth:true,
1950                autoResize:true,
1951                autoSize: true,
1952                closeClick: false,
1953                openEffect: 'none',
1954                closeEffect: 'none',
1955                padding: 0,
1956                wrapCSS:'popin_compteGDF popin_suppCpt_cptGDF'
1957            });
1958        });
1959        
1960        $('body').undelegate('#popIn_supp_cptGDF_retourCompte', 'click');
1961        $('body').delegate('#popIn_supp_cptGDF_retourCompte', 'click', function() {
1962            $.fancybox.close();
1963        });
1964        
1965        $('body').undelegate('#popIn_supp_cptGDF_btConfirm', 'click');
1966        $('body').delegate('#popIn_supp_cptGDF_btConfirm', 'click', function() {
1967           $.ajax({
1968                type: 'POST',
1969                url: urlCptClient,
1970                data: 'action=supprimeCompteGdf',
1971                success: function (result) {
1972                    var tabRetour = JSON.parse(result);
1973                    $.fancybox.close();
1974                    if(tabRetour.code === 'KO') {
1975                        if(tabRetour.msg) {
1976                            setMsgInfoCptGDF($('#cptGDF_delLstFicheVisitee_msgInfo'), tabRetour.msg);
1977                        }
1978                        return false;
1979                    }
1980                    $.fancybox(
1981                        $('#div_suppEffectCptGdf'), {
1982                            maxWidth: 650,
1983                            autoHeight:true,
1984                            autoWidth:true,
1985                            autoResize:true,
1986                            autoSize: true,
1987                            closeClick: false,
1988                            openEffect: 'none',
1989                            closeEffect: 'none',
1990                            padding: 0,
1991                            wrapCSS:'popin_compteGDF popin_suppEffectCpt_cptGDF',
1992                            afterClose: function() {
1993                                document.location.href = '/';
1994                            }
1995                        });
1996                }
1997            });
1998        });
1999     })(jQuery);
2000}
2001
2002function visualiseEtCropPhoto(idInputFile, foncApresCrop){
2003    var fichier = document.getElementById(idInputFile).files;
2004    
2005    var fileReader = new FileReader();
2006    
2007    fileReader.onloadend = function (e) {
2008        afficheLoaderGlobal();
2009        rotateImage(e.target.result, function (src) {
2010            effaceLoaderGlobal();
2011            affichePopinCropPhotoProfil(src, foncApresCrop);
2012        });               
2013    };
2014
2015    fileReader.readAsDataURL(fichier[0]);
2016}
2017
2018function rotateImage  (original_src, callback) {
2019    var rotated_src; // where the rotate image content will be
2020    var exifImg = new Image;
2021    exifImg.onload = function () {
2022        EXIF.getData(exifImg, function () {
2023            var orientation = EXIF.getTag(this, "Orientation");
2024            var canvas = jQuery('<canvas id="canvas_exif" width="' + exifImg.width + '" height="' + exifImg.height + '"></canvas>');
2025            canvas.attr('origin-clean', 'true');
2026            jQuery("body").append(canvas);
2027            var ctx = jQuery("#canvas_exif")[0].getContext('2d');
2028            ctx.translate(exifImg.width * 0.5, exifImg.height * 0.5);
2029
2030            switch(orientation) {
2031              case 2:
2032                  // horizontal flip
2033                  ctx.translate(canvas.width, 0);
2034                  ctx.scale(-1, 1);
2035                  break;
2036              case 3:
2037                  // 180° rotate left
2038                  ctx.translate(canvas.width, canvas.height);
2039                  ctx.rotate(Math.PI);
2040                  break;
2041              case 4:
2042                  // vertical flip
2043                  ctx.translate(0, canvas.height);
2044                  ctx.scale(1, -1);
2045                  break;
2046              case 5:
2047                  // vertical flip + 90 rotate right
2048                  ctx.rotate(0.5 * Math.PI);
2049                  ctx.scale(1, -1);
2050                  break;
2051              case 6:
2052                  // 90° rotate right
2053                  ctx.rotate(0.5 * Math.PI);
2054                  ctx.translate(0, -canvas.height);
2055                  break;
2056              case 7:
2057                  // horizontal flip + 90 rotate right
2058                  ctx.rotate(0.5 * Math.PI);
2059                  ctx.translate(canvas.width, -canvas.height);
2060                  ctx.scale(-1, 1);
2061                  break;
2062              case 8:
2063                  // 90° rotate left
2064                  ctx.rotate(-0.5 * Math.PI);
2065                  ctx.translate(-canvas.width, 0);
2066                  break;
2067            }
2068
2069            ctx.translate(-exifImg.width * 0.5, -exifImg.height * 0.5);
2070            ctx.drawImage(exifImg, 0, 0);
2071            rotated_src = jQuery("#canvas_exif")[0].toDataURL();
2072            jQuery("#canvas_exif").remove();
2073            callback(rotated_src);
2074        });
2075    };
2076    exifImg.src = original_src; // original_src is the original image content    
2077}
2078
2079function affichePopinCropPhotoProfil(src, foncApresCrop){
2080    jQuery('#div_croppieContainer').html('');
2081    var vanilla = new Croppie(document.getElementById('div_croppieContainer'), {
2082        viewport: { width: 150, height: 150, type: 'circle' },
2083        boundary: { width: 300, height: 300 }
2084    });
2085    vanilla.bind(src);
2086    
2087    document.querySelector('.btn_valideCrop').addEventListener('click', function (ev) {
2088        vanilla.result('canvas').then(function (src) {
2089            jQuery('#input_srcImageCropped').val(src);
2090            foncApresCrop();
2091            jQuery.fancybox.close();
2092        });
2093    });
2094    
2095    jQuery.fancybox(
2096        jQuery('#div_popinCropPhotoProfil'), {
2097            maxWidth: 1000,
2098            autoDimensions: false,
2099            openEffect: 'none',
2100            closeEffect: 'none',
2101            wrapCSS: 'popin_compteGDF popin_compteGDF_modifPhoto',
2102            fitToView :false,
2103            padding:0
2104    });
2105}
2106
2107function uploadPhotoProfilApresCrop(){
2108    (function($){
2109        var src = $('#input_srcImageCropped').val();
2110
2111        $.ajax({
2112            type: 'POST',
2113            url: urlCptClient,
2114            data: {action: 'modifiePhotoProfil', src: encodeURIComponent(src)},
2115            beforeSend: function(){
2116                
2117            },
2118            success: function(result){
2119                var tabRetour = JSON.parse(result);
2120                if(tabRetour.code === 'KO') {
2121                    if(tabRetour.msg) {
2122                        afficheMessageRetour_cptGDF(tabRetour);
2123                    }
2124                    return false;
2125                }
2126                if(!traiteRepKoCnxCptGDF(tabRetour)) {
2127                    return false;
2128                }
2129                remplacePhotoProfilApresModif(tabRetour.cheminPhoto);
2130                afficheMessageRetour_cptGDF(tabRetour);
2131                cptGDF_majJauge();
2132            }
2133        });
2134    })(jQuery);
2135}
2136
2137function remplacePhotoProfilApresCrop(){
2138    (function($){
2139        var src = $('#input_srcImageCropped').val();
2140        $('.img_photoProfil.infosPersos:visible').attr('src', src);
2141        $('#inpt_photoBase64').val(src);
2142    })(jQuery);
2143}
2144
2145function remplacePhotoProfilApresModif(src){
2146    (function($){
2147        $('.img_photoProfil').attr('src', src);
2148        $('.div_photoProfilBandeau_suppPhoto').show();
2149    })(jQuery);
2150}
2151
2152function widget_affichePopinNewPassModifieCptGDF(html, decoFinTraitement){
2153    (function($) {
2154        $.fancybox({
2155            maxWidth: 650,
2156            autoHeight:true,
2157            autoWidth:true,
2158            autoResize:true,
2159            autoSize: true,
2160            closeClick: false,
2161            openEffect: 'none',
2162            closeEffect: 'none',
2163            padding: 0,
2164            content : html,
2165            wrapCSS:'popin_compteGDF popin_validReinitMotDePasse_cptGDF',
2166            afterClose: function() {
2167                if(decoFinTraitement){
2168                    document.location.href = window.location.pathname + '?deconnexionChangementPass=1';
2169                } else {
2170                    document.location.href = '/';
2171                }
2172            }
2173         });
2174    })(jQuery);
2175}
2176
2177
2178function affichePopinSuppPhotoProfil(){
2179    (function($) {
2180        $.fancybox(
2181            $('#popIn_suppPhoto_cptGDF'), {
2182            maxWidth: 650,
2183            autoHeight:true,
2184            autoWidth:true,
2185            autoResize:true,
2186            autoSize: true,
2187            closeClick: false,
2188            openEffect: 'none',
2189            closeEffect: 'none',
2190            padding: 0,
2191            wrapCSS : 'popin_compteGDF popin_compteGDF_suppPhotoProfil'
2192        });
2193        
2194        $('body').undelegate('#popIn_suppPhoto_cptGDF_btConfirm', 'click');
2195        $('body').delegate('#popIn_suppPhoto_cptGDF_btConfirm', 'click', function() {
2196            //$('#input_srcImageCropped').val('');
2197            $.ajax({
2198                type: 'POST',
2199                url: urlCptClient,
2200                data: {action: 'supprimePhotoProfil'},
2201                success: function(result){
2202                    var tabRetour = JSON.parse(result);
2203                    if(tabRetour.code === 'KO') {
2204                        if(tabRetour.msg) {
2205                            afficheMessageRetour_cptGDF(tabRetour);
2206                        }
2207                        return false;
2208                    }
2209                    if(!traiteRepKoCnxCptGDF(tabRetour)) {
2210                        return false;
2211                    }
2212                    $.fancybox.close();
2213                    remplacePhotoProfilApresModif(tabRetour.cheminPhoto);
2214                    afficheMessageRetour_cptGDF(tabRetour);
2215                    cptGDF_majJauge();
2216                    $('.div_photoProfilBandeau_suppPhoto').hide();
2217                }
2218            });
2219        });
2220    })(jQuery);
2221    
2222}
2223
2224function affichePopinModifInformationsConnexion(html){
2225    (function($) {
2226        $.fancybox({
2227            maxWidth: 650,
2228            autoHeight:true,
2229            autoWidth:true,
2230            autoResize:true,
2231            autoSize: true,
2232            closeClick: false,
2233            openEffect: 'none',
2234            closeEffect: 'none',
2235            padding: 0,
2236            content : html,
2237            wrapCSS:'popin_compteGDF popin_modifInfosConnexion_cptGDF'
2238         });
2239    })(jQuery);
2240}
2241
2242function widget_affichePopinConfirmDemandePassword_cptGDF_mailEnvoye(html) {
2243    (function($) {
2244        $.fancybox({
2245            maxWidth: 650,
2246            autoHeight:true,
2247            autoWidth:true,
2248            autoResize:true,
2249            autoSize: true,
2250            closeClick: false,
2251            openEffect: 'none',
2252            closeEffect: 'none',
2253            padding: 0,
2254            content : html,
2255            afterClose: function() {
2256                $('#btDisconnectCptGDF').click();   // important pour se déconnecter de Google +
2257            }
2258         });
2259    })(jQuery);
2260}
2261
2262function cptGDF_initActionsBandeau(){
2263    (function($){
2264        $('#sp_fermeJaugeProfil').click(function(){
2265            $('.div_jaugeProfilBandeau').hide();
2266        });
2267    })(jQuery);
2268}
2269
2270function afficheMessageInfosObligatoires(){
2271    (function($){
2272        var msg = $('#div_profilInfosPersos .div_msgInfosObligatoires').text();
2273        afficheMessageRetour_cptGDF({code: 'KO', msg: msg});
2274    })(jQuery);
2275}
2276
2277function cptGdf_initInputChampsVides(){
2278    (function($){
2279        $('input.inpt_profilChampVide').unbind('blur');
2280        $('input.inpt_profilChampVide').bind('blur', function(){
2281            if ($(this).val()!='') {
2282                $(this).removeClass('inpt_profilChampVide');
2283            }
2284        })
2285    })(jQuery);
2286}
2287
2288function effaceLiveValidation(){
2289    (function($){
2290        $('span.LV_validation_message').hide();
2291    })(jQuery);
2292}
2293
2294function cptGDF_chargeListeResasAnnulees(){
2295    (function($){
2296        var nbResasAffichees = $('.compteGDF_uneResa_annulees').length;
2297        $.ajax({
2298            type: 'POST',
2299            url: urlCptClient,
2300            data: {action: 'getHTML_listeDossiersAnnules', offset: nbResasAffichees},
2301            beforeSend: function(){
2302                afficheLoaderGlobal()
2303            },
2304            success: function(result){
2305                var tabRetour = JSON.parse(result);
2306                $('#div_chargeResaAnnulees').before(tabRetour.html);
2307                if (tabRetour.toutEstAffiche) {
2308                    $('#div_chargeResaAnnulees').hide();
2309                }
2310                effaceLoaderGlobal();
2311            }
2312        });
2313    })(jQuery);
2314}
2315
2316function cptGDF_chargeListeResasEnCours(){
2317    (function($){
2318        var nbResasAffichees = $('.compteGDF_uneResa_enCours').length;
2319        $.ajax({
2320            type: 'POST',
2321            url: urlCptClient,
2322            data: {action: 'getHTML_listeResasEnCours', offset: nbResasAffichees},
2323            beforeSend: function(){
2324                afficheLoaderGlobal()
2325            },
2326            success: function(result){
2327                var tabRetour = JSON.parse(result);
2328                $('#div_plusDeResaEnCours').before(tabRetour.html);
2329                if (tabRetour.toutEstAffiche) {
2330                    $('#div_plusDeResaEnCours').hide();
2331                }
2332                cptGDF_initActionsDetailResas();
2333                effaceLoaderGlobal();
2334            }
2335        });
2336    })(jQuery);
2337}
2338
2339function cptGDF_chargeListeResasPassees(){
2340    (function($){
2341        var nbResasAffichees = $('.compteGDF_uneResa_passees').length;
2342        $.ajax({
2343            type: 'POST',
2344            url: urlCptClient,
2345            data: {action: 'getHTML_listeResasPassees', offset: nbResasAffichees},
2346            beforeSend: function(){
2347                afficheLoaderGlobal()
2348            },
2349            success: function(result){
2350                var tabRetour = JSON.parse(result);
2351                $('#div_plusDeResaPassees').before(tabRetour.html);
2352                if (tabRetour.toutEstAffiche) {
2353                    $('#div_plusDeResaPassees').hide();
2354                }
2355                cptGDF_initActionsDetailResas();
2356                effaceLoaderGlobal();
2357            }
2358        });
2359    })(jQuery);
2360}
2361
2362function afficherIframeYousign(){
2363    (function ($) {
2364        var tel = $("input[type='radio'][name='choixTel']:checked").val();
2365        if (tel == '0') {
2366            tel = $('#autreTel').val();
2367            if (tel == "") {
2368                return;
2369            }
2370        }
2371        var element = $('#validerTelYousign');
2372        var exercice = element.attr('data-exercice');
2373        var numero_resa = element.attr('data-numeroresa');
2374        var instance = element.attr('data-instance');
2375        var type_resa = element.attr('data-typeresa');
2376        
2377        $('#choixTelYousign').hide();
2378        $.ajax({
2379            type: 'POST',
2380            url: urlCptClient,
2381            data: {action: 'initYousign', exercice: exercice, numResa: numero_resa, instance: instance, typeresa: type_resa, tel: tel},
2382            beforeSend: function () {
2383                afficheLoaderGlobal();
2384            },
2385            success: function (retour) {
2386                retour = JSON.parse(retour);
2387                effaceLoaderGlobal();
2388                if (retour === 'KO' || retour === "" || retour === undefined || retour.code === 'KO') {
2389                    if (isNullOrUndefinedOrEmpty(retour.msg)) {
2390                        var msgErreur = "Il y a eu une erreur lors de la génération du contrat de votre réservation n°" + numero_resa + ". Veuillez essayer plus tard.";
2391                    }else{
2392                        var msgErreur = retour.msg;
2393                    }
2394                    $('#txtPopUpCM').html(msgErreur);
2395                    $('#titlePopUpCM').html("Il y a eu une erreur lors de la génération du contrat");
2396                    $('#popUpError').show();
2397                } else {
2398                    initIframeYousign(retour.srcIframe, retour.isSandbox);
2399                }
2400            }
2401        });
2402
2403    })(jQuery);
2404}
2405
2406function initIframeYousign(srcIframe, isSandbox) {
2407    (function($){
2408        $('#popUpError').hide();
2409        $('#div_signatureYousign').hide();
2410        $('#divHeaderCompteClient').hide();
2411        new Yousign({
2412            signatureLink: decodeURIComponent(srcIframe),
2413            iframeContainerId: 'yousign-iframe-container',
2414            isSandbox: isSandbox,
2415            iFrameAttributes: {
2416                referrerPolicy: 'origin-when-cross-origin'
2417            },
2418        });
2419    })(jQuery);
2420}
2421
2422function initFormTelYousign(){
2423    (function($){
2424        $('#formChoixTel #autre').attr('checked','checked');
2425    })(jQuery);
2426}
2427
2428function retourValidationEnregistreCartePourCaution_centralPay(){
2429    location.reload();
2430}
2431
2432function initCautionCompteClient(){
2433    (function($){
2434        $('#div_detailRefusPriseCaution').dialog({
2435            modal: true,
2436            autoOpen: false,
2437            width: 'auto',
2438            height: 'auto'
2439        });
2440        $('#sp_refusePriseCaution').unbind('click');
2441        $('#sp_refusePriseCaution').bind('click', function(){
2442            $('#div_detailRefusPriseCaution').dialog('open');
2443        });
2444        $('#sp_valideRefusPriseCaution').unbind('click');
2445        $('#sp_valideRefusPriseCaution').bind('click', function(){
2446            var commentaireClient = $('#textarea_commClient').val();
2447            if (commentaireClient.length>0) {
2448                refusePriseCaution(commentaireClient);
2449            } else {
2450                $('#div_msgCommObligatoire').show();
2451            }
2452        });
2453        
2454        $('#div_acceptePriseCaution').dialog({
2455            modal: true,
2456            autoOpen: false,
2457            width: 'auto',
2458            height: 'auto'
2459        });
2460        $('#sp_acceptePriseCaution').unbind('click');
2461        $('#sp_acceptePriseCaution').bind('click', function(){
2462            $('#div_acceptePriseCaution').dialog('open');
2463        });
2464        $('#sp_valideAcceptePriseCaution').unbind('click');
2465        $('#sp_valideAcceptePriseCaution').bind('click', function(){
2466            acceptePriseCaution();
2467        });
2468    })(jQuery);
2469}
2470
2471function refusePriseCaution(commentaireClient){
2472    (function($){
2473        var idObjet = $('#div_priseCaution').attr('data-idobjet');
2474        var tabInfosIdObjetPayable = getTabInfosIdObjetPayable(idObjet);
2475        $.ajax({
2476            type: 'POST',
2477            url: '/lib_2/ajax/passerelleBureauLocal.php',
2478            data: {url: 'lib_bureau/ajax/caution.php', instance: tabInfosIdObjetPayable['instance'], exercice: tabInfosIdObjetPayable['exercice'], action: 'clientRefusePriseCaution',
2479                    idObjet: idObjet, commentaireClient: commentaireClient},
2480            beforeSend: function(){
2481                afficheLoaderGlobal_site();
2482            },
2483            success: function(result){
2484                $('#div_msgRetourRefusPriseCaution').show();
2485                $('.div_infosPriseCaution').hide();
2486                console.log('refusePriseCaution result : ',result);
2487            },
2488            error: function(){
2489                $('#div_msgRetourErreurPriseCaution').show();
2490                console.log('refusePriseCaution error');
2491            },
2492            complete: function(){
2493                effaceLoaderGlobal_site();
2494                $('#div_detailRefusPriseCaution').dialog('close');
2495            }
2496        });
2497    })(jQuery);
2498}
2499function acceptePriseCaution(){
2500    (function($){
2501        var idObjet = $('#div_priseCaution').attr('data-idobjet');
2502        var tabInfosIdObjetPayable = getTabInfosIdObjetPayable(idObjet);
2503        $.ajax({
2504            type: 'POST',
2505            url: '/lib_2/ajax/passerelleBureauLocal.php',
2506            data: {url: 'lib_bureau/ajax/caution.php', instance: tabInfosIdObjetPayable['instance'], exercice: tabInfosIdObjetPayable['exercice'], action: 'clientAcceptePriseCaution', idObjet: idObjet},
2507            beforeSend: function(){
2508                afficheLoaderGlobal()
2509            },
2510            success: function(result){
2511                $('#div_msgRetourAcceptePriseCaution').show();
2512                $('.div_infosPriseCaution').hide();
2513                console.log('acceptePriseCaution result : ',result);
2514            },
2515            error: function(){
2516                $('#div_msgRetourErreurPriseCaution').show();
2517                console.log('acceptePriseCaution error');
2518            },
2519            complete: function(){
2520                effaceLoaderGlobal();
2521                $('#div_acceptePriseCaution').dialog('close');
2522            }
2523        });
2524    })(jQuery);
2525}
2526function ouvreModaleAnnulationResa(instance, numResa, exercice) {
2527    (function ($) {
2528        var html = '<div id="formMotifAnnulation">' +
2529                '<p class="titre">Annulation de la réservation n°' + numResa + ' ' + $('#dateCreation').text() + '</p>' +
2530                '<p class="titreMotif">Veullez indiquer le motif de votre annulation :</p>' +
2531                '<textarea id="motifAnnulation" class="block"></textarea>' +
2532                '<div class="btnsActionsAnnulation">' +
2533                    '<button class="btn_annulResaFermer" onclick="jQuery.fancybox.close()">Fermer</button>' +
2534                    '<button class="btn_annulResaConfirme" onclick="annuleResa(\'' + instance + '\',' + numResa + ',' + exercice + ')">Confirmer l\'annulation</button>' +                
2535                '</div>';
2536            '</div>';
2537
2538        affichePopinFancyBox(html, '',{
2539            width: 560,
2540            autoDimensions: false,
2541            autoScale: false
2542        });
2543    })(jQuery);
2544}
2545
2546function test () {
2547    return '<span>Annuler le dossier</span>';
2548}
2549
2550function annuleResa(instance,numResa,exercice) {
2551    (function ($) {
2552        var motif = $('#motifAnnulation').val();
2553        $.ajax({
2554            type: 'POST',
2555            url: urlCptClient,
2556            data: {
2557                action:'annuleDossierGp',
2558                numeroDossier:numResa,
2559                exercice:exercice,
2560                instance:instance,
2561                motif:motif
2562            },
2563            beforeSend: function (xhr) {
2564                afficheLoaderGlobal_site();
2565            },
2566            complete: function (jqXHR, textStatus) {
2567
2568            },
2569            success: function (data) {
2570                //rafraichir la resa
2571                if (data.code === 'KO') {
2572                    effaceLoaderGlobal_site();
2573                    return false;
2574                }
2575                refreshPage();
2576            }
2577        });
2578    })(jQuery);
2579}
2580
2581function initBtnPaiementCbLdCptCli(){
2582    (function ($) {
2583        $('#div_btnPaiementCbLdCptCli > button').unbind('click');
2584        $('#div_btnPaiementCbLdCptCli > button').bind('click', function(){
2585            $('#detailResaCptCliModifinfosPaiement').show();
2586            $('#tr_recapPrixFd').show();
2587            $('#div_btnPaiementCbLdCptCli').hide();
2588
2589            // On affiche les bons prix dans le recap
2590            if ($('#tr_recapPrixTotalAvecFraisCbLd').length>0) {
2591                $('#tr_recapPrixTotal').hide();
2592                $('#tr_recapPrixTotalAvecFraisCbLd').show();
2593            }
2594            if ($('#tr_recapFraisCbLd').length>0) {
2595                $('#tr_recapFraisCbLd').show();
2596            }
2597            if ($('#td_recapPrixMontantAPayerAvecFraisCbLd').length>0) {
2598                $('#td_recapPrixMontantAPayer').hide();
2599                $('#td_recapPrixMontantAPayerAvecFraisCbLd').show();
2600            }
2601        });
2602
2603        if ($('#div_btnPaiementCbLdCptCli').data('retour3ds') === 'O') {
2604            $('#div_btnPaiementCbLdCptCli > button').click();
2605        }
2606    })(jQuery);
2607}
2608
2609function ouvreModaleDemandeAnnulationResa(numResa){
2610    (function ($) {
2611        affichePopinFancyBox($('.div_modalDemandeAnnulation[data-dossier="'+numResa+'"]').html(), 'modaleDemandeAnnulation', {
2612            width: 560,
2613            autoDimensions: false,
2614            autoScale: false
2615        });
2616        return false;
2617    })(jQuery);
2618}
2619
2620function ouvreModalRemboursementAvoir() {
2621    (function ($) {
2622        $('#div_modalRemboursementAvoir').dialog({
2623            modal: true,
2624            autoOpen: false,
2625            width: '500',
2626            height: 'auto'
2627        });
2628        $('#div_modalRemboursementAvoir').dialog('open');
2629        if ($('.div_saisieIbanRemboursementAvoir').length > 0) {
2630            $('.div_saisieIbanRemboursementAvoir').iban();
2631        }
2632        
2633//        $('#div_modalRemboursementAvoir input[name="iban"]').blur(function () {
2634//            $('#div_modalRemboursementAvoir input[name="iban"]').val($('#div_modalRemboursementAvoir input[name="iban"]').val().replace(/ /g, '').toUpperCase());
2635//        });
2636    })(jQuery);
2637}
2638
2639function initRemboursementAvoirCompteClient(){
2640    (function($){
2641        $('#btn_demandeRbstAvoir').unbind('click');
2642        $('#btn_demandeRbstAvoir').bind('click', function(){
2643            $('#div_rbstAvoirCptCliOk').hide();
2644            $('#div_rbstAvoirCptCliKo').hide();
2645            if ($('#select_modeRbstAvoir').val() === 'V') {
2646                // virement
2647                demandeRemboursementAvoirVirement();
2648                return;
2649            }
2650        });
2651    })(jQuery);
2652}
2653
2654function demandeRemboursementAvoirVirement() {
2655    (function ($) {
2656        if ($('.div_saisieIbanRemboursementAvoir').iban('estValide')) {
2657            demandeRemboursement({iban: $('.div_saisieIbanRemboursementAvoir').iban('getValeur')}, 'R');
2658        }
2659    })(jQuery);
2660}
2661
2662function demandeRemboursement(params, statut) {
2663    (function ($) {
2664        $('#div_modalRemboursementAvoir').dialog('close');
2665        var data = {
2666            url: 'lib_bureau/ajax/avoir.php',
2667            instance: $('#div_modalRemboursementAvoir input[name="instance"]').val(), 
2668            avoir_remboursable: {id_avoir: $('#div_modalRemboursementAvoir input[name="id_avoir"]').val(), statut: statut},  
2669            action: 'demandeRemboursementAvoir'
2670        };
2671        $.ajax({
2672            url: '/lib_2/ajax/passerelleBureauLocal.php',
2673            data: $.extend(data, params),
2674            beforeSend: function () {
2675                afficheLoaderGlobal_site();
2676            },
2677            success: function () {
2678                $('#div_rbstAvoirCptCliOk').show();
2679                $('#div_rbstAvoirCptCli').hide();
2680            },
2681            error: function (erreur) {
2682                if (erreur && erreur.responseJSON) {
2683                    if (erreur.responseJSON.code === 'ERR_IBAN_INVALIDE') {
2684                        $('#div_rbstAvoirCptCliKo').show();
2685                        $('#p_rbstAvoirCptCliKo_ibanInvalide').show();
2686                        return;
2687                    }
2688                }
2689                $('#p_rbstAvoirCptCliKo_ibanInvalide').html($('#p_rbstAvoirCptCliKo_ibanInvalide')).show();
2690            },
2691            complete: function () {
2692                effaceLoaderGlobal_site();
2693            }
2694        });
2695    })(jQuery);
2696}
2697
2698function ouvreModaleAnnulationRemboursementResa(identResa){
2699    (function ($) {
2700        $('.div_modalErreurRemboursementCB[data-dossier="'+identResa+'"]').dialog({
2701            modal: true,
2702            autoOpen: false,
2703            width: 'auto',
2704            height: 'auto',
2705            dialogClass: 'modalErrRemboursementCb',
2706            draggable: false
2707        });
2708        
2709        $('.div_modalAnnulation[data-dossier="'+identResa+'"]').dialog({
2710            modal: true,
2711            autoOpen: false,
2712            width: 'auto',
2713            height: 'auto',
2714            dialogClass: 'modalAnnulationRemboursementResa',
2715            draggable: false
2716        });
2717        $('.div_modalAnnulation[data-dossier="'+identResa+'"] .div_actionAnnulation').show();
2718        $('.div_modalAnnulation[data-dossier="'+identResa+'"] .divMsgErr').hide();
2719        $('.div_modalAnnulation[data-dossier="'+identResa+'"]').dialog('open');
2720        
2721        initGestionModesRemboursements();
2722    })(jQuery);
2723}
2724
2725function initGestionModesRemboursements() {
2726    (function ($) {
2727        if ($('.div_saisieIbanRemboursement').length > 0) {
2728            $('.div_saisieIbanRemboursement').iban();
2729        }
2730        
2731        $('input[name="modeRemboursement"]').change(function(){
2732            $('.div_saisieComplementaireModeRemboursement').hide();
2733            if ($(this).val() === 'VIR') {
2734                $('.div_saisieIbanRemboursement').show();
2735            }
2736            if ($(this).val() === 'CBR') {
2737                $('.div_saisieRemboursementCb').show();
2738            }
2739        });
2740    })(jQuery);
2741}
2742
2743function confirmeAnnulationResa(identResa) {
2744    (function ($) {
2745        
2746        if (verifSaisieAnnulationResa() === false) {
2747            return;
2748        }
2749        
2750        var data = {
2751            url: 'bureau_local/php/webservices/gestionReservation.php',
2752            instance: $('.div_modalAnnulation[data-dossier="'+identResa+'"] input[name="instance"]').val(),
2753            identResa: identResa, 
2754            action: 'annulationResaCptCli',
2755            motifAnnulation: $('.div_modalAnnulation[data-dossier="'+identResa+'"] select.select_motifAnnulationClient').val(),
2756        };
2757        if ($('.div_modalAnnulation[data-dossier="'+identResa+'"] select.select_typeSinistre').length > 0) {
2758            data.typeSinistre = $('.div_modalAnnulation[data-dossier="'+identResa+'"] select.select_typeSinistre').val();
2759        }
2760        if ($('.div_modalAnnulation[data-dossier="'+identResa+'"] textarea.ta_msgAnnulationClient').val() !== "") {
2761            data.commentaire = $('.div_modalAnnulation[data-dossier="'+identResa+'"] textarea.ta_msgAnnulationClient').val();
2762        }
2763        
2764        $.ajax({
2765            url: '/lib_2/ajax/passerelleBureauLocal.php',
2766            data: data,
2767            beforeSend: function () {
2768                afficheLoaderGlobal_site();
2769            },
2770            success: function () {
2771                remboursementSuiteAnnulation(identResa);
2772            },
2773            error: function () {
2774                $('.div_modalAnnulation[data-dossier="'+identResa+'"] .div_actionAnnulation').hide();
2775                $('.div_modalAnnulation[data-dossier="'+identResa+'"] .div_msgErreurAnnulation').show();
2776                effaceLoaderGlobal_site();
2777            }
2778        });
2779    })(jQuery);
2780}
2781
2782function verifSaisieAnnulationResa() {
2783    jQuery('.divMsgErr').hide();
2784    
2785    if (jQuery('select.select_motifAnnulationClient').val() === '') {
2786        jQuery('.div_msgSelectMotifAnnulation').show();
2787        return false;
2788    }
2789    // Mode remboursement sélectionné
2790    if (jQuery('input[name="modeRemboursement"]').length > 0 && !jQuery('input[name="modeRemboursement"]:checked').val()) {
2791        jQuery('.div_msgSelectModeRemboursement').show();
2792        return false;
2793    }
2794    
2795    // CGV et CGA cochés
2796    if (jQuery('#inpt_valideCgv').attr('checked') !== 'checked') {
2797        jQuery('.div_msgCheckboxCgv').show();
2798        return false;
2799    }
2800    if (jQuery('#inpt_valideCga').length > 0 && jQuery('#inpt_valideCga').attr('checked') !== 'checked') {
2801        jQuery('.div_msgCheckboxCga').show();
2802        return false;
2803    }
2804    
2805    // IBAN renseigné
2806    if (jQuery('.div_saisieIbanRemboursement').length > 0 && jQuery('.div_saisieIbanRemboursement').is(':visible') && !jQuery('.div_saisieIbanRemboursement').iban('estValide')) {
2807        jQuery('.div_msgSaisieIban').show();
2808        return false;
2809    }
2810    
2811    // CB sélectionnée
2812    if (jQuery('.div_saisieRemboursementCb').length > 0 && jQuery('.div_saisieRemboursementCb').is(':visible') 
2813            && !jQuery('input[name="inptSelectCarteARembourser"]:checked').val()) {
2814        jQuery('.div_msgSelectCb').show();
2815        return false;
2816    }
2817
2818    // Motif annulation pour assurance
2819    if (jQuery('.select_typeSinistre').length > 0 && jQuery('.select_typeSinistre').val().length === 0) {
2820        jQuery('.div_msgSelectMotifAnnulation').show();
2821        return false;
2822    }
2823    
2824    return true;
2825    
2826}
2827
2828function remboursementSuiteAnnulation(identResa) {
2829    (function ($) {
2830        var modeRemboursement = $('input[name="modeRemboursement"]:checked').val();
2831        var tabIdentResa = identResa.split('_');
2832        var data = {
2833            url: 'bureau_local/php/webservices/gestionReservation.php',
2834            instance: tabIdentResa[0],
2835            exercice: tabIdentResa[2],
2836            identResa: identResa,
2837            action: 'gereRemboursementAnnulationCptCli',
2838            modeRemboursement: modeRemboursement
2839        };
2840        
2841        if (modeRemboursement === 'VIR') {
2842            data.iban = $('.div_saisieIbanRemboursement').iban('getValeur');
2843        } else if (modeRemboursement === 'CBR') {
2844            data.transactionId = jQuery('input[name="inptSelectCarteARembourser"]:checked').val();
2845            data.modeCentralPay = jQuery('input[name="inptSelectCarteARembourser"]:checked').data('mode');
2846        }
2847        
2848        $.ajax({
2849            url: '/lib_2/ajax/passerelleBureauLocal.php',
2850            data: data,
2851            beforeSend: function () {
2852                afficheLoaderGlobal_site();
2853            },
2854            success: function () {
2855                refreshPage();
2856            },
2857            error: function () {
2858                effaceLoaderGlobal_site();
2859                $('.div_modalAnnulation[data-dossier="'+identResa+'"]').dialog('close');
2860                $('.div_modalErreurRemboursementCB[data-dossier="'+identResa+'"]').dialog('open');
2861            }
2862        });
2863    })(jQuery);
2864}
2865
2866(function ($) {
2867    $.fn.iban = function (methodOrOptions) {
2868        var methods = {
2869            init: function (params) {
2870                this.data('iban', new Iban(this, params));
2871                return this;
2872            },
2873            estValide: function() {
2874                return this.data('iban').estValide();
2875            },
2876            getValeur: function() {
2877                return this.data('iban').getValeur();
2878            }
2879        };
2880        
2881        if (methods[methodOrOptions]) {
2882            return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
2883        } else if (typeof methodOrOptions === "object" || !methodOrOptions) {
2884            return methods.init.apply(this, arguments);
2885        } else {
2886            $.error("Method " + methodOrOptions + " does not exist");
2887        }
2888        
2889        function Iban(elem, params) {
2890            $.getScript('/api_externe/iban.js_0.0.7/iban.js');
2891            
2892            this.init = function() {
2893                this.elem = jQuery(elem);
2894                this.initParams(params);
2895
2896                this.inputVal = this.elem.find('input[name="iban"]');
2897                this.inputVal.focus(function() {
2898                    this.spSaisieIbanKo.hide();
2899                }.bind(this));
2900                this.inputVal.blur(function() {
2901                    this.inputVal.val(this.inputVal.val().replace(/ /g, '').toUpperCase());
2902                }.bind(this));
2903                
2904                this.inputFile = this.elem.find('input[name="fichierIban"]');
2905                this.inputFile.change(function() {
2906                    this.uploadFile();
2907                }.bind(this));
2908                
2909                this.spSaisieIbanKo = this.elem.find('.sp_msgSaisieIbanKo');
2910                this.spSaisieFichierIbanKo = this.elem.find('.sp_msgSaisieFichierIbanKo');
2911                this.spSaisieFichierIbanOk = this.elem.find('.sp_msgSaisieFichierIbanOk');
2912                this.spSaisieFichierIbanObligatoire = this.elem.find('.sp_msgSaisieFichierIbanObligatoire');
2913            };
2914            
2915            this.initParams = function(params) {
2916                this.ibanUploaded = false;
2917                this.setFileRequired(params);
2918            };
2919            this.setFileRequired = function() {
2920                this.fileRequired = false;
2921                if (params && params.fileRequired) {
2922                    this.fileRequired = true;
2923                } else if (this.elem.data('filerequired')) {
2924                    this.fileRequired = true;
2925                }
2926            };
2927            this.estValide = function() {
2928                if (IBAN.isValid(this.getValeur()) && (!this.fileRequired || this.ibanUploaded)) {
2929                    return true;
2930                }
2931                if (this.fileRequired && !this.ibanUploaded) {
2932                    this.spSaisieFichierIbanObligatoire.show();
2933                }
2934                this.spSaisieIbanKo.show();
2935                return false;
2936            };
2937            this.getValeur = function() {
2938                return this.inputVal.val();
2939            };
2940            this.uploadFile = function () {
2941                this.spSaisieFichierIbanObligatoire.hide();
2942                this.spSaisieFichierIbanKo.hide();
2943                this.spSaisieFichierIbanOk.hide();
2944                
2945                var formData = new FormData();
2946                formData.append('action', 'uploadIbanClientToPcs');
2947                formData.append('ibanFile', this.inputFile.prop('files')[0]);
2948
2949                $.ajax({
2950                    url: '/lib_2/ajax/gereCptClient.php',
2951                    type: 'POST',
2952                    processData: false,
2953                    contentType: false,
2954                    dataType: 'json',
2955                    data: formData,
2956                    success: function () {
2957                        this.ibanUploaded = true;
2958                        this.spSaisieFichierIbanOk.show();
2959                    }.bind(this),
2960                    error: function() {
2961                        this.spSaisieFichierIbanKo.show();
2962                    }
2963                });
2964            };
2965            
2966            this.init();
2967        }
2968    };
2969})(jQuery);
2970
2971function initPopinConnexionCptClient(vars, fonctionCallback, argsCallback) {
2972    (function($) {
2973        $('#inpt_loginCptClient').unbind('click');
2974        $('#inpt_loginCptClient').bind('click', function() {
2975            if (!valideFormConnexionCptClient()) {
2976                return;
2977            }
2978            $('#div_motDePasseOublieCptClient').hide();
2979            var data = {
2980                action: 'loginAjax',
2981                email: $('#input_email').val(),
2982                pass: $('#input_motPasse').val()
2983            };
2984            jQuery.ajax({
2985                url: '/lib_2/ajax/gereCptClient.php',
2986                data: Object.assign(data, vars),
2987                beforeSend: function() {
2988                    afficheLoaderGlobal_site();
2989                },
2990                success: function(result) {
2991                    effaceLoaderGlobal_site();
2992                    if (result === 'OK') {
2993                        window[fonctionCallback].apply(null, argsCallback);
2994                    } else if (result === 'KO_PASS') {
2995                        // Afficher gestion mdp
2996                        $('#div_motDePasseOublieCptClient').show();
2997                    } else {
2998                        // Afficher form création compte
2999                        $('.identificationCptClient').hide();
3000                        $('#p_cptCliIdentIntroConnexion').hide();
3001                        $('#p_cptCliIdentIntroCreation').show();
3002                        $('.creationCptClient').show();
3003                    }
3004                }
3005            });
3006        });
3007        
3008        $('#inpt_creationCptClient').unbind('click');
3009        $('#inpt_creationCptClient').bind('click', function() {
3010            if (!valideFormConnexionCptClient()) {
3011                return;
3012            }
3013            var data = {
3014                action: 'creationCptClient',
3015                e_mail: $('#input_email').val(),
3016                mdp: $('#input_motPasse').val(),
3017                nom: $('#input_nomClient').val(),
3018                prenom: $('#input_prenomClient').val(),
3019                tel1: $('#input_telMobile').val()
3020            };
3021            jQuery.ajax({
3022                url: '/lib_2/ajax/gereCptClient.php',
3023                data: data,
3024                beforeSend: function() {
3025                    afficheLoaderGlobal_site();
3026                },
3027                success: function(result) {
3028                    effaceLoaderGlobal_site();
3029                    console.log('creationCptClient success result : ',result);
3030                    if (result === 'OK') {
3031                        window[fonctionCallback].apply(null, argsCallback);
3032                    }
3033                }
3034            });
3035        });
3036    })(jQuery);
3037}
3038
3039function valideFormConnexionCptClient() {
3040    var emailValidation = new LiveValidation('input_email', {validMessage: ' '});
3041    addValidateOnLiveValidationEmail(emailValidation, undefined, true, ' ');
3042
3043    jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErr').hide();
3044    var champNonRempli = false;
3045    jQuery('#div_identificationCptClientSaisie input:visible').each(function() {
3046        if (jQuery(this).val() === '') {
3047            champNonRempli = true;
3048        }
3049    });
3050    if (champNonRempli) {
3051        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrChamps').show();
3052        return false;
3053    }
3054    if (!emailValidation.validate()) {
3055        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrMailIncorrect').show();
3056        return false;
3057    }
3058    
3059    if (!jQuery('#div_creationCptClientSaisie').is(':visible')) {
3060        return true;
3061    }
3062    
3063    champNonRempli = false;
3064    jQuery('#div_creationCptClientSaisie input:visible').each(function() {
3065        if (jQuery(this).val() === '') {
3066            champNonRempli = true;
3067        }
3068    });
3069    
3070    if (champNonRempli) {
3071        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrChamps').show();
3072        return false;
3073    }
3074    
3075    var emailConfirmation = new LiveValidation('input_confirmEmail', {validMessage: ' '});
3076    emailConfirmation.add(Validate.Confirmation, {match: 'input_email', failureMessage: ' '});
3077    if (!emailConfirmation.validate()) {
3078        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrConfirmMailIncorrect').show();
3079        return false;
3080    }
3081
3082    var passwordValidation = new LiveValidation('input_motPasse', {validMessage: ' '});
3083    passwordValidation.add(Validate.Format, {pattern: /^(?=.*[0-9]+.*)(?=.*[A-Z]+.*)(?=.*[a-z]+.*)[0-9a-zA-Z-_]{8,}$/, failureMessage: ' '});
3084    if (!passwordValidation.validate()) {
3085        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrMdpNonConforme').show();
3086        return false;
3087    }
3088
3089    var passwordConfirmation = new LiveValidation('input_confirmPass', {validMessage: ' '});
3090    passwordConfirmation.add(Validate.Confirmation, {match: 'input_motPasse', failureMessage: ' '});
3091    if (!passwordConfirmation.validate()) {
3092        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrConfirmPassIncorrect').show();
3093        return false;
3094    }
3095
3096    var telMobileValidation = new LiveValidation('input_telMobile', {validMessage: ' ',onlyOnBlur: true});
3097    telMobileValidation.add(Validate.Format, {pattern: /^0[6|7]([\-\s]?[0-9]+)+$/, failureMessage: ' '});
3098    
3099    if (!telMobileValidation.validate()) {
3100        jQuery('#div_msgErreursConnexionCptClient, #div_msgErreursConnexionCptClient .msgErrTelMobileNonConforme').show();
3101        return false;
3102    }
3103    
3104    return true;
3105}
3106
3107function initFormContactPropCptCli(dateDeb, dureeSejour) {
3108    (function($){
3109        $('.div_msgRetourEnvoiMessageGestionnaire').hide();
3110        initDatepickersLies('inpt_formPropmailDateDeb', 'inpt_formPropmailDateFin', {'dateDeb': dateDeb, 'dureeSejour': dureeSejour});
3111        
3112        $('#aValidationForm').unbind('click');
3113        $('#aValidationForm').bind('click', function() {
3114            if ($('#inpt_formPropmailDateDeb').val() === '' || $('#inpt_formPropmailDateFin').val() === '' 
3115                || $('#select_formPropmailAdultes').val() === '' || $('#textarea_formPropMessage').val() === '') {
3116                $('.div_msgRetourEnvoiMessageGestionnaire.incomplet').show();
3117                return;
3118            }
3119            
3120            var data = {
3121                action: 'envoieMessageAuPropByIdent',
3122                ident : $('#inpt_ident').val(),
3123                deb_loc: $('#inpt_formPropmailDateDeb').val(),
3124                fin_loc: $('#inpt_formPropmailDateFin').val(),
3125                nb_adultes: $('#select_formPropmailAdultes').val(),
3126                nb_enfants: $('#select_formPropmailEnfants').val() || 0,
3127                message: $('#textarea_formPropMessage').val()
3128            };
3129            jQuery.ajax({
3130                url: '/lib_2/ajax/gereCptClient.php',
3131                data: data,
3132                beforeSend: function() {
3133                    $('.div_msgRetourEnvoiMessageGestionnaire').hide();
3134                    afficheLoaderGlobal_site();
3135                },
3136                success: function(result) {
3137                    effaceLoaderGlobal_site();
3138                    console.log('initFormContactPropCptCli success result : ',result);
3139                    $('#div_formContactProp').hide();
3140                    $('#div_validation').hide();
3141                    $('.div_msgRetourEnvoiMessageGestionnaire.ok').show();
3142                },
3143                error: function() {
3144                    effaceLoaderGlobal_site();
3145                    $('.div_msgRetourEnvoiMessageGestionnaire.ko').show();
3146                }
3147            });
3148        });
3149    })(jQuery);
3150}
3151
3152function initMessagerieCptCli() {
3153    initConversationCptCli();
3154    (function($) {
3155        $('.divEchangeClientProp').unbind('click');
3156        $('.divEchangeClientProp').bind('click', function() {
3157            var data = {
3158                action : 'getHtmlDetailEchangeProp',
3159                instance : $(this).data('instance'),
3160                id_conversation : $(this).data('idconversation')
3161            };
3162            jQuery.ajax({
3163                url: '/lib_2/ajax/gereCptClient.php',
3164                data: data,
3165                dataType: 'html',
3166                beforeSend: function() {
3167                    afficheLoaderGlobal_site();
3168                },
3169                success: function(result) {
3170                    effaceLoaderGlobal_site();
3171                    $('#divDetailEchange').replaceWith(result);
3172                    $('.divEchangeClientProp').removeClass('open');
3173                    $(this).addClass('open');
3174                    initConversationCptCli();
3175                    majDateConsultationEchange();
3176                }.bind(this)
3177            });
3178        });
3179    })(jQuery);
3180}
3181
3182function initConversationCptCli() {
3183    (function($) {
3184        $('#divBtnValidationMessagePourProp').off('click');
3185        $('#divBtnValidationMessagePourProp').on('click', function() {
3186            if ($('#textareaMessagePourProp').length === 0 || $('#textareaMessagePourProp').val().length === 0) {
3187                return;
3188            }
3189            var data = {
3190                action : 'clientEnvoieMessageConversation',
3191                instance : $('#divDetailEchange').data('instance'),
3192                id_conversation : $('#divDetailEchange').data('idconversation'),
3193                numero_client : $('#divDetailEchange').data('numeroclient'),
3194                message : $('#textareaMessagePourProp').val()
3195            };
3196            jQuery.ajax({
3197                url: '/lib_2/ajax/gereCptClient.php',
3198                data: data,
3199                dataType: 'json',
3200                beforeSend: function() {
3201                    afficheLoaderGlobal_site();
3202                },
3203                success: function(result) {
3204                    effaceLoaderGlobal_site();
3205                    console.log('envoieMessageAuProp success result : ',result);
3206                    $('#textareaMessagePourProp').val('');
3207                    $('#divListeMessages').append(getHtmlDetailMessage(result));
3208                    // On scroll pour voir le dernier message ajouté
3209                    document.getElementById('divListeMessages').scrollTop = document.getElementById('divListeMessages').scrollHeight;
3210                    initConversationCptCli();
3211                }
3212            });
3213        });
3214        
3215        $('#divChargerPlus').off('click');
3216        $('#divChargerPlus').on('click', function() {
3217            var data = {
3218                action : 'getHtmlDetailEchangeProp',
3219                instance : $('#divDetailEchange').data('instance'),
3220                id_conversation : $('#divDetailEchange').data('idconversation'),
3221                offset: $('#divDetailEchange').data('offset')
3222            };
3223            var listeDeniersMessages = $('#divListeMessages').html();
3224            jQuery.ajax({
3225                url: '/lib_2/ajax/gereCptClient.php',
3226                data: data,
3227                beforeSend: function() {
3228                    afficheLoaderGlobal_site();
3229                },
3230                success: function(result) {
3231                    effaceLoaderGlobal_site();
3232                    $('#divDetailEchange').replaceWith(result);
3233                    if ($('#divListeMessages').children().length === 0) {
3234                        $('#btnChargerPlusMessages').hide();
3235                    }
3236                    $('#divListeMessages').append(listeDeniersMessages);
3237                    initConversationCptCli();
3238                }
3239            });
3240        });
3241        
3242        $('.btnEcrireAuGestionnaire').off('click');
3243        $('.btnEcrireAuGestionnaire').on('click', function(evt) {
3244            ecrireAuGestionnaire(this);
3245            evt.stopPropagation();
3246        });
3247    })(jQuery);
3248}
3249
3250function ecrireAuGestionnaire(btn) {
3251    (function($) {
3252        if ($(btn).data('idechange')) {
3253            window.open('?action=messagerie&id_echange='+$(btn).data('idechange'));
3254            return;
3255        }
3256        if ($('#divConversationResa').is(':visible')) {
3257            $('#divConversationResa').hide();
3258        } else {
3259            $('#divConversationResa').show();
3260        }
3261    })(jQuery);
3262}
3263
3264function afficheDetailEchangeProp(messages) {
3265    (function($) {
3266        $('#divListeMessages').html('');
3267        messages.forEach(function(infosMessage) {
3268            $('#divListeMessages').prepend(getHtmlDetailMessage(infosMessage));
3269        });
3270    })(jQuery);
3271}
3272
3273function getHtmlDetailMessage(infosMessage) {
3274    classesMessage = 'divMessage';
3275    var avatar = '/imgs_defaut/v5/user.png';
3276    if (infosMessage['type_emetteur'] === 'C') {
3277        classesMessage += ' client';
3278    } else {
3279        classesMessage += ' prop';
3280        avatar = '/imgs_defaut/v5/avatar-home.png';
3281    }
3282    var htmlMessage = '<div class="' + classesMessage + '">';
3283    htmlMessage += '<div class="divPhotoMessage"><img src="' + avatar + '" data-motcle="IMG_AVATAR_MESSAGERIE"></div>';
3284    htmlMessage += '<div class="divContentMessage">';
3285    htmlMessage += '<div class="divInfosMessage"><span class="nom">'+infosMessage['nom_prenom_emetteur']+'</span> <span class="date">' + infosMessage.date_message_fr + '</span></div>';
3286    htmlMessage += '<div class="divTexteMessage">' + infosMessage.texte_message + '</div>';
3287    htmlMessage += '</div>';
3288    htmlMessage += '</div>';
3289
3290    return htmlMessage;
3291}
3292
3293function majDateConsultationEchange() {
3294    (function($) {
3295         var data = {
3296            action : 'majDateConsultationEchange',
3297            instance : $('#divDetailEchange').data('instance'),
3298            id_conversation : $('#divDetailEchange').data('idconversation'),
3299            numero_client : $('#divDetailEchange').data('numeroclient')
3300        };
3301        // Pas de loader sur cet appel, il se fait en tâche de fond
3302        jQuery.ajax({
3303            url: '/lib_2/ajax/gereCptClient.php',
3304            data: data,
3305            success: function(result) {
3306                console.log('majDateConsultationEchange success result : ',result);
3307                $('.divEchangeClientProp[numeroproprio="'+$('#divDetailEchange').data('numeroproprio')+'"][numeroclient="'+$('#divDetailEchange').data('numeroclient')+'"]').removeClass('bold');
3308            }
3309        });
3310    })(jQuery);
3311}
3312
3313function envoieMessageAuPropByResa(idObjetPayable) {
3314    (function($){
3315        if ($('#textareaMessagePourProp').length === 0 || $('#textareaMessagePourProp').val().length === 0) {
3316            return;
3317        }
3318        var data = {
3319            action: 'envoieMessageAuPropByResa',
3320            id_objet_payable : idObjetPayable,
3321            message: $('#textareaMessagePourProp').val()
3322        };
3323        jQuery.ajax({
3324            url: '/lib_2/ajax/gereCptClient.php',
3325            data: data,
3326            dataType: 'json',
3327            beforeSend: function() {
3328                afficheLoaderGlobal_site();
3329            },
3330            success: function(result) {
3331                effaceLoaderGlobal_site();
3332                let instance = idObjetPayable.split('_')[0];
3333                console.log('envoieMessageAuPropByResa success result : ',result);
3334                if (!result) {
3335                    effaceLoaderGlobal_site();
3336                    $('#divConversationResa .div_msgRetourEnvoiMessageGestionnaire.ko').show();
3337                    return;
3338                }
3339                $('.btnEcrireAuGestionnaire').data('idechange', instance + '_' + result.id_conversation);
3340                $('#divNouveauMessage').hide();
3341                $('#divConversationResa .div_msgRetourEnvoiMessageGestionnaire.ok').show();
3342            },
3343            error: function() {
3344                effaceLoaderGlobal_site();
3345                $('#divConversationResa .div_msgRetourEnvoiMessageGestionnaire.ko').show();
3346            }
3347        });
3348    })(jQuery);
3349}
3350
3351function ouvreFichierMessagerie(fichier) {
3352    let url = '/prop_cache/' + fichier;
3353    if (estMobile()) {
3354        window.open(url, '_system');
3355        return;
3356    }
3357    window.open(url, '_blank');
3358}
3359
3360function desannulerResa() {
3361    (function ($) {
3362        var data = {
3363            action: 'desannulerResa',
3364            instance: $('#desannulerResa').data('instance'),
3365            exercice: $('#desannulerResa').data('exercice'),
3366            numResa: $('#desannulerResa').data('num-resa'),
3367            typeResa: $('#desannulerResa').data('type-resa')
3368        };
3369        $.ajax({
3370            type: 'POST',
3371            data: data,
3372            url: '/lib_2/ajax/gereCptClient.php',
3373            success: function () {
3374                refreshPage();
3375            }
3376        });
3377    })(jQuery);
3378}
3379
3380function confirmationSaisieOccupants() {
3381    (function ($) {
3382        $('#divMessageConfirmationSaisieOccupants').fadeIn().delay(5000).fadeOut();
3383    })(jQuery);
3384}
3385
3386function initConnexionCptCliVacancesConnect() {
3387    (function($) {
3388        if (sessionStorage.getItem('initConnexionCptCliVC') === "true") {
3389            return;
3390        }
3391        sessionStorage.setItem('initConnexionCptCliVC', true);
3392        $('#div_popinCreationCompteVacancesConnect').dialog({
3393            buttons:{
3394                'Oui': function() {
3395                    $(this).dialog('close');
3396                    afficheLoaderGlobal_site();
3397                    var data = {
3398                        action: 'transformeCompteClientVacancesConnect'
3399                    };
3400                    $.ajax({
3401                        type: 'POST',
3402                        data: data,
3403                        dataType: 'json',
3404                        url: '/lib_2/ajax/gereCptClient.php',
3405                        success: function (retour) {
3406                            if (retour === 'KO') {
3407                                // Message erreur
3408                            }
3409                            autoLoginVacancesConnect(retour.mail, retour.pass);
3410                        }
3411                    });
3412                },
3413                'Non' : function() {
3414                    $(this).dialog('close');
3415                }
3416            },
3417            modal: true,
3418            autoOpen: true,
3419            width: 'auto',
3420            height: 'auto'
3421        });
3422    })(jQuery);
3423}
3424
3425function callbackVacancesConnectOK_cptcli(dataClient) {
3426    (function ($) {
3427        var data = {
3428            action: 'connexionClientVacancesConnect',
3429            dataClient: dataClient
3430        };
3431        $.ajax({
3432            type: 'POST',
3433            data: data,
3434            url: '/lib_2/ajax/gereCptClient.php',
3435            success: function (retour) {
3436                if (retour === 'OK') {
3437                    refreshPage();
3438                }
3439            }
3440        });
3441    })(jQuery);
3442}
3443
3444function ouvreDetailVirementCentralPay(idObjet) {
3445    (function ($) {
3446        if ($('#div_paiementPossibleVirementCentralPay .div_virementCentralPay_compte').length > 0) {
3447            return; // le html a déjà été généré, on ne fait rien de plus
3448        }
3449        
3450        $('#div_paiementPossibleVirementCentralPay .div_paiementPossibleVirementCentralPay_erreur').hide();
3451
3452        // paramètres de l'appel ajax
3453        let params = {
3454            url: 'lib_bureau/ajax/centralPay.php',
3455            action: 'initieSctTransaction',
3456            idObjet: idObjet,
3457            paramsTransaction: {
3458                'browserUserAgent': navigator.userAgent,
3459                'browserAcceptLanguage': navigator.language,
3460            }
3461        };
3462        let tabIdObjet = idObjet.split('_');
3463        params.instance = tabIdObjet[0];
3464
3465        // récupération IBAN/BIC + màj affichage
3466        $.ajax({
3467            type: 'POST',
3468            url: '/lib_2/ajax/passerelleBureauLocal.php',
3469            data: params,
3470            beforeSend: function () {
3471                afficheLoaderGlobal_site();
3472            },
3473            success: function (result) {
3474                if ($('#div_paiementPossibleVirementCentralPay .div_virementCentralPay_compte').length > 0) {
3475                    return; // le html a déjà été généré, on ne fait rien de plus
3476                }
3477                if (!result.iban || !result.bic) {
3478                    errLogJS('ouvreDetailVirementCentralPay', '!result.iban ou !result.bic on va afficher la div .div_paiementPossibleVirementCentralPay_erreur pour idobjet: ' + idObjet);
3479                    $('#div_paiementPossibleVirementCentralPay .div_paiementPossibleVirementCentralPay_erreur').show();
3480                    return;
3481                }
3482                errLogJS('ouvreDetailVirementCentralPay', 'on va afficher iban: ' + result.iban + ' et bic: ' + result.bic + ' pour idobjet: ' + idObjet);
3483                let html = '<div class="div_virementCentralPay_compte">';
3484                    html += '<div class="div_virementCentralPay_iban"><span class="gras">IBAN :</span> ' + result.iban + '</div>';
3485                    html += '<div class="div_virementCentralPay_bic"><span class="gras">BIC :</span> ' + result.bic + '</div>';
3486                html += '</div>';
3487                $('#div_paiementPossibleVirementCentralPay .div_paiementPossibleVirementCentralPay_rib').append(html);
3488            },
3489            error: function () {
3490                errLogJS('ouvreDetailVirementCentralPay', 'erreur : on va afficher la div .div_paiementPossibleVirementCentralPay_erreur pour idobjet: ' + idObjet);
3491                $('#div_paiementPossibleVirementCentralPay .div_paiementPossibleVirementCentralPay_erreur').show();
3492            },
3493            complete: function () {
3494                effaceLoaderGlobal_site();
3495            }
3496        });
3497    })(jQuery);
3498}
3499
3500function payerVirementInitie(idObjet, token = null) {
3501    (function ($) {
3502        if ($('.modal_virementInitieCentralPay .iframe_virementInitieCentralPay').attr('src')) {
3503            // PR déjà créée
3504            ouvrePageVirementInitie($('.modal_virementInitieCentralPay .iframe_virementInitieCentralPay').attr('src'), $('.modal_virementInitieCentralPay .iframe_virementInitieCentralPay').data('prBreakdownId'), idObjet);
3505            return;
3506        }
3507        const url = new URL(window.location.href);
3508        [...url.searchParams.keys()].forEach(key => {
3509            if(!['action', 'numresa', 'exe', 'typeResa', 'IDOBJET', 'idUtilisateur'].includes(key)) {
3510                url.searchParams.delete(key);
3511            }
3512        });
3513        var headers = {};
3514        if (token) {
3515            headers['Authorization'] = 'Bearer ' + token;
3516        }
3517        $.ajax({
3518            type: 'POST',
3519            url: '/lib_2/ajax/centralPay.php',
3520            headers: headers,
3521            data: {
3522                action: 'createPaymentRequestSct',
3523                idObjet: idObjet,
3524                amount: $('#div_paiementPossibleVirementInitieCentralPay .div_choixMontantPayer input[name="choixPaiementCB"]:checked')?.data('montant'),
3525                tabParamsTransaction: {
3526                    'browserUserAgent': navigator.userAgent,
3527                    //On prend la première langue qu'on trouve dan le navigateur au format ll-CC sinon on prend fr-FR
3528                    'browserAcceptLanguage': navigator.languages.find(lang => /^[a-z]{2}-[A-Z]{2}$/.test(lang)) || 'fr-FR',
3529                    'urlOrigineClient': url.toString(),
3530                }
3531            },
3532            dataType: 'json',
3533            beforeSend: function () {
3534                afficheLoaderGlobal_site();
3535            },
3536            success: function (url) {
3537                if (!url) {
3538                    $('#div_paiementPossibleVirementInitieCentralPay .div_paiementPossibleVirementCentralPay_erreur').show();
3539                    return;
3540                }
3541                $('.modal_virementInitieCentralPay .iframe_virementInitieCentralPay').attr('src', url);
3542                ouvrePageVirementInitie(url);
3543            },
3544            error: function () {
3545                $('#div_paiementPossibleVirementInitieCentralPay .div_paiementPossibleVirementCentralPay_erreur').show();
3546            },
3547            complete: function () {
3548                effaceLoaderGlobal_site();
3549            }
3550        });
3551    })(jQuery);
3552}
3553
3554function ouvrePageVirementInitie(src) {
3555    (function ($) {
3556        window.open(src, '_self');
3557        $('#div_paiementPossibleVirementInitieCentralPay .div_paiementPossibleVirementCentralPay_attente').show();
3558        $('#div_paiementPossibleVirementInitieCentralPay .btn_valideSaisieVirement_centralPay').attr('disabled', 'disabled');
3559    })(jQuery);
3560}
3561
3562function ouvreModalVirementInitie() {
3563    (function ($) {
3564        $('.modal_virementInitieCentralPay').dialog({
3565            modal: true,
3566            autoOpen: false,
3567            width: '500',
3568            height: 'auto',
3569            close: () => {
3570                if ($('.modal_virementInitieCentralPay .iframe_virementInitieCentralPay').attr('src')) {
3571                    $('#div_paiementPossibleVirementInitieCentralPay .div_paiementPossibleVirementCentralPay_attente').show();
3572                    $('#div_paiementPossibleVirementInitieCentralPay .btn_valideSaisieVirement_centralPay').attr('disabled', 'disabled');
3573                }
3574            },
3575        });
3576        $('.modal_virementInitieCentralPay').dialog('open');
3577    })(jQuery);
3578}
3579
3580function ouvreModalVirementUnique(idObjet) {
3581    (function ($) {
3582        $('.modal_virementIbanUnique').dialog({
3583            modal: true,
3584            autoOpen: false,
3585            width: '500',
3586            height: 'auto',
3587        });
3588        $('.modal_virementIbanUnique').dialog('open');
3589        ouvreDetailVirementCentralPay(idObjet);
3590    })(jQuery);
3591}
3592
3593function historiseConnexion() {
3594    (function ($) {
3595        $.ajax({
3596            url: urlCptClient,
3597            data: { action: 'historiseConnexion' },
3598        });
3599    })(jQuery);
3600}
3601
3602function historiseConsultationDossier() {
3603    (function ($) {
3604        $.ajax({
3605            url: urlCptClient,
3606            data: { action: 'historiseConsultationDossier' },
3607        });
3608    })(jQuery);
3609}
3610
3611function ouvrePopinIframeVueCptCli(route, identProd, identResa, width = 800, token = null) {
3612    (function ($) {
3613        const langues = {'ALLEMAND': 'de', 'ESPAGNOL': 'es', 'ITALIEN': 'it', 'NEERLANDAIS': 'nl', 'PORTUGAIS': 'pt', 'ANGLAIS': 'en' };
3614        let langue = jQuery('.menu.langues #current')?.attr('data-lang')?.toLowerCase() ?? 'fr';    
3615        let searchParams = new URLSearchParams(window.location.search);
3616        if (searchParams.has('LANGUEMOTCLES')) {
3617            langue = langues[searchParams.get('LANGUEMOTCLES')];
3618        }
3619        $('#iframe_vueCptCli').show().attr('src', document.location.origin + '/compte-client/' + route + '?ident=' + identProd + '&idObjet=' + identResa + '&langue=' + langue + (token ? '&token=' 
3619+ token : ''));
3620        // 2753169 : on pose le cookie pour une heure afin de ne pas réafficher la popin
3621        var date = new Date();
3622        date.setTime(date.getTime() + (24 * 60 * 60 * 1000));
3623        setCookie('CHOIX_ASSURANCE', 'O', date);
3624        $('#div_vueCptCli').dialog({
3625            modal: true,
3626            width: width,
3627            close: () => {
3628                $('#iframe_vueCptCli').hide().attr('src', 'about:blank');
3629            },
3630        });
3631    })(jQuery);
3632}
3633
3634function gereAffichagePaiementMaintenant() {
3635    (function ($) {
3636        $('.div_unPaiementPossible').show();
3637        $('.div_choixMontantPayer').show();
3638        $('.inpt_valideAutorisationDebitSolde').removeAttr('disabled');
3639        $('#div_paiementPossibleCb .formCentralPay .sp_libelleBouton').html($('#div_paiementPossibleCb .formCentralPay .p_libelleValiderEtPayer').data('libelle'));
3640        $('#div_paiementPossibleCb .formCentralPay .inpt_valideAutorisationDebitSolde').attr('data-date', $('#detailResaCptCliModifDatePaiement').data('datesolde'));
3641        if ($('input[name="choixPaiementCB"]').val() === 'solde' && $('input[name="choixPaiementCB"]').is(':checked')) {
3642            $('.inpt_valideAutorisationDebitSolde').attr('checked', false);
3643            $('#valideAutorisationDebitSolde').hide();
3644        }
3645    })(jQuery);
3646}
3647
3648function gereAffichagePaiementDebitAutoCb() {
3649    (function ($) {
3650        $('.div_unPaiementPossible').hide();
3651        $('#div_paiementPossibleCb').show();
3652        $('.div_choixMontantPayer').hide();
3653        $('.inpt_valideAutorisationDebitSolde').removeAttr('checked');
3654        $('.inpt_valideAutorisationDebitSolde').click();
3655        $('.inpt_valideAutorisationDebitSolde').attr('disabled', 'disabled');
3656        $('#div_paiementPossibleCb .formCentralPay .sp_libelleBouton').html($('#div_paiementPossibleCb .formCentralPay .p_libelleValider').data('libelle'));
3657        $('#div_paiementPossibleCb .formCentralPay .inpt_valideAutorisationDebitSolde').attr('data-date', $('#detailResaCptCliModifDatePaiement').data('dateacompte'));
3658        $('#valideAutorisationDebitSolde').show();
3659    })(jQuery);
3660}
3661
3662function ouvreModalBlocagePlanning() {
3663    (function ($) {
3664        afficheLoaderGlobal();
3665        $('.erreurFormulaireBlocagePlanning').hide();
3666        $.ajax({
3667            type: 'POST',
3668            url: urlCptClient,
3669            data: {
3670                action: 'getHTMLFormCentralPayBlocagePlanning',
3671            },
3672            success: function (result) {
3673                if (result === 'KO') {
3674                    $('.erreurFormulaireBlocagePlanning').show();
3675                    return;
3676                }
3677                $('.modal_formulairePaiementBlocagePlanning .formulaireCbBlocagePlanning').html(result);
3678                $('.modal_formulairePaiementBlocagePlanning').dialog({
3679                    modal: true,
3680                    autoOpen: false,
3681                    width: '500',
3682                    height: 500,
3683                });
3684                $('.modal_formulairePaiementBlocagePlanning').dialog('open');
3685            },
3686            complete: function() {
3687                effaceLoaderGlobal();
3688            }
3689        })
3690    })(jQuery);
3691}
3692
3693function creerVenteBlocagePlanning() {
3694    (function ($) {
3695        afficheLoaderGlobal();
3696        $.ajax({
3697            type: 'POST',
3698            url: urlCptClient,
3699            data: {
3700                action: 'creerVenteBlocagePlanning',
3701            },
3702            success: function (result) {
3703                if (!result) {
3704                    $('.formulaireCbBlocagePlanning .div_msgErreurSaisieCB').html($('.formulaireCbBlocagePlanning .div_msgErreurTransaction').html()).show();
3705                    effaceLoaderGlobal();
3706                    reactiveBoutonValidationCentralPay();
3707                    return;
3708                }
3709                let tabResult = JSON.parse(result);
3710                valideSaisieCB_centralPay(tabResult.id_objet_payable, tabResult.montant_ttc);
3711            },
3712            error: function () {
3713                $('.formulaireCbBlocagePlanning .div_msgErreurSaisieCB').html($('.formulaireCbBlocagePlanning .div_msgErreurTransaction').html()).show();
3714                effaceLoaderGlobal();
3715                reactiveBoutonValidationCentralPay();
3716            },
3717        });   
3718    })(jQuery);
3719}
3720
3721function envoyerMailDesinscriptionVacancesConnect() {
3722    (function ($) {
3723        $.ajax({
3724                type: 'POST',
3725                url: urlCptClient,
3726                data: {action: 'envoyerMailDesinscriptionVacancesConnect'},
3727                success: function(){
3728                    $('.modal_confirmationDesinscriptionCompteVC').dialog({
3729                        modal: true,
3730                        autoOpen: false,
3731                        width: '250',
3732                        height: 100,
3733                    });
3734                    $('.modal_confirmationDesinscriptionCompteVC').dialog('open');
3735                },
3736                error: function () {
3737                    $('.modal_erreurDesinscriptionCompteVC').dialog({
3738                        modal: true,
3739                        autoOpen: false,
3740                        width: '250',
3741                        height: 100,
3742                    });
3743                    $('.modal_erreurDesinscriptionCompteVC').dialog('open');
3744                }
3745            });
3746    })(jQuery);
3747}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.