added events to manipulate report data
This commit is contained in:
parent
a96d6f22bc
commit
d22a3e2001
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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()
|
||||||
|
@ -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