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

Annotation of /trunk/app/js/script.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (hide annotations)
Fri Nov 9 17:02:00 2012 UTC (12 years, 2 months ago) by vpihour
File MIME type: application/javascript
File size: 12111 byte(s)
Ajout d'un nouveau formulaire pour les références cadastrales

1 fraynaud 88 // specific openfoncier ========================================================
2 nhaye 585 // OnReady
3     $(function(){
4     // Document is ready
5     $('#avis_code_barre_form #consultation').focus();
6     });
7 fraynaud 88
8 nhaye 585
9 fraynaud 88 function bible(){
10     if(fenetreouverte==true)
11     pfenetre.close();
12     var ev=document.f2.evenement.value;
13     var idx=document.f2.dossier.value;
14 fraynaud 343 pfenetre=window.open("../app/bible.php?ev="+ev+"&idx="+idx,"bible","scrollbars=yes,width=600,height=600,top=120,left=120");
15 fraynaud 88 fenetreouverte=true;
16     }
17    
18     function bible2()
19     {
20     if(fenetreouverte==true)
21     pfenetre.close();
22     var ev=document.f2.evenement.value;
23     var idx=document.f2.dossier.value;
24 fraynaud 343 pfenetre=window.open("../app/bible2.php?ev="+ev+"&idx="+idx,"bible","scrollbars=yes,width=600,height=600,top=120,left=120");
25 fraynaud 88 fenetreouverte=true;
26     }
27    
28     function bible_auto(){
29     if(fenetreouverte==true)
30     pfenetre.close();
31     var ev=document.f2.evenement.value;
32     var idx=document.f2.dossier.value;
33 fraynaud 90 pfenetre=window.open("../app/bible_auto.php?idx="+idx+"&ev="+ev,"evenement","width=600,height=300,top=120,left=120");
34 fraynaud 88 fenetreouverte=true;
35     }
36    
37     function dossierads_d(debut)
38     {
39     //if(fenetreouverte==true)
40     window.location="../pdf/pdfetat.php?obj=dossier_ads_d&nature="
41     +document.f1.nature.value+"&idx=demo&datedebut="
42     +document.f1.datedebut.value+"&datefin="+document.f1.datefin.value;
43     }
44    
45     function dossierdepot()
46     {
47     //if(fenetreouverte==true)
48     window.location="../pdf/pdfetat.php?obj=dossier_depot&nature="+
49     document.f1.nature.value+"&idx=demo&datedebut="+
50     document.f1.datedebut.value+"&datefin="+document.f1.datefin.value;
51     }
52    
53     function dossierads()
54     {
55     //if(fenetreouverte==true)
56     window.location="../pdf/pdfetat.php?obj=dossier_ads&nature="+
57     document.f1.nature.value+"&idx=demo&datedebut="+
58     document.f1.datedebut.value+"&datefin="+document.f1.datefin.value;
59     }
60    
61 fraynaud 271
62     function VerifNumdec(champ) {
63     champ.value = champ.value.replace(",", "."); // remplacement de la virgule
64     //if (champ.value.lastIndexOf(".") == -1){ // champ decimal
65     if (isNaN(champ.value)) {
66     alert(msg_alert_error_verifnum);
67     champ.value = "";
68     return;
69     }
70     //}
71    
72     }
73 vpihour 536 /* -- Debut -- */
74 vpihour 534 function messageIt(objsf, link, empty) {
75     // recuperation du terme recherche
76     var recherche = document.getElementById("recherchedyn");
77     if (recherche != null) {
78     link += "&recherche="+recherche.value;
79     }else {
80     link += "&recherche=";
81     }
82 vpihour 558 // execution de la requete en GET
83 vpihour 534 $.ajax({
84     type: "GET",
85     url: link,
86     cache: false,
87     success: function(html){
88     (empty == true )?$("#sousform-"+objsf).empty():'';
89     $("#sousform-"+objsf).append(html);
90     om_initialize_content();
91     },
92     async: false
93     });
94     }
95 vpihour 536
96     /* Plugin jQuery qui lance un espèce d'appel AJAX vers un script PHP de téléchargement de fichier*/
97     jQuery.download = function(url, data, method){
98     //url and data options required
99     if( url && data ){
100     //data can be string of parameters or array/object
101     data = typeof data == 'string' ? data : jQuery.param(data);
102     //split params into form inputs
103     var inputs = '';
104     jQuery.each(data.split('&'), function(){
105     var pair = this.split('=');
106     inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />';
107     });
108     //send request
109     jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
110     .prependTo('body').submit().remove();
111     };
112     };
113    
114 nhaye 544 /* -- FIN -- */
115     function popupIt(objsf, link) {
116     // Insertion du conteneur du dialog
117     var dialog = $('<div id=\"sousform-'+objsf+'\"></div>').insertAfter('.formControls');
118     $('<input type=\"text\" name=\"recherchedyn\" id=\"recherchedyn\" value=\"\" class=\"champFormulaire\" style=\"display:none\" />').insertAfter('#sousform-'+objsf);
119    
120     // execution de la requete passee en parametre
121     // (idem ajaxIt + callback)
122     $.ajax({
123     type: "GET",
124     url: link,
125     cache: false,
126     success: function(html){
127     //Suppression d'un precedent dialog
128     dialog.empty();
129     //Ajout du contenu recupere
130     dialog.append(html);
131     //Initialisation du theme OM
132     om_initialize_content();
133     //Creation du dialog
134     $(dialog).dialog({
135     //OnClose suppression du contenu
136     close: function(ev, ui) {
137 nhaye 557 // Si le formulaire est submit et valide
138     var valid=$('#sousform-'+objsf+' div.ui-state-valid');
139     if(valid.length > 0) {
140 nhaye 614 document.location.href="../scr/tab.php?obj="+$.getQuery('obj')+"&premier="+$.getQuery('premier')
141     +"&advs_id="+$.getQuery('advs_id')+"&recherche="+$.getQuery('recherche')+"&tricol="+$.getQuery('tricol')
142     +"&selectioncol="+$.getQuery('selectioncol');
143 nhaye 557 }
144 nhaye 544 $(this).remove();
145     },
146     resizable: false,
147     modal: true,
148     width: 700,
149     height: 520,
150     });
151     },
152     async : false
153     });
154     //Modification des boutons retours du sous formulaire pour fermer le dialog
155     $('#sousform-'+objsf).on("mousedown",'a.retour',function() {
156     $('#sousform-'+objsf+' a.retour').attr('onclick','');
157     });
158     $('#sousform-'+objsf).on("click",'a.retour',function() {
159     $(dialog).dialog('close').remove();
160     });
161     return false;
162     }
163 nhaye 557
164     // Parse URL Queries Method
165     (function($){
166     $.getQuery = function( query ) {
167     query = query.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
168     var expr = "[\\?&]"+query+"=([^&#]*)";
169     var regex = new RegExp( expr );
170     var results = regex.exec( window.location.href );
171     if( results !== null ) {
172     return results[1];
173     return decodeURIComponent(results[1].replace(/\+/g, " "));
174     } else {
175     return false;
176     }
177     };
178     })(jQuery);
179 vpihour 558
180 vpihour 641 function changeDataSelect(tn, ds, joker){
181    
182     var idArrondissement = $("#"+ds+" option:selected").val();
183     link = "../app/listData.php?idx=" + idArrondissement + "&tn=" + tn + "&ds=" + ds;
184 vpihour 626 $.ajax({
185     type: "GET",
186     url: link,
187     cache: false,
188 vpihour 641 dataType: "json",
189 vpihour 626 success: function(html){
190 vpihour 641
191     $('#'+tn).empty();
192    
193     if ( joker == true )
194     $('#'+tn).append(
195 vpihour 626 '<option value="" selected="selected">*</option>'
196     );
197 vpihour 641 else
198     $('#'+tn).append(
199     '<option value="" selected="selected">Choisir ' + tn + '</option>'
200     );
201    
202     if ( html !== '' ){
203 vpihour 626
204     html = html.split(';');
205     for ( i = 0 ; i < html.length - 1 ; i++ ){
206 vpihour 558
207 vpihour 626 html_temp = html[i].split('_');
208 vpihour 641 $('#'+tn).append(
209 vpihour 626 '<option value="'+html_temp[0]+'" >'+html_temp[1]+'</option>'
210 vpihour 558 );
211     }
212 vpihour 626 }
213     },
214     async: false
215     });
216 vpihour 558 }
217 nhaye 636 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 vpihour 641 }
239    
240     $(function() {
241 vpihour 651 if ( $('#date_demande').length > 0 && !$('#dossier_autorisation_type_detaille').is(':disabled') )
242     hideFields();
243    
244    
245 vpihour 641 });
246    
247     function changeDemandeType(){
248    
249     var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val();
250    
251     if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){
252    
253     changeDataSelect('demande_type','dossier_autorisation_type_detaille');
254    
255     $('#demande_type').parent().parent().show();
256 vpihour 651
257     $('.terrain_references_cadastrales_custom').append(
258     '<div class="field field-type-text" >'+
259     '<div class="form-libelle">' +
260     '<label '+
261     'class="libelle-terrain_references_cadastrales" '+
262     'for="terrain_references_cadastrales">'+
263     ' terrain_references_cadastrales '+
264     '</label>' +
265     '</div>' +
266     '<div class="form-content reference_cadastrale_custom_fields">' +
267     '<input ' +
268     'class="champFormulaire reference_cadastrale_custom_field" ' +
269     'type="text" ' +
270     'onchange="VerifNum(this)" ' +
271     'maxlength="3" ' +
272     'size="3" ' +
273     'value="" />' +
274     '<input ' +
275     'class="champFormulaire reference_cadastrale_custom_field" ' +
276     'type="text" ' +
277     'maxlength="2" ' +
278     'size="2" ' +
279     'value="" />' +
280     '<input ' +
281     'class="champFormulaire reference_cadastrale_custom_field" ' +
282     'type="text" ' +
283     'onchange="VerifNum(this)" ' +
284     'maxlength="4" ' +
285     'size="4" ' +
286     'value="" />' +
287     '</div>' +
288     '</div>' +
289     '<div id="moreFieldReferenceCadastrale"> + ajouter d\'autres champs</div>'
290     );
291    
292     $('#moreFieldReferenceCadastrale').click( function() {
293     $('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale());
294     });
295    
296     $('form').submit(
297     function(){
298    
299     var reference_cadastrale = '';
300    
301     $('.reference_cadastrale_custom_field').each(
302     function(){
303    
304     reference_cadastrale += $(this).val();
305     }
306     );
307    
308     $('#terrain_references_cadastrales').val(reference_cadastrale);
309     }
310     );
311    
312     $('.terrain_references_cadastrales_custom:').find(">:first-child").hide();
313 vpihour 641 }
314     else {
315     hideFields();
316     }
317     }
318    
319     function hideFields(){
320     $('.bloc').each(
321     function(){
322     if ( !$(this).hasClass('dossier_type') && !$(this).hasClass('dossier_type_demande_date') )
323     $(this).hide();
324     }
325     );
326    
327     $('.field-type-text').hide();
328     $('input[type=submit]').hide();
329     $('#demande_type').parent().parent().hide();
330     }
331    
332     function showFormsDemande(){
333     $('.bloc').each(
334     function(){
335     if ( !$(this).hasClass('dossier_type') && !$(this).hasClass('dossier_type_demande_date') )
336     $(this).show();
337     }
338     );
339    
340     $('.field-type-text').show();
341     $('input[type=submit]').show();
342     }
343 vpihour 651
344     function newInputReferenceCadastrale(){
345     return '<input ' +
346     'class="champFormulaire reference_cadastrale_custom_field" ' +
347     'type="text" ' +
348     'maxlength="1" ' +
349     'size="1" ' +
350     'value="" />' +
351     '<input ' +
352     'class="champFormulaire reference_cadastrale_custom_field" ' +
353     'type="text" ' +
354     'onchange="VerifNum(this)" ' +
355     'maxlength="4" ' +
356     'size="4" ' +
357     'value="" />';
358     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26