|
@@ -7,6 +7,7 @@ import '../../widgets/cod_desc_dropdown_item.dart';
|
|
|
import '../../../providers/order_provider.dart';
|
|
import '../../../providers/order_provider.dart';
|
|
|
import '../../../providers/database_provider.dart';
|
|
import '../../../providers/database_provider.dart';
|
|
|
import '../../../database/database.dart';
|
|
import '../../../database/database.dart';
|
|
|
|
|
+import '../../../core/constants.dart';
|
|
|
import 'selezione_cliente_page.dart';
|
|
import 'selezione_cliente_page.dart';
|
|
|
import 'selezione_articolo_page.dart';
|
|
import 'selezione_articolo_page.dart';
|
|
|
|
|
|
|
@@ -37,6 +38,7 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
int? _selectedPagamento;
|
|
int? _selectedPagamento;
|
|
|
|
|
|
|
|
bool _dataLoaded = false;
|
|
bool _dataLoaded = false;
|
|
|
|
|
+ bool _readOnly = false;
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
@@ -73,6 +75,10 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
final order = orderState.order;
|
|
final order = orderState.order;
|
|
|
if (order == null) return;
|
|
if (order == null) return;
|
|
|
|
|
|
|
|
|
|
+ if (widget.id != null && order.stato != AppConstants.kStatusNew) {
|
|
|
|
|
+ _readOnly = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
final cli = order.idCliente;
|
|
final cli = order.idCliente;
|
|
|
final clientiDao = ref.read(clientiDaoProvider);
|
|
final clientiDao = ref.read(clientiDaoProvider);
|
|
|
final filialiDao = ref.read(filialiDaoProvider);
|
|
final filialiDao = ref.read(filialiDaoProvider);
|
|
@@ -212,12 +218,15 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
|
|
|
|
|
return Scaffold(
|
|
return Scaffold(
|
|
|
appBar: AppBar(
|
|
appBar: AppBar(
|
|
|
- title: Text('Ordine #${orderState.order?.numeroOrdine ?? 'nuovo'}'),
|
|
|
|
|
|
|
+ title: Text(_readOnly
|
|
|
|
|
+ ? 'Ordine #${orderState.order?.numeroOrdine} - Trasmesso'
|
|
|
|
|
+ : 'Ordine #${orderState.order?.numeroOrdine ?? 'nuovo'}'),
|
|
|
actions: [
|
|
actions: [
|
|
|
- IconButton(
|
|
|
|
|
- icon: const Icon(Icons.save),
|
|
|
|
|
- onPressed: _salva,
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ if (!_readOnly)
|
|
|
|
|
+ IconButton(
|
|
|
|
|
+ icon: const Icon(Icons.save),
|
|
|
|
|
+ onPressed: _salva,
|
|
|
|
|
+ ),
|
|
|
],
|
|
],
|
|
|
bottom: TabBar(
|
|
bottom: TabBar(
|
|
|
controller: _tabController,
|
|
controller: _tabController,
|
|
@@ -238,12 +247,13 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
- floatingActionButton: _tabController.index == 1 && _cliente != null
|
|
|
|
|
- ? FloatingActionButton(
|
|
|
|
|
- onPressed: _aggiungiArticolo,
|
|
|
|
|
- child: const Icon(Icons.add),
|
|
|
|
|
- )
|
|
|
|
|
- : null,
|
|
|
|
|
|
|
+ floatingActionButton:
|
|
|
|
|
+ _tabController.index == 1 && _cliente != null && !_readOnly
|
|
|
|
|
+ ? FloatingActionButton(
|
|
|
|
|
+ onPressed: _aggiungiArticolo,
|
|
|
|
|
+ child: const Icon(Icons.add),
|
|
|
|
|
+ )
|
|
|
|
|
+ : null,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -327,10 +337,11 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
- IconButton(
|
|
|
|
|
- icon: Icon(Icons.search, color: cs.primary),
|
|
|
|
|
- onPressed: _selezionaCliente,
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ if (!_readOnly)
|
|
|
|
|
+ IconButton(
|
|
|
|
|
+ icon: Icon(Icons.search, color: cs.primary),
|
|
|
|
|
+ onPressed: _selezionaCliente,
|
|
|
|
|
+ ),
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
@@ -350,7 +361,8 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
.toList(),
|
|
.toList(),
|
|
|
- onChanged: (v) => setState(() => _selectedFiliale = v),
|
|
|
|
|
|
|
+ onChanged:
|
|
|
|
|
+ _readOnly ? null : (v) => setState(() => _selectedFiliale = v),
|
|
|
),
|
|
),
|
|
|
const SizedBox(height: 16),
|
|
const SizedBox(height: 16),
|
|
|
DropdownButtonFormField<int>(
|
|
DropdownButtonFormField<int>(
|
|
@@ -367,7 +379,8 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
.toList(),
|
|
.toList(),
|
|
|
- onChanged: (v) => setState(() => _selectedListino = v),
|
|
|
|
|
|
|
+ onChanged:
|
|
|
|
|
+ _readOnly ? null : (v) => setState(() => _selectedListino = v),
|
|
|
),
|
|
),
|
|
|
const SizedBox(height: 16),
|
|
const SizedBox(height: 16),
|
|
|
DropdownButtonFormField<int>(
|
|
DropdownButtonFormField<int>(
|
|
@@ -384,11 +397,14 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
.toList(),
|
|
.toList(),
|
|
|
- onChanged: (v) => setState(() => _selectedPagamento = v),
|
|
|
|
|
|
|
+ onChanged: _readOnly
|
|
|
|
|
+ ? null
|
|
|
|
|
+ : (v) => setState(() => _selectedPagamento = v),
|
|
|
),
|
|
),
|
|
|
const SizedBox(height: 16),
|
|
const SizedBox(height: 16),
|
|
|
TextFormField(
|
|
TextFormField(
|
|
|
controller: _noteClienteCtrl,
|
|
controller: _noteClienteCtrl,
|
|
|
|
|
+ enabled: !_readOnly,
|
|
|
decoration: const InputDecoration(
|
|
decoration: const InputDecoration(
|
|
|
labelText: 'Note Cliente',
|
|
labelText: 'Note Cliente',
|
|
|
alignLabelWithHint: true,
|
|
alignLabelWithHint: true,
|
|
@@ -398,6 +414,7 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
const SizedBox(height: 16),
|
|
const SizedBox(height: 16),
|
|
|
TextFormField(
|
|
TextFormField(
|
|
|
controller: _noteOrdineCtrl,
|
|
controller: _noteOrdineCtrl,
|
|
|
|
|
+ enabled: !_readOnly,
|
|
|
decoration: const InputDecoration(
|
|
decoration: const InputDecoration(
|
|
|
labelText: 'Note Ordine',
|
|
labelText: 'Note Ordine',
|
|
|
alignLabelWithHint: true,
|
|
alignLabelWithHint: true,
|
|
@@ -407,6 +424,7 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
const SizedBox(height: 16),
|
|
const SizedBox(height: 16),
|
|
|
TextFormField(
|
|
TextFormField(
|
|
|
controller: _riferimentoCtrl,
|
|
controller: _riferimentoCtrl,
|
|
|
|
|
+ enabled: !_readOnly,
|
|
|
decoration: const InputDecoration(labelText: 'Riferimento'),
|
|
decoration: const InputDecoration(labelText: 'Riferimento'),
|
|
|
maxLines: 1,
|
|
maxLines: 1,
|
|
|
),
|
|
),
|
|
@@ -425,6 +443,7 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
itemCount: orderState.lines.length,
|
|
itemCount: orderState.lines.length,
|
|
|
itemBuilder: (_, i) => _LineCard(
|
|
itemBuilder: (_, i) => _LineCard(
|
|
|
line: orderState.lines[i],
|
|
line: orderState.lines[i],
|
|
|
|
|
+ readOnly: _readOnly,
|
|
|
onDelete: () =>
|
|
onDelete: () =>
|
|
|
ref.read(orderProvider.notifier).removeLine(i),
|
|
ref.read(orderProvider.notifier).removeLine(i),
|
|
|
theme: theme,
|
|
theme: theme,
|
|
@@ -457,11 +476,13 @@ class _OrderEditPageState extends ConsumerState<OrderEditPage>
|
|
|
|
|
|
|
|
class _LineCard extends StatelessWidget {
|
|
class _LineCard extends StatelessWidget {
|
|
|
final RigaOrdine line;
|
|
final RigaOrdine line;
|
|
|
|
|
+ final bool readOnly;
|
|
|
final VoidCallback onDelete;
|
|
final VoidCallback onDelete;
|
|
|
final ThemeData theme;
|
|
final ThemeData theme;
|
|
|
|
|
|
|
|
const _LineCard({
|
|
const _LineCard({
|
|
|
required this.line,
|
|
required this.line,
|
|
|
|
|
+ required this.readOnly,
|
|
|
required this.onDelete,
|
|
required this.onDelete,
|
|
|
required this.theme,
|
|
required this.theme,
|
|
|
});
|
|
});
|
|
@@ -495,7 +516,7 @@ class _LineCard extends StatelessWidget {
|
|
|
style: TextStyle(color: Colors.white, fontSize: 10),
|
|
style: TextStyle(color: Colors.white, fontSize: 10),
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
- if (!isPromo)
|
|
|
|
|
|
|
+ if (!isPromo && !readOnly)
|
|
|
IconButton(
|
|
IconButton(
|
|
|
icon: const Icon(Icons.delete_outline, size: 20),
|
|
icon: const Icon(Icons.delete_outline, size: 20),
|
|
|
onPressed: onDelete,
|
|
onPressed: onDelete,
|