# Admin API: Get Report Time

## Endpoint
`GET /admin/report-time`

## Description
Retrieves the report time (time_from and time_to) for the authenticated admin based on their company ID and user ID (uid). Returns the most recent report time configuration for the admin's company.

## Authentication
Requires admin authentication via Bearer token (JWT or auth_token).

## Query Parameters
None required. Uses authenticated admin's company_id and uid automatically.

## cURL Examples

### Get Report Time for Authenticated Admin
```bash
curl -X GET "https://dayloanapp.xesstechlink.com/admin/report-time" \
  -H "accept: application/json" \
  -H "authorization: Bearer YOUR_ADMIN_JWT_TOKEN"
```

## Response Format

### Success Response (200 OK) - Report Time Found
```json
{
  "status": "success",
  "message": "Report time retrieved successfully",
  "data": {
    "id": 2,
    "company_id": 15,
    "admin_uid": 4,
    "time_from": "09:00:00",
    "time_to": "20:30:00",
    "created_at": "2025-12-10T09:40:54.000Z"
  }
}
```

### Success Response (200 OK) - No Report Time Found
```json
{
  "status": "success",
  "message": "No report time found for this admin and company",
  "data": {
    "company_id": 15,
    "admin_uid": 4,
    "time_from": null,
    "time_to": null,
    "report_time": null
  }
}
```

### Error Response (401 Unauthorized)
```json
{
  "status": "error",
  "message": "Admin authentication required"
}
```

### Error Response (500 Internal Server Error)
```json
{
  "status": "error",
  "message": "Failed to fetch report time",
  "error": "Error message details"
}
```

## Response Fields

### Data Object Fields (When Found)
- `id`: Report time record ID
- `company_id`: Company ID (automatically from authenticated admin)
- `admin_uid`: Admin user ID (uid from authenticated admin)
- `time_from`: Start time in HH:MM:SS format (e.g., "09:00:00")
- `time_to`: End time in HH:MM:SS format (e.g., "20:30:00")
- `created_at`: Timestamp when the report time was created

### Data Object Fields (When Not Found)
- `company_id`: Company ID
- `admin_uid`: Admin user ID
- `time_from`: null
- `time_to`: null
- `report_time`: null

## Notes

1. **Authentication**: Replace `YOUR_ADMIN_JWT_TOKEN` with a valid admin JWT token obtained from `/admin/login` or `/?admin_login=true`.

2. **Automatic Filtering**: 
   - The API automatically uses the authenticated admin's `com_id` (company_id)
   - The API automatically uses the authenticated admin's `uid` (user ID)
   - No need to pass these as parameters

3. **Multiple Records**: If multiple report time records exist for the same admin and company, the API returns the most recent one (ordered by `created_at DESC`).

4. **Time Format**: 
   - Times are returned in `HH:MM:SS` format (24-hour format)
   - Example: "09:00:00" for 9:00 AM, "20:30:00" for 8:30 PM

5. **Use Cases**:
   - Get admin's working hours for display
   - Set default check-in/check-out times
   - Display report time in admin dashboard
   - Validate admin's working hours

## Example with Real Server URL

```bash
curl -X GET "https://dayloanapp.xesstechlink.com/admin/report-time" \
  -H "accept: application/json" \
  -H "authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
```

## Database Schema Reference

The API queries the `report_time` table with the following structure:
- `id`: Primary key
- `com_id`: Company ID (matches admin's company)
- `uid`: User ID (matches admin's uid)
- `time_from`: Start time
- `time_to`: End time
- `created_at`: Creation timestamp

## Related Endpoints

- `GET /admin/dashboard/stats` - Get dashboard statistics
- `GET /admin/company` - Get current company information

