<?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;
use Joomla\CMS\Session\Session;

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

<div class="row">
    <div class="col-md-12" style="padding-top:20px;">
        <h1><i class="fas fa-download"></i> <?php echo Text::_('EDOCMAN_EXPORT_DATA'); ?></h1>
        <p class="lead"><?php echo Text::_('EDOCMAN_EXPORT_DATA_DESC'); ?></p>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-cog"></i> <?php echo Text::_('EDOCMAN_EXPORT_OPTIONS'); ?></h5>
            </div>
            <div class="card-body">
                <form method="post" action="<?php echo Route::_('index.php?option=com_edocman&task=exportdb.download'); ?>" id="exportForm">
                    <?php echo HTMLHelper::_('form.token'); ?>
                    
                    <div class="mb-3">
                        <label class="form-label"><?php echo Text::_('EDOCMAN_SELECT_TABLES'); ?>:</label>
                        <div class="mb-2">
                            <button type="button" class="btn btn-sm btn-outline-secondary" id="selectAll">
                                <?php echo Text::_('EDOCMAN_SELECT_ALL'); ?>
                            </button>
                            <button type="button" class="btn btn-sm btn-outline-secondary ms-2" id="selectNone">
                                <?php echo Text::_('EDOCMAN_SELECT_NONE'); ?>
                            </button>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="categories" id="categories" checked>
                                    <label class="form-check-label" for="categories">
                                        <?php echo Text::_('EDOCMAN_CATEGORIES'); ?> (<?php echo $this->stats['categories']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="documents" id="documents" checked>
                                    <label class="form-check-label" for="documents">
                                        <?php echo Text::_('EDOCMAN_DOCUMENTS'); ?> (<?php echo $this->stats['documents']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="document_categories" id="doc_categories" checked>
                                    <label class="form-check-label" for="doc_categories">
                                        <?php echo Text::_('EDOCMAN_DOCUMENT_CATEGORIES'); ?> (<?php echo $this->stats['document_categories']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="tags" id="tags" checked>
                                    <label class="form-check-label" for="tags">
                                        <?php echo Text::_('EDOCMAN_TAGS'); ?> (<?php echo $this->stats['tags']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="document_tags" id="doc_tags" checked>
                                    <label class="form-check-label" for="doc_tags">
                                        <?php echo Text::_('EDOCMAN_DOCUMENT_TAGS'); ?> (<?php echo $this->stats['document_tags']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="tables[]" 
                                           value="levels" id="levels" checked>
                                    <label class="form-check-label" for="levels">
                                        <?php echo Text::_('EDOCMAN_LEVELS'); ?> (<?php echo $this->stats['levels']; ?> <?php echo Text::_('EDOCMAN_RECORDS'); ?>)
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label"><?php echo Text::_('EDOCMAN_EXPORT_TYPE'); ?>:</label>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" name="export_type" 
                                   id="both" value="both" checked>
                            <label class="form-check-label" for="both">
                                <?php echo Text::_('EDOCMAN_STRUCTURE_AND_DATA'); ?>
                            </label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" name="export_type" 
                                   id="structure" value="structure">
                            <label class="form-check-label" for="structure">
                                <?php echo Text::_('EDOCMAN_STRUCTURE_ONLY'); ?>
                            </label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" name="export_type" 
                                   id="data" value="data">
                            <label class="form-check-label" for="data">
                                <?php echo Text::_('EDOCMAN_DATA_ONLY'); ?>
                            </label>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="include_files" 
                                   id="include_files" value="1">
                            <label class="form-check-label" for="include_files">
                                <?php echo Text::_('EDOCMAN_INCLUDE_FILES'); ?>
                            </label>
                            <div class="form-text">
                                <?php echo Text::_('EDOCMAN_INCLUDE_FILES_DESC'); ?>
                            </div>
                        </div>
                    </div>
                    
                    <div class="d-grid">
                        <button type="submit" class="btn btn-success btn-lg" id="exportBtn">
                            <i class="fas fa-download"></i> <?php echo Text::_('EDOCMAN_EXPORT_NOW'); ?>
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-info-circle"></i> <?php echo Text::_('EDOCMAN_EXPORT_INFO'); ?></h5>
            </div>
            <div class="card-body">
                <h6><?php echo Text::_('EDOCMAN_CURRENT_STATISTICS'); ?>:</h6>
                <ul class="list-unstyled">
                    <li><i class="fas fa-folder text-primary"></i> <?php echo Text::_('EDOCMAN_CATEGORIES'); ?>: <strong><?php echo $this->stats['categories']; ?></strong></li>
                    <li><i class="fas fa-file text-success"></i> <?php echo Text::_('EDOCMAN_DOCUMENTS'); ?>: <strong><?php echo $this->stats['documents']; ?></strong></li>
                    <li><i class="fas fa-tags text-warning"></i> <?php echo Text::_('EDOCMAN_TAGS'); ?>: <strong><?php echo $this->stats['tags']; ?></strong></li>
                    <li><i class="fas fa-link text-info"></i> <?php echo Text::_('EDOCMAN_RELATIONS'); ?>: <strong><?php echo $this->stats['document_categories']; ?></strong></li>
                </ul>
                
                <hr>
                
                <h6><?php echo Text::_('EDOCMAN_EXPORT_NOTES'); ?>:</h6>
                <ul class="small">
                    <li><?php echo Text::_('EDOCMAN_EXPORT_NOTE_1'); ?></li>
                    <li><?php echo Text::_('EDOCMAN_EXPORT_NOTE_2'); ?></li>
                    <li><?php echo Text::_('EDOCMAN_EXPORT_NOTE_3'); ?></li>
                    <li><?php echo Text::_('EDOCMAN_EXPORT_NOTE_4'); ?></li>
                </ul>
            </div>
        </div>
        
        <div class="card mt-3">
            <div class="card-header bg-warning">
                <h5><i class="fas fa-exclamation-triangle"></i> <?php echo Text::_('EDOCMAN_IMPORTANT_NOTES'); ?></h5>
            </div>
            <div class="card-body">
                <div class="alert alert-warning">
                    <strong><?php echo Text::_('EDOCMAN_BACKUP_REMINDER'); ?></strong>
                    <p class="mb-0 small"><?php echo Text::_('EDOCMAN_BACKUP_REMINDER_DESC'); ?></p>
                </div>
            </div>
        </div>
    </div>
</div>
