1 |
var pfenetre; |
2 |
var fenetreouverte = false; |
3 |
// espagnol |
4 |
var lang_calendrier = "calendar"; |
5 |
var lang_numerique = "vous devez saisir que des nombres"; |
6 |
|
7 |
// Parametrage du calendrier jquery ui |
8 |
var currDate = new Date (); |
9 |
var currYear = currDate.getFullYear(); |
10 |
var maxYear = currYear + 20; |
11 |
var minYear = currYear - 120; |
12 |
var dateFormat = 'dd/mm/yy'; |
13 |
|
14 |
$(function() { |
15 |
// Affichage du menu |
16 |
$("#menu-list").accordion({ |
17 |
autoHeight: false, |
18 |
collapsible: true, |
19 |
active : false |
20 |
}); |
21 |
// Skin en bouton |
22 |
$("button, input:submit, input:reset, input:button, p.linkjsclosewindow").button(); |
23 |
// |
24 |
var $tabs = $("#formulaire").tabs({ |
25 |
select: function(event, ui) { |
26 |
// Suppression du contenu de l'onglet precedemment selectionne |
27 |
// #ui-tabs-X correspond uniquement aux ids des onglets charges |
28 |
// dynamiquement |
29 |
selectedTabIndex = $tabs.tabs('option', 'selected'); |
30 |
$("#ui-tabs-"+selectedTabIndex).empty(); |
31 |
// Gestion de la recherche |
32 |
// Si le nouvel onglet clique est un onglet qui charge dynamiquement |
33 |
// son contenu |
34 |
var url = $.data(ui.tab, 'load.tabs'); |
35 |
if (url) { |
36 |
// On affiche la recherche |
37 |
var recherche = document.getElementById("recherchedyn").value; |
38 |
url += "&recherche="+recherche; |
39 |
$("#recherche_onglet").removeAttr("style"); |
40 |
$tabs.tabs("url", ui.index, url); |
41 |
} else { |
42 |
// On cache la recherche |
43 |
$("#recherche_onglet").attr("style", "display:none;") |
44 |
} |
45 |
return true; |
46 |
}, |
47 |
ajaxOptions: { |
48 |
error: function(xhr, status, index, anchor) { |
49 |
$(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible. If this wouldn't be a demo."); |
50 |
} |
51 |
} |
52 |
}); |
53 |
// |
54 |
$(".datepicker").datepicker({ |
55 |
dateFormat: dateFormat, |
56 |
changeMonth: true, |
57 |
changeYear: true, |
58 |
yearRange: minYear+':'+maxYear, |
59 |
showOn: 'button', |
60 |
buttonImage: '../img/calendar.png', |
61 |
buttonImageOnly: true, |
62 |
constrainInput: true |
63 |
}); |
64 |
// |
65 |
$("#accordion").accordion({ |
66 |
autoHeight: false, |
67 |
collapsible: true, |
68 |
active : false |
69 |
}); |
70 |
// |
71 |
$("fieldset.collapsible").collapse(); |
72 |
$("fieldset.startClosed").collapse( { closed: true } ); |
73 |
// Widget |
74 |
widget_bind_move_actions(); |
75 |
widget_bind_edit_actions(); |
76 |
widget_bind_add_action(); |
77 |
}); |
78 |
|
79 |
function aide (obj) |
80 |
{ |
81 |
if (fenetreouverte == true) |
82 |
pfenetre.close (); |
83 |
pfenetre = window.open ("../doc/"+obj+".html", "Aide", "toolbar=no, scrollbars=yes, status=no, width=600, height=400, top=120, left=120"); |
84 |
fenetreouverte = true; |
85 |
} |
86 |
|
87 |
function traces (fichier) |
88 |
{ |
89 |
if (fenetreouverte == true) |
90 |
pfenetre.close (); |
91 |
pfenetre = window.open ("../tmp/"+fichier, "Traces", "toolbar=no, scrollbars=yes, status=no, width=600, height=400, top=120, left=120"); |
92 |
fenetreouverte = true; |
93 |
} |
94 |
|
95 |
function vdate (origine) |
96 |
{ |
97 |
if (fenetreouverte == true) |
98 |
pfenetre.close (); |
99 |
pfenetre = window.open ("../spg/calendrier.php?origine="+origine, "Calendrier", "width=310, height=230, top=120, left=120"); |
100 |
fenetreouverte = true; |
101 |
} |
102 |
|
103 |
function fdate (champ) |
104 |
{ |
105 |
var flag = 0; |
106 |
var jour = ""; |
107 |
var mois = ""; |
108 |
var annee = ""; |
109 |
|
110 |
if (champ.value.lastIndexOf("/") == -1 && (champ.value.length == 6 || champ.value.length == 8)) |
111 |
{ |
112 |
jour = champ.value.substring(0,2); |
113 |
mois = champ.value.substring(2,4); |
114 |
if (champ.value.length == 6) |
115 |
annee = "20"+champ.value.substring(4,6); |
116 |
if (champ.value.length == 8) |
117 |
annee = champ.value.substring(4,8); |
118 |
} |
119 |
|
120 |
if (champ.value.lastIndexOf("/") != -1 && (champ.value.length == 8 || champ.value.length == 10)) |
121 |
{ |
122 |
jour = champ.value.substring(0,2); |
123 |
mois = champ.value.substring(3,5); |
124 |
if (champ.value.length == 8) |
125 |
annee = "20"+champ.value.substring(6,8); |
126 |
if (champ.value.length == 10) |
127 |
annee = champ.value.substring(6,10); |
128 |
} |
129 |
|
130 |
if (isNaN (jour) || isNaN (mois) || isNaN (annee)) |
131 |
{ |
132 |
flag = 1; |
133 |
} |
134 |
|
135 |
if (jour < '01' || jour > '31' || mois < '01' || mois > '12' || annee < '0000' || annee > '9999') |
136 |
{ |
137 |
flag = 1; |
138 |
} |
139 |
|
140 |
if (flag == 0) |
141 |
{ |
142 |
champ.value = jour+"/"+mois+"/"+annee; |
143 |
} |
144 |
else |
145 |
{ |
146 |
champ.value = ""; |
147 |
alert("La date n'est pas valide!") |
148 |
return; |
149 |
} |
150 |
} |
151 |
|
152 |
function ftime (champ) |
153 |
{ |
154 |
var flag = 0; |
155 |
var heure = ""; |
156 |
var minute = ""; |
157 |
var seconde = ""; |
158 |
|
159 |
if (champ.value.lastIndexOf(":") == -1 && (champ.value.length == 2 || champ.value.length == 4 || champ.value.length == 6)) |
160 |
{ |
161 |
heure = champ.value.substring(0,2); |
162 |
if (champ.value.length == 2) |
163 |
{ |
164 |
minute = "00"; |
165 |
seconde = "00"; |
166 |
} |
167 |
if (champ.value.length == 4) |
168 |
{ |
169 |
minute = champ.value.substring(2,4); |
170 |
seconde = "00"; |
171 |
} |
172 |
if (champ.value.length == 6) |
173 |
{ |
174 |
minute = champ.value.substring(2,4); |
175 |
seconde = champ.value.substring(4,6); |
176 |
} |
177 |
} |
178 |
|
179 |
if (champ.value.lastIndexOf(":") != -1 && (champ.value.length == 5 || champ.value.length == 8)) |
180 |
{ |
181 |
heure = champ.value.substring(0,2); |
182 |
if (champ.value.length == 5) |
183 |
{ |
184 |
minute = champ.value.substring(3,5); |
185 |
seconde = "00"; |
186 |
} |
187 |
if (champ.value.length == 8) |
188 |
{ |
189 |
minute = champ.value.substring(3,5); |
190 |
seconde = champ.value.substring(6,8); |
191 |
} |
192 |
} |
193 |
|
194 |
if (isNaN (heure) || isNaN (minute) || isNaN (seconde)) |
195 |
{ |
196 |
flag = 1; |
197 |
} |
198 |
|
199 |
if (heure < '00' || heure > '23' || minute < '00' || minute > '59' || seconde < '00' || seconde > '59') |
200 |
{ |
201 |
flag = 1; |
202 |
} |
203 |
|
204 |
if (flag == 0) |
205 |
{ |
206 |
champ.value = heure+":"+minute+":"+seconde; |
207 |
} |
208 |
else |
209 |
{ |
210 |
champ.value = ""; |
211 |
alert("L'heure n'est pas valide!") |
212 |
return; |
213 |
} |
214 |
} |
215 |
|
216 |
|
217 |
function vupload (origine) |
218 |
{ |
219 |
if (fenetreouverte == true) |
220 |
pfenetre.close (); |
221 |
pfenetre=window.open("../spg/upload.php?origine="+origine,"Upload","width=300,height=200,top=120,left=120"); |
222 |
fenetreouverte=true; |
223 |
} |
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
function VerifNum (champ) |
230 |
{ |
231 |
if (isNaN (champ.value)) |
232 |
{ |
233 |
alert (lang_numerique); |
234 |
champ.value = ""; |
235 |
return; |
236 |
} |
237 |
champ.value = champ.value.replace (".", ""); |
238 |
} |
239 |
|
240 |
function genaff(file) { |
241 |
if (fenetreouverte == true) { |
242 |
pfenetre.close(); |
243 |
} |
244 |
pfenetre = window.open("../spg/genaff.php?file="+file, "fichier", "width=600,height=400,top=120,left=120,scrollbars=yes"); |
245 |
fenetreouverte = true; |
246 |
} |
247 |
|
248 |
function adresse_postale(form,libelle_voie,numero_voie) |
249 |
{ |
250 |
if(fenetreouverte==true) |
251 |
pfenetre.close(); |
252 |
pfenetre=window.open("../sig/adresse_postale.php?form="+form+"&libelle_voie="+libelle_voie.replace('\'','\\\'')+"&numero_voie="+numero_voie,"adresse_postale","width=400,height=400,top=120,left=120"); |
253 |
fenetreouverte=true; |
254 |
} |
255 |
|
256 |
/** |
257 |
* WIDGET |
258 |
*/ |
259 |
// Cette fonction permet d'associer aux colonnes des actions de deplacement |
260 |
// des widgets |
261 |
function widget_bind_move_actions() { |
262 |
// |
263 |
$( ".column" ).sortable({ |
264 |
connectWith: ".column", |
265 |
handle: ".widget-header-move", |
266 |
stop: function(event, ui) { |
267 |
var order = "" |
268 |
$(".column").each(function(){ |
269 |
order += $(this).attr('id') + "="; |
270 |
order += $(this).sortable("toArray").join("x") + "&"; |
271 |
}) |
272 |
$("#info").load("../spg/widgetctl.php?action=update&"+order); |
273 |
} |
274 |
}); |
275 |
// |
276 |
$( ".column" ).disableSelection(); |
277 |
} |
278 |
|
279 |
// Cette fonction permet d'associer a l'icone "ajouter" l'action d'ajouter un |
280 |
// nouveau widget |
281 |
function widget_bind_add_action() { |
282 |
// |
283 |
$(".widget-add-action").click(function() { |
284 |
$("#widget_").remove(); |
285 |
// |
286 |
$.get("../spg/widgetctl.php?action=insert", function(data) { |
287 |
$(data).prependTo("#column_1").effect("highlight"); |
288 |
widget_bind_edit_actions("#widget_"); |
289 |
$("button, input:submit, input:reset, input:button, p.linkjsclosewindow").button(); |
290 |
}); |
291 |
}); |
292 |
} |
293 |
|
294 |
// Cette fonction permet d'associer a un widget ou a tous les widgets les |
295 |
// differentes actions possibles sur ce ou ces derniers : plier/deplier, |
296 |
// supprimer, ... |
297 |
function widget_bind_edit_actions(widget_selector) { |
298 |
|
299 |
// Initialisation de l'argument de la fonction si besoin |
300 |
widget_selector = typeof(widget_selector) != 'undefined' ? widget_selector : ""; |
301 |
|
302 |
// Ajout de l'icone "reduire" |
303 |
$(widget_selector+" .widget-header").prepend( "<span class='ui-icon ui-icon-minusthick'></span>"); |
304 |
|
305 |
// Ajout de l'icone "supprimer" |
306 |
$(widget_selector+" .widget-header-edit").prepend( "<span class='ui-icon ui-icon-closethick'></span>"); |
307 |
|
308 |
// Bind de l'evenement click sur l'icone "reduire" |
309 |
$(widget_selector+" .widget-header .ui-icon-minusthick" ).click(function() { |
310 |
// On change l'icone "reduire" par l'icone "deplier" ou l'inverse |
311 |
$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick"); |
312 |
// On cache le contenu du widget ou on l'affiche |
313 |
$(this).parents(".widget:first").find(".widget-content-wrapper").toggle(); |
314 |
}); |
315 |
|
316 |
// Bind de l'evenement click sur l'icone "supprimer" |
317 |
$(widget_selector+" .widget-header-edit .ui-icon-closethick" ).click(function() { |
318 |
// On recupere l'attribut id de l'element parent representant le widget |
319 |
widget = $(this).parents(".widget:first").attr('id'); |
320 |
// Si le widget n'est pas le widget d'ajout |
321 |
if (widget != "widget_") { |
322 |
// On appelle le script permettant de realiser l'action supprimer dans |
323 |
// la base de donnees |
324 |
$("#info").load("../spg/widgetctl.php?action=delete&widget="+widget); |
325 |
} |
326 |
// On supprime le widget de l'affichage |
327 |
$(this).parents(".widget:first").hide("highlight", function() { |
328 |
$(this).remove(); |
329 |
}); |
330 |
}); |
331 |
|
332 |
} |
333 |
|
334 |
// Cette fonction permet lors de la validation du formulaire d'ajout de widget, |
335 |
// d'appeler le script PHP permettant de faire le traitement d'ajout dans la |
336 |
// base puis d'ajouter a l'ecran le nouveau widget |
337 |
function widget_add_form_post() { |
338 |
// serialisation des valeurs du formulaire |
339 |
data = "widget_add_form_valid=true&widget="+$("#widget_add_form select").val(); |
340 |
// execution de la requete en POST pour ajouter le widget |
341 |
$.ajax({ |
342 |
type: "POST", |
343 |
url: "../spg/widgetctl.php?action=insert", |
344 |
cache: false, |
345 |
data: data, |
346 |
success: function(html){ |
347 |
// On cache le widget d'ajout |
348 |
$("#widget_").hide("highlight", function() { |
349 |
// On supprime le widget d'ajout |
350 |
$("#widget_").remove(); |
351 |
// On recupere la vue du widget que l'on vient d'ajouter |
352 |
$.get("../spg/widgetctl.php?action=view&widget="+html, function(data) { |
353 |
// On affiche le widget ajoute dans la premiere colonne |
354 |
$(data).prependTo("#column_1").effect("highlight"); |
355 |
// On associe les actions du widget |
356 |
widget_bind_edit_actions("#widget_"+html); |
357 |
}); |
358 |
}); |
359 |
} |
360 |
}); |
361 |
} |
362 |
|
363 |
|
364 |
// specific openfoncier ======================================================== |
365 |
|
366 |
function bible(){ |
367 |
if(fenetreouverte==true) |
368 |
pfenetre.close(); |
369 |
var ev=document.f2.evenement.value; |
370 |
var idx=document.f2.dossier.value; |
371 |
pfenetre=window.open("../spc/bible.php?ev="+ev+"&idx="+idx,"bible","width=600,height=100,top=120,left=120"); |
372 |
fenetreouverte=true; |
373 |
} |
374 |
|
375 |
function bible2() |
376 |
{ |
377 |
if(fenetreouverte==true) |
378 |
pfenetre.close(); |
379 |
var ev=document.f2.evenement.value; |
380 |
var idx=document.f2.dossier.value; |
381 |
pfenetre=window.open("../spc/bible2.php?ev="+ev,"bible","width=600,height=100,top=120,left=120"); |
382 |
fenetreouverte=true; |
383 |
} |
384 |
|
385 |
function bible_auto(){ |
386 |
if(fenetreouverte==true) |
387 |
pfenetre.close(); |
388 |
var ev=document.f2.evenement.value; |
389 |
var idx=document.f2.dossier.value; |
390 |
pfenetre=window.open("../spc/bible_auto.php?idx="+idx+"&ev="+ev,"evenement","width=600,height=300,top=120,left=120"); |
391 |
fenetreouverte=true; |
392 |
} |
393 |
|
394 |
function dossierads_d(debut) |
395 |
{ |
396 |
//if(fenetreouverte==true) |
397 |
window.location="../pdf/pdfetat.php?obj=dossier_ads_d&nature=" |
398 |
+document.f1.nature.value+"&idx=demo&datedebut=" |
399 |
+document.f1.datedebut.value+"&datefin="+document.f1.datefin.value; |
400 |
} |
401 |
|
402 |
function dossierdepot() |
403 |
{ |
404 |
//if(fenetreouverte==true) |
405 |
window.location="../pdf/pdfetat.php?obj=dossier_depot&nature="+ |
406 |
document.f1.nature.value+"&idx=demo&datedebut="+ |
407 |
document.f1.datedebut.value+"&datefin="+document.f1.datefin.value; |
408 |
} |
409 |
|
410 |
function dossierads() |
411 |
{ |
412 |
//if(fenetreouverte==true) |
413 |
window.location="../pdf/pdfetat.php?obj=dossier_ads&nature="+ |
414 |
document.f1.nature.value+"&idx=demo&datedebut="+ |
415 |
document.f1.datedebut.value+"&datefin="+document.f1.datefin.value; |
416 |
} |
417 |
|