Implementada logica para entornos dev/prod

This commit is contained in:
imnavajas
2025-06-12 14:57:48 +02:00
parent b0bceb20bc
commit 8288219872
7 changed files with 511 additions and 117 deletions

View File

@ -1,70 +1,111 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section('content'); ?>
<!--Content Body-->
<?= $this->section("content") ?>
<div class="row mt-4">
<div class="col-md-12">
<h4 class="mb-4">Backups disponibles</h4>
<a href="<?= route_to('backupsCreate') ?>" class="btn btn-primary mb-3">Crear backup</a>
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">Backups disponibles</h3>
</div>
<div class="table-responsive">
<table id="tablaBackups" class="table table-striped table-hover w-100">
<thead>
<tr>
<th>Archivo</th>
<th>Fecha</th>
<th>Tamaño</th>
<th>Local</th>
<th>Remoto</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php foreach ($backups as $b): ?>
<tr>
<td><?= esc($b['filename']) ?></td>
<td><?= esc($b['fecha']) ?></td>
<td><?= esc($b['tamano']) ?></td>
<td><span class="badge bg-<?= $b['local'] ? 'success' : 'secondary' ?>">
<?= $b['local'] ? 'Sí' : 'No' ?>
</span></td>
<td><span class="badge bg-<?= $b['remoto'] ? 'info' : 'secondary' ?>">
<?= $b['remoto'] ? 'Sí' : 'No' ?>
</span></td>
<td class="text-nowrap">
<?php if ($b['local']): ?>
<a href="<?= route_to('backupsRestoreLocal', $b['filename']) ?>"
class="btn btn-sm btn-warning">Restaurar Local</a>
<a href="<?= route_to('backupsDeleteLocal', $b['id']) ?>"
class="btn btn-sm btn-danger">Eliminar local</a>
<?php elseif ($b['remoto']): ?>
<a href="<?= route_to('backupsRestoreRemote', $b['filename']) ?>"
class="btn btn-sm btn-warning">Restaurar Remoto</a>
<?php else: ?>
<span class="text-muted">No disponible</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
</div>
<?php if (getenv('SK_ENVIRONMENT') === 'production'): ?>
<a href="<?= route_to('backupsCreate') ?>" class="btn btn-primary mb-3">Crear backup</a>
<?php else: ?>
<a href="<?= route_to('backupsCreateDev') ?>" class="btn btn-secondary mb-3">Crear backup desarrollo</a>
<?php endif; ?>
<?= session('message') ?>
</div>
</div>
<div class="table-responsive">
<table id="tablaBackups" class="table table-striped table-hover w-100">
<thead>
<tr>
<th>Archivo</th>
<th>Fecha</th>
<th>Tamaño</th>
<th>Local</th>
<th>Remoto</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php foreach ($backups as $b): ?>
<tr>
<td><?= esc($b['filename']) ?></td>
<td><?= esc($b['fecha']) ?></td>
<td><?= esc($b['tamano']) ?></td>
<td>
<span class="badge bg-<?= $b['local'] ? 'success' : 'secondary' ?>">
<?= $b['local'] ? 'Sí' : 'No' ?>
</span>
</td>
<td>
<span class="badge bg-<?= $b['remoto'] ? 'info' : 'secondary' ?>">
<?= $b['remoto'] ? 'Sí' : 'No' ?>
</span>
</td>
<td class="text-nowrap">
<!-- Descargar siempre disponible -->
<a href="<?= route_to('backupsDownload', $b['filename']) ?>"
class="btn btn-sm btn-info" title="Descargar backup">
Descargar
</a>
<!-- Restaurar y eliminar solo si local -->
<?php if ($b['local']): ?>
<?php if (getenv('SK_ENVIRONMENT') === 'production'): ?>
<a href="<?= route_to('backupsRestoreLocal', $b['filename']) ?>"
class="btn btn-sm btn-warning" title="Restaurar backup local">
Restaurar Local
</a>
<?php endif; ?>
<?php if (getenv('SK_ENVIRONMENT') === 'production' && !empty($b['id'])): ?>
<a href="<?= route_to('backupsDeleteLocal', $b['id']) ?>"
class="btn btn-sm btn-danger"
onclick="return confirm('¿Seguro que deseas eliminar este backup?')"
title="Eliminar archivo local (producción)">
Eliminar [PROD]
</a>
<?php elseif (getenv('SK_ENVIRONMENT') === 'development' && !empty($b['filename'])): ?>
<a href="<?= route_to('backupsDeleteLocalDev', $b['filename']) ?>"
class="btn btn-sm btn-danger"
onclick="return confirm('¿Eliminar archivo del sistema de archivos local?')"
title="Eliminar archivo local (DEV)">
Eliminar [DEV]
</a>
<?php endif; ?>
<?php elseif ($b['remoto']): ?>
<!-- Restaurar remoto si solo existe remoto -->
<a href="<?= route_to('backupsRestoreRemote', $b['filename']) ?>"
class="btn btn-sm btn-warning" title="Restaurar desde servidor remoto">
Restaurar Remoto
</a>
<?php else: ?>
<span class="text-muted">No disponible</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col -->
</div><!-- /.row -->
<?= $this->endSection() ?>
<?= $this->section('additionalInlineJs') ?>
$(document).ready(function () {
$('#tablaBackups').DataTable({
order: [[1, 'desc']],
language: {
url: '/assets/vendor/datatables/i18n/es-ES.json' // ajusta si usas idioma español
}
});
$('#tablaBackups').DataTable({
order: [[1, 'desc']]
});
});
<?= $this->endSection() ?>