Line # Revision Author
1 195 ahitrov <& "/contenido/components/header.msn" &>
2 <& "/contenido/components/naviline.msn", sect_id => $owner->id &>
3
4 <table width="100%" cellspacing="0" cellpadding="0" border="0">
5 <tr valign="top">
6 <td width="35%">
7
8 <& /contenido/users/components/find_user.msn,
9 search => $search, search_by => $search_by,
10 url=>'sections.html' &>
11
12 <& "/contenido/users/components/subsection.msn", section => $owner &>
13 <& "/contenido/components/class_filter.msn", class=> $class, section => $owner &>
14
15 % if (( $owner->id ) && ($owner->id > 0) && $owner->id != 1 )
16 % {
17 <& "/contenido/components/section_info.msn", section => $owner &>
18 % }
19
20 </td>
21 <td width="2%">&nbsp;</td>
22 <td width="65%">
23
24 % if($owner->id) {
25
26 <fieldset>
27 <legend>���������\
28 % if ($class) {
29 ������ <% $class %>\
30 % if ($use_section) {
31 c ������ ������� ������\
32 % }
33 % } else {
34 � �������\
35 % }
36 % if ($total > 0) {
37 (�����: <% $total %>, �������� � <% $first + 1 %> �� <% ($first + $n > $total) ? $total : $first + $n %>)
38 % }
39 </legend>
40
41 % if ($total or defined($alpha) or defined($search) ) {
42 % if ($section_access == 2) {
43 <& "/contenido/components/new_objects_form.msn", proto => 'documents',
44 sect_id => $owner->id,
45 default => ($owner->default_document_class ? $owner->default_document_class : $class) &>
46 % }
47 <div style="font-size:75%; font-family:Arial;">
48 <table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0 0; border:1px solid gray;">
49 <tr bgcolor="#e0e0e0"><th colspan="4">����� �� �����:&nbsp;&nbsp;[<a href="?id=<% $id %>" style="font-weight:normal;">����� �������</a>]</th></tr>
50 <tr><td style="font-size:75%; font-family:Arial; padding:2px 4px;">
51 <& /inc/alpha.msn, alpha=>$alpha, params=>\%ARGS, &>
52 </td></tr></table>
53 % ## ����� ������. �������� ��� ���������� ������� ������
54 % ## � ��������� ��� ������ ������� search_fields
55 % ########################################################
56 %
57 % if ( $filter{class} ) {
58 % my $document = $filter{class}->new ($keeper);
59 % my @fields = $document->search_fields;
60 % if ( @fields ) {
61 % my @props = $document->required_properties;
62 <form action="sections.html">
63 <table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0; border:1px solid gray;">
64 <tr bgcolor="#e0e0e0"><th colspan="4">����� �� ����:&nbsp;&nbsp;[<a href="?id=<% $id %>" style="font-weight:normal;">����� �������</a>]</th></tr><tr>
65 <td width="1%" nowrap style="padding:2px 0 2px 4px;"><select name="search_by">
66 % foreach my $field ( @fields ) {
67 % my ($prop) = grep { $_->{'attr'} eq $field } @props;
68 % my $selected = $field eq $search_by ? ' selected' : '';
69 <option value="<% $field %>"<% $selected %>><% $prop->{'rusname'} %>
70 % }
71 </td><td width="0">:</td>
72 <td width="98%"><input type="text" name="search" value="<% $search %>" style="width:100%"></td>
73 <td width="1%" style="padding:2px 4px 2px 0;"><input type="submit" value=" &raquo; " style="border:1px solid gray;"></td>
74 </tr></table>
75 % if ( $id ) {
76 <input type="hidden" name="id" value="<% $id %>">
77 % }
78 % if ( $class ) {
79 <input type="hidden" name="class" value="<% $class %>">
80 % }
81 % if ( $use_section ) {
82 <input type="hidden" name="use_section" value="<% $use_section %>">
83 % }
84 </form>
85 % }
86 % }
87
88 <& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
89 </div>
90
91 <table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs">
92 <tr bgcolor="#efefef">
93 %
94 % foreach (@columns) {
95 %
96 <th><% $_->{rusname} %></th>
97 %
98 % }
99 %
100 </tr>
101 %
102 % unless (@documents) {
103 <tr><td align="center" colspan="<% scalar @columns %>">��������� �� �������</td></tr>
104 % }
105 % foreach my $document (@documents) {
106 %
107 % next unless ref($document);
108 % my $document_access = $user->section_accesses($user, $document->section);
109 %
110 <tr valign="top">
111 %
112 % for my $col (@columns) {
113 %
114 % if ($col->{attr} eq '_sort_') {
115 %
116 <td width="20px"><% $document->{sorder} %>&nbsp;<a href="document_move.html?id=<% $document->{id} %>&move=up&s=<% $id %>&p=<% $p %>"><img src="/contenido/i/ico-up-9x10.gif" border=0 alt="����������� �������� �� ��� �����"></a>&nbsp;<a href="document_move.html?id=<% $document->{id} %>&move=down&s=<% $id %>&p=<% $p %>"><img src="/contenido/i/ico-down-9x10.gif" border=0 alt="����������� �������� �� ��� ����"></a>\
117 %
118 % } elsif ($col->{attr} eq 'dtime') {
119 %
120 <td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{dtime} &>\
121 %
122 % if ($document->{ctime} ne $document->{mtime}) {
123 %
124 % my $colortime = '#c66';
125 %
126 <div style="color:<% $colortime %>;"><& "/contenido/components/show_dtime.msn", dtime=>$document->{mtime} &></div>\
127 %
128 % }
129 %
130 % } elsif ($col->{attr} eq 'name') {
131 %
132 <td><span<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> class="<% $document->status ? '':'hiddensect' %>">\
133 %
134 % my $name=$document->name ? $document->name : '���������� �������� N'.$document->id;
135 % if ($document_access == 2) {
136 %
137 <a<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> href="document.html?id=<% $document->id %>&class=<% $document->class %>"><% $name | h %>&nbsp;</a>\
138 %
139 % } else {
140 %
141 <% $name | h %>&nbsp;\
142 %
143 % }
144 %
145 </span>\
146 %
147 % } elsif ($col->{attr} eq 'id') {
148 %
149 <td><span class="<% $document->status ? '':'hiddensect' %>">\
150 %
151 % if ($document_access == 2) {
152 %
153 <a href="document.html?id=<% $document->id %>&class=<% $document->class %>"><% $document->id %>&nbsp;</a>\
154 %
155 % } else {
156 %
157 <% $document->id %>&nbsp;\
158 %
159 % }
160 %
161 </span>\
162 %
163 % } elsif ($col->{attr} eq 'class') {
164 %
165 <td><% $document->class_name %>&nbsp;<font color="#999999">(<% $document->class %>)</font>\
166 %
167 % } elsif ($col->{type} eq 'datetime') {
168 %
169 <td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{$col->{attr}} &>\
170 %
171 % } elsif ($col->{attr} eq '_act_') {
172 %
173 <td>\
174 % if ($document_access == 2) {
175 %
176 <a href="document.html?id=<% $document->id %>&class=<% $document->class %>" title="������������� ��������"><img
177 src="/contenido/i/actions/edit.gif" width="15" height="17" alt="������������� ��������" align="absmiddle" border="0" hspace="1"></a>\
178 <a href="document.html?clone=1&id=<% $document->id %>&class=<% $document->class %>" title="���������� ��������"><img
179 src="/contenido/i/actions/copy.gif" width="15" height="17" alt="���������� ��������" align="absmiddle" border="0" hspace="1"></a>\
180 <a href="confirm.html?id=<% $document->id %>&action=documents_deletion&from=<% $owner->id %>&class=<% $document->class %>" title="������� ��������"><img
181 src="/contenido/i/actions/delete.gif" width="14" height="17" alt="������� ��������" align="absmiddle" border="0" hspace="1"></a>\
182 % if ( $document->status != 0 ) {
183 <a href="document.html?deactivate=1&id=<% $document->id %>&class=<% $document->class %>" title="�������������� ������������"><img
184 src="/contenido/i/actions/deactivate.gif" width="14" height="17" alt="�������������� ������������" align="absmiddle" border="0" hspace="1"></a>\
185 % }
186 % if ( $document->status != 1 ) {
187 <a href="document.html?activate=1&id=<% $document->id %>&class=<% $document->class %>" title="��������� ������������ ������=1"><img
188 src="/contenido/i/actions/activate.gif" width="14" height="17" alt="��������� ������������ ������=1" align="absmiddle" border="0" hspace="1"></a>\
189 % }
190 <br>\
191 %#<a href="document.html?id=<% $document->id %>&class=<% $document->class %>">�������������</a><br/>\
192 %#<a href="confirm.html?id=<% $document->id %>&action=documents_deletion&from=<% $owner->id %>&class=<% $document->class %>">�������</a>\
193 %
194 % } else {
195 &nbsp;\
196 % }
197 %
198 % } else {
199 %
200 % if ($col->{type} eq 'date') {
201 % my $date=$document->{$col->{attr}};
202 % $date=~/(\d{4}-\d{2}-\d{2})/;
203 <td nowrap align="right"><% $1 || '&nbsp;' %>\
204 % } elsif ($col->{type} eq 'datetime') {
205 <td nowrap align="right"><% $document->{$col->{attr}} || '&nbsp;' %>\
206 % } elsif ($col->{type} eq 'integer') {
207 <td align="right"><% $document->{$col->{attr}} %>&nbsp;\
208 % } elsif ($col->{type} eq 'lookup') {
209 <td align="left">\
210 % my $id = $document->{$col->{attr}};
211 % if ($id) {
212 % my ($doc)=$keeper->get_documents( ( ref($col->{lookup_opts}) ? %{$col->{lookup_opts}} : () ), id=>$id);
213 % if ($doc) {
214 <a href="document.html?id=<% $doc->id %>&class=<% $doc->class %>"><% $doc->name || $doc->id %></a>&nbsp;\
215 % } else {
216 <span class="hiddensect"><% $document->{$col->{attr}} %>???</span>\
217 % }
218 % } else {
219 <span class="hiddensect">NULL</span>\
220 % }
221 % } elsif ($col->{type} eq 'status') {
222 % my $status_map = ref $col->{cases} eq 'ARRAY' ? $col->{cases} : $keeper->default_status();
223 % my ($doc_status) = grep { $_->[0] eq $document->{$col->{attr}} } @$status_map;
224 % $doc_status ||= [$document->{$col->{attr}}, '�����������'];
225 <td nowrap><% $doc_status->[1].'('.$doc_status->[0].')' %>\
226 % } else {
227 <td><% defined($document->{$col->{attr}}) ? $document->{$col->{attr}} : '&nbsp;' %>\
228 % }
229 % }
230 %
231 </td>
232 %
233 % } #- for @columns
234 %
235 </tr>
236 % } #- foreach @documents
237 </table>
238
239 <div style="font-size:75%; font-family:Arial;">
240 <& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
241 </div>
242 % } else {
243 <h4 align="center"><i>---- ��� ���������� -----</i></h4>
244 % }
245 %
246 % if ($section_access == 2) {
247 <& "/contenido/components/new_objects_form.msn", proto => 'documents',
248 sect_id => $owner->id,
249 default => ($owner->default_document_class ? $owner->default_document_class : $class) &>
250 % }
251
252 </fieldset>
253 </td>
254 </tr>
255 </table>
256
257 % }
258
259 </body>
260 </html>
261 <%args>
262
263 $id => 1
264 $p => 1
265 $class => undef
266 $use_section => undef
267 $alpha => undef
268 $alpha_search => undef
269 $search_by => undef
270 $search => undef
271
272 </%args>
273 <%init>
274
275 $id = 0 if $id =~ /\D/;
276 my $owner;
277
278 # ��������...
279 if ($id && ($id > 0))
280 {
281 $owner = $keeper->get_section_by_id($id);
282 }
283 if (! ref($owner))
284 {
285 return undef;
286 }
287
288 $class = $state->{users}->profile_document_class;
289 # ������� �������� � ����� ������...
290 my $filter = $m->comp('/contenido/components/context.msn', name => 'filter');
291 my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');
292
293 unless (defined $request->{section_accesses}->{$id})
294 {
295 $request->{section_accesses}->{$id} = $user->get_section_access($id);
296 }
297 my $section_access = $request->{section_accesses}->{$id};
298
299 my (@documents, $total);
300
301 my $s = $owner->id;
302 my $sorted = $owner->_sorted();
303 $s .= ",$filter" if ($filter > 0);
304
305 my %filter=();
306 my %order = (not $class and $owner->order_by) ? (order_by => $owner->order_by) : (order => ['date','direct']);
307 if (defined $alpha and $alpha ne '') {
308 $filter{ilike}=1;
309 $filter{ $alpha_search || 'name' }="$alpha%";
310 $order{order}=['name','reverse'];
311 delete $order{order_by};
312 }
313
314 $filter{class} = $owner->default_document_class if $owner->default_document_class;
315 $filter{class}=$class if ($class);
316 $filter{s}=$s unless ($class && !$use_section);
317 if ( $search_by && $search ) {
318 $filter{$search_by}='%'.$search.'%';
319 $filter{ilike} = 1;
320 }
321
322 # �������������� ������� �������
323 if ($owner->filters) {
324 no strict 'vars';
325 my $filters = eval($owner->filters);
326 if ($@) {
327 warn "Bad filter: " . $owner->filters . " in section " . $owner->id;
328 } elsif (ref $filters eq 'HASH') {
329 map { $filter{$_} = $filters->{$_} } keys %$filters;
330 }
331 }
332
333 $total = $keeper->get_documents(%filter, count=>1);
334
335 my $n = 40;
336 my $first = $n * ($p - 1);
337 ($first,$p)=(0,0) if ($first>$total);
338
339 if ($class && !$use_section) {
340 @documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first, light=>1);
341 } elsif ($sorted) {
342 @documents = $keeper->get_sorted_documents(%filter, limit=>$n, offset=>$first, light=>1);
343 } else {
344 @documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first, light=>1);
345 }
346
347 # ����� ������� ������� ����������...
348 my @columns = $sorted ? ({attr => '_sort_', name => 'N'}) : ();
349
350 # �������� ����� �������, ������� �������� ��� ������� �������� (required_properties -> column)...
351 if ($filter{class} or @documents and $documents[0]) {
352 push @columns,
353 sort {$a->{column} <=> $b->{column}}
354 grep {$_->{column}} ($filter{class} ? $filter{class}->new($keeper)->structure : $documents[0]->structure);
355 }
356
357 # ����������� ����� �������...
358 @columns = (@columns,
359 {attr => '_act_', rusname => '��������'},
360 );
361 </%init>