Fix upload allegati

This commit is contained in:
Pek5892 2024-04-05 09:47:28 +02:00
parent 2d03b1b173
commit 60282b2007
5 changed files with 20 additions and 4 deletions

View File

@ -33,7 +33,7 @@ if (sizeof($id_allegati) == 1) {
$allegato = Upload::find($id_allegati[0]);
echo '
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->getTranslation('name').'" ]}
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->name.'" ]}
</div>
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "'.$allegato->category.'", "disabled": "'.intval(in_array($allegato->category, ['Fattura Elettronica'])).'" ]}

View File

@ -40,7 +40,11 @@ switch (filter('op')) {
$adapter->name = post('name');
$adapter->class = '\\Modules\\FileAdapters\\Adapters\\'.post('class');
$adapter->options = post('options');
$adapter->is_default = post('is_default');
if (post('is_default') == 1) {
$dbo->query('UPDATE `zz_storage_adapters` SET `is_default` = 0');
$adapter->is_default = post('is_default');
}
$adapter->save();

View File

@ -34,7 +34,7 @@ include_once __DIR__.'/../../core.php';
</div>
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "is_default", "value": "$is_default$" ]}
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "is_default", "value": "$is_default$", "extra": "<?php echo $record['is_default'] == 1 ? 'readonly' : ''; ?>" ]}
</div>
</div>

View File

@ -348,7 +348,7 @@ switch (post('op')) {
// Operazioni aggiuntive per il logo e filigrana stampe
if (filter('op') == 'aggiungi-allegato' || filter('op') == 'modifica-allegato') {
$nome = $upload->getTranslation('name');
$nome = $upload->name;
$logo_stampe = ['logo stampe', 'logo_stampe', 'logo stampe.jpg', 'logo stampe.png'];
if (in_array(strtolower($nome), $logo_stampe)) {

12
update/2_5_1.php Normal file
View File

@ -0,0 +1,12 @@
<?php
use Modules\FileAdapters\FileAdapter;
include __DIR__.'/core.php';
// Imposto l'adattatore locale di default se non definito
$default = FileAdapter::where('is_default', 1)->first();
if (empty($default)) {
$adapter = FileAdapter::where('name', 'Adattatore locale')->first();
$adapter->is_default = 1;
$adapter->save();
}