<?php

namespace Modules\Vrc\Http\Controllers\Registers;

use Modules\Vrc\Entities\VrcEnvironmentalAspect;

/** ISO 14001 environmental aspects & impacts register. */
class EnvironmentalAspectController extends AbstractRegisterController
{
    protected function schema(): array
    {
        $sig = ['low' => 'Low', 'medium' => 'Medium', 'high' => 'High'];
        $locations = $this->locations();

        return [
            'key' => 'env_aspects',
            'route' => 'vrc.env.aspects',
            'model' => VrcEnvironmentalAspect::class,
            'permView' => 'vrc.environment.view',
            'permManage' => 'vrc.environment.manage',
            'title' => 'Environmental Aspects',
            'singular' => 'Aspect',
            'defaults' => ['status' => 'active'],
            'columns' => [
                ['key' => 'activity', 'label' => 'Activity'],
                ['key' => 'aspect', 'label' => 'Aspect'],
                ['key' => 'impact', 'label' => 'Impact'],
                ['key' => 'significance', 'label' => 'Significance', 'map' => $sig, 'badge' => ['low' => 'success', 'medium' => 'warning', 'high' => 'danger']],
                ['key' => 'review_due', 'label' => 'Review due', 'type' => 'date'],
            ],
            'fields' => [
                ['name' => 'activity', 'label' => 'Activity', 'type' => 'text', 'required' => true, 'col' => 6, 'max' => 191],
                ['name' => 'aspect', 'label' => 'Environmental aspect', 'type' => 'text', 'required' => true, 'col' => 6, 'max' => 191],
                ['name' => 'impact', 'label' => 'Impact', 'type' => 'text', 'col' => 8, 'max' => 191],
                ['name' => 'significance', 'label' => 'Significance', 'type' => 'select', 'options' => $sig, 'col' => 4, 'default' => 'low'],
                ['name' => 'location_id', 'label' => 'Location', 'type' => 'select', 'options' => $locations, 'col' => 4],
                ['name' => 'review_due', 'label' => 'Review due', 'type' => 'date', 'col' => 4],
                ['name' => 'controls', 'label' => 'Controls', 'type' => 'textarea', 'col' => 12, 'rows' => 2],
                ['name' => 'monitoring', 'label' => 'Monitoring', 'type' => 'textarea', 'col' => 12, 'rows' => 2],
            ],
        ];
    }
}
