mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #4421 from turbo124/v5-develop
Fixes for email attachments and sending names
This commit is contained in:
commit
65f1ae024c
@ -294,7 +294,7 @@ class CheckData extends Command
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
foreach (Client::cursor() as $client) {
|
||||
foreach (Client::where('is_deleted', 0)->cursor() as $client) {
|
||||
$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$credit_balance = $client->credits->where('is_deleted', false)->sum('balance');
|
||||
|
||||
@ -318,7 +318,7 @@ class CheckData extends Command
|
||||
$wrong_paid_to_dates = 0;
|
||||
$credit_total_applied = 0;
|
||||
|
||||
Client::withTrashed()->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
|
||||
Client::withTrashed()->where('is_deleted', 0)->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
|
||||
$total_invoice_payments = 0;
|
||||
|
||||
foreach ($client->invoices->where('is_deleted', false)->where('status_id', '>', 1) as $invoice) {
|
||||
@ -358,7 +358,7 @@ class CheckData extends Command
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
Client::cursor()->each(function ($client) use ($wrong_balances) {
|
||||
Client::cursor()->where('is_deleted', 0)->each(function ($client) use ($wrong_balances) {
|
||||
$client->invoices->where('is_deleted', false)->whereIn('status_id', '!=', Invoice::STATUS_DRAFT)->each(function ($invoice) use ($wrong_balances, $client) {
|
||||
$total_amount = $invoice->payments->whereIn('status_id', [Payment::STATUS_PAID, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.amount');
|
||||
$total_refund = $invoice->payments->whereIn('status_id', [Payment::STATUS_PAID, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.refunded');
|
||||
@ -385,7 +385,7 @@ class CheckData extends Command
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
foreach (Client::cursor() as $client) {
|
||||
foreach (Client::cursor()->where('is_deleted', 0) as $client) {
|
||||
//$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$invoice_balance = Invoice::where('client_id', $client->id)->where('is_deleted', false)->where('status_id', '>', 1)->withTrashed()->sum('balance');
|
||||
$client_balance = Credit::where('client_id', $client->id)->where('is_deleted', false)->withTrashed()->sum('balance');
|
||||
|
@ -13,6 +13,7 @@ namespace App\Http\Requests\Project;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Utils\Traits\ChecksEntityStatus;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateProjectRequest extends Request
|
||||
{
|
||||
|
@ -77,6 +77,8 @@ class BaseMailerJob implements ShouldQueue
|
||||
|
||||
Config::set('mail.driver', 'gmail');
|
||||
Config::set('services.gmail.token', $user->oauth_user_token->access_token);
|
||||
Config::set('mail.from.address', $user->email);
|
||||
Config::set('mail.from.name', $user->present()->name());
|
||||
|
||||
(new MailServiceProvider(app()))->register();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
try {
|
||||
$mail_obj = (new EntityPaidObject($this->payment))->build();
|
||||
$mail_obj->from = [$this->user->email, $this->user->present()->name()];
|
||||
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
|
||||
|
||||
//send email
|
||||
Mail::to($this->user->email)
|
||||
|
@ -81,7 +81,7 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
||||
$this->setMailDriver();
|
||||
|
||||
$mail_obj = (new EntitySentObject($this->invitation, $this->entity_type))->build();
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
|
||||
|
||||
try {
|
||||
Mail::to($this->user->email)
|
||||
|
@ -81,7 +81,7 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
||||
$this->setMailDriver();
|
||||
|
||||
$mail_obj = (new EntityViewedObject($this->invitation, $this->entity_type))->build();
|
||||
$mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()];
|
||||
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
|
||||
|
||||
//send email
|
||||
try {
|
||||
|
@ -91,7 +91,7 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
||||
unset($methods[$key]);
|
||||
|
||||
$mail_obj = (new PaymentFailureObject($this->client, $this->message, $this->amount, $this->company))->build();
|
||||
$mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()];
|
||||
$mail_obj->from = [config('mail.from.address'), config('mail.from.name')];
|
||||
|
||||
//send email
|
||||
try {
|
||||
|
@ -199,8 +199,9 @@ class Import implements ShouldQueue
|
||||
}
|
||||
|
||||
$this->setInitialCompanyLedgerBalances();
|
||||
|
||||
Mail::to($this->user)->send(new MigrationCompleted());
|
||||
|
||||
Mail::to($this->user)
|
||||
->send(new MigrationCompleted());
|
||||
|
||||
/*After a migration first some basic jobs to ensure the system is up to date*/
|
||||
VersionCheck::dispatch();
|
||||
|
@ -34,7 +34,7 @@ class EntityNotificationMailer extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->from($this->mail_obj->from[0], $this->mail_obj->from[1])
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject($this->mail_obj->subject)
|
||||
->markdown($this->mail_obj->markdown, $this->mail_obj->data)
|
||||
->withSwiftMessage(function ($message) {
|
||||
|
@ -43,9 +43,9 @@ class BouncedEmail extends Mailable implements ShouldQueue
|
||||
$entity_type = class_basename(lcfirst($this->invitation->getEntityType()));
|
||||
|
||||
$subject = ctrans("texts.notification_{$entity_type}_bounced_subject", ['invoice' => $invoice->number]);
|
||||
|
||||
|
||||
return
|
||||
$this->from($invitation->user->email)
|
||||
$this->from(config('mail.from.name'), config('mail.from.address'))
|
||||
->text()
|
||||
->subject($subject);
|
||||
|
||||
|
@ -30,13 +30,15 @@ class DownloadInvoices extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->subject(ctrans('texts.download_files'))
|
||||
->markdown(
|
||||
'email.admin.download_files',
|
||||
[
|
||||
'url' => $this->file_path,
|
||||
'logo' => $this->company->present()->logo,
|
||||
]
|
||||
);
|
||||
|
||||
return $this->from(config('mail.from.name'), config('mail.from.address'))
|
||||
->subject(ctrans('texts.download_files'))
|
||||
->markdown(
|
||||
'email.admin.download_files',
|
||||
[
|
||||
'url' => $this->file_path,
|
||||
'logo' => $this->company->present()->logo,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class BaseEmailEngine implements EngineInterface
|
||||
|
||||
public $template_style;
|
||||
|
||||
public $attachments;
|
||||
public $attachments = [];
|
||||
|
||||
public $link;
|
||||
|
||||
@ -83,7 +83,8 @@ class BaseEmailEngine implements EngineInterface
|
||||
|
||||
public function setAttachments($attachments)
|
||||
{
|
||||
$this->attachments = $attachments;
|
||||
|
||||
$this->attachments = array_merge($this->getAttachments(), $attachments);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
->setViewText(ctrans('texts.view_credit'));
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
$this->setAttachments($invitation->pdf_file_path());
|
||||
$this->setAttachments([$this->credit->pdf_file_path()]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -97,7 +97,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
->setViewText(ctrans('texts.view_invoice'));
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
$this->setAttachments($this->invoice->pdf_file_path());
|
||||
$this->setAttachments([$this->invoice->pdf_file_path()]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -88,7 +88,7 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
->setViewText(ctrans('texts.view_quote'));
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false) {
|
||||
$this->setAttachments($this->invitation->pdf_file_path());
|
||||
$this->setAttachments([$this->invitation->pdf_file_path()]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -27,6 +27,8 @@ class ExistingMigration extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('email.migration.existing');
|
||||
|
||||
return $this->from(config('mail.from.name'), config('mail.from.address'))
|
||||
->view('email.migration.existing');
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ class InvoiceWasPaid extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('email.invoices.paid');
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))->view('email.invoices.paid');
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ class MigrationCompleted extends Mailable
|
||||
public function build()
|
||||
{
|
||||
$data['settings'] = auth()->user()->company()->settings;
|
||||
|
||||
return $this->view('email.migration.completed', $data);
|
||||
|
||||
return $this->from(config('mail.from.name'), config('mail.from.address'))
|
||||
->view('email.migration.completed', $data);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ class MigrationFailed extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->from('noreply@invoiceninja.com')
|
||||
->view('email.migration.failed');
|
||||
|
||||
return $this->from(config('mail.from.name'), config('mail.from.address'))
|
||||
->view('email.migration.failed');
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ class QuoteWasApproved extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('email.quotes.approved');
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))->view('email.quotes.approved');
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class SupportMessageSent extends Mailable
|
||||
|
||||
$subject = "Customer MSG {$user->present()->name} - [{$plan} - DB:{$company->db}]";
|
||||
|
||||
return $this->from(config('mail.from.address')) //todo this needs to be fixed to handle the hosted version
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name')) //todo this needs to be fixed to handle the hosted version
|
||||
->subject($subject)
|
||||
->markdown('email.support.message', [
|
||||
'message' => $this->message,
|
||||
|
@ -52,7 +52,7 @@ class TemplateEmail extends Mailable
|
||||
|
||||
$company = $this->client->company;
|
||||
|
||||
$this->from($this->user->email, $this->user->present()->name());
|
||||
$this->from(config('mail.from.address'), config('mail.from.name'));
|
||||
|
||||
if (strlen($settings->reply_to_email) > 1) {
|
||||
$this->replyTo($settings->reply_to_email, $settings->reply_to_email);
|
||||
|
@ -36,7 +36,7 @@ class TestMailServer extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->from($this->from_email) //todo this needs to be fixed to handle the hosted version
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.email'))
|
||||
->markdown('email.support.message', [
|
||||
'message' => $this->message,
|
||||
|
@ -34,7 +34,7 @@ class UserNotificationMailer extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->from($this->mail_obj->from[0], $this->mail_obj->from[1]) //todo
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject($this->mail_obj->subject)
|
||||
->markdown($this->mail_obj->markdown, $this->mail_obj->data)
|
||||
->withSwiftMessage(function ($message) {
|
||||
|
@ -23,6 +23,7 @@ return [
|
||||
'date_time_format' => 'Y-m-d H:i',
|
||||
'daily_email_limit' => 300,
|
||||
'error_email' => env('ERROR_EMAIL', ''),
|
||||
'mailer' => env('MAIL_MAILER',''),
|
||||
'company_id' => 0,
|
||||
'hash_salt' => env('HASH_SALT', ''),
|
||||
'currency_converter_api_key' => env('OPENEXCHANGE_APP_ID', ''),
|
||||
|
Loading…
Reference in New Issue
Block a user