<?php

if (!defined('ABSPATH')) { exit; }

class AIEO_DMM_ERP_Database extends AIEO_DMM_Module_Base {

    public function get_id()       { return 'erp_database'; }
    public function get_label()    { return __('ERP Database', 'ai-eshop-optimizer'); }
    public function get_priority() { return 130; }
    public function get_group()    { return 'tools'; }

    public function is_pro_locked() { return true; }
    public function get_pro_promo() {
        return array(
            'title'       => __('ERP Database Connections', 'ai-eshop-optimizer'),
            'description' => __('Encrypted connection registry for the ERP Bridge and Insights Remote DB export. Sodium-encrypted credentials, full audit trail, multiple simultaneous connections supported — same infrastructure powering both directions.', 'ai-eshop-optimizer'),
            'bullets'     => array(
                __('Sodium-encrypted passwords — credentials never round-trip through the admin UI.', 'ai-eshop-optimizer'),
                __('Multiple connections — point Bridge at the ERP and Remote Export at a BI warehouse simultaneously.', 'ai-eshop-optimizer'),
                __('Test-connection button with full driver-level error reporting.', 'ai-eshop-optimizer'),
            ),
        );
    }

    public function render_subtab() {
        if (!class_exists('AIEO_ERP')) {
            echo '<div class="notice notice-error"><p>'
                . esc_html__('AIEO_ERP class not loaded — see plugin bootstrap.', 'ai-eshop-optimizer')
                . '</p></div>';
            return;
        }
        $vars = AIEO_ERP::instance()->build_page_context();
        $this->render_template('erp-database.php', $vars);
    }
}
