framadate/tpl/part/vote_table_date.tpl
2021-03-25 08:48:24 +00:00

497 lines
27 KiB
Smarty
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{if !is_array($best_choices) || empty($best_choices)}
{$best_choices = [0]}
{/if}
<h3>
{t('Poll results', 'Votes')} {if $hidden}<i>({t('PollInfo', 'Results are hidden')})</i>{/if}
{if $accessGranted}
<a href="" data-toggle="modal" data-target="#hint_modal"><i class="fa fa-lightbulb-o" aria-hidden="true"></i></a>
{/if}
</h3>
{include 'part/scroll_left_right.tpl'}
<div id="tableContainer" class="tableContainer">
<form action="{if $admin}{poll_url id=$admin_poll_id admin=true}{else}{poll_url id=$poll_id}{/if}" method="POST" id="poll_form">
<input type="hidden" name="control" value="{$slots_hash}"/>
<table class="results">
<caption class="sr-only">{t('Poll results', 'Votes')} {$poll->title|html}</caption>
<thead>
{if $admin && !$expired}
<tr class="hidden-print">
<th role="presentation"></th>
{$headersDCount=0}
{foreach $slots as $slot}
{foreach $slot->moments as $id=>$moment}
<td headers="M{$slot@key} D{$headersDCount} H{$headersDCount}">
<a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=($slot->day|date_to_timestamp)|cat:'@'|cat:$moment}"
data-remove-confirmation="{t('adminstuds', 'Confirm removal of the column.')}"
class="btn btn-link btn-sm remove-column"
title="{t('adminstuds', 'Remove column')} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
<i class="fa fa-trash text-danger" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Remove')}</span>
</a>
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
<a href="{poll_url id=$admin_poll_id admin=true action='collect_mail' action_value=($headersDCount)}"
class="btn btn-link btn-sm collect-mail"
title="{t('adminstuds', 'Collect the emails of the polled users for the choice')} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
<i class="fa fa-envelope" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Collect emails')}</span>
</a>
{/if}
</td>
{$headersDCount = $headersDCount+1}
{/foreach}
{/foreach}
<td>
<a href="{poll_url id=$admin_poll_id admin=true action='add_column'}"
class="btn btn-link btn-sm" title="{t('adminstuds', 'Add a column')}">
<i class="fa fa-plus text-success" aria-hidden="true"></i>
<span class="sr-only">{t('Poll results', 'Add a column')}</span>
</a>
</td>
</tr>
{/if}
<tr>
<th role="presentation"></th>
{$count_same = 0}
{$previous = 0}
{foreach $slots as $id=>$slot}
{$display = $slot->day|date_format_intl:DATE_FORMAT_MONTH_YEAR|html}
{if $previous !== 0 && $previous != $display}
<th colspan="{$count_same}" class="bg-primary month" id="M{$id}">{$previous}</th>
{$count_same = 0}
{/if}
{$count_same = $count_same + ($slot->moments|count)}
{if $slot@last}
<th colspan="{$count_same}" class="bg-primary month" id="M{$id}">{$display}</th>
{/if}
{$previous = $display}
{for $foo=0 to ($slot->moments|count)-1}
{append var='headersM' value=$id}
{/for}
{/foreach}
<th></th>
</tr>
<tr>
<th role="presentation"></th>
{foreach $slots as $id=>$slot}
<th colspan="{$slot->moments|count}" class="bg-primary day" id="D{$id}">{$slot->day|date_format_intl:DATE_FORMAT_DAY|html}</th>
{for $foo=0 to ($slot->moments|count)-1}
{append var='headersD' value=$id}
{/for}
{/foreach}
<th></th>
</tr>
<tr>
<th role="presentation"></th>
{$headersDCount=0}
{$slots_raw = array()}
{foreach $slots as $slot}
{foreach $slot->moments as $id=>$moment}
<th colspan="1" class="bg-info" id="H{$headersDCount}">{$moment|html}</th>
{append var='headersH' value=$headersDCount}
{$headersDCount = $headersDCount+1}
{$slots_raw[] = $slot->day|date_format_intl:DATE_FORMAT_FULL|cat:' - '|cat:$moment}
{/foreach}
{/foreach}
<th></th>
</tr>
</thead>
<tbody>
{foreach $votes as $vote}
{* Edited line *}
{if $editingVoteId === $vote->uniqId && !$expired}
<tr class="hidden-print">
<td class="bg-info btn-edit">
<div class="input-group input-group-sm" id="edit">
<span class="input-group-addon" aria-hidden="true">
<i class="fa fa-user"></i>
</span>
<input type="hidden" name="edited_vote" value="{$vote->uniqId}"/>
<input type="text" id="name" name="name" value="{$vote->name|html}" class="form-control" title="{t('Generic', 'Your name')}" placeholder="{t('Generic', 'Your name')}" />
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
<input type="email" {if $poll->collect_users_mail != constant("Framadate\CollectMail::COLLECT")} required {/if} id="mail" name="mail" value="{$vote->mail|html}" class="form-control" title="{t('Generic', 'Your email address')}" placeholder="{t('Generic', 'Your email address')}" />
{/if}
</div>
</td>
{$k=0}
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{$choice=$vote->choices[$k]}
<td class="bg-info" headers="M{$headersM[$k]} D{$headersD[$k]} H{$headersH[$k]}">
<ul class="list-unstyled choice">
<li class="yes">
<input type="radio" id="y-choice-{$k}" name="choices[{$k}]" value="2" {if $choice=='2'}checked {/if}/>
<label class="btn btn-default btn-xs" for="y-choice-{$k}" title="{t('Poll results', 'Vote "yes" for')|html} {$slots_raw[$k]}">
<i class="fa fa-check" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Yes')}</span>
</label>
</li>
<li class="ifneedbe">
<input type="radio" id="i-choice-{$k}" name="choices[{$k}]" value="1" {if $choice=='1'}checked {/if}/>
<label class="btn btn-default btn-xs" for="i-choice-{$k}" title="{t('Poll results', 'Votes under reserve for')|html} {$slots_raw[$k]}">
<span aria-hidden="true">(<i class="fa fa-check"></i>)</span>
<span class="sr-only">{t('Generic', 'Under reserve')}</span>
</label>
</li>
<li class="no">
<input type="radio" id="n-choice-{$k}" name="choices[{$k}]" value="0" {if $choice=='0'}checked {/if}/>
<label class="btn btn-default btn-xs" for="n-choice-{$k}" title="{t('Poll results', 'Vote "no" for')|html} {$slots_raw[$k]}">
<i class="fa fa-times" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'No')}</span>
</label>
</li>
<li class="hide">
<input type="radio" id="n-choice-{$k}" name="choices[{$k}]" value=" "
{if $choice!='2' && $choice!='1' && $choice!='0'}checked {/if}
/>
<i class="fa fa-question" aria-hidden="true"></i>
</li>
</ul>
</td>
{$k=$k + 1}
{/foreach}
{/foreach}
<td class="btn-edit"><button type="submit" class="btn btn-success btn-xs" name="save" value="{$vote->id|html}" title="{t('Poll results', 'Save choices')} {$vote->name|html}">{t('Generic', 'Save')}</button></td>
</tr>
{elseif !$hidden}
<tr>
{* Voted line *}
<th class="bg-info" {if $accessGranted && $admin}title="{$vote->mail|html}"{/if}>{$vote->name|html}
{if $active && !$expired && $accessGranted &&
(
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
or $admin
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
) &&
$slots|count gt 4
}
<span class="edit-username-left">
<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="{n('Poll results', 'Edit line: %s', $vote->name)|html}">
<i class="fa fa-pencil" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Edit')}</span>
</a>
</span>
{/if}
</th>
{$k=0}
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{$choice=$vote->choices[$k]}
{if $choice=='2'}
<td class="bg-success text-success" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
<i class="fa fa-check" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Yes')}</span>
</td>
{elseif $choice=='1'}
<td class="bg-warning text-warning" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
<span aria-hidden="true">(<i class="fa fa-check"></i>)</span>
<span class="sr-only">{t('Generic', 'Under reserve')}</span>
</td>
{elseif $choice=='0'}
<td class="bg-danger text-danger" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
<i class="fa fa-times" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'No')}</span>
</td>
{else}
<td class="bg-info" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
<i class="fa fa-question" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Unknown')}</span>
</td>
{/if}
{$k=$k + 1}
{/foreach}
{/foreach}
{if $active && !$expired && $accessGranted &&
(
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
or $admin
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
)
}
<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="{n('Poll results', 'Edit line: %s', $vote->name)|html}">
<i class="fa fa-pencil" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Edit')}</span>
</a>
{if $admin}
<a href="{poll_url id=$poll->id vote_id=$vote->uniqId}" class="btn btn-default btn-sm clipboard-url" data-toggle="popover" data-trigger="manual" title="{t('Poll results', 'Link to edit this particular line')}" data-content="{t('Poll results', 'The link to edit this particular line has been copied to the clipboard!')}">
<i class="fa fa-link" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Link')}</span>
</a>
<a href="{poll_url id=$admin_poll_id admin=true action='delete_vote' action_value=$vote->id}"
class="btn btn-default btn-sm"
title="{t('Poll results', 'Remove line:')} {$vote->name|html}">
<i class="fa fa-trash text-danger" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Remove')}</span>
</a>
{/if}
</td>
{else}
<td></td>
{/if}
</tr>
{/if}
{/foreach}
{* Line to add a new vote *}
{if $active && $editingVoteId === 0 && !$expired && $accessGranted}
<tr id="vote-form" class="hidden-print">
<td class="bg-info btn-edit">
<div class="input-group input-group-sm">
<span class="input-group-addon" aria-hidden="true">
<i class="fa fa-user"></i>
</span>
<input type="text" id="name" name="name" class="form-control" title="{t('Generic', 'Your name')}" placeholder="{t('Generic', 'Your name')}" />
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
<input type="email" {if $poll->collect_users_mail != constant("Framadate\CollectMail::COLLECT")} required {/if} id="mail" name="mail" class="form-control" title="{t('Generic', 'Your email address')}" placeholder="{t('Generic', 'Your email address')}" />
{/if}
</div>
{if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT") && $poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')}
<div class="bg-danger">
<i class="fa fa-warning" aria-hidden="true"></i>
<label> {t('Poll results', 'Anyone will be able to see your email address after you voted')} </label>
</div>
{/if}
</td>
{$i = 0}
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
<td class="bg-info" headers="M{$headersM[$i]} D{$headersD[$i]} H{$headersH[$i]}">
<ul class="list-unstyled choice">
{if $poll->value_max eq NULL || $best_choices['y'][$i] lt $poll->value_max}
<li class="yes">
<input type="radio" id="y-choice-{$i}" name="choices[{$i}]" value="2"
{(!isset($selectedNewVotes[$i]) || ("2" !== $selectedNewVotes[$i])) ? "" : " checked"}
/>
<label class="btn btn-default btn-xs" for="y-choice-{$i}" title="{t('Poll results', 'Vote "yes" for')|html} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
<i class="fa fa-check" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'Yes')}</span>
</label>
</li>
<li class="ifneedbe">
<input type="radio" id="i-choice-{$i}" name="choices[{$i}]" value="1"
{(!isset($selectedNewVotes[$i]) || ("1" !== $selectedNewVotes[$i])) ? "" : " checked"}
/>
<label class="btn btn-default btn-xs" for="i-choice-{$i}" title="{t('Poll results', 'Votes under reserve for')|html} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
<span aria-hidden="true">(<i class="fa fa-check"></i>)</span>
<span class="sr-only">{t('Generic', 'Under reserve')}</span>
</label>
</li>
{/if}
<li class="no">
<input type="radio" id="n-choice-{$i}" name="choices[{$i}]" value="0"
{(!isset($selectedNewVotes[$i]) || ("0" !== $selectedNewVotes[$i])) ? "" : " checked"}
/>
<label class="btn btn-default btn-xs {(!isset($selectedNewVotes[$i]) || ("0" !== $selectedNewVotes[$i])) ? "startunchecked" : ""}" for="n-choice-{$i}" title="{t('Poll results', 'Vote "no" for')|html} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
<i class="fa fa-times" aria-hidden="true"></i>
<span class="sr-only">{t('Generic', 'No')}</span>
</label>
</li>
<li class="hide">
<input type="radio" id="n-choice-{$i}" name="choices[{$i}]" value=" "
{(isset($selectedNewVotes[$i]) && ("" !== $selectedNewVotes[$i])) ? "" : " checked"}
/>
<i class="fa fa-question" aria-hidden="true"></i>
</li>
</ul>
</td>
{$i = $i+1}
{/foreach}
{/foreach}
<td><button type="submit" class="btn btn-success btn-md" name="save" title="{t('Poll results', 'Save choices')}">{t('Generic', 'Save')}</button></td>
</tr>
{/if}
{if !$hidden}
{* Line displaying best moments *}
{$count_bests = 0}
{$max = max($best_choices['y'])}
{if $max > 0}
<tr id="addition">
<td>{t('Poll results', 'Total')}<br/>{$votes|count} {if ($votes|count)==1}{t('Poll results', 'polled user')}{else}{t('Poll results', 'polled users')}{/if}</td>
{foreach $best_choices['y'] as $i=>$best_moment}
{if $max == $best_moment}
{$count_bests = $count_bests +1}
<td>
<i class="fa fa-star text-info" aria-hidden="true"></i>
<span class="yes-count">{$best_moment|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_moment > 0}
<td>
<span class="yes-count">{$best_moment|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>
{else}
<td></td>
{/if}
{/foreach}
</tr>
{/if}
{/if}
</tbody>
</table>
</form>
</div>
{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">
<i class="fa fa-fw fa-bar-chart"></i>
{t('Poll results', 'Display the chart of the results')}
</button>
</p>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#showChart').on('click', function() {
$('#showChart')
.after("<h3>{t('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>")
.remove();
var resIfneedbe = [];
var resYes = [];
$('#addition').find('td').each(function () {
var inbCountText = $(this).find('.inb-count').text();
if(inbCountText != '' && inbCountText != undefined) {
resIfneedbe.push(inbCountText)
} else {
resIfneedbe.push(0);
}
var yesCountText = $(this).find('.yes-count').text();
if(yesCountText != '' && yesCountText != undefined) {
resYes.push(yesCountText)
} else {
resYes.push(0);
}
});
var cols = [
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
$('<div/>').html('{$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}').text(),
{/foreach}
{/foreach}
];
resIfneedbe.shift();
resYes.shift();
var barChartData = {
labels : cols,
datasets : [
{
label: "{t('Generic', 'Under reserve')}",
fillColor : "rgba(255,207,79,0.8)",
highlightFill: "rgba(255,207,79,1)",
barShowStroke : false,
data : resIfneedbe
},
{
label: "{t('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}
{if !$hidden}
{* Best votes listing *}
{$max = max($best_choices['y'])}
{if $max > 0}
<div class="row">
{if $count_bests == 1}
<div class="col-sm-12"><h3>{t('Poll results', 'Best choice')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-info">
<p>
<i class="fa fa-star text-info" aria-hidden="true"></i>
{t('Poll results', 'The current best choice is:')}
</p>
{elseif $count_bests > 1}
<div class="col-sm-12"><h3>{t('Poll results', 'Best choices')}</h3></div>
<div class="col-sm-6 col-sm-offset-3 alert alert-info">
<p>
<i class="fa fa-star text-info" aria-hidden="true"></i>
{t('Poll results', 'The current best choices are:')}
</p>
{/if}
{$i = 0}
<ul class="list-unstyled">
{foreach $slots as $slot}
{foreach $slot->moments as $moment}
{if $best_choices['y'][$i] == $max}
{assign var="space" value="`$slot->day|date_format_intl:DATE_FORMAT_DATE|html`|`$moment`"}
<li><strong>{$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}
<a href="{poll_url id=$poll_id action='get_ical_file' action_value=($space)}" class="btn btn-link btn-sm" title="{t('studs', 'Download as ical/ics file')}">
<i class="fa fa-calendar text-muted" aria-hidden="true"></i></a>
</strong></li>
{/if}
{$i = $i+1}
{/foreach}
{/foreach}
</ul>
<p>{t('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{t('Generic', 'vote')}{else}{t('Generic', 'votes')}{/if}.</p>
</div>
</div>
{/if}
{/if}