diff --git a/Dockerfile b/Dockerfile index 46654b42..28c46c56 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 @@ -49,4 +51,3 @@ RUN touch database/database.sqlite && \ EXPOSE 9000 CMD ["php-fpm", "--nodaemonize"] - diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index aec266e1..86b6015e 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -175,12 +175,6 @@ class EstimatesController extends Controller ]); } - if (!config('mail.from.name')) { - return response()->json([ - 'error' => 'from_email_does_not_exist' - ]); - } - \Mail::to($email)->send(new EstimatePdf($data)); } @@ -343,12 +337,6 @@ class EstimatesController extends Controller ]); } - if (!config('mail.from.name')) { - return response()->json([ - 'error' => 'from_email_does_not_exist' - ]); - } - \Mail::to($email)->send(new EstimatePdf($data)); if ($estimate->status == Estimate::STATUS_DRAFT) { diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 2a3eb089..cf3aaa96 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; @@ -175,6 +175,7 @@ class InvoicesController extends Controller ]); } +<<<<<<< HEAD if (!config('mail.from.name')) { return response()->json([ 'error' => 'from_email_does_not_exist' @@ -182,6 +183,9 @@ class InvoicesController extends Controller } \Mail::to($email)->send(new invoicePdf($data)); +======= + \Mail::to($email)->send(new InvoicePdf($data)); +>>>>>>> c2eb22d66634a3b57d7ebade6ab9c7b359047c93 } $invoice = Invoice::with(['items', 'user', 'invoiceTemplate', 'taxes'])->find($invoice->id); @@ -410,6 +414,7 @@ class InvoicesController extends Controller ]); } +<<<<<<< HEAD if (!config('mail.from.name')) { return response()->json([ 'error' => 'from_email_does_not_exist' @@ -417,6 +422,9 @@ class InvoicesController extends Controller } \Mail::to($email)->send(new invoicePdf($data)); +======= + \Mail::to($email)->send(new InvoicePdf($data)); +>>>>>>> c2eb22d66634a3b57d7ebade6ab9c7b359047c93 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 b6a4f225..d89dddcf 100644 --- a/app/Mail/EstimatePdf.php +++ b/app/Mail/EstimatePdf.php @@ -29,6 +29,9 @@ class EstimatePdf extends Mailable */ public function build() { - return $this->markdown('emails.send.estimate', ['data', $this->data]); + $company = $this->data['company']['name']; + + 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 71% rename from app/Mail/invoicePdf.php rename to app/Mail/InvoicePdf.php index 3e2645ec..e9dbd616 100644 --- a/app/Mail/invoicePdf.php +++ b/app/Mail/InvoicePdf.php @@ -6,7 +6,7 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -class invoicePdf extends Mailable +class InvoicePdf extends Mailable { use Queueable, SerializesModels; @@ -29,6 +29,9 @@ class invoicePdf extends Mailable */ public function build() { - return $this->markdown('emails.send.invoice', ['data', $this->data]); + $company = $this->data['company']['name']; + + 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 72471677..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; } /** @@ -33,6 +30,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->subject("Payment from $company") + ->markdown('emails.send.payment', ['data', $this->data]); } } 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", 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