Initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/***********************************************************************************
|
||||
* The contents of this file are subject to the Extension License Agreement
|
||||
* ("Agreement") which can be viewed at
|
||||
* https://www.espocrm.com/extension-license-agreement/.
|
||||
* By copying, installing downloading, or using this file, You have unconditionally
|
||||
* agreed to the terms and conditions of the Agreement, and You may not use this
|
||||
* file except in compliance with the Agreement. Under the terms of the Agreement,
|
||||
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
|
||||
* redistribute, market, publish, commercialize, or otherwise transfer rights or
|
||||
* usage to the software or any modified version or derivative work of the software
|
||||
* created by or for you.
|
||||
*
|
||||
* Copyright (C) 2015-2025 EspoCRM, Inc.
|
||||
*
|
||||
* License ID: 19bc86a68a7bb01f458cb391d43a9212
|
||||
************************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Advanced\Classes\FieldProcessing\BpmnFlowNode;
|
||||
|
||||
use Espo\Modules\Advanced\Entities\BpmnUserTask;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @implements Loader<BpmnUserTask>
|
||||
*/
|
||||
class UserTaskLoader implements Loader
|
||||
{
|
||||
private EntityManager $entityManager;
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
if ($entity->getElementType() !== 'taskUser') {
|
||||
return;
|
||||
}
|
||||
|
||||
$userTask = $this->entityManager
|
||||
->getRDBRepository(BpmnUserTask::ENTITY_TYPE)
|
||||
->where(['flowNodeId' => $entity->getId()])
|
||||
->findOne();
|
||||
|
||||
if ($userTask) {
|
||||
$entity->set('userTaskId', $userTask->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/***********************************************************************************
|
||||
* The contents of this file are subject to the Extension License Agreement
|
||||
* ("Agreement") which can be viewed at
|
||||
* https://www.espocrm.com/extension-license-agreement/.
|
||||
* By copying, installing downloading, or using this file, You have unconditionally
|
||||
* agreed to the terms and conditions of the Agreement, and You may not use this
|
||||
* file except in compliance with the Agreement. Under the terms of the Agreement,
|
||||
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
|
||||
* redistribute, market, publish, commercialize, or otherwise transfer rights or
|
||||
* usage to the software or any modified version or derivative work of the software
|
||||
* created by or for you.
|
||||
*
|
||||
* Copyright (C) 2015-2025 EspoCRM, Inc.
|
||||
*
|
||||
* License ID: 19bc86a68a7bb01f458cb391d43a9212
|
||||
************************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Advanced\Classes\FieldProcessing\BpmnProcess;
|
||||
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Modules\Advanced\Entities\BpmnFlowNode;
|
||||
use Espo\Modules\Advanced\Entities\BpmnProcess;
|
||||
use Espo\ORM\Collection;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @implements Loader<BpmnProcess>
|
||||
*/
|
||||
class FlowchartDataLoader implements Loader
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManager $entityManager
|
||||
) {}
|
||||
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
$flowchartData = $entity->get('flowchartData') ?? (object) [];
|
||||
|
||||
$list = $flowchartData->list ?? [];
|
||||
|
||||
$flowNodes = $this->entityManager
|
||||
->getRDBRepositoryByClass(BpmnFlowNode::class)
|
||||
->where(['processId' => $entity->getId()])
|
||||
->order('number', true)
|
||||
->limit(0, 400)
|
||||
->find();
|
||||
|
||||
foreach ($list as $item) {
|
||||
$this->loadOutlineData($item, $flowNodes);
|
||||
}
|
||||
|
||||
$entity->set('flowchartData', $flowchartData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass $item
|
||||
* @param Collection<BpmnFlowNode> $flowNodeList
|
||||
*/
|
||||
private function loadOutlineData($item, $flowNodeList): void
|
||||
{
|
||||
$type = $item->type ?? null;
|
||||
$id = $item->id ?? null;
|
||||
|
||||
if (!$type || !$id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type === 'flow') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type === 'eventSubProcess' || $type === 'subProcess') {
|
||||
$list = $item->dataList ?? [];
|
||||
|
||||
foreach ($flowNodeList as $flowNode) {
|
||||
if ($flowNode->get('elementId') == $id) {
|
||||
$subProcessId = $flowNode->getDataItemValue('subProcessId');
|
||||
|
||||
$spFlowNodeList = $this->entityManager
|
||||
->getRDBRepositoryByClass(BpmnFlowNode::class)
|
||||
->where(['processId' => $subProcessId])
|
||||
->order('number', true)
|
||||
->limit(0, 400)
|
||||
->find();
|
||||
|
||||
foreach ($list as $spItem) {
|
||||
$this->loadOutlineData($spItem, $spFlowNodeList);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($flowNodeList as $flowNode) {
|
||||
$status = $flowNode->get('status');
|
||||
|
||||
if ($flowNode->get('elementId') == $id) {
|
||||
if ($status === BpmnFlowNode::STATUS_PROCESSED) {
|
||||
$item->outline = 3;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($flowNodeList as $flowNode) {
|
||||
$status = $flowNode->get('status');
|
||||
|
||||
if ($flowNode->get('elementId') == $id) {
|
||||
if ($status === BpmnFlowNode::STATUS_IN_PROCESS) {
|
||||
$item->outline = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($flowNodeList as $flowNode) {
|
||||
$status = $flowNode->get('status');
|
||||
|
||||
if ($flowNode->get('elementId') == $id) {
|
||||
if ($status === BpmnFlowNode::STATUS_PENDING) {
|
||||
$item->outline = 2;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($flowNodeList as $flowNode) {
|
||||
$status = $flowNode->get('status');
|
||||
|
||||
if ($flowNode->get('elementId') == $id) {
|
||||
if (
|
||||
$status === BpmnFlowNode::STATUS_FAILED ||
|
||||
$status === BpmnFlowNode::STATUS_INTERRUPTED
|
||||
) {
|
||||
$item->outline = 4;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/***********************************************************************************
|
||||
* The contents of this file are subject to the Extension License Agreement
|
||||
* ("Agreement") which can be viewed at
|
||||
* https://www.espocrm.com/extension-license-agreement/.
|
||||
* By copying, installing downloading, or using this file, You have unconditionally
|
||||
* agreed to the terms and conditions of the Agreement, and You may not use this
|
||||
* file except in compliance with the Agreement. Under the terms of the Agreement,
|
||||
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
|
||||
* redistribute, market, publish, commercialize, or otherwise transfer rights or
|
||||
* usage to the software or any modified version or derivative work of the software
|
||||
* created by or for you.
|
||||
*
|
||||
* Copyright (C) 2015-2025 EspoCRM, Inc.
|
||||
*
|
||||
* License ID: 19bc86a68a7bb01f458cb391d43a9212
|
||||
************************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Advanced\Classes\FieldProcessing\Report;
|
||||
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Modules\Advanced\Entities\Report ;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
/**
|
||||
* @implements Loader<Report>
|
||||
*/
|
||||
class ChartOneLoader implements Loader
|
||||
{
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
|
||||
$entity->set('chartOneColumns', []);
|
||||
$entity->set('chartOneY2Columns', []);
|
||||
|
||||
if ($entity->getType() === Report::TYPE_GRID) {
|
||||
$chartDataList = $entity->get('chartDataList');
|
||||
|
||||
if ($chartDataList && count($chartDataList)) {
|
||||
$y = $chartDataList[0]->columnList ?? null;
|
||||
$y2 = $chartDataList[0]->y2ColumnList ?? null;
|
||||
|
||||
$entity->set('chartOneColumns', $y);
|
||||
$entity->set('chartOneY2Columns', $y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/***********************************************************************************
|
||||
* The contents of this file are subject to the Extension License Agreement
|
||||
* ("Agreement") which can be viewed at
|
||||
* https://www.espocrm.com/extension-license-agreement/.
|
||||
* By copying, installing downloading, or using this file, You have unconditionally
|
||||
* agreed to the terms and conditions of the Agreement, and You may not use this
|
||||
* file except in compliance with the Agreement. Under the terms of the Agreement,
|
||||
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
|
||||
* redistribute, market, publish, commercialize, or otherwise transfer rights or
|
||||
* usage to the software or any modified version or derivative work of the software
|
||||
* created by or for you.
|
||||
*
|
||||
* Copyright (C) 2015-2025 EspoCRM, Inc.
|
||||
*
|
||||
* License ID: 19bc86a68a7bb01f458cb391d43a9212
|
||||
************************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Advanced\Classes\FieldProcessing\Report;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Modules\Advanced\Entities\Report;
|
||||
use Espo\ORM\Entity;
|
||||
|
||||
/**
|
||||
* @implements Loader<Report>
|
||||
*/
|
||||
class UnsetPortals implements Loader
|
||||
{
|
||||
private Acl $acl;
|
||||
|
||||
public function __construct(
|
||||
Acl $acl
|
||||
) {
|
||||
$this->acl = $acl;
|
||||
}
|
||||
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
if ($this->acl->getPermissionLevel('portalPermission') !== Table::LEVEL_NO) {
|
||||
return;
|
||||
}
|
||||
|
||||
$entity->clear('portalsIds');
|
||||
$entity->clear('portalsNames');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/***********************************************************************************
|
||||
* The contents of this file are subject to the Extension License Agreement
|
||||
* ("Agreement") which can be viewed at
|
||||
* https://www.espocrm.com/extension-license-agreement/.
|
||||
* By copying, installing downloading, or using this file, You have unconditionally
|
||||
* agreed to the terms and conditions of the Agreement, and You may not use this
|
||||
* file except in compliance with the Agreement. Under the terms of the Agreement,
|
||||
* You shall not license, sublicense, sell, resell, rent, lease, lend, distribute,
|
||||
* redistribute, market, publish, commercialize, or otherwise transfer rights or
|
||||
* usage to the software or any modified version or derivative work of the software
|
||||
* created by or for you.
|
||||
*
|
||||
* Copyright (C) 2015-2025 EspoCRM, Inc.
|
||||
*
|
||||
* License ID: 19bc86a68a7bb01f458cb391d43a9212
|
||||
************************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Advanced\Classes\FieldProcessing\ReportPanel;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Modules\Advanced\Entities\Report as ReportEntity;
|
||||
use Espo\Modules\Advanced\Entities\ReportPanel;
|
||||
use Espo\Modules\Advanced\Tools\Report\GridType\Helper;
|
||||
use Espo\Modules\Advanced\Tools\Report\ReportHelper;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @implements Loader<ReportPanel>
|
||||
*/
|
||||
class Additional implements Loader
|
||||
{
|
||||
public function __construct(
|
||||
private Helper $helper,
|
||||
private EntityManager $entityManager,
|
||||
private ReportHelper $reportHelper
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
*/
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
if (
|
||||
$entity->get('reportType') === ReportEntity::TYPE_GRID &&
|
||||
$entity->get('reportId')
|
||||
) {
|
||||
/** @var ?ReportEntity $report */
|
||||
$report = $this->entityManager->getEntityById(ReportEntity::ENTITY_TYPE, $entity->get('reportId'));
|
||||
|
||||
if ($report) {
|
||||
$columnList = $report->getColumns();
|
||||
|
||||
$numericColumnList = [];
|
||||
|
||||
$gridData = $this->reportHelper->fetchGridDataFromReport($report);
|
||||
|
||||
foreach ($columnList as $column) {
|
||||
if ($this->helper->isColumnNumeric($column, $gridData)) {
|
||||
$numericColumnList[] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
count($report->getGroupBy()) === 1 ||
|
||||
count($report->getGroupBy()) === 0
|
||||
) &&
|
||||
count($numericColumnList) > 1
|
||||
) {
|
||||
array_unshift($numericColumnList, '');
|
||||
}
|
||||
|
||||
$entity->set('columnList', $numericColumnList);
|
||||
}
|
||||
|
||||
$entity->set('columnsData', $report->getColumnsData());
|
||||
}
|
||||
|
||||
$displayType = $entity->get('displayType');
|
||||
$reportType = $entity->get('reportType');
|
||||
$displayTotal = $entity->get('displayTotal');
|
||||
$displayOnlyTotal = $entity->get('displayOnlyTotal');
|
||||
|
||||
if (!$displayType) {
|
||||
if (
|
||||
$reportType === ReportEntity::TYPE_GRID ||
|
||||
$reportType === ReportEntity::TYPE_JOINT_GRID
|
||||
) {
|
||||
if ($displayOnlyTotal) {
|
||||
$displayType = 'Total';
|
||||
}
|
||||
else if ($displayTotal) {
|
||||
$displayType = 'Chart-Total';
|
||||
}
|
||||
else {
|
||||
$displayType = 'Chart';
|
||||
}
|
||||
}
|
||||
else if ($reportType === ReportEntity::TYPE_LIST) {
|
||||
if ($displayOnlyTotal) {
|
||||
$displayType = 'Total';
|
||||
}
|
||||
else {
|
||||
$displayType = 'List';
|
||||
}
|
||||
}
|
||||
|
||||
$entity->set('displayType', $displayType);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user