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

<body>

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

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

        <filterpane:currentCriteria domainBean="Person"
                                action="list"
                                dateFormat="EEE, dd-MMM-yyyy"
                                removeImgDir="images"
                                removeImgFile="bullet_delete.png"
                                title="Search"/>

        <div class="paginateButtons">
            Results: ${personList.size()} / ${personTotal}
            <span class="searchButtons">
                <filterpane:filterButton text="Search" appliedText="Change Search" />
            </span>
        </div>

        <jsUtil:toggleControl toggleId="options"
                                                imageId="optionsImg"
                                                closedImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_right.png')}"
                                                openImgUrl="${resource(dir:'images/skin',file:'bullet_arrow_down.png')}"
                                                text="${g.message(code: 'default.options.text')}"
                                                />

        <div id="options" style="display:none;">
            <g:form method="post" >
                <g:hiddenField name="params" value="${filterParams}" />
                <div class="dialog">
                    <table>
                        <tbody>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="max">Persons:</label>
                                </td>
                                <td valign="top" class="value">
                                    <g:link action="exportPersonsTemplate">
                                        Template
                                    </g:link>
                                    /
                                    <g:link action="importPersons">
                                        Import
                                    </g:link>
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
            </g:form>
        </div>

        <br />

        <g:if test="${personList.size() > 0}">
            <div class="list">
                <table>
                <thead>
                    <tr>
                        <g:sortableColumn property="id" title="Id" params="${filterParams}" />
                        <g:sortableColumn property="loginName" title="Login Name" params="${filterParams}" />
                        <g:sortableColumn property="firstName" title="First Name" params="${filterParams}" />
                        <g:sortableColumn property="lastName" title="Last Name" params="${filterParams}" />
                        <g:sortableColumn property="isActive" title="Active" params="${filterParams}" />
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                <g:each in="${personList}" status="i" var="person">
                    <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}">

                        <td onclick='window.location = "${request.getContextPath()}/person/show/${person.id}"'>
                            ${person.id}
                        </td>

                        <td onclick='window.location = "${request.getContextPath()}/person/show/${person.id}"'>
                            ${person.loginName?.encodeAsHTML()}
                        </td>

                        <td onclick='window.location = "${request.getContextPath()}/person/show/${person.id}"'>
                            ${person.firstName?.encodeAsHTML()}
                        </td>

                        <td onclick='window.location = "${request.getContextPath()}/person/show/${person.id}"'>
                            ${person.lastName?.encodeAsHTML()}
                        </td>

                        <td onclick='window.location = "${request.getContextPath()}/person/show/${person.id}"'>
                            ${person.isActive?.encodeAsHTML()}
                        </td>

                        <td class="notClickable">
                            <g:link action="show" id="${person.id}">
                                <img  src="${resource(dir:'images/skin',file:'database_go.png')}" alt="Show" />
                            </g:link>
                        </td>
                    </tr>
                </g:each>
                </tbody>
                </table>
            </div>
        </g:if>

        <div class="paginateButtons">
            <g:paginate total="${personTotal}" params="${filterParams}" />
        </div>

        <filterpane:filterPane domainBean="Person"
                               title="Search"
                               action="list"
                               class="overlayPane"
                               excludeProperties="password, sessionTimeout"
                               associatedProperties="authorities.authority, personGroups.name"
                               filterPropertyValues="${['personGroups.name':[values: associatedPropertyValues.personGroupList],
                                                        'authorities.authority':[values: associatedPropertyValues.authorityList]]}" />


    </div> <!-- end body div -->
</body>
