<div id="flapFeeds" class="tab-pane fade boxFlex">
    <div class="form-group main-panel-title">
        <div class="col-md-3">
            <h1 class="h4">
                Feed aktivován
            </h1>
        </div>
        <div class="col-md-1">
            {if $body.data.feed_token}
                {$activated = 'Y'}
            {else}
                {$activated = 'N'}
            {/if}
            {print_toggle name="feed_activated" value=$activated}
        </div>
    </div>

    <div id="feed_settings" style="display:none">
        <div class="form-group">
            <div class="col-md-4 control-label">
                <label>Současný token</label>
            </div>
            <div class="col-md-4 input-height">
                <p class="input-height">
                    <strong>
                        {if !$body.data.feed_token}
                            Po uložení bude vygenerován
                        {else}
                            {$body.data.feed_token}
                        {/if}
                    </strong>
                </p>
                <input type="hidden" name="data[feed_token]" value="{$body.data.feed_token}">
            </div>

            <div class="col-md-3 text-right">
                <button type="submit" class="btn btn-success btn-block" name="acn" value="regenerateToken">
                    <span class="glyphicon glyphicon-refresh"></span>&nbsp;Přegenerovat token
                </button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-4 control-label">
                <label>Zobrazit reálné počty kusů skladem</label>
            </div>
            <div class="col-md-1">
                {print_toggle name="feed_in_store" value=$body.data.feed_in_store}
            </div>
        </div>

        {if findModule(Modules::XML_FEEDS_B2B, 'feed_id')}
            <div class="form-group">
                <div class="col-md-4 control-label">
                    <label>Adresa feedu</label>
                </div>
                <div class="col-md-8">
                    {if !$body.data.feed_token}
                        <p class="input-height"><strong>Po uložení bude vygenerován</strong></p>
                    {else}
                        <div class="input-group">
                            <span class="form-control input disabled">{path('kupshop_xmlfeed_b2b_feed', ['feed' => 'b2b', 'token' => $body.data.feed_token], 0)}</span>
                            <span class="input-group-btn">
                                <button type="button"
                                        data-copy-clipboard="{path('kupshop_xmlfeed_b2b_feed', ['feed' => 'b2b', 'token' => $body.data.feed_token], 0)}"
                                        class="btn"
                                        title="{'clipboard-copy'|translate:'button'}">
                                   <i class="glyphicon glyphicon-copy"></i>
                                </button>
                            </span>
                        </div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-4 control-label">
                    <label>Adresa feedu pro stažení</label>
                </div>
                <div class="col-md-8">
                    {if !$body.data.feed_token}
                        <p class="input-height"><strong>Po uložení bude vygenerován</strong></p>
                    {else}
                        <div class="input-group">
                            <span class="form-control input disabled">{path('kupshop_xmlfeed_b2b_feed', ['feed' => 'b2b', 'token' => $body.data.feed_token], 0)}?download=1</span>
                            <span class="input-group-btn">
                                <button type="button"
                                        data-copy-clipboard="{path('kupshop_xmlfeed_b2b_feed', ['feed' => 'b2b', 'token' => $body.data.feed_token], 0)}?download=1"
                                        class="btn"
                                        title="{'clipboard-copy'|translate:'button'}">
                                   <i class="glyphicon glyphicon-copy"></i>
                                </button>
                            </span>
                        </div>
                    {/if}
                </div>
            </div>
        {/if}
        {if findModule(Modules::XML_FEEDS_B2B, Modules::SUB_FEED_IDS)}
            <div class="form-group">
                <div class="col-md-4 control-label">
                    <label>Výběr B2B feedů</label>
                </div>
                <div class="col-md-8">
                    <select class="selecter" data-filter-type="multiselect" name="data[custom_data][b2b_feeds][]" multiple="multiple">
                        {foreach $tab.data.b2b_feeds_options as $feedID => $feedName}
                            {if in_array($feedID, $tab.data.b2b_feeds_default)}
                                <option value="{$feedID}" selected="selected" disabled="disabled">{$feedName}</option>
                            {else}
                                <option value="{$feedID}"{if in_array($feedID, $body.data.data.b2b_feeds)} selected="selected"{/if}>{$feedName}</option>
                            {/if}
                        {/foreach}
                   </select>
                </div>
            </div>
            {foreach $tab.data.b2b_feeds_options as $selectedFeedID => $feedName}
                {if !in_array($selectedFeedID, $tab.data.b2b_feeds_enabled)}{continue}{/if}
                <div class="form-group">
                    <div class="col-md-4 control-label">
                        <label>{$feedName}</label>
                        <small>- Adresa feedu</small>
                    </div>
                    <div class="col-md-8">
                        {if !$body.data.feed_token}
                            <p class="input-height"><strong>Po uložení bude vygenerován</strong></p>
                        {else}
                            <div class="input-group">
                                <span class="form-control input disabled">{path('kupshop_xmlfeed_b2b_specificfeed', ['feed' => 'b2b', 'token' => $body.data.feed_token, 'feedID' => $selectedFeedID], 0)}</span>
                                <span class="input-group-btn">
                                    <button type="button"
                                            data-copy-clipboard="{path('kupshop_xmlfeed_b2b_specificfeed', ['feed' => 'b2b', 'token' => $body.data.feed_token, 'feedID' => $selectedFeedID], 0)}"
                                            class="btn" title="{'clipboard-copy'|translate:'button'}">
                                       <i class="glyphicon glyphicon-copy"></i>
                                    </button>
                                </span>
                            </div>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-4 control-label">
                        <small>Adresa feedu pro stažení</small>
                    </div>
                    <div class="col-md-8">
                        {if !$body.data.feed_token}
                            <p class="input-height"><strong>Po uložení bude vygenerován</strong></p>
                        {else}
                            <div class="input-group">
                                <span class="form-control input disabled">{path('kupshop_xmlfeed_b2b_specificfeed', ['feed' => 'b2b', 'token' => $body.data.feed_token, 'feedID' => $selectedFeedID], 0)}?download=1</span>
                                <span class="input-group-btn">
                                    <button type="button"
                                            data-copy-clipboard="{path('kupshop_xmlfeed_b2b_specificfeed', ['feed' => 'b2b', 'token' => $body.data.feed_token, 'feedID' => $selectedFeedID], 0)}?download=1"
                                            class="btn"
                                            title="{'clipboard-copy'|translate:'button'}">
                                       <i class="glyphicon glyphicon-copy"></i>
                                    </button>
                                </span>
                            </div>
                        {/if}
                    </div>
                </div>
            {/foreach}
        {/if}
    </div>

    <script type="text/javascript">
       $(':checkbox[name=data\\[feed_activated\\]]').change(function () {
          if ($(this).prop("checked")) {
             $('#feed_settings').fadeIn(600);
          }
          else {
             $('#feed_settings').fadeOut(600);
          }
       }).change();
    </script>
</div>
