/[openfoncier]/trunk/app/js/script.js
ViewVC logotype

Diff of /trunk/app/js/script.js

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

revision 938 by fmichon, Fri Nov 30 13:37:57 2012 UTC revision 1005 by fmichon, Thu Dec 6 15:48:07 2012 UTC
# Line 62  function changeDataSelect(tn, ds, joker) Line 62  function changeDataSelect(tn, ds, joker)
62                    
63      var id = $("#"+ds+" option:selected").val();      var id = $("#"+ds+" option:selected").val();
64      link = "../app/listData.php?idx=" + id + "&tn=" + tn + "&ds=" + ds;      link = "../app/listData.php?idx=" + id + "&tn=" + tn + "&ds=" + ds;
65        var val_tn = $('#'+tn).val();
66      $.ajax({      $.ajax({
67          type: "GET",          type: "GET",
68          url: link,          url: link,
# Line 70  function changeDataSelect(tn, ds, joker) Line 71  function changeDataSelect(tn, ds, joker)
71          success: function(html){          success: function(html){
72                            
73              $('#'+tn).empty();              $('#'+tn).empty();
74                            var selected = "";
75                if(val_tn == "") {
76                    selected=' selected="selected"';
77                }
78              if ( joker == true )              if ( joker == true )
79                  $('#'+tn).append(                  $('#'+tn).append(
80                      '<option value="" selected="selected">*</option>'                      '<option value=""'+selected+'>*</option>'
81                  );                  );
82              else              else {
83                  $('#'+tn).append(                  $('#'+tn).append(
84                      '<option value="" selected="selected">Choisir ' + tn + '</option>'                      '<option value=""'+selected+'>Choisir ' + tn + '</option>'
85                  );                  );
86                            }
87              if ( html !== '' ){              if ( html !== '' ){
88                                    
89                  html = html.split(';');                  html = html.split(';');
90                  for ( i = 0 ; i < html.length - 1 ; i++ ){                  for ( i = 0 ; i < html.length - 1 ; i++ ){
91                                            
92                      html_temp = html[i].split('_');                      html_temp = html[i].split('_');
93                        selected = "";
94                        if(val_tn == html_temp[0]) {
95                            selected=' selected="selected"';
96                        }
97                      $('#'+tn).append(                      $('#'+tn).append(
98                          '<option value="'+html_temp[0]+'" >'+html_temp[1]+'</option>'                          '<option value="'+html_temp[0]+'"'+selected+' >'+html_temp[1]+'</option>'
99                      );                      );
100                        
101                  }                  }
102              }              }
103          },          },
# Line 279  function popupIt(objsf, link, width, hei Line 288  function popupIt(objsf, link, width, hei
288              modal: true,              modal: true,
289              width: width,              width: width,
290              height: height,              height: height,
291                position: 'center',
292            });            });
293          },          },
294          async : false          async : false
# Line 342  function returnToTab(objsf) { Line 352  function returnToTab(objsf) {
352  function getDemandeurId(type) {  function getDemandeurId(type) {
353      var id_demandeur=$('#id_retour').val();      var id_demandeur=$('#id_retour').val();
354      if($.isNumeric(id_demandeur)) {      if($.isNumeric(id_demandeur)) {
         if(type != 'petitionnaire') {  
             $('#add_'+type).hide();  
         }  
           
355          afficherDemandeur(id_demandeur,type);          afficherDemandeur(id_demandeur,type);
356          om_initialize_content();          om_initialize_content();
357      }      }
# Line 360  function afficherDemandeur(id,type) { Line 366  function afficherDemandeur(id,type) {
366          url: '../app/afficher_synthese_demandeur.view.php?iddemandeur='+id+'&type='+type,          url: '../app/afficher_synthese_demandeur.view.php?iddemandeur='+id+'&type='+type,
367          cache: false,          cache: false,
368          success: function(html){          success: function(html){
369              $(html).insertBefore('#add_'+type).fadeIn(500);;              $(html).insertBefore('#add_'+type).fadeIn(500);
370          }  
371            },
372            async:false
373      });      });
374        affichageBoutonsDemandeurs();
375  }  }
376    
377  /**  /**
# Line 371  function afficherDemandeur(id,type) { Line 380  function afficherDemandeur(id,type) {
380  function editDemandeur(obj,id,type,id_css) {  function editDemandeur(obj,id,type,id_css) {
381      popupIt(type,      popupIt(type,
382                  '../scr/sousform.php?obj='+obj+'&action=1'+                  '../scr/sousform.php?obj='+obj+'&action=1'+
383                  '&retourformulaire=demande&idx='+id, 780, 500,                  '&retourformulaire=demande&idx='+id, 780, 'auto',
384                  replaceDemandeur, {'type':type,'id': id, 'id_css':id_css});                  replaceDemandeur, {'type':type,'id': id, 'id_css':id_css});
385          changeDemandeurType('qualite');      affichageBoutonsDemandeurs();
         addSearchIcon();  
         addDivDialog('.bloc_demandeur');  
386  }  }
387    
388  /**  /**
# Line 400  function removeDemandeur(id) { Line 407  function removeDemandeur(id) {
407      if(div_class == "delegataire") {      if(div_class == "delegataire") {
408          $('#add_delegataire').fadeIn(500);          $('#add_delegataire').fadeIn(500);
409      }      }
410      if(div_class == "petitionnaire_principal") {      affichageBoutonsDemandeurs();
411    }
412    
413    /**
414     * Fonction permettant d'afficher et cacher les boutons d'ajout de demandeurs
415     */
416    function affichageBoutonsDemandeurs(){
417        // Affichage du bouton d'ajout du petitionnaire principal
418        if($('input[name=petitionnaire_principal][type=hidden]').size() == 1) {
419            $('#add_petitionnaire_principal').hide();
420        } else {
421          $('#add_petitionnaire_principal').fadeIn(500);          $('#add_petitionnaire_principal').fadeIn(500);
422      }      }
423        // Affichage du bouton d'ajout du delegataire
424        if($('input[name=petitionnaire_principal][type=hidden]').size() == 1
425           || $('input[name=delegataire][type=hidden]').size() == 1) {
426            $('#delegataire').fadeIn(500);
427            if($('input[name=delegataire][type=hidden]').size() == 0) {
428                $('#add_delegataire').fadeIn(500);
429            } else {
430                $('#add_delegataire').hide();
431            }
432        } else {
433            $('#delegataire').hide();
434        }
435        // Affichage du bouton d'ajout de petitionnaires
436        if($('input[name=petitionnaire_principal][type=hidden]').size() == 0) {
437            $('#add_petitionnaire').hide();
438        } else {
439            $('#add_petitionnaire').fadeIn(500);
440        }
441  }  }
442    
443  /**  /**
# Line 415  $(function() { Line 450  $(function() {
450          addSearchIcon();          addSearchIcon();
451          addDivDialog('.bloc_demandeur');          addDivDialog('.bloc_demandeur');
452      }      }
453      if($('input[name=petitionnaire_principal][type=hidden]').size() == 1) {      affichageBoutonsDemandeurs();
         $('#add_petitionnaire_principal').hide();  
     }  
     if($('input[name=delegataire][type=hidden]').size() == 1) {  
         $('#add_delegataire').hide();  
     }  
454      // Bind de la fonction permettant l'ajout du pétitionnaire principal      // Bind de la fonction permettant l'ajout du pétitionnaire principal
455      $("#formulaire").on("click","#add_petitionnaire_principal",  function() {      $("#formulaire").on("click","#add_petitionnaire_principal",  function() {
456          popupIt('petitionnaire',          popupIt('petitionnaire',
457                  '../scr/sousform.php?obj=petitionnaire&action=0'+                  '../scr/sousform.php?obj=petitionnaire&action=0'+
458                  '&retourformulaire=demande&principal=true', 780, 500,                  '&retourformulaire=demande&principal=true', 780, 'auto',
459                  getDemandeurId, 'petitionnaire_principal');                  getDemandeurId, 'petitionnaire_principal');
460      });      });
461      // Bind de la fonction permettant l'ajout du délégataire      // Bind de la fonction permettant l'ajout du délégataire
462      $("#formulaire").on("click","#add_delegataire", function(event) {      $("#formulaire").on("click","#add_delegataire", function(event) {
463          popupIt('delegataire',          popupIt('delegataire',
464                  '../scr/sousform.php?obj=delegataire&action=0'+                  '../scr/sousform.php?obj=delegataire&action=0'+
465                  '&retourformulaire=demande', 780, 500,                  '&retourformulaire=demande', 780, 'auto',
466                  getDemandeurId, 'delegataire');                  getDemandeurId, 'delegataire');
467      });      });
468      // Bind de la fonction permettant l'ajout des pétitionnaires      // Bind de la fonction permettant l'ajout des pétitionnaires
469      $("#formulaire").on("click","#add_petitionnaire", function(event) {      $("#formulaire").on("click","#add_petitionnaire", function(event) {
470          popupIt('petitionnaire',          popupIt('petitionnaire',
471                  '../scr/sousform.php?obj=petitionnaire&action=0'+                  '../scr/sousform.php?obj=petitionnaire&action=0'+
472                  '&retourformulaire=demande', 780, 500,                  '&retourformulaire=demande', 780, 'auto',
473                  getDemandeurId, 'petitionnaire');                  getDemandeurId, 'petitionnaire');
474      });      });
475    
476                    
477      url = document.location + "" ;      url = document.location + "" ;
478        if (url.indexOf("form.php?obj=demande&") != -1
479            && url.indexOf("&action=3") == -1 ) {
480            changeDemandeType();
481        }
482    
483      if (url.indexOf("form.php?obj=demande&") != -1      if (url.indexOf("form.php?obj=demande&") != -1
484          && url.indexOf("&action=0") != -1 ){          && url.indexOf("&action=0") != -1 ){
485          /*Cache les champs avant que dossier_autorisation_type_detaille soit choisi*/          /*Cache les champs avant que dossier_autorisation_type_detaille soit choisi*/
486          hideFields();          hideFields();
487      }      }
488          
489     if (url.indexOf("form.php?obj=demande&") != -1     if (url.indexOf("form.php?obj=demande&") != -1
490          && url.indexOf("&action=1") != -1 ){          && url.indexOf("&action=1") != -1 ){
491                    
# Line 588  function formatFieldReferenceCadastrale( Line 623  function formatFieldReferenceCadastrale(
623   */   */
624  function addSearchIcon(){  function addSearchIcon(){
625    
626      $('.search_particulier_fields, .search_personne_morale_fields').each(function() {      $("#form-content:not(.form-is-valid) .search_particulier_fields,"+
627          "#form-content:not(.form-is-valid) .search_personne_morale_fields").each(function() {
628      /*Ajout de l'icône après le champs dénomination et nom de la personne morale*/      /*Ajout de l'icône après le champs dénomination et nom de la personne morale*/
629    
630              $(this).              $(this).
# Line 652  function addActionSearchIcon(id){ Line 688  function addActionSearchIcon(id){
688                  url: "../app/findPetitionnaire.php" + donnees ,                  url: "../app/findPetitionnaire.php" + donnees ,
689                  cache: false,                  cache: false,
690                  success: function(obj){                  success: function(obj){
                     console.log($.parseJSON(obj));  
691                      var freq = $.parseJSON(obj);                      var freq = $.parseJSON(obj);
692                      var res='';                      var res='';
693                      /*Si la recherche a donné des résultats*/                      /*Si la recherche a donné des résultats*/
# Line 693  function addActionSearchIcon(id){ Line 728  function addActionSearchIcon(id){
728    
729                                  }                                  }
730                                  var id = $('#dialog select option:selected').val();                                  var id = $('#dialog select option:selected').val();
731                                  ajaxIt('petitionnaire',                                  if($.isNumeric(id)) {
732                                  '../scr/sousform.php?obj=petitionnaire&action=1&retourformulaire=demande&idx='+id);                                      ajaxIt('petitionnaire',
733                                        '../scr/sousform.php?obj=petitionnaire&action=1&retourformulaire=demande&idx='+id);
734                                    }
735                                  // Fermeture de l'overlay                                  // Fermeture de l'overlay
736                                  $(this).dialog( "close" );                                  $(this).dialog( "close" ).empty();
737                              }                              }
738                          }                          }
739                      });                      });
# Line 872  function changeDemandeType(){ Line 909  function changeDemandeType(){
909            
910      var idDossierAutorisationTypeDetaille =      var idDossierAutorisationTypeDetaille =
911          $("#dossier_autorisation_type_detaille option:selected").val();          $("#dossier_autorisation_type_detaille option:selected").val();
       
912      /* Récupère les données saisies dans les champs pour la référence cadastrale */      /* Récupère les données saisies dans les champs pour la référence cadastrale */
913      getDataFieldReferenceCadastrale();          getDataFieldReferenceCadastrale();    
914            
# Line 883  function changeDemandeType(){ Line 919  function changeDemandeType(){
919              showFormsDemande();              showFormsDemande();
920                    
921         $('#demande_type').parent().parent().show();         $('#demande_type').parent().parent().show();
         
        formatFieldReferenceCadastrale();  
922      }      }
923      else {      else {
924          hideFields();          hideFields();
# Line 939  function hiddenSeparatorField(){ Line 973  function hiddenSeparatorField(){
973                  'value=";" />';                  'value=";" />';
974  }  }
975    
976    /**
977     * Test si la demande est sur dossier existant ou non
978     **/
979    function isDossierExistant() {
980        var id_demande_type = $('#demande_type').val();
981        $.ajax({
982                    type: "GET",
983                    url: "../app/getDemandeNature.php?iddemandetype=" + id_demande_type ,
984                    cache: false,
985                    success: function(val){
986                        return val;
987                    }
988                });
989    }
990  /*  /*
991      Ajout d'une nouvelle ligne de champ      Ajout d'une nouvelle ligne de champ
992   * */   * */
993  function fieldReferenceCadastraleBase(){  function fieldReferenceCadastraleBase(){
994      return '<input ' +      var reference_cadastrale = '<input ' +
995                  'class="champFormulaire reference_cadastrale_custom_field" ' +                  'class="champFormulaire reference_cadastrale_custom_field" ' +
996                  'type="text" ' +                  'type="text" ' +
997                  'onchange="VerifNum(this)" ' +                  'onchange="VerifNum(this)" ' +
998                  'maxlength="4" ' +                  'maxlength="4" ' +
999                  'size="4" ' +                  'size="4" ';
1000                  'value="" />' +      // désactivation des champs de référence cadastrale
1001              '<input ' +      if(isDossierExistant() != 'NOUV') {
1002            reference_cadastrale += 'disabled="disabled" ';
1003        }
1004        reference_cadastrale += 'value="" />';
1005    
1006        reference_cadastrale += '<input ' +
1007                  'class="champFormulaire reference_cadastrale_custom_field" ' +                  'class="champFormulaire reference_cadastrale_custom_field" ' +
1008                  'type="text" ' +                  'type="text" ' +
1009                  'maxlength="3" ' +                  'maxlength="3" ' +
1010                  'size="3" ' +                  'size="3" ';
1011                  'value="" '+      if(isDossierExistant() != 'NOUV') {
1012                  'onchange="if ( !isAlpha(this.value) ){ alert(\'Vous ne devez saisir que des lettres dans ce champs.\'); this.value = \'\'; }"/>' +          reference_cadastrale += 'disabled="disabled" ';
1013              '<input ' +      }
1014        reference_cadastrale += 'value="" '+
1015                    'onchange="if ( !isAlpha(this.value) ){ alert(\'Vous ne devez saisir que des lettres dans ce champs.\'); this.value = \'\'; }"/>';
1016        reference_cadastrale += '<input ' +
1017                  'class="champFormulaire reference_cadastrale_custom_field" ' +                  'class="champFormulaire reference_cadastrale_custom_field" ' +
1018                  'type="text" ' +                  'type="text" ' +
1019                  'onchange="VerifNum(this)" ' +                  'onchange="VerifNum(this)" ' +
1020                  'maxlength="5" ' +                  'maxlength="5" ' +
1021                  'size="5" ' +                  'size="5" ';
1022                  'value="" />' +      if(isDossierExistant() != 'NOUV') {
1023              '<span id="moreFieldReferenceCadastrale' + $('.moreFieldReferenceCadastrale').length + '" class="moreFieldReferenceCadastrale">' +          reference_cadastrale += 'disabled="disabled" ';
1024        }
1025        reference_cadastrale += 'value="" />';
1026        if(isDossierExistant() != 'NOUV') {
1027            reference_cadastrale += '<span id="moreFieldReferenceCadastrale' +
1028            $('.moreFieldReferenceCadastrale').length +
1029            '" class="moreFieldReferenceCadastrale">' +
1030                  hiddenSeparatorField() +                  hiddenSeparatorField() +
1031                  ' + ajouter d\'autres champs' +                  ' + ajouter d\'autres champs' +
1032              '</span>';              '</span>';
1033        }
1034        
1035        
1036        return reference_cadastrale;
1037  }  }
1038    
1039  /**  /**
# Line 994  function showFormsDemande(){ Line 1060  function showFormsDemande(){
1060              $(this).show();              $(this).show();
1061          }          }
1062      );      );
1063            formatFieldReferenceCadastrale();
1064      $('.field-type-text').show();      $('.field-type-text').show();
1065      $('input[type=submit]').show();      $('input[type=submit]').show();
1066      $('.terrain_references_cadastrales_custom').hide();      $('.terrain_references_cadastrales_custom').hide();
# Line 1047  function om_initialize_content() { Line 1113  function om_initialize_content() {
1113      changeDemandeurType('qualite');      changeDemandeurType('qualite');
1114      addSearchIcon();      addSearchIcon();
1115      addDivDialog('.bloc_demandeur');      addDivDialog('.bloc_demandeur');
1116        
1117  }  }
1118    
1119  /*  /*

Legend:
Removed from v.938  
changed lines
  Added in v.1005

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26