{% include "headitem.html.twig" with {title: "GENERAL_ADMIN_TITLE"|translate} %}

<script type="text/javascript">
<!--
{% if updatelist == 1 %}
    UpdateList('{{ oxid }}');
{% endif %}

function UpdateList( sID)
{
    let oSearch = parent.list.document.getElementById("search");
    oSearch.oxid.value=sID;
    oSearch.fnc.value='';
    oSearch.submit();
}

function EditThis( sID)
{
    let oTransfer = document.getElementById("transfer");
    oTransfer.oxid.value=sID;
    oTransfer.cl.value='';
    oTransfer.submit();

    let oSearch = parent.list.document.getElementById("search");
    oSearch.actedit.value = 0;
    oSearch.oxid.value=sID;
    oSearch.submit();
}

function _groupExp(el) {
    let _cur = el.parentNode;

    if (_cur.className === "exp") _cur.className = "";
    else _cur.className = "exp";
}

let sOldSettingElem = '';

function showFormatSettings(sElemId, visible, blUseOldElem)
{
    if (blUseOldElem && sOldSettingElem) {
        document.getElementById(sOldSettingElem).style.display = 'none';
        sOldSettingElem = sElemId;
    } else if (blUseOldElem) {
        document.getElementById('settings_global').style.display = 'none';
        document.getElementById('settingstxt_global').style.display = 'none';
        sOldSettingElem = sElemId;
    }

    if (visible === true)
        document.getElementById(sElemId).style.display = 'block';
    else
        document.getElementById(sElemId).style.display = 'none';

}

-->
</script>

<style>
<!--
    fieldset{
        border: 1px inset black;
        background-color: #F0F0F0;
    }

    legend{
        font-weight: bold;
    }

    dl dt{
        font-weight: normal;
        width: 49%;
    }

    .groupExp dl dd{
        padding-left: 50%;
    }

    .ext_edittext {
        padding: 2px;
    }

    td.edittext {
        white-space: normal;
    }
-->
</style>

{% if readonly %}
    {% set readonly = "readonly disabled" %}
{% else %}
    {% set readonly = "" %}
{% endif %}

<form name="transfer" id="transfer" action="{{ oViewConf.getSelfLink()|raw }}" method="post">
    {{ oViewConf.getHiddenSid()|raw }}
    <input type="hidden" name="oxid" value="{{ oxid }}">
    <input type="hidden" name="cl" value="{{ oViewConf.getActiveClassName() }}">
    <input type="hidden" name="actshop" value="{{ shop.id }}">
    <input type="hidden" name="editlanguage" value="{{ editlanguage }}">
</form>

<form name="myedit" id="myedit" action="{{ oViewConf.getSelfLink()|raw }}" method="post">
    {{ oViewConf.getHiddenSid()|raw }}
    <input type="hidden" name="cl" value="{{ oViewConf.getActiveClassName() }}">
    <input type="hidden" name="fnc" value="save">
    <input type="hidden" name="oxid" value="{{ oxid }}">
    <input type="hidden" name="cronid" value="">
    <input type="hidden" name="crontype" value="">
    <input type="hidden" name="editval[d3_cfg_mod__oxid]" value="{{ oxid }}">

    <table style="border: none; width: 98%">
        <tr>
            <td style="vertical-align: top;" class="edittext">

                {% include "@d3modcfg_lib/admin/inc/active.html.twig" %}

                <div class="groupExp">
                    <div class="">
                        <a class="rc" onclick="_groupExp(this); return false;" href="#">
                            <b>
                                {{ translate({ ident: "D3_ORDERMANAGER_SET_JOBSETTINGS" }) }}
                            </b>
                        </a>
                        <dl>
                            <dt>
                                <label for="SetCronActive">{{ translate({ ident: "D3_ORDERMANAGER_SET_CALCULATESTATONDEMAND" }) }}</label>
                            </dt>
                            <dd>
                                <input type="hidden" name="value[blCalcStatOnDemand]" value="0">
                                <input id="SetCronActive" class="edittext ext_edittext" type="checkbox" name="value[blCalcStatOnDemand]" value='1' {% if edit.getValue('blCalcStatOnDemand') == 1 %}checked{% endif %} {{ readonly }}>
                                {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CALCULATESTATONDEMAND_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CALCULATESTATONDEMAND_DESC")} %}
                            </dd>
                            <div class="spacer"></div>
                        </dl>
                        <dl>
                            <dt>
                                <label for="SetFolder">{{ translate({ ident: "D3_ORDERMANAGER_SET_FOLDERLIST" }) }}</label>
                            </dt>
                            <dd>
                                <textarea id="SetFolder" class="edittext ext_edittext" name="valuearr[aFolderList]" style="height: 70px; width: 300px;" {{ readonly }}>{{ edit.getEditValue('aFolderList') }}</textarea>
                                {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_FOLDERLIST_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_FOLDERLIST_DESC")} %}
                            </dd>
                            <div class="spacer"></div>
                        </dl>
                    </div>
                </div>

                <div class="groupExp">
                    <div class="">
                        <a class="rc" onclick="_groupExp(this); return false;" href="#">
                            <b>
                                {{ translate({ ident: "D3_ORDERMANAGER_SET_CRON" }) }}
                            </b>
                        </a>
                        <dl>
                            <dt>
                                <label for="SetCronActive">{{ translate({ ident: "D3_ORDERMANAGER_SET_CRON_ACTIVE" }) }}</label>
                            </dt>
                            <dd>
                                <input type="hidden" name="value[blCronActive]" value="0">
                                <input id="SetCronActive" class="edittext ext_edittext" type="checkbox" name="value[blCronActive]" value='1' {% if edit.getValue('blCronActive') == 1 %}checked{% endif %} {{ readonly }}>
                                {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_ACTIVE_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_ACTIVE_DESC")} %}
                            </dd>
                            <div class="spacer"></div>
                        </dl>
                        <dl>
                            <dt>
                                <label for="SetCronMaxOrderCnt">{{ translate({ ident: "D3_ORDERMANAGER_SET_CRON_MAXORDERCNT" }) }}</label>
                            </dt>
                            <dd>
                                <input type="hidden" name="value[iMaxOrderCnt]" value="0">
                                <input id="SetCronMaxOrderCnt" class="edittext ext_edittext" type="text" size="4" maxlength="7" name="value[iMaxOrderCnt]" value="{% if edit.getValue('iMaxOrderCnt') %}{{ edit.getValue('iMaxOrderCnt') }}{% else %}50{% endif %}" {{ readonly }}>
                                {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_MAXORDERCNT_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_MAXORDERCNT_DESC")} %}
                            </dd>
                            <div class="spacer"></div>
                        </dl>
                        <dl>
                            <dt>
                                <label for="SetCronPW">{{ translate({ ident: "D3_ORDERMANAGER_SET_CRON_PASSWORD" }) }}</label>
                            </dt>
                            <dd>
                                <input id="SetCronPW" class="edittext ext_edittext" type="text" size="20" maxlength="50" name="value[sCronPassword]" value="{% if edit.getValue('sCronPassword') %}{{ edit.getValue('sCronPassword') }}{% else %}{{ oView.getBaseCronPW() }}{% endif %}" {{ readonly }}>
                                {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_PASSWORD_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_PASSWORD_DESC")} %}
                            </dd>
                            <div class="spacer"></div>
                        </dl>
                    </div>
                </div>

                {% for aCronJobIds in oView.getAvailableCronjobIds() %}
                    <div class="groupExp">
                        <div class="">
                            <a class="rc" onclick="_groupExp(this); return false;" href="#">
                                <b>
                                    {{ oView.getCJIDDesc(aCronJobIds) }} {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_JOB_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_JOB_DESC")} %}
                                </b>
                            </a>
                            <dl>
                                <dt>
                                    {{ translate({ ident: "D3_ORDERMANAGER_SET_CRON_PATH" }) }}
                                </dt>
                                <dd>
                                    {{ oView.getCronPath(aCronJobIds.id) }}
                                    {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_PATH_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_PATH_DESC")} %}
                                </dd>
                                <div class="spacer"></div>
                            </dl>
                            <dl>
                                <dt>
                                    <label for="shcrontype_{{ aCronJobIds.id }}">{{ translate({ ident: "D3_SHGENERATOR_CRON_SHGENERATOR" }) }}</label>
                                </dt>
                                <dd>
                                    <select style="float: left; margin-right: 10px;" id="shcrontype_{{ aCronJobIds.id }}" {{ readonly }}>
                                        {% for sProviderId, sProviderName in oView.getCronProviderList() %}
                                            <option value="{{ sProviderId }}">
                                                {{ sProviderName }}
                                            </option>
                                        {% endfor %}
                                    </select>
                                    <span class="d3modcfg_btn icon d3color-blue">
                                        <button name="save" onclick="oForm = document.getElementById('myedit'); oForm.crontype.value = document.getElementById('shcrontype_{{ aCronJobIds.id }}').value; oForm.cronid.value='{{ aCronJobIds.id }}'; oForm.fnc.value='generateCronShFile'; oForm.submit();" {{ readonly }}>
                                            <i class="fa fa-download fa-inverse"></i>
                                            {{ translate({ ident: "D3_SHGENERATOR_CRON_SHGENERATOR_GENERATE" }) }}
                                        </button>
                                    </span>
                                    {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_SHGENERATOR_CRON_SHGENERATOR_DESC"), 'sHelpText': help_text("D3_SHGENERATOR_CRON_SHGENERATOR_DESC")} %}
                                </dd>
                                <div class="spacer"></div>
                            </dl>
                            <dl>
                                <dt>
                                    {{ translate({ ident: "D3_ORDERMANAGER_SET_CRON_LASTEXEC" }) }}
                                </dt>
                                <dd>
                                    {{ edit.getValue(oView.getCronTimestampVarName( aCronJobIds.id ))|format_date }}
                                    {% include "inputhelp.html.twig" with {'sHelpId': help_id("D3_ORDERMANAGER_SET_CRON_LASTEXEC_DESC"), 'sHelpText': help_text("D3_ORDERMANAGER_SET_CRON_LASTEXEC_DESC")} %}
                                </dd>
                                <div class="spacer"></div>
                            </dl>
                        </div>
                    </div>
                {% endfor %}

                <table style="width: 100%">
                    <tr>
                        <td class="edittext ext_edittext" style="text-align: left">
                            <span class="d3modcfg_btn icon d3color-green">
                                <button type="submit" name="save" onclick="oForm = document.getElementById('myedit'); oForm.crontype.value = ''; oForm.cronid.value=''; oForm.fnc.value='save'; oForm.submit();" {{ readonly }}>
                                    <i class="fa fa-check-circle fa-inverse"></i>
                                    {{ translate({ ident: "D3_CFG_MOD_GENERAL_SAVE" }) }}
                                </button>
                            </span>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

</form>

{% include "@d3modcfg_lib/admin/inc/inc.html.twig" %}
