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