Veeam

DATEADD(DAY, -2, GETDATE()) "; $rs_vms = odbc_exec($conn, $sql_vms); $vmsae = []; while ($row = odbc_fetch_array($rs_vms)){ $vmsae[] = $row['name']; } $conn = DB_INFRA(); $sql = "SELECT * FROM Veeam_Reporting"; $rs = odbc_exec($conn, $sql); $total = 0; $er = 0; $outdated = 0; $excluded = 0; $success = 0; $war = 0; $reportData = []; // 1. Stockage et pré-calcul des poids de tri while ($row = odbc_fetch_array($rs)) { if(!in_array($row['ClientName'], $vmsae)) continue; $total++; $rowClass = ""; $sortWeight = 4; // Par défaut Success $LastGoodStr = "NEVER"; // Calcul de l'ancienneté $diffDays = 999; if (!empty($row['LastSuccess']) && $row['LastSuccess'] != '1900-01-01') { $date1 = date_create($row['LastSuccess']); $diff = date_diff($date1, date_create(date("Y-m-d"))); $diffDays = (int)$diff->format("%R%a"); $LastGoodStr = date('Y-m-d H:i', strtotime($row['LastSuccess'])) . " (".$diffDays."J)"; if($diffDays > 365){$LastGoodStr = "NEVER";} } // Nouvelle logique de tri hiérarchique if ($row['LastStatus'] == 'Failed' || $row['LastStatus'] == 'Unknown') { $rowClass = "table-danger"; $sortWeight = 0; $er++; } elseif ($row['LastStatus'] == 'Warning') { $rowClass = "table-warning"; $sortWeight = 1; $war++; } elseif ($diffDays >= 2) { $rowClass = "table-info"; $sortWeight = 2; $outdated++; } elseif ($row['LastStatus'] == 'In Progress') { $rowClass = "table-info"; $sortWeight = 3; } else { $rowClass = "table-success"; $sortWeight = 4; $success++; } // On stocke les infos pour le tri PHP multiniveau $reportData[] = [ 'sort_weight' => $sortWeight, 'client_name' => $row['ClientName'], 'row_class' => $rowClass, 'last_run' => $row['LastRun'], 'last_status' => $row['LastStatus'], 'last_good' => $LastGoodStr, 'size' => $row['SizeGB'], 'duration' => $row['Duration'], 'policy_name' => $row['PolicyName'], 'error_message'=> $row['ErrorMessage'] ]; } // 2. Tri multiniveau en PHP : par poids d'abord, puis par nom de VM usort($reportData, function($a, $b) { if ($a['sort_weight'] === $b['sort_weight']) { return strcasecmp($a['client_name'], $b['client_name']); // Tri alphabétique A-Z de la VM } return $a['sort_weight'] <=> $b['sort_weight']; // Tri ascendant du poids (0 à 4) }); // 3. Rendu HTML des lignes triées foreach ($reportData as $data) { echo ""; echo ""; echo ""; // Conserve le data-sort pour permettre à l'utilisateur de retrier via bootstrap-table s'il clique sur la colonne echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } ?>
(GB) Duration Message
{$data['client_name']}" . date('Y-m-d H:i', strtotime($data['last_run'])) . "{$data['last_status']}{$data['last_good']}{$data['size']}{$data['duration']}{$data['policy_name']}{$data['error_message']}
$success OK - $er Error - $war Warning - $outdated $w_outdated)"; ?>