Aggiornamento importazione FE

This commit is contained in:
Thomas Zilio 2019-07-22 09:52:27 +02:00
parent ad21ebf9f2
commit e33eec69fc
5 changed files with 81 additions and 23 deletions

View File

@ -17,32 +17,76 @@ if (!empty($list)) {
<table class="table table-striped table-hover table-condensed table-bordered datatables">
<thead>
<tr>
<th>'.tr('Nome').'</th>
<th>'.tr('Descrizione').'</th>
<th>'.tr('Fornitore').'</th>
<th>'.tr('Totale imponibile').'</th>
<th width="20%" class="text-center">#</th>
</tr>
</thead>
<tbody>';
foreach ($list as $element) {
echo '
<tr>
<td>'.$element.'</td>
<td class="text-center">';
$name = $element['name'];
if (file_exists($directory.'/'.$element)) {
echo '
<tr>';
if (file_exists($directory.'/'.$name)) {
echo '
<button type="button" class="btn btn-danger" onclick="delete_fe(this, \''.$element.'\')">
<td>
<p>'.$name.'</p>
</td>
<td>-</td>
<td>-</td>
<td class="text-center">
<button type="button" class="btn btn-danger" onclick="delete_fe(this, \''.$name.'\')">
<i class="fa fa-trash"></i>
</button>';
} 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 '
<button type="button" class="btn btn-info" onclick="process_fe(this, \''.$element.'\')">
<td>
'.$descrizione.' <small>['.$name.']</small>
</td>
<td>'.$element['sender'].'</td>
<td>'.$element['amount'].'</td>
<td class="text-center">
<button type="button" class="btn btn-info" onclick="process_fe(this, \''.$name.'\')">
<i class="fa fa-upload"></i>
</button>';
}
echo '
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') and substr(strtolower($element), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$element.'\')">
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$name.'\')">
<i class="fa fa-download"></i> '.tr('Importa').'
</button>
</td>

View File

@ -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)

View File

@ -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');

View File

@ -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;
}

View File

@ -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';
}
}
}