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',
|
||||
],
|
||||
|
@ -2,84 +2,80 @@
|
||||
|
||||
return [
|
||||
|
||||
'edit_columns' => 'Edit Columns',
|
||||
'empty_items' => 'You have not added any items.',
|
||||
'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',
|
||||
'services' => 'Services',
|
||||
'another_item' => 'Another Item',
|
||||
'another_description' => 'and another description',
|
||||
'more_item' => '+:count more item',
|
||||
'invoice_detail' => [
|
||||
'marked' => '<b>You</b> marked this invoice as',
|
||||
'services' => 'Services',
|
||||
'another_item' => 'Another Item',
|
||||
'another_description' => 'and another description',
|
||||
'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',
|
||||
'expired' => 'Expired',
|
||||
'viewed' => 'Viewed',
|
||||
'approved' => 'Approved',
|
||||
'received' => 'Received',
|
||||
'refused' => 'Refused',
|
||||
'restored' => 'Restored',
|
||||
'reversed' => 'Reversed',
|
||||
'partial' => 'Partial',
|
||||
'paid' => 'Paid',
|
||||
'pending' => 'Pending',
|
||||
'invoiced' => 'Invoiced',
|
||||
'overdue' => 'Overdue',
|
||||
'unpaid' => 'Unpaid',
|
||||
'cancelled' => 'Cancelled',
|
||||
'voided' => 'Voided',
|
||||
'completed' => 'Completed',
|
||||
'shipped' => 'Shipped',
|
||||
'refunded' => 'Refunded',
|
||||
'failed' => 'Failed',
|
||||
'denied' => 'Denied',
|
||||
'processed' => 'Processed',
|
||||
'open' => 'Open',
|
||||
'closed' => 'Closed',
|
||||
'billed' => 'Billed',
|
||||
'delivered' => 'Delivered',
|
||||
'returned' => 'Returned',
|
||||
'drawn' => 'Drawn',
|
||||
'not_billed' => 'Not Billed',
|
||||
'issued' => 'Issued',
|
||||
'not_invoiced' => 'Not Invoiced',
|
||||
'confirmed' => 'Confirmed',
|
||||
'not_confirmed' => 'Not Confirmed',
|
||||
'active' => 'Active',
|
||||
'ended' => 'Ended',
|
||||
'draft' => 'Draft',
|
||||
'sent' => 'Sent',
|
||||
'expired' => 'Expired',
|
||||
'viewed' => 'Viewed',
|
||||
'approved' => 'Approved',
|
||||
'received' => 'Received',
|
||||
'refused' => 'Refused',
|
||||
'restored' => 'Restored',
|
||||
'reversed' => 'Reversed',
|
||||
'partial' => 'Partial',
|
||||
'paid' => 'Paid',
|
||||
'pending' => 'Pending',
|
||||
'invoiced' => 'Invoiced',
|
||||
'overdue' => 'Overdue',
|
||||
'unpaid' => 'Unpaid',
|
||||
'cancelled' => 'Cancelled',
|
||||
'voided' => 'Voided',
|
||||
'completed' => 'Completed',
|
||||
'shipped' => 'Shipped',
|
||||
'refunded' => 'Refunded',
|
||||
'failed' => 'Failed',
|
||||
'denied' => 'Denied',
|
||||
'processed' => 'Processed',
|
||||
'open' => 'Open',
|
||||
'closed' => 'Closed',
|
||||
'billed' => 'Billed',
|
||||
'delivered' => 'Delivered',
|
||||
'returned' => 'Returned',
|
||||
'drawn' => 'Drawn',
|
||||
'not_billed' => 'Not Billed',
|
||||
'issued' => 'Issued',
|
||||
'not_invoiced' => 'Not Invoiced',
|
||||
'confirmed' => 'Confirmed',
|
||||
'not_confirmed' => 'Not Confirmed',
|
||||
'active' => 'Active',
|
||||
'ended' => 'Ended',
|
||||
],
|
||||
|
||||
'form_description' => [
|
||||
'companies' => 'Change the address, logo, and other information for your company.',
|
||||
'billing' => 'Billing details appears in your document.',
|
||||
'advanced' => 'Select the category, add or edit the footer, and add attachments to your :type.',
|
||||
'attachment' => 'Download the files attached to this :type',
|
||||
'companies' => 'Change the address, logo, and other information for your company.',
|
||||
'billing' => 'Billing details appears in your document.',
|
||||
'advanced' => 'Select the category, add or edit the footer, and add attachments to your :type.',
|
||||
'attachment' => 'Download the files attached to this :type',
|
||||
],
|
||||
|
||||
'messages' => [
|
||||
'email_sent' => ':type email has been sent!',
|
||||
'marked_as' => ':type marked as :status!',
|
||||
'marked_sent' => ':type marked as sent!',
|
||||
'marked_paid' => ':type marked as paid!',
|
||||
'marked_viewed' => ':type marked as viewed!',
|
||||
'marked_cancelled' => ':type marked as cancelled!',
|
||||
'marked_received' => ':type marked as received!',
|
||||
'email_sent' => ':type email has been sent!',
|
||||
'marked_as' => ':type marked as :status!',
|
||||
'marked_sent' => ':type marked as sent!',
|
||||
'marked_paid' => ':type marked as paid!',
|
||||
'marked_viewed' => ':type marked as viewed!',
|
||||
'marked_cancelled' => ':type marked as cancelled!',
|
||||
'marked_received' => ':type marked as received!',
|
||||
],
|
||||
|
||||
'recurring' => [
|
||||
'auto_generated' => 'Auto-generated',
|
||||
'auto_generated' => 'Auto-generated',
|
||||
|
||||
'tooltip' => [
|
||||
'document_date' => 'The :type date will be automatically assigned based on the :type schedule and frequency.',
|
||||
|
Loading…
x
Reference in New Issue
Block a user