Fix: Corrige errores en recurrentes y limpia el repositorio

This commit is contained in:
2026-01-17 16:54:27 -06:00
parent 4c48c279de
commit 3f0727984a
32 changed files with 134 additions and 2157552 deletions

View File

@@ -111,7 +111,7 @@ require_once __DIR__ . '/templates/header.php';
<?php endif; ?>
</td>
<td>
<button class="btn btn-sm btn-info" onclick="previewMessage(<?php echo htmlspecialchars(json_encode($msg['message_content'])); ?>)" data-translate-title="true" title="Vista previa">
<button class="btn btn-sm btn-info" onclick='previewMessage(<?php echo json_encode($msg['message_content']); ?>)' data-translate-title="true" title="Vista previa">
<i class="bi bi-eye-fill"></i>
</button>
<a href="edit_recurrent_message.php?id=<?php echo $msg['id']; ?>" class="btn btn-sm btn-warning" data-translate-title="true" title="Editar">
@@ -150,7 +150,8 @@ require_once __DIR__ . '/templates/header.php';
} else {
foreach ($files as $file) {
if (is_file($gallery_path . '/' . $file)) {
echo '<div class="col-lg-3 col-md-4 col-sm-6 mb-4 text-center"><img src="galeria/' . htmlspecialchars($file) . '" class="img-fluid img-thumbnail gallery-item" style="cursor:pointer;" alt="' . htmlspecialchars($file) . '"><p class="small text-muted mt-1">' . htmlspecialchars($file) . '</p></div>';
$image_url = site_url('galeria/' . $file);
echo '<div class="col-lg-3 col-md-4 col-sm-6 mb-4 text-center"><img src="' . htmlspecialchars($image_url) . '" class="img-fluid img-thumbnail gallery-item" style="cursor:pointer;" alt="' . htmlspecialchars($file) . '"><p class="small text-muted mt-1">' . htmlspecialchars($file) . '</p></div>';
}
}
}
@@ -236,19 +237,25 @@ $(document).ready(function() {
$(document).on('click', '.gallery-item', function() { $(this).toggleClass('border-primary'); });
$('#insertImageFromGallery').click(function() {
$('.gallery-item.border-primary').each(function(){
$('#messageContent').summernote('insertImage', $(this).attr('src'));
const imageSrc = $(this).attr('src');
console.log('Inserting image:', imageSrc);
$('#messageContent').summernote('insertImage', imageSrc);
});
$('#galleryModal').modal('hide');
$('.gallery-item').removeClass('border-primary');
});
// Toggle between channel and user selection
// Toggle between channel and user selection (only if elements exist)
const recipientTypeChannel = document.getElementById('recipientTypeChannel');
const recipientTypeUser = a = document.getElementById('recipientTypeUser');
const recipientTypeUser = document.getElementById('recipientTypeUser');
const channelSelect = document.getElementById('recipientId');
const userSelect = document.getElementById('recipientId_user');
function updateRecipientType() {
if (!recipientTypeChannel || !recipientTypeUser || !channelSelect || !userSelect) {
return; // Elements don't exist, exit gracefully
}
if (recipientTypeChannel.checked) {
channelSelect.classList.remove('d-none');
channelSelect.required = true;
@@ -265,9 +272,13 @@ $(document).ready(function() {
userSelect.disabled = false;
}
}
recipientTypeChannel.addEventListener('change', updateRecipientType);
recipientTypeUser.addEventListener('change', updateRecipientType);
updateRecipientType(); // Initial call
// Only add event listeners if elements exist
if (recipientTypeChannel && recipientTypeUser) {
recipientTypeChannel.addEventListener('change', updateRecipientType);
recipientTypeUser.addEventListener('change', updateRecipientType);
updateRecipientType(); // Initial call
}
// Form validation
$('#recurrentMessageForm').submit(function(e) {
@@ -288,11 +299,27 @@ $(document).ready(function() {
// Preview message function
function previewMessage(content) {
const previewModalBody = document.getElementById('previewModalBody');
// Replace image URLs with absolute paths for preview
const baseUrl = "<?php echo $base_url; ?>";
let processedContent = content.replace(/src="galeria\//g, 'src="' + baseUrl + 'galeria/');
const modalElement = document.getElementById('previewModal');
if (!previewModalBody || !modalElement) {
console.error('Modal elements not found');
return;
}
let processedContent = content;
// Simple cleanup - ensure all image URLs are correct
processedContent = processedContent
.replace(/src="[^"]*galeria\/([^"]+)"/g, 'src="/galeria/$1"')
.replace(/src='[^']*galeria\/([^']+)'/g, "src='/galeria/$1'");
// Add proper styling to images
processedContent = processedContent.replace(/<img([^>]*)>/g, '<img$1 style="max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0;">');
previewModalBody.innerHTML = processedContent;
var myModal = new bootstrap.Modal(document.getElementById('previewModal'));
// Create and show the modal
const myModal = new bootstrap.Modal(modalElement);
myModal.show();
}
</script>