Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions Core/Controller/About.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2024-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2024-2026 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand All @@ -22,6 +22,7 @@
use FacturaScripts\Core\Base\Controller;
use FacturaScripts\Core\Kernel;
use FacturaScripts\Core\Plugins;
use FacturaScripts\Core\Tools;
use FacturaScripts\Core\UploadedFile;
use FacturaScripts\Dinamic\Model\AttachedFile;
use FacturaScripts\Dinamic\Model\Cliente;
Expand Down Expand Up @@ -77,6 +78,7 @@ private function getData(): array
// Espacio de almacenamiento para archivos adjuntos
$storage_limit = AttachedFile::getStorageLimit();
$storage_used = AttachedFile::getStorageUsed();
$storage = $this->getStorage();

// Obtener el tamaño maxim de subida de archivo
$max_filesize = UploadedFile::getMaxFilesize();
Expand All @@ -103,7 +105,8 @@ private function getData(): array
'server_date',
'server_software',
'storage_limit',
'storage_used'
'storage_used',
'storage'
);
}

Expand All @@ -128,4 +131,45 @@ private function getLimits(): array
'users' => $users,
];
}

private function getStorage(): array
{
$storage = [];

foreach (Tools::folderScan('MyFiles') as $item) {
// obtener la ruta completa
$path = Tools::folder('MyFiles', $item);

// si no es una carpeta, agrupar por archivo
if (!is_dir($path)) {
// obtenemos el tamaño del archivo
$size = filesize($path);

// guardar el resultado
if (!isset($storage['files'])) {
$storage['files'] = [
'name' => 'files',
'size' => 0,
'human_size' => '',
];
}

$storage['files']['size'] += $size;
$storage['files']['human_size'] = Tools::bytes($storage['files']['size']);
continue;
}

// obtener el tamaño
$size = Tools::folderSize($path);

// guardar el resultado
$storage[$item] = [
'name' => $item,
'size' => $size,
'human_size' => Tools::bytes($size),
];
}

return $storage;
}
}
32 changes: 32 additions & 0 deletions Core/View/About.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@
</div>
{% endblock %}

{% block storage %}
<div class="card shadow mb-4">
<div class="card-body">
<h3>
<i class="fa-solid fa-hard-drive me-2"></i> {{ trans('app-storage') }}
</h3>
<hr>
<div class="row">
{% for dataStorare in fsc.data.storage %}
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="text-center p-2">
{% if dataStorare.name == 'files' %}
<i class="fa-regular fa-file fa-2x mb-2"></i>
<h6 class="mb-1">{{ dataStorare.name }}</h6>
<p class="mb-0">
<strong>{{ dataStorare.human_size }}</strong>
</p>
{% else %}
<i class="fa-regular fa-folder fa-2x mb-2"></i>
<h6 class="mb-1">{{ dataStorare.name }}</h6>
<p class="mb-0">
<strong>{{ dataStorare.human_size }}</strong>
</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

{% block plugins %}
<div class="card shadow mb-4">
<div class="card-body">
Expand Down
Loading