218 |
/** |
/** |
219 |
* Cette fonction permet de charger dans un dialog jqueryui un formulaire tel |
* Cette fonction permet de charger dans un dialog jqueryui un formulaire tel |
220 |
* qu'il aurait été chargé avec ajaxIt |
* qu'il aurait été chargé avec ajaxIt |
221 |
|
* |
222 |
|
* @param objsf string : objet de sousformulaire |
223 |
|
* @param link string : lien vers un sousformulaire (../scr/sousform.php...) |
224 |
|
* @param width integer: width en px |
225 |
|
* @param height integer: height en px |
226 |
|
* @param callback function (optionel) : nom de la méthode à appeler |
227 |
|
* à la fermeture du dialog |
228 |
|
* @param callbackParams mixed (optionel) : paramètre à traiter dans la function |
229 |
|
* callback |
230 |
* |
* |
231 |
*/ |
**/ |
232 |
function popupIt(objsf, link) { |
function popupIt(objsf, link, width, height, callback, callbackParams) { |
233 |
// Insertion du conteneur du dialog |
// Insertion du conteneur du dialog |
234 |
var dialog = $('<div id=\"sousform-'+objsf+'\"></div>').insertAfter('.formControls'); |
var dialog = $('<div id=\"sousform-'+objsf+'\"></div>').insertAfter('.formControls'); |
235 |
$('<input type=\"text\" name=\"recherchedyn\" id=\"recherchedyn\" value=\"\" class=\"champFormulaire\" style=\"display:none\" />').insertAfter('#sousform-'+objsf); |
$('<input type=\"text\" name=\"recherchedyn\" id=\"recherchedyn\" value=\"\" class=\"champFormulaire\" style=\"display:none\" />').insertAfter('#sousform-'+objsf); |
251 |
$(dialog).dialog({ |
$(dialog).dialog({ |
252 |
//OnClose suppression du contenu |
//OnClose suppression du contenu |
253 |
close: function(ev, ui) { |
close: function(ev, ui) { |
254 |
// Si le formulaire est submit et valide |
// Si le formulaire est submit et valide on execute la méthode |
255 |
var valid=$('#sousform-'+objsf+' div.ui-state-valid'); |
// passée en paramètre |
256 |
if(valid.length > 0) { |
if (typeof(callback) === "function") { |
257 |
document.location.href="../scr/tab.php?obj="+$.getQuery('obj')+"&premier="+$.getQuery('premier') |
callback(callbackParams); |
|
+"&advs_id="+$.getQuery('advs_id')+"&recherche="+$.getQuery('recherche')+"&tricol="+$.getQuery('tricol') |
|
|
+"&selectioncol="+$.getQuery('selectioncol'); |
|
258 |
} |
} |
259 |
$(this).remove(); |
$(this).remove(); |
260 |
}, |
}, |
261 |
resizable: false, |
resizable: false, |
262 |
modal: true, |
modal: true, |
263 |
width: 700, |
width: width, |
264 |
height: 520, |
height: height, |
265 |
}); |
}); |
266 |
}, |
}, |
267 |
async : false |
async : false |
268 |
}); |
}); |
269 |
//Modification des boutons retours du sous formulaire pour fermer le dialog |
//Fermeture du dialog lors d'un clic sur le bouton retour |
|
$('#sousform-'+objsf).on("mousedown",'a.retour',function() { |
|
|
$('#sousform-'+objsf+' a.retour').attr('onclick',''); |
|
|
}); |
|
270 |
$('#sousform-'+objsf).on("click",'a.retour',function() { |
$('#sousform-'+objsf).on("click",'a.retour',function() { |
271 |
$(dialog).dialog('close').remove(); |
$(dialog).dialog('close').remove(); |
272 |
}); |
}); |
274 |
} |
} |
275 |
|
|
276 |
/*** |
/*** |
277 |
* |
* Fonction getter des paramètres de l'url courante |
|
* @todo XXX ????????? |
|
278 |
*/ |
*/ |
279 |
// Parse URL Queries Method |
// Parse URL Queries Method |
280 |
(function($){ |
(function($){ |
281 |
$.getQuery = function( query ) { |
$.getQuery = function( query ) { |
282 |
query = query.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
query = query.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
283 |
var expr = "[\\?&]"+query+"=([^&#]*)"; |
var expr = "[\\?&]"+query+"=([^&#]*)"; |
284 |
var regex = new RegExp( expr ); |
var regex = new RegExp( expr ); |
285 |
var results = regex.exec( window.location.href ); |
var results = regex.exec( window.location.href ); |
286 |
if( results !== null ) { |
if( results !== null ) { |
287 |
return results[1]; |
return results[1]; |
288 |
return decodeURIComponent(results[1].replace(/\+/g, " ")); |
return decodeURIComponent(results[1].replace(/\+/g, " ")); |
289 |
} else { |
} else { |
290 |
return false; |
return false; |
291 |
} |
} |
292 |
}; |
}; |
293 |
})(jQuery); |
})(jQuery); |
294 |
|
|
295 |
|
|
296 |
/* |
/* |
297 |
|
* Javascript concernant la demande d'avis |
298 |
|
* |
299 |
|
* |
300 |
|
*/ |
301 |
|
|
302 |
|
/** |
303 |
|
* Fonction de callback appellée lors de la fermeture du dialog (popupit) |
304 |
|
* du retour d'avis d'un service |
305 |
|
**/ |
306 |
|
function returnToTab(objsf) { |
307 |
|
var valid=$('#sousform-'+objsf+' div.ui-state-valid'); |
308 |
|
if(valid.length > 0) { |
309 |
|
document.location.href="../scr/tab.php?obj="+$.getQuery('obj')+"&premier="+$.getQuery('premier') |
310 |
|
+"&advs_id="+$.getQuery('advs_id')+"&recherche="+$.getQuery('recherche')+"&tricol="+$.getQuery('tricol') |
311 |
|
+"&selectioncol="+$.getQuery('selectioncol'); |
312 |
|
} |
313 |
|
}; |
314 |
|
|
315 |
|
|
316 |
|
/* |
317 |
* Javascript concernant la demande |
* Javascript concernant la demande |
318 |
* |
* |
319 |
* |
* |
348 |
/*Fonction d'ajout de nouveau pétitionnaire*/ |
/*Fonction d'ajout de nouveau pétitionnaire*/ |
349 |
$('.morePetitionnaire').click( function() { |
$('.morePetitionnaire').click( function() { |
350 |
|
|
351 |
}); |
}); |
352 |
|
|
353 |
|
$("#add_petitionnaire_principal").click( function() { |
354 |
|
popupIt('petitionnaire', |
355 |
|
'../scr/sousform.php?obj=petitionnaire&action=0'+ |
356 |
|
'&retourformulaire=demande', 780, 500); |
357 |
|
}); |
358 |
/*Cache les champs avant que dossier_autorisation_type_detaille soit choisi*/ |
/*Cache les champs avant que dossier_autorisation_type_detaille soit choisi*/ |
359 |
hideFields(); |
hideFields(); |
360 |
} |
} |
482 |
}); |
}); |
483 |
|
|
484 |
/* |
/* |
485 |
Action au changement du select du type de demandeur |
Action au changement du select de la qualite du demandeur |
486 |
* */ |
* */ |
487 |
function setTypeDemandeur(id, complement){ |
function changeDemandeurType(id){ |
|
|
|
|
$('#'+id + ' select[id="type_demandeur' + complement + '"]').on('change', |
|
|
function() { |
|
488 |
|
|
489 |
if ( $(this).find('option:selected').first().text() == 'particulier' ){ |
/*Si la qualite du demandeur est particulier */ |
490 |
|
if ( $('#' + id + ' option:selected').val() == 'particulier' ){ |
491 |
$(name + |
|
492 |
' select[id="particulier_civilite' + complement + |
$('.personne_morale_fields input').each( |
493 |
'"] option[value=""]').attr('selected', 'selected'); |
function(){ |
494 |
$(name + |
$(this).val(''); |
|
' input[id="particulier_nom' + |
|
|
complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="particulier_prenom' + |
|
|
complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="particulier_date_naissance' + |
|
|
complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="particulier_commune_naissance' + |
|
|
complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="particulier_departement_naissance' + |
|
|
complement + '"]').val(''); |
|
|
|
|
|
$( name + ' .particulier_fields').show(); |
|
|
$( name + ' .personne_morale_fields').hide(); |
|
495 |
} |
} |
496 |
else { |
); |
497 |
|
$('.personne_morale_fields select option[value=""]').each( |
498 |
$(name + |
function(){ |
499 |
' select[id="personne_morale_civilite' + |
$(this).attr('selected', 'selected'); |
|
complement + '"] option[value=""]').attr('selected', 'selected'); |
|
|
$(name + |
|
|
' input[id="personne_morale_denomination' |
|
|
+ complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="personne_morale_raison_sociale' |
|
|
+ complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="personne_morale_siret' |
|
|
+ complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="personne_morale_categorie_juridique' |
|
|
+ complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="personne_morale_nom' |
|
|
+ complement + '"]').val(''); |
|
|
$(name + |
|
|
' input[id="personne_morale_prenom' |
|
|
+ complement + '"]').val(''); |
|
|
|
|
|
$( name + ' .particulier_fields').hide(); |
|
|
$( name + ' .personne_morale_fields').show(); |
|
500 |
} |
} |
501 |
} |
); |
502 |
); |
|
503 |
|
$('.personne_morale_fields').hide(); |
504 |
|
$('.particulier_fields').show(); |
505 |
|
} |
506 |
|
else { |
507 |
|
|
508 |
|
$('.particulier_fields input').each( |
509 |
|
function(){ |
510 |
|
$(this).val(''); |
511 |
|
} |
512 |
|
); |
513 |
|
$('.particulier_fields select option[value=""]').each( |
514 |
|
function(){ |
515 |
|
$(this).attr('selected', 'selected'); |
516 |
|
} |
517 |
|
); |
518 |
|
|
519 |
|
$('.particulier_fields').hide(); |
520 |
|
$('.personne_morale_fields').show(); |
521 |
|
} |
522 |
} |
} |
523 |
|
|
524 |
/* |
/* |
984 |
'</span>'; |
'</span>'; |
985 |
} |
} |
986 |
|
|
987 |
/* |
/** |
988 |
Cache les champs inutules |
* Cache les champs inutules |
989 |
* */ |
**/ |
990 |
function hideFields(){ |
function hideFields(){ |
991 |
$('.bloc').each( |
$('.demande_hidden_bloc').each( |
992 |
function(){ |
function(){ |
993 |
if ( !$(this).hasClass('dossier_type') && |
$(this).hide(); |
|
!$(this).hasClass('dossier_type_demande_date') ){ |
|
|
$(this).hide(); |
|
|
} |
|
|
|
|
994 |
} |
} |
995 |
); |
); |
996 |
|
|
1003 |
Affiche les champs dont on a besoin |
Affiche les champs dont on a besoin |
1004 |
* */ |
* */ |
1005 |
function showFormsDemande(){ |
function showFormsDemande(){ |
1006 |
$('.bloc').each( |
$('.demande_hidden_bloc').each( |
1007 |
function(){ |
function(){ |
1008 |
if ( !$(this).hasClass('dossier_type') && |
$(this).show(); |
|
!$(this).hasClass('dossier_type_demande_date') ){ |
|
|
$(this).show(); |
|
|
} |
|
|
|
|
1009 |
} |
} |
1010 |
); |
); |
1011 |
|
|