FG Scan form validation improvements with warehouse module updates
- Fixed 3 JavaScript syntax errors in fg_scan.html (lines 951, 840-950, 1175-1215) - Restored form field validation with proper null safety checks - Re-enabled auto-advance between form fields - Re-enabled CP code auto-complete with hyphen detection - Updated validation error messages with clear format specifications and examples - Added autocomplete='off' to all input fields - Removed auto-prefix correction feature - Updated warehouse routes and modules for box assignment workflow - Added/improved database initialization scripts - Updated requirements.txt dependencies Format specifications implemented: - Operator Code: OP + 2 digits (example: OP01, OP99) - CP Code: CP + 8 digits + hyphen + 4 digits (example: CP00000000-0001) - OC1/OC2 Codes: OC + 2 digits (example: OC01, OC99) - Defect Code: 3 digits only
This commit is contained in:
@@ -874,7 +874,12 @@ def get_database_tables():
|
||||
|
||||
@settings_bp.route('/api/database/truncate', methods=['POST'])
|
||||
def truncate_table():
|
||||
"""Truncate (clear) a database table"""
|
||||
"""Truncate (clear) a database table
|
||||
|
||||
Special handling for warehouse_locations table:
|
||||
- Preserves the 2 default locations: FG_INCOMING and TRUCK_LOADING
|
||||
- Deletes only user-created locations
|
||||
"""
|
||||
if 'user_id' not in session:
|
||||
return jsonify({'error': 'Unauthorized'}), 401
|
||||
|
||||
@@ -898,12 +903,30 @@ def truncate_table():
|
||||
cursor.close()
|
||||
return jsonify({'error': 'Table not found'}), 404
|
||||
|
||||
# Truncate the table
|
||||
cursor.execute(f'TRUNCATE TABLE {table}')
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
|
||||
return jsonify({'success': True, 'message': f'Table {table} cleared successfully'})
|
||||
# Special handling for warehouse_locations table
|
||||
if table == 'warehouse_locations':
|
||||
# Delete all rows EXCEPT the 2 default locations
|
||||
cursor.execute("""
|
||||
DELETE FROM warehouse_locations
|
||||
WHERE location_code NOT IN ('FG_INCOMING', 'TRUCK_LOADING')
|
||||
""")
|
||||
conn.commit()
|
||||
deleted_count = cursor.rowcount
|
||||
cursor.close()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': f'Table {table} cleared successfully ({deleted_count} rows deleted)',
|
||||
'preserved_count': 2,
|
||||
'preserved_locations': ['FG_INCOMING', 'TRUCK_LOADING']
|
||||
})
|
||||
else:
|
||||
# For all other tables, perform standard truncate
|
||||
cursor.execute(f'TRUNCATE TABLE {table}')
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
|
||||
return jsonify({'success': True, 'message': f'Table {table} cleared successfully'})
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user