-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
159 lines (150 loc) · 22.3 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
var fs = require('fs'),
path = require('path'),
glob = require("glob"),
conf = require('./config.js'),
dataApp = {};
// Create the dataApp object with all informations.json file of the folder's hierarchy
fromDir(conf.rootPath, 'informations.json');
// Fetch user's submitted annexes
Object.keys(dataApp).map((formation)=>{
dataApp[formation].map(user =>{
annexesPath = user.folder + path.sep + 'annexes' ;
var annexes = fs.readdirSync(annexesPath);
// Remove Thumbs.db
annexes = annexes.filter(function(item) {
return item !== 'Thumbs.db';
});
user['annexes'] = annexes
});
});
// Save the concatenation of all information in json format
// - maybe it will be useful at some point
fs.writeFileSync('AllIn.json', JSON.stringify(dataApp), 'UTF-8');
// Create the HTML files and save it to the results directory
Object.keys(dataApp).map((formation)=>{
var html = '<!DOCTYPE html>\n<html>\n<head>';
html += '\n\t<meta charset="utf-8" />';
html += '\n\t<title>Candidature ' + formation + '</title>';
html += '\n\t<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">';
html += '\n\t<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>';
html += '\n\t<script src="http://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>';
html += '\n</head>';
html += '\n<body>';
html += '\n\t<h2>' + formation + ' (fichier généré le ' + new Date().toISOString().split('T')[0] + ')</h2>';
html += '\n\t<table id="' + formation + '">';
html += '\n\t\t<thead>';
html += '\n\t\t\t<tr>' + conf.tableHeaders[formation].headers.map(header => '\n\t\t\t<th nowrap>' + header + '</th>').join('') + '\n\t\t\t</tr>' + '\n\t\t</thead>';
html += dataApp[formation].map(user => '\n\t\t<tr>' + conf.tableHeaders[formation].keys.map(header => {
switch (header) {
case 'datePostulation':
var dP = user[header].split('-');
// Fix 0 padding in case they are missing
return '\n\t\t\t<td>' + dP[2] + '-' + ('00'+dP[1]).substring(dP[1].length) + '-' + ('00'+dP[0]).substring(dP[0].length) + ' ' + dP[4] + '</td>';
//return '\n\t\t\t<td>' + dP[2] + '-' + dP[1] + '-' + dP[0] + ' ' + dP[4] + '</td>';
case 'addresseApprentiComplete':
return '\n\t\t\t<td nowrap>' + user[header].rue +'<br />' + user[header].NPA + ' <a href="http://maps.google.com/?q=' + (user[header].rue + ' ' + user[header].NPA).split(' ').join('+') + '"><img class="imgmap" src="../img/fff/icons/map_go.png" alt="' + user[header].NPA + '" /></a></td>';
case 'filiere':
switch (user[header]) {
case 'entreprise':
return '\n\t\t\t<td>Entreprise <img src="" class="imgcomputer" title="' + user[header] + '" /></td>';
case 'developpementApplications':
return '\n\t\t\t<td>Dev <img src="" class="imgdev" title="' + user[header] + '" /></td>';
case 'techniqueSysteme':
return '\n\t\t\t<td>TechSys <img src="" class="imgtechsys" title="' + user[header] + '" /></td>';
case 'neSaisPas':
return '\n\t\t\t<td>? <img src="" class="imghelp" title="' + user[header] + '" /></td>';
default:
return '\n\t\t\t<td>' + user[header] + '</td>';
}
case 'mailApprenti':
return '\n\t\t\t<td><a href="mailto:' + user[header] + '">' + user[header] + '</a></td>';
case 'genreApprenti':
return '\n\t\t\t<td>' + ((user[header] == 'Femme') ? 'F <img class="imgfemale" src="../img/fff/icons/female.png' : 'M <img class="imgmale" src="../img/fff/icons/male.png') + '" title="' + user[header] + '" /></td>';
case 'maturite':
case 'majeur':
case 'dejaCandidat':
return '\n\t\t\t<td>' + ((user[header] == 'true') ? 'O <img class="imgtick" src="../img/fff/icons/tick.png' : 'N <img class="imgcross" src="../img/fff/icons/cross.png') + '" title="' + user[header] + '" /></td>';
case 'connaissancesLinguistiques':
return '\n\t\t\t<td>' + user[header].map(header => '\n\t\t\t\t' + header + '<img class="imgflag' + header + '"src="../img/fff/flags/' + header + '.png" title="' + header + '" />').join(' ') + '</td>';
case 'dateNaissanceApprenti':
var dob = user[header].split('/');
var birthday = new Date(dob[2], dob[1], dob[0]);
return '\n\t\t\t<td>' + dob[2] + ' (' + _calculateAge(birthday) + 'ans)</td>';
case 'activitesProfessionnelles':
return '\n\t\t\t<td>' + user[header].map(empl => empl.employeur).join('<br />') + '</td>';
case 'telFixeApprenti':
return '\n\t\t\t<td nowrap><img src="../img/fff/icons/telephone.png" /> ' + user[header].split(' ').join(' ') + '</td>';
case 'telMobileApprenti':
return '\n\t\t\t<td nowrap><img src="../img/fff/icons/phone.png" /> ' + user[header].split(' ').join(' ') + '</td>';
case 'stages':
return '\n\t\t\t<td nowrap>' + user[header].map(stage => stage.employeur).join(',<br />') + '</td>';
case 'annexes':
//var annexesPath = '..' + path.sep + user.folder + path.sep + 'annexes/' ;
var annexesPath = './' + user.folderUser + path.sep + 'annexes' + path.sep ;
return '\n\t\t\t<td nowrap><ul>' + user[header].map(annexe => '<li><a target="_blank" href="' + annexesPath + annexe + '">' + annexe + '</a></li>').join('\n') + '</ul></td>';
default:
return '\n\t\t\t<td>' + user[header] + '</td>';
}
}).join('') + '\n\t\t</tr>').join('');
html += '\n\t</table>';
html += "\n<script>$(document).ready(function(){";
html += "\n\t\t$('#" + formation + "').DataTable({'pageLength': 100});";
html += '\n\t$(\'.imgcomputer\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJ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BdQrzSCwksLRbOpHUSb7pcsnxCCwngvM2Rm/ugUCi84fycr4l2t8Bb6iqTxSCgNIAAAAAElFTkSuQmCC\');';
html += '\n\t$(\'.imgcross\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIhSURBVDjLlZPrThNRFIWJicmJz6BWiYbIkYDEG0JbBiitDQgm0PuFXqSAtKXtpE2hNuoPTXwSnwtExd6w0pl2OtPlrphKLSXhx07OZM769qy19wwAGLhM1ddC184+d18QMzoq3lfsD3LZ7Y3XbE5DL6Atzuyilc5Ciyd7IHVfgNcDYTQ2tvDr5crn6uLSvX+Av2Lk36FFpSVENDe3OxDZu8apO5rROJDLo30+Nlvj5RnTlVNAKs1aCVFr7b4BPn6Cls21AWgEQlz2+Dl1h7IdA+i97A/geP65WhbmrnZZ0GIJpr6OqZqYAd5/gJpKox4Mg7pD2YoC2b0/54rJQuJZdm6Izcgma4TW1WZ0h+y8BfbyJMwBmSxkjw+VObNanp5h/adwGhaTXF4NWbLj9gEONyCmUZmd10pGgf1/vwcgOT3tUQE0DdicwIod2EmSbwsKE1P8QoDkcHPJ5YESjgBJkYQpIEZ2KEB51Y6y3ojvY+P8XEDN7uKS0w0ltA7QGCWHCxSWWpwyaCeLy0BkA7UXyyg8fIzDoWHeBaDN4tQdSvAVdU1Aok+nsNTipIEVnkywo/FHatVkBoIhnFisOBoZxcGtQd4B0GYJNZsDSiAEadUBCkstPtN3Avs2Msa+Dt9XfxoFSNYF/Bh9gP0bOqHLAm2WUF1YQskwrVFYPWkf3h1iXwbvqGfFPSGW9Eah8HSS9fuZDnS32f71m8KFY7xs/QZyu6TH2+2+FAAAAABJRU5ErkJggg==\');';
html += '\n\t$(\'.imgflagen\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgA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Fll5b9///4CwZ+/QIN///7969evn0AQHf2egQEggMC2MDL+BwOoATAAcS9AAIFt+fEDLACGyCq+fgWqAAggFiBmBKrw9WX48+f/1q1QSXNzoFMYZWWBsgABBFIB9BXI5UDXwcGvX0AEcSlAAIFUMP3+A/QYSFF8AtAahp8/gLoZwNqAsgABxPgVKfj+oYYmBAEEGACuqcePp4nP0QAAAABJRU5ErkJggg==\');';
html += '\n\t$(\'.imgflagfr\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAIAAAD5gJpuAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGzSURBVHjaYiyeepkBBv79+Zfnx/f379+fP38CyT9//jAyMiq5GP77wvDnJ8MfoAIGBoAAYgGqC7STApL///3/9++/pCTv////Qdz/QO4/IMna0vf/z+9/v379//37bUUTQACBNDD8Z/j87fffvyAVX79+/Q8GQDbQeKA9fM+e/Pv18/+vnwzCIkBLAAKQOAY5AIAwCEv4/4PddNUm3ji0QJyxW3rgzE0iLfqDGr2oYuu0l54AYvnz5x9Q6d+/QPQfyAQqAin9B3EOyG1A1UDj//36zfjr1y8GBoAAFI9BDgAwCMIw+P8Ho3GDO6XQ0l4MN8b2kUwYaLszqgKM/KHcDXwBxAJUD3TJ779A8h9Q5D8SAHoARP36+Rfo41+/mcA2AAQQy49ff0Cu//MPpAeI/0FdA1QNYYNVA/3wmwEYVgwMAAHE8uPHH5BqoD1//gJJLADoJKDS378Z//wFhhJAALF8A3rizz8uTmYg788fJkj4QOKREQyYxSWBhjEC/fcXZANAALF8+/anbcHlHz9+ffvx58uPX9KckkCn/gby/wLd8uvHjx96k+cD1UGiGQgAAgwA7q17ZpsMdUQAAAAASUVORK5CYII=\');';
html += '\n\t$(\'.imgflagde\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAIAAAD5gJpuAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGzSURBVHjaYvTxcWb4+53h3z8GZpZff/79+v3n/7/fDAz/GHAAgABi+f37e3FxOZD1Dwz+/v3z9y+E/AMFv3//+Qumfv9et241QACxMDExAVWfOHkJJAEW/gUEP0EQDn78+AHE/gFOQJUAAcQiy8Ag8O+fLFj1n1+/QDp+/gQioK7fP378+vkDqOH39x9A/RJ/gE5lAAhAYhzcAACCQBDkgRXRjP034R0IaDTZTFZn0DItot37S94KLOINerEcI7aKHAHE8v/3r/9//zIA1f36/R+o4tevf1ANYNVA9P07RD9IJQMDQACxADHD3z8Ig4GMHz+AqqHagKp//fwLVA0U//v7LwMDQACx/LZiYFD7/5/53/+///79BqK/EMZ/UPACSYa/v/8DyX9A0oTxx2EGgABi+a/H8F/m339BoCoQ+g8kgRaCQvgPJJiBYmAuw39hxn+uDAABxMLwi+E/0PusRkwMvxhBGoDkH4b/v/+D2EDyz///QB1/QLb8+sP0lQEggFh+vGXYM2/SP6A2Zoaf30Ex/J+PgekHwz9gQDAz/P0FYrAyMfz7wcDAzPDtFwNAgAEAd3SIyRitX1gAAAAASUVORK5CYII=\');';
html += '\n\t$(\'.imgflagothers\').attr(\'src\', \'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAM+SURBVBgZBcHLT1xVAMDh333MkxmYAYZOwbGGPqRaHq0gpIBGba3GR2KibjQmsHDXsHDjP2DSmBgTU7swUUk0ajemK1HapjYIoYRqi4DoUAsNjwIyw9wZ7tzHOff4fZpSCgAAgJHJ4UHgPNADZAATKAG3VKAufTb49c8AAACaUgqAkclhExgF3nwtdyaSjmWw7BpsD4R0EGxxfXNMSCGvCiHf/vLlHyoAmlKKkcnhEHCju/HJ/hdzz2E5EVw8li2Ns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KOOzRsNI3OsbDWPDpC8dxkIoQQ2g3Z6jHJlqT+o8d4+1x1ZlD683Pju0kK6qNzdbM15VH6vrxSm6BCoEkCRD/SjW6Xb0JnL/biU5cV2ZJyrpZ07+uN+X1/fpR/8o0r4AgkoANBpTmpMz2u15reY69Wd2aizWNPI7bZi5YZinNs1uc/LaAdvn31KtFAJqAdDr9EXREH3f3/jLqSsXlI+k0u9+kWaZDdNbbZu/Xy/pe+mr97z21H4BNSEImJya182Gfohjf6R1WZF6dPsReVnIi1yhtNxZsmPTA6J04NkP9tgRnlaDsiydX/rdpRs/azZbkiSRZKm8LCyu/mpUZLJiZJSPdIc9Ozc/KBrFzg7eVQuIs76VfGR8rGmi0ZYMU0mWyPLMHZMLsiKXl4WbnT9NN+ddXPrG5eUr7u0eUCMIoaJl0iDExvOGNaEpzhLHz70iLVJJlrp7drtddz3mwuLXzi+e8+rBEz4+9qlaluXyPLdxeqeNMwQQ7NryJAghgMPH7hMqDZeXL3vj8Ic2Ti3I8k+EfYee+Hzd3Oyear2GIAACAOBM67i0LD3UP2RCS5blVm6tnPofTwlmPORvTlwAAAAASUVORK5CYII=\');';
html += "\n});</script>";
html += '\n</body>\n</html>';
//console.log(html);
fs.writeFileSync('./results/'+formation+'.html', html, 'UTF-8');
console.log('Files written in ./resuts/');
});
// Recurse into the startPath directory to find and read all the file matching filter
function fromDir(startPath, filter) {
if (!fs.existsSync(startPath)) {
console.log("no dir ", startPath);
return;
}
var files = fs.readdirSync(startPath);
for (var i = 0; i < files.length; i++) {
var filename = path.join(startPath, files[i]);
var stat = fs.lstatSync(filename);
if (stat.isDirectory()) {
fromDir(filename, filter); //recurse
} else if (filename.indexOf(filter) >= 0) {
// Read the JSON file synchronously
var obj = JSON.parse(fs.readFileSync(filename, 'utf8'));
obj.folder = filename.split(path.sep).slice(0, -2).join(path.sep);
obj.folderUser = filename.split(path.sep).slice(2, -2).join(path.sep);
//console.log(obj.folder2)
var form = filename.split(path.sep)[1];
if (form in conf.tableHeaders === false) {
console.log("The lookup index is not in table header, please check how the filename is splitted in fromDir function in app.js", form);
return;
}
if (!dataApp[form]){
dataApp[form] = [];
}
dataApp[form].push(obj);
}
}
}
// Return an Human Readable Date Diff in Year (aka Age)
function _calculateAge(birthday) { // birthday is a date
var birthday = new Date(birthday);
var ageDifMs = Date.now() - birthday.getTime();
var ageDate = new Date(ageDifMs); // miliseconds from epoch
return Math.abs(ageDate.getUTCFullYear() - 1970);
}