From 4ed6630907fcbbf360149f934d3faf855d9dce2e Mon Sep 17 00:00:00 2001 From: me-ssaxena <155807573+me-ssaxena@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:15:52 +0000 Subject: [PATCH] #2156 added note field to consume page --- controllers/StockApiController.php | 7 ++++++- public/viewjs/consume.js | 1 + services/StockService.php | 6 +++--- views/consume.blade.php | 10 ++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php index 27fd5b26..04e132db 100644 --- a/controllers/StockApiController.php +++ b/controllers/StockApiController.php @@ -315,8 +315,13 @@ class StockApiController extends BaseApiController $allowSubproductSubstitution = $requestBody['allow_subproduct_substitution']; } + $note = null; + if (array_key_exists('note', $requestBody)) { + $note = $requestBody['note']; + } + $transactionId = null; - $transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact); + $transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact, $note); $args['transactionId'] = $transactionId; return $this->StockTransactions($request, $response, $args); } diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 8cc9b022..85ca2637 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -22,6 +22,7 @@ jsonData.exact_amount = $('#consume-exact-amount').is(':checked'); jsonData.spoiled = $('#spoiled').is(':checked'); jsonData.allow_subproduct_substitution = true; + jsonData.note = jsonForm.note; if ($("#use_specific_stock_entry").is(":checked")) { diff --git a/services/StockService.php b/services/StockService.php index 56b42b49..eeb02bdb 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -355,7 +355,7 @@ class StockService extends BaseService } } - public function ConsumeProduct(int $productId, float $amount, bool $spoiled, $transactionType, $specificStockEntryId = 'default', $recipeId = null, $locationId = null, &$transactionId = null, $allowSubproductSubstitution = false, $consumeExactAmount = false) + public function ConsumeProduct(int $productId, float $amount, bool $spoiled, $transactionType, $specificStockEntryId = 'default', $recipeId = null, $locationId = null, &$transactionId = null, $allowSubproductSubstitution = false, $consumeExactAmount = false, $note = null) { if (!$this->ProductExists($productId)) { @@ -456,7 +456,7 @@ class StockService extends BaseService 'transaction_id' => $transactionId, 'user_id' => GROCY_USER_ID, 'location_id' => $stockEntry->location_id, - 'note' => $stockEntry->note + 'note' => $note ]); $logRow->save(); @@ -491,7 +491,7 @@ class StockService extends BaseService 'transaction_id' => $transactionId, 'user_id' => GROCY_USER_ID, 'location_id' => $stockEntry->location_id, - 'note' => $stockEntry->note + 'note' => $note ]); $logRow->save(); diff --git a/views/consume.blade.php b/views/consume.blade.php index f2bba01f..58bbd070 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -135,6 +135,16 @@ )) @endif +
+ +
+ +
+
+