{% load custom_tags_and_filters %}
<form method="POST" action="{% url 'customize' 'user' %}" class="form-horizontal">
    <div class="panel-body">
        {% csrf_token %}
        <h3 class="customization-section-title">General</h3>
        <div class="form-group">
            <label class="control-label col-md-4 col-lg-3" for="default_user_training_not_required">
                New user facility tutorial
            </label>
            <div class="col-md-8 col-lg-9">
                <div class="radio">
                    <label>
                        <input type="radio"
                               id="default_user_training_not_required"
                               name="default_user_training_not_required"
                               {% if not default_user_training_not_required %}checked{% endif %}
                               value="">
                        Required
                    </label>
                    <label>
                        <input type="radio"
                               name="default_user_training_not_required"
                               {% if default_user_training_not_required %}checked{% endif %}
                               value="enabled">
                        Not required
                    </label>
                </div>
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                Whether the facility rules tutorial is required for new users by default.
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4 col-lg-3" for="user_type_required">User type</label>
            <div class="col-md-8 col-lg-9">
                <div class="radio">
                    <label>
                        <input type="radio"
                               id="user_type_required"
                               name="user_type_required"
                               {% if user_type_required %}checked{% endif %}
                               value="enabled">
                        Required
                    </label>
                    <label>
                        <input type="radio" name="user_type_required" {% if not user_type_required %}checked{% endif %} value="">
                        Not required
                    </label>
                </div>
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                Whether the user type is required when adding new users.
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4 col-lg-3" for="user_list_active_only">User list</label>
            <div class="col-md-8 col-lg-9">
                <div class="checkbox">
                    <label>
                        <input type="checkbox"
                               id="user_list_active_only"
                               name="user_list_active_only"
                               {% if user_list_active_only %}checked{% endif %}
                               value="enabled">
                        Hide inactive
                    </label>
                </div>
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                Check this box to only show active users in the user list.
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4 col-lg-3" for="user_list_active_only">User document upload</label>
            <div class="col-md-8 col-lg-9">
                <div class="checkbox">
                    <label>
                        <input type="checkbox"
                               name="user_allow_document_upload"
                               {% if user_allow_document_upload %}checked{% endif %}
                               value="enabled">
                        Enable
                    </label>
                </div>
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                Check this box to allow uploading documents to users.
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4 col-lg-3" for="user_allow_profile_view">Enable user profile view</label>
            <div class="col-md-8 col-lg-9">
                <div class="checkbox">
                    <label>
                        <input type="checkbox"
                               id="user_allow_profile_view"
                               name="user_allow_profile_view"
                               {% if user_allow_profile_view %}checked{% endif %}
                               value="enabled">
                        Enable
                    </label>
                </div>
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                Check this box to enable users to view their own profile by clicking on their name in the navigation bar.
            </div>
        </div>
        <div class="customization-separation" style="margin-bottom: 15px"></div>
        <h3 class="customization-section-title">Access expiration - reminders</h3>
        <div class="form-group {% if errors.user_access_expiration_reminder_days %}has-error{% endif %}">
            <label class="control-label col-md-4 col-lg-3" for="user_access_expiration_reminder_days">Reminder days</label>
            <div class="col-md-8 col-lg-9">
                <input type="text"
                       id="user_access_expiration_reminder_days"
                       name="user_access_expiration_reminder_days"
                       class="form-control"
                       value="{% if errors.user_access_expiration_reminder_days %}{{ errors.user_access_expiration_reminder_days.value }}{% else %}{{ user_access_expiration_reminder_days }}{% endif %}" />
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                {% if errors.user_access_expiration_reminder_days %}
                    {{ errors.user_access_expiration_reminder_days.error }}
                {% else %}
                    The number of days to send a reminder prior to the user's access expiration. A comma-separated list can be used for multiple reminders.
                    This setting and the <a href="{% url 'customization' 'templates' %}?#user_access_expiration_reminder_email_id">user access expiration reminder email</a> need to be set to enable this feature.
                {% endif %}
            </div>
        </div>
        <div class="form-group {% if errors.user_access_expiration_reminder_cc %}has-error{% endif %}">
            <label class="control-label col-md-4 col-lg-3" for="user_access_expiration_reminder_cc">Reminder email CC</label>
            <div class="col-md-8 col-lg-9">
                <input type="text"
                       id="user_access_expiration_reminder_cc"
                       name="user_access_expiration_reminder_cc"
                       class="form-control"
                       value="{% if errors.user_access_expiration_reminder_cc %}{{ errors.user_access_expiration_reminder_cc.value }}{% else %}{{ user_access_expiration_reminder_cc }}{% endif %}"
                       placeholder="information@example.org" />
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                {% if errors.user_access_expiration_reminder_cc %}
                    {{ errors.user_access_expiration_reminder_cc.error }}
                {% else %}
                    Extra email address to copy when a user access expiration reminder is sent. A comma-separated list can be used.
                {% endif %}
            </div>
        </div>
        <div class="customization-separation" style="margin-bottom: 15px"></div>
        <h3 class="customization-section-title">Access expiration - deactivate users</h3>
        <div class="form-group {% if errors.user_access_expiration_types %}has-error{% endif %}">
            <label class="control-label col-md-4 col-lg-3" for="user_access_expiration_no_type">User types</label>
            <div class="col-md-8 col-lg-9">
                <div class="checkbox">
                    <label>
                        <input type="checkbox"
                               id="user_access_expiration_no_type"
                               name="user_access_expiration_no_type"
                               {% if user_access_expiration_no_type %}checked{% endif %}
                               value="enabled" />
                        Users without a type
                    </label>
                </div>
                {% for user_type in user_types %}
                    <div class="checkbox">
                        <label>
                            <input type="checkbox"
                                   name="user_access_expiration_types_list"
                                   value="{{ user_type.id }}"
                                   {% if user_type.id in user_access_expiration_types_list %}checked{% endif %} />
                            {{ user_type.name }}
                        </label>
                    </div>
                {% endfor %}
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                {% if errors.user_access_expiration_types %}
                    {{ errors.user_access_expiration_types.error }}
                {% else %}
                    Check to automatically deactivate users with the selected types when their access expiration is reached. If nothing is selected, no one will be deactivated
                {% endif %}
            </div>
        </div>
        <div class="form-group {% if errors.user_access_expiration_buffer_days %}has-error{% endif %}">
            <label class="control-label col-md-4 col-lg-3" for="user_access_expiration_buffer_days">Buffer days</label>
            <div class="col-md-5 col-lg-4">
                <input class="form-control"
                       type="number"
                       id="user_access_expiration_buffer_days"
                       name="user_access_expiration_buffer_days"
                       value="{{ user_access_expiration_buffer_days|default:0 }}" />
            </div>
            <div class="col-lg-offset-3 col-md-offset-4 col-md-8 col-lg-9 help-block light-grey">
                {% if errors.user_access_expiration_buffer_days %}
                    {{ errors.user_access_expiration_buffer_days.error }}
                {% else %}
                    Specify the number of days to wait after the expiration date before proceeding with deactivation
                {% endif %}
            </div>
        </div>
        <div class="customization-separation" style="margin-bottom: 15px"></div>
        <div class="text-center">{% button type="save" value="Save settings" %}</div>
    </div>
</form>
