mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-02 17:07:01 +01:00
Abilitazione generale esportazione tramite Azioni di gruppo esistenti
Abilitazione dell'esportazione tramite Azioni di gruppo esistenti per Articoli, Anagrafiche, Fatture e Impianti. Aggiunta formattazione automatica sulla base del tipo del campo per l'esportazione.
This commit is contained in:
parent
5473baf226
commit
56c761cad9
@ -83,25 +83,26 @@ $operations = [];
|
||||
|
||||
if (App::debug()) {
|
||||
$operations['delete-bulk'] = [
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger">beta</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi davvero eliminare le anagrafiche selezionate?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-danger',
|
||||
],
|
||||
];
|
||||
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi davvero esportare un CSV con le anagrafiche selezionate?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-danger',
|
||||
'blank' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi esportare un CSV con le anagrafiche selezionate?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-success',
|
||||
'blank' => true,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
if (App::debug() && $google) {
|
||||
$operations['ricerca-coordinate'] = [
|
||||
'text' => '<span><i class="fa fa-map"></i> '.tr('Ricerca coordinate').'</span>',
|
||||
|
@ -17,15 +17,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Articoli\Articolo;
|
||||
use Modules\Articoli\Export\CSV;
|
||||
use Modules\Preventivi\Components\Articolo as ArticoloPreventivo;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
use Modules\TipiIntervento\Tipo as TipoSessione;
|
||||
use Plugins\ListinoClienti\DettaglioPrezzo;
|
||||
use Prints;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (post('op')) {
|
||||
case 'change-acquisto':
|
||||
@ -154,6 +154,19 @@ switch (post('op')) {
|
||||
exit();
|
||||
|
||||
break;
|
||||
|
||||
case 'export-csv':
|
||||
$file = temp_file();
|
||||
$exporter = new CSV($file);
|
||||
|
||||
// Esportazione dei record selezionati
|
||||
$anagrafiche = Articolo::whereIn('id', $id_records)->get();
|
||||
$exporter->setRecords($anagrafiche);
|
||||
|
||||
$count = $exporter->exportRecords();
|
||||
|
||||
download($file, 'articoli.csv');
|
||||
break;
|
||||
}
|
||||
|
||||
if (App::debug()) {
|
||||
@ -167,6 +180,16 @@ if (App::debug()) {
|
||||
];
|
||||
}
|
||||
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi esportare un CSV con le anagrafiche selezionate?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-success',
|
||||
'blank' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$operations['change-acquisto'] = [
|
||||
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Aggiorna prezzo di acquisto').'</span>',
|
||||
'data' => [
|
||||
|
109
modules/articoli/src/Export/CSV.php
Normal file
109
modules/articoli/src/Export/CSV.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*
|
||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||
* Copyright (C) DevCode s.r.l.
|
||||
*
|
||||
* 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\Articoli\Export;
|
||||
|
||||
use Exporter\CSVExporter;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Articoli\Articolo;
|
||||
|
||||
/**
|
||||
* Struttura per la gestione delle operazioni di esportazione (in CSV) degli Articoli.
|
||||
*
|
||||
* @since 2.4.26
|
||||
*/
|
||||
class CSV extends CSVExporter
|
||||
{
|
||||
public function getAvailableFields()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'field' => 'codice',
|
||||
'label' => 'Codice',
|
||||
'primary_key' => true,
|
||||
],
|
||||
[
|
||||
'field' => 'descrizione',
|
||||
'label' => 'Descrizione',
|
||||
],
|
||||
[
|
||||
'field' => 'qta',
|
||||
'label' => 'Quantità',
|
||||
'type' => 'number',
|
||||
],
|
||||
[
|
||||
'field' => 'um',
|
||||
'label' => 'Unità di misura',
|
||||
],
|
||||
[
|
||||
'field' => 'prezzo_acquisto',
|
||||
'label' => 'Prezzo acquisto',
|
||||
'type' => 'number',
|
||||
],
|
||||
[
|
||||
'field' => 'prezzo_vendita',
|
||||
'label' => 'Prezzo vendita',
|
||||
'type' => 'number',
|
||||
],
|
||||
[
|
||||
'field' => 'peso_lordo',
|
||||
'label' => 'Peso lordo (KG)',
|
||||
'type' => 'number',
|
||||
],
|
||||
[
|
||||
'field' => 'volume',
|
||||
'label' => 'Volume (M3)',
|
||||
'type' => 'number',
|
||||
],
|
||||
[
|
||||
'field' => 'categoria.nome',
|
||||
'label' => 'Categoria',
|
||||
],
|
||||
[
|
||||
'field' => 'sottocategoria.nome',
|
||||
'label' => 'Sottocategoria',
|
||||
],
|
||||
[
|
||||
'field' => 'barcode',
|
||||
'label' => 'Barcode',
|
||||
],
|
||||
[
|
||||
'field' => 'id_fornitore',
|
||||
'label' => 'Fornitore predefinito',
|
||||
],
|
||||
[
|
||||
'field' => 'codice_iva_vendita',
|
||||
'label' => 'Codice IVA vendita',
|
||||
],
|
||||
[
|
||||
'field' => 'ubicazione',
|
||||
'label' => 'Ubicazione',
|
||||
],
|
||||
[
|
||||
'field' => 'note',
|
||||
'label' => 'Note',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getRecords()
|
||||
{
|
||||
return Articolo::all();
|
||||
}
|
||||
}
|
@ -381,20 +381,20 @@ switch (post('op')) {
|
||||
|
||||
if (App::debug()) {
|
||||
$operations['delete-bulk'] = [
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
];
|
||||
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi davvero esportare un CSV con le fatture selezionate?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-danger',
|
||||
'blank' => true,
|
||||
],
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger">beta</span>',
|
||||
];
|
||||
}
|
||||
|
||||
$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,
|
||||
],
|
||||
];
|
||||
|
||||
$operations['copy-bulk'] = [
|
||||
'text' => '<span><i class="fa fa-copy"></i> '.tr('Duplica selezionati').'</span>',
|
||||
'data' => [
|
||||
|
@ -38,16 +38,14 @@ switch (post('op')) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (App::debug()) {
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi davvero esportare un CSV con tutti gli impianti?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-danger',
|
||||
'blank' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
$operations['export-csv'] = [
|
||||
'text' => '<span><i class="fa fa-download"></i> '.tr('Esporta selezionati').'</span>',
|
||||
'data' => [
|
||||
'msg' => tr('Vuoi esportare un CSV con tutti gli impianti?'),
|
||||
'button' => tr('Procedi'),
|
||||
'class' => 'btn btn-lg btn-success',
|
||||
'blank' => true,
|
||||
],
|
||||
];
|
||||
|
||||
return $operations;
|
||||
|
@ -249,7 +249,7 @@ switch (post('op')) {
|
||||
|
||||
if (App::debug()) {
|
||||
$operations['delete-bulk'] = [
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger" >beta</span>',
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina selezionati').'</span> <span class="label label-danger">beta</span>',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,13 @@ abstract class CSVExporter implements ExporterInterface
|
||||
$dot_notation = explode('.', $nome);
|
||||
$contenuto = $record;
|
||||
foreach ($dot_notation as $segment) {
|
||||
$contenuto = isset($contenuto[$segment]) ? $contenuto[$segment] : null;
|
||||
$contenuto = $contenuto[$segment] ?? null;
|
||||
}
|
||||
|
||||
// Formattazione automatica del campo
|
||||
$type = $field['type'] ?? 'string';
|
||||
if ($type == 'number') {
|
||||
$contenuto = numberFormat($contenuto);
|
||||
}
|
||||
|
||||
$row[] = $contenuto;
|
||||
|
Loading…
x
Reference in New Issue
Block a user