<div class="help">
    <h2>{{ 'Domain details'|trans }}</h2>
</div>

<table class="tableStatic wide">
    <tbody>
        <tr class="noborder">
            <td style="width: 30%;">{{ 'Domain'|trans }}</td>
            <td><a target="_blank" href="http://{{ service.domain }}">{{ service.domain }}</a> </td>
        </tr>
        
        <tr>
            <td>{{ 'Registrar'|trans }}</td>
            <td>{{ service.registrar }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Nameserver 1'|trans }}</td>
            <td>{{ service.ns1 }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Nameserver 2'|trans }}</td>
            <td>{{ service.ns2 }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Nameserver 3'|trans }}</td>
            <td>{{ service.ns3 }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Nameserver 4'|trans }}</td>
            <td>{{ service.ns4 }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Transfer code'|trans }}</td>
            <td>{{ service.transfer_code }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Privacy protected'|trans }}</td>
            <td id="privacy-value">{{ service.privacy }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Locked'|trans }}</td>
            <td id="locked-value">{{ service.locked }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Registration/Renewal years'|trans }}</td>
            <td>{{ service.period }}</td>
        </tr>
        
        <tr>
            <td>{{ 'Registration date'|trans }}</td>
            <td>{{ service.registered_at|date('l, d F Y') }}</td>
        </tr>

        <tr>
            <td>{{ 'Expires at'|trans }}</td>
            <td>{{ service.expires_at|date('l, d F Y') }}</td>
        </tr>

    </tbody>
    
    <tfoot>
        <tr>
            <td colspan="2">
                <div class="aligncenter">
                    {{ order_actions }}
                    {% if order.status == 'active' %}
                    <a class="btn55 mr10" type="button" id="get-epp">
                        <img src="images/icons/middlenav/key.png" alt=""><span>Get EPP</span>
                    </a>
                    <a class="btn55 mr10" type="button" id="domain-unlock" {% if service.locked == 0 %}style="display:none;"{% endif %}>
                        <img src="images/icons/middlenav/locked2.png" alt=""><span>{{ 'Unlock'|trans }}</span>
                    </a>
                    <a class="btn55 mr10" type="button" id="domain-lock" {% if service.locked == 1 %}style="display:none;"{% endif %}>
                        <img src="images/icons/middlenav/unlocked.png" alt=""><span>{{ 'Lock'|trans }}</span>
                    </a>
                    <a class="btn55 mr10" type="button" id="domain-disable-pp">
                        <img src="images/icons/middlenav/umbrella.png" alt=""><span>{{ 'Disable privacy protection'|trans }}</span>
                    </a>
                    <a class="btn55 mr10" type="button" id="domain-enable-pp">
                        <img src="images/icons/middlenav/umbrella.png" alt=""><span>{{ 'Enable privacy protection'|trans }}</span>
                    </a>
                    {% endif %}
                </div>
            </td>
        </tr>
    </tfoot>
    
</table>

{% if order.status == 'active' %}
<div class="help">
    <h2>{{ 'Nameservers'|trans }}</h2>
</div>

<form method="post" action="{{ 'api/admin/servicedomain/update_nameservers'|link }}" class="mainForm api-form" data-api-msg="Nameservers updated">
    <fieldset>
        <div class="rowElem">
            <label>{{ 'Nameserver 1'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="ns1" value="{{ request.ns1|default(service.ns1) }}" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Nameserver 2'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="ns2" value="{{ request.ns2|default(service.ns2) }}" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Nameserver 3'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="ns3" value="{{ request.ns3|default(service.ns3) }}">
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Nameserver 4'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="ns4" value="{{ request.ns4|default(service.ns4) }}">
            </div>
            <div class="fix"></div>
        </div>
            
        <input type="hidden" name="order_id" value="{{ order.id }}">
        <input class="greyishBtn submitForm" type="submit" value="{{ 'Update'|trans }}">
    </fieldset>
</form>

<div class="help">
    <h2>{{ 'Domain data'|trans }}</h2>
</div>
<form method="post" action="{{ 'api/admin/servicedomain/update'|link }}" class="mainForm api-form" data-api-msg="Domain data updated">
    <fieldset>
        <div class="rowElem">
            <label>{{ 'Transfer code (EPP)'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="transfer_code" value="{{ request.transfer_code|default(service.transfer_code) }}" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Period'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="period" value="{{ request.period|default(service.period) }}">
            </div>
            <div class="fix"></div>
        </div>


        <input type="hidden" name="order_id" value="{{ order.id }}">
        <input class="greyishBtn submitForm" type="submit" value="{{ 'Update'|trans }}">
    </fieldset>
</form>

<div class="help">
    <h2>{{ 'Update domain contact details'|trans }}</h2>
</div>
<form method="post" action="{{ 'api/admin/servicedomain/update_contacts'|link }}" class="mainForm api-form" data-api-msg="Domain contact details updated">
    <fieldset>
        <div class="rowElem">
            <label>{{ 'First Name'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="contact[first_name]" value="{{ request.first_name|default(service.contact.first_name) }}" required="required">
            </div>
            <div class="fix"></div>
        </div>
        
        <div class="rowElem">
            <label>{{ 'Last Name'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[last_name]" value="{{ request.last_name|default(service.contact.last_name) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Email'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[email]" value="{{ request.email|default(service.contact.email) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Company'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[company]" value="{{ request.company|default(service.contact.company) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Address Line 1'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[address1]" value="{{ request.address1|default(service.contact.address1) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Address Line 2'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[address2]" value="{{ request.address2|default(service.contact.address2) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Country'|trans }}: </label>
            <div class="formRight">
                <input type="text" name="contact[country]" value="{{ request.country|default(service.contact.country) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'City'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[city]" value="{{ request.city|default(service.contact.city) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'State'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[state]" value="{{ request.state|default(service.contact.state) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Zip'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[postcode]" value="{{ request.postcode|default(service.contact.postcode) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Phone Country Code'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[phone_cc]" value="{{ request.phone_cc|default(service.contact.phone_cc) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <div class="rowElem">
            <label>{{ 'Phone number'|trans }}: </label>
            <div class="formRight">
            <input type="text" name="contact[phone]" value="{{ request.phone|default(service.contact.phone) }}" required="required" >
            </div>
            <div class="fix"></div>
        </div>

        <input type="hidden" name="order_id" value="{{ order.id }}">
        <input class="greyishBtn submitForm" type="submit" value="{{ 'Update'|trans }}">
    </fieldset>
</form>
{% endif %}

<script>
$(function() {
    {% if service.privacy == 0 %}
        $('#domain-disable-pp').hide();
    {% endif %}

    {% if service.privacy == 1 %}
        $('#domain-enable-pp').hide();
    {% endif %}
    
    $('#domain-lock').bind('click', function(event) {
        bb.post(
            'admin/servicedomain/lock',
            { order_id: {{ order.id }} },
            function(result) {
                bb.msg('Domain locked');
                $('#domain-lock').toggle();
                $('#domain-unlock').toggle();
                $('#locked-value').text('1');
            }
        );
    });

    $('#domain-unlock').bind('click', function(event) {
        bb.post(
            'admin/servicedomain/unlock',
            { order_id: {{ order.id }} },
            function(result) {
                bb.msg('Domain unlocked');
                $('#domain-lock').toggle();
                $('#domain-unlock').toggle();
                $('#locked-value').text('0');
            }
        );
    });

    $('#domain-enable-pp').bind('click', function(event) {
        bb.post(
            'admin/servicedomain/enable_privacy_protection',
            { order_id: {{ order.id }} },
            function(result) {
                bb.msg('Privacy Protection enabled');
                $('#domain-enable-pp').toggle();
                $('#domain-disable-pp').toggle();
                $('#privacy-value').text('1');
            }
        );
    });

    $('#domain-disable-pp').bind('click', function(event) {
        bb.post(
            'admin/servicedomain/disable_privacy_protection',
            { order_id: {{ order.id }} },
            function(result) {
                bb.msg('Privacy Protection disabled');
                $('#domain-enable-pp').toggle();
                $('#domain-disable-pp').toggle();
                $('#privacy-value').text('0');
            }
        );
    });

    $('#get-epp').bind('click', function(event) {
        bb.post(
            'admin/servicedomain/get_transfer_code',
            { order_id: {{ order.id }} },
            function(result) {
                bb.msg('Domain transfer code is: ' + result);
            }
        );
    });
});
</script>