diff --git a/btc-UI/src/app/components/middle-section/middle-section.component.html b/btc-UI/src/app/components/middle-section/middle-section.component.html
index df767e5..7e67d69 100755
--- a/btc-UI/src/app/components/middle-section/middle-section.component.html
+++ b/btc-UI/src/app/components/middle-section/middle-section.component.html
@@ -54,10 +54,10 @@
>
-
-
-
-
+
+
+
+
@@ -69,7 +69,12 @@
-
+
+
+
+
+
+
Amount : ₹ {{ grandTotal }}
diff --git a/btc-UI/src/app/components/middle-section/middle-section.component.ts b/btc-UI/src/app/components/middle-section/middle-section.component.ts
index df8d8e0..6d6eecb 100755
--- a/btc-UI/src/app/components/middle-section/middle-section.component.ts
+++ b/btc-UI/src/app/components/middle-section/middle-section.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, OnInit, OnDestroy } from '@angular/core';
+import { Component, Input, OnInit, OnDestroy, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SelectionService, SelectionData } from '../selection.service/selection.service';
import { Subscription } from 'rxjs';
@@ -12,11 +12,17 @@ import { Subscription } from 'rxjs';
})
export class MiddleSectionComponent implements OnInit, OnDestroy {
@Input() containerHeight: string = '50vh';
+ @Input() eraseTrigger: any;
summaryRows = Array.from({ length: 4 });
filledRows: SelectionData[] = [];
currentRow: SelectionData = { label: '', numbers: [], value: 0, total: 0 };
grandTotal: number = 0;
+ showConfirmButton: boolean = false;
+ lastTicket: any = null;
+ showRepeatTicket: boolean = false;
+ confirmRepeat: boolean = false;
+ showPrintButton: boolean = false;
private selections: SelectionData[] = [];
private sub1!: Subscription;
@@ -36,6 +42,12 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
});
}
+ ngOnChanges(changes: any) {
+ if (changes.eraseTrigger && changes.eraseTrigger.currentValue) {
+ this.erase();
+ }
+ }
+
updateFilledRows(saved: SelectionData[], current: SelectionData) {
const rows: SelectionData[] = [...saved];
if (rows.length < 5 && current.label) rows.push(current); // Include current row if label is selected
@@ -56,6 +68,76 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
this.grandTotal = this.filledRows.reduce((sum, row) => sum + (row.total || 0), 0);
}
+ repeat() {
+ try {
+ const storedTickets = localStorage.getItem('localTickets');
+ if (storedTickets) {
+ const tickets = JSON.parse(storedTickets);
+ const latestTicket = Array.isArray(tickets)
+ ? (tickets.length > 0 ? tickets[tickets.length - 1] : null)
+ : tickets;
+
+ if (latestTicket && latestTicket.winLabels) {
+ const parsedRows = this.parseWinLabelsToRows(latestTicket.winLabels);
+
+ // ✅ Always make sure we have exactly 5 rows
+ this.updateFilledRows(parsedRows, { label: '', numbers: [], value: 0, total: 0 });
+
+ this.showConfirmButton = true;
+ this.showPrintButton = false;
+ this.lastTicket = latestTicket;
+ } else {
+ console.warn('⚠️ No valid ticket data found in localStorage.');
+ }
+ } else {
+ console.warn('⚠️ No tickets found in localStorage.');
+ }
+ } catch (error) {
+ console.error('❌ Failed to load ticket from localStorage:', error);
+ }
+}
+
+ parseWinLabelsToRows(winLabels: string): SelectionData[] {
+ // Each line: `${label.padEnd(10)}${numbers.padEnd(15)} *${value} Rs${total}`
+ return (winLabels.split('\n') as string[])
+ .map(line => {
+ const match = line.match(/^(.{10})(.{15}) *\*([\d.]+) *Rs ?(\d+)/);
+ if (!match) return null;
+ return {
+ label: match[1].trim(),
+ numbers: match[2].trim().split(',').map(s => s.trim()).filter(s => s.length > 0),
+ value: Number(match[3]),
+ total: Number(match[4]),
+ isBoxed: match[2].trim().startsWith('#')
+ };
+ })
+ .filter(Boolean) as SelectionData[];
+ }
+
+ confirm() {
+ this.showPrintButton = true; // Show Print button after confirming
+ console.log('✅ [DEBUG] Ticket confirmed.');
+ }
+
+ print() {
+ console.log('🖨️ [DEBUG] Printing ticket...');
+ // Add your print logic here (e.g., window.print() or a custom print service)
+ }
+
+ erase() {
+ // Clear all rows and hide confirm/print buttons
+ this.filledRows = Array.from({ length: 5 }, () => ({
+ label: '',
+ numbers: [],
+ value: 0,
+ total: 0
+ }));
+ this.grandTotal = 0;
+ this.showConfirmButton = false;
+ this.showPrintButton = false;
+ // Optionally reset other state if needed
+ }
+
ngOnDestroy() {
this.sub1.unsubscribe();
this.sub2.unsubscribe();
diff --git a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts
index 17e76f6..f7409c3 100755
--- a/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts
+++ b/btc-UI/src/app/components/touch-pad-menu/touch-pad-menu.component.ts
@@ -217,7 +217,7 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
if (['FOR', 'QUI', 'TAN'].includes(label) && this.isBoxed) {
return false;
}
- const specialLabels = ['FOR', 'QUI', 'TAN', 'EXA', 'WSP', 'TRE', 'MJP', 'JKP', '.'];
+ const specialLabels = ['FOR', 'QUI', 'TAN', 'EXA', 'TRE', 'MJP', 'JKP', '.'];
return specialLabels.includes(label);
}
@@ -244,7 +244,7 @@ export class TouchPadMenuComponent implements OnInit, OnDestroy {
get isBoxToggleDisabled(): boolean {
if (!this.selectedLabel) return true;
- const disallowedBoxLabels = ['WIN', 'SHP', 'THP', 'PLC', 'SHW', 'TRE', 'MJP', 'JKP'];
+ const disallowedBoxLabels = ['WIN', 'SHP', 'THP', 'PLC', 'WSP','SHW', 'TRE', 'MJP', 'JKP'];
if (disallowedBoxLabels.includes(this.selectedLabel)) {
return true;
}
@@ -936,7 +936,8 @@ const winLabels = allRows.map(row => {
const label = row.label.padEnd(10);
const numbers = numbersStr.padEnd(15);
const value = (`*${row.value || 0}`).padEnd(8);
- return `${label}${numbers} ${value}`;
+ const total = `Rs ${row.total || 0}`.padStart(8);
+ return `${label}${numbers} ${value} ${total}`;
}).join('\n');
@@ -985,6 +986,25 @@ const winLabels = allRows.map(row => {
})
// ---------------------sending data to backend ---------------------------------
+
+// try {
+// const existingTicketsStr = localStorage.getItem('localTickets');
+// const existingTickets = existingTicketsStr ? JSON.parse(existingTicketsStr) : [];
+
+// existingTickets.push(payload);
+
+// localStorage.setItem('localTickets', JSON.stringify(existingTickets));
+
+// console.log('📦 [DEBUG] Ticket saved locally to localStorage.');
+// } catch (error) {
+// console.error('❌ Failed to store ticket locally:', error);
+// }
+try {
+ localStorage.setItem('localTickets', JSON.stringify([payload]));
+ console.log('📦 [DEBUG] Latest ticket stored in localStorage (previous cleared).');
+} catch (error) {
+ console.error('❌ Failed to store ticket locally:', error);
+}
fetch('http://192.168.1.12:8083/api/tickets', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },