akaunting 3.0 (the last dance)
This commit is contained in:
18
app/View/Components/Layouts/Admin.php
Normal file
18
app/View/Components/Layouts/Admin.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Admin extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.admin');
|
||||
}
|
||||
}
|
42
app/View/Components/Layouts/Admin/Menu.php
Normal file
42
app/View/Components/Layouts/Admin/Menu.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Admin;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Utilities\Versions;
|
||||
|
||||
class Menu extends Component
|
||||
{
|
||||
/** array */
|
||||
public $companies = [];
|
||||
|
||||
public $notification_count;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->companies = $this->getCompanies();
|
||||
|
||||
$version_update = Versions::getUpdates();
|
||||
|
||||
$this->notification_count = user()->unreadNotifications->count();
|
||||
$this->notification_count += count($version_update);
|
||||
|
||||
return view('components.layouts.admin.menu');
|
||||
}
|
||||
|
||||
public function getCompanies()
|
||||
{
|
||||
if ($user = user()) {
|
||||
$companies = $user->companies()->enabled()->limit(10)->get()->sortBy('name');
|
||||
} else {
|
||||
$companies = [];
|
||||
}
|
||||
|
||||
return $companies;
|
||||
}
|
||||
}
|
57
app/View/Components/Layouts/Admin/Notifications.php
Normal file
57
app/View/Components/Layouts/Admin/Notifications.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Admin;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\Modules;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class Notifications extends Component
|
||||
{
|
||||
use Modules;
|
||||
|
||||
public $notifications;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->notifications = $this->getNotify();
|
||||
|
||||
return view('components.layouts.admin.notifications');
|
||||
}
|
||||
|
||||
public function getNotify()
|
||||
{
|
||||
if (! $path = Route::current()->uri()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$path = str_replace('{company_id}/', '', $path);
|
||||
$path = str_replace('{company_id}', '', $path);
|
||||
|
||||
$notify = [];
|
||||
$notifications = $this->getNotifications($path);
|
||||
|
||||
// Push to a stack
|
||||
foreach ($notifications as $notification) {
|
||||
$path = str_replace('/', '#', $notification->path);
|
||||
|
||||
$message = str_replace('#path#', $path, $notification->message);
|
||||
$message = str_replace('#token#', csrf_token(), $message);
|
||||
$message = str_replace('#url#', route('dashboard'), $message);
|
||||
$message = str_replace('#company_id#', company_id(), $message);
|
||||
|
||||
if (! setting('notifications.' . $notification->path . '.' . $notification->id . '.status', 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$notify[] = $message;
|
||||
}
|
||||
|
||||
return $notify;
|
||||
}
|
||||
}
|
23
app/View/Components/Layouts/Modules.php
Normal file
23
app/View/Components/Layouts/Modules.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts;
|
||||
|
||||
use App\Traits\Modules as RemoteModules;
|
||||
use App\Utilities\Date;
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Modules extends Component
|
||||
{
|
||||
use RemoteModules;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.modules');
|
||||
}
|
||||
}
|
60
app/View/Components/Layouts/Modules/Bar.php
Normal file
60
app/View/Components/Layouts/Modules/Bar.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Modules;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\Modules;
|
||||
use App\Utilities\Date;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Bar extends Component
|
||||
{
|
||||
use Modules;
|
||||
|
||||
public $keyword;
|
||||
|
||||
/** array */
|
||||
public $categories = [];
|
||||
|
||||
/** array */
|
||||
public $popular = [];
|
||||
|
||||
public function categoryUrl($slug)
|
||||
{
|
||||
if ($slug == '*') {
|
||||
return route('apps.home.index');
|
||||
}
|
||||
|
||||
return route('apps.categories.show', $slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->keyword = request()->get('keyword');
|
||||
$this->categories = $this->getCategories();
|
||||
$this->popular = $this->getPopularModules();
|
||||
|
||||
return view('components.layouts.modules.bar');
|
||||
}
|
||||
|
||||
protected function getCategories()
|
||||
{
|
||||
$categories = collect([
|
||||
'*' => trans('general.all_type', ['type' => trans_choice('general.categories', 2)]),
|
||||
]);
|
||||
|
||||
if (setting('apps.api_key')) {
|
||||
$categories = Cache::remember('modules.categories.' . language()->getShortCode(), Date::now()->addHour(6), function () {
|
||||
return collect($this->getCategoriesOfModules())->pluck('name', 'slug')
|
||||
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '*');
|
||||
});
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
}
|
26
app/View/Components/Layouts/Modules/Releases.php
Normal file
26
app/View/Components/Layouts/Modules/Releases.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Modules;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Releases extends Component
|
||||
{
|
||||
public $releases;
|
||||
|
||||
public function __construct(
|
||||
$releases = []
|
||||
) {
|
||||
$this->releases = $releases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.modules.releases');
|
||||
}
|
||||
}
|
26
app/View/Components/Layouts/Modules/Reviews.php
Normal file
26
app/View/Components/Layouts/Modules/Reviews.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Modules;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Reviews extends Component
|
||||
{
|
||||
public $reviews;
|
||||
|
||||
public function __construct(
|
||||
$reviews = []
|
||||
) {
|
||||
$this->reviews = $reviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.modules.reviews');
|
||||
}
|
||||
}
|
34
app/View/Components/Layouts/Portal/Menu.php
Normal file
34
app/View/Components/Layouts/Portal/Menu.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Portal;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Menu extends Component
|
||||
{
|
||||
/** array */
|
||||
public $companies = [];
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->companies = $this->getCompanies();
|
||||
|
||||
return view('components.layouts.portal.menu');
|
||||
}
|
||||
|
||||
public function getCompanies()
|
||||
{
|
||||
if ($user = user()) {
|
||||
$companies = $user->companies()->enabled()->limit(10)->get()->sortBy('name');
|
||||
} else {
|
||||
$companies = [];
|
||||
}
|
||||
|
||||
return $companies;
|
||||
}
|
||||
}
|
18
app/View/Components/Layouts/Wizard.php
Normal file
18
app/View/Components/Layouts/Wizard.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Wizard extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.layouts.wizard');
|
||||
}
|
||||
}
|
183
app/View/Components/Layouts/Wizard/Scripts.php
Normal file
183
app/View/Components/Layouts/Wizard/Scripts.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Layouts\Wizard;
|
||||
|
||||
use Akaunting\Money\Currency as MoneyCurrency;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Media;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Traits\Modules;
|
||||
|
||||
class Scripts extends Component
|
||||
{
|
||||
use Modules;
|
||||
|
||||
public $company;
|
||||
|
||||
public $translations;
|
||||
|
||||
public $currencies;
|
||||
|
||||
public $currency_codes;
|
||||
|
||||
public $taxes;
|
||||
|
||||
public $modules;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->company = $this->getCompany();
|
||||
|
||||
$this->translations = $this->getTransalations();
|
||||
|
||||
$this->currencies = $this->getCurrencies();
|
||||
|
||||
// Prepare codes
|
||||
$this->currency_codes = $this->getCurrencyCodes();
|
||||
|
||||
$this->taxes = $this->getTaxes();
|
||||
|
||||
$this->modules = $this->getFeaturedModules([
|
||||
'query' => [
|
||||
'limit' => 5
|
||||
]
|
||||
]);
|
||||
|
||||
return view('components.layouts.wizard.scripts');
|
||||
}
|
||||
|
||||
protected function getCompany()
|
||||
{
|
||||
$company = company();
|
||||
|
||||
$company->api_key = setting('apps.api_key');
|
||||
$company->financial_start = setting('localisation.financial_start');
|
||||
|
||||
$logo_id = setting('company.logo');
|
||||
|
||||
$logo = false;
|
||||
|
||||
if ($logo_id) {
|
||||
$logo = Media::find($logo_id);
|
||||
|
||||
if ($logo) {
|
||||
$logo->path = route('uploads.get', $logo->id);
|
||||
}
|
||||
}
|
||||
|
||||
$company->logo = $logo;
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
/* Wizard page transactions */
|
||||
protected function getTransalations()
|
||||
{
|
||||
return [
|
||||
'company' => [
|
||||
'title' => trans_choice('general.companies', 1),
|
||||
'api_key' => trans('modules.api_key'),
|
||||
'form_enter' => trans('general.form.enter'),
|
||||
'get_api_key' => trans('modules.get_api_key'),
|
||||
'tax_number' => trans('general.tax_number'),
|
||||
'financial_start' => trans('settings.localisation.financial_start'),
|
||||
'address' => trans('settings.company.address'),
|
||||
'logo' => trans('settings.company.logo'),
|
||||
'skip' => trans('companies.skip_step'),
|
||||
'save' => trans('general.save'),
|
||||
'country' => trans_choice('general.countries', 1),
|
||||
],
|
||||
|
||||
'currencies' => [
|
||||
'title' => trans_choice('general.currencies', 2),
|
||||
'add_new' => trans('general.add_new'),
|
||||
'no_currency' => trans('currencies.no_currency'),
|
||||
'new_currency' => trans('currencies.new_currency'),
|
||||
'create_currency' => trans('currencies.create_currency'),
|
||||
'name' => trans('general.name'),
|
||||
'code' => trans('currencies.code'),
|
||||
'rate' => trans('currencies.rate'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'actions' => trans('general.actions') ,
|
||||
'yes' => trans('general.yes'),
|
||||
'no' => trans('general.no'),
|
||||
'edit' => trans('general.edit'),
|
||||
'delete' => trans('general.delete'),
|
||||
'save' => trans('general.save'),
|
||||
'precision' => trans('currencies.precision'),
|
||||
'symbol' => trans('currencies.symbol.symbol'),
|
||||
'position' => trans('currencies.symbol.position'),
|
||||
'decimal_mark' => trans('currencies.decimal_mark'),
|
||||
'thousands_separator' => trans('currencies.thousands_separator'),
|
||||
'previous' => trans('pagination.previous'),
|
||||
'next' => trans('pagination.next'),
|
||||
'delete_confirm' => trans('general.delete_confirm'),
|
||||
'cancel' => trans('general.cancel'),
|
||||
],
|
||||
|
||||
'taxes' => [
|
||||
'title' => trans_choice('general.taxes', 2),
|
||||
'add_new' => trans('general.add_new'),
|
||||
'no_taxes' => trans('taxes.no_taxes'),
|
||||
'create_task' => trans('taxes.create_task'),
|
||||
'new_tax' => trans('taxes.new_tax'),
|
||||
'name' => trans('general.name'),
|
||||
'rate_percent' => trans('taxes.rate_percent'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'actions' => trans('general.actions'),
|
||||
'yes' => trans('general.yes'),
|
||||
'no' => trans('general.no'),
|
||||
'edit' => trans('general.edit'),
|
||||
'delete' => trans('general.delete'),
|
||||
'name' => trans('general.name'),
|
||||
'rate' => trans('currencies.rate'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'save' => trans('general.save'),
|
||||
'previous' => trans('pagination.previous'),
|
||||
'next' => trans('pagination.next'),
|
||||
'cancel' => trans('general.cancel'),
|
||||
],
|
||||
|
||||
'finish' => [
|
||||
'title' => trans('modules.ready'),
|
||||
'recommended_apps' => trans('modules.recommended_apps'),
|
||||
'no_apps' => trans('modules.no_apps'),
|
||||
'developer' => trans('modules.developer'),
|
||||
'from' => trans('general.from'),
|
||||
'apps_managing' => trans('modules.apps_managing'),
|
||||
'reviews' => trans('modules.tab.reviews'),
|
||||
'previous' => trans('companies.skip_step'),
|
||||
'go_to_dashboard' => trans('general.go_to_dashboard'),
|
||||
'error_message' => trans('errors.title.500'),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function getCurrencies()
|
||||
{
|
||||
return Currency::all();
|
||||
}
|
||||
|
||||
protected function getCurrencyCodes()
|
||||
{
|
||||
$codes = [];
|
||||
$money_currencies = MoneyCurrency::getCurrencies();
|
||||
|
||||
foreach ($money_currencies as $key => $item) {
|
||||
$codes[$key] = $key;
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
protected function getTaxes()
|
||||
{
|
||||
return Tax::all();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user