diff --git a/app/Jobs/Company/CreateCompanyTaskStatuses.php b/app/Jobs/Company/CreateCompanyTaskStatuses.php index d95954f8d25c..2c07dbf6cf1f 100644 --- a/app/Jobs/Company/CreateCompanyTaskStatuses.php +++ b/app/Jobs/Company/CreateCompanyTaskStatuses.php @@ -48,6 +48,9 @@ class CreateCompanyTaskStatuses MultiDB::setDb($this->company->db); + if(TaskStatus::where('company_id', $this->company->id)->count() > 0) + return; + $task_statuses = [ ['name' => ctrans('texts.backlog'), 'company_id' => $this->company->id, 'user_id' => $this->user->id, 'created_at' => now(), 'updated_at' => now(), 'status_order' => 1], ['name' => ctrans('texts.ready_to_do'), 'company_id' => $this->company->id, 'user_id' => $this->user->id, 'created_at' => now(), 'updated_at' => now(), 'status_order' => 2], diff --git a/app/Jobs/Util/RefreshPdfs.php b/app/Jobs/Util/RefreshPdfs.php new file mode 100644 index 000000000000..4de8e77457cd --- /dev/null +++ b/app/Jobs/Util/RefreshPdfs.php @@ -0,0 +1,76 @@ +company = $company; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + + MultiDB::setDb($this->company->db); + + + InvoiceInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating invoice pdf for {$invitation->invoice_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + QuoteInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating quote pdf for {$invitation->quote_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + + CreditInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating credit pdf for {$invitation->credit_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + } +}