<?php
/**
 * @version        1.14.0
 * @package        Joomla
 * @subpackage     Edocman
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2011 - 2025 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\HTML\HTMLHelper;

HTMLHelper::_('bootstrap.framework');
?>

<div class="row">
    <div class="col-md-12" style="padding-top:20px;">
        <h1><?php echo Text::_('EDOCMAN_EXPORT_IMPORT_MANAGER'); ?></h1>
        <p class="lead"><?php echo Text::_('EDOCMAN_EXPORT_IMPORT_DESC'); ?></p>
    </div>
</div>

<!-- Statistics Cards -->
<div class="row mb-4">
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                <i class="fas fa-folder fa-2x text-primary mb-2"></i>
                <h4><?php echo $this->stats['categories']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_CATEGORIES'); ?></small>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                <i class="fas fa-file fa-2x text-success mb-2"></i>
                <h4><?php echo $this->stats['documents']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_DOCUMENTS'); ?></small>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                                <i class="fas fa-tags fa-2x text-warning mb-2"></i>
                <h4><?php echo $this->stats['tags']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_TAGS'); ?></small>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                <i class="fas fa-link fa-2x text-info mb-2"></i>
                <h4><?php echo $this->stats['document_categories']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_RELATIONS'); ?></small>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                <i class="fas fa-hashtag fa-2x text-secondary mb-2"></i>
                <h4><?php echo $this->stats['document_tags']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_DOC_TAGS'); ?></small>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="card text-center">
            <div class="card-body">
                <i class="fas fa-layer-group fa-2x text-dark mb-2"></i>
                <h4><?php echo $this->stats['levels']; ?></h4>
                <small><?php echo Text::_('EDOCMAN_LEVELS'); ?></small>
            </div>
        </div>
    </div>
</div>

<!-- Quick Actions -->
<div class="row mb-4">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-download"></i> <?php echo Text::_('EDOCMAN_EXPORT_DATA'); ?></h5>
            </div>
            <div class="card-body">
                <p><?php echo Text::_('EDOCMAN_EXPORT_DESC'); ?></p>
                <a href="<?php echo Route::_('index.php?option=com_edocman&view=exportdb'); ?>" class="btn btn-success btn-lg">
                    <i class="fas fa-download"></i> <?php echo Text::_('EDOCMAN_START_EXPORT'); ?>
                </a>
            </div>
        </div>
    </div>
    
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-upload"></i> <?php echo Text::_('EDOCMAN_IMPORT_DATA'); ?></h5>
            </div>
            <div class="card-body">
                <p><?php echo Text::_('EDOCMAN_IMPORT_DESC'); ?></p>
                <a href="<?php echo Route::_('index.php?option=com_edocman&view=importdb'); ?>" class="btn btn-primary btn-lg">
                    <i class="fas fa-upload"></i> <?php echo Text::_('EDOCMAN_START_IMPORT'); ?>
                </a>
            </div>
        </div>
    </div>
</div>

<!-- Recent Data -->
<div class="row">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-folder"></i> <?php echo Text::_('EDOCMAN_RECENT_CATEGORIES'); ?></h5>
            </div>
            <div class="card-body">
                <?php if (!empty($this->recentCategories)): ?>
                    <div class="list-group">
                        <?php foreach ($this->recentCategories as $category): ?>
                            <div class="list-group-item">
                                <h6 class="mb-1"><?php echo htmlspecialchars($category->title); ?></h6>
                                <small class="text-muted">
                                    <?php echo Text::_('EDOCMAN_LEVEL'); ?>: <?php echo $category->level; ?> | 
                                    <?php echo Text::_('EDOCMAN_PUBLISHED'); ?>: <?php echo $category->published ? Text::_('JYES') : Text::_('JNO'); ?>
                                </small>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php else: ?>
                    <p class="text-muted"><?php echo Text::_('EDOCMAN_NO_CATEGORIES'); ?></p>
                <?php endif; ?>
            </div>
        </div>
    </div>
    
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-file"></i> <?php echo Text::_('EDOCMAN_RECENT_DOCUMENTS'); ?></h5>
            </div>
            <div class="card-body">
                <?php if (!empty($this->recentDocuments)): ?>
                    <div class="list-group">
                        <?php foreach ($this->recentDocuments as $document): ?>
                            <div class="list-group-item">
                                <h6 class="mb-1"><?php echo htmlspecialchars($document->title); ?></h6>
                                <small class="text-muted">
                                    <?php echo Text::_('EDOCMAN_DOWNLOADS'); ?>: <?php echo $document->downloads; ?>
                                </small>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php else: ?>
                    <p class="text-muted"><?php echo Text::_('EDOCMAN_NO_DOCUMENTS'); ?></p>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

<!-- Database Size Information -->
<?php if (!empty($this->databaseSize)): ?>
<div class="row mt-4">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-database"></i> <?php echo Text::_('EDOCMAN_DATABASE_SIZE'); ?></h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th><?php echo Text::_('EDOCMAN_TABLE_NAME'); ?></th>
                                <th><?php echo Text::_('EDOCMAN_SIZE_MB'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($this->databaseSize as $table): ?>
                                <tr>
                                    <td><?php echo htmlspecialchars($table->table_name); ?></td>
                                    <td><?php echo $table->size_mb; ?> MB</td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>

