Skip to content

Commit 68566f2

Browse files
committed
fix: stampa documenti con rimandi a capo nelle righe
1 parent bd26908 commit 68566f2

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/Util/Autofill.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ public function setRows($rows, $additional = null, $first_page = null)
4747

4848
public function count($text, $small = null)
4949
{
50-
$text = strip_tags((string) $text);
51-
$count = ceil(strlen($text) / $this->char_number);
50+
$count = 0;
51+
$textLines = explode("\n", (string)$text);
5252

53-
if ($small) {
54-
$count /= 1.538461538;
53+
foreach ($textLines as $line) {
54+
$count += ceil(strlen($line) / $this->char_number);
55+
}
56+
57+
if ($count > 1) {
58+
$count /= 1.25;
5559
}
5660

61+
if ($small) {
62+
$count /= 1.538461538;
63+
}
64+
5765
$this->set($count);
5866
}
5967

templates/fatture/body.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
// Conteggio le righe da sottrarre al totale
3434
$c = 0;
35-
$documento['note'] ? $c += 3 : null;
3635
foreach ($v_iva as $desc_iva => $tot_iva) {
3736
++$c;
3837
}
@@ -237,6 +236,10 @@
237236
$autofill->count($dicitura);
238237
}
239238

239+
if ($documento['note']) {
240+
$autofill->count($documento['note']);
241+
$autofill->count(1);
242+
}
240243
$autofill->next();
241244

242245
echo '

0 commit comments

Comments
 (0)