108 lines
3.5 KiB
Markdown
108 lines
3.5 KiB
Markdown
# ABM Approval Functionality
|
|
|
|
## Overview
|
|
The ABM (Area Business Manager) approval functionality allows authorized users to approve neblogistic submissions by changing their status to "L1 Approved". This function is designed to be called from email links and displays a dedicated approval page.
|
|
|
|
## Access URL
|
|
```
|
|
/neblogisticreport/abmapprove?submission_id={SUBMISSION_ID}
|
|
```
|
|
|
|
Example:
|
|
```
|
|
https://web.buildrapport.co/neblogisticreport/abmapprove?submission_id=1755620200-671264c4-14fc-4f15-88c6-9ac3af78c0fa
|
|
```
|
|
|
|
## Requirements
|
|
- User must be authenticated
|
|
- User must have the ABM role: `1655449175-a39a5017-8232-4d58-NEBMITRAABM-90d06bc733d0`
|
|
|
|
## Allowed Status Transitions
|
|
The following statuses can be approved to "L1 Approved":
|
|
- Pending
|
|
- Submitted
|
|
- Under Review
|
|
- Pending Approval
|
|
|
|
## Response
|
|
The function returns a dedicated view (`neblogisticreport.abmapprove`) that displays:
|
|
|
|
### Success Response
|
|
- Green checkmark icon
|
|
- "Approval Successful" title
|
|
- Success message with details
|
|
- Request details including:
|
|
- Submission ID
|
|
- Employee Name
|
|
- Depot Name
|
|
- Doctor Name
|
|
- Previous and new status
|
|
- Request date
|
|
- Action buttons to navigate to reports or dashboard
|
|
- Auto-redirect to reports page after 10 seconds
|
|
|
|
### Error Response
|
|
- Red warning icon
|
|
- "Approval Failed" title
|
|
- Error message explaining the issue
|
|
- Available request details (if any)
|
|
- Action buttons to navigate to reports or dashboard
|
|
|
|
## Security Features
|
|
- Authentication required
|
|
- Role-based access control (ABM role only)
|
|
- Input validation for submission_id format
|
|
- Comprehensive logging of all actions
|
|
- CSRF protection (inherited from Laravel)
|
|
|
|
## Error Scenarios
|
|
- **Unauthenticated**: "Please login to perform this action"
|
|
- **Insufficient permissions**: "Access denied. Only ABM users can perform this action."
|
|
- **Missing submission_id**: "Submission ID is required"
|
|
- **Invalid format**: "Invalid submission ID format."
|
|
- **Record not found**: "Record not found with the provided submission ID"
|
|
- **Already approved**: "Status is already L1 Approved"
|
|
- **Invalid status**: "Current status '{status}' does not allow approval to L1 Approved"
|
|
- **Database error**: "Failed to update status. Please try again."
|
|
|
|
## Logging
|
|
All actions are logged with the following information:
|
|
- User ID and name
|
|
- Submission ID
|
|
- IP address
|
|
- User agent
|
|
- Action result (success/failure)
|
|
- Previous and new status
|
|
|
|
## Usage Example
|
|
```php
|
|
// In email templates
|
|
<a href="https://web.buildrapport.co/neblogisticreport/abmapprove?submission_id={{$data['submission_id']}}">
|
|
Approve Request
|
|
</a>
|
|
```
|
|
|
|
## View File
|
|
The response is displayed using the `resources/views/neblogisticreport/abmapprove.blade.php` view file, which provides:
|
|
- Responsive design
|
|
- Clear success/error indicators
|
|
- Detailed request information
|
|
- Navigation buttons
|
|
- Auto-redirect functionality for successful approvals
|
|
|
|
## Testing
|
|
Run the test suite to verify functionality:
|
|
```bash
|
|
php artisan test tests/Feature/NeblogisticreportControllerTest.php
|
|
```
|
|
|
|
## Database Changes
|
|
The method updates the `status` field in the `neblogistic` table from the current status to "L1 Approved".
|
|
|
|
## Notes
|
|
- This is a GET endpoint designed for easy access via email links
|
|
- All actions are logged for audit purposes
|
|
- The method follows Laravel best practices and existing project patterns
|
|
- The view provides a professional, user-friendly interface
|
|
- Successful approvals auto-redirect to the reports page after 10 seconds
|
|
- The page is fully responsive and works on all devices |