Line # Revision Author
1 616 ahitrov <% $json %>
2 <%once>
3
4 use JSON::XS;
5
6 </%once>
7 <%args>
8
9 $s => undef
10 $id => undef
11 $class => undef
12 $status => undef
13 $params => undef
14
15 </%args>
16 <%init>
17
18 my %result;
19
20 if ( $id && $id =~ /^\d+$/ && $class && $class =~ /::/ && defined $status ) {
21 my $section = $keeper->get_section_by_id( $s ) if $s;
22 my $document = $keeper->get_document_by_id( $id, class => $class );
23 my %filter;
24 map { if ( $_ =~ /(.+?)=(.*)/ ) { $filter{$1} = $2 } } split(/\&/, $params);
25 my $params_unclassed = join ('&', map { $_.'='.$filter{$_} } grep { $_ ne 'class' } keys %filter );
26 my $params_unsection = join ('&', map { $_.'='.$filter{$_} } grep { $_ ne 's' } keys %filter );
27 if ( ref $document ) {
28 # набор колонок таблицы документов...
29 my @columns = ref $section && $section->_sorted ? ({attr => '_sort_', name => 'N'}) : ();
30
31 # пытаемся найти колонки, которые документ сам пожелал показать (required_properties -> column)...
32 push @columns,
33 sort {$a->{column} <=> $b->{column}}
34 grep {$_->{column}} $document->structure;
35
36 # стандартная жопка таблицы...
37 push @columns, {attr => '_act_', rusname => 'Действия'};
38
39 $document->status( $status );
40 $document->store;
41
42 my $html = $m->scomp('/contenido/components/section_browse_row.msn', no_tr => 1,
43 document => $document, columns => \@columns, section => $section,
44 lookup_elemets => {}, filter => \%filter, params_unsection => $params_unsection, params_unclassed => $params_unclassed
45 );
46 $result{success} = 1;
47 $result{html} = Encode::decode('utf-8', $html);
48 } else {
49 $result{error} = Encode::decode('utf-8', 'Документ не найден');
50 }
51 } else {
52 $result{error} = Encode::decode('utf-8', 'Переданы неверные параметры');
53 }
54
55 my $json = encode_json \%result;
56
57 </%init>