# Brands, POS Display and Session Corrections

## Using Brands

Categories > Brands manages optional product brands. Add and Edit use a dialog.
The existing Categories View/Create/Update/Delete permissions control the same
actions for brands; brand access is also restricted to permitted branches.
Brands may be reused across main/sub categories within their branch.
An inactive brand stays on existing products but cannot be assigned to new ones.
A used brand cannot be deleted or moved to a different branch.

Products Add/Edit: Main Category, Sub Category, then Brand. No brand is required.
Products has a Brand filter and Brand column. Exact barcode entry automatically
submits the Products search after a short pause, including scanners without Enter.

## Selling Display

System Configuration > POS Mode controls the Retail and Wholesale windows:

- Retail: search/barcode entry and cart only, without a product catalogue.
- Restaurant: a compact browsing toolbar in Retail and Wholesale. Products start
  hidden. Main Categories, Sub Categories and Brands each open one touch-choice
  row at a time. Select a choice to show matching products, then narrow further
  using another group. All Categories explicitly shows all sellable products.
  Completing a sale resets the browser to hidden products; failed saves preserve
  the cart and browsing state. The close icon hides products manually.
  Products add/edit and product-list filters remain dropdowns.

This does not change a retail/wholesale sale into a restaurant order. Existing
Restaurant/Bar operation and printer routing are unchanged. Only active,
sellable products in the user's accessible branches are loaded. Existing image
versus price display, quantity/discount, stock and sales permissions remain.
Large lists render 60 product tiles at a time, with Show More.

## Session Corrections

Session cookies now have an installation-folder-specific suffix. Users sign in
once after applying this change. Unrelated copies on localhost no longer use
the identical authentication cookie name, even if SESSION_COOKIE is the same.
Logout messages are scoped to the installation and current session; logout still
propagates to other tabs in that same session.

The activity monitor no longer treats a stale CSRF token as proof of logout.
After a 419 it checks the authenticated, idle-checked status endpoint. Only the
same authenticated user receives refreshed form tokens. An expired session is
not revived. CSRF checking and licence enforcement remain enabled.
Typing, scanning, clicking and scrolling reset activity. Background polls alone
do not keep an unattended session alive. A 30 setting means 30 minutes.

## Database and Deployment

The new migration adds brands and a nullable products.brand_id foreign key.
It preserves current products, sales, stock and licences. This laptop's products
and migration history were backed up before the targeted migration was run.
The backup lives in storage/app/backups and must not be distributed to technicians.

For an existing client, compare their customised files first, back up, apply the
matching code and run only the required migration. Do not replace a live database
or client .env. Run artisan optimize:clear, hard-refresh and sign in again.
Do not blindly replace a client controller/routes containing modem customisations.

## Developer Map

- Brand.php and BrandController.php: branch-aware brand records and CRUD.
- brands/index.blade.php: listing and add/edit dialog.
- products/partials/brand_field.blade.php: optional product brand selector.
- ProductController.php and products/index.blade.php: assignment and filtering.
- RetailPosController.php: product metadata and POS mode flag.
- retail_pos/partials/product_catalogue.blade.php: filters and click-to-cart tiles.
- config/session.php: installation-specific cookie name.
- layouts/app.blade.php: session-scoped logout messages and idle configuration.
- public/js/idle-session.js: genuine activity tracking and token recovery.
- routes/web.php: authenticated activity/status endpoints and brand routes.
