Update cashier print report to include result, winning outcomes, and under/over columns

- Added Result column showing match result (WIN1, DRAW, WIN2, etc.)
- Added Winning Outcomes column showing all winning outcomes from extraction
- Added Under/Over column showing UNDER or OVER result
- Updated summary boxes to show wins, draws, under, and over counts
- Improved print layout with better column sizing
parent 14927410
...@@ -989,23 +989,51 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -989,23 +989,51 @@ function generateCashierPrintContent(matches, fixtureId) {
const status = match.status || 'pending'; const status = match.status || 'pending';
const statusText = status.toUpperCase(); const statusText = status.toUpperCase();
// Result display
const result = match.result || '-';
// Winning outcomes display
let winningOutcomes = '-';
if (match.winning_outcomes) {
try {
const wo = typeof match.winning_outcomes === 'string' ? JSON.parse(match.winning_outcomes) : match.winning_outcomes;
if (Array.isArray(wo) && wo.length > 0) {
winningOutcomes = wo.join(', ');
}
} catch (e) {
winningOutcomes = match.winning_outcomes;
}
}
// Under/Over display
const underOver = match.under_over_result || '-';
matchesHTML += ` matchesHTML += `
<tr> <tr>
<td style="text-align: center; font-weight: bold;">#${match.match_number}</td> <td style="text-align: center; font-weight: bold;">#${match.match_number}</td>
<td style="font-weight: bold;">${match.fighter1_township}</td> <td style="font-weight: bold;">${match.fighter1_township}</td>
<td style="font-weight: bold;">${match.fighter2_township}</td> <td style="font-weight: bold;">${match.fighter2_township}</td>
<td>${match.venue_kampala_township}</td> <td>${match.venue_kampala_township}</td>
<td style="font-size: 11px;">${startTime}</td>
<td style="text-align: center;">${statusText}</td> <td style="text-align: center;">${statusText}</td>
<td style="text-align: center; font-weight: bold;">${result}</td>
<td style="text-align: center; font-size: 10px;">${winningOutcomes}</td>
<td style="text-align: center;">${underOver}</td>
</tr> </tr>
`; `;
}); });
// Calculate summary stats
const doneMatches = matches.filter(m => m.status === 'done');
const winCount = doneMatches.filter(m => m.result && (m.result.startsWith('WIN') || m.result === 'W1' || m.result === 'W2')).length;
const drawCount = doneMatches.filter(m => m.result === 'DRAW' || m.result === 'X').length;
const underCount = doneMatches.filter(m => m.under_over_result === 'UNDER').length;
const overCount = doneMatches.filter(m => m.under_over_result === 'OVER').length;
return ` return `
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Pending Matches - Cashier Dashboard</title> <title>Fixture Matches Report - Cashier Dashboard</title>
<style> <style>
* { * {
margin: 0; margin: 0;
...@@ -1053,20 +1081,23 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -1053,20 +1081,23 @@ function generateCashierPrintContent(matches, fixtureId) {
margin-bottom: 20px; margin-bottom: 20px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
} }
.summary-box { .summary-box {
text-align: center; text-align: center;
padding: 10px 20px; padding: 10px 15px;
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 5px; border-radius: 5px;
min-width: 80px;
} }
.summary-box .number { .summary-box .number {
font-size: 24px; font-size: 20px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
} }
.summary-box .label { .summary-box .label {
font-size: 11px; font-size: 10px;
color: #666; color: #666;
} }
table.matches { table.matches {
...@@ -1079,12 +1110,13 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -1079,12 +1110,13 @@ function generateCashierPrintContent(matches, fixtureId) {
color: white; color: white;
padding: 8px 5px; padding: 8px 5px;
text-align: center; text-align: center;
font-size: 11px; font-size: 10px;
} }
table.matches td { table.matches td {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 6px 5px; padding: 6px 5px;
vertical-align: middle; vertical-align: middle;
font-size: 11px;
} }
.footer { .footer {
text-align: center; text-align: center;
...@@ -1103,7 +1135,7 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -1103,7 +1135,7 @@ function generateCashierPrintContent(matches, fixtureId) {
</head> </head>
<body> <body>
<div class="header"> <div class="header">
<h1>Pending Matches Report</h1> <h1>Fixture Matches Report</h1>
<div class="subtitle">Cashier Dashboard - Generated on ${now}</div> <div class="subtitle">Cashier Dashboard - Generated on ${now}</div>
</div> </div>
...@@ -1117,6 +1149,10 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -1117,6 +1149,10 @@ function generateCashierPrintContent(matches, fixtureId) {
<td>Total Matches:</td> <td>Total Matches:</td>
<td>${matches.length}</td> <td>${matches.length}</td>
</tr> </tr>
<tr>
<td>Completed:</td>
<td>${doneMatches.length}</td>
</tr>
<tr> <tr>
<td>Printed By:</td> <td>Printed By:</td>
<td>{{ current_user.username }} (Cashier)</td> <td>{{ current_user.username }} (Cashier)</td>
...@@ -1127,27 +1163,45 @@ function generateCashierPrintContent(matches, fixtureId) { ...@@ -1127,27 +1163,45 @@ function generateCashierPrintContent(matches, fixtureId) {
<div class="summary"> <div class="summary">
<div class="summary-box"> <div class="summary-box">
<div class="number">${matches.length}</div> <div class="number">${matches.length}</div>
<div class="label">Total Matches</div> <div class="label">Total</div>
</div> </div>
<div class="summary-box"> <div class="summary-box">
<div class="number">${matches.filter(m => m.status === 'bet').length}</div> <div class="number">${matches.filter(m => m.status === 'bet').length}</div>
<div class="label">Open for Betting</div> <div class="label">Betting</div>
</div>
<div class="summary-box">
<div class="number">${doneMatches.length}</div>
<div class="label">Done</div>
</div>
<div class="summary-box">
<div class="number">${winCount}</div>
<div class="label">Wins</div>
</div>
<div class="summary-box">
<div class="number">${drawCount}</div>
<div class="label">Draws</div>
</div>
<div class="summary-box">
<div class="number">${underCount}</div>
<div class="label">Under</div>
</div> </div>
<div class="summary-box"> <div class="summary-box">
<div class="number">${matches.filter(m => m.status === 'scheduled' || m.status === 'pending').length}</div> <div class="number">${overCount}</div>
<div class="label">Scheduled</div> <div class="label">Over</div>
</div> </div>
</div> </div>
<table class="matches"> <table class="matches">
<thead> <thead>
<tr> <tr>
<th style="width: 50px;">#</th> <th style="width: 40px;">#</th>
<th style="width: 120px;">Fighter 1</th> <th style="width: 100px;">Fighter 1</th>
<th style="width: 120px;">Fighter 2</th> <th style="width: 100px;">Fighter 2</th>
<th style="width: 100px;">Venue</th> <th style="width: 80px;">Venue</th>
<th style="width: 100px;">Start Time</th> <th style="width: 50px;">Status</th>
<th style="width: 60px;">Status</th> <th style="width: 50px;">Result</th>
<th style="width: 80px;">Win Outcomes</th>
<th style="width: 50px;">U/O</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment