mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-03 17:27:29 +01:00
Update Interaction.php
This commit is contained in:
parent
3018dee7cb
commit
75506424c5
@ -16,15 +16,12 @@ class Interaction extends Services
|
|||||||
$list = self::getRemoteList();
|
$list = self::getRemoteList();
|
||||||
|
|
||||||
// Ricerca fisica
|
// Ricerca fisica
|
||||||
$names = array_column($list, 'name');
|
$result = self::getFileList($list);
|
||||||
$files = self::getFileList($names);
|
|
||||||
|
|
||||||
$list = array_merge($list, $files);
|
|
||||||
|
|
||||||
// Aggiornamento cache hook
|
// Aggiornamento cache hook
|
||||||
InvoiceHook::update($list);
|
InvoiceHook::update($result);
|
||||||
|
|
||||||
return $list;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRemoteList()
|
public static function getRemoteList()
|
||||||
@ -42,9 +39,9 @@ class Interaction extends Services
|
|||||||
return $list ?: [];
|
return $list ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFileList($names = [])
|
public static function getFileList($list = [])
|
||||||
{
|
{
|
||||||
$list = [];
|
$names = array_column($list, 'name');
|
||||||
|
|
||||||
// Ricerca fisica
|
// Ricerca fisica
|
||||||
$directory = FatturaElettronica::getImportDirectory();
|
$directory = FatturaElettronica::getImportDirectory();
|
||||||
@ -52,13 +49,16 @@ class Interaction extends Services
|
|||||||
$files = glob($directory.'/*.xml*');
|
$files = glob($directory.'/*.xml*');
|
||||||
foreach ($files as $id => $file) {
|
foreach ($files as $id => $file) {
|
||||||
$name = basename($file);
|
$name = basename($file);
|
||||||
|
$pos = array_search($name, $names);
|
||||||
|
|
||||||
if (!in_array($name, $names)) {
|
if ($pos === false) {
|
||||||
$list[] = [
|
$list[] = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'file' => true,
|
'file' => true,
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
$list[$pos]['id'] = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user