/[openfoncier]/branches/3.2.x/app/js/script.js
ViewVC logotype

Diff of /branches/3.2.x/app/js/script.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 660 by fmichon, Mon Nov 12 09:13:10 2012 UTC revision 771 by vpihour, Tue Nov 20 15:08:10 2012 UTC
# Line 179  function popupIt(objsf, link) { Line 179  function popupIt(objsf, link) {
179    
180  function changeDataSelect(tn, ds, joker){  function changeDataSelect(tn, ds, joker){
181                    
182      var idArrondissement = $("#"+ds+" option:selected").val();      var id = $("#"+ds+" option:selected").val();
183      link = "../app/listData.php?idx=" + idArrondissement + "&tn=" + tn + "&ds=" + ds;      link = "../app/listData.php?idx=" + id + "&tn=" + tn + "&ds=" + ds;
184      $.ajax({      $.ajax({
185          type: "GET",          type: "GET",
186          url: link,          url: link,
# Line 237  function tmpUpload(champ) { Line 237  function tmpUpload(champ) {
237      fenetreouverte = true;      fenetreouverte = true;
238  }  }
239    
240  //$(function() {  /*
241  //    if ( $('#date_demande').length > 0 && !$('#dossier_autorisation_type_detaille').is(':disabled') )      Ajoute le formulaire d'jout de référence cadastrale personnalisé
242  //        hideFields();   * */
243  //          $(function() {
 //      
 //});  
   
 function changeDemandeType(){  
       
     var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();  
244            
245      if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){      url = document.location + "" ;
246        if ( $('#date_demande').length > 0
247            && !$('#dossier_autorisation_type_detaille').is(':disabled')
248            && url.indexOf("form.php?obj=demande&action=0") != -1 ){
249                    
250          changeDataSelect('demande_type','dossier_autorisation_type_detaille');          $.ajax({
251                type: "GET",
252                url: "sousform.php?obj=demandeur&action=0&tri=&objsf=demandeur&premiersf=0",
253                cache: false,
254                success: function(html){
255                    
256                    $('.lots').append(createFieldset('test', 'test'));
257                    $('#test').html(html);
258                    $('#test .formControls').remove();
259    
260                    $('#test').html($('#test .formEntete').html());
261                    
262                    $('#test #particulier_prenom').parent().append(
263                        '<span class="om-icon om-icon-16 om-icon-fix search-part-16" title="Chercher un petitionnaire"></span>'
264                    );
265                    $('#test #personne_morale_raison_sociale').parent().append(
266                        '<span class="om-icon om-icon-16 om-icon-fix search-mor-16" title="Chercher un petitionnaire"></span>'
267                    );
268                    $('#test input[id=personne_morale_prenom]').after(
269                        '<span class="om-icon om-icon-16 om-icon-fix search-mor-16" title="Chercher un petitionnaire"></span>'
270                    );
271                    
272                    obj = $('#type_demandeur').parent();
273                    obj.empty();
274                    obj.html(
275                        '<select id="type_demandeur" class="champFormulaire selectTypeDemandeur" name="type_personne" size="1">' +
276                            '<option selected="selected" value="particulier">particulier</option>' +
277                            '<option value="personne_morale">personne morale</option>' +                    
278                        '</select>'
279                    );
280                    
281                    setSelectCivilite();
282                },
283                async: false
284            });
285                    
286         $('#demande_type').parent().parent().show();          $('.lots').append(createFieldset('P&eacute;titionnaire(s)', 'petitionnaire__0'));
287                  $('#petitionnaire__0').after(
288         $('.terrain_references_cadastrales_custom').append(              '<div class="field field-type-text morePetitionnaire" style="display: table-row;">' +
            '<div class="field field-type-text" >'+  
289                  '<div class="form-libelle">' +                  '<div class="form-libelle">' +
290                      '<label '+                      '<label class="libelle-more_petitionnaire" for="terrain_superficie"> + Ajouter un autre p&eacute;titionnaire </label>' +
                         'class="libelle-terrain_references_cadastrales" '+  
                         'for="terrain_references_cadastrales">'+  
                         ' terrain_references_cadastrales '+  
                     '</label>' +  
291                  '</div>' +                  '</div>' +
292                  '<div class="form-content reference_cadastrale_custom_fields">' +                  '<div class="form-content">' +
                     '<input ' +  
                         'class="champFormulaire reference_cadastrale_custom_field" ' +  
                         'type="text" ' +  
                         'onchange="VerifNum(this)" ' +  
                         'maxlength="3" ' +  
                         'size="3" ' +  
                         'value="" />' +  
                     '<input ' +  
                         'class="champFormulaire reference_cadastrale_custom_field" ' +  
                         'type="text" ' +  
                         'maxlength="2" ' +  
                         'size="2" ' +  
                         'value="" />' +  
                     '<input ' +  
                         'class="champFormulaire reference_cadastrale_custom_field" ' +  
                         'type="text" ' +  
                         'onchange="VerifNum(this)" ' +  
                         'maxlength="4" ' +  
                         'size="4" ' +  
                         'value="" />' +  
293                  '</div>' +                  '</div>' +
294             '</div>' +              '</div>');
295             '<div id="moreFieldReferenceCadastrale"> + ajouter d\'autres champs</div>'          
296         );          $('.morePetitionnaire').click( function() {
297                      $('#fieldsetpetitionnaire__0 .morePetitionnaire').before(
298         $('#moreFieldReferenceCadastrale').click( function() {                  '<div id="petitionnaire__' + $('#fieldsetpetitionnaire__0 .fieldsetContent').size() +'" class="fieldsetContent">'+
299              $('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale());                      $('#fieldsetpetitionnaire__0 .formsDemandeur').val() +
300          });                  '</div>'
301                );
302                
303                nb = $('#fieldsetpetitionnaire__0 .fieldsetContent').size() - 1;
304                
305                changeIdNameField('petitionnaire__' + nb, '_' + nb );
306                
307                addDatePicker( 'petitionnaire__' + nb + ' #particulier_date_naissance_' + nb);
308                actionVeerifyFields('petitionnaire__' + nb, '_' + nb);
309                
310                addActionSearch('petitionnaire__' + nb, '_' + nb);
311                
312                setTypeDemandeur('petitionnaire__' + nb, '_' + nb );
313                
314                $('html, body').animate({
315                    scrollTop: $('#petitionnaire__' + nb + ' #type_demandeur').offset().top
316                }, 1000);
317            });    
318            
319            $('.lots').append(createFieldset('D&eacute;l&eacute;gataire', 'delegataire'));
320            setDelegataire();
321            setPetitionnaire();
322                    
323            $('#petitionnaire__0').before(
324                '<div id="dialog" title="Résultats de votre recherche"></div>'
325            );
326                
327            hideFields();
328        }
329      
330       if ( $('#date_demande').length > 0
331            && !$('#dossier_autorisation_type_detaille').is(':disabled')
332            && url.indexOf("form.php?obj=demande&action=1") != -1 ){
333                
334            addNewFieldReferencesCadastrales();
335            $('#terrain_references_cadastrales').parent().parent().hide();
336                    
337          $('form').submit(          reference_cadastrale = $('#terrain_references_cadastrales').val();
338              function(){          /*Formatage de la reference cadastrale*/
339            if ( reference_cadastrale != '' ){
340                
341                references_cadastrales = reference_cadastrale.split(';');
342                donnees = new Array();
343                
344                i = 0 ;
345                for ( l = 0 ; l < references_cadastrales.length - 1 ; l ++ ){
346                    
347                    k = 0;
348                    donnees[i] = '';
349                    for ( j = k ; j < references_cadastrales[l].length ; j++ )
350                        if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){
351                            donnees[i] += references_cadastrales[l].charAt(j);
352                            k++;
353                        } else {
354                            i++;
355                            break;
356                        }
357                    
358                          
359                    donnees[i] = '';
360                    for ( j = k ; j < references_cadastrales[l].length ; j++ )
361                        if ( isAlpha(references_cadastrales[l].charAt(j)) ){
362                            donnees[i] += references_cadastrales[l].charAt(j);
363                            k++;
364                        } else {
365                            i++;
366                            break;
367                        }
368                    
369                    donnees[i] = '';
370                    for ( j = k ; j < references_cadastrales[l].length ; j++ )
371                        if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){
372                            donnees[i] += references_cadastrales[l].charAt(j);
373                            k++;
374                        } else {
375                            break;
376                        }
377                    
378                    m = 0 ;
379                    if ( k < references_cadastrales[l].length ){
380                        
381                        for ( j = k ; j < references_cadastrales[l].length ; j++ )
382                            if ( isAlpha(references_cadastrales[l].charAt(j)) ){
383                                m++;
384                                donnees[++i] = references_cadastrales[l].charAt(j);
385                                donnees[++i] = '';
386                            }
387                            else {
388                                donnees[i] += references_cadastrales[l].charAt(j);
389                            }
390                    }
391    
392                    donnees[++i] = ';';
393                    i++;
394    
395                    if ( l > 0 )
396                        $('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase());
397                    actionFormReferenceCadastrale();
398                    
399                    if ( m > 0 ){
400                                
401                        for ( j = 0 ; j < m ; j++ )
402                            $('#moreFieldReferenceCadastrale' + ( $('.moreFieldReferenceCadastrale').length - 1 ) ).before(newInputReferenceCadastrale());
403                    }
404                }
405    
406                actionLineFormReferenceCadastrale();
407                
408                $('.reference_cadastrale_custom_field').each(
409                    function(index) {
410                         $(this).val(donnees[index])
411                    }
412                );
413            }
414       }
415    });
416    
417    /*
418        Création du formuliare pour le petitionnaire
419     * */
420    function setPetitionnaire(){
421        $('#petitionnaire__0').prepend("<br/>" + $('#test').html() + "<br/>");
422        $('#test').parent().remove();
423        $('#petitionnaire__0 #type_demandeur').after(addTypeDemandeur('petitionnaire'));
424        
425        addActionSearch('petitionnaire__0', '_0');
426        
427    }
428    
429    /*
430        Action au changement du select du type de demandeur
431     * */
432    function setTypeDemandeur(id, complement){
433    
434        $('#'+id + ' select[id="type_demandeur' + complement + '"]').on('change',
435            function() {
436    
437                if ( $(this).find('option:selected').first().text() == 'particulier' )
438                    fieldTypeDemandeur('#' + id, true, complement);
439                else
440                    fieldTypeDemandeur('#' + id, false, complement);
441            }
442        );
443    }
444    
445    /*
446        Création du formulaire pour le délégataire
447     * */
448    function setDelegataire(){
449        $('#delegataire').html($('#test').html());
450        
451        $('#delegataire #type_demandeur').after(addTypeDemandeur('delegataire'));
452        $('#delegataire #frequent').parent().parent().remove();
453        $('#delegataire .search-part-16').remove();
454        $('#delegataire .search-mor-16').remove();
455        
456        changeIdNameField('delegataire', '');
457        addDatePicker('delegataire #particulier_date_naissance');
458        actionVeerifyFields('delegataire', '');
459        setTypeDemandeur('delegataire', '');
460    }
461    
462    function addTypeDemandeur(value){
463        return '<input type="hidden" value="' + value + '" name="type_demandeur" id="type_demandeur_hidden"/>';
464    }
465    
466    /*
467        Change les id et les name des champs
468     * */
469    function changeIdNameField(id, complement){
470        
471        $('#' + id + ' input').each(
472            function(){
473                $(this).attr('name', id + '__' + $(this).attr('name') );
474                $(this).attr('id', $(this).attr('id') + complement );
475            }
476        );
477    
478        $('#' + id + ' select').each(
479            function(){
480                $(this).attr('name', id + '__' + $(this).attr('name') );
481                $(this).attr('id', $(this).attr('id') + complement );
482            }
483        );
484        
485        
486    }
487    
488    function actionVeerifyFields(id, complement){
489        $('#' + id + ' #numero'+complement).change(
490            function(){
491                VerifNum(this);
492            }
493        );
494        
495        $('#' + id + ' #telephone_fixe'+complement).change(
496            function(){
497                if ( !isPhoneNumber($(this).val()) ) {
498                    
499                    alert('Vous ne devez saisir que des nombres');
500                    $(this).val('');
501                }
502            }
503        );
504        
505        $('#' + id + ' #telephone_mobile'+complement).change(
506            function(){
507                if ( !isPhoneNumber($(this).val()) ) {
508                                    
509                  var reference_cadastrale = '';                  alert('Vous ne devez saisir que des nombres');
510                    $(this).val('');
511                }
512            }
513        );
514        
515        $('#' + id + ' #courriel'+complement).change(
516            function(){
517                if ( !isMail($(this).val()) ) {
518                    
519                    alert('Saisissez une adresse mail correcte');
520                }
521            }
522        );
523    }
524    
525    /*
526        Ajoute les le datespicker sur les champs de date
527     * */
528    function addDatePicker(id){
529        
530        $("#" + id ).datepicker({
531            dateFormat: dateFormat,
532            changeMonth: true,
533            changeYear: true,
534            yearRange: minYear+':'+maxYear,
535            showOn: 'button',
536            buttonImage: '../img/calendar.png',
537            buttonImageOnly: true,
538            constrainInput: true
539        });
540    }
541    
542    /*
543        Ajout de l'action de recherche des pétitionnaire fréquent dans un overlay
544     * */
545    function addActionSearch(id, complement){
546        
547        $('#' + id + ' .search-part-16').click(
548            function(){
549                
550                var donnees = "?type=particulier&par_nom=";
551                $('#' + id + ' .search_particulier_fields input').each(
552                    function(i){
553    
554                        donnees += $(this).val() + (( i == 0 ) ?  '&par_prenom='  : '') ;
555                    }
556                );
557    
558                $.ajax({
559                    type: "GET",
560                    url: "../app/findPetitionnaire.php" + donnees ,
561                    cache: false,
562                    success: function(html){
563                        
564                        res = 'Auncune correspondance trouvée.';
565                        
566                        if ( html.length > 2 ){
567                            
568                            res = '<select>' ;
569                            donnees = html.split(';');
570    
571                            for ( i = 0 ; i < donnees.length - 1 ; i++ ){
572    
573                                val = donnees[i].replace('"', '');
574                                line = donnees[i].split('_');
575                                
576                                if ( line[3] != '' ){
577                                    
578                                    line[3] = ' - ' + line[3];
579                                }
580                                
581                                res += '<option value="' + val + '">' + line[1] + ' ' + line[2] + line[3] + '</option>';
582                            }
583                            
584                            res += '</select>' ;
585                        }
586                        
587                        $('#dialog').html(res);
588                          
589                        $( "#dialog" ).dialog({
590                            modal: true,
591                            buttons : {
592                                Valider: function(){
593                                    
594                                    if ( res != 'Auncune correspondance trouvée.' ){
595                                        donnees = $('#dialog select option:selected').val();
596                                        donnees = donnees.split('_');
597                                        
598                                        if ( $.isNumeric(donnees[4]) )
599                                            $('#' + id + ' select[id="particulier_civilite' + complement + '"] option[value="' + $.trim(donnees[4]) + '"]').attr('selected','selected');
600                                        $('#' + id + ' input[id="particulier_nom' + complement + '"]').val($.trim(donnees[1]));
601                                        $('#' + id + ' input[id="particulier_prenom' + complement + '"]').val($.trim(donnees[2]));
602                                        
603                                        /*Vérifie si la date est non vide avant de la traiter*/
604                                        date_temp = $.trim(donnees[3]);
605                                        if ( date_temp != '' ){
606                                            date = date_temp.split('-');
607                                            date = date[2] + "/" + date[1] + "/" + date[0] ;
608                                            $('#' + id + ' input[id="particulier_date_naissance' + complement + '"]').val(date);
609                                        }
610                                        $('#' + id + ' input[id="particulier_commune_naissance' + complement + '"]').val($.trim(donnees[10]));
611                                        $('#' + id + ' input[id="particulier_departement_naissance' + complement + '"]').val($.trim(donnees[11]));
612                                        
613                                        changeValInputDemandeur(id, donnees, complement);
614                                    }
615                                    
616                                    $(this).dialog( "close" );
617                                }
618                            }
619                        });
620                    },
621                    async: false
622                });
623            }
624        );
625        
626        $('#' + id + ' .search-mor-16').click(
627            function(){
628                
629                var donnees = "?type=personne_morale"+
630                    "&mor_denomination="+$('#'+id+' input[id="personne_morale_denomination' + complement + '"]').val() +
631                    "&mor_nom="+$('#'+id+' input[id="personne_morale_nom' + complement + '"]').val();
632                                    
633                  $('.reference_cadastrale_custom_field').each(              $.ajax({
634                      function(){                  type: "GET",
635                    url: "../app/findPetitionnaire.php" + donnees ,
636                    cache: false,
637                    success: function(html){
638                        
639                        res = 'Auncune correspondance trouvée.';
640                        
641                        if ( html > 2 ){
642                                                    
643                          reference_cadastrale += $(this).val();                          res = '<select>' ;
644                            donnees = html.split(';');
645    
646                            for ( i = 0 ; i < donnees.length - 1 ; i++ ){
647    
648                                val = donnees[i].replace('"', '');
649                                line = donnees[i].split('_');
650                                
651                                res += '<option value="' + val + '">' + line[5] + ' ' + line[6] + '</option>';
652                            }
653                            
654                            res += '</select>' ;
655                      }                      }
656                  );                      
657                        $('#dialog').html(res);
658                          
659                        $( "#dialog" ).dialog({
660                            modal: true,
661                            buttons : {
662                                Valider: function(){
663                                    
664                                    if ( res != 'Auncune correspondance trouvée.' ){
665                                        donnees = $('#dialog select option:selected').val();
666                                        donnees = donnees.split('_');
667                                        
668                                        if ( $.isNumeric(donnees[8]) )
669                                            $('#' + id + ' select[id="personne_morale_civilite' + complement + '"] option[value="' + $.trim(donnees[8]) + '"]').attr('selected','selected');
670                                        $('#' + id + ' input[id="personne_morale_denomination' + complement + '"]').val($.trim(donnees[5]));
671                                        $('#' + id + ' input[id="personne_morale_raison_sociale' + complement + '"]').val($.trim(donnees[12]));
672                                        $('#' + id + ' input[id="personne_morale_siret' + complement + '"]').val($.trim(donnees[6]));
673                                        $('#' + id + ' input[id="personne_morale_categorie_juridique' + complement + '"]').val($.trim(donnees[13]));
674                                        $('#' + id + ' input[id="personne_morale_nom' + complement + '"]').val($.trim(donnees[7]));
675                                        $('#' + id + ' input[id="personne_morale_prenom' + complement + '"]').val($.trim(donnees[9]));
676                                        
677                                        changeValInputDemandeur(id, donnees, complement);
678                                    }
679                                    $(this).dialog( "close" );
680                                }
681                            }
682                        });
683                    },
684                    async: false
685                });
686            }
687        );
688    }
689    
690    /*
691        Change les valeurs des champs en commun des particuliers et des personnes morales
692     * */
693    function changeValInputDemandeur(id, donnees, complement){
694        
695        $('#' + id + ' input[id="demandeur' + complement + '"]').val($.trim(donnees[0]));
696        /*Teste si la valeur retournée est TRUE*/
697        if ( donnees[28] === 't' ){
698            $('#' + id + ' input[id="notification' + complement + '"]').attr('checked', 'checked');
699            $('#' + id + ' input[id="notification' + complement + '"]').val('Oui');
700        }
701        $('#' + id + ' input[id="frequent' + complement + '"]').attr('checked','checked');
702        $('#' + id + ' input[id="frequent' + complement + '"]').val('Oui');
703        $('#' + id + ' input[id="numero' + complement + '"]').val($.trim(donnees[14]));
704        $('#' + id + ' input[id="voie' + complement + '"]').val($.trim(donnees[15]));
705        $('#' + id + ' input[id="complement' + complement + '"]').val($.trim(donnees[16]));
706        $('#' + id + ' input[id="lieu_dit' + complement + '"]').val($.trim(donnees[17]));
707        $('#' + id + ' input[id="localite' + complement + '"]').val($.trim(donnees[18]));
708        $('#' + id + ' input[id="code_postal' + complement + '"]').val($.trim(donnees[19]));
709        $('#' + id + ' input[id="bp' + complement + '"]').val($.trim(donnees[20]));
710        $('#' + id + ' input[id="cedex' + complement + '"]').val($.trim(donnees[21]));
711        $('#' + id + ' input[id="pays' + complement + '"]').val($.trim(donnees[22]));
712        $('#' + id + ' input[id="division_territoriale' + complement + '"]').val($.trim(donnees[23]));
713        $('#' + id + ' input[id="telephone_fixe' + complement + '"]').val($.trim(donnees[24]));
714        $('#' + id + ' input[id="telephone_mobile' + complement + '"]').val($.trim(donnees[25]));
715        $('#' + id + ' input[id="indicatif' + complement + '"]').val($.trim(donnees[26]));
716        $('#' + id + ' input[id="courriel' + complement + '"]').val($.trim(donnees[27]));
717    }
718    
719    /*
720        Création des select pour la civilité
721     * */
722    function setSelectCivilite(){
723        
724        $.ajax({
725            type: "GET",
726            url: "../app/civilite.php",
727            dataType: "json",
728            cache: false,
729            success: function(html){
730                if ( html != '' ){
731                    
732                    $('#particulier_civilite').parent().html('<select id="particulier_civilite" class="champFormulaire" size="1" name="particulier_civilite">' +
733                            '<option value="" selected="selected">choisir particulier_civilite</option>');
734                    $('#personne_morale_civilite').parent().html('<select id="personne_morale_civilite" class="champFormulaire" size="1" name="personne_morale_civilite">' +
735                            '<option value="" selected="selected">choisir personne_morale_civilite</option>');
736                    
737                    civilites = html.split(';');
738                    for ( i = 0 ; i < civilites.length - 1 ; i++ ){
739                        
740                        civilite = civilites[i].split('_');
741                        $('#particulier_civilite').append('<option value="' + civilite[0] + '">' + civilite[1] + '</option>');
742                        $('#personne_morale_civilite').append('<option value="' + civilite[0] + '">' + civilite[1] + '</option>');
743                    }
744                                    
745                  $('#terrain_references_cadastrales').val(reference_cadastrale);                  $('#particulier_civilite').append('</select>');
746                    $('#personne_morale_civilite').append('</select>');
747              }              }
748          );          },
749            async: false
750        });
751    }
752    
753    /*
754        Retourne le code HTML d'un fieldset
755     * */
756    function createFieldset(name, className){
757        return '<fieldset class="cadre ui-corner-all ui-widget-content" id="fieldset' + className + '">' +
758                    '<legend class="ui-corner-all ui-widget-content ui-state-active">' + name + ' </legend>' +
759                    '<input class="formsDemandeur" type="hidden" val=""/>'+
760                    '<div class="fieldsetContent " id="' + className + '">' +
761                    '</div>' +
762                    '<div class="visualClear"></div>' +
763                    '</div>' +
764               '</fieldset>';
765    }
766    
767    /*
768        Test str est une lettre de l'alphabet
769     * */
770    function isAlpha(str) {
771        return /^[a-zA-Z\/]+$/.test(str);
772    }
773    
774    function isMail(str){
775        return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(str);
776    }
777    
778    function isPhoneNumber(str){
779        return /[0-9-()+]{3,20}/.test(str);
780    }
781    
782    /*
783        Ajoute les ations spécifiques pour le formulaire personnalisé d'ajout de référence cadastrale
784     * */
785    function actionFormReferenceCadastrale(){
786        $('form').submit(
787            function(){
788                
789                var reference_cadastrale = '';
790                var reference_cadastrale_temp = '';
791                
792                $('.reference_cadastrale_custom_field').each(
793                    function(){
794                        
795                        if ( $(this).val() == ';' ){
796                            
797                            reference_cadastrale_bis = reference_cadastrale_temp + ( ( reference_cadastrale_temp != '' && reference_cadastrale_temp.length > 0 ) ? ';' : '' );
798                            if ( /^([0-9]{1,4}[a-zA-Z]{1,3}[0-9]{1,5}([A\/]{1}[0-9]{1,4})*;)*$/.test(reference_cadastrale_bis) ){
799                                
800                                reference_cadastrale += reference_cadastrale_bis;
801                            }
802                            reference_cadastrale_temp = '';
803                        }
804                        else
805                            reference_cadastrale_temp += $(this).val();
806                        
807                    }
808                );
809                
810                $('#terrain_references_cadastrales').val(reference_cadastrale);
811            }
812        );
813    
814        $('#moreFieldReferenceCadastrale' + ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() {
815            $(this).before(newInputReferenceCadastrale());
816        });
817        
818    }
819    
820    /*
821        Action pour l'ajout de nouvelle ligne
822     * */
823    function actionLineFormReferenceCadastrale(){
824        $('#morelineReferenceCadastrale').click(
825            function(){
826                
827                $('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase());
828                $('#moreFieldReferenceCadastrale'+ ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() {
829                    $(this).before(newInputReferenceCadastrale());
830                });
831                
832                
833            }
834        );
835    }
836    
837    /*
838        Met à jour le select demande_type dès qu'un dossier_autorisation_type_detaille est choisi
839     * */
840    function changeDemandeType(){
841        
842        var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();
843        
844        if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){
845            
846            changeDataSelect('demande_type','dossier_autorisation_type_detaille');
847            if ( $('#demande_type option').size() < 2 )
848                showFormsDemande();
849                    
850          $('.terrain_references_cadastrales_custom:').find(">:first-child").hide();         $('#demande_type').parent().parent().show();
851          
852           addNewFieldReferencesCadastrales();
853          
854           actionFormReferenceCadastrale();
855           actionLineFormReferenceCadastrale()        
856      }      }
857      else {      else {
858          hideFields();          hideFields();
859      }      }
860  }  }
861    
862    /*
863        Ajoute le code HTML des champs pour les références cadastrales
864     * */
865    function addNewFieldReferencesCadastrales(){
866        $('.references_cadastrales_new_field').remove();
867        $('.moreFieldReferenceCadastrale').remove();
868        $('#morelineReferenceCadastrale').remove();
869        $('.localisation .fieldsetContent').prepend(
870           '<div class="field field-type-text references_cadastrales_new_field" >'+
871                '<div class="form-libelle">' +
872                    '<label '+
873                        'class="libelle-terrain_references_cadastrales" '+
874                        'for="terrain_references_cadastrales">'+
875                        ' terrain_references_cadastrales '+
876                    '</label>' +
877                '</div>' +
878                '<div class="form-content reference_cadastrale_custom_fields">' +
879                     fieldReferenceCadastraleBase() +
880                '</div>' +
881           '</div>' +
882           '<div class="field field-type-text" id="morelineReferenceCadastrale">' +
883                '<div class="form-libelle"></div>' +
884                '<div class="form-content">' +
885                    ' + ajouter d\'autres lignes' +
886                '</div>' +
887           '</div>'      
888       );
889       $('#terrain_superficie').parent().parent().after('<div class="field field-type-text" >' +
890                '<div class="form-libelle"></div>' +
891                '<div class="form-content">' +
892                    '<input id="cad-adr-them" class="ui-button ui-widget ui-state-default ui-corner-all" type="button" value="Cadastrale < = > Adresse"/>' +
893                '</div>' +
894           '</div>' );
895    }
896    
897    /*
898        Séparateur caché ;
899     * */
900    function hiddenSeparatorField(){
901        return '<input ' +
902                    'class="reference_cadastrale_custom_field " ' +
903                    'type="hidden" ' +
904                    'maxlength="2" ' +
905                    'size="2" ' +
906                    'value=";" />';
907    }
908    
909    /*
910        Ajout d'une nouvelle ligne de champ
911     * */
912    function fieldReferenceCadastraleBase(){
913        return '<input ' +
914                    'class="champFormulaire reference_cadastrale_custom_field" ' +
915                    'type="text" ' +
916                    'onchange="VerifNum(this)" ' +
917                    'maxlength="4" ' +
918                    'size="4" ' +
919                    'value="" />' +
920                '<input ' +
921                    'class="champFormulaire reference_cadastrale_custom_field" ' +
922                    'type="text" ' +
923                    'maxlength="3" ' +
924                    'size="3" ' +
925                    'value="" '+
926                    'onchange="if ( !isAlpha(this.value) ){ alert(\'Vous ne devez saisir que des lettres dans ce champs.\'); this.value = \'\'; }"/>' +
927                '<input ' +
928                    'class="champFormulaire reference_cadastrale_custom_field" ' +
929                    'type="text" ' +
930                    'onchange="VerifNum(this)" ' +
931                    'maxlength="5" ' +
932                    'size="5" ' +
933                    'value="" />' +
934                '<span id="moreFieldReferenceCadastrale' + $('.moreFieldReferenceCadastrale').length + '" class="moreFieldReferenceCadastrale">' +
935                    hiddenSeparatorField() +
936                    ' + ajouter d\'autres champs' +
937                '</span>';
938    }
939    
940    /*
941        Cache les champs inutules
942     * */    
943  function hideFields(){  function hideFields(){
944      $('.bloc').each(      $('.bloc').each(
945          function(){          function(){
# Line 329  function hideFields(){ Line 953  function hideFields(){
953      $('#demande_type').parent().parent().hide();      $('#demande_type').parent().parent().hide();
954  }  }
955    
956    /*
957        Affiche les champs dont on a besoin
958     * */
959  function showFormsDemande(){  function showFormsDemande(){
960      $('.bloc').each(      $('.bloc').each(
961          function(){          function(){
# Line 339  function showFormsDemande(){ Line 966  function showFormsDemande(){
966            
967      $('.field-type-text').show();      $('.field-type-text').show();
968      $('input[type=submit]').show();      $('input[type=submit]').show();
969        $('.terrain_references_cadastrales_custom').hide();
970        
971        $('#terrain_references_cadastrales').parent().parent().hide();
972        
973        /*Cache les champs inutiles*/
974        fieldTypeDemandeur('#petitionnaire__0', true, '_0');
975        fieldTypeDemandeur('#delegataire', true, '');
976        
977        $('#fieldsetpetitionnaire__0 .formsDemandeur').val($('#petitionnaire__0').html());
978        
979        changeIdNameField('petitionnaire__0', '_0');
980        setTypeDemandeur('petitionnaire__0', '_0');
981        actionVeerifyFields('petitionnaire__0', '_0');
982        
983        addDatePicker('petitionnaire__0 #particulier_date_naissance_0');
984        actionVeerifyFields('petitionnaire__0', '_0');
985  }  }
986    
987    /*
988        Cache/montre des champs selon le type de demandeur
989     * */
990    function fieldTypeDemandeur(name, particulier, complement){
991    
992        if ( particulier == true ){
993    
994            $(name + ' select[id="particulier_civilite' + complement + '"] option[value=""]').attr('selected', 'selected');
995            $(name + ' input[id="particulier_nom' + complement + '"]').val('');
996            $(name + ' input[id="particulier_prenom' + complement + '"]').val('');
997            $(name + ' input[id="particulier_date_naissance' + complement + '"]').val('');
998            $(name + ' input[id="particulier_commune_naissance' + complement + '"]').val('');
999            $(name + ' input[id="particulier_departement_naissance' + complement + '"]').val('');
1000            
1001            $( name + ' .particulier_fields').show();
1002            $( name + ' .personne_morale_fields').hide();
1003        }
1004        else{
1005            
1006            $(name + ' select[id="personne_morale_civilite' + complement + '"] option[value=""]').attr('selected', 'selected');
1007            $(name + ' input[id="personne_morale_denomination' + complement + '"]').val('');
1008            $(name + ' input[id="personne_morale_raison_sociale' + complement + '"]').val('');
1009            $(name + ' input[id="personne_morale_siret' + complement + '"]').val('');
1010            $(name + ' input[id="personne_morale_categorie_juridique' + complement + '"]').val('');
1011            $(name + ' input[id="personne_morale_nom' + complement + '"]').val('');
1012            $(name + ' input[id="personne_morale_prenom' + complement + '"]').val('');
1013            $( name + ' .particulier_fields').hide();
1014            $( name + ' .personne_morale_fields').show();
1015        }
1016    }
1017    
1018    /*
1019        Action au clique sur le bouton " + ajouter d'autres champs"
1020     * */
1021  function newInputReferenceCadastrale(){  function newInputReferenceCadastrale(){
1022      return '<input ' +      return '<input ' +
1023              'class="champFormulaire reference_cadastrale_custom_field" ' +              'class="champFormulaire reference_cadastrale_custom_field" ' +
1024              'type="text" ' +              'type="text" ' +
1025              'maxlength="1" ' +              'maxlength="1" ' +
1026              'size="1" ' +              'size="1" ' +
1027              'value="" />' +              'value="" ' +
1028                'onchange="testSeparator(this);"/>' +
1029          '<input ' +          '<input ' +
1030              'class="champFormulaire reference_cadastrale_custom_field" ' +              'class="champFormulaire reference_cadastrale_custom_field" ' +
1031              'type="text" ' +              'type="text" ' +
# Line 357  function newInputReferenceCadastrale(){ Line 1035  function newInputReferenceCadastrale(){
1035              'value="" />';              'value="" />';
1036  }  }
1037    
1038    function testSeparator(obj){
1039    
1040        if ( obj.value != 'A' &&
1041             obj.value != '/' ) {
1042                
1043            alert('Saisissez uniquement un A ou un / comme séparateur');
1044            obj.value = '';
1045        }
1046    }
1047    
1048  // Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau  // Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau
1049  // tableau de bord  // tableau de bord
1050  function widget_bind_move_actions() {}  function widget_bind_move_actions() {}
1051  function widget_bind_add_action() {}  function widget_bind_add_action() {}
1052  function widget_bind_edit_actions(widget_selector) {}  function widget_bind_edit_actions(widget_selector) {}
1053    
1054    function file(fichier) {
1055        //
1056        if (fichier == "") {
1057            alert("zone vide");
1058        }
1059        //
1060        pfenetre = window.open("../app/file.php?file="+fichier,"Visualisation","width=100,height=100,top=1,left=150,scrollbars=yes,resizable = yes");
1061        //
1062        fenetreouverte = true;
1063    }

Legend:
Removed from v.660  
changed lines
  Added in v.771

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26