From c0ea157ab6ee44bd354bbb75c70c42ae808a0940 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 9 Jul 2023 17:50:30 +1000 Subject: [PATCH 01/20] Adjustments for payments --- app/Jobs/Subscription/CleanStaleInvoiceOrder.php | 4 ++-- app/Services/ClientPortal/InstantPayment.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php index f872b467f636..b182a8831c1f 100644 --- a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php +++ b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php @@ -56,7 +56,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue Invoice::query() ->withTrashed() ->where('status_id', Invoice::STATUS_SENT) - ->where('created_at', '<', now()->subHours(2)) + ->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(10)]) ->where('balance', '>', 0) ->cursor() ->each(function ($invoice){ @@ -77,7 +77,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue Invoice::query() ->withTrashed() ->where('is_proforma', 1) - ->where('created_at', '<', now()->subHour()) + ->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(10)]) ->cursor() ->each(function ($invoice) use ($repo) { $invoice->is_proforma = false; diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 2e5feffd85ea..284e79d93a24 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -190,7 +190,7 @@ class InstantPayment /* Schedule a job to check the gateway fees for this invoice*/ if (Ninja::isHosted()) { - CheckGatewayFee::dispatch($first_invoice->id, $client->company->db)->delay(600); + CheckGatewayFee::dispatch($first_invoice->id, $client->company->db)->delay(800); } if ($gateway) { From dd61b41919221016a698fa18a9a929733b42d709 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 12:55:21 +1000 Subject: [PATCH 02/20] Updates for silent migrations --- app/Http/Controllers/MigrationController.php | 20 ++++++++++++++----- .../ProtectedDownloadController.php | 1 + app/Jobs/Util/Import.php | 15 +++++++++----- app/Jobs/Util/StartMigration.php | 10 +++++++--- app/Repositories/UserRepository.php | 4 ++-- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index 41f82d9fffb9..57b3044f228e 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -32,6 +32,8 @@ class MigrationController extends BaseController { use DispatchesJobs; + public bool $silent_migration = false; + public function __construct() { parent::__construct(); @@ -260,6 +262,9 @@ class MigrationController extends BaseController { nlog('Starting Migration'); + if($request->has('silent_migration')) + $this->silent_migration = true; + if ($request->companies) { //handle Laravel 5.5 UniHTTP $companies = json_decode($request->companies, 1); @@ -312,7 +317,9 @@ class MigrationController extends BaseController $nmo->company = $user->account->companies()->first(); $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; - NinjaMailerJob::dispatch($nmo, true); + + if(!$this->silent_migration) + NinjaMailerJob::dispatch($nmo, true); return; } elseif ($existing_company && $company_count > 10) { @@ -321,7 +328,9 @@ class MigrationController extends BaseController $nmo->company = $user->account->companies()->first(); $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; - NinjaMailerJob::dispatch($nmo, true); + + if(!$this->silent_migration) + NinjaMailerJob::dispatch($nmo, true); return; } @@ -341,7 +350,8 @@ class MigrationController extends BaseController $nmo->settings = $user->account->companies()->first(); $nmo->to_user = $user; - NinjaMailerJob::dispatch($nmo, true); + if(!$this->silent_migration) + NinjaMailerJob::dispatch($nmo, true); return response()->json([ '_id' => Str::uuid(), @@ -431,9 +441,9 @@ class MigrationController extends BaseController nlog($migration_file); if (Ninja::isHosted()) { - StartMigration::dispatch($migration_file, $user, $fresh_company)->onQueue('migration'); + StartMigration::dispatch($migration_file, $user, $fresh_company, $this->silent_migration)->onQueue('migration'); } else { - StartMigration::dispatch($migration_file, $user, $fresh_company); + StartMigration::dispatch($migration_file, $user, $fresh_company, $this->silent_migration); } } diff --git a/app/Http/Controllers/ProtectedDownloadController.php b/app/Http/Controllers/ProtectedDownloadController.php index 452989efda9e..c4c38761b9ab 100644 --- a/app/Http/Controllers/ProtectedDownloadController.php +++ b/app/Http/Controllers/ProtectedDownloadController.php @@ -35,6 +35,7 @@ class ProtectedDownloadController extends BaseController return response()->streamDownload(function () use ($hashed_path) { echo Storage::get($hashed_path); }, basename($hashed_path), []); + } diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index b45f3ead4cfa..e4de8ecc5244 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -165,6 +165,8 @@ class Import implements ShouldQueue public $timeout = 10000000; + public $silent_migration; + // public $backoff = 86430; // public $maxExceptions = 2; @@ -176,12 +178,13 @@ class Import implements ShouldQueue * @param User $user * @param array $resources */ - public function __construct(string $file_path, Company $company, User $user, array $resources = []) + public function __construct(string $file_path, Company $company, User $user, array $resources = [], $silent_migration = false) { $this->file_path = $file_path; $this->company = $company; $this->user = $user; $this->resources = $resources; + $this->silent_migration = $silent_migration; } public function middleware() @@ -263,8 +266,9 @@ class Import implements ShouldQueue $t = app('translator'); $t->replace(Ninja::transformTranslations($this->company->settings)); - Mail::to($this->user->email, $this->user->name()) - ->send(new MigrationCompleted($this->company->id, $this->company->db, implode("
", $check_data))); + if(!$this->silent_migration) + Mail::to($this->user->email, $this->user->name())->send(new MigrationCompleted($this->company->id, $this->company->db, implode("
", $check_data))); + } catch(\Exception $e) { nlog($e->getMessage()); } @@ -641,7 +645,6 @@ class Import implements ShouldQueue $user = $user_repository->save($modified, $this->fetchUser($resource['email']), true, true); $user->email_verified_at = now(); - // $user->confirmation_code = ''; if ($modified['deleted_at']) { $user->deleted_at = now(); @@ -1590,7 +1593,9 @@ class Import implements ShouldQueue $nmo->company = $this->company; $nmo->settings = $this->company->settings; $nmo->to_user = $this->user; - NinjaMailerJob::dispatch($nmo, true); + + if(!$this->silent_migration) + NinjaMailerJob::dispatch($nmo, true); $modified['gateway_key'] = 'd14dd26a47cecc30fdd65700bfb67b34'; } diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index a76afefb05f3..432b1c1b8be4 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -49,6 +49,8 @@ class StartMigration implements ShouldQueue */ private $company; + private $silent_migration; + /** * Create a new job instance. * @@ -60,11 +62,12 @@ class StartMigration implements ShouldQueue public $timeout = 0; - public function __construct($filepath, User $user, Company $company) + public function __construct($filepath, User $user, Company $company, $silent_migration = false) { $this->filepath = $filepath; $this->user = $user; $this->company = $company; + $this->silent_migration = $silent_migration; } /** @@ -116,7 +119,7 @@ class StartMigration implements ShouldQueue throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.'); } - (new Import($file, $this->company, $this->user))->handle(); + (new Import($file, $this->company, $this->user, [], $this->silent_migration))->handle(); Storage::deleteDirectory(public_path("storage/migrations/{$filename}")); @@ -138,7 +141,8 @@ class StartMigration implements ShouldQueue app('sentry')->captureException($e); } - Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $this->company, $e->getMessage())); + if(!$this->silent_migration) + Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $this->company, $e->getMessage())); if (Ninja::isHosted()) { $migration_failed = new MigrationFailed($e, $this->company, $e->getMessage()); diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 6b8707d158a9..1e59805c9bc6 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -39,7 +39,7 @@ class UserRepository extends BaseRepository * @param bool $unset_company_user * @return \App\Models\User user Object */ - public function save(array $data, User $user, $unset_company_user = false) + public function save(array $data, User $user, $unset_company_user = false, $is_migrating = false) { $details = $data; @@ -71,7 +71,7 @@ class UserRepository extends BaseRepository $user->password = Hash::make($data['password']); } - if (! $user->confirmation_code) { + if (! $user->confirmation_code && !$is_migrating) { $user->confirmation_code = $this->createDbHash($company->db); } From 7ba8fac6f441af133d7ed2c1c8ed2f932adf4838 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 18:29:24 +1000 Subject: [PATCH 03/20] minor fixes --- app/Jobs/Invoice/BulkInvoiceJob.php | 2 +- app/Jobs/Util/ReminderJob.php | 1 - app/Utils/Helpers.php | 40 ++++++++++++++++++++++++++++- app/Utils/HtmlEngine.php | 16 ++++++------ 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/app/Jobs/Invoice/BulkInvoiceJob.php b/app/Jobs/Invoice/BulkInvoiceJob.php index dfbdb18a7905..be2224d12378 100644 --- a/app/Jobs/Invoice/BulkInvoiceJob.php +++ b/app/Jobs/Invoice/BulkInvoiceJob.php @@ -41,7 +41,7 @@ class BulkInvoiceJob implements ShouldQueue */ public function handle() { //only the reminder should mark the reminder sent field - // $this->invoice->service()->touchReminder($this->reminder_template)->markSent()->save(); + $this->invoice->service()->markSent()->save(); $this->invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) { diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 879b759204fd..80f2676d2ab5 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -99,7 +99,6 @@ class ReminderJob implements ShouldQueue $query->where('is_disabled', 0); }) ->with('invitations')->chunk(50, function ($invoices) { - // if ($invoice->refresh() && $invoice->isPayable()) { foreach ($invoices as $invoice) { $this->sendReminderForInvoice($invoice); diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index c3c9ad8a10ba..ef38615696fc 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -56,8 +56,35 @@ class Helpers public function formatCustomFieldValue($custom_fields, $field, $value, $entity = null): ?string { $custom_field = ''; + $quote_or_credit_field = false; - if ($custom_fields && property_exists($custom_fields, $field)) { + if($custom_fields && stripos($field, 'quote') !== false && property_exists($custom_fields, $field)) { + $custom_field = $custom_fields->{$field}; + $custom_field_parts = explode('|', $custom_field); + + if (count($custom_field_parts) >= 2) { + $custom_field = $custom_field_parts[1]; + } + + $quote_or_credit_field = true; + + }elseif($custom_fields && stripos($field, 'credit') !== false && property_exists($custom_fields, $field)) { + $custom_field = $custom_fields->{$field}; + $custom_field_parts = explode('|', $custom_field); + + if (count($custom_field_parts) >= 2) { + $custom_field = $custom_field_parts[1]; + } + + $quote_or_credit_field = true; + + }elseif($custom_fields && stripos($field, 'credit') !== false) { + $field = str_replace("credit", "invoice", $field); + }elseif($custom_fields && stripos($field, 'quote') !== false) { + $field = str_replace("quote", "invoice", $field); + } + + if (!$quote_or_credit_field && $custom_fields && property_exists($custom_fields, $field)) { $custom_field = $custom_fields->{$field}; $custom_field_parts = explode('|', $custom_field); @@ -90,6 +117,17 @@ class Helpers */ public function makeCustomField($custom_fields, $field): string { + + if ($custom_fields && property_exists($custom_fields, $field)) { + $custom_field = $custom_fields->{$field}; + + $custom_field_parts = explode('|', $custom_field); + + return $custom_field_parts[0]; + } + + $field = str_replace(["quote","credit"], ["invoice","invoice"], $field); + if ($custom_fields && property_exists($custom_fields, $field)) { $custom_field = $custom_fields->{$field}; diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 7bc3c0acec9d..27451e68d1f6 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -222,10 +222,10 @@ class HtmlEngine $data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')]; $data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.quote_date')]; - $data['$quote.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')]; - $data['$quote.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')]; - $data['$quote.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice3')]; - $data['$quote.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')]; + $data['$quote.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'quote1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'quote1')]; + $data['$quote.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'quote2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'quote2')]; + $data['$quote.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'quote3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'quote3')]; + $data['$quote.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'quote4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'quote4')]; $data['$custom1'] = &$data['$quote.custom1']; $data['$custom2'] = &$data['$quote.custom2']; @@ -266,10 +266,10 @@ class HtmlEngine // $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')]; $data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.credit_date')]; - $data['$credit.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')]; - $data['$credit.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')]; - $data['$credit.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice3')]; - $data['$credit.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')]; + $data['$credit.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'credit1')]; + $data['$credit.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'credit2')]; + $data['$credit.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'credit3')]; + $data['$credit.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'credit4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'credit4')]; $data['$custom1'] = &$data['$credit.custom1']; $data['$custom2'] = &$data['$credit.custom2']; From 6a2600b7dcf6aa0667ebae68cd8d704a8188b9a3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 18:36:42 +1000 Subject: [PATCH 04/20] Fixes for protected download streams --- app/Http/Controllers/ProtectedDownloadController.php | 7 +------ app/Utils/Helpers.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ProtectedDownloadController.php b/app/Http/Controllers/ProtectedDownloadController.php index c4c38761b9ab..d7277d69f383 100644 --- a/app/Http/Controllers/ProtectedDownloadController.php +++ b/app/Http/Controllers/ProtectedDownloadController.php @@ -30,12 +30,7 @@ class ProtectedDownloadController extends BaseController abort(404, 'File no longer available'); } - UnlinkFile::dispatch(config('filesystems.default'), $hashed_path)->delay(now()->addSeconds(10)); - - return response()->streamDownload(function () use ($hashed_path) { - echo Storage::get($hashed_path); - }, basename($hashed_path), []); - + return response()->download($hashed_path, basename($hashed_path), [])->deleteFileAfterSend(true); } diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index ef38615696fc..6efc82126297 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -126,7 +126,7 @@ class Helpers return $custom_field_parts[0]; } - $field = str_replace(["quote","credit"], ["invoice","invoice"], $field); + $field = str_replace(["quote","credit"], ["invoice", "invoice"], $field); if ($custom_fields && property_exists($custom_fields, $field)) { $custom_field = $custom_fields->{$field}; From 97ce699879433dd69604f6c64dbef4b0516140ea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 22:52:03 +1000 Subject: [PATCH 05/20] Working on client portal --- app/Http/Livewire/PdfSlot.php | 75 ++++++++++++++++++- app/Services/Pdf/PdfBuilder.php | 15 +++- .../components/html-viewer.blade.php | 30 ++++++++ .../components/livewire/pdf-slot.blade.php | 2 +- 4 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 resources/views/portal/ninja2020/components/html-viewer.blade.php diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 9b52146a3412..6a4aae34799a 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -12,8 +12,14 @@ namespace App\Http\Livewire; -use App\Libraries\MultiDB; use Livewire\Component; +use App\Utils\HtmlEngine; +use App\Libraries\MultiDB; +use App\Utils\VendorHtmlEngine; +use App\Services\Pdf\PdfBuilder; +use App\Services\Pdf\PdfService; +use App\Services\Pdf\PdfDesigner; +use App\Services\Pdf\PdfConfiguration; class PdfSlot extends Component { @@ -44,6 +50,73 @@ class PdfSlot extends Component { $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + $pdf_service = new PdfService($this->invitation); + + + // $company_details = $pdf_service->config->settings->pdf_variables->company_details; + + + $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); + + + $pdf_service->html_variables = $pdf_service->config->client ? + (new HtmlEngine($this->invitation))->generateLabelsAndValues() : + (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); + + $pdf_service->designer = (new PdfDesigner($pdf_service)); + $pdf_service->designer->template = '
'; + + $pdf_service->builder = (new PdfBuilder($pdf_service)); + +$section = [ + 'company-details' => [ + 'id' => 'company-details', + 'elements' => $pdf_service->builder->companyDetails(), + ] +]; + + + +$document = new \DOMDocument(); +$document->validateOnParse = true; +@$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); +$pdf_service->builder->document = $document; + +$pdf_service->builder->sections = $section; + +$html = $pdf_service->builder + ->getEmptyElements() + ->updateElementProperties() + ->updateVariables(); + +nlog($html->getCompiledHTML()); + + + + + // nlog($section); + + // $document = new \DOMDocument(); + // @$document->loadHTML(mb_convert_encoding('
', 'HTML-ENTITIES', 'UTF-8')); + // $pdf_service->designer->template = ''; + // $pdf_service->builder->document = $document; + + // $pdf_service->builder + // ->sections = $section; + + // nlog($pdf_service->builder->sections); + + // $html = $pdf_service->builder + // ->getEmptyElements() + // ->updateElementProperties() + // ->updateVariables(); + + // nlog($html->getCompiledHTML()); + } + + public function getHtml() + { + } } diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 78d8d38fb2a9..0e55f97433f7 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -102,7 +102,12 @@ class PdfBuilder $this->document = $document; - // $this->xpath = new DOMXPath($document); + return $this; + } + + public function setDocument($document): self + { + $this->document = $document; return $this; } @@ -131,6 +136,13 @@ class PdfBuilder return $this; } + public function setSections($sections): self + { + $this->sections = $sections; + + return $this; + } + /** * Generates delivery note sections * @@ -1641,6 +1653,7 @@ class PdfBuilder public function updateVariables() { + $html = strtr($this->getCompiledHTML(), $this->service->html_variables['labels']); $html = strtr($html, $this->service->html_variables['values']); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php new file mode 100644 index 000000000000..2221732931fd --- /dev/null +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -0,0 +1,30 @@ +
+
+ @foreach($settings->pdf_variables->company_details as $variable) +

{{ $variable }}

+ @endforeach +
+ + +
+ @foreach($settings->pdf_variables->company_address as $variable) +

{{ $variable }}

+ @endforeach +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
\ No newline at end of file diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index 05b2ef44b044..bd8885707fe8 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -40,4 +40,4 @@ @endif - \ No newline at end of file + From 203e651b485a0d6f686971ffc98e43a34741148d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 23:01:12 +1000 Subject: [PATCH 06/20] Working on client portal --- app/Http/Livewire/PdfSlot.php | 77 +++++++++++++---------------------- 1 file changed, 29 insertions(+), 48 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 6a4aae34799a..029d7b088c3c 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -50,15 +50,17 @@ class PdfSlot extends Component { $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + + + } + + public function getHtml() + { + $pdf_service = new PdfService($this->invitation); - - - // $company_details = $pdf_service->config->settings->pdf_variables->company_details; - - + $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); - $pdf_service->html_variables = $pdf_service->config->client ? (new HtmlEngine($this->invitation))->generateLabelsAndValues() : (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); @@ -68,55 +70,34 @@ class PdfSlot extends Component $pdf_service->builder = (new PdfBuilder($pdf_service)); -$section = [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $pdf_service->builder->companyDetails(), - ] -]; + $section = [ + 'company-details' => [ + 'id' => 'company-details', + 'elements' => $pdf_service->builder->companyDetails(), + ] + ]; + $document = new \DOMDocument(); + $document->validateOnParse = true; + @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); + $pdf_service->builder->document = $document; -$document = new \DOMDocument(); -$document->validateOnParse = true; -@$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); -$pdf_service->builder->document = $document; + $pdf_service->builder->sections = $section; -$pdf_service->builder->sections = $section; + $html = $pdf_service->builder + ->getEmptyElements() + ->updateElementProperties() + ->updateVariables() + ->getCompiledHTML(); -$html = $pdf_service->builder - ->getEmptyElements() - ->updateElementProperties() - ->updateVariables(); + $doc = new \DOMDocument(); -nlog($html->getCompiledHTML()); - - - - - // nlog($section); - - // $document = new \DOMDocument(); - // @$document->loadHTML(mb_convert_encoding('
', 'HTML-ENTITIES', 'UTF-8')); - // $pdf_service->designer->template = ''; - // $pdf_service->builder->document = $document; - - // $pdf_service->builder - // ->sections = $section; - - // nlog($pdf_service->builder->sections); - - // $html = $pdf_service->builder - // ->getEmptyElements() - // ->updateElementProperties() - // ->updateVariables(); - - // nlog($html->getCompiledHTML()); - } - - public function getHtml() - { + $doc->loadHTML($html); + $doc->removeChild($doc->doctype); + $doc->replaceChild($doc->firstChild->firstChild->firstChild, $doc->firstChild); + nlog($doc->saveHTML()); } } From dfc67da3ef2228769b051cb8570b9e718e0afebf Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 10 Jul 2023 23:03:30 +1000 Subject: [PATCH 07/20] Working on client portal --- app/Http/Livewire/PdfSlot.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 029d7b088c3c..8942eb0d7596 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -82,22 +82,17 @@ class PdfSlot extends Component @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); $pdf_service->builder->document = $document; - $pdf_service->builder->sections = $section; $html = $pdf_service->builder ->getEmptyElements() ->updateElementProperties() - ->updateVariables() - ->getCompiledHTML(); + ->updateVariables(); - $doc = new \DOMDocument(); - - $doc->loadHTML($html); - $doc->removeChild($doc->doctype); - $doc->replaceChild($doc->firstChild->firstChild->firstChild, $doc->firstChild); - - nlog($doc->saveHTML()); + $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); + $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); + + nlog($pdf_service->builder->document->saveHTML()); } } From 8e12cfe4d5c53784ec1efe8151c94f055ff23855 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jul 2023 07:34:57 +1000 Subject: [PATCH 08/20] set requirement of array type on ids for bulk actions --- app/Http/Requests/Invoice/BulkInvoiceRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/Invoice/BulkInvoiceRequest.php b/app/Http/Requests/Invoice/BulkInvoiceRequest.php index 738a8f7bd762..68554d1ee71d 100644 --- a/app/Http/Requests/Invoice/BulkInvoiceRequest.php +++ b/app/Http/Requests/Invoice/BulkInvoiceRequest.php @@ -24,7 +24,7 @@ class BulkInvoiceRequest extends Request { return [ 'action' => 'required|string', - 'ids' => 'required', + 'ids' => 'required|array', 'email_type' => 'sometimes|in:reminder1,reminder2,reminder3,reminder_endless,custom1,custom2,custom3,invoice,quote,credit,payment,payment_partial,statement,purchase_order' ]; } From f37620300b4f15424e9120acf70179f09e48eca5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jul 2023 17:18:12 +1000 Subject: [PATCH 09/20] Working on client portal --- app/Http/Livewire/PdfSlot.php | 89 ++++++++++++++----- .../components/html-viewer.blade.php | 33 ++----- .../components/livewire/pdf-slot.blade.php | 1 + 3 files changed, 76 insertions(+), 47 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 8942eb0d7596..b13fd1a24a0c 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -43,18 +43,32 @@ class PdfSlot extends Component return render('components.livewire.pdf-slot', [ 'invitation' => $this->invitation, 'entity' => $this->entity, + 'data' => $this->invitation->company->settings ]); } public function getPdf() { - $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); } public function getHtml() + { + $pdf_service = new PdfService($this->invitation); + + $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); + + $pdf_service->html_variables = $pdf_service->config->client ? + (new HtmlEngine($this->invitation))->generateLabelsAndValues() : + (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); + + + } + + public function getHtmlX() { $pdf_service = new PdfService($this->invitation); @@ -66,33 +80,66 @@ class PdfSlot extends Component (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); $pdf_service->designer = (new PdfDesigner($pdf_service)); - $pdf_service->designer->template = '
'; $pdf_service->builder = (new PdfBuilder($pdf_service)); - $section = [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $pdf_service->builder->companyDetails(), - ] - ]; + $data = []; - $document = new \DOMDocument(); - $document->validateOnParse = true; - @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); + foreach(['company-details', 'company-address','client-details','entity-details','product-table','table-totals'] as $item) { - $pdf_service->builder->document = $document; - $pdf_service->builder->sections = $section; - $html = $pdf_service->builder - ->getEmptyElements() - ->updateElementProperties() - ->updateVariables(); + $pdf_service->designer->template = '
'; - $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); - $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); - - nlog($pdf_service->builder->document->saveHTML()); + match($item){ + 'company-details' => $block = $pdf_service->builder->companyDetails(), + 'company-address' => $block = $pdf_service->builder->companyAddress(), + 'client-details' => $block = $pdf_service->builder->clientDetails(), + 'entity-details' => $block = $pdf_service->builder->invoiceDetails(), + 'product-table' => $block = $this->productTable(), + 'table-totals' => $block = $pdf_service->builder->getTableTotals(), + default => $block = [], + }; + + $section = [ + $item => [ + 'id' => $item, + 'elements' => $block, + ] + ]; + + $document = new \DOMDocument(); + $document->validateOnParse = true; + @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); + + $pdf_service->builder->document = $document; + $pdf_service->builder->sections = $section; + + $html = $pdf_service->builder + ->getEmptyElements() + ->updateElementProperties() + ->updateVariables(); + + // $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); + // $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); + + $data[$item] = $pdf_service->builder->document->saveHTML(); + + $section = []; + } + // nlog($pdf_service->builder->document->saveHTML()); + + nlog($data); + + return $data; + } + + private function productTable() + { } + + private function sectionBuilder($tag) + { + + } } diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 2221732931fd..fad5cb38c549 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -1,30 +1,11 @@ +
+
-
- @foreach($settings->pdf_variables->company_details as $variable) -

{{ $variable }}

+
+ @foreach($data->pdf_variables->company_details as $cd) +
{{ $cd }}
@endforeach -
- - -
- @foreach($settings->pdf_variables->company_address as $variable) -

{{ $variable }}

- @endforeach -
- -
- -
- -
+ +
-
- -
- -
- -
- -
\ No newline at end of file diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index bd8885707fe8..d37fcd773640 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -41,3 +41,4 @@ @endif + @include('portal.ninja2020.components.html-viewer', ['data' => $data]) From 22bbbf26fb4b819c804085a092027553add8abd4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jul 2023 21:16:15 +1000 Subject: [PATCH 10/20] Working on html client portal --- .../ClientPortal/InvitationController.php | 3 + app/Http/Livewire/PdfSlot.php | 231 ++++++++++++------ .../components/html-viewer.blade.php | 185 +++++++++++++- .../components/livewire/pdf-slot.blade.php | 2 +- 4 files changed, 330 insertions(+), 91 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 25fea802d1f5..a1d4949f0175 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -136,8 +136,11 @@ class InvitationController extends Controller } else { $is_silent = 'true'; + return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key}), 'silent' => $is_silent]); + return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key}), 'silent' => $is_silent])->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); } + return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]); return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})])->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); } diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index b13fd1a24a0c..788e0048b3c4 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -12,14 +12,20 @@ namespace App\Http\Livewire; +use App\Utils\Number; use Livewire\Component; use App\Utils\HtmlEngine; use App\Libraries\MultiDB; +use App\Models\QuoteInvitation; use App\Utils\VendorHtmlEngine; +use App\Models\CreditInvitation; use App\Services\Pdf\PdfBuilder; use App\Services\Pdf\PdfService; +use App\Models\InvoiceInvitation; use App\Services\Pdf\PdfDesigner; use App\Services\Pdf\PdfConfiguration; +use App\Models\PurchaseOrderInvitation; +use App\Models\RecurringInvoiceInvitation; class PdfSlot extends Component { @@ -33,113 +39,178 @@ class PdfSlot extends Component public $url; + private $settings; + + private $html_variables; + + private $entity_type; + public function mount() { MultiDB::setDb($this->db); } + public function getPdf() + { + // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + } + public function render() { + $this->entity_type = $this->resolveEntityType(); + + $this->settings = $this->entity->client ? $this->entity->client->getMergedSettings() : $this->entity->company->settings; + + $this->html_variables = $this->entity->client ? + (new HtmlEngine($this->invitation))->generateLabelsAndValues() : + (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); + return render('components.livewire.pdf-slot', [ 'invitation' => $this->invitation, 'entity' => $this->entity, - 'data' => $this->invitation->company->settings + 'data' => $this->invitation->company->settings, + 'entity_type' => $this->entity_type, + 'products' => $this->getProducts(), + 'services' => $this->getServices(), + 'amount' => Number::formatMoney($this->entity->amount, $this->entity->client ?: $this->entity->vendor), + 'balance' => Number::formatMoney($this->entity->balance, $this->entity->client ?: $this->entity->vendor), + 'company_details' => $this->getCompanyDetails(), + 'company_address' => $this->getCompanyAddress(), + 'entity_details' => $this->getEntityDetails(), + 'user_details' => $this->getUserDetails(), + ]); } - public function getPdf() + private function convertVariables($string): string { - - // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + $html = strtr($string, $this->html_variables['labels']); + + $html = strtr($html, $this->html_variables['values']); + + return $html; } - public function getHtml() + private function getCompanyAddress() { - $pdf_service = new PdfService($this->invitation); - - $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); - - $pdf_service->html_variables = $pdf_service->config->client ? - (new HtmlEngine($this->invitation))->generateLabelsAndValues() : - (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); - - } + $company_address = ""; - public function getHtmlX() - { - - $pdf_service = new PdfService($this->invitation); - - $pdf_service->config = (new PdfConfiguration($pdf_service))->init(); - - $pdf_service->html_variables = $pdf_service->config->client ? - (new HtmlEngine($this->invitation))->generateLabelsAndValues() : - (new VendorHtmlEngine($this->invitation))->generateLabelsAndValues(); - - $pdf_service->designer = (new PdfDesigner($pdf_service)); - - $pdf_service->builder = (new PdfBuilder($pdf_service)); - - $data = []; - - foreach(['company-details', 'company-address','client-details','entity-details','product-table','table-totals'] as $item) { - - - $pdf_service->designer->template = '
'; - - match($item){ - 'company-details' => $block = $pdf_service->builder->companyDetails(), - 'company-address' => $block = $pdf_service->builder->companyAddress(), - 'client-details' => $block = $pdf_service->builder->clientDetails(), - 'entity-details' => $block = $pdf_service->builder->invoiceDetails(), - 'product-table' => $block = $this->productTable(), - 'table-totals' => $block = $pdf_service->builder->getTableTotals(), - default => $block = [], - }; - - $section = [ - $item => [ - 'id' => $item, - 'elements' => $block, - ] - ]; - - $document = new \DOMDocument(); - $document->validateOnParse = true; - @$document->loadHTML(mb_convert_encoding($pdf_service->designer->template, 'HTML-ENTITIES', 'UTF-8')); - - $pdf_service->builder->document = $document; - $pdf_service->builder->sections = $section; - - $html = $pdf_service->builder - ->getEmptyElements() - ->updateElementProperties() - ->updateVariables(); - - // $pdf_service->builder->document->removeChild($pdf_service->builder->document->doctype); - // $pdf_service->builder->document->replaceChild($pdf_service->builder->document->firstChild->firstChild->firstChild, $pdf_service->builder->document->firstChild); - - $data[$item] = $pdf_service->builder->document->saveHTML(); - - $section = []; + foreach($this->settings->pdf_variables->company_address as $variable) { + $company_address .= "

{$variable}

"; } - // nlog($pdf_service->builder->document->saveHTML()); - nlog($data); - - return $data; - } - - private function productTable() - { + return $this->convertVariables($company_address); } - private function sectionBuilder($tag) + private function getCompanyDetails() { + $company_details = ""; + + foreach($this->settings->pdf_variables->company_details as $variable) { + $company_details .= "

{$variable}

"; + } + + return $this->convertVariables($company_details); + + } + + private function getEntityDetails() + { + $entity_details = "
"; + + if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { + foreach($this->settings->pdf_variables->invoice_details as $variable) + $entity_details .= "
{$variable}_label
{$variable}
"; + + } + elseif($this->entity_type == 'quote'){ + foreach($this->settings->pdf_variables->quote_details as $variable) + $entity_details .= "
{$variable}_label
{$variable}
"; + } + elseif($this->entity_type == 'credit') { + foreach($this->settings->pdf_variables->credit_details as $variable) + $entity_details .= "
{$variable}_label
{$variable}
"; + } + elseif($this->entity_type == 'purchase_order'){ + foreach($this->settings->pdf_variables->purchase_order_details as $variable) + $entity_details .= "
{$variable}_label
{$variable}
"; + } + + $entity_details .= "
"; + + return $this->convertVariables($entity_details); + + } + + private function getUserDetails() + { + $user_details = ""; + + if($this->entity_type == 'purchase_order') { + foreach($this->settings->pdf_variables->vendor_details as $variable) { + $user_details .= "

{$variable}

"; + } + } + else{ + foreach($this->settings->pdf_variables->client_details as $variable) { + $user_details .= "

{$variable}

"; + } + } + return $this->convertVariables($user_details); + } + + private function getProducts() + { + $product_items = collect($this->entity->line_items)->filter(function ($item) { + return $item->type_id == 1 || $item->type_id == 6 || $item->type_id == 5; + })->map(function ($item){ + return [ + 'quantity' => $item->quantity, + 'cost' => Number::formatMoney($item->cost, $this->entity->client ?: $this->entity->vendor), + 'notes' => $item->notes, + 'line_total' => Number::formatMoney($item->line_total, $this->entity->client ?: $this->entity->vendor), + ]; + }); + + return $product_items; + } + + private function getServices() + { + $task_items = collect($this->entity->line_items)->filter(function ($item) { + return $item->type_id == 2; + })->map(function ($item){ + return [ + 'quantity' => $item->quantity, + 'cost' => Number::formatMoney($item->cost, $this->entity->client ?: $this->entity->vendor), + 'notes' => $item->notes, + 'line_total' => Number::formatMoney($item->line_total, $this->entity->client ?: $this->entity->vendor), + ]; + }); + + return $task_items; + + } + + private function resolveEntityType() :string + { + if ($this->invitation instanceof InvoiceInvitation) { + return 'invoice'; + } elseif ($this->invitation instanceof QuoteInvitation) { + return 'quote'; + } elseif ($this->invitation instanceof CreditInvitation) { + return 'credit'; + } elseif ($this->invitation instanceof RecurringInvoiceInvitation) { + return 'recurring_invoice'; + } elseif ($this->invitation instanceof PurchaseOrderInvitation) { + return 'purchase_order'; + } + + return ''; } } diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index fad5cb38c549..182e169966d0 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -1,11 +1,176 @@ -
-
-
- @foreach($data->pdf_variables->company_details as $cd) -
{{ $cd }}
- @endforeach -
-
- -
\ No newline at end of file + +
+
+
+ {!! $company_details !!} +
+ +
+ {!! $company_address !!} +
+
+ +
{!! $entity_details !!}
+ +
+ {!! $user_details !!} +
+ + @if($products->count() > 0) +
+ + + + + + + + + @foreach($products as $product) + + + + + @endforeach + +
ItemAmount
+
+
+

{{ $product['quantity'] }} × {{ $product['cost'] }}

+

{{ $product['notes'] }}

+
+
+
{{ $product['line_total'] }}
+
+ @endif + @if($services->count() > 0) +
+ + + Service + + + + + @foreach($services as $service) + + + + + @endforeach + +
Amount
+
+
+

{{ $service['quantity'] }} × {{ $service['cost'] }}

+

{{ $service['notes'] }}

+
+
+
{{ $service['line_total'] }}
+
+ @endif +
+ + + + + + + + + + + + + +
+
+
+

{{ ctrans('texts.total') }}

+
+
+
{{ $amount }}
+
+
+

{{ ctrans('texts.balance') }}

+
+
+
{{ $balance }}
+ +
+ + @if(strlen($entity->public_notes) > 3) +
+ + + +
+ {{ $entity->public_notes }} +
+ +
+ @endif + + @if(strlen($entity->terms) > 3) +
+ + + +
+ {{ $entity->terms }} +
+ +
+ @endif + + @if(strlen($entity->footer) > 3) +
+ + + +
+ {{ $entity->footer }} +
+ + +
+ @endif + diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index d37fcd773640..629979df06ea 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -41,4 +41,4 @@
@endif - @include('portal.ninja2020.components.html-viewer', ['data' => $data]) + @include('portal.ninja2020.components.html-viewer') From b8998f1d9415f8ec628eb5334436d2c1a02c30b4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jul 2023 21:19:55 +1000 Subject: [PATCH 11/20] Working on html client portal --- app/Http/Livewire/PdfSlot.php | 8 ++++---- .../portal/ninja2020/components/html-viewer.blade.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 788e0048b3c4..40a2ae4268b9 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -124,20 +124,20 @@ class PdfSlot extends Component if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } $entity_details .= ""; diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 182e169966d0..b91e6c7c0ffb 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -28,7 +28,7 @@ span {
-
+
{!! $company_details !!}
@@ -38,9 +38,9 @@ span {
-
{!! $entity_details !!}
+
{!! $entity_details !!}
-
+
{!! $user_details !!}
From f009f081711585c2ccbb34737293b2b66ffe7df3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 09:04:27 +1000 Subject: [PATCH 12/20] Handle edge case when deleting/restoring invoices --- app/Services/Invoice/HandleRestore.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index 18502189f485..4dc9621f4acf 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -44,6 +44,7 @@ class HandleRestore extends AbstractService //cannot restore an invoice with a deleted payment foreach ($this->invoice->payments as $payment) { if (($this->invoice->paid_to_date == 0) && $payment->is_deleted) { + $this->invoice->delete(); //set it back to deleted so that it can be restored from repository return $this->invoice; } } From 3a4ee0a00cd36e0589f90a71365977c0e98b9419 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 10:24:19 +1000 Subject: [PATCH 13/20] Minor cleanup --- app/Export/CSV/BaseExport.php | 1 + app/Http/Controllers/WebCronController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 2d4d2a5a82a3..d9731c49b680 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -318,6 +318,7 @@ class BaseExport private function resolvePaymentKey($column, $entity, $transformer) { + if($entity instanceof Payment){ $transformed_payment = $transformer->transform($entity); diff --git a/app/Http/Controllers/WebCronController.php b/app/Http/Controllers/WebCronController.php index 81e1633606df..c9607ba4fdec 100644 --- a/app/Http/Controllers/WebCronController.php +++ b/app/Http/Controllers/WebCronController.php @@ -26,7 +26,7 @@ class WebCronController extends Controller * @return Response * * @OA\Get( - * path="/api/v1/webcron", + * path="/webcron", * operationId="webcron", * tags={"webcron"}, * summary="Executes the task scheduler via a webcron service", From 8ebef188b4c22802ad74e08517550f2f2a8de1ae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 10:44:19 +1000 Subject: [PATCH 14/20] Client portal --- app/Http/Livewire/PdfSlot.php | 10 ++--- .../components/html-viewer.blade.php | 40 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 40a2ae4268b9..ce951f497223 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -120,24 +120,24 @@ class PdfSlot extends Component private function getEntityDetails() { - $entity_details = "
"; + $entity_details = "
"; if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "
{$variable}_label
{$variable}
"; } $entity_details .= "
"; diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index b91e6c7c0ffb..1be4224c2ba9 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -1,7 +1,6 @@ -
+
{!! $company_details !!} @@ -38,14 +37,17 @@ span {
-
{!! $entity_details !!}
+
-
+
{!! $entity_details !!}
+ +
{!! $user_details !!}
+
@if($products->count() > 0) -
+
@@ -72,7 +74,7 @@ span { @endif @if($services->count() > 0) -
+
+
@@ -129,45 +131,45 @@ span { @if(strlen($entity->public_notes) > 3) -
+
-
- {{ $entity->public_notes }} + {{ strip_tags($entity->public_notes) }}
@endif @if(strlen($entity->terms) > 3) -
+
- {{ $entity->terms }} + {{ strip_tags($entity->terms) }}
@endif @if(strlen($entity->footer) > 3) -
+
- {{ $entity->footer }} + {{ strip_tags($entity->footer) }}
From c33ced1d82e6433e9ed7e0d5f01b63f0c79681aa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 12:50:57 +1000 Subject: [PATCH 15/20] Client portal --- app/Http/Livewire/PdfSlot.php | 30 +++++--- .../components/html-viewer.blade.php | 74 ++++++++++++------- 2 files changed, 67 insertions(+), 37 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index ce951f497223..9be66121824a 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -78,6 +78,7 @@ class PdfSlot extends Component 'company_address' => $this->getCompanyAddress(), 'entity_details' => $this->getEntityDetails(), 'user_details' => $this->getUserDetails(), + 'user_name' => $this->getUserName(), ]); } @@ -120,43 +121,54 @@ class PdfSlot extends Component private function getEntityDetails() { - $entity_details = "
"; + $entity_details = ""; if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "
{$variable}_label
{$variable}
"; + $entity_details .= "

{$variable}_label

{$variable}

"; } - $entity_details .= "
"; - return $this->convertVariables($entity_details); } + private function getUserName() + { + if($this->entity_type == 'purchase_order') { + $name = $this->settings->pdf_variables->vendor_details[0]; + + } else { + $name = $this->settings->pdf_variables->client_details[0]; + } + + return $this->convertVariables($name); + + } + private function getUserDetails() { $user_details = ""; if($this->entity_type == 'purchase_order') { - foreach($this->settings->pdf_variables->vendor_details as $variable) { + foreach(array_slice($this->settings->pdf_variables->vendor_details,1) as $variable) { $user_details .= "

{$variable}

"; } } else{ - foreach($this->settings->pdf_variables->client_details as $variable) { + foreach(array_slice($this->settings->pdf_variables->client_details,1) as $variable) { $user_details .= "

{$variable}

"; } } diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 1be4224c2ba9..58fbdc575226 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -2,7 +2,7 @@ -
-
+
+ +
+
{!! $company_details !!}
-
+ + +
+ +
+ +
{!! $entity_details !!}
+ +
+ + +
+ +
+ + + +
+ {!! $user_details !!} +
+ +
-
- -
- -
{!! $entity_details !!}
- -
- {!! $user_details !!} -
+
@if($products->count() > 0) -
+
- + @foreach($products as $product) - + @@ -93,10 +89,10 @@ span { @endif @if($services->count() > 0) -
+
Item Amount
@@ -74,7 +93,7 @@ span {
@endif @if($services->count() > 0) -
+
+
@@ -109,21 +128,21 @@ span { - + - +
-

{{ ctrans('texts.total') }}

+

{{ ctrans('texts.total') }}

{{ $amount }}{{ $amount }}
-

{{ ctrans('texts.balance') }}

+

{{ ctrans('texts.balance') }}

{{ $balance }}{{ $balance }}
@@ -131,9 +150,9 @@ span {
@if(strlen($entity->public_notes) > 3) -
+
- @@ -146,7 +165,7 @@ span { @endif @if(strlen($entity->terms) > 3) -
+
- @endif - + @endif \ No newline at end of file From bff7e056ba0e1b34db6b71a1c0b6550105f73f48 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 14:06:32 +1000 Subject: [PATCH 16/20] Working on show/hide for screen sizes --- app/Http/Livewire/PdfSlot.php | 17 ++-- .../components/html-viewer.blade.php | 24 ++--- .../components/livewire/pdf-slot.blade.php | 93 ++++++++++--------- 3 files changed, 70 insertions(+), 64 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 9be66121824a..1baee4a081df 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -52,7 +52,7 @@ class PdfSlot extends Component public function getPdf() { - // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); + $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); } public function render() @@ -125,20 +125,20 @@ class PdfSlot extends Component if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } return $this->convertVariables($entity_details); @@ -147,10 +147,13 @@ class PdfSlot extends Component private function getUserName() { - if($this->entity_type == 'purchase_order') { + $name = ctrans('texts.details'); + + if($this->entity_type == 'purchase_order' && isset($this->settings->pdf_variables->vendor_details[0])) { $name = $this->settings->pdf_variables->vendor_details[0]; - } else { + } elseif(isset($this->settings->pdf_variables->client_details[0])) { + $name = $this->settings->pdf_variables->client_details[0]; } diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 58fbdc575226..1f08f1d535e5 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -34,10 +34,6 @@ span { {!! $company_details !!}
- -
@@ -47,7 +43,7 @@ span {
-
+
@@ -80,8 +76,8 @@ span {
-

{{ $product['quantity'] }} × {{ $product['cost'] }}

-

{{ $product['notes'] }}

+

{{ $product['quantity'] }} × {{ $product['cost'] }}

+

{{ $product['notes'] }}

- @@ -107,8 +103,8 @@ span { @@ -119,7 +115,7 @@ span {
Service Amount
-

{{ $service['quantity'] }} × {{ $service['cost'] }}

-

{{ $service['notes'] }}

+

{{ $service['quantity'] }} × {{ $service['cost'] }}

+

{{ $service['notes'] }}

@endif -
+
@@ -132,7 +128,7 @@ span { - + - +
{{ $amount }}{{ $amount }}
@@ -142,7 +138,7 @@ span { {{ $balance }}{{ $balance }}
diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index 629979df06ea..080ac4a2352f 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -1,44 +1,51 @@ -
- @if($pdf) - - @else -
- - -
- @endif +
+ - @include('portal.ninja2020.components.html-viewer') + + +
\ No newline at end of file From c331c5384a527f71bb3c6ec45b626ad6a843ad76 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 14:06:50 +1000 Subject: [PATCH 17/20] encode payment id --- app/Transformers/AccountTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 6d433715c40a..3581ba530ada 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -61,7 +61,7 @@ class AccountTransformer extends EntityTransformer 'plan_paid' => (string) $account->plan_paid, 'plan_expires' => (string) $account->plan_expires, 'user_agent' => (string) $account->user_agent, - 'payment_id' => (string) $account->payment_id, + 'payment_id' => (string) $this->encodePrimaryKey($account->payment_id), 'trial_started' => (string) $account->trial_started, 'trial_plan' => (string) $account->trial_plan, 'plan_price' => (float) $account->plan_price, From 8812286ccb1fddacd6f2bcd380462f6befcd1eca Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 14:55:48 +1000 Subject: [PATCH 18/20] Updates for html cp --- .../ClientPortal/InvoiceController.php | 2 -- app/Http/Livewire/PdfSlot.php | 23 ++++++++++++++++ .../components/html-viewer.blade.php | 1 + .../components/livewire/pdf-slot.blade.php | 14 +++++++++- .../ninja2020/components/pdf-viewer.blade.php | 26 ------------------- 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 838bf1dd1b09..8a0013c6d8f9 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -206,8 +206,6 @@ class InvoiceController extends Controller $file = $invoice->service()->getInvoicePdf(auth()->guard('contact')->user()); - // return response()->download(file_get_contents(public_path($file))); - return response()->streamDownload(function () use ($file) { echo Storage::get($file); }, basename($file), ['Content-Type' => 'application/pdf']); diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 1baee4a081df..65783bb506e5 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -45,9 +45,13 @@ class PdfSlot extends Component private $entity_type; + public $download_button_text; + public function mount() { MultiDB::setDb($this->db); + + $this->download_button_text = ctrans('texts.download_pdf'); } public function getPdf() @@ -55,6 +59,25 @@ class PdfSlot extends Component $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); } + public function downloadPdf() + { + + $this->download_button_text = ctrans('texts.working'); + + $file_name = $this->entity->numberFormatter().'.pdf'; + + $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); + + $headers = ['Content-Type' => 'application/pdf']; + + return response()->streamDownload(function () use ($file) { + echo $file; + }, $file_name, $headers); + + $this->download_button_text = ctrans('texts.download_pdf'); + + } + public function render() { $this->entity_type = $this->resolveEntityType(); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 1f08f1d535e5..94b20c8d0dbb 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -26,6 +26,7 @@ span { } +
diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index 080ac4a2352f..553b96d9bf8c 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -1,4 +1,16 @@
+
+ +
- \ No newline at end of file diff --git a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php index bcf438c8de24..75008ab7e424 100644 --- a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php @@ -53,32 +53,6 @@
-
-
- -
- -
From c239a77dd49293b711ee0f5e66ad3506f0ac3eed Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 16:57:03 +1000 Subject: [PATCH 19/20] Improvements for html presentation of invoice in client portal --- app/Http/Livewire/PdfSlot.php | 23 +++--- .../components/html-viewer.blade.php | 73 ++++++++++++++----- 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 65783bb506e5..8eda7b1c4ded 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -26,6 +26,7 @@ use App\Services\Pdf\PdfDesigner; use App\Services\Pdf\PdfConfiguration; use App\Models\PurchaseOrderInvitation; use App\Models\RecurringInvoiceInvitation; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; class PdfSlot extends Component { @@ -45,13 +46,11 @@ class PdfSlot extends Component private $entity_type; - public $download_button_text; + protected $listeners = ['viewportChanged' => 'getPdf']; public function mount() { MultiDB::setDb($this->db); - - $this->download_button_text = ctrans('texts.download_pdf'); } public function getPdf() @@ -62,11 +61,12 @@ class PdfSlot extends Component public function downloadPdf() { - $this->download_button_text = ctrans('texts.working'); - $file_name = $this->entity->numberFormatter().'.pdf'; - $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); + if($this->entity instanceof \App\Models\PurchaseOrder) + $file = (new CreatePurchaseOrderPdf($this->invitation, $this->invitation->company->db))->rawPdf(); + else + $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle(); $headers = ['Content-Type' => 'application/pdf']; @@ -74,8 +74,6 @@ class PdfSlot extends Component echo $file; }, $file_name, $headers); - $this->download_button_text = ctrans('texts.download_pdf'); - } public function render() @@ -110,7 +108,6 @@ class PdfSlot extends Component { $html = strtr($string, $this->html_variables['labels']); - $html = strtr($html, $this->html_variables['values']); return $html; @@ -148,20 +145,20 @@ class PdfSlot extends Component if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { foreach($this->settings->pdf_variables->invoice_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'quote'){ foreach($this->settings->pdf_variables->quote_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'credit') { foreach($this->settings->pdf_variables->credit_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } elseif($this->entity_type == 'purchase_order'){ foreach($this->settings->pdf_variables->purchase_order_details as $variable) - $entity_details .= "

{$variable}_label

{$variable}

"; + $entity_details .= "

{$variable}_label

{$variable}

"; } return $this->convertVariables($entity_details); diff --git a/resources/views/portal/ninja2020/components/html-viewer.blade.php b/resources/views/portal/ninja2020/components/html-viewer.blade.php index 94b20c8d0dbb..8b27738e3a54 100644 --- a/resources/views/portal/ninja2020/components/html-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/html-viewer.blade.php @@ -39,7 +39,7 @@ span {
-
{!! $entity_details !!}
+
{!! $entity_details !!}
@@ -118,27 +118,13 @@ span { @endif
- - - - + + - - + + @@ -190,4 +176,51 @@ span { - @endif \ No newline at end of file + @endif + + From ce21a5e9d6c1d96208182c62c92d67112885c147 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 12 Jul 2023 16:58:01 +1000 Subject: [PATCH 20/20] v5.6.18 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 2ea33cb9e706..6f75c330fa4c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.6.17 \ No newline at end of file +5.6.18 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index bf14dd03b055..ec48c4dfa316 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,8 +15,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION','5.6.17'), - 'app_tag' => env('APP_TAG','5.6.17'), + 'app_version' => env('APP_VERSION','5.6.18'), + 'app_tag' => env('APP_TAG','5.6.18'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),
-
-
-

{{ ctrans('texts.total') }}

-
-
-
{{ ctrans('texts.total') }} {{ $amount }}
-
-
-

{{ ctrans('texts.balance') }}

-
-
-
{{ ctrans('texts.balance') }} {{ $balance }}