diff --git a/app/Http/Controllers/Common/Notifications.php b/app/Http/Controllers/Common/Notifications.php index e19dd8c83..5e8c0356d 100644 --- a/app/Http/Controllers/Common/Notifications.php +++ b/app/Http/Controllers/Common/Notifications.php @@ -34,7 +34,19 @@ class Notifications extends Controller $notification->markAsRead(); } - $message = trans('messages.success.duplicated', ['type' => trans_choice('general.items', 1)]); + // Hide New Apps Notifications + $module_notifications = $this->getNotifications('new-apps' ); + + foreach ($module_notifications as $module_notification) { + setting()->set('notifications.'. user()->id . '.' . $module_notification->alias . '.name', $module_notification->name); + setting()->set('notifications.'. user()->id . '.' . $module_notification->alias . '.message', $module_notification->alias); + setting()->set('notifications.'. user()->id . '.' . $module_notification->alias . '.date', Date::now()); + setting()->set('notifications.'. user()->id . '.' . $module_notification->alias . '.status', '0'); + } + + setting()->save(); + + $message = trans('messages.success.duplicated', ['type' => trans_choice('general.notificatinos', 1)]); flash($message)->success(); diff --git a/app/Http/Livewire/Common/Notifications/NewApps.php b/app/Http/Livewire/Common/Notifications/NewApps.php index f3b4b0015..21e4a03e6 100644 --- a/app/Http/Livewire/Common/Notifications/NewApps.php +++ b/app/Http/Livewire/Common/Notifications/NewApps.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\Common\Notifications; +use Date; use App\Traits\Modules; use Livewire\Component; @@ -9,10 +10,91 @@ class NewApps extends Component { use Modules; + public function markRead($alias) + { + $notifications = $this->getNotifications('new-apps' ); + + foreach ($notifications as $notification) { + if ($notification->alias != $alias) { + continue; + } + + $readed = $notification; + } + + setting()->set('notifications.'. user()->id . '.' . $alias . '.name', $readed->name); + setting()->set('notifications.'. user()->id . '.' . $alias . '.message', $readed->alias); + setting()->set('notifications.'. user()->id . '.' . $alias . '.date', Date::now()); + setting()->set('notifications.'. user()->id . '.' . $alias . '.status', '0'); + + setting()->save(); + + $this->dispatchBrowserEvent('mark-read', [ + 'type' => 'new-apps', + 'message' => trans('notifications.messages.mark_read', ['type' => $notification->name]), + ]); + } + + public function markReadAll() + { + $notifications = $this->getNotifications('new-apps' ); + + foreach ($notifications as $notification) { + setting()->set('notifications.'. user()->id . '.' . $notification->alias . '.name', $notification->name); + setting()->set('notifications.'. user()->id . '.' . $notification->alias . '.message', $notification->alias); + setting()->set('notifications.'. user()->id . '.' . $notification->alias . '.date', Date::now()); + setting()->set('notifications.'. user()->id . '.' . $notification->alias . '.status', '0'); + + } + + setting()->save(); + + $this->dispatchBrowserEvent('mark-read-all', [ + 'type' => 'new-apps', + 'message' => trans('notifications.messages.mark_read_all', ['type' => trans_choice('notifications.new_apps', 2)]), + ]); + } + public function render() { $notifications = $this->getNotifications('new-apps'); + $this->clearReadNotifications($notifications); + return view('livewire.common.notifications.new-apps', compact('notifications')); } + + protected function clearReadNotifications(&$notifications) + { + $hide_notifications = setting('notifications.' . user()->id); + + if (!$hide_notifications) { + return; + } + + if (!$notifications) { + return; + } + + $aliases = []; + + // MarkRead app notification + foreach ($notifications as $index => $notification) { + $aliases[] = $notification->alias; + + if (setting('notifications.' . user()->id . '.' . $notification->alias)) { + unset($notifications[$index]); + } + } + + // Clear setting table missing notification + foreach ($hide_notifications as $alias => $hide_notification) { + if (in_array($alias, $aliases)) { + continue; + } + + setting()->forget('notifications.' . user()->id . '.' . $alias); + setting()->save(); + } + } } diff --git a/resources/views/common/notifications/index.blade.php b/resources/views/common/notifications/index.blade.php index 0b84b4d0c..bb7737bd9 100644 --- a/resources/views/common/notifications/index.blade.php +++ b/resources/views/common/notifications/index.blade.php @@ -31,7 +31,7 @@ @stack('bills_recurring') - + @stack('bills_reminder') @@ -48,6 +48,9 @@ document.getElementById(hash_split[1]).scrollIntoView({ behavior: 'smooth' }); + + document.getElementById('collapse-' + hash_split[1]).classList.add('show'); + document.getElementById('heading-' + hash_split[1]).ariaExpanded = 'true'; } @endpush diff --git a/resources/views/livewire/common/notifications/exports.blade.php b/resources/views/livewire/common/notifications/exports.blade.php index 0cd3e8055..8f7a57bc8 100644 --- a/resources/views/livewire/common/notifications/exports.blade.php +++ b/resources/views/livewire/common/notifications/exports.blade.php @@ -1,83 +1,95 @@ -@if ($notifications->total()) -
-
+
+
+ -
- - - @foreach ($notifications as $notification) - - +
+ @if ($notifications->total()) +
+
- @if (empty($notification->message)) - {!! trans('notifications.messages.export', [ - 'type' => $notification->translation, - 'file_name' => $notification->file_name, - 'url' => $notification->download_url - ]) !!} - @else - {!! $notification->message !!} - @endif -
+ + @foreach ($notifications as $notification) + + - - - @endforeach - -
+ @if (empty($notification->message)) + {!! trans('notifications.messages.export', [ + 'type' => $notification->translation, + 'file_name' => $notification->file_name, + 'url' => $notification->download_url + ]) !!} + @else + {!! $notification->message !!} + @endif + - -
-
- - @if ($notifications->total() > 5) - - @endif + + @if ($notifications->total() > 5) + + @endif + @else +
+ {{ trans('general.no_records') }} +
+ @endif +
+
@push('body_js') @endpush - -@endif diff --git a/resources/views/livewire/common/notifications/imports.blade.php b/resources/views/livewire/common/notifications/imports.blade.php index c1d1cffb7..bd9aeab25 100644 --- a/resources/views/livewire/common/notifications/imports.blade.php +++ b/resources/views/livewire/common/notifications/imports.blade.php @@ -1,102 +1,113 @@ -@if ($notifications->total()) -
-
+
+
+ -
- - - @foreach ($notifications as $notification) - - +
+ @if ($notifications->total()) +
+
- @if (empty($notification->errors)) - {!! trans('notifications.messages.import', [ - 'type' => $notification->translation, - 'count' => $notification->total_rows - ]) !!} - @else - @foreach ($notification->errors as $error) - {!! $error !!} - @endforeach - @endif -
+ + @foreach ($notifications as $notification) + + - - - @endforeach - -
+ @if (empty($notification->errors)) + {!! trans('notifications.messages.import', [ + 'type' => $notification->translation, + 'count' => $notification->total_rows + ]) !!} + @else + @foreach ($notification->errors as $error) + {!! $error !!} + @endforeach + @endif + - -
-
- - @if ($notifications->total() > 5) - - @endif + + @if ($notifications->total() > 5) + + @endif + @else +
+ {{ trans('general.no_records') }} +
+ @endif +
+
- @push('body_js') - - @endpush -@endif +@push('body_js') + +@endpush diff --git a/resources/views/livewire/common/notifications/new-apps.blade.php b/resources/views/livewire/common/notifications/new-apps.blade.php index 567034348..875cc94cb 100644 --- a/resources/views/livewire/common/notifications/new-apps.blade.php +++ b/resources/views/livewire/common/notifications/new-apps.blade.php @@ -1,27 +1,76 @@ -@if ($notifications) -
-
-
-
-

{{ trans_choice('notifications.new_apps', 2) }}

-
-
+
+
+
+
+

+ {{ trans_choice('notifications.new_apps', 2) }} -
+ @if ($notifications) + + @endif +

+
+
+ +
+ @if ($notifications)
@foreach ($notifications as $notification) - + + @endforeach
+ {!! $notification->message !!} + +
-
+ @else +
+ {{ trans('general.no_records') }} +
+ @endif
-@endif +
+ +@push('body_js') + +@endpush diff --git a/resources/views/livewire/common/notifications/recurring.blade.php b/resources/views/livewire/common/notifications/recurring.blade.php index 951be61a2..b99048efd 100644 --- a/resources/views/livewire/common/notifications/recurring.blade.php +++ b/resources/views/livewire/common/notifications/recurring.blade.php @@ -1,245 +1,256 @@ -@if ($notifications->count()) -
-
+
+
+ -
- - - - @stack('document_number_th_start') - @if (!$hideDocumentNumber) - + @endif + + @endforeach + +
- @stack('document_number_th_inside_start') +
+ @if ($notifications->total()) +
+ + + + @stack('document_number_th_start') + @if (!$hideDocumentNumber) + - @endif - @stack('document_number_th_end') + @stack('document_number_th_inside_end') + + @endif + @stack('document_number_th_end') - @stack('contact_name_th_start') - @if (!$hideContactName) - - @endif - @stack('contact_name_th_end') + @stack('contact_name_th_inside_end') + + @endif + @stack('contact_name_th_end') - @stack('amount_th_start') - @if (!$hideAmount) - - @endif - @stack('amount_th_end') + @stack('amount_th_inside_end') + + @endif + @stack('amount_th_end') - @stack('issued_at_th_start') - @if (!$hideIssuedAt) - - @endif - @stack('issued_at_th_end') + @stack('issued_at_th_inside_end') + + @endif + @stack('issued_at_th_end') - @stack('due_at_th_start') - @if (!$hideDueAt) - - @endif - @stack('due_at_th_end') + @stack('due_at_th_inside_end') + + @endif + @stack('due_at_th_end') - @stack('status_th_start') - @if (!$hideStatus) - - @endif - @stack('status_th_end') + @stack('status_th_inside_end') + + @endif + @stack('status_th_end') - @if (!$hideActions) - - @endif - - + @if (!$hideActions) + + @endif + + - - @foreach($notifications as $item) - - @stack('document_number_td_start') - @if (!$hideDocumentNumber) - - @endif - @stack('document_number_td_end') - - @stack('contact_name_td_start') - @if (!$hideContactName) - - @endif - @stack('contact_name_td_end') - - @stack('amount_td_start') - @if (!$hideAmount) - - @endif - @stack('amount_td_end') - - @stack('issued_at_td_start') - @if (!$hideIssuedAt) - - @endif - @stack('issued_at_td_end') + + @foreach($notifications as $item) + + @stack('document_number_td_start') + @if (!$hideDocumentNumber) + + @endif + @stack('document_number_td_end') + + @stack('contact_name_td_start') + @if (!$hideContactName) + + @endif + @stack('contact_name_td_end') + + @stack('amount_td_start') + @if (!$hideAmount) + + @endif + @stack('amount_td_end') + + @stack('issued_at_td_start') + @if (!$hideIssuedAt) + + @endif + @stack('issued_at_td_end') - @stack('due_at_td_start') - @if (!$hideDueAt) - - @endif - @stack('due_at_td_end') + @stack('due_at_td_inside_end') + + @endif + @stack('due_at_td_end') - @stack('status_td_start') - @if (!$hideStatus) - - @endif - @stack('status_td_end') + @stack('status_td_inside_end') + + @endif + @stack('status_td_end') - @if (!$hideActions) - - @endif - - @endforeach - -
+ @stack('document_number_th_inside_start') - {{ trans_choice($textDocumentNumber, 1) }} + {{ trans_choice($textDocumentNumber, 1) }} - @stack('document_number_th_inside_end') - - @stack('contact_name_th_inside_start') + @stack('contact_name_th_start') + @if (!$hideContactName) + + @stack('contact_name_th_inside_start') - {{ trans_choice($textContactName, 1) }} + {{ trans_choice($textContactName, 1) }} - @stack('contact_name_th_inside_end') - - @stack('amount_th_inside_start') + @stack('amount_th_start') + @if (!$hideAmount) + + @stack('amount_th_inside_start') - {{ trans('general.amount') }} + {{ trans('general.amount') }} - @stack('amount_th_inside_end') - - @stack('issued_at_th_inside_start') + @stack('issued_at_th_start') + @if (!$hideIssuedAt) + + @stack('issued_at_th_inside_start') - {{ trans($textIssuedAt) }} + {{ trans($textIssuedAt) }} - @stack('issued_at_th_inside_end') - - @stack('due_at_th_inside_start') + @stack('due_at_th_start') + @if (!$hideDueAt) + + @stack('due_at_th_inside_start') - {{ trans($textDueAt) }} + {{ trans($textDueAt) }} - @stack('due_at_th_inside_end') - - @stack('status_th_inside_start') + @stack('status_th_start') + @if (!$hideStatus) + + @stack('status_th_inside_start') - {{ trans_choice('general.statuses', 1) }} + {{ trans_choice('general.statuses', 1) }} - @stack('status_th_inside_end') - - {{ trans_choice('notifications.reads', 1) }} -
+ {{ trans_choice('notifications.reads', 1) }} +
- @stack('document_number_td_inside_start') - - {{ $item->document_number }} - - @stack('document_number_td_inside_end') - - @stack('contact_name_td_inside_start') - - {{ $item->contact_name }} - - @stack('contact_name_td_inside_end') - - @stack('amount_td_inside_start') - - @money($item->amount, $item->currency_code, true) - - @stack('amount_td_inside_end') - - @stack('issued_at_td_inside_start') - - @date($item->issued_at) - - @stack('issued_at_td_inside_end') -
+ @stack('document_number_td_inside_start') + + {{ $item->document_number }} + + @stack('document_number_td_inside_end') + + @stack('contact_name_td_inside_start') + + {{ $item->contact_name }} + + @stack('contact_name_td_inside_end') + + @stack('amount_td_inside_start') + + @money($item->amount, $item->currency_code, true) + + @stack('amount_td_inside_end') + + @stack('issued_at_td_inside_start') + + @date($item->issued_at) + + @stack('issued_at_td_inside_end') + - @stack('due_at_td_inside_start') + @stack('due_at_td_start') + @if (!$hideDueAt) + + @stack('due_at_td_inside_start') - @date($item->due_at) + @date($item->due_at) - @stack('due_at_td_inside_end') - - @stack('status_td_inside_start') + @stack('status_td_start') + @if (!$hideStatus) + + @stack('status_td_inside_start') - {{ trans($textDocumentStatus . $item->status) }} + {{ trans($textDocumentStatus . $item->status) }} - @stack('status_td_inside_end') - - -
-
- - @if ($notifications->total() > 5) -
+ +
-
- @endif + + @if ($notifications->total() > 5) + + @endif + @else +
+ {{ trans('general.no_records') }} +
+ @endif +
+
- @push('body_js') - - @endpush -@endif +@push('body_js') + +@endpush diff --git a/resources/views/livewire/common/notifications/reminder.blade.php b/resources/views/livewire/common/notifications/reminder.blade.php index 0d29e6f85..85aa0b053 100644 --- a/resources/views/livewire/common/notifications/reminder.blade.php +++ b/resources/views/livewire/common/notifications/reminder.blade.php @@ -1,227 +1,239 @@ -@if ($notifications->count()) -
-
+
+
+ -
- - - - @stack('document_number_th_start') - @if (!$hideDocumentNumber) - + @endif + + @endforeach + +
- @stack('document_number_th_inside_start') +
+ @if ($notifications->total()) +
+ + + + @stack('document_number_th_start') + @if (!$hideDocumentNumber) + - @endif - @stack('document_number_th_end') + @stack('document_number_th_inside_end') + + @endif + @stack('document_number_th_end') - @stack('contact_name_th_start') - @if (!$hideContactName) - - @endif - @stack('contact_name_th_end') + @stack('contact_name_th_inside_end') + + @endif + @stack('contact_name_th_end') - @stack('amount_th_start') - @if (!$hideAmount) - - @endif - @stack('amount_th_end') + @stack('amount_th_inside_end') + + @endif + @stack('amount_th_end') - @stack('issued_at_th_start') - @if (!$hideIssuedAt) - - @endif - @stack('issued_at_th_end') + @stack('issued_at_th_inside_end') + + @endif + @stack('issued_at_th_end') - @stack('due_at_th_start') - @if (!$hideDueAt) - - @endif - @stack('due_at_th_end') + @stack('due_at_th_inside_end') + + @endif + @stack('due_at_th_end') - @stack('status_th_start') - @if (!$hideStatus) - - @endif - @stack('status_th_end') + @stack('status_th_inside_end') + + @endif + @stack('status_th_end') - @if (!$hideActions) - - @endif - - + @if (!$hideActions) + + @endif + + - - @foreach($notifications as $item) - - @stack('document_number_td_start') - @if (!$hideDocumentNumber) - - @endif - @stack('document_number_td_end') - - @stack('contact_name_td_start') - @if (!$hideContactName) - - @endif - @stack('contact_name_td_end') - - @stack('amount_td_start') - @if (!$hideAmount) - - @endif - @stack('amount_td_end') - - @stack('issued_at_td_start') - @if (!$hideIssuedAt) - - @endif - @stack('issued_at_td_end') + + @foreach($notifications as $item) + + @stack('document_number_td_start') + @if (!$hideDocumentNumber) + + @endif + @stack('document_number_td_end') + + @stack('contact_name_td_start') + @if (!$hideContactName) + + @endif + @stack('contact_name_td_end') + + @stack('amount_td_start') + @if (!$hideAmount) + + @endif + @stack('amount_td_end') + + @stack('issued_at_td_start') + @if (!$hideIssuedAt) + + @endif + @stack('issued_at_td_end') - @stack('due_at_td_start') - @if (!$hideDueAt) - - @endif - @stack('due_at_td_end') + @stack('due_at_td_inside_end') + + @endif + @stack('due_at_td_end') - @stack('status_td_start') - @if (!$hideStatus) - - @endif - @stack('status_td_end') + @stack('status_td_inside_end') + + @endif + @stack('status_td_end') - @if (!$hideActions) - - @endif - - @endforeach - -
+ @stack('document_number_th_inside_start') - {{ trans_choice($textDocumentNumber, 1) }} + {{ trans_choice($textDocumentNumber, 1) }} - @stack('document_number_th_inside_end') - - @stack('contact_name_th_inside_start') + @stack('contact_name_th_start') + @if (!$hideContactName) + + @stack('contact_name_th_inside_start') - {{ trans_choice($textContactName, 1) }} + {{ trans_choice($textContactName, 1) }} - @stack('contact_name_th_inside_end') - - @stack('amount_th_inside_start') + @stack('amount_th_start') + @if (!$hideAmount) + + @stack('amount_th_inside_start') - {{ trans('general.amount') }} + {{ trans('general.amount') }} - @stack('amount_th_inside_end') - - @stack('issued_at_th_inside_start') + @stack('issued_at_th_start') + @if (!$hideIssuedAt) + + @stack('issued_at_th_inside_start') - {{ trans($textIssuedAt) }} + {{ trans($textIssuedAt) }} - @stack('issued_at_th_inside_end') - - @stack('due_at_th_inside_start') + @stack('due_at_th_start') + @if (!$hideDueAt) + + @stack('due_at_th_inside_start') - {{ trans($textDueAt) }} + {{ trans($textDueAt) }} - @stack('due_at_th_inside_end') - - @stack('status_th_inside_start') + @stack('status_th_start') + @if (!$hideStatus) + + @stack('status_th_inside_start') - {{ trans_choice('general.statuses', 1) }} + {{ trans_choice('general.statuses', 1) }} - @stack('status_th_inside_end') - - {{ trans_choice('notifications.reads', 1) }} -
+ {{ trans_choice('notifications.reads', 1) }} +
- @stack('document_number_td_inside_start') - - {{ $item->document_number }} - - @stack('document_number_td_inside_end') - - @stack('contact_name_td_inside_start') - - {{ $item->contact_name }} - - @stack('contact_name_td_inside_end') - - @stack('amount_td_inside_start') - - @money($item->amount, $item->currency_code, true) - - @stack('amount_td_inside_end') - - @stack('issued_at_td_inside_start') - - @date($item->issued_at) - - @stack('issued_at_td_inside_end') -
+ @stack('document_number_td_inside_start') + + {{ $item->document_number }} + + @stack('document_number_td_inside_end') + + @stack('contact_name_td_inside_start') + + {{ $item->contact_name }} + + @stack('contact_name_td_inside_end') + + @stack('amount_td_inside_start') + + @money($item->amount, $item->currency_code, true) + + @stack('amount_td_inside_end') + + @stack('issued_at_td_inside_start') + + @date($item->issued_at) + + @stack('issued_at_td_inside_end') + - @stack('due_at_td_inside_start') + @stack('due_at_td_start') + @if (!$hideDueAt) + + @stack('due_at_td_inside_start') - @date($item->due_at) + @date($item->due_at) - @stack('due_at_td_inside_end') - - @stack('status_td_inside_start') + @stack('status_td_start') + @if (!$hideStatus) + + @stack('status_td_inside_start') - {{ trans($textDocumentStatus . $item->status) }} + {{ trans($textDocumentStatus . $item->status) }} - @stack('status_td_inside_end') - - -
-
- - @if ($notifications->total() > 5) -
+ +
-
- @endif + + @if ($notifications->total() > 5) + + @endif + @else +
+ {{ trans('general.no_records') }} +
+ @endif +
+
@push('body_js') @endpush - -@endif