Clean up for quote email activity
This commit is contained in:
parent
117ff658ff
commit
6b06bfc9b3
|
|
@ -221,6 +221,31 @@ class TaskFilters extends QueryFilters
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by date range
|
||||||
|
*
|
||||||
|
* @param string $date_range
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function date_range(string $date_range = ''): Builder
|
||||||
|
{
|
||||||
|
$parts = explode(",", $date_range);
|
||||||
|
|
||||||
|
if (count($parts) != 2 || !in_array('calculated_start_date', \Illuminate\Support\Facades\Schema::getColumnListing($this->builder->getModel()->getTable()))) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$start_date = \Carbon\Carbon::parse($parts[0]);
|
||||||
|
$end_date = \Carbon\Carbon::parse($parts[1]);
|
||||||
|
|
||||||
|
return $this->builder->whereBetween('calculated_start_date', [$start_date, $end_date]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the query by the users company ID.
|
* Filters the query by the users company ID.
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ class QuoteEmailActivity implements ShouldQueue
|
||||||
|
|
||||||
$fields->user_id = $user_id;
|
$fields->user_id = $user_id;
|
||||||
|
|
||||||
$fields->quote_id = $event->invitation->quote->id;
|
$fields->quote_id = $event->invitation->quote_id;
|
||||||
$fields->client_id = $event->invitation->quote->client_id;
|
$fields->client_id = $event->invitation->quote->client_id;
|
||||||
$fields->company_id = $event->invitation->quote->company_id;
|
$fields->company_id = $event->invitation->company_id;
|
||||||
$fields->client_contact_id = $event->invitation->quote->client_contact_id;
|
$fields->client_contact_id = $event->invitation->client_contact_id;
|
||||||
$fields->activity_type_id = Activity::EMAIL_QUOTE;
|
$fields->activity_type_id = Activity::EMAIL_QUOTE;
|
||||||
|
|
||||||
$this->activity_repo->save($fields, $event->invitation, $event->event_vars);
|
$this->activity_repo->save($fields, $event->invitation, $event->event_vars);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue