mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
fix: generazione righe vuote in stampa fattura
This commit is contained in:
parent
731d7e654c
commit
39c325ecfa
@ -29,9 +29,10 @@ class Autofill
|
|||||||
protected $space = 0;
|
protected $space = 0;
|
||||||
protected $current = 0;
|
protected $current = 0;
|
||||||
|
|
||||||
protected $max_rows = 20;
|
protected $max_rows = 26;
|
||||||
protected $max_rows_first_page = 20;
|
protected $max_rows_first_page = 38;
|
||||||
protected $max_additional = 15;
|
protected $max_additional = 0;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(protected $column_number, protected $char_number = 70)
|
public function __construct(protected $column_number, protected $char_number = 70)
|
||||||
{
|
{
|
||||||
@ -41,32 +42,25 @@ class Autofill
|
|||||||
{
|
{
|
||||||
$this->max_rows = $rows;
|
$this->max_rows = $rows;
|
||||||
|
|
||||||
$this->max_additional = $additional ?? floor($this->max_rows - $this->max_rows / 4);
|
$this->max_additional = $additional ?: $this->max_rows;
|
||||||
$this->max_rows_first_page = $first_page ?? $rows;
|
$this->max_rows_first_page = $first_page ?? $this->max_rows_first_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count($text, $small = false)
|
public function count($text, $small = false)
|
||||||
{
|
{
|
||||||
$count = ceil(strlen((string) $text) / $this->char_number);
|
$count = ceil(strlen((string) $text) / $this->char_number);
|
||||||
$count += substr_count((string) $text, PHP_EOL);
|
|
||||||
$count += substr_count((string) $text, '<br>');
|
|
||||||
|
|
||||||
// Ricerca dei caratteri a capo
|
// Ricerca dei caratteri a capo
|
||||||
preg_match_all("/(\r\n|\r|\n)/", (string) $text, $matches);
|
preg_match_all("/(\r\n|\r|\n)/", (string) $text, $matches);
|
||||||
$count += count($matches[0]);
|
$count += count($matches[0]);
|
||||||
|
$count = ($count == 1 ? $count : $count / 1.538461538 );
|
||||||
if ($small) {
|
|
||||||
$count = $count / 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->set($count);
|
$this->set($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($count)
|
public function set($count)
|
||||||
{
|
{
|
||||||
if ($count > $this->current) {
|
$this->current += $count;
|
||||||
$this->current = $count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function next()
|
public function next()
|
||||||
@ -77,11 +71,20 @@ class Autofill
|
|||||||
|
|
||||||
public function getAdditionalNumber()
|
public function getAdditionalNumber()
|
||||||
{
|
{
|
||||||
$page = ceil($this->space / $this->max_rows_first_page);
|
if ($this->space <= $this->max_rows) {
|
||||||
if ($page > 1) {
|
$page = 1;
|
||||||
$rows = floor($this->space) % $this->max_rows;
|
|
||||||
} else {
|
} else {
|
||||||
$rows = floor($this->space) % $this->max_rows_first_page;
|
if ($this->space <= $this->max_rows_first_page) {
|
||||||
|
$page = 2;
|
||||||
|
} else {
|
||||||
|
$page = ceil(1 + (($this->space - $this->max_rows_first_page) / $this->max_rows));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($page > 1) {
|
||||||
|
$rows = $this->space - $this->max_rows_first_page * ($page - 1);
|
||||||
|
} else {
|
||||||
|
$rows = floor($this->space);
|
||||||
}
|
}
|
||||||
|
|
||||||
$number = $this->max_additional - $rows;
|
$number = $this->max_additional - $rows;
|
||||||
|
@ -25,9 +25,9 @@ $v_totale = [];
|
|||||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||||
|
|
||||||
// Creazione righe fantasma
|
// Creazione righe fantasma
|
||||||
$autofill = new Util\Autofill(6, 40);
|
$autofill = new Util\Autofill(6, 70);
|
||||||
$rows_per_page = $rows_per_page ?: ($fattura_accompagnatoria ? 13 : 25);
|
$rows_per_page = $rows_per_page ?: ($fattura_accompagnatoria ? 13 : 26);
|
||||||
$autofill->setRows($rows_per_page);
|
$autofill->setRows($rows_per_page, 0);
|
||||||
|
|
||||||
// Intestazione tabella per righe
|
// Intestazione tabella per righe
|
||||||
echo "
|
echo "
|
||||||
@ -52,13 +52,6 @@ if (setting('Raggruppa attività per tipologia in fattura')) {
|
|||||||
$righe = $documento->getRighe();
|
$righe = $documento->getRighe();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($righe) > 25) {
|
|
||||||
if (!empty($options['last-page-footer'])) {
|
|
||||||
$rows_per_page += 5;
|
|
||||||
$autofill->setRows($rows_per_page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
|
|
||||||
if (!setting('Visualizza riferimento su ogni riga in stampa')) {
|
if (!setting('Visualizza riferimento su ogni riga in stampa')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user