1 |
8 |
ahitrov@rambler.ru |
<script type="text/javascript"> |
2 |
|
|
<!-- |
3 |
421 |
ahitrov |
function checkbox_common_toggle ( sClassSelector ) { |
4 |
|
|
$('.' + sClassSelector).each(function(){ |
5 |
|
|
var oField = $(this)[0]; |
6 |
8 |
ahitrov@rambler.ru |
if ( oField.checked ) { |
7 |
|
|
oField.checked = 0; |
8 |
|
|
} else { |
9 |
|
|
oField.checked = 1; |
10 |
|
|
} |
11 |
421 |
ahitrov |
}); |
12 |
8 |
ahitrov@rambler.ru |
} |
13 |
386 |
ahitrov |
% if ( @inline_pickups ) { |
14 |
522 |
ahitrov |
$(document).ready(function() { |
15 |
386 |
ahitrov |
% foreach my $pickup ( @inline_pickups ) { |
16 |
|
|
% my $lookup_opts = $pickup->{lookup_opts}; |
17 |
|
|
% my $search_opts = join( '&', map { $_.'='.$lookup_opts->{$_} } keys %$lookup_opts ); |
18 |
|
|
|
19 |
|
|
$('.autocomplete_<% $pickup->{attr} %>').autocomplete({ |
20 |
|
|
minLength : 2, |
21 |
|
|
source : '/contenido/ajax/document_search.html?<% $search_opts %>', |
22 |
|
|
select : function( event, ui ) |
23 |
|
|
{ |
24 |
|
|
var sStoreId = $(this).attr('rel'); |
25 |
|
|
var item = ui.item; |
26 |
|
|
// alert(mydump(item)); |
27 |
|
|
$('#' + sStoreId).val( item.id ); |
28 |
|
|
// $(this).val(item.label); |
29 |
|
|
// alert( $('#' + sStoreId).val() ); |
30 |
|
|
}, |
31 |
|
|
change : function( event, ui ) |
32 |
|
|
{ |
33 |
|
|
var sStoreId = $(this).attr('rel'); |
34 |
|
|
var sValue = $(this).val(); |
35 |
|
|
if ( sValue == '' ) { |
36 |
|
|
$('#' + sStoreId).val(''); |
37 |
|
|
} |
38 |
|
|
} |
39 |
|
|
}); |
40 |
|
|
|
41 |
|
|
% } |
42 |
|
|
}); |
43 |
|
|
% } |
44 |
|
|
|
45 |
|
|
function mydump(arr,level) { |
46 |
|
|
var dumped_text = ""; |
47 |
|
|
if(!level) level = 0; |
48 |
|
|
|
49 |
|
|
var level_padding = ""; |
50 |
|
|
for(var j=0;j<level+1;j++) level_padding += " "; |
51 |
|
|
|
52 |
|
|
if(typeof(arr) == 'object') { |
53 |
|
|
for(var item in arr) { |
54 |
|
|
var value = arr[item]; |
55 |
|
|
|
56 |
|
|
if(typeof(value) == 'object') { |
57 |
|
|
dumped_text += level_padding + "'" + item + "' ...\n"; |
58 |
|
|
dumped_text += mydump(value,level+1); |
59 |
|
|
} else { |
60 |
|
|
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; |
61 |
|
|
} |
62 |
|
|
} |
63 |
|
|
} else { |
64 |
|
|
dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; |
65 |
|
|
} |
66 |
|
|
return dumped_text; |
67 |
|
|
} |
68 |
|
|
|
69 |
609 |
ahitrov |
$(document).ready(function(){ |
70 |
|
|
$('.move-up').on('click', function( ev ){ |
71 |
|
|
ev.preventDefault(); |
72 |
|
|
var $nID = $(this).data('id'); |
73 |
|
|
$.ajax({ |
74 |
|
|
'url' : '/contenido/ajax/document_move.html', |
75 |
|
|
'data' : { 's' : <% ref $section ? $section->id : 0 %>, 'id' : $nID, 'move' : 'up' }, |
76 |
|
|
'dataType' : 'json', |
77 |
|
|
'success' : function( data ){ |
78 |
|
|
if ( data.error ) { |
79 |
|
|
alert( data.error ); |
80 |
|
|
} else if ( data.before ) { |
81 |
|
|
var $nBefore = data.before; |
82 |
|
|
$('#row-' + $nID).insertBefore('#row-' + $nBefore); |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
}); |
86 |
|
|
}); |
87 |
|
|
$('.move-down').on('click', function( ev ){ |
88 |
|
|
ev.preventDefault(); |
89 |
|
|
var $nID = $(this).data('id'); |
90 |
|
|
$.ajax({ |
91 |
|
|
'url' : '/contenido/ajax/document_move.html', |
92 |
611 |
ahitrov |
'data' : { 's' : <% ref $section ? $section->id : 0 %>, 'id' : $nID, 'move' : 'down' }, |
93 |
609 |
ahitrov |
'dataType' : 'json', |
94 |
|
|
'success' : function( data ){ |
95 |
|
|
if ( data.error ) { |
96 |
|
|
alert( data.error ); |
97 |
|
|
} else if ( data.after ) { |
98 |
|
|
var $nAfter = data.after; |
99 |
|
|
$('#row-' + $nID).insertAfter('#row-' + $nAfter); |
100 |
|
|
} |
101 |
|
|
} |
102 |
|
|
}); |
103 |
|
|
}); |
104 |
|
|
}); |
105 |
8 |
ahitrov@rambler.ru |
//--> |
106 |
|
|
</script> |
107 |
|
|
<form name="section_browse" action="sections.html" method="POST"> |
108 |
|
|
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tlistdocs"> |
109 |
|
|
<tr bgcolor="#efefef"> |
110 |
421 |
ahitrov |
<th><a href="javascript:void(0)" onclick="checkbox_common_toggle('common-check'); return false;"><img src="/contenido/i/checkbox-14x14-green.gif" width="14" height="14" title="Выбор документов для групповых операций" align="absmiddle" border="0" style="margin-left:3px;"></a></th> |
111 |
8 |
ahitrov@rambler.ru |
% |
112 |
|
|
% foreach (@$columns) { |
113 |
421 |
ahitrov |
<th>\ |
114 |
|
|
% if ( $_->{inline} && $_->{type} eq 'checkbox' ) { |
115 |
|
|
<a href="javascript:void(0)" onclick="checkbox_common_toggle('<% $_->{attr} %>-check'); return false;"><img src="/contenido/i/checkbox-14x14-green.gif" width="14" height="14" title="Выбор документов для групповых операций" align="absmiddle" border="0" style="margin:0 5px 0 2px;"></a>\ |
116 |
|
|
% } |
117 |
|
|
<% $_->{shortname} || $_->{rusname} %></th> |
118 |
8 |
ahitrov@rambler.ru |
% } |
119 |
|
|
% |
120 |
|
|
</tr> |
121 |
|
|
% |
122 |
|
|
% unless (@$documents) { |
123 |
|
|
<tr><td align="center" colspan="<% scalar @$columns %>">Документы не найдены</td></tr> |
124 |
|
|
% } |
125 |
|
|
% foreach my $document (@$documents) { |
126 |
|
|
% |
127 |
|
|
% next unless ref($document); |
128 |
|
|
% my $document_access = $user->section_accesses($user, $document->section); |
129 |
|
|
% |
130 |
607 |
ahitrov |
<& /contenido/components/section_browse_row.msn, document => $document, columns => $columns, section => $section, |
131 |
|
|
toopi => $toopi, inline_status => $inline_status, lookup_elemets => \%lookup_elements, |
132 |
|
|
filter => $filter, params_unsection => $params_unsection, params_unclassed => $params_unclassed |
133 |
|
|
&> |
134 |
8 |
ahitrov@rambler.ru |
% } #- foreach @documents |
135 |
|
|
</table> |
136 |
|
|
<input type="hidden" name="id" value="<% $section->id %>"> |
137 |
|
|
% if ( ref $filter eq 'HASH' ) { |
138 |
|
|
% while ( my ($key, $value) = each %$filter ) { |
139 |
|
|
% next if $key eq 's'; |
140 |
|
|
<input type="hidden" name="<% $key %>" value="<% $value |h %>"> |
141 |
|
|
% } |
142 |
|
|
% } |
143 |
522 |
ahitrov |
% if ( $section->default_document_class || $section->default_table_class ) { |
144 |
|
|
<div style="display:inline-block; width:45%; margin:10px 0; min-height:80px; vertical-align:top;"> |
145 |
|
|
<& /contenido/components/inputs/parent.msn, name => 'tree', check => $section->id, style => 'width:100%;' &> |
146 |
|
|
<div style="text-align:left; margin-top:5px;"> |
147 |
|
|
<input type="submit" name="move" value="Перенести" class="input_btn"><input |
148 |
|
|
type="submit" name="link" value="Привязать" class="input_btn"><input |
149 |
|
|
type="submit" name="unlink" value="Отвязать от текущей" class="input_btn" onclick="return confirm('Объекты, не привязанные к другим секциям могут быть потеряны');"> |
150 |
|
|
</div> |
151 |
|
|
</div> |
152 |
|
|
% } |
153 |
8 |
ahitrov@rambler.ru |
% if ( $inline_status || $delete_status ) { |
154 |
522 |
ahitrov |
<div style="display:inline-block; width:45%; text-align:right; margin:5px; padding-top:29px; vertical-align:top;"> |
155 |
8 |
ahitrov@rambler.ru |
% if ( $inline_status ) { |
156 |
522 |
ahitrov |
<input type="submit" name="update" value="Сохранить изменения" class="input_btn">\ |
157 |
8 |
ahitrov@rambler.ru |
% } |
158 |
|
|
% if ( $delete_status ) { |
159 |
|
|
<input type="submit" name="delete" value="Удалить выбранные" class="input_btn" onclick="return confirm('Все отмеченные позиции будут удалены');"> |
160 |
|
|
% } |
161 |
|
|
</div> |
162 |
|
|
% } |
163 |
386 |
ahitrov |
<br clear="all"> |
164 |
8 |
ahitrov@rambler.ru |
</form> |
165 |
|
|
<%args> |
166 |
|
|
|
167 |
|
|
$section => undef |
168 |
|
|
$documents => undef |
169 |
|
|
$columns => undef |
170 |
|
|
$id => undef |
171 |
|
|
$filter => undef |
172 |
|
|
|
173 |
|
|
</%args> |
174 |
|
|
<%init> |
175 |
|
|
|
176 |
|
|
return unless ref $documents eq 'ARRAY'; |
177 |
|
|
return unless ref $columns eq 'ARRAY'; |
178 |
|
|
return unless ref $section; |
179 |
|
|
|
180 |
|
|
my $toopi = $project->documents(); |
181 |
|
|
my $inline_status = 0; |
182 |
|
|
my $delete_status = 0; |
183 |
|
|
my $params = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } keys %$filter ) : ''; |
184 |
|
|
my $params_unclassed = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } grep { $_ ne 'class' } keys %$filter ) : ''; |
185 |
|
|
my $params_unsection = ref $filter eq 'HASH' ? join ('&', map { $_.'='.$filter->{$_} } grep { $_ ne 's' } keys %$filter ) : ''; |
186 |
|
|
|
187 |
386 |
ahitrov |
my %lookup_elements; |
188 |
609 |
ahitrov |
my @inline_pickups = grep { |
189 |
|
|
my $type = exists $_->{inline_type} ? $_->{inline_type} : $_->{type}; |
190 |
|
|
exists $_->{inline} && ($type eq 'pickup' || $type eq 'autocomplete') |
191 |
|
|
} @$columns; |
192 |
8 |
ahitrov@rambler.ru |
|
193 |
607 |
ahitrov |
map { |
194 |
|
|
$_->{document_access} = $user->section_accesses($user, $_->section); |
195 |
|
|
if ( $_->{document_access} == 2 ) { |
196 |
|
|
$delete_status = 1; |
197 |
|
|
} |
198 |
|
|
} @$documents; |
199 |
|
|
map { |
200 |
|
|
if ( exists $_->{inline} && $_->{inline} ) { |
201 |
|
|
$inline_status = 1; |
202 |
|
|
} |
203 |
|
|
} @$columns; |
204 |
|
|
|
205 |
8 |
ahitrov@rambler.ru |
</%init> |