From e33eec69fce270b1a4f8decb3ca10b0c36f7dfd8 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Mon, 22 Jul 2019 09:52:27 +0200 Subject: [PATCH] Aggiornamento importazione FE --- plugins/importFE/list.php | 62 ++++++++++++++++++++---- plugins/importFE/src/Interaction.php | 26 ++++++---- plugins/statistiche_anagrafiche/info.php | 2 +- src/API/Manager.php | 8 ++- src/API/Response.php | 6 ++- 5 files changed, 81 insertions(+), 23 deletions(-) diff --git a/plugins/importFE/list.php b/plugins/importFE/list.php index 1d66b49de..c4e4fdd89 100644 --- a/plugins/importFE/list.php +++ b/plugins/importFE/list.php @@ -17,32 +17,76 @@ if (!empty($list)) { - + + + '; foreach ($list as $element) { - echo ' - - - '; + if (file_exists($directory.'/'.$name)) { echo ' - + + + + + + + + + + diff --git a/plugins/importFE/src/Interaction.php b/plugins/importFE/src/Interaction.php index e95ce4a31..5ce48fdca 100644 --- a/plugins/importFE/src/Interaction.php +++ b/plugins/importFE/src/Interaction.php @@ -16,11 +16,7 @@ class Interaction extends Services $directory = FatturaElettronica::getImportDirectory(); $list = []; - - $files = glob($directory.'/*.xml*'); - foreach ($files as $file) { - $list[] = basename($file); - } + $names = []; // Ricerca da remoto if (self::isEnabled()) { @@ -28,15 +24,25 @@ class Interaction extends Services $body = static::responseBody($response); if ($body['status'] == '200') { - $files = $body['results']; + $list = $body['results']; - foreach ($files as $file) { - $list[] = basename($file); - } + $names = array_column($list); } } - return array_clean($list); + // Ricerca fisica + $files = glob($directory.'/*.xml*'); + foreach ($files as $file) { + $name = basename($file); + + if (!in_array($name, $names)) { + $list[] = [ + 'name' => $name, + ]; + } + } + + return $list; } public static function getImportXML($name) diff --git a/plugins/statistiche_anagrafiche/info.php b/plugins/statistiche_anagrafiche/info.php index 535e9741c..c574c7964 100644 --- a/plugins/statistiche_anagrafiche/info.php +++ b/plugins/statistiche_anagrafiche/info.php @@ -6,9 +6,9 @@ use Modules\Anagrafiche\Anagrafica; use Modules\Contratti\Contratto; use Modules\DDT\DDT; use Modules\Fatture\Fattura; +use Modules\Interventi\Intervento; use Modules\Ordini\Ordine; use Modules\Preventivi\Preventivo; -use Modules\Interventi\Intervento; $calendar_id = filter('calendar_id'); $start = filter('start'); diff --git a/src/API/Manager.php b/src/API/Manager.php index fe6c09c24..b6982a993 100644 --- a/src/API/Manager.php +++ b/src/API/Manager.php @@ -22,12 +22,16 @@ class Manager */ public function __construct($resource, $type, $version) { - $resource = Resource::where('version', $version) + $object = Resource::where('version', $version) ->where('type', $type) ->where('resource', $resource) ->first(); - $this->resource = $resource; + if (empty($object)) { + throw new ResourceNotFound(); + } + + $this->resource = $object; $this->type = $type; } diff --git a/src/API/Response.php b/src/API/Response.php index 19f1e8c64..f902f60da 100644 --- a/src/API/Response.php +++ b/src/API/Response.php @@ -76,7 +76,7 @@ class Response } $request = self::getRequest(); - $version = $request['version'] ?: 'v1'; + $version = $request['version']; // Controllo sull'accesso if (!Auth::check() && $request['resource'] != 'login') { @@ -220,6 +220,10 @@ class Response if (empty($request['token'])) { $request['token'] = ''; } + + if (empty($request['version'])) { + $request['version'] = 'v1'; + } } }
'.tr('Nome').''.tr('Descrizione').''.tr('Fornitore').''.tr('Totale imponibile').' #
'.$element.''; + $name = $element['name']; - if (file_exists($directory.'/'.$element)) { + echo ' +
+

'.$name.'

+
-- + '; } else { + $date = new DateTime($element['date']); + $date = $date->format('Y-m-d'); + + $descrizione = ''; + if ($element['type'] == 'TD01') { + $descrizione = tr('Fattura num. _NUM_ del _DATE_', [ + '_NUM_' => $element['number'], + '_DATE_' => dateFormat($date), + ]); + } elseif ($element['type'] == 'TD04') { + $descrizione = tr('Nota di credito num. _NUM_ del _DATE_', [ + '_NUM_' => $element['number'], + '_DATE_' => dateFormat($date), + ]); + } elseif ($element['type'] == 'TD05') { + $descrizione = tr('Nota di debito num. _NUM_ del _DATE_', [ + '_NUM_' => $element['number'], + '_DATE_' => dateFormat($date), + ]); + } elseif ($element['type'] == 'TD06') { + $descrizione = tr('Parcella num. _NUM_ del _DATE_', [ + '_NUM_' => $element['number'], + '_DATE_' => dateFormat($date), + ]); + } + echo ' - + '.$descrizione.' ['.$name.'] + '.$element['sender'].''.$element['amount'].' + '; } echo ' -