<?php

namespace PloverCRM\Modules\FluentCRM\Helpers;

use PloverCRM\Common\BaseLogViewer;

/**
 * Log Viewer Helper
 * 
 * Handles viewing and downloading FluentCRM logs
 */
class LogViewer extends BaseLogViewer
{
    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct('fluent-crm', 'fluent-crm');
    }

    /**
     * Render log viewer for FluentCRM
     */
    public static function render(): void
    {
        $viewer = new self();
        $logs = $viewer->getRecentLogs();

        echo '<div style="padding: 20px; background: #fff; border: 1px solid #ddd; border-radius: 4px; margin-top: 20px;">';
        echo '<h3>FluentCRM Provider Logs</h3>';
        echo '<p>View logs for FluentCRM provider operations (last 7 days).</p>';

        $viewer->renderLogEntries($logs);

        if (!empty($logs)) {
            echo '<div style="margin-top: 15px;">';
            echo \PloverCRM\Common\BaseLogViewer::getDownloadButton('fluent-crm');
            echo '</div>';
        }

        echo '</div>';
    }
}
