Skip to content

Commit cb9256a

Browse files
committed
refactor: miglioria stampa checklist
1 parent d1eacfe commit cb9256a

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

modules/checklists/modutil.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function renderChecklist($check, $level = 1, $parent = 0, $has_images = false)
7575
</td>';
7676

7777
$result .= '
78-
<td style="width:400px;border-top:0px;">
78+
<td style="width:400px;border-top:0px;">
7979
'.input([
8080
'type' => 'textarea',
8181
'name' => 'note_checklist',
@@ -203,7 +203,7 @@ function renderChecklistInserimento($check, $level = 1, $parent = 0)
203203
}
204204

205205
if (!function_exists('renderChecklistHtml')) {
206-
function renderChecklistHtml($check, $level = 0, $has_images = false)
206+
function renderChecklistHtml($check, $level = 0, $has_images = false, $show_notes = false)
207207
{
208208
$user = auth()->getUser();
209209
$enabled = $check->assignedUsers ? $check->assignedUsers->pluck('id')->search($user->id) !== false : true;
@@ -229,13 +229,25 @@ function renderChecklistHtml($check, $level = 0, $has_images = false)
229229
$result .= '
230230
</td>
231231
<td style="border:none;vertical-align:middle;">
232-
<span class="text"><b>'.$check->content.'</b>'.(!empty($check->value) ? ': '.$check->value : '').'</span>
232+
<span class="text"><b>'.$check->content.'</b>'.(!empty($check->value) ? ': '.$check->value : '').'</span>';
233+
234+
// Aggiunta delle note se richiesto e se presenti
235+
if ($show_notes && !empty($check->note)) {
236+
$result .= ' <small style="font-weight: normal; color: #666;">'.nl2br($check->note).'</small>';
237+
}
238+
239+
$result .= '
233240
</td>
234241
</tr>
235242
</table>';
236243
} else {
237244
$result .= '
238245
<span class="text"><b>'.$check->content.'</b>'.(!empty($check->value) ? ': '.$check->value : '').'</span>';
246+
247+
// Aggiunta delle note se richiesto e se presenti
248+
if ($show_notes && !empty($check->note)) {
249+
$result .= ' <small style="font-weight: normal; color: #666;">'.nl2br($check->note).'</small>';
250+
}
239251
}
240252

241253
$result .= '
@@ -244,7 +256,7 @@ function renderChecklistHtml($check, $level = 0, $has_images = false)
244256

245257
$children = $check->children;
246258
foreach ($children as $child) {
247-
$result .= renderChecklistHtml($child, $level + 1);
259+
$result .= renderChecklistHtml($child, $level + 1, $has_images, $show_notes);
248260
}
249261

250262
return $result;

templates/interventi/body.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
$has_images = $checks->where('id_immagine', '!=', null)->count();
631631

632632
foreach ($checks as $check) {
633-
echo renderChecklistHtml($check, 0, $has_images);
633+
echo renderChecklistHtml($check, 0, $has_images, $options['note']);
634634
}
635635

636636
$impianti_collegati = $dbo->fetchArray('SELECT * FROM my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto = my_impianti.id WHERE idintervento = '.prepare($id_record));
@@ -646,7 +646,7 @@
646646
</th>
647647
</tr>';
648648
foreach ($checks as $check) {
649-
echo renderChecklistHtml($check, 0, $has_images);
649+
echo renderChecklistHtml($check, 0, $has_images, $options['note']);
650650
}
651651
}
652652
}

update/2_9_5.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,8 @@ ORDER BY
7777
`mg_articoli_lang`.`title`" WHERE `name` = 'Articoli';
7878

7979
UPDATE `zz_views` LEFT JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `query` = "IF(COALESCE(giacenze.stato_giacenza, 0) = -1, '#ec5353', IF(COALESCE(giacenze.stato_giacenza, 0) = 1, '#CCFFCC', ''))" WHERE `zz_views`.`name` = '_bg_' AND `zz_modules`.`name` = 'Articoli';
80+
81+
-- Aggiunta stampa intervento checklist con note
82+
INSERT INTO `zz_prints` (`id_module`, `is_record`, `name`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `enabled`, `available_options`) VALUES ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), '1', 'Intervento & checklist con note', 'interventi', 'idintervento', '{\"pricing\":true, \"checklist\": true, \"note\":true}', 'fa fa-print', '', '', '0', '0', '1', NULL);
83+
INSERT INTO `zz_prints_lang` (`id_lang`, `id_record`, `title`, `filename`) VALUES ('1', (SELECT MAX(`id`) FROM `zz_prints`), 'Intervento & checklist con note', 'Intervento num {numero} del {data}');
84+
INSERT INTO `zz_prints_lang` (`id_lang`, `id_record`, `title`, `filename`) VALUES ('2', (SELECT MAX(`id`) FROM `zz_prints`), 'Intervento & checklist con note', 'Intervento num {numero} del {data}');

0 commit comments

Comments
 (0)