From 5e6fc9117a3b799ba41cebd3b398bd29f273f2b1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 14 Dec 2022 09:20:26 +1100 Subject: [PATCH] Minor fixes --- app/Mail/Engine/InvoiceEmailEngine.php | 2 +- app/Mail/TemplateEmail.php | 3 --- app/Models/BaseModel.php | 7 ++----- app/Utils/Traits/NumberFormatter.php | 1 - lang/en/texts.php | 4 +++- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index f19d156ebc..26f3abc26b 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -130,7 +130,7 @@ class InvoiceEmailEngine extends BaseEmailEngine $pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle()); - $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]); + $this->setAttachments([['file' => base64_encode($pdf), 'name' => ctrans('texts.invoice') . " " .$this->invoice->numberFormatter().'.pdf']]); } //attach third party documents diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index aad3ec35c4..8f4299c939 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -118,14 +118,11 @@ class TemplateEmail extends Mailable 'logo' => $this->company->present()->logo($settings), ]); - - //22-10-2022 - Performance - To improve the performance/reliability of sending emails, attaching as Data is much better, stubs in place foreach ($this->build_email->getAttachments() as $file) { if(array_key_exists('file', $file)) $this->attachData(base64_decode($file['file']), $file['name']); else $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); - } if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 2983efd964..22fc9ba129 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -193,12 +193,9 @@ class BaseModel extends Model $number = strlen($this->number) >= 1 ? $this->number : class_basename($this) . "_" . Str::random(5); $formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $number); - // Remove any runs of periods (thanks falstro!) - $formatted_number = mb_ereg_replace("([\.]{2,})", '', $formatted_number); - - // $formatted_number = str_replace(" ", "_", $formatted_number); - //11-01-2021 fixes for multiple spaces + $formatted_number = mb_ereg_replace("([\.]{2,})", '', $formatted_number); + $formatted_number = preg_replace('/\s+/', '_', $formatted_number); return $formatted_number; diff --git a/app/Utils/Traits/NumberFormatter.php b/app/Utils/Traits/NumberFormatter.php index a83a85e51f..12c732c6d2 100644 --- a/app/Utils/Traits/NumberFormatter.php +++ b/app/Utils/Traits/NumberFormatter.php @@ -22,7 +22,6 @@ trait NumberFormatter return number_format($this->parseFloat(rtrim(sprintf('%f', $value), '0')), $precision, '.', ''); - // return number_format($this->parseFloat($value), $precision, '.', ''); } /** diff --git a/lang/en/texts.php b/lang/en/texts.php index ed0b754592..3bb6e40c14 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -4854,7 +4854,7 @@ $LANG = array( 'payment_type_Klarna' => 'Klarna', 'online_payment_email_help' => 'Send an email when an online payment is made', 'manual_payment_email_help' => 'Send an email when manually entering a payment', - 'mark_paid_payment_email_help' => 'Send an email when marking an invoice as pad', + 'mark_paid_payment_email_help' => 'Send an email when marking an invoice as paid', 'linked_transaction' => 'Successfully linked transaction', 'link_payment' => 'Link Payment', 'link_expense' => 'Link Expense', @@ -4900,6 +4900,8 @@ $LANG = array( 'otp_code_body' => 'Your one time passcode is :code', 'delete_tax_rate' => 'Delete Tax Rate', 'restore_tax_rate' => 'Restore Tax Rate', + 'company_backup_file' => 'Select company backup file', + 'company_backup_file_help' => 'Please upload the .zip file used to create this backup.' ); return $LANG;