<?php
/**
 * @package RSForm! Pro
 * @copyright (C) 2007-2019 www.rsjoomla.com
 * @license GPL, http://www.gnu.org/copyleft/gpl.html
 */

defined('_JEXEC') or die;

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

HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('script', 'com_rsform/admin/import.js', array('relative' => true, 'version' => 'auto'));

Text::script('COM_RSFORM_PLEASE_MAP_AT_LEAST_A_FIELD_FROM_THE_DROPDOWN');
Text::script('COM_RSFORM_YOU_HAVE_SELECTED_MULTIPLE_FIELDS');
Text::script('ERROR');
?>
<form action="<?php echo Route::_('index.php?option=com_rsform&view=submissions&layout=import'); ?>" method="post" name="adminForm" id="adminForm">
    <div style="overflow-x: auto; min-height: 400px;">
    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <?php
            for ($i = 0; $i < $this->countHeaders; $i++) {
            ?>
                <th>
                    <select name="header[]">
                        <?php echo HTMLHelper::_('select.options', $this->options, 'value', 'text', isset($this->selected[$i]) ? $this->selected[$i] : false); ?>
                    </select>
                </th>
            <?php
            }
            ?>
        </tr>
        </thead>
        <tbody>
        <?php
        foreach ($this->previewData as $line)
        {
            ?>
            <tr>
                <?php foreach ($line as $column) { ?>
                    <td><?php echo $this->escape($column); ?></td>
                <?php } ?>
            </tr>
            <?php
        }
        ?>
        </tbody>
    </table>
    </div>

    <?php echo HTMLHelper::_( 'form.token' ); ?>
    <input type="hidden" name="formId" value="<?php echo $this->formId; ?>" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="option" value="com_rsform" />
</form>