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 <?php
use App\Models\Design; use App\Models\Design;
use App\Services\PdfMaker\Design as PdfMakerDesign;
use App\Utils\Ninja;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use App\Services\PdfMaker\Design as PdfMakerDesign;
return new class extends Migration return new class extends Migration
{ {
@ -16,26 +17,27 @@ return new class extends Migration
public function up() 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->save();
$design = Design::create($design_array); } elseif (Design::count() !== 0) {
$design = new Design();
$template = new PdfMakerDesign(strtolower($design->name)); $design->name = 'Calm';
$template->document(); $design->is_custom = false;
$design->design = '';
$design->is_active = true;
$design_object = new \stdClass; $design->save();
$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->design = $design_object; \Illuminate\Support\Facades\Artisan::call('ninja:design-update');
$design->save();
} }

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' => 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' => 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' => 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) { 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 **/ /** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/
</style> </style>
<div id="body">
<table style="min-width: 100%"> <table style="min-width: 100%">
<thead> <thead>
<tr> <tr>
@ -302,7 +303,7 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<div id="body"> <div id="">
<div class="header-wrapper"> <div class="header-wrapper">
<div> <div>
<img class="company-logo" src="$company.logo" alt="$company.name logo"> <img class="company-logo" src="$company.logo" alt="$company.name logo">
@ -317,7 +318,7 @@
<div id="vendor-details"></div> <div id="vendor-details"></div>
<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> <table id="entity-details" cellspacing="0" dir="ltr"></table>
</div> </div>
</div> </div>
@ -344,6 +345,7 @@
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
</div>
<div class="repeating-header" id="header"></div> <div class="repeating-header" id="header"></div>