From 1c7653be970034ba6f93bc4fb67af12908182843 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Wed, 24 Jul 2019 17:39:11 +0200 Subject: [PATCH] Miglioramenti vari importFE --- plugins/importFE/actions.php | 54 ++++++++++++------ plugins/importFE/edit.php | 2 +- plugins/importFE/list.php | 82 +++++++++++++++++----------- plugins/importFE/src/Interaction.php | 4 +- plugins/receiptFE/edit.php | 2 +- plugins/receiptFE/list.php | 2 +- 6 files changed, 92 insertions(+), 54 deletions(-) diff --git a/plugins/importFE/actions.php b/plugins/importFE/actions.php index 61f420f61..9b2080998 100644 --- a/plugins/importFE/actions.php +++ b/plugins/importFE/actions.php @@ -25,32 +25,52 @@ switch (filter('op')) { $file = Interaction::getInvoiceFile($name); } - if (FatturaElettronica::isValid($file)) { - // Individuazione ID fisico - $files = Interaction::getFileList(); - foreach ($files as $key => $value) { - if ($value['name'] == $file) { - $index = $key; + try { + if (!FatturaElettronica::isValid($file)) { + echo json_encode([ + 'already' => 1, + ]); - break; - } + return; } - - echo json_encode([ - 'id' => $index + 1, - ]); - } else { - echo json_encode([ - 'already' => 1, - ]); + } catch (Exception $e) { } + // Individuazione ID fisico + $files = Interaction::getFileList(); + foreach ($files as $key => $value) { + if ($value['name'] == $file) { + $index = $key; + + break; + } + } + + echo json_encode([ + 'id' => $index + 1, + ]); + break; case 'delete': + $file_id = get('file_id'); + + $files = Interaction::getFileList(); + $file = $files[$file_id]; + + $directory = FatturaElettronica::getImportDirectory(); + delete($directory.'/'.$file['name']); + + break; + case 'download': + $file_id = get('file_id'); + + $files = Interaction::getFileList(); + $file = $files[$file_id]; + $directory = FatturaElettronica::getImportDirectory(); - delete($directory.'/'.get('name')); + download($directory.'/'.$file['name']); break; diff --git a/plugins/importFE/edit.php b/plugins/importFE/edit.php index 7bfba3085..30106d759 100644 --- a/plugins/importFE/edit.php +++ b/plugins/importFE/edit.php @@ -97,7 +97,7 @@ echo '
'; // Ricerca automatica diff --git a/plugins/importFE/list.php b/plugins/importFE/list.php index 9aeaa2bf8..94963b63f 100644 --- a/plugins/importFE/list.php +++ b/plugins/importFE/list.php @@ -29,7 +29,7 @@ if (!empty($list)) { echo ' '; - if (file_exists($directory.'/'.$name)) { + if (!empty($element['file'])) { echo '

'.$name.'

@@ -40,7 +40,7 @@ if (!empty($list)) { - - '; } else { @@ -85,10 +85,17 @@ if (!empty($list)) { '; } + if (file_exists($directory.'/'.$name)) { + echo ' + '; + } + echo ' - '; @@ -104,7 +111,7 @@ if (!empty($list)) { echo ' '; diff --git a/plugins/importFE/src/Interaction.php b/plugins/importFE/src/Interaction.php index 060dd0eff..37a0639e0 100644 --- a/plugins/importFE/src/Interaction.php +++ b/plugins/importFE/src/Interaction.php @@ -50,12 +50,14 @@ class Interaction extends Services $directory = FatturaElettronica::getImportDirectory(); $files = glob($directory.'/*.xml*'); - foreach ($files as $file) { + foreach ($files as $id => $file) { $name = basename($file); if (!in_array($name, $names)) { $list[] = [ + 'id' => $id, 'name' => $name, + 'file' => true, ]; } } diff --git a/plugins/receiptFE/edit.php b/plugins/receiptFE/edit.php index a75d8ce44..9a4ce8cea 100644 --- a/plugins/receiptFE/edit.php +++ b/plugins/receiptFE/edit.php @@ -50,7 +50,7 @@ if (Interaction::isEnabled()) { echo '
';