mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 04:20:50 +01:00
Miglioramenti vari importFE
This commit is contained in:
parent
5af5cf25e9
commit
1c7653be97
@ -25,32 +25,52 @@ switch (filter('op')) {
|
|||||||
$file = Interaction::getInvoiceFile($name);
|
$file = Interaction::getInvoiceFile($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FatturaElettronica::isValid($file)) {
|
try {
|
||||||
// Individuazione ID fisico
|
if (!FatturaElettronica::isValid($file)) {
|
||||||
$files = Interaction::getFileList();
|
echo json_encode([
|
||||||
foreach ($files as $key => $value) {
|
'already' => 1,
|
||||||
if ($value['name'] == $file) {
|
]);
|
||||||
$index = $key;
|
|
||||||
|
|
||||||
break;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
echo json_encode([
|
|
||||||
'id' => $index + 1,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
echo json_encode([
|
|
||||||
'already' => 1,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
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();
|
$directory = FatturaElettronica::getImportDirectory();
|
||||||
|
|
||||||
delete($directory.'/'.get('name'));
|
download($directory.'/'.$file['name']);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ echo '
|
|||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button type="button" class="btn btn-warning" onclick="importAll(this)">
|
<button type="button" class="btn btn-warning" onclick="importAll(this)">
|
||||||
<i class="fa fa-download"></i> '.tr('Importa in sequenza').'
|
<i class="fa fa-cloud-download"></i> '.tr('Importa in sequenza').'
|
||||||
</button>';
|
</button>';
|
||||||
|
|
||||||
// Ricerca automatica
|
// Ricerca automatica
|
||||||
|
@ -29,7 +29,7 @@ if (!empty($list)) {
|
|||||||
echo '
|
echo '
|
||||||
<tr>';
|
<tr>';
|
||||||
|
|
||||||
if (file_exists($directory.'/'.$name)) {
|
if (!empty($element['file'])) {
|
||||||
echo '
|
echo '
|
||||||
<td>
|
<td>
|
||||||
<p>'.$name.'</p>
|
<p>'.$name.'</p>
|
||||||
@ -40,7 +40,7 @@ if (!empty($list)) {
|
|||||||
<td class="text-center">-</td>
|
<td class="text-center">-</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<button type="button" class="btn btn-danger" onclick="delete_fe(this, \''.$name.'\')">
|
<button type="button" class="btn btn-danger" onclick="delete_fe(this, \''.$element['id'].'\')">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</button>';
|
</button>';
|
||||||
} else {
|
} else {
|
||||||
@ -85,10 +85,17 @@ if (!empty($list)) {
|
|||||||
</button>';
|
</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_exists($directory.'/'.$name)) {
|
||||||
|
echo '
|
||||||
|
<button type="button" class="btn btn-primary" onclick="download_fe(this, \''.$element['id'].'\')">
|
||||||
|
<i class="fa fa-download"></i>
|
||||||
|
</button>';
|
||||||
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$name.'\', \''.$data.'\')">
|
<button type="button" class="btn btn-warning" '.((!extension_loaded('openssl') && substr(strtolower($name), -4) == '.p7m') ? 'disabled' : '').' onclick="import_fe(this, \''.$name.'\', \''.$data.'\')">
|
||||||
<i class="fa fa-download"></i> '.tr('Importa').'
|
<i class="fa fa-cloud-download"></i> '.tr('Importa').'
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
@ -104,7 +111,7 @@ if (!empty($list)) {
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
function download(button, file, data_registrazione) {
|
function import_fe(button, file, data_registrazione) {
|
||||||
var restore = buttonLoading(button);
|
var restore = buttonLoading(button);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -140,34 +147,6 @@ function download(button, file, data_registrazione) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_fe(button, file) {
|
|
||||||
swal({
|
|
||||||
title: "'.tr('Rimuovere la fattura salvata localmente?').'",
|
|
||||||
html: "'.tr('Sarà possibile inserirla nuovamente nel gestionale attraverso il caricamento').'",
|
|
||||||
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,
|
|
||||||
id_plugin: '.$id_plugin.',
|
|
||||||
op: "delete",
|
|
||||||
name: file,
|
|
||||||
},
|
|
||||||
success: function(data) {
|
|
||||||
$("#list").load("'.$structure->fileurl('list.php').'?id_module='.$id_module.'&id_plugin='.$id_plugin.'", function() {
|
|
||||||
buttonRestore(button, restore);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function process_fe(button, file) {
|
function process_fe(button, file) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Segnare la fattura come processata?').'",
|
title: "'.tr('Segnare la fattura come processata?').'",
|
||||||
@ -196,5 +175,42 @@ function process_fe(button, file) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_fe(button, file_id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Rimuovere la fattura salvata localmente?').'",
|
||||||
|
html: "'.tr('Sarà possibile inserirla nuovamente nel gestionale attraverso il caricamento').'",
|
||||||
|
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,
|
||||||
|
id_plugin: '.$id_plugin.',
|
||||||
|
op: "delete",
|
||||||
|
file_id: file_id,
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$("#list").load("'.$structure->fileurl('list.php').'?id_module='.$id_module.'&id_plugin='.$id_plugin.'", function() {
|
||||||
|
buttonRestore(button, restore);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function download_fe(button, file_id) {
|
||||||
|
redirect(globals.rootdir + "/actions.php", {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_plugin: '.$id_plugin.',
|
||||||
|
op: "download",
|
||||||
|
file_id: file_id,
|
||||||
|
}, "get", true);
|
||||||
|
}
|
||||||
|
|
||||||
start_local_datatables();
|
start_local_datatables();
|
||||||
</script>';
|
</script>';
|
||||||
|
@ -50,12 +50,14 @@ class Interaction extends Services
|
|||||||
$directory = FatturaElettronica::getImportDirectory();
|
$directory = FatturaElettronica::getImportDirectory();
|
||||||
|
|
||||||
$files = glob($directory.'/*.xml*');
|
$files = glob($directory.'/*.xml*');
|
||||||
foreach ($files as $file) {
|
foreach ($files as $id => $file) {
|
||||||
$name = basename($file);
|
$name = basename($file);
|
||||||
|
|
||||||
if (!in_array($name, $names)) {
|
if (!in_array($name, $names)) {
|
||||||
$list[] = [
|
$list[] = [
|
||||||
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
'file' => true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ if (Interaction::isEnabled()) {
|
|||||||
echo '
|
echo '
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button type="button" class="btn btn-warning" onclick="importAll(this)">
|
<button type="button" class="btn btn-warning" onclick="importAll(this)">
|
||||||
<i class="fa fa-download"></i> '.tr('Importa tutte le ricevute').'
|
<i class="fa fa-cloud-download"></i> '.tr('Importa tutte le ricevute').'
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button type="button" class="btn btn-primary" onclick="search(this)">
|
<button type="button" class="btn btn-primary" onclick="search(this)">
|
||||||
|
@ -40,7 +40,7 @@ if (!empty($list)) {
|
|||||||
|
|
||||||
echo '
|
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') and substr(strtolower($element), -4) == '.p7m') ? 'disabled' : '').' onclick="download(this, \''.$element.'\')">
|
||||||
<i class="fa fa-download"></i> '.tr('Importa').'
|
<i class="fa fa-cloud-download"></i> '.tr('Importa').'
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user