# Bank Details module — installation

This patch is based on `plat_mt4_final(3).zip`. It contains only the new and modified files for the Bank Details module, with the original application folder structure.

## What is added

**Admin → Settings → Bank Details**

- Add, edit, delete, activate and deactivate multiple receiving bank accounts.
- Add/edit forms open in the existing Bootstrap offcanvas interface.
- Fields: account title, bank name, beneficiary / account holder, currency, IBAN, account number, SWIFT / BIC, routing number / sort code, bank address, beneficiary address, payment reference, transfer instructions, display order and status.
- Provide at least one of IBAN or account number. IBAN format/checksum and SWIFT/BIC format are checked. These checks do not verify account existence or ownership.
- Account numbers remain strings, preserving leading zeroes.
- New accounts start **Inactive**. Activate them after reviewing the details.
- Search and filter by status/currency. Lists are paginated. Lower display-order values come first, with record ID breaking ties.
- Create/edit/status/delete operations use AJAX; validation errors keep the form and entered values open.

**Client portal → Bank Details**

- A separate sidebar menu item appears alongside External Payment Solutions.
- The menu and route use the same eligibility rule as the existing external-payment page: the authenticated client must own at least one local MT4 trading account. Otherwise the route returns to the dashboard with an explanatory message.
- Clients can only read active accounts. There are no client-side bank-management endpoints.
- Copy buttons support the modern clipboard API, a legacy fallback and manual selection when browser permissions block copying.
- A currency filter appears when more than one currency is published.
- The page uses the existing client layout and theme colour variables, with a responsive mobile layout.
- Saved changes are read on the next client page load. There is no live, open-page bank-details refresh subscription.

Existing external-payment settings, deposit/withdrawal workflows and MT4 balances are not changed. No transfer is initiated and no deposit is submitted or approved by this module. Bank identifiers and instructions are excluded from generic admin change-notification payloads; publication metadata can still be reported through the existing notification system.

## Before uploading

Back up the database and these five files from the deployed application:

```
app/Services/SystemActivityNotificationService.php
resources/views/admin/includes/menu.blade.php
resources/views/client/includes/menu.blade.php
routes/adm.php
routes/client.php
```

This patch is for the supplied ZIP. Compare/merge those five files rather than overwriting them blindly if your server has newer changes made after that ZIP.

Put the application into maintenance mode before copying the patch:

```bash
php artisan down
```

Run commands from the Laravel project root — the directory containing `artisan`.

## Upload

Merge the patch's `app`, `database`, `public`, `resources`, `routes` and `docs` folders into the matching existing folders. Replace only the matching files, not whole directories. Do not put them inside another `plat_mt4_final` subfolder.

The patch does not contain `.env`, dependencies, media uploads, a database dump or unrelated theme files. Do not replace those on your server.

## Apply the module

After copying the files, run:

```bash
php artisan optimize:clear
composer dump-autoload -o
php artisan migrate --path=database/migrations/2026_09_16_120000_create_bank_details_table.php --path=database/migrations/2026_09_16_120100_add_bank_details_permissions.php --force
php artisan permission:cache-reset
php artisan up
```

Use the same PHP version as the application. The two explicit migration paths restrict this command to the new module migrations; unrelated pending migrations are not applied.

`composer dump-autoload -o` refreshes class discovery; it does not install or update dependencies. The existing vendor packages are sufficient. No `npm install` or `npm run build` is required: the new CSS/JavaScript is provided directly in `public/adm`.

Do not run `migrate:fresh`, `migrate:reset` or a general database reseed for this patch.

If a command fails, keep maintenance mode enabled while correcting it. Use `php artisan up` after the migrations and permission-cache reset complete successfully.

## Permissions

The migration creates a **Bank Details** permission group:

```
bank_details_access
bank_details_create
bank_details_edit
bank_details_delete
```

The project's full-access `Admin` role, recognized super-admin role names and users already marked as superadmins receive the new permissions. Other roles are not changed.

For a custom role, enable **Settings → Access** so the Settings section is visible, then assign the required Bank Details permissions in the existing Roles interface. `Edit / Activate` controls editing and activation/deactivation. An access-only role cannot mutate records.

If the menu is missing, check permissions, clear the permission cache and sign out/in. Do not modify the authentication guard configuration.

## Start using it

1. Open **Admin → Settings → Bank Details** and select **Add Bank Account**.
2. Fill in the receiving account details. Add the payment reference and instructions as plain text. References are displayed exactly as entered; no client/account placeholders are substituted.
3. Review the details, select **Active — visible to clients**, and save.
4. Sign in as a client that has an MT4 account. Open **Bank Details** beside **External Payment Solutions**.
5. Confirm the details and copy buttons. Deactivate the account in admin, then reload the client page to confirm it is hidden.

## Files included

Modified:

```
app/Services/SystemActivityNotificationService.php
resources/views/admin/includes/menu.blade.php
resources/views/client/includes/menu.blade.php
routes/adm.php
routes/client.php
```

New:

```
app/Http/Controllers/AdminBankDetailController.php
app/Http/Controllers/ClientBankDetailController.php
app/Http/Requests/BankDetailRequest.php
app/Models/BankDetail.php
app/Rules/ValidBankIban.php
database/migrations/2026_09_16_120000_create_bank_details_table.php
database/migrations/2026_09_16_120100_add_bank_details_permissions.php
public/adm/css/bank-details.css
public/adm/js/admin-bank-details.js
public/adm/js/client-bank-details.js
resources/views/admin/bank_details/index.blade.php
resources/views/admin/bank_details/_list.blade.php
resources/views/client/bank-details/index.blade.php
docs/BANK_DETAILS_INSTALLATION.md
```

## Checks performed

- PHP syntax checks for new/modified PHP and compiled Blade files; JavaScript syntax checks.
- 43 PHP checks covering validation, normalization, casts, mass-assignment protection, route middleware, query filtering/ordering, notification redaction, full-layout rendering, empty states and HTML escaping.
- 26 offline Chromium interface checks with fixture responses: create/edit offcanvas, input interaction, 422-error recovery, submission methods, activation/deletion requests, filters, clipboard behaviours and mobile layout/navigation.
- Migration SQL compiled for MySQL and SQLite. The SQLite DDL was executed against a temporary test database, with checks for CRUD, active status, leading zeroes, null-on-delete audit references and preservation of unrelated data.

The test environment does not have PHP database drivers, so the full Laravel database-backed workflow and permission migration were not executed against a live MySQL database. No connection was made to your server or MT4 API. Verify the installation on staging and check access for your actual roles before making receiving accounts active.

## Reverting the code

To undo the code patch, enter maintenance mode, restore the five modified files from your backup, refresh autoloading and clear caches, then leave maintenance mode. Leave the new bank table intact to preserve any details you entered. The restored routes/menus will no longer expose the module. Do not reset the entire application database.
