{extends file="admin-layout.tpl"}

{block name="no-return-functions"}
    {$admin_current_location = 'tools'}
{/block}

{block name="page-title"}{intl l='Export'}: {$TITLE}{/block}

{block name="check-resource"}admin.export{/block}
{block name="check-access"}view{/block}

{block name="main-content"}
    {loop type="export" name="export" id=$exportId}
        <div id="wrapper" class="container">
            <nav>
                <ul class="breadcrumb">
                    <li>
                        <a href="{url path='admin/home'}">{intl l='Home'}</a>
                    </li>
                    <li>
                        <a href="{url path='admin/tools'}">{intl l='Tools'}</a>
                    </li>
                    <li>
                        <a href="{url path='admin/export'}">{intl l="Exports"}</a>
                    </li>
                    <li>
                        {intl l="Export"}&nbsp;: {$TITLE}
                    </li>
                </ul>
            </nav>

            {if $general_error}
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-danger">{$general_error}</div>
                    </div>
                </div>
            {/if}

            {form name="thelia.export"}
                <form action="{$URL nofilter}" method="post" {form_enctype}>
                    {form_hidden_fields}

                    <div class="row">
                        <div class="col-md-12">
                            <div class="general-block-decorator">
                                <div class="title title-without-tabs">
                                    {intl l='Export'}: {$TITLE}
                                </div>

                                {if $form_error}
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="alert alert-danger">{$form_error_message}</div>
                                        </div>
                                    </div>
                                {/if}

                                {hook name="export.top" type="page" id=$ID}

                                {include 'includes/export-form-body.html'}

                                {hook name="export.bottom" type="page" id=$ID}

                                {ifloop rel="serializer"}
                                    <div>
                                        <button class="btn btn-primary" type="submit">{intl l="Do this export"}</button>
                                    </div>
                                {/ifloop}
                            </div>
                        </div>
                    </div>
                </form>
            {/form}
        </div>
    {/loop}
{/block}

{block name="javascript-initialization"}
    {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
        <script type="text/javascript" src="{$asset_url}"></script>
    {/javascripts}
{/block}

{block name="javascript-last-call"}
    {literal}
    <script type="text/javascript">
        $(document).ready(function() {

            var compression_switch = $("#export-compression-switch");
            var compression_row = $(".export-compression-selection-row");

            compression_switch.on("switch-change", function(e, data) {
                var is_checked = data.value;

                if (is_checked) {
                    compression_row.show("slow");
                } else {
                    compression_row.hide("slow");
                }
            });

            if ($("input[type=checkbox]", compression_switch).is(":checked")) {
                compression_row.show();
            } else {
                compression_row.hide();
            }

            $(".make-switch", export_modal).bootstrapSwitch();
            $("#real-export-modal").modal();

        });
    </script>

    {hook name="export.js" location="export-js" }
    {/literal}
{/block}
