Skip to content

Commit 8d74821

Browse files
committed
fix: importazione file in formato html
1 parent f9674a9 commit 8d74821

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

modules/adattatori_archiviazione/src/OSMFilesystem.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class OSMFilesystem extends Filesystem
2929
'php' => 'application/php',
3030
'php5' => 'application/php',
3131
'phtml' => 'application/php',
32-
'html' => 'text/html',
33-
'htm' => 'text/html',
32+
3433
];
3534

3635
public function upload($directory, $filename, $contents)

plugins/importFE/src/FatturaElettronica.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ public function saveAllegati($name = null)
179179
if (!empty($allegato['FormatoAttachment'])) {
180180
$extension = '.'.strtolower((string) $allegato['FormatoAttachment']);
181181
}
182-
182+
183+
if (strtolower($extension) == '.html' || strtolower($extension) == '.htm') {
184+
$extension = '.pdf';
185+
}
186+
183187
if (preg_match('/\./', (string) $allegato['NomeAttachment'])) {
184188
$original = $allegato['NomeAttachment'];
185189
} else {
@@ -195,10 +199,21 @@ public function saveAllegati($name = null)
195199
}
196200

197201
// Registrazione XML come allegato
198-
\Uploads::upload(file_get_contents($this->file), array_merge($info, [
199-
'name' => tr('Fattura Elettronica'),
200-
'original_name' => basename($this->file),
201-
]));
202+
$file_content = file_get_contents($this->file);
203+
204+
$original_name = basename($this->file);
205+
if (empty(pathinfo($original_name, PATHINFO_EXTENSION))) {
206+
$original_name .= '.xml';
207+
}
208+
209+
try {
210+
\Uploads::upload($file_content, array_merge($info, [
211+
'name' => tr('Fattura Elettronica'),
212+
'original_name' => $original_name,
213+
]));
214+
} catch (\UnexpectedValueException $e) {
215+
error_log('Errore durante il caricamento del file XML: ' . $e->getMessage());
216+
}
202217
}
203218

204219
public function findAnagrafica($tipo = null)

0 commit comments

Comments
 (0)