Revision 638

Date:
2017/01/12 12:34:10
Author:
ahitrov
Revision Log:
Orders by coupon functionality. Context table and browse mode table.

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/webshop/comps/contenido/webshop/autohandler

     
    2 2
    3 3 $r->content_type('text/html');
    4 4 $request->{cookie_filter_company} = 'filter_company';
    5
    6 my $company_filter_value;
    7 if ( exists $ARGS{order_company_filter} ) {
    8 $company_filter_value = $ARGS{order_company_filter};
    9 $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company}, value => $company_filter_value );
    10 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    11 $request->{company_id_filter} = $company_filter_value;
    12 }
    13 } else {
    14 $company_filter_value = $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company} );
    15 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    16 $request->{company_id_filter} = $company_filter_value;
    17 }
    18 }
    19
    5 20 $m->call_next();
    6 21
    7 22 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/components/block_coupon_orders.msn

     
    1 <fieldset style="background:white; margin:5px;">
    2 <legend>Последние заказы (<% scalar @orders %>)</legend>
    3 % if ( @orders ) {
    4 <table width="100%" border="0" cellpadding="3" cellspacing="0" class="tlistdocs">
    5 % foreach my $order ( @orders ) {
    6 % my ($href, $action, $user_id);
    7 % my $status = $order->status;
    8 % if ( ($status == 1 || $status == 6 || $status == 7 || $status == 8) && (!$active_rights || $active_rights == 1) ) {
    9 % $href = 'take_care.html';
    10 % $action = { href => $href, name => 'обработать' };
    11 % $user_id = 'manager_id';
    12 % } elsif ( $status == 2 && (!$active_rights || $active_rights == 2) ) {
    13 % $href = 'facility.html';
    14 % $action = { href => $href, name => 'собрать' };
    15 % $user_id = 'vault_id';
    16 % } elsif ( $status == 3 && (!$active_rights || $active_rights == 3) ) {
    17 % $href = 'delivery.html';
    18 % $action = { href => $href, name => 'доставить' };
    19 % $user_id = 'postman_id';
    20 % } elsif ( $status == 4 && !$active_rights ) {
    21 % $href = 'delivery.html';
    22 % $action = { href => $href, name => 'просмотр' };
    23 % } elsif ( $status == 5 && !$active_rights ) {
    24 % $href = 'delivery.html';
    25 % $action = { href => $href, name => 'просмотр' };
    26 % }
    27 % my $url = $href.'?id='.$order->id;
    28 % my $status_name = exists $status_options{$order->status} ? $status_options{$order->status} : 'unknown';
    29 <tr>
    30 <td><a href="<% $url %>"><% $order->id %></a></td>
    31 <td><a href="<% $url %>"><% $order->name %></a></td>
    32 <td><% $status_name %></td>
    33 <td><a href="<% $url %>"><% $action->{name} %></a></td>
    34 </tr>
    35 % }
    36 </table>
    37 <a href="/contenido/webshop/?coupon_id=<% $object->id %>">Все заказы (<% $total %>)</a>
    38 % }
    39 </fieldset>
    40 <%args>
    41
    42 $object => undef
    43
    44 </%args>
    45 <%init>
    46
    47 return unless ref $object && $object->id;
    48
    49 my $total = $keeper->get_documents(
    50 class => 'webshop::OrderCouponLink',
    51 dest_id => $object->id,
    52 source_id => 'positive',
    53 count => 1,
    54 );
    55 my (@links, @orders);
    56 if ( $total ) {
    57 @links = $keeper->get_documents(
    58 class => 'webshop::OrderCouponLink',
    59 dest_id => $object->id,
    60 source_id => 'positive',
    61 order_by => 'ctime desc',
    62 limit => 10,
    63 );
    64 my @ids = map { $_->source_id } @links;
    65 @orders = $keeper->get_documents(
    66 id => \@ids,
    67 class => 'webshop::Order',
    68 order_by => 'ctime desc',
    69 );
    70 }
    71 my %props = map { $_->{attr} => $_ } webshop::Order->new( $keeper )->structure;
    72 my $prop = $props{status};
    73 my %status_options = map { $_->[0] => $_->[1] } @{$prop->{cases}};
    74 my $active_rights = $m->comp('/contenido/webshop/subs/user_rights.msn');
    75
    76 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/components/block_order_company_filter.msn

     
    25 25 );
    26 26
    27 27 </%once>
    28 <%args>
    28 <%init>
    29 29
    30 $value => undef
    30 my $value;
    31 if ( exists $request->{company_id_filter} ) {
    32 $value = $request->{company_id_filter};
    33 }
    31 34
    32 </%args>
    35 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/components/order_browse.msn

     
    32 32 <tr><td align="center" colspan="<% scalar @$columns %>">Документы не найдены</td></tr>
    33 33 % }
    34 34 % foreach my $document (@$documents) {
    35 %
    35 % unless ( defined $status ) {
    36 % if ( ($document->status == 1 || $document->status == 6 || $document->status == 7 || $document->status == 8) && (!$active_rights || $active_rights == 1) ) {
    37 % $href = 'take_care.html';
    38 % @actions = { href => $href, name => 'обработать' };
    39 % $user_id = 'manager_id';
    40 % } elsif ( $document->status == 2 && (!$active_rights || $active_rights == 2) ) {
    41 % $href = 'facility.html';
    42 % @actions = { href => $href, name => 'собрать' };
    43 % $user_id = 'vault_id';
    44 % } elsif ( $document->status == 3 && (!$active_rights || $active_rights == 3) ) {
    45 % $href = 'delivery.html';
    46 % @actions = { href => $href, name => 'доставить' };
    47 % $user_id = 'postman_id';
    48 % } elsif ( $document->status == 4 && !$active_rights ) {
    49 % $href = 'delivery.html';
    50 % @actions = { href => $href, name => 'просмотр' };
    51 % $user_id = 'postman_id';
    52 % } elsif ( $document->status == 5 && !$active_rights ) {
    53 % $href = 'delivery.html';
    54 % @actions = { href => $href, name => 'просмотр' };
    55 % $user_id = 'postman_id';
    56 % }
    57 % }
    36 58 % next unless ref($document);
    37 59 % my $document_access = $user->section_accesses($user, $document->section);
    38 60 % my $style = $document->contenido_status_style ? ' style="'.$document->contenido_status_style.'"' : '';
     
    138 160 % }
    139 161 % }
    140 162 % if ( $active_rights == 0 ) {
    141 % if ( $document->$user_id && $document->$user_id != $user->id ) {
    163 % if ( $user_id && $user_id eq 'manager_id' && $document->$user_id && $document->$user_id != $user->id ) {
    142 164 % $actions .= ' (<a href="/contenido/webshop/?drop_owner=1&id='.$document->id.($params_unclassed ? '&'.$params_unclassed : '').'&field='.$user_id.'">unlock</a>)'
    143 165 % } else {
    144 166 % $actions = join (' | ', map { '<a href="./'.$_->{href}.'?id='.$document->id.($params_unclassed ? '&'.$params_unclassed : '').'">'.$_->{name}.'</a>' } @actions);
     
    224 246 return unless ref $documents eq 'ARRAY';
    225 247 return unless ref $columns eq 'ARRAY';
    226 248
    227 @$columns = grep { $_->{attr} ne 'status' } @$columns;
    228 249 my $toopi = $project->documents();
    229 250 my $inline_status = 0;
    230 251 my $delete_status = 0;
     
    236 257
    237 258 my %users;
    238 259 my ($href, @actions, $user_id);
    239 if ( ($status == 1 || $status == 6 || $status == 7 || $status == 8) && (!$active_rights || $active_rights == 1) ) {
    240 $href = 'take_care.html';
    241 @actions = { href => $href, name => 'обработать' };
    242 $user_id = 'manager_id';
    243 } elsif ( $status == 2 && (!$active_rights || $active_rights == 2) ) {
    244 $href = 'facility.html';
    245 @actions = { href => $href, name => 'собрать' };
    246 $user_id = 'vault_id';
    247 } elsif ( $status == 3 && (!$active_rights || $active_rights == 3) ) {
    248 $href = 'delivery.html';
    249 @actions = { href => $href, name => 'доставить' };
    250 $user_id = 'postman_id';
    251 } elsif ( $status == 4 && !$active_rights ) {
    252 $href = 'delivery.html';
    253 @actions = { href => $href, name => 'просмотр' };
    254 } elsif ( $status == 5 && !$active_rights ) {
    255 $href = 'delivery.html';
    256 @actions = { href => $href, name => 'просмотр' };
    260 if ( defined $status ) {
    261 @$columns = grep { $_->{attr} ne 'status' } @$columns;
    262 if ( ($status == 1 || $status == 6 || $status == 7 || $status == 8) && (!$active_rights || $active_rights == 1) ) {
    263 $href = 'take_care.html';
    264 @actions = { href => $href, name => 'обработать' };
    265 $user_id = 'manager_id';
    266 } elsif ( $status == 2 && (!$active_rights || $active_rights == 2) ) {
    267 $href = 'facility.html';
    268 @actions = { href => $href, name => 'собрать' };
    269 $user_id = 'vault_id';
    270 } elsif ( $status == 3 && (!$active_rights || $active_rights == 3) ) {
    271 $href = 'delivery.html';
    272 @actions = { href => $href, name => 'доставить' };
    273 $user_id = 'postman_id';
    274 } elsif ( $status == 4 && !$active_rights ) {
    275 $href = 'delivery.html';
    276 @actions = { href => $href, name => 'просмотр' };
    277 $user_id = 'postman_id';
    278 } elsif ( $status == 5 && !$active_rights ) {
    279 $href = 'delivery.html';
    280 @actions = { href => $href, name => 'просмотр' };
    281 $user_id = 'postman_id';
    282 }
    257 283 }
    258 284
    259 285 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/components/orders_by_coupon.msn

     
    1 <fieldset>
    2 <legend>Заказы с купоном "<span style="color:yellow"><% $object->name %></span>"</legend>
    3
    4 <& /contenido/webshop/components/order_browse.msn, documents => \@documents, columns => \@columns, filter => \%filter_params, no_inline => 1, %ARGS &>
    5
    6 </td>
    7 <td width="1%">&nbsp;</td>
    8 </tr>
    9 </table>
    10
    11 </body>
    12 </html>
    13 <%args>
    14
    15 $id => undef
    16
    17 </%args>
    18 <%init>
    19
    20 return unless $id && $id =~ /^\d+/;
    21
    22 my $object = $keeper->get_document_by_id( $id, class => 'webshop::Coupon' );
    23 my ($links, @documents);
    24 if ( ref $object ) {
    25 $links = $keeper->get_documents(
    26 class => 'webshop::OrderCouponLink',
    27 dest_id => $object->id,
    28 source_id => 'positive',
    29 order_by => 'ctime desc',
    30 return_mode => 'array_ref',
    31 );
    32 my @ids = map { $_->source_id } @$links;
    33 @documents = @ids ? $keeper->get_documents(
    34 id => \@ids,
    35 class => 'webshop::Order',
    36 order_by => 'ctime desc',
    37 ) : ();
    38 } else {
    39 return;
    40 }
    41
    42 my %filter_params;
    43 my $size = 40;
    44
    45 my %opts;
    46 my $company_filter_value;
    47 if ( exists $ARGS{order_company_filter} ) {
    48 $company_filter_value = $ARGS{order_company_filter};
    49 $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company}, value => $company_filter_value );
    50 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    51 $opts{company_id} = $company_filter_value;
    52 }
    53 } else {
    54 $company_filter_value = $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company} );
    55 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    56 $opts{company_id} = $company_filter_value;
    57 }
    58 }
    59
    60 my @structure = webshop::Order->new( $keeper->{webshop} )->structure;
    61 my @columns = sort { $a->{column} <=> $b->{column} }
    62 grep { $_->{column} } @structure;
    63 push @columns, {attr => '_act_', rusname => 'Действия'};
    64 my ($status_map) = grep { $_->{attr} eq 'status' } @structure;
    65
    66 my $active_rights = $m->comp('/contenido/webshop/subs/user_rights.msn');
    67
    68 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/coupon.html

     
    157 157
    158 158 </td>
    159 159 <td valign="top" bgcolor="#efefef">
    160 <% spacer(w=>270) %>
    160 <% spacer(w=>330) %>
    161 161 <div><iframe name="DocFinder" id="DocFinder" src="/contenido/find_document.html" frameborder="0"
    162 162 marginheight="0" marginwidth="0" width="100%" height="0"></iframe></div>
    163
    163 % if ( ref $object && $object->id ) {
    164 <& /contenido/webshop/components/block_coupon_orders.msn, object => $object &>
    165 % }
    164 166 </td>
    165 167 </tr>
    166 168 </table>
  • utf8/plugins/webshop/comps/contenido/webshop/index.html

     
    13 13 <tr valign="top">
    14 14 <td width="35%">
    15 15
    16 <& /contenido/webshop/components/block_order_company_filter.msn, value => $company_filter_value &>
    16 <& /contenido/webshop/components/block_order_company_filter.msn &>
    17 17 <& /contenido/webshop/components/block_order_id_finder.msn &>
    18 18 <& /contenido/webshop/components/block_order_status_changer.msn, status => $ost &>
    19 19
     
    26 26 <td width="65%">
    27 27
    28 28 <div id="search-by-id-found"></div>
    29 <div id="search-by-coupon-found"><& /contenido/webshop/components/orders_by_coupon.msn, id => $coupon_id &></div>
    29 30
    30 31 <fieldset>
    31 32 <legend>Заказы со статусом "<span style="color:yellow"><% $current_status->[1] %></span>"</legend>
     
    61 62 $p => 1
    62 63 $delete => undef
    63 64 $drop_owner => undef
    65 $coupon_id => undef
    64 66
    65 67 </%args>
    66 68 <%init>
     
    72 74 my $size = 40;
    73 75
    74 76 my %opts;
    75 my $company_filter_value;
    76 if ( exists $ARGS{order_company_filter} ) {
    77 $company_filter_value = $ARGS{order_company_filter};
    78 $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company}, value => $company_filter_value );
    79 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    80 $opts{company_id} = $company_filter_value;
    81 }
    82 } else {
    83 $company_filter_value = $m->comp( '/contenido/components/cookies.msn', name => $request->{cookie_filter_company} );
    84 if ( defined $company_filter_value && $company_filter_value ne '' ) {
    85 $opts{company_id} = $company_filter_value;
    86 }
    77 if ( exists $request->{company_id_filter} ) {
    78 $opts{company_id} = $request->{company_id_filter};
    87 79 }
    88 80
    89 81 @documents = $keeper->get_documents(