diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index aff60c6c9..2f8305913 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -345,14 +345,17 @@ class Labels extends CI_Controller { function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso,$orientation,$grid=true, $via=false, $reference = false){ $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); - $text = "To Radio: "; - $text .= $current_callsign; + $toradio = "To Radio: "; + $toradio .= $current_callsign; if (($via) && ($qso['via'] ?? '' != '')) { - $text.=' via '.substr($qso['via'],0,8); + $toradio.=' via '.substr($qso['via'],0,8); } - $text .= "\n"; - $text .= "Confirming QSO".($numofqsos>1 ? 's' : '')."\n"; - $text .= $builder->renderTable(); + $builder->setTitle($toradio); + + $additionalText = "Confirming QSO".($numofqsos>1 ? 's' : ''); + $builder->setAdditionalText($additionalText); + + $text = $builder->renderTable(); if($qso['sat'] != "") { if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) { $text .= "\n".'Satellite: '.$qso['sat'].' Band RX: '.$qso['sat_band_rx']; diff --git a/src/Label/vendor/malios/php-to-ascii-table/src/Builder.php b/src/Label/vendor/malios/php-to-ascii-table/src/Builder.php index 0e11e741f..638af911f 100644 --- a/src/Label/vendor/malios/php-to-ascii-table/src/Builder.php +++ b/src/Label/vendor/malios/php-to-ascii-table/src/Builder.php @@ -77,6 +77,8 @@ class Builder */ private $title; + private $additionalText; + public function __construct() { $this->table = new Table(); @@ -126,6 +128,11 @@ class Builder $this->title = $title; } + public function setAdditionalText(string $additionalText) + { + $this->additionalText = $additionalText; + } + /** * Add multiple rows * @@ -198,11 +205,11 @@ class Builder if ($this->title === null) { $titleString = ''; } else { - $titlePadding = intdiv(max(0, mb_strwidth($borderTop) - mb_strwidth($this->title)), 2); + $titlePadding = max(0, mb_strwidth($borderTop) - mb_strwidth($this->title)); $titleString = str_repeat(' ', $titlePadding) . $this->title . PHP_EOL; } - $tableAsString = $titleString . $borderTop . PHP_EOL . $header . PHP_EOL . $borderMiddle . PHP_EOL . $body . $borderBottom; + $tableAsString = $titleString . $this->additionalText . "\n" . $borderTop . PHP_EOL . $header . PHP_EOL . $borderMiddle . PHP_EOL . $body . $borderBottom; return $tableAsString; }