<style>
#quickfind_dlg {
  width: 500px;
  height: 10em;
}
.unsafepassword {
  color: red;
}
.user_disabled:before {
  content: "!! ";
  color: red;
}
.user_mustvalidate:before {
  content: "** ";
  color: magenta;
}
.user_expired:before {
  content: "-- ";
  color: orange;
}
</style>
{****************************************}
<script>
$(function(){
  $('#mams_filterbox').click(function(){
    if( this.checked ) {
      $('#mams_filterform').show();
    }
    else {
      $('#mams_filterform').hide();
    }
  });

  $('#dobulk').click(function(ev){
    var len = $('input.bulkselect:checked').length;
    if( len == 0 ) {
      ev.preventDefault();
      cms_alert('{$mod->Lang('bulk_selectone'|cms_escape)}');
    }
  })

  $('#quickfind_form').submit(function(ev){
    ev.preventDefault();
    var id = $('#quickfind_dlg').data('sel_id');
    var url = '{cms_action_url action=admin_edituser user_id=xxxx forjs=1}';
    url = url.replace('xxxx',id);
    window.location.href = url;
  })
  $('#quickfind_fld').autocomplete({
    minLength: 2,
    appendTo: '#quickfind_dlg',
    source: function( request, response ) {
      $.ajax({
        url: '{cms_action_url action=admin_ajax_quickfind forjs=1}',
        data: {
          term: request.term,
        },
        success: function( data ) {
          response( data );
        }
      })
    },
    select: function( event, ui ) {
      $('#quickfind_fld').val( ui.item.label );
      $('#quickfind_dlg').data('sel_id', ui.item.value);
      return false;
    }
  });
  $('#quickfind').click(function(){
    $('#quickfind_dlg').dialog({
      width: '500',
      height: '150',
      modal: true,
    });
  })
});

function select_all()
{
  cb = document.getElementsByName('{$actionid}selected[]');
  el = document.getElementById('selectall');
  st = el.checked;
  for( i = 0; i < cb.length; i++ ) {
    if( cb[i].type == "checkbox" )  cb[i].checked=st;
  }
}

function confirm_delete()
{
  var cb = document.getElementsByName('{$actionid}selected[]');
  var count = 0;
  for( i = 0; i < cb.length; i++ ) {
    if( cb[i].checked ) count++;
  }

  if( count > 250 ) {
    alert('{$mod->Lang('error_toomanyselected')}'|cms_escape);
    return false;
  }
  return confirm('{$mod->Lang('confirm_delete_selected')}');
}
</script>
{****************************************}

<div id="quickfind_dlg" title="{$mod->Lang('quickfind_user')}" style="display: none;">
   {form_start id=quickfind_form}
  <div class="pageoverflow">
       <label class="pagetext">{$mod->Lang('quickfind_idname')}</label>
       <input class="pageinput" id="quickfind_fld" placeholder="{$mod->Lang('quickfind_ph')}" size="60"/>
   </div>
   <div class="pageoverflow">
       <input class="pageinput" type="submit" value="{$mod->Lang('find')}"/>
   </div>
    {form_end}
</div>

{$startform}
<fieldset id="mams_filterform" style="display: none;">
    <legend>{$mod->Lang('filter')}:</legend>
    <div class="c_full cf">
        <div class="grid_6">
           {if isset($groups)}
             <div class="c_full cf">
                   <p class="grid_4">{$mod->Lang('group')}:</p>
                   <p class="grid_8">
                       <select class="grid_12" name="{$actionid}filter_group">
                           {html_options options=$groups selected=$filter.group}
                       </select>
                   </p>
               </div>
           {/if}
          <div class="c_full cf">
               <p class="grid_4">{$mod->Lang('userfilter')}:</p>
               <p class="grid_8">
                   <input class="grid_12" type="text" name="{$actionid}filter_regex" value="{$filter.regex}"/>
               </p>
           </div>
           <div class="c_full cf">
               <p class="grid_4">{$mod->Lang('propertyfilter')}:</p>
               <p class="grid_8">
                   <select class="grid_12" name="{$actionid}filter_propertysel">{html_options options=$defnlist selected=$filter.propsel}</select>
               </p>
           </div>
           <div class="c_full cf">
               <p class="grid_4">{$mod->Lang('propregex')}:</p>
               <div class="grid_8">
                   <input class="grid_12" type="text" name="{$actionid}filter_property" value="{$filter.propval}" size="30"/>
		   <p class="grid_12">{$mod->Lang('info_propregex')}</p>
               </div>
           </div>
           <div class="c_full cf">
               <p class="grid_4">{$mod->Lang('prompt_loggedinonly')}:</p>
               <p class="grid_8">
                   {xt_yesno_options prefix=$actionid name='filter_loggedinonly' selected=$filter.loggedinonly}
               </p>
           </div>
           <div class="c_full cf">
               <p class="grid_4">{$mod->Lang('prompt_disabledstatus')}:</p>
               <p class="grid_8">
	           {$opts=[''=>$mod->Lang('any'), 'dis'=>$mod->Lang('disabled'), 'en'=>$mod->Lang('enabled')] }
                 <select name="{$actionid}filter_disabled">
		       {html_options options=$opts selected=$filter.disabledstatus}
		   </select>
               </p>
           </div>
       </div>

   <div class="grid_6">
       <div class="c_full cf">
           <p class="grid_3">{$mod->Lang('prompt_viewprops')}:</p>
           <select class="grid_9" name="{$actionid}filter_viewprops[]" multiple="multiple" size="5">
               {html_options options=$alldefns selected=$viewprops}
           </select>
        </div>
        <div class="c_full cf">
            <p class="grid_3">{$mod->Lang('sortby')}:</p>
            <select class="grid_9" name="{$actionid}filter_sortby">{html_options options=$sortlist selected=$filter.sortby}</select>
        </div>
        <div class="c_full cf">
            <p class="grid_3">{$mod->Lang('userlimit')}:</p>
            <select class="grid_9" name="{$actionid}filter_limit">{html_options options=$limits selected=$filter.limit}</select>
        </div>
    </div>
</div>
<div class="c_full cf grid_12">
    <input type="submit" name="{$actionid}filter" value="{$mod->Lang('applyfilter')}"/>
    <input type="submit" name="{$actionid}filter_reset" value="{$mod->Lang('reset')}"/>
</div>
</fieldset>{* #mams_filterform *}

<div class="c_full cf">
  <div class="grid_10">
    <input id="mams_filterbox" type="checkbox" value="1"/><label for="mams_filterbox">{$mod->Lang('view_filter')} {if $filter_applied}<span style="color: green;">({$mod->Lang('applied')}){/if}</span></label>&nbsp;
    <span title="{$mod->Lang('usersmatching')}">{xtimage image='users.gif' alt=""} = {$numusers}</span>&nbsp;
      {if isset($add_url)}<a href="{$add_url}" title="{$mod->Lang('title_add_user')}">{xtimage image='icons/system/newobject.gif'} {$mod->Lang('adduser')}</a>{/if}
      {if isset($import_url)}<a href="{$import_url}" title="{$mod->Lang('title_import_users')}">{xtimage image='icons/system/import.gif'} {$mod->Lang('prompt_importusers')}</a>{/if}
      {if isset($export_url)}<a href="{$export_url}" title="{$mod->Lang('title_export_users')}">{xtimage image='icons/system/export.gif'} {$mod->Lang('prompt_exportusers')}</a>{/if}
    <a id="quickfind">{admin_icon icon='view.gif'} {$mod->Lang('quickfind_user')}</a>
  </div>
  <div class="grid_2 text-right">
  {if $itemcount > 0}
      {if isset($navigation.firstpage_url)}
        <a href="{$navigation.firstpage_url}">{$mod->Lang('firstpage')}</a>&nbsp;
      <a href="{$navigation.prevpage_url}">{$mod->Lang('prevpage')}</a>&nbsp;
      {/if}
    {$mod->Lang('page')} {$navigation.curpage} {$mod->Lang('prompt_of')} {$navigation.npages}
    {if isset($navigation.lastpage_url)}
    &nbsp;<a href="{$navigation.nextpage_url}">{$mod->Lang('nextpage')}</a>
      &nbsp;<a href="{$navigation.lastpage_url}">{$mod->Lang('lastpage')}</a>
  {/if}
  {/if}
  </div>
</div>
{*{if !isset($groups)}*}
{*  <div class="red center">{$mod->Lang('nogroups')}</div>*}
{if $itemcount > 0}
  <table class="pagetable">
	<thead>
		<tr>
			<th>{$usernametext}</th>
			<th>{$createdtext}</th>
			<th>{$expirestext}</th>
        {if isset($viewprops) && is_array($viewprops)}
            {foreach from=$viewprops item='one'}
              <th>{$alldefns.$one}</th>
            {/foreach}
        {/if}
      <th class="pageicon {literal}{sorter: false}{/literal}">&nbsp;</th>
			<th class="pageicon {literal}{sorter: false}{/literal}">&nbsp;</th>
			<th class="pageicon {literal}{sorter: false}{/literal}">&nbsp;</th>
			<th class="pageicon {literal}{sorter: false}{/literal}">&nbsp;</th>
			<th class="pageicon {literal}{sorter: false}{/literal}">&nbsp;</th>
			<th class="pageicon {literal}{sorter: false}{/literal}"><input id="selectall" type="checkbox" name="junk" onclick="select_all();"/></th>
		</tr>
	</thead>
	<tbody>
{foreach from=$items item=entry}
  <tr class="{cycle values='row1,row2'}">
			<td>
			  {if $entry->unsafepassword}<span class="unsafepassword" title="{$mod->Lang('info_unsafepassword')}">{$mod->Lang('unsafe')}</span>{/if}
          {if $entry->disabled}
            <span class="user_disabled" title="{$mod->Lang('info_disabled')}">{$entry->username}</span>
			  {else if $entry->must_validate}
			     <span class="user_mustvalidate" title="{$mod->Lang('info_must_validate')}">{$entry->username}</span>
			  {elseif strtotime($entry->expires) < $smarty.now}
			     <span class="user_expired" title="{$mod->Lang('info_expired')}">{$entry->username}</span>
          {else}
              {$entry->username}
          {/if}
			</td>
			<td>{$entry->created|date_format:'%x'}</td>
			<td>
			  {if strtotime($entry->expires) < $smarty.now}
          <span style="color: orange;" title="{$mod->Lang('info_expired')}">{$entry->expires|date_format:'%x'}</span>
        {else}
            {$entry->expires|date_format:'%x'}
        {/if}
			</td>
      {if isset($viewprops) && isset($entry->extra)}
          {foreach from=$viewprops item='one'}
            <td>
				    {if !empty($entry->extra[$one])}
                {if $entry->extra[$one]->defn.type == 8}
                    {$entry->extra[$one]->val|date_format:'%x'}
                {else}
                    {$entry->extra[$one]->val}
                {/if}
            {/if}
				</td>
          {/foreach}
      {/if}
    <td>
			  {if $entry->disabled}
          <a href="{mod_action_url action=admin_enable_user uid=$entry->id state=1}">{xtimage image='icons/system/false.gif' alt=$mod->Lang('enable_user')}</a>
			  {else}
			    <a href="{mod_action_url action=admin_enable_user uid=$entry->id state=0}">{xtimage image='icons/system/true.gif' alt=$mod->Lang('disable_user')}</a>
        {/if}
			</td>
			<td>{if isset($entry->logoutlink)}{$entry->logoutlink}{/if}</td>
			<td>{$entry->historylink|default:''}</td>
			<td>{$entry->editlink|default:''}</td>
			<td>{if isset($entry->deletelink)}{$entry->deletelink}{/if}</td>
			<td><input type="checkbox" class="bulkselect" name="{$actionid}selected[]" value="{$entry->id}"/></td>
		</tr>
{/foreach}
	</tbody>
</table>
{/if}

{$endform}

{if $itemcount > 0}
  <div class="c_full cf">
    <div class="grid_10">
      &nbsp;
    </div>
    <div class="grid_2 text-right">
          {if isset($navigation.firstpage_url)}
            <a href="{$navigation.firstpage_url}">{$mod->Lang('firstpage')}</a>&nbsp;
            <a href="{$navigation.prevpage_url}">{$mod->Lang('prevpage')}</a>&nbsp;
          {/if}
        {$mod->Lang('page')} {$navigation.curpage} {$mod->Lang('prompt_of')} {$navigation.npages}
        {if isset($navigation.lastpage_url)}
          &nbsp;<a href="{$navigation.nextpage_url}">{$mod->Lang('nextpage')}</a>
            &nbsp;<a href="{$navigation.lastpage_url}">{$mod->Lang('lastpage')}</a>
        {/if}
    </div>
  </div>
  {if !empty($bulk_actions)}
    <hr>
    <div class="text-right">
      <label>{$mod->Lang('with_selected')}:
         <select name="{$actionid}bulk_action">
            <option value="">{$mod->Lang('none')}</option>
             {html_options options=$bulk_actions}
         </select>
      </label>
      <input type="submit" id="dobulk" name="{$actionid}dobulk" value="{$mod->Lang('submit')}"/>
    </div>
  {/if}
{/if}


