Revision 451 (by ahitrov, 2014/11/18 14:43:14) Deblock button if only one option available
<form action="<% $INVITE->{$proto}->[1] %>" method="GET" name="formnew">
<div align="right">
	<table width="100%" border="0" cellpadding="3" cellspacing="0" class="tform">
	<tr><td><% $INVITE->{$proto}->[0] %></td>
	<td width="100%">
<& "/contenido/components/select.msn", name=>'class', values=>$classes, check=>$default, style=>'width:100%;', onChange => "set_create_button(this, 'create_$btn_id')" &>
	</td>
	<td><input id="create_<% $btn_id %>" type="submit" value="Создать"<% $default || scalar @class == 1 ? '' : ' disabled="disabled"' %>></td>
	<td><input type="hidden" name="sect_id" value="<% $sect_id %>"></td>
	</tr></table>
</div></form>
<%ONCE>
	use locale;
</%ONCE>
<%ARGS>

	$default	=> undef
	$proto		=> 'documents'
	$sect_id	=> 1
	$section	=> undef

</%ARGS>
<%INIT>

    my $INVITE = {
		'documents' => ['Новый&nbsp;документ','document.html'],
		'sections' => ['Новая&nbsp;секция','section.html'],
		'links' => ['Новая&nbsp;связь','link.html'],
		'users' => ['Новый&nbsp;пользователь','users.html'],
	};
    my $btn_id = int(rand(10000));

    my @class;
    if ( $proto eq 'documents' ) {
	@class = @{ $user->get_available_classes };
	if ( ref $section ) {
		if ( $section->default_table_class ) {
			@class = grep { $_->new( $keeper )->class_table eq $section->default_table_class } @class;
		} elsif ( $section->default_document_class ) {
			@class = grep { $_ eq $section->default_document_class } @class;
			($default) = grep { $_ eq $section->default_document_class } @class	unless $default;
		}
	}
    } else {
	@class = @{ $state->{'available_'.$proto} };
    }

    my $classes = scalar @class > 1 ? [ '' => '--- Выберите тип ---' ] : [];

    foreach my $class ( sort { $a->class_name cmp $b->class_name } @class ) {
	my $object = $class->new($keeper);
	push @$classes, $class, "".$object->class_name()." ($class)";
    }

</%INIT>