From a77e594da02740940a9008b15651ffc4a450a66f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 31 Dec 2017 11:01:02 +0200 Subject: [PATCH] Added 'approved quote' subscription --- app/Constants.php | 1 + app/Listeners/SubscriptionListener.php | 10 ++++++++++ app/Providers/EventServiceProvider.php | 1 + resources/lang/en/texts.php | 1 + resources/views/accounts/subscription.blade.php | 1 + 5 files changed, 14 insertions(+) diff --git a/app/Constants.php b/app/Constants.php index d2357e7fb1..703acd751f 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -319,6 +319,7 @@ if (! defined('APP_NAME')) { define('EVENT_CREATE_TASK', 18); define('EVENT_UPDATE_TASK', 19); define('EVENT_DELETE_TASK', 20); + define('EVENT_APPROVE_QUOTE', 21); define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN'); define('NINJA_ACCOUNT_KEY', env('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h')); diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index d7da75e088..769e007da4 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -11,6 +11,7 @@ use App\Events\ExpenseWasDeleted; use App\Events\QuoteItemsWereCreated; use App\Events\QuoteItemsWereUpdated; use App\Events\QuoteWasDeleted; +use App\Events\QuoteInvitationWasApproved; use App\Events\PaymentWasCreated; use App\Events\PaymentWasDeleted; use App\Events\InvoiceItemsWereCreated; @@ -132,6 +133,15 @@ class SubscriptionListener $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } + /** + * @param QuoteInvitationWasApproved $event + */ + public function approvedQuote(QuoteInvitationWasApproved $event) + { + $transformer = new InvoiceTransformer($event->quote->account); + $this->checkSubscriptions(EVENT_APPROVE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + } + /** * @param InvoiceWasDeleted $event */ diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 326724a9a2..3f9723c933 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -108,6 +108,7 @@ class EventServiceProvider extends ServiceProvider 'App\Events\QuoteInvitationWasApproved' => [ 'App\Listeners\ActivityListener@approvedQuote', 'App\Listeners\NotificationListener@approvedQuote', + 'App\Listeners\SubscriptionListener@approvedQuote', ], // Payments diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 5de58b6afa..3e12c9f8a6 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2593,6 +2593,7 @@ $LANG = array( 'subscription_event_18' => 'Created Task', 'subscription_event_19' => 'Updated Task', 'subscription_event_20' => 'Deleted Task', + 'subscription_event_21' => 'Approved Quote', 'subscriptions' => 'Subscriptions', 'updated_subscription' => 'Successfully updated subscription', 'created_subscription' => 'Successfully created subscription', diff --git a/resources/views/accounts/subscription.blade.php b/resources/views/accounts/subscription.blade.php index 1d9586958f..0c69db8189 100644 --- a/resources/views/accounts/subscription.blade.php +++ b/resources/views/accounts/subscription.blade.php @@ -38,6 +38,7 @@ trans('texts.quotes') => [ EVENT_CREATE_QUOTE => trans('texts.subscription_event_' . EVENT_CREATE_QUOTE), EVENT_UPDATE_QUOTE => trans('texts.subscription_event_' . EVENT_UPDATE_QUOTE), + EVENT_APPROVE_QUOTE => trans('texts.subscription_event_' . EVENT_APPROVE_QUOTE), EVENT_DELETE_QUOTE => trans('texts.subscription_event_' . EVENT_DELETE_QUOTE), ], trans('texts.tasks') => [