This commit is contained in:
KONE SOREL 2026-04-29 10:01:26 +00:00
parent 9e29c32536
commit 5fceb9110f
5 changed files with 44 additions and 7 deletions

View File

@ -22,8 +22,9 @@ class ControleurAjaxsppolice extends Controleur
$dj = date("Y-m-d");
$sppolice = $this->sppolice->getRapportSpPolicePol($idPolice, $dj);
$limiteConsommation = get_limite_consommation_police($idPolice);
$this->genererVueAjax(array('sppolice' => $sppolice));
$this->genererVueAjax(array('sppolice' => $sppolice, 'limiteConsommation' => $limiteConsommation));
}
public function categorie()
@ -33,8 +34,9 @@ class ControleurAjaxsppolice extends Controleur
$dj = date("Y-m-d");
$sppolices = $this->sppolice->getRapportSpPoliceCat($idPolice, $dj);
$limiteConsommation = get_limite_consommation_police($idPolice);
$this->genererVueAjax(array('sppolices' => $sppolices));
$this->genererVueAjax(array('sppolices' => $sppolices, 'limiteConsommation' => $limiteConsommation));
}
public function college()
@ -44,7 +46,8 @@ class ControleurAjaxsppolice extends Controleur
$dj = date("Y-m-d");
$sppolices = $this->sppolice->getRapportSpPoliceCol($idPolice, $dj);
$limiteConsommation = get_limite_consommation_police($idPolice);
$this->genererVueAjax(array('sppolices' => $sppolices));
$this->genererVueAjax(array('sppolices' => $sppolices, 'limiteConsommation' => $limiteConsommation));
}
}

View File

@ -981,4 +981,14 @@ class Police extends Modele {
return $liste->fetch(PDO::FETCH_ASSOC);
}
public function get_limite_consommation_police($idPolice)
{
$sql = 'SELECT fn_limite_consommation_police(?) AS limite_consommation';
$resultat = $this->executerRequete($sql, array($idPolice));
$ligne = $resultat->fetch(PDO::FETCH_ASSOC);
return $ligne['limite_consommation'];
}
}

View File

@ -15,7 +15,9 @@
<th width="18%"><?= _("Primes Acquises") ?></th>
<th width="18%"><?= _("Consommations") ?></th>
<th width="18%"><?= _("S/P (Acquis)") ?></th>
<?php if($limiteConsommation > "0") : ?>
<th width="18%"><?= _("S/P Global") ?></th>
<?php endif; ?>
</tr>
</thead>
@ -46,10 +48,11 @@
<div class="progress-bar <?= $progressColor ?>" role="progressbar" style="width: <?= min($ratio, 100) ?>%"></div>
</div>
</td>
<?php if($limiteConsommation > "0") : ?>
<td class="text-muted small">
<?= $this->nettoyer($sppolice['rapportspgeneral']) ?> %
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>

View File

@ -15,7 +15,9 @@
<th><?= _("Primes Acquises") ?></th>
<th><?= _("Consommations") ?></th>
<th width="15%"><?= _("Ratio S/P (Acquis)") ?></th>
<?php if($limiteConsommation > "0") : ?>
<th width="12%"><?= _("S/P Global") ?></th>
<?php endif; ?>
</tr>
</thead>
@ -50,10 +52,11 @@
</div>
</div>
</td>
<?php if($limiteConsommation > "0") : ?>
<td class="text-muted italic small">
<?= $this->nettoyer($sppolice['rapportspgeneral']) ?>%
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>

View File

@ -39,12 +39,11 @@
</div>
<div class="row g-3">
<?php if($limiteConsommation > "0") : ?>
<div class="col-md-6">
<?php
$sp_acquis = (float)str_replace(',', '.', $sppolice['rapportsp']);
$color_acquis = $sp_acquis > 80 ? 'danger' : ($sp_acquis > 60 ? 'warning' : 'success');
$limiteConsommation = $sppolice['limiteConsommation'];
?>
<div class="card border-0 shadow-sm bg-<?= $color_acquis ?> text-dark">
<div class="card-body d-flex align-items-center">
@ -72,6 +71,25 @@
</div>
</div>
</div>
<?php else : ?>
<div class="col-md-12">
<?php
$sp_acquis = (float)str_replace(',', '.', $sppolice['rapportsp']);
$color_acquis = $sp_acquis > 80 ? 'danger' : ($sp_acquis > 60 ? 'warning' : 'success');
?>
<div class="card border-0 shadow-sm bg-<?= $color_acquis ?> text-dark">
<div class="card-body d-flex align-items-center">
<div class="flex-grow-1">
<h6 class="small fw-bold text-uppercase opacity-75"><?= _("Rapport S/P (Acquises)") ?></h6>
<h2 class="fw-bold mb-0"><?= $this->nettoyer($sppolice['rapportsp']) ?> %</h2>
</div>
<div class="fs-1 opacity-25">
<i class="fas fa-chart-pie"></i>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>