2018-11-30 15:33:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
use Plugins\ImportFE\Interaction;
|
2019-07-05 09:53:53 +02:00
|
|
|
use Plugins\ImportFE\InvoiceHook;
|
2018-11-30 15:33:25 +01:00
|
|
|
|
|
|
|
$list = Interaction::listToImport();
|
2019-07-05 09:53:53 +02:00
|
|
|
|
|
|
|
// Aggiornamento cache hook
|
|
|
|
InvoiceHook::update($list);
|
|
|
|
|
2019-02-12 11:42:48 +01:00
|
|
|
$directory = Plugins\ImportFE\FatturaElettronica::getImportDirectory();
|
2018-11-30 15:33:25 +01:00
|
|
|
|
|
|
|
if (!empty($list)) {
|
|
|
|
echo '
|
2019-03-01 11:51:21 +01:00
|
|
|
<table class="table table-striped table-hover table-condensed table-bordered datatables">
|
2018-11-30 15:33:25 +01:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2019-07-22 09:52:27 +02:00
|
|
|
<th>'.tr('Descrizione').'</th>
|
2019-07-22 10:11:09 +02:00
|
|
|
<th class="text-center">'.tr('Fornitore').'</th>
|
2019-07-22 15:45:36 +02:00
|
|
|
<th class="text-center">'.tr('Data di registrazione').'</th>
|
2019-07-22 10:11:09 +02:00
|
|
|
<th class="text-center">'.tr('Totale imponibile').'</th>
|
2019-04-19 18:50:16 +02:00
|
|
|
<th width="20%" class="text-center">#</th>
|
2018-11-30 15:33:25 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
foreach ($list as $element) {
|
2019-07-22 09:52:27 +02:00
|
|
|
$name = $element['name'];
|
2019-07-22 15:45:36 +02:00
|
|
|
$data = $element['date_sent'] ?: '';
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-07-22 09:52:27 +02:00
|
|
|
echo '
|
|
|
|
<tr>';
|
2019-07-22 15:45:36 +02:00
|
|
|
|
2019-07-22 09:52:27 +02:00
|
|
|
if (file_exists($directory.'/'.$name)) {
|
2019-02-12 11:42:48 +01:00
|
|
|
echo '
|
2019-07-22 09:52:27 +02:00
|
|
|
<td>
|
|
|
|
<p>'.$name.'</p>
|
|
|
|
</td>
|
|
|
|
|
2019-07-22 15:45:36 +02:00
|
|
|
<td class="text-center">-</td>
|
2019-07-22 10:11:09 +02:00
|
|
|
<td class="text-center">-</td>
|
|
|
|
<td class="text-center">-</td>
|
2019-07-22 09:52:27 +02:00
|
|
|
|
|
|
|
<td class="text-center">
|
|
|
|
<button type="button" class="btn btn-danger" onclick="delete_fe(this, \''.$name.'\')">
|
2019-02-12 11:42:48 +01:00
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</button>';
|
2019-04-19 20:52:02 +02:00
|
|
|
} else {
|
2019-07-22 09:52:27 +02:00
|
|
|
$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),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-04-19 18:50:16 +02:00
|
|
|
echo '
|
2019-07-22 09:52:27 +02:00
|
|
|
<td>
|
|
|
|
'.$descrizione.' <small>['.$name.']</small>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>'.$element['sender'].'</td>
|
2019-07-22 15:45:36 +02:00
|
|
|
<td>'.dateFormat($element['date_sent']).'</td>
|
2019-07-22 10:11:09 +02:00
|
|
|
<td class="text-right">'.moneyFormat($element['amount']).'</td>
|
2019-07-22 09:52:27 +02:00
|
|
|
|
|
|
|
<td class="text-center">
|
|
|
|
<button type="button" class="btn btn-info" onclick="process_fe(this, \''.$name.'\')">
|
2019-04-19 18:50:16 +02:00
|
|
|
<i class="fa fa-upload"></i>
|
|
|
|
</button>';
|
2019-02-12 11:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-22 09:52:27 +02:00
|
|
|
|
2019-07-22 15:45:36 +02:00
|
|
|
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$name.'\', \''.$data.'\')">
|
2019-02-12 11:42:48 +01:00
|
|
|
<i class="fa fa-download"></i> '.tr('Importa').'
|
2018-11-30 15:33:25 +01:00
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>';
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Nessuna fattura da importare').'.</p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script>
|
2019-07-22 15:45:36 +02:00
|
|
|
function download(button, file, data_registrazione) {
|
2018-11-30 15:33:25 +01:00
|
|
|
var restore = buttonLoading(button);
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + "/actions.php",
|
|
|
|
type: "get",
|
|
|
|
data: {
|
|
|
|
id_module: globals.id_module,
|
|
|
|
id_plugin: '.$id_plugin.',
|
|
|
|
op: "prepare",
|
|
|
|
name: file,
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
if (!data.already) {
|
2019-07-22 18:35:13 +02:00
|
|
|
redirect(globals.rootdir + "/editor.php?id_module=" + globals.id_module + "&id_plugin=" + '.$id_plugin.' + "&id_record=" + data.id);
|
2018-11-30 15:33:25 +01:00
|
|
|
} else {
|
|
|
|
swal({
|
2019-01-03 12:57:17 +01:00
|
|
|
title: "'.tr('Fattura già importata.').'",
|
2018-11-30 15:33:25 +01:00
|
|
|
type: "info",
|
2019-01-03 12:57:17 +01:00
|
|
|
});
|
2019-02-01 17:44:31 +01:00
|
|
|
|
2019-01-03 12:57:17 +01:00
|
|
|
$(button).prop("disabled", true);
|
2018-11-30 15:33:25 +01:00
|
|
|
}
|
2019-07-22 18:35:13 +02:00
|
|
|
|
|
|
|
buttonRestore(button, restore);
|
2019-02-13 11:26:56 +01:00
|
|
|
},
|
|
|
|
error: function(xhr) {
|
|
|
|
alert("'.tr('Errore').': " + xhr.responseJSON.error.message);
|
|
|
|
|
|
|
|
buttonRestore(button, restore);
|
2018-11-30 15:33:25 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
|
|
|
|
function delete_fe(button, file) {
|
2019-04-19 18:50:16 +02:00
|
|
|
swal({
|
2019-04-19 20:52:02 +02:00
|
|
|
title: "'.tr('Rimuovere la fattura salvata localmente?').'",
|
|
|
|
html: "'.tr('Sarà possibile inserirla nuovamente nel gestionale attraverso il caricamento').'",
|
2019-04-19 18:50:16 +02:00
|
|
|
type: "error",
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: "'.tr('Sì').'"
|
|
|
|
}).then(function (result) {
|
|
|
|
var restore = buttonLoading(button);
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + "/actions.php",
|
|
|
|
type: "get",
|
|
|
|
data: {
|
|
|
|
id_module: globals.id_module,
|
2019-04-19 20:52:02 +02:00
|
|
|
id_plugin: '.$id_plugin.',
|
2019-04-19 18:50:16 +02:00
|
|
|
op: "delete",
|
|
|
|
name: file,
|
|
|
|
},
|
|
|
|
success: function(data) {
|
2019-04-19 20:52:02 +02:00
|
|
|
$("#list").load("'.$structure->fileurl('list.php').'?id_module='.$id_module.'&id_plugin='.$id_plugin.'", function() {
|
2019-04-19 18:50:16 +02:00
|
|
|
buttonRestore(button, restore);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-04-19 18:50:16 +02:00
|
|
|
function process_fe(button, file) {
|
|
|
|
swal({
|
2019-04-19 20:52:02 +02:00
|
|
|
title: "'.tr('Segnare la fattura come processata?').'",
|
2019-04-19 18:50:16 +02:00
|
|
|
html: "'.tr("Non sarà possibile individuarla nuovamente in modo automatico: l'unico modo per recuperarla sarà contattare l'assistenza").'",
|
|
|
|
type: "info",
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: "'.tr('Sì').'"
|
|
|
|
}).then(function (result) {
|
|
|
|
var restore = buttonLoading(button);
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + "/actions.php",
|
|
|
|
type: "get",
|
|
|
|
data: {
|
|
|
|
id_module: globals.id_module,
|
|
|
|
id_plugin: '.$id_plugin.',
|
|
|
|
op: "process",
|
|
|
|
name: file,
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
$("#list").load("'.$structure->fileurl('list.php').'?id_module='.$id_module.'&id_plugin='.$id_plugin.'", function() {
|
|
|
|
buttonRestore(button, restore);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2019-02-12 11:42:48 +01:00
|
|
|
});
|
|
|
|
}
|
2019-03-01 11:51:21 +01:00
|
|
|
|
|
|
|
start_local_datatables();
|
2018-11-30 15:33:25 +01:00
|
|
|
</script>';
|