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 3df520f..192d34a 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
@@ -77,7 +77,7 @@
-
+
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 73ae830..57462aa 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
@@ -94,7 +94,7 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
repeat() {
try {
- const storedTickets = localStorage.getItem('localTickets');
+ const storedTickets = localStorage.getItem('localTicketsnew');
if (storedTickets) {
const tickets = JSON.parse(storedTickets);
const latestTicket = Array.isArray(tickets)
@@ -143,25 +143,72 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
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
- }
+ //-----------------------REPEAT PRINT LOGIC ----------------------------------
+ printRepeat() {
+ console.log('🖨️ [DEBUG] Printing ticket...');
+ const username = localStorage.getItem('username') || 'Unknown';
+ const currentDate = new Date().toLocaleString();
+
+ const printableRows = this.filledRows
+ .filter(row => row.label && row.numbers.length > 0 && row.total > 0)
+ .map(row => {
+ const horses = Array.isArray(row.numbers) ? row.numbers.join(',') : row.numbers;
+ return `${row.label.padEnd(6)} ${horses.padEnd(15)} * ${String(row.value).padEnd(3)} ₹${row.total}`;
+ })
+ .join('\n');
+
+ const ticketContent = `
+=================================
+ 🏇 BTC Race Ticket 🏇
+=================================
+${printableRows}
+
+Printed by : ${username}
+Date : ${currentDate}
+=================================
+ `;
+
+ // ✅ Log preview in console
+ console.log('%c\n' + ticketContent, 'font-family: monospace; color: green');
+
+ // ✅ Send to print server
+ const payload = {
+ type: 'repeat',
+ printedBy: username,
+ content: ticketContent,
+ timestamp: currentDate
+ };
+
+ fetch('http://localhost:9100/print', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(payload)
+ })
+ .then(response => {
+ if (!response.ok) throw new Error(`Printer error: ${response.status}`);
+ return response.text();
+ })
+ .then(result => {
+ console.log("✅ Repeat ticket print successful:", result);
+ })
+ .catch(error => {
+ console.error("❌ Repeat ticket print failed:", error);
+ });
+ this.erase(); // Clear selections after printing
+
+}
+
+
+//------------------------------PRINT REPEAT ENDED HERE-----------------------------------------------------S
+ erase() {
+ this.selectionService.clearSelections();
+ this.resetSelections();
+ }
+ resetSelections() {
+ throw new Error('Method not implemented.');
+ }
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 22e0496..ec41b96 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
@@ -1017,12 +1017,14 @@ const winLabels = allRows.map(row => {
} 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);
-// }
+
+try {
+ localStorage.setItem('localTicketsnew', 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' },