# OGSG Asset Management System

A comprehensive asset management solution built for Ogun State Government (OGSG) to streamline the tracking, requesting, approval, and procurement of government assets across multiple ministries.

![Laravel](https://img.shields.io/badge/Laravel-12-FF2D20?style=flat-square&logo=laravel)
![PHP](https://img.shields.io/badge/PHP-8.3-777BB4?style=flat-square&logo=php)
![Tailwind CSS](https://img.shields.io/badge/Tailwind-3.x-06B6D4?style=flat-square&logo=tailwindcss)
![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)

## Features

### 🏛️ Multi-Ministry Support

- Centralized asset registry across all government ministries
- Ministry-scoped asset views and requests
- Cross-ministry asset transfers

### 📋 Multi-Level Approval Workflow

- **Ministry Admin** → Creates asset requests
- **Central Admin** → Reviews and forwards to approvers
- **Approver Level 1** (Auditor General) → First sign-off
- **Approver Level 2** (Permanent Secretary) → Final approval
- Full audit trail of all approval decisions

### 🛒 Procurement Management

- Supplier portal for quote submissions
- Order tracking from creation to delivery
- Automatic asset creation upon delivery
- PDF generation for procurement orders

### 📊 Reporting & Analytics

- Asset inventory reports by ministry/category
- Request status tracking
- Procurement analytics
- Export to PDF and Excel

### 💰 Depreciation Tracking

- Straight-line depreciation calculation
- Scheduled monthly depreciation updates
- Asset value tracking over time

## Tech Stack

- **Backend:** Laravel 12, PHP 8.3
- **Frontend:** Blade, Alpine.js, Tailwind CSS 3
- **Database:** MySQL / PostgreSQL
- **Authentication:** Laravel Breeze
- **Authorization:** Spatie Laravel Permission
- **Exports:** Maatwebsite Excel, DomPDF

## Installation

### Prerequisites

- PHP 8.3+
- Composer
- Node.js 18+
- MySQL 8+ or PostgreSQL 14+

### Setup

1. **Clone the repository**

    ```bash
    git clone https://github.com/praizo/ogsg-asset-management.git
    cd ogsg-asset-management
    ```

2. **Install dependencies**

    ```bash
    composer install
    npm install
    ```

3. **Environment configuration**

    ```bash
    cp .env.example .env
    php artisan key:generate
    ```

4. **Configure database** in `.env`:

    ```env
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=ogsg_assets
    DB_USERNAME=root
    DB_PASSWORD=
    ```

5. **Run migrations and seeders**

    ```bash
    php artisan migrate --seed
    ```

6. **Build assets**

    ```bash
    npm run build
    ```

7. **Start the development server**
    ```bash
    php artisan serve
    # Or use Laravel Herd/Valet
    ```

## Default Users

After seeding, the following test accounts are available:

| Role                       | Email                 | Password   |
| -------------------------- | --------------------- | ---------- |
| Super Admin                | `admin@ogsg.gov.ng`   | `password` |
| Central Admin              | `central@ogsg.gov.ng` | `password` |
| Ministry Admin (Education) | `edu@ogsg.gov.ng`     | `password` |
| Approver Level 1           | `auditor@ogsg.gov.ng` | `password` |
| Approver Level 2           | `permsec@ogsg.gov.ng` | `password` |
| Supplier                   | `sales@techsupply.ng` | `password` |

## User Roles & Permissions

| Role               | Capabilities                                            |
| ------------------ | ------------------------------------------------------- |
| **Super Admin**    | Full system access, user management                     |
| **Admin**          | Asset CRUD, categories, suppliers, procurement, reports |
| **Ministry Admin** | Create requests, view assigned assets                   |
| **Approver 1**     | First-level approval of forwarded requests              |
| **Approver 2**     | Final approval after Level 1                            |
| **Supplier**       | Submit quotes, mark orders as delivered                 |

## Key Workflows

### Asset Request Flow

```
Ministry creates request
        ↓
Admin reviews & forwards
        ↓
Approver 1 approves
        ↓
Approver 2 approves (Final)
        ↓
Admin creates procurement order
        ↓
Supplier submits quote
        ↓
Admin confirms order
        ↓
Supplier marks delivered → Assets auto-created
```

### Alternative: Fulfill from Inventory

```
Ministry creates request
        ↓
Admin reviews → Fulfills from existing stock
        ↓
Assets transferred to ministry (No procurement needed)
```

## Scheduled Tasks

Add to crontab for production:

```bash
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1
```

### Scheduled Jobs

- **Asset Depreciation** - Runs monthly on the 1st at 2:00 AM

### Manual Commands

```bash
# Trigger depreciation manually
php artisan assets:depreciate

# Clear caches
php artisan optimize:clear
```

## API Endpoints

The system uses traditional web routes. Key route groups:

- `/admin/*` - Admin dashboard and management
- `/ministry/*` - Ministry-specific views
- `/approvals/*` - Approval workflow
- `/supplier/*` - Supplier portal

## Testing

```bash
# Run all tests
php artisan test

# Run with coverage
php artisan test --coverage

# Run specific test
php artisan test --filter=AssetRequestTest
```

## Project Structure

```
app/
├── Http/
│   ├── Controllers/
│   │   ├── Admin/           # Admin controllers
│   │   ├── Ministry/        # Ministry controllers
│   │   └── Supplier/        # Supplier controllers
│   └── Requests/            # Form request validation
├── Models/                  # Eloquent models
├── Services/                # Business logic layer
├── Jobs/                    # Queued jobs
├── Imports/                 # Excel/CSV imports
└── Exports/                 # Excel exports

resources/views/
├── admin/                   # Admin views
├── ministry/                # Ministry views
├── supplier/                # Supplier views
├── approvals/               # Approval workflow views
├── dashboards/              # Role-specific dashboards
├── components/ui/           # Reusable UI components
└── layouts/                 # App layouts
```

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

For support, please contact the IT department or create an issue in this repository.

---

**Built with ❤️ for Ogun State Government**
