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