> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mileapp.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Order Management

The Order Management page is the central hub for creating, sending, and tracking delivery orders. Administrators create orders and send them to vendor teams, while vendors accept or reject incoming orders and track delivery progress.

<Note>
  Required permission:

  * View Data Source
  * Create Data Source
  * Edit Data Source
  * View Task
  * Create Task
  * View Team
  * View User
</Note>

## The Order Table

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/3z8jNNYAZ6iXNKDw/images/add-on/transport-vendor-management/order-list.png?fit=max&auto=format&n=3z8jNNYAZ6iXNKDw&q=85&s=3119715bcd50c3336adbaa9eb4615c23" alt="Order Management page" width="600" data-path="images/add-on/transport-vendor-management/order-list.png" />
</div>

<p><em>The Order Management page showing a filterable list of delivery orders with status, vendor, and priority columns.</em></p>

Each row displays:

| Column               | Description                                                                          |
| -------------------- | ------------------------------------------------------------------------------------ |
| **Order Number**     | A unique identifier generated from the configured prefix                             |
| **Status**           | Current state: Draft, Sent, Accepted, In Progress, Completed, Rejected, or Cancelled |
| **Vendor**           | The vendor team assigned to fulfill the order                                        |
| **Priority**         | Urgency level: Low, Normal, High, or Urgent                                          |
| **Delivery Address** | The destination address for the delivery                                             |
| **Date**             | When the order was created                                                           |
| **Actions**          | Send, Edit, Delete, Cancel, Accept, or Reject depending on status and role           |

## Searching and Filtering

Use the filter bar at the top of the page to narrow down orders.

| Control        | What It Filters                                                     |
| -------------- | ------------------------------------------------------------------- |
| **Status**     | Shows only orders with the selected status                          |
| **Vendor**     | Shows only orders assigned to the selected vendor team (admin only) |
| **Priority**   | Shows only orders with the selected priority level                  |
| **Date Range** | Shows only orders created within the selected date range            |

Filters combine. For example, selecting Status "Sent" and Vendor "PT Logistics" shows only sent orders for that vendor.

## Creating an Order

<Note>
  Required permission:

  * Create Data Source
</Note>

1. Click the **+ New** button on the Order Management page.
2. Fill in the order details in the form.

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/3z8jNNYAZ6iXNKDw/images/add-on/transport-vendor-management/order-form.png?fit=max&auto=format&n=3z8jNNYAZ6iXNKDw&q=85&s=2a64ed875a8419b4967d87fc9a80d529" alt="Order creation form" width="600" data-path="images/add-on/transport-vendor-management/order-form.png" />
</div>

<p><em>The order form with sections for general information, pickup details, delivery details, and items.</em></p>

The form is divided into four sections:

### General Information

| Field        | Required | Description                                                    |
| ------------ | -------- | -------------------------------------------------------------- |
| **Vendor**   | Yes      | The vendor team that will handle this delivery                 |
| **Priority** | Yes      | Urgency level: Low, Normal, High, or Urgent. Default is Normal |
| **Notes**    | No       | Additional instructions or remarks for the vendor              |

### Pickup Details

| Field              | Required | Description                                     |
| ------------------ | -------- | ----------------------------------------------- |
| **Pickup Address** | Yes      | Address where the driver will collect the items |
| **Contact Name**   | No       | Name of the person at the pickup location       |
| **Contact Phone**  | No       | Phone number for the pickup contact             |
| **Schedule**       | No       | Planned pickup date and time                    |
| **Coordinate**     | No       | GPS coordinates (latitude and longitude)        |

### Delivery Details

| Field                | Required | Description                              |
| -------------------- | -------- | ---------------------------------------- |
| **Delivery Address** | Yes      | Destination address for the delivery     |
| **Contact Name**     | No       | Name of the recipient                    |
| **Contact Phone**    | No       | Phone number for the delivery contact    |
| **Schedule**         | No       | Planned delivery date and time           |
| **Coordinate**       | No       | GPS coordinates (latitude and longitude) |

### Items

Click **Add Item** to add items to the order. Each item has:

| Field         | Description                     |
| ------------- | ------------------------------- |
| **Item Name** | Name or description of the item |
| **Quantity**  | Number of units                 |
| **Weight**    | Weight per unit                 |
| **Unit**      | Unit of measurement (e.g., kg)  |
| **Notes**     | Additional notes for the item   |

3. Click **Save** to save the order as a draft.

## Sending an Order

1. Find the order with **Draft** or **Rejected** status in the table.
2. Click the **Send** icon in the Actions column.
3. Confirm the action in the popup dialog.

The order status changes to **Sent** and the vendor team can now see it.

## Accepting an Order

When a vendor receives a sent order, they can accept it by assigning a driver and vehicle.

1. Find the order with **Sent** status.
2. Click the **Accept** button.

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/19jU7aar_WdTR7aT/images/add-on/transport-vendor-management/accept-order-modal.png?fit=max&auto=format&n=19jU7aar_WdTR7aT&q=85&s=706096068dcf303b32993641fe5c0a2f" alt="Accept order modal" width="600" data-path="images/add-on/transport-vendor-management/accept-order-modal.png" />
</div>

<p><em>The Accept Order modal where vendors select a driver from their team and a vehicle from their fleet.</em></p>

3. Select a **driver** from your team members.
4. Select a **vehicle** from your fleet (only active vehicles are shown).
5. Click **Confirm** to accept the order.

After acceptance:

* The order status changes to **Accepted**
* A pickup task is automatically created and assigned to the selected driver
* The driver receives the pickup task in the MileApp mobile app

## Rejecting an Order

1. Find the order with **Sent** status.
2. Click the **Reject** button.
3. Enter a rejection reason in the dialog.
4. Click **Confirm** to reject.

The order status changes to **Rejected**. The administrator can edit the order and resend it to the same or a different vendor.

## Viewing Order Details

Click on any order row to open the detail view.

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/3z8jNNYAZ6iXNKDw/images/add-on/transport-vendor-management/order-detail.png?fit=max&auto=format&n=3z8jNNYAZ6iXNKDw&q=85&s=7ba63c178e8e635ba9a5ff3154074621" alt="Order detail view" width="600" data-path="images/add-on/transport-vendor-management/order-detail.png" />
</div>

<p><em>The order detail view showing the timeline stepper, pickup and delivery details, assignment info, and task tracking.</em></p>

The detail view shows:

| Section              | Description                                                                       |
| -------------------- | --------------------------------------------------------------------------------- |
| **Timeline**         | Visual stepper showing order progression (Draft → Sent → In Progress → Completed) |
| **Pickup Details**   | Address, contact, schedule, and coordinate                                        |
| **Delivery Details** | Address, contact, schedule, and coordinate                                        |
| **Assignment**       | Assigned driver name, email, and vehicle (visible after acceptance)               |
| **Task Status**      | Current status of the pickup and delivery tasks                                   |
| **Driver Tracking**  | Last known driver location with a link to view on the map                         |
| **Rejection Reason** | Displayed if the order was rejected                                               |

## Cancelling an Order

1. Find the order in the table (status must be Sent, Accepted, or In Progress).
2. Click the **Cancel** icon in the Actions column.
3. Confirm the cancellation in the popup dialog.

<Note>
  Cancelling an in-progress order does not automatically cancel the associated pickup or delivery tasks. You may need to manage those tasks separately.
</Note>

## Order Status Lifecycle

| Status          | Description                                                 |
| --------------- | ----------------------------------------------------------- |
| **Draft**       | Order created but not yet sent to the vendor                |
| **Sent**        | Order sent to the vendor, awaiting acceptance               |
| **Accepted**    | Vendor accepted and assigned a driver and vehicle           |
| **In Progress** | The pickup task has been started by the driver              |
| **Completed**   | Both pickup and delivery tasks finished (set automatically) |
| **Rejected**    | Vendor rejected the order; admin can edit and resend        |
| **Cancelled**   | Admin cancelled the order                                   |

## Admin vs Vendor Actions

| Action                        | Admin | Vendor |
| ----------------------------- | ----- | ------ |
| Create order                  | Yes   | No     |
| Edit order (draft/rejected)   | Yes   | No     |
| Delete order (draft/rejected) | Yes   | No     |
| Send order                    | Yes   | No     |
| Cancel order                  | Yes   | No     |
| Accept order                  | No    | Yes    |
| Reject order                  | No    | Yes    |
| View order details            | Yes   | Yes    |
