<?php

namespace modules\cors;

use Yii;

/**
 * HSE Fatigue & Risk Calculator Module
 *
 * This module provides HSE-compliant fatigue and risk index calculations
 * for shift work patterns. It can be integrated into any Yii2 application.
 */
class Module extends \yii\base\Module
{
    public $controllerNamespace = 'modules\cors\controllers';

    public function init()
    {
        parent::init();

        // Register translations if needed
        if (!isset(Yii::$app->i18n->translations['cors*'])) {
            Yii::$app->i18n->translations['cors*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => '@modules/cors/messages',
            ];
        }
        if(Yii::$app->name == 'NGauge Commerce') {
            \Yii::$app->urlManager->addRules([
                'datests/<action:[\w\-]+>' => 'cors/datests/<action>',
                'finesandcharges/<action:[\w\-]+>' => 'cors/finesandcharges/<action>',
                'fueldata/<action:[\w\-]+>' => 'cors/fueldata/<action>',
                'licensecats/<action:[\w\-]+>' => 'cors/licensecats/<action>',
                'licensechecks/<action:[\w\-]+>' => 'cors/licensechecks/<action>',
                'licensedata/<action:[\w\-]+>' => 'cors/licensedata/<action>',
                'licenseendorsements/<action:[\w\-]+>' => 'cors/licenseendorsements/<action>',
                'sightcheck/<action:[\w\-]+>' => 'cors/sightcheck/<action>',
                'vehicle/<action:[\w\-]+>' => 'cors/vehicle/<action>',
                'vehiclekeys/<action:[\w\-]+>' => 'cors/vehiclekeys/<action>',
                'vehiclereminders/<action:[\w\-]+>' => 'cors/vehiclereminders/<action>',
                'vehicleservicehistory/<action:[\w\-]+>' => 'cors/vehicleservicehistory/<action>',
                'vehicleservicingbe/<action:[\w\-]+>' => 'cors/vehicleservicingbe/<action>',
            ]);
        } else{
            \Yii::$app->urlManager->addRules([
            ]);
        }
    }
}