diff --git a/app.py b/app.py index 933f186..8feba2f 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,9 @@ import mimetypes import time import uuid from datetime import datetime +import zipfile +import io + # from dotenv import load_dotenv # load_dotenv() @@ -532,6 +535,31 @@ def export_db(): return send_file(DB_FILE, as_attachment=True, download_name=f"SekiPOS_Backup_{datetime.now().strftime('%Y%m%d')}.db", mimetype='application/x-sqlite3') return "Error: Database file not found", 404 +@app.route('/export/images') +@login_required +def export_images(): + if not os.path.exists(CACHE_DIR) or not os.listdir(CACHE_DIR): + return "No images found to export", 404 + + # Create an in-memory byte stream to hold the zip data + memory_file = io.BytesIO() + + with zipfile.ZipFile(memory_file, 'w', zipfile.ZIP_DEFLATED) as zf: + for root, dirs, files in os.walk(CACHE_DIR): + for file in files: + file_path = os.path.join(root, file) + # Store files using their names only to avoid nesting inside the zip + zf.write(file_path, arcname=file) + + memory_file.seek(0) + + return send_file( + memory_file, + mimetype='application/zip', + as_attachment=True, + download_name=f"SekiPOS_Images_{datetime.now().strftime('%Y%m%d')}.zip" + ) + # @app.route('/process_payment', methods=['POST']) # @login_required # def process_payment(): diff --git a/migrate.py b/migrate.py index 5e58c8d..23435a5 100644 --- a/migrate.py +++ b/migrate.py @@ -5,6 +5,16 @@ DB_FILE = 'db/pos_database.db' def upgrade_db(): try: with sqlite3.connect(DB_FILE) as conn: +<<<<<<< HEAD +======= + # Add stock column + # conn.execute("ALTER TABLE products ADD COLUMN stock REAL DEFAULT 0") + # print("Successfully added 'stock' column.") + + # # App.py also expects unit_type, adding it to prevent future headaches + # conn.execute("ALTER TABLE products ADD COLUMN unit_type TEXT DEFAULT 'unit'") + # print("Successfully added 'unit_type' column.") +>>>>>>> 1a048a0e074ee26bd45dda9731c78c2ecef42fba conn.execute("ALTER TABLE dicom ADD COLUMN image_url TEXT;") print("Successfully added 'image_url' column.") diff --git a/templates/macros/modals.html b/templates/macros/modals.html index f024510..c13eb46 100644 --- a/templates/macros/modals.html +++ b/templates/macros/modals.html @@ -49,14 +49,39 @@