diff --git a/api/report.php b/api/report.php new file mode 100644 index 0000000..feb75f0 --- /dev/null +++ b/api/report.php @@ -0,0 +1,38 @@ + false, 'error' => 'No se recibieron datos.']); + exit; +} + +$name = $input['name'] ?? 'Anónimo'; +$email = $input['email'] ?? 'No proporcionado'; +$issueType = $input['issue_type'] ?? 'No especificado'; +$description = $input['description'] ?? 'Sin descripción'; +$song = $input['current_song'] ?? 'Desconocida'; + +$subject = "Reporte de Problema - Lili Records Radio"; +$html = " +

Reporte de Problema

+

Nombre: $name

+

Email: $email

+

Tipo de problema: $issueType

+

Descripción: $description

+

Canción sonando: $song

+
+

Enviado desde el reproductor web de Lili Records Radio.

+"; +$txt = "Reporte de Problema\nNombre: $name\nEmail: $email\nTipo: $issueType\nDescripción: $description\nCanción: $song"; + +// Use the default MAIL_TO from .env +$res = MailService::sendMail(null, $subject, $html, $txt, ['reply_to' => $email !== 'No proporcionado' ? $email : null]); + +if (!empty($res['success'])) { + echo json_encode(['success' => true]); +} else { + echo json_encode(['success' => false, 'error' => $res['error'] ?? 'Error desconocido al enviar el reporte.']); +} diff --git a/index.php b/index.php index 42c5a8e..ec06e66 100644 --- a/index.php +++ b/index.php @@ -952,14 +952,14 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; - + +
+
+

Reportar un Problema

+

Cuéntanos qué está fallando para poder arreglarlo.

+ +
+
+ + +
+
+ + +
+ +
+ + +
+
+
@@ -1850,6 +1883,63 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; // --- End Sleep Timer & Upcoming Tracks --- + function openReportModal() { + const modal = document.getElementById('report-modal'); + modal.style.display = 'flex'; + setTimeout(() => modal.classList.add('show'), 10); + } + + function closeReportModal() { + const modal = document.getElementById('report-modal'); + modal.classList.remove('show'); + setTimeout(() => modal.style.display = 'none', 300); + } + + async function submitReport() { + const btn = document.getElementById('submit-report-btn'); + const type = document.getElementById('report-issue-type').value; + const description = document.getElementById('report-description').value.trim(); + const name = document.getElementById('user-name').value.trim() || 'Anónimo'; + const phone = document.getElementById('user-phone').value.trim() || 'No proporcionado'; + const currentSong = document.getElementById('track-title').innerText; + + if (!description) { + alert('Por favor, describe el problema.'); + return; + } + + btn.disabled = true; + btn.innerHTML = ' ENVIANDO...'; + + try { + const response = await fetch('api/report.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + name: name, + email: phone, // Using phone as contact email since it's the identifier we have + issue_type: type, + description: description, + current_song: currentSong + }) + }); + const result = await response.json(); + if (result.success) { + alert('Gracias por tu reporte. Lo revisaremos pronto.'); + document.getElementById('report-description').value = ''; + closeReportModal(); + } else { + alert('Error: ' + (result.error || 'No se pudo enviar el reporte.')); + } + } catch (error) { + console.error('Report error:', error); + alert('Error de conexión al enviar el reporte.'); + } finally { + btn.disabled = false; + btn.innerHTML = ' ENVIAR REPORTE'; + } + } + // Fetch Now Playing Metadata from RadioKing let progressInterval = null;