<& "/contenido/components/header.msn" &>
<& "/contenido/components/naviline.msn", sect_id => $owner->id &>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr valign="top">
<td width="35%">
<& /contenido/users/components/find_user.msn,
search => $search, search_by => $search_by,
url=>'sections.html' &>
<& "/contenido/users/components/subsection.msn", section => $owner &>
<& "/contenido/components/class_filter.msn", class=> $class, section => $owner &>
% if (( $owner->id ) && ($owner->id > 0) && $owner->id != 1 )
% {
<& "/contenido/components/section_info.msn", section => $owner &>
% }
</td>
<td width="2%"> </td>
<td width="65%">
% if($owner->id) {
<fieldset>
<legend>���������\
% if ($class) {
������ <% $class %>\
% if ($use_section) {
c ������ ������� ������\
% }
% } else {
� �������\
% }
% if ($total > 0) {
(�����: <% $total %>, �������� � <% $first + 1 %> �� <% ($first + $n > $total) ? $total : $first + $n %>)
% }
</legend>
% if ($total or defined($alpha) or defined($search) ) {
% if ($section_access == 2) {
<& "/contenido/components/new_objects_form.msn", proto => 'documents',
sect_id => $owner->id,
default => ($owner->default_document_class ? $owner->default_document_class : $class) &>
% }
<div style="font-size:75%; font-family:Arial;">
<table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0 0; border:1px solid gray;">
<tr bgcolor="#e0e0e0"><th colspan="4">����� �� �����: [<a href="?id=<% $id %>" style="font-weight:normal;">����� �������</a>]</th></tr>
<tr><td style="font-size:75%; font-family:Arial; padding:2px 4px;">
<& /inc/alpha.msn, alpha=>$alpha, params=>\%ARGS, &>
</td></tr></table>
% ## ����� ������. �������� ��� ���������� ������� ������
% ## � ��������� ��� ������ ������� search_fields
% ########################################################
%
% if ( $filter{class} ) {
% my $document = $filter{class}->new ($keeper);
% my @fields = $document->search_fields;
% if ( @fields ) {
% my @props = $document->required_properties;
<form action="sections.html">
<table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0; border:1px solid gray;">
<tr bgcolor="#e0e0e0"><th colspan="4">����� �� ����: [<a href="?id=<% $id %>" style="font-weight:normal;">����� �������</a>]</th></tr><tr>
<td width="1%" nowrap style="padding:2px 0 2px 4px;"><select name="search_by">
% foreach my $field ( @fields ) {
% my ($prop) = grep { $_->{'attr'} eq $field } @props;
% my $selected = $field eq $search_by ? ' selected' : '';
<option value="<% $field %>"<% $selected %>><% $prop->{'rusname'} %>
% }
</td><td width="0">:</td>
<td width="98%"><input type="text" name="search" value="<% $search %>" style="width:100%"></td>
<td width="1%" style="padding:2px 4px 2px 0;"><input type="submit" value=" » " style="border:1px solid gray;"></td>
</tr></table>
% if ( $id ) {
<input type="hidden" name="id" value="<% $id %>">
% }
% if ( $class ) {
<input type="hidden" name="class" value="<% $class %>">
% }
% if ( $use_section ) {
<input type="hidden" name="use_section" value="<% $use_section %>">
% }
</form>
% }
% }
<& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
</div>
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs">
<tr bgcolor="#efefef">
%
% foreach (@columns) {
%
<th><% $_->{rusname} %></th>
%
% }
%
</tr>
%
% unless (@documents) {
<tr><td align="center" colspan="<% scalar @columns %>">��������� �� �������</td></tr>
% }
% foreach my $document (@documents) {
%
% next unless ref($document);
% my $document_access = $user->section_accesses($user, $document->section);
%
<tr valign="top">
%
% for my $col (@columns) {
%
% if ($col->{attr} eq '_sort_') {
%
<td width="20px"><% $document->{sorder} %> <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> <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>\
%
% } elsif ($col->{attr} eq 'dtime') {
%
<td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{dtime} &>\
%
% if ($document->{ctime} ne $document->{mtime}) {
%
% my $colortime = '#c66';
%
<div style="color:<% $colortime %>;"><& "/contenido/components/show_dtime.msn", dtime=>$document->{mtime} &></div>\
%
% }
%
% } elsif ($col->{attr} eq 'name') {
%
<td><span<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> class="<% $document->status ? '':'hiddensect' %>">\
%
% my $name=$document->name ? $document->name : '���������� �������� N'.$document->id;
% if ($document_access == 2) {
%
<a<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> href="document.html?id=<% $document->id %>&class=<% $document->class %>"><% $name | h %> </a>\
%
% } else {
%
<% $name | h %> \
%
% }
%
</span>\
%
% } elsif ($col->{attr} eq 'id') {
%
<td><span class="<% $document->status ? '':'hiddensect' %>">\
%
% if ($document_access == 2) {
%
<a href="document.html?id=<% $document->id %>&class=<% $document->class %>"><% $document->id %> </a>\
%
% } else {
%
<% $document->id %> \
%
% }
%
</span>\
%
% } elsif ($col->{attr} eq 'class') {
%
<td><% $document->class_name %> <font color="#999999">(<% $document->class %>)</font>\
%
% } elsif ($col->{type} eq 'datetime') {
%
<td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{$col->{attr}} &>\
%
% } elsif ($col->{attr} eq '_act_') {
%
<td>\
% if ($document_access == 2) {
%
<a href="document.html?id=<% $document->id %>&class=<% $document->class %>" title="������������� ��������"><img
src="/contenido/i/actions/edit.gif" width="15" height="17" alt="������������� ��������" align="absmiddle" border="0" hspace="1"></a>\
<a href="document.html?clone=1&id=<% $document->id %>&class=<% $document->class %>" title="���������� ��������"><img
src="/contenido/i/actions/copy.gif" width="15" height="17" alt="���������� ��������" align="absmiddle" border="0" hspace="1"></a>\
<a href="confirm.html?id=<% $document->id %>&action=documents_deletion&from=<% $owner->id %>&class=<% $document->class %>" title="������� ��������"><img
src="/contenido/i/actions/delete.gif" width="14" height="17" alt="������� ��������" align="absmiddle" border="0" hspace="1"></a>\
% if ( $document->status != 0 ) {
<a href="document.html?deactivate=1&id=<% $document->id %>&class=<% $document->class %>" title="�������������� ������������"><img
src="/contenido/i/actions/deactivate.gif" width="14" height="17" alt="�������������� ������������" align="absmiddle" border="0" hspace="1"></a>\
% }
% if ( $document->status != 1 ) {
<a href="document.html?activate=1&id=<% $document->id %>&class=<% $document->class %>" title="��������� ������������ ������=1"><img
src="/contenido/i/actions/activate.gif" width="14" height="17" alt="��������� ������������ ������=1" align="absmiddle" border="0" hspace="1"></a>\
% }
<br>\
%#<a href="document.html?id=<% $document->id %>&class=<% $document->class %>">�������������</a><br/>\
%#<a href="confirm.html?id=<% $document->id %>&action=documents_deletion&from=<% $owner->id %>&class=<% $document->class %>">�������</a>\
%
% } else {
\
% }
%
% } else {
%
% if ($col->{type} eq 'date') {
% my $date=$document->{$col->{attr}};
% $date=~/(\d{4}-\d{2}-\d{2})/;
<td nowrap align="right"><% $1 || ' ' %>\
% } elsif ($col->{type} eq 'datetime') {
<td nowrap align="right"><% $document->{$col->{attr}} || ' ' %>\
% } elsif ($col->{type} eq 'integer') {
<td align="right"><% $document->{$col->{attr}} %> \
% } elsif ($col->{type} eq 'lookup') {
<td align="left">\
% my $id = $document->{$col->{attr}};
% if ($id) {
% my ($doc)=$keeper->get_documents( ( ref($col->{lookup_opts}) ? %{$col->{lookup_opts}} : () ), id=>$id);
% if ($doc) {
<a href="document.html?id=<% $doc->id %>&class=<% $doc->class %>"><% $doc->name || $doc->id %></a> \
% } else {
<span class="hiddensect"><% $document->{$col->{attr}} %>???</span>\
% }
% } else {
<span class="hiddensect">NULL</span>\
% }
% } elsif ($col->{type} eq 'status') {
% my $status_map = ref $col->{cases} eq 'ARRAY' ? $col->{cases} : $keeper->default_status();
% my ($doc_status) = grep { $_->[0] eq $document->{$col->{attr}} } @$status_map;
% $doc_status ||= [$document->{$col->{attr}}, '�����������'];
<td nowrap><% $doc_status->[1].'('.$doc_status->[0].')' %>\
% } else {
<td><% defined($document->{$col->{attr}}) ? $document->{$col->{attr}} : ' ' %>\
% }
% }
%
</td>
%
% } #- for @columns
%
</tr>
% } #- foreach @documents
</table>
<div style="font-size:75%; font-family:Arial;">
<& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
</div>
% } else {
<h4 align="center"><i>---- ��� ���������� -----</i></h4>
% }
%
% if ($section_access == 2) {
<& "/contenido/components/new_objects_form.msn", proto => 'documents',
sect_id => $owner->id,
default => ($owner->default_document_class ? $owner->default_document_class : $class) &>
% }
</fieldset>
</td>
</tr>
</table>
% }
</body>
</html>
<%args>
$id => 1
$p => 1
$class => undef
$use_section => undef
$alpha => undef
$alpha_search => undef
$search_by => undef
$search => undef
</%args>
<%init>
$id = 0 if $id =~ /\D/;
my $owner;
# ��������...
if ($id && ($id > 0))
{
$owner = $keeper->get_section_by_id($id);
}
if (! ref($owner))
{
return undef;
}
$class = $state->{users}->profile_document_class;
# ������� �������� � ����� ������...
my $filter = $m->comp('/contenido/components/context.msn', name => 'filter');
my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');
unless (defined $request->{section_accesses}->{$id})
{
$request->{section_accesses}->{$id} = $user->get_section_access($id);
}
my $section_access = $request->{section_accesses}->{$id};
my (@documents, $total);
my $s = $owner->id;
my $sorted = $owner->_sorted();
$s .= ",$filter" if ($filter > 0);
my %filter=();
my %order = (not $class and $owner->order_by) ? (order_by => $owner->order_by) : (order => ['date','direct']);
if (defined $alpha and $alpha ne '') {
$filter{ilike}=1;
$filter{ $alpha_search || 'name' }="$alpha%";
$order{order}=['name','reverse'];
delete $order{order_by};
}
$filter{class} = $owner->default_document_class if $owner->default_document_class;
$filter{class}=$class if ($class);
$filter{s}=$s unless ($class && !$use_section);
if ( $search_by && $search ) {
$filter{$search_by}='%'.$search.'%';
$filter{ilike} = 1;
}
# �������������� ������� �������
if ($owner->filters) {
no strict 'vars';
my $filters = eval($owner->filters);
if ($@) {
warn "Bad filter: " . $owner->filters . " in section " . $owner->id;
} elsif (ref $filters eq 'HASH') {
map { $filter{$_} = $filters->{$_} } keys %$filters;
}
}
$total = $keeper->get_documents(%filter, count=>1);
my $n = 40;
my $first = $n * ($p - 1);
($first,$p)=(0,0) if ($first>$total);
if ($class && !$use_section) {
@documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first, light=>1);
} elsif ($sorted) {
@documents = $keeper->get_sorted_documents(%filter, limit=>$n, offset=>$first, light=>1);
} else {
@documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first, light=>1);
}
# ����� ������� ������� ����������...
my @columns = $sorted ? ({attr => '_sort_', name => 'N'}) : ();
# �������� ����� �������, ������� �������� ��� ������� �������� (required_properties -> column)...
if ($filter{class} or @documents and $documents[0]) {
push @columns,
sort {$a->{column} <=> $b->{column}}
grep {$_->{column}} ($filter{class} ? $filter{class}->new($keeper)->structure : $documents[0]->structure);
}
# ����������� ����� �������...
@columns = (@columns,
{attr => '_act_', rusname => '��������'},
);
</%init>