mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Add "one click shopping list to stock workflow" (closes #110)
This commit is contained in:
parent
c61c37e67a
commit
306d0f7da6
@ -48,3 +48,8 @@ DefaultUserSetting('auto_reload_on_db_change', true);
|
||||
|
||||
# Show a clock in the header next to the logo or not
|
||||
DefaultUserSetting('show_clock_in_header', false);
|
||||
|
||||
# Shopping list to stock workflow:
|
||||
# Automatically do the booking using the last price and the amount
|
||||
# of the shopping list item, if the product has "Default best before days" set
|
||||
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false);
|
||||
|
@ -70,9 +70,9 @@ class StockController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
public function ProductDefaults(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
public function StockSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'productpresets', [
|
||||
return $this->AppContainer->view->render($response, 'stocksettings', [
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name')
|
||||
|
@ -322,5 +322,8 @@ return array(
|
||||
'Task due' => 'Task due',
|
||||
'Chore due' => 'Chore due',
|
||||
'Battery charge cycle due' => 'Battery charge cycle due',
|
||||
'Show clock in header' => 'Show clock in header'
|
||||
'Show clock in header' => 'Show clock in header',
|
||||
'Stock settings' => 'Stock settings',
|
||||
'Shopping list to stock workflow' => 'Shopping list to stock workflow',
|
||||
'Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set' => 'Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set'
|
||||
);
|
||||
|
@ -357,3 +357,9 @@ function WindowMessageBag(message, payload = null)
|
||||
obj.Payload = payload;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Add border around anchor link section
|
||||
if (window.location.hash)
|
||||
{
|
||||
$(window.location.hash).addClass("p-2 border border-info rounded");
|
||||
}
|
||||
|
@ -104,6 +104,13 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
|
||||
}
|
||||
$('#amount').focus();
|
||||
|
||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
||||
if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true)
|
||||
{
|
||||
console.log("hey");
|
||||
$("#save-purchase-button").click();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
$("#product_presets_location_id").val(Grocy.UserSettings.product_presets_location_id);
|
||||
$("#product_presets_product_group_id").val(Grocy.UserSettings.product_presets_product_group_id);
|
||||
$("#product_presets_qu_id").val(Grocy.UserSettings.product_presets_qu_id);
|
||||
|
||||
if (BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled))
|
||||
{
|
||||
$("#shopping-list-to-stock-workflow-auto-submit-when-prefilled").prop("checked", true);
|
||||
}
|
@ -26,7 +26,7 @@ $app->group('', function()
|
||||
$this->get('/inventory', '\Grocy\Controllers\StockController:Inventory');
|
||||
$this->get('/products', '\Grocy\Controllers\StockController:ProductsList');
|
||||
$this->get('/product/{productId}', '\Grocy\Controllers\StockController:ProductEditForm');
|
||||
$this->get('/productpresets', '\Grocy\Controllers\StockController:ProductDefaults');
|
||||
$this->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings');
|
||||
$this->get('/locations', '\Grocy\Controllers\StockController:LocationsList');
|
||||
$this->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm');
|
||||
$this->get('/quantityunits', '\Grocy\Controllers\StockController:QuantityUnitsList');
|
||||
|
@ -54,10 +54,10 @@ class DemoDataGeneratorService extends BaseService
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Yogurt')}', 2, 6, 6, 1, 6); --9
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Cheese')}', 2, 3, 3, 1, 6); --10
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Cold cuts')}', 2, 3, 3, 1, 6); --11
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name) VALUES ('{$localizationService->Localize('Paprika')}', 2, 2, 2, 1, 5, 'paprika.jpg'); --12
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name) VALUES ('{$localizationService->Localize('Cucumber')}', 2, 2, 2, 1, 5, 'cucumber.jpg'); --13
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Radish')}', 2, 7, 7, 1, 5); --14
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name) VALUES ('{$localizationService->Localize('Tomato')}', 2, 2, 2, 1, 5, 'tomato.jpg'); --15
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name, default_best_before_days) VALUES ('{$localizationService->Localize('Paprika')}', 2, 2, 2, 1, 5, 'paprika.jpg', 7); --12
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name, default_best_before_days) VALUES ('{$localizationService->Localize('Cucumber')}', 2, 2, 2, 1, 5, 'cucumber.jpg', 7); --13
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, default_best_before_days) VALUES ('{$localizationService->Localize('Radish')}', 2, 7, 7, 1, 5, 7); --14
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id, picture_file_name, default_best_before_days) VALUES ('{$localizationService->Localize('Tomato')}', 2, 2, 2, 1, 5, 'tomato.jpg', 7); --15
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Pizza dough')}', 3, 3, 3, 1, 6); --16
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Sieved tomatoes')}', 4, 5, 5, 1, 3); --17
|
||||
INSERT INTO products (name, location_id, qu_id_purchase, qu_id_stock, qu_factor_purchase_to_stock, product_group_id) VALUES ('{$localizationService->Localize('Salami')}', 2, 3, 3, 1, 6); --18
|
||||
|
@ -274,6 +274,7 @@
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item discrete-link" href="{{ $U('/users') }}"><i class="fas fa-users"></i> {{ $L('Manage users') }}</a>
|
||||
<a class="dropdown-item discrete-link" href="{{ $U('/stocksettings') }}"><i class="fas fa-box"></i> {{ $L('Stock settings') }}</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item discrete-link" href="{{ $U('/manageapikeys') }}"><i class="fas fa-handshake"></i> {{ $L('Manage API keys') }}</a>
|
||||
<a class="dropdown-item discrete-link" target="_blank" href="{{ $U('/api') }}"><i class="fas fa-book"></i> {{ $L('REST API & data model documentation') }}</a>
|
||||
|
@ -1,45 +0,0 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@section('title', $L('Presets for new products'))
|
||||
|
||||
@section('viewJsName', 'productpresets')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-xs-12">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_location_id">{{ $L('Location') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_location_id" data-setting-key="product_presets_location_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($locations as $location)
|
||||
<option value="{{ $location->id }}">{{ $location->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_product_group_id">{{ $L('Product group') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_product_group_id" data-setting-key="product_presets_product_group_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($productGroups as $productGroup)
|
||||
<option value="{{ $productGroup->id }}">{{ $productGroup->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_qu_id">{{ $L('Quantity unit') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_qu_id" data-setting-key="product_presets_qu_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($quantityunits as $quantityunit)
|
||||
<option value="{{ $quantityunit->id }}">{{ $quantityunit->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<a href="{{ $U('/products') }}" class="btn btn-success">{{ $L('OK') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
@ -12,7 +12,7 @@
|
||||
<a class="btn btn-outline-dark" href="{{ $U('/product/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
</a>
|
||||
<a class="btn btn-outline-secondary" href="{{ $U('/productpresets') }}">
|
||||
<a class="btn btn-outline-secondary" href="{{ $U('/stocksettings#productpresets') }}">
|
||||
<i class="fas fa-sliders-h"></i> {{ $L('Presets for new products') }}
|
||||
</a>
|
||||
</h1>
|
||||
|
59
views/stocksettings.blade.php
Normal file
59
views/stocksettings.blade.php
Normal file
@ -0,0 +1,59 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@section('title', $L('Stock settings'))
|
||||
|
||||
@section('viewJsName', 'stocksettings')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-xs-12">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<div id="productpresets">
|
||||
<h4>{{ $L('Presets for new products') }}</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_location_id">{{ $L('Location') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_location_id" data-setting-key="product_presets_location_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($locations as $location)
|
||||
<option value="{{ $location->id }}">{{ $location->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_product_group_id">{{ $L('Product group') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_product_group_id" data-setting-key="product_presets_product_group_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($productGroups as $productGroup)
|
||||
<option value="{{ $productGroup->id }}">{{ $productGroup->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="product_presets_qu_id">{{ $L('Quantity unit') }}</label>
|
||||
<select class="form-control user-setting-control" id="product_presets_qu_id" data-setting-key="product_presets_qu_id">
|
||||
<option value="-1"></option>
|
||||
@foreach($quantityunits as $quantityunit)
|
||||
<option value="{{ $quantityunit->id }}">{{ $quantityunit->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 class="mt-2">{{ $L('Shopping list to stock workflow') }}</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label for="shopping-list-to-stock-workflow-auto-submit-when-prefilled">
|
||||
<input type="checkbox" class="user-setting-control" id="shopping-list-to-stock-workflow-auto-submit-when-prefilled" name="shopping-list-to-stock-workflow-auto-submit-when-prefilled" data-setting-key="shopping_list_to_stock_workflow_auto_submit_when_prefilled"> {{ $L('Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ $U('/products') }}" class="btn btn-success">{{ $L('OK') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
Loading…
x
Reference in New Issue
Block a user