<!-- BEGIN {$smarty.template} -->

    {literal}
      <script type="text/javascript">
        $(document).ready(function() { 
                var $delUserDialog = $('<div><span id="usrlogin"></span>{/literal}Delete this user?{literal}<\/div>').dialog({ 
            autoOpen: false, 
            title: '{/literal}Delete user{literal}', 
            width: 'auto', 
            height: 'auto',
            modal: true
            });

                $('.userdel').each(function() {
                    $(this).click(function() {
                        usr_id = $(this).attr('id').replace(/^usr/g, "");
                        usr_login = $(this).attr('title');
                        $('#usrlogin').html('<b>'+usr_login+'<\/b>: ');

                        $delUserDialog.dialog("option", {
                                //width: 500,
                                buttons: {
                                '{/literal}Delete{literal}': function() {
                                $.ajax({
                                    url: 'service.php',
                                    type: 'POST',
                                    data: 'saction={/literal}{$smarty.const.ACTION_SERVICE_DELETE_USER}{literal}&usr_id='+usr_id,
                                    dataType: 'json',
                                    cache: false,
                                    success: function(result) {
                                        if (result.status != 0) {
                                            alert(result.message);
                                        } else {
                                        $delUserDialog.dialog('close');
                                        $('#usrrow'+usr_id).fadeOut();
                                        }
                                    }
                                });

                            },
                            Cancel: function() { $(this).dialog('close'); }
                        }
                        });

                $delUserDialog.dialog('open');
                return false;
            });
        } );
        });
      </script>
  {/literal}

<form action="{$FORM_ACTION}" method="POST">

  <fieldset class="search">
    <legend>{t}Search users{/t}</legend>

    <label for="usr_login">{t}Login{/t}:</label>
    <input type="text" class="tinput" id="usr_login" name="usr_login" value="{$s_userInfo.usr_login|wash}" size="15" maxlength="15">
    <br>

    <label for="pe_lastname">{t}Last name{/t}:</label>
    <input type="text" class="tinput" id="pe_lastname" name="pe_lastname" value="{$s_userInfo.pe_lastname|wash}" size="20" maxlength="50">
    <br>

    <input type="submit" name="submit" value="{t}Search{/t}">
  </fieldset>
</form>

<table cellspacing="0">
    <caption><em>{t}Users{/t}</em>
        [ <a href="add_user.php">{t}Add user{/t}</a> ]
    </caption>
    <thead>
        <tr>
            <th> {t}Login{/t} </th>
            <th> {t}Name{/t} </th>
            <th> {t}Actions{/t} </th>
        </tr>
    </thead>
    <tbody>
        {section name=users loop=$rows}
        <tr id="usrrow{$rows[users].usr_id}">
            <td> <a href="user.php?id={$rows[users].usr_id}">{$rows[users].usr_login|wash}</a> </td>
            <td> <a href="person.php?id={$rows[users].pe_id}">{$rows[users].pe_name|wash}</a> </td>
            <td class="actions">
                <a href="user.php?id={$rows[users].usr_id}"><img src="img/phpaga/edit.png" height="16" width="16" border="0" alt="{t}Edit{/t}" title="{t}Edit{/t}"></a>
                <a class="userdel" id="usr{$rows[users].usr_id}" href="#" title="{$rows[users].usr_login|phpaga_popup_sanitizestr}"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
            </td>
        </tr>
        {/section}
    </tbody>
</table>

<!-- END {$smarty.template} -->
