2017-09-06 11:59:47 +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 />.
*/
2017-09-06 11:59:47 +02:00
include_once __DIR__ . '/../../core.php' ;
2021-02-25 10:23:26 +01:00
use Modules\Aggiornamenti\Controlli\DatiFattureElettroniche ;
2021-12-10 12:45:44 +01:00
use Modules\Anagrafiche\Anagrafica ;
2020-11-27 15:10:27 +01:00
use Modules\Fatture\Export\CSV ;
2019-03-07 17:16:42 +01:00
use Modules\Fatture\Fattura ;
2019-06-13 15:57:55 +02:00
use Plugins\ExportFE\FatturaElettronica ;
2019-08-29 16:01:49 +02:00
use Plugins\ExportFE\Interaction ;
2020-11-27 15:10:27 +01:00
use Util\XML ;
2019-06-29 11:01:26 +02:00
use Util\Zip ;
2022-02-16 15:57:11 +01:00
use Modules\Fatture\Stato ;
2018-09-19 16:51:37 +02:00
2021-12-10 12:45:44 +01:00
$anagrafica_azienda = Anagrafica :: find ( setting ( 'Azienda predefinita' ));
2022-02-16 15:57:11 +01:00
$stato_emessa = $dbo -> selectOne ( 'co_statidocumento' , 'id' , [ 'descrizione' => 'Emessa' ])[ 'id' ];
2021-12-10 12:45:44 +01:00
2017-09-06 11:59:47 +02:00
switch ( post ( 'op' )) {
case 'export-bulk' :
2020-09-23 13:36:37 +02:00
$dir = base_dir () . '/files/export_fatture/' ;
2017-09-13 15:38:47 +02:00
directory ( $dir . 'tmp/' );
2017-09-06 11:59:47 +02:00
2019-03-07 17:16:42 +01:00
$dir = slashes ( $dir );
$zip = slashes ( $dir . 'fatture_' . time () . '.zip' );
2017-09-07 16:51:14 +02:00
// Rimozione dei contenuti precedenti
$files = glob ( $dir . '/*.zip' );
foreach ( $files as $file ) {
2017-09-11 17:49:03 +02:00
delete ( $file );
2017-09-07 16:51:14 +02:00
}
2017-09-06 11:59:47 +02:00
// Selezione delle fatture da stampare
2018-07-18 15:20:10 +02:00
$fatture = $dbo -> fetchArray ( 'SELECT co_documenti.id, numero_esterno, data, ragione_sociale, co_tipidocumento.descrizione FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_documenti.id IN(' . implode ( ',' , $id_records ) . ')' );
2017-09-06 11:59:47 +02:00
2018-07-18 15:20:10 +02:00
if ( ! empty ( $fatture )) {
foreach ( $fatture as $r ) {
2018-09-26 10:49:38 +02:00
$print = Prints :: getModulePredefinedPrint ( $id_module );
2018-06-26 14:30:26 +02:00
2022-02-25 16:41:05 +01:00
Prints :: render ( $print [ 'id' ], $r [ 'id' ], $dir . 'tmp/' , false , false );
2017-09-13 18:47:42 +02:00
}
2017-09-06 11:59:47 +02:00
2017-09-13 18:47:42 +02:00
// Creazione zip
if ( extension_loaded ( 'zip' )) {
2019-03-07 17:16:42 +01:00
Zip :: create ( $dir . 'tmp/' , $zip );
2017-09-06 11:59:47 +02:00
2017-09-13 18:47:42 +02:00
// Invio al browser dello zip
2019-03-07 17:16:42 +01:00
download ( $zip );
2017-09-06 11:59:47 +02:00
2017-09-13 18:47:42 +02:00
// Rimozione dei contenuti
delete ( $dir . 'tmp/' );
}
2017-09-06 12:50:44 +02:00
}
2017-09-06 11:59:47 +02:00
break ;
2018-03-19 19:07:32 +01:00
2021-02-23 11:34:37 +01:00
case 'exportFE-bulk' :
$dir = base_dir () . '/files/export_fatture/' ;
directory ( $dir . 'tmp/' );
$dir = slashes ( $dir );
$zip = slashes ( $dir . 'fattureFE_' . time () . '.zip' );
// Rimozione dei contenuti precedenti
$files = glob ( $dir . '/*.zip' );
foreach ( $files as $file ) {
delete ( $file );
}
2021-02-20 13:31:05 +01:00
$module = module ( $id_module );
2021-02-23 11:34:37 +01:00
if ( $module [ 'name' ] == 'Fatture di vendita' ) {
$print_name = 'Fattura elettronica di vendita' ;
} else {
$print_name = 'Fattura elettronica di acquisto' ;
}
$print = $dbo -> SelectOne ( 'zz_prints' , 'id' , [ 'name' => $print_name ]);
if ( ! empty ( $id_records )) {
foreach ( $id_records as $id_record ) {
Prints :: render ( $print [ 'id' ], $id_record , $dir . 'tmp/' );
}
// Creazione zip
if ( extension_loaded ( 'zip' )) {
Zip :: create ( $dir . 'tmp/' , $zip );
// Invio al browser dello zip
download ( $zip );
// Rimozione dei contenuti
delete ( $dir . 'tmp/' );
}
}
break ;
2019-06-13 15:57:55 +02:00
case 'genera-xml' :
$failed = [];
2019-06-29 11:01:26 +02:00
$added = [];
2019-06-13 15:57:55 +02:00
2019-06-29 11:01:26 +02:00
foreach ( $id_records as $id ) {
2019-06-13 15:57:55 +02:00
$fattura = Fattura :: find ( $id );
2020-11-20 17:53:09 +01:00
2019-07-23 16:27:36 +02:00
try {
2020-11-20 17:53:09 +01:00
$fattura_elettronica = new FatturaElettronica ( $id );
2019-07-23 16:24:04 +02:00
2020-11-20 17:53:09 +01:00
if ( ! empty ( $fattura_elettronica ) && ! $fattura_elettronica -> isGenerated ()) {
$file = $fattura_elettronica -> save ( $upload_dir );
2019-06-13 15:57:55 +02:00
$added [] = $fattura -> numero_esterno ;
}
2019-07-23 16:27:36 +02:00
} catch ( UnexpectedValueException $e ) {
2019-06-13 15:57:55 +02:00
$failed [] = $fattura -> numero_esterno ;
}
}
if ( ! empty ( $failed )) {
flash () -> warning ( tr ( 'Le fatture elettroniche _LIST_ non sono state generate.' , [
'_LIST_' => implode ( ', ' , $failed ),
]));
}
if ( ! empty ( $added )) {
flash () -> info ( tr ( 'Le fatture elettroniche _LIST_ sono state generate.' , [
'_LIST_' => implode ( ', ' , $added ),
]));
}
break ;
2019-06-13 16:24:50 +02:00
2019-08-29 16:01:49 +02:00
case 'hook-send' :
foreach ( $id_records as $id ) {
$fattura = Fattura :: find ( $id );
2020-11-20 17:53:09 +01:00
try {
$fattura_elettronica = new FatturaElettronica ( $fattura -> id );
if ( ! empty ( $fattura_elettronica ) && $fattura_elettronica -> isGenerated () && $fattura -> codice_stato_fe == 'GEN' ) {
$fattura -> codice_stato_fe = 'QUEUE' ;
$fattura -> data_stato_fe = date ( 'Y-m-d H:i:s' );
$fattura -> hook_send = true ;
$fattura -> save ();
$added [] = $fattura -> numero_esterno ;
}
} catch ( UnexpectedValueException $e ) {
$failed [] = $fattura -> numero_esterno ;
2019-08-29 16:01:49 +02:00
}
}
flash () -> info ( tr ( 'Le fatture elettroniche sono state aggiunte alla coda di invio' ));
break ;
2019-03-07 17:16:42 +01:00
case 'export-xml-bulk' :
2020-09-23 13:36:37 +02:00
$dir = base_dir () . '/files/export_fatture/' ;
2019-03-07 17:16:42 +01:00
directory ( $dir . 'tmp/' );
$dir = slashes ( $dir );
$zip = slashes ( $dir . 'fatture_' . time () . '.zip' );
// Rimozione dei contenuti precedenti
$files = glob ( $dir . '/*.zip' );
foreach ( $files as $file ) {
delete ( $file );
}
2019-06-13 14:46:04 +02:00
// Selezione delle fatture da esportare
2019-05-10 17:30:00 +02:00
$fatture = $dbo -> fetchArray ( 'SELECT co_documenti.id, numero_esterno, data, ragione_sociale, co_tipidocumento.descrizione, co_tipidocumento.dir FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id WHERE co_documenti.id IN(' . implode ( ',' , $id_records ) . ')' );
2019-03-07 17:16:42 +01:00
$failed = [];
2019-06-13 14:46:04 +02:00
$added = 0 ;
2019-03-07 17:16:42 +01:00
if ( ! empty ( $fatture )) {
foreach ( $fatture as $r ) {
$fattura = Fattura :: find ( $r [ 'id' ]);
$include = true ;
try {
2019-03-28 13:00:49 +01:00
if ( $r [ 'dir' ] == 'entrata' ) {
2020-11-20 17:53:09 +01:00
$fe = new FatturaElettronica ( $fattura -> id );
2019-03-28 13:00:49 +01:00
$include = $fe -> isGenerated ();
} else {
$include = $fattura -> isFE ();
}
2019-03-07 17:16:42 +01:00
} catch ( UnexpectedValueException $e ) {
$include = false ;
2018-06-26 14:30:26 +02:00
}
2019-03-07 17:16:42 +01:00
if ( ! $include ) {
$failed [] = $fattura -> numero_esterno ;
} else {
2019-03-28 13:00:49 +01:00
if ( $r [ 'dir' ] == 'entrata' ) {
2021-09-07 15:51:03 +02:00
$dst = $fe -> getFilename ();
$src = $dbo -> selectOne ( 'zz_files' , 'filename' , [ 'original' => $dst ])[ 'filename' ];
2019-03-28 13:00:49 +01:00
} else {
2019-04-04 17:30:58 +02:00
$src = basename ( $fattura -> uploads () -> where ( 'name' , 'Fattura Elettronica' ) -> first () -> filepath );
2019-07-19 18:11:07 +02:00
$dst = basename ( $fattura -> uploads () -> where ( 'name' , 'Fattura Elettronica' ) -> first () -> original_name );
2019-03-28 13:00:49 +01:00
}
2019-03-07 17:16:42 +01:00
2019-03-28 13:00:49 +01:00
$file = slashes ( $module -> upload_directory . '/' . $src );
2021-09-07 15:51:03 +02:00
$dest = slashes ( $dir . 'tmp/' . $dst );
2019-03-07 17:16:42 +01:00
$result = copy ( $file , $dest );
2019-06-13 14:46:04 +02:00
2019-03-07 17:16:42 +01:00
if ( $result ) {
2019-06-29 11:01:26 +02:00
++ $added ;
2019-08-29 10:25:14 +02:00
//operationLog('export-xml-bulk', ['id_record' => $r['id']]);
2019-03-07 17:16:42 +01:00
} else {
$failed [] = $fattura -> numero_esterno ;
}
}
}
// Creazione zip
2019-06-29 11:01:26 +02:00
if ( extension_loaded ( 'zip' ) and ! empty ( $added )) {
2019-03-07 17:16:42 +01:00
Zip :: create ( $dir . 'tmp/' , $zip );
// Invio al browser il file zip
download ( $zip );
// Rimozione dei contenuti
delete ( $dir . 'tmp/' );
2018-06-26 14:30:26 +02:00
}
2019-03-07 17:16:42 +01:00
if ( ! empty ( $failed )) {
2019-06-13 14:46:04 +02:00
flash () -> warning ( tr ( 'Le fatture elettroniche _LIST_ non sono state incluse poichè non ancora generate o non presenti sul server' , [
2019-03-07 17:16:42 +01:00
'_LIST_' => implode ( ', ' , $failed ),
]));
}
}
2018-03-22 15:40:20 +01:00
break ;
2020-01-17 15:23:32 +01:00
case 'copy-bulk' :
2020-07-30 18:08:02 +02:00
$list = [];
2020-01-28 14:06:33 +01:00
foreach ( $id_records as $id ) {
$fattura = Fattura :: find ( $id );
2020-07-24 10:02:58 +02:00
array_push ( $list , $fattura -> numero_esterno );
2020-01-17 15:23:32 +01:00
2020-01-28 14:06:33 +01:00
$id_segment = ( post ( 'id_segment' ) ? post ( 'id_segment' ) : $fattura -> id_segment );
2020-02-05 14:51:39 +01:00
$dir = $dbo -> fetchOne ( 'SELECT dir FROM co_tipidocumento WHERE id=' . prepare ( $fattura -> idtipodocumento ))[ 'dir' ];
2020-01-17 15:23:32 +01:00
2020-01-28 14:06:33 +01:00
//+ 1 giorno
2020-02-05 14:51:39 +01:00
if ( post ( 'skip_time' ) == 'Giorno' ) {
$data = date ( 'Y-m-d' , strtotime ( '+1 day' , strtotime ( $fattura -> data )));
2020-01-17 15:23:32 +01:00
}
//+ 1 settimana
2020-02-05 14:51:39 +01:00
if ( post ( 'skip_time' ) == 'Settimana' ) {
$data = date ( 'Y-m-d' , strtotime ( '+1 week' , strtotime ( $fattura -> data )));
2020-01-17 15:23:32 +01:00
}
//+ 1 mese
2020-02-05 14:51:39 +01:00
if ( post ( 'skip_time' ) == 'Mese' ) {
$data = date ( 'Y-m-d' , strtotime ( '+1 month' , strtotime ( $fattura -> data )));
2020-01-17 15:23:32 +01:00
}
//+ 1 anno
2020-02-05 14:51:39 +01:00
if ( post ( 'skip_time' ) == 'Anno' ) {
$data = date ( 'Y-m-d' , strtotime ( '+1 year' , strtotime ( $fattura -> data )));
2020-01-17 15:23:32 +01:00
}
2020-01-28 14:06:33 +01:00
$new = $fattura -> replicate ();
2020-08-04 19:07:04 +02:00
$new -> data = $data ;
2020-01-28 14:06:33 +01:00
$new -> id_segment = $id_segment ;
$new -> numero = Fattura :: getNextNumero ( $data , $dir , $id_segment );
2020-08-04 19:07:04 +02:00
2020-01-28 14:06:33 +01:00
$new -> save ();
2020-01-17 15:23:32 +01:00
2020-01-28 14:06:33 +01:00
$righe = $fattura -> getRighe ();
foreach ( $righe as $riga ) {
$new_riga = $riga -> replicate ();
2020-09-22 20:28:37 +02:00
$new_riga -> setDocument ( $new );
2020-01-17 15:23:32 +01:00
2020-02-27 16:19:07 +01:00
if ( ! post ( 'riferimenti' )) {
$new_riga -> idpreventivo = 0 ;
$new_riga -> idcontratto = 0 ;
$new_riga -> idintervento = 0 ;
$new_riga -> idddt = 0 ;
$new_riga -> idordine = 0 ;
}
2020-01-28 14:06:33 +01:00
$new_riga -> save ();
2020-01-17 15:23:32 +01:00
2020-02-27 16:19:07 +01:00
if ( $new_riga -> isArticolo ()) {
$new_riga -> movimenta ( $new_riga -> qta );
2020-01-17 15:23:32 +01:00
}
}
}
2020-07-24 10:02:58 +02:00
flash () -> info ( tr ( 'Fatture _LIST_ duplicate correttamente!' , [
'_LIST_' => implode ( ',' , $list ),
]));
2020-01-17 15:23:32 +01:00
break ;
2020-11-27 15:10:27 +01:00
2020-11-21 03:16:59 +01:00
case 'check-bulk' :
2021-02-25 10:23:26 +01:00
$controllo = new DatiFattureElettroniche ();
$fatture = [];
2020-11-21 03:16:59 +01:00
foreach ( $id_records as $id ) {
$fattura_vendita = Fattura :: vendita ()
2021-02-25 10:23:26 +01:00
-> whereNotIn ( 'codice_stato_fe' , [ 'ERR' , 'NS' , 'EC02' , 'ERVAL' ])
2020-12-31 16:13:28 +01:00
-> where ( 'data' , '>=' , session ( 'period_start' ))
-> where ( 'data' , '<=' , session ( 'period_end' ))
2021-02-25 10:23:26 +01:00
-> where ( 'id' , '=' , $id )
-> orderBy ( 'data' )
-> first ();
2020-11-21 03:22:23 +01:00
2020-11-27 15:10:27 +01:00
if ( ! empty ( $fattura_vendita )) {
2021-02-25 10:23:26 +01:00
$fatture [ $id ] = $fattura_vendita ;
2020-11-27 15:10:27 +01:00
2021-02-25 10:23:26 +01:00
$controllo -> checkFattura ( $fattura_vendita );
2020-11-21 03:16:59 +01:00
}
}
2021-02-25 10:23:26 +01:00
$results = $controllo -> getResults ();
$num = count ( $results );
2020-11-21 03:16:59 +01:00
// Messaggi di risposta
2021-02-25 10:23:26 +01:00
if ( empty ( $fatture )) {
2020-11-21 03:16:59 +01:00
flash () -> warning ( tr ( 'Nessuna fattura utile per il controllo!' ));
2021-02-25 10:23:26 +01:00
} elseif ( empty ( $results )) {
flash () -> info ( tr ( 'Nessuna anomalia!' ));
2020-11-27 15:10:27 +01:00
} else {
2020-11-21 03:16:59 +01:00
flash () -> info ( tr ( 'Fatture _LIST_ controllate.' , [
2021-02-25 10:23:26 +01:00
'_LIST_' => implode ( ',' , array_column ( $results , 'numero' )),
2020-11-21 03:16:59 +01:00
]));
2021-02-25 10:23:26 +01:00
$riepilogo_anomalie = tr ( 'Attenzione: Trovate _NUM_ anomalie! Le seguenti fatture non trovano corrispondenza tra XML e dati nel documento' , [ '_NUM_' => $num ]) . ':</br></br>' ;
2020-11-27 15:10:27 +01:00
2021-02-25 10:23:26 +01:00
foreach ( $results as $anomalia ) {
$fattura = $fatture [ $anomalia [ 'id' ]];
2020-11-21 03:16:59 +01:00
2021-02-25 10:23:26 +01:00
$riepilogo_anomalie .= ' < ul >
< li > '.reference($fattura, $fattura->getReference()).' </ li >
< li > '.$anomalia[' descrizione '].' </ li >
</ ul >< br > ' ;
2020-11-21 03:16:59 +01:00
}
2021-02-25 10:23:26 +01:00
flash () -> warning ( $riepilogo_anomalie );
2020-11-21 03:16:59 +01:00
}
break ;
2020-11-27 15:10:27 +01:00
case 'export-csv' :
2020-12-04 16:37:07 +01:00
$file = temp_file ();
2020-11-27 15:10:27 +01:00
$exporter = new CSV ( $file );
2020-11-24 17:25:07 +01:00
2020-11-27 15:10:27 +01:00
// Esportazione dei record selezionati
$fatture = Fattura :: whereIn ( 'id' , $id_records ) -> get ();
$exporter -> setRecords ( $fatture );
2020-11-24 17:25:07 +01:00
2020-11-27 15:10:27 +01:00
$count = $exporter -> exportRecords ();
2020-11-24 17:25:07 +01:00
2020-11-27 15:10:27 +01:00
download ( $file , 'fatture.csv' );
2020-11-24 17:25:07 +01:00
break ;
2020-03-03 10:33:32 +01:00
case 'delete-bulk' :
foreach ( $id_records as $id ) {
$documento = Fattura :: find ( $id );
try {
$documento -> delete ();
} catch ( InvalidArgumentException $e ) {
}
}
flash () -> info ( tr ( 'Fatture eliminate!' ));
break ;
2021-12-10 12:45:44 +01:00
case 'change-bank' :
$list = [];
foreach ( $id_records as $id ) {
$documento = Fattura :: find ( $id );
$documento -> id_banca_azienda = post ( 'id_banca' );
$documento -> save ();
array_push ( $list , $fattura -> numero_esterno );
}
flash () -> info ( tr ( 'Banca aggiornata per le Fatture _LIST_ !' , [
'_LIST_' => implode ( ',' , $list ),
]));
2022-02-16 15:57:11 +01:00
break ;
case 'change-stato' :
$list = [];
$new_stato = Stato :: where ( 'descrizione' , 'Emessa' ) -> first ();
foreach ( $id_records as $id ) {
$fattura = Fattura :: find ( $id );
$stato_precedente = Stato :: find ( $fattura -> idstatodocumento );
if ( $stato_precedente -> descrizione == 'Bozza' ) {
$fattura -> stato () -> associate ( $new_stato );
$results = $fattura -> save ();
$message = '' ;
foreach ( $results as $numero => $result ) {
foreach ( $result as $title => $links ) {
foreach ( $links as $link => $errors ) {
if ( empty ( $title )) {
flash () -> warning ( tr ( 'La fattura elettronica num. _NUM_ potrebbe avere delle irregolarità!' , [
'_NUM_' => $numero ,
]) . ' ' . tr ( 'Controllare i seguenti campi: _LIST_' , [
'_LIST_' => implode ( ', ' , $errors ),
]) . '.' );
} else {
$message .= '
< p >< b > '.$title.' '.$link.' </ b ></ p >
< ul > ' ;
foreach ( $errors as $error ) {
if ( ! empty ( $error )) {
$message .= '
< li > '.$error.' </ li > ' ;
}
}
$message .= '
</ ul > ' ;
}
}
}
}
if ( $message ) {
// Messaggi informativi sulle problematiche
$message = tr ( 'La fattura elettronica numero _NUM_ non è stata generata a causa di alcune informazioni mancanti' , [
'_NUM_' => $numero ,
]) . ':' . $message ;
flash () -> warning ( $message );
}
array_push ( $list , $fattura -> numero_esterno );
}
}
if ( ! empty ( $list )) {
flash () -> info ( tr ( 'Le fatture _LIST_ sono state emesse!' , [
'_LIST_' => implode ( ',' , $list ),
]));
} else {
flash () -> warning ( tr ( 'Nessuna fattura emessa!' ));
}
2021-12-10 12:45:44 +01:00
break ;
2017-09-06 11:59:47 +02:00
}
2020-12-31 16:13:28 +01:00
if ( AppLegacy :: debug ()) {
2020-07-09 18:50:10 +02:00
$operations [ 'delete-bulk' ] = [
2021-09-20 13:33:45 +02:00
'text' => '<span><i class="fa fa-trash"></i> ' . tr ( 'Elimina selezionati' ) . '</span> <span class="label label-danger">beta</span>' ,
2020-11-24 17:25:07 +01:00
];
2019-05-13 17:01:43 +02:00
}
2018-03-19 19:07:32 +01:00
2021-09-20 13:33:45 +02:00
$operations [ 'export-csv' ] = [
'text' => '<span><i class="fa fa-download"></i> ' . tr ( 'Esporta selezionati' ) . '</span>' ,
'data' => [
'msg' => tr ( 'Vuoi esportare un CSV con le fatture selezionate?' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-success' ,
'blank' => true ,
],
];
2020-01-17 15:23:32 +01:00
$operations [ 'copy-bulk' ] = [
'text' => '<span><i class="fa fa-copy"></i> ' . tr ( 'Duplica selezionati' ) . '</span>' ,
'data' => [
2021-02-03 11:10:08 +01:00
'msg' => tr ( 'Vuoi davvero duplicare le righe selezionate?' ) . '<br><br>{[ "type": "select", "label": "' . tr ( 'Fattura in avanti di' ) . '", "name": "skip_time", "required": 1, "values": "list=\"Giorno\":\"' . tr ( 'Un giorno' ) . '\", \"Settimana\":\"' . tr ( 'Una settimana' ) . '\", \"Mese\":\"' . tr ( 'Un mese' ) . '\", \"Anno\":\"' . tr ( 'Un anno' ) . '\" ", "value": "Giorno" ]}<br>{[ "type": "select", "label": "' . tr ( 'Sezionale' ) . '", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=' . $id_module . ' ORDER BY name", "value": "' . $_SESSION [ 'module_' . $id_module ][ 'id_segment' ] . '" ]}<br>{[ "type": "checkbox", "label": "' . tr ( 'Aggiungere i riferimenti ai documenti esterni?' ) . '", "placeholder": "' . tr ( 'Aggiungere i riferimenti ai documenti esterni?' ) . '", "name": "riferimenti" ]}' ,
2020-01-17 15:23:32 +01:00
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
2019-07-25 15:06:07 +02:00
$operations [ 'registrazione-contabile' ] = [
2019-07-25 12:54:28 +02:00
'text' => '<span><i class="fa fa-calculator"></i> ' . tr ( 'Registrazione contabile' ) . '</span>' ,
'data' => [
'title' => tr ( 'Registrazione contabile' ),
'type' => 'modal' ,
'origine' => 'fatture' ,
2021-02-20 13:31:05 +01:00
'url' => base_url () . '/add.php?id_module=' . module ( 'Prima nota' )[ 'id' ],
2019-07-25 12:54:28 +02:00
],
];
2021-07-27 14:44:45 +02:00
$operations [ 'exportFE-bulk' ] = [
'text' => '<span class="' . (( ! extension_loaded ( 'zip' )) ? 'text-muted disabled' : '' ) . '"><i class="fa fa-file-archive-o"></i> ' . tr ( 'Esporta stampe FE' ) . '</span>' ,
'data' => [
'title' => '' ,
'msg' => tr ( 'Vuoi davvero esportare i PDF delle fatture elettroniche selezionate in un archivio ZIP?' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
];
2019-06-13 15:57:55 +02:00
if ( $module -> name == 'Fatture di vendita' ) {
$operations [ 'genera-xml' ] = [
2019-07-25 12:54:28 +02:00
'text' => '<span><i class="fa fa-file-code-o"></i> ' . tr ( 'Genera fatture elettroniche' ) . '</span>' ,
2019-06-13 15:57:55 +02:00
'data' => [
'title' => '' ,
2020-11-21 03:16:59 +01:00
'msg' => tr ( 'Generare le fatture elettroniche per i documenti selezionati?<br><small>(le fatture dovranno trovarsi nello stato <i class="fa fa-clock-o text-info" title="Emessa"></i> <small>Emessa</small> e non essere mai state generate)</small>' ),
2019-06-13 15:57:55 +02:00
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
];
2019-06-13 14:46:04 +02:00
2019-05-13 17:01:43 +02:00
$operations [ 'export-bulk' ] = [
2019-07-25 12:54:28 +02:00
'text' => '<span class="' . (( ! extension_loaded ( 'zip' )) ? 'text-muted disabled' : '' ) . '"><i class="fa fa-file-archive-o"></i> ' . tr ( 'Esporta stampe' ) . '</span>' ,
2017-09-06 11:59:47 +02:00
'data' => [
2019-06-13 14:46:04 +02:00
'title' => '' ,
'msg' => tr ( 'Vuoi davvero esportare i PDF delle fatture selezionate in un archivio ZIP?' ),
2017-09-06 11:59:47 +02:00
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
2017-09-07 16:51:14 +02:00
'blank' => true ,
2017-09-06 11:59:47 +02:00
],
2019-03-07 17:16:42 +01:00
];
2020-11-21 03:16:59 +01:00
$operations [ 'check-bulk' ] = [
'text' => '<span><i class="fa fa-list-alt"></i> ' . tr ( 'Controlla fatture elettroniche' ) . '</span>' ,
'data' => [
'title' => '' ,
'msg' => tr ( 'Controllare corrispondenza tra XML e fattura di vendita?<br><small>(le fatture dovranno essere state generate)</small>' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
];
2019-03-07 17:16:42 +01:00
}
2019-05-13 17:01:43 +02:00
$operations [ 'export-xml-bulk' ] = [
2019-07-25 12:54:28 +02:00
'text' => '<span class="' . (( ! extension_loaded ( 'zip' )) ? 'text-muted disabled' : '' ) . '"><i class="fa fa-file-archive-o"></i> ' . tr ( 'Esporta XML' ) . '</span>' ,
2019-03-28 13:00:49 +01:00
'data' => [
2019-06-13 14:46:04 +02:00
'title' => '' ,
'msg' => tr ( 'Vuoi davvero esportare le fatture elettroniche selezionate in un archivio ZIP?' ),
2019-03-28 13:00:49 +01:00
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
];
2021-12-10 12:45:44 +01:00
$operations [ 'change-bank' ] = [
'text' => '<span><i class="fa fa-refresh"></i> ' . tr ( 'Aggiorna banca' ) . '</span>' ,
'data' => [
'title' => tr ( 'Aggiornare la banca?' ),
2022-02-16 15:57:11 +01:00
'msg' => tr ( 'Per ciascuna fattura selezionata, verrà aggiornata la banca' ) . '
2021-12-10 12:45:44 +01:00
< br >< br > {[ " type " : " select " , " label " : " '.tr('Banca').' " , " name " : " id_banca " , " required " : 1 , " values " : " query=SELECT id, CONCAT (nome, \ ' - \ ' , iban) AS descrizione FROM co_banche WHERE id_anagrafica='.prepare( $anagrafica_azienda->idanagrafica ).' " ]} ' ,
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
2022-02-16 15:57:11 +01:00
if ( $dir == 'entrata' ) {
$operations [ 'change-stato' ] = [
'text' => '<span><i class="fa fa-refresh"></i> ' . tr ( 'Emetti fatture' ) . '</span>' ,
'data' => [
'title' => tr ( 'Emissione fatture' ),
'msg' => tr ( 'Vuoi emettere le fatture selezionate? Verranno emesse solo le fatture in Bozza' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
}
2019-08-29 16:01:49 +02:00
if ( Interaction :: isEnabled ()) {
$operations [ 'hook-send' ] = [
'text' => '<span><i class="fa fa-paper-plane"></i> ' . tr ( 'Coda di invio FE' ) . '</span>' ,
'data' => [
'title' => '' ,
'msg' => tr ( 'Vuoi davvero aggiungere queste fatture alla coda di invio per le fatture elettroniche?' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
}
2019-05-13 17:01:43 +02:00
return $operations ;