auto fixes + some impl.

This commit is contained in:
Dennis Eichhorn 2024-01-26 22:53:59 +00:00
parent 6a460b8e48
commit 4db364c31a
23 changed files with 369 additions and 403 deletions

View File

@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/helper/report/export.*$' => [
'^.*/helper/report/export(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\ApiController:apiHelperExport',
'verb' => RouteVerb::GET,
@ -29,7 +29,7 @@ return [
],
],
],
'^.*/helper/report/template.*$' => [
'^.*/helper/report/template(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\ApiController:apiTemplateCreate',
'verb' => RouteVerb::SET,
@ -40,7 +40,7 @@ return [
],
],
],
'^.*/helper/report/report.*$' => [
'^.*/helper/report/report(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\ApiController:apiReportCreate',
'verb' => RouteVerb::SET,

View File

@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/helper/template/create.*$' => [
'^.*/helper/template/create(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\BackendController:viewTemplateCreate',
'verb' => RouteVerb::GET,
@ -29,7 +29,7 @@ return [
],
],
],
'^.*/helper/report/create.*$' => [
'^.*/helper/report/create(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\BackendController:viewReportCreate',
'verb' => RouteVerb::GET,
@ -40,7 +40,7 @@ return [
],
],
],
'^.*/helper/list.*$' => [
'^.*/helper/list(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\BackendController:viewTemplateList',
'verb' => RouteVerb::GET,
@ -51,7 +51,7 @@ return [
],
],
],
'^.*/helper/report/view.*$' => [
'^.*/helper/report/view(\?.*$|$)' => [
[
'dest' => '\Modules\Helper\Controller\BackendController:viewHelperReport',
'verb' => RouteVerb::GET,

View File

@ -1,12 +1,16 @@
# Development
## Development environment
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md).
## Code of conduct
Every organization member and contributor to the organization must follow the [code of conduct](../Policies & Guidelines/Code of conduct.md).
Every organization member and contributor to the organization must follow the [Code of Conduct](../Policies%20&%20Guidelines/Code%20of%20Conduct.md).
## Becoming a contributor
For public repositories you can immediately start by creating forks and pull requests. For private repositories which are necessary to setup the complete developer environment, feel free to request access. Please not that we may not immediately give you access to private repositories and instead will give you smaller tasks regarding public repositories. Please contact info@jingga.app for more details. (**R1**)
For all contributions our [Contributor License Agreement "CLA"](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/HR/Hiring/Individual%20Contributor%20License%20Agreement.md) comes into effect. (**R2**)
## Code changes
@ -14,58 +18,106 @@ Every organization member and contributor to the organization must follow the [c
Generally, the development philosophy is result orientated. This means that anyone can propose tasks, pick up existing tasks or right away implement their code changes. However, implementing code changes without consulting with a senior developer in advance has a much higher risk of code changes not getting admitted. The easiest way to discuss a code change idea in advance are the github [issues](https://github.com/Karaka-Management/Karaka/issues) or [discussions](https://github.com/Karaka-Management/Karaka/discussions).
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10)
Open tasks can be found in the project overview: [Todos](https://github.com/orgs/Karaka-Management/projects/10)
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis.
### Code style
### Quality
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review.
#### Code style
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be changes in the programming language, special cases which cannot, are difficult or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review.
Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards) (**R3**). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R4**)
Automated checks which are run during the review process:
In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be for example special cases which are difficult automatize or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. (**R5**)
Automated checks which are run during the review process (**R4**):
```sh
php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
php ./vendor/bin/php-cs-fixer fix ./ --config=Build/Config/.php-cs-fixer.php --allow-risky=yes
php ./vendor/bin/phpcbf --standard=Build/Config/phpcs.xml ./
php ./vendor/bin/rector process --dry-run --config Build/Config/rector.php ./
npx eslint ./ -c ./Build/Config/.eslintrc.json
```
### Tests
#### Tests
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md). Developers should check if the code changes comply with the inspection guidelines before submitting them.
Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) (**R6**). Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R7**)
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted.
In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. (**R8**)
Automated tests which are run during the review process:
Automated tests which are run during the review process (**R7**):
```sh
php ./vendor/bin/phpunit -c tests/PHPUnit/phpunit_default.xml
php ./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./
php ./vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./
npx jasmine-node ./
./cOMS/tests/test.sh
```
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks.
Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. (**R7**)
### Demo
#### Performance
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically.
Developers should occasionaly check performance statistics. At this point no target metrics are defined.
### Code review
Since the primary application is a web based application a similar tool as the Google lighthouse tool can be used to inspect the application for best practicies which can significantly improve the application performance. The sitespeed.io tool shows potential performance improvements and slow pages. With the php trace and profiler enabled in the `php.ini` file the VM automatically generates profiling and trace reports for every web request. These can be found in the webgrind logs directory and inspected in webgrind and dropped into the trace visualizer for a flame chart visualization. With mysqldumpslow you can inspect slow sql queries which may need optimization.
1. Automatic trace and benchmark generation with every web request in `/var/www/html/webgrind/Logs`
2. Webgrind view `http://vm_ip:82`
3. Trace visualization `http://vm_ip:81`
1. Download the latest trace from `http://vm_ip:82/Logs`
2. Drag and drop that downloaded `*.xt` file in the trace visualizer
4. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed`
5. Slow query inspection.
```sh
mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log
mysqldumpslow -t 10 -s l /var/log/mysql/mysql-slow.log
```
#### Code review
In addition to the automatic code review performed by the various inspection tools such as (phpcs, phpstan, phpunit, eslint and custom scripts) a senior developer must check the proposed code change before it is merged with the respective `develop` branch. Only upon the approval by the reviewer a code change requests gets merged as no other developers have permission in the software to make such code merges.
In case a code change request is not approved the reviewer states the reason for the decision, this may include some tips and requests which will allow the contributor to make improvements so that the code change may get approved.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning.
If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. (**R5**+**R8**)
#### Demo
Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. (**R9**)
```sh
sudo -u www-data php -dxdebug.remote_enable=1 -dxdebug.start_with_request=yes -dxdebug.mode=coverage,develop,debug demoSetup/setup.php
```
#### Documentation
Occasionally new code or code changes also require new documentation or documentation changes. Developers should make sure that the new code is also reflected in the existing documentation ([Developer-Guide](), [User-Guide]() and/or module documentation) or if additional documentation is necessary.
#### Improvements, features, bugs
If a developer (or employee in general) has an idea for an improvement, feature or finds a potential bug it should be reported at https://github.com/Karaka-Management/Karaka/issues. A senior developer has to check these issues and decide how to proceed with them. The decision how to proceed with the issue must be explained by the senior developer as a response in the issue. Possible steps are:
* Accept the issue and put the task into the [Todos](https://github.com/orgs/Karaka-Management/projects/10)
* Dismiss the issue with an explanation
### Release flow
In case SCSS/CSS or JS files got changed they must get re-built locally before comitting the code change:
```sh
npx esbuild Web/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify
scss cssOMS/styles.scss > cssOMS/styles.css
```
For JS you may also use the shorthand command `npm run build`.
Code changes must be performed in a new branch. A new branch can be created with:
```sh
@ -75,8 +127,70 @@ git checkout -b new-branch-name
The name of the branch can be chosen freely however it is recommended to follow the following branch naming conventions:
* `feature-*` for feature implementations
* `hotfix-*` for security related fixes/improvements
* `bug-*` for bug fixes
* `security-*` for security related fixes/improvements
* `general-*` for general improvements (i.e. code documentation improvements, code style improvements)
* `general-*` for general improvements (i.e. documentation, code style & performance improvements)
The senior developer who performs the code review merges the change request into the `develop` branch upon approval.
```mermaid
%%{init: { 'gitGraph': {'mainBranchName': 'master'}} }%%
gitGraph
commit
branch hotfix-xxx
commit
checkout master
branch develop
checkout master
merge hotfix-xxx
checkout develop
branch bug-xxx
commit
commit
checkout hotfix-xxx
commit
checkout master
merge hotfix-xxx
checkout develop
merge bug-xxx
commit
checkout develop
branch feature-xxx
commit
commit
commit
checkout develop
merge feature-xxx
checkout master
merge develop
checkout develop
branch general-xxx
commit
checkout develop
merge general-xxx
branch security-xxx
commit
commit
checkout develop
merge security-xxx
checkout master
merge develop
```
The senior developer who performs the code review merges the change request into the `develop` branch after their successful code review. Unsuccessful reviews lead to change requests by the original developer, other developers who can make the requested changes, changes by the senior developer who performed the review, or dismissal of the changed code. (**R10**)
## Approved dependencies
### Customer dependencies
Developers may only rely on the dependencies defined in [Approved Customer Software]() when developing a solution. If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. (**R11**)
### Developer dependencies
Developers may only rely on the dependencies defined in [IT Equipment & Software](). If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. Changing the package managers such as `composer.json` or `package.json` is not allowed by anyone else than the CTO. (**R12**)
## Other related documents
* [Confidentiality Policy](../Policies%20&%20Guidelines/Confidentiality%20Policy.md)
* [Organization Activity Policy](../Policies%20&%20Guidelines/Organization%20Activity%20Policy.md)
* [Tutorials](./Development/Tutorials)

View File

@ -16,7 +16,6 @@ namespace Modules\Helper\Controller;
use Modules\Admin\Models\AccountPermission;
use Modules\Admin\Models\NullAccount;
use Modules\Helper\Models\NullReport;
use Modules\Helper\Models\NullTemplate;
use Modules\Helper\Models\PermissionCategory;
use Modules\Helper\Models\Report;
@ -29,10 +28,10 @@ use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\NullCollection;
use Modules\Media\Models\NullMedia;
use Modules\Media\Models\PathSettings;
use Modules\Tag\Models\NullTag;
use phpOMS\Account\PermissionType;
use phpOMS\Autoloader;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
@ -346,8 +345,8 @@ final class ApiController extends Controller
}
}
$view = new View($this->app->l11nManager, $request, $response);
$rcoll = [];
$view = new View($this->app->l11nManager, $request, $response);
$rcoll = [];
$report = null;
if (!$template->isStandalone) {
@ -370,10 +369,10 @@ final class ApiController extends Controller
}
}
$view->data['report'] = $report;
$view->data['rcoll'] = $rcoll;
$view->data['report'] = $report;
$view->data['rcoll'] = $rcoll;
$view->data['tcoll'] = $tcoll;
$view->data['lang'] = $request->getData('lang') ?? $request->header->l11n->language;
$view->data['lang'] = ISO639x1Enum::tryFromValue($request->getDataString('lang')) ?? $request->header->l11n->language;
$view->data['template'] = $template;
$view->data['basepath'] = __DIR__ . '/../../../';
@ -530,26 +529,8 @@ final class ApiController extends Controller
$helperTemplate->setExpected($request->getDataJson('expected'));
$helperTemplate->setDatatype($request->getDataInt('datatype') ?? TemplateDataType::OTHER);
if (!empty($tags = $request->getDataJson('tags'))) {
foreach ($tags as $tag) {
if (!isset($tag['id'])) {
$request->setData('title', $tag['title'], true);
$request->setData('color', $tag['color'], true);
$request->setData('icon', $tag['icon'] ?? null, true);
$request->setData('language', $tag['language'], true);
$internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse);
if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) {
continue;
}
$helperTemplate->addTag($data['response']);
} else {
$helperTemplate->addTag(new NullTag((int) $tag['id']));
}
}
if ($request->hasData('tags')) {
$helperTemplate->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request);
}
return $helperTemplate;

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Modules\Helper\Controller;
use Modules\Helper\Models\NullReport;
use Modules\Helper\Models\ReportMapper;
use Modules\Helper\Models\Template;
use Modules\Helper\Models\TemplateMapper;
@ -22,6 +21,7 @@ use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\Media;
use phpOMS\Contract\RenderableInterface;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Utils\StringUtils;
@ -158,7 +158,7 @@ final class BackendController extends Controller
->where('tags/title/language', $response->header->l11n->language)
->execute();
$view->setTemplate('/Modules/Helper/Theme/Backend/helper-single');
$view->setTemplate('/Modules/Helper/Theme/Backend/helper-view');
/** @var array<string, \Modules\Media\Models\Media> $tcoll */
$tcoll = [];
@ -199,7 +199,7 @@ final class BackendController extends Controller
}
}
$rcoll = [];
$rcoll = [];
$report = null;
if (!$template->isStandalone) {
if (!isset($tcoll['template'])) {
@ -227,7 +227,7 @@ final class BackendController extends Controller
$view->data['unit'] = $this->app->unitId;
$view->data['tcoll'] = $tcoll;
$view->data['rcoll'] = $rcoll;
$view->data['lang'] = $request->getData('lang') ?? $request->header->l11n->language;
$view->data['lang'] = ISO639x1Enum::tryFromValue($request->getDataString('lang')) ?? $request->header->l11n->language;
$view->data['template'] = $template;
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002701001, $request, $response);

View File

@ -27,7 +27,7 @@ Version 2.0
Subject to the terms and conditions of this License, each Contributor grants to You after purchase a perpetual, worldwide, non-exclusive, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform the Work and such Derivative Works in Source or Object form. You are not allowed to sublicense, reproduce, or distribute the Work and such Derivative Works in Source or Object form.
3. Redistribution.
3. Redistribution
You may not reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form.

View File

@ -114,44 +114,6 @@ class Report implements \JsonSerializable
$this->source = new NullCollection();
}
/**
* Get model id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the activity status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set the activity status
*
* @param int $status Report status
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
$this->status = $status;
}
/**
* {@inheritdoc}
*/

View File

@ -55,13 +55,13 @@ final class ReportMapper extends DataMapperFactory
* @since 1.0.0
*/
public const OWNS_ONE = [
'source' => [
'mapper' => \Modules\Media\Models\CollectionMapper::class,
'external' => 'helper_report_media',
'source' => [
'mapper' => \Modules\Media\Models\CollectionMapper::class,
'external' => 'helper_report_media',
],
'template' => [
'mapper' => TemplateMapper::class,
'external' => 'helper_report_template',
'mapper' => TemplateMapper::class,
'external' => 'helper_report_template',
],
];
@ -73,8 +73,8 @@ final class ReportMapper extends DataMapperFactory
*/
public const BELONGS_TO = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'helper_report_creator',
'mapper' => AccountMapper::class,
'external' => 'helper_report_creator',
],
];

View File

@ -167,18 +167,6 @@ class Template implements \JsonSerializable
$this->createdBy = new NullAccount();
}
/**
* Get model id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get newest report for template.
*
@ -235,32 +223,6 @@ class Template implements \JsonSerializable
$this->expected = $expected;
}
/**
* Set activity satuus
*
* @param int $status Template status (is active?)
*
* @return void
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
$this->status = $status;
}
/**
* Get activity status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set data type basis
*
@ -287,32 +249,6 @@ class Template implements \JsonSerializable
return $this->datatype;
}
/**
* Get tags
*
* @return array
*
* @since 1.0.0
*/
public function getTags() : array
{
return $this->tags;
}
/**
* Add tag
*
* @param Tag $tag Tag
*
* @return void
*
* @since 1.0.0
*/
public function addTag(Tag $tag) : void
{
$this->tags[] = $tag;
}
/**
* {@inheritdoc}
*/

View File

@ -40,19 +40,19 @@ final class TemplateMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'helper_template_id' => ['name' => 'helper_template_id', 'type' => 'int', 'internal' => 'id'],
'helper_template_status' => ['name' => 'helper_template_status', 'type' => 'int', 'internal' => 'status'],
'helper_template_title' => ['name' => 'helper_template_title', 'type' => 'string', 'internal' => 'name'],
'helper_template_data' => ['name' => 'helper_template_data', 'type' => 'int', 'internal' => 'datatype'],
'helper_template_standalone' => ['name' => 'helper_template_standalone', 'type' => 'bool', 'internal' => 'isStandalone'],
'helper_template_expected' => ['name' => 'helper_template_expected', 'type' => 'Json', 'internal' => 'expected'],
'helper_template_desc' => ['name' => 'helper_template_desc', 'type' => 'string', 'internal' => 'description'],
'helper_template_desc_raw' => ['name' => 'helper_template_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'helper_template_media' => ['name' => 'helper_template_media', 'type' => 'int', 'internal' => 'source'],
'helper_template_virtual' => ['name' => 'helper_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'],
'helper_template_creator' => ['name' => 'helper_template_creator', 'type' => 'int', 'internal' => 'createdBy'],
'helper_template_unit' => ['name' => 'helper_template_unit', 'type' => 'int', 'internal' => 'unit'],
'helper_template_created' => ['name' => 'helper_template_created', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
'helper_template_id' => ['name' => 'helper_template_id', 'type' => 'int', 'internal' => 'id'],
'helper_template_status' => ['name' => 'helper_template_status', 'type' => 'int', 'internal' => 'status'],
'helper_template_title' => ['name' => 'helper_template_title', 'type' => 'string', 'internal' => 'name'],
'helper_template_data' => ['name' => 'helper_template_data', 'type' => 'int', 'internal' => 'datatype'],
'helper_template_standalone' => ['name' => 'helper_template_standalone', 'type' => 'bool', 'internal' => 'isStandalone'],
'helper_template_expected' => ['name' => 'helper_template_expected', 'type' => 'Json', 'internal' => 'expected'],
'helper_template_desc' => ['name' => 'helper_template_desc', 'type' => 'string', 'internal' => 'description'],
'helper_template_desc_raw' => ['name' => 'helper_template_desc_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
'helper_template_media' => ['name' => 'helper_template_media', 'type' => 'int', 'internal' => 'source'],
'helper_template_virtual' => ['name' => 'helper_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'],
'helper_template_creator' => ['name' => 'helper_template_creator', 'type' => 'int', 'internal' => 'createdBy'],
'helper_template_unit' => ['name' => 'helper_template_unit', 'type' => 'int', 'internal' => 'unit'],
'helper_template_created' => ['name' => 'helper_template_created', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'],
];
/**
@ -63,8 +63,8 @@ final class TemplateMapper extends DataMapperFactory
*/
public const OWNS_ONE = [
'source' => [
'mapper' => CollectionMapper::class,
'external' => 'helper_template_media',
'mapper' => CollectionMapper::class,
'external' => 'helper_template_media',
],
];
@ -76,12 +76,12 @@ final class TemplateMapper extends DataMapperFactory
*/
public const BELONGS_TO = [
'createdBy' => [
'mapper' => AccountMapper::class,
'external' => 'helper_template_creator',
'mapper' => AccountMapper::class,
'external' => 'helper_template_creator',
],
'unit' => [
'mapper' => UnitMapper::class,
'external' => 'helper_template_unit',
'mapper' => UnitMapper::class,
'external' => 'helper_template_unit',
],
];
@ -93,10 +93,10 @@ final class TemplateMapper extends DataMapperFactory
*/
public const HAS_MANY = [
'reports' => [
'mapper' => ReportMapper::class,
'table' => 'helper_report',
'self' => 'helper_report_template',
'external' => null,
'mapper' => ReportMapper::class,
'table' => 'helper_report',
'self' => 'helper_report_template',
'external' => null,
],
'tags' => [
'mapper' => TagMapper::class,

View File

@ -105,11 +105,11 @@ echo $this->data['nav']->render(); ?>
<td>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->name); ?></a>
<td data-label="<?= $this->getHtml('Tag'); ?>">
<?php $tags = $template->getTags();
foreach ($tags as $tag) : ?>
<?php
foreach ($template->tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $template->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$template->createdBy->name1, $template->createdBy->name2, $template->createdBy->name3, $template->createdBy->login ?? ''])); ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/view?{?}&for=' . $template->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$template->createdBy->name1, $template->createdBy->name2, $template->createdBy->name3, $template->createdBy->login ?? ''])); ?></a>
<td data-label="<?= $this->getHtml('Updated'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->createdAt->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>

View File

@ -148,7 +148,7 @@ echo $this->data['nav']->render(); ?>
<td><?= $this->printHtml($template->name); ?>
<tr>
<td><?= $this->getHtml('Creator'); ?>
<td><a href="<?= UriFactory::build('{/base}/profile/single?for=' . $template->createdBy->id); ?>"><?= $this->printHtml($template->createdBy->name1); ?></a>
<td><a href="<?= UriFactory::build('{/base}/profile/view?for=' . $template->createdBy->id); ?>"><?= $this->printHtml($template->createdBy->name1); ?></a>
<tr>
<td><?= $this->getHtml('Created'); ?>
<td><?= $template->createdAt->format('Y-m-d'); ?>
@ -156,8 +156,7 @@ echo $this->data['nav']->render(); ?>
<td><?= $this->getHtml('Tags'); ?>
<td>
<?php
$tags = $template->getTags();
foreach ($tags as $tag) : ?>
foreach ($template->tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?>
</table>

View File

@ -75,8 +75,8 @@ final class Autoloader
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class);

View File

@ -1,4 +1,15 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Helper\tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
@ -67,10 +78,10 @@ $GLOBALS['is_github'] = $IS_GITHUB;
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'db' => [
'core' => [
'masters' => [
'admin' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -80,7 +91,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -90,7 +101,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -100,7 +111,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -110,7 +121,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -120,7 +131,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
@ -132,7 +143,7 @@ $CONFIG = [
],
],
'postgresql' => [
'admin' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -142,7 +153,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -152,7 +163,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -162,7 +173,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -172,7 +183,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -182,7 +193,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
@ -194,37 +205,37 @@ $CONFIG = [
],
],
'sqlite' => [
'admin' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
@ -232,7 +243,7 @@ $CONFIG = [
],
],
'mssql' => [
'admin' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -242,7 +253,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -252,7 +263,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -262,7 +273,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -272,7 +283,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -282,7 +293,7 @@ $CONFIG = [
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
@ -322,16 +333,16 @@ $CONFIG = [
'password' => '123456',
],
],
'log' => [
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
@ -350,7 +361,7 @@ $CONFIG = [
],
],
],
'socket' => [
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
@ -360,7 +371,7 @@ $CONFIG = [
'language' => [
'en',
],
'apis' => [
'apis' => [
],
];

View File

@ -31,7 +31,6 @@ use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\System\File\Local\Directory;
use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
/**
@ -64,13 +63,13 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
protected int $appId = 1;
};
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php');
$this->app->sessionManager = new HttpSession(36000);
$this->app->l11nManager = new L11nManager();
@ -106,7 +105,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testStandaloneTemplateCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', \ucfirst('depreciation'));
@ -153,7 +152,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testTemplateCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', \ucfirst('depreciation'));
@ -200,7 +199,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testTemplateCreateInvalidPermission() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 9999;
$request->setData('name', \ucfirst('depreciation'));
@ -247,7 +246,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportPdf() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -264,7 +263,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportXlsx() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -281,7 +280,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportDocx() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -298,7 +297,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportPptx() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -315,7 +314,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportCsv() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -332,7 +331,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportJson() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -349,7 +348,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportInvalidPermission() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 99999;
$request->setData('id', self::$depreciationHelper);
@ -366,7 +365,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportOtherType() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper);
@ -383,7 +382,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');
@ -399,7 +398,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiTemplateCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');
@ -416,7 +415,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testReportCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('name', \ucfirst('depreciation-report'));
@ -446,7 +445,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testExportOtherTypeNotStandalone() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('id', self::$depreciationHelper2);
@ -463,7 +462,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testReportCreateInvalidPermission() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 9999;
$request->setData('name', \ucfirst('depreciation-report'));
@ -498,7 +497,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
public function testApiReportCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();
$request->header->account = 1;
$request->setData('invalid', '1');

View File

@ -31,7 +31,7 @@ use phpOMS\Utils\TestUtils;
*/
class ControllerTest extends \PHPUnit\Framework\TestCase
{
protected $app = null;
protected $app = null;
protected $module = null;
@ -45,13 +45,13 @@ class ControllerTest extends \PHPUnit\Framework\TestCase
protected string $appName = 'Api';
};
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Api/Hooks.php');
$account = new Account();

View File

@ -2,53 +2,53 @@
declare(strict_types=1);
return [
'en' => [
':language' => 'English',
'Account' => 'Account',
'Actual' => 'Actual',
'Actuals' => 'Actuals',
'AdditionalSupport' => 'Additional Support',
'AdditionalSupportBudget' => 'Additional Support Budget',
'AdviceBudget' => 'Advice Budget',
'BriefingBudget' => 'Briefing & Training Budget',
'Budget' => 'Budget',
'CostCenter' => 'Cost Center',
'CostObject' => 'Cost Object',
'CourseBudget' => 'Course Budget',
'Current' => 'Current',
'Cutoff' => 'Cutoff',
'Date' => 'Date',
'Demo' => 'Demo',
'DemoBudget' => 'Demo Budget',
'Description' => 'Description',
'Diff' => 'Diff',
'DiffBudget%' => 'Diff Budget %',
'DiffHistory%' => 'Diff History %',
'End' => 'End',
'EventCourse' => 'Event Course',
'ExportCourseBudget' => 'Export Course Budget',
'FiscalYearEnd' => 'Fiscal Year End',
'FiscalYearStart' => 'Fiscal Year Start',
'Forecast' => 'Forecast',
'History' => 'History',
'ID' => 'ID',
'IMPLA' => 'IMPLA',
'IMPLABudget' => 'IMPLA Budget',
'MarketingSupport' => 'Marketing Support',
'MarketingSupportBudget' => 'Marketing Support Budget',
'Name' => 'Name',
'Overview' => 'Overview',
'Pending' => 'Pending',
'Plan' => 'Plan',
'Planning' => 'Planning',
'Promotion' => 'Promotion',
'PromotionBudget' => 'Promotion Budget',
'Progress' => 'Progress',
'Remaining' => 'Remaining',
'RemainingForecast' => 'Remaining Forecast',
'Roadshow' => 'Roadshow',
'RoadshowBudget' => 'Roadshow Budget',
'Start' => 'Start',
'Total' => 'Total',
'Type' => 'Type',
':language' => 'English',
'Account' => 'Account',
'Actual' => 'Actual',
'Actuals' => 'Actuals',
'AdditionalSupport' => 'Additional Support',
'AdditionalSupportBudget' => 'Additional Support Budget',
'AdviceBudget' => 'Advice Budget',
'BriefingBudget' => 'Briefing & Training Budget',
'Budget' => 'Budget',
'CostCenter' => 'Cost Center',
'CostObject' => 'Cost Object',
'CourseBudget' => 'Course Budget',
'Current' => 'Current',
'Cutoff' => 'Cutoff',
'Date' => 'Date',
'Demo' => 'Demo',
'DemoBudget' => 'Demo Budget',
'Description' => 'Description',
'Diff' => 'Diff',
'DiffBudget%' => 'Diff Budget %',
'DiffHistory%' => 'Diff History %',
'End' => 'End',
'EventCourse' => 'Event Course',
'ExportCourseBudget' => 'Export Course Budget',
'FiscalYearEnd' => 'Fiscal Year End',
'FiscalYearStart' => 'Fiscal Year Start',
'Forecast' => 'Forecast',
'History' => 'History',
'ID' => 'ID',
'IMPLA' => 'IMPLA',
'IMPLABudget' => 'IMPLA Budget',
'MarketingSupport' => 'Marketing Support',
'MarketingSupportBudget' => 'Marketing Support Budget',
'Name' => 'Name',
'Overview' => 'Overview',
'Pending' => 'Pending',
'Plan' => 'Plan',
'Planning' => 'Planning',
'Promotion' => 'Promotion',
'PromotionBudget' => 'Promotion Budget',
'Progress' => 'Progress',
'Remaining' => 'Remaining',
'RemainingForecast' => 'Remaining Forecast',
'Roadshow' => 'Roadshow',
'RoadshowBudget' => 'Roadshow Budget',
'Start' => 'Start',
'Total' => 'Total',
'Type' => 'Type',
],
];

View File

@ -111,8 +111,8 @@ require __DIR__ . '/Worker.php';
<tr>
<td><?= $key; ?>
<td><?= $stype; ?>
<td><?= (\number_format($history = $type[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($history = $type[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($forecast = ($type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')); ?>
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%'; ?>
<?php
@ -150,8 +150,8 @@ require __DIR__ . '/Worker.php';
<tr>
<td><?= $key; ?>
<td><?= $ccDef[$key]; ?>
<td><?= (\number_format($history = $costcenter[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($history = $costcenter[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($forecast = ($costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')); ?>
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%'; ?>
<?php
@ -189,8 +189,8 @@ require __DIR__ . '/Worker.php';
<tr>
<td><?= $key; ?>
<td><?= $acDef[$key]; ?>
<td><?= (\number_format($history = $account[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($history = $account[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($current = $account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')); ?>
<td><?= (\number_format($forecast = ($account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')); ?>
<td><?= \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%'; ?>
<?php

View File

@ -18,23 +18,23 @@ $headStyle->applyFromArray(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
],
'fill' => [
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
],
'borders' => [
'borders' => [
'bottom' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'right' => [
'right' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'top' => [
'top' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'left' => [
'left' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
@ -46,7 +46,7 @@ $headStyle->applyFromArray(
$inputStyle = new PHPExcel_Style();
$inputStyle->applyFromArray(
[
'fill' => [
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => ['argb' => 'FFA9FFB9'],
],
@ -55,15 +55,15 @@ $inputStyle->applyFromArray(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'right' => [
'right' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'top' => [
'top' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'left' => [
'left' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
@ -74,7 +74,7 @@ $inputStyle->applyFromArray(
$colored1Style = new PHPExcel_Style();
$colored1Style->applyFromArray(
[
'fill' => [
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => ['argb' => 'FFFFFF00'],
],
@ -83,15 +83,15 @@ $colored1Style->applyFromArray(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'right' => [
'right' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'top' => [
'top' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'left' => [
'left' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
@ -102,7 +102,7 @@ $colored1Style->applyFromArray(
$fixedStyle = new PHPExcel_Style();
$fixedStyle->applyFromArray(
[
'fill' => [
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => ['argb' => 'FFDADADA'],
],
@ -111,15 +111,15 @@ $fixedStyle->applyFromArray(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'right' => [
'right' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'top' => [
'top' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
'left' => [
'left' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FFD1D1D1'],
],
@ -130,10 +130,10 @@ $fixedStyle->applyFromArray(
$totalStyle = new PHPExcel_Style();
$totalStyle->applyFromArray(
[
'font' => [
'font' => [
'bold' => true,
],
'fill' => [
'fill' => [
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => ['argb' => 'FF97C8FF'],
],
@ -142,15 +142,15 @@ $totalStyle->applyFromArray(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'right' => [
'right' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'top' => [
'top' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],
'left' => [
'left' => [
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => ['argb' => 'FF000000'],
],

View File

@ -34,9 +34,9 @@ final class ReportMapperTest extends \PHPUnit\Framework\TestCase
{
$template = new Template();
$template->createdBy = new NullAccount(1);
$template->name = 'Report Template';
$template->setStatus(HelperStatus::ACTIVE);
$template->createdBy = new NullAccount(1);
$template->name = 'Report Template';
$template->status = HelperStatus::ACTIVE;
$template->description = 'Description';
$template->setDatatype(TemplateDataType::OTHER);
$template->isStandalone = false;
@ -108,9 +108,9 @@ final class ReportMapperTest extends \PHPUnit\Framework\TestCase
{
$report = new Report();
$report->createdBy = new NullAccount(1);
$report->title = 'Title';
$report->setStatus(HelperStatus::ACTIVE);
$report->createdBy = new NullAccount(1);
$report->title = 'Title';
$report->status = HelperStatus::ACTIVE;
$report->description = 'Description';
$report->template = $this->createTemplate();
@ -177,7 +177,7 @@ final class ReportMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($report->createdBy->id, $reportR->createdBy->id);
self::assertEquals($report->description, $reportR->description);
self::assertEquals($report->title, $reportR->title);
self::assertEquals($report->getStatus(), $reportR->getStatus());
self::assertEquals($report->status, $reportR->status);
self::assertEquals($report->template->name, $reportR->template->name);
}
}

View File

@ -48,7 +48,7 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->report->createdBy->id);
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->report->createdAt->format('Y-m-d'));
self::assertEquals('', $this->report->title);
self::assertEquals(HelperStatus::INACTIVE, $this->report->getStatus());
self::assertEquals(HelperStatus::INACTIVE, $this->report->status);
self::assertEquals('', $this->report->description);
self::assertEquals('', $this->report->descriptionRaw);
self::assertEquals(0, $this->report->template->id);
@ -77,17 +77,6 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
self::assertEquals('Title', $this->report->title);
}
/**
* @testdox The status can be set and returned correctly
* @covers Modules\Helper\Models\Report
* @group module
*/
public function testStatusInputOutput() : void
{
$this->report->setStatus(HelperStatus::ACTIVE);
self::assertEquals(HelperStatus::ACTIVE, $this->report->getStatus());
}
/**
* @testdox The description can be set and returned correctly
* @covers Modules\Helper\Models\Report

View File

@ -39,14 +39,14 @@ final class TemplateMapperTest extends \PHPUnit\Framework\TestCase
{
$template = new Template();
$template->createdBy = new NullAccount(1);
$template->name = 'Title';
$template->setStatus(HelperStatus::ACTIVE);
$template->createdBy = new NullAccount(1);
$template->name = 'Title';
$template->status = HelperStatus::ACTIVE;
$template->description = 'Description';
$template->descriptionRaw = 'DescriptionRaw';
$template->setDatatype(TemplateDataType::OTHER);
$template->isStandalone = false;
$template->setExpected(['source1.csv', 'source2.csv']);
$template->datatype = TemplateDataType::OTHER;
$template->isStandalone = false;
$template->expected = ['source1.csv', 'source2.csv'];
$collection = new Collection();
$collection->createdBy = new NullAccount(1);
@ -112,7 +112,7 @@ final class TemplateMapperTest extends \PHPUnit\Framework\TestCase
self::assertEquals($template->description, $templateR->description);
self::assertEquals($template->descriptionRaw, $templateR->descriptionRaw);
self::assertEquals($template->name, $templateR->name);
self::assertEquals($template->getStatus(), $templateR->getStatus());
self::assertEquals($template->status, $templateR->status);
self::assertEquals($template->isStandalone, $templateR->isStandalone);
self::assertEquals($template->getDatatype(), $templateR->getDatatype());
self::assertEquals($template->getExpected(), $templateR->getExpected());

View File

@ -21,7 +21,6 @@ use Modules\Helper\Models\Template;
use Modules\Helper\Models\TemplateDataType;
use Modules\Media\Models\NullCollection;
use Modules\Organization\Models\NullUnit;
use Modules\Tag\Models\Tag;
use phpOMS\Utils\TestUtils;
/**
@ -53,7 +52,7 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->template->createdBy->id);
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->template->createdAt->format('Y-m-d'));
self::assertEquals('', $this->template->name);
self::assertEquals(HelperStatus::INACTIVE, $this->template->getStatus());
self::assertEquals(HelperStatus::INACTIVE, $this->template->status);
self::assertEquals('', $this->template->description);
self::assertEquals('', $this->template->descriptionRaw);
self::assertEquals([], $this->template->getExpected());
@ -96,17 +95,6 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
self::assertEquals('Title', $this->template->name);
}
/**
* @testdox The status can be set and returned correctly
* @covers Modules\Helper\Models\Template
* @group module
*/
public function testStatusInputOutput() : void
{
$this->template->setStatus(HelperStatus::ACTIVE);
self::assertEquals(HelperStatus::ACTIVE, $this->template->getStatus());
}
/**
* @testdox The template can be set as standalone and returned correctly
* @covers Modules\Helper\Models\Template
@ -174,19 +162,6 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
self::assertEquals(TemplateDataType::GLOBAL_DB, $this->template->getDatatype());
}
/**
* @covers Modules\Helper\Models\Template
* @group module
*/
public function testTagInputOutput() : void
{
$tag = new Tag();
$tag->setL11n('Tag');
$this->template->addTag($tag);
self::assertCount(1, $this->template->getTags());
}
/**
* @covers Modules\Helper\Models\Template
* @group module
@ -208,10 +183,10 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testToArray() : void
{
$this->template->name = 'testName';
$this->template->description = 'testDescription';
$this->template->descriptionRaw = 'testDescriptionRaw';
$this->template->isStandalone = true;
$this->template->name = 'testName';
$this->template->description = 'testDescription';
$this->template->descriptionRaw = 'testDescriptionRaw';
$this->template->isStandalone = true;
$array = $this->template->toArray();
$expected = [
@ -240,10 +215,10 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
*/
public function testJsonSerialize() : void
{
$this->template->name = 'testName';
$this->template->description = 'testDescription';
$this->template->descriptionRaw = 'testDescriptionRaw';
$this->template->isStandalone = true;
$this->template->name = 'testName';
$this->template->description = 'testDescription';
$this->template->descriptionRaw = 'testDescriptionRaw';
$this->template->isStandalone = true;
$array = $this->template->jsonSerialize();
$expected = [