1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Bug with viewed_date populating erroneously

This commit is contained in:
David Bomba 2020-07-14 15:37:49 +10:00
parent 1d7ba6d1e6
commit 00a3d36fcd
5 changed files with 100 additions and 88 deletions

View File

@ -45,7 +45,9 @@ class InvitationController extends Controller
auth()->guard('contact')->login($invitation->contact, true);
}
if (!request()->has('silent')) {
if (!request()->has('silent') && !$invitation->viewed_date) {
// if (!request()->has('silent')) {
$invitation->markViewed();
event(new InvitationWasViewed($invitation->{$entity}, $invitation, $invitation->{$entity}->company, Ninja::eventVars()));

View File

@ -46,6 +46,7 @@ class InvitationViewedListener implements ShouldQueue
$invitation = $event->invitation;
$notification = new EntityViewedNotification($invitation, $entity_name);
$notification_not_fired_yet = true;
foreach ($invitation->company->company_users as $company_user) {
@ -53,10 +54,11 @@ class InvitationViewedListener implements ShouldQueue
$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]);
EntityViewedMailer::dispatch($invitation, $entity_name, $company_user->user, $invitation->company);
$notification_not_fired_yet = false;
}

View File

@ -42,37 +42,37 @@ class CreditInvitation extends BaseModel
return CreditInvitation::class;
}
public function getSignatureDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSignatureDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getSentDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSentDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getViewedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getViewedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getOpenedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getOpenedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function entityType()
{

View File

@ -41,37 +41,37 @@ class InvoiceInvitation extends BaseModel
return InvoiceInvitation::class;
}
public function getSignatureDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSignatureDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getSentDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSentDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getViewedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getViewedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getOpenedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getOpenedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function entityType()
{
@ -126,10 +126,18 @@ class InvoiceInvitation extends BaseModel
public function markViewed()
{
info('marking viewed here');
$this->viewed_date = Carbon::now();
$this->save();
}
public function markOpened()
{
$this->opened_date = Carbon::now();
$this->save();
}
public function pdf_file_path()
{
$storage_path = Storage::url($this->invoice->client->invoice_filepath() . $this->invoice->number . '.pdf');

View File

@ -36,37 +36,37 @@ class QuoteInvitation extends BaseModel
return QuoteInvitation::class;
}
public function getSignatureDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSignatureDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getSentDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getSentDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getViewedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getViewedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function getOpenedDateAttribute($value)
{
if (!$value) {
return (new Carbon($value))->format('Y-m-d');
}
return $value;
}
// public function getOpenedDateAttribute($value)
// {
// if (!$value) {
// return (new Carbon($value))->format('Y-m-d');
// }
// return $value;
// }
public function entityType()
{