{% extends 'standingssync/base.html' %}
{% load i18n %}
{% load humanize %}

{% block details %}    

    <div class="panel panel-primary">
        <div class="panel-heading" style="display:flex;">
            <h3 class="panel-title">{% trans 'Alliance Available for Sync' %}</h3>
        </div>
        <div class="panel-body">            
            {% if alliance_contacts_count != None %}
                <img class="ra-avatar img-circle" src="{{ alliance.logo_url }}">
                &nbsp;&nbsp;
                {{ alliance.alliance_name }}
                &nbsp;                
                ({{ alliance_contacts_count }} contacts)
            {% else %}
                None
            {% endif %}
        </div>
    </div>
    <div class="panel panel-primary">
        <div class="panel-heading" style="display:flex;">
            <h3 class="panel-title">{% trans 'Your Synced Characters' %}</h3>
        </div>
        <div class="panel-body">            
            {% if has_synced_chars %}
                <table class="table" id="tab_standingssync">
                    <thead>                        
                        <tr>
                            <th></th>
                            <th>Name</th>
                            <th>Status</th>             
                            <th>Remove from Sync</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for character in characters %}
                            {% if character.has_error %}                                    
                                <tr class="danger">
                            {% else %}
                                <tr>    
                            {% endif %}                            
                                <td class="text-center"><img class="ra-avatar img-circle" src="{{ character.portrait_url }}">
                                </td>
                                <td>{{ character.name }}</td>
                                <td>{{ character.status_message }}</td>
                                <td><a class="btn btn-warning" href="{% url 'standingssync:remove_character' character.pk %}" role="button">
                                    <span class="fa fa-trash" style="font-size: 120%;"></span>
                                </a></td>
                            </tr>
                        {% endfor %}
                    </tbody>                        
                </table>
            {% else %}
                <p>None</p>
            {% endif %}
        </div>
    </div>

    {% if alliance_contacts_count == None and not perms.standingssync.add_syncmanager %}
        <div class="bs-callout bs-callout-warning">
        <h4>Warning</h4>        
            <p>
                {% if request.user.profile.main_character.alliance_name != None %}
                    This app is not fully setup yet for the 
                    <strong>{{ request.user.profile.main_character.alliance_name  }}</strong> alliance.
                {% else %}
                    You do not appear to belong to any alliance, but this app is for alliance members only.
                {% endif %}
                Please contact an admin for details.</p>
        </div>   
    {% endif %}

    {% if alliance_contacts_count != None %}            
        <a id="standingssyncBtnAddSyncChar" class="btn btn-primary" href="{% url 'standingssync:add_character' %}">Add Character to Sync</a>    
    {% endif %}
    
    {% if perms.standingssync.add_syncmanager %}        
        <a class="btn btn-default" href="{% url 'standingssync:add_alliance_manager' %}">            
            Set Alliance Character            
        </a>
    {% endif %}

    <div class="bs-callout bs-callout-warning">
        <h4>Read Me First</h4>
        <p>This app enables you to always have the current alliance standings on your non-alliance character. 
            Once activated it will automatically replace the personal contacts of your character with 
            the current Alliance contacts and will continue to do so until deactivated.</p>
            <p><strong>Careful!</strong> You will loose all your personal contacts on a synced character, so use with care.</p>
    </div>
        
{% endblock %}
