{% extends "base.html" %}
{% block content %}
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover model-list">
        <thead>
        <tr class="info">
            <th class="col-md-1">&nbsp;</th>
            <th class="column-header">Institution/employer</th>
            <th class="column-header">City</th>
            <th class="column-header">State/region</th>
            <th class="column-header">Country</th>
            <th class="column-header">Department</th>
            <th class="column-header">Role</th>
            <th class="column-header"></th>

        </tr>
        </thead>

        <tbody>
        {% for r in data.get('employment_summary', []) %}
        <tr>
            {% if org_client_id in r["source"]["source_client_id"]["path"] %}
            <td class="list-buttons-column">
                <a class="icon"
                   href="{{url_for('employment', user_id=user_id, put_code=r['put_code']) }}?url={{url_for('employment_list', user_id=user_id)}}"
                   title="Edit Record">
                    <span class="fa fa-pencil glyphicon glyphicon-pencil"></span>
                </a>
                <form class="icon" method="POST"
                      action="{{url_for('delete_employment', user_id=user_id, put_code=r['put_code'])}}">
                    <input id="put-code" name="put_code" type="hidden" value="{{r['put_code']}}">
                    <button onclick="return safeConfirm('Are you sure you want to delete this record?');"
                            title="Delete record">
                        <span class="fa fa-trash glyphicon glyphicon-trash"></span>
                    </button>
                </form>
            </td>
            {% else %}
            <td class="list-buttons-column"></td>
            {% endif %}

            <td>
                {{r["organization"]["name"]}}<br/>
                <span class="small">
                    Source: {{r["source"]["source_name"]["value"]}}
                </span>
            </td>
            <td>{{r["organization"]["address"].get("city")|default("", True)}}</td>
            <td>{{r["organization"]["address"].get("region", "")|default("", True)}}</td>
            <td>{{r["organization"]["address"].get("country", "")}}</td>
            <td>{{r.get("department_name", "")|default("", True)}}</td>
            <td>{{r.get("role_title", "")|default("", True)}}</td>
            <td>{{r|year_range}}</td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
    {% if url %}
      <a role="button" class="btn btn-danger pull-right" href="{{url}}">Cancel</a>
    {% endif %}
    <a role="button" class="btn btn-primary pull-right" href="{{url_for('employment', user_id=user_id)}}">New...</a>
</div>
{% endblock %}
