Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
<h1><% $voting->name %></h1>
<p><% $voting->abstr %></p>

<table height="100" cellpadding="0" cellspacing="0">
<tr><td>
%		foreach my $question_data (@{$vote_data->{questions}}) {
%			if ($question_data->{amount}) {
%				my $question_name = $question_data->{question};
%				my $qimg_src;
%				if ( $question_name =~ /<%\s*\w+_(\d+)\s*%>/i ) {
%					my $index = $1;
%					if ( ref $pictures && exists $pictures->{"image_$index"} ) {
%						my $img = $pictures->{"image_$index"};
%					my $mini = $pictures->{"image_$index"}{mini};
%						$qimg_src = '<a href="/images/'.$img->{filename}.'" rel="lightbox" title=""><img src="/images/'.$mini->{filename}.'" width="'.$mini->{width}.'" height="'.$mini->{height}.'" hspace="5"></a>';
%					}
%					$question_name =~ s/<%\s*\w+_(\d+)\s*%>/$qimg_src/i;
%				}

<h2><% $question_name %></h2>

%				my $total=0;
%				my $max_value=1;
%				my $total_procent=0;
%	 			map { $total += $_->{votes}; $max_value = $_->{votes} if ($max_value<$_->{votes}); }	@{$question_data->{choices}};
%				next unless $total;
%				my $delta;
%				if ( $question_data->{range} ) {
%					map {$_->{procent}=int(1000*$_->{votes}/$question_data->{range})/10; $total_procent+=$_->{procent};} @{$question_data->{choices}};
%				} else {
%					map {$_->{procent}=int(1000*$_->{votes}/$total)/10; $total_procent+=$_->{procent};} @{$question_data->{choices}};
%					my $delta = 100-$total_procent;
%				}
<table class="diagram" border="0" width="700">

%				my $COLORS=$m->comp('/subs/'.$prj.'/get_colors_green.msn', split=>scalar(@{$question_data->{choices}}));
%				my $first=1;
%				foreach my $answer_data (sort {$b->{votes} <=> $a->{votes}} @{$question_data->{choices}}) {
% 					my $color=pop @$COLORS;
%					my $procent=$answer_data->{procent};
%					if ($first) {
%						$first=0;
%						$procent+=$delta;
%					}
%					my $choice_name = $answer_data->{choice};
%					my $img_src;
%					if ( $choice_name =~ /<%\s*\w+_(\d+)\s*%>/i ) {
%						my $index = $1;
%						if ( ref $pictures && exists $pictures->{"image_$index"} ) {
%							my $img = $pictures->{"image_$index"};
%						my $mini = $pictures->{"image_$index"}{mini};
%							$img_src = '<a href="/images/'.$img->{filename}.'" rel="lightbox" title=""><img src="/images/'.$mini->{filename}.'" width="'.$mini->{width}.'" height="'.$mini->{height}.'"></a>';
%						}
%						$choice_name =~ s/<%\s*\w+_(\d+)\s*%>//i;
%					}
%					my $width;
%					if ( $question_data->{range} ) {
%						$width=int($answer_data->{procent}) || 1;
%					} else {
%						$width=int(100*$answer_data->{votes}/$max_value) || 1;
%					}
<tr><td></td><td class="otvet"><% $img_src %><br><% $choice_name %><td></tr>
<tr class="rezult">
	<th class="proc" width="50"><% sprintf("%.1f",$procent) %>%</th>
	<td><div class="bar"><span style="width: <% int(2.65*($width)) %>px; background-color: <% $color %>"><!----></span></div></td>
</tr>
%				}

</table>

%			}
%		}

%		if ($vote_data->{total}) {
<h1>Всего проголосовало: <% $vote_data->{total} %></h1>
%		}
%
</td></tr></table>

<%ONCE>
        # Попробуйте поменять начальные и конечные цвета!
        my @max = (117,151,196);
        my @min = (2, 65, 145);
</%ONCE>
<%args>

        $voting => undef

</%args>
<%init>

  return        unless ref $voting;
  return	unless $voting->visible;

  my $prj = $request->{project};
  my $profile = $request->{project_profile};
  my $root = $request->{project_section};

  my $vote_data = $voting->get_image('voting');
  my $pictures = $voting->get_image('pictures');

</%init>