Merge branch 'master' of github.com:akaunting/akaunting
This commit is contained in:
commit
71eb916b57
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
|
use App\Events\Report\DataLoaded;
|
||||||
|
use App\Events\Report\DataLoading;
|
||||||
use App\Events\Report\FilterApplying;
|
use App\Events\Report\FilterApplying;
|
||||||
use App\Events\Report\FilterShowing;
|
use App\Events\Report\FilterShowing;
|
||||||
use App\Events\Report\GroupApplying;
|
use App\Events\Report\GroupApplying;
|
||||||
@ -92,12 +94,21 @@ abstract class Report
|
|||||||
$this->setDates();
|
$this->setDates();
|
||||||
$this->setFilters();
|
$this->setFilters();
|
||||||
$this->setRows();
|
$this->setRows();
|
||||||
$this->setData();
|
$this->loadData();
|
||||||
$this->setColumnWidth();
|
$this->setColumnWidth();
|
||||||
|
|
||||||
$this->loaded = true;
|
$this->loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadData()
|
||||||
|
{
|
||||||
|
event(new DataLoading($this));
|
||||||
|
|
||||||
|
$this->setData();
|
||||||
|
|
||||||
|
event(new DataLoaded($this));
|
||||||
|
}
|
||||||
|
|
||||||
public function getDefaultName()
|
public function getDefaultName()
|
||||||
{
|
{
|
||||||
if (!empty($this->default_name)) {
|
if (!empty($this->default_name)) {
|
||||||
|
22
app/Events/Report/DataLoaded.php
Normal file
22
app/Events/Report/DataLoaded.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Report;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class DataLoaded
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $class
|
||||||
|
*/
|
||||||
|
public function __construct($class)
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Report/DataLoading.php
Normal file
22
app/Events/Report/DataLoading.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Report;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class DataLoading
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $class
|
||||||
|
*/
|
||||||
|
public function __construct($class)
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
}
|
||||||
|
}
|
@ -3,13 +3,12 @@
|
|||||||
namespace App\Http\ViewComposers;
|
namespace App\Http\ViewComposers;
|
||||||
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use App\Traits\Modules as RemoteModules;
|
use App\Traits\Modules;
|
||||||
use Route;
|
use Route;
|
||||||
use App\Models\Module\Module;
|
|
||||||
|
|
||||||
class Suggestions
|
class Suggestions
|
||||||
{
|
{
|
||||||
use RemoteModules;
|
use Modules;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind data to the view.
|
* Bind data to the view.
|
||||||
@ -24,30 +23,32 @@ class Suggestions
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$modules = false;
|
if ((!$user = user()) || $user->cannot('read-modules-home')) {
|
||||||
|
return;
|
||||||
if (user()) {
|
|
||||||
$path = Route::current()->uri();
|
|
||||||
|
|
||||||
if ($path) {
|
|
||||||
$suggestions = $this->getSuggestions($path);
|
|
||||||
|
|
||||||
if ($suggestions) {
|
|
||||||
$suggestion_modules = $suggestions->modules;
|
|
||||||
|
|
||||||
foreach ($suggestion_modules as $key => $module) {
|
|
||||||
$installed = Module::where('company_id', session('company_id'))->where('alias', $module->alias)->first();
|
|
||||||
|
|
||||||
if ($installed) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$modules[] = $module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$view->with(['suggestion_modules' => $modules]);
|
if (!$path = Route::current()->uri()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$suggestions = $this->getSuggestions($path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules = [];
|
||||||
|
|
||||||
|
foreach ($suggestions->modules as $s_module) {
|
||||||
|
if ($this->moduleIsEnabled($s_module->alias)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules[] = $s_module;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($modules)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->getFactory()->startPush('header_button_end', view('partials.admin.suggestions', compact('modules')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,6 @@ class ProfitLoss extends Report
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to views
|
|
||||||
foreach ($this->footer_totals as $table => $dates) {
|
|
||||||
foreach ($dates as $date => $total) {
|
|
||||||
if (!isset($this->net_profit[$date])) {
|
|
||||||
$this->net_profit[$date] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->net_profit[$date] += $total;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
|
@ -558,7 +558,7 @@ trait Modules
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moduleEnabled($alias)
|
public function moduleIsEnabled($alias)
|
||||||
{
|
{
|
||||||
if (!$this->moduleExists($alias)) {
|
if (!$this->moduleExists($alias)) {
|
||||||
return false;
|
return false;
|
||||||
@ -674,10 +674,10 @@ trait Modules
|
|||||||
|
|
||||||
if (isset($data['query'])){
|
if (isset($data['query'])){
|
||||||
foreach($data['query'] as $key => $value) {
|
foreach($data['query'] as $key => $value) {
|
||||||
$result .= '.' . $key . '.' . $value;
|
$result .= '.' . $key . '.' . $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,26 @@
|
|||||||
@stack('header_start')
|
@stack('header_start')
|
||||||
<div id="header" class="header pb-6">
|
|
||||||
<div class="container-fluid content-layout">
|
|
||||||
<div class="header-body">
|
|
||||||
<div class="row py-4 align-items-center">
|
|
||||||
<div class="col-xs-12 col-sm-4 col-md-5 align-items-center">
|
|
||||||
<h2 class="d-inline-flex mb-0 long-texts">@yield('title')</h2>
|
|
||||||
@yield('dashboard_action')
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-xs-12 col-sm-8 col-md-7">
|
<div id="header" class="header pb-6">
|
||||||
<div class="text-right">
|
<div class="container-fluid content-layout">
|
||||||
@yield('new_button')
|
<div class="header-body">
|
||||||
|
<div class="row py-4 align-items-center">
|
||||||
|
<div class="col-xs-12 col-sm-4 col-md-5 align-items-center">
|
||||||
|
<h2 class="d-inline-flex mb-0 long-texts">@yield('title')</h2>
|
||||||
|
@yield('dashboard_action')
|
||||||
|
</div>
|
||||||
|
|
||||||
@permission('read-modules-home')
|
<div class="col-xs-12 col-sm-8 col-md-7">
|
||||||
@if (!empty($suggestion_modules))
|
<div class="text-right">
|
||||||
@foreach($suggestion_modules as $s_module)
|
@stack('header_button_start')
|
||||||
<span>
|
|
||||||
<a href="{{ url($s_module->action_url) . '?' . http_build_query((array) $s_module->action_parameters) }}" class="btn btn-white btn-sm header-button-bottom" target="{{ $s_module->action_target }}"><span class="fa fa-rocket"></span> {{ $s_module->name }}</a>
|
|
||||||
</span>
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
@endpermission
|
|
||||||
|
|
||||||
@stack('header_button')
|
@yield('new_button')
|
||||||
</div>
|
|
||||||
|
@stack('header_button_end')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@stack('header_end')
|
@stack('header_end')
|
||||||
|
6
resources/views/partials/admin/suggestions.blade.php
Normal file
6
resources/views/partials/admin/suggestions.blade.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
@foreach($modules as $module)
|
||||||
|
<span>
|
||||||
|
<a href="{{ url($module->action_url) . '?' . http_build_query((array) $module->action_parameters) }}" class="btn btn-white btn-sm header-button-bottom" target="{{ $module->action_target }}"><span class="fa fa-rocket"></span> {{ $module->name }}</a>
|
||||||
|
</span>
|
||||||
|
@endforeach
|
@ -1,3 +1,15 @@
|
|||||||
|
@php
|
||||||
|
foreach ($class->footer_totals as $table => $dates) {
|
||||||
|
foreach ($dates as $date => $total) {
|
||||||
|
if (!isset($class->net_profit[$date])) {
|
||||||
|
$class->net_profit[$date] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$class->net_profit[$date] += $total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
|
||||||
<div class="table-responsive my-2">
|
<div class="table-responsive my-2">
|
||||||
<table class="table table-hover align-items-center rp-border-collapse">
|
<table class="table table-hover align-items-center rp-border-collapse">
|
||||||
<tfoot class="border-top-style">
|
<tfoot class="border-top-style">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user