vote_table_date.tpl 27.2 KB
Newer Older
1
2
{if !is_array($best_choices) || empty($best_choices)}
    {$best_choices = [0]}
3
4
{/if}

Olivier Perez's avatar
Olivier Perez committed
5
<h3>
6
    {t('Poll results', 'Votes')} {if $hidden}<i>({t('PollInfo', 'Results are hidden')})</i>{/if}
7
    {if $accessGranted}
 JosephK's avatar
JosephK committed
8
        <a href="" data-toggle="modal" data-target="#hint_modal"><i class="fa fa-lightbulb-o" aria-hidden="true"></i></a>
9
    {/if}
Olivier Perez's avatar
Olivier Perez committed
10
</h3>
11

12

13
14
15
{include 'part/scroll_left_right.tpl'}


16
<div id="tableContainer" class="tableContainer">
17
    <form action="{if $admin}{poll_url id=$admin_poll_id admin=true}{else}{poll_url id=$poll_id}{/if}" method="POST" id="poll_form">
18
        <input type="hidden" name="control" value="{$slots_hash}"/>
19
        <table class="results">
20
            <caption class="sr-only">{t('Poll results', 'Votes')} {$poll->title|html}</caption>
21
            <thead>
Olivier Perez's avatar
Olivier Perez committed
22
            {if $admin && !$expired}
23
                <tr class="hidden-print">
24
25
26
27
28
                    <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}">
29
                                <a href="{poll_url id=$admin_poll_id admin=true action='delete_column' action_value=($slot->day|date_to_timestamp)|cat:'@'|cat:$moment}"
30
                                   data-remove-confirmation="{t('adminstuds', 'Confirm removal of the column.')}"
Antonin's avatar
Antonin committed
31
                                   class="btn btn-link btn-sm remove-column"
32
                                   title="{t('adminstuds', 'Remove column')} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
 JosephK's avatar
JosephK committed
33
                                    <i class="fa fa-trash text-danger" aria-hidden="true"></i>
34
                                    <span class="sr-only">{t('Generic', 'Remove')}</span>
35
                                </a>
Luc Didry's avatar
Luc Didry committed
36
37
38
                            {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"
39
                                   title="{t('adminstuds', 'Collect the emails of the polled users for the choice')} {$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}">
 JosephK's avatar
JosephK committed
40
                                    <i class="fa fa-envelope" aria-hidden="true"></i>
41
                                    <span class="sr-only">{t('Generic', 'Collect emails')}</span>
Luc Didry's avatar
Luc Didry committed
42
43
                                </a>
                            {/if}
44
45
46
47
48
                            </td>
                            {$headersDCount = $headersDCount+1}
                        {/foreach}
                    {/foreach}
                    <td>
Olivier Perez's avatar
Olivier Perez committed
49
                        <a href="{poll_url id=$admin_poll_id admin=true action='add_column'}"
50
                           class="btn btn-link btn-sm" title="{t('adminstuds', 'Add a column')}">
 JosephK's avatar
JosephK committed
51
                            <i class="fa fa-plus text-success" aria-hidden="true"></i>
52
                            <span class="sr-only">{t('Poll results', 'Add a column')}</span>
53
                        </a>
54
55
56
                    </td>
                </tr>
            {/if}
57
58
            <tr>
                <th role="presentation"></th>
59
60
                {$count_same = 0}
                {$previous = 0}
61
                {foreach $slots as $id=>$slot}
62
                    {$display = $slot->day|date_format_intl:DATE_FORMAT_MONTH_YEAR|html}
63
64
65
66
67
                    {if $previous !== 0 && $previous != $display}
                        <th colspan="{$count_same}" class="bg-primary month" id="M{$id}">{$previous}</th>
                        {$count_same = 0}
                    {/if}

68
                    {$count_same = $count_same + ($slot->moments|count)}
69
70
71
72
73
74
75

                    {if $slot@last}
                        <th colspan="{$count_same}" class="bg-primary month" id="M{$id}">{$display}</th>
                    {/if}

                    {$previous = $display}

76
77
78
79
80
81
82
83
84
                    {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}
85
                    <th colspan="{$slot->moments|count}" class="bg-primary day" id="D{$id}">{$slot->day|date_format_intl:DATE_FORMAT_DAY|html}</th>
86
87
88
                    {for $foo=0 to ($slot->moments|count)-1}
                        {append var='headersD' value=$id}
                    {/for}
89
90
91
92
93
94
                {/foreach}
                <th></th>
            </tr>
            <tr>
                <th role="presentation"></th>
                {$headersDCount=0}
95
                {$slots_raw = array()}
96
97
                {foreach $slots as $slot}
                    {foreach $slot->moments as $id=>$moment}
98
                        <th colspan="1" class="bg-info" id="H{$headersDCount}">{$moment|html}</th>
99
                        {append var='headersH' value=$headersDCount}
100
                        {$headersDCount = $headersDCount+1}
101
                        {$slots_raw[] = $slot->day|date_format_intl:DATE_FORMAT_FULL|cat:' - '|cat:$moment}
102
103
104
105
106
107
108
                    {/foreach}
                {/foreach}
                <th></th>
            </tr>
            </thead>
            <tbody>
            {foreach $votes as $vote}
109
                {* Edited line *}
110

111
112
                {if $editingVoteId === $vote->uniqId && !$expired}
                <tr class="hidden-print">
Thomas Citharel's avatar
Thomas Citharel committed
113
                    <td class="bg-info btn-edit">
114
                        <div class="input-group input-group-sm" id="edit">
 JosephK's avatar
JosephK committed
115
116
117
                            <span class="input-group-addon" aria-hidden="true">
                                <i class="fa fa-user"></i>
                            </span>
118
                            <input type="hidden" name="edited_vote" value="{$vote->uniqId}"/>
119
                            <input type="text" id="name" name="name" value="{$vote->name|html}" class="form-control" title="{t('Generic', 'Your name')}" placeholder="{t('Generic', 'Your name')}" />
 JosephK's avatar
JosephK committed
120
                            {if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
121
                                <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')}" />
 JosephK's avatar
JosephK committed
122
                            {/if}
123
124
                        </div>
                    </td>
125

Erwan TERTRAIS's avatar
Erwan TERTRAIS committed
126

Olivier Perez's avatar
Olivier Perez committed
127
                    {$k=0}
128
129
130
131
                    {foreach $slots as $slot}
                      {foreach $slot->moments as $moment}
                        {$choice=$vote->choices[$k]}

132
133
134
135

                        <td class="bg-info" headers="M{$headersM[$k]} D{$headersD[$k]} H{$headersH[$k]}">
                            <ul class="list-unstyled choice">
                                <li class="yes">
136
                                    <input type="radio" id="y-choice-{$k}" name="choices[{$k}]" value="2" {if $choice=='2'}checked {/if}/>
137
                                    <label class="btn btn-default btn-xs" for="y-choice-{$k}" title="{t('Poll results', 'Vote "yes" for')|html} {$slots_raw[$k]}">
 JosephK's avatar
JosephK committed
138
                                        <i class="fa fa-check" aria-hidden="true"></i>
139
                                        <span class="sr-only">{t('Generic', 'Yes')}</span>
140
141
142
                                    </label>
                                </li>
                                <li class="ifneedbe">
143
                                    <input type="radio" id="i-choice-{$k}" name="choices[{$k}]" value="1" {if $choice=='1'}checked {/if}/>
144
                                    <label class="btn btn-default btn-xs" for="i-choice-{$k}" title="{t('Poll results', 'Votes under reserve for')|html} {$slots_raw[$k]}">
 JosephK's avatar
JosephK committed
145
                                        <span aria-hidden="true">(<i class="fa fa-check"></i>)</span>
146
                                        <span class="sr-only">{t('Generic', 'Under reserve')}</span>
147
148
149
                                    </label>
                                </li>
                                <li class="no">
150
                                    <input type="radio" id="n-choice-{$k}" name="choices[{$k}]" value="0" {if $choice=='0'}checked {/if}/>
151
                                    <label class="btn btn-default btn-xs" for="n-choice-{$k}" title="{t('Poll results', 'Vote "no" for')|html} {$slots_raw[$k]}">
 JosephK's avatar
JosephK committed
152
                                        <i class="fa fa-times" aria-hidden="true"></i>
153
                                        <span class="sr-only">{t('Generic', 'No')}</span>
154
155
                                    </label>
                                </li>
Thomas Citharel's avatar
Thomas Citharel committed
156
                                <li class="hide">
 JosephK's avatar
JosephK committed
157
158
159
160
                                    <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>
161
                                </li>
162
163
                            </ul>
                        </td>
164
165
166

                        {$k=$k + 1}
                      {/foreach}
167
                    {/foreach}
168

169
                    <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>
170

171
172
173
                </tr>
                {elseif !$hidden}
                <tr>
174

175
                    {* Voted line *}
Thomas Citharel's avatar
Thomas Citharel committed
176
                    <th class="bg-info" {if $accessGranted && $admin}title="{$vote->mail|html}"{/if}>{$vote->name|html}
177
178
179
180
181
182
183
184
                    {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
                    }
 JosephK's avatar
JosephK committed
185
            <span class="edit-username-left">
186
                <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}">
 JosephK's avatar
JosephK committed
187
                    <i class="fa fa-pencil" aria-hidden="true"></i>
188
                    <span class="sr-only">{t('Generic', 'Edit')}</span>
 JosephK's avatar
JosephK committed
189
190
191
192
                </a>
          </span>
          {/if}
          </th>
193

Thomas Citharel's avatar
Thomas Citharel committed
194
195
196



Olivier Perez's avatar
Olivier Perez committed
197
                    {$k=0}
198
199
200
                    {foreach $slots as $slot}
                      {foreach $slot->moments as $moment}
                        {$choice=$vote->choices[$k]}
201

202
                        {if $choice=='2'}
 JosephK's avatar
JosephK committed
203
204
                            <td class="bg-success text-success" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
                                <i class="fa fa-check" aria-hidden="true"></i>
205
                                <span class="sr-only">{t('Generic', 'Yes')}</span>
 JosephK's avatar
JosephK committed
206
                            </td>
207
                        {elseif $choice=='1'}
 JosephK's avatar
JosephK committed
208
209
                            <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>
210
                                <span class="sr-only">{t('Generic', 'Under reserve')}</span>
 JosephK's avatar
JosephK committed
211
                            </td>
212
                        {elseif $choice=='0'}
 JosephK's avatar
JosephK committed
213
214
                            <td class="bg-danger text-danger" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
                                <i class="fa fa-times" aria-hidden="true"></i>
215
                                <span class="sr-only">{t('Generic', 'No')}</span>
 JosephK's avatar
JosephK committed
216
                            </td>
Olivier Perez's avatar
Olivier Perez committed
217
                        {else}
 JosephK's avatar
JosephK committed
218
219
                            <td class="bg-info" headers="M{$headersM[$k]} D{$headersD[$k]} H{$k}">
                                <i class="fa fa-question" aria-hidden="true"></i>
220
                                <span class="sr-only">{t('Generic', 'Unknown')}</span>
 JosephK's avatar
JosephK committed
221
                            </td>
222
                        {/if}
223

224
225
                        {$k=$k + 1}
                      {/foreach}
226
227
                    {/foreach}

Antonin's avatar
Antonin committed
228
                    {if $active && !$expired && $accessGranted &&
229
230
231
                        (
                            $poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
                            or $admin
232
                            or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
233
234
                        )
                    }
235
                        <td class="hidden-print">
236
                            <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}">
 JosephK's avatar
JosephK committed
237
                                <i class="fa fa-pencil" aria-hidden="true"></i>
238
                                <span class="sr-only">{t('Generic', 'Edit')}</span>
239
240
                            </a>
                            {if $admin}
241
                                <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!')}">
 JosephK's avatar
JosephK committed
242
                                    <i class="fa fa-link" aria-hidden="true"></i>
243
                                    <span class="sr-only">{t('Generic', 'Link')}</span>
244
                                </a>
245
246
                                <a href="{poll_url id=$admin_poll_id admin=true action='delete_vote' action_value=$vote->id}"
                                   class="btn btn-default btn-sm"
247
                                   title="{t('Poll results', 'Remove line:')} {$vote->name|html}">
 JosephK's avatar
JosephK committed
248
                                    <i class="fa fa-trash text-danger" aria-hidden="true"></i>
249
                                    <span class="sr-only">{t('Generic', 'Remove')}</span>
250
                                </a>
251

252
253
254
255
                            {/if}
                        </td>
                    {else}
                        <td></td>
256
257
                    {/if}
                </tr>
258
                {/if}
259
260
261
262
            {/foreach}

            {* Line to add a new vote *}

263
            {if $active && $editingVoteId === 0 && !$expired && $accessGranted}
264
                <tr id="vote-form" class="hidden-print">
Thomas Citharel's avatar
Thomas Citharel committed
265
                    <td class="bg-info btn-edit">
266
                        <div class="input-group input-group-sm">
 JosephK's avatar
JosephK committed
267
268
269
                            <span class="input-group-addon" aria-hidden="true">
                                <i class="fa fa-user"></i>
                            </span>
270
                            <input type="text" id="name" name="name" class="form-control" title="{t('Generic', 'Your name')}" placeholder="{t('Generic', 'Your name')}" />
Thomas Citharel's avatar
Thomas Citharel committed
271
                            {if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT")}
272
                                <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')}" />
273
                            {/if}
274
                        </div>
Thomas Citharel's avatar
Thomas Citharel committed
275
                        {if $poll->collect_users_mail != constant("Framadate\CollectMail::NO_COLLECT") && $poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')}
276
                            <div class="bg-danger">
 JosephK's avatar
JosephK committed
277
                                <i class="fa fa-warning" aria-hidden="true"></i>
278
                                <label> {t('Poll results', 'Anyone will be able to see your email address after you voted')} </label>
279
280
                            </div>
                        {/if}
281
                    </td>
282
283


284
                    {$i = 0}
285
                    {foreach $slots as $slot}
286
                        {foreach $slot->moments as $moment}
287

288
                            <td class="bg-info" headers="M{$headersM[$i]} D{$headersD[$i]} H{$headersH[$i]}">
289
                                <ul class="list-unstyled choice">
Thomas Citharel's avatar
Thomas Citharel committed
290
                                    {if $poll->value_max eq NULL || $best_choices['y'][$i] lt $poll->value_max}
291
                                    <li class="yes">
292
                                        <input type="radio" id="y-choice-{$i}" name="choices[{$i}]" value="2"
 JosephK's avatar
JosephK committed
293
                                            {(!isset($selectedNewVotes[$i]) || ("2" !== $selectedNewVotes[$i])) ? "" : " checked"}
294
                                        />
295
                                        <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}">
 JosephK's avatar
JosephK committed
296
                                            <i class="fa fa-check" aria-hidden="true"></i>
297
                                            <span class="sr-only">{t('Generic', 'Yes')}</span>
298
299
300
                                        </label>
                                    </li>
                                    <li class="ifneedbe">
301
                                        <input type="radio" id="i-choice-{$i}" name="choices[{$i}]" value="1"
 JosephK's avatar
JosephK committed
302
                                            {(!isset($selectedNewVotes[$i]) || ("1" !== $selectedNewVotes[$i])) ? "" : " checked"}
303
                                        />
304
                                        <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}">
 JosephK's avatar
JosephK committed
305
                                            <span aria-hidden="true">(<i class="fa fa-check"></i>)</span>
306
                                            <span class="sr-only">{t('Generic', 'Under reserve')}</span>
307
308
                                        </label>
                                    </li>
309
                                    {/if}
310

311
                                    <li class="no">
312
                                        <input type="radio" id="n-choice-{$i}" name="choices[{$i}]" value="0"
 JosephK's avatar
JosephK committed
313
                                            {(!isset($selectedNewVotes[$i]) || ("0" !== $selectedNewVotes[$i])) ? "" : " checked"}
314
                                        />
315
                                        <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}">
 JosephK's avatar
JosephK committed
316
                                            <i class="fa fa-times" aria-hidden="true"></i>
317
                                            <span class="sr-only">{t('Generic', 'No')}</span>
318
319
                                        </label>
                                    </li>
Thomas Citharel's avatar
Thomas Citharel committed
320
                                    <li class="hide">
 JosephK's avatar
JosephK committed
321
322
323
324
                                        <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>
325
                                    </li>
326
327
                                </ul>
                            </td>
328

329
330
331
                            {$i = $i+1}
                        {/foreach}
                    {/foreach}
332
                    <td><button type="submit" class="btn btn-success btn-md" name="save" title="{t('Poll results', 'Save choices')}">{t('Generic', 'Save')}</button></td>
333
334
335
                </tr>
            {/if}

336
337
338
            {if !$hidden}
                {* Line displaying best moments *}
                {$count_bests = 0}
339
                {$max = max($best_choices['y'])}
340
341
                {if $max > 0}
                    <tr id="addition">
342
                        <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>
343
                        {foreach $best_choices['y'] as $i=>$best_moment}
344
345
                            {if $max == $best_moment}
                                {$count_bests = $count_bests +1}
 JosephK's avatar
JosephK committed
346
347
348
349
350
351
352
353
                                <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>
354
                            {elseif $best_moment > 0}
 JosephK's avatar
JosephK committed
355
356
357
358
359
360
361
                                <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>
 JosephK's avatar
JosephK committed
362
                            {elseif $best_choices['inb'][$i]>0}
 JosephK's avatar
JosephK committed
363
364
365
366
                                <td>
                                    <br>
                                    <span class="small text-muted">(+<span class="inb-count">{$best_choices['inb'][$i]|html}</span>)</span>
                                </td>
367
368
369
370
371
372
                            {else}
                                <td></td>
                            {/if}
                        {/foreach}
                    </tr>
                {/if}
373
            {/if}
374
375
376
377
378
            </tbody>
        </table>
    </form>
</div>

 JosephK's avatar
JosephK committed
379
380
381
382
383
{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">
 JosephK's avatar
JosephK committed
384
                    <i class="fa fa-fw fa-bar-chart"></i>
385
                    {t('Poll results', 'Display the chart of the results')}
 JosephK's avatar
JosephK committed
386
387
388
389
390
391
392
                </button>
            </p>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#showChart').on('click', function() {
393
                $('#showChart')
394
                        .after("<h3>{t('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>")
395
                        .remove();
Thomas Citharel's avatar
Thomas Citharel committed
396

 JosephK's avatar
JosephK committed
397
398
                var resIfneedbe = [];
                var resYes = [];
Thomas Citharel's avatar
Thomas Citharel committed
399

400
401
402
403
                $('#addition').find('td').each(function () {
                    var inbCountText = $(this).find('.inb-count').text();
                    if(inbCountText != '' && inbCountText != undefined) {
                        resIfneedbe.push(inbCountText)
 JosephK's avatar
JosephK committed
404
405
406
                    } else {
                        resIfneedbe.push(0);
                    }
407
408
409
                    var yesCountText = $(this).find('.yes-count').text();
                    if(yesCountText != '' && yesCountText != undefined) {
                        resYes.push(yesCountText)
 JosephK's avatar
JosephK committed
410
411
412
413
414
415
416
                    } else {
                        resYes.push(0);
                    }
                });
                var cols = [
                {foreach $slots as $slot}
                    {foreach $slot->moments as $moment}
417
                        $('<div/>').html('{$slot->day|date_format_intl:DATE_FORMAT_SHORT|html} - {$moment|html}').text(),
 JosephK's avatar
JosephK committed
418
419
420
421
                    {/foreach}
                {/foreach}
                ];

422
423
                resIfneedbe.shift();
                resYes.shift();
424

 JosephK's avatar
JosephK committed
425
426
427
428
                var barChartData = {
                    labels : cols,
                    datasets : [
                    {
429
                        label: "{t('Generic', 'Under reserve')}",
 JosephK's avatar
JosephK committed
430
431
432
433
434
435
                        fillColor : "rgba(255,207,79,0.8)",
                        highlightFill: "rgba(255,207,79,1)",
                        barShowStroke : false,
                        data : resIfneedbe
                    },
                    {
436
                        label: "{t('Generic', 'Yes')}",
 JosephK's avatar
JosephK committed
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
                        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>
Thomas Citharel's avatar
Thomas Citharel committed
453

 JosephK's avatar
JosephK committed
454
455
{/if}

456
457
{if !$hidden}
    {* Best votes listing *}
458
    {$max = max($best_choices['y'])}
459
460
461
    {if $max > 0}
        <div class="row">
        {if $count_bests == 1}
462
        <div class="col-sm-12"><h3>{t('Poll results', 'Best choice')}</h3></div>
 JosephK's avatar
JosephK committed
463
        <div class="col-sm-6 col-sm-offset-3 alert alert-info">
 JosephK's avatar
JosephK committed
464
465
            <p>
                <i class="fa fa-star text-info" aria-hidden="true"></i>
466
                {t('Poll results', 'The current best choice is:')}
 JosephK's avatar
JosephK committed
467
            </p>
468
            {elseif $count_bests > 1}
469
            <div class="col-sm-12"><h3>{t('Poll results', 'Best choices')}</h3></div>
 JosephK's avatar
JosephK committed
470
            <div class="col-sm-6 col-sm-offset-3 alert alert-info">
 JosephK's avatar
JosephK committed
471
472
                <p>
                    <i class="fa fa-star text-info" aria-hidden="true"></i>
473
                    {t('Poll results', 'The current best choices are:')}
 JosephK's avatar
JosephK committed
474
                </p>
475
                {/if}
476
477


478
                {$i = 0}
Thomas Citharel's avatar
Thomas Citharel committed
479
                <ul class="list-unstyled">
480
481
                    {foreach $slots as $slot}
                        {foreach $slot->moments as $moment}
482
                            {if $best_choices['y'][$i] == $max}
483
484
485
486
487
488
                                {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}
489
490
                            {$i = $i+1}
                        {/foreach}
491
                    {/foreach}
492
                </ul>
493
                <p>{t('Generic', 'with')} <b>{$max|html}</b> {if $max==1}{t('Generic', 'vote')}{else}{t('Generic', 'votes')}{/if}.</p>
494
            </div>
495
        </div>
496
    {/if}
 JosephK's avatar
JosephK committed
497
{/if}