diff --git a/app/Designs/Designer.php b/app/Designs/Designer.php
index 70feff34a6..f54986bbde 100644
--- a/app/Designs/Designer.php
+++ b/app/Designs/Designer.php
@@ -107,7 +107,7 @@ class Designer
'
;
- $signature = '
'; /** @wip */
+ $signature = '
';
$logo = '';
if (!$this->entity->user->account->isPaid()) {
diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php
index c5e261518f..ae856a240f 100644
--- a/app/Http/Controllers/ClientPortal/PaymentController.php
+++ b/app/Http/Controllers/ClientPortal/PaymentController.php
@@ -14,6 +14,7 @@ namespace App\Http\Controllers\ClientPortal;
use App\Filters\PaymentFilters;
use App\Http\Controllers\Controller;
+use App\Jobs\Invoice\InjectSignature;
use App\Models\CompanyGateway;
use App\Models\Invoice;
use App\Models\Payment;
@@ -71,8 +72,6 @@ class PaymentController extends Controller
*/
public function process()
{
- // $signature = request()->signature // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADICA..
-
$invoices = Invoice::whereIn('id', $this->transformKeys(request()->invoices))
->where('company_id', auth('contact')->user()->company->id)
->get();
@@ -92,9 +91,14 @@ class PaymentController extends Controller
$invoices->map(function ($invoice) {
$invoice->balance = Number::formatMoney($invoice->balance, $invoice->client);
$invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format());
+
return $invoice;
});
+ $invoices->each(function ($invoice) {
+ InjectSignature::dispatch($invoice, request()->signature);
+ });
+
$payment_methods = auth()->user()->client->getPaymentMethods($amount);
$gateway = CompanyGateway::find(request()->input('company_gateway_id'));
@@ -112,7 +116,6 @@ class PaymentController extends Controller
'hashed_ids' => request()->invoices,
];
-
return $gateway->driver(auth()->user()->client)->processPaymentView($data);
}
diff --git a/app/Jobs/Invoice/InjectSignature.php b/app/Jobs/Invoice/InjectSignature.php
new file mode 100644
index 0000000000..5e2f763642
--- /dev/null
+++ b/app/Jobs/Invoice/InjectSignature.php
@@ -0,0 +1,56 @@
+invoice = $invoice;
+
+ $this->signature = $signature;
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ $invitation = $this->invoice->invitations->whereNotNull('signature_base64')->first();
+
+ if (!$invitation) {
+ return;
+ }
+
+ $invitation->signature_base64 = $this->signature;
+ $invitation->save();
+
+ CreateInvoicePdf::dispatch($invitation);
+ }
+}
diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 7b43cb9732..337c170d45 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -301,7 +301,7 @@ class HtmlEngine
$data['$task.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$task.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$task.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
- //$data['$contact.signature']
+ $data['$contact.signature'] = ['value' => $this->invitation->signature_base64, 'label' => ctrans('texts.signature')];
// $data['custom_label1'] = ['value' => '', 'label' => ctrans('texts.')];
// $data['custom_label2'] = ['value' => '', 'label' => ctrans('texts.')];
diff --git a/resources/views/portal/ninja2020/invoices/includes/signature.blade.php b/resources/views/portal/ninja2020/invoices/includes/signature.blade.php
index 3da52cec87..a1a84a4166 100644
--- a/resources/views/portal/ninja2020/invoices/includes/signature.blade.php
+++ b/resources/views/portal/ninja2020/invoices/includes/signature.blade.php
@@ -27,7 +27,7 @@