Revision 638 (by ahitrov, 2017/01/12 12:34:10) Orders by coupon functionality. Context table and browse mode table.

<fieldset>
<legend>Заказы с купоном "<span style="color:yellow"><% $object->name %></span>"</legend>

<& /contenido/webshop/components/order_browse.msn, documents => \@documents, columns => \@columns, filter => \%filter_params, no_inline => 1, %ARGS &>

</td>
<td width="1%">&nbsp;</td>
</tr>
</table>

</body>
</html>
<%args>

	$id	=> undef

</%args>
<%init>

    return	unless $id && $id =~ /^\d+/;

    my $object = $keeper->get_document_by_id( $id, class => 'webshop::Coupon' );
    my ($links, @documents);
    if ( ref $object ) {
	$links = $keeper->get_documents(
			class   => 'webshop::OrderCouponLink',
			dest_id => $object->id,
			source_id       => 'positive',
			order_by        => 'ctime desc',
			return_mode	=> 'array_ref',
		);
	my @ids = map { $_->source_id } @$links;
	@documents = @ids ? $keeper->get_documents(
			id      => \@ids,
			class   => 'webshop::Order',
			order_by        => 'ctime desc',
		) : ();
    } else {
	return;
    }

    my %filter_params;
    my $size = 40;

    my %opts;
    my $company_filter_value;
    if ( exists $ARGS{order_company_filter} ) {
	$company_filter_value = $ARGS{order_company_filter};
	$m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company}, value => $company_filter_value );
	if ( defined $company_filter_value && $company_filter_value ne '' ) {
		$opts{company_id} = $company_filter_value;
	}
    } else {
	$company_filter_value = $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company} );
	if ( defined $company_filter_value && $company_filter_value ne '' ) {
		$opts{company_id} = $company_filter_value;
	}
    }

    my @structure = webshop::Order->new( $keeper->{webshop} )->structure;
    my @columns = sort { $a->{column} <=> $b->{column} }
			grep { $_->{column} } @structure;
    push @columns, {attr => '_act_', rusname => 'Действия'};
    my ($status_map) = grep { $_->{attr} eq 'status' } @structure;

    my $active_rights = $m->comp('/contenido/webshop/subs/user_rights.msn');

</%init>