-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added statistic for price development
Fixes #58
- Loading branch information
1 parent
4231b69
commit e4e7b80
Showing
8 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Price; | ||
use Framework\Authentication\Auth; | ||
use Framework\Routing\BaseController; | ||
use Framework\Routing\ControllerInterface; | ||
|
||
class PriceDevelopmentStatsController extends BaseController implements ControllerInterface | ||
{ | ||
public function execute(): void | ||
{ | ||
Auth::checkRole('Maintainer'); | ||
|
||
$prices = Price::all(Price::getQueryBuilder()->orderBy('productId')->orderBy('recipientId')->orderBy('year')); | ||
|
||
$dataPrice = []; | ||
$dataPricePayout = []; | ||
/** @var \App\Models\Price $price */ | ||
foreach ($prices as $price) { | ||
$productName = $price->getProduct()->getName() . ' - ' . $price->getRecipient()->getName(); | ||
|
||
if (!key_exists($productName, $dataPrice)) { | ||
$dataPrice[$productName] = []; | ||
} | ||
$dataPrice[$productName][$price->getYear()] = $price->getPrice(); | ||
|
||
if (!key_exists($productName, $dataPricePayout)) { | ||
$dataPricePayout[$productName] = []; | ||
} | ||
$dataPricePayout[$productName][$price->getYear()] = $price->getPricePayout(); | ||
} | ||
|
||
view('statistics.priceDevelopment', ['dataPrice' => $dataPrice, 'dataPricePayout' => $dataPricePayout]); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php use Framework\Facades\Format; ?> | ||
<?= component('layout.header') ?> | ||
|
||
<h1><?= __('PriceDevelopment') ?></h1> | ||
|
||
<table class="scrollable"> | ||
<tr> | ||
<th class="center"><?= __('Product') ?></th> | ||
<th class="center"><?= __('Year') ?></th> | ||
<th class="center"><?= __('Price') ?> (<?= __('XPerY', setting('currencyUnit'), setting('massUnit')) ?>)</th> | ||
<th class="center"><?= __('Payout') ?> (<?= __('XPerY', setting('currencyUnit'), setting('massUnit')) ?>)</th> | ||
</tr> | ||
<?php foreach ($dataPrice as $product => $prices): ?> | ||
<?php foreach ($prices as $year => $price): ?> | ||
<tr> | ||
<td><?= $product ?></td> | ||
<td class="center"><?= $year ?></td> | ||
<td class="center"><?= Format::currency($price) ?></td> | ||
<td class="center"><?= Format::currency($dataPricePayout[$product][$year]) ?></td> | ||
</tr> | ||
<?php endforeach ?> | ||
<?php endforeach ?> | ||
</table> | ||
|
||
<?php | ||
$chartCount = 0; | ||
foreach (array_keys($dataPrice) as $product) { | ||
?><h3><?= $product ?></h3><?php | ||
component('chart.line', [ | ||
'chartName' => 'priceDevelopment' . $chartCount, | ||
'xTitle' => __('Year'), | ||
'yTitle' => __('XPerY', setting('currencyUnit'), setting('massUnit')), | ||
'dataSet' => [ | ||
['label' => __('Price'), 'data' => $dataPrice[$product]], | ||
['label' => __('Payout'), 'data' => $dataPricePayout[$product]], | ||
], | ||
]); | ||
$chartCount += 1; | ||
} | ||
?> | ||
|
||
<?= component('layout.footer') ?> |