Removed LABEL_PRINTER_INCLUDE_DETAILS flag

This commit is contained in:
Fándly Gergő 2025-03-20 11:09:33 +02:00
parent 031dc83aa9
commit 80b12dc142
5 changed files with 21 additions and 54 deletions

View File

@ -111,7 +111,6 @@ Setting('LABEL_PRINTER_WEBHOOK', ''); // The URI that Grocy will POST to when as
Setting('LABEL_PRINTER_RUN_SERVER', true); // Whether the webhook will be called server- or client-side
Setting('LABEL_PRINTER_PARAMS', ['font_family' => 'Source Sans Pro (Regular)']); // Additional parameters supplied to the webhook
Setting('LABEL_PRINTER_HOOK_JSON', false); // TRUE to use JSON or FALSE to use normal POST request variables
Setting('LABEL_PRINTER_INCLUDE_DETAILS', false); // TRUE to include details for the object as well
// Thermal printer options

View File

@ -69,18 +69,14 @@ class BatteriesApiController extends BaseApiController
{
try
{
$battery = $this->getDatabase()->batteries()->where('id', $args['batteryId'])->fetch();
$batteryDetails = $this->getBatteriesService()->GetBatteryDetails($args['batteryId']);
$webhookData = array_merge([
'battery' => $battery->name,
'battery' => $batteryDetails->battery->name,
'grocycode' => (string)(new Grocycode(Grocycode::BATTERY, $args['batteryId'])),
'details' => $batteryDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $this->getBatteriesService()->GetBatteryDetails($battery->id);
}
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);

View File

@ -120,18 +120,14 @@ class ChoresApiController extends BaseApiController
{
try
{
$chore = $this->getDatabase()->chores()->where('id', $args['choreId'])->fetch();
$choreDetails = $this->getChoresService()->GetChoreDetails($args['choreId']);
$webhookData = array_merge([
'chore' => $chore->name,
'chore' => $choreDetails->chore->name,
'grocycode' => (string)(new Grocycode(Grocycode::CHORE, $args['choreId'])),
'details' => $choreDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $this->getChoresService()->GetChoreDetails($chore->id);
}
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);

View File

@ -672,18 +672,14 @@ class StockApiController extends BaseApiController
{
try
{
$product = $this->getDatabase()->products()->where('id', $args['productId'])->fetch();
$productDetails = $this->getStockService()->GetProductDetails($args['productId']);
$webhookData = array_merge([
'product' => $product->name,
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $product->id)),
'details' => $productDetails,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $this->getStockService()->GetProductDetails($product->id);
}
if (GROCY_LABEL_PRINTER_RUN_SERVER)
{
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
@ -702,19 +698,15 @@ class StockApiController extends BaseApiController
try
{
$stockEntry = $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch();
$product = $this->getDatabase()->products()->where('id', $stockEntry->product_id)->fetch();
$productDetails = $this->getStockService()->GetProductDetails($stockEntry->product_id);
$webhookData = array_merge([
'product' => $product->name,
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id])),
'details' => $productDetails,
'stock_entry' => $stockEntry,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $this->getStockService()->GetProductDetails($product->id);
$webhookData['details']['stock_entry'] = $stockEntry;
}
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $stockEntry->best_before_date;

View File

@ -227,14 +227,10 @@ class StockService extends BaseService
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
'details' => $productDetails,
'stock_entry' => $stockRow,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $productDetails;
$webhookData['details']['stock_entry'] = $stockRow;
}
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
@ -284,14 +280,10 @@ class StockService extends BaseService
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
'details' => $productDetails,
'stock_entry' => $stockRow,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $productDetails;
$webhookData['details']['stock_entry'] = $stockRow;
}
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
@ -1021,14 +1013,10 @@ class StockService extends BaseService
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
'details' => $productDetails,
'stock_entry' => $stockEntry,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $productDetails;
$webhookData['details']['stock_entry'] = $stockEntry;
}
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;
@ -1339,14 +1327,10 @@ class StockService extends BaseService
$webhookData = array_merge([
'product' => $productDetails->product->name,
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
'details' => $productDetails,
'stock_entry' => $stockEntry,
], GROCY_LABEL_PRINTER_PARAMS);
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
{
$webhookData['details'] = $productDetails;
$webhookData['details']['stock_entry'] = $stockEntry;
}
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;