diff --git a/controllers/BatteriesApiController.php b/controllers/BatteriesApiController.php index dfc131d8..2e311dfc 100644 --- a/controllers/BatteriesApiController.php +++ b/controllers/BatteriesApiController.php @@ -24,8 +24,8 @@ class BatteriesApiController extends BaseApiController try { - $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime); - return $this->VoidApiActionResponse($response); + $chargeCycleId = $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime); + return $this->ApiResponse(array('charge_cycle_id' => $chargeCycleId)); } catch (\Exception $ex) { diff --git a/controllers/BatteriesController.php b/controllers/BatteriesController.php index ce9f79f2..9ee3625b 100644 --- a/controllers/BatteriesController.php +++ b/controllers/BatteriesController.php @@ -53,4 +53,12 @@ class BatteriesController extends BaseController ]); } } + + public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + { + return $this->AppContainer->view->render($response, 'batteriesjournal', [ + 'chargeCycles' => $this->Database->battery_charge_cycles()->orderBy('tracked_time', 'DESC'), + 'batteries' => $this->Database->batteries()->orderBy('name') + ]); + } } diff --git a/controllers/ChoresApiController.php b/controllers/ChoresApiController.php index 41886140..7a4d3939 100644 --- a/controllers/ChoresApiController.php +++ b/controllers/ChoresApiController.php @@ -30,8 +30,8 @@ class ChoresApiController extends BaseApiController try { - $this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy); - return $this->VoidApiActionResponse($response); + $choreExecutionId = $this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy); + return $this->ApiResponse(array('chore_execution_id' => $choreExecutionId)); } catch (\Exception $ex) { diff --git a/controllers/ChoresController.php b/controllers/ChoresController.php index 09d916fd..95a55c09 100644 --- a/controllers/ChoresController.php +++ b/controllers/ChoresController.php @@ -38,10 +38,10 @@ class ChoresController extends BaseController ]); } - public function Analysis(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { - return $this->AppContainer->view->render($response, 'choresanalysis', [ - 'choresLog' => $this->Database->chores_log()->where('undone', 0)->orderBy('tracked_time', 'DESC'), + return $this->AppContainer->view->render($response, 'choresjournal', [ + 'choresLog' => $this->Database->chores_log()->orderBy('tracked_time', 'DESC'), 'chores' => $this->Database->chores()->orderBy('name'), 'users' => $this->Database->users()->orderBy('username') ]); diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php index 49d94c55..6843ee57 100644 --- a/controllers/StockApiController.php +++ b/controllers/StockApiController.php @@ -60,8 +60,8 @@ class StockApiController extends BaseApiController try { - $this->StockService->AddProduct($args['productId'], $args['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price); - return $this->VoidApiActionResponse($response); + $bookingId = $this->StockService->AddProduct($args['productId'], $args['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price); + return $this->ApiResponse(array('booking_id' => $bookingId)); } catch (\Exception $ex) { @@ -85,8 +85,8 @@ class StockApiController extends BaseApiController try { - $this->StockService->ConsumeProduct($args['productId'], $args['amount'], $spoiled, $transactionType); - return $this->VoidApiActionResponse($response); + $bookingId = $this->StockService->ConsumeProduct($args['productId'], $args['amount'], $spoiled, $transactionType); + return $this->ApiResponse(array('booking_id' => $bookingId)); } catch (\Exception $ex) { @@ -104,8 +104,8 @@ class StockApiController extends BaseApiController try { - $this->StockService->InventoryProduct($args['productId'], $args['newAmount'], $bestBeforeDate); - return $this->VoidApiActionResponse($response); + $bookingId = $this->StockService->InventoryProduct($args['productId'], $args['newAmount'], $bestBeforeDate); + return $this->ApiResponse(array('booking_id' => $bookingId)); } catch (\Exception $ex) { diff --git a/controllers/StockController.php b/controllers/StockController.php index 63e330bd..fb133f49 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -192,4 +192,13 @@ class StockController extends BaseController ]); } } + + public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + { + return $this->AppContainer->view->render($response, 'stockjournal', [ + 'stockLog' => $this->Database->stock_log()->orderBy('row_created_timestamp', 'DESC'), + 'products' => $this->Database->products()->orderBy('name'), + 'quantityunits' => $this->Database->quantity_units()->orderBy('name') + ]); + } } diff --git a/localization/de.php b/localization/de.php index 3b1cf5ad..811c09c5 100644 --- a/localization/de.php +++ b/localization/de.php @@ -184,7 +184,7 @@ return array( 'Last done by' => 'Zuletzt ausgeführt von', 'Unknown' => 'Unbekannt', 'Filter by chore' => 'Nach Hausarbeit filtern', - 'Chores analysis' => 'Hausarbeiten Analyse', + 'Chores journal' => 'Hausarbeitenjournal', '0 means suggestions for the next charge cycle are disabled' => '0 bedeutet dass Vorschläge für den nächsten Ladezyklus deaktiviert sind', 'Charge cycle interval (days)' => 'Ladezyklusintervall (Tage)', 'Last price' => 'Letzter Preis', @@ -286,10 +286,30 @@ return array( 'Edit included recipe' => 'Enthaltenes Rezept bearbeiten', 'Group' => 'Gruppe', 'This will be used as a headline to group ingredients together' => 'Dies wird als Überschrift verwendet, um Zutaten zusammenzufassen', + 'Journal' => 'Journal', + 'Stock journal' => 'Bestandsjournal', + 'Filter by product' => 'Nach Produkt filtern', + 'Booking time' => 'Buchungszeit', + 'Booking type' => 'Buchungsart', + 'Undo booking' => 'Buchung rückgängig machen', + 'Undone on' => 'Rückgängig gemacht am', + 'Batteries journal' => 'Batteriejournal', + 'Filter by battery' => 'Nach Batterie filtern', + 'Undo charge cycle' => 'Ladezyklus rückgängig machen', + 'Undo chore execution' => 'Ausführung rückgängig machen', + 'Chore execution successfully undone' => 'Ausführung erfolgreich rückgängig gemacht', + 'Undo' => 'Rückgängig machen', + 'Booking successfully undone' => 'Buchung erfolgreich rückgängig gemacht', + 'Charge cycle successfully undone' => 'Ladezyklus erfolgreich rückgängig gemacht', - //Constants + //Constants - Chore types 'manually' => 'Manuell', 'dynamic-regular' => 'Dynamisch regelmäßig', + + //Constants - Stock transaction types + 'purchase' => 'Einkauf', + 'consume' => 'Verbrauch', + 'inventory-correction' => 'Inventur-Korrektur', //Technical component translations 'timeago_locale' => 'de', diff --git a/localization/en.php b/localization/en.php index 4c951a26..ead84c9e 100644 --- a/localization/en.php +++ b/localization/en.php @@ -1,9 +1,14 @@ 'Manually', 'dynamic-regular' => 'Dynamic regular', + + //Constants - Stock transaction types + 'purchase' => 'Purchase', + 'consume' => 'Consume', + 'inventory-correction' => 'Inventory correction', //Technical component translations 'timeago_locale' => 'en', diff --git a/localization/no.php b/localization/no.php index e1188d5d..310dc7ca 100644 --- a/localization/no.php +++ b/localization/no.php @@ -184,7 +184,7 @@ return array( 'Last done by' => 'Sist utført av', 'Unknown' => 'Ukjent', 'Filter by chore' => 'Filtrér husarbeid', - 'Chores analysis' => 'Statistikk husarbeid', + 'Chores journal' => 'Statistikk husarbeid', '0 means suggestions for the next charge cycle are disabled' => '0 betyr neste ladesyklus er avslått', 'Charge cycle interval (days)' => 'Ladesyklysintervall (dager)', 'Last price' => 'Siste pris', diff --git a/public/viewjs/batteriesjournal.js b/public/viewjs/batteriesjournal.js new file mode 100644 index 00000000..db34da1f --- /dev/null +++ b/public/viewjs/batteriesjournal.js @@ -0,0 +1,70 @@ +var batteriesJournalTable = $('#batteries-journal-table').DataTable({ + 'paginate': true, + 'order': [[1, 'desc']], + 'columnDefs': [ + { 'orderable': false, 'targets': 0 } + ], + 'language': JSON.parse(L('datatables_localization')), + 'scrollY': false, + 'colReorder': true, + 'stateSave': true, + 'stateSaveParams': function(settings, data) + { + data.search.search = ""; + + data.columns.forEach(column => + { + column.search.search = ""; + }); + } +}); + +$("#battery-filter").on("change", function() +{ + var value = $(this).val(); + var text = $("#battery-filter option:selected").text(); + if (value === "all") + { + text = ""; + } + + batteriesJournalTable.column(1).search(text).draw(); +}); + +$("#search").on("keyup", function() +{ + var value = $(this).val(); + if (value === "all") + { + value = ""; + } + + batteriesJournalTable.search(value).draw(); +}); + +if (typeof GetUriParam("battery") !== "undefined") +{ + $("#battery-filter").val(GetUriParam("battery")); + $("#battery-filter").trigger("change"); +} + +$(document).on('click', '.undo-battery-execution-button', function(e) +{ + e.preventDefault(); + + var element = $(e.currentTarget); + var chargeCycleId = $(e.currentTarget).attr('data-charge-cycle-id'); + + Grocy.Api.Get('batteries/undo-charge-cycle/' + chargeCycleId.toString(), + function(result) + { + element.closest("tr").addClass("text-muted"); + element.closest(".undo-battery-execution-button").addClass("disabled"); + toastr.success(L("Charge cycle successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}); diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js index d859482e..8ee60a37 100644 --- a/public/viewjs/batterytracking.js +++ b/public/viewjs/batterytracking.js @@ -10,7 +10,7 @@ Grocy.Api.Get('batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').find('input').val(), function(result) { - toastr.success(L('Tracked charge cylce of battery #1 on #2', batteryDetails.battery.name, $('#tracked_time').find('input').val())); + toastr.success(L('Tracked charge cycle of battery #1 on #2', batteryDetails.battery.name, $('#tracked_time').find('input').val()) + '
' + L("Undo") + ''); $('#battery_id').val(''); $('#battery_id_text_input').focus(); @@ -86,3 +86,16 @@ $('#tracked_time').find('input').on('keypress', function (e) Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); }); +function UndoChargeCycle(chargeCycleId) +{ + Grocy.Api.Get('batteries/undo-charge-cycle/' + chargeCycleId.toString(), + function(result) + { + toastr.success(L("Charge cycle successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}; diff --git a/public/viewjs/choresanalysis.js b/public/viewjs/choresanalysis.js deleted file mode 100644 index 146746c6..00000000 --- a/public/viewjs/choresanalysis.js +++ /dev/null @@ -1,46 +0,0 @@ -var choresAnalysisTable = $('#chores-analysis-table').DataTable({ - 'paginate': false, - 'order': [[1, 'desc']], - 'language': JSON.parse(L('datatables_localization')), - 'scrollY': false, - 'colReorder': true, - 'stateSave': true, - 'stateSaveParams': function(settings, data) - { - data.search.search = ""; - - data.columns.forEach(column => - { - column.search.search = ""; - }); - } -}); - -$("#chore-filter").on("change", function() -{ - var value = $(this).val(); - var text = $("#chore-filter option:selected").text(); - if (value === "all") - { - text = ""; - } - - choresAnalysisTable.column(0).search(text).draw(); -}); - -$("#search").on("keyup", function() -{ - var value = $(this).val(); - if (value === "all") - { - value = ""; - } - - choresAnalysisTable.search(value).draw(); -}); - -if (typeof GetUriParam("chore") !== "undefined") -{ - $("#chore-filter").val(GetUriParam("chore")); - $("#chore-filter").trigger("change"); -} diff --git a/public/viewjs/choresjournal.js b/public/viewjs/choresjournal.js new file mode 100644 index 00000000..cf2c4093 --- /dev/null +++ b/public/viewjs/choresjournal.js @@ -0,0 +1,70 @@ +var choresJournalTable = $('#chores-journal-table').DataTable({ + 'paginate': true, + 'order': [[1, 'desc']], + 'columnDefs': [ + { 'orderable': false, 'targets': 0 } + ], + 'language': JSON.parse(L('datatables_localization')), + 'scrollY': false, + 'colReorder': true, + 'stateSave': true, + 'stateSaveParams': function(settings, data) + { + data.search.search = ""; + + data.columns.forEach(column => + { + column.search.search = ""; + }); + } +}); + +$("#chore-filter").on("change", function() +{ + var value = $(this).val(); + var text = $("#chore-filter option:selected").text(); + if (value === "all") + { + text = ""; + } + + choresJournalTable.column(1).search(text).draw(); +}); + +$("#search").on("keyup", function() +{ + var value = $(this).val(); + if (value === "all") + { + value = ""; + } + + choresJournalTable.search(value).draw(); +}); + +if (typeof GetUriParam("chore") !== "undefined") +{ + $("#chore-filter").val(GetUriParam("chore")); + $("#chore-filter").trigger("change"); +} + +$(document).on('click', '.undo-chore-execution-button', function(e) +{ + e.preventDefault(); + + var element = $(e.currentTarget); + var executionId = $(e.currentTarget).attr('data-execution-id'); + + Grocy.Api.Get('chores/undo-chore-execution/' + executionId.toString(), + function(result) + { + element.closest("tr").addClass("text-muted"); + element.closest(".undo-chore-execution-button").addClass("disabled"); + toastr.success(L("Chore execution successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}); diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js index 7e6b50e3..4ecbcb20 100644 --- a/public/viewjs/choretracking.js +++ b/public/viewjs/choretracking.js @@ -10,7 +10,7 @@ Grocy.Api.Get('chores/track-chore-execution/' + jsonForm.chore_id + '?tracked_time=' + Grocy.Components.DateTimePicker.GetValue() + "&done_by=" + Grocy.Components.UserPicker.GetValue(), function(result) { - toastr.success(L('Tracked execution of chore #1 on #2', choreDetails.chore.name, Grocy.Components.DateTimePicker.GetValue())); + toastr.success(L('Tracked execution of chore #1 on #2', choreDetails.chore.name, Grocy.Components.DateTimePicker.GetValue()) + '
' + L("Undo") + ''); $('#chore_id').val(''); $('#chore_id_text_input').focus(); @@ -82,3 +82,17 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e) { Grocy.FrontendHelpers.ValidateForm('choretracking-form'); }); + +function UndoChoreExecution(executionId) +{ + Grocy.Api.Get('chores/undo-chore-execution/' + executionId.toString(), + function(result) + { + toastr.success(L("Chore execution successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}; diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index d04bd909..2840c65c 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -16,7 +16,7 @@ Grocy.Api.Get('stock/consume-product/' + jsonForm.product_id + '/' + jsonForm.amount + '?spoiled=' + spoiled, function(result) { - toastr.success(L('Removed #1 #2 of #3 from stock', jsonForm.amount, Pluralize(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name)); + toastr.success(L('Removed #1 #2 of #3 from stock', jsonForm.amount, Pluralize(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + L("Undo") + ''); $('#amount').val(1); Grocy.Components.ProductPicker.SetValue(''); @@ -102,3 +102,17 @@ $('#consume-form input').keydown(function(event) } } }); + +function UndoStockBooking(bookingId) +{ + Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(), + function(result) + { + toastr.success(L("Booking successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}; diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index 1ba6e058..fbeb0893 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -32,7 +32,7 @@ ); } - toastr.success(L('Stock amount of #1 is now #2 #3', productDetails.product.name, jsonForm.new_amount, Pluralize(jsonForm.new_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural))); + toastr.success(L('Stock amount of #1 is now #2 #3', productDetails.product.name, jsonForm.new_amount, Pluralize(jsonForm.new_amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)) + '
' + L("Undo") + ''); if (addBarcode !== undefined) { @@ -186,3 +186,17 @@ $('#new_amount').on('keyup', function(e) ); } }); + +function UndoStockBooking(bookingId) +{ + Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(), + function(result) + { + toastr.success(L("Booking successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}; diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 341103c9..506d2a72 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -5,7 +5,7 @@ var jsonForm = $('#purchase-form').serializeJSON(); Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id, - function (productDetails) + function(productDetails) { var amount = jsonForm.amount * productDetails.product.qu_factor_purchase_to_stock; @@ -40,7 +40,7 @@ ); } - toastr.success(L('Added #1 #2 of #3 to stock', amount, Pluralize(amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name)); + toastr.success(L('Added #1 #2 of #3 to stock', amount, Pluralize(amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + L("Undo") + ''); if (addBarcode !== undefined) { @@ -171,3 +171,17 @@ $('#amount').on('change', function (e) { Grocy.FrontendHelpers.ValidateForm('purchase-form'); }); + +function UndoStockBooking(bookingId) +{ + Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(), + function(result) + { + toastr.success(L("Booking successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}; diff --git a/public/viewjs/stockjournal.js b/public/viewjs/stockjournal.js new file mode 100644 index 00000000..00cc22dc --- /dev/null +++ b/public/viewjs/stockjournal.js @@ -0,0 +1,70 @@ +var stockJournalTable = $('#stock-journal-table').DataTable({ + 'paginate': true, + 'order': [[3, 'desc']], + 'columnDefs': [ + { 'orderable': false, 'targets': 0 } + ], + 'language': JSON.parse(L('datatables_localization')), + 'scrollY': false, + 'colReorder': true, + 'stateSave': true, + 'stateSaveParams': function(settings, data) + { + data.search.search = ""; + + data.columns.forEach(column => + { + column.search.search = ""; + }); + } +}); + +$("#product-filter").on("change", function() +{ + var value = $(this).val(); + var text = $("#product-filter option:selected").text(); + if (value === "all") + { + text = ""; + } + + stockJournalTable.column(1).search(text).draw(); +}); + +$("#search").on("keyup", function() +{ + var value = $(this).val(); + if (value === "all") + { + value = ""; + } + + stockJournalTable.search(value).draw(); +}); + +if (typeof GetUriParam("product") !== "undefined") +{ + $("#product-filter").val(GetUriParam("product")); + $("#product-filter").trigger("change"); +} + +$(document).on('click', '.undo-stock-booking-button', function(e) +{ + e.preventDefault(); + + var element = $(e.currentTarget); + var bookingId = $(e.currentTarget).attr('data-booking-id'); + + Grocy.Api.Get('stock/undo-booking/' + bookingId.toString(), + function(result) + { + element.closest("tr").addClass("text-muted"); + element.closest(".undo-stock-booking-button").addClass("disabled"); + toastr.success(L("Booking successfully undone")); + }, + function(xhr) + { + console.error(xhr); + } + ); +}); diff --git a/routes.php b/routes.php index 2d5ad2ec..d1baa9fb 100644 --- a/routes.php +++ b/routes.php @@ -35,6 +35,7 @@ $app->group('', function() $this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm'); $this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList'); $this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); + $this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal'); // Recipe routes $this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview'); @@ -44,7 +45,7 @@ $app->group('', function() // Chore routes $this->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview'); $this->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution'); - $this->get('/choresanalysis', '\Grocy\Controllers\ChoresController:Analysis'); + $this->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal'); $this->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList'); $this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm'); @@ -52,6 +53,7 @@ $app->group('', function() // Battery routes $this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview'); $this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle'); + $this->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal'); $this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList'); $this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm'); diff --git a/services/BatteriesService.php b/services/BatteriesService.php index 5e1de622..e7c879fa 100644 --- a/services/BatteriesService.php +++ b/services/BatteriesService.php @@ -18,14 +18,14 @@ class BatteriesService extends BaseService } $battery = $this->Database->batteries($batteryId); - $batteryChargeCylcesCount = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->count(); + $batteryChargeCyclesCount = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->count(); $batteryLastChargedTime = $this->Database->battery_charge_cycles()->where('battery_id = :1 AND undone = 0', $batteryId)->max('tracked_time'); $nextChargeTime = $this->Database->batteries_current()->where('battery_id', $batteryId)->min('next_estimated_charge_time'); return array( 'battery' => $battery, 'last_charged' => $batteryLastChargedTime, - 'charge_cycles_count' => $batteryChargeCylcesCount, + 'charge_cycles_count' => $batteryChargeCyclesCount, 'next_estimated_charge_time' => $nextChargeTime ); } @@ -43,7 +43,7 @@ class BatteriesService extends BaseService )); $logRow->save(); - return true; + return $this->Database->lastInsertId(); } private function BatteryExists($batteryId) diff --git a/services/ChoresService.php b/services/ChoresService.php index e84d9319..cacc4af6 100644 --- a/services/ChoresService.php +++ b/services/ChoresService.php @@ -63,7 +63,7 @@ class ChoresService extends BaseService )); $logRow->save(); - return true; + return $this->Database->lastInsertId(); } private function ChoreExists($choreId) diff --git a/services/StockService.php b/services/StockService.php index b2a39da2..9c9d4af3 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -47,8 +47,8 @@ class StockService extends BaseService $product = $this->Database->products($productId); $productStockAmount = $this->Database->stock()->where('product_id', $productId)->sum('amount'); - $productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->max('purchased_date')->where('undone', 0); - $productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->max('used_date')->where('undone', 0); + $productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->where('undone', 0)->max('purchased_date'); + $productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone', 0)->max('used_date'); $nextBestBeforeDate = $this->Database->stock()->where('product_id', $productId)->min('best_before_date'); $quPurchase = $this->Database->quantity_units($product->qu_id_purchase); $quStock = $this->Database->quantity_units($product->qu_id_stock); @@ -113,6 +113,8 @@ class StockService extends BaseService )); $logRow->save(); + $returnValue = $this->Database->lastInsertId(); + $stockRow = $this->Database->stock()->createRow(array( 'product_id' => $productId, 'amount' => $amount, @@ -123,7 +125,7 @@ class StockService extends BaseService )); $stockRow->save(); - return true; + return $returnValue; } else { @@ -197,7 +199,7 @@ class StockService extends BaseService } } - return true; + return $this->Database->lastInsertId(); } else { @@ -226,7 +228,7 @@ class StockService extends BaseService $this->ConsumeProduct($productId, $amountToRemove, false, self::TRANSACTION_TYPE_INVENTORY_CORRECTION); } - return true; + return $this->Database->lastInsertId(); } public function AddMissingProductsToShoppingList() diff --git a/views/batteriesjournal.blade.php b/views/batteriesjournal.blade.php new file mode 100644 index 00000000..e5c43a34 --- /dev/null +++ b/views/batteriesjournal.blade.php @@ -0,0 +1,66 @@ +@extends('layout.default') + +@section('title', $L('Batteries journal')) +@section('activeNav', 'batteriesjournal') +@section('viewJsName', 'batteriesjournal') + +@section('content') +
+
+

@yield('title')

+
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + + + + + + + + @foreach($chargeCycles as $chargeCycleEntry) + + + + + + @endforeach + +
#{{ $L('Battery') }}{{ $L('Tracked time') }}
+ + + + + {{ FindObjectInArrayByPropertyValue($batteries, 'id', $chargeCycleEntry->battery_id)->name }} + @if($chargeCycleEntry->undone == 1) +
+ {{ $L('Undone on') . ' ' . $chargeCycleEntry->undone_timestamp }} + + @endif +
+ {{ $chargeCycleEntry->tracked_time }} + +
+
+
+@stop diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 1c11c5f9..8ab8d5ef 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -11,7 +11,11 @@ @section('content')
-

@yield('title')

+

@yield('title') + + {{ $L('Journal') }} + +

@@ -53,6 +57,9 @@ data-battery-name="{{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }}"> + + + {{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }} diff --git a/views/choresanalysis.blade.php b/views/choresjournal.blade.php similarity index 56% rename from views/choresanalysis.blade.php rename to views/choresjournal.blade.php index e09d8f55..aec7f698 100644 --- a/views/choresanalysis.blade.php +++ b/views/choresjournal.blade.php @@ -1,8 +1,8 @@ @extends('layout.default') -@section('title', $L('Chores analysis')) -@section('activeNav', 'choresanalysis') -@section('viewJsName', 'choresanalysis') +@section('title', $L('Chores journal')) +@section('activeNav', 'choresjournal') +@section('viewJsName', 'choresjournal') @section('content')
@@ -11,7 +11,7 @@
-
+
+ + @foreach($products as $product) + + @endforeach + +
+
+ + +
+
+ +
+
+ + + + + + + + + + + + @foreach($stockLog as $stockLogEntry) + + + + + + + + @endforeach + +
#{{ $L('Product') }}{{ $L('Amount') }}{{ $L('Booking time') }}{{ $L('Booking type') }}
+ + + + + {{ FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->name }} + @if($stockLogEntry->undone == 1) +
+ {{ $L('Undone on') . ' ' . $stockLogEntry->undone_timestamp }} + + @endif +
+ {{ $stockLogEntry->amount }} {{ Pluralize($stockLogEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockLogEntry->product_id)->qu_id_stock)->name_plural) }} + + {{ $stockLogEntry->row_created_timestamp }} + + + {{ $L($stockLogEntry->transaction_type) }} +
+
+
+@stop diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 22b8a478..6ff692a2 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -19,7 +19,12 @@ @section('content')
-

@yield('title')

+

@yield('title') + + + {{ $L('Journal') }} + +

@@ -92,6 +97,9 @@ data-consume-amount="{{ $currentStockEntry->amount }}"> {{ $L('All') }} + + + {{ FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name }}