Line # Revision Author
1 616 ahitrov % unless ( $no_tr ) {
2 842 ahitrov <tr valign="top" class="data-row" id="row-<% $document->id %>" data-id="<% $document->id %>" <% $section->_sorted() ? 'draggable="true"' : '' %>>
3 616 ahitrov % }
4 607 ahitrov <td nowrap>\
5 616 ahitrov % if ($document_access == 2) {
6 607 ahitrov <input type="checkbox" class="common-check" name="<% 'delete_'.$document->id.'_id' %>">
7 616 ahitrov % } else {
8 607 ahitrov &nbsp;
9 616 ahitrov % }
10 607 ahitrov </td>
11 %
12 616 ahitrov % for my $col (@$columns) {
13 % my $attr = $col->{attr};
14 % my $type = exists $col->{inline_type} ? $col->{inline_type} : $col->{type};
15 % my $class_name = $document->class;
16 % $class_name =~ s/:/-/g;
17 % if ($attr eq '_sort_') {
18 607 ahitrov %
19 609 ahitrov <td width="20px"><% $document->{sorder} %>&nbsp;<a class="move-up" data-id="<% $document->id %>"
20 607 ahitrov href="document_move.html?id=<% $document->{id} %>&move=up&s=<% $id %><% $params_unsection ? '&'.$params_unsection : '' %>"><img
21 609 ahitrov src="/contenido/i/ico-up-9x10.gif" border=0 alt="Переместить документ на шаг вверх"></a>&nbsp;<a class="move-down" data-id="<% $document->id %>"
22 607 ahitrov href="document_move.html?id=<% $document->{id} %>&move=down&s=<% $id %><% $params_unsection ? '&'.$params_unsection : '' %>"><img
23 src="/contenido/i/ico-down-9x10.gif" border=0 alt="Переместить документ на шаг вниз"></a>\
24 %
25 616 ahitrov % } elsif ($attr eq 'dtime') {
26 607 ahitrov %
27 <td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{dtime} &>\
28 %
29 616 ahitrov % if ($document->{ctime} ne $document->{mtime}) {
30 % my $colortime = '#c66';
31 607 ahitrov %
32 <div style="color:<% $colortime %>;"><& "/contenido/components/show_dtime.msn", dtime=>$document->{mtime} &></div>\
33 %
34 616 ahitrov % }
35 607 ahitrov %
36 616 ahitrov % } elsif ($attr eq 'name') {
37 607 ahitrov %
38 <td><span<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> class="<% $document->status ? '':'hiddensect' %>">\
39 %
40 616 ahitrov % my $name=$document->name ? $document->name : 'Безымянный документ N'.$document->id;
41 % if ($document_access == 2) {
42 607 ahitrov %
43 <a<% $document->contenido_status_style ? ' style="' . $document->contenido_status_style . '"' : '' %> href="document.html?id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"><% $name | h %></a>\
44 %
45 616 ahitrov % } else {
46 607 ahitrov %
47 <% $name | h %>\
48 %
49 616 ahitrov % }
50 607 ahitrov %
51 </span>\
52 %
53 616 ahitrov % } elsif ($attr eq 'id') {
54 607 ahitrov %
55 <td><span class="<% $document->status ? '':'hiddensect' %>">\
56 616 ahitrov % if ($document_access == 2) {
57 607 ahitrov <a href="document.html?id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"><% $document->id %>&nbsp;</a>\
58 616 ahitrov % } else {
59 607 ahitrov <% $document->id %>&nbsp;\
60 616 ahitrov % }
61 607 ahitrov </span>\
62 %
63 616 ahitrov % } elsif ( exists $col->{inline} && $col->{inline} ) {
64 % if ( $type =~ /^(string|integer|float)$/ && $col->{inline} ) {
65 % my $style = $col->{inline_style} ? $col->{inline_style} : ($col->{type} =~ /^(integer|float)$/ ? 'text-align:right; ' : '' );
66 % $style .= $col->{inline_width} ? ' width:'.$col->{inline_width}.'px; ' : ' width:65px; ';
67 607 ahitrov <td><input type="text" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>" style="<% $style %>">
68 616 ahitrov % } elsif ($type eq 'checkbox') {
69 % my $checked = $document->$attr ? ' checked' : '';
70 607 ahitrov <td align="center"><input type="checkbox" class="<% $attr %>-check" name="<% 'update_'.$document->id.'_'.$attr %>"<% $checked %>>
71 616 ahitrov % } elsif ($type eq 'text') {
72 % my $style = $col->{inline_style} ? $col->{inline_style} : '';
73 % $style .= $col->{inline_width} ? ' width:'.$col->{inline_width}.'px; ' : ' width:100px; ';
74 % $style .= $col->{inline_height} ? ' width:'.$col->{inline_height}.'px; ' : ' height:70px; ';
75 % my $value = $document->$attr;
76 % for ( $value ) {
77 % s/</&lt;/sgi;
78 % s/>/&gt;/sgi;
79 % }
80 607 ahitrov <td><textarea name="<% 'update_'.$document->id.'_'.$attr %>" style="<% $style %>"><% $value %></textarea>
81 616 ahitrov % } elsif ($type eq 'select') {
82 % my $options = {};
83 % if ($toopi && (ref($toopi) eq 'HASH') && (exists($toopi->{$document->class}))) {
84 % %{ $options } = %{ $toopi->{$document->class} };
85 % }
86 % my $values = $options->{$attr};
87 607 ahitrov <td><select name="<% 'update_'.$document->id.'_'.$attr %>" autocomplete="off">
88 616 ahitrov % if ( ref $values eq 'ARRAY' ) {
89 % foreach my $val ( @$values ) {
90 % my $selected = $val eq $document->$attr ? ' selected' : '';
91 607 ahitrov <option value="<% $val %>"<% $selected %>><% $val %>
92 616 ahitrov % }
93 % }
94 607 ahitrov </select>
95 616 ahitrov % } elsif ($type eq 'status') {
96 % my $cases = $col->{cases};
97 % if ( ref $cases eq 'ARRAY' ) {
98 607 ahitrov <td><select name="<% 'update_'.$document->id.'_'.$attr %>" style="<% $col->{inline_width} ? 'width:'.$col->{inline_width}.'px;' : '' %> <% $col->{inline_style} || '' %>" autocomplete="off">
99 616 ahitrov % foreach my $case ( @$cases ) {
100 % my $selected = $case->[0] eq $document->$attr ? ' selected' : '';
101 607 ahitrov <option value="<% $case->[0] %>"<% $selected %>><% $case->[1] %>
102 616 ahitrov % }
103 607 ahitrov </select>
104 616 ahitrov % }
105 % } elsif ($type eq 'pickup' || $type eq 'autocomplete') {
106 % my %opts = %{ $col->{lookup_opts} };
107 % my $doc;
108 % if ( $document->$attr ) {
109 % $doc = $keeper->get_document_by_id( $document->$attr, %opts );
110 % }
111 607 ahitrov <td><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" id="<% 'update_'.$document->id.'_'.$attr %>" value="<% ($document->$attr || '') |h %>">
112 <input type="text" class="<% 'autocomplete_'.$attr %>" id="<% 'autocomplete_'.$document->id.'_'.$attr %>" value="<% (ref $doc ? $doc->name : '') |h %>"
113 title="<% defined $document->$attr ? 'Значение: '.$document->$attr : '' %>"
114 rel="<% 'update_'.$document->id.'_'.$attr %>" style="<% $col->{inline_width} ? 'width:'.$col->{inline_width}.'px;' : '' %> <% $col->{inline_style} || '' %>"
115 old-value="<% (ref $doc ? $doc->name : '') |h %>" onfocus="" onblur="">
116 616 ahitrov % } elsif ($type eq 'lookup') {
117 % my %opts = %{ $col->{lookup_opts} };
118 % delete $opts{search_by} if exists $opts{search_by};
119 % my $docs;
120 % if ( ref $lookup_elements eq 'HASH' && exists $lookup_elements->{$attr} ) {
121 % $docs = $lookup_elements->{$attr};
122 % } else {
123 % $docs = $keeper->get_documents( %opts, return_mode => 'array_ref', names => 1 );
124 % if ( ref $lookup_elements eq 'HASH' ) {
125 % $lookup_elements->{$attr} = $docs;
126 % }
127 % }
128 % if ( ref $docs eq 'ARRAY' && @$docs ) {
129 607 ahitrov <td><select name="<% 'update_'.$document->id.'_'.$attr %>" style="<% $col->{inline_width} ? 'width:'.$col->{inline_width}.'px;' : '' %> <% $col->{inline_style} || '' %>" autocomplete="off">
130 <option value="<% $col->{allow_null} ? '' : 0 %>"></option>
131 616 ahitrov % foreach my $case ( @$docs ) {
132 % my $selected = $case->[0] eq $document->$attr ? ' selected' : '';
133 607 ahitrov <option value="<% $case->[0] %>"<% $selected %>><% $case->[1] %>
134 616 ahitrov % }
135 607 ahitrov </select>
136 616 ahitrov % } else {
137 607 ahitrov <td><% $document->$attr %><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>">\
138 616 ahitrov % }
139 % } else {
140 607 ahitrov <td><% $document->$attr %><input type="hidden" name="<% 'update_'.$document->id.'_'.$attr %>" value="<% $document->$attr |h %>">\
141 616 ahitrov % }
142 607 ahitrov %
143 616 ahitrov % } elsif ($attr eq 'class') {
144 607 ahitrov %
145 <td><% $document->class_name %>&nbsp;<font color="#999999">(<% $document->class %>)</font>\
146 %
147 616 ahitrov % } elsif ($type eq 'datetime') {
148 607 ahitrov %
149 610 ahitrov <td nowrap><& "/contenido/components/show_dtime.msn", dtime=>$document->{$attr} &>\
150 607 ahitrov %
151 616 ahitrov % } elsif ($attr eq '_act_') {
152 607 ahitrov %
153 621 ahitrov <td nowrap class="actions">\
154 616 ahitrov % if ($document_access == 2) {
155 607 ahitrov %
156 <a href="document.html?id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>" title="Редактировать документ"><img
157 src="/contenido/i/actions/edit.gif" width="15" height="17" alt="Редактировать документ" align="absmiddle" border="0" hspace="1"></a>\
158 <a href="document.html?clone=1&id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>" title="Копировать документ"><img
159 src="/contenido/i/actions/copy.gif" width="15" height="17" alt="Копировать документ" align="absmiddle" border="0" hspace="1"></a>\
160 <a href="confirm.html?id=<% $document->id %>&action=documents_deletion&from=<% $section->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>" title="Удалить документ"><img
161 src="/contenido/i/actions/delete.gif" width="14" height="17" alt="Удалить документ" align="absmiddle" border="0" hspace="1"></a>\
162 616 ahitrov % if ( $document->status != 0 ) {
163 <a href="document.html?deactivate=1&id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"
164 618 ahitrov class="context-menu-<% $class_name %>" id="status-set-<% $document->id %>" title="Статус документа" data-id="<% $document->id %>"><img
165 616 ahitrov src="/contenido/i/actions/activate.gif" width="14" height="17" alt="Документ активен" align="absmiddle" border="0" hspace="1"></a>\
166 % } else {
167 <a href="document.html?activate=1&id=<% $document->id %>&class=<% $document->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"
168 618 ahitrov class="context-menu-<% $class_name %>" id="status-set-<% $document->id %>" title="Статус документа" data-id="<% $document->id %>"><img
169 616 ahitrov src="/contenido/i/actions/deactivate.gif" width="14" height="17" alt="Документ не активен" align="absmiddle" border="0" hspace="1"></a>\
170 % }
171 607 ahitrov <br>\
172 %
173 616 ahitrov % } else {
174 607 ahitrov &nbsp;\
175 616 ahitrov % }
176 % if ( $inline_status ) {
177 607 ahitrov <input type="hidden" name="update_<% $document->id %>_class" value="<% $document->class %>">
178 616 ahitrov % }
179 % if ( $delete_status ) {
180 607 ahitrov <input type="hidden" name="delete_<% $document->id %>_class" value="<% $document->class %>">
181 616 ahitrov % }
182 607 ahitrov %
183 616 ahitrov % } else {
184 % my $attr = $attr;
185 % if ($type eq 'date') {
186 % my $date=$document->{$attr};
187 836 ahitrov % $date=~/(\d{4})-(\d{2})-(\d{2})/;
188 <td nowrap align="right"><% $3.'.'.$2.'.'.$1 || '&nbsp;' %>\
189 616 ahitrov % } elsif ($type eq 'datetime') {
190 610 ahitrov <td nowrap align="right"><% $document->{$attr} || '&nbsp;' %>\
191 616 ahitrov % } elsif ($type eq 'integer') {
192 610 ahitrov <td align="right"><% $document->{$attr} %>&nbsp;\
193 616 ahitrov % } elsif ($type eq 'lookup' || $type eq 'pickup' || $type eq 'autocomplete') {
194 607 ahitrov <td align="left">\
195 616 ahitrov % my $id = $document->{$attr};
196 % if ($id) {
197 % my ($doc)=$keeper->get_documents( ( ref($col->{lookup_opts}) ? %{$col->{lookup_opts}} : () ), id=>$id);
198 % if ($doc) {
199 607 ahitrov <a href="document.html?id=<% $doc->id %>&class=<% $doc->class %><% $params_unclassed ? '&'.$params_unclassed : '' %>"><% $doc->name || $doc->id %></a>&nbsp;\
200 616 ahitrov % } else {
201 610 ahitrov <span class="hiddensect"><% $document->{$attr} %>???</span>\
202 616 ahitrov % }
203 % } else {
204 607 ahitrov <span class="hiddensect">NULL</span>\
205 616 ahitrov % }
206 % } elsif ($type eq 'checkbox') {
207 607 ahitrov <td align="center"><% $document->$attr ? '<img src="/contenido/i/checked-16x16.png" width="16" height="16">' : '&nbsp;' %>\
208 616 ahitrov % } elsif ($type eq 'status') {
209 % my $status_map = ref $col->{cases} eq 'ARRAY' ? $col->{cases} : $keeper->default_status();
210 % my ($doc_status) = grep { $_->[0] eq $document->{$attr} } @$status_map;
211 % $doc_status ||= [$document->{$attr}, 'Неизвестный'];
212 607 ahitrov <td nowrap><% $doc_status->[1].'('.$doc_status->[0].')' %>\
213 616 ahitrov % } else {
214 607 ahitrov <td><% defined($document->$attr) ? $document->$attr : '&nbsp;' %>\
215 616 ahitrov % }
216 % }
217 607 ahitrov </td>
218 %
219 616 ahitrov % } #- for @columns
220 % unless ( $no_tr ) {
221 607 ahitrov </tr>
222 616 ahitrov % }
223 607 ahitrov <%args>
224
225 616 ahitrov $no_tr => undef
226 607 ahitrov $toopi => undef
227 $filter => undef
228 $document => undef
229 $columns => undef
230 $section => undef
231 $inline_status => undef
232 $lookup_elements => undef
233 $params_unclassed => undef
234 $params_unsection => undef
235
236 </%args>
237 <%init>
238
239 return unless ref $document;
240 return unless ref $columns eq 'ARRAY';
241 my $document_access = exists $document->{document_access} ? $document->{document_access} : $user->section_accesses($user, $document->section);
242 my $delete_status = $document_access == 2 ? 1 : 0;
243 my $id = ref $section ? $section->id : undef;
244 $toopi = $project->documents() unless defined $toopi;
245
246 my $params = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } keys %$filter ) : '';
247 unless ( defined $params_unclassed ) {
248 $params_unclassed = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } grep { $_ ne 'class' } keys %$filter ) : '';
249 }
250 unless ( defined $params_unsection ) {
251 $params_unsection = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } grep { $_ ne 's' } keys %$filter ) : '';
252 }
253
254 unless ( defined $inline_status ) {
255 map {
256 if ( exists $_->{inline} && $_->{inline} ) {
257 $inline_status = 1;
258 }
259 } @$columns;
260 }
261
262 </%init>