From 0990ce4678b8d0490ce57df02b52b43f6474fc04 Mon Sep 17 00:00:00 2001 From: MakerLab <47223013+MakerLab-Dev@users.noreply.github.com> Date: Sat, 18 Jan 2020 16:29:48 +0100 Subject: [PATCH 1/7] cross-env should only be in devDependencies --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 157194c5..050f131d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "axios": "^0.19", "bootstrap": "^4.1.0", "chart.js": "^2.7.3", - "cross-env": "^5.1.4", "easy-pie-chart": "^2.1.7", "fs": "0.0.1-security", "guid": "0.0.12", From 406d098172e37f5b24c5df3cc1f704f848b75f0b Mon Sep 17 00:00:00 2001 From: Evgenij Date: Sun, 26 Jan 2020 23:18:15 +0300 Subject: [PATCH 2/7] Update Dockerfile Generation does not work due to: iconv(): Wrong charset, conversion from `UTF-8' to `UTF-8//IGNORE' is not allowed Installing the library gnu-libiconv will solve the problem --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 46654b42..a736bf4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,10 @@ RUN touch database/database.sqlite && \ chmod -R 775 storage/logs/ && \ chmod -R 775 bootstrap/cache/ +# Fix for https://github.com/bytefury/crater/issues/69 +RUN apk add --no-cache gnu-libiconv +ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php + EXPOSE 9000 CMD ["php-fpm", "--nodaemonize"] - From 5dcc7b9efd01d0988614aac99f3c4e7685dd450e Mon Sep 17 00:00:00 2001 From: mdpoulter Date: Mon, 27 Jan 2020 14:45:40 +0200 Subject: [PATCH 3/7] Add more descriptive subject lines. --- app/Mail/EstimatePdf.php | 5 ++++- app/Mail/PaymentPdf.php | 5 ++++- app/Mail/invoicePdf.php | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Mail/EstimatePdf.php b/app/Mail/EstimatePdf.php index 42e88ee2..ad32d23b 100644 --- a/app/Mail/EstimatePdf.php +++ b/app/Mail/EstimatePdf.php @@ -32,6 +32,9 @@ class EstimatePdf extends Mailable */ public function build() { - return $this->from($this->notificationEmail)->markdown('emails.send.estimate', ['data', $this->data]); + $company = $this->data['company']['name']; + return $this->from($this->notificationEmail) + ->subject("Estimate from $company") + ->markdown('emails.send.estimate', ['data', $this->data]); } } diff --git a/app/Mail/PaymentPdf.php b/app/Mail/PaymentPdf.php index 72471677..a69174cc 100644 --- a/app/Mail/PaymentPdf.php +++ b/app/Mail/PaymentPdf.php @@ -33,6 +33,9 @@ class PaymentPdf extends Mailable */ public function build() { - return $this->from($this->notificationEmail)->markdown('emails.send.payment', ['data', $this->data]); + $company = $this->data['company']['name']; + return $this->from($this->notificationEmail) + ->subject("Payment from $company") + ->markdown('emails.send.payment', ['data', $this->data]); } } diff --git a/app/Mail/invoicePdf.php b/app/Mail/invoicePdf.php index a7a4e5a9..fb9f43ca 100644 --- a/app/Mail/invoicePdf.php +++ b/app/Mail/invoicePdf.php @@ -32,6 +32,9 @@ class invoicePdf extends Mailable */ public function build() { - return $this->from($this->notificationEmail)->markdown('emails.send.invoice', ['data', $this->data]); + $company = $this->data['company']['name']; + return $this->from($this->notificationEmail) + ->subject("Invoice from $company") + ->markdown('emails.send.invoice', ['data', $this->data]); } } From 3401ca049e5132cdd3f3d74617e79940e509bfdf Mon Sep 17 00:00:00 2001 From: mdpoulter Date: Mon, 27 Jan 2020 14:47:02 +0200 Subject: [PATCH 4/7] Make viewed emails more descriptive. --- resources/views/emails/viewed/estimate.blade.php | 2 +- resources/views/emails/viewed/invoice.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/emails/viewed/estimate.blade.php b/resources/views/emails/viewed/estimate.blade.php index 10633bc3..ae1ab91a 100644 --- a/resources/views/emails/viewed/estimate.blade.php +++ b/resources/views/emails/viewed/estimate.blade.php @@ -1,6 +1,6 @@ @component('mail::message') # Introduction -Customer viewed this Estimate. +{{ $data['user']['name'] }} viewed this Estimate. @component('mail::button', ['url' => url('/admin/estimates/'.$data['estimate']['id'].'/view')]) Estimate diff --git a/resources/views/emails/viewed/invoice.blade.php b/resources/views/emails/viewed/invoice.blade.php index 71867466..f1a706cd 100644 --- a/resources/views/emails/viewed/invoice.blade.php +++ b/resources/views/emails/viewed/invoice.blade.php @@ -1,6 +1,6 @@ @component('mail::message') # Introduction -Customer viewed this Invoice. +{{ $data['user']['name'] }} viewed this Invoice. @component('mail::button', ['url' => url('/admin/invoices/'.$data['invoice']['id'].'/view')]) Invoice From 8ce7e14a02419e80722a802fac2602ac94a94ba9 Mon Sep 17 00:00:00 2001 From: mdpoulter Date: Mon, 27 Jan 2020 14:50:56 +0200 Subject: [PATCH 5/7] Add name in From field. --- app/Http/Controllers/EstimatesController.php | 24 ++--------------- app/Http/Controllers/InvoicesController.php | 27 +++----------------- app/Http/Controllers/PaymentController.php | 12 +-------- app/Mail/EstimatePdf.php | 9 +++---- app/Mail/EstimateViewed.php | 4 ++- app/Mail/{invoicePdf.php => InvoicePdf.php} | 11 +++----- app/Mail/InvoiceViewed.php | 4 ++- app/Mail/PaymentPdf.php | 9 +++---- 8 files changed, 22 insertions(+), 78 deletions(-) rename app/Mail/{invoicePdf.php => InvoicePdf.php} (67%) diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index f49f6f4b..86b6015e 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -168,10 +168,6 @@ class EstimatesController extends Controller $data['user'] = User::find($userId)->toArray(); $data['company'] = Company::find($estimate->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -179,13 +175,7 @@ class EstimatesController extends Controller ]); } - if (!$notificationEmail) { - return response()->json([ - 'error' => 'notification_email_does_not_exist' - ]); - } - - \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); + \Mail::to($email)->send(new EstimatePdf($data)); } $estimate = Estimate::with([ @@ -340,10 +330,6 @@ class EstimatesController extends Controller $data['company'] = Company::find($estimate->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -351,13 +337,7 @@ class EstimatesController extends Controller ]); } - if (!$notificationEmail) { - return response()->json([ - 'error' => 'notification_email_does_not_exist' - ]); - } - - \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); + \Mail::to($email)->send(new EstimatePdf($data)); if ($estimate->status == Estimate::STATUS_DRAFT) { $estimate->status = Estimate::STATUS_SENT; diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 01e4e674..3e0d8a03 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -12,7 +12,7 @@ use Crater\Invoice; use Crater\InvoiceItem; use Carbon\Carbon; use Crater\Item; -use Crater\Mail\invoicePdf; +use Crater\Mail\InvoicePdf; use function MongoDB\BSON\toJSON; use Illuminate\Support\Facades\Log; use Crater\User; @@ -167,11 +167,6 @@ class InvoicesController extends Controller $data['user'] = User::find($request->user_id)->toArray(); $data['company'] = Company::find($invoice->company_id); - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); - $email = $data['user']['email']; if (!$email) { @@ -180,13 +175,7 @@ class InvoicesController extends Controller ]); } - if (!$notificationEmail) { - return response()->json([ - 'error' => 'notification_email_does_not_exist' - ]); - } - - \Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); + \Mail::to($email)->send(new InvoicePdf($data)); } $invoice = Invoice::with(['items', 'user', 'invoiceTemplate', 'taxes'])->find($invoice->id); @@ -408,10 +397,6 @@ class InvoicesController extends Controller $data['user'] = User::find($userId)->toArray(); $data['company'] = Company::find($invoice->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -419,13 +404,7 @@ class InvoicesController extends Controller ]); } - if (!$notificationEmail) { - return response()->json([ - 'error' => 'notification_email_does_not_exist' - ]); - } - - \Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); + \Mail::to($email)->send(new InvoicePdf($data)); if ($invoice->status == Invoice::STATUS_DRAFT) { $invoice->status = Invoice::STATUS_SENT; diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 9a7e4873..a323ea05 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -305,10 +305,6 @@ class PaymentController extends Controller $data['user'] = User::find($userId)->toArray(); $data['company'] = Company::find($payment->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -316,13 +312,7 @@ class PaymentController extends Controller ]); } - if (!$notificationEmail) { - return response()->json([ - 'error' => 'notification_email_does_not_exist' - ]); - } - - \Mail::to($email)->send(new PaymentPdf($data, $notificationEmail)); + \Mail::to($email)->send(new PaymentPdf($data)); return response()->json([ 'success' => true diff --git a/app/Mail/EstimatePdf.php b/app/Mail/EstimatePdf.php index ad32d23b..d89dddcf 100644 --- a/app/Mail/EstimatePdf.php +++ b/app/Mail/EstimatePdf.php @@ -12,17 +12,14 @@ class EstimatePdf extends Mailable public $data = []; - public $notificationEmail = ''; - /** * Create a new message instance. * * @return void */ - public function __construct($data, $notificationEmail) + public function __construct($data) { $this->data = $data; - $this->notificationEmail = $notificationEmail; } /** @@ -33,8 +30,8 @@ class EstimatePdf extends Mailable public function build() { $company = $this->data['company']['name']; - return $this->from($this->notificationEmail) - ->subject("Estimate from $company") + + return $this->subject("Estimate from $company") ->markdown('emails.send.estimate', ['data', $this->data]); } } diff --git a/app/Mail/EstimateViewed.php b/app/Mail/EstimateViewed.php index 7cfde433..140ea461 100644 --- a/app/Mail/EstimateViewed.php +++ b/app/Mail/EstimateViewed.php @@ -31,6 +31,8 @@ class EstimateViewed extends Mailable public function build() { $email = $this->data['user']['email']; - return $this->from($email)->markdown('emails.viewed.estimate', ['data', $this->data]); + $name = $this->data['user']['name']; + return $this->from($email, $name) + ->markdown('emails.viewed.estimate', ['data', $this->data]); } } diff --git a/app/Mail/invoicePdf.php b/app/Mail/InvoicePdf.php similarity index 67% rename from app/Mail/invoicePdf.php rename to app/Mail/InvoicePdf.php index fb9f43ca..e9dbd616 100644 --- a/app/Mail/invoicePdf.php +++ b/app/Mail/InvoicePdf.php @@ -6,23 +6,20 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -class invoicePdf extends Mailable +class InvoicePdf extends Mailable { use Queueable, SerializesModels; public $data = []; - public $notificationEmail = ''; - /** * Create a new message instance. * * @return void */ - public function __construct($data, $notificationEmail) + public function __construct($data) { $this->data = $data; - $this->notificationEmail = $notificationEmail; } /** @@ -33,8 +30,8 @@ class invoicePdf extends Mailable public function build() { $company = $this->data['company']['name']; - return $this->from($this->notificationEmail) - ->subject("Invoice from $company") + + return $this->subject("Invoice from $company") ->markdown('emails.send.invoice', ['data', $this->data]); } } diff --git a/app/Mail/InvoiceViewed.php b/app/Mail/InvoiceViewed.php index 2a0bd06f..48356b4d 100644 --- a/app/Mail/InvoiceViewed.php +++ b/app/Mail/InvoiceViewed.php @@ -31,6 +31,8 @@ class InvoiceViewed extends Mailable public function build() { $email = $this->data['user']['email']; - return $this->from($email)->markdown('emails.viewed.invoice', ['data', $this->data]); + $name = $this->data['user']['name']; + return $this->from($email, $name) + ->markdown('emails.viewed.invoice', ['data', $this->data]); } } diff --git a/app/Mail/PaymentPdf.php b/app/Mail/PaymentPdf.php index a69174cc..775ba0eb 100644 --- a/app/Mail/PaymentPdf.php +++ b/app/Mail/PaymentPdf.php @@ -13,17 +13,14 @@ class PaymentPdf extends Mailable public $data = []; - public $notificationEmail = ''; - /** * Create a new message instance. * * @return void */ - public function __construct($data, $notificationEmail) + public function __construct($data) { $this->data = $data; - $this->notificationEmail = $notificationEmail; } /** @@ -34,8 +31,8 @@ class PaymentPdf extends Mailable public function build() { $company = $this->data['company']['name']; - return $this->from($this->notificationEmail) - ->subject("Payment from $company") + + return $this->subject("Payment from $company") ->markdown('emails.send.payment', ['data', $this->data]); } } From ee14070a7bbad29aefdfdb500d0d21c64fcdfcc0 Mon Sep 17 00:00:00 2001 From: Evgenij Date: Mon, 27 Jan 2020 22:37:41 +0300 Subject: [PATCH 6/7] Update Dockerfile slight change --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a736bf4e..39547c11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,9 +23,11 @@ FROM php:7.3.12-fpm-alpine # Use the default production configuration RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" -RUN apk add --no-cache libpng-dev libxml2-dev oniguruma-dev libzip-dev && \ +RUN apk add --no-cache libpng-dev libxml2-dev oniguruma-dev libzip-dev gnu-libiconv && \ docker-php-ext-install bcmath ctype json gd mbstring pdo pdo_mysql tokenizer xml zip +ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php + # Set container's working dir WORKDIR /app @@ -47,8 +49,6 @@ RUN touch database/database.sqlite && \ chmod -R 775 bootstrap/cache/ # Fix for https://github.com/bytefury/crater/issues/69 -RUN apk add --no-cache gnu-libiconv -ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php EXPOSE 9000 From 92f1f196bba6421863f8a2a67070823f53ba7b87 Mon Sep 17 00:00:00 2001 From: Evgenij Date: Mon, 27 Jan 2020 22:38:47 +0300 Subject: [PATCH 7/7] Update Dockerfile --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39547c11..28c46c56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,8 +48,6 @@ RUN touch database/database.sqlite && \ chmod -R 775 storage/logs/ && \ chmod -R 775 bootstrap/cache/ -# Fix for https://github.com/bytefury/crater/issues/69 - EXPOSE 9000 CMD ["php-fpm", "--nodaemonize"]