diff --git a/VERSION.txt b/VERSION.txt index 598bbaa3a03d..7d5275de2ccd 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.20 \ No newline at end of file +5.5.21 \ No newline at end of file diff --git a/app/DataMapper/Analytics/EmailCount.php b/app/DataMapper/Analytics/EmailCount.php new file mode 100644 index 000000000000..2c4745de3975 --- /dev/null +++ b/app/DataMapper/Analytics/EmailCount.php @@ -0,0 +1,59 @@ +int_metric1 = $int_metric1; + $this->string_metric5 = $string_metric5; + } +} diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 1722d0409e8f..03d49d7c5ae3 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -306,7 +306,7 @@ class PreviewController extends BaseController if (Ninja::isHosted()) { LightLogs::create(new LivePreview()) ->increment() - ->queue(); + ->batch(); } $response = Response::make($file_path, 200); diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index f5736c2587ee..8d7b11a8a5ee 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -69,7 +69,7 @@ class QueryLogging } LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()),0,180), $count, $time, $ip)) - ->queue(); + ->batch(); } return $response; diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index b6895b3db4a8..1b9331d8adb9 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -123,7 +123,7 @@ class NinjaMailerJob implements ShouldQueue ->send($this->nmo->mailable); LightLogs::create(new EmailSuccess($this->nmo->company->company_key)) - ->queue(); + ->batch(); /* Count the amount of emails sent across all the users accounts */ Cache::increment($this->company->account->key); diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index 0dca3f00e727..2f79eb177478 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -217,7 +217,7 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->request['MessageID'] ); - LightLogs::create($bounce)->queue(); + LightLogs::create($bounce)->batch(); SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); @@ -263,7 +263,7 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->request['MessageID'] ); - LightLogs::create($spam)->queue(); + LightLogs::create($spam)->batch(); SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); diff --git a/app/Mail/VendorTemplateEmail.php b/app/Mail/VendorTemplateEmail.php index 2211a0adccfe..670a59e93676 100644 --- a/app/Mail/VendorTemplateEmail.php +++ b/app/Mail/VendorTemplateEmail.php @@ -61,7 +61,7 @@ class VendorTemplateEmail extends Mailable } if ($this->build_email->getTemplate() == 'custom') { - $this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom'))); + $this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->company->getSetting('email_style_custom'))); } $settings = $this->company->settings; diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 461c7e7400b5..ba9fbb96c0fc 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -64,7 +64,7 @@ class Vendor extends BaseModel protected $touches = []; protected $with = [ - 'company', + 'contacts.company', ]; protected $presenter = VendorPresenter::class; diff --git a/app/Models/VendorContact.php b/app/Models/VendorContact.php index 72479d5a6939..6dd0cff534e6 100644 --- a/app/Models/VendorContact.php +++ b/app/Models/VendorContact.php @@ -45,10 +45,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference 'hashed_id', ]; - protected $with = [ - // 'vendor', - // 'company' - ]; + protected $with = []; protected $casts = [ 'updated_at' => 'timestamp', diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index ec6f9c75d78f..1de57a84e35b 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -1,4 +1,5 @@ setEntity() - ->setSettingsObject() - ->setTemplates() - ->replaceValues() - ->renderTemplate(); + ->setSettingsObject() + ->setTemplates() + ->replaceValues() + ->renderTemplate(); } private function setEntity() { if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) { - $class = 'App\Models\\'.ucfirst(Str::camel($this->entity)); + $class = 'App\Models\\' . ucfirst(Str::camel($this->entity)); $this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first(); } else { $this->mockEntity(); @@ -107,11 +108,10 @@ class TemplateEngine private function setSettingsObject() { - if($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order'){ + if ($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order') { $this->settings_entity = auth()->user()->company(); $this->settings = $this->settings_entity->settings; - } - elseif ($this->entity_obj->client()->exists()) { + } elseif ($this->entity_obj->client()->exists()) { $this->settings_entity = $this->entity_obj->client; $this->settings = $this->settings_entity->getMergedSettings(); } else { @@ -155,13 +155,11 @@ class TemplateEngine $this->raw_body = $this->body; $this->raw_subject = $this->subject; - if($this->entity == 'purchaseOrder'){ - $this->fakerValues(); - } - elseif ($this->entity_obj->client()->exists()) { + if ($this->entity_obj->client()->exists()) { $this->entityValues($this->entity_obj->client->primary_contact()->first()); - } - else { + } elseif ($this->entity_obj->vendor()->exists()) { + $this->entityValues($this->entity_obj->vendor->primary_contact()->first()); + } else { $this->fakerValues(); } @@ -184,16 +182,16 @@ class TemplateEngine ]); $this->body = $converter->convert($this->body)->getContent(); - } private function entityValues($contact) { - if($this->entity == 'purchaseOrder') + if (in_array($this->entity, ['purchaseOrder', 'purchase_order'])) $this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues(); else $this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues(); + $this->body = strtr($this->body, $this->labels_and_values['labels']); $this->body = strtr($this->body, $this->labels_and_values['values']); @@ -217,16 +215,15 @@ class TemplateEngine $data['footer'] = ''; $data['logo'] = auth()->user()->company()->present()->logo(); - if($this->entity_obj->client()->exists()) + if ($this->entity_obj->client()->exists()) $data = array_merge($data, Helpers::sharedEmailVariables($this->entity_obj->client)); - else{ + else { $data['signature'] = $this->settings->email_signature; $data['settings'] = $this->settings; $data['whitelabel'] = $this->entity_obj ? $this->entity_obj->company->account->isPaid() : true; $data['company'] = $this->entity_obj ? $this->entity_obj->company : ''; $data['settings'] = $this->settings; - } @@ -235,7 +232,6 @@ class TemplateEngine // In order to parse variables such as $signature in the body, // we need to replace strings with the values from HTMLEngine. - $wrapper = strtr($wrapper, $this->labels_and_values['values']); /*If no custom design exists, send back a blank!*/ @@ -269,7 +265,7 @@ class TemplateEngine private function mockEntity() { - if(!$this->entity && $this->template && str_contains($this->template, 'purchase_order')) + if (!$this->entity && $this->template && str_contains($this->template, 'purchase_order')) $this->entity = 'purchaseOrder'; DB::connection(config('database.default'))->beginTransaction(); @@ -289,7 +285,7 @@ class TemplateEngine 'send_email' => true, ]); - if (! $this->entity || $this->entity == 'invoice') { + if (!$this->entity || $this->entity == 'invoice') { $this->entity_obj = Invoice::factory()->create([ 'user_id' => auth()->user()->id, 'company_id' => auth()->user()->company()->id, @@ -321,40 +317,37 @@ class TemplateEngine - if($this->entity == 'purchaseOrder') - { + if ($this->entity == 'purchaseOrder') { $vendor = Vendor::factory()->create([ - 'user_id' => auth()->user()->id, - 'company_id' => auth()->user()->company()->id, - ]); + 'user_id' => auth()->user()->id, + 'company_id' => auth()->user()->company()->id, + ]); $contact = VendorContact::factory()->create([ - 'user_id' => auth()->user()->id, - 'company_id' => auth()->user()->company()->id, - 'vendor_id' => $vendor->id, - 'is_primary' => 1, - 'send_email' => true, - ]); + 'user_id' => auth()->user()->id, + 'company_id' => auth()->user()->company()->id, + 'vendor_id' => $vendor->id, + 'is_primary' => 1, + 'send_email' => true, + ]); $this->entity_obj = PurchaseOrder::factory()->create([ - 'user_id' => auth()->user()->id, - 'company_id' => auth()->user()->company()->id, - 'vendor_id' => $vendor->id, - ]); - - $invitation = PurchaseOrderInvitation::factory()->create([ - 'user_id' => auth()->user()->id, - 'company_id' => auth()->user()->company()->id, - 'purchase_order_id' => $this->entity_obj->id, - 'vendor_contact_id' => $contact->id, + 'user_id' => auth()->user()->id, + 'company_id' => auth()->user()->company()->id, + 'vendor_id' => $vendor->id, ]); + $invitation = PurchaseOrderInvitation::factory()->create([ + 'user_id' => auth()->user()->id, + 'company_id' => auth()->user()->company()->id, + 'purchase_order_id' => $this->entity_obj->id, + 'vendor_contact_id' => $contact->id, + ]); } - if($vendor) - { + if ($vendor) { $this->entity_obj->setRelation('invitations', $invitation); $this->entity_obj->setRelation('vendor', $vendor); @@ -362,10 +355,7 @@ class TemplateEngine $this->entity_obj->load('vendor'); $vendor->setRelation('company', auth()->user()->company()); $vendor->load('company'); - - } - else - { + } else { $this->entity_obj->setRelation('invitations', $invitation); $this->entity_obj->setRelation('client', $client); $this->entity_obj->setRelation('company', auth()->user()->company()); diff --git a/config/ninja.php b/config/ninja.php index ebead6b85e9d..5289374b4f34 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.20', - 'app_tag' => '5.5.20', + 'app_version' => '5.5.21', + 'app_tag' => '5.5.21', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),