<?php
if (!$_REQUEST['edit']) {
    ?>

    <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" class="style" enctype="multipart/form-data">
        <fieldset class="<?= $_REQUEST['action'] == 'csv' ? ' show ' : '' ?>">
            <h1><a class="show el">Manage CSVs<i class="fa fa-caret-right"></i></a></h1>
            <div class="row">
                <input type="submit" name="export" value="Export CSV" class="BUTTON"/>
            </div>
            <div class="row">
                <input type="submit" name="import" value="Import CSV" class="BUTTON" />
                <input type="file" name="csv" id="csv" />
            </div>
            <input type="hidden" name="action" value="csv" />
        </fieldset>
    </form>
    <script type="text/javascript">
        $(function() {
            $("input:file[name=csv]").hide();
            $("input:submit[name=import]").click(function(e) {
                if (!$("input:file[name=csv]").is(':visible')) {
                    e.preventDefault();
                    $("input:file[name=csv]").fadeIn(250);
                }
                else if ($("input:file[name=csv]").val() == '') {
                    e.preventDefault();
                    $("input:file[name=csv]").click();
                }
            });
        });
    </script>
    <?php
}