mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add delete company email
This commit is contained in:
parent
d82491d163
commit
74551c2caf
@ -25,7 +25,10 @@ use App\Jobs\Company\CreateCompany;
|
|||||||
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||||
use App\Jobs\Company\CreateCompanyToken;
|
use App\Jobs\Company\CreateCompanyToken;
|
||||||
|
use App\Jobs\Mail\NinjaMailerJob;
|
||||||
|
use App\Jobs\Mail\NinjaMailerObject;
|
||||||
use App\Jobs\Ninja\RefundCancelledAccount;
|
use App\Jobs\Ninja\RefundCancelledAccount;
|
||||||
|
use App\Mail\Company\CompanyDeleted;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
@ -505,6 +508,15 @@ class CompanyController extends BaseController
|
|||||||
$company_user->forceDelete();
|
$company_user->forceDelete();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$other_company = $company->account->companies->where('id', '!=', $company->id)->first();
|
||||||
|
|
||||||
|
$nmo = new NinjaMailerObject;
|
||||||
|
$nmo->mailable = new CompanyDeleted($company->present()->name, auth()->user(), $company->account, $company->settings);
|
||||||
|
$nmo->company = $other_company;
|
||||||
|
$nmo->settings = $other_company->settings;
|
||||||
|
$nmo->to_user = auth()->user();
|
||||||
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
$company->delete();
|
$company->delete();
|
||||||
|
|
||||||
//If we are deleting the default companies, we'll need to make a new company the default.
|
//If we are deleting the default companies, we'll need to make a new company the default.
|
||||||
|
61
app/Mail/Company/CompanyDeleted.php
Normal file
61
app/Mail/Company/CompanyDeleted.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Mail\Company;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class CompanyDeleted extends Mailable
|
||||||
|
{
|
||||||
|
// use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $account;
|
||||||
|
|
||||||
|
public $company;
|
||||||
|
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public $settings;
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($company, $user, $account, $settings)
|
||||||
|
{
|
||||||
|
$this->company = $company;
|
||||||
|
$this->user = $user;
|
||||||
|
$this->account = $account;
|
||||||
|
$this->settings = $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||||
|
->subject(ctrans('texts.company_deleted'))
|
||||||
|
->view('email.admin.company_deleted')
|
||||||
|
->with([
|
||||||
|
'settings' => $this->settings,
|
||||||
|
'logo' => '',
|
||||||
|
'title' => ctrans('texts.company_deleted'),
|
||||||
|
'body' => ctrans('texts.company_deleted_body', ['company' => $this->company, 'user' => $this->user->present()->name(), 'time' => now()]),
|
||||||
|
'whitelabel' => $this->account->isPaid(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -4282,6 +4282,8 @@ $LANG = array(
|
|||||||
'no_quotes_available_for_download' => 'No quotes available for download.',
|
'no_quotes_available_for_download' => 'No quotes available for download.',
|
||||||
'copyright' => 'Copyright',
|
'copyright' => 'Copyright',
|
||||||
'user_created_user' => ':user created :created_user at :time',
|
'user_created_user' => ':user created :created_user at :time',
|
||||||
|
'company_deleted' => 'Company deleted',
|
||||||
|
'company_deleted_body' => 'Company [ :company ] was deleted by :user',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
6
resources/views/email/admin/company_deleted.blade.php
Normal file
6
resources/views/email/admin/company_deleted.blade.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@component('email.template.admin', ['logo' => $logo, 'settings' => $settings])
|
||||||
|
<div class="center">
|
||||||
|
<h1>{!! $title !!}</h1>
|
||||||
|
<p>{!! $body !!}</p>
|
||||||
|
</div>
|
||||||
|
@endcomponent
|
Loading…
x
Reference in New Issue
Block a user