diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index bc7efa865314..7aab42ff4518 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -206,7 +206,7 @@ class Import implements ShouldQueue $this->setInitialCompanyLedgerBalances(); Mail::to($this->user) - ->send(new MigrationCompleted()); + ->send(new MigrationCompleted($this->company)); /*After a migration first some basic jobs to ensure the system is up to date*/ VersionCheck::dispatch(); diff --git a/app/Mail/MigrationCompleted.php b/app/Mail/MigrationCompleted.php index 301b91c60ca3..54f158ca9af6 100644 --- a/app/Mail/MigrationCompleted.php +++ b/app/Mail/MigrationCompleted.php @@ -2,6 +2,7 @@ namespace App\Mail; +use App\Models\Company; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; @@ -10,14 +11,16 @@ class MigrationCompleted extends Mailable { use Queueable, SerializesModels; + public $company; + /** * Create a new message instance. * * @return void */ - public function __construct() + public function __construct(Company $company) { - // + $this->company = $company; } /** @@ -27,9 +30,11 @@ class MigrationCompleted extends Mailable */ public function build() { - $data['settings'] = auth()->user()->company()->settings; + $data['settings'] = $this->company->settings; + $data['company'] = $this->company; return $this->from(config('mail.from.address'), config('mail.from.name')) - ->view('email.migration.completed', $data); + ->view('email.import.completed', $data) + ->attach($this->company->invoices->first()->pdf_file_path()); } } diff --git a/app/Models/Company.php b/app/Models/Company.php index 90a266d18e99..e02d87f0b053 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -373,6 +373,11 @@ class Company extends BaseModel return $this->hasMany(CompanyToken::class); } + public function client_gateway_tokens() + { + return $this->hasMany(ClientGatewayToken::class); + } + public function system_logs() { return $this->hasMany(SystemLog::class)->orderBy('id', 'DESC')->take(50); diff --git a/resources/views/email/import/completed.blade.php b/resources/views/email/import/completed.blade.php index 4f62a77bede3..1eb858798fa9 100644 --- a/resources/views/email/import/completed.blade.php +++ b/resources/views/email/import/completed.blade.php @@ -6,51 +6,74 @@
Hello, here is the output of your recent import job.
- @if(isset($clients) && count($clients) >=1) -If your logo imported correctly it will display below. If it didn't import, you'll need to reupload your logo
+ +Clients Imported: {{ count($company->clients) }}
@endif - @if(isset($errors['clients']) && count($errors['clients']) >=1) -Products Imported: {{ count($company->products) }}
@endif - @if(isset($invoices) && count($invoices) >=1) + @if(isset($company) && count($company->invoices) >=1) +Invoices Imported: {{ count($company->invoices) }}
-To test your PDF generation is working correctly, click here. We've also attempted to attach the PDF to this email. @endif - @if(isset($errors['invoices']) && count($errors['invoices']) >=1) -
Payments Imported: {{ count($company->payments) }}
@endif - @if(isset($products) && count($products) >=1) -Recurring Invoices Imported: {{ count($company->recurring_invoices) }}
@endif - @if(isset($errors['products']) && count($errors['products']) >=1) -Quotes Imported: {{ count($company->quotes) }}
@endif - Visit portal + @if(isset($company) && count($company->credits) >=1) +Credits Imported: {{ count($company->credits) }}
+ @endif -Thank you,
Invoice Ninja.
Projects Imported: {{ count($company->projects) }}
+ @endif + + @if(isset($company) && count($company->tasks) >=1) +Tasks Imported: {{ count($company->tasks) }}
+ @endif + + @if(isset($company) && count($company->vendors) >=1) +Vendors Imported: {{ count($company->vendors) }}
+ @endif + + @if(isset($company) && count($company->expenses) >=1) +Expenses Imported: {{ count($company->expenses) }}
+ @endif + + @if(isset($company) && count($company->company_gateways) >=1) +Gateways Imported: {{ count($company->company_gateways) }}
+ @endif + + @if(isset($company) && count($company->client_gateway_tokens) >=1) +Client Gateway Tokens Imported: {{ count($company->client_gateway_tokens) }}
+ @endif + + @if(isset($company) && count($company->tax_rates) >=1) +Tax Rates Imported: {{ count($company->tax_rates) }}
+ @endif + + @if(isset($company) && count($company->documents) >=1) +Documents Imported: {{ count($company->documents) }}
+ @endif + + {{ ctrans('texts.account_login')}} + +{{ ctrans('texts.email_signature')}}
{{ ctrans('texts.email_from') }}