{% load freeadmin %}

{% if sw_name != "freenas" %}
<h1>Production</h1>
<form data-dojo-type="dijit.form.Form" id="form_{% cls_name production_form %}" {% if production_form and form.is_multipart %}enctype="multipart/form-data" {% endif %}method="POST">
    <script type="dojo/method" data-dojo-event="submitForm" data-dojo-args="form,e,conf">
        {% block onSubmit %}
        doSubmit({
	        form: this,
	        event: e,
	        url: '{% block formpost %}{{ request.path }}{% endblock %}',
            confirm: conf
	    });
        {% endblock %}
    </script>
    <script type="dojo/event" data-dojo-event="onSubmit" data-dojo-args="e">
    this.submitForm(this, e);
    </script>
    <table class="form">
        {% block production_form %}
        {% csrf_token %}
        {% admin_form production_form %}
        {% endblock %}
        <tr>
            <td colspan="2">
                {% block buttons %}
                <button id="btn_{% cls_name production_form %}_Ok" data-dojo-type="dijit.form.Button" type="submit" data-dojo-props="type:'submit'" class="submitform">
                    {% block oklabel %}{% trans "OK" %}{% endblock %}
                </button>
                {% if not inline %}
                <button id="btn_{% cls_name production_form %}_Cancel" data-dojo-type="dijit.form.Button" type="button">
                    {% block cancellabel %}{% trans "Cancel" %}{% endblock %}
                    <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="evt">
                        cancelDialog(this);
                    </script>
                </button>
                {% endif %}
                {% with form.advanced_fields as advfields %}
                {% include "freeadmin/advanced_btn.html" %}
                {% endwith %}
                {% block extra_buttons %}{% endblock %}
                {% endblock %}
            </td>
        </tr>
    </table>
</form>
{% endif %}
{% if sw_name != "freenas" or license %}
<h1>
{% trans "License Information" %}
{% if allow_update %}
<div data-dojo-type="dijit/form/Button">
  {% trans "Update License" %}
  <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="e, e2">
    var me = this;
    require([
      "dijit/registry"
    ], function(registry) {
      editObject('{% trans "Update License"|escapejs %}', '{% url "support_license_update" %}', [registry.getEnclosingWidget(me.domNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode), ]);
    });
  </script>
</div>
{% endif %}
</h1>
<table class="form">
{% if license %}
  <tr>
    <th>{% trans "Model" %}</th>
    <td>{{ license.model }}</td>
    <th>{% trans "System Serial" %}</th>
    <td>{{ license.system_serial }}{% if license.system_serial_ha %} / {{ license.system_serial_ha }}{% endif %}</td>
    <th>{% trans "Contract Type" %}</th>
    <td>
      {% if license.contract_type == 'LEGACY' %}
        Hardware:
        {% if license.contract_hardware == 'PARTS' %}Advanced Parts Replacement{% endif %}
        {% if license.contract_hardware == 'NEXTDAY' %}Next Business Day On-Site{% endif %}
        {% if license.contract_hardware == 'FOURHOUR' %}4-Hour On-Site{% endif %}
        <br />
        Software:
        {% if license.contract_software == 'NONE' %}None{% endif %}
        {% if license.contract_software == 'BUSINESS' %}8x5 Help Desk{% endif %}
        {% if license.contract_software == 'INTEGRAL' %}24x7 Help Desk{% endif %}
      {% endif %}
      {% if license.contract_type == 'STANDARD' %}{% trans "Standard" %}{% endif %}
      {% if license.contract_type == 'BRONZE' %}{% trans "Bronze" %}{% endif %}
      {% if license.contract_type == 'SILVER' %}{% trans "Silver" %}{% endif %}
      {% if license.contract_type == 'GOLD' %}{% trans "Gold" %}{% endif %}
      {% if license.contract_type == 'FREENASCERTIFIED' %}{% trans "8x5 FreeNAS Support" %}{% endif %}
      {% if license.contract_type == 'FREENASMINI' %}{% trans "8x5 FreeNAS Support" %}<br />{% trans "Maximum of 6 incidents per year" %}{% endif %}
    </td>
    <th>{% trans "Contract Date" %}</th>
    <td>{{ license.contract_start }} - {{ license.contract_end }}{% if license.expired %} <span style="color: red;">({% trans "Expired" %})</span>{% endif %}</td>
  </tr>
  <tr>
    <th>{% trans "Customer Name" %}</th>
    <td>{{ license.customer_name }}</td>
    <th>{% trans "Features" %}</th>
    <td>
      {% for f in license.features %}
        {% if f == 'DEDUP' %}{% trans "Deduplication" %}<br />{% endif %}
        {% if f == 'JAILS' %}{% trans "Jails/Plugins" %}<br />{% endif %}
        {% if f == 'VM' %}{% trans "Virtual Machines" %}<br />{% endif %}
        {% if f == 'FIBRECHANNEL' %}{% trans "Fibre Channel" %}<br />{% endif %}
      {% empty %}
        {% trans "None" %}
      {% endfor %}
    </td>
    <th>{% trans "Additional Hardware" %}</th>
    <td>
      {% for f in license.addhw %}
        {% if f.1 == 1 %}{% trans "E16 Enclosure" %}{% endif %}
        {% if f.1 == 2 %}{% trans "E24 Enclosure" %}{% endif %}
        {% if f.1 == 3 %}{% trans "E60 Enclosure" %}{% endif %}: {{ f.0 }}<br />
        {% if f.1 == 5 %}{% trans "ES12 Enclosure" %}{% endif %}: {{ f.0 }}<br />
        {% if f.1 == 4 %}{% trans "ES60 Enclosure" %}{% endif %}: {{ f.0 }}<br />
      {% empty %}
        {% trans "None" %}
      {% endfor %}
    </td>
    <th>{% trans "EULA" %}</th>
    <td>
      {% if eula_not_accepted %}
        <div style="color: #ff0000;">Not accepted</div>
      {% else %}
        <div data-dojo-type="freeadmin/UnacceptEula" data-dojo-props=""></div>
        <form action="{% url "support_home" %}" method="post" enctype="multipart/form-data" id="unaccept_eula_form" style="margin: 0;">{% csrf_token %}
            <input type="hidden" name="eula" value="unaccept" />
        </form>
      {% endif %}
      <div data-dojo-type="dijit/form/Button">
        {% trans "Show EULA" %}
        <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="e, e2">
          window.open('{% url "support_eula" %}');
        </script>
      </div>
    </td>
  </tr>
{% else %}
  {% if license_invalid %}
  <tr>
    <td colspan="2">{% trans "License is not valid! Contact iXsystems support." %}</td>
  </tr>
  {% else %}
  <tr>
    <td colspan="2">{% trans "License not found! Contact iXsystems support." %}</td>
  </tr>
  {% endif %}
{% endif %}
</table>
{% endif %}

{% if sw_name == "freenas" %}
<p style="margin-left: 15px;">{% trans "Before filing a bug report or feature request, search" %} <a href="http://bugs.freenas.org" target="_blank">http://bugs.freenas.org</a> {% trans "to ensure the issue has not already been reported. If it has, add a comment to the existing issue instead of creating a new one." %}<br />
{% trans "For enterprise-grade storage solutions and support, please visit" %} <a href="http://www.ixsystems.com/storage/" target="_blank">http://www.ixsystems.com/storage/</a>.</p>
{% endif %}

<div data-dojo-type="freeadmin/SupportTicket" data-dojo-props="softwareName: '{{ sw_name }}'{% if error_message %}, errorMessage: '{{ error_message|escapejs }}'{% endif %}{% if initial %}, initial: '{{ initial|escapejs }}'{% endif %}, categoriesUrl: '{% url "support_ticket_categories" %}', progressUrl: '{% url "support_ticket_progress" %}'"></div>
