Skip to content

Commit 7dc9f23

Browse files
authored
Merge pull request #1240 from datanfr/upload-results
Upload results
2 parents 7f53f54 + e7af882 commit 7dc9f23

3 files changed

Lines changed: 61 additions & 21 deletions

File tree

application/controllers/Elections.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ public function results_city($dpt, $city) {
305305
$secondRoundInfos = $this->elections_model->get_infos_city_municipales_ministry($insee, '2026_muni_t2');
306306
$secondRoundListes = $this->elections_model->get_municipales_listes('2026_muni_t2', $insee);
307307
$secondRoundListes = $this->elections_model->get_nuances_edited($secondRoundListes);
308-
$hasSecondRoundOfficialResults = !empty($secondRoundResults['results']);
308+
$hasSecondRoundOfficialResults =
309+
!empty($secondRoundResults['results']) &&
310+
isset($secondRoundInfos['pct_saisis']) &&
311+
(float) $secondRoundInfos['pct_saisis'] === 100.0;
309312

310313
$secondRoundLeaders = array();
311314
foreach ($secondRoundListes as $liste) {

application/models/Elections_model.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public function get_results_city_municipales_ministry($city, $id_election){
639639
}
640640

641641
public function get_infos_city_municipales_ministry($city, $id_election){
642-
$this->db->select('code_commune, inscrits, abstentions, votants, blancs, nuls, exprimes');
642+
$this->db->select('code_commune, inscrits, abstentions, votants, blancs, nuls, exprimes, pct_saisis, pourvu');
643643
$this->db->where('id_election', $id_election);
644644
$this->db->where('code_commune', $city);
645645

@@ -655,6 +655,7 @@ public function get_infos_city_municipales_ministry($city, $id_election){
655655
$result['blancs'] = isset($result['blancs']) ? (int) $result['blancs'] : 0;
656656
$result['nuls'] = isset($result['nuls']) ? (int) $result['nuls'] : 0;
657657
$result['exprimes'] = isset($result['exprimes']) ? (int) $result['exprimes'] : 0;
658+
$result['pct_saisis'] = isset($result['pct_saisis']) ? (float) $result['pct_saisis'] : null;
658659
$result['blancs_nuls'] = $result['blancs'] + $result['nuls'];
659660
$result['abstention_pct'] = $result['inscrits'] > 0
660661
? round($result['abstentions'] / $result['inscrits'] * 100, 2)

application/views/elections/results_city.php

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@
2222
}
2323
$municipalesDefaultRound = $municipales_ministry_default_round ?? 't1';
2424
$showMunicipalesRoundToggle = !empty($municipales_ministry_show_round_toggle);
25+
$hasSecondRoundPartialResults =
26+
!empty($municipalesRounds['t2']) &&
27+
!empty($municipalesRounds['t2']['results']) &&
28+
isset($municipalesRounds['t2']['infos']['pct_saisis']) &&
29+
(float) $municipalesRounds['t2']['infos']['pct_saisis'] < 100.0;
2530
$hasSecondRoundOfficialResults =
2631
!empty($municipalesRounds['t2']) &&
2732
(($municipalesRounds['t2']['display_mode'] ?? '') === 'results') &&
33+
isset($municipalesRounds['t2']['infos']['pct_saisis']) &&
34+
(float) $municipalesRounds['t2']['infos']['pct_saisis'] === 100.0 &&
2835
!empty($municipalesRounds['t2']['results']);
2936
$hasSecondRound = isset($municipalesRounds['t2']);
3037
$listSituations = isset($municipales_list_situations) && is_array($municipales_list_situations)
@@ -93,15 +100,24 @@
93100
}
94101
}
95102
?>
96-
<?php if ($hasSecondRound && !$hasSecondRoundOfficialResults): ?>
103+
<?php if ($hasSecondRound && !$hasSecondRoundOfficialResults && !$hasSecondRoundPartialResults): ?>
97104
<div class="alert alert-primary mt-4">
98105
Les résultats seront disponibles dès que possible pour la ville de <?= $ville['commune_nom'] ?> à partir de 20h.
99106
</div>
100107
<?php endif; ?>
101108
<?php if ($hasMunicipalesRoundData): ?>
102109
<?php
103110
$summaryRound = $municipalesRounds['t1'] ?? reset($municipalesRounds);
104-
if (!empty($municipalesRounds['t2']) && ($municipalesRounds['t2']['display_mode'] ?? '') === 'results' && !empty($municipalesRounds['t2']['results'])) {
111+
if (!empty($municipalesRounds['t2']) && !empty($municipalesRounds['t2']['results']) && isset($municipalesRounds['t2']['infos']['pct_saisis']) && (float) $municipalesRounds['t2']['infos']['pct_saisis'] < 100.0) {
112+
$summaryRound = $municipalesRounds['t2'];
113+
}
114+
if (
115+
!empty($municipalesRounds['t2']) &&
116+
($municipalesRounds['t2']['display_mode'] ?? '') === 'results' &&
117+
isset($municipalesRounds['t2']['infos']['pct_saisis']) &&
118+
(float) $municipalesRounds['t2']['infos']['pct_saisis'] === 100.0 &&
119+
!empty($municipalesRounds['t2']['results'])
120+
) {
105121
$summaryRound = $municipalesRounds['t2'];
106122
}
107123
$summaryRoundKey = $summaryRound['key'] ?? '';
@@ -150,6 +166,12 @@
150166
La liste dirigée par <b><?= trim(($winningCandidate['prenom'] ?? '') . ' ' . ($winningCandidate['nom'] ?? '')) ?></b> a remporté les élections municipales 2026 <?= $ville_infos['nom_a'] ?> avec <u><?= number_format($winningCandidate['voix_pct'], 2, ',', ' ') ?>%</u> des voix.
151167
</div>
152168
</div>
169+
<?php elseif ($summaryRoundKey === 't2' && isset($summaryInfos['pct_saisis']) && (float) $summaryInfos['pct_saisis'] < 100.0): ?>
170+
<div class="card border-primary mt-4">
171+
<div class="card-body py-3">
172+
Dépouillement en cours (<?= number_format((float) $summaryInfos['pct_saisis'], 0, ',', ' ') ?>%).
173+
</div>
174+
</div>
153175
<?php elseif ($summaryRoundKey === 't1'): ?>
154176
<div class="card border-primary my-4">
155177
<div class="card-body py-3">
@@ -236,6 +258,18 @@ class="previous-election-round-btn municipales-round-btn <?= (($round['key'] ??
236258
$roundResults = $round['results'] ?? array();
237259
$roundInfos = $round['infos'] ?? array();
238260
$roundListes = $round['listes'] ?? array();
261+
$roundIsPartialCount =
262+
$roundKey === 't2' &&
263+
!empty($roundResults) &&
264+
isset($roundInfos['pct_saisis']) &&
265+
(float) $roundInfos['pct_saisis'] < 100.0;
266+
267+
if (
268+
$roundKey === 't2' &&
269+
!isset($roundInfos['pct_saisis'])
270+
) {
271+
$roundDisplayMode = 'listes';
272+
}
239273
?>
240274
<div
241275
class="municipales-round-content"
@@ -316,26 +350,28 @@ class="municipales-round-content"
316350
</div>
317351
</div>
318352

319-
<div class="col-4 order-2 col-lg-2 order-lg-3 px-0 text-right mb-1 mb-md-0">
320-
<div class="font-weight-bold">
321-
<?= number_format($candidate['voix_pct'] ?? 0, 2, ',', ' ') ?>%
353+
<?php if (!$roundIsPartialCount): ?>
354+
<div class="col-4 order-2 col-lg-2 order-lg-3 px-0 text-right mb-1 mb-md-0">
355+
<div class="font-weight-bold">
356+
<?= number_format($candidate['voix_pct'] ?? 0, 2, ',', ' ') ?>%
357+
</div>
358+
<small class="text-muted">
359+
<?= formatNumber($candidate['voix'] ?? 0) ?> vote<?= ($candidate['voix'] ?? 0) > 1 ? 's' : '' ?>
360+
</small>
322361
</div>
323-
<small class="text-muted">
324-
<?= formatNumber($candidate['voix'] ?? 0) ?> vote<?= ($candidate['voix'] ?? 0) > 1 ? 's' : '' ?>
325-
</small>
326-
</div>
327362

328-
<div class="col-12 order-3 col-lg-4 px-0 order-lg-2 ml-lg-0 px-lg-5 align-self-lg-center">
329-
<div class="progress" style="height: 8px; background-color: #e9ecef">
330-
<div
331-
class="progress-bar bg-primary"
332-
role="progressbar"
333-
style="width: <?= number_format($score_pct, 2, '.', '') ?>%;"
334-
aria-valuenow="<?= number_format($score_pct, 2, '.', '') ?>"
335-
aria-valuemin="0"
336-
aria-valuemax="100"></div>
363+
<div class="col-12 order-3 col-lg-4 px-0 order-lg-2 ml-lg-0 px-lg-5 align-self-lg-center">
364+
<div class="progress" style="height: 8px; background-color: #e9ecef">
365+
<div
366+
class="progress-bar bg-primary"
367+
role="progressbar"
368+
style="width: <?= number_format($score_pct, 2, '.', '') ?>%;"
369+
aria-valuenow="<?= number_format($score_pct, 2, '.', '') ?>"
370+
aria-valuemin="0"
371+
aria-valuemax="100"></div>
372+
</div>
337373
</div>
338-
</div>
374+
<?php endif; ?>
339375
</div>
340376
<?php endforeach; ?>
341377
<?php elseif ($roundDisplayMode === 'listes' && !empty($roundListes)): ?>

0 commit comments

Comments
 (0)