This commit is contained in:
Dennis Eichhorn 2023-05-09 16:07:43 +00:00
parent 686d1ecd47
commit 5fa64005cf
6 changed files with 93 additions and 62 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -70,6 +70,9 @@ class DefaultPdf extends TCPDF
];
public array $attributes = [
'logo' => __DIR__ . '/../Web/Backend/img/logo.png',
'title_name' => 'Jingga',
'slogan' => 'Business solutions made simple.',
'legal_name' => '',
'address' => '',
'city' => '',
@ -95,7 +98,7 @@ class DefaultPdf extends TCPDF
parent::__construct('P', 'mm', 'A4', true, 'UTF-8', false);
// set default header data
$this->setHeaderData('', 15, 'Jingga', 'Business solutions made simple.');
$this->setHeaderData('', 15, $this->attributes['title_name'], $this->attributes['slogan']);
// set header and footer fonts
$this->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);

View File

@ -22,6 +22,62 @@ declare(strict_types=1);
*/
class DefaultWord extends \PhpOffice\PhpWord\PhpWord
{
/**
* Font
*
* @var string
* @since 1.0.0
*/
public string $fontName = 'helvetica';
/**
* Font size
*
* @var int
* @since 1.0.0
*/
public int $fontSize = 8;
public string $language = 'en';
public array $lang = [
'en' => [
'Page' => 'Page',
'CEO' => 'CEO',
'TaxOffice' => 'Tax office',
'TaxNumber' => 'Tax number',
'Swift' => 'BIC',
'BankAccount' => 'Account',
],
'de' => [
'Page' => 'Seite',
'CEO' => 'Geschäftsführer',
'TaxOffice' => 'Finanzamt',
'TaxNumber' => 'Steuernummer',
'Swift' => 'BIC',
'BankAccount' => 'IBAN',
]
];
public array $attributes = [
'logo' => __DIR__ . '/../Web/Backend/img/logo.png',
'title_name' => 'Jingga',
'slogan' => 'Business solutions made simple.',
'legal_name' => '',
'address' => '',
'city' => '',
'country' => '',
'ceo' => '',
'tax_office' => '',
'tax_number' => '',
'bank_name' => '',
'swift' => '',
'bank_account' => '',
'website' => '',
'email' => '',
'phone' => '',
];
/**
* Constructor.
*
@ -54,20 +110,20 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord
$table->addRow();
// first column
$table->addCell(1300)->addImage(__DIR__ . '/../Web/Backend/img/logo.png', ['width' => 50, 'height' => 50]);
$table->addCell(1300)->addImage($this->attributes['logo'], ['width' => 50, 'height' => 50]);
//second column
$cell = $table->addCell(8700, ['valign' => 'bottom']);
$textrun = $cell->addTextRun();
$textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]);
$textrun->addText($this->attributes['title_name'], ['name' => $this->fontName, 'bold' => true, 'size' => 20]);
$textrun = $cell->addTextRun();
$textrun->addText('Business solutions made simple.', ['name' => 'helvetica', 'size' => 10]);
$textrun->addText($this->attributes['slogan'], ['name' => $this->fontName, 'size' => 10]);
// first page footer
$firstFooter = $section->addFooter();
$firstFooter->firstPage();
$firstFooter->addPreserveText('Page {PAGE}/{NUMPAGES}', ['name' => 'helvetica', 'italic' => true], ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]);
$firstFooter->addPreserveText($this->lang[$this->language]['Page'] . ' {PAGE}/{NUMPAGES}', ['name' => $this->fontName, 'italic' => true], ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]);
$firstFooter->addTextRun();
$table = $firstFooter->addTable('FooterTableStyle');
@ -78,35 +134,35 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord
$cell = $table->addCell(2000);
$textrun = $cell->addTextRun();
$textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['legal_name'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('Gartenstr. 26', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['address'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['city'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2700);
$textrun = $cell->addTextRun();
$textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['CEO']. ': ' . $this->attributes['ceo'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('Finanzamt: HRB ???', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['TaxOffice']. ': ' . $this->attributes['tax_office'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['TaxNumber']. ': ' . $this->attributes['tax_number'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2700);
$textrun = $cell->addTextRun();
$textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['bank_name'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('BIC: ??????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['Swift']. ': ' . $this->attributes['swift'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['BankAccount']. ': ' . $this->attributes['bank_account'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2100);
$textrun = $cell->addTextRun();
$textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['website'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('info@jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['email'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('+49 0152 ???????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['phone'], ['name' => $this->fontName, 'size' => 7]);
return $section;
}
@ -132,13 +188,13 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord
//second column
$cell = $table->addCell(8700, ['valign' => 'bottom']);
$textrun = $cell->addTextRun();
$textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]);
$textrun->addText('Jingga', ['name' => $this->fontName, 'bold' => true, 'size' => 20]);
$textrun = $cell->addTextRun();
$textrun->addText('Business solutions made simple.', ['name' => 'helvetica', 'size' => 10]);
$textrun->addText('Business solutions made simple.', ['name' => $this->fontName, 'size' => 10]);
$footer = $section->addFooter();
$footer->addPreserveText('Page {PAGE}/{NUMPAGES}', ['name' => 'helvetica', 'italic' => true], ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]);
$footer->addPreserveText($this->lang[$this->language]['Page'] . ' {PAGE}/{NUMPAGES}', ['name' => $this->fontName, 'italic' => true], ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]);
$footer->addTextRun();
$table = $footer->addTable('FooterTableStyle');
@ -149,58 +205,36 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord
$cell = $table->addCell(2000);
$textrun = $cell->addTextRun();
$textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['legal_name'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('Gartenstr. 26', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['address'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['city'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2700);
$textrun = $cell->addTextRun();
$textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['CEO']. ': ' . $this->attributes['ceo'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('Finanzamt: HRB ???', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['TaxOffice']. ': ' . $this->attributes['tax_office'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['TaxNumber']. ': ' . $this->attributes['tax_number'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2700);
$textrun = $cell->addTextRun();
$textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['bank_name'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('BIC: ??????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['Swift']. ': ' . $this->attributes['swift'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->lang[$this->language]['BankAccount']. ': ' . $this->attributes['bank_account'], ['name' => $this->fontName, 'size' => 7]);
$cell = $table->addCell(2100);
$textrun = $cell->addTextRun();
$textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['website'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('info@jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['email'], ['name' => $this->fontName, 'size' => 7]);
$textrun = $cell->addTextRun();
$textrun->addText('+49 0152 ???????', ['name' => 'helvetica', 'size' => 7]);
$textrun->addText($this->attributes['phone'], ['name' => $this->fontName, 'size' => 7]);
return $section;
}
}
/*
[
'company' => '',
'slogan' => '',
'company_full' => '',
'address' => '',
'ciry' => '',
'manager' => '',
'tax_office' => '',
'tax_id' => '',
'tax_vat' => '',
'bank_name' => '',
'bank_bic' => '',
'bank_iban' => '',
'website' => '',
'email' => '',
'phone' => '',
'creator' => '',
'date' => '',
]
*/

View File

@ -28,7 +28,7 @@ $word = new DefaultWord();
$section = $word->createFirstPage();
$file = \tempnam(\sys_get_temp_dir(), 'oms_');
$writer->save($file);
//$writer->save($file);
$content = \file_get_contents($file);
if ($content !== false) {

View File

@ -30,11 +30,6 @@
"type": "INT(11)",
"null": false
},
"country_region": {
"name": "country_region",
"type": "VARCHAR(15)",
"null": true
},
"country_developed": {
"name": "country_developed",
"type": "TINYINT",

View File

@ -120,7 +120,7 @@ final class Installer extends InstallerAbstract
$con = $dbPool->get();
$query = new Builder($con);
$query->insert('country_name', 'country_code2', 'country_code3', 'country_numeric', 'country_region', 'country_developed')
$query->insert('country_name', 'country_code2', 'country_code3', 'country_numeric', 'country_developed')
->into('country');
$querySqlite = new Builder($sqlite);
@ -136,7 +136,6 @@ final class Installer extends InstallerAbstract
$country['country_code2'] === null ? null : \trim((string) $country['country_code2']),
$country['country_code3'] === null ? null : \trim((string) $country['country_code3']),
$country['country_numeric'],
$country['country_region'],
(int) $country['country_developed']
);
}