1 |
196 |
ahitrov |
<script type="text/javascript"> |
2 |
|
|
<!-- |
3 |
|
|
function StartSearch () { |
4 |
|
|
var oForm = document.forms['user_search']; |
5 |
|
|
var oFormStart = document.forms['start_search']; |
6 |
|
|
% my $i = 0; |
7 |
|
|
% foreach my $field ( @fields ) { |
8 |
|
|
<% $i++ ? '} else if' : 'if' %> ( oForm.<% $field %>.value ) { |
9 |
|
|
oFormStart.search.value = oForm.<% $field %>.value; |
10 |
|
|
oFormStart.search_by.value = oForm.<% $field %>.name; |
11 |
|
|
% } |
12 |
|
|
% if ($i) { |
13 |
|
|
} |
14 |
|
|
% } |
15 |
|
|
if ( oFormStart.search.value && oFormStart.search_by.value ) { |
16 |
|
|
oFormStart.submit(); |
17 |
|
|
} |
18 |
|
|
} |
19 |
|
|
//--> |
20 |
|
|
</script> |
21 |
|
|
<fieldset> |
22 |
|
|
<legend>Поиск пользователя</legend> |
23 |
|
|
<form id="start_search" name="start_search" action="<% $url %>" method="get"> |
24 |
|
|
<input type="hidden" name="search" value=""> |
25 |
|
|
<input type="hidden" name="search_by" value=""> |
26 |
|
|
</form> |
27 |
|
|
<form id="user_search" name="user_search" action="<% $url %>" method="get"> |
28 |
|
|
<table cellspacing="2" cellpadding="0" border="0" class="tform"> |
29 |
|
|
<tr><td height="3"></td></tr> |
30 |
|
|
% foreach my $field ( @fields ) { |
31 |
|
|
<tr><td align="right"><b><% $props{$field} %>: </b></td> |
32 |
|
|
<td><input type="text" name="<% $field %>" size="40" value="<% $search_by && $search_by eq $field ? $search : '' %>"></td></tr> |
33 |
|
|
% } |
34 |
|
|
|
35 |
|
|
<tr><td align="right"> </td> |
36 |
|
|
<td align="right"><input type="button" size="40" value="Искать" onclick="StartSearch();"> |
37 |
|
|
<a href="<% $url %>">сбросить фильтр</a> |
38 |
|
|
</td></tr> |
39 |
|
|
<tr><td height="5"></td></tr> |
40 |
|
|
</table> |
41 |
|
|
</form> |
42 |
|
|
</fieldset> |
43 |
|
|
<%args> |
44 |
|
|
|
45 |
|
|
$url => 'index.html' |
46 |
|
|
$search => undef |
47 |
|
|
$search_by => undef |
48 |
|
|
|
49 |
|
|
</%args> |
50 |
|
|
<%init> |
51 |
|
|
|
52 |
|
|
my @fields; |
53 |
|
|
my @properties; |
54 |
|
|
my %props; |
55 |
|
|
my $class = $state->{users}->profile_document_class; |
56 |
|
|
my $object = $class->new ($keeper); |
57 |
|
|
if ( ref $object ) { |
58 |
|
|
@fields = $object->search_fields; |
59 |
|
|
@fields = qw( login email nickname name ) unless @fields; |
60 |
|
|
@properties = $object->structure(); |
61 |
|
|
%props = map { $_->{attr} => $_->{rusname} } @properties; |
62 |
|
|
} else { |
63 |
|
|
@fields = qw( login email nickname name ); |
64 |
|
|
%props = ( |
65 |
|
|
'login' => { 'Логин' }, |
66 |
|
|
'email' => { 'E-mail' }, |
67 |
|
|
'nickname' => { 'Ник' }, |
68 |
|
|
'name' => { 'Ф.И.О.' }, |
69 |
|
|
); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
</%init> |