2018-09-24 18:10:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2018-09-24 18:10:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2018-11-30 15:33:25 +01:00
use Plugins\ImportFE\Interaction ;
2019-07-24 17:17:54 +02:00
if ( ! empty ( $record )) {
2019-07-22 18:35:13 +02:00
include $structure -> filepath ( 'generate.php' );
return ;
}
2018-09-24 18:10:16 +02:00
echo '
< script >
2018-12-12 17:54:31 +01:00
function upload ( btn ) {
2018-09-24 18:10:16 +02:00
if ( $ ( " #blob " ) . val ()) {
swal ({
title : " '.tr('Avviare la procedura?').' " ,
type : " warning " ,
showCancelButton : true ,
confirmButtonText : " '.tr('Sì').' "
}) . then ( function ( result ) {
2018-12-12 17:54:31 +01:00
var restore = buttonLoading ( btn );
2018-09-24 18:10:16 +02:00
$ ( " #upload " ) . ajaxSubmit ({
url : globals . rootdir + " /actions.php " ,
data : {
op : " save " ,
id_module : " '. $id_module .' " ,
id_plugin : " '. $id_plugin .' " ,
},
type : " post " ,
success : function ( data ){
data = JSON . parse ( data );
2018-09-25 11:55:52 +02:00
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-09-25 11:55:52 +02:00
} else {
swal ({
2019-02-21 22:21:30 +01:00
title : " '.tr('Fattura già importata').'. " ,
2018-09-25 11:55:52 +02:00
type : " info " ,
2019-01-03 12:57:17 +01:00
});
2020-09-07 15:04:06 +02:00
2019-01-03 13:01:06 +01:00
$ ( " #blob " ) . val ( " " );
2018-09-25 11:55:52 +02:00
}
2020-09-07 15:04:06 +02:00
2019-01-03 13:01:06 +01:00
buttonRestore ( btn , restore );
2018-09-24 18:10:16 +02:00
},
2019-02-01 17:44:31 +01:00
error : function ( xhr ) {
alert ( " '.tr('Errore').': " + xhr . responseJSON . error . message );
2018-12-12 17:54:31 +01:00
buttonRestore ( btn , restore );
2018-09-24 18:10:16 +02:00
}
});
})
} else {
swal ({
title : " '.tr('Selezionare un file!').' " ,
type : " error " ,
})
}
}
</ script >
< div class = " box box-success " >
< div class = " box-header with-border " >
< h3 class = " box-title " >
2018-12-19 23:53:02 +01:00
'.tr(' Carica un XML ').'
2019-11-23 06:48:58 +01:00
< span class = " tip " title = " '.tr('Formati supportati: XML, P7M e ZIP').'. " >
2018-12-19 23:53:02 +01:00
< i class = " fa fa-question-circle-o " ></ i >
</ span >
2018-09-24 18:10:16 +02:00
</ h3 >
</ div >
< div class = " box-body " id = " upload " >
< div class = " row " >
< div class = " col-md-9 " >
2019-05-29 05:19:15 +02:00
{[ " type " : " file " , " name " : " blob " , " required " : 1 ]}
2018-09-24 18:10:16 +02:00
</ div >
< div class = " col-md-3 " >
2018-12-19 23:53:02 +01:00
< button type = " button " class = " btn btn-primary pull-right " onclick = " upload(this) " >
2019-01-10 18:41:25 +01:00
< i class = " fa fa-upload " ></ i > '.tr(' Carica documento fornitore ').'
2018-09-24 18:10:16 +02:00
</ button >
</ div >
</ div >
</ div >
</ div > ' ;
2018-11-30 15:33:25 +01:00
2019-02-12 11:42:48 +01:00
echo '
2018-11-30 15:33:25 +01:00
< div class = " box box-info " >
< div class = " box-header with-border " >
< h3 class = " box-title " >
2019-02-12 11:42:48 +01:00
'.tr(' Fatture da importare ').' </ span >
2019-07-24 17:17:54 +02:00
</ h3 >
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
< div class = " pull-right " >
< button type = " button " class = " btn btn-warning " onclick = " importAll(this) " >
2019-07-24 17:39:11 +02:00
< i class = " fa fa-cloud-download " ></ i > '.tr(' Importa in sequenza ').'
2019-07-24 17:17:54 +02:00
</ button > ' ;
2019-02-12 11:42:48 +01:00
// Ricerca automatica
if ( Interaction :: isEnabled ()) {
echo '
2019-07-24 17:17:54 +02:00
< button type = " button " class = " btn btn-primary " onclick = " search(this) " >
< i class = " fa fa-refresh " ></ i > '.tr(' Ricerca fatture di acquisto ').'
</ button > ' ;
2019-02-12 11:42:48 +01:00
}
echo '
2019-07-24 17:17:54 +02:00
</ div >
2018-11-30 15:33:25 +01:00
</ div >
< div class = " box-body " id = " list " > ' ;
2019-03-01 11:51:21 +01:00
if ( Interaction :: isEnabled ()) {
echo '
< p > '.tr(' Per vedere le fatture da importare utilizza il pulsante _BUTTON_ ' , [
2024-03-22 15:52:24 +01:00
'_BUTTON_' => '<b>"' . tr ( 'Ricerca fatture di acquisto' ) . '"</b>' ,
]) . '.</p>' ;
2019-03-01 11:51:21 +01:00
} else {
2018-11-30 15:33:25 +01:00
include $structure -> filepath ( 'list.php' );
2019-03-01 11:51:21 +01:00
}
2018-11-30 15:33:25 +01:00
2024-01-15 15:30:45 +01:00
echo '
2018-11-30 15:33:25 +01:00
</ div >
</ div >
< script >
2019-07-23 16:49:05 +02:00
$ ( document ) . ready ( function () {
$ ( $ . fn . dataTable . tables ( true )) . DataTable () . columns . adjust ();
$ ( $ . fn . dataTable . tables ( true )) . DataTable () . scroller . measure ();
2019-07-24 17:17:54 +02:00
}); ' ;
if ( Interaction :: isEnabled ()) {
echo '
function importAll ( btn ) {
swal ({
title : " '.tr('Importare tutte le fatture?').' " ,
html : " '.tr('Verranno scaricate tutte le fatture da importare, e non sarà più possibile visualizzare altre informazioni oltre al nome per le fatture che non verranno importate completamente. Continuare?').' " ,
showCancelButton : true ,
confirmButtonText : " '.tr('Procedi').' " ,
type : " info " ,
}) . then ( function ( result ) {
var restore = buttonLoading ( btn );
$ ( " #main_loading " ) . show ();
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
data : {
op : " list " ,
id_module : " '. $id_module .' " ,
id_plugin : " '. $id_plugin .' " ,
},
type : " post " ,
success : function ( data ){
data = JSON . parse ( data );
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
count = data . length ;
counter = 0 ;
data . forEach ( function ( element ) {
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
type : " get " ,
data : {
id_module : " '. $id_module .' " ,
id_plugin : " '. $id_plugin .' " ,
op : " prepare " ,
name : element . name ,
},
success : function ( data ) {
counter ++ ;
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
importComplete ( count , counter , btn , restore );
},
error : function ( data ) {
counter ++ ;
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
importComplete ( count , counter , btn , restore );
}
});
});
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
importComplete ( count , counter , btn , restore );
},
error : function ( data ) {
alert ( " '.tr('Errore').': " + data );
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
$ ( " #main_loading " ) . fadeOut ();
buttonRestore ( btn , restore );
}
});
});
}
2020-09-07 15:04:06 +02:00
function importComplete ( count , counter , btn , restore ) {
2019-07-24 17:17:54 +02:00
if ( counter == count ){
$ ( " #main_loading " ) . fadeOut ();
buttonRestore ( btn , restore );
2020-09-07 15:04:06 +02:00
2019-07-24 17:17:54 +02:00
redirect ( globals . rootdir + " /editor.php?id_module= " + globals . id_module + " &id_plugin= " + '.$id_plugin.' + " &id_record=1&sequence=1 " );
}
} ' ;
} else {
echo '
function importAll ( btn ) {
redirect ( globals . rootdir + " /editor.php?id_module= " + globals . id_module + " &id_plugin= " + '.$id_plugin.' + " &id_record=1&sequence=1 " );
} ' ;
}
echo '
2019-07-23 16:49:05 +02:00
2019-07-24 17:17:54 +02:00
function search ( btn ) {
var restore = buttonLoading ( btn );
2018-11-30 15:33:25 +01:00
$ ( " #list " ) . load ( " '. $structure->fileurl ('list.php').'?id_module='. $id_module .'&id_plugin='. $id_plugin .' " , function () {
2019-07-24 17:17:54 +02:00
buttonRestore ( btn , restore );
2018-11-30 15:33:25 +01:00
});
}
2019-07-24 17:17:54 +02:00
2018-11-30 15:33:25 +01:00
</ script > ' ;