<div class="container">
    <div class="row">
        <div class="page-header">
            <h4><?= $this->lang->line('Configure columns in table below and press "Import" button') ?></h4>
        </div>
    </div>
    <div class="row">
        <form method="post" class="form-horizontal" action="<?= base_url($this->uri->uri_string() . '?step=process') ?>">
            <div id="table_container">
                <table class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <?php foreach (array_keys($fields) as $col => $field) : ?>
                            <th><?= form_dropdown('col[' . $col . ']', $fields, $field) ?></th>
                        <?php endforeach; ?>
                    </thead>
                    <tbody>
                    <?php foreach ($schedules as $row => $cols) : ?>
                        <tr<?= $row == 0 ? ' class="muted"' : ''; ?>>
                            <?php foreach ($cols as $val) : ?>
                                <td><?= $val ?></td>
                            <?php endforeach; ?>
                            <?php if (count($fields) > count($cols)) : ?>
                                <?php for ($a = count($cols); $a < count($fields); $a++) : ?>
                                    <td></td>
                                <?php endfor; ?>
                            <?php endif; ?>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <div class="form-actions">
                <a class="btn btn-large"
                   href="<?= base_url($this->uri->uri_string() . '?step=file') ?>"><?= $this->lang->line('Back') ?></a>
                <input type="submit" class="btn btn-large btn-primary" name="import" value="Import" onclick="$(this).hide()">
            </div>
        </form>
    </div>
</div>
<style>
    #table_container {
        overflow: scroll;
        max-height: 400px;
    }

    #table_container th {
        position: sticky;
        top: 0;
        background: white;
        box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
    }
</style>