Update VM and DHCP management pages, optimize code
- Modified VM queries in `SYN-VMList.php` to remove unnecessary cluster filtering. - Adjusted page titles for better context in `SYN-VMList.php`. - Updated `dhcp_servers.php` with enhanced table export and added new JavaScript (`switch.js`). - Extended French translations in `fr.php` with new VM-related terms. - Enhanced KPI calculations in `Crossover-KPI.js` with improved checks and parameter handling. - Refactored and streamlined `GlobalCrossover.php` for cleaner and more efficient code, improving readability and maintainability.
This commit is contained in:
@@ -1,29 +1,59 @@
|
||||
function dateDiffInDays(a) {
|
||||
const _MS_PER_DAY = 1000 * 60 * 60 * 24;
|
||||
return Math.floor((Date.now() - new Date(a)) / _MS_PER_DAY);
|
||||
if (!a || a === 'Missing' || a === ' ') return 999; // Sécurité
|
||||
const _MS_PER_DAY = 1000 * 60 * 60 * 24;
|
||||
return Math.floor((Date.now() - new Date(a)) / _MS_PER_DAY);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$button.click(function () {
|
||||
$data = $table.bootstrapTable('getData')
|
||||
$dl = $data.length
|
||||
$nSCCM=0; $nAD=0; $nGLPI=0;$nEPO=0;$nNBU=0;$nOS=0;$nSCOM=0;$nZabbix=0;$nS1=0;
|
||||
for( $i=0 ; $i < $dl ; $i++ ){
|
||||
if ($data[$i]['AD'] !== 'Missing') { $nAD++ ; }
|
||||
if ((dateDiffInDays($data[$i]['ADlu'].split(" ")[0]) > 45 || $data[$i]['ADlu'] == 'Missing') && $data[$i]['AD'] !== 'Missing'){ $nAD-- ;}
|
||||
if ($data[$i]['SCCM'] !== 'Missing') { $nSCCM++ ; }
|
||||
if ((dateDiffInDays($data[$i]['SCCMlu'].split(" ")[0]) > 7 || $data[$i]['SCCMlu'] == 'Missing') && $data[$i]['SCCM'] !== 'Missing'){ $nSCCM-- ;}
|
||||
if ($data[$i]['GLPI'] !== 'Missing') { $nGLPI++ ; }
|
||||
if ((dateDiffInDays($data[$i]['GLPIlu'].split(" ")[0]) > 7 || $data[$i]['GLPIlu'] == 'Missing') && $data[$i]['GLPI'] !== 'Missing'){ $nGLPI-- ;}
|
||||
if ($data[$i]['NESSUS'] !== 'Missing') { $nEPO++ ; }
|
||||
if ($data[$i]['Backup'] !== 'Missing') { $nNBU++ ; }
|
||||
if ((dateDiffInDays($data[$i]['NBUlu'].split(" ")[0]) > 30 || $data[$i]['NBUlu'] == 'Missing') && $data[$i]['Backup'].split(" ")[0] !== 'Missing'){ $nNBU-- ;}
|
||||
if (($data[$i]['OS'].includes('XP') || $data[$i]['OS'].includes('2000') || $data[$i]['OS'].includes('2003') || $data[$i]['OS'].includes('2008') || $data[$i]['OS'].includes('2012') || $data[$i]['OS'].includes('7') || $data[$i]['OS'].includes('Windows NT')) == false && $data[$i]['OS'] !==' ') { $nOS++ ;}
|
||||
if ($data[$i]['SCOM'] !== 'Missing') { $nSCOM++ ; }
|
||||
if ($data[$i]['Zabbix'] !== 'Missing') { $nZabbix++ ; }
|
||||
if ($data[$i]['S1'] !== 'Missing') { $nS1++ ; }
|
||||
if ((dateDiffInDays($data[$i]['S1lu'].split(" ")[0]) > 7 || $data[$i]['S1lu'] == 'Missing') && $data[$i]['S1'] !== 'Missing'){ $nS1-- ;}
|
||||
}
|
||||
$('#button').click(function () {
|
||||
var $data = $('#t1').bootstrapTable('getData');
|
||||
var $dl = $data.length;
|
||||
if ($dl === 0) return;
|
||||
|
||||
var $nSCCM=0, $nAD=0, $nGLPI=0, $nEPO=0, $nNBU=0, $nOS=0, $nSCOM=0, $nZabbix=0, $nS1=0;
|
||||
|
||||
for(var $i=0 ; $i < $dl ; $i++ ){
|
||||
// Vérification AD
|
||||
if ($data[$i]['AD'] !== 'Missing') {
|
||||
$nAD++;
|
||||
var adDate = ($data[$i]['ADlu'] || '').split(" ")[0];
|
||||
if (dateDiffInDays(adDate) > 45 || adDate === '') { $nAD--; }
|
||||
}
|
||||
// Vérification SCCM
|
||||
if ($data[$i]['SCCM'] !== 'Missing') {
|
||||
$nSCCM++;
|
||||
var sccmDate = ($data[$i]['SCCMlu'] || '').split(" ")[0];
|
||||
if (dateDiffInDays(sccmDate) > 7 || sccmDate === '') { $nSCCM--; }
|
||||
}
|
||||
// Vérification GLPI
|
||||
if ($data[$i]['GLPI'] !== 'Missing') {
|
||||
$nGLPI++;
|
||||
var glpiDate = ($data[$i]['GLPIlu'] || '').split(" ")[0];
|
||||
if (dateDiffInDays(glpiDate) > 7 || glpiDate === '') { $nGLPI--; }
|
||||
}
|
||||
// NESSUS
|
||||
if ($data[$i]['NESSUS'] !== 'Missing' && $data[$i]['NESSUS'] !== ' ') { $nEPO++; }
|
||||
// BACKUP
|
||||
if ($data[$i]['Backup'] !== 'Missing') {
|
||||
$nNBU++;
|
||||
var nbuDate = ($data[$i]['NBUlu'] || '').split(" ")[0];
|
||||
if (dateDiffInDays(nbuDate) > 30 || nbuDate === '') { $nNBU--; }
|
||||
}
|
||||
// OS (Supporté)
|
||||
var os = $data[$i]['OS'] || '';
|
||||
if (!(os.includes('XP') || os.includes('2000') || os.includes('2003') || os.includes('2008') || os.includes('2012') || os.includes('7')) && os !== ' ') { $nOS++; }
|
||||
|
||||
// SCOM & Zabbix
|
||||
if ($data[$i]['SCOM'] !== 'Missing') { $nSCOM++; }
|
||||
if ($data[$i]['Zabbix'] !== 'Missing') { $nZabbix++; }
|
||||
|
||||
// S1
|
||||
if ($data[$i]['S1'] !== 'Missing') {
|
||||
$nS1++;
|
||||
var s1Date = ($data[$i]['S1lu'] || '').split(" ")[0];
|
||||
if (dateDiffInDays(s1Date) > 7 || s1Date === '') { $nS1--; }
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("KPIAD").innerHTML = Math.round($nAD/$dl*1000)/10 + "%";
|
||||
if(Math.round($nAD/$dl*100) >=90){
|
||||
|
||||
Reference in New Issue
Block a user