pdf wip
This commit is contained in:
1 parent
9eb19cf8fd
commit
551ad2369e
17 files changed
+277
-38
No files matched your search
@@ -7,7 +7,7 @@ use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
|
||||
class Deckblatt
|
||||
{
|
||||
public static function create()
|
||||
public static function create($textblock)
|
||||
{
|
||||
// $table->boolean('logo_anzeigen')->default(0);
|
||||
// $table->boolean('text_anzeigen')->default(0);
|
||||
@@ -33,8 +33,9 @@ class Deckblatt
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div id="deckblatt-festsetzung">';
|
||||
$html .= '<h2>Zur Festsetzung der Nutzwerte';
|
||||
$html .= '<h2>ZUR FESTSETZUNG DER NUTZWERTE';
|
||||
$html .= '<div class="base bold">'.trim(MakeGutachten::$projekt->offizieller_name).'</div>';
|
||||
$html .= '<div class="base">'.trim($textblock).'</div>';
|
||||
$html .= '</h2>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Gutachten;
|
||||
|
||||
use App\Actions\Generate\MakeGutachten;
|
||||
|
||||
class Platzhalter
|
||||
{
|
||||
public static function replace($standardtext)
|
||||
{
|
||||
return str_replace(array_keys(MakeGutachten::$platzhalter), array_values(MakeGutachten::$platzhalter), $standardtext);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Gutachten;
|
||||
|
||||
use App\Actions\Generate\GenerateStandardTexte;
|
||||
|
||||
class Standardtext
|
||||
{
|
||||
public static function replace($standardtext)
|
||||
{
|
||||
return str_replace(array_keys(GenerateStandardTexte::$platzhalter), array_values(GenerateStandardTexte::$platzhalter), $standardtext);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,16 @@ use App\Actions\Generate\Gutachten\AllgemeinTabelle;
|
||||
use App\Actions\Generate\Gutachten\Deckblatt;
|
||||
use App\Actions\Generate\Gutachten\Inhalt;
|
||||
use App\Actions\Generate\Gutachten\Paragraph6Tabelle;
|
||||
use App\Actions\Generate\Gutachten\Platzhalter;
|
||||
use App\Actions\Generate\Gutachten\Standardtext;
|
||||
use App\Actions\Generate\Gutachten\Tabelle;
|
||||
use App\Actions\Generate\Utilities\Format;
|
||||
use App\Actions\Generate\Utilities\Html;
|
||||
use App\Models\Auftraggeber;
|
||||
use App\Models\Gutachter;
|
||||
use App\Models\Inhaltsverzeichnis;
|
||||
use App\Models\Projekte;
|
||||
use App\Models\ProjektInhaltsverzeichnis;
|
||||
use App\Models\ProjektPlatzhalter;
|
||||
use Mpdf\HTMLParserMode;
|
||||
use Mpdf\Mpdf;
|
||||
@@ -29,8 +33,6 @@ class MakeGutachten
|
||||
public static function generate($filepath, $projekte_id)
|
||||
{
|
||||
|
||||
exit;
|
||||
|
||||
self::$projekt = Projekte::where('id', $projekte_id)->first();
|
||||
|
||||
self::$gutachter = Gutachter::where('id', self::$projekt->gutachter_id)->first();
|
||||
@@ -61,11 +63,36 @@ class MakeGutachten
|
||||
$mpdf->SetCreator('nutzwerte.at');
|
||||
$mpdf->SetAuthor(self::$gutachter->title.' '.self::$gutachter->gender.' '.self::$gutachter->name);
|
||||
|
||||
/**
|
||||
* DECKBLATT
|
||||
*/
|
||||
$html = Deckblatt::create();
|
||||
$mpdf->WriteHTML($html, HTMLParserMode::HTML_BODY);
|
||||
$inhalte = ProjektInhaltsverzeichnis::where('projekte_id', $projekte_id)->orderBy('sort')->get();
|
||||
|
||||
foreach ($inhalte as $inhalt) {
|
||||
/**
|
||||
* DECKBLATT
|
||||
*/
|
||||
if ($inhalt->name == 'DECKBLATT') {
|
||||
$textblock = Platzhalter::replace($inhalt->textblock);
|
||||
$html = Deckblatt::create($textblock);
|
||||
$mpdf->WriteHTML($html, HTMLParserMode::HTML_BODY);
|
||||
}
|
||||
/**
|
||||
* INHALTSVERZEICHNIS
|
||||
*/
|
||||
if ($inhalt->name == 'INHALTSVERZEICHNIS') {
|
||||
$mpdf->AddPage();
|
||||
$html = '<div class="header">INHALTSVERZEICHNIS</div>';
|
||||
$html .= '<table class="inhalt">';
|
||||
foreach ($inhalte as $data) {
|
||||
$html .= '<tr>';
|
||||
$html .= Html::td(Format::numeric($data->ordnungszahl, 2));
|
||||
$html .= Html::td($data->name);
|
||||
$html .= Html::td(Format::numeric($data->seite, 0));
|
||||
$html .= '</tr>';
|
||||
}
|
||||
$html .= '</table>';
|
||||
$mpdf->SetHTMLFooter('<div class="size09 center">Seite {PAGENO}<br><br></div>');
|
||||
$mpdf->WriteHTML($html, HTMLParserMode::HTML_BODY);
|
||||
}
|
||||
}
|
||||
|
||||
// $inhalte = Inhaltsverzeichnis::where('projekte_id', $projekte_id)->where('is_active', 1)->orderBy('pos')->get();
|
||||
// if (count($inhalte) == 0) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Utilities;
|
||||
|
||||
class Filter
|
||||
{
|
||||
public static function filter_array($array, $filter)
|
||||
{
|
||||
$return = [];
|
||||
foreach ($array as $value) {
|
||||
if (isset($value[$filter])) {
|
||||
$return[] = $value[$filter];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function get_separator($row)
|
||||
{
|
||||
if (substr_count($row, '|') == 3) {
|
||||
return '|';
|
||||
} elseif (substr_count($row, ';') == 3) {
|
||||
return ';';
|
||||
} elseif (substr_count($row, ',' == 3)) {
|
||||
return ',';
|
||||
}
|
||||
}
|
||||
|
||||
public static function is_active(array $documents): array
|
||||
{
|
||||
foreach ($documents as $key => $row) {
|
||||
if ($row['is_active'] == 1) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Utilities;
|
||||
|
||||
class Format
|
||||
{
|
||||
public static function numeric($value, $stellen)
|
||||
{
|
||||
if (is_numeric($value) && $value * 1 > 0) {
|
||||
return number_format($value, $stellen, '.', '.');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Utilities;
|
||||
|
||||
class Html
|
||||
{
|
||||
public static function table_header_90($_row)
|
||||
{
|
||||
$html = '<thead><tr text-rotate="90deg">';
|
||||
$mm = 190 / \count($_row);
|
||||
foreach ($_row as $value) {
|
||||
$html .= '<td class="head right bl bt br bb" style="background-color:#d1d1d1; width: '.$mm.'mm;">'.$value.'</td>';
|
||||
}
|
||||
$html .= '</tr></thead>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function make_table($str)
|
||||
{
|
||||
$array = explode('<br />', $str);
|
||||
$html = '<table class="table-striped bt bl">';
|
||||
foreach ($array as $value) {
|
||||
$tmp = explode('|', $value);
|
||||
$html .= '<tr>';
|
||||
$html .= self::td($tmp[0], 'br bb');
|
||||
$html .= self::td($tmp[1], 'br bb');
|
||||
$html .= '</tr>';
|
||||
}
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function td($value = '', $classname = '', $colspan = 0)
|
||||
{
|
||||
$cls = $classname != '' ? ' class="'.$classname.'"' : '';
|
||||
$spn = $colspan != '' ? ' colspan="'.$colspan.'"' : '';
|
||||
|
||||
return "<td $cls $spn>".$value.'</td>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Generate\Utilities;
|
||||
|
||||
class Notice
|
||||
{
|
||||
// note
|
||||
|
||||
public static function note($message, $color = '', $exit = false)
|
||||
{
|
||||
switch ($color) {
|
||||
case 'g':
|
||||
echo "\e[32m";
|
||||
break;
|
||||
case 'r':
|
||||
echo "\e[31m";
|
||||
break;
|
||||
case 'b':
|
||||
echo "\e[1;34m";
|
||||
break;
|
||||
default:
|
||||
echo "\e[39m";
|
||||
break;
|
||||
}
|
||||
|
||||
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message.PHP_EOL;
|
||||
}
|
||||
echo '-----------------------------------------------------------'.PHP_EOL;
|
||||
echo "\e[39m";
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static function html($message, $color = '', $exit = false)
|
||||
{
|
||||
switch ($color) {
|
||||
case 'g':
|
||||
echo '<div style="margin:10px; padding:3px; color:green; width=20rem; text-align:center; border:solid 1px green; background-color:lightgreen;">';
|
||||
break;
|
||||
case 'r':
|
||||
echo '<div style="margin:10px; padding:3px; color:red; width=20rem; text-align:center; border:solid 1px red; background-color:#fdd;">';
|
||||
break;
|
||||
case 'b':
|
||||
echo '<div style="margin:10px; padding:3px; color:blue; width=20rem; text-align:center; border:solid 1px blue; background-color:lightblue;">';
|
||||
break;
|
||||
default:
|
||||
echo '<div style="margin:10px; padding:3px; color:black; width=20rem; text-align:center; border:solid 1px black; background-color:#eee;">';
|
||||
break;
|
||||
}
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message;
|
||||
}
|
||||
echo '</div>';
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ class InhaltsverzeichnisForm
|
||||
->components([
|
||||
Section::make('Überschrift')
|
||||
->schema([
|
||||
Checkbox::make('neue_seite')
|
||||
->label('Start neuer Seite')
|
||||
->columnSpan(2),
|
||||
Textarea::make('name')
|
||||
->required()
|
||||
->label('Kapitel / Absatz')
|
||||
@@ -44,7 +47,7 @@ class InhaltsverzeichnisForm
|
||||
])
|
||||
->columnSpan(1),
|
||||
])->columnSpanFull(),
|
||||
Section::make('Tabelle & Textblöcke')
|
||||
Section::make('Tabellen & Textblöcke')
|
||||
->hiddenLabel()
|
||||
->schema([
|
||||
Select::make('tabellen_id')->label('Tabelle')
|
||||
@@ -54,10 +57,11 @@ class InhaltsverzeichnisForm
|
||||
)
|
||||
->default(0)
|
||||
->options(function () {
|
||||
return Tabellen::all()->pluck('name', 'id')->toArray();
|
||||
})->belowContent([
|
||||
'Kann auch frei bleiben',
|
||||
]),
|
||||
$res = Tabellen::all()->pluck('name', 'id')->toArray();
|
||||
array_unshift($res, 'Ohne Tabelle');
|
||||
|
||||
return $res;
|
||||
}),
|
||||
|
||||
Select::make('textblock_id')->label('Textblock')
|
||||
->prefixIcon('phosphor-article')
|
||||
@@ -66,10 +70,11 @@ class InhaltsverzeichnisForm
|
||||
)
|
||||
->default(0)
|
||||
->options(function () {
|
||||
return Textblock::all()->pluck('name', 'id')->toArray();
|
||||
})->belowContent([
|
||||
'Kann auch frei bleiben',
|
||||
]),
|
||||
$res = Textblock::all()->pluck('name', 'id')->toArray();
|
||||
array_unshift($res, 'Ohne Textblock');
|
||||
|
||||
return $res;
|
||||
}),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Inhaltsverzeichnis\Tables;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
@@ -20,6 +21,12 @@ class InhaltsverzeichnisTable
|
||||
TextColumn::make('ordnungszahl')
|
||||
->label('Index')
|
||||
->getStateUsing(fn ($record): string => $record->ordnungszahl == '0' ? '' : number_format($record->ordnungszahl, 2)),
|
||||
IconColumn::make('neue_seite')
|
||||
->label('Seite')
|
||||
->icon(fn (string $state): string => match ($state) {
|
||||
'1' => 'phosphor-file-plus',
|
||||
default => ''
|
||||
}),
|
||||
TextColumn::make('name')
|
||||
->label('Überschrift')
|
||||
->wrap()
|
||||
|
||||
+27
-1
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
use App\Actions\Create\CreateProjektInhaltsverzeichnis;
|
||||
use App\Models\KontoTextblock;
|
||||
use App\Models\ProjektInhaltsverzeichnis;
|
||||
use App\Models\Tabellen;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -48,7 +49,11 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make('Überschrift')
|
||||
->hidden(fn ($record) => $record->name == 'DECKBLATT' ? true : false)
|
||||
->schema([
|
||||
Checkbox::make('neue_seite')
|
||||
->label('Start neuer Seite')
|
||||
->columnSpan(2),
|
||||
Textarea::make('name')
|
||||
->required()
|
||||
->label('Kapitel / Absatz')
|
||||
@@ -158,6 +163,21 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
])->columns(1),
|
||||
]),
|
||||
]),
|
||||
Tab::make('Tabellen')
|
||||
->schema([
|
||||
Select::make('tabellen_id')->label('Tabelle')
|
||||
->prefixIcon('phosphor-table')
|
||||
->prefixIconColor(
|
||||
fn ($record): string => $record->tabellen_id == 0 ? 'gray' : 'primary'
|
||||
)
|
||||
->default(0)
|
||||
->options(function () {
|
||||
$res = Tabellen::all()->pluck('name', 'id')->toArray();
|
||||
array_unshift($res, 'Ohne Tabelle');
|
||||
|
||||
return $res;
|
||||
}),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
@@ -171,6 +191,12 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
->width('2rem')
|
||||
->label('Index')
|
||||
->getStateUsing(fn ($record): string => $record->ordnungszahl == '0' ? '' : number_format($record->ordnungszahl, 2)),
|
||||
IconColumn::make('neue_seite')
|
||||
->label('Seite')
|
||||
->icon(fn (string $state): string => match ($state) {
|
||||
'1' => 'phosphor-file-plus',
|
||||
default => ''
|
||||
}),
|
||||
TextColumn::make('name')
|
||||
->wrap()
|
||||
->weight(fn ($record): FontWeight => match ($record->ueberschrift_nicht_anzeigen) {
|
||||
@@ -221,7 +247,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
->createAnother(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
EditAction::make()->iconButton()->hidden(fn ($record) => $record->name == 'INHALTSVERZEICHNIS' ? true : false),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@@ -14,6 +14,7 @@ class Inhaltsverzeichnis extends Model
|
||||
'sort',
|
||||
'ordnungszahl',
|
||||
'seite',
|
||||
'neue_seite',
|
||||
'ohne_seitenzahl_anzeige',
|
||||
];
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class ProjektInhaltsverzeichnis extends Model
|
||||
'sort',
|
||||
'ordnungszahl',
|
||||
'seite',
|
||||
'neue_seite',
|
||||
'ohne_seitenzahl_anzeige',
|
||||
'textblock',
|
||||
];
|
||||
|
||||
@@ -29,7 +29,6 @@ return new class extends Migration
|
||||
$table->boolean('pdf_gutachten_status')->default(0);
|
||||
$table->boolean('excel_nutzwerte_status')->default(0);
|
||||
$table->boolean('evaluation_gutachten')->default(0);
|
||||
$table->boolean('evaluation_nutzwerte')->default(0);
|
||||
$table->timestamp('bezahlt_am')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -20,6 +20,7 @@ return new class extends Migration
|
||||
$table->integer('sort')->default(0);
|
||||
$table->double('ordnungszahl')->default(0);
|
||||
$table->integer('seite')->default(0);
|
||||
$table->integer('neue_seite')->default(0);
|
||||
$table->integer('ohne_seitenzahl_anzeige')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -22,6 +22,7 @@ return new class extends Migration
|
||||
$table->integer('sort')->default(0);
|
||||
$table->double('ordnungszahl')->default(0);
|
||||
$table->integer('seite')->default(0);
|
||||
$table->integer('neue_seite')->default(0);
|
||||
$table->integer('ohne_seitenzahl_anzeige')->default(0);
|
||||
$table->text('textblock')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
body,
|
||||
table,
|
||||
.base {
|
||||
font-family: DejaVuSans;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 10px;
|
||||
line-height: 16px;
|
||||
margin: 0;
|
||||
@@ -38,7 +38,7 @@ table,
|
||||
|
||||
#deckblatt-auftraggeber {
|
||||
position: absolute;
|
||||
top: 240mm;
|
||||
top: 220mm;
|
||||
width: 185mm;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -55,20 +55,28 @@ table,
|
||||
|
||||
|
||||
/** FORMATTING */
|
||||
.header {
|
||||
padding: 1.3mm 3mm;
|
||||
margin: 2rem 0;
|
||||
font-size: 1.5rem;
|
||||
border: 0.5px solid #f3f4f6;
|
||||
background-color: #eff6ff;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-size: 22px;
|
||||
line-height: 26px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-size: 18px;
|
||||
line-height: 22px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
line-height: 18px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user