/[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 655 by fmichon, Sun Nov 11 22:02:21 2012 UTC revision 664 by vpihour, Mon Nov 12 12:12:45 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() {
244  //          
245  //});      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            hideFields();
250      
251       if ( $('#date_demande').length > 0
252            && !$('#dossier_autorisation_type_detaille').is(':disabled')
253            && url.indexOf("form.php?obj=demande&action=1") != -1 ){
254            addNewFieldReferencesCadastrales();
255            $('#terrain_references_cadastrales').parent().parent().hide();
256            
257            reference_cadastrale = $('#terrain_references_cadastrales').val();
258            /*Formatage de la reference cadastrale*/
259            if ( reference_cadastrale != '' ){
260                i = 0 ;
261                
262                quartier = '';
263                for ( j = i ; j < reference_cadastrale.length ; j++ )
264                    if ( reference_cadastrale.charAt(j) >= 0 && reference_cadastrale.charAt(j) <= 9 ){
265                        quartier += reference_cadastrale.charAt(j);
266                        i++;
267                    }
268                    else
269                        break;
270                        
271                section ='';
272                for ( j = i ; j < reference_cadastrale.length ; j++ )
273                    if ( isAlphaOrParen(reference_cadastrale.charAt(j)) ){
274                        section += reference_cadastrale.charAt(j);
275                        i++;
276                    }
277                    else
278                        break;
279                
280                parcelle = '';
281                for ( j = i ; j < reference_cadastrale.length ; j++ )
282                    if ( reference_cadastrale.charAt(j) >= 0 && reference_cadastrale.charAt(j) <= 9 ){
283                        parcelle += reference_cadastrale.charAt(j);
284                        i++;
285                    }
286                    else
287                        break;
288                
289                k = 0;
290                if ( i < reference_cadastrale.length ){
291                    
292                    var parcelles = new Array();
293                    for ( j = i ; j < reference_cadastrale.length ; j++ )
294                        if ( isAlphaOrParen(reference_cadastrale.charAt(j)) ){
295                            k++;
296                            parcelles[k] = reference_cadastrale.charAt(j);
297                            k++;
298                            parcelles[k] = '';
299                        }
300                        else {
301                            parcelles[k] += reference_cadastrale.charAt(j);
302                        }
303                }
304                
305                if ( k > 0 ){
306                            
307                    for ( j = 0 ; j < k ; j+=2 )
308                        $('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale());
309                }
310                
311                i = 1;
312                $('.reference_cadastrale_custom_field').each(
313                    function(index) {
314                        ( index == 0 ) ? $(this).val(quartier) : '' ;
315                        ( index == 1 ) ? $(this).val(section) : '' ;
316                        ( index == 2 ) ? $(this).val(parcelle) : '' ;
317                        
318                        if ( k > 0 && index > 2 ){
319                            
320                            $(this).val(parcelles[i++])
321                        }
322                    }
323                );
324                
325                actionFormReferenceCadastrale();
326            }
327       }
328    });
329    
330    /*
331        Test str est une lettre de l'alphabet
332     * */
333    function isAlphaOrParen(str) {
334        return /^[a-zA-Z\/]+$/.test(str);
335    }
336    
337    /*
338        Ajoute les ations spécifiques pour le formulaire personnalisé d'ajout de référence cadastrale
339     * */
340    function actionFormReferenceCadastrale(){
341        $('form').submit(
342            function(){
343                
344                var reference_cadastrale = '';
345                
346                $('.reference_cadastrale_custom_field').each(
347                    function(){
348                        
349                        reference_cadastrale += $(this).val();
350                    }
351                );
352                
353                $('#terrain_references_cadastrales').val(reference_cadastrale);
354            }
355        );
356        
357        $('#moreFieldReferenceCadastrale').click( function() {
358            $('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale());
359        });
360    }
361    
362    /*
363        Met à jour le select demande_type dès qu'un dossier_autorisation_type_detaille est choisi
364     * */
365  function changeDemandeType(){  function changeDemandeType(){
366            
367      var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();      var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();
# Line 251  function changeDemandeType(){ Line 369  function changeDemandeType(){
369      if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){      if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){
370                    
371          changeDataSelect('demande_type','dossier_autorisation_type_detaille');          changeDataSelect('demande_type','dossier_autorisation_type_detaille');
372            if ( $('#demande_type option').size() < 2 )
373                showFormsDemande();
374                    
375         $('#demande_type').parent().parent().show();         $('#demande_type').parent().parent().show();
376                
377         $('.terrain_references_cadastrales_custom').append(         addNewFieldReferencesCadastrales();
            '<div class="field field-type-text" >'+  
                 '<div class="form-libelle">' +  
                     '<label '+  
                         'class="libelle-terrain_references_cadastrales" '+  
                         'for="terrain_references_cadastrales">'+  
                         ' terrain_references_cadastrales '+  
                     '</label>' +  
                 '</div>' +  
                 '<div class="form-content reference_cadastrale_custom_fields">' +  
                     '<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="" />' +  
                 '</div>' +  
            '</div>' +  
            '<div id="moreFieldReferenceCadastrale"> + ajouter d\'autres champs</div>'  
        );  
378                
379         $('#moreFieldReferenceCadastrale').click( function() {         actionFormReferenceCadastrale();
             $('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale());  
         });  
380                    
         $('form').submit(  
             function(){  
                   
                 var reference_cadastrale = '';  
                   
                 $('.reference_cadastrale_custom_field').each(  
                     function(){  
                           
                         reference_cadastrale += $(this).val();  
                     }  
                 );  
                   
                 $('#terrain_references_cadastrales').val(reference_cadastrale);  
             }  
         );  
           
         $('.terrain_references_cadastrales_custom:').find(">:first-child").hide();  
381      }      }
382      else {      else {
383          hideFields();          hideFields();
384      }      }
385  }  }
386    
387    /*
388        Ajoute le code HTML des champs pour les références cadastrales
389     * */
390    function addNewFieldReferencesCadastrales(){
391        $('.references_cadastrales_new_field').remove();
392        $('#moreFieldReferenceCadastrale').remove();
393        $('.localisation .fieldsetContent').prepend(
394           '<div class="field field-type-text references_cadastrales_new_field" >'+
395                '<div class="form-libelle">' +
396                    '<label '+
397                        'class="libelle-terrain_references_cadastrales" '+
398                        'for="terrain_references_cadastrales">'+
399                        ' terrain_references_cadastrales '+
400                    '</label>' +
401                '</div>' +
402                '<div class="form-content reference_cadastrale_custom_fields">' +
403                    '<input ' +
404                        'class="champFormulaire reference_cadastrale_custom_field" ' +
405                        'type="text" ' +
406                        'onchange="VerifNum(this)" ' +
407                        'maxlength="3" ' +
408                        'size="3" ' +
409                        'value="" />' +
410                    '<input ' +
411                        'class="champFormulaire reference_cadastrale_custom_field" ' +
412                        'type="text" ' +
413                        'maxlength="2" ' +
414                        'size="2" ' +
415                        'value="" />' +
416                    '<input ' +
417                        'class="champFormulaire reference_cadastrale_custom_field" ' +
418                        'type="text" ' +
419                        'onchange="VerifNum(this)" ' +
420                        'maxlength="4" ' +
421                        'size="4" ' +
422                        'value="" />' +
423                '</div>' +
424           '</div>' +
425           '<div class="field field-type-text" id="moreFieldReferenceCadastrale">' +
426                '<div class="form-libelle"></div>' +
427                '<div class="form-content">' +
428                    ' + ajouter d\'autres champs' +
429                '</div>' +
430            '</div>'
431       );
432    }
433    
434    /*
435        Cache les champs inutules
436     * */    
437  function hideFields(){  function hideFields(){
438      $('.bloc').each(      $('.bloc').each(
439          function(){          function(){
# Line 329  function hideFields(){ Line 447  function hideFields(){
447      $('#demande_type').parent().parent().hide();      $('#demande_type').parent().parent().hide();
448  }  }
449    
450    /*
451        Affiche les champs dont on a besoin
452     * */
453  function showFormsDemande(){  function showFormsDemande(){
454      $('.bloc').each(      $('.bloc').each(
455          function(){          function(){
# Line 339  function showFormsDemande(){ Line 460  function showFormsDemande(){
460            
461      $('.field-type-text').show();      $('.field-type-text').show();
462      $('input[type=submit]').show();      $('input[type=submit]').show();
463        $('.terrain_references_cadastrales_custom').hide();
464        
465        $('#terrain_references_cadastrales').parent().parent().hide();
466  }  }
467    
468    /*
469        Action au clique sur le bouton " + ajouter d'autres champs"
470     * */
471  function newInputReferenceCadastrale(){  function newInputReferenceCadastrale(){
472      return '<input ' +      return '<input ' +
473              'class="champFormulaire reference_cadastrale_custom_field" ' +              'class="champFormulaire reference_cadastrale_custom_field" ' +
# Line 356  function newInputReferenceCadastrale(){ Line 483  function newInputReferenceCadastrale(){
483              'size="4" ' +              'size="4" ' +
484              'value="" />';              'value="" />';
485  }  }
486    
487    // Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau
488    // tableau de bord
489    function widget_bind_move_actions() {}
490    function widget_bind_add_action() {}
491    function widget_bind_edit_actions(widget_selector) {}
492    

Legend:
Removed from v.655  
changed lines
  Added in v.664

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26