added marked sent event
This commit is contained in:
parent
d17c3a89b3
commit
4940720ec0
@ -5,7 +5,7 @@ namespace App\BulkActions\Sales;
|
||||
use App\Abstracts\BulkAction;
|
||||
use App\Events\Document\DocumentCancelled;
|
||||
use App\Events\Document\DocumentCreated;
|
||||
use App\Events\Document\DocumentSent;
|
||||
use App\Events\Document\DocumentMarkedSent;
|
||||
use App\Events\Document\PaymentReceived;
|
||||
use App\Exports\Sales\Invoices as Export;
|
||||
use App\Jobs\Document\DeleteDocument;
|
||||
@ -58,7 +58,7 @@ class Invoices extends BulkAction
|
||||
continue;
|
||||
}
|
||||
|
||||
event(new DocumentSent($invoice));
|
||||
event(new DocumentMarkedSent($invoice));
|
||||
}
|
||||
}
|
||||
|
||||
|
20
app/Events/Document/DocumentMarkedSent.php
Normal file
20
app/Events/Document/DocumentMarkedSent.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Document;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class DocumentMarkedSent extends Event
|
||||
{
|
||||
public $document;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $document
|
||||
*/
|
||||
public function __construct($document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
}
|
@ -220,7 +220,7 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function markSent(Document $invoice)
|
||||
{
|
||||
event(new \App\Events\Document\DocumentSent($invoice));
|
||||
event(new \App\Events\Document\DocumentMarkedSent($invoice));
|
||||
|
||||
$message = trans('documents.messages.marked_sent', ['type' => trans_choice('general.invoices', 1)]);
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentSent as Event;
|
||||
use App\Events\Document\DocumentMarkedSent;
|
||||
use App\Events\Document\DocumentSent;
|
||||
use App\Jobs\Document\CreateDocumentHistory;
|
||||
use App\Traits\Jobs;
|
||||
|
||||
@ -10,13 +11,7 @@ class MarkDocumentSent
|
||||
{
|
||||
use Jobs;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
public function handle(DocumentMarkedSent|DocumentSent $event): void
|
||||
{
|
||||
if ($event->document->status != 'partial') {
|
||||
$event->document->status = 'sent';
|
||||
@ -24,6 +19,11 @@ class MarkDocumentSent
|
||||
$event->document->save();
|
||||
}
|
||||
|
||||
$this->dispatch(new CreateDocumentHistory($event->document, 0, $this->getDescription($event)));
|
||||
}
|
||||
|
||||
public function getDescription(DocumentMarkedSent|DocumentSent $event): string
|
||||
{
|
||||
$type_text = '';
|
||||
|
||||
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
|
||||
@ -34,12 +34,8 @@ class MarkDocumentSent
|
||||
|
||||
$type = trans_choice($type_text, 1);
|
||||
|
||||
$this->dispatch(
|
||||
new CreateDocumentHistory(
|
||||
$event->document,
|
||||
0,
|
||||
trans('documents.messages.marked_sent', ['type' => $type])
|
||||
)
|
||||
);
|
||||
$message = ($event instanceof DocumentMarkedSent) ? 'marked_sent' : 'email_sent';
|
||||
|
||||
return trans('documents.messages.' . $message, ['type' => $type]);
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,9 @@ class Event extends Provider
|
||||
'App\Listeners\Document\CreateDocumentTransaction',
|
||||
'App\Listeners\Document\SendDocumentPaymentNotification',
|
||||
],
|
||||
'App\Events\Document\DocumentMarkedSent' => [
|
||||
'App\Listeners\Document\MarkDocumentSent',
|
||||
],
|
||||
'App\Events\Document\DocumentSent' => [
|
||||
'App\Listeners\Document\MarkDocumentSent',
|
||||
],
|
||||
|
@ -4,6 +4,11 @@ return [
|
||||
|
||||
'edit_columns' => 'Edit Columns',
|
||||
'empty_items' => 'You have not added any items.',
|
||||
'grand_total' => 'Grand Total',
|
||||
'accept_payment_online' => 'Accept Payments Online',
|
||||
'transaction' => 'A payment for :amount was made using :account.',
|
||||
'billing' => 'Billing',
|
||||
'advanced' => 'Advanced',
|
||||
|
||||
'invoice_detail' => [
|
||||
'marked' => '<b>You</b> marked this invoice as',
|
||||
@ -13,15 +18,6 @@ return [
|
||||
'more_item' => '+:count more item',
|
||||
],
|
||||
|
||||
'grand_total' => 'Grand Total',
|
||||
|
||||
'accept_payment_online' => 'Accept Payments Online',
|
||||
|
||||
'transaction' => 'A payment for :amount was made using :account.',
|
||||
|
||||
'billing' => 'Billing',
|
||||
'advanced' => 'Advanced',
|
||||
|
||||
'statuses' => [
|
||||
'draft' => 'Draft',
|
||||
'sent' => 'Sent',
|
||||
|
Loading…
x
Reference in New Issue
Block a user