From 6d5d1da472f0d0909a90cbac24709f6c151e7e1a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 Mar 2020 22:09:43 +1100 Subject: [PATCH] Fixes for pdf_variables validation (#3419) * Client and System Notifications * Fix for group settings currency not applying correctly. * Split head out of design in order to reuse headers and footers * export the designs * Fixes for pdf_variables --- app/Designs/AbstractDesign.php | 1 + app/Designs/Bold.php | 35 +++-- app/Designs/Business.php | 29 ++-- app/Designs/Clean.php | 31 ++-- app/Designs/Creative.php | 29 ++-- app/Designs/Custom.php | 9 +- app/Designs/Designer.php | 3 +- app/Designs/Elegant.php | 31 ++-- app/Designs/Hipster.php | 32 ++-- app/Designs/Modern.php | 15 +- app/Designs/Photo.php | 33 ++-- app/Designs/Plain.php | 32 ++-- app/Designs/Playful.php | 29 ++-- app/Events/Misc/InvitationWasViewed.php | 40 +++++ app/Helpers/Email/InvoiceEmail.php | 8 +- .../ClientPortal/InvitationController.php | 10 +- app/Http/Controllers/InvoiceController.php | 9 ++ .../Requests/Client/StoreClientRequest.php | 2 +- app/Http/Requests/User/StoreUserRequest.php | 2 +- .../Invoice/InvoiceEmailActivity.php | 4 +- .../Invoice/InvoiceEmailedNotification.php | 56 +++++++ .../Misc/InvitationViewedListener.php | 55 +++++++ app/Listeners/Payment/PaymentNotification.php | 7 +- app/Models/Currency.php | 1 + app/Models/QuoteInvitation.php | 5 + .../Admin/EntityViewedNotification.php | 131 ++++++++++++++++ .../Admin/InvoiceSentNotification.php | 142 ++++++++++++++++++ .../InvoiceViewedNotification.php | 7 +- .../NewPartialPaymentNotification.php | 2 +- .../NewPaymentNotification.php | 2 +- app/Providers/EventServiceProvider.php | 8 + app/Utils/Traits/Inviteable.php | 10 +- app/Utils/Traits/SettingsSaver.php | 5 + database/seeds/DesignSeeder.php | 17 +++ resources/lang/en/texts.php | 7 +- 35 files changed, 714 insertions(+), 125 deletions(-) create mode 100644 app/Events/Misc/InvitationWasViewed.php create mode 100644 app/Listeners/Invoice/InvoiceEmailedNotification.php create mode 100644 app/Listeners/Misc/InvitationViewedListener.php create mode 100644 app/Notifications/Admin/EntityViewedNotification.php create mode 100644 app/Notifications/Admin/InvoiceSentNotification.php rename app/Notifications/{Ninja => Admin}/InvoiceViewedNotification.php (96%) rename app/Notifications/{Payment => Admin}/NewPartialPaymentNotification.php (99%) rename app/Notifications/{Payment => Admin}/NewPaymentNotification.php (98%) diff --git a/app/Designs/AbstractDesign.php b/app/Designs/AbstractDesign.php index 4954822019..591a4ba757 100644 --- a/app/Designs/AbstractDesign.php +++ b/app/Designs/AbstractDesign.php @@ -13,6 +13,7 @@ namespace App\Designs; abstract class AbstractDesign { + abstract public function include(); abstract public function header(); diff --git a/app/Designs/Bold.php b/app/Designs/Bold.php index 8a6a14d795..431995e524 100644 --- a/app/Designs/Bold.php +++ b/app/Designs/Bold.php @@ -17,21 +17,21 @@ class Bold extends AbstractDesign public function __construct() { } - public function header() { - - return ' - - - - $number - - - - - + public function include() + { + return ' + + + + $number + + + + + + '; + } + public function header() { + + return '
diff --git a/app/Designs/Business.php b/app/Designs/Business.php index c3682b9036..3e244d8abc 100644 --- a/app/Designs/Business.php +++ b/app/Designs/Business.php @@ -17,21 +17,21 @@ class Business extends AbstractDesign public function __construct() { } - public function header() { - + public function include() + { return ' - - - - $number - - - - - + + '; + } + + public function header() { + + return ' +
diff --git a/app/Designs/Clean.php b/app/Designs/Clean.php index f993422c28..fe410d490b 100644 --- a/app/Designs/Clean.php +++ b/app/Designs/Clean.php @@ -17,21 +17,22 @@ class Clean extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - - - + + '; + } + + + public function header() { + + return ' +
diff --git a/app/Designs/Creative.php b/app/Designs/Creative.php index 791526942f..5b3ddd18f7 100644 --- a/app/Designs/Creative.php +++ b/app/Designs/Creative.php @@ -20,21 +20,22 @@ class Creative extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - + public function include() + { + return ' + + + + $number + + + - + + '; + } + + + public function header() { + + return ' +
diff --git a/app/Designs/Custom.php b/app/Designs/Custom.php index 5d88133f2f..30ba401a9e 100644 --- a/app/Designs/Custom.php +++ b/app/Designs/Custom.php @@ -13,7 +13,8 @@ namespace App\Designs; class Custom extends AbstractDesign { - + private $include; + private $header; private $body; @@ -26,6 +27,7 @@ class Custom extends AbstractDesign public function __construct($design) { + $this->include = $design->include; $this->header = $design->header; @@ -39,6 +41,11 @@ class Custom extends AbstractDesign } + public function include() + { + return $this->include; + } + public function header() { diff --git a/app/Designs/Designer.php b/app/Designs/Designer.php index 5aa110a439..3d1d002134 100644 --- a/app/Designs/Designer.php +++ b/app/Designs/Designer.php @@ -69,7 +69,8 @@ class Designer { { $this->exportVariables($entity) - ->setDesign($this->getSection('header')) + ->setDesign($this->getSection('include')) + ->setDesign($this->getSection('header')) ->setDesign($this->getSection('body')) ->setDesign($this->getTable($entity)) ->setDesign($this->getSection('footer')); diff --git a/app/Designs/Elegant.php b/app/Designs/Elegant.php index da5115950c..78020a3837 100644 --- a/app/Designs/Elegant.php +++ b/app/Designs/Elegant.php @@ -17,21 +17,22 @@ class Elegant extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - - - + + '; + } + + + public function header() { + + return ' +
diff --git a/app/Designs/Hipster.php b/app/Designs/Hipster.php index 099c00790d..89b67ea4f3 100644 --- a/app/Designs/Hipster.php +++ b/app/Designs/Hipster.php @@ -17,21 +17,22 @@ class Hipster extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - - - + + + '; + } + + + public function header() { + + return ' +
diff --git a/app/Designs/Modern.php b/app/Designs/Modern.php index aba551eb6c..ccbc98c99f 100644 --- a/app/Designs/Modern.php +++ b/app/Designs/Modern.php @@ -17,10 +17,11 @@ class Modern extends AbstractDesign public function __construct() { } - public function header() { - return ' - + public function include() + { + return ' + $number @@ -34,6 +35,14 @@ class Modern extends AbstractDesign + '; + } + + + public function header() { + + return ' +

$company.name

diff --git a/app/Designs/Photo.php b/app/Designs/Photo.php index aa63d3266a..2ec146db90 100644 --- a/app/Designs/Photo.php +++ b/app/Designs/Photo.php @@ -17,23 +17,34 @@ class Photo extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - - - + + + '; + } + + + + public function header() { + + return ' + - + + + '; + } + + + public function header() { + + return ' +
$company_logo diff --git a/app/Designs/Playful.php b/app/Designs/Playful.php index 5134e2c21a..3dac04574e 100644 --- a/app/Designs/Playful.php +++ b/app/Designs/Playful.php @@ -17,21 +17,22 @@ class Playful extends AbstractDesign public function __construct() { } - public function header() { - return ' - - - - $number - - - - - + + '; + } + + public function header() { + + return '
diff --git a/app/Events/Misc/InvitationWasViewed.php b/app/Events/Misc/InvitationWasViewed.php new file mode 100644 index 0000000000..0f5a5463af --- /dev/null +++ b/app/Events/Misc/InvitationWasViewed.php @@ -0,0 +1,40 @@ +entity = $entity; + $this->invitation = $invitation; + } +} diff --git a/app/Helpers/Email/InvoiceEmail.php b/app/Helpers/Email/InvoiceEmail.php index 8e603168be..21f5c2434f 100644 --- a/app/Helpers/Email/InvoiceEmail.php +++ b/app/Helpers/Email/InvoiceEmail.php @@ -11,6 +11,7 @@ namespace App\Helpers\Email; use App\Models\Invoice; use App\Models\InvoiceInvitation; +use App\Utils\Number; class InvoiceEmail extends EmailBuilder { @@ -30,7 +31,12 @@ class InvoiceEmail extends EmailBuilder /* Use default translations if a custom message has not been set*/ if (iconv_strlen($body_template) == 0) { $body_template = trans('texts.invoice_message', - ['invoice' => $invoice->number, 'company' => $invoice->company->present()->name()], null, + [ + 'invoice' => $invoice->number, + 'company' => $invoice->company->present()->name(), + 'amount' => Number::formatMoney($invoice->balance, $invoice->client), + ], + null, $invoice->client->locale()); } diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 431e04e135..8ed79a8332 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -41,8 +41,14 @@ class InvitationController extends Controller } else { auth()->guard('contact')->login($invitation->contact, false); } - - $invitation->markViewed(); + + if(!request()->has('is_admin')){ + + $invitation->markViewed(); + + event(new InvitationWasViewed($entity, $invitation)); + + } return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]); } else { diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 815a639776..cd1c47375a 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; use App\Events\Invoice\InvoiceWasCreated; +use App\Events\Invoice\InvoiceWasEmailed; use App\Events\Invoice\InvoiceWasUpdated; use App\Factory\CloneInvoiceFactory; use App\Factory\CloneInvoiceToQuoteFactory; @@ -675,6 +676,9 @@ class InvoiceController extends BaseController { } break; case 'email': + + $this->reminder_template = $invoice->calculateTemplate(); + $invoice->invitations->each(function ($invitation) use($invoice){ $email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template); @@ -683,6 +687,11 @@ class InvoiceController extends BaseController { }); + if($invoice->invitations->count() > 0){ + \Log::error("more than one invitation to send"); + event(new InvoiceWasEmailed($invoice->invitations->first())); + } + if (!$bulk) { return response()->json(['message' => 'email sent'], 200); } diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index 43cf27f177..6353b58998 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -94,7 +94,7 @@ class StoreClientRequest extends Request { $group_settings = GroupSetting::find($input['group_settings_id']); - if($group_settings && property_exists($group_settings, 'currency_id') && is_int($group_settings->currency_id)) + if($group_settings && property_exists($group_settings->settings, 'currency_id') && is_int($group_settings->settings->currency_id)) $input['settings']->currency_id = $group_settings->currency_id; else $input['settings']->currency_id = auth()->user()->company()->settings->currency_id; diff --git a/app/Http/Requests/User/StoreUserRequest.php b/app/Http/Requests/User/StoreUserRequest.php index b8594cdd1d..bce91953b5 100644 --- a/app/Http/Requests/User/StoreUserRequest.php +++ b/app/Http/Requests/User/StoreUserRequest.php @@ -74,7 +74,7 @@ class StoreUserRequest extends Request $this->replace($input); } - + //@todo make sure the user links back to the account ID for this company!!!!!! public function fetchUser() :User { $user = MultiDB::hasUser(['email' => $this->input('email')]); diff --git a/app/Listeners/Invoice/InvoiceEmailActivity.php b/app/Listeners/Invoice/InvoiceEmailActivity.php index 8aa9db0ea5..f0ca3d4086 100644 --- a/app/Listeners/Invoice/InvoiceEmailActivity.php +++ b/app/Listeners/Invoice/InvoiceEmailActivity.php @@ -46,9 +46,9 @@ class InvoiceEmailActivity implements ShouldQueue $fields->invoice_id = $event->invitation->invoice->id; $fields->user_id = $event->invitation->invoice->user_id; $fields->company_id = $event->invitation->invoice->company_id; - $fields->contact_id = $event->invitation->invoice->client_contact_id; + $fields->client_contact_id = $event->invitation->invoice->client_contact_id; $fields->activity_type_id = Activity::EMAIL_INVOICE; - $this->activity_repo->save($fields, $event->invoice); + $this->activity_repo->save($fields, $event->invitation->invoice); } } diff --git a/app/Listeners/Invoice/InvoiceEmailedNotification.php b/app/Listeners/Invoice/InvoiceEmailedNotification.php new file mode 100644 index 0000000000..17b2aede2b --- /dev/null +++ b/app/Listeners/Invoice/InvoiceEmailedNotification.php @@ -0,0 +1,56 @@ +invitation; + + foreach($invitation->company->company_users as $company_user) + { + + $company_user->user->notify(new InvoiceSentNotification($invitation, $invitation->company)); + + } + + if(isset($invitation->company->slack_webhook_url)){ + + Notification::route('slack', $invitation->company->slack_webhook_url) + ->notify(new InvoiceSentNotification($invitation, $invitation->company, true)); + + } + } +} diff --git a/app/Listeners/Misc/InvitationViewedListener.php b/app/Listeners/Misc/InvitationViewedListener.php new file mode 100644 index 0000000000..3b3c2d6d15 --- /dev/null +++ b/app/Listeners/Misc/InvitationViewedListener.php @@ -0,0 +1,55 @@ +entity; + $invitation = $event->invitation; + + $notification = new EntityViewedNotification($invitation, $entity_name); + + foreach($invitation->company->company_users as $company_user) + { + $company_user->user->notify($notification); + } + + if(isset($invitation->company->slack_webhook_url)){ + + $notification->is_system = true; + + Notification::route('slack', $payment->company->slack_webhook_url) + ->notify($notification); + + } + } +} diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index 8d906d5fc7..ee9d1f562f 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -14,7 +14,7 @@ namespace App\Listeners\Payment; use App\Models\Activity; use App\Models\Invoice; use App\Models\Payment; -use App\Notifications\Payment\NewPaymentNotification; +use App\Notifications\Admin\NewPaymentNotification; use App\Repositories\ActivityRepository; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -41,8 +41,9 @@ class PaymentNotification implements ShouldQueue { $payment = $event->payment; - //$invoices = $payment->invoices; - + //todo need to iterate through teh company user and determine if the user + //will receive this notification. + foreach($payment->company->company_users as $company_user) { $company_user->user->notify(new NewPaymentNotification($payment, $payment->company)); diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 7a3ebdc2aa..adc551eb99 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -18,6 +18,7 @@ class Currency extends StaticModel public $timestamps = false; protected $casts = [ + 'exchange_rate' => 'float', 'swap_currency_symbol' => 'boolean', 'updated_at' => 'timestamp', 'created_at' => 'timestamp', diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index 942cd99c1e..375df47ba7 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -71,4 +71,9 @@ class QuoteInvitation extends BaseModel return sprintf('

%s: %s', $this->signature_base64, ctrans('texts.signed'), $this->createClientDate($this->signature_date, $this->contact->client->timezone()->name)); } + + public function markViewed() { + $this->viewed_date = Carbon::now(); + $this->save(); + } } diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php new file mode 100644 index 0000000000..1d6459934a --- /dev/null +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -0,0 +1,131 @@ +entity = $invitation->{$entity_name}; + $this->contact = $invitation->contact; + $this->company = $invitation->company; + $this->settings = $this->entity->client->getMergedSettings(); + $this->is_system = $is_system; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + + return $this->is_system ? ['slack'] : ['mail']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + $data = $this->buildDataArray(); + $subject = $this->buildSubject(); + + return (new MailMessage) + ->subject($subject) + ->markdown('email.admin.generic', $data); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } + + public function toSlack($notifiable) + { + $logo = $this->company->present()->logo(); + $amount = Number::formatMoney($this->entity->amount, $this->entity->client); + + return (new SlackMessage) + ->success() + ->from(ctrans('texts.notification_bot')) + ->image($logo) + ->content(ctrans("texts.notification_{$this->entity_name}_viewed", + [ + 'amount' => $amount, + 'client' => $this->contact->present()->name(), + $this->entity_name => $this->entity->number + ])); + + } + + + private function buildDataArray() + { + + $amount = Number::formatMoney($this->entity->amount, $this->entity->client); + $subject = ctrans("texts.notification_{$this->entity_name}_viewed_subject", + [ + 'client' => $this->contact->present()->name(), + $this->entity_name => $this->entity->number, + ]); + + $data = [ + 'title' => $subject, + 'message' => ctrans("texts.notification_{$this->entity_name}_viewed", + [ + 'amount' => $amount, + 'client' => $this->contact->present()->name(), + $this->entity_name => $this->entity->number, + ]), + 'url' => config('ninja.site_url') . "/{$this->entity_name}s/" . $this->entity->hashed_id, + 'button' => ctrans("texts.view_{$this->entity_name}"), + 'signature' => $this->settings->email_signature, + 'logo' => $this->company->present()->logo(), + ]; + + } +} diff --git a/app/Notifications/Admin/InvoiceSentNotification.php b/app/Notifications/Admin/InvoiceSentNotification.php new file mode 100644 index 0000000000..3c3a67e4a2 --- /dev/null +++ b/app/Notifications/Admin/InvoiceSentNotification.php @@ -0,0 +1,142 @@ +invoice = $invitation->invoice; + $this->contact = $invitation->contact; + $this->company = $company; + $this->settings = $this->invoice->client->getMergedSettings(); + $this->is_system = $is_system; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + + return $this->is_system ? ['slack'] : ['mail']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + + $amount = Number::formatMoney($this->invoice->amount, $this->invoice->client); + $subject = ctrans('texts.notification_invoice_sent_subject', + [ + 'client' => $this->contact->present()->name(), + 'invoice' => $this->invoice->number, + ]); + + $data = [ + 'title' => $subject, + 'message' => ctrans('texts.notification_invoice_sent', + [ + 'amount' => $amount, + 'client' => $this->contact->present()->name(), + 'invoice' => $this->invoice->number, + ]), + 'url' => config('ninja.site_url') . '/invoices/' . $this->invoice->hashed_id, + 'button' => ctrans('texts.view_invoice'), + 'signature' => $this->settings->email_signature, + 'logo' => $this->company->present()->logo(), + ]; + + + return (new MailMessage) + ->subject($subject) + ->markdown('email.admin.generic', $data); + + + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } + + public function toSlack($notifiable) + { + $logo = $this->company->present()->logo(); + $amount = Number::formatMoney($this->invoice->amount, $this->invoice->client); + + // return (new SlackMessage) + // ->success() + // ->from(ctrans('texts.notification_bot')) + // ->image($logo) + // ->content(ctrans('texts.notification_invoice_sent', + // [ + // 'amount' => $amount, + // 'client' => $this->contact->present()->name(), + // 'invoice' => $this->invoice->number + // ])); + + + return (new SlackMessage) + ->from(ctrans('texts.notification_bot')) + ->success() + ->image('https://app.invoiceninja.com/favicon-v2.png') + ->content(trans('texts.notification_invoice_sent_subject', + [ + 'amount' => $amount, + 'client' => $this->contact->present()->name(), + 'invoice' => $this->invoice->number + ])) + ->attachment(function ($attachment) use($amount){ + $attachment->title(ctrans('texts.invoice_number_placeholder', ['invoice' => $this->invoice->number]), 'http://linky') + ->fields([ + ctrans('texts.client') => $this->contact->present()->name(), + ctrans('texts.amount') => $amount, + ]); + }); + } + +} diff --git a/app/Notifications/Ninja/InvoiceViewedNotification.php b/app/Notifications/Admin/InvoiceViewedNotification.php similarity index 96% rename from app/Notifications/Ninja/InvoiceViewedNotification.php rename to app/Notifications/Admin/InvoiceViewedNotification.php index dc1d1c2488..9f2037e0d9 100644 --- a/app/Notifications/Ninja/InvoiceViewedNotification.php +++ b/app/Notifications/Admin/InvoiceViewedNotification.php @@ -1,6 +1,6 @@ $amount, 'client' => $this->contact->present()->name(), - 'invoice' => $this->invoice->number, - ]); + 'invoice' => $this->invoice->number + ])); + } } diff --git a/app/Notifications/Payment/NewPartialPaymentNotification.php b/app/Notifications/Admin/NewPartialPaymentNotification.php similarity index 99% rename from app/Notifications/Payment/NewPartialPaymentNotification.php rename to app/Notifications/Admin/NewPartialPaymentNotification.php index e1d303eac8..ded25364f3 100644 --- a/app/Notifications/Payment/NewPartialPaymentNotification.php +++ b/app/Notifications/Admin/NewPartialPaymentNotification.php @@ -1,6 +1,6 @@ [ InvoiceEmailActivity::class, + InvoiceEmailedNotification::class, ], InvoiceWasEmailedAndFailed::class => [ InvoiceEmailFailedActivity::class, ], + + InvitationWasViewed::class => [ + InvitationViewedListener::class + ], ]; diff --git a/app/Utils/Traits/Inviteable.php b/app/Utils/Traits/Inviteable.php index ca3cc1e42d..e26b221d46 100644 --- a/app/Utils/Traits/Inviteable.php +++ b/app/Utils/Traits/Inviteable.php @@ -24,7 +24,7 @@ trait Inviteable * * @return string The status. */ - public function getStatus() : string + public function getStatus() :string { $status = ''; @@ -44,7 +44,7 @@ trait Inviteable return $status; } - public function getLink() : string + public function getLink() :string { $entity_type = strtolower(class_basename($this->entityType())); @@ -67,4 +67,10 @@ trait Inviteable } } + + public function getAdminLink() :string + { + + return $this->getLink(). '?is_admin=true'; + } } diff --git a/app/Utils/Traits/SettingsSaver.php b/app/Utils/Traits/SettingsSaver.php index 48359250b8..f05f846955 100644 --- a/app/Utils/Traits/SettingsSaver.php +++ b/app/Utils/Traits/SettingsSaver.php @@ -112,6 +112,11 @@ trait SettingsSaver private function checkSettingType($settings) : \stdClass { $settings = (object)$settings; + + /* Because of the object casting we cannot check pdf_variables */ + if(property_exists($settings, 'pdf_variables')) + unset($settings->pdf_variables); + $casts = CompanySettings::$casts; foreach ($casts as $key => $value) { diff --git a/database/seeds/DesignSeeder.php b/database/seeds/DesignSeeder.php index e9737a3eab..440e0f7262 100644 --- a/database/seeds/DesignSeeder.php +++ b/database/seeds/DesignSeeder.php @@ -35,6 +35,23 @@ class DesignSeeder extends Seeder if(!$d) Design::create($design); } + + foreach(Design::all() as $design){ + + $class = 'App\Designs\\'.$design->name; + $invoice_design = new $class(); + + $design_object = new \stdClass; + $design_object->include = $invoice_design->include(); + $design_object->header = $invoice_design->header(); + $design_object->body = $invoice_design->body(); + $design_object->table_styles = $invoice_design->table_styles(); + $design_object->table = $invoice_design->table(); + $design_object->footer = $invoice_design->footer(); + + $design->design = $design_object; + $design->save(); + } } } \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 7ef674ad7d..56e738e7d0 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -251,9 +251,13 @@ $LANG = array( 'notification_invoice_paid_subject' => 'Invoice :invoice was paid by :client', 'notification_invoice_sent_subject' => 'Invoice :invoice was sent to :client', 'notification_invoice_viewed_subject' => 'Invoice :invoice was viewed by :client', + 'notification_credit_viewed_subject' => 'Credit :credit was viewed by :client', + 'notification_quote_viewed_subject' => 'Quote :quote was viewed by :client', 'notification_invoice_paid' => 'A payment of :amount was made by client :client towards Invoice :invoice.', 'notification_invoice_sent' => 'The following client :client was emailed Invoice :invoice for :amount.', 'notification_invoice_viewed' => 'The following client :client viewed Invoice :invoice for :amount.', + 'notification_credit_viewed' => 'The following client :client viewed Credit :credit for :amount.', + 'notification_quote_viewed' => 'The following client :client viewed Quote :quote for :amount.', 'reset_password' => 'You can reset your account password by clicking the following button:', 'secure_payment' => 'Secure Payment', 'card_number' => 'Card Number', @@ -3124,8 +3128,9 @@ $LANG = array( 'notification_payment_paid' => 'A payment of :amount was made by client :client towards :invoice', 'notification_partial_payment_paid' => 'A partial payment of :amount was made by client :client towards :invoice', 'notification_bot' => 'Notification Bot', - + 'invoice_number_placeholder' => 'Invoice # :invoice', 'email_link_not_working' => 'If button above isn\'t working for you, please click on the link', + ); return $LANG;