1 |
8 |
ahitrov@rambler.ru |
<& "/contenido/components/title.msn" &> |
2 |
516 |
ahitrov |
% if ( ref $class eq 'ARRAY' ) { |
3 |
|
|
<div style="font:bold 13px Verdana; margin:4px;">Классы: |
4 |
|
|
% foreach my $cls ( @$class ) { |
5 |
|
|
<span style="color:teal;"><% $cls %></span> <span style="font:11px Verdana;">(<a href="document.html?class=<% $cls %>&<% $field %>=<% $id %><% $defaults %>" target="_blank">создать</a>)</span> | |
6 |
|
|
% } |
7 |
|
|
</div> |
8 |
|
|
% } else { |
9 |
8 |
ahitrov@rambler.ru |
<div style="font:bold 13px Verdana; margin:4px;">Класс: <span style="color:teal;"><% $class %></span> |
10 |
|
|
<span style="font:11px Verdana;">(<a href="document.html?class=<% $class %>&<% $field %>=<% $id %><% $defaults %>" target="_blank">создать новый</a>)</span></div> |
11 |
516 |
ahitrov |
% } |
12 |
8 |
ahitrov@rambler.ru |
% if ( ref $docs eq 'ARRAY' && @$docs ) { |
13 |
|
|
% if ($total > $size) { |
14 |
117 |
ahitrov |
<div style="font-size:12px; font-family:Arial; text-align:center;"> |
15 |
8 |
ahitrov@rambler.ru |
<& /inc/pages_.msn, p => $p, n => $size, total => $total, params => {%ARGS} &></div> |
16 |
|
|
% } |
17 |
368 |
ahitrov |
% my @props = sort { $a->{column} <=> $b->{column} } grep { exists $_->{column} && $_->{column} } $docs->[0]->structure; |
18 |
8 |
ahitrov@rambler.ru |
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs"> |
19 |
|
|
<tr bgcolor="#efefef"> |
20 |
|
|
% foreach my $prop (@props) { |
21 |
671 |
ahitrov |
<th><% exists $prop->{shortname} ? $prop->{shortname} : $prop->{rusname} %></th> |
22 |
8 |
ahitrov@rambler.ru |
% } |
23 |
|
|
<th> </th> |
24 |
|
|
</tr> |
25 |
|
|
% foreach my $doc (@$docs) { |
26 |
|
|
% my $document_access = $user->section_accesses($user, $doc->section); |
27 |
|
|
% my $color = $doc->contenido_status_style ? $doc->contenido_status_style : |
28 |
188 |
ahitrov |
% $doc->status == 1 ? 'color:blue;' : |
29 |
|
|
% $doc->status == 0 ? 'color:gray;' : 'color:blue;'; |
30 |
8 |
ahitrov@rambler.ru |
% my ($a1, $a2) = $document_access == 2 ? ('<a href="document.html?id='.$doc->id.'&class='.$doc->class.'" style="'.$color.'" target="_blank">', '</a>') : ('',''); |
31 |
|
|
%# my ($stat) = grep { $_->{attr} eq 'status' } @props; |
32 |
|
|
%# my ($case) = grep { $_->[0] == $banner->status } @{ $stat->{cases} } if ref $stat eq 'HASH' && exists $stat->{cases}; |
33 |
|
|
<tr> |
34 |
|
|
% foreach my $prop (@props) { |
35 |
|
|
% my $attr = $prop->{attr}; |
36 |
368 |
ahitrov |
% if ( $prop->{type} =~ /(datetime|date)/ ) { |
37 |
8 |
ahitrov@rambler.ru |
<td><% $a1 %><& "/contenido/components/show_dtime.msn", dtime => $doc->$attr &><% $a2 %></td> |
38 |
368 |
ahitrov |
% } elsif ( $prop->{type} eq 'status' ) { |
39 |
|
|
% my ($case) = grep { $_->[0] == $doc->$attr } @{$prop->{cases}}; |
40 |
|
|
<td><% ref $case ? $case->[1] : 'неизвестно ['.$doc->$attr.']' %></td> |
41 |
|
|
% } else { |
42 |
8 |
ahitrov@rambler.ru |
<td><% $a1.$doc->$attr.$a2 %></td> |
43 |
|
|
% } |
44 |
|
|
% } |
45 |
|
|
<td nowrap>\ |
46 |
|
|
% if ($document_access == 2) { |
47 |
|
|
<a href="document_fast_delete.html?id=<% $doc->id %>&class=<% $doc->class %>" onclick="return confirm('Удалить документ?');" title="Удалить документ"><img |
48 |
|
|
src="/contenido/i/actions/delete.gif" width="14" height="17" alt="Удалить документ" align="absmiddle" border="0" hspace="1"></a>\ |
49 |
|
|
% } |
50 |
|
|
</td> |
51 |
|
|
</tr> |
52 |
|
|
% } |
53 |
|
|
</table> |
54 |
|
|
% } |
55 |
|
|
%#<pre><% Dumper($docs->[0]->required_properties) %></pre> |
56 |
|
|
<%args> |
57 |
|
|
$id => undef |
58 |
|
|
$filter => undef |
59 |
|
|
$field => undef |
60 |
|
|
$from => undef |
61 |
|
|
$to => undef |
62 |
|
|
$class => undef |
63 |
|
|
$order_by => undef |
64 |
|
|
$p => 1 |
65 |
|
|
</%args> |
66 |
|
|
<%init> |
67 |
|
|
|
68 |
|
|
my ($docs, $total); |
69 |
|
|
my $defaults = ''; |
70 |
|
|
my $size = 15; |
71 |
|
|
if ( $id && $filter && $class ) { |
72 |
|
|
my %opts = (); |
73 |
|
|
$opts{$filter} = $id; |
74 |
|
|
$opts{order_by} = $order_by if $order_by; |
75 |
|
|
$docs = $keeper->get_documents ( |
76 |
|
|
class => $class, |
77 |
|
|
return_mode => 'array_ref', |
78 |
|
|
offset => ($p-1)*$size, |
79 |
|
|
limit => $size, |
80 |
|
|
%opts, |
81 |
|
|
); |
82 |
|
|
delete $opts{order_by}; |
83 |
|
|
$total = $keeper->get_documents ( |
84 |
|
|
class => $class, |
85 |
|
|
count => 1, |
86 |
|
|
%opts, |
87 |
|
|
); |
88 |
|
|
} else { |
89 |
|
|
return; |
90 |
|
|
} |
91 |
|
|
if ( defined $from && defined $to ) { |
92 |
|
|
if ( ref $from eq 'ARRAY' && ref $to eq 'ARRAY' && (scalar @$from == scalar @$to) ) { |
93 |
|
|
for ( 0..(scalar @$from - 1) ) { |
94 |
|
|
$defaults .= '&'.$from->[$_].'='.$to->[$_]; |
95 |
|
|
} |
96 |
|
|
} elsif ( !ref $from && !ref $to ) { |
97 |
|
|
$defaults .= '&'.$from.'='.$to; |
98 |
|
|
} |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
</%init> |