Bakery POS - Phase 5 Update

IMPORTANT: Use the currently working Bakery POS as the base. This package was built from the ZIP supplied on 2026-09-29.

DATABASE
1. Back up engrgolk_bakery.
2. Import ONLY /sql/006_phase5_products_recipes.sql once.
3. Do NOT import /sql/001_master_schema.sql into the existing live database. It is only the updated future clean-install schema.

REPLACE / ADD THESE FILES
REPLACE:
- /app/Support/layout.php
- /config/app.php
- /assets/css/app.css
- /assets/js/app.js
- /service-worker.js
- /bakery/index.php
- /sql/001_master_schema.sql (reference/future clean install only)

ADD:
- /app/Services/ProductRecipeService.php
- /app/Services/BarcodeService.php
- /assets/js/phase5.js
- /bakery/products.php
- /bakery/recipes.php
- /bakery/recipe-edit.php
- /bakery/barcodes.php
- /bakery/barcode-label.php
- /bakery/barcode-pdf.php
- /sql/006_phase5_products_recipes.sql
- /assets/uploads/products/.htaccess

UNCHANGED
Authentication, Email OTP, registration, password reset, RawMaterialService, purchases, supplier payments, stock adjustments and Phase 4 transaction logic were not modified.

PHASE 5 FEATURES
- Product categories: Bakery / Grocery / Stationery / Other
- Bilingual product names (English + Sinhala)
- Manufactured and third-party products
- Variants/sizes, selling units, shelf life, expiry/stock tracking
- Optional product images (JPG/PNG/WEBP, max 2 MB)
- Internal Code 128 generation when no barcode exists
- Existing manufacturer barcode support
- Barcode preview, print labels, selected/all PDF download
- Versioned bakery recipes
- Raw-material ingredients with existing unit conversion rules
- Active sub-recipes with cycle protection
- Draft -> Active recipe workflow; old Active version becomes Archived
- Estimated ingredient cost from current weighted-average material costs
- Bakery dashboard Phase 5 summary
- Automatic asset versioning + service-worker old-cache cleanup

CACHE
After this update, versioned CSS/JS URLs and the new service worker are designed to prevent the previous Ctrl+F5 problem. The first visit after upload may still require one normal reload while the new service worker activates; subsequent releases using a new asset_version should refresh automatically.
