Skip to content

Commit

Permalink
Added statistic for amount development
Browse files Browse the repository at this point in the history
Fixes #31
  • Loading branch information
MasterZydra committed Mar 14, 2024
1 parent 72d1d39 commit 4231b69
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Types of changes: `Added`, `Changed`, `Deprecate`, `Removed`, `Fixed`, `Secruity

### Added
- Added component for line chart #59
- Added statistic for amount development #31

## v2.4.0 - 11.03.2024 - Added revenue and profit statistic

Expand Down
27 changes: 27 additions & 0 deletions app/Http/Controllers/AmountDevelopmentStatsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers;

use Framework\Authentication\Auth;
use Framework\Database\Database;
use Framework\Routing\BaseController;
use Framework\Routing\ControllerInterface;

class AmountDevelopmentStatsController extends BaseController implements ControllerInterface
{
public function execute(): void
{
Auth::checkRole('Maintainer');

$dataSet = Database::unprepared('SELECT year, SUM(amount) AS amount FROM deliveryNotes GROUP BY year ORDER BY year ASC');
$data = [];
if ($dataSet !== false) {
while ($row = $dataSet->fetch_assoc()) {
$data[$row['year']] = $row['amount'];
}
}

view('statistics.amountDevelopment', ['data' => $data]);
}

}
2 changes: 2 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use App\Http\Controllers\ActiveSuppliersController;
use App\Http\Controllers\AmountDevelopmentStatsController;
use App\Http\Controllers\DeliveryNoteController;
use App\Http\Controllers\DeveloperToolsController;
use App\Http\Controllers\EditImprintSettingsController;
Expand Down Expand Up @@ -69,6 +70,7 @@
Router::addController('showVolumeDistribution', new VolumeDistributionPdfController());
Router::addController('showVolumeDistribution', new VolumeDistributionPdfController(), 'POST');
Router::addController('financialRevenueProfitStats', new FinancialRevenueProfitStatsController());
Router::addController('amountDevelopmentStats', new AmountDevelopmentStatsController());
}

if (Auth::hasRole('Administrator')) {
Expand Down
1 change: 1 addition & 0 deletions resources/Lang/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'Administration' => 'Administration',
'Administrator' => 'Administrator',
'Amount' => 'Menge',
'AmountDevelopment' => 'Mengenentwicklung',
'AmountInVolumeDistribution' => 'Menge in Mengenverteilung',
'Analyses' => 'Auswertungen',
'Author' => 'Autor',
Expand Down
1 change: 1 addition & 0 deletions resources/Lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'Administration' => 'Administration',
'Administrator' => 'Administrator',
'Amount' => 'Amount',
'AmountDevelopment' => 'Amount development',
'AmountInVolumeDistribution' => 'Amount in volume distribution',
'Analyses' => 'Analyses',
'Author' => 'Author',
Expand Down
3 changes: 2 additions & 1 deletion resources/Views/auth/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
<div class="box">
<strong><?= __('DeliveryNote') ?></strong><br>
<a href="openVolumeDistributions"><?= __('OpenVolumeDistributions') ?></a><br>
<a href="showVolumeDistribution"><?= __('ShowVolumeDistribution') ?></a>
<a href="showVolumeDistribution"><?= __('ShowVolumeDistribution') ?></a><br>
<a href="amountDevelopmentStats"><?= __('AmountDevelopment') ?></a>
</div>

<div class="box">
Expand Down
26 changes: 26 additions & 0 deletions resources/Views/statistics/amountDevelopment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php use Framework\Facades\Format; ?>
<?= component('layout.header') ?>

<h1><?= __('AmountDevelopment') ?></h1>

<table class="scrollable">
<tr>
<th class="center"><?= __('Year') ?></th>
<th class="center"><?= __('Amount') ?></th>
</tr>
<?php foreach ($data as $year => $amount): ?>
<tr>
<td class="center"><?= $year ?></td>
<td class="center"><?= Format::decimal($amount) ?></td>
</tr>
<?php endforeach ?>
</table>

<?= component('chart.line', [
'chartName' => 'amountDevelopment',
'xTitle' => __('Year'),
'yTitle' => __('inX', setting('massUnit')),
'dataSet' => [['label' => __('Amount'), 'data' => $data]],
]) ?>

<?= component('layout.footer') ?>

0 comments on commit 4231b69

Please sign in to comment.