{% load custom_tags_and_filters %}
<div class="panel-body" style="padding-bottom: 0">
    <h3 class="customization-section-title">Billing/Accounting settings</h3>
    <form method="POST" action="{% url 'customize' 'billing' %}" class="form-horizontal">
        {% csrf_token %}
        <div class="form-group {% if errors.billing_accounting_email_address %}has-error{% endif %}">
            <label class="control-label col-md-2" for="billing_accounting_email_address">Billing/Accounting email</label>
            <div class="col-md-5">
                <input type="email"
                       id="billing_accounting_email_address"
                       name="billing_accounting_email_address"
                       class="form-control"
                       value="{% if errors.billing_accounting_email_address %}{{ errors.billing_accounting_email_address.value }}{% else %}{{ billing_accounting_email_address }}{% endif %}"
                       placeholder="accounting@example.org">
            </div>
            <div class="col-md-5 help-block light-grey">
                {% if errors.billing_accounting_email_address %}
                    {{ errors.billing_accounting_email_address.error }}
                {% else %}
                    The accounting/billing point of contact for the {{ facility_name }}. Accounting/billing emails sent from {{ site_title }} are typically 'from' this address.
                {% endif %}
            </div>
        </div>
        <div class="form-group {% if errors.billing_project_expiration_reminder_days %}has-error{% endif %}">
            <label class="control-label col-md-2" for="billing_project_expiration_reminder_days">
                Project expiration reminder days
            </label>
            <div class="col-md-5">
                <input type="text"
                       id="billing_project_expiration_reminder_days"
                       name="billing_project_expiration_reminder_days"
                       class="form-control"
                       value="{% if errors.billing_project_expiration_reminder_days %}{{ errors.billing_project_expiration_reminder_days.value }}{% else %}{{ billing_project_expiration_reminder_days }}{% endif %}" />
            </div>
            <div class="col-md-5 help-block light-grey">
                {% if errors.billing_project_expiration_reminder_days %}
                    {{ errors.billing_project_expiration_reminder_days.error }}
                {% else %}
                    The numbers of days to send a reminder prior to a project expiration. A comma-separated list can be used for multiple reminders.
                {% endif %}
            </div>
        </div>
        <div class="form-group {% if errors.billing_project_expiration_reminder_cc %}has-error{% endif %}">
            <label class="control-label col-md-2" for="billing_project_expiration_reminder_cc">
                Project expiration reminder CC
            </label>
            <div class="col-md-5">
                <input type="text"
                       id="billing_project_expiration_reminder_cc"
                       name="billing_project_expiration_reminder_cc"
                       class="form-control"
                       value="{% if errors.billing_project_expiration_reminder_cc %}{{ errors.billing_project_expiration_reminder_cc.value }}{% else %}{{ billing_project_expiration_reminder_cc }}{% endif %}"
                       placeholder="accounting@example.org" />
            </div>
            <div class="col-md-5 help-block light-grey">
                {% if errors.billing_project_expiration_reminder_cc %}
                    {{ errors.billing_project_expiration_reminder_cc.error }}
                {% else %}
                    The email address to copy when a project expiration reminder is sent. A comma-separated list can be used.
                {% endif %}
            </div>
        </div>
        <div class="form-group {% if errors.billing_usage_show_pending_vs_final %}has-error{% endif %}">
            <label class="control-label col-md-2">Usage pending charges</label>
            <div class="col-md-10">
                <div class="checkbox">
                    <label>
                        <input type="checkbox"
                               name="billing_usage_show_pending_vs_final"
                               {% if billing_usage_show_pending_vs_final %}checked{% endif %}
                               value="enabled">
                        In the usage page, display "pending" for charges not invoiced yet
                    </label>
                    <br />
                </div>
            </div>
            {% if errors.billing_usage_show_pending_vs_final %}
                <div class="col-md-offset-2 col-md-10 help-block light-grey">
                    {{ errors.billing_usage_show_pending_vs_final.error }}
                </div>
            {% endif %}
        </div>
        <div class="form-group {% if errors.billing_core_facility_external_id_name %}has-error{% endif %}">
            <label class="control-label col-md-2" for="billing_core_facility_external_id_name">
                Core Facility external id name
            </label>
            <div class="col-md-5">
                <input type="text"
                       id="billing_core_facility_external_id_name"
                       name="billing_core_facility_external_id_name"
                       class="form-control"
                       value="{{ billing_core_facility_external_id_name }}">
            </div>
            <div class="col-md-5 help-block light-grey">
                {% if errors.billing_core_facility_external_id_name %}
                    {{ errors.billing_core_facility_external_id_name.error }}
                {% else %}
                    The name of the external identifier property for Core Facilities.
                {% endif %}
            </div>
        </div>
        <div class="customization-separation" style="margin-bottom: 15px"></div>
        <div class="text-center" style="margin-bottom: 15px">{% button type="save" value="Save settings" %}</div>
    </form>
    <div class="customization-separation"></div>
    <div class="form-group form-horizontal" style="margin-top: 15px">
        <h3 class="customization-section-title" id="billing_project_expiration_reminder_email_message_id">
            Project expiration reminder email subject & message
        </h3>
        <p>
            This is the email the project contacts (or project PIs if left blank) will receive as a reminder when they have projects about to expire. The following context variables are provided when the email is rendered:
        </p>
        <ul style="margin-bottom: 25px">
            <li>
                <b>projects</b> - the project(s) about to expire
            </li>
            <li>
                <b>today</b> - today's date used to display time until expiration
            </li>
        </ul>
        <div class="col-md-6">
            {% include 'customizations/customizations_upload.html' with element=billing_project_expiration_reminder_email_subject name='billing project expiration reminder email subject' button_name='Upload project expiration reminder subject' extension='txt' key='billing' %}
        </div>
        <div class="col-md-6">
            {% include 'customizations/customizations_upload.html' with element=billing_project_expiration_reminder_email_message name='billing project expiration reminder email message' button_name='Upload project expiration reminder email' key='billing' %}
        </div>
    </div>
</div>
