# Create Event from RM Request — Implementation Plan

## Problem

The RM request details page (`/rm/rm-request-details/{uuid}`) has a "Create Event" button (line 15 of `details.blade.php`) that does nothing. The admin needs to create events **on behalf of the client** who raised the RM request — the same flow that happens via the client app's "browse vendors" API, but done from the admin panel.

## Current State

- VisoAdmin has **zero** event creation capability
- Events are only created via `POST /event/create` in `OotboAPI/VisoAPI/app/Http/Controllers/MVP/EventController.php`
- The "Create Event" button is a dead `<button>` with no `onclick` or `href`

## What Gets Inherited from RM Request

The `client_rm_requests` table has fields we pre-fill:

| RM Field | Event Field | Notes |
|----------|------------|-------|
| `client_id` | `events.client_id` | Hidden — the event owner |
| `country_id` | `events.country_id` | Pre-selected in dropdown |
| `state_id` | `events.state_id` | Pre-selected in dropdown |
| `city_id` | `events.cities_id` | Pre-selected in dropdown |
| `category` | `events.category` | Pre-selected (references `categories.id`) |
| `budget` | Displayed as reference | Shown read-only, not stored in events |

## Files Changed (7 total)

| # | File | Action | Doc |
|---|------|--------|-----|
| 1 | `routes/web.php` | Modify | [01-routes.md](01-routes.md) |
| 2 | `app/Http/Controllers/RmController.php` | Modify | [02-rm-controller.md](02-rm-controller.md) |
| 3 | `app/Http/Controllers/LocationController.php` | Modify | [03-location-controller.md](03-location-controller.md) |
| 4 | `app/Models/EventModel.php` | Modify | [04-event-model.md](04-event-model.md) |
| 5 | `resources/views/rm/details.blade.php` | Modify | [05-details-blade.md](05-details-blade.md) |
| 6 | `resources/views/rm/createEvent.blade.php` | **New** | [06-create-event-blade.md](06-create-event-blade.md) |
| 7 | `public/assets/custom/js/createEvent.js` | **New** | [07-create-event-js.md](07-create-event-js.md) |

## Database Tables Affected

| Table | Operation | Details |
|-------|-----------|---------|
| `events` | INSERT | New event row |
| `event_services` | INSERT | One row per selected service |
| `client_rm_requests` | UPDATE | Set status=2, link event UUID |

No migrations needed — all required columns already exist.

## Event Creation Flow

```
Admin clicks "Create Event" on RM details page
    |
    v
GET /rm/create-event/{rmUuid}
    |-- Fetch RM request + client details
    |-- Fetch dropdown data (countries, states, cities, services, categories)
    |-- Pre-fill form with RM data
    |
    v
Admin fills remaining fields (name, date, time, guests, description, services)
    |
    v
POST /rm/store-event
    |-- Validate all fields
    |-- BEGIN TRANSACTION
    |   |-- Generate unique human_usable_id (EVN + 9-digit random)
    |   |-- INSERT into events table
    |   |-- INSERT into event_services (one per service)
    |   |-- UPDATE client_rm_requests (status=2, link event)
    |-- COMMIT
    |
    v
Redirect to /rm/rm-request-details/{rmUuid} with success flash
```
