<div id="flapMailerLite" class="tab-pane fade in boxFlex">
<div class="row bottom-space">
    <div class="col-md-12">
        <h1 class="h4 main-panel-title">MailerLite API</h1>
    </div>
    <div class="col-md-12">
        <i class="bi bi-question-circle" style="color: #00a154;"></i> MailerLite > Integrations > Developer API (https://app.mailerlite.com/integrations/api/)<br>
    </div>
</div>

<div id="mailerlite_settings">
    <div class="form-group">
        <div class="col-md-2 control-label"><label>API Key</label></div>
        <div class="col-md-6">
            <input type="text" class="form-control input-sm" name="data[mailerlite][api_key]" size="30" value="{$tab.data.mailerlite->api_key}">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-2 control-label"><label>Subscriber group</label></div>
        <div class="col-md-6">
            <input type="text" class="form-control input-sm" name="data[mailerlite][group]" size="30" maxlength="255" value="{$tab.data.mailerlite->groupID}">
            <input type="hidden" class="form-control input-sm" name="data[mailerlite][version]" size="30" maxlength="255" value="{$tab.data.mailerlite->version}">
        </div>
    </div>
</div>

<div class="row bottom-space">
    <div class="col-md-12">
        <h1 class="h4 main-panel-title">MailerLite Forms</h1>
    </div>

    <div class="form-group">
        <div class="col-md-2 control-label">
            <label>Identifiers</label>
            <a class="help-tip" data-toggle="tooltip" title="var ml_account = ml('accounts', '1099518', 'x6l9p5g0k2', 'load');"><i class="bi bi-question-circle"></i></a>
        </div>
        <div class="col-md-2">
            <input type="text" class="form-control input-sm" name="data[mailerlite][forms][id]" size="30" maxlength="255" value="{$dbcfg.mailerlite.forms.id}">
        </div>
        <div class="col-md-2">
            <input type="text" class="form-control input-sm" name="data[mailerlite][forms][key]" size="30" maxlength="255" value="{$dbcfg.mailerlite.forms.key}">
        </div>
    </div>
</div>

{if !empty($tab.data.mailerlite->error)}
    <div id="mailerlite_error">
        <div class="col-md-10 col-md-offset-2"><label>{$tab.data.mailerlite->error}</label></div>
    </div>
{/if}
{if !empty($tab.data.mailerlite->group.id) && $tab.data.mailerlite->group.id == $tab.data.mailerlite->groupID}
    <div id="mailerlite_group">
        <div class="row bottom-space">
            <div class="col-md-12">
                <h1 class="h4 main-panel-title">{$tab.data.mailerlite->group.name}</h1>
            </div>
        </div>
        <div class="col-md-2"><label>Group ID:</label> {$tab.data.mailerlite->group.id}</div>
        <div class="col-md-3"><label>Created:</label> {$tab.data.mailerlite->group.date_created}</div>
        <div class="col-md-3"><label>Updated:</label> {$tab.data.mailerlite->group.date_updated}</div>
        <div class="col-md-4"><label>Active Subscribers:</label> {$tab.data.mailerlite->group.active}</div>
        {if isSuperuser()}
        <div class="col-md-2">
            <button type="button" class="btn btn-success btn-block" name="acn" value="MailerLite" onclick="javascript:nw('MailerLite', 'Unsubscribed', 'acn=MailerLite');">Subscribers</button>
        </div>
        <div class="col-md-2">
            <button type="submit" target="_blank" class="btn btn-danger btn-block" name="acn" value="mailerliteUpgradeCustomFields" title="Upgrade Custom Fields" onclick="javascript:nw('MailerLiteActions', 'UpgradeCustomFields', 'acn=Upgrade');">Upgrade Fields</button>
        </div>
        <div class="col-md-2">
            <button type="submit" target="_blank" class="btn btn-danger btn-block" name="acn" value="mailerliteUpgradeWebhooks" title="Upgrade Webhooks" onclick="javascript:nw('MailerLiteActions', 'UpgradeWebhooks', 'acn=Upgrade');">Upgrade Webhooks</button>
        </div>
        <div class="col-md-2">
            <button type="submit" target="_blank" class="btn btn-danger btn-block" name="acn" value="mailerliteSyncEverything" title="Sync everything" onclick="javascript:nw('MailerLiteActions', 'SyncEverything', 'acn=Synchronize');">Sync everything</button>
        </div>
        {/if}
        <div class="col-md-2">
            <button type="submit" target="_blank" class="btn btn-danger btn-block" name="acn" value="mailerliteSynchronize" title="Synchronize" onclick="javascript:nw('MailerLiteActions', 'Synchronize', 'acn=Synchronize');">Synchronize</button>
        </div>
    </div>
{/if}
</div>
