1 | //---------------------Include/remove users--------------------------------------------- |
---|
2 | function remove_user(out,usrTasks){ |
---|
3 | select_users = document.getElementById(out); |
---|
4 | array_usrTasks = usrTasks.split("|"); |
---|
5 | for(i=0;i<array_usrTasks.length;i++){ |
---|
6 | if(array_usrTasks[i] == select_users.value){ |
---|
7 | alert("O usuario nao pode ser removido pois possui tarefas pendentes"); |
---|
8 | return; |
---|
9 | } |
---|
10 | } |
---|
11 | for(var i = 0;i < select_users.options.length; i++){ |
---|
12 | if(select_users.options[i].selected) |
---|
13 | select_users.options[i--] = null; |
---|
14 | } |
---|
15 | } |
---|
16 | |
---|
17 | function add_user(out, inp) |
---|
18 | { |
---|
19 | //Verifica a versao do FF |
---|
20 | var agt = navigator.userAgent.toLowerCase(); |
---|
21 | var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false; |
---|
22 | |
---|
23 | var select_available_users = document.getElementById(inp); |
---|
24 | var select_users = document.getElementById(out); |
---|
25 | var count_available_users = select_available_users.length; |
---|
26 | var count_users = select_users.options.length; |
---|
27 | var new_options = ''; |
---|
28 | |
---|
29 | for (i = 0 ; i < count_available_users ; i++) { |
---|
30 | if (select_available_users.options[i].selected) { |
---|
31 | if(document.all) { |
---|
32 | if ( (select_users.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) { |
---|
33 | new_options += '<option value=' |
---|
34 | + select_available_users.options[i].value |
---|
35 | + '>' |
---|
36 | + select_available_users.options[i].text |
---|
37 | + '</option>'; |
---|
38 | } |
---|
39 | } |
---|
40 | else if ( (select_users.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) { |
---|
41 | new_options += '<option value=' |
---|
42 | + select_available_users.options[i].value |
---|
43 | + '>' |
---|
44 | + select_available_users.options[i].text |
---|
45 | + '</option>'; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | if (new_options != '') { |
---|
50 | if(is_firefox_0) |
---|
51 | fixBugInnerSelect(select_users,'###' + new_options + select_users.innerHTML); |
---|
52 | else |
---|
53 | select_users.innerHTML = '###' + new_options + select_users.innerHTML; |
---|
54 | select_users.outerHTML = select_users.outerHTML; |
---|
55 | } |
---|
56 | } |
---|
57 | //-----------------------Fim include/remove users----------------------------------- |
---|
58 | //----------------------Serialize Arrays-------------------------------------------- |
---|
59 | function serialize( mixed_value ) { |
---|
60 | var _getType = function( inp ) { |
---|
61 | var type = typeof inp, match; |
---|
62 | var key; |
---|
63 | if (type == 'object' && !inp) { |
---|
64 | return 'null'; |
---|
65 | } |
---|
66 | if (type == "object") { |
---|
67 | if (!inp.constructor) { |
---|
68 | return 'object'; |
---|
69 | } |
---|
70 | var cons = inp.constructor.toString(); |
---|
71 | match = cons.match(/(\w+)\(/); |
---|
72 | if (match) { |
---|
73 | cons = match[1].toLowerCase(); |
---|
74 | } |
---|
75 | var types = ["boolean", "number", "string", "array"]; |
---|
76 | for (key in types) { |
---|
77 | if (cons == types[key]) { |
---|
78 | type = types[key]; |
---|
79 | break; |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | return type; |
---|
84 | }; |
---|
85 | var type = _getType(mixed_value); |
---|
86 | var val, ktype = ''; |
---|
87 | |
---|
88 | switch (type) { |
---|
89 | case "function": |
---|
90 | val = ""; |
---|
91 | break; |
---|
92 | case "undefined": |
---|
93 | val = "N"; |
---|
94 | break; |
---|
95 | case "boolean": |
---|
96 | val = "b:" + (mixed_value ? "1" : "0"); |
---|
97 | break; |
---|
98 | case "number": |
---|
99 | val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value; |
---|
100 | break; |
---|
101 | case "string": |
---|
102 | val = "s:" + mixed_value.length + ":\"" + mixed_value + "\""; |
---|
103 | break; |
---|
104 | case "array": |
---|
105 | case "object": |
---|
106 | val = "a"; |
---|
107 | var count = 0; |
---|
108 | var vals = ""; |
---|
109 | var okey; |
---|
110 | var key; |
---|
111 | for (key in mixed_value) { |
---|
112 | ktype = _getType(mixed_value[key]); |
---|
113 | if (ktype == "function") { |
---|
114 | continue; |
---|
115 | } |
---|
116 | |
---|
117 | okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key); |
---|
118 | vals += serialize(okey) + |
---|
119 | serialize(mixed_value[key]); |
---|
120 | count++; |
---|
121 | } |
---|
122 | val += ":" + count + ":{" + vals + "}"; |
---|
123 | break; |
---|
124 | } |
---|
125 | if (type != "object" && type != "array") { |
---|
126 | val += ";"; |
---|
127 | } |
---|
128 | return val; |
---|
129 | } |
---|
130 | //---------------------Fim serialize arrays----------------------------------------- |
---|
131 | //----------------------Count Values------------------------------------------------ |
---|
132 | function countValues(val){ |
---|
133 | var num=val.length; |
---|
134 | users = new Array(num); |
---|
135 | for(i=0;i<num;i++){ |
---|
136 | users[i]=val.options[i].value; |
---|
137 | } |
---|
138 | return(users); |
---|
139 | } |
---|
140 | |
---|
141 | //--------------------Fim Count Values---------------------------------------------- |
---|
142 | //----------------------Cria Projeto------------------------------------------------ |
---|
143 | function newProject(name, description,partic,admin){ |
---|
144 | var particArray = serialize(countValues(partic)); |
---|
145 | var adminArray = serialize(countValues(admin)); |
---|
146 | http = new XMLHttpRequest(); |
---|
147 | var url = "action.php"; |
---|
148 | var params = "type=project&name="+name+"&description="+description+"&particArray="+particArray+"&adminArray="+adminArray; |
---|
149 | http.open("POST",url,true); |
---|
150 | |
---|
151 | //Send the proper header information along with the request |
---|
152 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
153 | http.setRequestHeader("Content-length", params.length); |
---|
154 | http.setRequestHeader("Connection", "close"); |
---|
155 | |
---|
156 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
157 | if(http.readyState == 4 && http.status == 200) { |
---|
158 | alert("Projeto criado com sucesso"); |
---|
159 | dataRequest('tabs-1'); |
---|
160 | } |
---|
161 | } |
---|
162 | http.send(params); |
---|
163 | } |
---|
164 | //-----------------------Fim Cria Projeto------------------------------------------- |
---|
165 | //----------------------Cria Sprint------------------------------------------------- |
---|
166 | function newSprint(name, dt_start,dt_end, goal){ |
---|
167 | http = new XMLHttpRequest(); |
---|
168 | var url = "action.php"; |
---|
169 | var params = "type=newSprint&name="+name+"&dt_start="+dt_start+"&dt_end="+dt_end+"&goal="+goal; |
---|
170 | http.open("POST",url,true); |
---|
171 | |
---|
172 | //Send the proper header information along with the request |
---|
173 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
174 | http.setRequestHeader("Content-length", params.length); |
---|
175 | http.setRequestHeader("Connection", "close"); |
---|
176 | |
---|
177 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
178 | if(http.readyState == 4 && http.status == 200) { |
---|
179 | alert("Sprint criado com sucesso"); |
---|
180 | dataRequest('tabs-3'); |
---|
181 | } |
---|
182 | } |
---|
183 | http.send(params); |
---|
184 | } |
---|
185 | //-----------------------Fim Cria Sprint-------------------------------------------- |
---|
186 | //----------------------Cria Tarefa------------------------------------------------- |
---|
187 | function newTask(sprint,important, responsable,title,description,estimate){ |
---|
188 | http = new XMLHttpRequest(); |
---|
189 | var url = "action.php"; |
---|
190 | var params = "type=newTask&sprint="+sprint+"&important="+important+"&responsable="+responsable+"&title="+title+"&description="+description+"&estimate="+estimate; |
---|
191 | http.open("POST",url,true); |
---|
192 | |
---|
193 | //Send the proper header information along with the request |
---|
194 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
195 | http.setRequestHeader("Content-length", params.length); |
---|
196 | http.setRequestHeader("Connection", "close"); |
---|
197 | |
---|
198 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
199 | if(http.readyState == 4 && http.status == 200) { |
---|
200 | alert("Tarefa criada com sucesso"); |
---|
201 | dataRequest('tabs-2'); |
---|
202 | } |
---|
203 | } |
---|
204 | http.send(params); |
---|
205 | } |
---|
206 | //-----------------------Fim Cria Tarefa-------------------------------------------- |
---|
207 | //----------------------Cria Projeto------------------------------------------------ |
---|
208 | function saveProject(projId,name,description,partic,admin){ |
---|
209 | var particArray = serialize(countValues(partic)); |
---|
210 | var adminArray = serialize(countValues(admin)); |
---|
211 | http = new XMLHttpRequest(); |
---|
212 | var url = "action.php"; |
---|
213 | var params = "type=saveProject&projId="+projId+"&name="+name+"&description="+description+"&particArray="+particArray+"&adminArray="+adminArray; |
---|
214 | http.open("POST",url,true); |
---|
215 | |
---|
216 | //Send the proper header information along with the request |
---|
217 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
218 | http.setRequestHeader("Content-length", params.length); |
---|
219 | http.setRequestHeader("Connection", "close"); |
---|
220 | |
---|
221 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
222 | if(http.readyState == 4 && http.status == 200) { |
---|
223 | alert("Projeto salvo com sucesso"); |
---|
224 | dataRequest('tabs-1'); |
---|
225 | } |
---|
226 | } |
---|
227 | http.send(params); |
---|
228 | } |
---|
229 | //-----------------------Fim Cria Projeto------------------------------------------- |
---|
230 | //---------------------Remove Projeto----------------------------------------------- |
---|
231 | function removeProject(projName, projId, projOwner,userLog){ |
---|
232 | if(projOwner != userLog){ |
---|
233 | alert("Voce nao tem permissao para excluir esse projeto."); |
---|
234 | } |
---|
235 | else{ |
---|
236 | var answer = confirm("Tem certeza que deseja excluir o projeto ["+projName+"] ?"); |
---|
237 | if (answer){ |
---|
238 | http = new XMLHttpRequest(); |
---|
239 | var url = "action.php"; |
---|
240 | var params = "type=removeProject&projId="+projId; |
---|
241 | http.open("POST",url,true); |
---|
242 | |
---|
243 | //Send the proper header information along with the request |
---|
244 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
245 | http.setRequestHeader("Content-length", params.length); |
---|
246 | http.setRequestHeader("Connection", "close"); |
---|
247 | |
---|
248 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
249 | if(http.readyState == 4 && http.status == 200) { |
---|
250 | alert("Projeto excluido com sucesso"); |
---|
251 | dataRequest('tabs-1'); |
---|
252 | } |
---|
253 | } |
---|
254 | http.send(params); |
---|
255 | } |
---|
256 | } |
---|
257 | } |
---|
258 | //-------------------Fim remove projeto--------------------------------------------- |
---|
259 | //---------------------listUidNumbers----------------------------------------------- |
---|
260 | function listUidNumber(usr, projId){ |
---|
261 | http = new XMLHttpRequest(); |
---|
262 | url = "action.php"; |
---|
263 | params = "type=listUidNumbers&projId="+projId+"&usr="+usr; |
---|
264 | http.open("POST",url,true); |
---|
265 | |
---|
266 | //Send the proper header information along with the request |
---|
267 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
268 | http.setRequestHeader("Content-length", params.length); |
---|
269 | http.setRequestHeader("Connection", "close"); |
---|
270 | |
---|
271 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
272 | if(http.readyState == 4 && http.status == 200) { |
---|
273 | return(http.responseText); |
---|
274 | } |
---|
275 | } |
---|
276 | } |
---|
277 | //-------------------End listUidNumbers--------------------------------------------- |
---|
278 | //------------------------Edit Project---------------------------------------------- |
---|
279 | function editProject(projId, projOwner, userLog){ |
---|
280 | if(projOwner != userLog){ |
---|
281 | alert("Voce nao tem permissao para editar esse projeto."); |
---|
282 | } |
---|
283 | else{ |
---|
284 | http = new XMLHttpRequest(); |
---|
285 | var url = "action.php"; |
---|
286 | var params = "type=editProject&projId="+projId; |
---|
287 | http.open("POST",url,true); |
---|
288 | |
---|
289 | //Send the proper header information along with the request |
---|
290 | http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
---|
291 | http.setRequestHeader("Content-length", params.length); |
---|
292 | http.setRequestHeader("Connection", "close"); |
---|
293 | |
---|
294 | http.onreadystatechange = function() {//Call a function when the state changes. |
---|
295 | if(http.readyState == 4 && http.status == 200) { |
---|
296 | document.getElementById('tabs-1').innerHTML = ''; |
---|
297 | document.getElementById('tabs-1').innerHTML = http.responseText; |
---|
298 | } |
---|
299 | } |
---|
300 | http.send(params); |
---|
301 | } |
---|
302 | } |
---|
303 | //--------------------Fim Edit Project---------------------------------------------- |
---|
304 | //----------------------Active Project---------------------------------------------- |
---|
305 | function activeProject(projName,projId,activeId){ |
---|
306 | // active = "active_project"+activeId; |
---|
307 | // unactive = "active_project"+projId; |
---|
308 | http = new XMLHttpRequest(); |
---|
309 | http.onreadystatechange = stateActiveProject; |
---|
310 | http.open("GET","/agileProjects/action.php?type=activeProject&projId="+projId+"&projName="+projName); |
---|
311 | http.send(null); |
---|
312 | respostServer = http.responseXML; |
---|
313 | } |
---|
314 | function stateActiveProject() { |
---|
315 | if ( http.readyState == 4) { // Complete |
---|
316 | if ( http.status == 200) { // server reply is OK |
---|
317 | dataRequest('tabs-1'); |
---|
318 | alert("Projeto carregado com sucesso "); |
---|
319 | } else { |
---|
320 | alert( "Problema: " + http.statusText ); |
---|
321 | } |
---|
322 | } |
---|
323 | } |
---|
324 | //----------------------Fim Active Project------------------------------------------ |
---|
325 | //----------------------Active Sprint----------------------------------------------- |
---|
326 | function activeSprint(sprintId){ |
---|
327 | http = new XMLHttpRequest(); |
---|
328 | http.onreadystatechange = stateActiveSprint; |
---|
329 | http.open("GET","/agileProjects/action.php?type=activeSprint&sprintId="+sprintId); |
---|
330 | http.send(null); |
---|
331 | respostServer = http.responseXML; |
---|
332 | } |
---|
333 | function stateActiveSprint() { |
---|
334 | if ( http.readyState == 4) { // Complete |
---|
335 | if ( http.status == 200) { // server reply is OK |
---|
336 | dataRequest('tabs-3'); |
---|
337 | alert("Sprint carregado com sucesso "); |
---|
338 | } else { |
---|
339 | alert( "Problema: " + http.statusText ); |
---|
340 | } |
---|
341 | } |
---|
342 | } |
---|
343 | //----------------------Fim Active Sprint------------------------------------------- |
---|
344 | //---------------------Verifica data------------------------------------------------ |
---|
345 | function mascara_data(d){ |
---|
346 | var mydata = ''; |
---|
347 | data = d.value; |
---|
348 | mydata = mydata + data; |
---|
349 | if (mydata.length == 2){ |
---|
350 | mydata = mydata + '/'; |
---|
351 | d.value = mydata; |
---|
352 | } |
---|
353 | if (mydata.length == 5){ |
---|
354 | mydata = mydata + '/'; |
---|
355 | d.value = mydata; |
---|
356 | } |
---|
357 | if (mydata.length == 10){ |
---|
358 | verifica_data(d); |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | function verifica_data (d) { |
---|
363 | |
---|
364 | dia = (d.value.substring(0,2)); |
---|
365 | mes = (d.value.substring(3,5)); |
---|
366 | ano = (d.value.substring(6,10)); |
---|
367 | |
---|
368 | |
---|
369 | situacao = ""; |
---|
370 | // verifica o dia valido para cada mes |
---|
371 | if ((dia < 01)||(dia < 01 || dia > 30) && ( mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { |
---|
372 | situacao = "falsa"; |
---|
373 | } |
---|
374 | |
---|
375 | // verifica se o mes e valido |
---|
376 | if (mes < 01 || mes > 12 ) { |
---|
377 | situacao = "falsa"; |
---|
378 | } |
---|
379 | |
---|
380 | // verifica se e ano bissexto |
---|
381 | if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { |
---|
382 | situacao = "falsa"; |
---|
383 | } |
---|
384 | |
---|
385 | if (d.value == "") { |
---|
386 | situacao = "falsa"; |
---|
387 | } |
---|
388 | |
---|
389 | if (situacao == "falsa") { |
---|
390 | alert("Data incorreta"); |
---|
391 | d.value = ""; |
---|
392 | d.focus(); |
---|
393 | } |
---|
394 | } |
---|
395 | //--------------------Fim Verifica data--------------------------------------------- |
---|