Line # Revision Author
1 8 ahitrov@rambler.ru <style>
2 .td { font:11px Verdana; padding:2px 4px; }
3 .th { padding:4px 4px; }
4 </style>
5 % unless ($error) {
6
7 % if (@ids) {
8 <table width="95%" cellpadding="2" cellspacing="1" bgcolor="gray">
9 <tr bgcolor="silver"><th width="99%" class="th">Название</th><th width="1%" class="th">Удалить?</th></tr>
10 % my $i = 0;
11 % foreach my $obj_id (@ids) {
12 % my $obj = ref $objects eq 'HASH' && exists $objects->{$obj_id} ? $objects->{$obj_id} : undef;
13 <tr bgcolor="<% $i++ % 2 ? '#e0e0e0' : 'white' %>"><td class="td">
14 <input type="hidden" name="<% $name %>_<% $obj_id %>_id" value="<% $obj_id %>">
15 % if ( ref $obj ) {
16 % my ($a1, $a2) = $obj->id ? ('<a href="document.html?id='.$obj->id.'&class='.$obj->class.'" target="_blank">','</a>') : ('','');
17 <% $a1.($obj->name || 'Безымянный документ #'.$obj->id).$a2 %></a>
18 % } else {
19 <span style="color:red;">Неверная ссылка!!!</span>
20 % }
21 </td><td align="center"><input type="checkbox" name="<% $name %>_<% $obj_id %>_delete" value="<% $obj_id %>"/></td></tr>
22 % }
23 </table>
24 % }
25
26 <table width="100%" cellspacing="1" cellpadding="0" border="0">
27 <tr><td width="5%">
28 <input type="text" name="<% $name %>_addanotheritem" id="<% $name %>_value"
29 value="" style="width:100px;">
30 </td><td width="94%" class="td">
31 <input type="text" name="<% $name %>_docname" id="<% $name %>_docname"
32 value="" style="width:100%;" onclick="lookfor_<% $name %>()"
33 style="width:100%; color:blue; text-decoration:underline;" readonly>
34 </td><td width="1%" class="td"><a href="#top"
35 onclick="search_<% $name %>();">
36 <img src="/contenido/i/lookup-19x19.gif" width="19" height="19" class="bb gb"></a>
37 </td></tr>
38 <tr id="<% $name %>_prev_table" style="display: none;">
39 <td id="<% $name %>_prev_value" class="bb undo" style="padding:3px;">&nbsp;</td>
40 <td id="<% $name %>_prev_docname" class="bb undo" style="padding:3px;">&nbsp;</td>
41 <td style="padding-left: 3px; vertical-align: top;"><a href="#"
42 onclick="return <% $name %>_undo();" title="Отменить изменения"><img
43 src="/contenido/i/undo-19x19.gif" width="19" height="19" class="bb gb"></a></td>
44 </tr>
45 </table>
46
47 % } else {
48 <font color="red"><% $error %></font>
49 % }
50
51 <script type="text/javascript">
52 <!--
53 var key_flag_<% $name %> = 1;
54 var <% $name %>_prev_value = document.getElementById('<% $name %>_value').value;
55 var <% $name %>_prev_docname = document.getElementById('<% $name %>_docname').value;
56
57 function search_<% $name %>() {
58 document.getElementById('DocFinder').style.height = 470;
59 document.getElementById('DocFinder').src = '<% $lookup_string %>';
60 }
61
62 function lookfor_<% $name %>() {
63 var id = document.getElementById('<% $name %>_value').value;
64 if (id) {
65 386 ahitrov % if ( exists $prop->{lookup_opts}{class} ) {
66 var Class = '<% $prop->{lookup_opts}{class} %>';
67 8 ahitrov@rambler.ru var Uri = 'document.html?id=' + id + '&class=' + Class;
68 386 ahitrov % } elsif ( exists $prop->{lookup_opts}{table} ) {
69 var Class = '<% $prop->{lookup_opts}{table} %>';
70 var Uri = 'document.html?id=' + id + '&table=' + Class;
71 % }
72 8 ahitrov@rambler.ru var Width = screen.width;
73 var Height = screen.height;
74 window.open(Uri,'Interface','width='+Width+',height='+Height+',top=0,left=0,location=1,menubar=1,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=1,directories=1,hotkeys=1');
75 }
76 }
77
78 function lookthrough_<% $name %>(id) {
79 if (id) {
80 386 ahitrov % if ( exists $prop->{lookup_opts}{class} ) {
81 var Class = '<% $prop->{lookup_opts}{class} %>';
82 8 ahitrov@rambler.ru var Uri = 'document.html?id=' + id + '&class=' + Class;
83 386 ahitrov % } elsif ( exists $prop->{lookup_opts}{table} ) {
84 var Class = '<% $prop->{lookup_opts}{table} %>';
85 var Uri = 'document.html?id=' + id + '&table=' + Class;
86 % }
87 8 ahitrov@rambler.ru var Width = screen.width;
88 var Height = screen.height;
89 window.open(Uri,'Interface','width='+Width+',height='+Height+',top=0,left=0,location=1,menubar=1,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=1,directories=1,hotkeys=1');
90 }
91 }
92
93 function <% $name %>_changed() {
94 var t = document.getElementById('<% $name %>_prev_table');
95 var v = document.getElementById('<% $name %>_value');
96 if (v.value == <% $name %>_prev_value) {
97 if (t.style.display!='none') {
98 t.style.display = 'none';
99 }
100 return;
101 }
102 if (t.style.display=='none') {
103 t.style.display = '';
104 }
105 }
106
107 function <% $name %>_undo() {
108 document.getElementById('<% $name %>_value').value = <% $name %>_prev_value;
109 document.getElementById('<% $name %>_docname').value = <% $name %>_prev_docname;
110 <% $name %>_changed();
111 return false;
112 }
113
114 //-->
115 </script>
116 <%args>
117 $object
118 $name => undef
119 $check => undef
120 $prop => {}
121 </%args>
122 <%init>
123
124 my ($objects, $lookup_string, $error);
125
126 # Если оно хранится в поле типа integer[] то нам вернется массив, если в data, то ссылка на массив.
127 # Просекаем фишку
128 my @ids = ref($object->$name) eq 'ARRAY' ? @{ $object->$name } : $object->$name ? $object->$name : ();
129
130 386 ahitrov if ($prop && ref($prop) && exists $prop->{lookup_opts} && ref $prop->{lookup_opts} eq 'HASH') {
131 8 ahitrov@rambler.ru if ( @ids ) {
132 $objects = $keeper->get_documents (
133 in_id => \@ids,
134 %{$prop->{lookup_opts}},
135 return_mode => 'hash_ref',
136 );
137 }
138 $lookup_string = '/contenido/find_document.html?nf='.$name.'_docname&vf='.$name.'_value';
139 386 ahitrov while ( my ($param, $value) = each %{ $prop->{lookup_opts} } ) {
140 $lookup_string .= '&'.$param.'='.$value;
141 }
142 8 ahitrov@rambler.ru }else{
143 $error = 'Похоже неверное описание lookup_opts в документе';
144 }
145
146 </%init>