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 |
|
/* |
241 |
|
Ajoute le formulaire d'jout de référence cadastrale personnalisé |
242 |
|
* */ |
243 |
$(function() { |
$(function() { |
244 |
hideFields(); |
|
245 |
|
$.ajax({ |
246 |
|
type: "GET", |
247 |
|
url: "sousform.php?obj=demandeur&action=0&tri=&objsf=demandeur&premiersf=0", |
248 |
|
cache: false, |
249 |
|
success: function(html){ |
250 |
|
|
251 |
|
$('.lots').append(html); |
252 |
|
}, |
253 |
|
error:function (xhr, ajaxOptions, thrownError){ |
254 |
|
alert(xhr.status); |
255 |
|
alert(thrownError); |
256 |
|
} |
257 |
|
}); |
258 |
|
|
259 |
|
url = document.location + "" ; |
260 |
|
if ( $('#date_demande').length > 0 |
261 |
|
&& !$('#dossier_autorisation_type_detaille').is(':disabled') |
262 |
|
&& url.indexOf("form.php?obj=demande&action=0") != -1 ) |
263 |
|
hideFields(); |
264 |
|
|
265 |
|
if ( $('#date_demande').length > 0 |
266 |
|
&& !$('#dossier_autorisation_type_detaille').is(':disabled') |
267 |
|
&& url.indexOf("form.php?obj=demande&action=1") != -1 ){ |
268 |
|
|
269 |
|
addNewFieldReferencesCadastrales(); |
270 |
|
$('#terrain_references_cadastrales').parent().parent().hide(); |
271 |
|
|
272 |
|
reference_cadastrale = $('#terrain_references_cadastrales').val(); |
273 |
|
/*Formatage de la reference cadastrale*/ |
274 |
|
if ( reference_cadastrale != '' ){ |
275 |
|
|
276 |
|
|
277 |
|
references_cadastrales = reference_cadastrale.split(';'); |
278 |
|
donnees = new Array(); |
279 |
|
|
280 |
|
i = 0 ; |
281 |
|
for ( l = 0 ; l < references_cadastrales.length - 1 ; l ++ ){ |
282 |
|
|
283 |
|
k = 0; |
284 |
|
donnees[i] = ''; |
285 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
286 |
|
if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){ |
287 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
288 |
|
k++; |
289 |
|
} else { |
290 |
|
i++; |
291 |
|
break; |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
|
donnees[i] = ''; |
296 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
297 |
|
if ( isAlpha(references_cadastrales[l].charAt(j)) ){ |
298 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
299 |
|
k++; |
300 |
|
} else { |
301 |
|
i++; |
302 |
|
break; |
303 |
|
} |
304 |
|
|
305 |
|
donnees[i] = ''; |
306 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
307 |
|
if ( references_cadastrales[l].charAt(j) >= 0 && references_cadastrales[l].charAt(j) <= 9 ){ |
308 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
309 |
|
k++; |
310 |
|
} else { |
311 |
|
break; |
312 |
|
} |
313 |
|
|
314 |
|
m = 0 ; |
315 |
|
if ( k < references_cadastrales[l].length ){ |
316 |
|
|
317 |
|
for ( j = k ; j < references_cadastrales[l].length ; j++ ) |
318 |
|
if ( isAlpha(references_cadastrales[l].charAt(j)) ){ |
319 |
|
m++; |
320 |
|
donnees[++i] = references_cadastrales[l].charAt(j); |
321 |
|
donnees[++i] = ''; |
322 |
|
} |
323 |
|
else { |
324 |
|
donnees[i] += references_cadastrales[l].charAt(j); |
325 |
|
} |
326 |
|
} |
327 |
|
|
328 |
|
donnees[++i] = ';'; |
329 |
|
i++; |
330 |
|
|
331 |
|
if ( l > 0 ) |
332 |
|
$('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase()); |
333 |
|
actionFormReferenceCadastrale(); |
334 |
|
|
335 |
|
if ( m > 0 ){ |
336 |
|
|
337 |
|
for ( j = 0 ; j < m ; j++ ) |
338 |
|
$('#moreFieldReferenceCadastrale' + ( $('.moreFieldReferenceCadastrale').length - 1 ) ).before(newInputReferenceCadastrale()); |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
actionLineFormReferenceCadastrale(); |
343 |
|
|
344 |
|
$('.reference_cadastrale_custom_field').each( |
345 |
|
function(index) { |
346 |
|
$(this).val(donnees[index]) |
347 |
|
} |
348 |
|
); |
349 |
|
} |
350 |
|
} |
351 |
}); |
}); |
352 |
|
|
353 |
|
/* |
354 |
|
Test str est une lettre de l'alphabet |
355 |
|
* */ |
356 |
|
function isAlpha(str) { |
357 |
|
return /^[a-zA-Z\/]+$/.test(str); |
358 |
|
} |
359 |
|
|
360 |
|
/* |
361 |
|
Ajoute les ations spécifiques pour le formulaire personnalisé d'ajout de référence cadastrale |
362 |
|
* */ |
363 |
|
function actionFormReferenceCadastrale(){ |
364 |
|
$('form').submit( |
365 |
|
function(){ |
366 |
|
|
367 |
|
var reference_cadastrale = ''; |
368 |
|
|
369 |
|
$('.reference_cadastrale_custom_field').each( |
370 |
|
function(){ |
371 |
|
|
372 |
|
reference_cadastrale += $(this).val(); |
373 |
|
} |
374 |
|
); |
375 |
|
|
376 |
|
$('#terrain_references_cadastrales').val(reference_cadastrale); |
377 |
|
} |
378 |
|
); |
379 |
|
|
380 |
|
$('#moreFieldReferenceCadastrale' + ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() { |
381 |
|
$(this).before(newInputReferenceCadastrale()); |
382 |
|
}); |
383 |
|
} |
384 |
|
|
385 |
|
/* |
386 |
|
Action pour l'ajout de nouvelle ligne |
387 |
|
* */ |
388 |
|
function actionLineFormReferenceCadastrale(){ |
389 |
|
$('#morelineReferenceCadastrale').click( |
390 |
|
function(){ |
391 |
|
|
392 |
|
$('.reference_cadastrale_custom_fields').append( "<br/>" + fieldReferenceCadastraleBase()); |
393 |
|
$('#moreFieldReferenceCadastrale'+ ($('.moreFieldReferenceCadastrale').length - 1 )).on("click", function() { |
394 |
|
$(this).before(newInputReferenceCadastrale()); |
395 |
|
}); |
396 |
|
} |
397 |
|
); |
398 |
|
} |
399 |
|
|
400 |
|
/* |
401 |
|
Met à jour le select demande_type dès qu'un dossier_autorisation_type_detaille est choisi |
402 |
|
* */ |
403 |
function changeDemandeType(){ |
function changeDemandeType(){ |
404 |
|
|
405 |
var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val(); |
var idDossierAutorisationTypeDetaille = $("#dossier_autorisation_type_detaille option:selected").val(); |
407 |
if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){ |
if ( $.isNumeric(idDossierAutorisationTypeDetaille) ){ |
408 |
|
|
409 |
changeDataSelect('demande_type','dossier_autorisation_type_detaille'); |
changeDataSelect('demande_type','dossier_autorisation_type_detaille'); |
410 |
|
if ( $('#demande_type option').size() < 2 ) |
411 |
|
showFormsDemande(); |
412 |
|
|
413 |
$('#demande_type').parent().parent().show(); |
$('#demande_type').parent().parent().show(); |
414 |
|
|
415 |
|
addNewFieldReferencesCadastrales(); |
416 |
|
|
417 |
|
actionFormReferenceCadastrale(); |
418 |
|
actionLineFormReferenceCadastrale() |
419 |
} |
} |
420 |
else { |
else { |
421 |
hideFields(); |
hideFields(); |
422 |
} |
} |
423 |
} |
} |
424 |
|
|
425 |
|
/* |
426 |
|
Ajoute le code HTML des champs pour les références cadastrales |
427 |
|
* */ |
428 |
|
function addNewFieldReferencesCadastrales(){ |
429 |
|
$('.references_cadastrales_new_field').remove(); |
430 |
|
$('.moreFieldReferenceCadastrale').remove(); |
431 |
|
$('#morelineReferenceCadastrale').remove(); |
432 |
|
$('.localisation .fieldsetContent').prepend( |
433 |
|
'<div class="field field-type-text references_cadastrales_new_field" >'+ |
434 |
|
'<div class="form-libelle">' + |
435 |
|
'<label '+ |
436 |
|
'class="libelle-terrain_references_cadastrales" '+ |
437 |
|
'for="terrain_references_cadastrales">'+ |
438 |
|
' terrain_references_cadastrales '+ |
439 |
|
'</label>' + |
440 |
|
'</div>' + |
441 |
|
'<div class="form-content reference_cadastrale_custom_fields">' + |
442 |
|
fieldReferenceCadastraleBase() + |
443 |
|
'</div>' + |
444 |
|
'</div>' + |
445 |
|
'<div class="field field-type-text" id="morelineReferenceCadastrale">' + |
446 |
|
'<div class="form-libelle"></div>' + |
447 |
|
'<div class="form-content">' + |
448 |
|
' + ajouter d\'autres lignes' + |
449 |
|
'</div>' + |
450 |
|
'</div>' |
451 |
|
); |
452 |
|
} |
453 |
|
|
454 |
|
/* |
455 |
|
Séparateur caché ; |
456 |
|
* */ |
457 |
|
function hiddenSeparatorField(){ |
458 |
|
return '<input ' + |
459 |
|
'class="reference_cadastrale_custom_field " ' + |
460 |
|
'type="hidden" ' + |
461 |
|
'maxlength="2" ' + |
462 |
|
'size="2" ' + |
463 |
|
'value=";" />'; |
464 |
|
} |
465 |
|
|
466 |
|
/* |
467 |
|
Ajout d'une nouvelle ligne de champ |
468 |
|
* */ |
469 |
|
function fieldReferenceCadastraleBase(){ |
470 |
|
return '<input ' + |
471 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
472 |
|
'type="text" ' + |
473 |
|
'onchange="VerifNum(this)" ' + |
474 |
|
'maxlength="3" ' + |
475 |
|
'size="3" ' + |
476 |
|
'value="" />' + |
477 |
|
'<input ' + |
478 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
479 |
|
'type="text" ' + |
480 |
|
'maxlength="2" ' + |
481 |
|
'size="2" ' + |
482 |
|
'value="" />' + |
483 |
|
'<input ' + |
484 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
485 |
|
'type="text" ' + |
486 |
|
'onchange="VerifNum(this)" ' + |
487 |
|
'maxlength="4" ' + |
488 |
|
'size="4" ' + |
489 |
|
'value="" />' + |
490 |
|
'<span id="moreFieldReferenceCadastrale' + $('.moreFieldReferenceCadastrale').length + '" class="moreFieldReferenceCadastrale">' + |
491 |
|
hiddenSeparatorField() + |
492 |
|
' + ajouter d\'autres champs' + |
493 |
|
'</span>'; |
494 |
|
} |
495 |
|
|
496 |
|
/* |
497 |
|
Cache les champs inutules |
498 |
|
* */ |
499 |
function hideFields(){ |
function hideFields(){ |
500 |
$('.bloc').each( |
$('.bloc').each( |
501 |
function(){ |
function(){ |
509 |
$('#demande_type').parent().parent().hide(); |
$('#demande_type').parent().parent().hide(); |
510 |
} |
} |
511 |
|
|
512 |
|
/* |
513 |
|
Affiche les champs dont on a besoin |
514 |
|
* */ |
515 |
function showFormsDemande(){ |
function showFormsDemande(){ |
516 |
$('.bloc').each( |
$('.bloc').each( |
517 |
function(){ |
function(){ |
522 |
|
|
523 |
$('.field-type-text').show(); |
$('.field-type-text').show(); |
524 |
$('input[type=submit]').show(); |
$('input[type=submit]').show(); |
525 |
|
$('.terrain_references_cadastrales_custom').hide(); |
526 |
|
|
527 |
|
$('#terrain_references_cadastrales').parent().parent().hide(); |
528 |
} |
} |
529 |
|
|
530 |
|
/* |
531 |
|
Action au clique sur le bouton " + ajouter d'autres champs" |
532 |
|
* */ |
533 |
|
function newInputReferenceCadastrale(){ |
534 |
|
return '<input ' + |
535 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
536 |
|
'type="text" ' + |
537 |
|
'maxlength="1" ' + |
538 |
|
'size="1" ' + |
539 |
|
'value="" />' + |
540 |
|
'<input ' + |
541 |
|
'class="champFormulaire reference_cadastrale_custom_field" ' + |
542 |
|
'type="text" ' + |
543 |
|
'onchange="VerifNum(this)" ' + |
544 |
|
'maxlength="4" ' + |
545 |
|
'size="4" ' + |
546 |
|
'value="" />'; |
547 |
|
} |
548 |
|
|
549 |
|
// Desactivation des fonctions widget du tableau de bord inutiles sur le nouveau |
550 |
|
// tableau de bord |
551 |
|
function widget_bind_move_actions() {} |
552 |
|
function widget_bind_add_action() {} |
553 |
|
function widget_bind_edit_actions(widget_selector) {} |
554 |
|
|