FIxes for new calm design

This commit is contained in:
David Bomba 2022-11-16 23:08:03 +11:00
parent f0e51e5a67
commit 2b5285a58a
3 changed files with 23 additions and 18 deletions

View File

@ -1,10 +1,11 @@
<?php
use App\Models\Design;
use App\Services\PdfMaker\Design as PdfMakerDesign;
use App\Utils\Ninja;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Services\PdfMaker\Design as PdfMakerDesign;
return new class extends Migration
{
@ -16,26 +17,27 @@ return new class extends Migration
public function up()
{
$design_array = ['name' => 'Calm', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true];
if (Ninja::isHosted()) {
$design = new Design();
$design = Design::where('name', 'Calm')->whereNull('company_id')->first();
$design->name = 'Calm';
$design->is_custom = false;
$design->design = '';
$design->is_active = true;
if(!$design)
$design = Design::create($design_array);
$design->save();
} elseif (Design::count() !== 0) {
$design = new Design();
$template = new PdfMakerDesign(strtolower($design->name));
$template->document();
$design->name = 'Calm';
$design->is_custom = false;
$design->design = '';
$design->is_active = true;
$design_object = new \stdClass;
$design_object->includes = $template->getSectionHTML('style');
$design_object->header = $template->getSectionHTML('header');
$design_object->body = $template->getSectionHTML('body');
$design_object->product = '';
$design_object->task = '';
$design_object->footer = $template->getSectionHTML('footer');
$design->save();
}
$design->design = $design_object;
$design->save();
\Illuminate\Support\Facades\Artisan::call('ninja:design-update');
}

View File

@ -38,6 +38,7 @@ class DesignSeeder extends Seeder
['id' => 8, 'name' => 'Hipster', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 9, 'name' => 'Playful', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 10, 'name' => 'Tech', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 11, 'name' => 'Calm', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
];
foreach ($designs as $design) {

View File

@ -291,6 +291,7 @@
/** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/
</style>
<div id="body">
<table style="min-width: 100%">
<thead>
<tr>
@ -302,7 +303,7 @@
<tbody>
<tr>
<td>
<div id="body">
<div id="">
<div class="header-wrapper">
<div>
<img class="company-logo" src="$company.logo" alt="$company.name logo">
@ -317,7 +318,7 @@
<div id="vendor-details"></div>
<div>
<p class="entity-label" style="font-size:32px; color:$primary_color;">$entity_label</p>
<p class="entity-label" style="font-size:32px; font-weight: bold; color:$primary_color;">$entity_label</p>
<table id="entity-details" cellspacing="0" dir="ltr"></table>
</div>
</div>
@ -344,6 +345,7 @@
</tr>
</tfoot>
</table>
</div>
<div class="repeating-header" id="header"></div>