diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index 8635b330..17ac8ddd 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -89,6 +89,7 @@ ### General +- Like already possible for products/chores/batteries, locations, stores, quantity units, product groups and task categories can now be disabled to keep them for existing references without deleting them, but to hide them everywhere for selections and so on (new option "Active") - Added a new `config.php` setting `ENERGY_UNIT` to customize the label to display energy values (was fixed `kcal` before and defaults to that, so no changed behavior when not configured) - Fixed that users were unable to delete their own API keys (when not having the `All permissions` permission) - Fixed that button tooltips on some places didn't disappear after clicking the corresponding button diff --git a/controllers/StockController.php b/controllers/StockController.php index 1af1123c..76cad254 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -26,8 +26,8 @@ class StockController extends BaseController return $this->renderPage($response, 'inventory', [ 'products' => $this->getDatabase()->products()->where('active = 1 AND no_own_stock = 0')->orderBy('name', 'COLLATE NOCASE'), 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('stock') @@ -97,8 +97,17 @@ class StockController extends BaseController public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + if (isset($request->getQueryParams()['include_disabled'])) + { + $locations = $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'); + } + else + { + $locations = $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'); + } + return $this->renderPage($response, 'locations', [ - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $locations, 'userfields' => $this->getUserfieldsService()->GetFields('locations'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations') ]); @@ -111,10 +120,10 @@ class StockController extends BaseController return $this->renderPage($response, 'stockoverview', [ 'currentStock' => $this->getStockService()->GetCurrentStockOverview(), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(), 'nextXDays' => $nextXDays, - 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('products'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products') ]); @@ -134,7 +143,7 @@ class StockController extends BaseController 'mode' => 'create', 'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'), 'product' => $product, - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes') @@ -146,7 +155,7 @@ class StockController extends BaseController 'mode' => 'edit', 'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']), 'product' => $product, - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes') @@ -159,13 +168,13 @@ class StockController extends BaseController if ($args['productId'] == 'new') { return $this->renderPage($response, 'productform', [ - 'locations' => $this->getDatabase()->locations()->orderBy('name'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name'), 'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunitsStock' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'referencedQuantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), - 'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'referencedQuantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'productgroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('products'), 'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL and active = 1')->orderBy('name', 'COLLATE NOCASE'), 'isSubProductOfOthers' => false, @@ -178,13 +187,13 @@ class StockController extends BaseController return $this->renderPage($response, 'productform', [ 'product' => $product, - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunitsStock' => $this->getDatabase()->quantity_units()->where('id IN (SELECT to_qu_id FROM quantity_unit_conversions_resolved WHERE product_id = :1) OR NOT EXISTS(SELECT 1 FROM stock_log WHERE product_id = :1)', $product->id)->orderBy('name', 'COLLATE NOCASE'), - 'referencedQuantityunits' => $this->getDatabase()->quantity_units()->where('id IN (SELECT to_qu_id FROM quantity_unit_conversions_resolved WHERE product_id = :1)', $product->id)->orderBy('name', 'COLLATE NOCASE'), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), - 'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'referencedQuantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->where('id IN (SELECT to_qu_id FROM quantity_unit_conversions_resolved WHERE product_id = :1)', $product->id)->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'productgroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('products'), 'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL and active = 1', $product->id)->orderBy('name', 'COLLATE NOCASE'), 'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0, @@ -223,8 +232,17 @@ class StockController extends BaseController public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + if (isset($request->getQueryParams()['include_disabled'])) + { + $productGroups = $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'); + } + else + { + $productGroups = $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'); + } + return $this->renderPage($response, 'productgroups', [ - 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'productGroups' => $productGroups, 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('product_groups'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups') @@ -254,7 +272,7 @@ class StockController extends BaseController 'products' => $products, 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'shoppingLocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('products'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products') @@ -266,9 +284,9 @@ class StockController extends BaseController return $this->renderPage($response, 'purchase', [ 'products' => $this->getDatabase()->products()->where('active = 1 AND no_own_stock = 0')->orderBy('name', 'COLLATE NOCASE'), 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('stock') ]); @@ -294,7 +312,7 @@ class StockController extends BaseController return $this->renderPage($response, 'quantityunitconversionform', [ 'mode' => 'create', 'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'product' => $product, 'defaultQuUnit' => $defaultQuUnit ]); @@ -305,7 +323,7 @@ class StockController extends BaseController 'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']), 'mode' => 'edit', 'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'product' => $product, 'defaultQuUnit' => $defaultQuUnit ]); @@ -342,14 +360,23 @@ class StockController extends BaseController public function QuantityUnitPluralFormTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { return $this->renderPage($response, 'quantityunitpluraltesting', [ - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE') + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE') ]); } public function QuantityUnitsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + if (isset($request->getQueryParams()['include_disabled'])) + { + $quantityUnits = $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'); + } + else + { + $quantityUnits = $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'); + } + return $this->renderPage($response, 'quantityunits', [ - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $quantityUnits, 'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units') ]); @@ -408,7 +435,7 @@ class StockController extends BaseController 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), 'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'), 'mode' => 'create', - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('shopping_list') ]); @@ -421,7 +448,7 @@ class StockController extends BaseController 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), 'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'), 'mode' => 'edit', - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(), 'userfields' => $this->getUserfieldsService()->GetFields('shopping_list') ]); @@ -447,7 +474,7 @@ class StockController extends BaseController else { return $this->renderPage($response, 'shoppinglocationform', [ - 'shoppinglocation' => $this->getDatabase()->shopping_locations($args['shoppingLocationId']), + 'shoppingLocation' => $this->getDatabase()->shopping_locations($args['shoppingLocationId']), 'mode' => 'edit', 'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations') ]); @@ -456,8 +483,17 @@ class StockController extends BaseController public function ShoppingLocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + if (isset($request->getQueryParams()['include_disabled'])) + { + $shoppingLocations = $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'); + } + else + { + $shoppingLocations = $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'); + } + return $this->renderPage($response, 'shoppinglocations', [ - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $shoppingLocations, 'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_locations') ]); @@ -468,8 +504,8 @@ class StockController extends BaseController return $this->renderPage($response, 'stockentryform', [ 'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(), 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'userfields' => $this->getUserfieldsService()->GetFields('stock') ]); } @@ -493,9 +529,9 @@ class StockController extends BaseController public function StockSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { return $this->renderPage($response, 'stocksettings', [ - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE') + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE') ]); } @@ -506,9 +542,9 @@ class StockController extends BaseController return $this->renderPage($response, 'stockentries', [ 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), - 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'), + 'quantityunits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'shoppinglocations' => $this->getDatabase()->shopping_locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'stockEntries' => $this->getDatabase()->uihelper_stock_entries()->orderBy('product_id'), 'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(), 'nextXDays' => $nextXDays, @@ -524,8 +560,8 @@ class StockController extends BaseController return $this->renderPage($response, 'transfer', [ 'products' => $this->getDatabase()->products()->where('active = 1')->where('no_own_stock = 0 AND id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)')->orderBy('name', 'COLLATE NOCASE'), 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), - 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'), - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'locations' => $this->getDatabase()->locations()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved() ]); } @@ -570,7 +606,7 @@ class StockController extends BaseController return $this->renderPage($response, 'quantityunitconversionsresolved', [ 'product' => $product, - 'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), + 'quantityUnits' => $this->getDatabase()->quantity_units()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityUnitConversionsResolved' => $quantityUnitConversionsResolved ]); } diff --git a/controllers/StockReportsController.php b/controllers/StockReportsController.php index 1c78eb34..4c81a028 100644 --- a/controllers/StockReportsController.php +++ b/controllers/StockReportsController.php @@ -63,7 +63,7 @@ class StockReportsController extends BaseController return $this->renderPage($response, 'stockreportspendings', [ 'metrics' => $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ), - 'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'), + 'productGroups' => $this->getDatabase()->product_groups()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'selectedGroup' => isset($request->getQueryParams()['product_group']) ? $request->getQueryParams()['product_group'] : null, 'byGroup' => isset($request->getQueryParams()['byGroup']) ? $request->getQueryParams()['byGroup'] : null ]); diff --git a/controllers/TasksController.php b/controllers/TasksController.php index 3c6a0282..481996db 100644 --- a/controllers/TasksController.php +++ b/controllers/TasksController.php @@ -41,7 +41,7 @@ class TasksController extends BaseController return $this->renderPage($response, 'tasks', [ 'tasks' => $tasks, 'nextXDays' => $nextXDays, - 'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'), + 'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'users' => $this->getDatabase()->users(), 'userfields' => $this->getUserfieldsService()->GetFields('tasks'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('tasks') @@ -50,8 +50,17 @@ class TasksController extends BaseController public function TaskCategoriesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { + if (isset($request->getQueryParams()['include_disabled'])) + { + $categories = $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'); + } + else + { + $categories = $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'); + } + return $this->renderPage($response, 'taskcategories', [ - 'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'), + 'taskCategories' => $categories, 'userfields' => $this->getUserfieldsService()->GetFields('task_categories'), 'userfieldValues' => $this->getUserfieldsService()->GetAllValues('task_categories') ]); @@ -82,7 +91,7 @@ class TasksController extends BaseController { return $this->renderPage($response, 'taskform', [ 'mode' => 'create', - 'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'), + 'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'users' => $this->getDatabase()->users()->orderBy('username'), 'userfields' => $this->getUserfieldsService()->GetFields('tasks') ]); @@ -92,7 +101,7 @@ class TasksController extends BaseController return $this->renderPage($response, 'taskform', [ 'task' => $this->getDatabase()->tasks($args['taskId']), 'mode' => 'edit', - 'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name', 'COLLATE NOCASE'), + 'taskCategories' => $this->getDatabase()->task_categories()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'users' => $this->getDatabase()->users()->orderBy('username'), 'userfields' => $this->getUserfieldsService()->GetFields('tasks') ]); diff --git a/migrations/0218.sql b/migrations/0218.sql new file mode 100644 index 00000000..07eedc0a --- /dev/null +++ b/migrations/0218.sql @@ -0,0 +1,14 @@ +ALTER TABLE locations +ADD active TINYINT NOT NULL DEFAULT 1 CHECK(active IN (0, 1)); + +ALTER TABLE shopping_locations +ADD active TINYINT NOT NULL DEFAULT 1 CHECK(active IN (0, 1)); + +ALTER TABLE quantity_units +ADD active TINYINT NOT NULL DEFAULT 1 CHECK(active IN (0, 1)); + +ALTER TABLE product_groups +ADD active TINYINT NOT NULL DEFAULT 1 CHECK(active IN (0, 1)); + +ALTER TABLE task_categories +ADD active TINYINT NOT NULL DEFAULT 1 CHECK(active IN (0, 1)); diff --git a/public/viewjs/locations.js b/public/viewjs/locations.js index c8e2f784..33db0ce1 100644 --- a/public/viewjs/locations.js +++ b/public/viewjs/locations.js @@ -61,3 +61,20 @@ $(document).on('click', '.location-delete-button', function(e) } }); }); + +$("#show-disabled").change(function() +{ + if (this.checked) + { + window.location.href = U('/locations?include_disabled'); + } + else + { + window.location.href = U('/locations'); + } +}); + +if (GetUriParam('include_disabled')) +{ + $("#show-disabled").prop('checked', true); +} diff --git a/public/viewjs/productgroups.js b/public/viewjs/productgroups.js index 3c9b85d0..4f303625 100644 --- a/public/viewjs/productgroups.js +++ b/public/viewjs/productgroups.js @@ -70,3 +70,20 @@ $(window).on("message", function(e) window.location.reload(); } }); + +$("#show-disabled").change(function() +{ + if (this.checked) + { + window.location.href = U('/productgroups?include_disabled'); + } + else + { + window.location.href = U('/productgroups'); + } +}); + +if (GetUriParam('include_disabled')) +{ + $("#show-disabled").prop('checked', true); +} diff --git a/public/viewjs/quantityunits.js b/public/viewjs/quantityunits.js index e3be09fe..1a943493 100644 --- a/public/viewjs/quantityunits.js +++ b/public/viewjs/quantityunits.js @@ -61,3 +61,20 @@ $(document).on('click', '.quantityunit-delete-button', function(e) } }); }); + +$("#show-disabled").change(function() +{ + if (this.checked) + { + window.location.href = U('/quantityunits?include_disabled'); + } + else + { + window.location.href = U('/quantityunits'); + } +}); + +if (GetUriParam('include_disabled')) +{ + $("#show-disabled").prop('checked', true); +} diff --git a/public/viewjs/shoppinglocations.js b/public/viewjs/shoppinglocations.js index abbad22b..93e3a9ec 100644 --- a/public/viewjs/shoppinglocations.js +++ b/public/viewjs/shoppinglocations.js @@ -61,3 +61,20 @@ $(document).on('click', '.shoppinglocation-delete-button', function(e) } }); }); + +$("#show-disabled").change(function() +{ + if (this.checked) + { + window.location.href = U('/shoppinglocations?include_disabled'); + } + else + { + window.location.href = U('/shoppinglocations'); + } +}); + +if (GetUriParam('include_disabled')) +{ + $("#show-disabled").prop('checked', true); +} diff --git a/public/viewjs/taskcategories.js b/public/viewjs/taskcategories.js index ab798d79..364064d3 100644 --- a/public/viewjs/taskcategories.js +++ b/public/viewjs/taskcategories.js @@ -61,3 +61,20 @@ $(document).on('click', '.task-category-delete-button', function(e) } }); }); + +$("#show-disabled").change(function() +{ + if (this.checked) + { + window.location.href = U('/taskcategories?include_disabled'); + } + else + { + window.location.href = U('/taskcategories'); + } +}); + +if (GetUriParam('include_disabled')) +{ + $("#show-disabled").prop('checked', true); +} diff --git a/services/StockService.php b/services/StockService.php index 0b2f5fc4..4c04745c 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -1772,7 +1772,7 @@ class StockService extends BaseService if (file_exists($path)) { require_once $path; - return new $pluginName($this->getDatabase()->locations()->fetchAll(), $this->getDatabase()->quantity_units()->fetchAll()); + return new $pluginName($this->getDatabase()->locations()->where('active = 1')->fetchAll(), $this->getDatabase()->quantity_units()->fetchAll()); } else { @@ -1782,7 +1782,7 @@ class StockService extends BaseService private function LocationExists($locationId) { - $locationRow = $this->getDatabase()->locations()->where('id = :1', $locationId)->fetch(); + $locationRow = $this->getDatabase()->locations()->where('id = :1', $locationId)->where('active = 1')->fetch(); return $locationRow !== null; } diff --git a/services/TasksService.php b/services/TasksService.php index 9bbcf34b..6f545385 100644 --- a/services/TasksService.php +++ b/services/TasksService.php @@ -7,7 +7,7 @@ class TasksService extends BaseService public function GetCurrent(): \LessQL\Result { $users = $this->getUsersService()->GetUsersAsDto(); - $categories = $this->getDatabase()->task_categories(); + $categories = $this->getDatabase()->task_categories()->where('active = 1'); $tasks = $this->getDatabase()->tasks_current(); foreach ($tasks as $task) diff --git a/views/locationform.blade.php b/views/locationform.blade.php index 69f491a0..4b0fc158 100644 --- a/views/locationform.blade.php +++ b/views/locationform.blade.php @@ -43,6 +43,19 @@
{{ $__t('A name is required') }}
+
+
+ active == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="active" name="active" value="1"> + +
+
+
+ name="description">@if($mode == 'edit'){{ $shoppingLocation->description }}@endif
@include('components.userfieldsform', array( diff --git a/views/shoppinglocations.blade.php b/views/shoppinglocations.blade.php index ebadf725..02dc9d17 100644 --- a/views/shoppinglocations.blade.php +++ b/views/shoppinglocations.blade.php @@ -53,6 +53,17 @@ placeholder="{{ $__t('Search') }}"> +
+
+ + +
+
+
+
+ + +
+
+
+
+ active == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="active" name="active" value="1"> + +
+
+