Revision 196 (by ahitrov, 2012/03/15 18:28:32) Users plugin
<script type="text/javascript">
<!--
function StartSearch () {
  var oForm = document.forms['user_search'];
  var oFormStart = document.forms['start_search'];
% my $i = 0;
% foreach my $field ( @fields ) {
	<% $i++ ? '} else if' : 'if' %> ( oForm.<% $field %>.value ) {
		oFormStart.search.value = oForm.<% $field %>.value;
		oFormStart.search_by.value = oForm.<% $field %>.name;
% }
%	if ($i) {
	}
%	}
	if ( oFormStart.search.value && oFormStart.search_by.value ) {
		oFormStart.submit();
	}
}
//-->
</script>
<fieldset>
<legend>Поиск пользователя</legend>
<form id="start_search" name="start_search" action="<% $url %>" method="get">
<input type="hidden" name="search" value="">
<input type="hidden" name="search_by" value="">
</form>
<form id="user_search" name="user_search" action="<% $url %>" method="get">
<table cellspacing="2" cellpadding="0" border="0" class="tform">
<tr><td height="3"></td></tr>
% foreach my $field ( @fields ) {
<tr><td align="right"><b><% $props{$field} %>:&nbsp;</b></td>
<td><input type="text" name="<% $field %>" size="40" value="<% $search_by && $search_by eq $field ? $search : '' %>"></td></tr>
% }

<tr><td align="right">&nbsp;</td>
<td align="right"><input type="button" size="40" value="Искать" onclick="StartSearch();">
&nbsp;&nbsp;&nbsp;<a href="<% $url %>">сбросить фильтр</a>
</td></tr>
<tr><td height="5"></td></tr>
</table>
</form>
</fieldset>
<%args>

	$url	=> 'index.html'
	$search	=> undef
	$search_by	=> undef

</%args>
<%init>

  my @fields;
  my @properties;
  my %props;
  my $class = $state->{users}->profile_document_class;
  my $object = $class->new ($keeper);
  if ( ref $object ) {
	@fields = $object->search_fields;
	@fields =  qw( login email nickname name )	unless @fields;
	@properties = $object->structure();
	%props = map { $_->{attr} => $_->{rusname} } @properties;
  } else {
	@fields = qw( login email nickname name );
	%props = (
		'login'		=> { 'Логин' },
		'email'		=> { 'E-mail' },
		'nickname'	=> { 'Ник' },
		'name'		=> { 'Ф.И.О.' },
	);
  }

</%init>