Enhance cashier dashboard with full fixture view and date filtering

- Changed from 'pending matches' to 'all matches in today's fixture'
- Added summary row showing counts by status (total, pending, bet, ingame, done, other)
- Added Result and Under/Over columns to the match table
- Made 'Bet' status badge clickable - links to new bet page for that match
- Added date filter to select past fixtures by date
- Updated API endpoint to support date parameter for filtering
- Color-coded rows based on match status (done=green, failed=red, ingame=blue, bet=yellow)
parent 84fe418f
...@@ -4122,7 +4122,7 @@ def calculate_fixture_status(matches, today, db_manager=None): ...@@ -4122,7 +4122,7 @@ def calculate_fixture_status(matches, today, db_manager=None):
@api_bp.route('/cashier/pending-matches') @api_bp.route('/cashier/pending-matches')
@get_api_auth_decorator() @get_api_auth_decorator()
def get_cashier_pending_matches(): def get_cashier_pending_matches():
"""Get pending matches from the correct fixture for cashier dashboard""" """Get matches from the fixture for cashier dashboard - supports date filtering"""
try: try:
# Allow access from localhost without authentication # Allow access from localhost without authentication
if request.remote_addr == '127.0.0.1': if request.remote_addr == '127.0.0.1':
...@@ -4151,6 +4151,9 @@ def get_cashier_pending_matches(): ...@@ -4151,6 +4151,9 @@ def get_cashier_pending_matches():
session = api_bp.db_manager.get_session() session = api_bp.db_manager.get_session()
try: try:
# Check for date parameter in query string
date_param = request.args.get('date')
# Get today's date # Get today's date
today = date.today() today = date.today()
yesterday = today - timedelta(days=1) yesterday = today - timedelta(days=1)
...@@ -4158,20 +4161,33 @@ def get_cashier_pending_matches(): ...@@ -4158,20 +4161,33 @@ def get_cashier_pending_matches():
# First, auto-fail old fixtures with pending/scheduled/bet results # First, auto-fail old fixtures with pending/scheduled/bet results
auto_fail_old_fixtures(session, yesterday) auto_fail_old_fixtures(session, yesterday)
# Find fixtures with start_time of today (get the LAST one, not first) # Determine the target date for fixture selection
fixtures_with_today_start = session.query(MatchModel.fixture_id)\ if date_param:
# Parse the date parameter (format: YYYY-MM-DD)
try:
target_date = datetime.strptime(date_param, '%Y-%m-%d').date()
except ValueError:
return jsonify({
"success": False,
"error": f"Invalid date format: {date_param}. Use YYYY-MM-DD format."
}), 400
else:
target_date = today
# Find fixtures with start_time on the target date (get the LAST one)
fixtures_with_target_start = session.query(MatchModel.fixture_id)\
.filter(MatchModel.start_time.isnot(None))\ .filter(MatchModel.start_time.isnot(None))\
.filter(MatchModel.start_time >= datetime.combine(today, datetime.min.time()))\ .filter(MatchModel.start_time >= datetime.combine(target_date, datetime.min.time()))\
.filter(MatchModel.start_time < datetime.combine(today, datetime.max.time()))\ .filter(MatchModel.start_time < datetime.combine(target_date, datetime.max.time()))\
.order_by(MatchModel.created_at.desc())\ .order_by(MatchModel.created_at.desc())\
.first() .first()
selected_fixture_id = None selected_fixture_id = None
if fixtures_with_today_start: if fixtures_with_target_start:
# Use the LAST fixture where matches start today # Use the LAST fixture where matches start on target date
selected_fixture_id = fixtures_with_today_start.fixture_id selected_fixture_id = fixtures_with_target_start.fixture_id
logger.info(f"Selected fixture {selected_fixture_id} - last fixture with matches starting today") logger.info(f"Selected fixture {selected_fixture_id} - last fixture with matches starting on {target_date}")
else: else:
# Fallback: find the first fixture where ALL matches are in pending status (not scheduled/bet) # Fallback: find the first fixture where ALL matches are in pending status (not scheduled/bet)
all_fixtures = session.query(MatchModel.fixture_id).distinct().order_by(MatchModel.fixture_id.asc()).all() all_fixtures = session.query(MatchModel.fixture_id).distinct().order_by(MatchModel.fixture_id.asc()).all()
...@@ -4192,7 +4208,8 @@ def get_cashier_pending_matches(): ...@@ -4192,7 +4208,8 @@ def get_cashier_pending_matches():
"success": True, "success": True,
"matches": [], "matches": [],
"total": 0, "total": 0,
"fixture_id": None "fixture_id": None,
"date": target_date.isoformat() if target_date else None
}) })
# Get all matches from the selected fixture # Get all matches from the selected fixture
...@@ -4210,7 +4227,8 @@ def get_cashier_pending_matches(): ...@@ -4210,7 +4227,8 @@ def get_cashier_pending_matches():
"success": True, "success": True,
"matches": matches_data, "matches": matches_data,
"total": len(matches_data), "total": len(matches_data),
"fixture_id": selected_fixture_id "fixture_id": selected_fixture_id,
"date": target_date.isoformat() if target_date else None
}) })
finally: finally:
......
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