diff --git a/app/Listeners/Update/V21/Version2119.php b/app/Listeners/Update/V21/Version2119.php new file mode 100644 index 000000000..22fe958d0 --- /dev/null +++ b/app/Listeners/Update/V21/Version2119.php @@ -0,0 +1,56 @@ +skipThisUpdate($event)) { + return; + } + + $this->updateEmailTemplate(); + + Artisan::call('cache:clear'); + } + + protected function updateEmailTemplate() + { + $company_id = company_id(); + + $companies = Company::cursor(); + + foreach ($companies as $company) { + $company->makeCurrent(); + + EmailTemplate::create([ + 'company_id' => $company->id, + 'alias' => 'payment_new_vendor', + 'class' => 'App\Notifications\Purchase\Payment', + 'name' => 'settings.email.templates.payment_new_vendor', + 'subject' => trans('email_templates.payment_new_vendor.subject'), + 'body' => trans('email_templates.payment_new_vendor.body'), + ]); + } + + company($company_id)->makeCurrent(); + } +} diff --git a/app/Notifications/Purchase/Payment.php b/app/Notifications/Purchase/Payment.php index 20afda5d4..c325c97f6 100644 --- a/app/Notifications/Purchase/Payment.php +++ b/app/Notifications/Purchase/Payment.php @@ -79,7 +79,7 @@ class Payment extends Notification return [ 'template_alias' => $this->template->alias, 'payment_id' => $this->payment->id, - 'customer_name' => $this->payment->contact->name, + 'vendor_name' => $this->payment->contact->name, 'amount' => $this->payment->amount, 'payment_date' => company_date($this->payment->paid_at), ]; @@ -91,7 +91,7 @@ class Payment extends Notification '{payment_amount}', '{payment_date}', '{payment_admin_link}', - '{customer_name}', + '{vendor_name}', '{company_name}', '{company_email}', '{company_tax_number}', diff --git a/app/Providers/Event.php b/app/Providers/Event.php index 772e7662e..8fc0a0a0c 100644 --- a/app/Providers/Event.php +++ b/app/Providers/Event.php @@ -35,6 +35,7 @@ class Event extends Provider 'App\Listeners\Update\V21\Version2116', 'App\Listeners\Update\V21\Version2117', 'App\Listeners\Update\V21\Version2118', + 'App\Listeners\Update\V21\Version2119', ], 'Illuminate\Auth\Events\Login' => [ 'App\Listeners\Auth\Login', diff --git a/database/seeds/EmailTemplates.php b/database/seeds/EmailTemplates.php index c9eccdebf..f2550fe12 100644 --- a/database/seeds/EmailTemplates.php +++ b/database/seeds/EmailTemplates.php @@ -77,6 +77,11 @@ class EmailTemplates extends Seeder 'class' => 'App\Notifications\Sale\Revenue', 'name' => 'settings.email.templates.revenue_new_customer', ], + [ + 'alias' => 'payment_new_vendor', + 'class' => 'App\Notifications\Purchase\Payment', + 'name' => 'settings.email.templates.payment_new_vendor', + ], ]; foreach ($templates as $template) { diff --git a/resources/lang/en-GB/email_templates.php b/resources/lang/en-GB/email_templates.php index 526c9c0d0..718d00657 100644 --- a/resources/lang/en-GB/email_templates.php +++ b/resources/lang/en-GB/email_templates.php @@ -51,4 +51,9 @@ return [ 'subject' => '{revenue_date} payment created', 'body' => 'Dear {customer_name},

We have prepared the following payment.

You can see the payment details from the following link: {revenue_date}.

Feel free to contact us with any questions..

Best Regards,
{company_name}', ], + + 'payment_new_vendor' => [ + 'subject' => '{revenue_date} payment created', + 'body' => 'Dear {vendor_name},

We have prepared the following payment.

You can see the payment details from the following link: {payment_date}.

Feel free to contact us with any questions..

Best Regards,
{company_name}', + ], ]; diff --git a/resources/views/purchases/payments/show.blade.php b/resources/views/purchases/payments/show.blade.php index 3a0dcb955..661712a3b 100644 --- a/resources/views/purchases/payments/show.blade.php +++ b/resources/views/purchases/payments/show.blade.php @@ -3,7 +3,7 @@ @section('title', trans('payments.payment_made')) @section('new_button') - + @endsection @section('content')