Skip to content

Commit

Permalink
Updates for bulk emails
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Jan 15, 2025
1 parent f3a9e2f commit 20f4d64
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 117 deletions.
1 change: 0 additions & 1 deletion app/Http/Controllers/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use App\Events\General\EntityWasEmailed;
use App\Transformers\InvoiceTransformer;
use App\Http\Requests\Email\SendEmailRequest;
use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
use App\Transformers\PurchaseOrderTransformer;
use App\Transformers\RecurringInvoiceTransformer;

Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/PurchaseOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use App\Http\Requests\PurchaseOrder\UpdatePurchaseOrderRequest;
use App\Http\Requests\PurchaseOrder\UploadPurchaseOrderRequest;
use App\Jobs\Entity\CreateRawPdf;
use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
use App\Jobs\PurchaseOrder\ZipPurchaseOrders;
use App\Models\Account;
use App\Models\Client;
Expand Down Expand Up @@ -672,8 +671,7 @@ private function performAction(PurchaseOrder $purchase_order, $action, $bulk = f
case 'email':
case 'send_email':
//check query parameter for email_type and set the template else use calculateTemplate
// PurchaseOrderEmail::dispatch($purchase_order, $purchase_order->company);


$purchase_order->service()->sendEmail();

if (! $bulk) {
Expand Down
107 changes: 0 additions & 107 deletions app/Jobs/PurchaseOrder/PurchaseOrderEmail.php

This file was deleted.

5 changes: 3 additions & 2 deletions app/Listeners/General/EntityEmailedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EntityEmailedNotification implements ShouldQueue
{
use UserNotifies;

public $delay = 1;
public $delay = 10;

private $entity_string;

Expand Down Expand Up @@ -79,7 +79,8 @@ public function handle($event)
unset($methods[$key]);

$nmo = new NinjaMailerObject();
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, $this->entity_string, $event->template, $company_user->portalType()))->build());
$sent_object = (new EntitySentObject($event->invitation, $this->entity_string, $event->template, $company_user->portalType()))->build();
$nmo->mailable = new NinjaMailer($sent_object);
$nmo->company = $event->invitation->company;
$nmo->settings = $event->invitation->company->settings;
$nmo->to_user = $user;
Expand Down
2 changes: 1 addition & 1 deletion app/Mail/Admin/EntitySentObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function build()
'vendor' => $this->contact->vendor->present()->name(),
'purchase_order' => $this->entity->number,
]
);
),
];

$mail_obj->markdown = 'email.admin.generic';
Expand Down
3 changes: 2 additions & 1 deletion app/Services/PurchaseOrder/SendEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function __construct(protected PurchaseOrder $purchase_order, protected ?
public function run()
{
$this->purchase_order->last_sent_date = now();

$this->purchase_order->save();

$this->purchase_order->invitations->load('contact.vendor.country', 'purchase_order.vendor.country', 'purchase_order.company')->each(function ($invitation) {

App::forgetInstance('translator');
Expand Down
3 changes: 1 addition & 2 deletions app/Services/PurchaseOrder/TriggeredActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace App\Services\PurchaseOrder;

use App\Jobs\PurchaseOrder\PurchaseOrderEmail;
use App\Models\PurchaseOrder;
use App\Services\AbstractService;
use App\Utils\Traits\GeneratesCounter;
Expand Down Expand Up @@ -71,6 +70,6 @@ public function run()

private function sendEmail()
{
PurchaseOrderEmail::dispatch($this->purchase_order, $this->purchase_order->company);
$this->purchase_order->service()->sendEmail();
}
}

0 comments on commit 20f4d64

Please sign in to comment.