Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BeppeJQ committed Oct 31, 2024
2 parents c1fe61e + a02499c commit 7ca8c70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Util/Autofill.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ public function setRows($rows, $additional = null, $first_page = null)
$this->max_rows_first_page = $first_page ?? $this->max_rows_first_page;
}

public function count($text, $small = false)
public function count($text, $small = null)
{
$count = ceil(strlen((string) $text) / $this->char_number);

// Ricerca dei caratteri a capo
preg_match_all("/(\r\n|\r|\n)/", (string) $text, $matches);
$count += count($matches[0]);
$count = ($count == 1 ? $count : $count / 1.538461538 );
if ($small) {
$count *= 1.5;
} elseif ($count != 1) {
$count /= 1.538461538;
}

$this->set($count);
}
Expand Down
1 change: 1 addition & 0 deletions templates/fatture/body.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
echo '
<p class="small-bold text-muted">'.tr('Note', [], ['upper' => true]).':</p>
<p>'.nl2br((string) $record['note']).'</p>';
$autofill->count($record['note'], true);
}

echo '
Expand Down

0 comments on commit 7ca8c70

Please sign in to comment.