2014-12-27 00:19:48 +01:00
|
|
|
|
{if !is_array($best_choices) || empty($best_choices)}
|
|
|
|
|
{$best_choices = [0]}
|
2014-12-19 00:28:20 +01:00
|
|
|
|
{/if}
|
|
|
|
|
|
2015-04-06 12:39:58 +02:00
|
|
|
|
<h3>{__('Poll results', 'Votes of the poll')} {if $hidden}<i>({__('PollInfo', 'Results are hidden.')})</i>{/if}</h3>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
|
|
|
|
|
<div id="tableContainer" class="tableContainer">
|
2015-04-11 17:03:10 +02:00
|
|
|
|
<form action="{if $admin}{poll_url id=$admin_poll_id admin=true}{else}{poll_url id=$poll_id}{/if}" method="POST" id="poll_form">
|
2014-12-17 23:12:05 +01:00
|
|
|
|
<table class="results">
|
2015-03-30 15:19:56 +02:00
|
|
|
|
<caption class="sr-only">{__('Poll results', 'Votes of the poll')} {$poll->title|html}</caption>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
<thead>
|
2015-02-28 19:18:59 +01:00
|
|
|
|
{if $admin && !$expired}
|
2015-01-04 02:00:02 +01:00
|
|
|
|
<tr class="hidden-print">
|
2014-12-21 00:45:39 +01:00
|
|
|
|
<th role="presentation"></th>
|
2014-12-27 00:00:14 +01:00
|
|
|
|
{foreach $slots as $id=>$slot}
|
|
|
|
|
<td headers="C{$id}">
|
2015-04-13 12:33:43 +02:00
|
|
|
|
<a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=$slot->title}"
|
|
|
|
|
class="btn btn-link btn-sm" title="{__('adminstuds', 'Remove the column')} {$slot->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-remove text-danger"></i><span class="sr-only">{__('Generic', 'Remove')}</span>
|
2015-04-13 12:33:43 +02:00
|
|
|
|
</a>
|
|
|
|
|
</td>
|
2014-12-21 00:45:39 +01:00
|
|
|
|
{/foreach}
|
|
|
|
|
<td>
|
2015-04-13 12:33:43 +02:00
|
|
|
|
<a href="{poll_url id=$admin_poll_id admin=true action='add_slot' action_value=true}"
|
|
|
|
|
class="btn btn-link btn-sm" title="{__('adminstuds', 'Add a column')} {$slot->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-plus text-success"></i><span class="sr-only">{__('Poll results', 'Add a column')}</span>
|
2015-04-13 12:33:43 +02:00
|
|
|
|
</a>
|
2014-12-21 00:45:39 +01:00
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
{/if}
|
2014-12-17 23:12:05 +01:00
|
|
|
|
<tr>
|
|
|
|
|
<th role="presentation"></th>
|
|
|
|
|
{foreach $slots as $id=>$slot}
|
2015-04-13 14:52:43 +02:00
|
|
|
|
<th class="bg-info" id="C{$id}">{$slot->title|markdown}</th>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{/foreach}
|
|
|
|
|
<th></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{foreach $votes as $vote}
|
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{if $editingVoteId === $vote->uniqId} {* Edited line *}
|
2015-01-07 23:29:46 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
<tr class="hidden-print">
|
|
|
|
|
<td class="bg-info" style="padding:5px">
|
|
|
|
|
<div class="input-group input-group-sm" id="edit">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
<input type="hidden" name="edited_vote" value="{$vote->uniqId}"/>
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<input type="text" id="name" name="name" value="{$vote->name|html}" class="form-control" title="{__('Generic', 'Your name')}" placeholder="{__('Generic', 'Your name')}" />
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</div>
|
|
|
|
|
</td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{foreach $vote->choices as $id=>$choice}
|
2014-12-17 23:12:05 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
<td class="bg-info" headers="C{$id}">
|
|
|
|
|
<ul class="list-unstyled choice">
|
|
|
|
|
<li class="yes">
|
|
|
|
|
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" {if $choice==2}checked {/if}/>
|
|
|
|
|
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {$slots[$id]->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="ifneedbe">
|
|
|
|
|
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1" {if $choice==1}checked {/if}/>
|
|
|
|
|
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {$slots[$id]->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="no">
|
|
|
|
|
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0" {if $choice==0}checked {/if}/>
|
|
|
|
|
<label class="btn btn-default btn-xs" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {$slots[$id]->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</td>
|
|
|
|
|
{/foreach}
|
|
|
|
|
<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{__('Poll results', 'Save the choices')} {$vote->name|html}">{__('Generic', 'Save')}</button></td>
|
|
|
|
|
</tr>
|
|
|
|
|
{elseif !$hidden} {* Voted line *}
|
|
|
|
|
<tr>
|
2015-01-07 23:29:46 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
<th class="bg-info">{$vote->name|html}</th>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{foreach $vote->choices as $id=>$choice}
|
2014-12-17 23:12:05 +01:00
|
|
|
|
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{if $choice==2}
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<td class="bg-success text-success" headers="C{$id}"><i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span></td>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{elseif $choice==1}
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<td class="bg-warning text-warning" headers="C{$id}">(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span></td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{else}
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<td class="bg-danger text-danger" headers="C{$id}"><i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span></td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{/if}
|
2015-05-29 12:00:56 +02:00
|
|
|
|
|
|
|
|
|
{/foreach}
|
|
|
|
|
|
|
|
|
|
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
|
|
|
|
|
<td class="hidden-print">
|
|
|
|
|
<a href="{if $admin}{poll_url id=$poll->admin_id vote_id=$vote->uniqId admin=true}{else}{poll_url id=$poll->id vote_id=$vote->uniqId}{/if}" class="btn btn-default btn-sm" title="{__('Poll results', 'Edit the line:')|html} {$vote->name|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</a>
|
|
|
|
|
{if $admin}
|
|
|
|
|
<a href="{poll_url id=$admin_poll_id admin=true action='delete_vote' action_value=$vote->id}"
|
|
|
|
|
class="btn btn-default btn-sm"
|
|
|
|
|
title="{__('Poll results', 'Remove the line:')} {$vote->name|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-remove text-danger"></i><span class="sr-only">{__('Generic', 'Remove')}</span>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
</td>
|
|
|
|
|
{else}
|
|
|
|
|
<td></td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{/if}
|
|
|
|
|
</tr>
|
2015-05-29 12:00:56 +02:00
|
|
|
|
{/if}
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{/foreach}
|
|
|
|
|
|
|
|
|
|
{* Line to add a new vote *}
|
|
|
|
|
|
2015-04-02 16:52:46 +02:00
|
|
|
|
{if $active && $editingVoteId === 0 && !$expired}
|
2015-05-29 12:00:56 +02:00
|
|
|
|
<tr id="vote-form" class="hidden-print">
|
2014-12-17 23:12:05 +01:00
|
|
|
|
<td class="bg-info" style="padding:5px">
|
|
|
|
|
<div class="input-group input-group-sm">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
|
2015-03-30 15:19:56 +02:00
|
|
|
|
<input type="text" id="name" name="name" class="form-control" title="{__('Generic', 'Your name')}" placeholder="{__('Generic', 'Your name')}" />
|
2014-12-17 23:12:05 +01:00
|
|
|
|
</div>
|
|
|
|
|
</td>
|
2014-12-27 00:00:14 +01:00
|
|
|
|
{foreach $slots as $id=>$slot}
|
|
|
|
|
<td class="bg-info" headers="C{$id}">
|
|
|
|
|
<ul class="list-unstyled choice">
|
|
|
|
|
<li class="yes">
|
|
|
|
|
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" />
|
2015-04-02 16:52:46 +02:00
|
|
|
|
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {$slot->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
2014-12-27 00:00:14 +01:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="ifneedbe">
|
|
|
|
|
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1" />
|
2015-04-02 16:52:46 +02:00
|
|
|
|
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {$slot->title|html}">
|
2015-06-17 23:13:44 +02:00
|
|
|
|
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
2014-12-27 00:00:14 +01:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="no">
|
|
|
|
|
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0" checked/>
|
2015-06-17 23:13:44 +02:00
|
|
|
|
<label class="btn btn-default btn-xs startunchecked" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {$slot->title|html}">
|
|
|
|
|
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
2014-12-27 00:00:14 +01:00
|
|
|
|
</label>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
{/foreach}
|
2015-04-02 17:25:01 +02:00
|
|
|
|
<td><button type="submit" class="btn btn-success btn-md" name="save" title="{__('Poll results', 'Save the choices')}">{__('Generic', 'Save')}</button></td>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
</tr>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{if !$hidden}
|
|
|
|
|
{* Line displaying best moments *}
|
|
|
|
|
{$count_bests = 0}
|
2015-04-23 23:18:31 +02:00
|
|
|
|
{$max = max($best_choices['y'])}
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{if $max > 0}
|
|
|
|
|
<tr id="addition">
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<td>{__('Poll results', 'Addition')}<br/>{$votes|count} {if ($votes|count)==1}{__('Poll results', 'polled user')}{else}{__('Poll results', 'polled users')}{/if}</td>
|
2015-04-23 23:18:31 +02:00
|
|
|
|
{foreach $best_choices['y'] as $i=>$best_choice}
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{if $max == $best_choice}
|
|
|
|
|
{$count_bests = $count_bests +1}
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<td><i class="glyphicon glyphicon-star text-info"></i><span class="yes-count">{$best_choice|html}</span>{if $best_choices['inb'][$i]>0}<br/><span class="small text-muted">(+<span class="inb-count">{$best_choices['inb'][$i]|html}</span>)</span>{/if}</td>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{elseif $best_choice > 0}
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<td><span class="yes-count">{$best_choice|html}</span>{if $best_choices['inb'][$i]>0}<br/><span class="small text-muted">(+<span class="inb-count">{$best_choices['inb'][$i]|html}</span>)</span>{/if}</td>
|
|
|
|
|
{elseif $best_choices['inb'][$i]>0}
|
|
|
|
|
<td><br/><span class="small text-muted">(+<span class="inb-count">{$best_choices['inb'][$i]|html}</span>)</span></td>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{else}
|
|
|
|
|
<td></td>
|
|
|
|
|
{/if}
|
|
|
|
|
{/foreach}
|
|
|
|
|
</tr>
|
|
|
|
|
{/if}
|
2014-12-19 00:28:20 +01:00
|
|
|
|
{/if}
|
2014-12-17 23:12:05 +01:00
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
2015-06-17 22:39:14 +02:00
|
|
|
|
{if !$hidden && $max > 0}
|
|
|
|
|
<div class="row" aria-hidden="true">
|
|
|
|
|
<div class="col-xs-12">
|
|
|
|
|
<p class="text-center" id="showChart">
|
|
|
|
|
<button class="btn btn-lg btn-default">
|
|
|
|
|
<span class="fa fa-fw fa-bar-chart"></span> {__('Poll results', 'Display the chart of the results')}
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
$('#showChart').on('click', function() {
|
2015-06-23 21:54:39 +02:00
|
|
|
|
$('#showChart')
|
|
|
|
|
.after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>")
|
|
|
|
|
.remove();
|
2015-06-17 22:39:14 +02:00
|
|
|
|
|
|
|
|
|
var resIfneedbe = [];
|
|
|
|
|
var resYes = [];
|
|
|
|
|
|
2015-06-23 21:54:39 +02:00
|
|
|
|
$('#addition').find('td').each(function () {
|
|
|
|
|
var inbCountText = $(this).find('.inb-count').text();
|
|
|
|
|
if(inbCountText != '' && inbCountText != undefined) {
|
2015-06-17 22:39:14 +02:00
|
|
|
|
resIfneedbe.push($(this).find('.inb-count').html())
|
|
|
|
|
} else {
|
|
|
|
|
resIfneedbe.push(0);
|
|
|
|
|
}
|
2015-06-23 21:54:39 +02:00
|
|
|
|
|
|
|
|
|
var yesCountText = $(this).find('.yes-count').text();
|
|
|
|
|
if(yesCountText != '' && yesCountText != undefined) {
|
2015-06-17 22:39:14 +02:00
|
|
|
|
resYes.push($(this).find('.yes-count').html())
|
|
|
|
|
} else {
|
|
|
|
|
resYes.push(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var cols = [
|
|
|
|
|
{foreach $slots as $id=>$slot}
|
|
|
|
|
$('<div/>').html('{$slot->title|markdown:true}').text(),
|
|
|
|
|
{/foreach}
|
|
|
|
|
];
|
|
|
|
|
|
2015-06-23 21:54:39 +02:00
|
|
|
|
resIfneedbe.shift();
|
|
|
|
|
resYes.shift();
|
2015-06-17 23:13:44 +02:00
|
|
|
|
|
2015-06-17 22:39:14 +02:00
|
|
|
|
var barChartData = {
|
|
|
|
|
labels : cols,
|
|
|
|
|
datasets : [
|
|
|
|
|
{
|
|
|
|
|
label: "{__('Generic', 'Ifneedbe')}",
|
|
|
|
|
fillColor : "rgba(255,207,79,0.8)",
|
|
|
|
|
highlightFill: "rgba(255,207,79,1)",
|
|
|
|
|
barShowStroke : false,
|
|
|
|
|
data : resIfneedbe
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "{__('Generic', 'Yes')}",
|
|
|
|
|
fillColor : "rgba(103,120,53,0.8)",
|
|
|
|
|
highlightFill : "rgba(103,120,53,1)",
|
|
|
|
|
barShowStroke : false,
|
|
|
|
|
data : resYes
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ctx = document.getElementById("Chart").getContext("2d");
|
|
|
|
|
window.myBar = new Chart(ctx).StackedBar(barChartData, {
|
|
|
|
|
responsive : true
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{if !$hidden}
|
|
|
|
|
{* Best votes listing *}
|
2015-04-23 23:18:31 +02:00
|
|
|
|
{$max = max($best_choices['y'])}
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{if $max > 0}
|
|
|
|
|
<div class="row">
|
|
|
|
|
{if $count_bests == 1}
|
|
|
|
|
<div class="col-sm-12"><h3>{__('Poll results', 'Best choice')}</h3></div>
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<div class="col-sm-6 col-sm-offset-3 alert alert-info">
|
|
|
|
|
<p><i class="glyphicon glyphicon-star text-info"></i> {__('Poll results', 'The best choice at this time is:')}</p>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{elseif $count_bests > 1}
|
|
|
|
|
<div class="col-sm-12"><h3>{__('Poll results', 'Best choices')}</h3></div>
|
2015-06-17 22:39:14 +02:00
|
|
|
|
<div class="col-sm-6 col-sm-offset-3 alert alert-info">
|
|
|
|
|
<p><i class="glyphicon glyphicon-star text-info"></i> {__('Poll results', 'The bests choices at this time are:')}</p>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{$i = 0}
|
|
|
|
|
<ul style="list-style:none">
|
|
|
|
|
{foreach $slots as $slot}
|
2015-04-23 23:18:31 +02:00
|
|
|
|
{if $best_choices['y'][$i] == $max}
|
2015-04-13 14:52:43 +02:00
|
|
|
|
<li><strong>{$slot->title|markdown:true}</strong></li>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{/if}
|
|
|
|
|
{$i = $i+1}
|
|
|
|
|
{/foreach}
|
|
|
|
|
</ul>
|
|
|
|
|
<p>{__('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{__('Generic', 'vote')}{else}{__('Generic', 'votes')}{/if}.</p>
|
|
|
|
|
</div>
|
2014-12-17 23:12:05 +01:00
|
|
|
|
</div>
|
2015-04-06 12:39:58 +02:00
|
|
|
|
{/if}
|
2015-06-17 22:39:14 +02:00
|
|
|
|
{/if}
|