Revision 438

Date:
2014/07/17 17:45:17
Author:
ahitrov
Revision Log:
Order report now can be filtered by coupons

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/webshop/comps/contenido/webshop/components/block_coupons.msn

     
    34 34 <%init>
    35 35
    36 36 my $now = Contenido::DateTime->new;
    37 my $sql = $keeper->SQL->prepare( "select status, count(id) as cnt from webshop_coupons where class = 'webshop::Coupon' and ? <= etime group by status" );
    38 $sql->execute( $now->ymd('-').' '.$now->hms );
    37 # my $sql = $keeper->SQL->prepare( "select status, count(id) as cnt from webshop_coupons where class = 'webshop::Coupon' and ? <= etime group by status" );
    38 # $sql->execute( $now->ymd('-').' '.$now->hms );
    39 my $sql = $keeper->SQL->prepare( "select status, count(id) as cnt from webshop_coupons where class = 'webshop::Coupon' group by status" );
    40 $sql->execute();
    39 41
    40 42 my %stats;
    41 43 while ( my $ln = $sql->fetchrow_hashref ) {
  • utf8/plugins/webshop/comps/contenido/webshop/components/block_order_finder.msn

     
    10 10 <tr><td><b>Диапазон дат:</b></td></tr>
    11 11 <tr><td><& "/contenido/components/inputs/date.msn", name => 'from' &></td></tr>
    12 12 <tr><td><& "/contenido/components/inputs/date.msn", name => 'to' &></td></tr>
    13 <tr><td><b>По купону:</b></td></tr>
    14 <tr><td><& "/contenido/components/select.msn", name=>'coupon', values => \@coupons, style=>'width:100%;font-size:8pt;' &></td>
    13 15 <tr><td><b>Отобразить:</b></td></tr>
    14 16 <tr><td><& "/contenido/components/select.msn", name=>'show', values => \@shows, style=>'width:100%;font-size:8pt;' &></td>
    15 17 <tr><td><input type="submit" value="Отобрать" class="btn"></td></tr>
     
    39 41 my @props = webshop::Order->new($keeper)->structure;
    40 42 my ($prop_status) = grep { $_->{attr} eq 'status' } @props;
    41 43 my @status_values = map { $_->[0] => $_->[1] } @{$prop_status->{cases}};
    44 $status_values[1] = 'без учета статуса';
    42 45
    46 my @coupons = ('' => 'без учета купонов');
    47 my $sql = "select id, name from webshop_coupons where class = 'webshop::Coupon' and ( status in (0, 4) or (status in (1,3) and pid = 0) ) order by status = 1 desc, status, dtime desc";
    48 my $que = $keeper->SQL->prepare($sql);
    49 $que->execute();
    50 while ( my $ln = $que->fetchrow_hashref ) {
    51 push @coupons, ($ln->{id}, $ln->{name});
    52 }
    53
    43 54 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/orders.html

     
    19 19 % if ( $status ) {
    20 20 Со статусом: <b><% $status_opts{$status} %></b><br>
    21 21 % }
    22 % if ( $coupon && ref $COUPON ) {
    23 С купоном: <b><% $COUPON->name %></b> (скидка: <% $COUPON->discount %> на сумму свыше <% $COUPON->min_sum %> р.)<br>
    24 % }
    22 25 % if ( $sort && exists $sorts{$sort} ) {
    23 26 Сортировка <b><% $sorts{$sort}{name} %></b>
    24 27 % }
     
    67 70 <td><% $order->sum_delivery %></td>
    68 71 <td><% $order->sum_total %></td>
    69 72 <td>
    70 % if ( ref $coupons eq 'ARRAY'&& @$coupons ) {
    73 % if ( ref $coupons eq 'ARRAY' && @$coupons ) {
    71 74 % foreach my $coupon ( @$coupons ) {
    72 75 <% $coupon->name %><br>
    73 76 % }
     
    112 115 $status => undef
    113 116 $sort => undef
    114 117 $show => 'html'
    118 $coupon => undef
    115 119
    116 120 $from_day => undef
    117 121 $from_month => undef
     
    151 155 if ( $status ) {
    152 156 $opts{status} = $status;
    153 157 }
    158 my ($COUPON);
    159 if ( $coupon ) {
    160 $COUPON = $keeper->get_document_by_id($coupon, class => 'webshop::Coupon');
    161 if ( ref $COUPON ) {
    162 if ( $COUPON->status == 4 ) {
    163 my @cids = $keeper->get_documents(
    164 class => 'webshop::Coupon',
    165 pid => $COUPON->id,
    166 ids => 1,
    167 no_limit => 1,
    168 );
    169 if ( \@cids ) {
    170 $opts{ldest} = \@cids;
    171 $opts{lclass} = 'webshop::OrderCouponLink';
    172 }
    173 } else {
    174 $opts{ldest} = $COUPON->id;
    175 $opts{lclass} = 'webshop::OrderCouponLink';
    176 }
    177 } else {
    178 $errstr = 'Купон не найден';
    179 }
    180 }
    154 181 if ( $sort && exists $sorts{$sort} ) {
    155 182 $opts{order_by} = $sorts{$sort}{order_by};
    156 183 }
  • utf8/plugins/webshop/lib/webshop/SQL/Order.pm

     
    22 22 _date_filter
    23 23 _previous_days_filter
    24 24 _s_filter
    25 _link_filter
    25 26
    26 27 _payment_filter
    27 28 _uid_filter