mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-05 10:17:30 +01:00
Introduzione esportazione CSV anagrafiche e fatture
This commit is contained in:
parent
dbddb460bb
commit
dff6d65952
@ -63,19 +63,51 @@ switch (post('op')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'download-csv':
|
||||||
|
|
||||||
|
$dir = base_dir().'/files/export_anagrafiche/';
|
||||||
|
directory($dir.'tmp/');
|
||||||
|
$file = secure_random_string().'.csv';
|
||||||
|
$dir_csv = slashes($dir.'tmp/'.$file);
|
||||||
|
|
||||||
|
$filename = 'anagrafiche.csv';
|
||||||
|
|
||||||
|
$t = new Modules\Anagrafiche\Export\CSV($dir_csv);
|
||||||
|
|
||||||
|
if($t->exportRecords()){
|
||||||
|
|
||||||
|
download($dir_csv, $filename);
|
||||||
|
delete($dir.'tmp/');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$operations = [];
|
$operations = [];
|
||||||
|
|
||||||
if (App::debug()) {
|
if (App::debug()) {
|
||||||
$operations['delete-bulk'] = [
|
$operations['delete-bulk'] = [
|
||||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span>',
|
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||||
'data' => [
|
'data' => [
|
||||||
'msg' => tr('Vuoi davvero eliminare le anagrafiche selezionate?'),
|
'msg' => tr('Vuoi davvero eliminare le anagrafiche selezionate?'),
|
||||||
'button' => tr('Procedi'),
|
'button' => tr('Procedi'),
|
||||||
'class' => 'btn btn-lg btn-danger',
|
'class' => 'btn btn-lg btn-danger',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$operations['download-csv'] = [
|
||||||
|
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta tutto').'</span> <span class="label label-danger" >beta</span>',
|
||||||
|
'data' => [
|
||||||
|
'msg' => tr('Vuoi davvero esportare un CSV con tutte le anagrafiche?'),
|
||||||
|
'button' => tr('Procedi'),
|
||||||
|
'class' => 'btn btn-lg btn-danger',
|
||||||
|
'blank' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App::debug() && $google) {
|
if (App::debug() && $google) {
|
||||||
|
@ -442,6 +442,24 @@ switch (post('op')) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'download-csv':
|
||||||
|
|
||||||
|
$dir = base_dir().'/files/export_fatture/';
|
||||||
|
directory($dir.'tmp/');
|
||||||
|
$file = secure_random_string().'.csv';
|
||||||
|
$dir_csv = slashes($dir.'tmp/'.$file);
|
||||||
|
|
||||||
|
$filename = 'fatture.csv';
|
||||||
|
|
||||||
|
$t = new Modules\Fatture\Export\CSV($dir_csv);
|
||||||
|
|
||||||
|
if($t->exportRecords()){
|
||||||
|
|
||||||
|
download($dir_csv, $filename);
|
||||||
|
delete($dir.'tmp/');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'delete-bulk':
|
case 'delete-bulk':
|
||||||
foreach ($id_records as $id) {
|
foreach ($id_records as $id) {
|
||||||
@ -458,8 +476,19 @@ switch (post('op')) {
|
|||||||
|
|
||||||
if (App::debug()) {
|
if (App::debug()) {
|
||||||
$operations['delete-bulk'] = [
|
$operations['delete-bulk'] = [
|
||||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span>',
|
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$operations['download-csv'] = [
|
||||||
|
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta tutto').'</span> <span class="label label-danger" >beta</span>',
|
||||||
|
'data' => [
|
||||||
|
'msg' => tr('Vuoi davvero esportare un CSV con tutte le fatture?'),
|
||||||
|
'button' => tr('Procedi'),
|
||||||
|
'class' => 'btn btn-lg btn-danger',
|
||||||
|
'blank' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$operations['copy-bulk'] = [
|
$operations['copy-bulk'] = [
|
||||||
|
76
modules/fatture/src/Export/CSV.php
Normal file
76
modules/fatture/src/Export/CSV.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||||
|
* Copyright (C) DevCode s.n.c.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Modules\Fatture\Export;
|
||||||
|
|
||||||
|
use Exporter\CSVExporter;
|
||||||
|
use Modules\Fatture\Fattura;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Struttura per la gestione delle operazioni di esportazione (in CSV) delle Fatture.
|
||||||
|
*
|
||||||
|
* @since 2.4.18
|
||||||
|
*/
|
||||||
|
class CSV extends CSVExporter
|
||||||
|
{
|
||||||
|
public function getAvailableFields()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'field' => 'id',
|
||||||
|
'label' => 'ID',
|
||||||
|
'primary_key' => true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'numero_esterno',
|
||||||
|
'label' => 'Numero',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'data',
|
||||||
|
'label' => 'Data',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'idanagrafica',
|
||||||
|
'label' => 'Ragione sociale',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'totale',
|
||||||
|
'label' => 'Totale',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'idstatodocumento',
|
||||||
|
'label' => 'Stato',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'codice_stato_fe',
|
||||||
|
'label' => 'Stato FE',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRecords()
|
||||||
|
{
|
||||||
|
|
||||||
|
$id_module = filter('id_module');
|
||||||
|
$results = Fattura::all()->where('id_segment', $_SESSION['module_'.$id_module]['id_segment']);
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -18,32 +18,41 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
use Modules\Impianti\Impianto;
|
use Modules\Impianti\Impianto;
|
||||||
|
|
||||||
switch (post('op')) {
|
switch (post('op')) {
|
||||||
|
|
||||||
|
case 'download-csv':
|
||||||
|
|
||||||
|
$dir = base_dir().'/files/export_impianti/';
|
||||||
|
directory($dir.'tmp/');
|
||||||
|
$file = secure_random_string().'.csv';
|
||||||
|
$dir_csv = slashes($dir.'tmp/'.$file);
|
||||||
|
|
||||||
case 'export-bulk':
|
$filename = 'impianti.csv';
|
||||||
|
|
||||||
$t = new Modules\Impianti\Export\CSV(__DIR__.'\..\..\files\impianti\Impianti.csv');
|
$t = new Modules\Impianti\Export\CSV($dir_csv);
|
||||||
|
|
||||||
if($t->exportRecords())
|
if($t->exportRecords()){
|
||||||
flash()->info(tr('Esportazione riuscita!'));
|
|
||||||
|
download($dir_csv, $filename);
|
||||||
|
delete($dir.'tmp/');
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App::debug()) {
|
if (App::debug()) {
|
||||||
$operations['export-bulk'] = [
|
$operations['download-csv'] = [
|
||||||
'text' => '<span><i class="fa fa-upload"></i> '.tr('Esporta tutto').'</span>',
|
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta tutto').'</span> <span class="label label-danger" >beta</span>',
|
||||||
'data' => [
|
'data' => [
|
||||||
'msg' => tr('Vuoi davvero esportare un CSV degli impianti?'),
|
'msg' => tr('Vuoi davvero esportare un CSV con tutti gli impianti?'),
|
||||||
'button' => tr('Procedi'),
|
'button' => tr('Procedi'),
|
||||||
'class' => 'btn btn-lg btn-danger',
|
'class' => 'btn btn-lg btn-danger',
|
||||||
|
'blank' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $operations;
|
||||||
|
|
||||||
return $operations;
|
|
@ -23,7 +23,7 @@ use Exporter\CSVExporter;
|
|||||||
use Modules\Impianti\Impianto;
|
use Modules\Impianti\Impianto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struttura per la gestione delle operazioni di esportazione (in CSV) delle Impianti.
|
* Struttura per la gestione delle operazioni di esportazione (in CSV) degli impianti.
|
||||||
*
|
*
|
||||||
* @since 2.4.18
|
* @since 2.4.18
|
||||||
*/
|
*/
|
||||||
@ -32,10 +32,14 @@ class CSV extends CSVExporter
|
|||||||
public function getAvailableFields()
|
public function getAvailableFields()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
[
|
||||||
|
'field' => 'id',
|
||||||
|
'label' => 'ID',
|
||||||
|
'primary_key' => true,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'field' => 'matricola',
|
'field' => 'matricola',
|
||||||
'label' => 'Matricola',
|
'label' => 'Matricola',
|
||||||
'primary_key' => true,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'field' => 'nome',
|
'field' => 'nome',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user