Add Set Boxes Locations page with status management and remove company branding from labels

- Renamed Store Articles card to Set Boxes Locations on warehouse main page
- Created new mobile-optimized page with two tabs for box location management:
  - Tab 1: Assign box to location (scan box, change status to closed, assign location)
  - Tab 2: Move box from location (scan location, list boxes, move to new location)
- Added box status management (open/closed) with status change button
- Enforced rule: only closed boxes can be assigned to locations
- Moved API logic to warehouse.py module:
  - search_box_by_number()
  - assign_box_to_location()
  - search_location_with_boxes()
  - move_box_to_new_location()
  - change_box_status()
- Added API routes in routes.py as thin wrappers
- Aligned page theme colors with application Bootstrap theme
- Added dark mode support for the new page
- Added Warehouse Main button to page header
- Removed 'INNOFA ROMANIA SRL' branding from:
  - Print module label preview and PDF generation
  - Print lost labels page
  - pdf_generator.py PDF creation function
This commit is contained in:
Quality App System
2025-12-27 19:47:32 +02:00
parent 9a2e21796e
commit 5a423b3704
9 changed files with 1481 additions and 14 deletions

View File

@@ -6,7 +6,14 @@ from flask import Blueprint, render_template, redirect, url_for, request, flash,
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
import csv
from .warehouse import add_location
from .warehouse import (
add_location,
search_box_by_number,
assign_box_to_location,
search_location_with_boxes,
move_box_to_new_location,
change_box_status
)
from app.settings import (
settings_handler,
role_permissions_handler,
@@ -5473,3 +5480,98 @@ def restore_single_table():
}), 500
# Warehouse Box Location Management API Routes
@bp.route('/api/warehouse/box/search', methods=['POST'])
@requires_warehouse_module
def api_search_box():
"""Search for a box by box number"""
data = request.get_json()
box_number = data.get('box_number', '').strip()
success, response_data, status_code = search_box_by_number(box_number)
return jsonify({
'success': success,
**response_data
}), status_code
@bp.route('/api/warehouse/box/assign-location', methods=['POST'])
@requires_warehouse_module
def api_assign_box_to_location():
"""Assign a box to a warehouse location (only if box is closed)"""
data = request.get_json()
box_id = data.get('box_id')
location_code = data.get('location_code', '').strip()
# Additional check: verify box is closed before assigning
if box_id:
try:
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("SELECT status FROM boxes_crates WHERE id = %s", (box_id,))
result = cursor.fetchone()
conn.close()
if result and result[0] == 'open':
return jsonify({
'success': False,
'message': 'Cannot assign an open box to a location. Please close the box first.'
}), 400
except Exception as e:
pass # Continue to the main function which will handle other errors
success, response_data, status_code = assign_box_to_location(box_id, location_code)
return jsonify({
'success': success,
**response_data
}), status_code
@bp.route('/api/warehouse/box/change-status', methods=['POST'])
@requires_warehouse_module
def api_change_box_status():
"""Change the status of a box (open/closed)"""
data = request.get_json()
box_id = data.get('box_id')
new_status = data.get('new_status', '').strip()
success, response_data, status_code = change_box_status(box_id, new_status)
return jsonify({
'success': success,
**response_data
}), status_code
@bp.route('/api/warehouse/location/search', methods=['POST'])
@requires_warehouse_module
def api_search_location():
"""Search for a location and get all boxes in it"""
data = request.get_json()
location_code = data.get('location_code', '').strip()
success, response_data, status_code = search_location_with_boxes(location_code)
return jsonify({
'success': success,
**response_data
}), status_code
@bp.route('/api/warehouse/box/move-location', methods=['POST'])
@requires_warehouse_module
def api_move_box_to_location():
"""Move a box from one location to another"""
data = request.get_json()
box_id = data.get('box_id')
new_location_code = data.get('new_location_code', '').strip()
success, response_data, status_code = move_box_to_new_location(box_id, new_location_code)
return jsonify({
'success': success,
**response_data
}), status_code