Add daily stock lot sellout forecast
This commit is contained in:
1 parent
9a1192ae81
commit
1639960ab6
9 files changed
+440
-3
No files matched your search
@@ -223,6 +223,23 @@ function auth_render_lager_table(string $title, array $rows, array $columns, str
|
||||
$value = $tableKey === 'products'
|
||||
? (string) max(0, (int) round((float) ($row['available_qty'] ?? 0)))
|
||||
: (string) ($row['item_code'] ?? '');
|
||||
$forecastText = '';
|
||||
$forecastWarning = false;
|
||||
if ($tableKey === 'products') {
|
||||
$forecastStatus = (string) ($row['sellout_forecast_status'] ?? 'no_demand');
|
||||
$forecastDate = $row['sellout_date'] ?? null;
|
||||
if ($forecastDate !== null && $forecastDate !== '') {
|
||||
$forecastDateObject = new DateTimeImmutable((string) $forecastDate);
|
||||
$forecastText = $forecastDateObject->format('d.m.Y');
|
||||
$forecastWarning = $forecastStatus === 'depleted';
|
||||
if (!$forecastWarning && !empty($row['expiry_date'])) {
|
||||
$expiryDate = new DateTimeImmutable((string) $row['expiry_date']);
|
||||
$forecastWarning = $forecastDateObject >= $expiryDate->modify('-3 months');
|
||||
}
|
||||
} else {
|
||||
$forecastText = 'Keine Prognose';
|
||||
}
|
||||
}
|
||||
$nameData = ' data-lager-drawer-name="' . auth_escape_html($name) . '"';
|
||||
$valueData = ' data-lager-drawer-value="' . auth_escape_html($value) . '"';
|
||||
$typeData = ' data-lager-drawer-type="' . auth_escape_html($tableKey === 'products' ? 'Produkt' : 'Artikel') . '"';
|
||||
@@ -230,6 +247,10 @@ function auth_render_lager_table(string $title, array $rows, array $columns, str
|
||||
$html[] = '<div class="' . $rowClass . '" role="row" data-component-part="large-table-row" data-lager-row="true" data-lager-id="' . $id . '">';
|
||||
$html[] = '<div class="sg-large-table__cell" role="cell"><a class="sg-hyperlink" href="#" aria-haspopup="dialog" aria-expanded="false" data-lager-drawer-open="true"' . $nameData . $valueData . $typeData . '>' . auth_escape_html($name) . '</a></div>';
|
||||
$html[] = '<div class="sg-large-table__cell" role="cell"><a class="sg-hyperlink" href="#" aria-haspopup="dialog" aria-expanded="false" data-lager-drawer-open="true"' . $nameData . $valueData . $typeData . '>' . auth_escape_html($value) . '</a></div>';
|
||||
if ($tableKey === 'products') {
|
||||
$forecastClass = $forecastWarning ? ' sg-strong lager-forecast-warning' : '';
|
||||
$html[] = '<div class="sg-large-table__cell' . $forecastClass . '" role="cell">' . auth_escape_html($forecastText) . '</div>';
|
||||
}
|
||||
$html[] = '</div>';
|
||||
}
|
||||
|
||||
@@ -241,7 +262,7 @@ function auth_render_lager_content(array $lagerProducts, array $lagerArtikel): s
|
||||
{
|
||||
return '<div data-lager-content="true">'
|
||||
. '<section class="sg-card-list-page" aria-label="Lager">'
|
||||
. auth_render_lager_table('Produkte', $lagerProducts, ['Produktname', 'Anzahl im Lager'], 'products')
|
||||
. auth_render_lager_table('Produkte', $lagerProducts, ['Produktname', 'Anzahl im Lager', 'Verbraucht bis'], 'products')
|
||||
. auth_render_lager_table('Artikel', $lagerArtikel, ['Artikel-Name', 'Artikelnummer'], 'articles')
|
||||
. '</section>'
|
||||
. '<div class="sg-card-list-page-drawer-backdrop" aria-hidden="true" data-lager-drawer-backdrop="true" data-open="false"></div>'
|
||||
|
||||
Reference in new issue
Block a user