mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for Notifications
This commit is contained in:
parent
c8e4fdd3bd
commit
5f5a33bac9
@ -38,7 +38,7 @@ class CreditCreatedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($event->company->db);
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
$first_notification_sent = true;
|
// $first_notification_sent = true;
|
||||||
|
|
||||||
$credit = $event->credit;
|
$credit = $event->credit;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class CreditCreatedNotification implements ShouldQueue
|
|||||||
$methods = $this->findUserNotificationTypes($credit->invitations()->first(), $company_user, 'credit', ['all_notifications', 'credit_created', 'credit_created_all']);
|
$methods = $this->findUserNotificationTypes($credit->invitations()->first(), $company_user, 'credit', ['all_notifications', 'credit_created', 'credit_created_all']);
|
||||||
|
|
||||||
/* If one of the methods is email then we fire the EntitySentMailer */
|
/* If one of the methods is email then we fire the EntitySentMailer */
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class CreditCreatedNotification implements ShouldQueue
|
|||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
/* This prevents more than one notification being sent */
|
/* This prevents more than one notification being sent */
|
||||||
$first_notification_sent = false;
|
// $first_notification_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Override the methods in the Notification Class */
|
/* Override the methods in the Notification Class */
|
||||||
|
@ -38,7 +38,7 @@ class CreditEmailedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($event->company->db);
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
$first_notification_sent = true;
|
// $first_notification_sent = true;
|
||||||
|
|
||||||
$credit = $event->invitation->credit;
|
$credit = $event->invitation->credit;
|
||||||
$credit->last_sent_date = now();
|
$credit->last_sent_date = now();
|
||||||
@ -56,14 +56,15 @@ class CreditEmailedNotification implements ShouldQueue
|
|||||||
|
|
||||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']);
|
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']);
|
||||||
|
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
|
// if (($key = array_search('mail', $methods))) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
$nmo->to_user = $user;
|
$nmo->to_user = $user;
|
||||||
|
|
||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
$first_notification_sent = false;
|
// $first_notification_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $notification->method = $methods;
|
// $notification->method = $methods;
|
||||||
|
@ -52,24 +52,23 @@ class InvoiceCreatedNotification implements ShouldQueue
|
|||||||
|
|
||||||
/* The User */
|
/* The User */
|
||||||
$user = $company_user->user;
|
$user = $company_user->user;
|
||||||
|
|
||||||
/* This is only here to handle the alternate message channels - ie Slack */
|
/* This is only here to handle the alternate message channels - ie Slack */
|
||||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||||
|
|
||||||
/* Returns an array of notification methods */
|
/* Returns an array of notification methods */
|
||||||
$methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']);
|
$methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']);
|
||||||
|
|
||||||
/* If one of the methods is email then we fire the EntitySentMailer */
|
/* If one of the methods is email then we fire the EntitySentMailer */
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
// if (($key = array_search('mail', $methods))) {
|
||||||
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
|
|
||||||
$nmo->to_user = $user;
|
$nmo->to_user = $user;
|
||||||
|
|
||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
/* This prevents more than one notification being sent */
|
/* This prevents more than one notification being sent */
|
||||||
$first_notification_sent = false;
|
$first_notification_sent = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Override the methods in the Notification Class */
|
/* Override the methods in the Notification Class */
|
||||||
|
@ -63,7 +63,7 @@ class InvoiceEmailedNotification implements ShouldQueue
|
|||||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
||||||
|
|
||||||
/* If one of the methods is email then we fire the EntitySentMailer */
|
/* If one of the methods is email then we fire the EntitySentMailer */
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods))) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class InvoiceFailedEmailNotification
|
|||||||
|
|
||||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
||||||
|
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods))) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
$nmo->to_user = $user;
|
$nmo->to_user = $user;
|
||||||
|
@ -60,7 +60,7 @@ class QuoteCreatedNotification implements ShouldQueue
|
|||||||
$methods = $this->findUserNotificationTypes($quote->invitations()->first(), $company_user, 'quote', ['all_notifications', 'quote_created', 'quote_created_all']);
|
$methods = $this->findUserNotificationTypes($quote->invitations()->first(), $company_user, 'quote', ['all_notifications', 'quote_created', 'quote_created_all']);
|
||||||
|
|
||||||
/* If one of the methods is email then we fire the EntitySentMailer */
|
/* If one of the methods is email then we fire the EntitySentMailer */
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods))) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($event->company->db);
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
$first_notification_sent = true;
|
// $first_notification_sent = true;
|
||||||
|
|
||||||
$quote = $event->invitation->quote;
|
$quote = $event->invitation->quote;
|
||||||
$quote->last_sent_date = now();
|
$quote->last_sent_date = now();
|
||||||
@ -57,7 +57,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
|||||||
|
|
||||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']);
|
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']);
|
||||||
|
|
||||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
if (($key = array_search('mail', $methods)) !== false) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
|||||||
|
|
||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
$first_notification_sent = false;
|
// $first_notification_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $notification->method = $methods;
|
// $notification->method = $methods;
|
||||||
|
@ -36,6 +36,7 @@ trait CompanySettingsSaver
|
|||||||
*/
|
*/
|
||||||
public function saveSettings($settings, $entity)
|
public function saveSettings($settings, $entity)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* No Settings, No Save!*/
|
/* No Settings, No Save!*/
|
||||||
if (! $settings) {
|
if (! $settings) {
|
||||||
return;
|
return;
|
||||||
@ -58,14 +59,17 @@ trait CompanySettingsSaver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(property_exists($settings, 'translations'))
|
||||||
|
{
|
||||||
//this pass will handle any null values that are in the translations
|
//this pass will handle any null values that are in the translations
|
||||||
foreach ($settings->translations as $key => $value) {
|
foreach ($settings->translations as $key => $value) {
|
||||||
if (is_null($settings->translations[$key])) {
|
if (is_null($settings->translations[$key])) {
|
||||||
$settings->translations[$key] = '';
|
$settings->translations[$key] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$company_settings->translations = $settings->translations;
|
$company_settings->translations = $settings->translations;
|
||||||
|
}
|
||||||
|
|
||||||
$entity->settings = $company_settings;
|
$entity->settings = $company_settings;
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ class CompanyTest extends TestCase
|
|||||||
$settings->invoice_design_id = '2';
|
$settings->invoice_design_id = '2';
|
||||||
$settings->quote_design_id = '1';
|
$settings->quote_design_id = '1';
|
||||||
|
|
||||||
|
nlog($settings);
|
||||||
$company->settings = $settings;
|
$company->settings = $settings;
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user