mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Add journal and undo UI for stock bookings, chore executions and battery charge cycles (closes #63, closes #97)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
@@ -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')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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')
|
||||
]);
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user