# Dev Log — 2026-03-31 ## Non-EB Claims Module — Session 5 --- ### 1. Asset File Upload — `createClaim()` API Endpoint Replaced the silent `handleAssetFileUpload()` call with inline validation to give proper API error responses. **Problems fixed:** - Invalid file extension was silently ignored — claim was created without the file, no error returned - Upload failure had no error response - Success response had no `asset_file` field **Changes in `app/Controllers/Api/NonEbClaimApiController.php`:** - Reads `asset_file` from request directly - Returns **415** with allowed types listed if extension is not in `UPLOAD_EXT_ASSET_FILES` (`pdf, xls, xlsx, csv`) - Returns **400** if `loss_description` is missing when file is provided - Returns **500** if `file_Upload()` fails - Success response now includes `"asset_file": "filename.pdf"` (or `null` if none sent) - `asset_file` is optional — omitting it creates the claim normally **How to call:** ``` POST /api/v1/non-eb-claim/create Content-Type: multipart/form-data Authorization: Bearer client_policy_id, nature_of_loss, loss_location, loss_date, [asset_file] ``` --- ### 2. Sidebar — Claims Menu Restructured **`app/Views/layout/header.php`** | Before | After | |---|---| | New claim | New EB Claim | | Non EB Claims | EB Claim List | | Claim List | New Non EB Claim | | *(nothing)* | Non EB Claim List | Final menu order: 1. **New EB Claim** → `openTicketTypeAskModal()` 2. **EB Claim List** → `/ticket/list` 3. **New Non EB Claim** → `/non-eb-claim/new` 4. **Non EB Claim List** → `/non-eb-claim/list` --- ### 3. New Non-EB Claim — Route Added **`app/Config/Routes.php`** - Added `GET non-eb-claim/new` → `NonEbClaimController::claimForm/50` (bare route, policy type hardcoded to 50 temporarily) - Existing `new/(:any)` route preserved for dynamic use --- ### 4. Non-EB List Page — Add Button Bypasses Policy Type Modal **`app/Views/non_eb_claim_search.php`** - `#policyTypeModal` HTML commented out - `goToNewClaim()` JS function commented out **`app/Views/non_eb_claim_list.php`** - Add button action changed from `openPolicyTypeModal()` → `window.location.href = base_url('non-eb-claim/new/50')` - `openPolicyTypeModal()` JS function commented out --- ### 5. New Non-EB Claim Form — Nhance Logo Loader on Client Select **`app/Views/non_eb_claim_form.php`** - Shows global nhance gif loader (`.loader` / `.loader-mask`) when client is selected and AJAX fires to fetch branches/policies - Hides loader on AJAX success and on AJAX error (so loader never gets stuck) --- ### 6. New API Endpoints — Policies List & Claim Statuses **`app/Controllers/Api/NonEbClaimApiController.php`** — 2 new methods added #### `GET /api/v1/non-eb-claim/statuses` - Returns all `ticket_claim_status` rows where `ticket_type = 50` (Non-EB, hardcoded) and `is_active = 1` - Returns: `id`, `claim_status`, `display_name` - No request body required #### `POST /api/v1/non-eb-claim/policies` - Accepts: `client_id` (MD5 hash, required), `client_branch_id` (integer, required) - Validates MD5 format — returns 400 if not a 32-char hex string - Queries `client_policy` using `MD5(cp.client_id)` for secure lookup - Filters: `client_branch_id`, `is_active = 1`, `policy_type.allocg IN ('Non-EB', 'Marine')` - Returns: `id`, `policy_no`, `policy_type_id`, `policy_type_name`, `insurer_id`, `insurer_name`, `insurer_short_name`, `policy_start_date`, `policy_end_date` **`app/Config/Routes.php`** — 2 new routes added inside `api/v1/non-eb-claim` group: ``` GET api/v1/non-eb-claim/statuses → listClaimStatuses POST api/v1/non-eb-claim/policies → listPolicies ``` --- ### Files Modified Today | File | Changes | |---|---| | `app/Controllers/Api/NonEbClaimApiController.php` | Asset file inline validation + 415/500 errors + asset_file in success response; added `listClaimStatuses()` and `listPolicies()` | | `app/Config/Routes.php` | Added `non-eb-claim/new` bare route; added `statuses` and `policies` API routes | | `app/Views/layout/header.php` | Claims sidebar menu restructured (4 items) | | `app/Views/non_eb_claim_search.php` | policyTypeModal + goToNewClaim commented out | | `app/Views/non_eb_claim_list.php` | Add button redirects directly; openPolicyTypeModal commented out | | `app/Views/non_eb_claim_form.php` | Nhance loader shown/hidden around getBranchAndPolicy AJAX |