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, |
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 |
|
|
255 |
|
addNewFieldReferencesCadastrales(); |
256 |
|
$('#terrain_references_cadastrales').parent().parent().hide(); |
257 |
|
|
258 |
|
reference_cadastrale = $('#terrain_references_cadastrales').val(); |
259 |
|
/*Formatage de la reference cadastrale*/ |
260 |
|
if ( reference_cadastrale != '' ){ |
261 |
|
|
262 |
|
|
263 |
|
references_cadastrales = reference_cadastrale.split(';'); |
264 |
|
donnees = new Array(); |
265 |
|
|
266 |
|
i = 0 ; |
267 |
|
for ( l = 0 ; l < references_cadastrales.length - 1 ; l ++ ){ |
268 |
|
|
269 |
|
k = 0; |
270 |
|
donnees[i] = ''; |
271 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
272 |
|
if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){ |
273 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
274 |
|
k++; |
275 |
|
} else { |
276 |
|
i++; |
277 |
|
break; |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
|
donnees[i] = ''; |
282 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
283 |
|
if ( isAlpha(references_cadastrales[l].charAt(j)) ){ |
284 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
285 |
|
k++; |
286 |
|
} else { |
287 |
|
i++; |
288 |
|
break; |
289 |
|
} |
290 |
|
|
291 |
|
donnees[i] = ''; |
292 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
293 |
|
if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){ |
294 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
295 |
|
k++; |
296 |
|
} else { |
297 |
|
break; |
298 |
|
} |
299 |
|
|
300 |
|
m = 0 ; |
301 |
|
if ( k < references_cadastrales[l].length ){ |
302 |
|
|
303 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
304 |
|
if ( isAlpha(references_cadastrales[l].charAt(j)) ){ |
305 |
|
m++; |
306 |
|
donnees[++i] = references_cadastrales[l].charAt(j); |
307 |
|
donnees[++i] = ''; |
308 |
|
} |
309 |
|
else { |
310 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
311 |
|
} |
312 |
|
} |
313 |
|
|
314 |
|
donnees[++i] = ';'; |
315 |
|
i++; |
316 |
|
|
317 |
|
if ( l > 0 ) |
318 |
|
$('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase()); |
319 |
|
actionFormReferenceCadastrale(); |
320 |
|
|
321 |
|
if ( m > 0 ){ |
322 |
|
|
323 |
|
for ( j = 0 ; j < m ; j++ ) |
324 |
|
$('#moreFieldReferenceCadastrale' + ( $('.moreFieldReferenceCadastrale').length - 1 ) ).before(newInputReferenceCadastrale()); |
325 |
|
} |
326 |
|
} |
327 |
|
|
328 |
|
actionLineFormReferenceCadastrale(); |
329 |
|
|
330 |
|
$('.reference_cadastrale_custom_field').each( |
331 |
|
function(index) { |
332 |
|
$(this).val(donnees[index]) |
333 |
|
} |
334 |
|
); |
335 |
|
} |
336 |
|
} |
337 |
|
}); |
338 |
|
|
339 |
|
/* |
340 |
|
Test str est une lettre de l'alphabet |
341 |
|
* */ |
342 |
|
function isAlpha(str) { |
343 |
|
return /^[a-zA-Z\/]+$/.test(str); |
344 |
|
} |
345 |
|
|
346 |
|
/* |
347 |
|
Ajoute les ations spécifiques pour le formulaire personnalisé d'ajout de référence cadastrale |
348 |
|
* */ |
349 |
|
function actionFormReferenceCadastrale(){ |
350 |
|
$('form').submit( |
351 |
|
function(){ |
352 |
|
|
353 |
|
var reference_cadastrale = ''; |
354 |
|
|
355 |
|
$('.reference_cadastrale_custom_field').each( |
356 |
|
function(){ |
357 |
|
|
358 |
|
reference_cadastrale += $(this).val(); |
359 |
|
} |
360 |
|
); |
361 |
|
|
362 |
|
$('#terrain_references_cadastrales').val(reference_cadastrale); |
363 |
|
} |
364 |
|
); |
365 |
|
|
366 |
|
$('#moreFieldReferenceCadastrale' + ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() { |
367 |
|
$(this).before(newInputReferenceCadastrale()); |
368 |
|
}); |
369 |
|
} |
370 |
|
|
371 |
|
function actionLineFormReferenceCadastrale(){ |
372 |
|
$('#morelineReferenceCadastrale').click( |
373 |
|
function(){ |
374 |
|
|
375 |
|
$('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase()); |
376 |
|
$('#moreFieldReferenceCadastrale'+ ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() { |
377 |
|
$(this).before(newInputReferenceCadastrale()); |
378 |
|
}); |
379 |
|
} |
380 |
|
); |
381 |
|
} |
382 |
|
|
383 |
|
/* |
384 |
|
Met à jour le select demande_type dès qu'un dossier_autorisation_type_detaille est choisi |
385 |
|
* */ |
386 |
function changeDemandeType(){ |
function changeDemandeType(){ |
387 |
|
|
388 |
var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val(); |
var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val(); |
390 |
if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){ |
if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){ |
391 |
|
|
392 |
changeDataSelect('demande_type','dossier_autorisation_type_detaille'); |
changeDataSelect('demande_type','dossier_autorisation_type_detaille'); |
393 |
|
if ( $('#demande_type option').size() < 2 ) |
394 |
|
showFormsDemande(); |
395 |
|
|
396 |
$('#demande_type').parent().parent().show(); |
$('#demande_type').parent().parent().show(); |
397 |
|
|
398 |
$('.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>' |
|
|
); |
|
399 |
|
|
400 |
$('#moreFieldReferenceCadastrale').click( function() { |
actionFormReferenceCadastrale(); |
401 |
$('.reference_cadastrale_custom_fields').append(newInputReferenceCadastrale()); |
actionLineFormReferenceCadastrale() |
|
}); |
|
|
|
|
|
$('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(); |
|
402 |
} |
} |
403 |
else { |
else { |
404 |
hideFields(); |
hideFields(); |
405 |
} |
} |
406 |
} |
} |
407 |
|
|
408 |
|
/* |
409 |
|
Ajoute le code HTML des champs pour les références cadastrales |
410 |
|
* */ |
411 |
|
function addNewFieldReferencesCadastrales(){ |
412 |
|
$('.references_cadastrales_new_field').remove(); |
413 |
|
$('.moreFieldReferenceCadastrale').remove(); |
414 |
|
$('.localisation .fieldsetContent').prepend( |
415 |
|
'<div class="field field-type-text references_cadastrales_new_field" >'+ |
416 |
|
'<div class="form-libelle">' + |
417 |
|
'<label '+ |
418 |
|
'class="libelle-terrain_references_cadastrales" '+ |
419 |
|
'for="terrain_references_cadastrales">'+ |
420 |
|
' terrain_references_cadastrales '+ |
421 |
|
'</label>' + |
422 |
|
'</div>' + |
423 |
|
'<div class="form-content reference_cadastrale_custom_fields">' + |
424 |
|
fieldReferenceCadastraleBase() + |
425 |
|
'</div>' + |
426 |
|
'</div>' + |
427 |
|
'<div class="field field-type-text" id="morelineReferenceCadastrale">' + |
428 |
|
'<div class="form-libelle"></div>' + |
429 |
|
'<div class="form-content">' + |
430 |
|
' + ajouter d\'autres lignes' + |
431 |
|
'</div>' + |
432 |
|
'</div>' |
433 |
|
); |
434 |
|
} |
435 |
|
|
436 |
|
function hiddenSeparatorField(){ |
437 |
|
return '<input ' + |
438 |
|
'class="reference_cadastrale_custom_field " ' + |
439 |
|
'type="hidden" ' + |
440 |
|
'maxlength="2" ' + |
441 |
|
'size="2" ' + |
442 |
|
'value=";" />'; |
443 |
|
} |
444 |
|
|
445 |
|
function fieldReferenceCadastraleBase(){ |
446 |
|
return '<input ' + |
447 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
448 |
|
'type="text" ' + |
449 |
|
'onchange="VerifNum(this)" ' + |
450 |
|
'maxlength="3" ' + |
451 |
|
'size="3" ' + |
452 |
|
'value="" />' + |
453 |
|
'<input ' + |
454 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
455 |
|
'type="text" ' + |
456 |
|
'maxlength="2" ' + |
457 |
|
'size="2" ' + |
458 |
|
'value="" />' + |
459 |
|
'<input ' + |
460 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
461 |
|
'type="text" ' + |
462 |
|
'onchange="VerifNum(this)" ' + |
463 |
|
'maxlength="4" ' + |
464 |
|
'size="4" ' + |
465 |
|
'value="" />' + |
466 |
|
'<span id="moreFieldReferenceCadastrale' + $('.moreFieldReferenceCadastrale').length + '" class="moreFieldReferenceCadastrale">' + |
467 |
|
hiddenSeparatorField() + |
468 |
|
' + ajouter d\'autres champs' + |
469 |
|
'</span>'; |
470 |
|
} |
471 |
|
|
472 |
|
/* |
473 |
|
Cache les champs inutules |
474 |
|
* */ |
475 |
function hideFields(){ |
function hideFields(){ |
476 |
$('.bloc').each( |
$('.bloc').each( |
477 |
function(){ |
function(){ |
485 |
$('#demande_type').parent().parent().hide(); |
$('#demande_type').parent().parent().hide(); |
486 |
} |
} |
487 |
|
|
488 |
|
/* |
489 |
|
Affiche les champs dont on a besoin |
490 |
|
* */ |
491 |
function showFormsDemande(){ |
function showFormsDemande(){ |
492 |
$('.bloc').each( |
$('.bloc').each( |
493 |
function(){ |
function(){ |
498 |
|
|
499 |
$('.field-type-text').show(); |
$('.field-type-text').show(); |
500 |
$('input[type=submit]').show(); |
$('input[type=submit]').show(); |
501 |
|
$('.terrain_references_cadastrales_custom').hide(); |
502 |
|
|
503 |
|
$('#terrain_references_cadastrales').parent().parent().hide(); |
504 |
} |
} |
505 |
|
|
506 |
|
/* |
507 |
|
Action au clique sur le bouton " + ajouter d'autres champs" |
508 |
|
* */ |
509 |
function newInputReferenceCadastrale(){ |
function newInputReferenceCadastrale(){ |
510 |
return '<input ' + |
return '<input ' + |
511 |
'class="champFormulaire reference_cadastrale_custom_field" ' + |
'class="champFormulaire reference_cadastrale_custom_field" ' + |