1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Refactor Phantom JS building HTML

This commit is contained in:
David Bomba 2020-10-27 14:09:13 +11:00
parent 3bef11c87e
commit 1de7a693cc
3 changed files with 14 additions and 8 deletions

View File

@ -75,7 +75,6 @@ class EmailBuilder
*/ */
public function setSubject($subject) public function setSubject($subject)
{ {
//$this->subject = $this->parseTemplate($subject, false, $this->contact);
if (! empty($this->variables)) { if (! empty($this->variables)) {
$subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject); $subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject);

View File

@ -70,7 +70,8 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
* @return void * @return void
*/ */
public function handle() public function handle()
{info("invoice email"); {
MultiDB::setDB($this->company->db); MultiDB::setDB($this->company->db);
$this->setMailDriver(); $this->setMailDriver();

View File

@ -37,10 +37,13 @@ class Phantom
if ($invitation instanceof InvoiceInvitation) { if ($invitation instanceof InvoiceInvitation) {
$entity = 'invoice'; $entity = 'invoice';
$entity_design_id = 'invoice_design_id';
} elseif ($invitation instanceof CreditInvitation) { } elseif ($invitation instanceof CreditInvitation) {
$entity = 'credit'; $entity = 'credit';
$entity_design_id = 'credit_design_id';
} elseif ($invitation instanceof QuoteInvitation) { } elseif ($invitation instanceof QuoteInvitation) {
$entity = 'quote'; $entity = 'quote';
$entity_design_id = 'quote_design_id';
} }
$entity_obj = $invitation->{$entity}; $entity_obj = $invitation->{$entity};
@ -81,6 +84,7 @@ class Phantom
$invitation_instance = 'App\Models\\'.ucfirst($entity).'Invitation'; $invitation_instance = 'App\Models\\'.ucfirst($entity).'Invitation';
$invitation = $invitation_instance::whereRaw('BINARY `key`= ?', [$invitation_key])->first(); $invitation = $invitation_instance::whereRaw('BINARY `key`= ?', [$invitation_key])->first();
$entity_obj = $invitation->{$entity}; $entity_obj = $invitation->{$entity};
@ -88,13 +92,15 @@ class Phantom
App::setLocale($invitation->contact->preferredLocale()); App::setLocale($invitation->contact->preferredLocale());
$design_id = $entity_obj->design_id ? $entity_obj->design_id : $this->decodePrimaryKey($entity_obj->client->getSetting($entity.'_design_id')); // $design_id = $entity_obj->design_id ? $entity_obj->design_id : $this->decodePrimaryKey($entity_obj->client->getSetting($entity_design_id));
// $design = Design::find($design_id);
// $designer = new Designer($entity_obj, $design, $entity_obj->client->getSetting('pdf_variables'), $entity);
// $data['html'] = (new HtmlEngine($designer, $invitation, $entity))->build();
$design = Design::find($design_id); $entity_design_id = $entity . '_design_id';
$entity_design_id = $entity_obj->design_id ? $entity_obj->design_id : $this->decodePrimaryKey($entity_obj->client->getSetting($entity_design_id));
$designer = new Designer($entity_obj, $design, $entity_obj->client->getSetting('pdf_variables'), $entity); $design = Design::find($entity_design_id);
$data['html'] = new HtmlEngine(null, $invitation, $entity);
$data['html'] = (new HtmlEngine($designer, $invitation, $entity))->build();
return view('pdf.html', $data); return view('pdf.html', $data);
} }