mirror of
https://github.com/grocy/grocy.git
synced 2026-04-09 14:06:16 +02:00
Add "Journal-Summary"
This commit is contained in:
parent
3c849885b3
commit
1410afe2b3
|
|
@ -720,6 +720,11 @@ class StockApiController extends BaseApiController
|
||||||
return $this->FilteredApiResponse($response, $this->getDatabase()->uihelper_stock_journal(), $request->getQueryParams());
|
return $this->FilteredApiResponse($response, $this->getDatabase()->uihelper_stock_journal(), $request->getQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function JournalSummary(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
|
{
|
||||||
|
return $this->FilteredApiResponse($response, $this->getDatabase()->uihelper_stock_journal_summary(), $request->getQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(\DI\Container $container)
|
public function __construct(\DI\Container $container)
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
|
|
|
||||||
|
|
@ -440,4 +440,24 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function JournalSummary(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
|
{
|
||||||
|
$entries = $this->getDatabase()->uihelper_stock_journal_summary();
|
||||||
|
if (isset($request->getQueryParams()['product_id']))
|
||||||
|
{
|
||||||
|
$entries = $entries->where('product_id', $request->getQueryParams()['product_id']);
|
||||||
|
}
|
||||||
|
if (isset($request->getQueryParams()['user_id']))
|
||||||
|
{
|
||||||
|
$entries = $entries->where('user_id', $request->getQueryParams()['user_id']);
|
||||||
|
}
|
||||||
|
if (isset($request->getQueryParams()['transaction_type']))
|
||||||
|
{
|
||||||
|
$entries = $entries->where('transaction_type', $request->getQueryParams()['transaction_type']);
|
||||||
|
}
|
||||||
|
return $this->renderPage($response, 'stockjournalsummary', [
|
||||||
|
'entries' => $entries
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1900,3 +1900,9 @@ msgstr ""
|
||||||
|
|
||||||
msgid "Default"
|
msgid "Default"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Journal-Summary"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Stock journal summary"
|
||||||
|
msgstr ""
|
||||||
|
|
|
||||||
|
|
@ -72,3 +72,18 @@ FROM stock_log
|
||||||
JOIN products p on stock_log.product_id = p.id
|
JOIN products p on stock_log.product_id = p.id
|
||||||
JOIN locations l on p.location_id = l.id
|
JOIN locations l on p.location_id = l.id
|
||||||
JOIN quantity_units qu ON p.qu_id_stock = qu.id;
|
JOIN quantity_units qu ON p.qu_id_stock = qu.id;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE VIEW uihelper_stock_journal_summary
|
||||||
|
AS
|
||||||
|
SELECT user_id AS id, -- dummy, LessQL needs an id column
|
||||||
|
user_id, u.display_name AS user_display_name, p.name AS product_name, product_id, transaction_type,
|
||||||
|
qu.name AS qu_name,
|
||||||
|
qu.name_plural AS qu_name_plural,
|
||||||
|
SUM(amount) AS amount
|
||||||
|
FROM stock_log
|
||||||
|
JOIN users_dto u on stock_log.user_id = u.id
|
||||||
|
JOIN products p on stock_log.product_id = p.id
|
||||||
|
JOIN quantity_units qu ON p.qu_id_stock = qu.id
|
||||||
|
WHERE undone = 0
|
||||||
|
GROUP BY user_id, product_id,transaction_type;
|
||||||
|
|
|
||||||
6
public/viewjs/stockjournalsummary.js
Normal file
6
public/viewjs/stockjournalsummary.js
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
var journalSummaryTable = $('#journal-summary-table').DataTable({
|
||||||
|
'paginate': true,
|
||||||
|
'order': [[0, 'desc']]
|
||||||
|
});
|
||||||
|
$('#journal-summary-table tbody').removeClass("d-none");
|
||||||
|
journalSummaryTable.columns.adjust().draw();
|
||||||
|
|
@ -57,6 +57,7 @@ $app->group('', function (RouteCollectorProxy $group) {
|
||||||
$group->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
|
$group->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
|
||||||
$group->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet');
|
$group->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet');
|
||||||
$group->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting');
|
$group->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting');
|
||||||
|
$group->get('/stockjournal/summary', '\Grocy\Controllers\StockController:JournalSummary');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stock price tracking
|
// Stock price tracking
|
||||||
|
|
@ -204,6 +205,7 @@ $app->group('/api', function (RouteCollectorProxy $group) {
|
||||||
$group->get('/stock/barcodes/external-lookup/{barcode}', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
$group->get('/stock/barcodes/external-lookup/{barcode}', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
||||||
$group->get('/productbarcodedetails/{barcode}', '\Grocy\Controllers\StockApiController:ProductBarcodeDetails');
|
$group->get('/productbarcodedetails/{barcode}', '\Grocy\Controllers\StockApiController:ProductBarcodeDetails');
|
||||||
$group->get('/stock/journal', '\Grocy\Controllers\StockApiController:Journal');
|
$group->get('/stock/journal', '\Grocy\Controllers\StockApiController:Journal');
|
||||||
|
$group->get('/stock/journal/summary', '\Grocy\Controllers\StockApiController:JournalSummary');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shopping list
|
// Shopping list
|
||||||
|
|
|
||||||
47
views/stockjournalsummary.blade.php
Normal file
47
views/stockjournalsummary.blade.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
@extends('layout.default')
|
||||||
|
|
||||||
|
@section('title', $__t('Stock journal summary'))
|
||||||
|
@section('activeNav', '')
|
||||||
|
@section('viewJsName', 'stockjournalsummary')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h2 class="title">@yield('title')</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<table id="journal-summary-table"
|
||||||
|
class="table table-sm table-striped dt-responsive">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ $__t('Product') }}</th>
|
||||||
|
<th>{{ $__t('Booking type') }}</th>
|
||||||
|
<th>{{ $__t('User') }}</th>
|
||||||
|
<th>{{ $__t('Amount') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="d-none">
|
||||||
|
@foreach($entries as $journalEntry)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ $journalEntry->product_name }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ $__t($journalEntry->transaction_type) }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ $journalEntry->user_display_name }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="locale-number locale-number-quantity-amount">{{ $journalEntry->amount }}</span> {{ $__n($journalEntry->amount, $journalEntry->qu_name, $journalEntry->qu_name_plural) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
<div class="title-related-links">
|
<div class="title-related-links">
|
||||||
<h2 class="title">@yield('title')</h2>
|
<h2 class="title">@yield('title')</h2>
|
||||||
<div class="related-links">
|
<div class="related-links">
|
||||||
|
<a class="btn btn-outline-dark responsive-button"
|
||||||
|
href="{{ $U('/stockjournal/summary') }}">
|
||||||
|
{{ $__t('Stock journal summary') }}
|
||||||
|
</a>
|
||||||
<a class="btn btn-outline-dark responsive-button"
|
<a class="btn btn-outline-dark responsive-button"
|
||||||
href="{{ $U('/stockjournal') }}">
|
href="{{ $U('/stockjournal') }}">
|
||||||
{{ $__t('Journal') }}
|
{{ $__t('Journal') }}
|
||||||
|
|
@ -268,6 +272,11 @@
|
||||||
<span class="dropdown-item-icon"><i class="fas fa-cocktail"></i></span> <span class="dropdown-item-text">{{ $__t('Search for recipes containing this product') }}</span>
|
<span class="dropdown-item-icon"><i class="fas fa-cocktail"></i></span> <span class="dropdown-item-text">{{ $__t('Search for recipes containing this product') }}</span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
<a class="dropdown-item"
|
||||||
|
type="button"
|
||||||
|
href="{{ $U('/stockjournal/summary?product_id=') }}{{ $currentStockEntry->product_id }}">
|
||||||
|
<span class="dropdown-item-icon"><i class="fas fa-cocktail"></i></span> <span class="dropdown-item-text">{{ $__t('Journal-Summary') }}</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user