|
@@ -98,6 +98,8 @@ class _PedidoScreenState extends State<PedidoScreen> {
|
|
final double? columnSpacing = isMobile ? null : 0;
|
|
final double? columnSpacing = isMobile ? null : 0;
|
|
TextStyle estilo = const TextStyle(fontWeight: FontWeight.bold);
|
|
TextStyle estilo = const TextStyle(fontWeight: FontWeight.bold);
|
|
List<DataRow> registros = [];
|
|
List<DataRow> registros = [];
|
|
|
|
+ final permisoViewModel = Provider.of<PermisoViewModel>(context);
|
|
|
|
+ List<String> userPermisos = permisoViewModel.userPermisos;
|
|
for (Pedido item in pvm.pedidos) {
|
|
for (Pedido item in pvm.pedidos) {
|
|
final sincronizadoStatus =
|
|
final sincronizadoStatus =
|
|
item.sincronizado == null || item.sincronizado!.isEmpty
|
|
item.sincronizado == null || item.sincronizado!.isEmpty
|
|
@@ -113,72 +115,74 @@ class _PedidoScreenState extends State<PedidoScreen> {
|
|
child: const Text('Detalle'),
|
|
child: const Text('Detalle'),
|
|
onTap: () => go(item),
|
|
onTap: () => go(item),
|
|
),
|
|
),
|
|
- PopupMenuItem(
|
|
|
|
- child: const Text('Cancelar Pedido'),
|
|
|
|
- onTap: () async {
|
|
|
|
- bool confirmado = await showDialog<bool>(
|
|
|
|
- context: context,
|
|
|
|
- builder: (context) {
|
|
|
|
- return AlertDialog(
|
|
|
|
- title: const Text("Cancelar Pedido",
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontWeight: FontWeight.w500, fontSize: 22)),
|
|
|
|
- content: const Text(
|
|
|
|
- '¿Estás seguro de que deseas cancelar este pedido?',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- actions: [
|
|
|
|
- Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- TextButton(
|
|
|
|
- onPressed: () =>
|
|
|
|
- Navigator.of(context).pop(false),
|
|
|
|
- child: const Text('No',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(
|
|
|
|
- 20, 10, 20, 10)),
|
|
|
|
- backgroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- Colors.red),
|
|
|
|
- foregroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.secondary)),
|
|
|
|
- ),
|
|
|
|
- TextButton(
|
|
|
|
- onPressed: () =>
|
|
|
|
- Navigator.of(context).pop(true),
|
|
|
|
- child: const Text('Sí',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(
|
|
|
|
- 20, 10, 20, 10)),
|
|
|
|
- backgroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.tertiary),
|
|
|
|
- foregroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.quaternary)),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- ) ??
|
|
|
|
- false;
|
|
|
|
|
|
+ if (userPermisos.contains(Usuario.CANCELAR_PEDIDO))
|
|
|
|
+ PopupMenuItem(
|
|
|
|
+ child: const Text('Cancelar Pedido'),
|
|
|
|
+ onTap: () async {
|
|
|
|
+ bool confirmado = await showDialog<bool>(
|
|
|
|
+ context: context,
|
|
|
|
+ builder: (context) {
|
|
|
|
+ return AlertDialog(
|
|
|
|
+ title: const Text("Cancelar Pedido",
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
|
+ fontSize: 22)),
|
|
|
|
+ content: const Text(
|
|
|
|
+ '¿Estás seguro de que deseas cancelar este pedido?',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ actions: [
|
|
|
|
+ Row(
|
|
|
|
+ mainAxisAlignment:
|
|
|
|
+ MainAxisAlignment.spaceBetween,
|
|
|
|
+ children: [
|
|
|
|
+ TextButton(
|
|
|
|
+ onPressed: () =>
|
|
|
|
+ Navigator.of(context).pop(false),
|
|
|
|
+ child: const Text('No',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(
|
|
|
|
+ 20, 10, 20, 10)),
|
|
|
|
+ backgroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ Colors.red),
|
|
|
|
+ foregroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.secondary)),
|
|
|
|
+ ),
|
|
|
|
+ TextButton(
|
|
|
|
+ onPressed: () =>
|
|
|
|
+ Navigator.of(context).pop(true),
|
|
|
|
+ child: const Text('Sí',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(
|
|
|
|
+ 20, 10, 20, 10)),
|
|
|
|
+ backgroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.tertiary),
|
|
|
|
+ foregroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.quaternary)),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ ) ??
|
|
|
|
+ false;
|
|
|
|
|
|
- if (confirmado) {
|
|
|
|
- await Provider.of<PedidoViewModel>(context, listen: false)
|
|
|
|
- .cancelarPedido(item.id);
|
|
|
|
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
|
|
- content: Text("Pedido cancelado correctamente")));
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- )
|
|
|
|
|
|
+ if (confirmado) {
|
|
|
|
+ await Provider.of<PedidoViewModel>(context, listen: false)
|
|
|
|
+ .cancelarPedido(item.id);
|
|
|
|
+ ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
|
|
+ content: Text("Pedido cancelado correctamente")));
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ )
|
|
],
|
|
],
|
|
icon: const Icon(Icons.more_vert),
|
|
icon: const Icon(Icons.more_vert),
|
|
)
|
|
)
|
|
@@ -218,11 +222,12 @@ class _PedidoScreenState extends State<PedidoScreen> {
|
|
color: AppTheme.secondary, fontWeight: FontWeight.w500),
|
|
color: AppTheme.secondary, fontWeight: FontWeight.w500),
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
actions: <Widget>[
|
|
- IconButton(
|
|
|
|
- icon: const Icon(Icons.save_alt),
|
|
|
|
- onPressed: exportCSV,
|
|
|
|
- tooltip: 'Exportar a CSV',
|
|
|
|
- ),
|
|
|
|
|
|
+ if (userPermisos.contains(Usuario.VER_REPORTE))
|
|
|
|
+ IconButton(
|
|
|
|
+ icon: const Icon(Icons.save_alt),
|
|
|
|
+ onPressed: exportCSV,
|
|
|
|
+ tooltip: 'Exportar a CSV',
|
|
|
|
+ ),
|
|
],
|
|
],
|
|
iconTheme: IconThemeData(color: AppTheme.secondary)),
|
|
iconTheme: IconThemeData(color: AppTheme.secondary)),
|
|
body: Stack(
|
|
body: Stack(
|