Revision 198 (by ahitrov, 2012/03/15 18:29:29) Simple webshop support plugin
<!-- Форма для редактирования объекта -->
<a name="top"></a>
%	if ( $context eq 'facil' ) {
<b style="font-size:110%">Комплектация ЗАКАЗА</b>
%	} elsif ( $context eq 'post' ) {
<b style="font-size:110%">Доставка ЗАКАЗА</b>
%	} else {
<b style="font-size:110%">Просмотр и редактирование ЗАКАЗА</b>
%	}
<center>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#999999">


<table width="100%" cellpadding="0" cellspacing="1" border="0">
<tr><td valign="top" width="50%" bgcolor="#ffffff">

<form enctype="multipart/form-data" action="<% $action %>" method="POST" name="form" onSubmit="javascript:Save()">

<table border="0" width="100%" cellspacing="0" cellpadding="6">
<tr>
<td align="right">
<input type="submit" value="Сохранить" class="input_btn">
<input type="submit" name="_save_and_leave" value="Сохранить и выйти" class="input_btn">
<input type="submit" name="delete" value="Отменить" onClick="return confirm('Отменить заказ?');" class="input_btn"><br>
%	if ( $context eq 'facil' ) {
<input type="submit" name="_ret_manager" value="Вернуть менеджеру" class="input_btn">
<input type="submit" name="_save_and_deliver" value="Отправить в доставку" class="input_btn">
%	} elsif ( $context eq 'post' ) {
<input type="submit" name="_ret_manager" value="Вернуть менеджеру" class="input_btn">
<input type="submit" name="_ret_facility" value="Вернуть в доставку" class="input_btn">
<input type="submit" name="_save_and_deliver" value="Отметка о доставке" class="input_btn">
%	} else {
<input type="submit" name="_save_and_complect" value="На комплектацию" class="input_btn">
<input type="submit" name="_save_and_deliver" value="Сразу в доставку" class="input_btn">
%	}

<input type="hidden" name="control_charset" value="Контроль">
%	if ( ref $filter_params eq 'HASH' ) {
%		while ( my ($key, $value) = each %$filter_params ) {
%			next	if grep { $_->{attr} eq $key } $object->structure();
<input type="hidden" name="<% $key %>" value="<% $value %>">
%		}
%	}
</td>
</tr>
</table>

<center>
<table width="98%" cellpadding="1" cellspacing="0" border="0">

<%perl>

	my @properties = $object->structure();

	for (0..$#properties)
	{

		my $prop = $properties[$_];
		my $field = $prop->{attr};
		next	if ($prop->{hidden} == 1) || ($prop->{type} eq 'external');
		if ( $context eq 'facil' ) {
			next	unless $prop->{$context.'show'} || $prop->{$context."edit"};
		} elsif ( $context eq 'post' ) {
			next	unless $prop->{$context.'show'} || $prop->{$context."edit"};
		} else {
			next	if $prop->{manager_hidden};
		}

</%perl>
<tr><td height="8"></td></tr>
<tr><td nowrap>
	<table cellpadding="0" cellspacing="0" border="0">
	<tr>
%		if( ( $prop->{type} eq 'flag' ) || ($prop->{type} eq 'checkbox') ) {
	<td><& "/contenido/components/inputs/checkbox.msn", prop => $prop, object=>$object, options=>$options, name => $prop->{attr}, check => $object->{$prop->{attr}}, id => $object->id() &></td>
% 		}
	<td nowrap><b><% $prop->{rusname} %></b>&nbsp;/</td>
	<td align="right" nowrap><font color="#888888" size="-1">&nbsp;name="<% $prop->{attr} %>"</font></td>
%		if( $prop->{readonly} ) {
	<td align="right" nowrap>&nbsp;/&nbsp;<font color="#CC0000" size="-1">Значение нельзя изменить</font></td>
%		}
	</tr>	
	</table>
</td></tr>
%		if ( ($context && $prop->{$context.'show'}) || $prop->{manshow} ) {
%			if ( exists $prop->{lookup_opts} ) {
%				my $doc = $keeper->get_document_by_id( $object->$field, class => $prop->{lookup_opts}{class} );
<tr><td><% $doc->name %></td></tr>
%			} elsif ( $prop->{type} eq 'status' ) {
%				my ($case) = grep { $_->[0] == $object->$field } @{$prop->{cases}};
<tr><td><% ref $case ? $case->[1] : '<span style="color:red;">Значение: '.$object->$field.'</span>' %></td></tr>
%			} else {
<tr><td><% $object->$field %></td></tr>
%			}
%		} else { 
%			if ($prop->{type} eq 'parent') {
<tr><td><& "/contenido/components/inputs/$prop->{type}.msn", prop => $prop, object=>$object, options=>$options, name => $prop->{attr}, check => ($object->{$prop->{attr} } || $prop->{default} || $sect_id ), id => $object->id() &></td></tr>
%			} elsif( ( $prop->{type} ne 'flag' ) && ($prop->{type} ne 'checkbox') ) {
<tr><td><& "/contenido/components/inputs/$prop->{type}.msn", prop => $prop, object=>$object, options => $options, name => $prop->{attr}, check => $object->{$prop->{attr}}, id => ($object->id() || 0) &></td></tr>
%			}
%		}
%	}
<tr>
<td><br>

%	for (0..$#properties) {
%		my $prop = $properties[$_];
%		next	if ($prop->{hidden} != 1);
<input type="hidden" name="<% $prop->{attr} %>" value="<% html_escape($object->{ $prop->{attr} }) %>">
%	}
<input type="hidden" name="sect_id" value="<% $sect_id %>">
%#если класса в свойствах обьекта нет все равно надо его пробросить как hidden
% unless (grep {$_->{attr} eq 'class'} @properties) {
<input type="hidden" name="class" value="<% html_escape($object->{class}) %>">
% }
<input type="hidden" name="save" value="1">

</td>
</tr>
</table>
</center>

</form>

</td>
<td valign="top" bgcolor="white" width="50%">
<% spacer(w=>270) %>
<div><iframe name="DocFinder" id="DocFinder" src="/contenido/find_document.html" frameborder="0"
 marginheight="0" marginwidth="0" width="100%" height="0"></iframe></div>
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td>
<p><font size=+1><b><nobr>Список позиций в заказе:</nobr></b></font></p>


<& /contenido/webshop/components/order_list.msn, order => $object, filter_params => $filter_params, context => $context &>



</table>
</td></tr></table>


</td></tr>
</table>

</td></tr></table>
</center>

<script>
<!--
function updateList(theFild,value,text) {
	for (var i = 0; i < theFild.options.length; i++) {
		if (theFild.options[i].value == value) {
			return false;
		}
	}
	var option_length = theFild.options.length++;
	eval("theFild.options[option_length].value=value");
	eval("theFild.options[option_length].text=text");

	Save(); this.form.submit();

	}
//-->
</script>


<%ARGS>

	$proto	=> 'documents'
	$object	=> undef
	$context	=> undef
	$sect_id	=> 1
	$filter_params	=> undef

</%ARGS>

<%ONCE>
        my $PROTOS = {
                'documents' => ['документа','document.html','документу','документе'],
                'sections' => ['секции','section.html','секции','секции'],
                'links' => ['связи','link.html','связи','связи'],
                'users' => ['пользователя','users.html','пользователю','пользователе'],
        };
</%ONCE>

<%INIT>
	return undef		unless ref($object);

	my $action = $context eq 'facil' ? 'facility.html' : $context eq 'post' ? 'delivery.html' : 'take_care.html';
	my $toopi = $project->$proto();
	my $options = {};
	if ($toopi && (ref($toopi) eq 'HASH') && (exists($toopi->{ $object->class }))) {
		%{ $options } = %{ $toopi->{ $object->class } };
	}
</%INIT>