mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 12:34:35 -04:00
Bug with viewed_date populating erroneously
This commit is contained in:
parent
1d7ba6d1e6
commit
00a3d36fcd
@ -44,8 +44,10 @@ class InvitationController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
auth()->guard('contact')->login($invitation->contact, true);
|
auth()->guard('contact')->login($invitation->contact, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!request()->has('silent')) {
|
if (!request()->has('silent') && !$invitation->viewed_date) {
|
||||||
|
// if (!request()->has('silent')) {
|
||||||
|
|
||||||
$invitation->markViewed();
|
$invitation->markViewed();
|
||||||
|
|
||||||
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));
|
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));
|
||||||
|
@ -46,6 +46,7 @@ class InvitationViewedListener implements ShouldQueue
|
|||||||
$invitation = $event->invitation;
|
$invitation = $event->invitation;
|
||||||
|
|
||||||
$notification = new EntityViewedNotification($invitation, $entity_name);
|
$notification = new EntityViewedNotification($invitation, $entity_name);
|
||||||
|
$notification_not_fired_yet = true;
|
||||||
|
|
||||||
foreach ($invitation->company->company_users as $company_user) {
|
foreach ($invitation->company->company_users as $company_user) {
|
||||||
|
|
||||||
@ -53,11 +54,12 @@ class InvitationViewedListener implements ShouldQueue
|
|||||||
|
|
||||||
$methods = $this->findUserNotificationTypes($invitation, $company_user, $entity_name, ['all_notifications', $entity_viewed]);
|
$methods = $this->findUserNotificationTypes($invitation, $company_user, $entity_name, ['all_notifications', $entity_viewed]);
|
||||||
|
|
||||||
if (($key = array_search('mail', $methods)) !== false) {
|
if (($key = array_search('mail', $methods)) !== false && $notification_not_fired_yet) {
|
||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
EntityViewedMailer::dispatch($invitation, $entity_name, $company_user->user, $invitation->company);
|
EntityViewedMailer::dispatch($invitation, $entity_name, $company_user->user, $invitation->company);
|
||||||
|
$notification_not_fired_yet = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification->method = $methods;
|
$notification->method = $methods;
|
||||||
|
@ -42,37 +42,37 @@ class CreditInvitation extends BaseModel
|
|||||||
return CreditInvitation::class;
|
return CreditInvitation::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
// public function getSignatureDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getSentDateAttribute($value)
|
// public function getSentDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getViewedDateAttribute($value)
|
// public function getViewedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getOpenedDateAttribute($value)
|
// public function getOpenedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function entityType()
|
public function entityType()
|
||||||
{
|
{
|
||||||
|
@ -41,37 +41,37 @@ class InvoiceInvitation extends BaseModel
|
|||||||
return InvoiceInvitation::class;
|
return InvoiceInvitation::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
// public function getSignatureDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getSentDateAttribute($value)
|
// public function getSentDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getViewedDateAttribute($value)
|
// public function getViewedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getOpenedDateAttribute($value)
|
// public function getOpenedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function entityType()
|
public function entityType()
|
||||||
{
|
{
|
||||||
@ -126,10 +126,18 @@ class InvoiceInvitation extends BaseModel
|
|||||||
|
|
||||||
public function markViewed()
|
public function markViewed()
|
||||||
{
|
{
|
||||||
|
info('marking viewed here');
|
||||||
|
|
||||||
$this->viewed_date = Carbon::now();
|
$this->viewed_date = Carbon::now();
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function markOpened()
|
||||||
|
{
|
||||||
|
$this->opened_date = Carbon::now();
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
public function pdf_file_path()
|
public function pdf_file_path()
|
||||||
{
|
{
|
||||||
$storage_path = Storage::url($this->invoice->client->invoice_filepath() . $this->invoice->number . '.pdf');
|
$storage_path = Storage::url($this->invoice->client->invoice_filepath() . $this->invoice->number . '.pdf');
|
||||||
|
@ -36,37 +36,37 @@ class QuoteInvitation extends BaseModel
|
|||||||
return QuoteInvitation::class;
|
return QuoteInvitation::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignatureDateAttribute($value)
|
// public function getSignatureDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getSentDateAttribute($value)
|
// public function getSentDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getViewedDateAttribute($value)
|
// public function getViewedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function getOpenedDateAttribute($value)
|
// public function getOpenedDateAttribute($value)
|
||||||
{
|
// {
|
||||||
if (!$value) {
|
// if (!$value) {
|
||||||
return (new Carbon($value))->format('Y-m-d');
|
// return (new Carbon($value))->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
return $value;
|
// return $value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function entityType()
|
public function entityType()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user