<head>
    <meta name="layout" content="main" />
    <title>Show Person</title>
    <nav:resources override="true"/>
</head>

<body>

    <div class="nav">
        <nav:renderSubItems group="navAlt"/>
    </div>

    <div class="body">
        <g:render template="/shared/messages" />
        <div class="dialog">
            <table>
            <tbody>

                <tr class="prop">
                    <td valign="top" class="name">ID:</td>
                    <td valign="top" class="value">${person.id}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Login Name:</td>
                    <td valign="top" class="value">${person.loginName?.encodeAsHTML()}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">First Name:</td>
                    <td valign="top" class="value">${person.firstName?.encodeAsHTML()}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Last Name:</td>
                    <td valign="top" class="value">${person.lastName?.encodeAsHTML()}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Active:</td>
                    <td valign="top" class="value">${person.isActive}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Description:</td>
                    <td valign="top" class="value">${person.description?.encodeAsHTML()}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Contact:</td>

                    <td  valign="top" class="value">
                        <ul>
                        <g:each var="i" in="${person.contacts}">
                            <li><g:link controller="contactDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>
                        </g:each>
                        </ul>
                    </td>

                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Addresses:</td>

                    <td  valign="top" class="value">
                        <ul>
                        <g:each var="i" in="${person.addresses}">
                            <li><g:link controller="addressDetailed" action="show" id="${i.id}">${i?.encodeAsHTML()}</g:link></li>
                        </g:each>
                        </ul>
                    </td>

                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Employee ID:</td>
                    <td valign="top" class="value">${person.employeeID}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Department:</td>
                    <td valign="top" class="value">${person.department}</td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Groups:</td>
                    <td valign="top" class="value">
                        <ul>
                        <g:each var='group' in="${ person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">
                            <li>
                                <g:link controller="personGroupDetailed"
                                                action="show"
                                                id="${group.id}">
                                    ${group.encodeAsHTML()}
                                </g:link>
                            </li>
                        </g:each>
                        </ul>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Purchasing Groups:</td>
                    <td valign="top" class="value">
                        <ul>
                        <g:each  var='a' in="${ person.purchasingGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">
                            <li>
                                <g:link controller="purchasingGroupDetailed"
                                                action="show"
                                                id="${a.id}">
                                    ${a.encodeAsHTML()}
                                </g:link>
                            </li>
                        </g:each>
                        </ul>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Authorities:</td>
                    <td valign="top" class="value">
                        <ul>
                        <g:each  var='a' in="${authorityList}">
                            <li>${a.description.encodeAsHTML()}</li>
                        </g:each>
                        </ul>
                    </td>
                </tr>

            </tbody>
            </table>
        </div>

        <div class="buttons">
            <g:form>
                <input type="hidden" name="id" value="${person.id}" />
                <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
                <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
            </g:form>
        </div>

    </div>
</body>
