Add line to add vote + Add line to show best choices
This commit is contained in:
parent
fafa5393ed
commit
ea105960b4
@ -41,7 +41,7 @@ $smarty->assign('TITLE_IMAGE', IMAGE_TITRE);
|
||||
$smarty->assign('use_nav_js', file_exists($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js'));
|
||||
$smarty->assign('lang', $lang);
|
||||
$smarty->assign('langs', $ALLOWED_LANGUAGES);
|
||||
$smarty->assign('day_format', $date_format['txt_day']);
|
||||
$smarty->assign('date_format', $date_format);
|
||||
|
||||
function smarty_modifier_poll_url($poll_id, $admin=false){return \Framadate\Utils::getUrlSondage($poll_id, $admin);}
|
||||
//$smarty->registerPlugin('modifier', 'poll_url', 'sqqmarty_modifier_poll_url');
|
||||
|
19
studs.php
19
studs.php
@ -49,6 +49,22 @@ function split_votes($votes) {
|
||||
return $splitted;
|
||||
}
|
||||
|
||||
function computeBestMoments($votes) {
|
||||
$result = [];
|
||||
foreach ($votes as $vote) {
|
||||
$choices = str_split($vote->reponses);
|
||||
foreach ($choices as $i=>$choice) {
|
||||
if (empty($result[$i])) {
|
||||
$result[$i] = 0;
|
||||
}
|
||||
if ($choice == 2) {
|
||||
$result[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* PAGE */
|
||||
/* ---- */
|
||||
|
||||
@ -75,8 +91,9 @@ $smarty->assign('poll', $poll);
|
||||
$smarty->assign('title', _('Poll') . ' - ' . $poll->title);
|
||||
$smarty->assign('slots', split_slots($slots));
|
||||
$smarty->assign('votes', split_votes($votes));
|
||||
$smarty->assign('best_moments', computeBestMoments($votes));
|
||||
$smarty->assign('editingVoteId', 0); // TODO Replace by the right ID
|
||||
|
||||
//Utils::debug(split_votes($votes));exit;
|
||||
//Utils::debug(computeBestMoments($votes));exit;
|
||||
|
||||
$smarty->display('studs.tpl');
|
||||
|
@ -76,21 +76,27 @@
|
||||
<th role="presentation"></th>
|
||||
{foreach $slots as $id=>$slot}
|
||||
<th colspan="{$slot->moments|count}" class="bg-primary month" id="M{$id}">{$slot->day|date_format:'%B %Y'}</th>
|
||||
{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:$day_format}</th>
|
||||
<th colspan="{$slot->moments|count}" class="bg-primary day" id="D{$id}">{$slot->day|date_format:$date_format.txt_day}</th>
|
||||
{/foreach}
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th role="presentation"></th>
|
||||
{$headersDCount=0}
|
||||
{foreach $slots as $slot}
|
||||
{foreach $slot->moments as $id=>$moment}
|
||||
<th colspan="1" class="bg-info" id="H{$id}">{$moment}</th>
|
||||
<th colspan="1" class="bg-info" id="H{$headersDCount}">{$moment}</th>
|
||||
{append var='headersD' value=$headersDCount}
|
||||
{$headersDCount = $headersDCount+1}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
<th></th>
|
||||
@ -99,29 +105,30 @@
|
||||
<tbody>
|
||||
{foreach $votes as $vote}
|
||||
<tr>
|
||||
{* Edited line *}
|
||||
|
||||
<th class="bg-info">{$vote->name}</th>
|
||||
|
||||
{if $editingVoteId == $vote->id}
|
||||
{foreach $vote->choices as $k=>$choice}
|
||||
{* Edited line *}
|
||||
|
||||
<td class="bg-info" headers="'.$td_headers[$k ].'">
|
||||
<td class="bg-info" headers="'.$td_headers[$k].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-{$k}" name="choix{$k}" '.$car_html[1].' />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-{$k}" title="{_('Vote "yes" for ')} . $radio_title[$k] . '">
|
||||
<input type="radio" id="y-choice-{$k}" name="choice{$k}" value="2" {if $choice==2}checked {/if}/>
|
||||
<label class="btn btn-default btn-xs" for="y-choice-{$k}" title="{_('Vote yes for ')} . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-{$k}" name="choix{$k}" '.$car_html[2].' />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-{$k}" title="{_('Vote "ifneedbe" for ')} . $radio_title[$k] . '">
|
||||
<input type="radio" id="i-choice-{$k}" name="choice{$k}" value="1" {if $choice==1}checked {/if}/>
|
||||
<label class="btn btn-default btn-xs" for="i-choice-{$k}" title="{_('Vote ifneedbe for ')} . $radio_title[$k] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-{$k}" name="choix{$k}" '.$car_html[0].'/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-{$k}" title="{_('Vote "no" for ')} . $radio_title[$k] . '">
|
||||
<input type="radio" id="n-choice-{$k}" name="choice{$k}" value="0" {if $choice==0}checked {/if}/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-{$k}" title="{_('Vote no for ')} . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">{_('No')}</span>
|
||||
</label>
|
||||
</li>
|
||||
@ -130,15 +137,17 @@
|
||||
<td></td>
|
||||
{/foreach}
|
||||
{else}
|
||||
{foreach $vote->choices as $k=>$choice}
|
||||
|
||||
{* Voted line *}
|
||||
|
||||
{if $choice==1}
|
||||
<td class="bg-success text-success" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span></td>
|
||||
{else if $choice==2}
|
||||
<td class="bg-warning text-warning" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span></td>
|
||||
{foreach $vote->choices as $k=>$choice}
|
||||
|
||||
{if $choice==2}
|
||||
<td class="bg-success text-success" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span></td>
|
||||
{else if $choice==1}
|
||||
<td class="bg-warning text-warning" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span></td>
|
||||
{else}
|
||||
<td class="bg-danger" headers="'.$td_headers[$k].'"><span class="sr-only">{_('No')}</span></td>
|
||||
<td class="bg-danger" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}"><span class="sr-only">{_('No')}</span></td>
|
||||
{/if}
|
||||
|
||||
{/foreach}
|
||||
@ -156,6 +165,61 @@
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
{* Line to add a new vote *}
|
||||
|
||||
{if $poll->active && $editingVoteId == 0}
|
||||
<tr id="vote-form">
|
||||
<td class="bg-info" style="padding:5px">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
|
||||
<input type="text" id="nom" name="nom" class="form-control" title="{_('Your name')}" placeholder="{_('Your name')}" />
|
||||
</div>
|
||||
</td>
|
||||
{$i = 0}
|
||||
{foreach $slots as $slot}
|
||||
{foreach $slot->moments as $moment}
|
||||
<td class="bg-info" headers="M{$headersM[$i]} D{$headersD[$i]} H{$i}">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-{$i}" name="choice{$i}" value="2" />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-{$i}" title="{_('Vote yes for')} {$slot->day|date_format:$date_format.txt_short} - {$moment}">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-{$i}" name="choice{$i}" value="1" />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-{$i}" title="{_('Vote ifneedbe for')} {$slot->day|date_format:$date_format.txt_short} - {$moment}">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice{$i}" name="choice{$i}" value="0" checked/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-{$i}" title="{_('Vote no for')} {$slot->day|date_format:$date_format.txt_short} - {$moment}">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">{_('No')}</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
{$i = $i+1}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
<td><button type="submit" class="btn btn-success btn-sm" name="add_vote" title="{_('Save the choices')}">{_('Save')}</button></td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{* Line displaying best moments *}
|
||||
<tr id="addition">
|
||||
<td>{_("Addition")}</td>
|
||||
{$max = max($best_moments)}
|
||||
{foreach $best_moments as $best_moment}
|
||||
{if $max == $best_moment}
|
||||
<td><span class="glyphicon glyphicon-star text-warning"></span><span>{$max}</span></td>
|
||||
{else}
|
||||
<td></td>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user