diff --git a/app.py b/app.py index 47edfc3..a324ce3 100644 --- a/app.py +++ b/app.py @@ -38,7 +38,7 @@ app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=1) # 1. Define the version -APP_VERSION = '0.13.0' +APP_VERSION = '0.13.2' # 2. Inject it into all templates automatically @app.context_processor @@ -164,22 +164,6 @@ def admin_dashboard(): -@app.route('/staff-mode') -@login_required -def staff_mode(): - """Allow admin/owner to switch to staff view for scanning""" - # Show staff dashboard view regardless of role - active_sessions = query_db(''' - SELECT session_id, session_name, session_type, created_timestamp - FROM CountSessions - WHERE status = 'active' - ORDER BY created_timestamp DESC - ''') - - return render_template('staff_dashboard.html', sessions=active_sessions, is_admin_mode=True) - - - # ==================== PWA SUPPORT ROUTES ==================== @app.route('/manifest.json') diff --git a/blueprints/__pycache__/counting.cpython-313.pyc b/blueprints/__pycache__/counting.cpython-313.pyc index a3a9aaf..e8d6273 100644 Binary files a/blueprints/__pycache__/counting.cpython-313.pyc and b/blueprints/__pycache__/counting.cpython-313.pyc differ diff --git a/blueprints/counting.py b/blueprints/counting.py index 0c258b5..4a5ee4a 100644 --- a/blueprints/counting.py +++ b/blueprints/counting.py @@ -10,6 +10,50 @@ def get_active_session(session_id): return None return sess + + +@counting_bp.route('/counts/admin') +@login_required +def admin_dashboard(): + """Admin dashboard for Counts module""" + # Security check: Ensure user is admin/owner + if session.get('role') not in ['owner', 'admin']: + flash('Access denied. Admin role required.', 'danger') + return redirect(url_for('counting.index')) + + show_archived = request.args.get('show_archived', '0') == '1' + + # This SQL was moved from app.py + if show_archived: + sessions_list = query_db(''' + SELECT s.*, u.full_name as created_by_name, + COUNT(DISTINCT lc.location_count_id) as total_locations, + SUM(CASE WHEN lc.status = 'completed' THEN 1 ELSE 0 END) as completed_locations, + SUM(CASE WHEN lc.status = 'in_progress' THEN 1 ELSE 0 END) as in_progress_locations + FROM CountSessions s + LEFT JOIN Users u ON s.created_by = u.user_id + LEFT JOIN LocationCounts lc ON s.session_id = lc.session_id + WHERE s.status IN ('active', 'archived') + GROUP BY s.session_id + ORDER BY s.status ASC, s.created_timestamp DESC + ''') + else: + sessions_list = query_db(''' + SELECT s.*, u.full_name as created_by_name, + COUNT(DISTINCT lc.location_count_id) as total_locations, + SUM(CASE WHEN lc.status = 'completed' THEN 1 ELSE 0 END) as completed_locations, + SUM(CASE WHEN lc.status = 'in_progress' THEN 1 ELSE 0 END) as in_progress_locations + FROM CountSessions s + LEFT JOIN Users u ON s.created_by = u.user_id + LEFT JOIN LocationCounts lc ON s.session_id = lc.session_id + WHERE s.status = 'active' + GROUP BY s.session_id + ORDER BY s.created_timestamp DESC + ''') + + return render_template('counts/admin_dashboard.html', sessions=sessions_list, show_archived=show_archived) + + @counting_bp.route('/counts') @login_required def index(): @@ -33,7 +77,7 @@ def index(): ORDER BY created_timestamp DESC ''') - return render_template('staff_dashboard.html', sessions=active_sessions) + return render_template('counts/staff_dashboard.html', sessions=active_sessions) @counting_bp.route('/count/') @@ -91,7 +135,7 @@ def my_counts(session_id): ORDER BY lc.end_timestamp DESC ''', [session_id, session['user_id']]) - return render_template('my_counts.html', + return render_template('counts/my_counts.html', count_session=sess, active_bins=active_bins, completed_bins=completed_bins) @@ -219,7 +263,7 @@ def count_location(session_id, location_count_id): ORDER BY lot_number ''', [session_id, location['location_name'], location_count_id]) - return render_template('count_location.html', + return render_template('counts/count_location.html', session_id=session_id, location=location, scans=scans, diff --git a/templates/admin_dashboard.html b/templates/admin_dashboard.html index 1ed1226..c03c978 100644 --- a/templates/admin_dashboard.html +++ b/templates/admin_dashboard.html @@ -4,121 +4,28 @@ {% block content %}
- -
- - Back to Home - - - -
- - - -
-
-

Admin Dashboard

- + - - - - - {% if sessions %} -
- {% for session in sessions %} -
-
-

- {{ session.session_name }} - {% if session.status == 'archived' %}ARCHIVED{% endif %} -

- - {{ 'Full Physical' if session.session_type == 'full_physical' else 'Cycle Count' }} - -
- -
-
-
{{ session.total_locations or 0 }}
-
Total Locations
-
-
-
{{ session.completed_locations or 0 }}
-
Completed
-
-
-
{{ session.in_progress_locations or 0 }}
-
In Progress
-
-
- -
-
- Created: - {{ session.created_timestamp[:16] }} -
-
- By: - {{ session.created_by_name }} -
-
- - -
- {% endfor %} -
- {% else %} -
-
📋
-

No Active Sessions

-

Create a new count session to get started

- - Create First Session - -
- {% endif %}
{% endblock %} \ No newline at end of file diff --git a/templates/cons_sheets/admin_processes.html b/templates/cons_sheets/admin_processes.html index f0f66de..a776ef4 100644 --- a/templates/cons_sheets/admin_processes.html +++ b/templates/cons_sheets/admin_processes.html @@ -4,18 +4,18 @@ {% block content %}
- - - -
-
-

Consumption Sheets

-

Manage process types and templates

+
+
+ + Back to Admin + + +
+

Consumption Sheets

+

Manage process types and templates

+
+ + New Process diff --git a/templates/count_session.html b/templates/counts/DELETE_count_session.html similarity index 100% rename from templates/count_session.html rename to templates/counts/DELETE_count_session.html diff --git a/templates/counts/admin_dashboard.html b/templates/counts/admin_dashboard.html new file mode 100644 index 0000000..4fa1d21 --- /dev/null +++ b/templates/counts/admin_dashboard.html @@ -0,0 +1,102 @@ +{% extends "base.html" %} + +{% block title %}Inventory Counts - ScanLook{% endblock %} + +{% block content %} +
+
+
+ + Back to Admin + +
+

Inventory Counts

+

Manage cycle counts and physical inventory

+
+
+
+ + + + New Session + +
+
+ + {% if sessions %} +
+ {% for session in sessions %} +
+
+

+ {{ session.session_name }} + {% if session.status == 'archived' %}ARCHIVED{% endif %} +

+ + {{ 'Full Physical' if session.session_type == 'full_physical' else 'Cycle Count' }} + +
+ +
+
+
{{ session.total_locations or 0 }}
+
Total Locations
+
+
+
{{ session.completed_locations or 0 }}
+
Completed
+
+
+
{{ session.in_progress_locations or 0 }}
+
In Progress
+
+
+ +
+
+ Created: + {{ session.created_timestamp[:16] }} +
+
+ By: + {{ session.created_by_name }} +
+
+ + +
+ {% endfor %} +
+ {% else %} +
+
📋
+

No Active Sessions

+

Create a new count session to get started

+
+ {% endif %} +
+ + + + +{% endblock %} \ No newline at end of file diff --git a/templates/count_location.html b/templates/counts/count_location.html similarity index 100% rename from templates/count_location.html rename to templates/counts/count_location.html diff --git a/templates/my_counts.html b/templates/counts/my_counts.html similarity index 100% rename from templates/my_counts.html rename to templates/counts/my_counts.html diff --git a/templates/staff_dashboard.html b/templates/counts/staff_dashboard.html similarity index 100% rename from templates/staff_dashboard.html rename to templates/counts/staff_dashboard.html