1 |
296 |
ahitrov |
<h1><% $voting->name %></h1> |
2 |
|
|
<p><% $voting->abstr %></p> |
3 |
|
|
|
4 |
|
|
<table height="100" cellpadding="0" cellspacing="0"> |
5 |
|
|
<tr><td> |
6 |
|
|
% foreach my $question_data (@{$vote_data->{questions}}) { |
7 |
|
|
% if ($question_data->{amount}) { |
8 |
|
|
% my $question_name = $question_data->{question}; |
9 |
|
|
% my $qimg_src; |
10 |
|
|
% if ( $question_name =~ /<%\s*\w+_(\d+)\s*%>/i ) { |
11 |
|
|
% my $index = $1; |
12 |
|
|
% if ( ref $pictures && exists $pictures->{"image_$index"} ) { |
13 |
|
|
% my $img = $pictures->{"image_$index"}; |
14 |
|
|
% my $mini = $pictures->{"image_$index"}{mini}; |
15 |
|
|
% $qimg_src = '<a href="/images/'.$img->{filename}.'" rel="lightbox" title=""><img src="/images/'.$mini->{filename}.'" width="'.$mini->{width}.'" height="'.$mini->{height}.'" hspace="5"></a>'; |
16 |
|
|
% } |
17 |
|
|
% $question_name =~ s/<%\s*\w+_(\d+)\s*%>/$qimg_src/i; |
18 |
|
|
% } |
19 |
|
|
|
20 |
|
|
<h2><% $question_name %></h2> |
21 |
|
|
|
22 |
|
|
% my $total=0; |
23 |
|
|
% my $max_value=1; |
24 |
|
|
% my $total_procent=0; |
25 |
|
|
% map { $total += $_->{votes}; $max_value = $_->{votes} if ($max_value<$_->{votes}); } @{$question_data->{choices}}; |
26 |
|
|
% next unless $total; |
27 |
|
|
% my $delta; |
28 |
|
|
% if ( $question_data->{range} ) { |
29 |
|
|
% map {$_->{procent}=int(1000*$_->{votes}/$question_data->{range})/10; $total_procent+=$_->{procent};} @{$question_data->{choices}}; |
30 |
|
|
% } else { |
31 |
|
|
% map {$_->{procent}=int(1000*$_->{votes}/$total)/10; $total_procent+=$_->{procent};} @{$question_data->{choices}}; |
32 |
|
|
% my $delta = 100-$total_procent; |
33 |
|
|
% } |
34 |
|
|
<table class="diagram" border="0" width="700"> |
35 |
|
|
|
36 |
|
|
% my $COLORS=$m->comp('/subs/'.$prj.'/get_colors_green.msn', split=>scalar(@{$question_data->{choices}})); |
37 |
|
|
% my $first=1; |
38 |
|
|
% foreach my $answer_data (sort {$b->{votes} <=> $a->{votes}} @{$question_data->{choices}}) { |
39 |
|
|
% my $color=pop @$COLORS; |
40 |
|
|
% my $procent=$answer_data->{procent}; |
41 |
|
|
% if ($first) { |
42 |
|
|
% $first=0; |
43 |
|
|
% $procent+=$delta; |
44 |
|
|
% } |
45 |
|
|
% my $choice_name = $answer_data->{choice}; |
46 |
|
|
% my $img_src; |
47 |
|
|
% if ( $choice_name =~ /<%\s*\w+_(\d+)\s*%>/i ) { |
48 |
|
|
% my $index = $1; |
49 |
|
|
% if ( ref $pictures && exists $pictures->{"image_$index"} ) { |
50 |
|
|
% my $img = $pictures->{"image_$index"}; |
51 |
|
|
% my $mini = $pictures->{"image_$index"}{mini}; |
52 |
|
|
% $img_src = '<a href="/images/'.$img->{filename}.'" rel="lightbox" title=""><img src="/images/'.$mini->{filename}.'" width="'.$mini->{width}.'" height="'.$mini->{height}.'"></a>'; |
53 |
|
|
% } |
54 |
|
|
% $choice_name =~ s/<%\s*\w+_(\d+)\s*%>//i; |
55 |
|
|
% } |
56 |
|
|
% my $width; |
57 |
|
|
% if ( $question_data->{range} ) { |
58 |
|
|
% $width=int($answer_data->{procent}) || 1; |
59 |
|
|
% } else { |
60 |
|
|
% $width=int(100*$answer_data->{votes}/$max_value) || 1; |
61 |
|
|
% } |
62 |
|
|
<tr><td></td><td class="otvet"><% $img_src %><br><% $choice_name %><td></tr> |
63 |
|
|
<tr class="rezult"> |
64 |
|
|
<th class="proc" width="50"><% sprintf("%.1f",$procent) %>%</th> |
65 |
|
|
<td><div class="bar"><span style="width: <% int(2.65*($width)) %>px; background-color: <% $color %>"><!----></span></div></td> |
66 |
|
|
</tr> |
67 |
|
|
% } |
68 |
|
|
|
69 |
|
|
</table> |
70 |
|
|
|
71 |
|
|
% } |
72 |
|
|
% } |
73 |
|
|
|
74 |
|
|
% if ($vote_data->{total}) { |
75 |
|
|
<h1>Всего проголосовало: <% $vote_data->{total} %></h1> |
76 |
|
|
% } |
77 |
|
|
% |
78 |
|
|
</td></tr></table> |
79 |
|
|
|
80 |
|
|
<%ONCE> |
81 |
|
|
# Попробуйте поменять начальные и конечные цвета! |
82 |
|
|
my @max = (117,151,196); |
83 |
|
|
my @min = (2, 65, 145); |
84 |
|
|
</%ONCE> |
85 |
|
|
<%args> |
86 |
|
|
|
87 |
|
|
$voting => undef |
88 |
|
|
|
89 |
|
|
</%args> |
90 |
|
|
<%init> |
91 |
|
|
|
92 |
|
|
return unless ref $voting; |
93 |
|
|
return unless $voting->visible; |
94 |
|
|
|
95 |
|
|
my $prj = $request->{project}; |
96 |
|
|
my $profile = $request->{project_profile}; |
97 |
|
|
my $root = $request->{project_section}; |
98 |
|
|
|
99 |
|
|
my $vote_data = $voting->get_image('voting'); |
100 |
|
|
my $pictures = $voting->get_image('pictures'); |
101 |
|
|
|
102 |
|
|
</%init> |