Revision 3 (by ahitrov@rambler.ru, 2010/03/24 15:19:32) The CORE
<style>
.td { font:11px Verdana; padding:2px 4px; }
.th { padding:4px 4px; }
</style>
% unless ($error) {

%	if (@ids) {
<pre><% Dumper($object->$name) %></pre>
<table width="95%" cellpadding="2" cellspacing="1" bgcolor="gray">
<tr bgcolor="silver"><th width="99%" class="th">��������</th><th width="1%" class="th">�������?</th></tr>
%		my $i = 0;
%		foreach my $obj_id (@ids) {
%			my $obj = ref $objects eq 'HASH' && exists $objects->{$obj_id} ? $objects->{$obj_id} : undef;
<tr bgcolor="<% $i++ % 2 ? '#e0e0e0' : 'white' %>"><td class="td">
<input type="hidden" name="<% $name %>_<% $obj_id %>_id" value="<% $obj_id %>">
%			if ( ref $obj ) {
%				my ($a1, $a2) = $obj->id ? ('<a href="document.html?id='.$obj->id.'&class='.$obj->class.'" target="_blank">','</a>') : ('','');
<% $a1.($obj->name || '���������� �������� #'.$obj->id).$a2 %></a>
%			} else {
<span style="color:red;">�������� ������!!!</span>
%			}
</td><td align="center"><input type="checkbox" name="<% $name %>_<% $obj_id %>_delete" value="<% $obj_id %>"/></td></tr>
%               }
</table>
%	}

<table width="100%" cellspacing="1" cellpadding="0" border="0">
<tr><td width="5%">
<input type="text" name="<% $name %>_addanotheritem" id="<% $name %>_value"
 value="" style="width:100px;">
</td><td width="94%" class="td">
<input type="text" name="<% $name %>_docname" id="<% $name %>_docname"
 value="" style="width:100%;" onclick="lookfor_<% $name %>()"
 style="width:100%; color:blue; text-decoration:underline;" readonly>
</td><td width="1%" class="td"><a href="#top"
 onclick="search_<% $name %>();">
<img src="/contenido/i/lookup-19x19.gif" width="19" height="19" class="bb gb"></a>
</td></tr>
<tr id="<% $name %>_prev_table" style="display: none;">
<td id="<% $name %>_prev_value" class="bb undo" style="padding:3px;">&nbsp;</td>
<td id="<% $name %>_prev_docname" class="bb undo" style="padding:3px;">&nbsp;</td>
<td style="padding-left: 3px; vertical-align: top;"><a href="#"
 onclick="return <% $name %>_undo();" title="�������� ���������"><img
 src="/contenido/i/undo-19x19.gif" width="19" height="19" class="bb gb"></a></td>
</tr>
</table>

% } else {
	<font color="red"><% $error %></font>
% }

<script type="text/javascript">
<!--
  var key_flag_<% $name %> = 1;
  var <% $name %>_prev_value = document.getElementById('<% $name %>_value').value;
  var <% $name %>_prev_docname = document.getElementById('<% $name %>_docname').value;

  function search_<% $name %>() {
	document.getElementById('DocFinder').style.height = 470;
	document.getElementById('DocFinder').src = '<% $lookup_string %>';
  }

  function lookfor_<% $name %>() {
        var id = document.getElementById('<% $name %>_value').value;
	if (id) {
	        var Class = '<% $prop->{lookup_opts}->{class} %>';
		var Uri = 'document.html?id=' + id + '&class=' + Class;
		var Width = screen.width;
		var Height = screen.height;
		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');
	}
  }

  function lookthrough_<% $name %>(id) {
	if (id) {
		var Class = '<% $prop->{lookup_opts}->{class} %>';
		var Uri = 'document.html?id=' + id + '&class=' + Class;
		var Width = screen.width;
		var Height = screen.height;
		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');
	}
  }

  function <% $name %>_changed() {
	var t = document.getElementById('<% $name %>_prev_table');
	var v = document.getElementById('<% $name %>_value');
	if (v.value == <% $name %>_prev_value) {
		if (t.style.display!='none') {
			t.style.display = 'none';
		}
		return;
	}
	if (t.style.display=='none') {
		t.style.display = '';
	}
  }

  function <% $name %>_undo() {
	document.getElementById('<% $name %>_value').value = <% $name %>_prev_value;
	document.getElementById('<% $name %>_docname').value = <% $name %>_prev_docname;
	<% $name %>_changed();
	return false;
  }

//-->
</script>
<%args>
	$object
	$name => undef
	$check => undef
	$prop => {}
</%args>
<%init>

  my ($objects, $lookup_string, $error);

  # ���� ��� �������� � ���� ���� integer[] �� ��� �������� ������, ���� � data, �� ������ �� ������.
  # ��������� �����
  my @ids = ref($object->$name) eq 'ARRAY' ? @{ $object->$name } : $object->$name ? $object->$name : ();

  if ($prop && ref($prop) && ref($prop->{lookup_opts}) eq 'HASH') {
	if ( @ids ) {
		$objects = $keeper->get_documents (
			in_id	=> \@ids,
			%{$prop->{lookup_opts}},
			return_mode	=> 'hash_ref',
		);
	}
	$lookup_string = '/contenido/find_document.html?nf='.$name.'_docname&vf='.$name.'_value';
	$lookup_string .= '&class='.$prop->{lookup_opts}->{class}               if exists $prop->{lookup_opts}->{class};
	$lookup_string .= '&s='.$prop->{lookup_opts}->{s}                       if exists $prop->{lookup_opts}->{s};
	$lookup_string .= '&search_by='.$prop->{lookup_opts}->{search_by}       if exists $prop->{lookup_opts}->{search_by};
  }else{
	$error = '������ �������� �������� lookup_opts � ���������';
  }

</%init>