akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -2,10 +2,12 @@
namespace App\Listeners\Menu;
use App\Events\Menu\AdminCreated as Event;
use App\Traits\Permissions;
use App\Events\Menu\AdminCreated as Event;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
class AddAdminItems
class ShowInAdmin
{
use Permissions;
@ -22,85 +24,53 @@ class AddAdminItems
$attr = ['icon' => ''];
// Dashboards
$title = trim(trans_choice('general.dashboards', 2));
$title = trim(trans_choice('general.dashboards', 1));
if ($this->canAccessMenuItem($title, 'read-common-dashboards')) {
$dashboards = user()->dashboards()->enabled()->get();
if ($dashboards->count() > 1) {
$menu->dropdown($title, function ($sub) use ($attr, $dashboards) {
foreach ($dashboards as $key => $dashboard) {
if (session('dashboard_id') != $dashboard->id) {
$sub->route('dashboards.switch', $dashboard->name, ['dashboard' => $dashboard->id], $key, $attr);
} else {
$sub->url('/' . company_id(), $dashboard->name, $key, $attr);
}
}
}, 10, [
'url' => '/' . company_id(),
'title' => $title,
'icon' => 'fa fa-tachometer-alt',
]);
} else {
$menu->add([
'url' => '/' . company_id(),
'title' => trans_choice('general.dashboards', 1),
'icon' => 'fa fa-tachometer-alt',
'order' => 10,
]);
}
$inactive = ('dashboard' != Route::currentRouteName()) ? true : false;
$menu->route('dashboard', $title, [], 10, ['icon' => 'speed', 'inactive' => $inactive]);
}
// Items
$title = trim(trans_choice('general.items', 2));
if ($this->canAccessMenuItem($title, 'read-common-items')) {
$menu->route('items.index', $title, [], 20, ['icon' => 'fa fa-cube']);
$menu->route('items.index', $title, [], 20, ['icon' => 'inventory_2']);
}
// Sales
$title = trim(trans_choice('general.sales', 2));
if ($this->canAccessMenuItem($title, ['read-sales-invoices', 'read-sales-revenues', 'read-sales-customers'])) {
if ($this->canAccessMenuItem($title, ['read-sales-invoices', 'read-sales-customers'])) {
$menu->dropdown($title, function ($sub) use ($attr) {
$title = trim(trans_choice('general.invoices', 2));
if ($this->canAccessMenuItem($title, 'read-sales-invoices')) {
$sub->route('invoices.index', $title, [], 10, $attr);
}
$title = trim(trans_choice('general.revenues', 2));
if ($this->canAccessMenuItem($title, 'read-sales-revenues')) {
$sub->route('revenues.index', $title, [], 20, $attr);
}
$title = trim(trans_choice('general.customers', 2));
if ($this->canAccessMenuItem($title, 'read-sales-customers')) {
$sub->route('customers.index', $title, [], 30, $attr);
$sub->route('customers.index', $title, [], 20, $attr);
}
}, 30, [
'title' => $title,
'icon' => 'fa fa-money-bill',
'icon' => 'payments',
]);
}
// Purchases
$title = trim(trans_choice('general.purchases', 2));
if ($this->canAccessMenuItem($title, ['read-purchases-bills', 'read-purchases-payments', 'read-purchases-vendors'])) {
if ($this->canAccessMenuItem($title, ['read-purchases-bills', 'read-purchases-vendors'])) {
$menu->dropdown($title, function ($sub) use ($attr) {
$title = trim(trans_choice('general.bills', 2));
if ($this->canAccessMenuItem($title, 'read-purchases-bills')) {
$sub->route('bills.index', $title, [], 10, $attr);
}
$title = trim(trans_choice('general.payments', 2));
if ($this->canAccessMenuItem($title, 'read-purchases-payments')) {
$sub->route('payments.index', $title, [], 20, $attr);
}
$title = trim(trans_choice('general.vendors', 2));
if ($this->canAccessMenuItem($title, 'read-purchases-vendors')) {
$sub->route('vendors.index', $title, [], 30, $attr);
$sub->route('vendors.index', $title, [], 20, $attr);
}
}, 40, [
'title' => $title,
'icon' => 'fa fa-shopping-cart',
'icon' => 'shopping_cart',
]);
}
@ -113,14 +83,14 @@ class AddAdminItems
$sub->route('accounts.index', $title, [], 10, $attr);
}
$title = trim(trans_choice('general.transfers', 2));
if ($this->canAccessMenuItem($title, 'read-banking-transfers')) {
$sub->route('transfers.index', $title, [], 20, $attr);
}
$title = trim(trans_choice('general.transactions', 2));
if ($this->canAccessMenuItem($title, 'read-banking-transactions')) {
$sub->route('transactions.index', $title, [], 30, $attr);
$sub->route('transactions.index', $title, [], 20, $attr);
}
$title = trim(trans_choice('general.transfers', 2));
if ($this->canAccessMenuItem($title, 'read-banking-transfers')) {
$sub->route('transfers.index', $title, [], 30, $attr);
}
$title = trim(trans_choice('general.reconciliations', 2));
@ -129,26 +99,21 @@ class AddAdminItems
}
}, 50, [
'title' => $title,
'icon' => 'fa fa-briefcase',
'icon' => 'account_balance',
]);
}
// Reports
$title = trim(trans_choice('general.reports', 2));
if ($this->canAccessMenuItem($title, 'read-common-reports')) {
$menu->route('reports.index', $title, [], 60, ['icon' => 'fa fa-chart-pie']);
}
// Settings
$title = trim(trans_choice('general.settings', 2));
if ($this->canAccessMenuItem($title, 'read-settings-settings')) {
$menu->route('settings.index', $title, [], 70, ['icon' => 'fa fa-cog']);
$menu->route('reports.index', $title, [], 60, ['icon' => 'donut_small']);
}
// Apps
$title = trim(trans_choice('general.modules', 2));
if ($this->canAccessMenuItem($title, 'read-modules-home')) {
$menu->route('apps.home.index', $title, [], 80, ['icon' => 'fa fa-rocket']);
$active = (Str::contains(Route::currentRouteName(), 'apps')) ? true : false;
$menu->route('apps.home.index', $title, [], 80, ['icon' => 'rocket_launch', 'active' => $active]);
}
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace App\Listeners\Menu;
use App\Events\Menu\NewwCreated as Event;
use App\Traits\Permissions;
class ShowInNeww
{
use Permissions;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$menu = $event->menu;
$title = trim(trans_choice('general.invoices', 1));
if ($this->canAccessMenuItem($title, 'create-sales-invoices')) {
$menu->route('invoices.create', $title, [], 10, ['icon' => 'description']);
}
$title = trim(trans_choice('general.incomes', 1));
if ($this->canAccessMenuItem($title, 'create-banking-transactions')) {
$menu->route('transactions.create', $title, ['type' => 'income'], 20, ['icon' => 'request_quote']);
}
$title = trim(trans_choice('general.customers', 1));
if ($this->canAccessMenuItem($title, 'create-sales-customers')) {
$menu->route('customers.create', $title, [], 30, ['icon' => 'person']);
}
$title = trim(trans_choice('general.bills', 1));
if ($this->canAccessMenuItem($title, 'create-purchases-bills')) {
$menu->route('bills.create', $title, [], 40, ['icon' => 'file_open']);
}
$title = trim(trans_choice('general.expenses', 1));
if ($this->canAccessMenuItem($title, 'create-banking-transactions')) {
$menu->route('transactions.create', $title, ['type' => 'expense'], 50, ['icon' => 'paid']);
}
$title = trim(trans_choice('general.vendors', 1));
if ($this->canAccessMenuItem($title, 'create-purchases-vendors')) {
$menu->route('vendors.create', $title, [], 60, ['icon' => 'engineering']);
}
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace App\Listeners\Menu;
use App\Events\Menu\NotificationsCreated as Event;
use App\Traits\Modules;
use App\Utilities\Versions;
use Illuminate\Notifications\DatabaseNotification;
class ShowInNotifications
{
use Modules;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
if (user()->cannot('read-notifications')) {
return;
}
// Notification tables
$notifications = collect();
// Update notifications
if (user()->can('read-install-updates')) {
$updates = Versions::getUpdates();
foreach ($updates as $key => $update) {
$prefix = ($key == 'core') ? 'core' : 'module';
$new = new DatabaseNotification();
$new->id = $key;
$new->type = 'updates';
$new->notifiable_type = "users";
$new->notifiable_id = user()->id;
$new->data = [
'title' => $key . ' (v' . $update . ')',
'description' => '<a href="' . route('updates.index') . '">' . trans('install.update.' . $prefix) . '</a>',
];
$new->created_at = \Carbon\Carbon::now();
$notifications->push($new);
}
}
// New app notifcations
$new_apps = $this->getNotifications('new-apps');
foreach ($new_apps as $key => $new_app) {
if (setting('notifications.' . user()->id . '.' . $new_app->alias)) {
unset($new_apps[$key]);
continue;
}
$new = new DatabaseNotification();
$new->id = $key;
$new->type = 'new-apps';
$new->notifiable_type = "users";
$new->notifiable_id = user()->id;
$new->data = [
'title' => $new_app->name,
'description' => $new_app->alias,
];
$new->created_at = $new_app->started_at->date;
$notifications->push($new);
}
$unReadNotifications = user()->unReadNotifications;
foreach ($unReadNotifications as $unReadNotification) {
$notifications->push($unReadNotification);
}
$event->notifications->notifications = $notifications;
}
}

View File

@ -4,7 +4,7 @@ namespace App\Listeners\Menu;
use App\Events\Menu\PortalCreated as Event;
class AddPortalItems
class ShowInPortal
{
/**
* Handle the event.
@ -23,14 +23,14 @@ class AddPortalItems
$inactive = true;
}
$menu->route('portal.dashboard', trans_choice('general.dashboards', 1), [], 10, ['icon' => 'fa fa-tachometer-alt', 'inactive' => $inactive]);
$menu->route('portal.dashboard', trans_choice('general.dashboards', 1), [], 10, ['icon' => 'speed', 'inactive' => $inactive]);
if ($user->can('read-portal-invoices')) {
$menu->route('portal.invoices.index', trans_choice('general.invoices', 2), [], 20, ['icon' => 'fa fa-file-signature']);
$menu->route('portal.invoices.index', trans_choice('general.invoices', 2), [], 20, ['icon' => 'description']);
}
if ($user->can('read-portal-payments')) {
$menu->route('portal.payments.index', trans_choice('general.payments', 2), [], 30, ['icon' => 'fa fa-money-bill']);
$menu->route('portal.payments.index', trans_choice('general.payments', 2), [], 30, ['icon' => 'credit_score']);
}
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace App\Listeners\Menu;
use App\Events\Menu\ProfileCreated as Event;
use App\Traits\Permissions;
class ShowInProfile
{
use Permissions;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$menu = $event->menu;
$title = trim(trans('auth.profile'));
if ($this->canAccessMenuItem($title, 'read-auth-profile')) {
$menu->route('profile.edit', $title, [user()->id], 10, ['icon' => 'badge']);
}
if (user()->isCustomer()) {
$menu->route('portal.profile.edit', $title, [user()->id], 10, ['icon' => 'badge']);
}
$title = trim(trans_choice('general.users', 2));
if ($this->canAccessMenuItem($title, 'read-auth-users')) {
$menu->route('users.index', $title, [], 20, ['icon' => 'people']);
}
$title = trim(trans('auth.logout'));
$menu->route('logout', $title, [], 90, ['icon' => 'power_settings_new', 'class' => 'mt-5']);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Listeners\Menu;
use App\Events\Menu\SettingsCreated as Event;
use App\Traits\Permissions;
class ShowInSettings
{
use Permissions;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$menu = $event->menu;
$title = trim(trans_choice('general.companies', 1));
if ($this->canAccessMenuItem($title, 'read-settings-company')) {
$menu->route('settings.company.edit', $title, [], 10, ['icon' => 'business', 'search_keywords' => trans('settings.company.search_keywords')]);
}
$title = trim(trans_choice('general.localisations', 1));
if ($this->canAccessMenuItem($title, 'read-settings-localisation')) {
$menu->route('settings.localisation.edit', $title, [], 20, ['icon' => 'flag', 'search_keywords' => trans('settings.localisation.search_keywords')]);
}
$title = trim(trans_choice('general.invoices', 1));
if ($this->canAccessMenuItem($title, 'read-settings-invoice')) {
$menu->route('settings.invoice.edit', $title, [], 30, ['icon' => 'description', 'search_keywords' => trans('settings.invoice.search_keywords')]);
}
$title = trim(trans_choice('general.defaults', 1));
if ($this->canAccessMenuItem($title, 'read-settings-defaults')) {
$menu->route('settings.default.edit', $title, [], 40, ['icon' => 'tune', 'search_keywords' => trans('settings.default.search_keywords')]);
}
$title = trim(trans_choice('general.email_services', 1));
if ($this->canAccessMenuItem($title, 'read-settings-email')) {
$menu->route('settings.email.edit', $title, [], 50, ['icon' => 'email', 'search_keywords' => trans('settings.email_services.search_keywords')]);
}
$title = trim(trans_choice('general.email_templates', 2));
if ($this->canAccessMenuItem($title, 'read-settings-email-templates')) {
$menu->route('settings.email-templates.edit', $title, [], 60, ['icon' => 'attach_email', 'search_keywords' => trans('settings.email.templates.search_keywords')]);
}
$title = trim(trans('settings.scheduling.name'));
if ($this->canAccessMenuItem($title, 'read-settings-schedule')) {
$menu->route('settings.schedule.edit', $title, [], 70, ['icon' => 'alarm', 'search_keywords' => trans('settings.scheduling.search_keywords')]);
}
$title = trim(trans_choice('general.categories', 2));
if ($this->canAccessMenuItem($title, 'read-settings-categories')) {
$menu->route('categories.index', $title, [], 80, ['icon' => 'folder', 'search_keywords' => trans('settings.categories.search_keywords')]);
}
$title = trim(trans_choice('general.currencies', 2));
if ($this->canAccessMenuItem($title, 'read-settings-currencies')) {
$menu->route('currencies.index', $title, [], 90, ['icon' => 'attach_money', 'search_keywords' => trans('settings.currencies.search_keywords')]);
}
$title = trim(trans_choice('general.taxes', 2));
if ($this->canAccessMenuItem($title, 'read-settings-taxes')) {
$menu->route('taxes.index', $title, [], 100, ['icon' => 'percent', 'search_keywords' => trans('settings.taxes.search_keywords')]);
}
}
}