mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Fixed number input min/max amount handling Only (auto) save valid user inputs More filters on the stock journal pages Save the last price per used barcode and preselect that as a total price on purchase if not empty (closes #1131) Don't apply conversions for only_check_single_unit_in_stock ingredients (fixes #1120) Render shopping list userfields (closes #1052) Fixed Focus when adding included recipes (closes #1019) Order all base objects with NOCASE (closes #1086)
100 lines
3.5 KiB
PHP
100 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace Grocy\Controllers;
|
|
|
|
class GenericEntityController extends BaseController
|
|
{
|
|
public function UserentitiesList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
return $this->renderPage($response, 'userentities', [
|
|
'userentities' => $this->getDatabase()->userentities()->orderBy('name', 'COLLATE NOCASE')
|
|
]);
|
|
}
|
|
|
|
public function UserentityEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
if ($args['userentityId'] == 'new')
|
|
{
|
|
return $this->renderPage($response, 'userentityform', [
|
|
'mode' => 'create'
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
return $this->renderPage($response, 'userentityform', [
|
|
'mode' => 'edit',
|
|
'userentity' => $this->getDatabase()->userentities($args['userentityId'])
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function UserfieldEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
if ($args['userfieldId'] == 'new')
|
|
{
|
|
return $this->renderPage($response, 'userfieldform', [
|
|
'mode' => 'create',
|
|
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
|
|
'entities' => $this->getUserfieldsService()->GetEntities()
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
return $this->renderPage($response, 'userfieldform', [
|
|
'mode' => 'edit',
|
|
'userfield' => $this->getUserfieldsService()->GetField($args['userfieldId']),
|
|
'userfieldTypes' => $this->getUserfieldsService()->GetFieldTypes(),
|
|
'entities' => $this->getUserfieldsService()->GetEntities()
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function UserfieldsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
return $this->renderPage($response, 'userfields', [
|
|
'userfields' => $this->getUserfieldsService()->GetAllFields(),
|
|
'entities' => $this->getUserfieldsService()->GetEntities()
|
|
]);
|
|
}
|
|
|
|
public function UserobjectEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
|
|
|
if ($args['userobjectId'] == 'new')
|
|
{
|
|
return $this->renderPage($response, 'userobjectform', [
|
|
'userentity' => $userentity,
|
|
'mode' => 'create',
|
|
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName'])
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
return $this->renderPage($response, 'userobjectform', [
|
|
'userentity' => $userentity,
|
|
'mode' => 'edit',
|
|
'userobject' => $this->getDatabase()->userobjects($args['userobjectId']),
|
|
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName'])
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function UserobjectsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
|
{
|
|
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
|
|
|
return $this->renderPage($response, 'userobjects', [
|
|
'userentity' => $userentity,
|
|
'userobjects' => $this->getDatabase()->userobjects()->where('userentity_id = :1', $userentity->id),
|
|
'userfields' => $this->getUserfieldsService()->GetFields('userentity-' . $args['userentityName']),
|
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('userentity-' . $args['userentityName'])
|
|
]);
|
|
}
|
|
|
|
public function __construct(\DI\Container $container)
|
|
{
|
|
parent::__construct($container);
|
|
}
|
|
}
|