|
1
|
|
|
/** |
|
2
|
|
|
Copyright (C) 2018-2020 KANOUN Salim |
|
3
|
|
|
This program is free software; you can redistribute it and/or modify |
|
4
|
|
|
it under the terms of the Affero GNU General Public v.3 License as published by |
|
5
|
|
|
the Free Software Foundation; |
|
6
|
|
|
This program is distributed in the hope that it will be useful, |
|
7
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9
|
|
|
Affero GNU General Public Public for more details. |
|
10
|
|
|
You should have received a copy of the Affero GNU General Public Public along |
|
11
|
|
|
with this program; if not, write to the Free Software Foundation, Inc., |
|
12
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* check all require filds in a form before submit |
|
17
|
|
|
*/ |
|
18
|
|
|
function checkForm(form) { |
|
19
|
|
|
var inputs = form.elements; |
|
20
|
|
|
for (var i = 0; i < inputs.length; i++) { |
|
21
|
|
|
if(inputs[i].hasAttribute("required")){ |
|
22
|
|
|
if(inputs[i].value == ""){ |
|
23
|
|
|
// found an empty field |
|
24
|
|
|
alertifyError("Please fill in all fields"); |
|
25
|
|
|
return false; |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
return true; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Change color of key text value in the tables |
|
34
|
|
|
* @returns |
|
35
|
|
|
*/ |
|
36
|
|
|
function changeColor(){ |
|
37
|
|
|
|
|
38
|
|
|
//Polly fill for IE11 missing function |
|
39
|
|
|
if (!String.prototype.includes) { |
|
40
|
|
|
Object.defineProperty(String.prototype, 'includes', { |
|
41
|
|
|
value: function(search, start) { |
|
42
|
|
|
if (typeof start !== 'number') { |
|
43
|
|
|
start = 0 |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if (start + search.length > this.length) { |
|
47
|
|
|
return false |
|
48
|
|
|
} else { |
|
|
|
|
|
|
49
|
|
|
return this.indexOf(search, start) !== -1 |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
}) |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
//on parcours tout les tableaux (balises table) |
|
57
|
|
|
$("table:visible").each(function (i, el){ |
|
58
|
|
|
//si la table a un id |
|
59
|
|
|
if(el.id != ""){ |
|
60
|
|
|
//on parcours chaque clonne de la table (identifiée grace à son id) |
|
61
|
|
|
$('#'+el.id+' tr').each(function (i, el){ |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$(this).find('td').each (function() { |
|
64
|
|
|
if( $(this).html().includes("Not Done") || $(this).html().includes("Refused") ){ |
|
65
|
|
|
$(this).css('color', '#D53333'); |
|
66
|
|
|
} |
|
67
|
|
|
else if( $(this).html().includes("Done") || $(this).html().includes("Accepted") ) { |
|
68
|
|
|
$(this).css('color', '#47B236)'); |
|
69
|
|
|
} |
|
70
|
|
|
else if($(this).html().includes("Should be done") || $(this).html().includes("Wait Definitive Conclusion") || $(this).html().includes("Draft") || $(this).html().includes("Corrective Action Asked")){ |
|
71
|
|
|
$(this).css('color', '#E29300'); |
|
72
|
|
|
} |
|
73
|
|
|
}); |
|
74
|
|
|
}); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
}); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Download documentation by id |
|
82
|
|
|
* @param id |
|
83
|
|
|
* @returns |
|
84
|
|
|
*/ |
|
85
|
|
|
function downloadDocumentation(id){ |
|
86
|
|
|
window.location="scripts/download_documentation.php?idDocumentation="+id; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
function alertifyError(message){ |
|
90
|
|
|
alertify.error(message); |
|
|
|
|
|
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
function alertifyWarning(message){ |
|
94
|
|
|
alertify.warning(message); |
|
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
function alertifySuccess(message){ |
|
98
|
|
|
alertify.success(message); |
|
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
function alertifyMessage(message) { |
|
102
|
|
|
alertify.message(message); |
|
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
function µ(str) { |
|
106
|
|
|
// Escape & < > " chars |
|
107
|
|
|
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
|