Skip to content

Commit e3f1164

Browse files
committed
fix: selezione contratti con monte ore esaurito
1 parent f895100 commit e3f1164

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

modules/contratti/ajax/select.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* - stato
3030
*/
3131
case 'contratti':
32-
$query = 'SELECT
32+
$query = 'SELECT
3333
`co_contratti`.`id` AS id,
3434
CONCAT("Contratto ", `numero`, " del ", DATE_FORMAT(`data_bozza`, "%d/%m/%Y"), " - ", `co_contratti`.`nome`, " [", (SELECT `title` FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `co_staticontratti`.`id` = `idstato`) , "]") AS descrizione,
3535
(SELECT SUM(`subtotale`) FROM `co_righe_contratti` WHERE `idcontratto`=`co_contratti`.`id`) AS totale,
@@ -69,14 +69,15 @@
6969
$contratto = Contratto::find($r['id']);
7070
$ore_erogate = $contratto->interventi->sum('ore_totali');
7171
$ore_previste = $contratto->getRighe()->where('um', 'ore')->sum('qta');
72-
$perc_ore = $ore_previste != 0 ? ($ore_erogate * 100) / ($ore_previste ?: 1) : 0;
73-
72+
$perc_ore = $ore_previste > 0 ? ($ore_erogate * 100) / $ore_previste : 0;
7473
if ($ore_previste) {
7574
if ($perc_ore < 75) {
7675
$color = '#81f794';
77-
} elseif ($perc_ore <= 100) {
76+
} elseif ($perc_ore > 75) {
7877
$color = '#f5cb78';
7978
}
79+
} else {
80+
$color = '';
8081
}
8182

8283
$descrizione = ($ore_previste > 0 ? $r['descrizione'].' - '.tr('_EROGATE_/_PREVISTE_ ore', [

0 commit comments

Comments
 (0)