/[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 740 by vpihour, Thu Nov 15 09:36:32 2012 UTC revision 741 by vpihour, Mon Nov 19 10:29:19 2012 UTC
# Line 255  $(function() { Line 255  $(function() {
255                                    
256                  $('.lots').append(createFieldset('test', 'test'));                  $('.lots').append(createFieldset('test', 'test'));
257                  $('#test').html(html);                  $('#test').html(html);
258                  $('#test').html($('#test .formEntete>#form-content').html());                  $('#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();                  obj = $('#type_demandeur').parent();
273                  obj.empty();                  obj.empty();
# Line 271  $(function() { Line 283  $(function() {
283              async: false              async: false
284          });          });
285                    
286          $('.lots').append(createFieldset('P&eacute;titionnaire(s)', 'petitionnaire'));          $('.lots').append(createFieldset('P&eacute;titionnaire(s)', 'petitionnaire__0'));
287          $('#petitionnaire').after(          $('#petitionnaire__0').after(
288              '<div class="field field-type-text morePetitionnaire" style="display: table-row;">' +              '<div class="field field-type-text morePetitionnaire" style="display: table-row;">' +
289                  '<div class="form-libelle">' +                  '<div class="form-libelle">' +
290                      '<label class="libelle-more_petitionnaire" for="terrain_superficie"> + Ajouter un autre p&eacute;titionnaire </label>' +                      '<label class="libelle-more_petitionnaire" for="terrain_superficie"> + Ajouter un autre p&eacute;titionnaire </label>' +
# Line 282  $(function() { Line 294  $(function() {
294              '</div>');              '</div>');
295                    
296          $('.morePetitionnaire').click( function() {          $('.morePetitionnaire').click( function() {
297              $('#fieldsetpetitionnaire .morePetitionnaire').before(              $('#fieldsetpetitionnaire__0 .morePetitionnaire').before(
298                  '<div id="petitionnaire' + $('#fieldsetpetitionnaire .fieldsetContent').size() +'" class="fieldsetContent">'+                  '<div id="petitionnaire__' + $('#fieldsetpetitionnaire__0 .fieldsetContent').size() +'" class="fieldsetContent">'+
299                      $('#fieldsetpetitionnaire #formsDemandeur').val() +                      $('#fieldsetpetitionnaire__0 .formsDemandeur').val() +
300                  '</div>'                  '</div>'
301              );              );
302                            
303              nb = $('#fieldsetpetitionnaire .fieldsetContent').size() - 1;              nb = $('#fieldsetpetitionnaire__0 .fieldsetContent').size() - 1;
304                            
305              changeIdNameField('petitionnaire' + nb );              changeIdNameField('petitionnaire__' + nb );
306                            
307              addDatePicker( 'petitionnaire' + nb + '_petitionnaire_particulier_date_naissance');              addDatePicker( 'petitionnaire__' + nb + '_petitionnaire_particulier_date_naissance');
308                            
309              setTypeDemandeur('petitionnaire' + nb, 'petitionnaire' + nb , '_petitionnaire');              addActionSearch('petitionnaire__' + nb);
310                
311                setTypeDemandeur('petitionnaire__' + nb, 'petitionnaire__' + nb , '_petitionnaire');
312                
313                $('#petitionnaire__' + nb + '_type_demandeur').focus();
314          });              });    
315                    
316          $('.lots').append(createFieldset('D&eacute;l&eacute;gataire', 'delegataire'));          $('.lots').append(createFieldset('D&eacute;l&eacute;gataire', 'delegataire'));
317          setDelegataire();          setDelegataire();
318          setPetitionnaire();          setPetitionnaire();
319          setTypeDemandeur('petitionnaire', 'petitionnaire_type_demandeur', '');          setTypeDemandeur('petitionnaire__0', 'petitionnaire_type_demandeur', '');
320                            
321            $('#petitionnaire__0').before(
322                '<div id="dialog" title="Résultats de votre recherche"></div>'
323            );
324                
325          hideFields();          hideFields();
326      }      }
327        
# Line 396  $(function() { Line 416  $(function() {
416      Création du formuliare pour le petitionnaire      Création du formuliare pour le petitionnaire
417   * */   * */
418  function setPetitionnaire(){  function setPetitionnaire(){
419      $('#petitionnaire').prepend("<br/>" + $('#test').html() + "<br/>");      $('#petitionnaire__0').prepend("<br/>" + $('#test').html() + "<br/>");
420      $('#test').parent().remove();      $('#test').parent().remove();
421            
422      changeIdNameField('petitionnaire');      addActionSearch('petitionnaire__0');
423        
424  }  }
425    
426  /*  /*
# Line 438  function setDelegataire(){ Line 459  function setDelegataire(){
459  }  }
460    
461  /*  /*
462      Change les id et name des champs      Change les id des champs
463   * */   * */
464  function changeIdNameField(name){  function changeIdNameField(name){
465            
466      $('#' + name + ' input').each(      $('#' + name + ' input').each(
467          function(){          function(){
468              $(this).attr('id', name + '_' + $(this).attr('id') );              $(this).attr('name', name + '__' + $(this).attr('name') );
             $(this).attr('name', name + '_' + $(this).attr('name') );  
469          }          }
470      );      );
471    
472      $('#' + name + ' #type_demandeur').attr('id', name + '_' + $('#' + name + ' #type_demandeur').attr('id'));      $('#' + name + ' select').each(
473      $('#' + name + ' #type_demandeur').attr('name', name + '_' + $('#' + name + ' #type_demandeur').attr('name'));          function(){
474                    $(this).attr('name', name + '__' + $(this).attr('name') );
475      $('#' + name + ' #particulier_civilite').attr('id', name + '_' + $('#' + name + ' #particulier_civilite').attr('id'));          }
476      $('#' + name + ' #particulier_civilite').attr('name', name + '_' + $('#' + name + ' #particulier_civilite').attr('name'));      );
       
     $('#' + name + ' #personne_morale_civilite').attr('id', name + '_' + $('#' + name + ' #personne_morale_civilite').attr('id'));  
     $('#' + name + ' #personne_morale_civilite').attr('name', name + '_' + $('#' + name + ' #personne_morale_civilite').attr('name'));  
477            
478            
479  }  }
480    
481    /*
482        Ajoute les le datespicker sur les champs de date
483     * */
484  function addDatePicker(id){  function addDatePicker(id){
485            
486      $("#" + id ).datepicker({      $("#" + id ).datepicker({
# Line 476  function addDatePicker(id){ Line 496  function addDatePicker(id){
496  }  }
497    
498  /*  /*
499        Ajout de l'action de recherche des pétitionnaire fréquent dans un overlay
500     * */
501    function addActionSearch(id){
502        
503        $('#' + id + ' .search-part-16').click(
504            function(){
505                
506                var donnees = "?type=particulier&nom=";
507                $('#' + id + ' .search_particulier_fields input').each(
508                    function(i){
509    
510                        donnees += $(this).val() + (( i == 0 ) ?  '&prenom='  : '') ;
511                    }
512                );
513    
514                $.ajax({
515                    type: "GET",
516                    url: "../app/findPetitionnaire.php" + donnees ,
517                    cache: false,
518                    success: function(html){
519                        
520                        res = 'Auncune correspondance trouvée.';
521                        
522                        if ( html != '' ){
523                            
524                            res = '<select>' ;
525                            donnees = html.split(';');
526    
527                            for ( i = 0 ; i < donnees.length - 1 ; i++ ){
528    
529                                val = donnees[i].replace('"', '');
530                                line = donnees[i].split('_');
531                                
532                                res += '<option value="' + val + '">' + line[1] + ' ' + line[2] + ' - ' + line[3] + '</option>';
533                            }
534                            
535                            res += '</select>' ;
536                        }
537                        
538                        $('#dialog').html(res);
539                          
540                        $( "#dialog" ).dialog({
541                            modal: true,
542                            buttons : {
543                                Valider: function(){
544                                    donnees = $('#dialog select option:selected').val();
545                                    donnees = donnees.split('_');
546                                    
547                                    if ( $.isNumeric(donnees[4]) )
548                                        $('#' + id + ' select[id="particulier_civilite"] option[value="' + $.trim(donnees[4]) + '"]').attr('selected','selected');
549                                    $('#' + id + ' input[id="particulier_nom"]').val($.trim(donnees[1]));
550                                    $('#' + id + ' input[id="particulier_prenom"]').val($.trim(donnees[2]));
551                                    date = $.trim(donnees[3]).split('-');
552                                    date = date[2] + "/" + date[1] + "/" + date[0] ;
553                                    $('#' + id + ' input[id="particulier_date_naissance"]').val(date);
554                                    $('#' + id + ' input[id="particulier_commune_naissance"]').val($.trim(donnees[10]));
555                                    $('#' + id + ' input[id="particulier_departement_naissance"]').val($.trim(donnees[11]));
556                                    
557                                    changeValInputDemandeur(id, donnees);
558                                    
559                                    $(this).dialog( "close" );
560                                }
561                            }
562                        });
563                    },
564                    async: false
565                });
566            }
567        );
568        
569        $('#' + id + ' .search-mor-16').click(
570            function(){
571                
572                var donnees = "?type=personne_morale"+
573                    "&mor_denomination="+$('#'+id+' input[id="personne_morale_denomination"]').val() +
574                    "&mor_nom="+$('#'+id+' input[id="personne_morale_nom"]').val();
575                
576                $.ajax({
577                    type: "GET",
578                    url: "../app/findPetitionnaire.php" + donnees ,
579                    cache: false,
580                    success: function(html){
581                        
582                        res = 'Auncune correspondance trouvée.';
583                        
584                        if ( html != '' ){
585                            
586                            res = '<select>' ;
587                            donnees = html.split(';');
588    
589                            for ( i = 0 ; i < donnees.length - 1 ; i++ ){
590    
591                                val = donnees[i].replace('"', '');
592                                line = donnees[i].split('_');
593                                
594                                res += '<option value="' + val + '">' + line[5] + ' ' + line[6] + '</option>';
595                            }
596                            
597                            res += '</select>' ;
598                        }
599                        
600                        $('#dialog').html(res);
601                          
602                        $( "#dialog" ).dialog({
603                            modal: true,
604                            buttons : {
605                                Valider: function(){
606                                    donnees = $('#dialog select option:selected').val();
607                                    donnees = donnees.split('_');
608                                    
609                                    if ( $.isNumeric(donnees[8]) )
610                                        $('#' + id + ' select[id="personne_morale_civilite"] option[value="' + $.trim(donnees[8]) + '"]').attr('selected','selected');
611                                    $('#' + id + ' input[id="personne_morale_denomination"]').val($.trim(donnees[5]));
612                                    $('#' + id + ' input[id="personne_morale_raison_sociale"]').val($.trim(donnees[12]));
613                                    $('#' + id + ' input[id="personne_morale_siret"]').val($.trim(donnees[6]));
614                                    $('#' + id + ' input[id="personne_morale_categorie_juridique"]').val($.trim(donnees[13]));
615                                    $('#' + id + ' input[id="personne_morale_nom"]').val($.trim(donnees[7]));
616                                    $('#' + id + ' input[id="personne_morale_prenom"]').val($.trim(donnees[9]));
617                                    
618                                    changeValInputDemandeur(id, donnees);
619                                    
620                                    $(this).dialog( "close" );
621                                }
622                            }
623                        });
624                    },
625                    async: false
626                });
627            }
628        );
629    }
630    
631    /*
632        Change les valeurs des champs en commun des particuliers et des personnes morales
633     * */
634    function changeValInputDemandeur(id, donnees){
635        
636        /*Teste si la valeur retournée est TRUE*/
637        if ( donnees[28] === 't' )
638            $('#' + id + ' input[id="notification"]').attr('checked', 'checked');
639        $('#' + id + ' input[id="frequent"]').attr('checked','checked');
640        $('#' + id + ' input[id="numero"]').val($.trim(donnees[14]));
641        $('#' + id + ' input[id="voie"]').val($.trim(donnees[15]));
642        $('#' + id + ' input[id="complement"]').val($.trim(donnees[16]));
643        $('#' + id + ' input[id="lieu_dit"]').val($.trim(donnees[17]));
644        $('#' + id + ' input[id="localite"]').val($.trim(donnees[18]));
645        $('#' + id + ' input[id="code_postal"]').val($.trim(donnees[19]));
646        $('#' + id + ' input[id="bp"]').val($.trim(donnees[20]));
647        $('#' + id + ' input[id="cedex"]').val($.trim(donnees[21]));
648        $('#' + id + ' input[id="pays"]').val($.trim(donnees[22]));
649        $('#' + id + ' input[id="division_territoriale"]').val($.trim(donnees[23]));
650        $('#' + id + ' input[id="telephone_fixe"]').val($.trim(donnees[24]));
651        $('#' + id + ' input[id="telephone_mobile"]').val($.trim(donnees[25]));
652        $('#' + id + ' input[id="indicatif"]').val($.trim(donnees[26]));
653        $('#' + id + ' input[id="courriel"]').val($.trim(donnees[27]));
654    }
655    
656    /*
657      Création des select pour la civilité      Création des select pour la civilité
658   * */   * */
659  function setSelectCivilite(){  function setSelectCivilite(){
# Line 515  function setSelectCivilite(){ Line 693  function setSelectCivilite(){
693  function createFieldset(name, className){  function createFieldset(name, className){
694      return '<fieldset class="cadre ui-corner-all ui-widget-content" id="fieldset' + className + '">' +      return '<fieldset class="cadre ui-corner-all ui-widget-content" id="fieldset' + className + '">' +
695                  '<legend class="ui-corner-all ui-widget-content ui-state-active">' + name + ' </legend>' +                  '<legend class="ui-corner-all ui-widget-content ui-state-active">' + name + ' </legend>' +
696                  '<input id="formsDemandeur" type="hidden" val=""/>'+                  '<input class="formsDemandeur" type="hidden" val=""/>'+
697                  '<div class="fieldsetContent " id="' + className + '">' +                  '<div class="fieldsetContent " id="' + className + '">' +
698                  '</div>' +                  '</div>' +
699                  '<div class="visualClear"></div>' +                  '<div class="visualClear"></div>' +
# Line 714  function showFormsDemande(){ Line 892  function showFormsDemande(){
892      $('#terrain_references_cadastrales').parent().parent().hide();      $('#terrain_references_cadastrales').parent().parent().hide();
893            
894      /*Cache les champs inutiles*/      /*Cache les champs inutiles*/
895      fieldTypeDemandeur('#petitionnaire', '', true);      fieldTypeDemandeur('#petitionnaire__0', '', true);
896            
897      $('#fieldsetpetitionnaire #formsDemandeur').val($('#petitionnaire').html());      $('#fieldsetpetitionnaire__0 .formsDemandeur').val($('#petitionnaire__0').html());
898            
899      addDatePicker( 'petitionnaire_particulier_date_naissance');      changeIdNameField('petitionnaire__0');
900        
901        addDatePicker('petitionnaire_particulier_date_naissance');
902  }  }
903    
904  /*  /*
# Line 728  function fieldTypeDemandeur(name,complem Line 908  function fieldTypeDemandeur(name,complem
908    
909      if ( particulier == true ){      if ( particulier == true ){
910                    
911          $( name + ' ' + name + complement + '_particulier_civilite').parent().parent().show();          $(name + ' select[id="particulier_civilite"] option[value=""]').attr('selected', 'selected');
912          $( name + ' ' + name + complement + '_particulier_nom').parent().parent().show();          $(name + ' input[id="particulier_nom"]').val('');
913          $( name + ' ' + name + complement + '_particulier_prenom').parent().parent().show();          $(name + ' input[id="particulier_prenom"]').val('');
914          $( name + ' ' + name + complement + '_particulier_date_naissance').parent().parent().show();          $(name + ' input[id="particulier_date_naissance"]').val('');
915          $( name + ' ' + name + complement + '_particulier_commune_naissance').parent().parent().show();          $(name + ' input[id="particulier_commune_naissance"]').val('');
916          $( name + ' ' + name + complement + '_particulier_departement_naissance').parent().parent().show();          $(name + ' input[id="particulier_departement_naissance"]').val('');
917                    
918          $( name + ' ' + name + complement + '_personne_morale_denomination').parent().parent().hide();          $( name + ' .particulier_fields').show();
919          $( name + ' ' + name + complement + '_personne_morale_raison_sociale').parent().parent().hide();          $( name + ' .personne_morale_fields').hide();
         $( name + ' ' + name + complement + '_personne_morale_siret').parent().parent().hide();  
         $( name + ' ' + name + complement + '_personne_morale_categorie_juridique').parent().parent().hide();  
         $( name + ' ' + name + complement + '_personne_morale_civilite').parent().parent().hide();  
         $( name + ' ' + name + complement + '_personne_morale_nom').parent().parent().hide();  
         $( name + ' ' + name + complement + '_personne_morale_prenom').parent().parent().hide();  
920      }      }
921      else{      else{
922                    
923          $( name + ' ' + name + complement + '_particulier_civilite').parent().parent().hide();          $(name + ' select[id="personne_morale_civilite"] option[value=""]').attr('selected', 'selected');
924          $( name + ' ' + name + complement + '_particulier_nom').parent().parent().hide();          $(name + ' input[id="personne_morale_denomination"]').val('');
925          $( name + ' ' + name + complement + '_particulier_prenom').parent().parent().hide();          $(name + ' input[id="personne_morale_raison_sociale"]').val('');
926          $( name + ' ' + name + complement + '_particulier_date_naissance').parent().parent().hide();          $(name + ' input[id="personne_morale_siret"]').val('');
927          $( name + ' ' + name + complement + '_particulier_commune_naissance').parent().parent().hide();          $(name + ' input[id="personne_morale_categorie_juridique"]').val('');
928          $( name + ' ' + name + complement + '_particulier_departement_naissance').parent().parent().hide();          $(name + ' input[id="personne_morale_nom"]').val('');
929                    $(name + ' input[id="personne_morale_prenom"]').val('');
930          $( name + ' ' + name + complement + '_personne_morale_denomination').parent().parent().show();          $( name + ' .particulier_fields').hide();
931          $( name + ' ' + name + complement + '_personne_morale_raison_sociale').parent().parent().show();          $( name + ' .personne_morale_fields').show();
         $( name + ' ' + name + complement + '_personne_morale_siret').parent().parent().show();  
         $( name + ' ' + name + complement + '_personne_morale_categorie_juridique').parent().parent().show();  
         $( name + ' ' + name + complement + '_personne_morale_civilite').parent().parent().show();  
         $( name + ' ' + name + complement + '_personne_morale_nom').parent().parent().show();  
         $( name + ' ' + name + complement + '_personne_morale_prenom').parent().parent().show();  
932      }      }
933  }  }
934    
# Line 771  function newInputReferenceCadastrale(){ Line 941  function newInputReferenceCadastrale(){
941              'type="text" ' +              'type="text" ' +
942              'maxlength="1" ' +              'maxlength="1" ' +
943              'size="1" ' +              'size="1" ' +
944              'value="" />' +              'value="" ' +
945                'onchange="testSeparator(this);"/>' +
946          '<input ' +          '<input ' +
947              'class="champFormulaire reference_cadastrale_custom_field" ' +              'class="champFormulaire reference_cadastrale_custom_field" ' +
948              'type="text" ' +              'type="text" ' +
# Line 781  function newInputReferenceCadastrale(){ Line 952  function newInputReferenceCadastrale(){
952              'value="" />';              'value="" />';
953  }  }
954    
955    function testSeparator(obj){
956    
957        if ( (obj.value != 'a' || obj.value != 'A') &&
958             obj.value != '/' ) {
959                
960            alert('Saisissez uniquement un A ou un / comme séparateur');
961            obj.value = '';
962        }
963    }
964    
965  // Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau  // Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau
966  // tableau de bord  // tableau de bord
967  function widget_bind_move_actions() {}  function widget_bind_move_actions() {}

Legend:
Removed from v.740  
changed lines
  Added in v.741

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26