akaunting 3.0 (the last dance)
This commit is contained in:
@@ -23,11 +23,11 @@ class MarkDocumentCancelled
|
||||
|
||||
$type_text = '';
|
||||
|
||||
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
|
||||
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
|
||||
$type_text .= $alias . '::';
|
||||
}
|
||||
|
||||
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
|
||||
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
|
||||
|
||||
$type = trans_choice($type_text, 1);
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ class MarkDocumentReceived
|
||||
|
||||
$type_text = '';
|
||||
|
||||
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
|
||||
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
|
||||
$type_text .= $alias . '::';
|
||||
}
|
||||
|
||||
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
|
||||
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
|
||||
|
||||
$type = trans_choice($type_text, 1);
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ class MarkDocumentSent
|
||||
|
||||
$type_text = '';
|
||||
|
||||
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
|
||||
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
|
||||
$type_text .= $alias . '::';
|
||||
}
|
||||
|
||||
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
|
||||
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
|
||||
|
||||
$type = trans_choice($type_text, 1);
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ class MarkDocumentViewed
|
||||
|
||||
$type_text = '';
|
||||
|
||||
if ($alias = config('type.' . $event->document->type . '.alias', '')) {
|
||||
if ($alias = config('type.document.' . $event->document->type . '.alias', '')) {
|
||||
$type_text .= $alias . '::';
|
||||
}
|
||||
|
||||
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
|
||||
$type_text .= 'general.' . config('type.document.' . $event->document->type .'.translation.prefix');
|
||||
|
||||
$type = trans_choice($type_text, 1);
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ class SendDocumentPaymentNotification
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($event->request['mark_paid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document = $event->document;
|
||||
$transaction = $document->transactions()->latest()->first();
|
||||
|
||||
@@ -33,7 +29,7 @@ class SendDocumentPaymentNotification
|
||||
|
||||
// Notify all users assigned to this company
|
||||
foreach ($document->company->users as $user) {
|
||||
if (!$user->can('read-notifications')) {
|
||||
if ($user->cannot('read-notifications')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentRecurring as Event;
|
||||
use App\Traits\Documents;
|
||||
|
||||
class SendDocumentRecurringNotification
|
||||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
@@ -15,21 +18,25 @@ class SendDocumentRecurringNotification
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$document = $event->document;
|
||||
$config = config('type.' . $document->type . '.notification');
|
||||
$config = config('type.document.' . $document->type . '.notification');
|
||||
|
||||
if (empty($config) || empty($config['class'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($document->parent?->recurring?->auto_send == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notification = $config['class'];
|
||||
|
||||
// Notify the customer
|
||||
if ($config['notify_contact'] && $document->contact && !empty($document->contact_email)) {
|
||||
if ($this->canNotifyTheContactOfDocument($document)) {
|
||||
$document->contact->notify(new $notification($document, "{$document->type}_recur_customer"));
|
||||
}
|
||||
|
||||
// Check if should notify users
|
||||
if (!$config['notify_user']) {
|
||||
if (! $config['notify_user']) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentReminded as Event;
|
||||
use App\Traits\Documents;
|
||||
|
||||
class SendDocumentReminderNotification
|
||||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
@@ -18,13 +21,13 @@ class SendDocumentReminderNotification
|
||||
$notification = $event->notification;
|
||||
|
||||
// Notify the customer
|
||||
if ($document->contact && !empty($document->contact_email)) {
|
||||
if ($this->canNotifyTheContactOfDocument($document)) {
|
||||
$document->contact->notify(new $notification($document, "{$document->type}_remind_customer"));
|
||||
}
|
||||
|
||||
// Notify all users assigned to this company
|
||||
foreach ($document->company->users as $user) {
|
||||
if (!$user->can('read-notifications')) {
|
||||
if ($user->cannot('read-notifications')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
43
app/Listeners/Document/SendDocumentViewNotification.php
Normal file
43
app/Listeners/Document/SendDocumentViewNotification.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentViewed as Event;
|
||||
use App\Traits\Documents;
|
||||
|
||||
class SendDocumentViewNotification
|
||||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return array
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$document = $event->document;
|
||||
$config = config('type.document.' . $document->type . '.notification');
|
||||
|
||||
if (empty($config) || empty($config['class'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if should notify users
|
||||
if (! $config['notify_user']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notification = $config['class'];
|
||||
|
||||
// Notify all users assigned to this company
|
||||
foreach ($document->company->users as $user) {
|
||||
if ($user->cannot('read-notifications')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user->notify(new $notification($document, "{$document->type}_view_admin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class SettingFieldCreated
|
||||
$company = Company::find($document->company_id);
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
// Upload attachment
|
||||
// Upload attachment
|
||||
$media = $this->getMedia($value, 'settings');
|
||||
|
||||
$company->attachMedia($media, Str::snake($real_key));
|
||||
|
||||
Reference in New Issue
Block a user