diff --git a/modules/impianti/bulk.php b/modules/impianti/bulk.php new file mode 100644 index 000000000..6c5f8c3f5 --- /dev/null +++ b/modules/impianti/bulk.php @@ -0,0 +1,49 @@ +. + */ + +include_once __DIR__.'/../../core.php'; +use Modules\Impianti\Impianto; + +switch (post('op')) { + + + case 'export-bulk': + + $t = new Modules\Impianti\Export\CSV(__DIR__.'\..\..\files\impianti\Impianti.csv'); + + if($t->exportRecords()) + flash()->info(tr('Esportazione riuscita!')); + + break; +} + +if (App::debug()) { + $operations['export-bulk'] = [ + 'text' => ' '.tr('Esporta tutto').'', + 'data' => [ + 'msg' => tr('Vuoi davvero esportare un CSV degli impianti?'), + 'button' => tr('Procedi'), + 'class' => 'btn btn-lg btn-danger', + ], + ]; +} + + + +return $operations; diff --git a/modules/impianti/src/Export/CSV.php b/modules/impianti/src/Export/CSV.php new file mode 100644 index 000000000..a9497320e --- /dev/null +++ b/modules/impianti/src/Export/CSV.php @@ -0,0 +1,51 @@ +. + */ + +namespace Modules\Impianti\Export; + +use Exporter\CSVExporter; +use Modules\Impianti\Impianto; + +/** + * Struttura per la gestione delle operazioni di esportazione (in CSV) delle Impianti. + * + * @since 2.4.18 + */ +class CSV extends CSVExporter +{ + public function getAvailableFields() + { + return [ + [ + 'field' => 'matricola', + 'label' => 'Matricola', + 'primary_key' => true, + ], + [ + 'field' => 'nome', + 'label' => 'Nome', + ], + ]; + } + + public function getRecords() + { + return Impianto::all(); + } +}