# Dava India ERP — Views & Frontend Reference

> See [`../CLAUDE.md`](../CLAUDE.md) for the project overview. Compiled 2026-07-30.

## 1. `resources/views/*` — Feature Area Inventory

Views map **1:1 by folder name to controllers** in almost all cases — a predictable convention to
navigate by.

| Folder | Controller | Notes |
|---|---|---|
| `sell/` | `SellController` | Traditional (non-POS) sales screens |
| `sale_pos/` | `SellPosController` | The POS terminal UI (64 files). `create`/`display` = POS screen; `receipts/` = invoice print templates (see §6) |
| `sell_return/` | `SellReturnController` | Sales returns |
| `purchase/`, `purchase_order/`, `purchase_return/`, `purchase_requisition/` | respective controllers | Procurement lifecycle |
| `product/` | `ProductController` | Product/inventory catalog (32 files) |
| `variation/`, `unit/`, `brand/`, `taxonomy/`, `manufacturer/`, `division/` | respective controllers | Product taxonomy/attributes; `manufacturer`/`division` are Dava-specific |
| `composition/` | `CompositionController` | **Dava-specific** — drug composition/salt master |
| `doctor/` | `DoctorController` | **Dava-specific** — doctor master for Rx-linked sales |
| `pharmacy/` | `PharmacyController` | Only `expiry_alerts.blade.php` |
| `warranties/` | `WarrantyController` | Stock feature |
| `types_of_service/`, `sales_commission_agent/`, `sales_order/`, `selling_price_group/` | respective controllers | Service catalog, commission agents, quotation→order pipeline, price groups |
| `ledger_discount/`, `discount/` | discount controllers | Pricing/discount rules |
| `stock_adjustment/`, `stock_transfer/` | respective controllers | Inventory movement |
| `opening_stock/`, `import_*/` | Import* controllers | Bulk CSV import wizards |
| `labels/` | `LabelsController` | Barcode/label design + preview + PDF |
| `barcode/` | barcode controller | Barcode settings |
| `contact/`, `customer_group/` | `ContactController` | CRM — customers & suppliers unified |
| `supplier_portal/` | `SupplierPortalController` | **Dava-specific** — large external-supplier sub-app (dashboard, POs, consignments, cycle counts, cold chain, QC, AI insights, rebalance, bin locations) |
| `business/`, `business_location/`, `location_settings/` | Business controllers | Company & branch settings |
| `account/`, `account_types/`, `account_reports/` | Accounting controllers | Chart of accounts / ledgers |
| `cash_register/` | `CashRegisterController` | POS till open/close |
| `expense/`, `expense_category/` | Expense controllers | Expense tracking |
| `tax_group/`, `tax_rate/` | Tax controllers | Tax config |
| `invoice_layout/`, `invoice_scheme/` | Invoice settings | Numbering & layout templates config |
| `report/` | `ReportController` (55 files) | GST purchase/sales, stock, P&L, trending products, tax, register report, etc. |
| `role/`, `user/`, `manage_user/` | Role/User controllers | RBAC & user management |
| `notification/`, `notification_template/` | Notification controllers | SMS/email templates |
| `printer/` | `PrinterController` | Receipt printer config |
| `dashboard/`, `dashboard_configurator/`, `home/` | Dashboard controllers | Main dashboard + drag-drop widget configurator |
| `transaction_payment/` | Payment controller | Payment recording UI |
| `restaurant/` | Restaurant module controllers | Table/order mode (kept from upstream, dormant) |
| `myfatoorah/` | MyFatoorah gateway | Third-party payment views |
| `activity_log/`, `documents_and_notes/` | respective controllers | Audit trail, attachments/notes widget |
| `backup/`, `install/` | Backup/Installer | DB backup UI, installer wizard |
| `auth/` | Laravel auth scaffolding | Login/register/password reset |
| `emails/` | Mailable templates | Sent via `Mail::` |
| `components/` | Blade components | `avatar`, `filters`, `widget`, `static`, `document_help_text` |
| `layouts/` | Base layouts | See §2 |
| `vendor/` (top-level) | Published package views | `charts`, `mail`, `notifications`, `nwidart`, `pagination`, `passport` — Laravel's `vendor:publish` output, not app code |

**Modules note**: `Modules/{Accounting,AssetManagement,Connector,Essentials,Spreadsheet,Superadmin,SupportTicket}/Resources/views`
have their own separate view trees (not under `resources/views`), wired into the main layout via
`@include('essentials::...')`-style calls and `Module::has(...)` checks.

## 2. Layouts & Page Structure

`resources/views/layouts/app.blade.php` is the main authenticated-app shell:
- Detects POS mode (`$pos_layout`) for `pos/create|edit|payment` URLs → switches to a stripped
  `header-pos`/`footer_pos` layout (no sidebar).
- Renders `<div id="app">` — an empty Vue mount point (Vue is present but nearly unused; only
  `resources/js/components/Example.vue` + Passport's OAuth scaffolding use it).
- Partials in `layouts/partials/`: `css`, `javascripts`, `extracss`, `header`/`header-pos`/
  `header-restaurant`/`header-auth`, `footer`/`footer_pos`/`footer-restaurant`, `sidebar`, `logo`,
  `language_btn`, `notification_list`, `calculator` (POS calculator widget), `module_form_part`.
- Other layouts: `auth.blade.php`/`auth2.blade.php`/`guest.blade.php`, `home.blade.php`,
  `install.blade.php`, `restaurant.blade.php`, `supplier.blade.php` (dedicated shell for
  `supplier_portal`), `module-assets.blade.php` (injects per-module JS/CSS via `Module::has()`).

**Frontend stack**: a **hybrid** of an **AdminLTE 2** theme
(`hold-transition`, `skin-blue-light`, `sidebar-mini`, Bootstrap-based) **plus a custom Dava India
re-skin built with Tailwind CSS** utility classes prefixed `tw-` (e.g. `tw-flex`, `tw-bg-gray-100`)
to avoid clashing with Bootstrap/AdminLTE. The sidebar has extensive custom Dava-branded CSS
(green/orange theme, gradients) hardcoded inline in `layouts/partials/css.blade.php`, alongside a
runtime theme-color map (`session('business.theme_color')`) for multi-tenant color theming.

Core JS libs: **jQuery**, **DataTables** (`yajra/laravel-datatables-oracle` backing it),
**Select2**, **Moment.js**, **Dropzone.js**, **FullCalendar**, Bootstrap popovers — classic
AdminLTE-era jQuery stack, not a modern SPA.

## 3. Asset Pipeline

- **No root-level `webpack.mix.js`/`package.json`** — compiled assets (`public/css/app.css`,
  `public/js/app.js`, `public/js/vendor.js`) are committed directly to `public/` rather than built
  from a live root Mix pipeline in this checkout (source `resources/js/app.js`,
  `resources/sass/app.scss` still exist, but there's no visible root build entry point).
- A separate **Tailwind build**: `public/css/tailwind/app.css` / `public/js/tailwind/app.js`,
  loaded first in `<head>` — no `tailwind.config.js` at root, so its build tooling lives outside
  this checkout or was pre-compiled.
- **Per-module Mix pipelines**: `Modules/{Accounting,AssetManagement,Connector,Essentials,Spreadsheet,Superadmin}`
  each have their own `webpack.mix.js` + `package.json` — self-contained per-module frontend builds.

## 4. Notable Custom JS (`public/js/`)

`pos.js` (core POS terminal logic — cart, product search, payment; the most business-critical
file), `product.js`, `purchase.js`/`purchase_return.js`, `sell_return.js`,
`stock_adjustment.js`/`stock_transfer.js`, `opening_stock.js`, `labels.js`, `printer.js`,
`payment.js`, `report.js`, `restaurant.js`, `documents_and_note.js`, `home.js`,
`common.js`/`functions.js`/`init.js`/`app.js` (shared globals), `help-tour.js`,
`support_ticket.js`, `login.js`, `gridstack-all.js` (powers `dashboard_configurator`),
`vendor.js` (bundled 3rd-party libs), `tailwind/app.js`, `lang/*.js` (per-locale JS i18n bundles).

`public/css/`: `app.css`, `vendor.css`, `init.css`, `rtl.css` (RTL languages), `gridstack.min.css`,
plus `tailwind/`.

## 5. Localization (`lang/`)

19 locale directories: `ar, ce, de, en, es, fr, he, hi, id, lo, nl, ps, pt, ro, sq, tr, vi` +
`vendor/` (package translations, e.g. Passport). RTL languages listed in
`config('constants.langs_rtl')`, triggering `css/rtl.css` + `dir="rtl"`.

Files organized **per-domain**, not one giant `messages.php`. `lang/en/` includes:
`account.php`, `auth.php`, `barcode.php`, `brand.php`, `business.php`, `cash_register.php`,
`category.php`, `composition.php` (Dava-specific), `contact.php`, `dashboard.php`, `doctor.php`
(Dava-specific), `expense.php`, `home.php`, `invoice.php`, `lang_v1.php` (legacy catch-all),
`messages.php`, `myfatoorah.php`, `printer.php`, `product.php`, `purchase.php`, `receipt.php`,
`report.php`, `restaurant.php`, `role.php`, `sale.php`, `stock_adjustment.php`, `tax_rate.php`,
`tooltip.php`, `unit.php`, `user.php`, `validation.php`.

**Three parallel i18n systems** must be kept in sync when adding a new user-facing string: Laravel
Blade `__()` (`lang/`), a JS lang bundle (`public/js/lang/{locale}.js`, loaded in
`javascripts.blade.php`, falls back to `en.js`), and vendor-plugin locale files (Select2, jQuery
Validation) — all keyed off `session('user.language')`.

## 6. PDF Generation

Two PDF engines available: `barryvdh/laravel-dompdf` (^2.0) and `mpdf/mpdf` (^8.1).

- `resources/views/labels/partials/{pdf,preview,preview_2}.blade.php` — barcode/label sheet PDF
  (`LabelsController`).
- `resources/views/purchase/receipts/download_pdf.blade.php` and
  `resources/views/purchase_order/receipts/download_pdf.blade.php` — PO/GRN PDF downloads.
- `resources/views/sale_pos/receipts/` — invoice/receipt template set (PDF and/or thermal print
  depending on settings): `classic`, `detailed`, `elegant`, `elegant_modified`, `slim`, `slim2`,
  `pharmacy` (**Dava-specific receipt layout**), `english-arabic`, `columnize-taxes`,
  `delivery_note`, `packing_slip`, `partial/` (shared fragments). Selected via the
  `invoice_layout`/`invoice_scheme` settings screens.
- Also touched by `ContactController`, `NotificationController` (customer statements, notification
  attachments).

## Key Takeaways

1. Views map 1:1 to controllers by folder name — very navigable.
2. Dava-specific additions: `composition/`, `doctor/`, `pharmacy/`, `supplier_portal/` (a full
   secondary portal), and the `pharmacy.blade.php` receipt template.
3. Frontend is legacy jQuery/AdminLTE 2 being incrementally re-skinned with Tailwind (`tw-`
   prefix) — expect both idioms in the same blade file; no unified modern build pipeline at root.
4. Three overlapping i18n mechanisms must stay in sync for any new user-facing string.
5. PDF/print output is template-driven through `invoice_layout`/`invoice_scheme` pointing at
   `sale_pos/receipts/*.blade.php`, separate from ad-hoc `download_pdf.blade.php` files for
   purchase-side documents.

## 2026-08 additions & two conventions worth obeying

New view folders: `resources/views/expiry_disposal/` (store despatch, warehouse receive,
disposals, printable Certificate of Destruction, return detail, receive modal) and
`Modules/Superadmin/Resources/views/{compliance,expiry_analytics,bounce_rate}/`.

**1. Put page JS in `@section('javascript')`, never inside `@section('content')`.**
`layouts/app.blade.php` yields `content` at ~L96 but only loads jQuery (bundled in
`js/vendor.js`) at ~L138, where it yields `javascript`. A `<script>` left in the content
section runs before jQuery exists, dies on `$ is not defined`, and every handler below it
silently never binds — no visible error, the button just does nothing.

**2. In a Bootstrap modal, the `<form>` must wrap `.modal-content`, not sit inside
`.modal-body`.** A form opened inside the body is implicitly closed by that div during HTML
parsing, which leaves a submit button in `.modal-footer` outside the form — the button appears
normal and submits nothing.

**Tables**: use a plain `$('#id').DataTable()`. `public/js/common.js` (~L365) sets project-wide
defaults, so pagination, search, page-length and the CSV/Excel/PDF/print/column-visibility
buttons come for free. Mark non-data columns `class="not-export"`, and give computed columns
a `data-order` attribute or they sort as text.
