mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for sending custom templates with purchase orders
This commit is contained in:
parent
26577d6aef
commit
6015bb36dd
@ -131,8 +131,10 @@ class EmailController extends BaseController
|
||||
if(Ninja::isHosted() && !$entity_obj->company->account->account_sms_verified)
|
||||
return response(['message' => 'Please verify your account to send emails.'], 400);
|
||||
|
||||
if($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order'){
|
||||
return $this->sendPurchaseOrder($entity_obj, $data);
|
||||
nlog($entity);
|
||||
|
||||
if($entity == 'purchaseOrder' || $entity == 'purchase_order' || $template == 'purchase_order' || $entity == 'App\Models\PurchaseOrder'){
|
||||
return $this->sendPurchaseOrder($entity_obj, $data, $template);
|
||||
}
|
||||
|
||||
$entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) {
|
||||
@ -183,13 +185,15 @@ class EmailController extends BaseController
|
||||
return $this->itemResponse($entity_obj->fresh());
|
||||
}
|
||||
|
||||
private function sendPurchaseOrder($entity_obj, $data)
|
||||
private function sendPurchaseOrder($entity_obj, $data, $template)
|
||||
{
|
||||
|
||||
$this->entity_type = PurchaseOrder::class;
|
||||
|
||||
$this->entity_transformer = PurchaseOrderTransformer::class;
|
||||
|
||||
$data['template'] = $template;
|
||||
|
||||
PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data);
|
||||
|
||||
return $this->itemResponse($entity_obj);
|
||||
|
@ -78,15 +78,11 @@ class EmailEntity implements ShouldQueue
|
||||
|
||||
$this->invitation = $invitation;
|
||||
|
||||
|
||||
$this->entity_string = $this->resolveEntityString();
|
||||
|
||||
$this->entity = $invitation->{$this->entity_string};
|
||||
|
||||
if($this->entity_string == 'purchase_order')
|
||||
$this->settings = $this->company->settings;
|
||||
else
|
||||
$this->settings = $invitation->contact->client->getMergedSettings();
|
||||
$this->settings = $invitation->contact->client->getMergedSettings();
|
||||
|
||||
$this->reminder_template = $reminder_template ?: $this->entity->calculateTemplate($this->entity_string);
|
||||
|
||||
@ -144,8 +140,6 @@ class EmailEntity implements ShouldQueue
|
||||
return 'credit';
|
||||
} elseif ($this->invitation instanceof RecurringInvoiceInvitation) {
|
||||
return 'recurring_invoice';
|
||||
} elseif($this->invitation instanceof PurchaseOrderInvitation) {
|
||||
return 'purchase_order';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,12 @@ class PurchaseOrderEmail implements ShouldQueue
|
||||
/* Mark entity sent */
|
||||
$invitation->purchase_order->service()->markSent()->save();
|
||||
|
||||
$email_builder = (new PurchaseOrderEmailEngine($invitation, 'purchase_order', $this->template_data))->build();
|
||||
if(is_array($this->template_data) && array_key_exists('template', $this->template_data))
|
||||
$template = $this->template_data['template'];
|
||||
else
|
||||
$template = 'purchase_order';
|
||||
|
||||
$email_builder = (new PurchaseOrderEmailEngine($invitation, $template, $this->template_data))->build();
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new VendorTemplateEmail($email_builder, $invitation->contact, $invitation);
|
||||
@ -86,7 +91,7 @@ class PurchaseOrderEmail implements ShouldQueue
|
||||
$nmo->to_user = $invitation->contact;
|
||||
$nmo->entity_string = 'purchase_order';
|
||||
$nmo->invitation = $invitation;
|
||||
$nmo->reminder_template = 'purchase_order';
|
||||
$nmo->reminder_template = 'email_template_purchase_order';
|
||||
$nmo->entity = $invitation->purchase_order;
|
||||
|
||||
NinjaMailerJob::dispatch($nmo)->delay(5);
|
||||
|
Loading…
Reference in New Issue
Block a user