lets add settings new to css

This commit is contained in:
2025-10-09 00:34:52 +03:00
parent a8811b94b7
commit b0e17b69e7
18 changed files with 1816 additions and 118 deletions

View File

@@ -218,3 +218,59 @@ def generate_location_label_pdf():
except Exception as e:
print(f"Error generating location label PDF: {e}")
return jsonify({'error': str(e)}), 500
def update_location(location_id, location_code, size, description):
"""Update an existing warehouse location"""
try:
conn = get_db_connection()
cursor = conn.cursor()
# Check if location exists
cursor.execute("SELECT id FROM warehouse_locations WHERE id = ?", (location_id,))
if not cursor.fetchone():
conn.close()
return {"success": False, "error": "Location not found"}
# Check if location code already exists for different location
cursor.execute("SELECT id FROM warehouse_locations WHERE location_code = ? AND id != ?", (location_code, location_id))
if cursor.fetchone():
conn.close()
return {"success": False, "error": "Location code already exists"}
# Update location
cursor.execute(
"UPDATE warehouse_locations SET location_code = ?, size = ?, description = ? WHERE id = ?",
(location_code, size if size else None, description, location_id)
)
conn.commit()
conn.close()
return {"success": True, "message": "Location updated successfully"}
except Exception as e:
print(f"Error updating location: {e}")
return {"success": False, "error": str(e)}
def delete_location_by_id(location_id):
"""Delete a warehouse location by ID"""
try:
conn = get_db_connection()
cursor = conn.cursor()
# Check if location exists
cursor.execute("SELECT location_code FROM warehouse_locations WHERE id = ?", (location_id,))
location = cursor.fetchone()
if not location:
conn.close()
return {"success": False, "error": "Location not found"}
# Delete location
cursor.execute("DELETE FROM warehouse_locations WHERE id = ?", (location_id,))
conn.commit()
conn.close()
return {"success": True, "message": f"Location '{location[0]}' deleted successfully"}
except Exception as e:
print(f"Error deleting location: {e}")
return {"success": False, "error": str(e)}