Revision 438 (by ahitrov, 2014/07/17 17:45:17) Order report now can be filtered by coupons

<fieldset>
<legend>Актуальные купоны</legend>

	<table width="100%" border="0" cellpadding="3" cellspacing="0" class="tlistdocs">
	<tr class="<% $status == 1 ? 'inverted' : '' %>">
	<td><a href="/contenido/webshop/coupons.html">Активные:</a></td>
	<td><b><% $stats{1} || 0 %></b></td></tr>
	<tr class="<% defined $status && $status == 0 ? 'inverted' : '' %>">
	<td><a href="/contenido/webshop/coupons.html?cst=0" style="<% defined $status && $status == 0 ? '' : 'color:gray' %>">Неактивные:</a></td>
	<td><b><% $stats{0} || 0 %></b></td></tr>
	<tr class="<% $status == 3 ? 'inverted' : '' %>">
	<td><a href="/contenido/webshop/coupons.html?cst=3" style="<% $status == 3 ? '' : 'color:black' %>">Использованные:</a></td>
	<td><b><% $stats{3} || 0 %></b></td></tr>
	<tr class="<% $status == 2 ? 'inverted' : '' %>">
	<td><a href="/contenido/webshop/coupons.html?cst=2" style="<% $status == 2 ? '' : 'color:red' %>">Прототипы:</a></td>
	<td><b><% $stats{2} || 0 %></b></td></tr>
	<tr class="<% $status == 4 ? 'inverted' : '' %>">
	<td><a href="/contenido/webshop/coupons.html?cst=4" style="<% $status == 4 ? '' : 'color:olive' %>">Обработанные:</a></td>
	<td><b><% $stats{4} || 0 %></b></td></tr>
	</table>

	<table cellspacing="2" cellpadding="0" border="0" class="tform">
	<tr><td height="3"></td></tr>
	<tr><td colspan="2"><b><a href="/contenido/webshop/coupon.html">Зарегистрировать &raquo;</a></b></td></tr>

	</table>

</fieldset>
<%args>

	$status	=> undef

</%args>
<%init>

    my $now = Contenido::DateTime->new;
#    my $sql = $keeper->SQL->prepare( "select status, count(id) as cnt from webshop_coupons where class = 'webshop::Coupon' and ? <= etime group by status" );
#    $sql->execute( $now->ymd('-').'  '.$now->hms );
    my $sql = $keeper->SQL->prepare( "select status, count(id) as cnt from webshop_coupons where class = 'webshop::Coupon' group by status" );
    $sql->execute();

    my %stats;
    while ( my $ln = $sql->fetchrow_hashref ) {
	$stats{$ln->{status}} = $ln->{cnt};
    }
#    my $active = $keeper->get_documents (
#			class	=> 'webshop::Coupon',
#			status	=> 1,
#			count	=> 1,
#			interval	=> [$now, $now],
#		);
#    my $used = $keeper->get_documents (
#			class	=> 'webshop::Coupon',
#			status	=> 3,
#			count	=> 1,
#			interval	=> [$now, $now],
#		);

</%init>