{% extends 'admin.twig' %}

{% block content %}
<h2>{{ 'UsersManager_MenuUserSettings'|translate }}</h2>

<br/>

<div class="ui-confirm" id="confirmPasswordChange">
    <h2>{{ 'UsersManager_ChangePasswordConfirm'|translate }}</h2>
    <input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
    <input role="no" type="button" value="{{ 'General_No'|translate }}"/>
</div>

<table id='userSettingsTable' class="adminTable">
    <tr>
        <td><label for="username">{{ 'General_Username'|translate }} </label></td>
        <td>
            <input size="25" value="{{ userLogin }}" id="username" disabled="disabled"/>
            <span class='form-description'>{{ 'UsersManager_YourUsernameCannotBeChanged'|translate }}</span>
        </td>
    </tr>

    <tr>
        <td><label for="alias">{{ 'UsersManager_Alias'|translate }} </label></td>
        <td><input size="25" value="{{ userAlias }}" id="alias"{% if isSuperUser %} disabled="disabled"{% endif %} />
            {% if isSuperUser %}
                <span class='form-description'>
                    {{ 'UsersManager_TheSuperUserAliasCannotBeChanged'|translate }}
			</span>
            {% endif %}
        </td>
    </tr>
    <tr>
        <td><label for="email">{{ 'UsersManager_Email'|translate }} </label></td>
        <td><input size="25" value="{{ userEmail }}" id="email"/></td>
    </tr>
    <tr>
        <td>{{ 'UsersManager_ReportToLoadByDefault'|translate }}</td>
        <td>
            <fieldset>
                <input id="defaultReportRadioAll" type="radio" value="MultiSites"
                      name="defaultReport"{% if defaultReport=='MultiSites' %} checked="checked"{% endif %} />
                <label for="defaultReportRadioAll">{{ 'General_AllWebsitesDashboard'|translate }}</label><br/>
                <input id="defaultReportSpecific" type="radio" value="1"
                       name="defaultReport"{% if defaultReport != 'MultiSites' %} checked="checked"{% endif %} />
                <label for="defaultReportSpecific" style="padding-right:12px;">{{ 'General_DashboardForASpecificWebsite'|translate }}</label>
                {% if defaultReport=='MultiSites' %}
                    {% set defaultReportIdSite=1 %}
                {% else %}
                    {% set defaultReportIdSite=defaultReport %}
                {% endif %}
                {% include "@CoreHome/_siteSelect.twig" with {
                    'siteName':defaultReportSiteName,
                    'idSite':defaultReportIdSite,
                    'switchSiteOnSelect':false,
                    'showAllSitesItem':false,
                    'showSelectedSite':true,
                    'siteSelectorId': 'defaultReportSiteSelector'
                } %}
            </fieldset>
        </td>
    </tr>
    <tr>
        <td>{{ 'UsersManager_ReportDateToLoadByDefault'|translate }}</td>
        <td>
            <fieldset>
                {% for value,description in availableDefaultDates %}
                    <input id="defaultDate-{{ loop.index }}" type="radio"{% if defaultDate==value %} checked="checked"{% endif %} value="{{ value }}" name="defaultDate"/>
                    <label for="defaultDate-{{ loop.index }}">{{ description }}</label>
                    <br/>
                {% endfor %}
            </fieldset>
        </td>
    </tr>

    {% if isValidHost is defined and isValidHost %}
        <tr>
            <td><label for="email">{{ 'General_ChangePassword'|translate }} </label></td>
            <td><input size="25" value="" autocomplete="off" id="password" type="password"/>
                <span class='form-description'>{{ 'UsersManager_IfYouWouldLikeToChangeThePasswordTypeANewOne'|translate }}</span>
                <br/><br/><input size="25" value="" autocomplete="off" id="passwordBis" type="password"/>
                <span class='form-description'> {{ 'UsersManager_TypeYourPasswordAgain'|translate }}</span>
            </td>
        </tr>
    {% endif %}
</table>
{% if isValidHost is not defined or not isValidHost %}
    <div id="injectedHostCannotChangePwd">
        {% set injectedHostCannotChangePwd %}
        {{ 'UsersManager_InjectedHostCannotChangePwd'|translate(invalidHost) }}
        &nbsp;{% if not isSuperUser %}{{ 'UsersManager_EmailYourAdministrator'|translate(invalidHostMailLinkStart,'</a>')|raw }}{% endif %}
        {% endset %}
        {{ injectedHostCannotChangePwd|notification({'raw': true, 'context': 'error', 'placeat': '#injectedHostCannotChangePwd', 'noclear': true}) }}
    </div>
    <br/>
{% endif %}

{% import 'ajaxMacros.twig' as ajax %}
{{ ajax.errorDiv('ajaxErrorUserSettings') }}
{{ ajax.loadingDiv('ajaxLoadingUserSettings') }}
<input type="submit" value="{{ 'General_Save'|translate }}" id="userSettingsSubmit" class="submit"/>

<br/><br/>

<h2 id="excludeCookie">{{ 'UsersManager_ExcludeVisitsViaCookie'|translate }}</h2>
<p>
{% if ignoreCookieSet %}
   {{ 'UsersManager_YourVisitsAreIgnoredOnDomain'|translate("<strong>", piwikHost, "</strong>")|raw }}
{% else %}
   {{ 'UsersManager_YourVisitsAreNotIgnored'|translate("<strong>","</strong>")|raw }}
{% endif %}
</p>
<span style="margin-left:20px;">
<a href='{{ linkTo({'token_auth':token_auth, 'action':'setIgnoreCookie'}) }}#excludeCookie'>&rsaquo; {% if ignoreCookieSet %}{{ 'UsersManager_ClickHereToDeleteTheCookie'|translate }}
    {% else %}{{'UsersManager_ClickHereToSetTheCookieOnDomain'|translate(piwikHost) }}{% endif %}
    <br/>
</a></span>

<br/><br/>
{% if isSuperUser %}
    <h2>{{ 'UsersManager_MenuAnonymousUserSettings'|translate }}</h2>
    {% if anonymousSites|length == 0 %}
        <h3 class='form-description'><strong>{{ 'UsersManager_NoteNoAnonymousUserAccessSettingsWontBeUsed2'|translate }}</strong></h3>
        <br/>
    {% else %}
        <br/>
        {{ ajax.errorDiv('ajaxErrorAnonymousUserSettings') }}
        {{ ajax.loadingDiv('ajaxLoadingAnonymousUserSettings') }}
        <table id='anonymousUserSettingsTable' class="adminTable" style='width:850px;'>
            <tr>
                <td style="width:400px;">{{ 'UsersManager_WhenUsersAreNotLoggedInAndVisitPiwikTheyShouldAccess'|translate }}</td>
                <td>
                    <fieldset>
                        <input id="anonymousDefaultReport-login" type="radio" value="Login"
                               name="anonymousDefaultReport"{% if anonymousDefaultReport==loginModule %} checked="checked"{% endif %} />
                        <label for="anonymousDefaultReport-login">{{ 'UsersManager_TheLoginScreen'|translate }}</label><br/>
                        <input id="anonymousDefaultReport-multisites" {% if anonymousSites is empty %}disabled="disabled" {% endif %}type="radio" value="MultiSites"
                               name="anonymousDefaultReport"{% if anonymousDefaultReport=='MultiSites' %} checked="checked"{% endif %} />
                        <label for="anonymousDefaultReport-multisites">{{ 'General_AllWebsitesDashboard'|translate }}</label><br/>

                        <input id="anonymousDefaultReport-specific" {% if anonymousSites is empty %}disabled="disabled" {% endif %}type="radio" value="1"
                               name="anonymousDefaultReport"{% if anonymousDefaultReport>0 %} checked="checked"{% endif %} />
                        <label for="anonymousDefaultReport-specific">{{ 'General_DashboardForASpecificWebsite'|translate }}</label>
                        {% if anonymousSites is not empty %}
                            <select id="anonymousDefaultReportWebsite">
                                {% for info in anonymousSites %}
                                    <option value="{{ info.idsite }}" {% if anonymousDefaultReport==info.idsite %} selected="selected"{% endif %}>{{ info.name|raw }}</option>
                                {% endfor %}
                            </select>
                        {% endif %}
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td>{{ 'UsersManager_ForAnonymousUsersReportDateToLoadByDefault'|translate }}</td>
                <td>
                    <fieldset>
                        {% for value,description in availableDefaultDates %}
                            <input id="anonymousDefaultDate-{{ loop.index }}" type="radio" {% if anonymousDefaultDate==value %}checked="checked" {% endif %}value="{{ value }}"
                                   name="anonymousDefaultDate"/>
                            <label for="anonymousDefaultDate-{{ loop.index }}">{{ description }}</label>
                            <br/>
                        {% endfor %}
                    </fieldset>
                </td>
            </tr>

        </table>
        <input type="submit" value="{{ 'General_Save'|translate }}" id="anonymousUserSettingsSubmit" class="submit"/>
    {% endif %}
{% endif %}
{% endblock %}