d
This commit is contained in:
@@ -29,14 +29,12 @@ import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
|||||||
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
||||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||||
import 'package:flux/features/operations/blocs/operation_form_cubit.dart';
|
import 'package:flux/features/operations/blocs/operation_form_cubit.dart';
|
||||||
import 'package:flux/features/operations/blocs/operation_list_cubit.dart';
|
|
||||||
import 'package:flux/features/operations/models/operation_model.dart';
|
import 'package:flux/features/operations/models/operation_model.dart';
|
||||||
import 'package:flux/features/operations/ui/operation_form_screen.dart';
|
import 'package:flux/features/operations/ui/operation_form_screen.dart';
|
||||||
import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
||||||
import 'package:flux/features/settings/settings_screen.dart';
|
import 'package:flux/features/settings/settings_screen.dart';
|
||||||
import 'package:flux/features/settings/theme_settings_view.dart';
|
import 'package:flux/features/settings/theme_settings_view.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_list_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/ticket_form_screen.dart';
|
import 'package:flux/features/tickets/ui/ticket_form_screen.dart';
|
||||||
import 'package:flux/features/tickets/ui/ticket_list_screen.dart';
|
import 'package:flux/features/tickets/ui/ticket_list_screen.dart';
|
||||||
@@ -182,10 +180,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/operations',
|
path: '/operations',
|
||||||
name: Routes.operations,
|
name: Routes.operations,
|
||||||
builder: (context, state) => BlocProvider(
|
builder: (context, state) => const OperationListScreen(),
|
||||||
create: (context) => OperationListCubit(),
|
|
||||||
child: const OperationListScreen(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/customers',
|
path: '/customers',
|
||||||
@@ -196,10 +191,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/tickets',
|
path: '/tickets',
|
||||||
name: Routes.tickets,
|
name: Routes.tickets,
|
||||||
builder: (context, state) => BlocProvider(
|
builder: (context, state) => const TicketListScreen(),
|
||||||
create: (context) => TicketListCubit(),
|
|
||||||
child: const TicketListScreen(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -125,7 +125,9 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
TicketStatus? status,
|
TicketStatus? status,
|
||||||
String? request,
|
String? request,
|
||||||
String? targetSn,
|
String? targetSn,
|
||||||
|
String? targetPassword,
|
||||||
String? sourceSn,
|
String? sourceSn,
|
||||||
|
String? sourcePassword,
|
||||||
String? alternativePhoneNumber,
|
String? alternativePhoneNumber,
|
||||||
bool? hasCourtesyDevice,
|
bool? hasCourtesyDevice,
|
||||||
String? includedAccessories,
|
String? includedAccessories,
|
||||||
@@ -135,6 +137,7 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
double? internalCost,
|
double? internalCost,
|
||||||
String? assignedToId,
|
String? assignedToId,
|
||||||
String? assignedToName,
|
String? assignedToName,
|
||||||
|
WarrantyType? warrantyType,
|
||||||
}) {
|
}) {
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
@@ -143,6 +146,8 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
ticketStatus: status ?? state.ticket.ticketStatus,
|
ticketStatus: status ?? state.ticket.ticketStatus,
|
||||||
request: request ?? state.ticket.request,
|
request: request ?? state.ticket.request,
|
||||||
targetSn: targetSn ?? state.ticket.targetSn,
|
targetSn: targetSn ?? state.ticket.targetSn,
|
||||||
|
targetPassword: targetPassword ?? state.ticket.targetPassword,
|
||||||
|
sourcePassword: sourcePassword ?? state.ticket.sourcePassword,
|
||||||
sourceSn: sourceSn ?? state.ticket.sourceSn,
|
sourceSn: sourceSn ?? state.ticket.sourceSn,
|
||||||
alternativePhoneNumber:
|
alternativePhoneNumber:
|
||||||
alternativePhoneNumber ?? state.ticket.alternativePhoneNumber,
|
alternativePhoneNumber ?? state.ticket.alternativePhoneNumber,
|
||||||
@@ -156,6 +161,7 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
internalCost: internalCost ?? state.ticket.internalCost,
|
internalCost: internalCost ?? state.ticket.internalCost,
|
||||||
assignedToId: assignedToId ?? state.ticket.assignedToId,
|
assignedToId: assignedToId ?? state.ticket.assignedToId,
|
||||||
assignedToName: assignedToName ?? state.ticket.assignedToName,
|
assignedToName: assignedToName ?? state.ticket.assignedToName,
|
||||||
|
warrantyType: warrantyType ?? state.ticket.warrantyType,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -271,4 +277,45 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> pauseTicket({
|
||||||
|
required TicketStatus newStatus,
|
||||||
|
required String notes,
|
||||||
|
}) async {
|
||||||
|
final currentTicket = state.ticket;
|
||||||
|
if (currentTicket.id == null || currentTicket.id!.isEmpty) return;
|
||||||
|
|
||||||
|
// 1. Usiamo lo stato esatto scelto dal tecnico
|
||||||
|
final updatedTicket = currentTicket.copyWith(ticketStatus: newStatus);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await _repository.updateTicket(updatedTicket);
|
||||||
|
|
||||||
|
// 2. Componiamo un bel messaggio per la Timeline
|
||||||
|
// Es: "Sospeso per: waitingForQuote. Note: Cliente in ferie"
|
||||||
|
String timelineMessage = "Lavorazione sospesa (${newStatus.name}).";
|
||||||
|
if (notes.isNotEmpty) {
|
||||||
|
timelineMessage += " Note: $notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
await GetIt.I.get<TrackingRepository>().logQuickEvent(
|
||||||
|
companyId: currentTicket.companyId,
|
||||||
|
message: timelineMessage,
|
||||||
|
type: TrackingType.statusChange,
|
||||||
|
parentId: currentTicket.id!,
|
||||||
|
parentType: TrackingParentType.ticket,
|
||||||
|
staffId: currentTicket.assignedToId ?? '',
|
||||||
|
isInternal: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
emit(state.copyWith(ticket: updatedTicket));
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
status: TicketFormStatus.failure,
|
||||||
|
errorMessage: 'Errore durante la sospensione: $e',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ enum TicketStatus {
|
|||||||
ready('ready', 'Pronto'),
|
ready('ready', 'Pronto'),
|
||||||
closed('closed', 'Chiuso'),
|
closed('closed', 'Chiuso'),
|
||||||
waitingForShipping('waiting_for_shipping', 'In attesa di spedire'),
|
waitingForShipping('waiting_for_shipping', 'In attesa di spedire'),
|
||||||
waitingForReturn('waiting_for_return', 'In attesa di ritorno');
|
waitingForReturn('waiting_for_return', 'In attesa di ritorno'),
|
||||||
|
waitingForQuote('waiting_for_quote', 'In attesa di preventivo'),
|
||||||
|
waitingForCustomer('waiting_for_customer', 'In attesa del cliente');
|
||||||
|
|
||||||
final String value;
|
final String value;
|
||||||
final String displayValue;
|
final String displayValue;
|
||||||
@@ -294,9 +296,9 @@ class TicketModel extends Equatable {
|
|||||||
sourceModelName: (map['source_model']?['name_with_brand'] as String?)
|
sourceModelName: (map['source_model']?['name_with_brand'] as String?)
|
||||||
?.myFormat(),
|
?.myFormat(),
|
||||||
createdById: map['staff_id'] as String?,
|
createdById: map['staff_id'] as String?,
|
||||||
createdByName: (map['staff']?['name'] as String?).myFormat(),
|
createdByName: (map['created_by']?['name'] as String?)?.myFormat(),
|
||||||
assignedToId: map['assigned_to_id'] as String?,
|
assignedToId: map['assigned_to_id'] as String?,
|
||||||
assignedToName: (map['assigned_to']?['name'] as String?).myFormat(),
|
assignedToName: (map['assigned_to']?['name'] as String?)?.myFormat(),
|
||||||
includedAccessories: map['included_accessories'] as String?,
|
includedAccessories: map['included_accessories'] as String?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -322,7 +324,7 @@ class TicketModel extends Equatable {
|
|||||||
'returned_at': returnedAt!.toUtc().toIso8601String(),
|
'returned_at': returnedAt!.toUtc().toIso8601String(),
|
||||||
'request': request,
|
'request': request,
|
||||||
'created_by_id': createdById,
|
'created_by_id': createdById,
|
||||||
'warranty_type': warrantyType,
|
'warranty_type': warrantyType?.value ?? WarrantyType.noWarranty.value,
|
||||||
'public_notes': publicNotes,
|
'public_notes': publicNotes,
|
||||||
'internal_notes': internalNotes,
|
'internal_notes': internalNotes,
|
||||||
'reference_id': referenceId,
|
'reference_id': referenceId,
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ extension TicketStatusVisuals on TicketStatus {
|
|||||||
switch (this) {
|
switch (this) {
|
||||||
case TicketStatus.open:
|
case TicketStatus.open:
|
||||||
return Colors.blueGrey;
|
return Colors.blueGrey;
|
||||||
case TicketStatus.waitingForParts:
|
case TicketStatus.waitingForParts ||
|
||||||
|
TicketStatus.waitingForQuote ||
|
||||||
|
TicketStatus.waitingForCustomer:
|
||||||
return Colors.amber.shade700;
|
return Colors.amber.shade700;
|
||||||
case TicketStatus.inProgress:
|
case TicketStatus.inProgress:
|
||||||
return Colors.blue;
|
return Colors.blue;
|
||||||
@@ -26,7 +28,9 @@ extension TicketStatusVisuals on TicketStatus {
|
|||||||
switch (this) {
|
switch (this) {
|
||||||
case TicketStatus.open:
|
case TicketStatus.open:
|
||||||
return Icons.inbox;
|
return Icons.inbox;
|
||||||
case TicketStatus.waitingForParts:
|
case TicketStatus.waitingForParts ||
|
||||||
|
TicketStatus.waitingForQuote ||
|
||||||
|
TicketStatus.waitingForCustomer:
|
||||||
return Icons.hourglass_empty;
|
return Icons.hourglass_empty;
|
||||||
case TicketStatus.inProgress:
|
case TicketStatus.inProgress:
|
||||||
return Icons.build;
|
return Icons.build;
|
||||||
|
|||||||
@@ -6,15 +6,18 @@ import 'package:flux/core/blocs/session/session_cubit.dart';
|
|||||||
import 'package:flux/core/widgets/shared_forms/customer_section.dart';
|
import 'package:flux/core/widgets/shared_forms/customer_section.dart';
|
||||||
import 'package:flux/core/widgets/shared_forms/model_section.dart';
|
import 'package:flux/core/widgets/shared_forms/model_section.dart';
|
||||||
import 'package:flux/core/widgets/shared_forms/shared_files_section.dart';
|
import 'package:flux/core/widgets/shared_forms/shared_files_section.dart';
|
||||||
|
import 'package:flux/core/widgets/staff_selector_modal.dart';
|
||||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||||
import 'package:flux/features/company/models/company_model.dart';
|
import 'package:flux/features/company/models/company_model.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_form_state.dart';
|
import 'package:flux/features/tickets/blocs/ticket_form_state.dart';
|
||||||
|
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
import 'package:flux/core/widgets/shared_forms/staff_section.dart';
|
import 'package:flux/core/widgets/shared_forms/staff_section.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
||||||
import 'package:flux/features/tickets/ui/ticket_timeline_section.dart';
|
import 'package:flux/features/tickets/ui/ticket_timeline_section.dart';
|
||||||
import 'package:flux/features/tickets/ui/ticket_workspace_screen.dart';
|
import 'package:flux/features/tickets/ui/ticket_workspace/ticket_workspace_screen.dart';
|
||||||
import 'package:flux/features/tickets/utils/ticket_pdf_service.dart';
|
import 'package:flux/features/tickets/utils/ticket_pdf_service.dart';
|
||||||
import 'package:flux/features/tracking/blocs/tracking_cubit.dart';
|
import 'package:flux/features/tracking/blocs/tracking_cubit.dart';
|
||||||
import 'package:flux/features/tracking/models/tracking_model.dart';
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
@@ -36,7 +39,9 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
|
|
||||||
final _altPhoneCtrl = TextEditingController();
|
final _altPhoneCtrl = TextEditingController();
|
||||||
final _targetSerialCtrl = TextEditingController();
|
final _targetSerialCtrl = TextEditingController();
|
||||||
|
final _targetPasswordCtrl = TextEditingController();
|
||||||
final _sourceSerialCtrl = TextEditingController();
|
final _sourceSerialCtrl = TextEditingController();
|
||||||
|
final _sourcePasswordCtrl = TextEditingController();
|
||||||
final _requestCtrl = TextEditingController();
|
final _requestCtrl = TextEditingController();
|
||||||
final _accessoriesCtrl = TextEditingController();
|
final _accessoriesCtrl = TextEditingController();
|
||||||
final _publicNotesCtrl = TextEditingController();
|
final _publicNotesCtrl = TextEditingController();
|
||||||
@@ -59,6 +64,8 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_altPhoneCtrl.dispose();
|
_altPhoneCtrl.dispose();
|
||||||
_targetSerialCtrl.dispose();
|
_targetSerialCtrl.dispose();
|
||||||
|
_targetPasswordCtrl.dispose();
|
||||||
|
_sourcePasswordCtrl.dispose();
|
||||||
_sourceSerialCtrl.dispose();
|
_sourceSerialCtrl.dispose();
|
||||||
_requestCtrl.dispose();
|
_requestCtrl.dispose();
|
||||||
_accessoriesCtrl.dispose();
|
_accessoriesCtrl.dispose();
|
||||||
@@ -76,9 +83,15 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
if (_targetSerialCtrl.text.isEmpty) {
|
if (_targetSerialCtrl.text.isEmpty) {
|
||||||
_targetSerialCtrl.text = model.targetSn ?? '';
|
_targetSerialCtrl.text = model.targetSn ?? '';
|
||||||
}
|
}
|
||||||
|
if (_targetPasswordCtrl.text.isEmpty) {
|
||||||
|
_targetPasswordCtrl.text = model.targetPassword ?? '';
|
||||||
|
}
|
||||||
if (_sourceSerialCtrl.text.isEmpty) {
|
if (_sourceSerialCtrl.text.isEmpty) {
|
||||||
_sourceSerialCtrl.text = model.sourceSn ?? '';
|
_sourceSerialCtrl.text = model.sourceSn ?? '';
|
||||||
}
|
}
|
||||||
|
if (_sourcePasswordCtrl.text.isEmpty) {
|
||||||
|
_sourcePasswordCtrl.text = model.sourcePassword ?? '';
|
||||||
|
}
|
||||||
if (_requestCtrl.text.isEmpty) _requestCtrl.text = model.request;
|
if (_requestCtrl.text.isEmpty) _requestCtrl.text = model.request;
|
||||||
if (_accessoriesCtrl.text.isEmpty) {
|
if (_accessoriesCtrl.text.isEmpty) {
|
||||||
_accessoriesCtrl.text = model.includedAccessories ?? '';
|
_accessoriesCtrl.text = model.includedAccessories ?? '';
|
||||||
@@ -102,6 +115,8 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
context.read<TicketFormCubit>().updateFields(
|
context.read<TicketFormCubit>().updateFields(
|
||||||
alternativePhoneNumber: _altPhoneCtrl.text,
|
alternativePhoneNumber: _altPhoneCtrl.text,
|
||||||
targetSn: _targetSerialCtrl.text,
|
targetSn: _targetSerialCtrl.text,
|
||||||
|
targetPassword: _targetPasswordCtrl.text,
|
||||||
|
sourcePassword: _sourcePasswordCtrl.text,
|
||||||
sourceSn: _sourceSerialCtrl.text,
|
sourceSn: _sourceSerialCtrl.text,
|
||||||
request: _requestCtrl.text,
|
request: _requestCtrl.text,
|
||||||
includedAccessories: _accessoriesCtrl.text,
|
includedAccessories: _accessoriesCtrl.text,
|
||||||
@@ -275,6 +290,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.status == TicketFormStatus.success) {
|
if (state.status == TicketFormStatus.success) {
|
||||||
|
context.read<TicketListCubit>().fetchTickets();
|
||||||
_showSuccessActions(
|
_showSuccessActions(
|
||||||
context,
|
context,
|
||||||
state.ticket,
|
state.ticket,
|
||||||
@@ -313,7 +329,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
|
|
||||||
// CONDIZIONE A: Da iniziare
|
// CONDIZIONE A: Da iniziare
|
||||||
if (ticket.ticketStatus == TicketStatus.open ||
|
if (ticket.ticketStatus == TicketStatus.open ||
|
||||||
ticket.ticketStatus == TicketStatus.inProgress) {
|
ticket.ticketStatus == TicketStatus.waitingForParts) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16.0,
|
horizontal: 16.0,
|
||||||
@@ -324,28 +340,27 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
backgroundColor:
|
backgroundColor:
|
||||||
Colors.amber.shade700, // Colore Action
|
Colors.amber.shade700, // Colore Action
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
final currentUserId = GetIt.I
|
StaffMemberModel? takenBy = await getStaffMember(
|
||||||
.get<SessionCubit>()
|
context,
|
||||||
.state
|
|
||||||
.currentStaffMember!
|
|
||||||
.id!;
|
|
||||||
final currentUserName = GetIt.I
|
|
||||||
.get<SessionCubit>()
|
|
||||||
.state
|
|
||||||
.currentStaffMember!
|
|
||||||
.name;
|
|
||||||
|
|
||||||
context.read<TicketFormCubit>().takeInCharge(
|
|
||||||
staffId: currentUserId,
|
|
||||||
staffName: currentUserName,
|
|
||||||
);
|
);
|
||||||
|
if (takenBy == null || !context.mounted) return;
|
||||||
|
final formCubit = context.read<TicketFormCubit>();
|
||||||
|
_flushControllersToCubit();
|
||||||
|
context.read<TicketFormCubit>().takeInCharge(
|
||||||
|
staffId: takenBy.id!,
|
||||||
|
staffName: takenBy.name,
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) =>
|
builder: (_) => BlocProvider.value(
|
||||||
TicketWorkspaceScreen(ticket: ticket),
|
value:
|
||||||
|
formCubit, // Magia! La nuova schermata userà lo stesso Cubit!
|
||||||
|
child:
|
||||||
|
const TicketWorkspaceScreen(), // Non passiamo più il ticket
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -366,8 +381,21 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
),
|
),
|
||||||
child: FilledButton.icon(
|
child: FilledButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
final formCubit = context.read<TicketFormCubit>();
|
||||||
// Naviga direttamente alla schermata di lavorazione
|
// Naviga direttamente alla schermata di lavorazione
|
||||||
// Navigator.push(context, MaterialPageRoute(builder: (_) => TicketWorkspaceScreen(ticket: ticket)));
|
_flushControllersToCubit();
|
||||||
|
if (!context.mounted) return;
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => BlocProvider.value(
|
||||||
|
value:
|
||||||
|
formCubit, // Magia! La nuova schermata userà lo stesso Cubit!
|
||||||
|
child:
|
||||||
|
const TicketWorkspaceScreen(), // Non passiamo più il ticket
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.handyman),
|
icon: const Icon(Icons.handyman),
|
||||||
label: const Text('Vai a Lavorazione'),
|
label: const Text('Vai a Lavorazione'),
|
||||||
@@ -614,6 +642,14 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
prefixIcon: Icon(Icons.qr_code),
|
prefixIcon: Icon(Icons.qr_code),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _targetPasswordCtrl, // Controller per il seriale TARGET
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'PIN / Password',
|
||||||
|
prefixIcon: Icon(Icons.qr_code),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// --- DISPOSITIVO SORGENTE (Animato per Passaggio Dati) ---
|
// --- DISPOSITIVO SORGENTE (Animato per Passaggio Dati) ---
|
||||||
AnimatedSize(
|
AnimatedSize(
|
||||||
@@ -704,6 +740,38 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _sourcePasswordCtrl,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'PIN / Password Sorgente',
|
||||||
|
prefixIcon: Icon(
|
||||||
|
Icons.qr_code,
|
||||||
|
color: Colors.orange.shade700.withValues(
|
||||||
|
alpha: 0.7,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Usiamo lo stesso riempimento tenue per coerenza
|
||||||
|
fillColor: Colors.white.withValues(alpha: 0.1),
|
||||||
|
filled: true,
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange.shade300.withValues(
|
||||||
|
alpha: 0.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange.shade500.withValues(
|
||||||
|
alpha: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -755,6 +823,26 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
if (ticket.ticketType == TicketType.repair) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
DropdownButtonFormField<WarrantyType>(
|
||||||
|
initialValue: ticket
|
||||||
|
.warrantyType, // Assicurati di avere questo campo nel TicketModel
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Tipo Garanzia',
|
||||||
|
prefixIcon: Icon(Icons.verified_user_outlined),
|
||||||
|
),
|
||||||
|
items: WarrantyType.values
|
||||||
|
.map(
|
||||||
|
(w) =>
|
||||||
|
DropdownMenuItem(value: w, child: Text(w.displayValue)),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
onChanged: (val) {
|
||||||
|
context.read<TicketFormCubit>().updateFields(warrantyType: val);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _requestCtrl,
|
controller: _requestCtrl,
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
|
|
||||||
|
Future<({TicketStatus status, String reason})?> showPauseTicketDialog(
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
return showDialog<({TicketStatus status, String reason})>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => const PauseTicketDialog(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class PauseTicketDialog extends StatefulWidget {
|
||||||
|
const PauseTicketDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PauseTicketDialog> createState() => _PauseTicketDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PauseTicketDialogState extends State<PauseTicketDialog> {
|
||||||
|
final _reasonCtrl = TextEditingController();
|
||||||
|
// Partiamo con un default sensato
|
||||||
|
TicketStatus _selectedStatus = TicketStatus.waitingForParts;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_reasonCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.pause_circle_outline, color: Colors.orange),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text('Sospendi Lavorazione'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
// Un po' di larghezza per i chips
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Seleziona il motivo della sospensione:'),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// --- SCELTA DELLO STATO (CHIPS) ---
|
||||||
|
Wrap(
|
||||||
|
spacing: 8.0,
|
||||||
|
runSpacing: 8.0,
|
||||||
|
children: [
|
||||||
|
ChoiceChip(
|
||||||
|
label: const Text('Attesa Ricambi'),
|
||||||
|
selected: _selectedStatus == TicketStatus.waitingForParts,
|
||||||
|
onSelected: (bool selected) {
|
||||||
|
if (selected) {
|
||||||
|
setState(
|
||||||
|
() => _selectedStatus = TicketStatus.waitingForParts,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ChoiceChip(
|
||||||
|
label: const Text('Attesa Preventivo'),
|
||||||
|
selected: _selectedStatus == TicketStatus.waitingForQuote,
|
||||||
|
onSelected: (bool selected) {
|
||||||
|
if (selected) {
|
||||||
|
setState(
|
||||||
|
() => _selectedStatus = TicketStatus.waitingForQuote,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ChoiceChip(
|
||||||
|
label: const Text('Attesa Cliente'),
|
||||||
|
selected: _selectedStatus == TicketStatus.waitingForCustomer,
|
||||||
|
onSelected: (bool selected) {
|
||||||
|
if (selected) {
|
||||||
|
setState(
|
||||||
|
() => _selectedStatus = TicketStatus.waitingForCustomer,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
const Text(
|
||||||
|
'Note aggiuntive (opzionali):',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
|
// --- NOTE AGGIUNTIVE ---
|
||||||
|
TextField(
|
||||||
|
controller: _reasonCtrl,
|
||||||
|
maxLines: 2,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Es: Il fornitore consegna martedì...',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.of(context).pop(), // Ritorna null (Annulla)
|
||||||
|
child: const Text('Annulla'),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: Colors.orange.shade700,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// RITORNIAMO IL RECORD CON STATO E NOTE!
|
||||||
|
Navigator.of(
|
||||||
|
context,
|
||||||
|
).pop((status: _selectedStatus, reason: _reasonCtrl.text.trim()));
|
||||||
|
},
|
||||||
|
child: const Text('Conferma Pausa'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||||
|
import 'package:flux/features/tickets/blocs/ticket_form_state.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/ticket_workspace/pause_ticket_dialog.dart';
|
||||||
|
|
||||||
class TicketWorkspaceScreen extends StatelessWidget {
|
class TicketWorkspaceScreen extends StatelessWidget {
|
||||||
final TicketModel ticket; // Sostituisci con TicketModel
|
const TicketWorkspaceScreen({super.key});
|
||||||
|
|
||||||
const TicketWorkspaceScreen({super.key, required this.ticket});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -13,29 +15,37 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Banco di Lavoro'),
|
title: const Text('Banco di Lavoro'),
|
||||||
backgroundColor: theme.colorScheme.inversePrimary,
|
//backgroundColor: theme.colorScheme.inversePrimary,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
// SafeArea in basso per ospitare i bottoni fissi
|
// SafeArea in basso per ospitare i bottoni fissi
|
||||||
bottomNavigationBar: SafeArea(child: _buildBottomActions(context)),
|
bottomNavigationBar: SafeArea(child: _buildBottomActions(context)),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(24.0),
|
padding: const EdgeInsets.all(24.0),
|
||||||
child: Column(
|
child: BlocBuilder<TicketFormCubit, TicketFormState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
_buildDeviceHeader(theme),
|
_buildDeviceHeader(theme, state.ticket),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
_buildDefectRecap(theme),
|
_buildDefectRecap(theme, state.ticket),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
_buildOperationsSection(theme),
|
_buildOperationsSection(theme, state.ticket),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 1. HEADER DISPOSITIVO E PASSWORD ---
|
// --- 1. HEADER DISPOSITIVO E PASSWORD ---
|
||||||
Widget _buildDeviceHeader(ThemeData theme) {
|
Widget _buildDeviceHeader(ThemeData theme, TicketModel ticket) {
|
||||||
|
bool hasTargetPw =
|
||||||
|
((ticket.targetPassword != null && ticket.targetPassword!.isNotEmpty));
|
||||||
|
bool hasSourcePw =
|
||||||
|
((ticket.sourcePassword != null && ticket.sourcePassword!.isNotEmpty));
|
||||||
return Card(
|
return Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
color: theme.colorScheme.primaryContainer.withValues(alpha: 0.4),
|
color: theme.colorScheme.primaryContainer.withValues(alpha: 0.4),
|
||||||
@@ -75,9 +85,17 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// IL DATO PIÙ CERCATO DAI TECNICI: LA PASSWORD
|
if (hasSourcePw || hasTargetPw) ...[
|
||||||
|
Wrap(
|
||||||
|
spacing: 12,
|
||||||
|
runSpacing: 12,
|
||||||
|
children: [
|
||||||
|
if (hasTargetPw)
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: theme.colorScheme.surface,
|
color: theme.colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@@ -98,6 +116,22 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
letterSpacing: 2,
|
letterSpacing: 2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (hasSourcePw)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: theme.dividerColor),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'PIN / SBLOCCO Source device',
|
'PIN / SBLOCCO Source device',
|
||||||
style: TextStyle(fontSize: 10, color: Colors.grey),
|
style: TextStyle(fontSize: 10, color: Colors.grey),
|
||||||
@@ -116,12 +150,15 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 2. RECAP DIFETTO ---
|
// --- 2. RECAP DIFETTO ---
|
||||||
Widget _buildDefectRecap(ThemeData theme) {
|
Widget _buildDefectRecap(ThemeData theme, TicketModel ticket) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -156,7 +193,7 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- 3. SEZIONE COSTI E RICAMBI (Mockup) ---
|
// --- 3. SEZIONE COSTI E RICAMBI (Mockup) ---
|
||||||
Widget _buildOperationsSection(ThemeData theme) {
|
Widget _buildOperationsSection(ThemeData theme, TicketModel ticket) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -215,26 +252,31 @@ class TicketWorkspaceScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
// Bottone Pausa / Attesa Ricambi
|
// Bottone Pausa
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: OutlinedButton.icon(
|
child: OutlinedButton.icon(
|
||||||
style: OutlinedButton.styleFrom(
|
// ... stile del bottone ...
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
onPressed: () async {
|
||||||
foregroundColor: Colors.orange.shade700,
|
// 1. Apriamo la modale e riceviamo il RECORD
|
||||||
side: BorderSide(color: Colors.orange.shade700),
|
final result = await showPauseTicketDialog(context);
|
||||||
),
|
|
||||||
onPressed: () {
|
// 2. Se l'utente ha confermato...
|
||||||
// TODO: Logica Metti in Pausa
|
if (result != null && context.mounted) {
|
||||||
|
// 3. Lanciamo l'azione passando lo stato esatto e le note
|
||||||
|
await context.read<TicketFormCubit>().pauseTicket(
|
||||||
|
newStatus: result.status,
|
||||||
|
notes: result.reason,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Riportiamo l'utente alla dashboard
|
||||||
|
if (context.mounted) Navigator.of(context).pop();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.pause),
|
icon: const Icon(Icons.pause),
|
||||||
label: const Text(
|
label: const Text('Metti in Pausa'),
|
||||||
'Metti in Pausa',
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
// Bottone Completa
|
// Bottone Completa
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
@@ -11,6 +11,7 @@ import 'package:flux/features/operations/blocs/operation_list_cubit.dart';
|
|||||||
import 'package:flux/features/operations/data/operations_repository.dart';
|
import 'package:flux/features/operations/data/operations_repository.dart';
|
||||||
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
||||||
import 'package:flux/features/settings/document_sequence/data/document_sequence_repository.dart';
|
import 'package:flux/features/settings/document_sequence/data/document_sequence_repository.dart';
|
||||||
|
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||||
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
||||||
import 'package:flux/features/tracking/data/tracking_repository.dart';
|
import 'package:flux/features/tracking/data/tracking_repository.dart';
|
||||||
import 'package:flux/l10n/app_localizations.dart';
|
import 'package:flux/l10n/app_localizations.dart';
|
||||||
@@ -67,6 +68,8 @@ void main() async {
|
|||||||
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
||||||
BlocProvider<ProvidersCubit>(create: (_) => ProvidersCubit()),
|
BlocProvider<ProvidersCubit>(create: (_) => ProvidersCubit()),
|
||||||
BlocProvider<SettingsCubit>(create: (_) => SettingsCubit()),
|
BlocProvider<SettingsCubit>(create: (_) => SettingsCubit()),
|
||||||
|
BlocProvider<TicketListCubit>(create: (_) => TicketListCubit()),
|
||||||
|
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
||||||
],
|
],
|
||||||
child: const FluxApp(),
|
child: const FluxApp(),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user