fix ticket shipping
This commit is contained in:
1 parent
4b4d0c5cb6
commit
6e01729bf5
7 files changed
+380
-72
No files matched your search
@@ -49,3 +49,4 @@ app.*.map.json
|
|||||||
|
|
||||||
appimagetool*
|
appimagetool*
|
||||||
*.AppDir
|
*.AppDir
|
||||||
|
*.AppImage
|
||||||
@@ -55,6 +55,44 @@ class TicketShippingCubit extends Cubit<TicketShippingState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> createQuickProvider({
|
||||||
|
required String name,
|
||||||
|
required String address,
|
||||||
|
String city = '',
|
||||||
|
String zipCode = '',
|
||||||
|
String province = '',
|
||||||
|
}) async {
|
||||||
|
emit(state.copyWith(status: TicketShippingStatus.loading));
|
||||||
|
try {
|
||||||
|
final newProvider = await _repository.createQuickRepairCenter(
|
||||||
|
name: name,
|
||||||
|
address: address,
|
||||||
|
city: city,
|
||||||
|
zipCode: zipCode,
|
||||||
|
province: province,
|
||||||
|
);
|
||||||
|
|
||||||
|
final updatedProviders = List<ProviderModel>.from(state.availableProviders)
|
||||||
|
..add(newProvider);
|
||||||
|
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
status: TicketShippingStatus.initial,
|
||||||
|
availableProviders: updatedProviders,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
selectProvider(newProvider.id!);
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
status: TicketShippingStatus.failure,
|
||||||
|
errorMessage: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void selectProvider(String providerId) {
|
void selectProvider(String providerId) {
|
||||||
final ProviderModel provider = state.availableProviders.firstWhere(
|
final ProviderModel provider = state.availableProviders.firstWhere(
|
||||||
(p) => p.id == providerId,
|
(p) => p.id == providerId,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/core/enums_and_consts/consts.dart';
|
||||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||||
import 'package:flux/features/attachments/data/attachments_repository.dart';
|
import 'package:flux/features/attachments/data/attachments_repository.dart';
|
||||||
import 'package:flux/features/tickets/models/shipping_document_model.dart';
|
import 'package:flux/features/tickets/models/shipping_document_model.dart';
|
||||||
|
import 'package:flux/features/master_data/providers/models/provider_location_model.dart';
|
||||||
import 'package:flux/features/master_data/providers/models/provider_model.dart';
|
import 'package:flux/features/master_data/providers/models/provider_model.dart';
|
||||||
import 'package:flux/features/master_data/providers/models/provider_role.dart';
|
import 'package:flux/features/master_data/providers/models/provider_role.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
@@ -17,8 +19,8 @@ class TicketsShippingRepository {
|
|||||||
Future<List<ProviderModel>> fetchRepairCenters() async {
|
Future<List<ProviderModel>> fetchRepairCenters() async {
|
||||||
try {
|
try {
|
||||||
final response = await _supabase
|
final response = await _supabase
|
||||||
.from('provider')
|
.from(Tables.providers)
|
||||||
.select('*, provider_locations (*)')
|
.select('*, ${Tables.providerLocations} (*)')
|
||||||
.eq('is_active', true)
|
.eq('is_active', true)
|
||||||
.order('name');
|
.order('name');
|
||||||
|
|
||||||
@@ -35,13 +37,63 @@ class TicketsShippingRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<ProviderModel> createQuickRepairCenter({
|
||||||
|
required String name,
|
||||||
|
required String address,
|
||||||
|
String city = '',
|
||||||
|
String zipCode = '',
|
||||||
|
String province = '',
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final provider = ProviderModel(
|
||||||
|
companyId: _companyId,
|
||||||
|
name: name,
|
||||||
|
isActive: true,
|
||||||
|
roles: const [ProviderRole.repairCenter],
|
||||||
|
);
|
||||||
|
|
||||||
|
final savedRow = await _supabase
|
||||||
|
.from(Tables.providers)
|
||||||
|
.insert(provider.toMap())
|
||||||
|
.select()
|
||||||
|
.single();
|
||||||
|
|
||||||
|
final savedProvider = ProviderModel.fromMap(savedRow);
|
||||||
|
|
||||||
|
final location = ProviderLocationModel(
|
||||||
|
providerId: savedProvider.id!,
|
||||||
|
companyId: _companyId,
|
||||||
|
name: 'Sede Principale',
|
||||||
|
address: address,
|
||||||
|
city: city,
|
||||||
|
zipCode: zipCode,
|
||||||
|
province: province,
|
||||||
|
isMain: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
final locationRow = await _supabase
|
||||||
|
.from(Tables.providerLocations)
|
||||||
|
.insert(location.toMap())
|
||||||
|
.select()
|
||||||
|
.single();
|
||||||
|
|
||||||
|
final savedLocation = ProviderLocationModel.fromMap(locationRow);
|
||||||
|
|
||||||
|
return savedProvider.copyWith(
|
||||||
|
locations: [savedLocation],
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
throw ('Errore creazione centro di riparazione rapido: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<ShippingDocumentModel>> fetchShipmentDocumentsForTicket(
|
Future<List<ShippingDocumentModel>> fetchShipmentDocumentsForTicket(
|
||||||
String ticketId,
|
String ticketId,
|
||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _supabase
|
final response = await _supabase
|
||||||
.from('shipping_documents')
|
.from(Tables.shippingDocuments)
|
||||||
.select('*, attachments (*)')
|
.select('*, ${Tables.attachments} (*)')
|
||||||
.contains('ticket_ids', [ticketId]);
|
.contains('ticket_ids', [ticketId]);
|
||||||
|
|
||||||
return (response as List)
|
return (response as List)
|
||||||
@@ -57,8 +109,8 @@ class TicketsShippingRepository {
|
|||||||
Future<List<ShippingDocumentModel>> fetchCompanyShipmentDocuments() async {
|
Future<List<ShippingDocumentModel>> fetchCompanyShipmentDocuments() async {
|
||||||
try {
|
try {
|
||||||
final response = await _supabase
|
final response = await _supabase
|
||||||
.from('shipping_documents')
|
.from(Tables.shippingDocuments)
|
||||||
.select('*, attachments (*)')
|
.select('*, ${Tables.attachments} (*)')
|
||||||
.eq('company_id', _companyId);
|
.eq('company_id', _companyId);
|
||||||
|
|
||||||
return (response as List)
|
return (response as List)
|
||||||
@@ -76,8 +128,8 @@ class TicketsShippingRepository {
|
|||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _supabase
|
final response = await _supabase
|
||||||
.from('shipping_documents')
|
.from(Tables.shippingDocuments)
|
||||||
.select('*, attachments (*)')
|
.select('*, ${Tables.attachments} (*)')
|
||||||
.eq('id', documentId)
|
.eq('id', documentId)
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
@@ -99,7 +151,7 @@ class TicketsShippingRepository {
|
|||||||
// 1. Inseriamo prima il Documento di Trasporto (DDT) su Postgres
|
// 1. Inseriamo prima il Documento di Trasporto (DDT) su Postgres
|
||||||
// Il modello iniziale non ha ancora gli allegati popolati, quindi passiamo il toMap standard
|
// Il modello iniziale non ha ancora gli allegati popolati, quindi passiamo il toMap standard
|
||||||
final savedDocument = await _supabase
|
final savedDocument = await _supabase
|
||||||
.from('shipping_documents')
|
.from(Tables.shippingDocuments)
|
||||||
.insert(document.toMap())
|
.insert(document.toMap())
|
||||||
.select('id')
|
.select('id')
|
||||||
.single();
|
.single();
|
||||||
@@ -123,7 +175,7 @@ class TicketsShippingRepository {
|
|||||||
|
|
||||||
// 4. Aggiorniamo lo stato di TUTTI i ticket inclusi nel DDT e li colleghiamo all'ID del DDT
|
// 4. Aggiorniamo lo stato di TUTTI i ticket inclusi nel DDT e li colleghiamo all'ID del DDT
|
||||||
await _supabase
|
await _supabase
|
||||||
.from('ticket')
|
.from(Tables.tickets)
|
||||||
.update({
|
.update({
|
||||||
'ticket_status': newTicketStatus.value,
|
'ticket_status': newTicketStatus.value,
|
||||||
'shipping_document_id': documentId,
|
'shipping_document_id': documentId,
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
typedef QuickProviderData = ({
|
||||||
|
String name,
|
||||||
|
String address,
|
||||||
|
String city,
|
||||||
|
String zipCode,
|
||||||
|
String province,
|
||||||
|
});
|
||||||
|
|
||||||
|
class QuickProviderDialog extends StatefulWidget {
|
||||||
|
const QuickProviderDialog({super.key});
|
||||||
|
|
||||||
|
static Future<QuickProviderData?> show(BuildContext context) {
|
||||||
|
return showDialog<QuickProviderData>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const QuickProviderDialog(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<QuickProviderDialog> createState() => _QuickProviderDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuickProviderDialogState extends State<QuickProviderDialog> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _nameController = TextEditingController();
|
||||||
|
final _addressController = TextEditingController();
|
||||||
|
final _cityController = TextEditingController();
|
||||||
|
final _zipController = TextEditingController();
|
||||||
|
final _provinceController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_nameController.dispose();
|
||||||
|
_addressController.dispose();
|
||||||
|
_cityController.dispose();
|
||||||
|
_zipController.dispose();
|
||||||
|
_provinceController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _submit() {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
Navigator.of(context).pop<QuickProviderData>((
|
||||||
|
name: _nameController.text.trim(),
|
||||||
|
address: _addressController.text.trim(),
|
||||||
|
city: _cityController.text.trim(),
|
||||||
|
zipCode: _zipController.text.trim(),
|
||||||
|
province: _provinceController.text.trim().toUpperCase(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
return AlertDialog(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
backgroundColor: theme.colorScheme.primaryContainer,
|
||||||
|
child: Icon(Icons.domain_add, color: theme.colorScheme.primary),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
const Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Nuovo Centro Riparazioni',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: SingleChildScrollView(
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _nameController,
|
||||||
|
autofocus: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Nome Laboratorio *',
|
||||||
|
hintText: 'Es: riparazioni.it / Laboratorio Centrale',
|
||||||
|
prefixIcon: Icon(Icons.storefront),
|
||||||
|
),
|
||||||
|
validator: (v) => v == null || v.trim().isEmpty
|
||||||
|
? 'Campo obbligatorio'
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _addressController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Indirizzo Spedizione *',
|
||||||
|
hintText: 'Es: Via Roma 15',
|
||||||
|
prefixIcon: Icon(Icons.location_on),
|
||||||
|
),
|
||||||
|
validator: (v) => v == null || v.trim().isEmpty
|
||||||
|
? 'Campo obbligatorio'
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _cityController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Città',
|
||||||
|
hintText: 'Es: Milano',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _zipController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'CAP',
|
||||||
|
hintText: '20100',
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _provinceController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Prov.',
|
||||||
|
hintText: 'MI',
|
||||||
|
),
|
||||||
|
textCapitalization: TextCapitalization.characters,
|
||||||
|
maxLength: 2,
|
||||||
|
buildCounter: (
|
||||||
|
_, {
|
||||||
|
required currentLength,
|
||||||
|
required isFocused,
|
||||||
|
maxLength,
|
||||||
|
}) => null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Annulla'),
|
||||||
|
),
|
||||||
|
FilledButton.icon(
|
||||||
|
onPressed: _submit,
|
||||||
|
icon: const Icon(Icons.check),
|
||||||
|
label: const Text('Salva e Seleziona'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -160,32 +160,39 @@ class TicketListCard extends StatelessWidget {
|
|||||||
// CASO 2: Più allegati. Mostriamo una BottomSheet fulminea per far scegliere all'utente.
|
// CASO 2: Più allegati. Mostriamo una BottomSheet fulminea per far scegliere all'utente.
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => ListView.builder(
|
builder: (context) => Material(
|
||||||
shrinkWrap: true,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
itemCount: attachments.length,
|
borderRadius: const BorderRadius.vertical(
|
||||||
itemBuilder: (context, index) {
|
top: Radius.circular(28),
|
||||||
final file = attachments[index];
|
),
|
||||||
return ListTile(
|
clipBehavior: Clip.antiAlias,
|
||||||
leading: Icon(
|
child: ListView.builder(
|
||||||
file.extension == 'pdf'
|
shrinkWrap: true,
|
||||||
? Icons.picture_as_pdf
|
itemCount: attachments.length,
|
||||||
: Icons.image,
|
itemBuilder: (context, index) {
|
||||||
),
|
final file = attachments[index];
|
||||||
title: Text(file.name),
|
return ListTile(
|
||||||
subtitle: Text(
|
leading: Icon(
|
||||||
'${(file.fileSize / 1024).toStringAsFixed(1)} KB',
|
file.extension == 'pdf'
|
||||||
),
|
? Icons.picture_as_pdf
|
||||||
onTap: () {
|
: Icons.image,
|
||||||
Navigator.pop(
|
),
|
||||||
context,
|
title: Text(file.name),
|
||||||
); // Chiude la scelta
|
subtitle: Text(
|
||||||
_openFile(
|
'${(file.fileSize / 1024).toStringAsFixed(1)} KB',
|
||||||
context: context,
|
),
|
||||||
file: file,
|
onTap: () {
|
||||||
); // Apre il viewer
|
Navigator.pop(
|
||||||
},
|
context,
|
||||||
);
|
); // Chiude la scelta
|
||||||
},
|
_openFile(
|
||||||
|
context: context,
|
||||||
|
file: file,
|
||||||
|
); // Apre il viewer
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_shipping_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_shipping_cubit.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
|
import 'package:flux/features/tickets/ui/widgets/quick_provider_dialog.dart';
|
||||||
|
|
||||||
class TicketShippingModal extends StatefulWidget {
|
class TicketShippingModal extends StatefulWidget {
|
||||||
final List<String> ticketIds;
|
final List<String> ticketIds;
|
||||||
@@ -24,18 +25,18 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Material(
|
||||||
padding: EdgeInsets.only(
|
color: Theme.of(context).colorScheme.surface,
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom + 24,
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
|
||||||
top: 24,
|
clipBehavior: Clip.antiAlias,
|
||||||
left: 24,
|
child: Padding(
|
||||||
right: 24,
|
padding: EdgeInsets.only(
|
||||||
),
|
bottom: MediaQuery.of(context).viewInsets.bottom + 24,
|
||||||
decoration: BoxDecoration(
|
top: 24,
|
||||||
color: Theme.of(context).colorScheme.surface,
|
left: 24,
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
|
right: 24,
|
||||||
),
|
),
|
||||||
child: BlocConsumer<TicketShippingCubit, TicketShippingState>(
|
child: BlocConsumer<TicketShippingCubit, TicketShippingState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state.status == TicketShippingStatus.success) {
|
if (state.status == TicketShippingStatus.success) {
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
@@ -129,11 +130,12 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -170,21 +172,49 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
TicketShippingState state,
|
TicketShippingState state,
|
||||||
) {
|
) {
|
||||||
return DropdownButtonFormField<String>(
|
return Row(
|
||||||
initialValue: state.document.providerId.isEmpty
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
? null
|
children: [
|
||||||
: state.document.providerId,
|
Expanded(
|
||||||
decoration: const InputDecoration(
|
child: DropdownButtonFormField<String>(
|
||||||
labelText: "Seleziona Centro Riparazioni",
|
key: ValueKey('provider_${state.document.providerId}'),
|
||||||
prefixIcon: Icon(Icons.store),
|
initialValue: state.document.providerId.isEmpty
|
||||||
),
|
? null
|
||||||
items: state.availableProviders
|
: state.document.providerId,
|
||||||
.map((p) => DropdownMenuItem(value: p.id, child: Text(p.name)))
|
decoration: const InputDecoration(
|
||||||
.toList(),
|
labelText: "Seleziona Centro Riparazioni",
|
||||||
onChanged: (val) => val != null
|
prefixIcon: Icon(Icons.store),
|
||||||
? context.read<TicketShippingCubit>().selectProvider(val)
|
),
|
||||||
: null,
|
items: state.availableProviders
|
||||||
validator: (v) => v == null || v.isEmpty ? 'Campo obbligatorio' : null,
|
.map((p) => DropdownMenuItem(value: p.id, child: Text(p.name)))
|
||||||
|
.toList(),
|
||||||
|
onChanged: (val) => val != null
|
||||||
|
? context.read<TicketShippingCubit>().selectProvider(val)
|
||||||
|
: null,
|
||||||
|
validator: (v) => v == null || v.isEmpty ? 'Campo obbligatorio' : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4.0),
|
||||||
|
child: IconButton.filledTonal(
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
tooltip: "Aggiungi nuovo centro riparazioni",
|
||||||
|
onPressed: () async {
|
||||||
|
final data = await QuickProviderDialog.show(context);
|
||||||
|
if (data != null && context.mounted) {
|
||||||
|
context.read<TicketShippingCubit>().createQuickProvider(
|
||||||
|
name: data.name,
|
||||||
|
address: data.address,
|
||||||
|
city: data.city,
|
||||||
|
zipCode: data.zipCode,
|
||||||
|
province: data.province,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +223,7 @@ class _TicketShippingModalState extends State<TicketShippingModal> {
|
|||||||
TicketShippingState state,
|
TicketShippingState state,
|
||||||
) {
|
) {
|
||||||
return DropdownButtonFormField<String>(
|
return DropdownButtonFormField<String>(
|
||||||
|
key: ValueKey('location_${state.document.destinationLocationId}'),
|
||||||
initialValue: state.document.destinationLocationId.isEmpty
|
initialValue: state.document.destinationLocationId.isEmpty
|
||||||
? null
|
? null
|
||||||
: state.document.destinationLocationId,
|
: state.document.destinationLocationId,
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class TicketShippingPdfService {
|
|||||||
build: (pw.Context context) {
|
build: (pw.Context context) {
|
||||||
return [
|
return [
|
||||||
pw.TableHelper.fromTextArray(
|
pw.TableHelper.fromTextArray(
|
||||||
headers: ['Rif. Ticket', 'Modello', 'Difetto / Note', 'Q.tà'],
|
headers: ['Prodotto', 'Difetto', 'Q.tà'],
|
||||||
headerStyle: pw.TextStyle(
|
headerStyle: pw.TextStyle(
|
||||||
fontWeight: pw.FontWeight.bold,
|
fontWeight: pw.FontWeight.bold,
|
||||||
color: PdfColors.white,
|
color: PdfColors.white,
|
||||||
@@ -134,12 +134,24 @@ class TicketShippingPdfService {
|
|||||||
headerDecoration: const pw.BoxDecoration(
|
headerDecoration: const pw.BoxDecoration(
|
||||||
color: PdfColors.blueGrey800,
|
color: PdfColors.blueGrey800,
|
||||||
),
|
),
|
||||||
cellAlignment: pw.Alignment.centerLeft,
|
columnWidths: {
|
||||||
|
0: const pw.FlexColumnWidth(3),
|
||||||
|
1: const pw.FlexColumnWidth(4),
|
||||||
|
2: const pw.FixedColumnWidth(45),
|
||||||
|
},
|
||||||
|
cellAlignments: {
|
||||||
|
0: pw.Alignment.centerLeft,
|
||||||
|
1: pw.Alignment.centerLeft,
|
||||||
|
2: pw.Alignment.center,
|
||||||
|
},
|
||||||
|
headerAlignments: {
|
||||||
|
0: pw.Alignment.centerLeft,
|
||||||
|
1: pw.Alignment.centerLeft,
|
||||||
|
2: pw.Alignment.center,
|
||||||
|
},
|
||||||
data: tickets.map((t) {
|
data: tickets.map((t) {
|
||||||
return [
|
return [
|
||||||
t.id?.substring(0, 8).toUpperCase() ??
|
'${t.targetModelName ?? 'Modello sconosciuto'} - Rif. Ticket ${t.referenceId ?? 'Sconosciuto'}',
|
||||||
'-', // Magari hai un ID progressivo migliore
|
|
||||||
t.targetModelName ?? 'Sconosciuto',
|
|
||||||
t.request,
|
t.request,
|
||||||
'1', // Tipicamente 1 per ogni ticket
|
'1', // Tipicamente 1 per ogni ticket
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in new issue
Block a user