/[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 626 by vpihour, Wed Nov 7 16:54:25 2012 UTC revision 664 by vpihour, Mon Nov 12 12:12:45 2012 UTC
# Line 177  function popupIt(objsf, link) { Line 177  function popupIt(objsf, link) {
177          };          };
178  })(jQuery);  })(jQuery);
179    
180  function changeQuartier(){  function changeDataSelect(tn, ds, joker){
181                
182      var idArrondissement = $("#arrondissement option:selected").val();      var id = $("#"+ds+" option:selected").val();
183      link = "../app/listeQuartier.php?idx=" + idArrondissement;      link = "../app/listData.php?idx=" + id + "&tn=" + tn + "&ds=" + ds;
184      $.ajax({      $.ajax({
185          type: "GET",          type: "GET",
186          url: link,          url: link,
187          cache: false,          cache: false,
188            dataType: "json",
189          success: function(html){          success: function(html){
190              if ( html !== '' ){              
191                                $('#'+tn).empty();
192                  $('#quartier').empty();              
193                  $('#quartier').append(              if ( joker == true )
194                    $('#'+tn).append(
195                      '<option value="" selected="selected">*</option>'                      '<option value="" selected="selected">*</option>'
196                  );                  );
197                else
198                    $('#'+tn).append(
199                        '<option value="" selected="selected">Choisir ' + tn + '</option>'
200                    );
201                
202                if ( html !== '' ){
203                                    
204                  html = html.split(';');                  html = html.split(';');
205                  for ( i = 0 ; i < html.length - 1 ; i++ ){                  for ( i = 0 ; i < html.length - 1 ; i++ ){
206                                            
207                      html_temp = html[i].split('_');                      html_temp = html[i].split('_');
208                      $('#quartier').append(                      $('#'+tn).append(
209                          '<option value="'+html_temp[0]+'" >'+html_temp[1]+'</option>'                          '<option value="'+html_temp[0]+'" >'+html_temp[1]+'</option>'
210                      );                      );
211                  }                  }
# Line 206  function changeQuartier(){ Line 214  function changeQuartier(){
214          async: false          async: false
215      });      });
216  }  }
217    function vuploadMulti(champ) {
218        //
219        if (fenetreouverte == true) {
220            pfenetre.close();
221        }
222        //
223        pfenetre = window.open("../spg/upload.php?origine="+champ+"&form="+$('input[name='+champ+']').closest('form').attr('name'),"upload","width=400,height=300,top=120,left=120");
224        //pfenetre = window.open("../spg/upload2.php?origine="+champ,"upload2","width=300,height=100,top=120,left=120");
225        //
226        fenetreouverte = true;
227    }
228    function tmpUpload(champ) {
229        //
230        if (fenetreouverte == true) {
231            pfenetre.close();
232        }
233        //
234        pfenetre = window.open("../app/tmpUpload.php?origine="+champ+"&form="+$('input[name='+champ+']').closest('form').attr('name'),"upload","width=400,height=300,top=120,left=120");
235        //pfenetre = window.open("../spg/upload2.php?origine="+champ,"upload2","width=300,height=100,top=120,left=120");
236        //
237        fenetreouverte = true;
238    }
239    
240    /*
241        Ajoute le formulaire d'jout de référence cadastrale personnalisé
242     * */
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(){
366        
367        var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();
368        
369        if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){
370            
371            changeDataSelect('demande_type','dossier_autorisation_type_detaille');
372            if ( $('#demande_type option').size() < 2 )
373                showFormsDemande();
374            
375           $('#demande_type').parent().parent().show();
376          
377           addNewFieldReferencesCadastrales();
378          
379           actionFormReferenceCadastrale();
380            
381        }
382        else {
383            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(){
438        $('.bloc').each(
439            function(){
440                if ( !$(this).hasClass('dossier_type') && !$(this).hasClass('dossier_type_demande_date') )
441                    $(this).hide();
442            }
443        );
444        
445        $('.field-type-text').hide();
446        $('input[type=submit]').hide();
447        $('#demande_type').parent().parent().hide();
448    }
449    
450    /*
451        Affiche les champs dont on a besoin
452     * */
453    function showFormsDemande(){
454        $('.bloc').each(
455            function(){
456                if ( !$(this).hasClass('dossier_type') && !$(this).hasClass('dossier_type_demande_date') )
457                    $(this).show();
458            }
459        );
460        
461        $('.field-type-text').show();
462        $('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(){
472        return '<input ' +
473                'class="champFormulaire reference_cadastrale_custom_field" ' +
474                'type="text" ' +
475                'maxlength="1" ' +
476                'size="1" ' +
477                'value="" />' +
478            '<input ' +
479                'class="champFormulaire reference_cadastrale_custom_field" ' +
480                'type="text" ' +
481                'onchange="VerifNum(this)" ' +
482                'maxlength="4" ' +
483                'size="4" ' +
484                '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.626  
changed lines
  Added in v.664

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26