Skip to content

Commit 84ebf00

Browse files
committed
fix: stampa preventivi con descrizione
1 parent 085c3b2 commit 84ebf00

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

templates/preventivi/body.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,20 @@
6868
$autofill = new Util\Autofill($columns);
6969
$rows_per_page = 22;
7070
$rows_first_page = 36;
71-
$autofill->setRows($rows_per_page, 0, $rows_first_page);
72-
7371
// Conto le righe da diminuire
7472
$c = 0;
75-
$destinazione ? $c += 2 : null;
73+
$destinazione ? $c += 2 : 0;
74+
75+
$descrizione_righe = 0;
76+
if (!empty($documento['descrizione'])) {
77+
$descrizione_text = (string) $documento['descrizione'];
78+
$descrizione_lines = explode("\n", $descrizione_text);
79+
foreach ($descrizione_lines as $line) {
80+
$descrizione_righe += ceil(strlen($line) / 70);
81+
}
82+
$descrizione_righe += 2;
83+
$c += $descrizione_righe;
84+
}
7685

7786
// Diminuisco le righe disponibili per pagina
7887
$autofill->setRows($rows_per_page - $c, 0, $rows_first_page - $c);
@@ -82,7 +91,6 @@
8291
echo '
8392
<p>'.nl2br((string) $documento['descrizione']).'</p>
8493
<br>';
85-
$autofill->count($documento['descrizione']);
8694
}
8795

8896
// Intestazione tabella per righe
@@ -204,6 +212,7 @@
204212

205213
echo '
206214
<br><small class="text-muted">'.$text.'</small>';
215+
$autofill->count($text, true);
207216
}
208217

209218
echo '

0 commit comments

Comments
 (0)