{block name="content"}


    <div class="row">

        <div class="col-md-3 ib_profile_width">
            {$menu}
        </div>

        <div class="col-md-9">


            <div class="ibox float-e-margins animated fadeIn">
                <div class="ibox-title">
                    <h3>Settings</h3>
                </div>
                <div class="ibox-content">

                    <div class="row" style="margin-bottom: 15px;">
                        <div class="col-md-6"><h4>Your Stores</h4></div>
                        <div class="col-md-6">
                            <a class="btn btn-primary pull-right" href="{$_url}wcsuite/app/add-store">Add New Store</a>
                        </div>
                    </div>

                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th scope="col">#</th>
                            <th scope="col">Name</th>
                            <th scope="col">URL</th>
                            <th scope="col">Key</th>
                            <th scope="col">Manage</th>
                        </tr>
                        </thead>
                        <tbody>

                        {if $integrations_count > 0}

                            {foreach $integrations as $integration}
                                <tr>
                                    <th scope="row">{counter}</th>
                                    <td>{$integration->name}</td>
                                    <td><a href="{$integration->url}" target="_blank">{$integration->url}</a> </td>
                                    <td>{$integration->key}</td>
                                    <td>
                                        {if !$integration->is_default}
                                            <a href="{$_url}wcsuite/app/make-default-integration/{$integration->id}" class="btn btn-success">Make Default</a>
                                        {/if}
                                        <a href="{$_url}wcsuite/app/edit-integration/{$integration->id}" class="btn btn-primary">Edit</a>
                                        <a href="{$_url}wcsuite/app/delete-integration/{$integration->id}" class="btn btn-danger">Delete</a>

                                    </td>
                                </tr>
                            {/foreach}

                            {else}

                            <tr>
                                <td colspan="6" class="text-center">
                                    <a href="{$_url}wcsuite/app/add-store">You didn't add any Store, Click here to add one</a>
                                </td>
                            </tr>

                        {/if}

                        </tbody>
                    </table>

                    <hr>

                    <h4>Webhooks</h4>
                    <p>To add webhook, go to WooCommerce → Settings → Advanced → Webhooks & add following actions.</p>
                    <p>Use generated secret & select WP REST API Integration V3 when adding hooks.</p>

                    {if !isset($config['woocommerce_webhooks_secret']) || ($config['woocommerce_webhooks_secret'] == '')}
                        <a href="{$_url}wcsuite/app/webhook-generate-secret" class="btn btn-primary">Generate secret</a>
                        {else}
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <tr>
                                    <td><a href="{$_url}wcsuite/app/webhook-generate-secret" class="btn btn-primary">Regenerate secret</a></td>
                                    <td>
                                        <input class="form-control" value="{$config['woocommerce_webhooks_secret']}" onClick="this.setSelectionRange(0, this.value.length)">
                                    </td>
                                </tr>
                            </table>
                        </div>
                    {/if}

                    <hr>

                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <tr>
                                <th>Name</th>
                                <th>Status</th>
                                <th>Topic</th>
                                <th>Delivery Url</th>

                            </tr>
                            {foreach $hooks as $hook}
                                <tr>
                                    <td>{$hook['name']}</td>
                                    <td><span class="label label-success">Active</span> </td>
                                    <td>{$hook['name']}</td>
                                    <td><input class="form-control" value="{$hook['delivery_url']}" onClick="this.setSelectionRange(0, this.value.length)"></td>

                                </tr>
                            {/foreach}
                        </table>
                    </div>

                </div>
            </div>



        </div>

    </div>
{/block}