mirror of
https://github.com/grocy/grocy.git
synced 2026-04-08 13:46:14 +02:00
Added option to include details in the webhook sent to label printers
This commit is contained in:
parent
541318e964
commit
031dc83aa9
|
|
@ -111,6 +111,7 @@ 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_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_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_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
|
// Thermal printer options
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,11 @@ class BatteriesApiController extends BaseApiController
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::BATTERY, $args['batteryId'])),
|
'grocycode' => (string)(new Grocycode(Grocycode::BATTERY, $args['batteryId'])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], GROCY_LABEL_PRINTER_PARAMS);
|
||||||
|
|
||||||
|
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
|
||||||
|
{
|
||||||
|
$webhookData['details'] = $this->getBatteriesService()->GetBatteryDetails($battery->id);
|
||||||
|
}
|
||||||
|
|
||||||
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
||||||
{
|
{
|
||||||
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,11 @@ class ChoresApiController extends BaseApiController
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::CHORE, $args['choreId'])),
|
'grocycode' => (string)(new Grocycode(Grocycode::CHORE, $args['choreId'])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], GROCY_LABEL_PRINTER_PARAMS);
|
||||||
|
|
||||||
|
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
|
||||||
|
{
|
||||||
|
$webhookData['details'] = $this->getChoresService()->GetChoreDetails($chore->id);
|
||||||
|
}
|
||||||
|
|
||||||
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
||||||
{
|
{
|
||||||
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,11 @@ class StockApiController extends BaseApiController
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $product->id)),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $product->id)),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], GROCY_LABEL_PRINTER_PARAMS);
|
||||||
|
|
||||||
|
if (GROCY_LABEL_PRINTER_INCLUDE_DETAILS)
|
||||||
|
{
|
||||||
|
$webhookData['details'] = $this->getStockService()->GetProductDetails($product->id);
|
||||||
|
}
|
||||||
|
|
||||||
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
if (GROCY_LABEL_PRINTER_RUN_SERVER)
|
||||||
{
|
{
|
||||||
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
(new WebhookRunner())->run(GROCY_LABEL_PRINTER_WEBHOOK, $webhookData, GROCY_LABEL_PRINTER_HOOK_JSON);
|
||||||
|
|
@ -704,6 +709,12 @@ class StockApiController extends BaseApiController
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id])),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $stockEntry->product_id, [$stockEntry->stock_id])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], 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)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $stockEntry->best_before_date;
|
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $stockEntry->best_before_date;
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,12 @@ class StockService extends BaseService
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], 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)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
|
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
|
||||||
|
|
@ -280,6 +286,12 @@ class StockService extends BaseService
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockId])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], 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)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
|
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $bestBeforeDate;
|
||||||
|
|
@ -1011,6 +1023,12 @@ class StockService extends BaseService
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], 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)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;
|
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;
|
||||||
|
|
@ -1323,6 +1341,12 @@ class StockService extends BaseService
|
||||||
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
|
'grocycode' => (string)(new Grocycode(Grocycode::PRODUCT, $productId, [$stockEntry->stock_id])),
|
||||||
], GROCY_LABEL_PRINTER_PARAMS);
|
], 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)
|
if (GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||||
{
|
{
|
||||||
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;
|
$webhookData['due_date'] = $this->getLocalizationService()->__t('DD') . ': ' . $newBestBeforeDate;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user