|
@@ -10,17 +10,32 @@ import 'package:flutter/services.dart' show rootBundle;
|
|
|
|
|
|
import '../../viewmodels/viewmodels.dart';
|
|
|
|
|
|
+const int _gamepadCode = 0xf11b;
|
|
|
+
|
|
|
Future<void> imprimirTicketsJuntos(BuildContext context, Pedido pedido) async {
|
|
|
bool ticketCocinaActivo =
|
|
|
await Provider.of<VariableViewModel>(context, listen: false)
|
|
|
.isVariableActive('ticket_cocina');
|
|
|
+
|
|
|
final pdf = pw.Document();
|
|
|
final image = pw.MemoryImage(
|
|
|
(await rootBundle.load('assets/logo.png')).buffer.asUint8List(),
|
|
|
);
|
|
|
|
|
|
+ final igImage = pw.MemoryImage(
|
|
|
+ (await rootBundle.load('assets/igLogo.png')).buffer.asUint8List(),
|
|
|
+ );
|
|
|
+
|
|
|
+ final phoneImage = pw.MemoryImage(
|
|
|
+ (await rootBundle.load('assets/phoneImage.png')).buffer.asUint8List(),
|
|
|
+ );
|
|
|
+
|
|
|
+ final webImage = pw.MemoryImage(
|
|
|
+ (await rootBundle.load('assets/web.png')).buffer.asUint8List(),
|
|
|
+ );
|
|
|
+
|
|
|
pdf.addPage(
|
|
|
- generarPaginaPrimerTicket(pedido, image),
|
|
|
+ generarPaginaPrimerTicket(pedido, image, igImage, phoneImage, webImage),
|
|
|
);
|
|
|
|
|
|
if (ticketCocinaActivo) {
|
|
@@ -32,7 +47,12 @@ Future<void> imprimirTicketsJuntos(BuildContext context, Pedido pedido) async {
|
|
|
await printPdf(Uint8List.fromList(await pdf.save()));
|
|
|
}
|
|
|
|
|
|
-pw.Page generarPaginaPrimerTicket(Pedido pedido, pw.MemoryImage image) {
|
|
|
+pw.Page generarPaginaPrimerTicket(
|
|
|
+ Pedido pedido,
|
|
|
+ pw.MemoryImage image,
|
|
|
+ pw.MemoryImage igImage,
|
|
|
+ pw.MemoryImage phoneImage,
|
|
|
+ pw.MemoryImage webImage) {
|
|
|
final numberFormat = NumberFormat('#,##0.00', 'es_MX');
|
|
|
|
|
|
double totalSinDescuento = 0;
|
|
@@ -122,10 +142,33 @@ pw.Page generarPaginaPrimerTicket(Pedido pedido, pw.MemoryImage image) {
|
|
|
style: pw.TextStyle(
|
|
|
fontSize: 12, fontWeight: pw.FontWeight.bold))),
|
|
|
pw.SizedBox(height: 10),
|
|
|
- pw.Text('Fecha: ${pedido.peticion}',
|
|
|
+ pw.Row(children: []),
|
|
|
+ pw.Text('Fecha: ${_formatDateTime(pedido.peticion)}',
|
|
|
style: const pw.TextStyle(fontSize: 9)),
|
|
|
pw.Text('Hermosillo',
|
|
|
style: const pw.TextStyle(fontSize: 9)),
|
|
|
+ pw.SizedBox(height: 5),
|
|
|
+ pw.Row(children: [
|
|
|
+ pw.Image(igImage, width: 8, height: 8),
|
|
|
+ pw.SizedBox(width: 20),
|
|
|
+ pw.Text('turquessacoffee',
|
|
|
+ style: pw.TextStyle(fontSize: 9)),
|
|
|
+ ]),
|
|
|
+ pw.Row(children: [
|
|
|
+ pw.Image(phoneImage, width: 8, height: 8),
|
|
|
+ pw.SizedBox(width: 25),
|
|
|
+ pw.Text('662-466-6626',
|
|
|
+ textAlign: pw.TextAlign.center,
|
|
|
+ style: pw.TextStyle(fontSize: 9)),
|
|
|
+ ]),
|
|
|
+ pw.Row(
|
|
|
+ mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ pw.Image(webImage, width: 8, height: 8),
|
|
|
+ pw.SizedBox(width: 5),
|
|
|
+ pw.Text('https://turquessacoffee.com/',
|
|
|
+ style: pw.TextStyle(fontSize: 9))
|
|
|
+ ]),
|
|
|
])),
|
|
|
pw.SizedBox(height: 10),
|
|
|
pw.Text('Pedido: ${pedido.folio}',
|
|
@@ -203,7 +246,7 @@ pw.Page generarPaginaSegundoTicket(Pedido pedido) {
|
|
|
List<pw.Widget> content = [
|
|
|
pw.Padding(
|
|
|
padding: const pw.EdgeInsets.only(right: 15),
|
|
|
- child: pw.Text('Fecha: ${pedido.peticion}',
|
|
|
+ child: pw.Text('Fecha: ${_formatDateTime(pedido.peticion)}',
|
|
|
style: pw.TextStyle(
|
|
|
fontSize: 9, fontWeight: pw.FontWeight.bold))),
|
|
|
pw.SizedBox(height: 5),
|
|
@@ -292,3 +335,12 @@ Future<void> printPdf(Uint8List pdfBytes) async {
|
|
|
onLayout: (PdfPageFormat format) => pdfBytes,
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+String _formatDateTime(String? dateTimeString) {
|
|
|
+ if (dateTimeString == null) return "Sin fecha";
|
|
|
+
|
|
|
+ DateTime parsedDate = DateTime.parse(dateTimeString);
|
|
|
+
|
|
|
+ var formatter = DateFormat('dd-MM-yyyy HH:mm:ss');
|
|
|
+ return formatter.format(parsedDate.toLocal());
|
|
|
+}
|