Line # Revision Author
1 270 ahitrov <& "/contenido/components/header.msn" &>
2
3 <style>
4 <!--
5 .inverted td { font-weight:bold; color:white; background-color:#8093B0; }
6 .inverted td a { color:white; font-weight:bold; }
7 //-->
8 </style>
9
10 <% spacer( h=>10 ) %>
11
12 <table width="100%" cellspacing="0" cellpadding="0" border="0">
13 <tr valign="top">
14 <td width="35%">
15
16 <& /contenido/webshop/components/block_order_status_changer.msn &>
17
18 <& /contenido/webshop/components/block_coupons.msn, status => $cst &>
19
20 </td>
21 <td width="1%">&nbsp;</td>
22 <td width="65%">
23
24 <fieldset>
25 <legend>Купоны со статусом "<span style="color:yellow"><% $current_status->[1] %></span>"</legend>
26
27 % if ( $total ) {
28
29 <div style="font-size:75%; font-family:Arial;">
30 <& /inc/pages_.msn, p=>$p, n=>$size, total=>$total, params=>\%filter_params, &>
31 <div style="height:5px"><spacer type="block" height="5"></div>
32 </div>
33
34 <& /contenido/webshop/components/coupon_browse.msn, documents => \@documents, columns => \@columns, filter => \%filter_params, status => $cst, %ARGS &>
35
36 <div style="font-size:75%; font-family:Arial;">
37 <& /inc/pages_.msn, p=>$p, n=>$size, total=>$total, params=>\%filter_params, &>
38 <div style="height:5px"><spacer type="block" height="5"></div>
39 </div>
40
41 % } else {
42 <h4 align="center"><i>---- Нет документов -----</i></h4>
43 % }
44
45 </td>
46 <td width="1%">&nbsp;</td>
47 </tr>
48 </table>
49
50 </body>
51 </html>
52 <%args>
53
54 $cst => 1
55 $p => 1
56 $delete => undef
57
58 </%args>
59 <%init>
60
61 my %filter_params;
62
63 my (@documents, $total);
64 $filter_params{cst} = $cst if $cst != 1;
65 my $size = 40;
66
67 @documents = $keeper->get_documents(
68 class => 'webshop::Coupon',
69 status => $cst,
70 limit => $size,
71 offset => ($p-1)*$size,
72 order_by => 'dtime desc',
73 );
74 $total = $keeper->get_documents(
75 class => 'webshop::Coupon',
76 status => $cst,
77 count => 1,
78 );
79 my @structure = webshop::Coupon->new( $keeper->{webshop} )->structure;
80 my @columns = sort { $a->{column} <=> $b->{column} }
81 grep { $_->{column} } @structure;
82 push @columns, {attr => '_act_', rusname => 'Действия'};
83 my ($status_map) = grep { $_->{attr} eq 'status' } @structure;
84 my ($current_status) = grep { $_->[0] == $cst } @{$status_map->{cases}};
85
86 my $active_rights = $m->comp('/contenido/webshop/subs/user_rights.msn');
87 if ( !$active_rights && $delete ) {
88 my $return_params = join ('&', map { $_.'='.$filter_params{$_} } grep { $_ ne 's' } keys %filter_params );
89 my %deleted;
90 while ( my ($field, $value) = each %ARGS ) {
91 if ( $field =~ /^delete_(\d+)_(\w+)$/ ) {
92 my $oid = $1;
93 my $attr = $2;
94 $deleted{$oid}{$attr} = $value;
95 }
96 }
97 my %classes = map { $_->{class} => 1 } values %deleted;
98 foreach my $delete_class ( keys %classes ) {
99 my @ids;
100 while ( my ($oid, $attr) = each %deleted) {
101 push @ids, $oid if exists $attr->{id} && $attr->{id} && ($attr->{class} eq $delete_class);
102 }
103 my @objects = $keeper->get_documents (
104 id => \@ids,
105 class => $delete_class
106 ) if @ids;
107 foreach my $object ( @objects ) {
108 my $document_access = $user->section_accesses($user, $object->section);
109 next unless $document_access == 2;
110 $object->delete;
111 }
112 }
113 $m->redirect("/contenido/webshop/".($return_params ? '?'.$return_params : ''));
114 }
115
116 </%init>