Email template styling issue solved ( #337y1z3 )

This commit is contained in:
Cüneyt Şentürk 2022-07-07 12:54:47 +03:00
parent 974995634a
commit f50e181b4a
2 changed files with 51 additions and 7 deletions

View File

@ -4,8 +4,9 @@ namespace App\Listeners\Update\V30;
use App\Abstracts\Listeners\Update as Listener; use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event; use App\Events\Install\UpdateFinished as Event;
use App\Models\Common\Company;
use App\Models\Setting\EmailTemplate;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -31,6 +32,8 @@ class Version304 extends Listener
$this->updateDatabase(); $this->updateDatabase();
$this->updateCompanies();
$this->deleteOldFiles(); $this->deleteOldFiles();
Log::channel('stderr')->info('Akaunting 3.0.4 update finished.'); Log::channel('stderr')->info('Akaunting 3.0.4 update finished.');
@ -40,17 +43,55 @@ class Version304 extends Listener
{ {
Log::channel('stderr')->info('Updating database...'); Log::channel('stderr')->info('Updating database...');
DB::table('migrations')->insert([
'id' => DB::table('migrations')->max('id') + 1,
'migration' => '2022_06_28_000000_core_v304',
'batch' => DB::table('migrations')->max('batch') + 1,
]);
Artisan::call('migrate', ['--force' => true]); Artisan::call('migrate', ['--force' => true]);
Log::channel('stderr')->info('Database updated.'); Log::channel('stderr')->info('Database updated.');
} }
public function updateCompanies()
{
Log::channel('stderr')->info('Updating companies...');
$company_id = company_id();
$companies = Company::cursor();
foreach ($companies as $company) {
Log::channel('stderr')->info('Updating company:' . $company->id);
$company->makeCurrent();
$this->updateEmailTemplates();
Log::channel('stderr')->info('Company updated:' . $company->id);
}
company($company_id)->makeCurrent();
Log::channel('stderr')->info('Companies updated.');
}
public function updateEmailTemplates()
{
Log::channel('stderr')->info('Updating Email Templates...');
$email_templates = EmailTemplate::cursor();
foreach ($email_templates as $email_template) {
Log::channel('stderr')->info('Updating email template:' . $email_template->id);
$body = preg_replace('%<p(.*?)>|</p>%s', '', $email_template->body);
$email_template->body = $body;
$email_template->save();
Log::channel('stderr')->info('Email Template updated:' . $email_template->id);
}
Log::channel('stderr')->info('Email Templates updated.');
}
public function deleteOldFiles() public function deleteOldFiles()
{ {
Log::channel('stderr')->info('Deleting old files...'); Log::channel('stderr')->info('Deleting old files...');

View File

@ -80,6 +80,9 @@ export default {
}, },
content (newVal) { content (newVal) {
// #337y1z3 This issue reason <p> tag broken email template
newVal = newVal.replace(/(<p[^>]+?>|<p>|<\/p>)/img, "");
this.$emit('input', newVal); this.$emit('input', newVal);
}, },
}, },