fix mail e converted video flag

This commit is contained in:
Francesco Picone
2025-12-09 17:15:54 +01:00
parent 59c9b1f5be
commit 91e4559bd2
6 changed files with 71 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ $videos = [];
// Trova tutti i video che potrebbero aver bisogno di conversione
$pdo = get_db_connection();
$stmt = $pdo->query("
SELECT id, title, video_url, video_platform
SELECT id, title, video_url, video_platform, video_converted
FROM lessons
WHERE type = 'video'
AND video_platform = 'local'
@@ -96,15 +96,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['convert_video'])) {
$new_file_path = str_replace('.' . $old_extension, '.' . $new_extension, $input_file);
rename($input_file, $new_file_path);
$stmt = $pdo->prepare("UPDATE lessons SET video_url = ? WHERE id = ?");
$stmt = $pdo->prepare("UPDATE lessons SET video_url = ?, video_converted = TRUE WHERE id = ?");
$stmt->execute([$new_video_url, $lesson_id]);
} else {
// Aggiorna solo il flag video_converted
$stmt = $pdo->prepare("UPDATE lessons SET video_converted = TRUE WHERE id = ?");
$stmt->execute([$lesson_id]);
}
$message = "✅ Video convertito con successo! Il file originale è stato salvato come backup.";
// Ricarica la lista
$stmt = $pdo->query("
SELECT id, title, video_url, video_platform
SELECT id, title, video_url, video_platform, video_converted
FROM lessons
WHERE type = 'video'
AND video_platform = 'local'
@@ -200,7 +204,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['convert_video'])) {
<th>ID</th>
<th>Titolo Lezione</th>
<th>Percorso Video</th>
<th>Formato</th>
<th>Formato & Stato</th>
<th>Dimensione</th>
<th>Azione</th>
</tr>
@@ -228,17 +232,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['convert_video'])) {
<span class="badge" style="background: <?php echo $extension === 'mp4' ? '#2ecc71' : '#e74c3c'; ?>;">
<?php echo strtoupper($extension); ?>
</span>
<?php if ($video['video_converted']): ?>
<span class="badge" style="background: #3498db; margin-left: 5px;">✓ Convertito</span>
<?php endif; ?>
</td>
<td><?php echo $file_size_mb; ?> MB</td>
<td>
<?php if ($exists && $ffmpeg_available): ?>
<form method="POST" style="display: inline;"
onsubmit="return confirm('Vuoi convertire questo video? Il processo potrebbe richiedere alcuni minuti.');">
<input type="hidden" name="lesson_id" value="<?php echo $video['id']; ?>">
<button type="submit" name="convert_video" class="btn btn-primary btn-sm">
🔄 Converti
</button>
</form>
<?php if ($video['video_converted']): ?>
<span style="color: #27ae60; font-size: 0.9em;">✓ Già convertito</span>
<?php else: ?>
<form method="POST" style="display: inline;"
onsubmit="return confirm('Vuoi convertire questo video? Il processo potrebbe richiedere alcuni minuti.');">
<input type="hidden" name="lesson_id" value="<?php echo $video['id']; ?>">
<button type="submit" name="convert_video" class="btn btn-primary btn-sm">
🔄 Converti
</button>
</form>
<?php endif; ?>
<?php else: ?>
<span style="color: #999;">Non disponibile</span>
<?php endif; ?>