-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.php
167 lines (148 loc) · 6.44 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use pollext\poll\AjaxSubmitButton;
use yii\helpers\Url;
?>
<style>
.poll{
display: inline-block;
margin-top: 10px;
margin-bottom: 10px;
background: #ffffff;
}
.poll label{
width: 100%;
font-size: 10pt;
font-weight: bold;
display: block;
color: #464646;
}
.poll label:hover{
cursor: pointer;
}
.poll button[type="submit"]{
font-weight: bold;
font-size: 10pt;
margin-top: 10px;
color: #4682B4;
}
.poll-option-name{
font-weight: bold;
font-size: 10pt;
color: #464646;
}
.per_container{
font-weight: bold;
font-size: 10pt;
color: #464646;
padding: 0;
margin: 0;
max-width: 50px;
}
.support_forms button[type="submit"]{
border: none;
font-weight: normal;
color: #4682B4;
margin-left: 0;
padding: 0;
background: #ffffff;
}
.support_forms button[type="submit"]:hover{
text-decoration: underline;
}
.support_forms button[type="submit"]:focus{
outline: none;
border: none;
}
.support_forms{
margin-top: 0;
}
</style>
<div class="poll" style="width:<?php echo $params['maxLineWidth']+55;?>px;" >
<?php echo "<div style=\"max-width:".$params['maxLineWidth']."px; word-wrap: break-word; margin-bottom: 10px; font-size:12pt; font-weight:bold;\">".$pollData['poll_name']."</div>";?>
<?php $pullName = (isset($_POST['nameOfPoll']) ? $_POST['nameOfPoll'] : '';?>
<?php if((Yii::$app->user->getId()==null && $_POST['pollStatus']!='show' && $isVote == false ) || ($pullName==$pollData['poll_name'] && $_POST['pollStatus']=='vote'&& $_POST['pollStatus']!='show' && Yii::$app->user->getId()==null)){
echo "Sign in to vote";
}?>
<?php if(($isVote == false && Yii::$app->user->getId()!=null && $_POST['pollStatus']!='show') || ($pullName==$pollData['poll_name'] && $_POST['pollStatus']=='vote'&& $_POST['pollStatus']!='show' && Yii::$app->user->getId()!=null)){?>
<?php echo Html::beginForm('#', 'post', ['class'=>'uk-width-medium-1-1 uk-form uk-form-horizontal']); ?>
<?php echo Html::activeRadioList($model,'voice',$answers); ?>
<input type="hidden" name="poll_name" value="<?=$pollData['poll_name']?>"/>
<?php AjaxSubmitButton::begin([
'label' => 'Vote',
'ajaxOptions' => [
'type'=>'POST',
'url'=>'#',
'success' => new \yii\web\JsExpression('function(data){
$("body").html(data);
}'),
],
'options' => ['class' => 'customclass', 'type' => 'submit'],
]);
AjaxSubmitButton::end();
?>
<?php echo Html::endForm();
}
?>
<?php if(($isVote == false && $_POST['pollStatus']!='show') || (Yii::$app->user->getId()==null && $_POST['pollStatus']!='show') || ($pullName==$pollData['poll_name'] && $_POST['pollStatus']=='vote'&& $_POST['pollStatus']!='show')){?>
<form method="POST" action="" class="support_forms">
<input type="hidden" name="nameOfPoll" value="<?=$pollData['poll_name']?>"/>
<input type="hidden" name="pollStatus" value="show"/>
<?php AjaxSubmitButton::begin([
'label' => 'Show results',
'ajaxOptions' => [
'type'=>'POST',
'url'=>'#',
'success' => new \yii\web\JsExpression('function(data){
$("body").html(data);
}'),
],
'options' => ['class' => 'customclass', 'type' => 'submit'],
]);
AjaxSubmitButton::end();
?>
</form>
<?php }?>
<?php if($isVote == true || ($pullName==$pollData['poll_name'] && $_POST['pollStatus']=='show') ){?>
<?php
for($i = 0; $i<count($answersData); $i++){
$voicesPer = 0;
if($sumOfVoices ==0){
$voicesPer = 0;
}else{
$voicesPer = round($answersData[$i]['value']/$sumOfVoices, 4);
}
$lineWidth = $params['maxLineWidth']*$voicesPer;
?>
<div class="single-line" style="margin-bottom: 10px; ">
<?php echo "<div class=\"poll-option-name\">".$answersData[$i]['answers'].": ".$answersData[$i]['value']."</div>"; ?>
<div style="width: <?php echo $params['maxLineWidth']; ?>px; height: <?php echo $params['linesHeight']; ?>px; background-color: <?php echo $params['backgroundLinesColor']; ?>; ">
<div style="width: <?php echo $lineWidth;?>px; height: <?php echo $params['linesHeight'] ?>px; background-color: <?php echo $params['linesColor']; ?>;">
<div class="per_container" style="display: block; line-height:<?php echo $params['linesHeight'] ?>px; height: <?php echo $params['linesHeight'] ?>px;
position: relative; left:<?php echo $params['maxLineWidth']+5; ?>px; margin: 0;"><?php echo ($voicesPer*100)."%"?></div>
</div>
</div>
</div>
<?php }?>
<?php }?>
<?php if ($isVote == false && $_POST['pollStatus']=='show'){?>
<form method="POST" action="" class="support_forms" style="margin-top: -10px;">
<input type="hidden" name="nameOfPoll" value="<?=$pollData['poll_name']?>"/>
<input type="hidden" name="pollStatus" value="vote"/>
<?php AjaxSubmitButton::begin([
'label' => 'Vote',
'ajaxOptions' => [
'type'=>'POST',
'url'=>'#',
'success' => new \yii\web\JsExpression('function(data){
$("body").html(data);
}'),
],
'options' => ['class' => 'customclass', 'type' => 'submit'],
]);
AjaxSubmitButton::end();
?>
<?php }?>
</form>
</div>